decocms 4.102.0 → 4.104.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-C_nk91tH.js → AlertCircle-BRqx3xep.js} +1 -1
- package/dist/client/assets/{AreaChart-CmrBd_oc.js → AreaChart-CTIAAql6.js} +1 -1
- package/dist/client/assets/{ArrowRight-x5eFsUyE.js → ArrowRight-BvfxmFPm.js} +1 -1
- package/dist/client/assets/{ArrowUp-B_NkVhQy.js → ArrowUp-D9gId7O2.js} +1 -1
- package/dist/client/assets/{ArrowUpRight-Bjz3wM7_.js → ArrowUpRight-i87r5MHo.js} +1 -1
- package/dist/client/assets/{Check-CmXcFUFA.js → Check-CKEgzuW7.js} +1 -1
- package/dist/client/assets/{CheckCircle-GzoutZzh.js → CheckCircle-DUFed_ZY.js} +1 -1
- package/dist/client/assets/{ChevronDown-BU2ru4r_.js → ChevronDown-BtwsJF3q.js} +1 -1
- package/dist/client/assets/{ChevronRight-BLHTQ9Db.js → ChevronRight-NUnWKoQ_.js} +1 -1
- package/dist/client/assets/{ChevronUp-3FMqPib6.js → ChevronUp-DihHtLht.js} +1 -1
- package/dist/client/assets/{Copy01-BzXUnxIt.js → Copy01-C5bN0aQx.js} +1 -1
- package/dist/client/assets/{DotsVertical-BXRC3vMY.js → DotsVertical-hq3t58jm.js} +1 -1
- package/dist/client/assets/{Eye-DZiWXjzc.js → Eye-D6wgl9MG.js} +1 -1
- package/dist/client/assets/{FilterLines-Dw3b3U6U.js → FilterLines-kzf7tlKR.js} +1 -1
- package/dist/client/assets/{Globe01-Ct1oKJdh.js → Globe01-BryNz0dd.js} +1 -1
- package/dist/client/assets/{Globe04-BiqYhKIv.js → Globe04-DUBgGRbs.js} +1 -1
- package/dist/client/assets/{HardDrive-DV_SLLYZ.js → HardDrive-B-Cz-BH_.js} +1 -1
- package/dist/client/assets/{Image01-BoP1xUXy.js → Image01-C-5icdHD.js} +1 -1
- package/dist/client/assets/{Key01-C1HipuOz.js → Key01-zw1UNPHV.js} +1 -1
- package/dist/client/assets/{LayoutLeft-CxYJNTGI.js → LayoutLeft-ClXrwu6i.js} +1 -1
- package/dist/client/assets/{LinkExternal01-CGrGeU4Q.js → LinkExternal01-CUrTcP_i.js} +1 -1
- package/dist/client/assets/{Monitor01-C6zpq4qC.js → Monitor01-BntiOroW.js} +1 -1
- package/dist/client/assets/{Package-nklzvxt3.js → Package-CyI3pPtY.js} +1 -1
- package/dist/client/assets/{Palette-vt3KT1N3.js → Palette-Bf9UBt-Z.js} +1 -1
- package/dist/client/assets/{Play-C8mWR1Az.js → Play-cf98mvjp.js} +1 -1
- package/dist/client/assets/{Plus-7RPIQWLb.js → Plus-6kDymf85.js} +1 -1
- package/dist/client/assets/{SearchLg-CWLjZme7.js → SearchLg-Ca6Gs9PO.js} +1 -1
- package/dist/client/assets/{SearchMd-4O6fg9oW.js → SearchMd-Bq5ma3BB.js} +1 -1
- package/dist/client/assets/{Settings02-DU8SxETa.js → Settings02-DJcNlPiV.js} +1 -1
- package/dist/client/assets/{Shield01-oWOP2zLR.js → Shield01-BOWKmWSM.js} +1 -1
- package/dist/client/assets/{Star01-kfwc8V_o.js → Star01-4luDViOK.js} +1 -1
- package/dist/client/assets/{Stars01-C1l0RlUa.js → Stars01-DbhvFj37.js} +1 -1
- package/dist/client/assets/{Stars02-C3tFxKGI.js → Stars02-CSMCax45.js} +1 -1
- package/dist/client/assets/{Sun-CkVbwhKo.js → Sun-BS_t5Sm5.js} +1 -1
- package/dist/client/assets/{SwitchHorizontal01-BP51S8DS.js → SwitchHorizontal01-B78Wff9t.js} +1 -1
- package/dist/client/assets/{Tool01-DE3j460t.js → Tool01-CSTeisaV.js} +1 -1
- package/dist/client/assets/{Tool02-BQUR2DKB.js → Tool02-BFPH6-tL.js} +1 -1
- package/dist/client/assets/{Trash01-cB1sS901.js → Trash01-D6SSf8SM.js} +1 -1
- package/dist/client/assets/{TrendUp01-Ddu99xHU.js → TrendUp01-uCNtQJGh.js} +1 -1
- package/dist/client/assets/{Upload01-CYVHio4I.js → Upload01-IWZGSkQD.js} +1 -1
- package/dist/client/assets/{User01-CtR14f1U.js → User01-h19-qQKE.js} +1 -1
- package/dist/client/assets/{Users01-BqyJARKJ.js → Users01-BVosV5Zq.js} +1 -1
- package/dist/client/assets/{Users03-CQdAxDaw.js → Users03-BnKaYSKo.js} +1 -1
- package/dist/client/assets/{X-CAmHDMPk.js → X-Cl_lyAjH.js} +1 -1
- package/dist/client/assets/{XCircle-CANBtGHI.js → XCircle-DrkKVisl.js} +1 -1
- package/dist/client/assets/{XClose-BAfFl7aF.js → XClose-Bqw0j4zC.js} +1 -1
- package/dist/client/assets/{Zap-YiLxlwec.js → Zap-CRHRXn7z.js} +1 -1
- package/dist/client/assets/{ZapSquare-DkWTs6ms.js → ZapSquare-BNsFa87S.js} +1 -1
- package/dist/client/assets/{ZoomOut-C_3JH0WD.js → ZoomOut-Bdun-ybj.js} +1 -1
- package/dist/client/assets/{access-gate-D9ZNkrgA.js → access-gate-BqRQWMeI.js} +1 -1
- package/dist/client/assets/{add-section-modal-D-r-HB6h.js → add-section-modal-DmyUgFgN.js} +1 -1
- package/dist/client/assets/{agent-icon-VQci6jYK.js → agent-icon-gGMqm39Y.js} +1 -1
- package/dist/client/assets/{agents-list-BBAnTAXz.js → agents-list-DJkGR1B7.js} +1 -1
- package/dist/client/assets/{ai-providers-CfWuGi9h.js → ai-providers-FXkuA6xr.js} +1 -1
- package/dist/client/assets/{alert-DqafSjaL.js → alert-EqBw_yIC.js} +1 -1
- package/dist/client/assets/{alert-dialog-GMDN2a2p.js → alert-dialog-BhTFO1xE.js} +3 -3
- package/dist/client/assets/app-editor-CLJXkmZ1.js +1 -0
- package/dist/client/assets/{auth-D3hjVX0I.js → auth-CC0hVF1j.js} +1 -1
- package/dist/client/assets/{auth-catchall-DCIWbV2r.js → auth-catchall-qFVbHjsU.js} +1 -1
- package/dist/client/assets/{auth-entry-CzwaudQl.js → auth-entry-B0eRh6Z1.js} +1 -1
- package/dist/client/assets/{auth-split-layout-B15UCYf9.js → auth-split-layout-Dps5LnFV.js} +1 -1
- package/dist/client/assets/{authenticate-and-persist-oauth-B6DLU1uJ.js → authenticate-and-persist-oauth-CHxJhIDr.js} +1 -1
- package/dist/client/assets/{automation-list-row-C69OPCMn.js → automation-list-row-DDcgXspJ.js} +1 -1
- package/dist/client/assets/{automation-runs-jf4CQyxT.js → automation-runs-C-RCLuKF.js} +14 -14
- package/dist/client/assets/{automations-38lwJ0Pb.js → automations-CYBxh7wL.js} +1 -1
- package/dist/client/assets/{autosend-CrLNAcK4.js → autosend-B9JChviy.js} +1 -1
- package/dist/client/assets/{avatar-DGoq0KTj.js → avatar-D2Ibs6zj.js} +1 -1
- package/dist/client/assets/{badge-ICotptLx.js → badge-WaoanX2u.js} +1 -1
- package/dist/client/assets/{block-document-_k2vMK-w.js → block-document-DxcFxi9r.js} +1 -1
- package/dist/client/assets/{brand-context-B9pILASi.js → brand-context-NxGH-6zR.js} +1 -1
- package/dist/client/assets/{buckets-DwIjpZ7F.js → buckets-cqrj_dAj.js} +1 -1
- package/dist/client/assets/bulk-category-panel-Ca_By5bp.js +1 -0
- package/dist/client/assets/{calendar-BFIHiiFD.js → calendar-yjvySUql.js} +1 -1
- package/dist/client/assets/{capability-load-error-CghFcLQ5.js → capability-load-error-CoZ48QgK.js} +1 -1
- package/dist/client/assets/{card-DeRX92PE.js → card-gNDjFGep.js} +1 -1
- package/dist/client/assets/category-editor-BH2HxeFP.js +1 -0
- package/dist/client/assets/{chat-context-B9cQc_h3.js → chat-context-B5rz213z.js} +1 -1
- package/dist/client/assets/{checkbox-CvYv_Km6.js → checkbox-D4JNeDbC.js} +1 -1
- package/dist/client/assets/{cli-auth-success-DbrcSaQM.js → cli-auth-success-BIuDb680.js} +1 -1
- package/dist/client/assets/{collection-detail-D_jZAWBQ.js → collection-detail-TexT8fDE.js} +1 -1
- package/dist/client/assets/{collection-display-button-C91SGRBy.js → collection-display-button-BmTCVJk9.js} +1 -1
- package/dist/client/assets/{collection-search-tV8cd3K2.js → collection-search-OxgUuTDC.js} +1 -1
- package/dist/client/assets/{collection-table-wrapper-B0sW2nuq.js → collection-table-wrapper-6MozrKcJ.js} +1 -1
- package/dist/client/assets/{collection-tabs-CORSMF6h.js → collection-tabs-wFROlbKE.js} +1 -1
- package/dist/client/assets/{command-BOlKzV0V.js → command-CPJ3-fx9.js} +1 -1
- package/dist/client/assets/commerce-onboarding-CKbgdpWn.js +1 -0
- package/dist/client/assets/{companions-core-oBQaybV8.js → companions-core-Cpw1YNEa.js} +1 -1
- package/dist/client/assets/{connect-DoEAuWku.js → connect-PjtNV5Et.js} +1 -1
- package/dist/client/assets/{connect-desktop-dialog-dbCJQTWC.js → connect-desktop-dialog-D1LywKPY.js} +1 -1
- package/dist/client/assets/{connection-card-NrIXzO1v.js → connection-card-BTp_Mexf.js} +1 -1
- package/dist/client/assets/{connection-detail-DJ_6dzel.js → connection-detail-h2UhV5I3.js} +1 -1
- package/dist/client/assets/{connection-form-helpers-Dq97qH29.js → connection-form-helpers-pJAJWYOQ.js} +1 -1
- package/dist/client/assets/{connections-DJIWkSt4.js → connections-I0rMCbY8.js} +1 -1
- package/dist/client/assets/{decopilot-sse-pool-DNUfg0HV.js → decopilot-sse-pool-BKYCROku.js} +1 -1
- package/dist/client/assets/{dialog-CtcL8Rge.js → dialog-ZqiHDqPF.js} +1 -1
- package/dist/client/assets/{domain-settings-CENW7GQu.js → domain-settings-BrXjZEu1.js} +1 -1
- package/dist/client/assets/{drawer-C31EzZAL.js → drawer-DQaSiCfP.js} +1 -1
- package/dist/client/assets/{dropdown-menu-BqJxwxsq.js → dropdown-menu-Def3XQ2r.js} +1 -1
- package/dist/client/assets/{empty-state-BoA_YW3D.js → empty-state-Bv0o4pop.js} +1 -1
- package/dist/client/assets/{extract-connection-data--_aU5sYg.js → extract-connection-data-DliliWWi.js} +1 -1
- package/dist/client/assets/file-explorer-CgJTQxdk.js +2 -0
- package/dist/client/assets/{file-type-icon-BqEXVrTQ.js → file-type-icon-K2dXxjrg.js} +1 -1
- package/dist/client/assets/{files-Bye5Bbv6.js → files-BpUaRdzk.js} +1 -1
- package/dist/client/assets/{form-B5plGGFv.js → form-hSS6YV_K.js} +1 -1
- package/dist/client/assets/{general-Jd2yB-b8.js → general-mfcsqfrX.js} +1 -1
- package/dist/client/assets/github-repo-picker-gznstzb9.js +1 -0
- package/dist/client/assets/{hooks-v_4liDIo.js → hooks-C3cd-7It.js} +1 -1
- package/dist/client/assets/{index-DA5rV0RV.js → index-0_RcfZs5.js} +1 -1
- package/dist/client/assets/{index-BnE6Altg.js → index-5q66t9__.js} +1 -1
- package/dist/client/assets/{index-BAxO0Mwx.js → index-B9cuRTAq.js} +1 -1
- package/dist/client/assets/{index-Dt1PB5Sc.js → index-Bs1Iy52V.js} +1 -1
- package/dist/client/assets/{index-Chb0IZth.js → index-CPmAFNBC.js} +1 -1
- package/dist/client/assets/index-CriTplNU.js +1 -0
- package/dist/client/assets/{index-yINFUQcR.js → index-DV5sb8rn.js} +1 -1
- package/dist/client/assets/{index-Bpt5-Vj-.js → index-DawtOaQW.js} +1 -1
- package/dist/client/assets/index-DxLKWgfK.js +517 -0
- package/dist/client/assets/{index-BzyW0JhV.js → index-NnDGnKWr.js} +1 -1
- package/dist/client/assets/index-bQ7eQRAG.js +8 -0
- package/dist/client/assets/{index-82forbXV.js → index-raAj8hl6.js} +1 -1
- package/dist/client/assets/{index-redirect--8WvwlkD.js → index-redirect-D2qMNgI3.js} +1 -1
- package/dist/client/assets/{index-CmUMOI85.js → index-zLQ_KwUp.js} +4 -4
- package/dist/client/assets/{input-Cf6f3BmN.js → input-_d3dZcaj.js} +1 -1
- package/dist/client/assets/{integration-icon-dAGuZlLn.js → integration-icon-BW4ZUBDF.js} +1 -1
- package/dist/client/assets/{invite-member-dialog-DHMIvCZa.js → invite-member-dialog-B4i_qrPG.js} +1 -1
- package/dist/client/assets/{label-VkdXgHd7.js → label-BSqo1nfb.js} +1 -1
- package/dist/client/assets/{layout-Ci8_KpkR.js → layout-Du_0a-mS.js} +1 -1
- package/dist/client/assets/{login-DYMzVGTT.js → login-C1sweMWO.js} +1 -1
- package/dist/client/assets/{mcp-oauth-DUnhZRN8.js → mcp-oauth-CJiL395p.js} +1 -1
- package/dist/client/assets/{members-C_dKp9cE.js → members-zHaMXlc4.js} +1 -1
- package/dist/client/assets/{monaco-editor-Du7tJEjc.js → monaco-editor-B__egIpZ.js} +2 -2
- package/dist/client/assets/{monitoring-stats-row-CGa_Hf8X.js → monitoring-stats-row-COOk7YGw.js} +1 -1
- package/dist/client/assets/{multi-select-CKCzXjXB.js → multi-select-C-FSYlSF.js} +1 -1
- package/dist/client/assets/{oauth-callback-YH1uSwt3.js → oauth-callback-BL-L6UI-.js} +1 -1
- package/dist/client/assets/{oauth-callback-ai-provider-CfCAwFe_.js → oauth-callback-ai-provider-C_HMNOh9.js} +1 -1
- package/dist/client/assets/{onboarding-BOzlNnjb.js → onboarding-tsx5LMke.js} +1 -1
- package/dist/client/assets/{org-install-Bh_jspMI.js → org-install-D_rzgEnE.js} +1 -1
- package/dist/client/assets/{org-layout-phPHQXN7.js → org-layout-CYcTViI4.js} +1 -1
- package/dist/client/assets/{organization-choice-b-1zF0V4.js → organization-choice-DXt7QQPT.js} +1 -1
- package/dist/client/assets/{orgs-BNj-B7ZU.js → orgs-BIM3XY2Q.js} +1 -1
- package/dist/client/assets/{page-seo-form-DEBPMXNg.js → page-seo-form-VLW_NzAm.js} +1 -1
- package/dist/client/assets/page-seo-sheet-D75ZAusC.js +1 -0
- package/dist/client/assets/{popover-RUk1Jxx9.js → popover-BLlzoM5T.js} +1 -1
- package/dist/client/assets/post-editor-MhFXsnxa.js +1 -0
- package/dist/client/assets/{primitives-DjhzqWF2.js → primitives-BwYP-BE9.js} +1 -1
- package/dist/client/assets/{profile-zgo76jeb.js → profile-C0nTmLiS.js} +1 -1
- package/dist/client/assets/project-app-view-CRipBtzb.js +1 -0
- package/dist/client/assets/record-editor-DwE3lAwY.js +1 -0
- package/dist/client/assets/redirect-editor-BGHY1mAE.js +1 -0
- package/dist/client/assets/registry-CllMiCFB.js +2 -0
- package/dist/client/assets/{registry-layout-BYEc0-pE.js → registry-layout-0J0a2Ujw.js} +1 -1
- package/dist/client/assets/{reports-DKgwgjGZ.js → reports-BDrtR7vy.js} +1 -1
- package/dist/client/assets/{require-capability-tPbQgnBt.js → require-capability-iEGLG_o_.js} +1 -1
- package/dist/client/assets/{required-auth-layout-Bw_23wtD.js → required-auth-layout-BBQqJQ3M.js} +1 -1
- package/dist/client/assets/{reset-password-C_05Hu8v.js → reset-password-B2OeOUDh.js} +1 -1
- package/dist/client/assets/{roles-BVMrqSER.js → roles-ZGYesZ44.js} +1 -1
- package/dist/client/assets/{search-input-D1vvih4b.js → search-input-jKTRliwf.js} +1 -1
- package/dist/client/assets/{secrets-BLPRuVeZ.js → secrets-B2GJpjmZ.js} +1 -1
- package/dist/client/assets/{sections-editor-qd7Dwqwc.js → sections-editor-B9WQ_qSW.js} +2 -2
- package/dist/client/assets/{select-DQl8Nkd-.js → select-LJtxIB-u.js} +1 -1
- package/dist/client/assets/{select-model-DDvi29I3.js → select-model-BxAY6ZVn.js} +1 -1
- package/dist/client/assets/self-tool-result-B4zU4shH.js +1 -0
- package/dist/client/assets/seo-editor-Cv-AlrO0.js +1 -0
- package/dist/client/assets/{settings-layout-Bn989CC7.js → settings-layout-Bqxe7Le8.js} +1 -1
- package/dist/client/assets/{settings-section-BUqk0nQQ.js → settings-section-DiO-ilon.js} +1 -1
- package/dist/client/assets/{shell-controls-B8ZbVsnA.js → shell-controls-BO1iBU8O.js} +1 -1
- package/dist/client/assets/{shell-layout-_h-q07bi.js → shell-layout-B-ggkJxp.js} +1 -1
- package/dist/client/assets/{sidebar-CCp56Env.js → sidebar-CMBLFeKd.js} +1 -1
- package/dist/client/assets/{skeleton-BOpN06w4.js → skeleton-CK77xki0.js} +1 -1
- package/dist/client/assets/{sso-BkvAY4e8.js → sso-20c3PF9y.js} +1 -1
- package/dist/client/assets/{store-CMf550pL.js → store-fph_z5c6.js} +1 -1
- package/dist/client/assets/store-registry-ePKba1tj.js +2 -0
- package/dist/client/assets/{studio-tools-BVRXDcEz.js → studio-tools-BDPy4sbt.js} +1 -1
- package/dist/client/assets/{switch-BM-HDdky.js → switch-DAZLVlwZ.js} +1 -1
- package/dist/client/assets/{table-zJH1gBbm.js → table-DpElKEEr.js} +1 -1
- package/dist/client/assets/{tabs-CELqSRxW.js → tabs-BTnvaiWr.js} +1 -1
- package/dist/client/assets/{textarea-PL3tBRfL.js → textarea-Ci575ef_.js} +1 -1
- package/dist/client/assets/{toggle-group-DSJnwILX.js → toggle-group-j1ezUTaN.js} +1 -1
- package/dist/client/assets/{toolbar-XFnqI6aL.js → toolbar-_ubtVWm6.js} +1 -1
- package/dist/client/assets/{toolbar-icon-button-Drpylp7y.js → toolbar-icon-button-CzwvD8BJ.js} +1 -1
- package/dist/client/assets/{tooltip-DLvHocW9.js → tooltip-y2P8oLl6.js} +1 -1
- package/dist/client/assets/{use-ai-providers-DB0PWqc_.js → use-ai-providers-B8Bw0Tf-.js} +1 -1
- package/dist/client/assets/{use-api-keys-dCJwGqEj.js → use-api-keys-BhyKb5WG.js} +1 -1
- package/dist/client/assets/{use-automations-DHjQTH3C.js → use-automations-_qY82s9O.js} +1 -1
- package/dist/client/assets/{use-autosave-BbOXI1wB.js → use-autosave-DsJinH0F.js} +1 -1
- package/dist/client/assets/{use-capability-ZRZyXZT2.js → use-capability-BaUd0xWe.js} +1 -1
- package/dist/client/assets/{use-clock-tick-DeftYEin.js → use-clock-tick-gdHsdqwN.js} +1 -1
- package/dist/client/assets/{use-connection-BvbWEpu1.js → use-connection-BA0SHZq4.js} +1 -1
- package/dist/client/assets/{use-copy-_PBbl_ae.js → use-copy-Cn6MReyw.js} +1 -1
- package/dist/client/assets/{use-create-virtual-mcp-CsZebPFO.js → use-create-virtual-mcp-qP-tA4jh.js} +1 -1
- package/dist/client/assets/{use-debounced-autosave-DpFFxhds.js → use-debounced-autosave-BDgaG6ie.js} +1 -1
- package/dist/client/assets/{use-debounced-value-RZv6Czrq.js → use-debounced-value-Z46cTfvU.js} +1 -1
- package/dist/client/assets/{use-deco-credits-CPmWdsys.js → use-deco-credits-eJFjSf8h.js} +1 -1
- package/dist/client/assets/{use-decopilot-events-Bp76K5aB.js → use-decopilot-events-DIb8-xa4.js} +1 -1
- package/dist/client/assets/{use-delete-connection-DM4ddJG8.js → use-delete-connection-BRgvmH64.js} +1 -1
- package/dist/client/assets/{use-deployment-admin-CzIxD_pk.js → use-deployment-admin-CFSaL5ar.js} +1 -1
- package/dist/client/assets/{use-file-configs-CIAOsadi.js → use-file-configs-CXDDq-eK.js} +1 -1
- package/dist/client/assets/{use-infinite-scroll-UBZNLC2q.js → use-infinite-scroll-CSB5LAvZ.js} +1 -1
- package/dist/client/assets/{use-join-requests-Df1KaVAV.js → use-join-requests-CVHRtviB.js} +1 -1
- package/dist/client/assets/{use-mcp-auth-status-xCpfo047.js → use-mcp-auth-status-CMaGVn6x.js} +1 -1
- package/dist/client/assets/{use-mcp-client-FpSZFiJp.js → use-mcp-client-MwuAGCP0.js} +1 -1
- package/dist/client/assets/{use-mcp-tools-Bfgi1tbs.js → use-mcp-tools-BLLnaQRh.js} +1 -1
- package/dist/client/assets/{use-members-CUYuiUkk.js → use-members-DJzFLRoA.js} +1 -1
- package/dist/client/assets/{use-mobile-Bwjx_QMs.js → use-mobile-C13C4uh-.js} +1 -1
- package/dist/client/assets/{use-navigate-to-agent-Dlk0IC9Q.js → use-navigate-to-agent-CDRQ3LGW.js} +1 -1
- package/dist/client/assets/{use-org-auth-client-B6uCBHg4.js → use-org-auth-client-B3ECJOc5.js} +1 -1
- package/dist/client/assets/{use-org-sso-BhLu2IJL.js → use-org-sso-DwM8K-hN.js} +1 -1
- package/dist/client/assets/{use-organization-roles-DRWNxAn0.js → use-organization-roles-BoQYsJwI.js} +1 -1
- package/dist/client/assets/{use-organization-settings-CNDPvDWL.js → use-organization-settings-BxFrc-MV.js} +1 -1
- package/dist/client/assets/{use-registry-app-8Rk9qQRz.js → use-registry-app-F_eDYFGU.js} +1 -1
- package/dist/client/assets/{use-registry-connections-Bp9WZcYU.js → use-registry-connections-DRdZgjEN.js} +1 -1
- package/dist/client/assets/{use-secrets-C2xWkrG-.js → use-secrets-JzPHoSYH.js} +1 -1
- package/dist/client/assets/{use-status-sounds-Cil-9RHI.js → use-status-sounds-CRrS5x2x.js} +1 -1
- package/dist/client/assets/{use-view-mode-Dtt2tGe0.js → use-view-mode-BLv7KScm.js} +1 -1
- package/dist/client/assets/{use-virtual-mcp-BO12Buo0.js → use-virtual-mcp-DkfSN5A7.js} +1 -1
- package/dist/client/assets/useInfiniteQuery-Bulr5qLo.js +1 -0
- package/dist/client/assets/useQueries-Daf1r_8_.js +1 -0
- package/dist/client/assets/{useRouterState-Sf-Gnpuq.js → useRouterState-id8js3QE.js} +1 -1
- package/dist/client/assets/useSuspenseInfiniteQuery-CbOAXJqn.js +1 -0
- package/dist/client/assets/{users-C1aTmE5Y.js → users-BKPEAP3d.js} +1 -1
- package/dist/client/assets/{variant-calendar-D_jp21Fc.js → variant-calendar-BlplYmKq.js} +1 -1
- package/dist/client/assets/{view-mode-toggle-CdCRem0B.js → view-mode-toggle-BMwXmXt9.js} +1 -1
- package/dist/client/index.html +1 -1
- package/dist/server/cli.js +3 -3
- package/dist/server/server.js +3 -3
- package/package.json +1 -1
- package/dist/client/assets/app-editor-CdS1tGJ2.js +0 -1
- package/dist/client/assets/bulk-category-panel-7Z7LJBC2.js +0 -1
- package/dist/client/assets/category-editor-DHD2RkWu.js +0 -1
- package/dist/client/assets/commerce-onboarding-BkltthW8.js +0 -1
- package/dist/client/assets/file-explorer-Dd9gHOUu.js +0 -2
- package/dist/client/assets/github-repo-picker-Cy6gXTqi.js +0 -1
- package/dist/client/assets/index-Bnc4IoFE.js +0 -517
- package/dist/client/assets/index-BqJMq6o8.js +0 -1
- package/dist/client/assets/index-C-7MA5rL.js +0 -8
- package/dist/client/assets/page-seo-sheet-CMU3RR2I.js +0 -1
- package/dist/client/assets/post-editor-BYA6kioK.js +0 -1
- package/dist/client/assets/project-app-view-CaeNKaZB.js +0 -1
- package/dist/client/assets/record-editor-3_i-4UK5.js +0 -1
- package/dist/client/assets/redirect-editor-C87YqCVU.js +0 -1
- package/dist/client/assets/registry-Xj97xqvk.js +0 -2
- package/dist/client/assets/self-tool-result-DgDO0CYL.js +0 -1
- package/dist/client/assets/seo-editor-wLb7dDyd.js +0 -1
- package/dist/client/assets/store-registry-DwtUD-KU.js +0 -2
- package/dist/client/assets/useInfiniteQuery-C3F84whK.js +0 -1
- package/dist/client/assets/useSuspenseInfiniteQuery-CHz5LFPW.js +0 -1
|
@@ -0,0 +1,517 @@
|
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/sections-editor-B9WQ_qSW.js","assets/index-zLQ_KwUp.js","assets/index-BfpiUr3Z.css","assets/ChevronDown-BtwsJF3q.js","assets/agent-icon-gGMqm39Y.js","assets/AlertCircle-BRqx3xep.js","assets/Tool01-CSTeisaV.js","assets/ArrowUp-D9gId7O2.js","assets/Settings02-DJcNlPiV.js","assets/Tool02-BFPH6-tL.js","assets/ArrowRight-BvfxmFPm.js","assets/ArrowUpRight-i87r5MHo.js","assets/TrendUp01-uCNtQJGh.js","assets/ZapSquare-BNsFa87S.js","assets/ZoomOut-Bdun-ybj.js","assets/Users03-BnKaYSKo.js","assets/CheckCircle-DUFed_ZY.js","assets/Check-CKEgzuW7.js","assets/ChevronRight-NUnWKoQ_.js","assets/ChevronUp-DihHtLht.js","assets/DotsVertical-hq3t58jm.js","assets/Stars02-CSMCax45.js","assets/Copy01-C5bN0aQx.js","assets/Globe01-BryNz0dd.js","assets/Eye-D6wgl9MG.js","assets/FilterLines-kzf7tlKR.js","assets/Star01-4luDViOK.js","assets/Globe04-DUBgGRbs.js","assets/SwitchHorizontal01-B78Wff9t.js","assets/HardDrive-B-Cz-BH_.js","assets/Image01-C-5icdHD.js","assets/Key01-zw1UNPHV.js","assets/LayoutLeft-ClXrwu6i.js","assets/XCircle-DrkKVisl.js","assets/LinkExternal01-CUrTcP_i.js","assets/Monitor01-BntiOroW.js","assets/Sun-BS_t5Sm5.js","assets/Package-CyI3pPtY.js","assets/Palette-Bf9UBt-Z.js","assets/Play-cf98mvjp.js","assets/Plus-6kDymf85.js","assets/SearchLg-Ca6Gs9PO.js","assets/SearchMd-Bq5ma3BB.js","assets/Shield01-BOWKmWSM.js","assets/Stars01-DbhvFj37.js","assets/Trash01-D6SSf8SM.js","assets/Upload01-IWZGSkQD.js","assets/User01-h19-qQKE.js","assets/Users01-BVosV5Zq.js","assets/XClose-Bqw0j4zC.js","assets/X-Cl_lyAjH.js","assets/Zap-CRHRXn7z.js","assets/automation-runs-C-RCLuKF.js","assets/select-LJtxIB-u.js","assets/tooltip-y2P8oLl6.js","assets/useInfiniteQuery-Bulr5qLo.js","assets/use-infinite-scroll-CSB5LAvZ.js","assets/use-connection-BA0SHZq4.js","assets/use-mcp-client-MwuAGCP0.js","assets/auth-CC0hVF1j.js","assets/use-virtual-mcp-DkfSN5A7.js","assets/card-gNDjFGep.js","assets/sidebar-CMBLFeKd.js","assets/use-mobile-C13C4uh-.js","assets/table-DpElKEEr.js","assets/empty-state-Bv0o4pop.js","assets/use-members-DJzFLRoA.js","assets/use-org-auth-client-B3ECJOc5.js","assets/use-clock-tick-gdHsdqwN.js","assets/use-automations-_qY82s9O.js","assets/studio-tools-BDPy4sbt.js","assets/useSuspenseInfiniteQuery-CbOAXJqn.js","assets/avatar-D2Ibs6zj.js","assets/format-time-BnbuEtat.js","assets/differenceInSeconds-NQ4PDo0z.js","assets/use-copy-Cn6MReyw.js","assets/file-type-icon-K2dXxjrg.js","assets/dialog-ZqiHDqPF.js","assets/tab-id-BijBBRwE.js","assets/hooks-C3cd-7It.js","assets/decopilot-sse-pool-BKYCROku.js","assets/backoff-CrEUbyZT.js","assets/delay-CnY5UFtP.js","assets/chat-context-B5rz213z.js","assets/autosend-B9JChviy.js","assets/use-ai-providers-B8Bw0Tf-.js","assets/location-BpLtHjTZ.js","assets/use-decopilot-events-DIb8-xa4.js","assets/use-organization-settings-BxFrc-MV.js","assets/monaco-editor-B__egIpZ.js","assets/index-DawtOaQW.js","assets/index-0_RcfZs5.js","assets/calendar-yjvySUql.js","assets/shell-layout-B-ggkJxp.js","assets/required-auth-layout-BBQqJQ3M.js","assets/use-org-sso-DwM8K-hN.js","assets/integration-icon-BW4ZUBDF.js","assets/use-navigate-to-agent-CDRQ3LGW.js","assets/reusable-new-chat-CouMjkYR.js","assets/AreaChart-CTIAAql6.js","assets/form-hSS6YV_K.js","assets/label-BSqo1nfb.js","assets/input-_d3dZcaj.js","assets/dropdown-menu-Def3XQ2r.js","assets/page-seo-form-VLW_NzAm.js","assets/switch-DAZLVlwZ.js","assets/add-section-modal-DmyUgFgN.js","assets/drawer-DQaSiCfP.js","assets/collection-search-OxgUuTDC.js","assets/index-bQ7eQRAG.js","assets/get-initials-D-f_fDFw.js","assets/popover-BLlzoM5T.js","assets/use-registry-app-F_eDYFGU.js","assets/use-mcp-tools-BLLnaQRh.js","assets/github-repo-scope-DjMZbiKa.js","assets/authenticate-and-persist-oauth-CHxJhIDr.js","assets/mcp-oauth-CJiL395p.js","assets/extract-connection-data-DliliWWi.js","assets/command-CPJ3-fx9.js","assets/index-raAj8hl6.js","assets/companions-core-Cpw1YNEa.js","assets/tabs-BTnvaiWr.js","assets/toggle-group-j1ezUTaN.js","assets/use-deco-credits-eJFjSf8h.js","assets/connection-card-BTp_Mexf.js","assets/use-registry-connections-DRdZgjEN.js","assets/retry-CErkP7V6.js","assets/connection-slug-eyAPH6o3.js","assets/textarea-Ci575ef_.js","assets/connection-form-helpers-pJAJWYOQ.js","assets/collection-tabs-wFROlbKE.js","assets/badge-WaoanX2u.js","assets/connect-desktop-dialog-D1LywKPY.js","assets/select-model-BxAY6ZVn.js","assets/checkbox-D4JNeDbC.js","assets/skeleton-CK77xki0.js","assets/ai-providers-logos-DD3qZ33J.js","assets/settings-section-DiO-ilon.js","assets/index-Bs1Iy52V.js","assets/alert-dialog-BhTFO1xE.js","assets/toolbar-_ubtVWm6.js","assets/use-debounced-value-Z46cTfvU.js","assets/question-004-sINsf4GQ.js","assets/use-status-sounds-CRrS5x2x.js","assets/use-capability-BaUd0xWe.js","assets/toolbar-icon-button-CzwvD8BJ.js","assets/pt-BR-CLy76QW2.js","assets/use-mcp-auth-status-CMaGVn6x.js","assets/use-debounced-autosave-BDgaG6ie.js","assets/index-5q66t9__.js","assets/search-input-jKTRliwf.js","assets/github-repo-picker-gznstzb9.js","assets/provision-repo-scoped-github-connection-2iDn-wQ1.js","assets/use-secrets-JzPHoSYH.js","assets/useQueries-Daf1r_8_.js","assets/use-file-configs-CXDDq-eK.js","assets/automation-list-row-DDcgXspJ.js","assets/page-seo-sheet-D75ZAusC.js","assets/file-explorer-CgJTQxdk.js","assets/app-editor-CLJXkmZ1.js","assets/post-editor-MhFXsnxa.js","assets/multi-select-C-FSYlSF.js","assets/block-document-DxcFxi9r.js","assets/primitives-BwYP-BE9.js","assets/use-autosave-DsJinH0F.js","assets/record-editor-DwE3lAwY.js","assets/category-editor-BH2HxeFP.js","assets/bulk-category-panel-Ca_By5bp.js","assets/seo-editor-Cv-AlrO0.js","assets/variant-calendar-BlplYmKq.js","assets/view-mode-toggle-BMwXmXt9.js","assets/redirect-editor-BGHY1mAE.js","assets/project-app-view-CRipBtzb.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{o as Ls,r as A,a0 as H5,a1 as W5,c as B,F as Fe,m as ie,j as r,E as _s,b as re,t as ge,J as tn,a2 as q5,M as rs,a3 as K0,B as le,R as U0,P as cm,a4 as G5,a5 as Y5,v as ii,a6 as ys,a7 as ro,a8 as Ku,d as St,e as Ys,q as $e,a9 as J5,z as Sr,aa as X5,ab as dm,$ as um,K as at,ac as Hl,a as Di,ad as Q5,ae as hm,af as Z5,ag as hn,ah as Mc,ai as tr,aj as ex,ak as Oc,al as tx,am as sx,an as nx,ao as ix,ap as rx,aq as ox,ar as ax,as as lx,at as fm,au as vo,n as Ft,k as et,y as H0,u as wr,f as Wl,I as cx,G as dx,x as mm,av as ux,L as pm,aw as hx,ax as gm,ay as fx,az as ql,aA as dr,aB as it,aC as ur,aD as xm,aE as mx,aF as px,aG as vm,aH as gx,aI as xx,aJ as vx,aK as bx,aL as oo,aM as $s,Z as yx}from"./index-zLQ_KwUp.js";import{i as W0,n as _x}from"./ArrowUp-D9gId7O2.js";import{a as Ts,b as Js,S as wi,c as Ii,u as bm,d as Zt,e as ym,s as Lx,f as Sx,g as wx,p as _m,h as q0,A as jx,i as Cx,j as kx,t as Vx,k as Nx,l as Tx}from"./chat-context-B5rz213z.js";import{s as jr,g as pn,P as Ao,d as G0,a as Ax,M as Ex,i as Px,b as Rx,F as Dx,c as Lm,e as Sm,S as Ix,u as Mx,f as Ox,h as $x,j as Uu,k as Bx,l as wm,O as Fx,m as ri,T as zx,n as jm,R as Kx,C as Ux,G as Hx,o as Wx,p as qx,q as Gx,A as Yx}from"./automation-runs-C-RCLuKF.js";import{c as ji,T as Ke,a as Ue,b as He}from"./tooltip-y2P8oLl6.js";import{a as ms,b as ps,d as es,e as ts,h as oi,c as Mi}from"./dialog-ZqiHDqPF.js";import{c as Jx,b as Cm,a as km,D as Vm}from"./drawer-DQaSiCfP.js";import{C as Xx}from"./collection-search-OxgUuTDC.js";import{u as Cr}from"./use-mobile-C13C4uh-.js";import{a as Xo,u as ht,S as Qo,i as nl,c as Qx,d as Zx,W as ev,e as tv,C as Hu,g as il,f as Nm,b as Wu,m as sv}from"./use-mcp-client-MwuAGCP0.js";import{u as Tm,g as Zo,l as Ad,X as nv,C as iv,a as rv,A as ov,b as av,c as lv}from"./AreaChart-CTIAAql6.js";import{c as Y0,t as Ci,P as cv,a as dv,i as hr,g as uv,b as hv,u as Am,E as fv,d as J0,M as mv,e as Em,f as pv,h as gv,C as xv}from"./calendar-yjvySUql.js";import{t as ss}from"./ChevronDown-BtwsJF3q.js";import{i as ks}from"./X-Cl_lyAjH.js";import{t as vv,z as bv,u as Gl,b as Pm}from"./hooks-C3cd-7It.js";import{K as yv,i as Rm,u as ea,r as _v,a as Dm}from"./shell-layout-B-ggkJxp.js";import{u as ta,a as gs,b as X0,c as Lv}from"./use-virtual-mcp-DkfSN5A7.js";import{w as Im,A as Sv}from"./autosend-B9JChviy.js";import{u as wv,S as jv,a as Cv,b as kv,r as qu,i as Vv,c as Nv,w as Tv,H as Av,d as Ev,e as Pv,f as Rv,g as Mm,h as Dv,j as Iv,T as Mv,k as Ov,P as $v,l as Bv,m as Fv}from"./index-bQ7eQRAG.js";import{n as fr,b as Om}from"./ZapSquare-BNsFa87S.js";import{i as zt}from"./Check-CKEgzuW7.js";import{s as gn}from"./Star01-4luDViOK.js";import{a as En}from"./Image01-C-5icdHD.js";import{t as Yl,l as $m,m as Q0,n as zv,o as Zs,p as Z0,q as e9,r as Bm,u as Kv,A as Qn,v as Fm,w as zm,x as Uv,y as Hv,d as Km,z as Gu,f as Um,B as Wv,C as Hm,D as qv,E as Jl,F as Oi,G as Gv,H as t9,I as Wm,J as qm,K as Ed,L as $c,M as Yu,N as Yv,O as Jv,P as Xv,Q as Qv,R as Zv,S as e6,T as s9,U as Gm,V as ai,W as n9,X as Ym,h as i9,k as Jm,Y as r9,Z as t6,_ as s6,$ as n6,a0 as Ju,a1 as i6,a2 as r6,a3 as o6,a4 as a6,a5 as Nn,a6 as rl,a7 as sa,a8 as Xm,a9 as ol,aa as Qm,ab as l6,ac as c6,ad as d6,ae as u6,af as h6,ag as f6,ah as m6,ai as p6,aj as g6,ak as Xu,al as x6,am as v6,an as b6,ao as y6,ap as _6,aq as L6,b as S6,ar as Zm,as as e2,at as t2}from"./agent-icon-gGMqm39Y.js";import{i as $i}from"./Upload01-IWZGSkQD.js";import{i as wn}from"./AlertCircle-BRqx3xep.js";import{a as Os}from"./Copy01-C5bN0aQx.js";import{a as Pd,b as o9,d as a9,f as l9,F as s2}from"./form-hSS6YV_K.js";import{d as vt,a as Jt,b as as,c as Xt,S as Qt}from"./select-LJtxIB-u.js";import{b as Xl,a as w6,i as j6}from"./Settings02-DJcNlPiV.js";import{i as kr}from"./ArrowRight-BvfxmFPm.js";import{T as yi,a as Vr,b as na,c as xn}from"./tabs-BTnvaiWr.js";import{t as Rd}from"./Tool02-BFPH6-tL.js";import{a as c9,T as Eo}from"./toggle-group-j1ezUTaN.js";import{I as rt}from"./input-_d3dZcaj.js";import{u as d9,b as ia,g as u9,A as h9,c as n2,a as sn,r as C6,f as k6,d as V6}from"./use-deco-credits-eJFjSf8h.js";import{u as Bs}from"./studio-tools-BDPy4sbt.js";import{i as Nr}from"./Monitor01-BntiOroW.js";import{C as N6,l as T6,a as A6,b as E6}from"./connect-desktop-dialog-D1LywKPY.js";import{s as Pn}from"./XClose-Bqw0j4zC.js";import{m as Ql,i as P6,g as i2,a as R6,N as D6,M as I6}from"./select-model-BxAY6ZVn.js";import{u as M6,a as r2}from"./use-members-DJzFLRoA.js";import{g as O6}from"./get-initials-D-f_fDFw.js";import{A as ir}from"./avatar-D2Ibs6zj.js";import{C as Zn,e as Ms,a as Vs,f as Qu,d as Tr,b as Bi,c as Fi,g as $6}from"./command-CPJ3-fx9.js";import{b as As,P as Es,a as Ps}from"./popover-BLlzoM5T.js";import{u as o2}from"./useInfiniteQuery-Bulr5qLo.js";import{u as ra,a as f9,b as a2}from"./use-mcp-tools-BLLnaQRh.js";import{D as ds,c as us,d as ao,b as hs,a as Xe,e as Po,f as Ro,g as Do,h as Dd,i as Io,j as rr}from"./dropdown-menu-Def3XQ2r.js";import{t as Gn}from"./Stars01-DbhvFj37.js";import{f as B6,a as F6,s as z6,u as K6,b as U6,c as H6,d as W6,g as q6,e as l2,h as G6,R as c2,i as al,j as d2,k as Y6,F as J6,l as X6,m as Q6,n as Z6,o as eb,p as tb,q as sb,H as nb,L as ib,r as rb,S as ob,B as ab,t as Zl,T as m9,v as lb}from"./index-Bs1Iy52V.js";import{a as u2,i as cb}from"./XCircle-DrkKVisl.js";import{s as kt}from"./Plus-6kDymf85.js";import{p as db,q as ub}from"./question-004-sINsf4GQ.js";import{i as bn}from"./ChevronRight-NUnWKoQ_.js";import{u as h2}from"./use-ai-providers-B8Bw0Tf-.js";import{i as ec}from"./CheckCircle-DUFed_ZY.js";import{I as an}from"./integration-icon-BW4ZUBDF.js";import{u as hb}from"./use-status-sounds-CRrS5x2x.js";import{E as ki}from"./empty-state-Bv0o4pop.js";import{r as ll,a as fb,p as f2,f as Ua,b as m2,c as p2,d as g2,e as mb,F as pb,g as gb,h as xb,i as vb,j as bb,k as yb,O as _b,l as Lb,m as Sb}from"./tab-id-BijBBRwE.js";import{T as cl}from"./toolbar-_ubtVWm6.js";import{a as ei,b as oa,i as x2,c as mr,d as wb,e as jb}from"./ZoomOut-Bdun-ybj.js";import{u as tc,a as v2,b as b2}from"./use-organization-settings-BxFrc-MV.js";import{i as li,n as Cb}from"./Globe01-BryNz0dd.js";import{u as Rn,a as p9,b as y2}from"./use-connection-BA0SHZq4.js";import{g as sc,M as kb}from"./index-0_RcfZs5.js";import{e as _2}from"./backoff-CrEUbyZT.js";import{F as pr,M as g9,O as Vb}from"./file-type-icon-K2dXxjrg.js";import{u as Nb}from"./use-capability-BaUd0xWe.js";import{T as gr}from"./textarea-Ci575ef_.js";import{s as x9}from"./Eye-D6wgl9MG.js";import{l as Tb,w as Ab}from"./index-DawtOaQW.js";import{T as Id}from"./toolbar-icon-button-CzwvD8BJ.js";import{p as Eb,f as Pb}from"./pt-BR-CLy76QW2.js";import{g as Rb}from"./extract-connection-data-DliliWWi.js";import{a as Db,i as Zu}from"./mcp-oauth-CJiL395p.js";import{f as dl,e as ul,b as hl,A as fl,a as ml,d as pl,c as gl,g as xl}from"./alert-dialog-BhTFO1xE.js";import{C as vl,a as Mo}from"./card-gNDjFGep.js";import{I as Ib,R as Mb,a as Ob,T as L2,u as S2}from"./use-mcp-auth-status-CMaGVn6x.js";import{i as $b,a as w2}from"./DotsVertical-hq3t58jm.js";import{i as Vi}from"./Play-cf98mvjp.js";import{s as Ns}from"./Trash01-D6SSf8SM.js";import{u as bl}from"./use-debounced-autosave-BDgaG6ie.js";import{i as Oo}from"./SearchMd-Bq5ma3BB.js";import{P as en}from"./index-5q66t9__.js";import{C as Ar}from"./checkbox-D4JNeDbC.js";import{S as v9}from"./search-input-jKTRliwf.js";import{C as j2}from"./collection-tabs-wFROlbKE.js";import{g as Bb,s as C2}from"./connection-slug-eyAPH6o3.js";import{L as lt}from"./label-BSqo1nfb.js";import{S as xr}from"./switch-DAZLVlwZ.js";import{i as Fb}from"./LayoutLeft-ClXrwu6i.js";import{i as b9}from"./Key01-zw1UNPHV.js";import{G as $o}from"./use-registry-app-F_eDYFGU.js";import{G as k2}from"./github-repo-picker-gznstzb9.js";import{S as Rt}from"./skeleton-CK77xki0.js";import{s as zb}from"./User01-h19-qQKE.js";import{t as nc}from"./Users01-BVosV5Zq.js";import{u as Kb,a as Ub}from"./use-secrets-JzPHoSYH.js";import{a as V2}from"./format-time-BnbuEtat.js";import{i as N2}from"./ArrowUpRight-i87r5MHo.js";import{c as y9,s as _9,b as Hb}from"./TrendUp01-uCNtQJGh.js";import{g as Wb}from"./github-repo-scope-DjMZbiKa.js";import{f as T2}from"./provision-repo-scoped-github-connection-2iDn-wQ1.js";import{m as qb,n as Gb,o as Yb,p as Jb,q as Xb}from"./sidebar-CMBLFeKd.js";import{n as Dn}from"./LinkExternal01-CUrTcP_i.js";import{i as L9}from"./SearchLg-Ca6Gs9PO.js";import{i as S9,a as Qb,b as w9,c as j9}from"./Tool01-CSTeisaV.js";import{u as Md}from"./useQueries-Daf1r_8_.js";import{d as Zb}from"./delay-CnY5UFtP.js";import{c as A2,i as e8}from"./SwitchHorizontal01-B78Wff9t.js";import{i as Ni}from"./Zap-CRHRXn7z.js";import{M as aa}from"./monaco-editor-B__egIpZ.js";import{u as t8}from"./use-debounced-value-Z46cTfvU.js";import{u as s8,a as E2}from"./use-file-configs-CXDDq-eK.js";import{i as n8}from"./FilterLines-kzf7tlKR.js";import{B as i8}from"./badge-WaoanX2u.js";import{u as la,a as r8,b as o8,c as a8,d as l8}from"./use-automations-_qY82s9O.js";import{s as bo}from"./Stars02-CSMCax45.js";import{A as c8}from"./automation-list-row-DDcgXspJ.js";function d8(t,e){const s=Ls(e);return u8({filters:{...t,status:"pending"}},s).length}function eh(t,e){return t.findAll(e.filters).map(s=>e.select?e.select(s):s.state)}function u8(t={},e){const s=Ls(e).getMutationCache(),n=A.useRef(t),i=A.useRef(null);return i.current===null&&(i.current=eh(s,t)),A.useEffect(()=>{n.current=t}),A.useSyncExternalStore(A.useCallback(o=>s.subscribe(()=>{const a=H5(i.current,eh(s,n.current));i.current!==a&&(i.current=a,W5.schedule(o))}),[s]),()=>i.current,()=>i.current)}const th=3,P2="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",h8="flex flex-col gap-1.5 p-4 rounded-xl bg-accent/40 text-sm leading-snug transition-colors cursor-pointer text-left";function R2(t){const e=B.c(46),{item:s,onSelect:n,isLoading:i,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 j=pn(c._meta);d=c.title??G0(c.name,j),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 j;e[4]!==n||e[5]!==c?(j=()=>n(c),e[4]=n,e[5]=c,e[6]=j):j=e[6];const S=o||i,C=i&&"bg-accent/40",N=(o||i)&&"cursor-not-allowed opacity-50";let V;e[7]!==C||e[8]!==N?(V=ie(h8,"hover:bg-accent/60 text-foreground",C,N),e[7]=C,e[8]=N,e[9]=V):V=e[9];let E;e[10]!==h?(E=r.jsx("span",{className:"font-medium truncate capitalize",children:h}),e[10]=h,e[11]=E):E=e[11];let T;e[12]!==i?(T=i&&r.jsx(wi,{size:"xs"}),e[12]=i,e[13]=T):T=e[13];let k;e[14]!==E||e[15]!==T?(k=r.jsxs("div",{className:"flex items-center justify-between gap-2",children:[E,T]}),e[14]=E,e[15]=T,e[16]=k):k=e[16];let R;e[17]!==u?(R=u&&r.jsx("span",{className:"text-xs text-muted-foreground line-clamp-2",children:u}),e[17]=u,e[18]=R):R=e[18];let P;return e[19]!==k||e[20]!==R||e[21]!==j||e[22]!==S||e[23]!==V?(P=r.jsxs("button",{type:"button",onClick:j,disabled:S,className:V,children:[k,R]}),e[19]=k,e[20]=R,e[21]=j,e[22]=S,e[23]=V,e[24]=P):P=e[24],P}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||i,p=i&&"bg-muted/50",g=(o||i)&&"cursor-not-allowed opacity-50";let x;e[28]!==p||e[29]!==g?(x=ie(P2,"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=r.jsx("span",{className:"capitalize",children:h}),e[31]=h,e[32]=v):v=e[32];let b;e[33]!==i?(b=i&&r.jsx(wi,{size:"xs"}),e[33]=i,e[34]=b):b=e[34];let _;e[35]!==f||e[36]!==m||e[37]!==x||e[38]!==v||e[39]!==b?(_=r.jsx(Ke,{asChild:!0,children:r.jsxs("button",{type:"button",onClick:f,disabled:m,className:x,children:[v,b]})}),e[35]=f,e[36]=m,e[37]=x,e[38]=v,e[39]=b,e[40]=_):_=e[40];const y=u??h;let L;e[41]!==y?(L=r.jsx(Ue,{side:"top",className:"max-w-xs",children:r.jsx("p",{className:"text-xs",children:y})}),e[41]=y,e[42]=L):L=e[42];let w;return e[43]!==_||e[44]!==L?(w=r.jsxs(He,{delayDuration:400,children:[_,L]}),e[43]=_,e[44]=L,e[45]=w):w=e[45],w}function f8(t){const e=B.c(61),{items:s,open:n,onOpenChange:i,onSelect:o,loadingPrompt:a}=t,l=re(),[c,d]=A.useState(""),h=!!a;let u;e[0]!==s||e[1]!==c?(u=c.trim()?s.filter(E=>{const T=c.toLowerCase();return E.prompt.name.toLowerCase().includes(T)||(E.prompt.title??"").toLowerCase().includes(T)||(E.prompt.description??"").toLowerCase().includes(T)}):s,e[0]=s,e[1]=c,e[2]=u):u=e[2];const f=u,m=Cr();let p;e[3]!==f.length||e[4]!==c||e[5]!==l?(p=f.length===0&&r.jsx("p",{className:"col-span-4 text-sm text-muted-foreground text-center py-8",children:l("chat.iceBreakers.noPromptsMatch",{search:c})}),e[3]=f.length,e[4]=c,e[5]=l,e[6]=p):p=e[6];let g;if(e[7]!==f||e[8]!==h||e[9]!==a?.name||e[10]!==i||e[11]!==o){let E;e[13]!==h||e[14]!==a?.name||e[15]!==i||e[16]!==o?(E=T=>r.jsx(R2,{item:T,variant:"card",onSelect:k=>{i(!1),o(k)},isLoading:a?.name===T.prompt.name,isDisabled:h&&a?.name!==T.prompt.name},T.prompt.name),e[13]=h,e[14]=a?.name,e[15]=i,e[16]=o,e[17]=E):E=e[17],g=f.map(E),e[7]=f,e[8]=h,e[9]=a?.name,e[10]=i,e[11]=o,e[12]=g}else g=e[12];let x;e[18]!==p||e[19]!==g?(x=r.jsx("div",{className:"flex-1 overflow-y-auto [scrollbar-gutter:stable]",children:r.jsxs("div",{className:"grid grid-cols-2 sm:grid-cols-3 lg:grid-cols-4 gap-3 p-5",children:[p,g]})}),e[18]=p,e[19]=g,e[20]=x):x=e[20];const v=x;let b;e[21]!==l?(b=l("chat.iceBreakers.searchPromptsPlaceholder"),e[21]=l,e[22]=b):b=e[22];let _;e[23]===Symbol.for("react.memo_cache_sentinel")?(_=E=>{E.key==="Escape"&&d("")},e[23]=_):_=e[23];let y;e[24]!==c||e[25]!==b?(y=r.jsx(Xx,{value:c,onChange:d,placeholder:b,onKeyDown:_}),e[24]=c,e[25]=b,e[26]=y):y=e[26];const L=y;if(m){let E;e[27]!==l?(E=l("chat.iceBreakers.allPromptsTitle"),e[27]=l,e[28]=E):E=e[28];let T;e[29]!==E?(T=r.jsx(Jx,{className:"sr-only",children:r.jsx(Cm,{children:E})}),e[29]=E,e[30]=T):T=e[30];let k;e[31]!==l?(k=l("chat.iceBreakers.promptsLabel"),e[31]=l,e[32]=k):k=e[32];let R;e[33]!==k?(R=r.jsx("div",{className:"flex items-center h-12 border-b border-border px-4 shrink-0",children:r.jsx("span",{className:"text-sm font-medium text-foreground",children:k})}),e[33]=k,e[34]=R):R=e[34];let P;e[35]!==v||e[36]!==L||e[37]!==R||e[38]!==T?(P=r.jsxs(km,{className:"h-[85vh] flex flex-col p-0 gap-0",children:[T,R,L,v]}),e[35]=v,e[36]=L,e[37]=R,e[38]=T,e[39]=P):P=e[39];let D;return e[40]!==i||e[41]!==n||e[42]!==P?(D=r.jsx(ji,{delayDuration:400,children:r.jsx(Vm,{open:n,onOpenChange:i,children:P})}),e[40]=i,e[41]=n,e[42]=P,e[43]=D):D=e[43],D}let w;e[44]!==l?(w=l("chat.iceBreakers.allPromptsTitle"),e[44]=l,e[45]=w):w=e[45];let j;e[46]!==w?(j=r.jsx(ms,{className:"sr-only",children:r.jsx(ps,{children:w})}),e[46]=w,e[47]=j):j=e[47];let S;e[48]!==l?(S=l("chat.iceBreakers.promptsLabel"),e[48]=l,e[49]=S):S=e[49];let C;e[50]!==S?(C=r.jsx("div",{className:"flex items-center h-12 border-b border-border px-4 shrink-0",children:r.jsx("span",{className:"text-sm font-medium text-foreground",children:S})}),e[50]=S,e[51]=C):C=e[51];let N;e[52]!==v||e[53]!==L||e[54]!==C||e[55]!==j?(N=r.jsxs(es,{className:"sm:max-w-[1100px] h-[680px] p-0 gap-0 overflow-hidden flex flex-col",children:[j,C,L,v]}),e[52]=v,e[53]=L,e[54]=C,e[55]=j,e[56]=N):N=e[56];let V;return e[57]!==i||e[58]!==n||e[59]!==N?(V=r.jsx(ji,{delayDuration:400,children:r.jsx(ts,{open:n,onOpenChange:i,children:N})}),e[57]=i,e[58]=n,e[59]=N,e[60]=V):V=e[60],V}function m8(t){const e=B.c(30),{items:s,onSelect:n,loadingPrompt:i,className:o}=t,a=re(),[l,c]=A.useState(!1);if(s.length===0)return null;let d,h,u,f,m;if(e[0]!==o||e[1]!==s||e[2]!==i||e[3]!==n||e[4]!==a){const v=s.slice(0,th),b=s.slice(th),_=!!i;let y;e[10]!==_||e[11]!==i?.name||e[12]!==n?(y=w=>r.jsx(R2,{item:w,onSelect:n,isLoading:i?.name===w.prompt.name,isDisabled:_&&i?.name!==w.prompt.name},w.prompt.name),e[10]=_,e[11]=i?.name,e[12]=n,e[13]=y):y=e[13];const L=v.map(y);d=ji,m=400,e[14]!==o?(h=ie("w-full flex flex-wrap gap-2 justify-center",o),e[14]=o,e[15]=h):h=e[15],u=L,f=b.length>0&&r.jsx("button",{type:"button",disabled:_,onClick:()=>c(!0),className:ie(P2,"hover:bg-muted/70 hover:text-foreground",_&&"opacity-50 cursor-not-allowed"),children:a("chat.iceBreakers.moreButton",{count:b.length})}),e[0]=o,e[1]=s,e[2]=i,e[3]=n,e[4]=a,e[5]=d,e[6]=h,e[7]=u,e[8]=f,e[9]=m}else d=e[5],h=e[6],u=e[7],f=e[8],m=e[9];let p;e[16]!==h||e[17]!==u||e[18]!==f?(p=r.jsxs("div",{className:h,children:[u,f]}),e[16]=h,e[17]=u,e[18]=f,e[19]=p):p=e[19];let g;e[20]!==s||e[21]!==i||e[22]!==l||e[23]!==n?(g=r.jsx(f8,{items:s,open:l,onOpenChange:c,onSelect:n,loadingPrompt:i}),e[20]=s,e[21]=i,e[22]=l,e[23]=n,e[24]=g):g=e[24];let x;return e[25]!==d||e[26]!==m||e[27]!==p||e[28]!==g?(x=r.jsxs(d,{delayDuration:m,children:[p,g]}),e[25]=d,e[26]=m,e[27]=p,e[28]=g,e[29]=x):x=e[29],x}function p8(){return null}function g8(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 x8(t){const e=B.c(31),{connectionId:s}=t,n=re(),{sendMessage:i}=Js(),{org:o}=Fe();let a;e[0]!==s||e[1]!==o.id||e[2]!==o.slug?(a={connectionId:s,orgId:o.id,orgSlug:o.slug},e[0]=s,e[1]=o.id,e[2]=o.slug,e[3]=a):a=e[3];const l=ht(a);let c;e[4]!==l?(c={client:l,staleTime:6e4},e[4]=l,e[5]=c):c=e[5];const{data:d}=Tm(c);let h;e[6]!==d?.prompts?(h=d?.prompts??[],e[6]=d?.prompts,e[7]=h):h=e[7];const u=h;let f;e[8]!==u?(f=u.map(v8),e[8]=u,e[9]=f):f=e[9];const m=f;let p;e[10]===Symbol.for("react.memo_cache_sentinel")?(p={stage:"idle"},e[10]=p):p=e[10];const[g,x]=A.useReducer(g8,p),[v,b]=A.useState(null);let _;e[11]!==l||e[12]!==i||e[13]!==n?(_=async(k,R)=>{if(!l){ge.error(n("chat.iceBreakers.mcpClientNotAvailable")),x({type:"RESET"});return}try{const P=await Zo(l,k.name,R);x({type:"RESET"});const D={type:"doc",content:[{type:"paragraph",content:[Y0({id:k.name,name:jr(k.name,pn(k._meta)),metadata:P.messages,char:"/",kind:"prompt",args:R}),{type:"text",text:" "}]}]};await i(D)}catch(P){console.error("[ice-breakers] Failed to fetch prompt:",P),ge.error(n("chat.iceBreakers.failedToLoadPrompt")),x({type:"RESET"})}},e[11]=l,e[12]=i,e[13]=n,e[14]=_):_=e[14];const y=_;let L;e[15]!==y?(L=async k=>{if(k.arguments&&k.arguments.length>0){x({type:"SELECT_PROMPT",prompt:k}),b(k);return}x({type:"START_LOADING",prompt:k}),await y(k)},e[15]=y,e[16]=L):L=e[16];const w=L;let j;e[17]!==v||e[18]!==y?(j=async k=>{v&&(x({type:"START_LOADING",prompt:v,arguments:k}),b(null),await y(v,k))},e[17]=v,e[18]=y,e[19]=j):j=e[19];const S=j;if(m.length===0)return null;const C=g.stage==="loading"?g.prompt:null;let N;e[20]!==w||e[21]!==m||e[22]!==C?(N=r.jsx(m8,{items:m,onSelect:w,loadingPrompt:C}),e[20]=w,e[21]=m,e[22]=C,e[23]=N):N=e[23];let V;e[24]===Symbol.for("react.memo_cache_sentinel")?(V=()=>{b(null),x({type:"RESET"})},e[24]=V):V=e[24];let E;e[25]!==v||e[26]!==S?(E=r.jsx(Ao,{prompt:v,setPrompt:V,onSubmit:S}),e[25]=v,e[26]=S,e[27]=E):E=e[27];let T;return e[28]!==N||e[29]!==E?(T=r.jsxs(r.Fragment,{children:[N,E]}),e[28]=N,e[29]=E,e[30]=T):T=e[30],T}function v8(t){return{prompt:t}}function b8(t){const e=B.c(13),{className:s}=t,{selectedVirtualMcp:n}=Ts(),{org:i}=Fe();let o;e[0]!==i.id?(o=Xo(i.id),e[0]=i.id,e[1]=o):o=e[1];const a=o.id,l=n?.id??a;let c;e[2]!==s?(c=ie("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=r.jsx(p8,{}),e[4]=h):h=e[4];let u;e[5]!==l?(u=r.jsx(x8,{connectionId:l}),e[5]=l,e[6]=u):u=e[6];let f;e[7]!==d||e[8]!==u?(f=r.jsx(_s,{fallback:null,children:r.jsx(A.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=r.jsx("div",{className:c,children:f}),e[10]=c,e[11]=f,e[12]=m):m=e[12],m}const Bc="cubic-bezier(0.645, 0.045, 0.355, 1)",y8=44,_8={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-warning/5 after:pointer-events-none after:-z-10"},L8={default:"border-border",error:"border-destructive/30",warning:"border-warning/30"},S8={default:"text-muted-foreground",error:"text-destructive",warning:"text-warning"};function ti(t){const e=B.c(69),{icon:s,label:n,count:i,title:o,footerLeft:a,footerRight:l,children:c,defaultExpanded:d,variant:h,onClose:u}=t,f=h===void 0?"default":h,m=re(),[p,g]=A.useState(d),[x,v]=A.useState(!1);let b;e[0]!==u?(b=()=>{v(!0),u?.()},e[0]=u,e[1]=b):b=e[1];const _=b;if(x)return null;const y=L8[f],L=_8[f];let w;e[2]!==y||e[3]!==L?(w=ie("relative flex flex-col rounded-xl bg-background border shadow-md","w-[calc(100%-16px)] max-w-[640px] mx-auto mb-2",y,L),e[2]=y,e[3]=L,e[4]=w):w=e[4];let j;e[5]===Symbol.for("react.memo_cache_sentinel")?(j=()=>g(w8),e[5]=j):j=e[5];const S=p&&"rounded-b-none",C=!p&&"rounded-b-xl";let N;e[6]!==S||e[7]!==C?(N=ie("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,C),e[6]=S,e[7]=C,e[8]=N):N=e[8];const V=S8[f];let E;e[9]!==V?(E=ie("shrink-0",V),e[9]=V,e[10]=E):E=e[10];let T;e[11]!==s||e[12]!==E?(T=r.jsx("span",{className:E,children:s}),e[11]=s,e[12]=E,e[13]=T):T=e[13];let k;e[14]!==n?(k=r.jsx("span",{className:"flex-1 min-w-0 truncate",children:n}),e[14]=n,e[15]=k):k=e[15];let R;e[16]!==i?(R=i?r.jsx("span",{className:"text-xs text-muted-foreground shrink-0",children:i}):null,e[16]=i,e[17]=R):R=e[17];const P=p?"rotate(180deg)":"rotate(0deg)";let D;e[18]!==P?(D=r.jsx("span",{"aria-hidden":"true",className:"text-muted-foreground shrink-0 flex items-center justify-center",children:r.jsx(ss,{size:16,style:{transform:P,transition:`transform 180ms ${Bc}`}})}),e[18]=P,e[19]=D):D=e[19];let I;e[20]!==m?(I=m("chat.collapsibleHighlight.closeLabel"),e[20]=m,e[21]=I):I=e[21];let M;e[22]!==m?(M=m("chat.collapsibleHighlight.closeTitle"),e[22]=m,e[23]=M):M=e[23];let O,F;e[24]!==_?(O=se=>{se.stopPropagation(),_()},F=se=>{(se.key==="Enter"||se.key===" ")&&(se.preventDefault(),se.stopPropagation(),_())},e[24]=_,e[25]=O,e[26]=F):(O=e[25],F=e[26]);let $;e[27]===Symbol.for("react.memo_cache_sentinel")?($=r.jsx(ks,{size:16}),e[27]=$):$=e[27];let z;e[28]!==I||e[29]!==M||e[30]!==O||e[31]!==F?(z=r.jsx("span",{role:"button",tabIndex:0,"data-testid":"collapsible-highlight-close","aria-label":I,title:M,onClick:O,onKeyDown:F,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:$}),e[28]=I,e[29]=M,e[30]=O,e[31]=F,e[32]=z):z=e[32];let K;e[33]!==p||e[34]!==T||e[35]!==k||e[36]!==R||e[37]!==D||e[38]!==z||e[39]!==N?(K=r.jsxs("button",{type:"button","data-testid":"collapsible-highlight-chip","aria-expanded":p,onClick:j,className:N,children:[T,k,R,D,z]}),e[33]=p,e[34]=T,e[35]=k,e[36]=R,e[37]=D,e[38]=z,e[39]=N,e[40]=K):K=e[40];const X=p?"1fr":"0fr";let J;e[41]!==X?(J={display:"grid",gridTemplateRows:X,transition:`grid-template-rows 180ms ${Bc}`},e[41]=X,e[42]=J):J=e[42];let H;e[43]===Symbol.for("react.memo_cache_sentinel")?(H={overflow:"hidden",minHeight:0},e[43]=H):H=e[43];const W=p?1:0;let U;e[44]!==W?(U={opacity:W,transition:`opacity 120ms ${Bc}`,maxHeight:"60vh"},e[44]=W,e[45]=U):U=e[45];let Q;e[46]!==o?(Q=o?r.jsx("div",{className:"flex items-start gap-2 px-4 pt-4 pb-5 border-t border-dashed border-border/60",children:r.jsx("p",{className:"flex-1 text-base font-medium text-foreground min-w-0",children:o})}):r.jsx("div",{className:"border-t border-dashed border-border/60"}),e[46]=o,e[47]=Q):Q=e[47];let q;e[48]!==c||e[49]!==o?(q=c?r.jsx("div",{className:ie("pb-4",!o&&"pt-4"),children:c}):null,e[48]=c,e[49]=o,e[50]=q):q=e[50];let Z;e[51]!==Q||e[52]!==q?(Z=r.jsxs("div",{className:"flex-1 min-h-0 overflow-y-auto",children:[Q,q]}),e[51]=Q,e[52]=q,e[53]=Z):Z=e[53];let Y;e[54]!==a||e[55]!==l?(Y=a||l?r.jsx("div",{className:"shrink-0 border-t border-border px-3 py-3 pb-6",children:r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsx("div",{children:a}),r.jsx("div",{className:"flex items-center gap-2",children:l})]})}):null,e[54]=a,e[55]=l,e[56]=Y):Y=e[56];let ee;e[57]!==U||e[58]!==Z||e[59]!==Y?(ee=r.jsx("div",{style:H,children:r.jsxs("div",{className:"flex flex-col",style:U,children:[Z,Y]})}),e[57]=U,e[58]=Z,e[59]=Y,e[60]=ee):ee=e[60];let G;e[61]!==J||e[62]!==ee?(G=r.jsx("div",{"data-testid":"collapsible-highlight-body",style:J,children:ee}),e[61]=J,e[62]=ee,e[63]=G):G=e[63];let te;return e[64]!==K||e[65]!==G||e[66]!==w||e[67]!==f?(te=r.jsxs("div",{"data-testid":"collapsible-highlight","data-variant":f,className:w,children:[K,G]}),e[64]=K,e[65]=G,e[66]=w,e[67]=f,e[68]=te):te=e[68],te}function w8(t){return!t}const j8=tn({content:rs().min(1).describe("Imperative form, e.g. 'Implement the login flow'"),status:K0(["pending","in_progress","completed"]),activeForm:rs().min(1).describe("Present-continuous form shown in the UI while the todo is in progress, e.g. 'Implementing the login flow'")}),D2=tn({todos:q5(j8)}),C8="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.";vv({description:C8,inputSchema:bv(D2),execute:async({todos:t})=>({ok:!0,count:t.length})});const k8="tool-todo_write",V8=new Set(["input-available","output-available"]);function N8(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 i=n.length-1;i>=0;i--){const o=n[i];if(o.type!==k8||typeof o.state!="string"||!V8.has(o.state))continue;const a=D2.safeParse(o.input);if(a.success)return a.data.todos}}return[]}function I2(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:Ci(Ax(n)),input:s.input})}return e}function M2(t){return t.at(-1)}function O2(t){const e=[];for(const s of t)s.type==="tool-propose_plan"&&s.state==="input-available"&&e.push({toolCallId:s.toolCallId,plan:s.input.plan,state:s.state});return e}function T8(t){return t?t.message.startsWith("[CREDITS]"):!1}const A8={isCreditExhausted:!1,hasTodos:!1,showError:!1,showWarning:!1,hasApprovals:!1,hasPlans:!1,isWaitingForUserInput:!1,todos:[]};function E8(t){const{messages:e,error:s,finishReason:n,isStreaming:i,isWaitingForApprovals:o}=t;if(!i&&s&&T8(s))return{...A8,isCreditExhausted:!0};const a=e.at(-1),l=a?.role==="assistant"?a.parts:[],c=l,h=!!c.filter(_=>_.type==="tool-user_ask").filter(_=>_.state!=="output-available").length,u=O2(l),f=I2(c),m=N8(e),p=!i&&!!s,g=f.length>0||i&&o,x=u.length>0,b=!i&&!!n&&n!=="stop"&&!(n==="tool-calls"&&(h||g||x))&&!p;return{isCreditExhausted:!1,hasTodos:m.length>0,showError:p,showWarning:b,hasApprovals:g,hasPlans:x,isWaitingForUserInput:h,todos:m}}function $2(){const t=B.c(6),{messages:e,error:s,finishReason:n,isStreaming:i,isWaitingForApprovals:o}=Js(),a=s??null,l=n??null;let c;return t[0]!==i||t[1]!==o||t[2]!==e||t[3]!==a||t[4]!==l?(c=E8({messages:e,error:a,finishReason:l,isStreaming:i,isWaitingForApprovals:o}),t[0]=i,t[1]=o,t[2]=e,t[3]=a,t[4]=l,t[5]=c):c=t[5],c}function P8(){const t=$2();return t.isCreditExhausted?0:Number(t.hasTodos)+Number(t.showError)+Number(t.showWarning)+Number(t.hasApprovals)+Number(t.hasPlans)+Number(t.isWaitingForUserInput)}function R8(t){const e=B.c(30),{current:s,total:n,onPrev:i,onNext:o}=t,a=re();if(n<=1)return null;const l=s===0,c=s===0?"opacity-30 cursor-not-allowed":"hover:text-foreground cursor-pointer";let d;e[0]!==c?(d=ie("p-0.5 rounded transition-colors",c),e[0]=c,e[1]=d):d=e[1];let h;e[2]!==a?(h=a("chat.pagination.previousLabel"),e[2]=a,e[3]=h):h=e[3];let u;e[4]===Symbol.for("react.memo_cache_sentinel")?(u=r.jsx(Xl,{size:14}),e[4]=u):u=e[4];let f;e[5]!==i||e[6]!==l||e[7]!==d||e[8]!==h?(f=r.jsx("button",{type:"button",onClick:i,disabled:l,className:d,"aria-label":h,children:u}),e[5]=i,e[6]=l,e[7]=d,e[8]=h,e[9]=f):f=e[9];const m=s+1;let p;e[10]!==a||e[11]!==m||e[12]!==n?(p=a("chat.pagination.counter",{current:m,total:n}),e[10]=a,e[11]=m,e[12]=n,e[13]=p):p=e[13];let g;e[14]!==p?(g=r.jsx("span",{className:"tabular-nums text-xs",children:p}),e[14]=p,e[15]=g):g=e[15];const x=s===n-1,v=s===n-1?"opacity-30 cursor-not-allowed":"hover:text-foreground cursor-pointer";let b;e[16]!==v?(b=ie("p-0.5 rounded transition-colors",v),e[16]=v,e[17]=b):b=e[17];let _;e[18]!==a?(_=a("chat.pagination.nextLabel"),e[18]=a,e[19]=_):_=e[19];let y;e[20]===Symbol.for("react.memo_cache_sentinel")?(y=r.jsx(kr,{size:14}),e[20]=y):y=e[20];let L;e[21]!==o||e[22]!==x||e[23]!==b||e[24]!==_?(L=r.jsx("button",{type:"button",onClick:o,disabled:x,className:b,"aria-label":_,children:y}),e[21]=o,e[22]=x,e[23]=b,e[24]=_,e[25]=L):L=e[25];let w;return e[26]!==L||e[27]!==f||e[28]!==g?(w=r.jsxs("div",{className:"flex items-center gap-1 text-sm text-muted-foreground",children:[f,g,L]}),e[26]=L,e[27]=f,e[28]=g,e[29]=w):w=e[29],w}function B2(t){const e=B.c(8),{currentIndex:s,total:n,onPrev:i,onNext:o,extraLeft:a}=t;let l;e[0]!==s||e[1]!==o||e[2]!==i||e[3]!==n?(l=r.jsx(R8,{current:s,total:n,onPrev:i,onNext:o}),e[0]=s,e[1]=o,e[2]=i,e[3]=n,e[4]=l):l=e[4];let c;return e[5]!==a||e[6]!==l?(c=r.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 D8(t){const e=B.c(17),{isStreaming:s,isAllAnswered:n,isCurrentAnswered:i,onAdvanceOrSubmit:o,submitLabel:a,nextLabel:l}=t,h=n?a===void 0?"Submit":a:l===void 0?"Next":l,u=n?s:!i,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=ie("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=r.jsx(le,{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 b;e[10]!==v?(b=r.jsx(Ke,{asChild:!0,children:v}),e[10]=v,e[11]=b):b=e[11];let _;e[12]!==f?(_=r.jsx(Ue,{children:f}),e[12]=f,e[13]=_):_=e[13];let y;return e[14]!==b||e[15]!==_?(y=r.jsxs(He,{children:[b,_]}),e[14]=b,e[15]=_,e[16]=y):y=e[16],y}function F2(t,e,s){return t.findIndex(n=>e(n)===s)}function sh(t,e,s,n){return t.length===0?!1:t.every(i=>n(s[e(i)]))}function nh(t,e,s,n,i){if(t.length===0)return null;const o=F2(t,e,i);for(let a=1;a<=t.length;a++){const l=t[(o+a)%t.length];if(!l)continue;const c=e(l);if(c!==i&&!n(s[c]))return c}return null}function I8(t){return!t.isStreaming&&t.allAnswered}function z2(t){const{parts:e,partKey:s,schema:n,defaultValues:i,isStreaming:o,hasAnswer:a,onSubmit:l}=t,c=e[0]?s(e[0]):"",[d,h]=A.useState(c),[u,f]=A.useState(!1),m=U0({resolver:cm(n),defaultValues:i}),p=m.watch(),g=F2(e,s,d),x=g>=0?e[g]:void 0,v=a(p[d]),b=sh(e,s,p,a),_=I8({isStreaming:o,allAnswered:b}),y=()=>{if(g>0){const V=e[g-1];V&&h(s(V))}},L=()=>{if(g>=0&&g<e.length-1){const V=e[g+1];V&&h(s(V))}},w=()=>{const V=m.getValues(),E=nh(e,s,V,a,d);E&&h(E)},j=()=>{m.handleSubmit(V=>{const E=V;for(const T of e)l(T,E[s(T)])})()},S=A.useRef(j);S.current=j;const C=()=>{_&&(f(!1),S.current())},N=()=>{const V=m.getValues();if(sh(e,s,V,a)){if(o){f(!0);return}f(!1),S.current()}else{const E=nh(e,s,V,a,d);E&&h(E)}};return A.useEffect(()=>{if(u&&!o){if(!b){f(!1);return}f(!1),S.current()}},[u,o,b]),{form:m,activeKey:d,setActiveKey:h,currentIndex:g,currentPart:x,isCurrentAnswered:v,isAllAnswered:b,canSubmit:_,goPrev:y,goNext:L,advanceToNextUnanswered:w,submit:C,submitOrAdvance:N}}const K2="chat.approval.defaultDenyReason";function U2(t){const e=B.c(13),{onYolo:s}=t,n=re(),[i,o]=ii();let a;e[0]!==s||e[1]!==i||e[2]!==o?(a=m=>{const p=m,g=i.toolApprovalLevel??"readonly";o({...i,toolApprovalLevel:p}),p==="auto"&&s(g)},e[0]=s,e[1]=i,e[2]=o,e[3]=a):a=e[3];const l=a,c=i.toolApprovalLevel;let d;e[4]===Symbol.for("react.memo_cache_sentinel")?(d=r.jsx(Jt,{size:"xs",className:"text-xs text-muted-foreground border-border/60 bg-transparent hover:bg-accent/60 h-7 gap-1",onClick:M8,children:r.jsx(as,{})}),e[4]=d):d=e[4];let h;e[5]!==n?(h=ro.map(m=>r.jsx(vt,{value:m.value,children:n(m.labelKey)},m.value)),e[5]=n,e[6]=h):h=e[6];let u;e[7]!==h?(u=r.jsx(Xt,{children:h}),e[7]=h,e[8]=u):u=e[8];let f;return e[9]!==l||e[10]!==i.toolApprovalLevel||e[11]!==u?(f=r.jsxs(Qt,{value:c,onValueChange:l,children:[d,u]}),e[9]=l,e[10]=i.toolApprovalLevel,e[11]=u,e[12]=f):f=e[12],f}function M8(t){return t.stopPropagation()}function H2(t){const e=B.c(8),{input:s}=t,n=re();if(s==null){let a;e[0]!==n?(a=n("chat.approval.noInput"),e[0]=n,e[1]=a):a=e[1];let l;return e[2]!==a?(l=r.jsx("div",{className:"px-4 text-xs text-muted-foreground",children:a}),e[2]=a,e[3]=l):l=e[3],l}let i;try{let a;e[4]!==s?(a=JSON.stringify(s,null,2),e[4]=s,e[5]=a):a=e[5],i=a}catch{i=String(s)}let o;return e[6]!==i?(o=r.jsx("div",{className:"px-4",children:r.jsx("pre",{className:"text-xs font-mono text-muted-foreground/70 whitespace-pre-wrap wrap-break-word max-h-32 overflow-y-auto rounded-md bg-muted/30 px-3 py-2",children:i})}),e[6]=i,e[7]=o):o=e[7],o}function O8(t){const e=B.c(38),{approval:s,onRespond:n}=t,i=re(),[o]=ii(),a=o.toolApprovalLevel??"readonly";let l;e[0]!==s.approvalId||e[1]!==a||e[2]!==n||e[3]!==i?(l=()=>n(s.approvalId,!1,i(K2),a),e[0]=s.approvalId,e[1]=a,e[2]=n,e[3]=i,e[4]=l):l=e[4];const c=l;let d;e[5]!==s.approvalId||e[6]!==a||e[7]!==n?(d=()=>n(s.approvalId,!0,void 0,a),e[5]=s.approvalId,e[6]=a,e[7]=n,e[8]=d):d=e[8];const h=d;let u;e[9]!==s.approvalId||e[10]!==n?(u=C=>n(s.approvalId,!0,void 0,C),e[9]=s.approvalId,e[10]=n,e[11]=u):u=e[11];const f=u;let m;e[12]!==f?(m=r.jsx("div",{className:"flex items-center gap-2",children:r.jsx(U2,{onYolo:f})}),e[12]=f,e[13]=m):m=e[13];const p=m;let g;e[14]!==i?(g=i("chat.approval.denyButton"),e[14]=i,e[15]=g):g=e[15];let x;e[16]!==c||e[17]!==g?(x=r.jsx(le,{type:"button",variant:"ghost",size:"sm",className:"h-7 px-2.5 text-xs text-muted-foreground [@media(hover:hover)]:hover:text-foreground active:scale-[0.97] transition-transform",onClick:c,children:g}),e[16]=c,e[17]=g,e[18]=x):x=e[18];let v;e[19]!==i?(v=i("chat.approval.acceptButton"),e[19]=i,e[20]=v):v=e[20];let b;e[21]!==h||e[22]!==v?(b=r.jsx(le,{type:"button",size:"sm",className:"h-7 px-2.5 text-xs active:scale-[0.97] transition-transform",onClick:h,children:v}),e[21]=h,e[22]=v,e[23]=b):b=e[23];let _;e[24]!==x||e[25]!==b?(_=r.jsxs(r.Fragment,{children:[x,b]}),e[24]=x,e[25]=b,e[26]=_):_=e[26];const y=_;let L;e[27]===Symbol.for("react.memo_cache_sentinel")?(L=r.jsx(Yl,{size:14}),e[27]=L):L=e[27];let w;e[28]!==i?(w=i("chat.approval.needsApproval"),e[28]=i,e[29]=w):w=e[29];let j;e[30]!==s.input?(j=r.jsx(H2,{input:s.input}),e[30]=s.input,e[31]=j):j=e[31];let S;return e[32]!==s.friendlyName||e[33]!==p||e[34]!==y||e[35]!==w||e[36]!==j?(S=r.jsx(ti,{icon:L,label:w,title:s.friendlyName,defaultExpanded:!0,footerLeft:p,footerRight:y,children:j}),e[32]=s.friendlyName,e[33]=p,e[34]=y,e[35]=w,e[36]=j,e[37]=S):S=e[37],S}const $8=G5(rs(),tn({approved:Y5().optional(),levelOverride:K0(["auto","readonly"]).optional()}));function B8(t){const e=B.c(46),{approvals:s,isStreaming:n,onRespond:i}=t,o=re(),[a]=ii(),l=a.toolApprovalLevel??"readonly";let c;e[0]!==s?(c=Object.fromEntries(s.map(K8)),e[0]=s,e[1]=c):c=e[1];const d=c;let h;e[2]!==l||e[3]!==i||e[4]!==o?(h=(E,T)=>{const k=T;typeof k?.approved=="boolean"&&i(E.approvalId,k.approved,k.approved===!1?o(K2):void 0,k.levelOverride??l)},e[2]=l,e[3]=i,e[4]=o,e[5]=h):h=e[5];let u;e[6]!==s||e[7]!==d||e[8]!==n||e[9]!==h?(u={parts:s,partKey:z8,schema:$8,defaultValues:d,isStreaming:n,hasAnswer:F8,onSubmit:h},e[6]=s,e[7]=d,e[8]=n,e[9]=h,e[10]=u):u=e[10];const f=z2(u);let m;e[11]!==s||e[12]!==f?(m=E=>{f.form.reset(Object.fromEntries(s.map(T=>[T.approvalId,{approved:!0,levelOverride:E}]))),f.submitOrAdvance()},e[11]=s,e[12]=f,e[13]=m):m=e[13];const p=m,g=f.currentPart,x=f.form;let v;e[14]!==f?(v=E=>{E.preventDefault(),f.submit()},e[14]=f,e[15]=v):v=e[15];let b;e[16]===Symbol.for("react.memo_cache_sentinel")?(b=r.jsx(Yl,{size:14}),e[16]=b):b=e[16];let _;e[17]!==s.length||e[18]!==o?(_=o("chat.approval.batchedLabel",{count:s.length}),e[17]=s.length,e[18]=o,e[19]=_):_=e[19];const y=g?.friendlyName??"";let L;e[20]!==p?(L=r.jsx(U2,{onYolo:p}),e[20]=p,e[21]=L):L=e[21];let w;e[22]!==s.length||e[23]!==f.currentIndex||e[24]!==f.goNext||e[25]!==f.goPrev||e[26]!==L?(w=r.jsx(B2,{currentIndex:f.currentIndex,total:s.length,onPrev:f.goPrev,onNext:f.goNext,extraLeft:L}),e[22]=s.length,e[23]=f.currentIndex,e[24]=f.goNext,e[25]=f.goPrev,e[26]=L,e[27]=w):w=e[27];let j;e[28]!==g||e[29]!==f.form.control||e[30]!==f.submitOrAdvance?(j=g?r.jsx(U8,{approvalId:g.approvalId,control:f.form.control,onChange:f.submitOrAdvance}):null,e[28]=g,e[29]=f.form.control,e[30]=f.submitOrAdvance,e[31]=j):j=e[31];let S;e[32]!==g?(S=g?r.jsx(H2,{input:g.input}):null,e[32]=g,e[33]=S):S=e[33];let C;e[34]!==w||e[35]!==j||e[36]!==S||e[37]!==_||e[38]!==y?(C=r.jsx(ti,{icon:b,label:_,title:y,defaultExpanded:!0,footerLeft:w,footerRight:j,children:S}),e[34]=w,e[35]=j,e[36]=S,e[37]=_,e[38]=y,e[39]=C):C=e[39];let N;e[40]!==C||e[41]!==v?(N=r.jsx("form",{onSubmit:v,children:C}),e[40]=C,e[41]=v,e[42]=N):N=e[42];let V;return e[43]!==f.form||e[44]!==N?(V=r.jsx(Pd,{...x,children:N}),e[43]=f.form,e[44]=N,e[45]=V):V=e[45],V}function F8(t){return typeof t?.approved=="boolean"}function z8(t){return t.approvalId}function K8(t){return[t.approvalId,{approved:void 0}]}function U8(t){const e=B.c(7),{approvalId:s,control:n,onChange:i}=t,o=re(),a=`${s}.approved`;let l;e[0]!==i||e[1]!==o?(l=d=>{const{field:h}=d,u=h.value===!0,f=h.value===!1;return r.jsxs(r.Fragment,{children:[r.jsx(le,{type:"button",variant:f?"secondary":"ghost",size:"sm",className:"h-7 px-2.5 text-xs",onClick:()=>{h.onChange(!1),i()},"aria-pressed":f,children:o("chat.approval.denyButton")}),r.jsx(le,{type:"button",variant:u?"default":"outline",size:"sm",className:"h-7 px-2.5 text-xs",onClick:()=>{h.onChange(!0),i()},"aria-pressed":u,children:o("chat.approval.acceptButton")})]})},e[0]=i,e[1]=o,e[2]=l):l=e[2];let c;return e[3]!==n||e[4]!==a||e[5]!==l?(c=r.jsx(ys,{control:n,name:a,render:l}),e[3]=n,e[4]=a,e[5]=l,e[6]=c):c=e[6],c}function H8(){const t=B.c(5),e=re();let s;t[0]===Symbol.for("react.memo_cache_sentinel")?(s=r.jsx(Yl,{className:"size-5 text-muted-foreground shimmer"}),t[0]=s):s=t[0];let n;t[1]!==e?(n=e("chat.approval.preparingRequest"),t[1]=e,t[2]=n):n=t[2];let i;return t[3]!==n?(i=r.jsxs("div",{className:"flex items-center gap-2 p-4 border border-dashed rounded-lg bg-accent/50 w-[calc(100%-16px)] max-w-[640px] mx-auto mb-2",children:[s,r.jsx("span",{className:"text-sm text-muted-foreground shimmer",children:n})]}),t[3]=n,t[4]=i):i=t[4],i}function W8(t){const e=B.c(8),{approvals:s,isStreaming:n,onRespond:i}=t;if(n&&s.length===0){let a;return e[0]===Symbol.for("react.memo_cache_sentinel")?(a=r.jsx(H8,{}),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]!==i||e[2]!==a?(l=r.jsx(O8,{approval:a,onRespond:i}),e[1]=i,e[2]=a,e[3]=l):l=e[3],l}let o;return e[4]!==s||e[5]!==n||e[6]!==i?(o=r.jsx(B8,{approvals:s,isStreaming:n,onRespond:i}),e[4]=s,e[5]=n,e[6]=i,e[7]=o):o=e[7],o}function q8(t){const e=B.c(28),{plan:s,onApprove:n,onDismiss:i}=t,o=re();let a;e[0]!==n||e[1]!==s.plan?(a=()=>{n(s.plan)},e[0]=n,e[1]=s.plan,e[2]=a):a=e[2];const l=a;let c;e[3]!==o?(c=o("chat.proposePlan.keepIterating"),e[3]=o,e[4]=c):c=e[4];let d;e[5]!==i||e[6]!==c?(d=r.jsx(le,{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:i,children:c}),e[5]=i,e[6]=c,e[7]=d):d=e[7];let h;e[8]!==o?(h=o("chat.proposePlan.letsGo"),e[8]=o,e[9]=h):h=e[9];let u;e[10]!==l||e[11]!==h?(u=r.jsx(le,{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:l,children:h}),e[10]=l,e[11]=h,e[12]=u):u=e[12];let f;e[13]!==d||e[14]!==u?(f=r.jsxs(r.Fragment,{children:[d,u]}),e[13]=d,e[14]=u,e[15]=f):f=e[15];const m=f;let p;e[16]===Symbol.for("react.memo_cache_sentinel")?(p=r.jsx($m,{size:14}),e[16]=p):p=e[16];let g;e[17]!==o?(g=o("chat.proposePlan.planReady"),e[17]=o,e[18]=g):g=e[18];let x;e[19]!==o?(x=o("chat.proposePlan.implementationPlan"),e[19]=o,e[20]=x):x=e[20];let v;e[21]!==s.plan?(v=r.jsx("div",{className:"px-4 max-h-64 overflow-y-auto",children:r.jsx("div",{className:"prose prose-sm max-w-none text-sm",children:r.jsx(Ex,{id:"plan-preview",part:{type:"text",text:s.plan}})})}),e[21]=s.plan,e[22]=v):v=e[22];let b;return e[23]!==m||e[24]!==v||e[25]!==g||e[26]!==x?(b=r.jsx(ti,{icon:p,label:g,title:x,defaultExpanded:!0,footerRight:m,children:v}),e[23]=m,e[24]=v,e[25]=g,e[26]=x,e[27]=b):b=e[27],b}function G8(t){const e=B.c(6),{plans:s,onApprove:n,onDismiss:i}=t;let o;e[0]!==s?(o=M2(s),e[0]=s,e[1]=o):o=e[1];const a=o;if(!a)return null;let l;return e[2]!==a||e[3]!==n||e[4]!==i?(l=r.jsx(q8,{plan:a,onApprove:n,onDismiss:i}),e[2]=a,e[3]=n,e[4]=i,e[5]=l):l=e[5],l}function W2(t){return t?"response"in t?t.response:t.option??t.draft:""}const ih=tn({response:rs().min(1,"Response is required")}),Y8=tn({option:rs().nullable(),draft:rs()}).refine(t=>(t.option??t.draft).length>0,{message:"Please select or enter an option"}),J8=tn({response:K0(["yes","no"])});function X8(t){switch(t.type){case"text":return ih;case"choice":return Y8;case"confirm":return J8;default:return ih}}function Q8(t){const e={};for(const s of t)e[s.toolCallId]=X8(s.input);return tn(e)}function Z8(t){const e=B.c(7),{control:s,name:n,placeholder:i}=t,o=re();let a;e[0]!==i||e[1]!==o?(a=c=>{const{field:d}=c,h=d.value??"";return r.jsxs(o9,{children:[r.jsx(a9,{children:r.jsx("div",{className:"px-2",children:r.jsxs("div",{className:"flex items-center gap-3 px-2 py-3 rounded-lg bg-accent/50",children:[r.jsx("span",{className:"flex items-center justify-center size-6 rounded-md bg-muted shrink-0",children:r.jsx(Q0,{size:16,className:"text-muted-foreground"})}),r.jsx("input",{...d,value:h,type:"text",placeholder:i||o("chat.userAskQuestion.typeResponse"),autoFocus:!0,"aria-label":o("chat.userAskQuestion.textResponseInputAriaLabel"),className:"flex-1 text-sm bg-transparent outline-none placeholder:text-foreground/25 text-foreground min-w-0"})]})})}),r.jsx(l9,{})]})},e[0]=i,e[1]=o,e[2]=a):a=e[2];let l;return e[3]!==s||e[4]!==n||e[5]!==a?(l=r.jsx(s2,{control:s,name:n,render:a}),e[3]=s,e[4]=n,e[5]=a,e[6]=l):l=e[6],l}function q2(t,e){const s=B.c(4);let n,i;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)},i=[t,e],s[0]=t,s[1]=e,s[2]=n,s[3]=i):(n=s[2],i=s[3]),A.useEffect(n,i)}function ey(t){const e=B.c(51),{control:s,name:n,options:i}=t,o=re(),a=`${n}.option`;let l;e[0]!==s||e[1]!==a?(l={control:s,name:a,defaultValue:null},e[0]=s,e[1]=a,e[2]=l):l=e[2];const{field:c}=Ku(l),d=`${n}.draft`;let h;e[3]!==s||e[4]!==d?(h={control:s,name:d,defaultValue:""},e[3]=s,e[4]=d,e[5]=h):h=e[5];const{field:u}=Ku(h),f=c.value,m=u.value??"";let p;if(e[6]!==c||e[7]!==i?(p=P=>{const D=i[P];D!=null&&c.onChange(D)},e[6]=c,e[7]=i,e[8]=p):p=e[8],q2(i.length,p),i.length===0)return null;const g=f===null;let x;e[9]!==o?(x=o("chat.userAskQuestion.choiceOptionsAriaLabel"),e[9]=o,e[10]=x):x=e[10];let v;if(e[11]!==c||e[12]!==f||e[13]!==i||e[14]!==o){let P;e[16]!==c||e[17]!==f||e[18]!==o?(P=(D,I)=>{const M=f===D;return r.jsxs("button",{type:"button",onClick:()=>c.onChange(D),className:ie("flex items-start gap-3 px-2 py-3 rounded-lg text-left transition-colors w-full",M&&"bg-accent/50",!M&&"hover:bg-accent/30"),"aria-label":o("chat.userAskQuestion.selectOption",{option:D}),children:[r.jsx("span",{className:ie("flex items-center justify-center size-6 rounded-md text-sm shrink-0 mt-0.5",M?"bg-chart-1 text-white":"bg-muted text-foreground"),children:I+1}),r.jsx("span",{className:"text-sm text-foreground min-w-0 break-words",children:D})]},`${I}-${D}`)},e[16]=c,e[17]=f,e[18]=o,e[19]=P):P=e[19],v=i.map(P),e[11]=c,e[12]=f,e[13]=i,e[14]=o,e[15]=v}else v=e[15];const b=g&&"bg-accent/50",_=!g&&"hover:bg-accent/30";let y;e[20]!==b||e[21]!==_?(y=ie("flex items-center gap-3 px-2 py-3 rounded-lg transition-colors w-full cursor-text",b,_),e[20]=b,e[21]=_,e[22]=y):y=e[22];let L;e[23]===Symbol.for("react.memo_cache_sentinel")?(L=r.jsx("span",{className:"flex items-center justify-center size-6 rounded-md bg-muted shrink-0",children:r.jsx(Q0,{size:16,className:"text-muted-foreground"})}),e[23]=L):L=e[23];const w=g?m:"";let j;e[24]!==u||e[25]!==c||e[26]!==f?(j=P=>{u.onChange(P.target.value),f!==null&&c.onChange(null)},e[24]=u,e[25]=c,e[26]=f,e[27]=j):j=e[27];let S;e[28]!==c||e[29]!==f?(S=()=>{f!==null&&c.onChange(null)},e[28]=c,e[29]=f,e[30]=S):S=e[30];let C;e[31]!==o?(C=o("chat.userAskQuestion.somethingElsePlaceholder"),e[31]=o,e[32]=C):C=e[32];let N;e[33]!==o?(N=o("chat.userAskQuestion.customChoiceInputAriaLabel"),e[33]=o,e[34]=N):N=e[34];let V;e[35]!==w||e[36]!==j||e[37]!==S||e[38]!==C||e[39]!==N?(V=r.jsx("input",{type:"text",value:w,onChange:j,onFocus:S,placeholder:C,"aria-label":N,className:"flex-1 text-sm bg-transparent outline-none placeholder:text-foreground/25 text-foreground min-w-0"}),e[35]=w,e[36]=j,e[37]=S,e[38]=C,e[39]=N,e[40]=V):V=e[40];let E;e[41]!==y||e[42]!==V?(E=r.jsxs("label",{className:y,children:[L,V]}),e[41]=y,e[42]=V,e[43]=E):E=e[43];let T;e[44]!==E||e[45]!==x||e[46]!==v?(T=r.jsx(a9,{children:r.jsxs("div",{className:"flex flex-col px-2",role:"group","aria-label":x,children:[v,E]})}),e[44]=E,e[45]=x,e[46]=v,e[47]=T):T=e[47];let k;e[48]===Symbol.for("react.memo_cache_sentinel")?(k=r.jsx(l9,{}),e[48]=k):k=e[48];let R;return e[49]!==T?(R=r.jsxs(o9,{children:[T,k]}),e[49]=T,e[50]=R):R=e[50],R}function ty(t){const e=B.c(8),{control:s,name:n}=t,i=re();let o;e[0]===Symbol.for("react.memo_cache_sentinel")?(o=["yes","no"],e[0]=o):o=e[0];const a=o,l=A.useRef(null);let c;e[1]===Symbol.for("react.memo_cache_sentinel")?(c=u=>{l.current?.onChange(a[u]??"")},e[1]=c):c=e[1],q2(a.length,c);let d;e[2]!==i?(d=u=>{const{field:f}=u;return l.current=f,r.jsxs(o9,{children:[r.jsx(a9,{children:r.jsx("div",{className:"flex gap-2 px-2",role:"group","aria-label":i("chat.userAskQuestion.confirmationOptionsAriaLabel"),children:a.map(m=>{const p=f.value===m;return r.jsxs("button",{type:"button",onClick:()=>f.onChange(m),className:ie("flex items-center gap-3 px-4 py-3 rounded-lg text-left transition-colors flex-1",p&&"bg-accent/50",!p&&"hover:bg-accent/30"),"aria-label":i("chat.userAskQuestion.confirmValue",{value:i(`chat.userAskQuestion.confirm${m==="yes"?"Yes":"No"}`)}),children:[r.jsx("span",{className:ie("flex items-center justify-center size-6 rounded-md text-sm shrink-0",p?"bg-chart-1 text-white":"bg-muted text-foreground"),children:m==="yes"?1:2}),r.jsx("span",{className:"text-sm text-foreground capitalize",children:i(`chat.userAskQuestion.confirm${m==="yes"?"Yes":"No"}`)})]},m)})})}),r.jsx(l9,{})]})},e[2]=i,e[3]=d):d=e[3];let h;return e[4]!==s||e[5]!==n||e[6]!==d?(h=r.jsx(s2,{control:s,name:n,render:d}),e[4]=s,e[5]=n,e[6]=d,e[7]=h):h=e[7],h}function rh(t){const e=B.c(13),{input:s,control:n,toolCallId:i}=t;switch(s.type){case"text":{const o=`${i}.response`;let a;return e[0]!==n||e[1]!==s.default||e[2]!==o?(a=r.jsx(Z8,{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]!==i?(l=r.jsx(ey,{control:n,name:i,options:a}),e[6]=n,e[7]=a,e[8]=i,e[9]=l):l=e[9],l}case"confirm":{const o=`${i}.response`;let a;return e[10]!==n||e[11]!==o?(a=r.jsx(ty,{control:n,name:o}),e[10]=n,e[11]=o,e[12]=a):a=e[12],a}default:return null}}function sy(t){const e=B.c(91),{parts:s,isStreaming:n,onSubmit:i}=t;let o;e[0]!==s?(o=Q8(s.map(oy)),e[0]=s,e[1]=o):o=e[1];const a=o;let l;e[2]!==s?(l=Object.fromEntries(s.map(ry)),e[2]=s,e[3]=l):l=e[3];const c=l;let d;e[4]!==i?(d=(F,$)=>{const z=W2($);z&&i(F,z)},e[4]=i,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:iy,schema:a,defaultValues:c,isStreaming:n,hasAnswer:ny,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=z2(h),f=u.currentPart,m=re();let p;e[12]!==f||e[13]!==u||e[14]!==m?(p=()=>{const F=f;if(!F)return;const $=m("chat.userAskQuestion.skipMessage"),z=F.toolCallId;F.input?.type==="choice"?(u.form.setValue(`${z}.option`,null),u.form.setValue(`${z}.draft`,$)):u.form.setValue(`${z}.response`,$),u.advanceToNextUnanswered()},e[12]=f,e[13]=u,e[14]=m,e[15]=p):p=e[15];const g=p;let x;e[16]!==u.currentIndex||e[17]!==u.goNext||e[18]!==u.goPrev||e[19]!==s.length?(x=r.jsx(B2,{currentIndex:u.currentIndex,total:s.length,onPrev:u.goPrev,onNext:u.goNext}),e[16]=u.currentIndex,e[17]=u.goNext,e[18]=u.goPrev,e[19]=s.length,e[20]=x):x=e[20];const v=x;let b;e[21]!==m?(b=m("chat.userAskQuestion.skip"),e[21]=m,e[22]=b):b=e[22];let _;e[23]!==g||e[24]!==b?(_=r.jsx(le,{type:"button",variant:"outline",size:"sm",onClick:g,className:"h-7",children:b}),e[23]=g,e[24]=b,e[25]=_):_=e[25];let y;e[26]!==u.isAllAnswered||e[27]!==u.isCurrentAnswered||e[28]!==u.submitOrAdvance||e[29]!==n?(y=r.jsx(D8,{isStreaming:n,isAllAnswered:u.isAllAnswered,isCurrentAnswered:u.isCurrentAnswered,onAdvanceOrSubmit:u.submitOrAdvance}),e[26]=u.isAllAnswered,e[27]=u.isCurrentAnswered,e[28]=u.submitOrAdvance,e[29]=n,e[30]=y):y=e[30];let L;e[31]!==_||e[32]!==y?(L=r.jsxs(r.Fragment,{children:[_,y]}),e[31]=_,e[32]=y,e[33]=L):L=e[33];const w=L;if(s.length===1){const F=s[0];if(!F?.input)return null;const $=u.form;let z;e[34]!==u?(z=Z=>{Z.preventDefault(),u.submit()},e[34]=u,e[35]=z):z=e[35];let K;e[36]===Symbol.for("react.memo_cache_sentinel")?(K=r.jsx(Rd,{size:14}),e[36]=K):K=e[36];let X;e[37]!==m?(X=m("chat.userAskQuestion.questionPending"),e[37]=m,e[38]=X):X=e[38];let J;e[39]!==F.input?.prompt||e[40]!==m?(J=F.input?.prompt??m("chat.userAskQuestion.question"),e[39]=F.input?.prompt,e[40]=m,e[41]=J):J=e[41];const H=F.input;let W;e[42]!==u.form.control||e[43]!==F.toolCallId||e[44]!==H?(W=r.jsx(rh,{input:H,control:u.form.control,toolCallId:F.toolCallId}),e[42]=u.form.control,e[43]=F.toolCallId,e[44]=H,e[45]=W):W=e[45];let U;e[46]!==w||e[47]!==X||e[48]!==J||e[49]!==W?(U=r.jsx(ti,{icon:K,label:X,title:J,defaultExpanded:!0,footerRight:w,children:W}),e[46]=w,e[47]=X,e[48]=J,e[49]=W,e[50]=U):U=e[50];let Q;e[51]!==z||e[52]!==U?(Q=r.jsx("form",{onSubmit:z,autoComplete:"off",children:U}),e[51]=z,e[52]=U,e[53]=Q):Q=e[53];let q;return e[54]!==u.form||e[55]!==Q?(q=r.jsx(Pd,{...$,children:Q}),e[54]=u.form,e[55]=Q,e[56]=q):q=e[56],q}const j=u.form;let S;e[57]!==u?(S=F=>{F.preventDefault(),u.submit()},e[57]=u,e[58]=S):S=e[58];let C;e[59]===Symbol.for("react.memo_cache_sentinel")?(C=r.jsx(Rd,{size:14}),e[59]=C):C=e[59];let N;e[60]!==m?(N=m("chat.userAskQuestion.questionPending"),e[60]=m,e[61]=N):N=e[61];const V=u.currentIndex+1;let E;e[62]!==s.length||e[63]!==m||e[64]!==V?(E=m("chat.userAskQuestion.questionCount",{current:V,total:s.length}),e[62]=s.length,e[63]=m,e[64]=V,e[65]=E):E=e[65];let T;e[66]!==f?.input?.prompt||e[67]!==m?(T=f?.input?.prompt??m("chat.userAskQuestion.question"),e[66]=f?.input?.prompt,e[67]=m,e[68]=T):T=e[68];const k=u.activeKey,R=u.setActiveKey;let P;if(e[69]!==u.form||e[70]!==s){let F;e[72]!==u.form?(F=$=>r.jsx(yi,{value:$.toolCallId,className:"mt-0",children:r.jsx(rh,{input:$.input,control:u.form.control,toolCallId:$.toolCallId})},$.toolCallId),e[72]=u.form,e[73]=F):F=e[73],P=s.map(F),e[69]=u.form,e[70]=s,e[71]=P}else P=e[71];let D;e[74]!==u.activeKey||e[75]!==u.setActiveKey||e[76]!==P?(D=r.jsx(Vr,{value:k,onValueChange:R,children:P}),e[74]=u.activeKey,e[75]=u.setActiveKey,e[76]=P,e[77]=D):D=e[77];let I;e[78]!==v||e[79]!==w||e[80]!==N||e[81]!==E||e[82]!==T||e[83]!==D?(I=r.jsx(ti,{icon:C,label:N,count:E,title:T,defaultExpanded:!0,footerLeft:v,footerRight:w,children:D}),e[78]=v,e[79]=w,e[80]=N,e[81]=E,e[82]=T,e[83]=D,e[84]=I):I=e[84];let M;e[85]!==S||e[86]!==I?(M=r.jsx("form",{onSubmit:S,autoComplete:"off",children:I}),e[85]=S,e[86]=I,e[87]=M):M=e[87];let O;return e[88]!==u.form||e[89]!==M?(O=r.jsx(Pd,{...j,children:M}),e[88]=u.form,e[89]=M,e[90]=O):O=e[90],O}function ny(t){return!!W2(t)}function iy(t){return t.toolCallId}function ry(t){return t.input?.type==="choice"?[t.toolCallId,{option:null,draft:""}]:[t.toolCallId,{response:""}]}function oy(t){return{toolCallId:t.toolCallId,input:t.input}}function ay(){const t=B.c(5),e=re();let s;t[0]===Symbol.for("react.memo_cache_sentinel")?(s=r.jsx(Rd,{className:"size-5 text-muted-foreground shimmer"}),t[0]=s):s=t[0];let n;t[1]!==e?(n=e("chat.userAskQuestion.preparingQuestion"),t[1]=e,t[2]=n):n=t[2];let i;return t[3]!==n?(i=r.jsxs("div",{className:"flex items-center gap-2 p-4 border border-dashed rounded-lg bg-accent/50 w-[calc(100%-16px)] max-w-[640px] mx-auto mb-2",children:[s,r.jsx("span",{className:"text-sm text-muted-foreground shimmer",children:n})]}),t[3]=n,t[4]=i):i=t[4],i}function G2(t){const e=B.c(7),{userAskParts:s,isStreaming:n,onSubmit:i}=t;let o;e[0]!==s?(o=s.filter(ly),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=r.jsx(ay,{}),e[2]=c):c=e[2],c}return null}let l;return e[3]!==n||e[4]!==i||e[5]!==a?(l=r.jsx(sy,{parts:a,isStreaming:n,onSubmit:i}),e[3]=n,e[4]=i,e[5]=a,e[6]=l):l=e[6],l}function ly(t){return t.state==="input-available"}function cy(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[i]=e;return i&&e.length===1?{icon:"in_progress",activity:i.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 dy(t){const e=B.c(13),{todos:s}=t;if(s.length===0)return null;let n;e[0]!==s?(n=cy(s),e[0]=s,e[1]=n):n=e[1];const i=n;let o;e[2]!==i.icon?(o=r.jsx(my,{status:i.icon}),e[2]=i.icon,e[3]=o):o=e[3];const a=i.activity,l=i.progress;let c;e[4]!==s?(c=s.map(uy),e[4]=s,e[5]=c):c=e[5];let d;e[6]!==c?(d=r.jsx("ul",{"data-testid":"todos-list",className:"flex flex-col px-2 max-h-[40vh] overflow-y-auto",children:c}),e[6]=c,e[7]=d):d=e[7];let h;return e[8]!==i.activity||e[9]!==i.progress||e[10]!==o||e[11]!==d?(h=r.jsx(ti,{icon:o,label:a,count:l,defaultExpanded:!1,children:d}),e[8]=i.activity,e[9]=i.progress,e[10]=o,e[11]=d,e[12]=h):h=e[12],h}function uy(t,e){return r.jsx(hy,{todo:t},e)}function hy(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=r.jsx(fy,{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=ie("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=r.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=r.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=r.jsxs("li",{className:"flex items-start gap-2.5 px-2 py-1.5 rounded-lg hover:bg-accent/50 transition-colors",children:[a,f]}),e[11]=a,e[12]=f,e[13]=m):m=e[13],m}function fy(t){const e=B.c(4),{status:s}=t,n=s==="completed"?"true":void 0,i=s==="in_progress"?"true":void 0;let o;e[0]===Symbol.for("react.memo_cache_sentinel")?(o=r.jsx("svg",{viewBox:"0 0 21 21",children:r.jsx("path",{d:"M5,10.75 L8.5,14.25 L19.4,2.3 C18.8333333,1.43333333 18.0333333,1 17,1 L4,1 C2.35,1 1,2.35 1,4 L1,17 C1,18.65 2.35,20 4,20 L17,20 C18.65,20 20,18.65 20,17 L20,7.99769186"})}),e[0]=o):o=e[0];let a;return e[1]!==n||e[2]!==i?(a=r.jsx("div",{className:"todo-cb mt-0.5","data-checked":n,"data-progress":i,"aria-hidden":"true",children:o}),e[1]=n,e[2]=i,e[3]=a):a=e[3],a}function my(t){const e=B.c(3),{status:s}=t;if(s==="completed"){let i;return e[0]===Symbol.for("react.memo_cache_sentinel")?(i=r.jsx("span",{"aria-label":"completed",className:"inline-flex items-center justify-center w-3.5 h-3.5 rounded-sm bg-primary",children:r.jsx("svg",{viewBox:"0 0 10 8",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",className:"w-2 h-2 text-primary-foreground",style:{strokeWidth:2},children:r.jsx("path",{d:"M1 4l2.5 2.5L9 1"})})}),e[0]=i):i=e[0],i}if(s==="in_progress"){let i;return e[1]===Symbol.for("react.memo_cache_sentinel")?(i=r.jsx("span",{"aria-label":"in progress",className:"inline-block w-2 h-2 rounded-full bg-primary animate-pulse shrink-0"}),e[1]=i):i=e[1],i}let n;return e[2]===Symbol.for("react.memo_cache_sentinel")?(n=r.jsx("span",{"aria-label":"pending",className:"inline-block w-3.5 h-3.5 rounded-sm border-[1.5px] border-muted-foreground/50 shrink-0"}),e[2]=n):n=e[2],n}const py={usd:[{dollars:10,labelKey:"chat.creditsExhaustedBanner.tierStarter"},{dollars:20,labelKey:"chat.creditsExhaustedBanner.tierPopular"},{dollars:100,labelKey:"chat.creditsExhaustedBanner.tierBestValue"}],brl:[{dollars:50,labelKey:"chat.creditsExhaustedBanner.tierStarter"},{dollars:100,labelKey:"chat.creditsExhaustedBanner.tierPopular"},{dollars:500,labelKey:"chat.creditsExhaustedBanner.tierBestValue"}]},gy=["chat.creditsExhaustedBanner.benefit1","chat.creditsExhaustedBanner.benefit2","chat.creditsExhaustedBanner.benefit3"];function Y2(t){const e=B.c(65),{onDismiss:s}=t,{org:n}=Fe(),i=St(),{decoKeyId:o}=d9(),a=Bs(),l=re(),[c,d]=A.useState(""),[h,u]=A.useState(!1),[f,m]=A.useState("usd"),p=f==="brl"?"R$":"$";let g,x;e[0]!==n.id?(g=()=>{$e("credits_exhausted_shown",{organization_id:n.id})},x=[n.id],e[0]=n.id,e[1]=g,e[2]=x):(g=e[1],x=e[2]),A.useEffect(g,x);let v;e[3]!==f||e[4]!==a?(v=async H=>{const{url:W}=await a.call("AI_PROVIDER_TOPUP_URL",{providerId:"deco",amountCents:H,currency:f});return W},e[3]=f,e[4]=a,e[5]=v):v=e[5];let b;e[6]!==s?(b=H=>{H&&window.open(H,"_blank","noopener,noreferrer"),s?.()},e[6]=s,e[7]=b):b=e[7];let _;e[8]!==l?(_=H=>{ge.error(l("chat.creditsExhaustedBanner.topupError",{error:H.message}))},e[8]=l,e[9]=_):_=e[9];let y;e[10]!==v||e[11]!==b||e[12]!==_?(y={mutationFn:v,onSuccess:b,onError:_},e[10]=v,e[11]=b,e[12]=_,e[13]=y):y=e[13];const{mutate:L,isPending:w}=Ys(y),j=parseFloat(c),S=!isNaN(j)&&j>=1;let C;e[14]!==s?(C=H=>!H&&s?.(),e[14]=s,e[15]=C):C=e[15];let N;e[16]===Symbol.for("react.memo_cache_sentinel")?(N=["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[16]=N):N=e[16];let V;e[17]===Symbol.for("react.memo_cache_sentinel")?(V=r.jsx("div",{className:"absolute inset-x-0 top-0 h-36 pointer-events-none",style:{backgroundImage:N.join(", "),maskImage:"linear-gradient(to bottom, black 0%, transparent 100%)",WebkitMaskImage:"linear-gradient(to bottom, black 0%, transparent 100%)"}}),e[17]=V):V=e[17];let E;e[18]===Symbol.for("react.memo_cache_sentinel")?(E=r.jsx("img",{src:"/logos/deco%20logo.svg",alt:"Deco AI Gateway",className:"size-9 rounded-lg object-contain dark:bg-white dark:p-0.5"}),e[18]=E):E=e[18];let T;e[19]!==l?(T=l("chat.creditsExhaustedBanner.title"),e[19]=l,e[20]=T):T=e[20];let k;e[21]!==T?(k=r.jsx(ps,{className:"text-xl font-semibold tracking-tight",children:T}),e[21]=T,e[22]=k):k=e[22];let R;e[23]!==l?(R=l("chat.creditsExhaustedBanner.description"),e[23]=l,e[24]=R):R=e[24];let P;e[25]!==R?(P=r.jsx(oi,{className:"mt-1.5 text-sm leading-relaxed",children:R}),e[25]=R,e[26]=P):P=e[26];let D;e[27]!==k||e[28]!==P?(D=r.jsxs("div",{className:"relative px-8 pt-8 pb-2 overflow-hidden",children:[V,r.jsxs(ms,{className:"relative gap-4",children:[E,r.jsxs("div",{children:[k,P]})]})]}),e[27]=k,e[28]=P,e[29]=D):D=e[29];let I;e[30]!==f||e[31]!==p||e[32]!==c||e[33]!==j||e[34]!==o||e[35]!==S||e[36]!==w||e[37]!==h||e[38]!==l||e[39]!==L?(I=o&&r.jsxs("div",{className:"px-8 pt-5 pb-6",children:[r.jsx("div",{className:"mb-4",children:r.jsxs(c9,{type:"single",variant:"outline",size:"sm",value:f,onValueChange:H=>{H&&m(H)},children:[r.jsx(Eo,{value:"usd",className:"h-8 px-3 text-xs",children:"USD"}),r.jsx(Eo,{value:"brl",className:"h-8 px-3 text-xs",children:"BRL"})]})}),r.jsxs("div",{className:"rounded-xl border border-border p-5",children:[r.jsx("div",{className:"grid grid-cols-3 gap-2.5",children:py[f].map(H=>{const{dollars:W,labelKey:U}=H;return r.jsxs("button",{type:"button",disabled:w,onClick:()=>{$e("credits_topup_clicked",{amount_cents:W*100,currency:f,tier_label:U,source:"exhausted_banner"}),L(W*100)},className:ie("relative flex flex-col items-center gap-1 py-5 rounded-xl border transition-all duration-150 cursor-pointer","disabled:opacity-50 disabled:cursor-wait","border-border hover:border-foreground/20 hover:bg-muted/30"),children:[r.jsxs("span",{className:"text-2xl font-semibold tabular-nums text-foreground",children:[p,W]}),r.jsx("span",{className:"text-xs text-muted-foreground",children:l(U)})]},W)})}),h?r.jsxs("div",{className:"flex gap-2 mt-3",children:[r.jsxs("div",{className:"relative flex-1",children:[r.jsx("span",{className:"absolute left-3 top-1/2 -translate-y-1/2 text-sm text-muted-foreground select-none",children:p}),r.jsx(rt,{type:"number",min:"1",step:"1",placeholder:l("chat.creditsExhaustedBanner.customPlaceholder"),value:c,onChange:H=>d(H.target.value),className:"h-10 text-sm pl-7",autoFocus:!0})]}),r.jsx(le,{className:"h-10",disabled:!S||w,onClick:()=>{$e("credits_topup_clicked",{amount_cents:Math.round(j*100),currency:f,tier_label:"custom",source:"exhausted_banner"}),L(Math.round(j*100))},children:l(w?"chat.creditsExhaustedBanner.opening":"chat.creditsExhaustedBanner.add")})]}):r.jsx("button",{type:"button",className:"w-full mt-3 text-xs text-muted-foreground hover:text-foreground transition-colors py-1",onClick:()=>u(!0),children:l("chat.creditsExhaustedBanner.enterCustom")})]}),r.jsx("div",{className:"mt-5 rounded-xl bg-muted/25 border border-border/50 p-4 space-y-3",children:gy.map(H=>r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsx("div",{className:"flex items-center justify-center size-5 rounded-full bg-[hsl(var(--chart-1))]/15 shrink-0",children:r.jsx(zt,{size:12,className:"text-[hsl(var(--chart-1))]"})}),r.jsx("span",{className:"text-sm text-foreground/80",children:l(H)})]},H))})]}),e[30]=f,e[31]=p,e[32]=c,e[33]=j,e[34]=o,e[35]=S,e[36]=w,e[37]=h,e[38]=l,e[39]=L,e[40]=I):I=e[40];let M;e[41]!==l?(M=l("chat.creditsExhaustedBanner.dismiss"),e[41]=l,e[42]=M):M=e[42];let O;e[43]!==s||e[44]!==M?(O=r.jsx(le,{variant:"ghost",size:"sm",onClick:s,children:M}),e[43]=s,e[44]=M,e[45]=O):O=e[45];let F;e[46]!==i||e[47]!==s||e[48]!==n.slug?(F=()=>{i({to:"/$org/settings/ai-providers",params:{org:n.slug}}),s?.()},e[46]=i,e[47]=s,e[48]=n.slug,e[49]=F):F=e[49];let $;e[50]!==l?($=l("chat.creditsExhaustedBanner.manageProviders"),e[50]=l,e[51]=$):$=e[51];let z;e[52]!==F||e[53]!==$?(z=r.jsx("button",{type:"button",className:"text-xs text-muted-foreground hover:text-foreground transition-colors",onClick:F,children:$}),e[52]=F,e[53]=$,e[54]=z):z=e[54];let K;e[55]!==O||e[56]!==z?(K=r.jsxs("div",{className:"px-8 py-4 border-t border-border bg-muted/30 flex items-center justify-between",children:[O,z]}),e[55]=O,e[56]=z,e[57]=K):K=e[57];let X;e[58]!==D||e[59]!==I||e[60]!==K?(X=r.jsxs(es,{className:"sm:max-w-[520px] gap-0 p-0 overflow-hidden",onOpenAutoFocus:xy,children:[D,I,K]}),e[58]=D,e[59]=I,e[60]=K,e[61]=X):X=e[61];let J;return e[62]!==X||e[63]!==C?(J=r.jsx(ts,{open:!0,onOpenChange:C,children:X}),e[62]=X,e[63]=C,e[64]=J):J=e[64],J}function xy(t){return t.preventDefault()}function vy(){const t=B.c(24),e=re(),s=Ii(),n=bm(),[i,o]=A.useState(!1);if(!(s?.lockedSandbox==="user-desktop")||!n.ready||n.online)return null;let l;t[0]===Symbol.for("react.memo_cache_sentinel")?(l=r.jsx(Nr,{size:14}),t[0]=l):l=t[0];let c;t[1]!==e?(c=e("chat.desktopOfflineBanner.label"),t[1]=e,t[2]=c):c=t[2];let d;t[3]!==e?(d=e("chat.desktopOfflineBanner.title"),t[3]=e,t[4]=d):d=t[4];let h;t[5]===Symbol.for("react.memo_cache_sentinel")?(h=()=>o(!0),t[5]=h):h=t[5];let u;t[6]!==e?(u=e("chat.desktopOfflineBanner.reconnectButton"),t[6]=e,t[7]=u):u=t[7];let f;t[8]!==u?(f=r.jsx(le,{size:"sm",variant:"outline",className:"h-7 text-xs",onClick:h,children:u}),t[8]=u,t[9]=f):f=t[9];let m;t[10]!==e?(m=e("chat.desktopOfflineBanner.instructions"),t[10]=e,t[11]=m):m=t[11];let p;t[12]!==m?(p=r.jsx("p",{className:"mx-4 text-xs text-muted-foreground",children:m}),t[12]=m,t[13]=p):p=t[13];let g;t[14]!==c||t[15]!==d||t[16]!==f||t[17]!==p?(g=r.jsx(ti,{icon:l,label:c,title:d,defaultExpanded:!0,variant:"warning",footerRight:f,children:p}),t[14]=c,t[15]=d,t[16]=f,t[17]=p,t[18]=g):g=t[18];let x;t[19]!==i?(x=r.jsx(N6,{open:i,onOpenChange:o}),t[19]=i,t[20]=x):x=t[20];let v;return t[21]!==g||t[22]!==x?(v=r.jsxs(r.Fragment,{children:[g,x]}),t[21]=g,t[22]=x,t[23]=v):v=t[23],v}function by(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),i=/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}:i?{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 yy={length:"chat.highlight.warningDescriptionLength","content-filter":"chat.highlight.warningDescriptionContentFilter","tool-calls":"chat.highlight.warningDescriptionToolCalls"};function yl(t){const e=B.c(29),s=re(),{variant:n,onDismiss:i}=t,o=n==="error";let a;e[0]!==o||e[1]!==s?(a=s(o?"chat.highlight.errorOccurred":"chat.highlight.responseIncomplete"),e[0]=o,e[1]=s,e[2]=a):a=e[2];const l=a,c=o?wn:Sr;let d;e[3]!==t.error||e[4]!==t.finishReason||e[5]!==t.variant||e[6]!==s?(d=t.variant==="error"?t.error.message:(()=>{const b=yy[t.finishReason];return b?s(b):s("chat.highlight.responseStoppedUnexpectedly",{reason:t.finishReason})})(),e[3]=t.error,e[4]=t.finishReason,e[5]=t.variant,e[6]=s,e[7]=d):d=e[7];const h=d;let u;e[8]!==o||e[9]!==h?(u=o?by(h):{summary:h,rawDetails:null},e[8]=o,e[9]=h,e[10]=u):u=e[10];const{summary:f,rawDetails:m}=u;let p;e[11]!==c?(p=r.jsx(c,{size:14}),e[11]=c,e[12]=p):p=e[12];let g;e[13]!==o||e[14]!==t.onContinue||e[15]!==t.onFixInChat||e[16]!==s?(g=o?r.jsx(le,{size:"sm",variant:"outline",onClick:t.onFixInChat,className:"h-7 text-xs",children:s("chat.highlight.fixInChat")}):r.jsx(le,{size:"sm",variant:"outline",onClick:t.onContinue,className:"h-7 text-xs",children:s("chat.highlight.continue")}),e[13]=o,e[14]=t.onContinue,e[15]=t.onFixInChat,e[16]=s,e[17]=g):g=e[17];let x;e[18]!==m||e[19]!==s?(x=m?r.jsxs("details",{className:"group mx-4",children:[r.jsxs("summary",{className:"flex cursor-pointer list-none items-center gap-1.5 text-xs text-muted-foreground transition-colors hover:text-foreground [&::-webkit-details-marker]:hidden",children:[r.jsx("svg",{"aria-hidden":"true",className:"size-3 transition-transform group-open:rotate-90",viewBox:"0 0 12 12",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:r.jsx("path",{d:"m4.5 3 3 3-3 3"})}),r.jsx("span",{className:"group-open:hidden",children:s("chat.highlight.showTechnicalDetails")}),r.jsx("span",{className:"hidden group-open:inline",children:s("chat.highlight.hideTechnicalDetails")})]}),r.jsxs("div",{className:"relative mt-2",children:[r.jsx("button",{type:"button",onClick:()=>{navigator.clipboard.writeText(m).then(()=>ge.success(s("chat.highlight.copiedToClipboard"))).catch(()=>ge.error(s("chat.highlight.couldNotCopy")))},"aria-label":s("chat.highlight.copyErrorDetails"),title:s("chat.highlight.copy"),className:"absolute right-1.5 top-1.5 z-10 flex h-6 w-6 items-center justify-center rounded-md bg-background/80 text-muted-foreground backdrop-blur-sm transition-colors hover:bg-background hover:text-foreground",children:r.jsx(Os,{className:"size-3.5"})}),r.jsx("pre",{className:"max-h-40 overflow-auto rounded-md border border-border/60 bg-background px-3 py-2 pr-8 font-mono text-xs text-foreground/80 whitespace-pre-wrap break-all",children:m})]})]}):null,e[18]=m,e[19]=s,e[20]=x):x=e[20];let v;return e[21]!==l||e[22]!==i||e[23]!==f||e[24]!==p||e[25]!==g||e[26]!==x||e[27]!==n?(v=r.jsx(ti,{icon:p,label:l,title:f,defaultExpanded:!0,variant:n,onClose:i,footerRight:g,children:x}),e[21]=l,e[22]=i,e[23]=f,e[24]=p,e[25]=g,e[26]=x,e[27]=n,e[28]=v):v=e[28],v}function ic(){const t=B.c(67),e=re(),{error:s,clearError:n,finishReason:i,clearFinishReason:o,messages:a,isStreaming:l,submit:c,sendMessage:d}=Js(),[h,u]=ii(),{virtualMcpId:f,createTaskWithMessage:m}=Zt(),{chatMode:p,simpleModeTier:g}=Ts();let x;t[0]!==p||t[1]!==g||t[2]!==f?(x=G=>({tier:g,mode:p,toolApprovalLevel:G,agent:f?{id:f}:void 0}),t[0]=p,t[1]=g,t[2]=f,t[3]=x):x=t[3];const v=x;let b;t[4]!==h.toolApprovalLevel?(b=h.toolApprovalLevel??J5(),t[4]=h.toolApprovalLevel,t[5]=b):b=t[5];const _=b,y=a.at(-1),L=y?.role==="assistant"?y.parts:[],w=L.filter(wy),j=O2(L),S=I2(L);let C;t[6]!==s||t[7]!==d||t[8]!==e?(C=()=>{if(s){const te={type:"doc",content:[{type:"paragraph",content:[{type:"text",text:e("chat.highlight.fixInChatMessage",{error:s.message})}]}]};d(te)}},t[6]=s,t[7]=d,t[8]=e,t[9]=C):C=t[9];const N=C;let V;t[10]!==d||t[11]!==e?(V=()=>{const G={type:"doc",content:[{type:"paragraph",content:[{type:"text",text:e("chat.highlight.pleaseContinue")}]}]};d(G)},t[10]=d,t[11]=e,t[12]=V):V=t[12];const E=V;let T;t[13]!==v||t[14]!==_||t[15]!==c?(T=(G,te)=>{c({kind:"toolOutput",toolCallId:G.toolCallId,output:{response:te}},v(_))},t[13]=v,t[14]=_,t[15]=c,t[16]=T):T=t[16];const k=T;let R;t[17]!==m||t[18]!==h||t[19]!==u||t[20]!==e||t[21]!==f?(R=G=>{u({...h,toolApprovalLevel:"auto"}),m({virtualMcpId:f,message:{parts:[{type:"text",text:e("chat.highlight.implementPlanMessage",{plan:G})}]}})},t[17]=m,t[18]=h,t[19]=u,t[20]=e,t[21]=f,t[22]=R):R=t[22];const P=R,D=Sy;let I;t[23]!==v||t[24]!==c?(I=(G,te,se,ne)=>{c({kind:"approval",approvalId:G,approved:te,...se?{reason:se}:{}},v(ne))},t[23]=v,t[24]=c,t[25]=I):I=t[25];const M=I,O=$2();if(O.isCreditExhausted){let G;return t[26]!==n?(G=r.jsx(Y2,{onDismiss:n}),t[26]=n,t[27]=G):G=t[27],G}const{showError:F,showWarning:$,hasApprovals:z}=O,K=w.map(Ly).join("|"),X=M2(j)?.toolCallId??"",J=S.map(_y).join("|");let H;t[28]!==O.todos?(H=r.jsx(dy,{todos:O.todos}),t[28]=O.todos,t[29]=H):H=t[29];let W;t[30]===Symbol.for("react.memo_cache_sentinel")?(W=r.jsx(vy,{}),t[30]=W):W=t[30];let U;t[31]!==n||t[32]!==s||t[33]!==N||t[34]!==F?(U=F&&r.jsx(yl,{variant:"error",error:s,onDismiss:n,onFixInChat:N}),t[31]=n,t[32]=s,t[33]=N,t[34]=F,t[35]=U):U=t[35];let Q;t[36]!==o||t[37]!==i||t[38]!==E||t[39]!==$?(Q=$&&r.jsx(yl,{variant:"warning",finishReason:i,onDismiss:o,onContinue:E}),t[36]=o,t[37]=i,t[38]=E,t[39]=$,t[40]=Q):Q=t[40];let q;t[41]!==J||t[42]!==M||t[43]!==z||t[44]!==l||t[45]!==S?(q=z&&r.jsx(W8,{approvals:S,isStreaming:l,onRespond:M},J),t[41]=J,t[42]=M,t[43]=z,t[44]=l,t[45]=S,t[46]=q):q=t[46];let Z;t[47]!==O.hasPlans||t[48]!==P||t[49]!==D||t[50]!==l||t[51]!==j||t[52]!==X?(Z=O.hasPlans&&r.jsx(G8,{plans:j,isStreaming:l,onApprove:P,onDismiss:D},X),t[47]=O.hasPlans,t[48]=P,t[49]=D,t[50]=l,t[51]=j,t[52]=X,t[53]=Z):Z=t[53];let Y;t[54]!==O.isWaitingForUserInput||t[55]!==k||t[56]!==l||t[57]!==K||t[58]!==w?(Y=O.isWaitingForUserInput&&r.jsx(G2,{userAskParts:w,isStreaming:l,onSubmit:k},K),t[54]=O.isWaitingForUserInput,t[55]=k,t[56]=l,t[57]=K,t[58]=w,t[59]=Y):Y=t[59];let ee;return t[60]!==Q||t[61]!==q||t[62]!==Z||t[63]!==Y||t[64]!==H||t[65]!==U?(ee=r.jsxs("div",{className:"absolute bottom-full left-0 right-0",children:[H,W,U,Q,q,Z,Y]}),t[60]=Q,t[61]=q,t[62]=Z,t[63]=Y,t[64]=H,t[65]=U,t[66]=ee):ee=t[66],ee}function _y(t){return t.approvalId}function Ly(t){return t.toolCallId}function Sy(){document.querySelector("[data-chat-input]")?.focus()}function wy(t){return t.type==="tool-user_ask"}ic.Error=function(e){return r.jsx(yl,{variant:"error",error:e.error,onDismiss:e.onDismiss,onFixInChat:e.onFixInChat})};ic.Warning=function(e){return r.jsx(yl,{variant:"warning",finishReason:e.finishReason,onDismiss:e.onDismiss,onContinue:e.onContinue})};ic.UserAskQuestion=G2;function jy(t){const e=B.c(17),{taskId:s}=t,n=re(),i=ym(s),o=Lx(i),a=Sx(),{stop:l,removeLocalMessage:c}=Js();if(o.length===0)return null;let d;e[0]!==l?(d=()=>{l()},e[0]=l,e[1]=d):d=e[1];let h;e[2]===Symbol.for("react.memo_cache_sentinel")?(h=r.jsx(W0,{size:14}),e[2]=h):h=e[2];let u;e[3]!==d?(u=r.jsx(Ke,{asChild:!0,children:r.jsx(le,{type:"button",variant:"ghost",size:"icon-sm",onClick:d,children:h})}),e[3]=d,e[4]=u):u=e[4];let f;e[5]!==n?(f=n("chat.queueTray.sendNow"),e[5]=n,e[6]=f):f=e[6];let m;e[7]!==f?(m=r.jsx(Ue,{side:"top",children:r.jsx("p",{className:"text-xs",children:f})}),e[7]=f,e[8]=m):m=e[8];let p;e[9]!==u||e[10]!==m?(p=r.jsxs(He,{delayDuration:400,children:[u,m]}),e[9]=u,e[10]=m,e[11]=p):p=e[11];let g;return e[12]!==a||e[13]!==c||e[14]!==n||e[15]!==s?(g=(x,v)=>r.jsxs("div",{className:"group/queuerow flex items-center gap-2 px-3 py-1.5",children:[r.jsx("span",{className:"flex size-[18px] shrink-0 items-center justify-center rounded-full bg-muted text-[10px] font-semibold text-muted-foreground dark:bg-background",children:v+1}),r.jsx("span",{className:"min-w-0 flex-1 truncate text-sm text-foreground",children:x.text}),r.jsx("div",{className:"flex shrink-0 items-center gap-1 opacity-0 transition-opacity group-hover/queuerow:opacity-100",children:r.jsx(le,{type:"button",variant:"ghost",size:"icon-sm",title:n("chat.queueTray.removeFromQueue"),onClick:()=>{a.cancel(s,x.messageId).then(b=>{b&&(wx(s,x.messageId),c(x.messageId))})},children:r.jsx(Pn,{className:"size-3.5"})})})]},x.messageId),e[12]=a,e[13]=c,e[14]=n,e[15]=s,e[16]=g):g=e[16],r.jsxs("div",{className:"mb-1 overflow-hidden rounded-2xl border border-border bg-card dark:bg-muted",children:[r.jsxs("div",{className:"flex items-center justify-between gap-2 border-b border-border py-1.5 pr-2 pl-3 text-xs text-muted-foreground",children:[r.jsx("span",{children:n("chat.queueTray.queuedMessages",{count:o.length})}),p]}),o.map(g)]})}function Cy(t){return(t??"").normalize("NFKD").replace(/[̀-ͯ]/g,"").toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")||"user"}function J2(t){const e=Cy(t),s=Date.now().toString(36).split("").reverse().join("");return`${e}-${s}`}const ky={amp:"&",lt:"<",gt:">",quot:'"',apos:"'",nbsp:" "};function vr(t){return t?t.replace(/&(#x?[0-9a-fA-F]+|[a-zA-Z]+);/g,(e,s)=>{if(s.startsWith("#x")||s.startsWith("#X")){const n=Number.parseInt(s.slice(2),16);return Number.isFinite(n)?String.fromCodePoint(n):e}if(s.startsWith("#")){const n=Number.parseInt(s.slice(1),10);return Number.isFinite(n)?String.fromCodePoint(n):e}return ky[s]??e}):""}const Vy=10080*60*1e3;function Ny({sandboxMap:t,userId:e,rawBranches:s,now:n}){const i=new Map;for(const[u,f]of Object.entries(t??{}))for(const[m,p]of Object.entries(f??{})){let g=i.get(m);g||(g={userIds:new Set,lastActiveAt:0},i.set(m,g)),g.userIds.add(u);for(const x of Object.values(p??{})){const v=x?.createdAt??0;v>g.lastActiveAt&&(g.lastActiveAt=v)}}const o=n-Vy,a=[...i.entries()].filter(([,u])=>u.lastActiveAt>=o).sort((u,f)=>f[1].lastActiveAt-u[1].lastActiveAt).map(([u,f])=>({name:u,source:"recent",contributors:[...f.userIds],lastActiveAt:f.lastActiveAt})),l=new Set(a.map(u=>u.name)),c=new Set(Object.keys(t?.[e]??{})),d=[...c].filter(u=>!l.has(u)).sort().map(u=>({name:u,source:"yours"})),h=s.filter(u=>!c.has(u.name)&&!l.has(u.name)).map(u=>({name:u.name,source:"other",author:u.author??null}));return{recent:a,yours:d,others:h}}const Ha=100;function Ty(t,e,s){const n=e.trim().toLowerCase();return n?(t??[]).some(i=>i.branches.some(o=>typeof o.name=="string"&&!s.has(o.name)&&o.name.toLowerCase().includes(n))):!0}function Ay(t,e){const s=e.trim().toLowerCase();return s?[...t].some(n=>n.toLowerCase().includes(s)):!0}function Ey(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 Py(t){const e=B.c(47),{orgId:s,orgSlug:n,userId:i,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=ht(f);let p;e[4]!==o||e[5]!==s||e[6]!==n||e[7]!==l||e[8]!==c?(p=X5.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 O=>{const{pageParam:F,signal:$}=O,z=Number(F),K=await m.callTool({name:"list_branches",arguments:{owner:l,repo:c,page:z,perPage:Ha}},void 0,{signal:$}),X=Ey(K);return{branches:Array.isArray(X)?X:X.branches??[],default_branch:Array.isArray(X)?null:X.default_branch??null,page:z}},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:$y},e[14]=p,e[15]=g,e[16]=x,e[17]=v):v=e[17];const{data:b,isLoading:_,isError:y,hasNextPage:L,isFetchingNextPage:w,fetchNextPage:j}=o2(v);let S,C,N,V;if(e[18]!==b?.pages||e[19]!==a||e[20]!==i){const O=new Map;for(const $ of b?.pages??[])for(const z of $.branches)typeof z.name=="string"&&O.set(z.name,z);const F=[...O.values()].filter(Oy).map(My);({recent:C,yours:V,others:S}=Ny({sandboxMap:a,userId:i,rawBranches:F,now:Date.now()})),N=new Set([...C,...V].map(Iy)),e[18]=b?.pages,e[19]=a,e[20]=i,e[21]=S,e[22]=C,e[23]=N,e[24]=V}else S=e[21],C=e[22],N=e[23],V=e[24];const E=N;let T;e[25]!==b?.pages?(T=b?.pages.find(Dy)?.default_branch??null,e[25]=b?.pages,e[26]=T):T=e[26];const k=T;let R;e[27]!==b?.pages||e[28]!==j||e[29]!==w||e[30]!==E?(R=async(O,F)=>{const $=F===void 0?Ry:F;if(!$()||Ay(E,O)||w)return;let z=b?.pages??[];for(;$()&&!Ty(z,O,E)&&(z.at(-1)?.branches.length??Ha)>=Ha;){const K=await j();if(!$())break;const X=K.data?.pages??z;if(X.length===z.length)break;z=X}},e[27]=b?.pages,e[28]=j,e[29]=w,e[30]=E,e[31]=R):R=e[31];const P=R,D=L??!1;let I;e[32]!==j||e[33]!==L||e[34]!==w?(I=()=>{L&&!w&&j()},e[32]=j,e[33]=L,e[34]=w,e[35]=I):I=e[35];let M;return e[36]!==k||e[37]!==P||e[38]!==y||e[39]!==w||e[40]!==_||e[41]!==S||e[42]!==C||e[43]!==D||e[44]!==I||e[45]!==V?(M={recent:C,yours:V,others:S,defaultBase:k,isLoading:_,isError:y,hasMore:D,isFetchingMore:w,fetchMore:I,fetchUntilMatch:P},e[36]=k,e[37]=P,e[38]=y,e[39]=w,e[40]=_,e[41]=S,e[42]=C,e[43]=D,e[44]=I,e[45]=V,e[46]=M):M=e[46],M}function Ry(){return!0}function Dy(t){return t.default_branch}function Iy(t){return t.name}function My(t){return{name:t.name,author:typeof t.commit?.author=="string"?t.commit.author:t.commit?.author?.login??null}}function Oy(t){return typeof t.name=="string"}function $y(t){if(!(t.branches.length<Ha))return t.page+1}function By(t){try{return JSON.parse(t)}catch{return null}}function Fy(t){if(!t||typeof t!="object")return null;const e=t,s=e.content?.find(o=>o.type==="text")?.text,n=s?By(s):null,i=e.structuredContent;return i==null?n:typeof i=="object"&&!Array.isArray(i)&&Object.keys(i).length===0?n??i:i}function zi(t){const e=Fy(t);return e===null?null:e}function C9(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 zy(t){if(!t||typeof t!="object")return null;const e=t.content?.find(i=>i.type==="text")?.text;if(!e)return null;const s=e.match(/https:\/\/github\.com\/[^\s"]+\/pull\/\d+/)?.[0],n=C9(s);return!n||!s?null:{number:n,htmlUrl:s}}const oh=/[\r\n<>]/,Ky=/^[^\s@<>]+@[^\s@<>]+\.[^\s@<>]+$/;function ca(t){const e=t?.userName?.trim();if(!e||oh.test(e))return null;const s=t?.userEmail?.trim();return!s||oh.test(s)?{userName:e}:Ky.test(s)?{userName:e,userEmail:s}:{userName:e}}function Uy(t){return t.split(`
|
|
3
|
+
`).filter(e=>!/^Co-authored-by:\s/i.test(e)).join(`
|
|
4
|
+
`).trimEnd()}function Hy(t){const e=t.userName.trim(),s=t.userEmail?.trim();return s?`Co-authored-by: ${e} <${s}>`:`Co-authored-by: ${e}`}function X2(t,e){const s=ca(e);if(!s)return t;const n=Uy(t),i=Hy(s);if(n.includes(i))return n;const o=n.trimEnd();return o.length>0?`${o}
|
|
5
|
+
|
|
6
|
+
${i}`:i}function Q2(t,e){const s=t?.trim();return s?X2(s,e):s||void 0}const Wy=["dev","start"];function qy(t){if(!t||typeof t!="object")return null;const e=t;return e.isError?e.content?.find(n=>n.type==="text")?.text?.trim()||"GitHub MCP tool returned an error":null}function k9(t){const e=qy(t);if(e)throw new Error(e)}function Z2(t,e){for(const s of e){const n=t[s];if(typeof n=="string"&&n.length>0)return n}}function ep(t,e){for(const s of e){const n=t[s];if(typeof n=="number"&&Number.isFinite(n)&&n>0)return n;if(typeof n=="string"&&/^\d+$/.test(n)){const i=Number(n);if(i>0)return i}}}function Gy(t){const s=t.head?.ref;return typeof s=="string"&&s.length>0?s:null}function Yy(t,e){return Gy(t)===e}function rc(t){const e=zi(t);if(Array.isArray(e))return e.filter(s=>s!=null&&typeof s=="object");if(e&&typeof e=="object"){const s=e;for(const n of["pull_requests","items","data"]){const i=s[n];if(Array.isArray(i))return i.filter(o=>o!=null&&typeof o=="object")}}return[]}function Jy(t){const e=Z2(t,["html_url","htmlUrl","url","URL"]),s=ep(t,["number","pullNumber"])??C9(e);return!s||!e?null:{number:s,htmlUrl:e}}function Xy(t){k9(t);const e=zy(t);if(e)return e;const s=zi(t);if(s&&typeof s=="object"){const n=Z2(s,["url","URL","html_url","htmlUrl"]),i=ep(s,["number","pullNumber"])??C9(n);if(i&&n)return{number:i,htmlUrl:n}}throw new Error("Failed to open pull request")}function Qy(t){return/already exists|pull request already/i.test(t)}async function Zy(t,e){const s=await t.callTool({name:"list_pull_requests",arguments:{owner:e.owner,repo:e.repo,state:"open",...e.head?{head:e.head}:{},perPage:10}});return k9(s),rc(s)}async function ah(t,e){const s=[`${e.owner}:${e.branch}`,e.branch];for(const n of s){const o=(await Zy(t,{owner:e.owner,repo:e.repo,head:n})).find(l=>Yy(l,e.branch)),a=o?Jy(o):null;if(a)return a}return null}async function e_(t,e){const s=Q2(e.body,ca(e.coAuthor));if(s)try{await t.callTool({name:"update_pull_request",arguments:{owner:e.owner,repo:e.repo,pullNumber:e.pullNumber,body:s}})}catch{}}async function t_(t,e){const s=Q2(e.body,ca(e.coAuthor)),n=await t.callTool({name:"create_pull_request",arguments:{owner:e.owner,repo:e.repo,title:e.title,body:s||void 0,head:e.head,base:e.base}});return Xy(n)}async function lh(t,e){const s=await ah(t,{owner:e.owner,repo:e.repo,branch:e.branch});if(s)return await e_(t,{owner:e.owner,repo:e.repo,pullNumber:s.number,body:e.body,coAuthor:e.coAuthor}),s;try{return await t_(t,{owner:e.owner,repo:e.repo,title:e.title,body:e.body,head:e.branch,base:e.base,coAuthor:e.coAuthor})}catch(n){const i=n instanceof Error?n.message:String(n);if(!Qy(i))throw n;const o=await ah(t,{owner:e.owner,repo:e.repo,branch:e.branch});if(o)return o;throw n}}async function tp(t,e){const s=ca(e.coAuthor),n=s?X2(e.commitMessage?.trim()??"",s):e.commitMessage?.trim()||void 0,i=await t.callTool({name:"merge_pull_request",arguments:{owner:e.owner,repo:e.repo,pullNumber:e.pullNumber,merge_method:"squash",...e.commitTitle?{commit_title:e.commitTitle}:{},...n?{commit_message:n}:{}}});k9(i);const o=zi(i);if(!o||o.merged!==!0)throw new Error(o?.message??"Failed to merge pull request");return{merged:!0,message:o.message??"Pull request merged"}}const V9=6e4,oc=3e4;function sp(t){const e=t.base,s=t.head,n=s?.repo,i=t.user;return{number:t.number??0,title:t.title??"",body:t.body??"",state:t.state==="closed"?"closed":"open",merged:t.merged_at!=null,mergedAt:t.merged_at??null,base:e?.ref??"main",head:s?.ref??"",headSha:s?.sha??"",headRepoFullName:n?.full_name??null,htmlUrl:t.html_url??"",author:i?.login??""}}function N9(t){const e=B.c(15);let s;e[0]!==t.connectionId||e[1]!==t.orgId||e[2]!==t.orgSlug?(s={connectionId:t.connectionId,orgId:t.orgId,orgSlug:t.orgSlug},e[0]=t.connectionId,e[1]=t.orgId,e[2]=t.orgSlug,e[3]=s):s=e[3];const n=ht(s);let i;e[4]!==t.branch||e[5]!==t.owner?(i=t.branch?{head:`${t.owner}:${t.branch}`}:{},e[4]=t.branch,e[5]=t.owner,e[6]=i):i=e[6];let o;e[7]!==t.owner||e[8]!==t.repo||e[9]!==i?(o={owner:t.owner,repo:t.repo,state:"all",...i,perPage:1},e[7]=t.owner,e[8]=t.repo,e[9]=i,e[10]=o):o=e[10];const a=!!t.branch&&!!t.connectionId&&!!t.owner&&!!t.repo;let l;return e[11]!==n||e[12]!==o||e[13]!==a?(l={client:n,toolName:"list_pull_requests",toolArguments:o,enabled:a,refetchInterval:V9,refetchIntervalInBackground:!1,staleTime:oc,select:s_},e[11]=n,e[12]=o,e[13]=a,e[14]=l):l=e[14],ra(l)}function s_(t){const e=rc(t);return e.length===0?null:sp(e[0])}const n_=50;function i_(t){const e=B.c(11);let s;e[0]!==t.connectionId||e[1]!==t.orgId||e[2]!==t.orgSlug?(s={connectionId:t.connectionId,orgId:t.orgId,orgSlug:t.orgSlug},e[0]=t.connectionId,e[1]=t.orgId,e[2]=t.orgSlug,e[3]=s):s=e[3];const n=ht(s);let i;e[4]!==t.owner||e[5]!==t.repo?(i={owner:t.owner,repo:t.repo,state:"open",perPage:n_},e[4]=t.owner,e[5]=t.repo,e[6]=i):i=e[6];const o=(t.enabled??!0)&&!!t.connectionId&&!!t.owner&&!!t.repo;let a;return e[7]!==n||e[8]!==i||e[9]!==o?(a={client:n,toolName:"list_pull_requests",toolArguments:i,enabled:o,staleTime:oc,select:r_},e[7]=n,e[8]=i,e[9]=o,e[10]=a):a=e[10],ra(a)}function r_(t){return rc(t).map(sp)}function np(t){const e=B.c(12);let s;e[0]!==t.connectionId||e[1]!==t.orgId||e[2]!==t.orgSlug?(s={connectionId:t.connectionId,orgId:t.orgId,orgSlug:t.orgSlug},e[0]=t.connectionId,e[1]=t.orgId,e[2]=t.orgSlug,e[3]=s):s=e[3];const n=ht(s),i=t.prNumber??0;let o;e[4]!==t.owner||e[5]!==t.repo||e[6]!==i?(o={method:"get_check_runs",owner:t.owner,repo:t.repo,pullNumber:i},e[4]=t.owner,e[5]=t.repo,e[6]=i,e[7]=o):o=e[7];const a=!!t.prNumber;let l;return e[8]!==n||e[9]!==o||e[10]!==a?(l={client:n,toolName:"pull_request_read",toolArguments:o,enabled:a,refetchInterval:V9,refetchIntervalInBackground:!1,staleTime:oc,select:o_},e[8]=n,e[9]=o,e[10]=a,e[11]=l):l=e[11],ra(l)}function o_(t){const e=zi(t);return(Array.isArray(e)?e:e?.check_runs??[]).map(a_)}function a_(t){const e=t.started_at,s=t.completed_at,n=e&&s?new Date(s).getTime()-new Date(e).getTime():null;return{id:String(t.id??""),name:String(t.name??""),status:t.status??"completed",conclusion:t.conclusion??null,htmlUrl:String(t.html_url??""),durationMs:n}}function l_(t){const e=B.c(12);let s;e[0]!==t.connectionId||e[1]!==t.orgId||e[2]!==t.orgSlug?(s={connectionId:t.connectionId,orgId:t.orgId,orgSlug:t.orgSlug},e[0]=t.connectionId,e[1]=t.orgId,e[2]=t.orgSlug,e[3]=s):s=e[3];const n=ht(s),i=t.prNumber??0;let o;e[4]!==t.owner||e[5]!==t.repo||e[6]!==i?(o={method:"get_comments",owner:t.owner,repo:t.repo,pullNumber:i},e[4]=t.owner,e[5]=t.repo,e[6]=i,e[7]=o):o=e[7];const a=!!t.prNumber;let l;return e[8]!==n||e[9]!==o||e[10]!==a?(l={client:n,toolName:"pull_request_read",toolArguments:o,enabled:a,refetchInterval:V9,refetchIntervalInBackground:!1,staleTime:oc,select:c_},e[8]=n,e[9]=o,e[10]=a,e[11]=l):l=e[11],ra(l)}function c_(t){const e=zi(t);return Array.isArray(e)?e.map(d_):[]}function d_(t){const e=t.user;return{id:Number(t.id??0),author:e?.login??"",body:String(t.body??""),createdAt:String(t.created_at??""),htmlUrl:String(t.html_url??"")}}function u_(t){const e=B.c(137),{orgId:s,orgSlug:n,userId:i,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,g=m===void 0?"chat":m,x=re(),v=g==="header",[b,_]=A.useState(!1),[y,L]=A.useState("branches"),[w,j]=A.useState(""),[S,C]=A.useState(!1),N=A.useRef(0);let V;e[0]!==a||e[1]!==b||e[2]!==s||e[3]!==n||e[4]!==l||e[5]!==c||e[6]!==d||e[7]!==i?(V={orgId:s,orgSlug:n,userId:i,connectionId:a,sandboxMap:d,owner:l,repo:c,enabled:b},e[0]=a,e[1]=b,e[2]=s,e[3]=n,e[4]=l,e[5]=c,e[6]=d,e[7]=i,e[8]=V):V=e[8];const{recent:E,yours:T,others:k,isLoading:R,isError:P,hasMore:D,isFetchingMore:I,fetchMore:M,fetchUntilMatch:O}=Py(V);let F;e[9]!==b?(F={enabled:b},e[9]=b,e[10]=F):F=e[10];const{data:$}=M6(F);let z;e[11]!==$?.data?.members?(z=new Map(($?.data?.members??[]).map(h_)),e[11]=$?.data?.members,e[12]=z):z=e[12];const K=z,X=a??"",J=b&&y==="prs";let H;e[13]!==s||e[14]!==n||e[15]!==l||e[16]!==c||e[17]!==X||e[18]!==J?(H={orgId:s,orgSlug:n,connectionId:X,owner:l,repo:c,enabled:J},e[13]=s,e[14]=n,e[15]=l,e[16]=c,e[17]=X,e[18]=J,e[19]=H):H=e[19];const{data:W,isLoading:U,isError:Q}=i_(H);let q,Z,Y,ee,G,te,se,ne,de,xe,he,ce,oe;if(e[20]!==p||e[21]!==M||e[22]!==O||e[23]!==D||e[24]!==P||e[25]!==I||e[26]!==v||e[27]!==R||e[28]!==S||e[29]!==K||e[30]!==u||e[31]!==b||e[32]!==k||e[33]!==l||e[34]!==Q||e[35]!==U||e[36]!==E||e[37]!==c||e[38]!==w||e[39]!==x||e[40]!==W||e[41]!==y||e[42]!==o||e[43]!==h||e[44]!==T){const Oe=W===void 0?[]:W,ye=`${l}/${c}`;let je;e[58]!==ye?(je=ye.toLowerCase(),e[58]=ye,e[59]=je):je=e[59];const Pe=je;let Ee;e[60]!==Pe?(Ee=We=>We.headRepoFullName?.toLowerCase()===Pe,e[60]=Pe,e[61]=Ee):Ee=e[61];const be=Oe.filter(Ee),Ve=Oe.length-be.length;let Re;e[62]!==u?(Re=We=>{u(We),_(!1)},e[62]=u,e[63]=Re):Re=e[63];const Le=Re;let ve;e[64]!==x||e[65]!==h?(ve=h??x("thread.branchPicker.selectBranch"),e[64]=x,e[65]=h,e[66]=ve):ve=e[66];const Se=ve;let Be;e[67]!==O||e[68]!==y?(Be=We=>{j(We),N.current=N.current+1;const ae=N.current,De=We.trim();if(!De||y!=="branches"){C(!1);return}C(!0),O(De,()=>ae===N.current).finally(()=>{ae===N.current&&C(!1)})},e[67]=O,e[68]=y,e[69]=Be):Be=e[69];const Ce=Be;let ke;e[70]!==M||e[71]!==y?(ke=We=>{const ae=We.currentTarget,De=ae.scrollHeight-ae.scrollTop-ae.clientHeight;y==="branches"&&De<48&&M()},e[70]=M,e[71]=y,e[72]=ke):ke=e[72];const ze=ke;ee=As,he=b,ce=p?void 0:_;const nt=v?"outline":"ghost",pt=v?"sm":"default";let Je;e[73]!==p||e[74]!==v?(Je=ie("font-mono shrink min-w-0 max-w-[200px]",v?"gap-1.5 text-xs":ie("text-xs text-muted-foreground hover:text-foreground transition-[gap] duration-200",p?"gap-0":"gap-0 @[320px]/chat-bottom:gap-1.5")),e[73]=p,e[74]=v,e[75]=Je):Je=e[75];let gt;e[76]===Symbol.for("react.memo_cache_sentinel")?(gt=r.jsx(Zs,{className:"h-3.5 w-3.5 shrink-0"}),e[76]=gt):gt=e[76];const dt=v?"":"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 st;e[77]!==dt?(st=ie("min-w-0 truncate",dt),e[77]=dt,e[78]=st):st=e[78];let ft;e[79]!==Se||e[80]!==st?(ft=r.jsx("span",{className:st,children:Se}),e[79]=Se,e[80]=st,e[81]=ft):ft=e[81];let fe;e[82]!==p||e[83]!==v?(fe=!p&&r.jsx(ss,{size:12,className:ie("opacity-60 shrink-0",v?"":"hidden @[320px]/chat-bottom:inline-block")}),e[82]=p,e[83]=v,e[84]=fe):fe=e[84];let Me;e[85]!==p||e[86]!==Se||e[87]!==nt||e[88]!==pt||e[89]!==Je||e[90]!==ft||e[91]!==fe?(Me=r.jsx(Ke,{asChild:!0,children:r.jsx("span",{className:"inline-flex min-w-0 shrink",children:r.jsx(Es,{asChild:!0,children:r.jsxs(le,{variant:nt,size:pt,"aria-label":Se,disabled:p,className:Je,children:[gt,ft,fe]})})})}),e[85]=p,e[86]=Se,e[87]=nt,e[88]=pt,e[89]=Je,e[90]=ft,e[91]=fe,e[92]=Me):Me=e[92];let Qe;e[93]!==Se?(Qe=r.jsx(Ue,{children:Se}),e[93]=Se,e[94]=Qe):Qe=e[94],e[95]!==Me||e[96]!==Qe?(oe=r.jsxs(He,{children:[Me,Qe]}),e[95]=Me,e[96]=Qe,e[97]=oe):oe=e[97],Y=Ps,de="w-[min(420px,calc(100vw-2rem))] p-0",xe="start",Z=Tr;let xt;e[98]!==x||e[99]!==y?(xt=y==="branches"?x("thread.branchPicker.searchLoadedBranches"):"Search pull requests…",e[98]=x,e[99]=y,e[100]=xt):xt=e[100];let ls;e[101]!==Ce||e[102]!==w||e[103]!==xt?(ls=r.jsx(Bi,{placeholder:xt,value:w,onValueChange:Ce}),e[101]=Ce,e[102]=w,e[103]=xt,e[104]=ls):ls=e[104];let Vt;e[105]!==Le||e[106]!==x||e[107]!==y||e[108]!==o?(Vt=y==="branches"&&r.jsx(le,{variant:"outline",size:"sm",className:"h-7 shrink-0",onClick:()=>Le(J2(o)),children:x("thread.branchPicker.new")}),e[105]=Le,e[106]=x,e[107]=y,e[108]=o,e[109]=Vt):Vt=e[109],e[110]!==ls||e[111]!==Vt?(se=r.jsxs("div",{className:"*:data-[slot=command-input-wrapper]:flex-1 *:data-[slot=command-input-wrapper]:border-b-0 flex items-center border-b pr-2",children:[ls,Vt]}),e[110]=ls,e[111]=Vt,e[112]=se):se=e[112];let Ut;e[113]===Symbol.for("react.memo_cache_sentinel")?(Ut=We=>{L(We),j("")},e[113]=Ut):Ut=e[113];let is;e[114]===Symbol.for("react.memo_cache_sentinel")?(is=r.jsxs(na,{className:"h-auto w-fit justify-start gap-1 bg-accent p-1",variant:"pill",children:[r.jsx(xn,{value:"branches",className:"h-6 px-2.5 text-xs",children:"Branches"}),r.jsx(xn,{value:"prs",className:"h-6 px-2.5 text-xs",children:"PRs"})]}),e[114]=is):is=e[114],e[115]!==y?(ne=r.jsx(Vr,{className:"px-2 pt-2 pb-1",value:y,onValueChange:Ut,children:is}),e[115]=y,e[116]=ne):ne=e[116],q=Fi,G=ze,te=y==="prs"?r.jsxs(r.Fragment,{children:[Q&&r.jsx("div",{className:"p-3 text-xs text-muted-foreground",children:"Couldn't load pull requests from GitHub."}),U&&r.jsx("div",{className:"p-3 text-xs text-muted-foreground",children:"Loading pull requests…"}),!Q&&!U&&r.jsx(Zn,{children:w.trim()?"No pull requests match your search.":"No open pull requests."}),be.length>0&&r.jsx(Ms,{heading:"Open pull requests",children:be.map(We=>r.jsxs(Vs,{value:`#${We.number} ${We.title} ${We.head}`,className:"cursor-pointer",onSelect:()=>Le(We.head),children:[r.jsx(zv,{className:"mr-2 h-4 w-4 shrink-0 text-muted-foreground"}),r.jsxs("div",{className:"flex min-w-0 flex-1 flex-col",children:[r.jsx("span",{className:"truncate",children:vr(We.title)}),r.jsxs("span",{className:"truncate text-xs text-muted-foreground",children:["#",We.number," · ",We.head,We.author?` · @${We.author}`:""]})]})]},We.number))}),Ve>0&&r.jsxs("div",{className:"border-t p-2 text-center text-xs text-muted-foreground",children:[Ve," PR",Ve>1?"s":""," from forks hidden — open on a branch in this repo"]})]}):r.jsxs(r.Fragment,{children:[P&&r.jsx("div",{className:"p-3 text-xs text-muted-foreground",children:x("thread.branchPicker.couldntLoadBranches")}),!P&&!R&&r.jsx(Zn,{children:x(D?"thread.branchPicker.lookingThroughMoreBranches":"thread.branchPicker.noBranchesFound")}),E.length>0&&r.jsx(Ms,{heading:"Last 7 days",children:E.map(We=>r.jsxs(Vs,{value:We.name,className:"cursor-pointer",onSelect:()=>Le(We.name),children:[r.jsx(Zs,{className:"mr-2 h-4 w-4 shrink-0"}),r.jsx("span",{className:"flex-1 truncate",children:We.name}),r.jsx(f_,{userIds:We.contributors??[],memberById:K})]},We.name))}),T.length>0&&r.jsxs(r.Fragment,{children:[E.length>0&&r.jsx(Qu,{}),r.jsx(Ms,{heading:x("thread.branchPicker.yourBranches"),children:T.map(We=>r.jsxs(Vs,{value:We.name,className:"cursor-pointer",onSelect:()=>Le(We.name),children:[r.jsx(Zs,{className:"mr-2 h-4 w-4 shrink-0"}),r.jsx("span",{className:"flex-1 truncate",children:We.name})]},We.name))})]}),k.length>0&&r.jsxs(r.Fragment,{children:[r.jsx(Qu,{}),r.jsx(Ms,{heading:x("thread.branchPicker.otherBranchesInRepo"),children:k.map(We=>r.jsxs(Vs,{value:We.name,className:"cursor-pointer",onSelect:()=>Le(We.name),children:[r.jsx(Zs,{className:"mr-2 h-4 w-4"}),r.jsx("span",{className:"flex-1 truncate",children:We.name}),We.author&&r.jsxs("span",{className:"text-xs text-muted-foreground",children:["@",We.author]})]},We.name))})]}),D&&r.jsx("div",{className:"border-t p-2",children:r.jsx(le,{variant:"ghost",size:"sm",className:"h-7 w-full text-xs",disabled:I,onClick:M,children:x(I||S?"thread.branchPicker.loadingMore":"thread.branchPicker.loadMoreBranches")})}),!D&&k.length>0&&r.jsx("div",{className:"border-t p-2 text-center text-xs text-muted-foreground",children:x("thread.branchPicker.allLoaded")})]}),e[20]=p,e[21]=M,e[22]=O,e[23]=D,e[24]=P,e[25]=I,e[26]=v,e[27]=R,e[28]=S,e[29]=K,e[30]=u,e[31]=b,e[32]=k,e[33]=l,e[34]=Q,e[35]=U,e[36]=E,e[37]=c,e[38]=w,e[39]=x,e[40]=W,e[41]=y,e[42]=o,e[43]=h,e[44]=T,e[45]=q,e[46]=Z,e[47]=Y,e[48]=ee,e[49]=G,e[50]=te,e[51]=se,e[52]=ne,e[53]=de,e[54]=xe,e[55]=he,e[56]=ce,e[57]=oe}else q=e[45],Z=e[46],Y=e[47],ee=e[48],G=e[49],te=e[50],se=e[51],ne=e[52],de=e[53],xe=e[54],he=e[55],ce=e[56],oe=e[57];let me;e[117]!==q||e[118]!==G||e[119]!==te?(me=r.jsx(q,{onScroll:G,children:te}),e[117]=q,e[118]=G,e[119]=te,e[120]=me):me=e[120];let pe;e[121]!==Z||e[122]!==se||e[123]!==ne||e[124]!==me?(pe=r.jsxs(Z,{children:[se,ne,me]}),e[121]=Z,e[122]=se,e[123]=ne,e[124]=me,e[125]=pe):pe=e[125];let we;e[126]!==Y||e[127]!==de||e[128]!==xe||e[129]!==pe?(we=r.jsx(Y,{className:de,align:xe,children:pe}),e[126]=Y,e[127]=de,e[128]=xe,e[129]=pe,e[130]=we):we=e[130];let Ne;return e[131]!==ee||e[132]!==he||e[133]!==ce||e[134]!==oe||e[135]!==we?(Ne=r.jsxs(ee,{open:he,onOpenChange:ce,children:[oe,we]}),e[131]=ee,e[132]=he,e[133]=ce,e[134]=oe,e[135]=we,e[136]=Ne):Ne=e[136],Ne}function h_(t){return[t.userId,t.user]}function f_(t){const e=B.c(13),{userIds:s,memberById:n}=t;if(s.length===0)return null;let i,o,a;if(e[0]!==n||e[1]!==s){const d=s.slice(0,3);i=s.length-d.length,o="ml-2 flex shrink-0 items-center -space-x-1.5";let h;e[5]!==n?(h=u=>{const f=n.get(u);return r.jsx(ir,{url:f?.image??void 0,fallback:O6(f?.name??void 0),shape:"circle",size:"xs",className:"ring-2 ring-background"},u)},e[5]=n,e[6]=h):h=e[6],a=d.map(h),e[0]=n,e[1]=s,e[2]=i,e[3]=o,e[4]=a}else i=e[2],o=e[3],a=e[4];let l;e[7]!==i?(l=i>0&&r.jsxs("span",{className:"flex h-6 w-6 items-center justify-center rounded-full bg-muted text-[9px] font-semibold text-muted-foreground ring-2 ring-background",children:["+",i]}),e[7]=i,e[8]=l):l=e[8];let c;return e[9]!==o||e[10]!==a||e[11]!==l?(c=r.jsxs("span",{className:o,children:[a,l]}),e[9]=o,e[10]=a,e[11]=l,e[12]=c):c=e[12],c}function m_(t){const e=B.c(25);let s,n,i,o;e[0]!==t?({locked:s,placement:n,value:o,...i}=t,e[0]=t,e[1]=s,e[2]=n,e[3]=i,e[4]=o):(s=e[1],n=e[2],i=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=ie("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=r.jsx(Zs,{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=ie("min-w-0 truncate",f),e[8]=f,e[9]=m):m=e[9];let p;e[10]!==c||e[11]!==m?(p=r.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=r.jsx(Ke,{asChild:!0,children:r.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=r.jsxs(Ue,{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=r.jsxs(He,{children:[g,x]}),e[18]=g,e[19]=x,e[20]=v):v=e[20],v}let l;return e[21]!==n||e[22]!==i||e[23]!==o?(l=r.jsx(u_,{...i,value:o,placement:n}),e[21]=n,e[22]=i,e[23]=o,e[24]=l):l=e[24],l}function ac(){const t=B.c(11),e=bm(),s=dm();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 i;t[3]!==e.capabilities||t[4]!==e.online?(i=e.online&&e.capabilities.includes("codex"),t[3]=e.capabilities,t[4]=e.online,t[5]=i):i=t[5];let o;return t[6]!==e.online||t[7]!==s.runtime.agentSandbox||t[8]!==n||t[9]!==i?(o={agentSandbox:s.runtime.agentSandbox,userDesktop:e.online,claudeCode:n,codex:i},t[6]=e.online,t[7]=s.runtime.agentSandbox,t[8]=n,t[9]=i,t[10]=o):o=t[10],o}function ip(t){const e=Object.values(t),[s]=e;return s?e.find(n=>n.sandboxProviderKind!=="user-desktop")??s:null}async function p_(t,e,s){const n=await t.callTool({name:e,arguments:s});if(n.isError){const i=n.content?.[0]?.text??`Tool ${e} failed without a message`;throw new Error(i)}return n}const rp=["SANDBOX_START"],ba=new Map,g_=t=>`${t.virtualMcpId}::${t.branch??""}`,Fc=new Set,_l={mark:(t,e)=>Fc.add(`${t}::${e}`),clear:(t,e)=>Fc.delete(`${t}::${e}`),isStopped:(t,e)=>Fc.has(`${t}::${e}`)};function T9(t){const e=Ls();return Ys({mutationKey:rp,mutationFn:async s=>{s.branch&&_l.clear(s.virtualMcpId,s.branch);const n=g_(s),i=ba.get(n);if(i)return i;const o=(async()=>(await p_(t,"SANDBOX_START",s)).structuredContent)();ba.set(n,o);try{return await o}finally{ba.get(n)===o&&ba.delete(n)}},onSuccess:()=>{um(e)}})}function x_(t,e){const s=B.c(3);let n;return s[0]!==e||s[1]!==t?(n={mutationKey:rp,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],d8(n)>0}const v_={phase:null,lifecycle:{phase:"idle"},status:{state:"running"},branch:{kind:"unknown"},notFound:!1,scripts:[],activeProcesses:[],getBuffer:()=>"",hasData:()=>!1,subscribeChunks:()=>()=>{},subscribeReload:()=>()=>{},subscribeReloadStart:()=>()=>{}},op=A.createContext(v_),ch=16384;class b_{data="";append(e){this.data+=e,this.data.length>ch&&(this.data=this.data.slice(this.data.length-ch))}get(){return this.data}clear(){this.data=""}}const y_=1e3,__=3e4,L_=3e3,dh=["lifecycle","status","tasks","scripts","branch","reload","file-changed"],uh="log";function S_(t,e,s,n){return t[0]==="live-meta"&&t[1]===e&&t[2]===s&&t[3]===n}function w_(t){if(!t)return null;try{return new URL("/_sandbox/events",t).href}catch{return null}}function j_(t){return t===404}async function C_(t){try{const e=await fetch(t,{headers:{Accept:"text/event-stream"},cache:"no-store",signal:AbortSignal.timeout(L_)});return await e.body?.cancel().catch(()=>{}),j_(e.status)}catch{return!1}}function k_({virtualMcpId:t,branch:e,previewUrl:s=null,enabled:n=!0,children:i}){const{org:o}=Fe(),a=Ls(),[l,c]=A.useState(null),[d,h]=A.useState({phase:"idle"}),[u,f]=A.useState({state:"running"}),[m,p]=A.useState({kind:"unknown"}),[g,x]=A.useState(!1),[v,b]=A.useState([]),[_,y]=A.useState([]),[,L]=A.useState(0),w=A.useRef(new Map),j=A.useRef(new Set),S=A.useRef(new Set),C=A.useRef(new Set),N=A.useRef(null),V=w_(s),E=k=>{let R=w.current.get(k);return R||(R=new b_,w.current.set(k,R)),R};A.useEffect(()=>{if(c(null),h({phase:"idle"}),f({state:"running"}),p({kind:"unknown"}),N.current=null,x(!1),b([]),y([]),w.current.clear(),!t||!e||!n)return;const k=`/api/${encodeURIComponent(o.slug)}/sandbox/${encodeURIComponent(t)}/${encodeURIComponent(e)}/events`;let R=!1,P=0,D=null,I=null,M=null,O=null,F=null,$=null;const z=q=>{try{const Z=JSON.parse(q.data);c(Z),Z.kind!=="failed"&&(x(!1),P=0),Z.kind==="ready"&&W()}catch(Z){console.warn("[vm-events] bad phase payload",Z)}},K=()=>{x(!0),c(null),h({phase:"idle"}),f({state:"running"}),p({kind:"unknown"}),b([]),y([]),w.current.clear()},X=q=>{try{const Z=JSON.parse(q.data);if(typeof Z.data!="string")return;P=0;const Y=Z.data.replace(/\r?\n/g,`\r
|
|
7
|
+
`);E(Z.source).append(Y);for(const ee of j.current)try{ee(Z.source,Y)}catch{}L(ee=>ee+1)}catch{}},J=q=>{const Z=q.type;try{const Y=JSON.parse(q.data);switch(P=0,Z){case"lifecycle":{const ee=Y;if(h(ee.state),ee.state.phase==="running"&&$!=="running"){const se=`${o.slug}/${t}/${e}`;a.invalidateQueries({queryKey:at.decofile(se)}),a.invalidateQueries({predicate:ne=>ne.queryKey[0]==="live-meta"&&typeof ne.queryKey[1]=="string"&&ne.queryKey[1].startsWith(`${se}/`)})}$=ee.state.phase;const G=ee.state.phase==="running"?ee.state.port:null,te=N.current;if(N.current=G,te!==null&&G!==null&&te!==G)for(const se of S.current)try{se()}catch{}return}case"status":f(Y);return;case"tasks":{const G=Y.active.map(te=>te.logName??"").filter(Boolean);y(G);return}case"scripts":b(Y.scripts);return;case"branch":{const ee=Y.meta;p(ee);return}case"reload":for(const ee of S.current)try{ee()}catch{}return;case"file-changed":{const{path:ee}=Y,G=`${o.slug}/${t}/${e}`;if(ee.startsWith(".deco/")||ee.includes("/.deco/")){if($!=="running")return;for(const se of C.current)try{se()}catch{}M&&clearTimeout(M),M=setTimeout(()=>{M=null,a.invalidateQueries({queryKey:at.decofile(G)});for(const se of S.current)try{se()}catch{}},500)}else I&&clearTimeout(I),I=setTimeout(()=>{I=null,a.invalidateQueries({predicate:se=>S_(se.queryKey,o.slug,t,e)})},1e3);return}}}catch{}};function H(){if(R)return;const q=new EventSource(k);O=q,q.onopen=()=>{},q.onerror=()=>{O===q&&q.readyState===EventSource.CLOSED&&Q("studio")},q.addEventListener("phase",z),q.addEventListener("gone",K),q.addEventListener(uh,X);for(const Z of dh)q.addEventListener(Z,J)}function W(){if(R||!V||F)return;const q=new EventSource(V);F=q;let Z=!1;q.onopen=()=>{if(R||F!==q)return;Z=!0,P=0;const Y=O;O=null,Y?.close()},q.onerror=()=>{F===q&&q.readyState===EventSource.CLOSED&&U(q,Z)},q.addEventListener(uh,X);for(const Y of dh)q.addEventListener(Y,J)}async function U(q,Z){const Y=V?await C_(V):!1;if(!(R||F!==q)){if(q.close(),F=null,Y){K(),O||H();return}Z&&Q("direct")}}function Q(q){if(R||D)return;const Z=Math.min(y_*2**P,__);P++,D=setTimeout(()=>{if(D=null,!R){if(q==="direct"){F?.close(),F=null,W();return}O?.close(),O=null,H()}},Z)}return H(),()=>{R=!0,O?.close(),F?.close(),D&&clearTimeout(D),I&&clearTimeout(I),M&&clearTimeout(M)}},[t,e,o.slug,n,V,a]);const T={phase:l,lifecycle:d,status:u,branch:m,notFound:g,scripts:v,activeProcesses:_,getBuffer:k=>w.current.get(k)?.get()??"",hasData:k=>(w.current.get(k)?.get().length??0)>0,subscribeChunks:k=>(j.current.add(k),()=>{j.current.delete(k)}),subscribeReload:k=>(S.current.add(k),()=>{S.current.delete(k)}),subscribeReloadStart:k=>(C.current.add(k),()=>{C.current.delete(k)})};return r.jsx(op,{value:T,children:i})}function Fs(){return A.use(op)}function ap(t){const{subscribeChunks:e}=Fs(),s=A.useRef(t);s.current=t,A.useEffect(()=>e((o,a)=>{s.current?.(o,a)}),[e])}function V_(t){const{subscribeReload:e}=Fs(),s=A.useRef(t);s.current=t,A.useEffect(()=>e(()=>{s.current?.()}),[e])}function N_(t){const{subscribeReloadStart:e}=Fs(),s=A.useRef(t);s.current=t,A.useEffect(()=>e(()=>{s.current?.()}),[e])}function lp(t){return t.othersThreadGate&&!t.previewUrl?{kind:"othersThread",label:t.othersThreadGate.label}: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 cp={githubNotAuthenticated:"GITHUB_NOT_AUTHENTICATED"},hh="::";function dp(t){const e=t.indexOf(hh);if(e>0){const s=t.slice(0,e);if(Object.values(cp).includes(s))return{code:s,message:t.slice(e+hh.length)}}return{code:null,message:t}}function T_(t){return t.hasActiveGithubRepo&&!!t.userId&&!t.vmEntry&&!t.userStopped&&!t.isPending&&!t.attempted&&!t.autoStartBlocked}function A_(t){return t.notFound&&!!t.deadVmId&&!t.isPending&&!t.userStopped&&!t.autoStartBlocked&&t.deadVmId!==t.lastDeadVmId}function E_(t){return!!t.userId&&!!t.createdBy&&t.createdBy!==t.userId?t.branch??t.title??null:null}function P_(t){const e=t.acknowledgedThreadId!==null&&t.acknowledgedThreadId===t.threadId;return{autoStartBlocked:!!t.othersThreadLabel&&!e}}function zc(t,e,s){const n={virtualMcpId:t};return e&&(n.branch=e),s&&(n.sandboxProviderKind=s),n}function R_(t){switch(t.kind){case"suspended":return"suspended";case"iframe":return"running";case"starting":return"starting";case"errored":return"errored";case"othersThread":return"idle"}}const D_={branch:null,previewState:{kind:"starting"},status:"idle",vmEntry:null,previewUrl:null,userStopped:!1,start:()=>{},stop:async()=>{},restart:async()=>{},retry:()=>{},resume:()=>{},acknowledgeOthersThread:()=>{}},up=A.createContext(D_);function Er(){return A.use(up)}function I_({virtualMcpId:t,branch:e,userId:s,hasActiveGithubRepo:n,sandboxMap:i,sandboxProviderKind:o,othersThreadLabel:a,othersThreadId:l,children:c}){const{org:d}=Fe(),{setCurrentTaskBranch:h}=Zt(),u=Fs(),f=Ls(),[m,p]=A.useState(null),{autoStartBlocked:g}=P_({othersThreadLabel:a,acknowledgedThreadId:m,threadId:l}),x=ht({connectionId:Qo,orgId:d.id,orgSlug:d.slug}),v=T9(x),{mutate:b,reset:_}=v,y=A.useRef(new Set),L=A.useRef(null),w=s&&e?Hl(i?.[s]?.[e]):{},j=o?w[o]??null:ip(w),S=j?.previewUrl??null,C=!!t&&!!e&&_l.isStopped(t,e),N=u.status.state==="paused",V=v.isError&&v.error?dp(v.error.message):null,E=lp({previewUrl:S,appPaused:N,userStopped:C,startError:V,othersThreadGate:g&&a?{label:a}:null}),T=R_(E),k=e??"",R=y.current.has(k),P=T_({hasActiveGithubRepo:n,userId:s,vmEntry:j,userStopped:C,isPending:v.isPending,attempted:R,autoStartBlocked:g});A.useEffect(()=>{if(!P||!t)return;y.current.add(k);const J=zc(t,e,o);b(J,{onSuccess:H=>{H?.branch&&!e&&h(H.branch)},onError:H=>{console.error("[sandbox-lifecycle] auto-start failed:",H)}})},[P,k,e,t,o,b,h]);const D=u.notFound?j?.sandboxHandle??null:null,I=A_({notFound:u.notFound,deadVmId:D,lastDeadVmId:L.current,isPending:v.isPending,userStopped:C,autoStartBlocked:g});A.useEffect(()=>{if(!I||!D||!t)return;L.current=D;const J=zc(t,e,o);b(J,{onSuccess:H=>{H?.branch&&!e&&h(H.branch)},onError:H=>{console.error("[sandbox-lifecycle] self-heal failed:",H)}})},[I,D,t,e,o,b,h]);const M=()=>{if(!t)return;const J=zc(t,e,o);b(J,{onSuccess:H=>{H?.branch&&!e&&h(H.branch)},onError:H=>{console.error("[sandbox-lifecycle] user start failed:",H)}})},O=async()=>{if(!t||!e)return;const J=j?.sandboxProviderKind;if(J){_l.mark(t,e);try{await x.callTool({name:"SANDBOX_DELETE",arguments:{virtualMcpId:t,branch:e,sandboxProviderKind:J}})}catch{}um(f)}},F=async()=>{await O(),M()},$=()=>{y.current=new Set,L.current=null,_(),M()},X={branch:e,previewState:E,status:T,vmEntry:j,previewUrl:S,userStopped:C,start:M,stop:O,restart:F,retry:$,resume:$,acknowledgeOthersThread:()=>p(l)};return r.jsx(up,{value:X,children:c})}function M_(t,e){return t==="user-desktop"?{key:"local",label:e("chat.runtimeSwitcher.thisDevice"),Icon:Nr}:{key:"cloud",label:e("chat.runtimeSwitcher.cloudSandbox"),Icon:Z0}}function fh(t){const e=B.c(20),{icon:s,label:n,description:i,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=ie("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=r.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&&r.jsx(zt,{size:13,className:"text-muted-foreground"}),e[4]=o,e[5]=m):m=e[5];let p;e[6]!==n||e[7]!==m?(p=r.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?i:l;let x;e[9]!==g?(x=r.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=r.jsxs("span",{className:"min-w-0 flex-1",children:[p,x]}),e[11]=p,e[12]=x,e[13]=v):v=e[13];let b;return e[14]!==c||e[15]!==d||e[16]!==u||e[17]!==f||e[18]!==v?(b=r.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]=b):b=e[19],b}function O_(t){return t.toLowerCase()}function $_(t){const e=B.c(71);let s;e[0]!==t?(s=t===void 0?{}:t,e[0]=t,e[1]=s):s=e[1];const{showLabel:n}=s,i=n===void 0?!1:n,o=re(),{pendingSandboxProviderKind:a,setPendingAgentOption:l}=Ts(),{isThreadLocked:c}=Zt(),{vmEntry:d}=Er(),h=ac();if(c)return null;let u;e[2]!==h?(u=_m(h),e[2]=h,e[3]=u):u=e[3];const f=u,m=d?.sandboxProviderKind??a??(h.agentSandbox?"agent-sandbox":f?"user-desktop":null);let p,g,x,v,b,_,y;if(e[4]!==m||e[5]!==i||e[6]!==o){v=M_(m,o);const H=v.Icon;x=us,g=He;const W=o("chat.runtimeSwitcher.runtime",{label:v.label}),U=i?"h-9 gap-1.5 px-2 text-xs font-medium":"size-9";let Q;e[14]!==U?(Q=ie("text-muted-foreground hover:text-foreground",U),e[14]=U,e[15]=Q):Q=e[15];const q=r.jsx(ds,{asChild:!0,children:r.jsxs(le,{variant:"ghost",size:i?"sm":"icon","aria-label":W,className:Q,children:[r.jsx(H,{size:16}),i&&r.jsxs(r.Fragment,{children:[r.jsx("span",{className:"truncate",children:v.label}),r.jsx(ss,{size:12,className:"shrink-0 opacity-70"})]})]})});e[16]!==q?(y=r.jsx(Ke,{asChild:!0,children:q}),e[16]=q,e[17]=y):y=e[17],p=Ue,b="bottom",_=o("chat.runtimeSwitcher.runningOn",{label:O_(v.label)}),e[4]=m,e[5]=i,e[6]=o,e[7]=p,e[8]=g,e[9]=x,e[10]=v,e[11]=b,e[12]=_,e[13]=y}else p=e[7],g=e[8],x=e[9],v=e[10],b=e[11],_=e[12],y=e[13];let L;e[18]!==p||e[19]!==b||e[20]!==_?(L=r.jsx(p,{side:b,children:_}),e[18]=p,e[19]=b,e[20]=_,e[21]=L):L=e[21];let w;e[22]!==g||e[23]!==y||e[24]!==L?(w=r.jsxs(g,{children:[y,L]}),e[22]=g,e[23]=y,e[24]=L,e[25]=w):w=e[25];let j;e[26]!==o?(j=o("chat.runtimeSwitcher.runOn"),e[26]=o,e[27]=j):j=e[27];let S;e[28]!==j?(S=r.jsx(ao,{className:"text-xs font-normal text-muted-foreground",children:j}),e[28]=j,e[29]=S):S=e[29];let C;e[30]===Symbol.for("react.memo_cache_sentinel")?(C=r.jsx(Z0,{size:14}),e[30]=C):C=e[30];let N;e[31]!==o?(N=o("chat.runtimeSwitcher.cloudSandbox"),e[31]=o,e[32]=N):N=e[32];let V;e[33]!==o?(V=o("chat.runtimeSwitcher.runsInDecosCloud"),e[33]=o,e[34]=V):V=e[34];const E=v.key==="cloud",T=h.agentSandbox;let k;e[35]!==o?(k=o("chat.runtimeSwitcher.notAvailableOnThisDeployment"),e[35]=o,e[36]=k):k=e[36];let R;e[37]!==l?(R=()=>l("decopilot"),e[37]=l,e[38]=R):R=e[38];let P;e[39]!==h.agentSandbox||e[40]!==N||e[41]!==V||e[42]!==E||e[43]!==k||e[44]!==R?(P=r.jsx(fh,{icon:C,label:N,description:V,active:E,available:T,disabledHint:k,onSelect:R}),e[39]=h.agentSandbox,e[40]=N,e[41]=V,e[42]=E,e[43]=k,e[44]=R,e[45]=P):P=e[45];let D;e[46]===Symbol.for("react.memo_cache_sentinel")?(D=r.jsx(Nr,{size:14}),e[46]=D):D=e[46];let I;e[47]!==o?(I=o("chat.runtimeSwitcher.thisDevice"),e[47]=o,e[48]=I):I=e[48];let M;e[49]!==o?(M=o("chat.runtimeSwitcher.runsOnYourMachineViaDecoLink"),e[49]=o,e[50]=M):M=e[50];const O=v.key==="local",F=f!==null;let $;e[51]!==o?($=o("chat.runtimeSwitcher.runDecocmsLinkOnYourDesktop"),e[51]=o,e[52]=$):$=e[52];let z;e[53]!==f||e[54]!==l?(z=()=>f&&l(f),e[53]=f,e[54]=l,e[55]=z):z=e[55];let K;e[56]!==I||e[57]!==M||e[58]!==O||e[59]!==F||e[60]!==$||e[61]!==z?(K=r.jsx(fh,{icon:D,label:I,description:M,active:O,available:F,disabledHint:$,onSelect:z}),e[56]=I,e[57]=M,e[58]=O,e[59]=F,e[60]=$,e[61]=z,e[62]=K):K=e[62];let X;e[63]!==S||e[64]!==P||e[65]!==K?(X=r.jsxs(hs,{align:"start",className:"w-64 p-1",children:[S,P,K]}),e[63]=S,e[64]=P,e[65]=K,e[66]=X):X=e[66];let J;return e[67]!==x||e[68]!==X||e[69]!==w?(J=r.jsxs(x,{children:[w,X]}),e[67]=x,e[68]=X,e[69]=w,e[70]=J):J=e[70],J}function B_(t){const e=B.c(2),{branchPill:s}=t;if(!s)return null;let n;return e[0]!==s?(n=r.jsx(r.Fragment,{children:s}),e[0]=s,e[1]=n):n=e[1],n}function hp(t){const e=B.c(27),{virtualMcp:s,currentBranch:n,showRuntimeLabel:i}=t,o=i===void 0?!1:i,a=q0(),l=Ii();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=ia(s),e[3]=s,e[4]=u):u=e[4];const f=u,m=f?.connectionId,p=!!f,{data:g}=Di.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 b=v,{org:_}=Fe();let y;e[8]!==m||e[9]!==n||e[10]!==f||e[11]!==d||e[12]!==_||e[13]!==h||e[14]!==x||e[15]!==b||e[16]!==s?.id||e[17]!==s?.metadata?.sandboxMap?(y=f&&m?r.jsx(m_,{orgId:_.id,orgSlug:_.slug,userId:x,userLabel:b,virtualMcpId:s?.id??"",connectionId:m,owner:f.owner,repo:f.name,sandboxMap:s?.metadata?.sandboxMap,value:n,onChange:C=>{h&&h(C)},locked:d,placement:"chat"}):null,e[8]=m,e[9]=n,e[10]=f,e[11]=d,e[12]=_,e[13]=h,e[14]=x,e[15]=b,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&&r.jsx($_,{showLabel:o}),e[19]=p,e[20]=o,e[21]=w):w=e[21];let j;e[22]!==L?(j=r.jsx(B_,{branchPill:L}),e[22]=L,e[23]=j):j=e[23];let S;return e[24]!==w||e[25]!==j?(S=r.jsxs(r.Fragment,{children:[w,j]}),e[24]=w,e[25]=j,e[26]=S):S=e[26],S}const F_={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"}},z_={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 K_(t){return t==="claude-code"?F_:t==="codex"?z_:null}function mh(t,e){return K_(t)?.[e]??null}const U_={decopilot:"cloud-decopilot","claude-code-desktop":"local-claude-code","codex-desktop":"local-codex"};function H_(t){return t===null?"cloud-decopilot":U_[t]}function W_(){const t=B.c(2),{pendingAgentOption:e}=Ts();let s;return t[0]!==e?(s=H_(e),t[0]=e,t[1]=s):s=t[1],s}function q_(){return Ts().simpleModeTier}function G_(){return Ts().setSimpleModeTier}const Y_={fast:"Quicker responses",smart:"Balanced quality",thinking:"Deeper reasoning"};function fp(t,e){return t==="local-claude-code"?mh("claude-code",e)?.label??null:t==="local-codex"?mh("codex",e)?.label??null:Y_[e]}const mp=["fast","smart","thinking"];function J_(t){const e=B.c(33),{tier:s,pillIcon:n,pillLabel:i,groups:o,header:a}=t,l=re();let c;e[0]!==l?(c={fast:l("chat.tierTrigger.tierFast"),smart:l("chat.tierTrigger.tierSmart"),thinking:l("chat.tierTrigger.tierThinking")},e[0]=l,e[1]=c):c=e[1];const d=c,[h,u]=A.useState(!1);let f;e[2]===Symbol.for("react.memo_cache_sentinel")?(f=E=>{E.onSelect(),u(!1)},e[2]=f):f=e[2];const m=f,p=i??d[s];let g;e[3]===Symbol.for("react.memo_cache_sentinel")?(g=ie("text-muted-foreground hover:text-foreground transition-[gap] duration-200 shrink min-w-0","gap-0 @[320px]/chat-bottom:gap-1.5"),e[3]=g):g=e[3];let x;e[4]===Symbol.for("react.memo_cache_sentinel")?(x=ie("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[4]=x):x=e[4];const v=d[s];let b;e[5]!==v?(b=r.jsx("span",{className:x,children:v}),e[5]=v,e[6]=b):b=e[6];let _;e[7]===Symbol.for("react.memo_cache_sentinel")?(_=r.jsx(ss,{size:12,className:"opacity-60 hidden @[320px]/chat-bottom:inline-block"}),e[7]=_):_=e[7];let y;e[8]!==n||e[9]!==p||e[10]!==b?(y=r.jsx(Ke,{asChild:!0,children:r.jsx("span",{className:"inline-flex min-w-0 shrink",children:r.jsx(Es,{asChild:!0,children:r.jsxs(le,{type:"button",variant:"ghost",size:"default","aria-label":p,className:g,children:[n,b,_]})})})}),e[8]=n,e[9]=p,e[10]=b,e[11]=y):y=e[11];let L;e[12]!==p?(L=r.jsx(Ue,{children:p}),e[12]=p,e[13]=L):L=e[13];let w;e[14]!==y||e[15]!==L?(w=r.jsxs(He,{children:[y,L]}),e[14]=y,e[15]=L,e[16]=w):w=e[16];let j;e[17]!==a?(j=a&&r.jsx("div",{className:"mb-1 border-b border-border/60 pb-1",children:a}),e[17]=a,e[18]=j):j=e[18];let S;if(e[19]!==o||e[20]!==l){let E;e[22]!==l?(E=T=>r.jsxs("div",{className:"flex flex-col",children:[T.label&&r.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:r.jsx("span",{className:"truncate",children:T.label})}),T.rows.map(k=>r.jsxs("button",{type:"button",role:"menuitem","aria-label":T.label?`${T.label} ${k.title}`:k.title,onClick:()=>m(k),className:ie("flex items-start gap-2 px-2 py-1.5 rounded-md text-left","hover:bg-muted"),children:[k.icon&&r.jsx("span",{className:"shrink-0 text-muted-foreground mt-0.5",children:k.icon}),r.jsxs("div",{className:"flex-1",children:[r.jsx("div",{className:"text-sm",children:k.title}),k.subtitle&&r.jsx("div",{className:"text-xs text-muted-foreground",children:k.subtitle})]}),k.active&&r.jsx("span",{title:l("chat.tierTrigger.selected"),children:r.jsx(zt,{size:14,className:"text-foreground mt-0.5"})})]},k.key))]},T.key),e[22]=l,e[23]=E):E=e[23],S=o.map(E),e[19]=o,e[20]=l,e[21]=S}else S=e[21];let C;e[24]!==S?(C=r.jsx("div",{role:"menu",className:"flex flex-col",children:S}),e[24]=S,e[25]=C):C=e[25];let N;e[26]!==j||e[27]!==C?(N=r.jsxs(Ps,{align:"end",className:"p-1 w-64",children:[j,C]}),e[26]=j,e[27]=C,e[28]=N):N=e[28];let V;return e[29]!==h||e[30]!==w||e[31]!==N?(V=r.jsxs(As,{open:h,onOpenChange:u,children:[w,N]}),e[29]=h,e[30]=w,e[31]=N,e[32]=V):V=e[32],V}function ph(t){return t==="fast"?r.jsx(e9,{size:16}):t==="thinking"?r.jsx(Bm,{size:16}):r.jsx(Gn,{size:16})}const X_="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",Q_="bg-background text-foreground shadow-sm",Z_="text-muted-foreground hover:text-foreground";function e7(t){const e=B.c(7),{options:s}=t,n=re();let i;if(e[0]!==s||e[1]!==n){let a;e[3]!==n?(a=l=>r.jsxs("button",{type:"button",onClick:l.onSelect,className:ie(X_,l.active?Q_:Z_),title:l.active?n("chat.tierTrigger.selected"):void 0,children:[l.icon,r.jsx("span",{className:"truncate",children:l.label})]},l.key),e[3]=n,e[4]=a):a=e[4],i=s.map(a),e[0]=s,e[1]=n,e[2]=i}else i=e[2];let o;return e[5]!==i?(o=r.jsx("div",{className:"flex items-center gap-1 p-1 rounded-lg bg-muted",children:i}),e[5]=i,e[6]=o):o=e[6],o}function t7(){const t=B.c(24),e=re(),{pendingHarnessId:s,setPendingAgentOption:n}=Ts(),i=ac(),o=s==="claude-code"||s==="codex";let a;t[0]!==i?(a=_m(i)??"claude-code-desktop",t[0]=i,t[1]=a):a=t[1];const l=a;let c;t[2]===Symbol.for("react.memo_cache_sentinel")?(c=r.jsx(Z0,{size:14}),t[2]=c):c=t[2];let d;t[3]!==e?(d=e("chat.tierTrigger.runtimeCloud"),t[3]=e,t[4]=d):d=t[4];const h=!o;let u;t[5]!==n?(u=()=>n("decopilot"),t[5]=n,t[6]=u):u=t[6];let f;t[7]!==d||t[8]!==h||t[9]!==u?(f={key:"cloud",icon:c,label:d,active:h,onSelect:u},t[7]=d,t[8]=h,t[9]=u,t[10]=f):f=t[10];let m;t[11]===Symbol.for("react.memo_cache_sentinel")?(m=r.jsx(Nr,{size:14}),t[11]=m):m=t[11];let p;t[12]!==e?(p=e("chat.tierTrigger.runtimeThisDevice"),t[12]=e,t[13]=p):p=t[13];let g;t[14]!==l||t[15]!==n?(g=()=>n(l),t[14]=l,t[15]=n,t[16]=g):g=t[16];let x;t[17]!==o||t[18]!==p||t[19]!==g?(x={key:"local",icon:m,label:p,active:o,onSelect:g},t[17]=o,t[18]=p,t[19]=g,t[20]=x):x=t[20];let v;return t[21]!==f||t[22]!==x?(v=r.jsx("div",{className:"p-1",children:r.jsx(e7,{options:[f,x]})}),t[21]=f,t[22]=x,t[23]=v):v=t[23],v}function gh(t){return{key:t.key,label:t.label,rows:mp.map(e=>({key:`${t.key}-${e}`,icon:t.icon,title:t.tierLabels[e],subtitle:fp(t.mode,e),active:t.isActiveRuntime&&t.currentTier===e,onSelect:()=>{t.setOption(t.option),t.setTier(e)}}))}}function s7(){const t=B.c(37),e=re(),s=q_(),n=G_(),i=W_(),{pendingHarnessId:o,setPendingAgentOption:a}=Ts(),l=ac(),d=Ii()?.isThreadLocked??!1,h=l.claudeCode||l.codex,u=i!=="cloud-decopilot";let f;t[0]!==e?(f=()=>({fast:e("chat.tierTrigger.tierFast"),smart:e("chat.tierTrigger.tierSmart"),thinking:e("chat.tierTrigger.tierThinking")}),t[0]=e,t[1]=f):f=t[1];const m=f;let p,g;if(t[2]!==l.claudeCode||t[3]!==l.codex||t[4]!==m||t[5]!==u||t[6]!==d||t[7]!==o||t[8]!==a||t[9]!==n||t[10]!==e||t[11]!==s){if(g=m(),u){const w=d?o==="claude-code":l.claudeCode||o==="claude-code",j=d?o==="codex":l.codex||o==="codex",S=w&&j,C=[];if(w){let N;t[14]===Symbol.for("react.memo_cache_sentinel")?(N=r.jsx(A6,{size:16}),t[14]=N):N=t[14],C.push(gh({key:"claude-code",label:S?e("chat.tierTrigger.runtimeClaudeCode"):void 0,icon:N,mode:"local-claude-code",option:"claude-code-desktop",isActiveRuntime:o==="claude-code",currentTier:s,setOption:a,setTier:n,tierLabels:g}))}if(j){let N;t[15]===Symbol.for("react.memo_cache_sentinel")?(N=r.jsx(E6,{size:16}),t[15]=N):N=t[15],C.push(gh({key:"codex",label:S?e("chat.tierTrigger.runtimeCodex"):void 0,icon:N,mode:"local-codex",option:"codex-desktop",isActiveRuntime:o==="codex",currentTier:s,setOption:a,setTier:n,tierLabels:g}))}p=C}else{const w={key:"cloud",rows:mp.map(S=>({key:`cloud-${S}`,icon:ph(S),title:g[S],subtitle:fp("cloud-decopilot",S),active:s===S,onSelect:()=>n(S)}))};let j;t[16]!==w?(j=[w],t[16]=w,t[17]=j):j=t[17],p=j}t[2]=l.claudeCode,t[3]=l.codex,t[4]=m,t[5]=u,t[6]=d,t[7]=o,t[8]=a,t[9]=n,t[10]=e,t[11]=s,t[12]=p,t[13]=g}else p=t[12],g=t[13];let x,v,b,_;if(t[18]!==u||t[19]!==o||t[20]!==e||t[21]!==s||t[22]!==g){const w=u?T6(o):null,j=w?.Icon;x=J_,v=s,b=j?r.jsx(j,{size:16}):ph(s),_=w?`${e(w.labelKey)} ${g[s]}`:g[s],t[18]=u,t[19]=o,t[20]=e,t[21]=s,t[22]=g,t[23]=x,t[24]=v,t[25]=b,t[26]=_}else x=t[23],v=t[24],b=t[25],_=t[26];let y;t[27]!==h||t[28]!==d?(y=h&&!d?r.jsx(t7,{}):void 0,t[27]=h,t[28]=d,t[29]=y):y=t[29];let L;return t[30]!==x||t[31]!==p||t[32]!==v||t[33]!==b||t[34]!==_||t[35]!==y?(L=r.jsx(x,{tier:v,pillIcon:b,pillLabel:_,groups:p,header:y}),t[30]=x,t[31]=p,t[32]=v,t[33]=b,t[34]=_,t[35]=y,t[36]=L):L=t[36],L}async function A9(t,e,s,n,i,o){if(!Ql(e)){ge.error("Selected model does not support file uploads");return}const a=s.type||"application/octet-stream";if(!P6(a,e)){const c=i2(e).parts.map(h=>o(h)).join(", "),d=e?.title??"This model";i?i({fileName:s.name,modelName:d,accepted:c}):ge.error(`"${s.name}" can't be attached`,{description:`${d} accepts ${c}.`});return}const l=10*1024*1024;if(s.size>l){ge.error(`File "${s.name}" exceeds 10MB limit`);return}try{const c=new FileReader,d=new Promise((f,m)=>{c.onload=()=>{const p=c.result;if(typeof p!="string"){m(new Error("Failed to read file as data URL"));return}const g=p.includes(",")?p.split(",")[1]??p:p;f(g)},c.onerror=m});c.readAsDataURL(s);const h=await d,u={id:crypto.randomUUID(),name:s.name,mimeType:s.type||"application/octet-stream",size:s.size,data:h};Px(t,{from:n,to:n},u)}catch(c){console.error("Failed to process file:",c),ge.error(`Failed to load file "${s.name}"`)}}function n7(t){const e=B.c(9),{editor:s,selectedModel:n,onUnsupportedFile:i}=t,o=re(),a=A.useRef(r7);let l,c;e[0]!==s||e[1]!==i||e[2]!==n||e[3]!==o?(l=()=>{a.current=async(u,f)=>{await A9(s,n,u,f,i,o)}},c=[s,n,i,o],e[0]=s,e[1]=i,e[2]=n,e[3]=o,e[4]=l,e[5]=c):(l=e[4],c=e[5]),A.useEffect(l,c);let d,h;return e[6]!==s?(d=()=>{if(s?.isDestroyed)return;const u=new cv("fileDropHandler");s.state.plugins.find(p=>p.spec.key===u)&&s.unregisterPlugin(u);const m=new dv({key:u,props:{handleDrop:(p,g,x,v)=>{if(v)return!1;const b=g.dataTransfer?.files;if(!b||b.length===0)return!1;g.preventDefault();const _=p.posAtCoords({left:g.clientX,top:g.clientY});if(!_)return!1;const y=Array.from(b);return(async()=>{let L=_.pos;for(const w of y)await a.current?.(w,L),L=p.state.selection.to})(),!0},handlePaste:(p,g)=>{const x=g.clipboardData?.items;if(!x)return!1;const v=Array.from(x).filter(i7);return v.length===0?!1:(g.preventDefault(),(async()=>{let b=p.state.selection.from;for(const _ of v){const y=_.getAsFile();y&&(await a.current?.(y,b),b=p.state.selection.to)}})(),!0)}}});return s.registerPlugin(m),()=>{s?.isDestroyed||s.unregisterPlugin(u)}},h=[s],e[6]=s,e[7]=d,e[8]=h):(d=e[7],h=e[8]),A.useEffect(d,h),null}function i7(t){return t.kind==="file"}function r7(){return Promise.resolve()}function o7(t){const e=B.c(43),{info:s,onClose:n}=t,i=re(),o=s!==null;let a;e[0]!==n?(a=E=>!E&&n(),e[0]=n,e[1]=a):a=e[1];let l;e[2]===Symbol.for("react.memo_cache_sentinel")?(l=["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]=l):l=e[2];let c;e[3]===Symbol.for("react.memo_cache_sentinel")?(c=r.jsx("div",{className:"absolute inset-x-0 top-0 h-36 pointer-events-none",style:{backgroundImage:l.join(", "),maskImage:"linear-gradient(to bottom, black 0%, transparent 100%)",WebkitMaskImage:"linear-gradient(to bottom, black 0%, transparent 100%)"}}),e[3]=c):c=e[3];let d;e[4]===Symbol.for("react.memo_cache_sentinel")?(d=r.jsx("div",{className:"flex items-center justify-center size-9 rounded-lg bg-warning/15 text-warning",children:r.jsx(Sr,{size:18})}),e[4]=d):d=e[4];let h;e[5]!==i?(h=i("chat.uploader.fileTypeNotSupported"),e[5]=i,e[6]=h):h=e[6];let u;e[7]!==h?(u=r.jsx(ps,{className:"text-xl font-semibold tracking-tight",children:h}),e[7]=h,e[8]=u):u=e[8];const f=s?.fileName;let m;e[9]!==f?(m=r.jsxs("span",{className:"font-medium text-foreground",children:["“",f,"”"]}),e[9]=f,e[10]=m):m=e[10];let p;e[11]!==i?(p=i("chat.uploader.cantAttachToChat"),e[11]=i,e[12]=p):p=e[12];let g;e[13]!==p||e[14]!==m?(g=r.jsxs(oi,{className:"mt-1.5 text-sm leading-relaxed",children:[m," ",p]}),e[13]=p,e[14]=m,e[15]=g):g=e[15];let x;e[16]!==g||e[17]!==u?(x=r.jsxs("div",{className:"relative px-8 pt-8 pb-2 overflow-hidden",children:[c,r.jsxs(ms,{className:"relative gap-4",children:[d,r.jsxs("div",{children:[u,g]})]})]}),e[16]=g,e[17]=u,e[18]=x):x=e[18];const v=s?.modelName??"";let b;e[19]!==i||e[20]!==v?(b=i("chat.uploader.accepts",{modelName:v}),e[19]=i,e[20]=v,e[21]=b):b=e[21];let _;e[22]!==b?(_=r.jsx("div",{className:"text-xs font-medium uppercase tracking-wide text-muted-foreground mb-2",children:b}),e[22]=b,e[23]=_):_=e[23];let y;e[24]===Symbol.for("react.memo_cache_sentinel")?(y=r.jsx(Kv,{size:14,className:"text-muted-foreground"}),e[24]=y):y=e[24];const L=s?.accepted;let w;e[25]!==L?(w=r.jsxs("div",{className:"flex items-center gap-2 text-sm text-foreground",children:[y,r.jsx("span",{className:"capitalize",children:L})]}),e[25]=L,e[26]=w):w=e[26];let j;e[27]!==_||e[28]!==w?(j=r.jsx("div",{className:"px-8 pt-3 pb-6 space-y-3",children:r.jsxs("div",{className:"rounded-xl border border-border p-4",children:[_,w]})}),e[27]=_,e[28]=w,e[29]=j):j=e[29];let S;e[30]!==i?(S=i("chat.uploader.gotIt"),e[30]=i,e[31]=S):S=e[31];let C;e[32]!==n||e[33]!==S?(C=r.jsx("div",{className:"px-8 py-4 border-t border-border bg-muted/30 flex items-center justify-end",children:r.jsx(le,{onClick:n,children:S})}),e[32]=n,e[33]=S,e[34]=C):C=e[34];let N;e[35]!==x||e[36]!==j||e[37]!==C?(N=r.jsxs(es,{className:"sm:max-w-[480px] gap-0 p-0 overflow-hidden",onOpenAutoFocus:a7,children:[x,j,C]}),e[35]=x,e[36]=j,e[37]=C,e[38]=N):N=e[38];let V;return e[39]!==o||e[40]!==a||e[41]!==N?(V=r.jsx(ts,{open:o,onOpenChange:a,children:N}),e[39]=o,e[40]=a,e[41]=N,e[42]=V):V=e[42],V}function a7(t){return t.preventDefault()}function l7(){const t=B.c(3),[e,s]=A.useState(null);let n;t[0]===Symbol.for("react.memo_cache_sentinel")?(n=()=>s(null),t[0]=n):n=t[0];let i;return t[1]!==e?(i={unsupportedFile:e,onUnsupportedFile:s,clearUnsupportedFile:n},t[1]=e,t[2]=i):i=t[2],i}var c7=Rx;var d7=["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] *)"],Od=d7.join(","),pp=typeof Element>"u",Bo=pp?function(){}:Element.prototype.matches||Element.prototype.msMatchesSelector||Element.prototype.webkitMatchesSelector,Ll=!pp&&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},Sl=function(e,s){var n;s===void 0&&(s=!0);var i=e==null||(n=e.getAttribute)===null||n===void 0?void 0:n.call(e,"inert"),o=i===""||i==="true",a=o||s&&e&&(typeof e.closest=="function"?e.closest("[inert]"):Sl(e.parentNode));return a},u7=function(e){var s,n=e==null||(s=e.getAttribute)===null||s===void 0?void 0:s.call(e,"contenteditable");return n===""||n==="true"},h7=function(e,s,n){if(Sl(e))return[];var i=Array.prototype.slice.apply(e.querySelectorAll(Od));return s&&Bo.call(e,Od)&&i.unshift(e),i=i.filter(n),i},$d=function(e,s,n){for(var i=[],o=Array.from(e);o.length;){var a=o.shift();if(!Sl(a,!1))if(a.tagName==="SLOT"){var l=a.assignedElements(),c=l.length?l:a.children,d=$d(c,!0,n);n.flatten?i.push.apply(i,d):i.push({scopeParent:a,candidates:d})}else{var h=Bo.call(a,Od);h&&n.filter(a)&&(s||!e.includes(a))&&i.push(a);var u=a.shadowRoot||typeof n.getShadowRoot=="function"&&n.getShadowRoot(a),f=!Sl(u,!1)&&(!n.shadowRootFilter||n.shadowRootFilter(a));if(u&&f){var m=$d(u===!0?a.children:u.children,!0,n);n.flatten?i.push.apply(i,m):i.push({scopeParent:a,candidates:m})}else o.unshift.apply(o,a.children)}}return i},gp=function(e){return!isNaN(parseInt(e.getAttribute("tabindex"),10))},xp=function(e){if(!e)throw new Error("No node provided");return e.tabIndex<0&&(/^(AUDIO|VIDEO|DETAILS)$/.test(e.tagName)||u7(e))&&!gp(e)?0:e.tabIndex},f7=function(e,s){var n=xp(e);return n<0&&s&&!gp(e)?0:n},m7=function(e,s){return e.tabIndex===s.tabIndex?e.documentOrder-s.documentOrder:e.tabIndex-s.tabIndex},vp=function(e){return e.tagName==="INPUT"},p7=function(e){return vp(e)&&e.type==="hidden"},g7=function(e){var s=e.tagName==="DETAILS"&&Array.prototype.slice.apply(e.children).some(function(n){return n.tagName==="SUMMARY"});return s},x7=function(e,s){for(var n=0;n<e.length;n++)if(e[n].checked&&e[n].form===s)return e[n]},v7=function(e){if(!e.name)return!0;var s=e.form||Ll(e),n=function(l){return s.querySelectorAll('input[type="radio"][name="'+l+'"]')},i;if(typeof window<"u"&&typeof window.CSS<"u"&&typeof window.CSS.escape=="function")i=n(window.CSS.escape(e.name));else try{i=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=x7(i,e.form);return!o||o===e},b7=function(e){return vp(e)&&e.type==="radio"},y7=function(e){return b7(e)&&!v7(e)},_7=function(e){var s,n=e&&Ll(e),i=(s=n)===null||s===void 0?void 0:s.host,o=!1;if(n&&n!==e){var a,l,c;for(o=!!((a=i)!==null&&a!==void 0&&(l=a.ownerDocument)!==null&&l!==void 0&&l.contains(i)||e!=null&&(c=e.ownerDocument)!==null&&c!==void 0&&c.contains(e));!o&&i;){var d,h,u;n=Ll(i),i=(d=n)===null||d===void 0?void 0:d.host,o=!!((h=i)!==null&&h!==void 0&&(u=h.ownerDocument)!==null&&u!==void 0&&u.contains(i))}}return o},xh=function(e){var s=e.getBoundingClientRect(),n=s.width,i=s.height;return n===0&&i===0},L7=function(e,s){var n=s.displayCheck,i=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=Bo.call(e,"details>summary:first-of-type"),l=a?e.parentElement:e;if(Bo.call(l,"details:not([open]) *"))return!0;if(!n||n==="full"||n==="full-native"||n==="legacy-full"){if(typeof i=="function"){for(var c=e;e;){var d=e.parentElement,h=Ll(e);if(d&&!d.shadowRoot&&i(d)===!0)return xh(e);e.assignedSlot?e=e.assignedSlot:!d&&h!==e.ownerDocument?e=h.host:e=d}e=c}if(_7(e))return!e.getClientRects().length;if(n!=="legacy-full")return!0}else if(n==="non-zero-area")return xh(e);return!1},S7=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 i=s.children.item(n);if(i.tagName==="LEGEND")return Bo.call(s,"fieldset[disabled] *")?!0:!i.contains(e)}return!0}s=s.parentElement}return!1},w7=function(e,s){return!(s.disabled||p7(s)||L7(s,e)||g7(s)||S7(s))},vh=function(e,s){return!(y7(s)||xp(s)<0||!w7(e,s))},j7=function(e){var s=parseInt(e.getAttribute("tabindex"),10);return!!(isNaN(s)||s>=0)},bp=function(e){var s=[],n=[];return e.forEach(function(i,o){var a=!!i.scopeParent,l=a?i.scopeParent:i,c=f7(l,a),d=a?bp(i.candidates):l;c===0?a?s.push.apply(s,d):s.push(l):n.push({documentOrder:o,tabIndex:c,item:i,isScope:a,content:d})}),n.sort(m7).reduce(function(i,o){return o.isScope?i.push.apply(i,o.content):i.push(o.content),i},[]).concat(s)},yp=function(e,s){s=s||{};var n;return s.getShadowRoot?n=$d([e],s.includeContainer,{filter:vh.bind(null,s),flatten:!1,getShadowRoot:s.getShadowRoot,shadowRootFilter:j7}):n=h7(e,s.includeContainer,vh.bind(null,s)),bp(n)};function C7(){return/apple/i.test(navigator.vendor)}const bh="data-floating-ui-focusable";function k7(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 Bd(t,e){if(!t||!e)return!1;const s=e.getRootNode==null?void 0:e.getRootNode();if(t.contains(e))return!0;if(s&&Q5(s)){let n=e;for(;n;){if(t===n)return!0;n=n.parentNode||n.host}}return!1}function Ur(t){return"composedPath"in t?t.composedPath()[0]:t.target}function Kc(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 V7(t){return t.matches("html,body")}function Fo(t){return t?.ownerDocument||document}function N7(t){return t?t.hasAttribute(bh)?t:t.querySelector("["+bh+"]")||t:null}function Wa(t,e,s){return s===void 0&&(s=!0),t.filter(i=>{var o;return i.parentId===e&&(!s||((o=i.context)==null?void 0:o.open))}).flatMap(i=>[i,...Wa(t,i.id,s)])}function T7(t){return"nativeEvent"in t}var A7=typeof document<"u",E7=function(){},_i=A7?A.useLayoutEffect:E7;const P7={...hm},R7=P7.useInsertionEffect,D7=R7||(t=>t());function Zi(t){const e=A.useRef(()=>{});return D7(()=>{e.current=t}),A.useCallback(function(){for(var s=arguments.length,n=new Array(s),i=0;i<s;i++)n[i]=arguments[i];return e.current==null?void 0:e.current(...n)},[])}const _p=()=>({getShadowRoot:!0,displayCheck:typeof ResizeObserver=="function"&&ResizeObserver.toString().includes("[native code]")?"full":"none"});function Lp(t,e){const s=yp(t,_p()),n=s.length;if(n===0)return;const i=k7(Fo(t)),o=s.indexOf(i),a=o===-1?e===1?0:n-1:o+e;return s[a]}function I7(t){return Lp(Fo(t).body,1)||t}function M7(t){return Lp(Fo(t).body,-1)||t}function Uc(t,e){const s=e||t.currentTarget,n=t.relatedTarget;return!n||!Bd(s,n)}function O7(t){yp(t,_p()).forEach(s=>{s.dataset.tabindex=s.getAttribute("tabindex")||"",s.setAttribute("tabindex","-1")})}function yh(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 $7="data-floating-ui-focusable",_h="active",Lh="selected",B7={...hm};let Sh=!1,F7=0;const wh=()=>"floating-ui-"+Math.random().toString(36).slice(2,6)+F7++;function z7(){const[t,e]=A.useState(()=>Sh?wh():void 0);return _i(()=>{t==null&&e(wh())},[]),A.useEffect(()=>{Sh=!0},[]),t}const K7=B7.useId,E9=K7||z7;function U7(){const t=new Map;return{emit(e,s){var n;(n=t.get(e))==null||n.forEach(i=>i(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 H7=A.createContext(null),W7=A.createContext(null),Sp=()=>{var t;return((t=A.useContext(H7))==null?void 0:t.id)||null},wp=()=>A.useContext(W7);function P9(t){return"data-floating-ui-"+t}const q7={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},jh=A.forwardRef(function(e,s){const[n,i]=A.useState();_i(()=>{C7()&&i("button")},[]);const o={ref:s,tabIndex:0,role:n,"aria-hidden":n?void 0:!0,[P9("focus-guard")]:"",style:q7};return r.jsx("span",{...e,...o})}),G7={clipPath:"inset(50%)",position:"fixed",top:0,left:0},jp=A.createContext(null),Ch=P9("portal");function Y7(t){t===void 0&&(t={});const{id:e,root:s}=t,n=E9(),i=X7(),[o,a]=A.useState(null),l=A.useRef(null);return _i(()=>()=>{o?.remove(),queueMicrotask(()=>{l.current=null})},[o]),_i(()=>{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(Ch,""),c.appendChild(d),l.current=d,a(d)},[e,n]),_i(()=>{if(s===null||!n||l.current)return;let c=s||i?.portalNode;c&&!ix(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(Ch,""),c=d||c,c.appendChild(h),l.current=h,a(h)},[e,s,n,i]),o}function J7(t){const{children:e,id:s,root:n,preserveTabOrder:i=!0}=t,o=Y7({id:s,root:n}),[a,l]=A.useState(null),c=A.useRef(null),d=A.useRef(null),h=A.useRef(null),u=A.useRef(null),f=a?.modal,m=a?.open,p=!!a&&!a.modal&&a.open&&i&&!!(n||o);return A.useEffect(()=>{if(!o||!i||f)return;function g(x){o&&Uc(x)&&(x.type==="focusin"?yh:O7)(o)}return o.addEventListener("focusin",g,!0),o.addEventListener("focusout",g,!0),()=>{o.removeEventListener("focusin",g,!0),o.removeEventListener("focusout",g,!0)}},[o,i,f]),A.useEffect(()=>{o&&(m||yh(o))},[m,o]),r.jsxs(jp.Provider,{value:A.useMemo(()=>({preserveTabOrder:i,beforeOutsideRef:c,afterOutsideRef:d,beforeInsideRef:h,afterInsideRef:u,portalNode:o,setFocusManagerState:l}),[i,o]),children:[p&&o&&r.jsx(jh,{"data-type":"outside",ref:c,onFocus:g=>{if(Uc(g,o)){var x;(x=h.current)==null||x.focus()}else{const v=a?a.domReference:null,b=M7(v);b?.focus()}}}),p&&o&&r.jsx("span",{"aria-owns":o.id,style:G7}),o&&tr.createPortal(e,o),p&&o&&r.jsx(jh,{"data-type":"outside",ref:d,onFocus:g=>{if(Uc(g,o)){var x;(x=u.current)==null||x.focus()}else{const v=a?a.domReference:null,b=I7(v);b?.focus(),a?.closeOnFocusOut&&a?.onOpenChange(!1,g.nativeEvent,"focus-out")}}})]})}const X7=()=>A.useContext(jp),Q7={pointerdown:"onPointerDown",mousedown:"onMouseDown",click:"onClick"},Z7={pointerdown:"onPointerDownCapture",mousedown:"onMouseDownCapture",click:"onClickCapture"},kh=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 eL(t,e){e===void 0&&(e={});const{open:s,onOpenChange:n,elements:i,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=wp(),x=Zi(typeof c=="function"?c:()=>!1),v=typeof c=="function"?x:c,b=A.useRef(!1),{escapeKey:_,outsidePress:y}=kh(m),{escapeKey:L,outsidePress:w}=kh(p),j=A.useRef(!1),S=Zi(k=>{var R;if(!s||!a||!l||k.key!=="Escape"||j.current)return;const P=(R=o.current.floatingContext)==null?void 0:R.nodeId,D=g?Wa(g.nodesRef.current,P):[];if(!_&&(k.stopPropagation(),D.length>0)){let I=!0;if(D.forEach(M=>{var O;if((O=M.context)!=null&&O.open&&!M.context.dataRef.current.__escapeKeyBubbles){I=!1;return}}),!I)return}n(!1,T7(k)?k.nativeEvent:k,"escape-key")}),C=Zi(k=>{var R;const P=()=>{var D;S(k),(D=Ur(k))==null||D.removeEventListener("keydown",P)};(R=Ur(k))==null||R.addEventListener("keydown",P)}),N=Zi(k=>{var R;const P=o.current.insideReactTree;o.current.insideReactTree=!1;const D=b.current;if(b.current=!1,d==="click"&&D||P||typeof v=="function"&&!v(k))return;const I=Ur(k),M="["+P9("inert")+"]",O=Fo(i.floating).querySelectorAll(M);let F=hn(I)?I:null;for(;F&&!Oc(F);){const X=tx(F);if(Oc(X)||!hn(X))break;F=X}if(O.length&&hn(I)&&!V7(I)&&!Bd(I,i.floating)&&Array.from(O).every(X=>!Bd(F,X)))return;if(sx(I)&&T){const X=Oc(I),J=nx(I),H=/auto|scroll/,W=X||H.test(J.overflowX),U=X||H.test(J.overflowY),Q=W&&I.clientWidth>0&&I.scrollWidth>I.clientWidth,q=U&&I.clientHeight>0&&I.scrollHeight>I.clientHeight,Z=J.direction==="rtl",Y=q&&(Z?k.offsetX<=I.offsetWidth-I.clientWidth:k.offsetX>I.clientWidth),ee=Q&&k.offsetY>I.clientHeight;if(Y||ee)return}const $=(R=o.current.floatingContext)==null?void 0:R.nodeId,z=g&&Wa(g.nodesRef.current,$).some(X=>{var J;return Kc(k,(J=X.context)==null?void 0:J.elements.floating)});if(Kc(k,i.floating)||Kc(k,i.domReference)||z)return;const K=g?Wa(g.nodesRef.current,$):[];if(K.length>0){let X=!0;if(K.forEach(J=>{var H;if((H=J.context)!=null&&H.open&&!J.context.dataRef.current.__outsidePressBubbles){X=!1;return}}),!X)return}n(!1,k,"outside-press")}),V=Zi(k=>{var R;const P=()=>{var D;N(k),(D=Ur(k))==null||D.removeEventListener(d,P)};(R=Ur(k))==null||R.addEventListener(d,P)});A.useEffect(()=>{if(!s||!a)return;o.current.__escapeKeyBubbles=_,o.current.__outsidePressBubbles=y;let k=-1;function R(O){n(!1,O,"ancestor-scroll")}function P(){window.clearTimeout(k),j.current=!0}function D(){k=window.setTimeout(()=>{j.current=!1},ex()?5:0)}const I=Fo(i.floating);l&&(I.addEventListener("keydown",L?C:S,L),I.addEventListener("compositionstart",P),I.addEventListener("compositionend",D)),v&&I.addEventListener(d,w?V:N,w);let M=[];return f&&(hn(i.domReference)&&(M=Mc(i.domReference)),hn(i.floating)&&(M=M.concat(Mc(i.floating))),!hn(i.reference)&&i.reference&&i.reference.contextElement&&(M=M.concat(Mc(i.reference.contextElement)))),M=M.filter(O=>{var F;return O!==((F=I.defaultView)==null?void 0:F.visualViewport)}),M.forEach(O=>{O.addEventListener("scroll",R,{passive:!0})}),()=>{l&&(I.removeEventListener("keydown",L?C:S,L),I.removeEventListener("compositionstart",P),I.removeEventListener("compositionend",D)),v&&I.removeEventListener(d,w?V:N,w),M.forEach(O=>{O.removeEventListener("scroll",R)}),window.clearTimeout(k)}},[o,i,l,v,d,s,n,f,a,_,y,S,L,C,N,w,V]),A.useEffect(()=>{o.current.insideReactTree=!1},[o,v,d]);const E=A.useMemo(()=>({onKeyDown:S,...h&&{[Q7[u]]:k=>{n(!1,k.nativeEvent,"reference-press")},...u!=="click"&&{onClick(k){n(!1,k.nativeEvent,"reference-press")}}}}),[S,n,h,u]),T=A.useMemo(()=>{function k(R){R.button===0&&(b.current=!0)}return{onKeyDown:S,onMouseDown:k,onMouseUp:k,[Z7[d]]:()=>{o.current.insideReactTree=!0}}},[S,d,o]);return A.useMemo(()=>a?{reference:E,floating:T}:{},[a,E,T])}function tL(t){const{open:e=!1,onOpenChange:s,elements:n}=t,i=E9(),o=A.useRef({}),[a]=A.useState(()=>U7()),l=Sp()!=null,[c,d]=A.useState(n.reference),h=Zi((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=A.useMemo(()=>({setPositionReference:d}),[]),f=A.useMemo(()=>({reference:c||n.reference||null,floating:n.floating||null,domReference:n.reference}),[c,n.reference,n.floating]);return A.useMemo(()=>({dataRef:o,open:e,onOpenChange:h,elements:f,events:a,floatingId:i,refs:u}),[e,h,f,a,i,u])}function sL(t){t===void 0&&(t={});const{nodeId:e}=t,s=tL({...t,elements:{reference:null,floating:null,...t.elements}}),n=t.rootContext||s,i=n.elements,[o,a]=A.useState(null),[l,c]=A.useState(null),h=i?.domReference||o,u=A.useRef(null),f=wp();_i(()=>{h&&(u.current=h)},[h]);const m=Z5({...t,elements:{...i,...l&&{reference:l}}}),p=A.useCallback(_=>{const y=hn(_)?{getBoundingClientRect:()=>_.getBoundingClientRect(),getClientRects:()=>_.getClientRects(),contextElement:_}:_;c(y),m.refs.setReference(y)},[m.refs]),g=A.useCallback(_=>{(hn(_)||_===null)&&(u.current=_,a(_)),(hn(m.refs.reference.current)||m.refs.reference.current===null||_!==null&&!hn(_))&&m.refs.setReference(_)},[m.refs]),x=A.useMemo(()=>({...m.refs,setReference:g,setPositionReference:p,domReference:u}),[m.refs,g,p]),v=A.useMemo(()=>({...m.elements,domReference:h}),[m.elements,h]),b=A.useMemo(()=>({...m,...n,refs:x,elements:v,nodeId:e}),[m,x,v,e,n]);return _i(()=>{n.dataRef.current.floatingContext=b;const _=f?.nodesRef.current.find(y=>y.id===e);_&&(_.context=b)}),A.useMemo(()=>({...m,context:b,refs:x,elements:v}),[m,x,v,b])}function Hc(t,e,s){const n=new Map,i=s==="item";let o=t;if(i&&t){const{[_h]:a,[Lh]:l,...c}=t;o=c}return{...s==="floating"&&{tabIndex:-1,[$7]:""},...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(!(i&&[_h,Lh].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 nL(t){t===void 0&&(t=[]);const e=t.map(l=>l?.reference),s=t.map(l=>l?.floating),n=t.map(l=>l?.item),i=A.useCallback(l=>Hc(l,t,"reference"),e),o=A.useCallback(l=>Hc(l,t,"floating"),s),a=A.useCallback(l=>Hc(l,t,"item"),n);return A.useMemo(()=>({getReferenceProps:i,getFloatingProps:o,getItemProps:a}),[i,o,a])}const iL=new Map([["select","listbox"],["combobox","listbox"],["label",!1]]);function rL(t,e){var s,n;e===void 0&&(e={});const{open:i,elements:o,floatingId:a}=t,{enabled:l=!0,role:c="dialog"}=e,d=E9(),h=((s=o.domReference)==null?void 0:s.id)||d,u=A.useMemo(()=>{var b;return((b=N7(o.floating))==null?void 0:b.id)||a},[o.floating,a]),f=(n=iL.get(c))!=null?n:c,p=Sp()!=null,g=A.useMemo(()=>f==="tooltip"||c==="label"?{["aria-"+(c==="label"?"labelledby":"describedby")]:i?u:void 0}:{"aria-expanded":i?"true":"false","aria-haspopup":f==="alertdialog"?"dialog":f,"aria-controls":i?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,i,h,c]),x=A.useMemo(()=>{const b={id:u,...f&&{role:f}};return f==="tooltip"||c==="label"?b:{...b,...f==="menu"&&{"aria-labelledby":h}}},[f,u,h,c]),v=A.useCallback(b=>{let{active:_,selected:y}=b;const L={role:"option",..._&&{id:u+"-fui-option"}};switch(c){case"select":case"combobox":return{...L,"aria-selected":y}}return{}},[u,c]);return A.useMemo(()=>l?{reference:g,floating:x,item:v}:{},[l,g,x,v])}function oL({children:t}){const{state:e,dispatch:s}=Cv(),{open:n,element:i}=e,o=()=>{s({type:"ON_EXIT"})},{refs:a,floatingStyles:l,context:c}=sL({placement:"bottom-start",open:n,onOpenChange:f=>{f||o()},elements:{reference:i},middleware:[rx(10),ox(),ax()],whileElementsMounted:lx}),d=eL(c,{outsidePress:f=>!(f.target instanceof Element&&f.target.closest(".ProseMirror"))}),h=rL(c,{role:"listbox"}),{getFloatingProps:u}=nL([d,h]);return n?r.jsx(J7,{children:r.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 aL=t=>{const e=B.c(29),{item:s,isSelected:n,onSelect:i,isLoading:o,ref:a}=t;let l;if(e[0]!==s){const w=pn(s._meta);l=s.title||G0(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=ie("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&&r.jsx(Qn,{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=r.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&&r.jsx(wi,{size:"xs"}),e[10]=o,e[11]=x):x=e[11];let v;e[12]!==g||e[13]!==x?(v=r.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 b;e[15]!==d?(b=d&&r.jsx("div",{className:"text-xs text-muted-foreground line-clamp-1",children:d}),e[15]=d,e[16]=b):b=e[16];let _;e[17]!==v||e[18]!==b?(_=r.jsxs("div",{className:"flex flex-col gap-0.5 flex-1 min-w-0",children:[v,b]}),e[17]=v,e[18]=b,e[19]=_):_=e[19];let y;e[20]!==s.drillable?(y=s.drillable&&r.jsx("kbd",{className:"shrink-0 ml-2 px-1.5 py-0.5 text-[10px] font-medium text-muted-foreground bg-muted border border-border rounded",children:"↵"}),e[20]=s.drillable,e[21]=y):y=e[21];let L;return e[22]!==i||e[23]!==a||e[24]!==_||e[25]!==y||e[26]!==m||e[27]!==p?(L=r.jsxs("div",{ref:a,onClick:i,className:m,children:[p,_,y]}),e[22]=i,e[23]=a,e[24]=_,e[25]=y,e[26]=m,e[27]=p,e[28]=L):L=e[28],L},lL=t=>{const e=B.c(21),{editor:s,queryKey:n,queryFn:i,onSelect:o}=t,a=re();let l;e[0]!==s||e[1]!==o||e[2]!==i||e[3]!==n?(l={editor:s,queryKey:n,queryFn:i,onSelect:o},e[0]=s,e[1]=o,e[2]=i,e[3]=n,e[4]=l):l=e[4];const{items:c,selectedIndex:d,onSelect:h,selectedItem:u}=kv(l);if(!c.length){let g;e[5]!==a?(g=a("chat.mention.noItemsFound"),e[5]=a,e[6]=g):g=e[6];let x;return e[7]!==g?(x=r.jsx("div",{className:"min-w-[360px] max-w-[520px] bg-popover text-popover-foreground rounded-md border shadow-md p-3 text-sm",children:g}),e[7]=g,e[8]=x):x=e[8],x}let f;e[9]===Symbol.for("react.memo_cache_sentinel")?(f={maxHeight:"min(320px, var(--radix-popover-content-available-height, 320px))"},e[9]=f):f=e[9];let m;if(e[10]!==h||e[11]!==c||e[12]!==d||e[13]!==u?.name){let g;e[15]!==h||e[16]!==d||e[17]!==u?.name?(g=(x,v)=>r.jsx(aL,{item:x,isSelected:v===d,ref:v===d?uL:void 0,onSelect:()=>h(x,v),isLoading:u?.name===x.name},`${x.kind??"item"}:${x.name}`),e[15]=h,e[16]=d,e[17]=u?.name,e[18]=g):g=e[18],m=c.map(g),e[10]=h,e[11]=c,e[12]=d,e[13]=u?.name,e[14]=m}else m=e[14];let p;return e[19]!==m?(p=r.jsx("div",{className:"min-w-[360px] max-w-[520px] bg-popover text-popover-foreground rounded-md overflow-y-auto",style:f,children:r.jsx("div",{className:"p-1",children:m})}),e[19]=m,e[20]=p):p=e[20],p};function cL(){const t=B.c(1);let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=r.jsx("div",{className:"p-1",children:[...Array(3)].map(dL)}),t[0]=e):e=t[0],e}function dL(t,e){return r.jsxs("div",{className:"flex items-center gap-1.5 px-2 py-1.5 animate-pulse",children:[r.jsx("div",{className:"h-4 w-24 bg-muted rounded"}),r.jsx("div",{className:"h-3 w-32 bg-muted rounded"})]},e)}function Cp(t){const e=B.c(18),{editor:s,char:n,pluginKey:i,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]!==i?(h={editor:s,char:n,pluginKey:i,allow:c,onOpenChange:d},e[0]=c,e[1]=n,e[2]=s,e[3]=d,e[4]=i,e[5]=h):h=e[5];const{state:u,dispatch:f}=wv(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=r.jsx(cL,{}),e[9]=p):p=e[9];let g;e[10]!==s||e[11]!==l||e[12]!==a||e[13]!==o?(g=r.jsx(oL,{children:r.jsx(A.Suspense,{fallback:p,children:r.jsx(lL,{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=r.jsx(jv.Provider,{value:m,children:g}),e[15]=m,e[16]=g,e[17]=x):x=e[17],x}function uL(t){t&&t.scrollIntoView({block:"center",behavior:"smooth"})}const hL=t=>{const e=B.c(53),{editor:s,virtualMcpId:n,suggestionOpenRef:i}=t,o=re(),a=Ls(),{org:l}=Fe(),c=ta();let d;e[0]!==c?(d=u9(c),e[0]=c,e[1]=d):d=e[1];const h=d;let u;e[2]!==l.id||e[3]!==l.slug||e[4]!==n?(u={connectionId:n,orgId:l.id,orgSlug:l.slug},e[2]=l.id,e[3]=l.slug,e[4]=n,e[5]=u):u=e[5];const f=ht(u);let m;e[6]!==l.id||e[7]!==n?(m=at.virtualMcpResources(n,l.id),e[6]=l.id,e[7]=n,e[8]=m):m=e[8];const p=m,[g,x]=A.useState("categories");let v;e[9]!==g?(v=()=>g,e[9]=g,e[10]=v):v=e[10];const b=A.useEffectEvent(v),_=A.useRef(null),y=A.useRef(!1),L=n??"default";let w;e[11]!==g||e[12]!==l.id||e[13]!==L?(w=["at-mention",l.id,L,g],e[11]=g,e[12]=l.id,e[13]=L,e[14]=w):w=e[14];const j=w;let S;e[15]!==o?(S=o("chat.mentionAt.agentsTitle"),e[15]=o,e[16]=S):S=e[16];let C;e[17]!==o?(C=o("chat.mentionAt.agentsDescription"),e[17]=o,e[18]=C):C=e[18];let N;e[19]!==S||e[20]!==C?(N={name:"agents",title:S,description:C,kind:"category",drillable:!0},e[19]=S,e[20]=C,e[21]=N):N=e[21];let V;e[22]!==o?(V=o("chat.mentionAt.resourcesTitle"),e[22]=o,e[23]=V):V=e[23];let E;e[24]!==o?(E=o("chat.mentionAt.resourcesDescription"),e[24]=o,e[25]=E):E=e[25];let T;e[26]!==V||e[27]!==E?(T={name:"resources",title:V,description:E,kind:"category",drillable:!0},e[26]=V,e[27]=E,e[28]=T):T=e[28];let k;e[29]!==T||e[30]!==N?(k=[N,T],e[29]=T,e[30]=N,e[31]=k):k=e[31];const R=k;let P;e[32]!==f||e[33]!==s||e[34]!==o?(P=async z=>{const{item:K,range:X}=z;if($e("chat_picker_item_selected",{picker:"@",item_kind:K.kind,item_name:K.name}),K.kind!=="category"&&(y.current=!0),K.kind==="category")return x(K.name==="agents"?"agents":"resources"),!1;if(K.kind==="agent"&&K.agentId){hr(s,X,{id:K.agentId,name:K.name,metadata:{agentId:K.agentId,title:K.name},char:"@"}),x("categories");return}if(K.kind==="resource"&&K.uri&&f){try{const J=await fm(f,K.uri);hr(s,X,{id:K.uri,name:K.uri,metadata:J.contents,char:"@"})}catch(J){console.error("[at-mention] Failed to fetch resource:",J),ge.error(o("chat.mentionAt.failedToLoadResource"))}x("categories");return}},e[32]=f,e[33]=s,e[34]=o,e[35]=P):P=e[35];const D=P;let I;e[36]!==c||e[37]!==R||e[38]!==f||e[39]!==h||e[40]!==b||e[41]!==a||e[42]!==p||e[43]!==n?(I=async z=>{const{query:K}=z,X=b();if(X==="categories"){if(!K.trim())return R;const W=K.toLowerCase(),U=c.filter(q=>q.status==="active"&&(!q.id||!nl(q.id))&&!h.has(q.id)&&q.id!==n&&(q.title.toLowerCase().includes(W)||q.description?.toLowerCase().includes(W))).map(fL),Q=await(async()=>{if(!f)return[];let q=a.getQueryData(p);return q||(q=await a.fetchQuery({queryKey:p,queryFn:()=>vo(f),staleTime:6e4})),(q?.resources??[]).filter(Z=>Z.uri.toLowerCase().includes(W)||Z.name?.toLowerCase().includes(W)||Z.description?.toLowerCase().includes(W)).map(mL)})();return[...U,...Q]}if(X==="agents"){let W=c.filter(U=>U.status==="active"&&(!U.id||!nl(U.id))&&!h.has(U.id)&&U.id!==n);if(K.trim()){const U=K.toLowerCase();W=W.filter(Q=>Q.title.toLowerCase().includes(U)||Q.description?.toLowerCase().includes(U))}return W.map(pL)}if(!f)return[];let J=a.getQueryData(p);J?a.fetchQuery({queryKey:p,queryFn:()=>vo(f),staleTime:6e4}).catch(gL):J=await a.fetchQuery({queryKey:p,queryFn:()=>vo(f),staleTime:6e4});let H=J?.resources??[];if(K.trim()){const W=K.toLowerCase();H=H.filter(U=>U.uri.toLowerCase().includes(W)||U.name?.toLowerCase().includes(W)||U.description?.toLowerCase().includes(W))}return H.map(xL)},e[36]=c,e[37]=R,e[38]=f,e[39]=h,e[40]=b,e[41]=a,e[42]=p,e[43]=n,e[44]=I):I=e[44];const M=I;let O;e[45]!==i?(O=z=>{if(i&&(i.current=z),z)_.current=Date.now(),y.current=!1,$e("chat_picker_opened",{picker:"@"});else{const K=_.current;$e("chat_picker_closed",{picker:"@",outcome:y.current?"selected":"dismissed",duration_ms:K?Date.now()-K:null}),_.current=null,x("categories")}},e[45]=i,e[46]=O):O=e[46];const F=O;let $;return e[47]!==s||e[48]!==M||e[49]!==D||e[50]!==F||e[51]!==j?($=r.jsx(Cp,{editor:s,char:"@",pluginKey:"atDropdownMenu",queryKey:j,queryFn:M,onSelect:D,onOpenChange:F}),e[47]=s,e[48]=M,e[49]=D,e[50]=F,e[51]=j,e[52]=$):$=e[52],$};function fL(t){return{name:t.title,title:t.title,description:t.description??void 0,icon:t.icon??null,kind:"agent",agentId:t.id}}function mL(t){return{name:t.name??t.uri,title:t.name,description:t.description,kind:"resource",uri:t.uri}}function pL(t){return{name:t.title,title:t.title,description:t.description??void 0,icon:t.icon??null,kind:"agent",agentId:t.id}}function gL(){}function xL(t){return{name:t.name??t.uri,title:t.name,description:t.description,kind:"resource",uri:t.uri}}async function Vh(t,e,s,n,i,o,a){try{const l=await Zo(s,n,o);hr(t,e,{id:n,name:jr(n,i),metadata:l.messages,char:"/",kind:"prompt",args:o})}catch(l){console.error("[slash] Failed to fetch prompt:",l),ge.error(a.t("chat.mentionSlash.failedLoadPrompt"))}}async function vL(t,e,s,n,i){try{const o=await fm(s,n);hr(t,e,{id:n,name:n,metadata:o.contents,char:"/",kind:"resource"})}catch(o){console.error("[slash] Failed to fetch resource:",o),ge.error(i.t("chat.mentionSlash.failedLoadResource"))}}async function bL(t,e,s,n,i){try{const{files:o,omittedPaths:a}=await B6(s,n.volume,n.path),l={sandboxPath:n.sandboxPath,files:o,omittedPaths:a};hr(t,e,{id:n.id,name:n.name,metadata:l,char:"/",kind:"skill"})}catch(o){console.error("[slash] Failed to fetch skill:",o),ge.error(i.t("chat.mentionSlash.failedLoadSkill"))}}const yL=({editor:t,virtualMcpId:e,suggestionOpenRef:s})=>{const n=re(),i=Ls(),{org:o}=Fe(),a=ht({connectionId:e,orgId:o.id,orgSlug:o.slug}),l=at.virtualMcpPrompts(e,o.id),c=at.virtualMcpResources(e,o.id),d=at.slashSkills(o.id),h=["slash-mention",o.id,e??"default"],[u,f]=A.useState(null),[m,p]=A.useState(null),g=uv(t);g&&(g.onEditChip=async j=>{if(a)try{const C=(await Nh(i,l,a)).find(N=>N.name===j.promptId);if(!C?.arguments||C.arguments.length===0)return;p({...j,prompt:C})}catch(S){console.error("[slash] Failed to load prompt for editing:",S),ge.error(n("chat.mentionSlash.failedLoadPrompt"))}});const x=A.useRef(null),v=A.useRef(!1),b=async({item:j,range:S})=>{if($e("chat_picker_item_selected",{picker:"/",item_kind:j.kind,item_name:j.name}),v.current=!0,!!a)if(j.kind==="prompt"){if(j.arguments&&j.arguments.length>0){f({range:S,item:j});return}const C=pn(j._meta);await Vh(t,S,a,j.name,C,void 0,{t:n})}else j.kind==="skill"?j.skill&&await bL(t,S,o.slug,j.skill,{t:n}):j.uri&&await vL(t,S,a,j.uri,{t:n})},_=async j=>{if(!u||!a)return;const{range:S,item:C}=u,N=pn(C._meta);await Vh(t,S,a,C.name,N,j,{t:n}),f(null)},y=async j=>{if(!(!m||!a)){if(!hv(t,m.pos,m.promptId)){ge.error(n("chat.mentionSlash.failedUpdatePrompt")),p(null);return}try{const S=await Zo(a,m.promptId,j),C=pn(m.prompt._meta);t.chain().focus().setNodeSelection(m.pos).deleteSelection().insertContentAt(m.pos,Y0({id:m.promptId,name:jr(m.promptId,C),metadata:S.messages,char:"/",kind:"prompt",args:j})).run(),$e("chat_picker_item_selected",{picker:"/edit",item_kind:"prompt",item_name:m.promptId})}catch(S){console.error("[slash] Failed to update prompt:",S),ge.error(n("chat.mentionSlash.failedUpdatePrompt"))}p(null)}},L=async j=>{const{query:S}=j;if(!a)return[];const[C,N,V]=await Promise.all([Nh(i,l,a),LL(i,c,a),_L(i,d,o.slug)]),E=S.trim().toLowerCase(),T=(C??[]).filter(P=>!E||P.name.toLowerCase().includes(E)||P.title?.toLowerCase().includes(E)||P.description?.toLowerCase().includes(E)).map(P=>({name:P.name,title:P.title,description:P.description,kind:"prompt",arguments:P.arguments,_meta:P._meta})),k=(N??[]).filter(P=>!E||P.uri.toLowerCase().includes(E)||P.name?.toLowerCase().includes(E)||P.description?.toLowerCase().includes(E)).map(P=>({name:P.name??P.uri,title:P.name,description:P.description,kind:"resource",uri:P.uri})),R=(V??[]).filter(P=>!E||P.name.toLowerCase().includes(E)||P.id.toLowerCase().includes(E)||P.description?.toLowerCase().includes(E)).map(P=>({name:P.name,title:P.name,description:P.description??void 0,kind:"skill",skill:P}));return[...T,...k,...R]},w=u?.item.kind==="prompt"?{name:u.item.name,title:u.item.title,arguments:u.item.arguments,description:u.item.description,_meta:u.item._meta}:null;return r.jsxs(r.Fragment,{children:[r.jsx(Cp,{editor:t,char:"/",pluginKey:"slashDropdownMenu",queryKey:h,queryFn:L,onSelect:b,onOpenChange:j=>{if(s&&(s.current=j),j)x.current=Date.now(),v.current=!1,$e("chat_picker_opened",{picker:"/"});else{const S=x.current;$e("chat_picker_closed",{picker:"/",outcome:v.current?"selected":"dismissed",duration_ms:S?Date.now()-S:null}),x.current=null}}}),r.jsx(Ao,{prompt:w,setPrompt:()=>f(null),onSubmit:_}),r.jsx(Ao,{prompt:m?.prompt??null,setPrompt:()=>p(null),onSubmit:y,defaultValues:m?.args},m?`edit-${m.promptId}-${m.pos}`:"edit-idle")]})};async function Nh(t,e,s){let n=t.getQueryData(e);return n?t.fetchQuery({queryKey:e,queryFn:()=>Ad(s),staleTime:6e4}).catch(()=>{}):n=await t.fetchQuery({queryKey:e,queryFn:()=>Ad(s),staleTime:6e4}),n?.prompts??[]}async function _L(t,e,s){const n=t.getQueryData(e),i=()=>t.fetchQuery({queryKey:e,queryFn:()=>F6(s),staleTime:6e4});return n?(i().catch(()=>{}),n):i().catch(()=>[])}async function LL(t,e,s){let n=t.getQueryData(e);return n?t.fetchQuery({queryKey:e,queryFn:()=>vo(s),staleTime:6e4}).catch(()=>{}):n=await t.fetchQuery({queryKey:e,queryFn:()=>vo(s),staleTime:6e4}),n?.resources??[]}function SL(t){return[Lm.configure({heading:!1,blockquote:!1,codeBlock:!1,horizontalRule:!1,dropcursor:!1}),c7.configure({placeholder:()=>t.current??"Ask anything, / for prompts & skills, @ for agents & resources...",showOnlyWhenEditable:!1}),mv,Dx]}function kp({tiptapDoc:t,setTiptapDoc:e,disabled:s=!1,enterToSubmit:n=!1,placeholder:i,onSubmit:o,suggestionOpenRef:a,children:l}){const c=A.useRef(o),d=A.useRef(e),h=A.useRef(n),u=A.useRef(i),f=Am({extensions:SL(u),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:(m,p)=>p.key==="Enter"&&!p.shiftKey&&h.current&&!a?.current?(p.preventDefault(),c.current?.(),!0):!1},onUpdate:({editor:m})=>{d.current(m?.getJSON())}});return A.useEffect(()=>{f?.setEditable(!s)},[f,s]),A.useEffect(()=>{c.current=o},[o]),A.useEffect(()=>{d.current=e},[e]),A.useEffect(()=>{h.current=n},[n]),A.useEffect(()=>{u.current=i},[i]),A.useEffect(()=>{if(!f||f.isDestroyed)return;const m=JSON.stringify(f.getJSON()),p=JSON.stringify(t||{type:"doc",content:[]});m!==p&&f.commands.setContent(t||{type:"doc",content:[]})},[f,t]),r.jsx(fv.Provider,{value:{editor:f},children:l})}function Vp(t){const e=B.c(29),{disabled:s,virtualMcpId:n,showFileUploader:i,selectedModel:o,onUnsupportedFile:a,suggestionOpenRef:l,ref:c,className:d}=t,h=s===void 0?!1:s,u=i===void 0?!1:i,{editor:f}=J0();let m,p;if(e[0]!==f?(m=()=>({focus:()=>{f?.commands.focus()},clear:()=>{f?.commands.clearContent(!0)},appendText:C=>{if(!f)return;const N=f.state.doc.textContent.trim()==="";f.commands.focus("end"),N||f.commands.insertContent(" "),f.commands.insertContent(C)},syncVoiceText:(C,N)=>{if(f&&(f.commands.setContent(C||{type:"doc",content:[]}),N)){f.commands.focus("end");const V=f.state.doc.textContent.trim().length>0;f.commands.insertContent({type:"text",text:V?" "+N:N})}},restoreContent:C=>{f&&f.commands.setContent(C||{type:"doc",content:[]})}}),p=[f],e[0]=f,e[1]=m,e[2]=p):(m=e[1],p=e[2]),A.useImperativeHandle(c??null,m,p),!f)return null;const g=h&&"cursor-not-allowed opacity-70",x=h&&"[&_.ProseMirror]:cursor-not-allowed";let v;e[3]!==d||e[4]!==g||e[5]!==x?(v=ie("overflow-y-auto relative flex-1 max-h-[164px] min-h-[20px] w-full flex flex-col",d,"[&_.ProseMirror]:outline-none [&_.ProseMirror]:min-h-[20px] [&_.ProseMirror]:flex-1","[&_.ProseMirror_p.is-editor-empty:first-child::before]:content-[attr(data-placeholder)]","[&_.ProseMirror_p.is-editor-empty:first-child::before]:text-muted-foreground","[&_.ProseMirror_p.is-editor-empty:first-child::before]:opacity-50","[&_.ProseMirror_p.is-editor-empty:first-child::before]:float-left","[&_.ProseMirror_p.is-editor-empty:first-child::before]:pointer-events-none","[&_.ProseMirror_p.is-editor-empty:first-child::before]:h-0",g,x),e[3]=d,e[4]=g,e[5]=x,e[6]=v):v=e[6];let b;e[7]!==f||e[8]!==v?(b=r.jsx(Em,{editor:f,className:v}),e[7]=f,e[8]=v,e[9]=b):b=e[9];const _=n??null;let y;e[10]!==f||e[11]!==l||e[12]!==_?(y=r.jsx(A.Suspense,{fallback:null,children:r.jsx(yL,{editor:f,virtualMcpId:_,suggestionOpenRef:l})}),e[10]=f,e[11]=l,e[12]=_,e[13]=y):y=e[13];const L=n??null;let w;e[14]!==f||e[15]!==l||e[16]!==L?(w=r.jsx(A.Suspense,{fallback:null,children:r.jsx(hL,{editor:f,virtualMcpId:L,suggestionOpenRef:l})}),e[14]=f,e[15]=l,e[16]=L,e[17]=w):w=e[17];let j;e[18]!==h||e[19]!==f||e[20]!==a||e[21]!==o||e[22]!==u?(j=u&&o&&!h?r.jsx(n7,{editor:f,selectedModel:o,onUnsupportedFile:a}):null,e[18]=h,e[19]=f,e[20]=a,e[21]=o,e[22]=u,e[23]=j):j=e[23];let S;return e[24]!==y||e[25]!==w||e[26]!==j||e[27]!==b?(S=r.jsxs(r.Fragment,{children:[b,y,w,j]}),e[24]=y,e[25]=w,e[26]=j,e[27]=b,e[28]=S):S=e[28],S}function Np(t){const e=B.c(3),[s]=ii();let n;return e[0]!==s.enableSounds||e[1]!==t?(n=()=>{s.enableSounds&&db(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 wL={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"},jL=yv.togglePlanMode.keys.map(t=>t==="Shift"?"⇧":t).join(""),CL=[{src:"/connections/gmail.png",name:"Gmail"},{src:"/connections/perplexity.png",name:"Perplexity"},{src:"/connections/github.png",name:"GitHub"}];function kL(){const t=B.c(1);let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=r.jsx("div",{className:"flex items-center -space-x-1.5",children:CL.map(VL)}),t[0]=e):e=t[0],e}function VL(t){return r.jsx("img",{src:t.src,alt:t.name,className:"size-5 rounded-sm ring-1 ring-border object-cover bg-white"},t.name)}function NL({disabled:t,onOpenConnections:e,virtualMcpId:s,selectedModel:n,isStreaming:i,onUnsupportedFile:o}){const a=re(),[l,c]=A.useState(!1),d=Np(wL),{org:h}=Fe(),{editor:u}=J0(),f=A.useRef(null),m=Ql(n),p=()=>{!m||i||(c(!1),f.current?.click())},g=async H=>{const W=H.target.files;if(!W||W.length===0||!u)return;const U=Array.from(W),{from:Q}=u.state.selection;try{for(const q of U)await A9(u,n??null,q,Q,o,a)}finally{f.current&&(f.current.value="")}},x=ht({connectionId:s,orgId:h.id,orgSlug:h.slug}),v=at.virtualMcpPrompts(s,h.id),{data:b,isLoading:_}=Ft({queryKey:v,queryFn:()=>Ad(x),staleTime:6e4,enabled:l&&!!x}),y=b?.prompts??[],[L,w]=A.useState(null),{chatMode:j,setChatMode:S}=Ts(),[C,N]=ii(),V=ro.find(H=>H.value===C.toolApprovalLevel)??ro[0],E=a(V.shortKey),T=H=>{const W=ro.find(U=>U.value===H);if(W){if(W.value===C.toolApprovalLevel){c(!1);return}d(),$e("chat_approval_level_changed",{from_level:C.toolApprovalLevel,to_level:W.value,source:"tools_popover"}),N({...C,toolApprovalLevel:W.value}),c(!1)}},k=j==="plan",R=()=>{d();const H=k?"default":"plan";$e("chat_mode_changed",{from_mode:j,to_mode:H,source:"tools_popover"}),S(H),c(!1)},P=()=>{e(),c(!1)},D=async(H,W)=>{if(!u||!x)return;const U=pn(H._meta),Q={from:u.state.selection.from,to:u.state.selection.to};try{const q=await Zo(x,H.name,W);hr(u,Q,{id:H.name,name:jr(H.name,U),metadata:q.messages,char:"/",kind:"prompt",args:W})}catch{ge.error(a("chat.toolsPopover.failedLoadPrompt"))}},I=async H=>{c(!1);const W=!!(H.arguments&&H.arguments.length>0);if($e("chat_prompt_inserted",{prompt_name:H.name,with_arguments:W}),W){w(H);return}await D(H)},M=async H=>{L&&(await D(L,H),w(null))},O=()=>{d();const H=j==="gen-image"?"default":"gen-image";$e("chat_mode_changed",{from_mode:j,to_mode:H,source:"tools_popover"}),S(H),c(!1)},F=()=>{d();const H=j==="web-search"?"default":"web-search";$e("chat_mode_changed",{from_mode:j,to_mode:H,source:"tools_popover"}),S(H),c(!1)},$=()=>{d();const H=j==="deep-research"?"default":"deep-research";$e("chat_mode_changed",{from_mode:j,to_mode:H,source:"tools_popover"}),S(H),c(!1)},z=j==="gen-image",K=j==="web-search",X=j==="deep-research",J=r.jsx("input",{ref:f,type:"file",multiple:!0,accept:R6(n??null),className:"hidden",onChange:g,disabled:i});return r.jsxs(r.Fragment,{children:[J,r.jsxs(us,{open:l,onOpenChange:H=>{H&&!l&&$e("chat_tools_popover_opened",{chat_mode:j}),c(H)},children:[r.jsx(ds,{asChild:!0,children:r.jsxs(le,{type:"button",variant:"ghost",size:"default",disabled:t,title:a("chat.toolsPopover.tools"),"aria-label":a("chat.toolsPopover.tools"),className:ie("text-muted-foreground hover:text-foreground transition-[gap] duration-200 shrink min-w-0","gap-0 @[320px]/chat-bottom:gap-1.5"),children:[r.jsx(Fm,{size:14}),r.jsx("span",{className:ie("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:a("chat.toolsPopover.tools")})]})}),r.jsxs(hs,{align:"start",className:"w-56 p-1.5 space-y-1",children:[m?r.jsxs(Xe,{onClick:p,disabled:i,children:[r.jsx(kt,{size:16}),r.jsx("span",{className:"flex-1",children:a("chat.toolsPopover.addFile")})]}):r.jsxs(He,{children:[r.jsx(Ke,{asChild:!0,children:r.jsxs(Xe,{"aria-disabled":"true",className:"opacity-50 cursor-not-allowed",onSelect:H=>H.preventDefault(),children:[r.jsx(kt,{size:16}),r.jsx("span",{className:"flex-1",children:a("chat.toolsPopover.addFile")})]})}),r.jsx(Ue,{side:"right",children:a("chat.toolsPopover.modelNoFileSupport")})]}),r.jsxs(Xe,{onClick:R,className:ie(k&&"text-special"),children:[r.jsx(fr,{size:16,className:ie(k&&"text-special")}),r.jsx("span",{className:"flex-1 whitespace-nowrap",children:a("chat.toolsPopover.planMode")}),r.jsx("span",{className:ie("text-xs text-muted-foreground",k&&"text-special font-medium"),children:jL})]}),r.jsxs(Xe,{onClick:O,className:ie(z&&"text-special"),children:[r.jsx(En,{size:16,className:ie(z&&"text-special")}),r.jsx("span",{className:"flex-1",children:a("chat.toolsPopover.createImage")}),z&&r.jsx("span",{className:"text-xs text-special font-medium",children:a("chat.toolsPopover.on")})]}),r.jsxs(Xe,{onClick:F,className:ie(K&&"text-special"),children:[r.jsx(gn,{size:16,className:ie(K&&"text-special")}),r.jsx("span",{className:"flex-1",children:a("chat.toolsPopover.webSearch")}),K&&r.jsx("span",{className:"text-xs text-special font-medium",children:a("chat.toolsPopover.on")})]}),r.jsxs(Xe,{onClick:$,className:ie(X&&"text-special"),children:[r.jsx(zm,{size:16,className:ie(X&&"text-special")}),r.jsx("span",{className:"flex-1",children:a("chat.toolsPopover.deepResearch")}),X&&r.jsx("span",{className:"text-xs text-special font-medium",children:a("chat.toolsPopover.on")})]}),r.jsxs(Po,{children:[r.jsxs(Ro,{className:"gap-2",children:[r.jsx("span",{className:"flex size-4 items-center justify-center text-base font-medium text-muted-foreground",children:"/"}),r.jsx("span",{className:"flex-1",children:a("chat.toolsPopover.prompts")})]}),r.jsx(Do,{className:"w-80 max-h-72 overflow-y-auto p-1.5",children:_?r.jsxs("div",{className:"flex items-center gap-2 px-2 py-3 text-sm text-muted-foreground",children:[r.jsx(et,{size:14,className:"animate-spin"}),a("chat.toolsPopover.loadingPrompts")]}):y.length===0?r.jsx("div",{className:"px-2 py-3 text-sm text-muted-foreground",children:a("chat.toolsPopover.noPromptsAvailable")}):y.map(H=>r.jsxs(Xe,{onClick:()=>I(H),className:"flex flex-col items-start gap-0.5",children:[r.jsx("span",{className:"font-medium text-sm capitalize",children:H.title||G0(H.name,pn(H._meta))}),H.description&&r.jsx("span",{className:"text-xs text-muted-foreground line-clamp-2",children:H.description})]},H.name))})]}),r.jsxs(Po,{children:[r.jsxs(Ro,{className:"gap-2",children:[r.jsx(Yl,{size:16}),r.jsx("span",{className:"flex-1",children:a("chat.toolsPopover.approval")}),r.jsx("span",{className:"text-xs text-muted-foreground",children:E})]}),r.jsx(Do,{className:"w-48 p-1.5",children:r.jsx(Dd,{value:C.toolApprovalLevel,onValueChange:T,children:ro.map(H=>r.jsx(Io,{value:H.value,children:a(H.labelKey)},H.value))})})]}),r.jsxs(Xe,{onClick:P,children:[r.jsx(u2,{size:16}),r.jsx("span",{className:"flex-1",children:a("chat.toolsPopover.connections")}),r.jsx(A.Suspense,{children:r.jsx(kL,{})})]})]})]}),r.jsx(Ao,{prompt:L,setPrompt:w,onSubmit:M})]})}const TL=[{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 AL(){const t=B.c(1);let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=r.jsx("div",{className:"flex items-center -space-x-1",children:TL.map(EL)}),t[0]=e):e=t[0],e}function EL(t){return r.jsx("img",{src:t.src,alt:t.name,className:"size-5 rounded-sm ring-2 ring-muted object-cover bg-white"},t.name)}function PL(t){const e=B.c(6),{onClick:s}=t;let n,i,o,a;e[0]===Symbol.for("react.memo_cache_sentinel")?(n=ie("group relative z-10 flex items-center gap-3 w-full px-4 py-3","rounded-b-2xl","cursor-pointer"),i=r.jsx("p",{className:"flex-1 text-xs text-muted-foreground truncate text-left",children:"Connect tools and get more done"}),o=r.jsx(AL,{}),a=r.jsx(bn,{size:14,className:"shrink-0 text-muted-foreground/60 group-hover:text-muted-foreground transition-colors"}),e[0]=n,e[1]=i,e[2]=o,e[3]=a):(n=e[0],i=e[1],o=e[2],a=e[3]);let l;return e[4]!==s?(l=r.jsxs("button",{type:"button",onClick:s,className:n,children:[i,o,a]}),e[4]=s,e[5]=l):l=e[5],l}const lo=48;function RL(){const t=B.c(9),[e,s]=A.useState("idle"),[n,i]=A.useState(""),[o,a]=A.useState(""),[l,c]=A.useState(ML),d=A.useRef(null),h=A.useRef(null),u=A.useRef(null),f=A.useRef(null),m=A.useRef(0),p=A.useRef(!1),g=A.useRef(""),x=A.useRef(""),v=typeof window<"u"&&!!(window.SpeechRecognition||window.webkitSpeechRecognition);let b;t[0]===Symbol.for("react.memo_cache_sentinel")?(b=()=>{m.current&&(cancelAnimationFrame(m.current),m.current=0),h.current?.close().catch(IL),f.current?.getTracks().forEach(DL),u.current=null,h.current=null,f.current=null},t[0]=b):b=t[0];const _=b;let y;if(t[1]===Symbol.for("react.memo_cache_sentinel")){const V=E=>{f.current=E;const T=new AudioContext;h.current=T;const k=T.createMediaStreamSource(E),R=T.createAnalyser();R.fftSize=128,R.smoothingTimeConstant=.8,k.connect(R),u.current=R;const P=new Uint8Array(R.frequencyBinCount),D=()=>{if(!u.current)return;u.current.getByteFrequencyData(P);const I=[];for(let M=0;M<lo;M++){const O=Math.floor(M/lo*P.length);I.push(Math.max(.04,(P[O]??0)/255))}c(I),m.current=requestAnimationFrame(D)};D()};y=async()=>{const E=window.SpeechRecognition||window.webkitSpeechRecognition;if(!E)return s("unsupported"),"unsupported";let T;try{T=await navigator.mediaDevices.getUserMedia({audio:!0})}catch{return s("permission-denied"),"permission-denied"}i(""),a(""),x.current="",g.current="",p.current=!0,s("recording"),V(T);const k=new E;d.current=k,k.interimResults=!0,k.continuous=!0,k.lang=navigator.language||"en-US",k.onresult=R=>{let P="",D="";for(let I=R.resultIndex;I<R.results.length;I++){const M=R.results[I],O=M?.[0]?.transcript??"";M?.isFinal?D=D+O:P=P+O}D&&(g.current=g.current+D,i(g.current)),x.current=P,a(P)},k.onend=()=>{if(p.current)try{k.start()}catch{}};try{k.start()}catch{return p.current=!1,d.current=null,_(),s("idle"),"idle"}return"recording"},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(),_(),s("idle"),c(Array(lo).fill(.05)),a("");const V=(g.current+(x.current?" "+x.current:"")).trim();return i(""),g.current="",x.current="",V},t[2]=w):w=t[2];const j=w;let S;t[3]===Symbol.for("react.memo_cache_sentinel")?(S=()=>{p.current=!1,d.current?.abort(),_(),s("idle"),i(""),a(""),c(Array(lo).fill(.05)),g.current="",x.current=""},t[3]=S):S=t[3];const C=S;let N;return t[4]!==o||t[5]!==e||t[6]!==n||t[7]!==l?(N={status:e,transcript:n,interimTranscript:o,waveformData:l,isSupported:v,startRecording:L,stopRecording:j,cancelRecording:C},t[4]=o,t[5]=e,t[6]=n,t[7]=l,t[8]=N):N=t[8],N}function DL(t){return t.stop()}function IL(){}function ML(){return Array(lo).fill(.05)}function OL(t){const e=B.c(4),{data:s}=t;let n;e[0]!==s?(n=s.map($L),e[0]=s,e[1]=n):n=e[1];let i;return e[2]!==n?(i=r.jsx("div",{className:"flex items-center justify-center gap-[2px] h-10 overflow-hidden","aria-hidden":"true",children:n}),e[2]=n,e[3]=i):i=e[3],i}function $L(t,e){return r.jsx("div",{className:"w-[2px] shrink-0 rounded-full bg-chart-2 transition-[height] duration-75 ease-out",style:{height:`${Math.max(4,Math.round(t*40))}px`}},e)}function BL({messageCount:t,showConnectionsBanner:e}){return t>0||e}function FL(t){return t.hasDraft?"send":t.isStreaming||t.isRunInProgress?"stop":"disabled"}function zL(t){const e=B.c(3),{message:s}=t;let n;e[0]===Symbol.for("react.memo_cache_sentinel")?(n=r.jsx(H0,{size:14,className:"shrink-0"}),e[0]=n):n=e[0];const i=s??"";let o;return e[1]!==i?(o=r.jsxs("div",{className:"flex w-full items-center gap-2 px-3 py-2.5 rounded-xl border border-border bg-muted/40 text-muted-foreground",children:[n,r.jsx("span",{className:"text-sm",children:i})]}),e[1]=i,e[2]=o):o=e[2],o}function KL(t,e,s){const n=B.c(7),{editor:i}=J0(),o=re(),[a,l]=A.useState(!1),c=A.useRef(0);let d,h;return n[0]!==s||n[1]!==i||n[2]!==e||n[3]!==t||n[4]!==o?(d=()=>{const u=g=>{g.dataTransfer?.types.includes("Files")&&(g.preventDefault(),c.current=c.current+1,l(!0))},f=g=>{g.preventDefault(),c.current=Math.max(0,c.current-1),c.current===0&&l(!1)},m=UL,p=g=>{if(g.preventDefault(),c.current=0,l(!1),s||!i||!t||!Ql(t))return;const x=g.dataTransfer?.files;if(!x||x.length===0)return;const{from:v}=i.state.selection;for(const b of Array.from(x))A9(i,t,b,v,e,o)};return window.addEventListener("dragenter",u),window.addEventListener("dragleave",f),window.addEventListener("dragover",m),window.addEventListener("drop",p),()=>{window.removeEventListener("dragenter",u),window.removeEventListener("dragleave",f),window.removeEventListener("dragover",m),window.removeEventListener("drop",p)}},h=[i,t,e,o,s],n[0]=s,n[1]=i,n[2]=e,n[3]=t,n[4]=o,n[5]=d,n[6]=h):(d=n[5],h=n[6]),A.useEffect(d,h),a}function UL(t){t.dataTransfer?.types.includes("Files")&&t.preventDefault()}function HL(t){const e=B.c(14),{selectedModel:s}=t,n=re();let i,o,a;if(e[0]!==s||e[1]!==n){const{parts:d}=i2(s);e[5]===Symbol.for("react.memo_cache_sentinel")?(a=r.jsx($i,{size:24}),e[5]=a):a=e[5],i="text-sm font-medium";let h;e[6]!==n?(h=u=>n(u),e[6]=n,e[7]=h):h=e[7],o=n("chat.input.dropFilesHere",{fileTypes:d.map(h).join(", ")}),e[0]=s,e[1]=n,e[2]=i,e[3]=o,e[4]=a}else i=e[2],o=e[3],a=e[4];let l;e[8]!==i||e[9]!==o?(l=r.jsx("span",{className:i,children:o}),e[8]=i,e[9]=o,e[10]=l):l=e[10];let c;return e[11]!==a||e[12]!==l?(c=r.jsxs(r.Fragment,{children:[a,l]}),e[11]=a,e[12]=l,e[13]=c):c=e[13],c}function WL(){const t=B.c(5),e=re();let s;t[0]===Symbol.for("react.memo_cache_sentinel")?(s=r.jsx(H0,{size:24}),t[0]=s):s=t[0];let n;t[1]!==e?(n=e("chat.input.modelCannotReadAttachments"),t[1]=e,t[2]=n):n=t[2];let i;return t[3]!==n?(i=r.jsxs(r.Fragment,{children:[s,r.jsx("span",{className:"text-sm font-medium",children:n})]}),t[3]=n,t[4]=i):i=t[4],i}function qL(t){const e=B.c(11),{selectedModel:s,onUnsupportedFile:n,disabled:i}=t,o=KL(s,n,i);let a;e[0]!==s?(a=Ql(s),e[0]=s,e[1]=a):a=e[1];const l=a,c=o?"opacity-100":"opacity-0 pointer-events-none",d=l?"border-primary/40 text-primary/70":"border-destructive/30 text-destructive/70";let h;e[2]!==c||e[3]!==d?(h=ie("absolute inset-0 z-20 rounded-xl flex flex-col items-center justify-center gap-2 bg-muted border-2 border-dashed transition-opacity",c,d),e[2]=c,e[3]=d,e[4]=h):h=e[4];let u;e[5]!==s||e[6]!==l?(u=l?r.jsx(HL,{selectedModel:s}):r.jsx(WL,{}),e[5]=s,e[6]=l,e[7]=u):u=e[7];let f;return e[8]!==h||e[9]!==u?(f=r.jsx("div",{className:h,children:u}),e[8]=h,e[9]=u,e[10]=f):f=e[10],f}function GL(){const t=B.c(6),e=St(),{org:s,locator:n}=Fe(),{create:i}=Gl();let o;return t[0]!==i||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??Xo(s.id).id;Im(sessionStorage,n,d,{tiptapDoc:l});try{await i({id:d,virtual_mcp_id:h})}catch{}const u={virtualmcpid:h,autosend:Sv};e({to:"/$org/$taskId",params:{org:s.slug,taskId:d},search:u})},t[0]=i,t[1]=n,t[2]=e,t[3]=s.id,t[4]=s.slug,t[5]=o):o=t[5],o}function YL({onOpenContextPanel:t,showConnectionsBanner:e=!1}){const s=re(),n=q0(),i=Ii(),o=n?.messages??[],a=n?.isStreaming??!1,l=n?.isRunInProgress??!1,c=n?.stop??(()=>{}),d=i?.taskId??"",h=d||Av,u=GL(),{selectedModel:f,selectedVirtualMcp:m,isModelsLoading:p,tiptapDocRef:g,imageModel:x,webSearchModel:v,deepResearchModel:b,chatMode:_,setChatMode:y}=Ts(),{data:L}=Di.useSession(),w=L?.user?.id,{org:j,locator:S}=Fe(),C=Xo(j.id).id,N=gs(m?.id??C),V=Np(ub),[E,T]=A.useState(!1),{unsupportedFile:k,onUnsupportedFile:R,clearUnsupportedFile:P}=l7(),D=RL(),I=A.useRef(void 0),M=async()=>{I.current=z;const he=await D.startRecording();$e("chat_voice_started",{thread_id:d,outcome:he==="recording"?"started":he==="unsupported"?"unsupported":he==="permission-denied"?"permission_denied":"unknown"})},O=()=>{$e("chat_voice_confirmed",{thread_id:d});const he=D.stopRecording();U.current?.syncVoiceText(I.current,he),U.current?.focus()},F=()=>{$e("chat_voice_cancelled",{thread_id:d}),D.cancelRecording(),U.current?.restoreContent(I.current)};A.useEffect(()=>{if(D.status!=="recording")return;const he=(D.transcript+(D.interimTranscript?" "+D.interimTranscript:"")).trim();U.current?.syncVoiceText(I.current,he)},[D.transcript,D.interimTranscript,D.status]);const $=i?.activeTask??null,[z,K]=A.useState(()=>qu(sessionStorage,S,h)??void 0),X=he=>{K(he),g.current=he,Tv(sessionStorage,S,h,he,{onQuotaExceeded:({docSizeBytes:ce})=>{$e("chat_draft_quota_exceeded",{thread_id:d||null,doc_size_bytes:ce}),console.warn("[chat-draft] sessionStorage quota exceeded; draft not saved")}})},J=A.useRef(d);if(J.current!==d){J.current=d;const he=qu(sessionStorage,S,h)??void 0;K(he),g.current=he}const W=[...o].reverse().find(he=>he.role==="assistant")?.metadata?.modelLimits?.contextWindow??f?.limits?.contextWindow,U=A.useRef(null),Q=A.useRef(!1),q=_==="plan";A.useEffect(()=>{const he=ce=>{Rm(ce)&&ce.code==="KeyL"&&(ce.preventDefault(),ce.shiftKey&&y(_==="plan"?"default":"plan"),U.current?.focus())};return document.addEventListener("keydown",he),()=>document.removeEventListener("keydown",he)},[_,y]);const Z=Sm(o),ee=[...o].reverse().find(he=>he.role==="assistant"&&he.metadata?.usage)?.metadata?.usage?.contextTokens??0,G=!p&&!Vv(z),te=FL({hasDraft:G,isStreaming:a,isRunInProgress:l}),se=te==="send",ne=te==="stop",de=BL({messageCount:o.length,showConnectionsBanner:e}),xe=he=>{if(he?.preventDefault(),te==="send"&&z){if($e("chat_message_sent",{thread_id:d||null,mode:_,model_id:f?.modelId??null,model_provider:f?.providerId??null,virtual_mcp_id:m?.id??null,submission:he?"button_or_enter":"programmatic"}),n){if(n.isSendInFlight()){ge.info(s("chat.input.stillSendingPreviousMessage"));return}n.sendMessage(z)}else u({tiptapDoc:z,virtualMcp:m});Nv(sessionStorage,S,h),X(void 0)}else te==="stop"&&($e("chat_message_stopped",{thread_id:d}),c())};return w&&$?.created_by&&$.created_by!==w?r.jsx(zL,{message:s("chat.input.readOnlyOthersChat")}):r.jsxs(r.Fragment,{children:[r.jsx("div",{className:"flex flex-col w-full justify-end",children:r.jsxs("div",{className:"relative rounded-2xl w-full flex flex-col",children:[e&&r.jsx("div",{className:"absolute inset-0 rounded-2xl pointer-events-none bg-muted/50"}),n&&i&&r.jsx(ic,{}),n&&i&&d?r.jsx(jy,{taskId:d}):null,r.jsx(kp,{tiptapDoc:z,setTiptapDoc:X,disabled:D.status==="recording",enterToSubmit:!0,placeholder:s("chat.input.placeholder"),onSubmit:xe,suggestionOpenRef:Q,children:r.jsxs("form",{onSubmit:xe,className:ie("w-full relative rounded-2xl min-h-[110px] md:min-h-[130px] flex flex-col bg-card dark:bg-muted card-shadow overflow-hidden"),children:[r.jsx(qL,{selectedModel:f,onUnsupportedFile:R,disabled:D.status==="recording"}),r.jsx("div",{className:"group/input relative flex flex-col gap-2 flex-1",children:r.jsx(Vp,{ref:U,disabled:D.status==="recording",virtualMcpId:m?.id??C,showFileUploader:!0,selectedModel:f,onUnsupportedFile:R,suggestionOpenRef:Q})}),r.jsx("div",{className:"@container/chat-bottom flex items-center justify-between p-2.5 gap-1",children:D.status==="recording"?r.jsxs(r.Fragment,{children:[r.jsx("div",{className:"flex-1"}),r.jsxs("div",{className:"flex items-center gap-1.5 shrink-0",children:[r.jsx(OL,{data:D.waveformData.slice(0,28)}),r.jsx("button",{type:"button",onClick:F,className:"flex items-center justify-center size-8 rounded-lg hover:bg-muted text-muted-foreground hover:text-foreground transition-colors","aria-label":s("chat.input.cancelRecording"),children:r.jsx(ks,{size:16})}),r.jsx("button",{type:"button",onClick:O,className:"flex items-center justify-center size-8 rounded-lg bg-foreground text-background hover:opacity-80 transition-opacity","aria-label":s("chat.input.useTranscription"),children:r.jsx(zt,{size:16})})]})]}):r.jsxs(r.Fragment,{children:[r.jsxs("div",{className:"flex items-center gap-1.5 min-w-0",children:[r.jsx(NL,{disabled:!1,onOpenConnections:()=>{$e("connections_dialog_opened",{source:"tools_popover",mode:"add"}),T(!0)},virtualMcpId:m?.id??C,selectedModel:f,isStreaming:a,onUnsupportedFile:R}),q&&r.jsxs("button",{type:"button",onClick:()=>{V(),$e("chat_mode_changed",{from_mode:"plan",to_mode:"default",source:"pill_dismiss"}),y("default")},title:s("chat.input.planMode"),"aria-label":s("chat.input.planMode"),className:"flex items-center gap-1.5 h-8 rounded-lg px-2.5 text-sm font-medium text-violet-600 dark:text-violet-400 hover:bg-violet-500/10 group min-w-0 shrink animate-in fade-in duration-200",children:[r.jsx(fr,{size:14,className:"shrink-0"}),r.jsx("span",{className:"min-w-0 truncate transition-[max-width,opacity] duration-200 ease-out max-w-0 opacity-0 @[320px]/chat-bottom:max-w-32 @[320px]/chat-bottom:opacity-100",children:s("chat.input.planMode")}),r.jsx(ks,{size:14,className:"shrink-0 hidden group-hover:block group-disabled:hidden"})]}),_==="gen-image"&&x&&r.jsxs("button",{type:"button",onClick:()=>{V(),$e("chat_mode_changed",{from_mode:"gen-image",to_mode:"default",source:"pill_dismiss"}),y("default")},title:s("chat.input.createImage"),"aria-label":s("chat.input.createImage"),className:"flex items-center gap-1.5 h-8 rounded-lg px-2.5 text-sm font-medium text-pink-600 dark:text-pink-400 hover:bg-pink-500/10 group min-w-0 shrink animate-in fade-in duration-200 disabled:opacity-50 disabled:cursor-not-allowed disabled:hover:bg-transparent",children:[r.jsx(En,{size:14,className:"shrink-0"}),r.jsx("span",{className:"min-w-0 truncate transition-[max-width,opacity] duration-200 ease-out max-w-0 opacity-0 @[320px]/chat-bottom:max-w-[120px] @[320px]/chat-bottom:opacity-100",children:s("chat.input.createImage")}),r.jsx(ks,{size:14,className:"shrink-0 hidden group-hover:block group-disabled:hidden"})]}),_==="web-search"&&v&&r.jsxs("button",{type:"button",onClick:()=>{V(),$e("chat_mode_changed",{from_mode:"web-search",to_mode:"default",source:"pill_dismiss"}),y("default")},title:s("chat.input.webSearch"),"aria-label":s("chat.input.webSearch"),className:"flex items-center gap-1.5 h-8 rounded-lg px-2.5 text-sm font-medium text-blue-600 dark:text-blue-400 hover:bg-blue-500/10 group min-w-0 shrink animate-in fade-in duration-200 disabled:opacity-50 disabled:cursor-not-allowed disabled:hover:bg-transparent",children:[r.jsx(gn,{size:14,className:"shrink-0"}),r.jsx("span",{className:"min-w-0 truncate transition-[max-width,opacity] duration-200 ease-out max-w-0 opacity-0 @[320px]/chat-bottom:max-w-[120px] @[320px]/chat-bottom:opacity-100",children:s("chat.input.webSearch")}),r.jsx(ks,{size:14,className:"shrink-0 hidden group-hover:block group-disabled:hidden"})]}),_==="deep-research"&&b&&r.jsxs("button",{type:"button",onClick:()=>{V(),$e("chat_mode_changed",{from_mode:"deep-research",to_mode:"default",source:"pill_dismiss"}),y("default")},title:s("chat.input.deepResearch"),"aria-label":s("chat.input.deepResearch"),className:"flex items-center gap-1.5 h-8 rounded-lg px-2.5 text-sm font-medium text-blue-600 dark:text-blue-400 hover:bg-blue-500/10 group min-w-0 shrink animate-in fade-in duration-200 disabled:opacity-50 disabled:cursor-not-allowed disabled:hover:bg-transparent",children:[r.jsx(zm,{size:14,className:"shrink-0"}),r.jsx("span",{className:"min-w-0 truncate transition-[max-width,opacity] duration-200 ease-out max-w-0 opacity-0 @[320px]/chat-bottom:max-w-[120px] @[320px]/chat-bottom:opacity-100",children:s("chat.input.deepResearch")}),r.jsx(ks,{size:14,className:"shrink-0 hidden group-hover:block group-disabled:hidden"})]}),W&&ee>0&&r.jsx(Ix,{usage:Z,totalTokens:ee,contextWindow:W,onOpenContextPanel:t})]}),r.jsxs("div",{className:"flex items-center gap-1.5 min-w-0",children:[de&&r.jsx(hp,{virtualMcp:N,currentBranch:i?.currentBranch??null}),r.jsx(s7,{}),D.isSupported&&r.jsx(le,{type:"button",onClick:M,disabled:!1,variant:"ghost",size:"icon",className:ie("size-8 rounded-lg transition-colors",D.status==="permission-denied"?"text-destructive hover:text-destructive hover:bg-destructive/10":"text-muted-foreground hover:text-foreground"),title:D.status==="permission-denied"?s("chat.input.microphoneAccessDenied"):s("chat.input.voiceInput"),"aria-label":D.status==="permission-denied"?s("chat.input.microphoneAccessDenied"):s("chat.input.voiceInput"),children:r.jsx(Uv,{size:18})}),r.jsx(le,{type:ne?"button":"submit",onClick:he=>{ne&&(he.preventDefault(),he.stopPropagation(),c())},variant:se||ne?"default":"ghost",size:"icon",disabled:!se&&!ne,className:ie("size-8 rounded-lg transition-all",!se&&!ne&&"bg-muted text-muted-foreground hover:bg-muted hover:text-muted-foreground cursor-not-allowed"),title:s(te==="stop"?a?"chat.input.stopGenerating":"chat.input.cancelRun":"chat.input.sendMessageEnter"),"aria-label":s(te==="stop"?a?"chat.input.stopGenerating":"chat.input.cancelRun":"chat.input.sendMessage"),children:ne?r.jsx(Hv,{size:20}):r.jsx(W0,{size:20})})]})]})})]})},d),e&&r.jsx(PL,{onClick:()=>{$e("connections_banner_clicked",{source:"home_chat_input"}),$e("connections_dialog_opened",{source:"home_banner",mode:"add"}),T(!0)}})]})}),r.jsx(h9,{mode:"browse",open:E,onOpenChange:T,defaultTab:"all"}),r.jsx(o7,{info:k,onClose:P})]})}function JL(){const t=B.c(7),e=St(),s=q0()?.messages??[],n=Ii()?.taskId??null;let i;t[0]!==s?(i=s.some(QL),t[0]=s,t[1]=i):i=t[1];const o=i,a=A.useRef(null);let l,c;t[2]!==e||t[3]!==o||t[4]!==n?(l=()=>{!o||!n||a.current===n||(a.current=n,e({to:".",search:XL,replace:!0}))},c=[o,n,e],t[2]=e,t[3]=o,t[4]=n,t[5]=l,t[6]=c):(l=t[5],c=t[6]),A.useEffect(l,c)}function XL(t){return{...t,main:"preview"}}function QL(t){return t.parts?.some(ZL)}function ZL(t){const e=t;return e.type==="tool-load_repo"&&e.state==="output-available"&&e.output?.success===!0}const eS={usd:[{dollars:10,labelKey:"chat.creditsEmptyState.starterLabel"},{dollars:20,labelKey:"chat.creditsEmptyState.popularLabel"},{dollars:100,labelKey:"chat.creditsEmptyState.bestValueLabel"}],brl:[{dollars:50,labelKey:"chat.creditsEmptyState.starterLabel"},{dollars:100,labelKey:"chat.creditsEmptyState.popularLabel"},{dollars:500,labelKey:"chat.creditsEmptyState.bestValueLabel"}]};function Tp(t){return`deco-credits-empty-dismissed:${t}`}function tS(t){try{return localStorage.getItem(Tp(t))==="1"}catch{return!1}}function sS(){const t=B.c(68),e=re(),{org:s}=Fe(),n=St(),{decoKeyId:i}=d9(),o=Bs(),[a,l]=A.useState(!0),[c,d]=A.useState(""),[h,u]=A.useState(!1),[f,m]=A.useState("usd"),p=f==="brl"?"R$":"$";let g;t[0]!==s.id?(g=()=>{$e("credits_empty_state_dismissed",{organization_id:s.id}),l(!1);try{localStorage.setItem(Tp(s.id),"1")}catch{}},t[0]=s.id,t[1]=g):g=t[1];const x=g;let v,b;t[2]!==a||t[3]!==s.id?(v=()=>{a&&$e("credits_empty_state_shown",{organization_id:s.id})},b=[a,s.id],t[2]=a,t[3]=s.id,t[4]=v,t[5]=b):(v=t[4],b=t[5]),A.useEffect(v,b);let _;t[6]!==f||t[7]!==o?(_=async U=>{const{url:Q}=await o.call("AI_PROVIDER_TOPUP_URL",{providerId:"deco",amountCents:U,currency:f});return Q},t[6]=f,t[7]=o,t[8]=_):_=t[8];let y;t[9]!==x?(y=U=>{U&&window.open(U,"_blank","noopener,noreferrer"),x()},t[9]=x,t[10]=y):y=t[10];let L;t[11]!==e?(L=U=>{ge.error(e("chat.creditsEmptyState.topUpFailed",{message:U.message}))},t[11]=e,t[12]=L):L=t[12];let w;t[13]!==_||t[14]!==y||t[15]!==L?(w={mutationFn:_,onSuccess:y,onError:L},t[13]=_,t[14]=y,t[15]=L,t[16]=w):w=t[16];const{mutate:j,isPending:S}=Ys(w),C=parseFloat(c),N=!isNaN(C)&&C>=1;if(!a)return null;let V;t[17]!==x?(V=U=>!U&&x(),t[17]=x,t[18]=V):V=t[18];let E;t[19]===Symbol.for("react.memo_cache_sentinel")?(E=r.jsx("div",{className:"absolute inset-x-0 top-0 h-24 bg-gradient-to-b from-warning/8 to-transparent pointer-events-none rounded-t-lg"}),t[19]=E):E=t[19];let T;t[20]===Symbol.for("react.memo_cache_sentinel")?(T=r.jsx("div",{className:"flex items-center justify-center size-11 rounded-full bg-warning/10 border border-warning/20 mx-auto",children:r.jsx(Km,{size:20,className:"text-warning"})}),t[20]=T):T=t[20];let k;t[21]!==e?(k=e("chat.creditsEmptyState.title"),t[21]=e,t[22]=k):k=t[22];let R;t[23]!==k?(R=r.jsx(ps,{className:"text-lg font-semibold",children:k}),t[23]=k,t[24]=R):R=t[24];let P;t[25]!==e?(P=e("chat.creditsEmptyState.description"),t[25]=e,t[26]=P):P=t[26];let D;t[27]!==P?(D=r.jsx(oi,{className:"mt-2 text-[13px] leading-relaxed max-w-[320px] mx-auto",children:P}),t[27]=P,t[28]=D):D=t[28];let I;t[29]!==R||t[30]!==D?(I=r.jsxs("div",{className:"relative px-6 pt-7 pb-5",children:[E,r.jsxs(ms,{className:"relative gap-3",children:[T,r.jsxs("div",{className:"text-center",children:[R,D]})]})]}),t[29]=R,t[30]=D,t[31]=I):I=t[31];let M;t[32]!==f||t[33]!==p||t[34]!==c||t[35]!==C||t[36]!==i||t[37]!==N||t[38]!==S||t[39]!==h||t[40]!==e||t[41]!==j?(M=i&&r.jsxs("div",{className:"px-6 pb-5",children:[r.jsx("div",{className:"mb-4",children:r.jsxs(c9,{type:"single",variant:"outline",size:"sm",value:f,onValueChange:U=>{U&&m(U)},children:[r.jsx(Eo,{value:"usd",className:"h-8 px-3 text-xs",children:"USD"}),r.jsx(Eo,{value:"brl",className:"h-8 px-3 text-xs",children:"BRL"})]})}),r.jsx("div",{className:"grid grid-cols-3 gap-2.5",children:eS[f].map(U=>{const{dollars:Q,labelKey:q}=U;return r.jsxs("button",{type:"button",disabled:S,onClick:()=>{$e("credits_topup_clicked",{amount_cents:Q*100,currency:f,tier_label:q,source:"empty_state"}),j(Q*100)},className:ie("relative flex flex-col items-center gap-1 py-6 rounded-xl border transition-all duration-150 cursor-pointer","disabled:opacity-50 disabled:cursor-wait","border-border hover:border-foreground/20 hover:bg-muted/30"),children:[r.jsxs("span",{className:"text-2xl font-semibold tabular-nums text-foreground",children:[p,Q]}),r.jsx("span",{className:"text-xs text-muted-foreground",children:e(q)})]},Q)})}),h?r.jsxs("div",{className:"flex gap-2 mt-3",children:[r.jsxs("div",{className:"relative flex-1",children:[r.jsx("span",{className:"absolute left-3 top-1/2 -translate-y-1/2 text-sm text-muted-foreground select-none",children:p}),r.jsx(rt,{type:"number",min:"1",step:"1",placeholder:"50",value:c,onChange:U=>d(U.target.value),className:"h-10 text-sm pl-7",autoFocus:!0})]}),r.jsx(le,{className:"h-10",disabled:!N||S,onClick:()=>{$e("credits_topup_clicked",{amount_cents:Math.round(C*100),currency:f,tier_label:"custom",source:"empty_state"}),j(Math.round(C*100))},children:e(S?"chat.creditsEmptyState.opening":"chat.creditsEmptyState.add")})]}):r.jsx("button",{type:"button",className:"w-full mt-2.5 text-xs text-muted-foreground hover:text-foreground transition-colors py-1",onClick:()=>u(!0),children:e("chat.creditsEmptyState.enterCustomAmount")})]}),t[32]=f,t[33]=p,t[34]=c,t[35]=C,t[36]=i,t[37]=N,t[38]=S,t[39]=h,t[40]=e,t[41]=j,t[42]=M):M=t[42];let O;t[43]!==x||t[44]!==n||t[45]!==s.slug?(O=()=>{n({to:"/$org/settings/ai-providers",params:{org:s.slug}}),x()},t[43]=x,t[44]=n,t[45]=s.slug,t[46]=O):O=t[46];let F;t[47]!==e?(F=e("chat.creditsEmptyState.useYourOwnProvider"),t[47]=e,t[48]=F):F=t[48];let $;t[49]===Symbol.for("react.memo_cache_sentinel")?($=r.jsx(kr,{size:12,className:"transition-transform duration-150 group-hover:translate-x-0.5"}),t[49]=$):$=t[49];let z;t[50]!==O||t[51]!==F?(z=r.jsxs("button",{type:"button",className:"group flex items-center gap-1 text-xs text-muted-foreground hover:text-foreground transition-colors",onClick:O,children:[F,$]}),t[50]=O,t[51]=F,t[52]=z):z=t[52];let K;t[53]!==e?(K=e("chat.creditsEmptyState.skipForNow"),t[53]=e,t[54]=K):K=t[54];let X;t[55]!==x||t[56]!==K?(X=r.jsx(le,{variant:"ghost",size:"sm",className:"text-xs text-muted-foreground",onClick:x,children:K}),t[55]=x,t[56]=K,t[57]=X):X=t[57];let J;t[58]!==z||t[59]!==X?(J=r.jsxs("div",{className:"px-6 py-3.5 border-t border-border bg-muted/30 flex items-center justify-between",children:[z,X]}),t[58]=z,t[59]=X,t[60]=J):J=t[60];let H;t[61]!==I||t[62]!==M||t[63]!==J?(H=r.jsxs(es,{className:"sm:max-w-[500px] gap-0 p-0 overflow-hidden",onOpenAutoFocus:nS,children:[I,M,J]}),t[61]=I,t[62]=M,t[63]=J,t[64]=H):H=t[64];let W;return t[65]!==H||t[66]!==V?(W=r.jsx(ts,{open:!0,onOpenChange:V,children:H}),t[65]=H,t[66]=V,t[67]=W):W=t[67],W}function nS(t){return t.preventDefault()}function iS(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 i=n;let o,a;e[2]===Symbol.for("react.memo_cache_sentinel")?(o=ie("inline-flex items-center gap-1.5 px-3 py-1 rounded-full","bg-success/10 border border-success/20","animate-in fade-in-0 slide-in-from-bottom-2 duration-300"),a=r.jsx(Km,{size:13,className:"text-success"}),e[2]=o,e[3]=a):(o=e[2],a=e[3]);let l;return e[4]!==i?(l=r.jsxs("div",{className:o,children:[a,r.jsxs("span",{className:"text-xs font-medium text-success tabular-nums",children:["$",i," in credits to get started"]})]}),e[4]=i,e[5]=l):l=e[5],l}function rS(){const t=B.c(8),{org:e}=Fe(),s=St();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 i,o,a;t[3]===Symbol.for("react.memo_cache_sentinel")?(i=ie("inline-flex items-center gap-1.5 px-3 py-1 rounded-full cursor-pointer","bg-warning/10 border border-warning/20","hover:bg-warning/15","transition-colors duration-150","animate-in fade-in-0 slide-in-from-bottom-2 duration-300"),o=r.jsx(wn,{size:13,className:"text-warning"}),a=r.jsx("span",{className:"text-xs font-medium text-warning",children:"No credits remaining · Add more"}),t[3]=i,t[4]=o,t[5]=a):(i=t[3],o=t[4],a=t[5]);let l;return t[6]!==n?(l=r.jsxs("button",{type:"button",onClick:n,className:i,children:[o,a]}),t[6]=n,t[7]=l):l=t[7],l}function oS(t){const e=B.c(11),{className:s}=t;let n;e[0]!==s?(n=ie("flex h-full w-full flex-col bg-background",s),e[0]=s,e[1]=n):n=e[1];let i;e[2]===Symbol.for("react.memo_cache_sentinel")?(i=r.jsx("div",{className:"size-6 rounded-lg bg-muted animate-pulse"}),e[2]=i):i=e[2];let o;e[3]===Symbol.for("react.memo_cache_sentinel")?(o=r.jsxs("div",{className:"flex items-center gap-3",children:[i,r.jsxs("div",{className:"flex flex-col gap-2",children:[r.jsx("div",{className:"h-3.5 w-28 rounded bg-muted animate-pulse"}),r.jsx("div",{className:"h-3 w-40 rounded bg-muted/60 animate-pulse"})]})]}),e[3]=o):o=e[3];let a;e[4]===Symbol.for("react.memo_cache_sentinel")?(a=r.jsx("div",{className:"flex items-center h-12 flex-none border-b border-border/80 px-4",children:r.jsxs("div",{className:"flex items-center justify-between gap-3 w-full",children:[o,r.jsxs("div",{className:"flex items-end gap-2",children:[r.jsx("div",{className:"h-6 w-6 rounded-full bg-muted animate-pulse"}),r.jsx("div",{className:"h-6 w-6 rounded-lg bg-muted animate-pulse"})]})]})}),e[4]=a):a=e[4];let l;e[5]===Symbol.for("react.memo_cache_sentinel")?(l=r.jsx("div",{className:"flex-1 overflow-hidden px-4 py-4",children:r.jsxs("div",{className:"mx-auto flex w-full max-w-2xl flex-col gap-4",children:[r.jsx(ya,{align:"right",width:"w-3/4"}),r.jsx(ya,{align:"left",width:"w-full",lines:3}),r.jsx(ya,{align:"right",width:"w-2/3"}),r.jsx(ya,{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=r.jsx("div",{className:"relative flex flex-1 flex-col gap-2 p-2.5",children:r.jsx("div",{className:"relative flex-1",children:r.jsxs("div",{className:"space-y-2 p-2",children:[r.jsx("div",{className:"h-3 w-full rounded bg-muted/40 animate-pulse"}),r.jsx("div",{className:"h-3 w-4/5 rounded bg-muted/40 animate-pulse"})]})})}),e[6]=c):c=e[6];let d;e[7]===Symbol.for("react.memo_cache_sentinel")?(d=r.jsx("div",{className:"flex items-center gap-1",children:r.jsx("div",{className:"size-8 rounded-full bg-muted/60 animate-pulse"})}),e[7]=d):d=e[7];let h;e[8]===Symbol.for("react.memo_cache_sentinel")?(h=r.jsx("div",{className:"px-4 py-4",children:r.jsx("div",{className:"mx-auto w-full max-w-2xl",children:r.jsxs("div",{className:"relative flex min-h-[130px] flex-col rounded-xl bg-background card-shadow",children:[c,r.jsxs("div",{className:"flex items-center justify-between px-2.5 pb-2.5",children:[d,r.jsxs("div",{className:"flex items-center gap-1",children:[r.jsx("div",{className:"h-8 w-32 rounded-lg bg-muted/60 animate-pulse"}),r.jsx("div",{className:"size-8 rounded-full bg-muted animate-pulse"})]})]})]})})}),e[8]=h):h=e[8];let u;return e[9]!==n?(u=r.jsxs("div",{className:n,children:[a,l,h]}),e[9]=n,e[10]=u):u=e[10],u}function ya(t){const e=B.c(22),{align:s,width:n,lines:i}=t,o=n===void 0?"w-full":n,a=i===void 0?1:i,l=s==="right"?"flex-row-reverse":"flex-row";let c;e[0]!==l?(c=ie("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=ie("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=r.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=ie("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=r.jsx("div",{className:"space-y-2",children:p.map((_,y)=>r.jsx("div",{className:ie("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=r.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=r.jsxs("div",{className:h,children:[u,x]}),e[16]=x,e[17]=h,e[18]=v):v=e[18];let b;return e[19]!==v||e[20]!==c?(b=r.jsx("div",{className:c,children:v}),e[19]=v,e[20]=c,e[21]=b):b=e[21],b}function aS(t){const e=B.c(7),{scrollRef:s,sentinelRef:n,hasMoreOlder:i,isFetchingOlder:o,fetchOlderMessages:a}=t;let l,c;e[0]!==a||e[1]!==i||e[2]!==o||e[3]!==s||e[4]!==n?(l=()=>{const d=n.current,h=s.current;if(!d||!h||!i)return;const u=new IntersectionObserver(async f=>{if(!f[0]?.isIntersecting||o||!i)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,i,o,a],e[0]=a,e[1]=i,e[2]=o,e[3]=s,e[4]=n,e[5]=l,e[6]=c):(l=e[5],c=e[6]),A.useEffect(l,c)}function lS(t){const e=B.c(5),{className:s,children:n}=t;let i;e[0]!==s?(i=ie("flex flex-col h-full w-full bg-background transform-[translateZ(0)]",s),e[0]=s,e[1]=i):i=e[1];let o;return e[2]!==n||e[3]!==i?(o=r.jsx("div",{className:i,children:n}),e[2]=n,e[3]=i,e[4]=o):o=e[4],o}function cS(t){const e=B.c(5),{children:s,className:n}=t;let i;e[0]!==n?(i=ie("flex-1 min-h-0 overflow-y-auto isolate",n),e[0]=n,e[1]=i):i=e[1];let o;return e[2]!==s||e[3]!==i?(o=r.jsx("div",{className:i,children:s}),e[2]=s,e[3]=i,e[4]=o):o=e[4],o}function dS(t){const e=B.c(2),{children:s}=t;let n;return e[0]!==s?(n=r.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 uS(){const t=re(),{messages:e,status:s,hasMoreOlder:n,isFetchingOlder:i,fetchOlderMessages:o}=Js(),{taskId:a}=Zt();JL();const l=ym(a??""),c=kx(l),d=c.size===0?e:e.filter(b=>!c.has(b.id)),h=Mx(d),u=h.at(-1),m=P8()*y8+16,p=A.useRef(null),g=A.useRef(null);aS({scrollRef:p,sentinelRef:g,hasMoreOlder:n,isFetchingOlder:i,fetchOlderMessages:o});const x=Ox({initial:!1}),v=b=>{p.current=b,x.scrollRef(b)};return r.jsx($x,{messages:e,children:r.jsxs("div",{className:"relative h-full w-full min-w-0",children:[r.jsx("div",{ref:v,"data-chat-scroller":!0,className:"w-full min-w-0 max-w-full overflow-y-auto h-full [container-type:size]",style:{paddingBottom:m},children:r.jsxs("div",{ref:x.contentRef,className:"overflow-x-clip",children:[r.jsxs("div",{className:"flex flex-col min-w-0 max-w-2xl mx-auto w-full",children:[r.jsx("div",{ref:g,"aria-hidden":!0,className:"h-px"}),i&&r.jsx("div",{className:"flex items-center justify-center py-3 text-xs text-muted-foreground",children:t("chat.chat.loadingOlderMessages")}),h.slice(0,-1).map((b,_)=>r.jsx(Uu,{pair:b,isLastPair:!1,status:_===h.length-1?s:void 0},`pair-${b.user?.id??b.assistant?.id}`))]}),u&&r.jsx("div",{className:"min-h-[100cqh] min-w-0 max-w-2xl mx-auto w-full",children:r.jsx(Uu,{pair:u,isLastPair:!0,status:s},`pair-${u.user?.id??u.assistant?.id}`)})]})}),!x.isAtBottom&&r.jsx(le,{type:"button",variant:"outline",size:"icon-sm","aria-label":t("chat.chat.jumpToLatest"),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:m+8},onClick:()=>{x.scrollToBottom()},children:r.jsx(_x,{size:14})})]})})}function hS(t){const e=B.c(5),{children:s,className:n}=t;let i;e[0]!==n?(i=ie("flex-none w-full mx-auto p-2 pt-0","max-w-2xl min-w-0",n),e[0]=n,e[1]=i):i=e[1];let o;return e[2]!==s||e[3]!==i?(o=r.jsx("div",{className:i,children:s}),e[2]=s,e[3]=i,e[4]=o):o=e[4],o}const _t=Object.assign(lS,{Main:cS,Messages:uS,EmptyState:dS,Footer:hS,Input:YL,Provider:Cx,ActiveTaskProvider:jx,Skeleton:oS,IceBreakers:b8,NoAiProviderEmptyState:D6,CreditsEmptyState:sS,CreditsEyebrow:iS,NoCreditsEyebrow:rS,CreditsExhaustedBanner:Y2});function fS(){const t=h2(),{pendingAgentOption:e}=Ts(),s=ac();if(Ii()?.isThreadLocked)return!1;const i=e==="claude-code-desktop"&&s.claudeCode||e==="codex-desktop"&&s.codex;return t.length===0&&!i}function Hr(t){return t>=1e6?`${(t/1e6).toFixed(1)}M`:t>=1e3?`${(t/1e3).toFixed(1)}k`:String(t)}function Wc(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 mS(t){return t?t.replace(/-\d{8}(?:-[a-z0-9]+)*$/i,"").replace(/-/g," "):"—"}function pS(t){const e=B.c(4),{items:s}=t;let n;e[0]!==s?(n=s.map(gS),e[0]=s,e[1]=n):n=e[1];let i;return e[2]!==n?(i=r.jsx("div",{className:"grid grid-cols-2 gap-x-8 gap-y-6",children:n}),e[2]=n,e[3]=i):i=e[3],i}function gS(t){return r.jsxs("div",{className:"flex flex-col gap-1 min-w-0",children:[r.jsx("span",{className:"text-xs text-muted-foreground truncate",children:t.label}),r.jsx("span",{className:"text-sm text-foreground tabular-nums truncate",children:t.value})]},t.label)}function xS(t){const e=B.c(33),{userTokens:s,assistantTokens:n,otherTokens:i}=t,o=re(),a=s+n+i,l=a>0?s/a*100:0,c=a>0?n/a*100:0,d=a>0?i/a*100:0;let h;e[0]!==l?(h=l>0&&r.jsx("div",{className:"h-full bg-chart-1",style:{width:`${l}%`}}),e[0]=l,e[1]=h):h=e[1];let u;e[2]!==c?(u=c>0&&r.jsx("div",{className:"h-full bg-chart-2",style:{width:`${c}%`}}),e[2]=c,e[3]=u):u=e[3];let f;e[4]!==d?(f=d>0&&r.jsx("div",{className:"h-full bg-muted-foreground/30",style:{width:`${d}%`}}),e[4]=d,e[5]=f):f=e[5];let m;e[6]!==h||e[7]!==u||e[8]!==f?(m=r.jsxs("div",{className:"flex h-2 w-full overflow-hidden rounded-full bg-muted",children:[h,u,f]}),e[6]=h,e[7]=u,e[8]=f,e[9]=m):m=e[9];let p;e[10]===Symbol.for("react.memo_cache_sentinel")?(p=r.jsx("span",{className:"inline-block h-2 w-2 rounded-sm bg-chart-1 shrink-0"}),e[10]=p):p=e[10];let g;e[11]!==o||e[12]!==l?(g=o("chat.contextPanel.userPercent",{pct:l.toFixed(1)}),e[11]=o,e[12]=l,e[13]=g):g=e[13];let x;e[14]!==g?(x=r.jsxs("div",{className:"flex items-center gap-1.5",children:[p,r.jsx("span",{className:"text-xs text-muted-foreground",children:g})]}),e[14]=g,e[15]=x):x=e[15];let v;e[16]===Symbol.for("react.memo_cache_sentinel")?(v=r.jsx("span",{className:"inline-block h-2 w-2 rounded-sm bg-chart-2 shrink-0"}),e[16]=v):v=e[16];let b;e[17]!==c||e[18]!==o?(b=o("chat.contextPanel.assistantPercent",{pct:c.toFixed(1)}),e[17]=c,e[18]=o,e[19]=b):b=e[19];let _;e[20]!==b?(_=r.jsxs("div",{className:"flex items-center gap-1.5",children:[v,r.jsx("span",{className:"text-xs text-muted-foreground",children:b})]}),e[20]=b,e[21]=_):_=e[21];let y;e[22]!==d||e[23]!==i||e[24]!==o?(y=i>0&&r.jsxs("div",{className:"flex items-center gap-1.5",children:[r.jsx("span",{className:"inline-block h-2 w-2 rounded-sm bg-muted-foreground/30 shrink-0"}),r.jsx("span",{className:"text-xs text-muted-foreground",children:o("chat.contextPanel.otherPercent",{pct:d.toFixed(1)})})]}),e[22]=d,e[23]=i,e[24]=o,e[25]=y):y=e[25];let L;e[26]!==_||e[27]!==y||e[28]!==x?(L=r.jsxs("div",{className:"flex flex-wrap gap-x-3 gap-y-1",children:[x,_,y]}),e[26]=_,e[27]=y,e[28]=x,e[29]=L):L=e[29];let w;return e[30]!==L||e[31]!==m?(w=r.jsxs("div",{className:"flex flex-col gap-2",children:[m,L]}),e[30]=L,e[31]=m,e[32]=w):w=e[32],w}function vS(t){const e=B.c(11),{agentId:s,isError:n}=t,i=gs(s),o=i?.title??"Subtask",a=i?.icon??null;let l;e[0]!==a||e[1]!==o?(l=r.jsx(an,{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=ie("shrink-0 font-medium",c),e[3]=c,e[4]=d):d=e[4];let h;e[5]!==o||e[6]!==d?(h=r.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=r.jsxs(r.Fragment,{children:[l,h]}),e[8]=l,e[9]=h,e[10]=u):u=e[10],u}function bS(t){const e=B.c(12),{isError:s}=t,n=re();let i;e[0]!==n?(i=n("chat.contextPanel.subtask"),e[0]=n,e[1]=i):i=e[1];const o=i;let a;e[2]!==o?(a=r.jsx(an,{icon:null,name:o,size:"xs",className:"size-6 rounded-md shrink-0"}),e[2]=o,e[3]=a):a=e[3];const l=s?"text-destructive":"text-foreground";let c;e[4]!==l?(c=ie("shrink-0 font-medium",l),e[4]=l,e[5]=c):c=e[5];let d;e[6]!==o||e[7]!==c?(d=r.jsx("span",{className:c,children:o}),e[6]=o,e[7]=c,e[8]=d):d=e[8];let h;return e[9]!==a||e[10]!==d?(h=r.jsxs(r.Fragment,{children:[a,d]}),e[9]=a,e[10]=d,e[11]=h):h=e[11],h}function yS(t){const e=B.c(18),{part:s}=t,n=s.input?.agent_id,i=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=r.jsx(bS,{isError:o}),e[0]=o,e[1]=l):l=e[1];let c;e[2]!==n||e[3]!==o?(c=r.jsx(vS,{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=r.jsx(A.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&&r.jsxs(r.Fragment,{children:[r.jsx("span",{className:"text-muted-foreground/50",children:"·"}),r.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]!==i?(u=r.jsx("span",{className:"ml-auto shrink-0",children:i?r.jsx(et,{size:12,className:"animate-spin text-muted-foreground"}):o?r.jsx(cb,{size:12,className:"text-destructive"}):a?r.jsx(wn,{size:12,className:"text-warning"}):r.jsx(ec,{size:12,className:"text-success"})}),e[10]=a,e[11]=o,e[12]=i,e[13]=u):u=e[13];let f;return e[14]!==d||e[15]!==h||e[16]!==u?(f=r.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 _S(t){const e=B.c(78),{onClose:s,back:n,className:i}=t,o=re(),[a,l]=A.useState(null),{messages:c}=Js(),{activeTask:d}=Zt(),{selectedModel:h,selectedVirtualMcp:u}=Ts();let f,m,p,g,x,v,b,_;if(e[0]!==d||e[1]!==n||e[2]!==i||e[3]!==c||e[4]!==s||e[5]!==a?.id||e[6]!==h||e[7]!==u?.title||e[8]!==o){_=Symbol.for("react.early_return_sentinel");e:{const w=Sm(c),j=[...c].reverse().find(ES),S=j?.metadata?.usage,C=j?.metadata?.modelLimits?.contextWindow??h?.limits?.contextWindow??null,N=S?.contextTokens??0,V=C&&C>0?(N/C*100).toFixed(1):null,E=c;let T;e[17]!==E?(T=E.filter(AS).reduce(TS,0),e[17]=E,e[18]=T):T=e[18];const k=T,R=c;let P;e[19]!==R?(P=R.filter(NS).reduce(VS,0),e[19]=R,e[20]=P):P=e[20];const D=P,I=Math.max(0,w.totalTokens-k-D),M=c[0],O=c.at(-1),F=M?.metadata?.created_at??d?.created_at,$=O?.metadata?.created_at??d?.updated_at,z=c.filter(kS),K=c.flatMap(jS),X=h?.modelId?mS(h.modelId):"—",J=u?.title??"Super Agent",H=[{label:o("chat.contextPanel.sessionLabel"),value:d?.title??o("chat.contextPanel.newChat")},{label:o("chat.contextPanel.messagesLabel"),value:z.length},{label:o("chat.contextPanel.agentLabel"),value:J},{label:o("chat.contextPanel.modelLabel"),value:X},{label:o("chat.contextPanel.contextLimitLabel"),value:C?Hr(C):"—"},{label:o("chat.contextPanel.sessionTokensLabel"),value:w.totalTokens>0?Hr(w.totalTokens):"0"},{label:o("chat.contextPanel.usageLabel"),value:V!==null?`${V}%`:"—"},{label:o("chat.contextPanel.inputTokensLabel"),value:w.inputTokens>0?Hr(w.inputTokens):"0"},{label:o("chat.contextPanel.outputTokensLabel"),value:w.outputTokens>0?Hr(w.outputTokens):"0"},{label:o("chat.contextPanel.reasoningTokensLabel"),value:w.reasoningTokens>0?Hr(w.reasoningTokens):"0"},{label:o("chat.contextPanel.costLabel"),value:w.cost>0?`$${w.cost<.001?w.cost.toFixed(6):w.cost.toFixed(4)}`:"$0.00"},{label:o("chat.contextPanel.sessionCreatedLabel"),value:Wc(F)},{label:o("chat.contextPanel.lastActivityLabel"),value:Wc($)}];if(!d&&z.length===0){let G;e[21]!==i?(G=ie("flex flex-col h-full w-full border-l border-border bg-background",i),e[21]=i,e[22]=G):G=e[22];let te;e[23]!==o?(te=o("chat.contextPanel.title"),e[23]=o,e[24]=te):te=e[24];let se;e[25]!==te?(se=r.jsx("span",{className:"text-sm font-medium text-foreground",children:te}),e[25]=te,e[26]=se):se=e[26];let ne;e[27]!==n?(ne=n?r.jsx(Gu,{size:14,className:"text-muted-foreground"}):r.jsx(Pn,{size:14,className:"text-muted-foreground"}),e[27]=n,e[28]=ne):ne=e[28];let de;e[29]!==s||e[30]!==ne?(de=r.jsx("button",{type:"button",onClick:s,className:"flex size-6 items-center justify-center rounded hover:bg-accent transition-colors",children:ne}),e[29]=s,e[30]=ne,e[31]=de):de=e[31];let xe;e[32]!==se||e[33]!==de?(xe=r.jsxs("div",{className:"h-11 px-4 flex items-center justify-between shrink-0 border-b border-border/50",children:[se,de]}),e[32]=se,e[33]=de,e[34]=xe):xe=e[34];let he;e[35]!==o?(he=o("chat.contextPanel.emptyState"),e[35]=o,e[36]=he):he=e[36];let ce;e[37]!==he?(ce=r.jsx("div",{className:"flex-1 flex items-center justify-center px-4 text-center",children:r.jsx("p",{className:"text-xs text-muted-foreground",children:he})}),e[37]=he,e[38]=ce):ce=e[38];let oe;e[39]!==G||e[40]!==xe||e[41]!==ce?(oe=r.jsxs("div",{className:G,children:[xe,ce]}),e[39]=G,e[40]=xe,e[41]=ce,e[42]=oe):oe=e[42],_=oe;break e}e[43]!==i?(v=ie("flex flex-col h-full w-full border-l border-border bg-background overflow-y-auto",i),e[43]=i,e[44]=v):v=e[44];let W;e[45]!==o?(W=o("chat.contextPanel.title"),e[45]=o,e[46]=W):W=e[46];let U;e[47]!==W?(U=r.jsx("span",{className:"text-sm font-medium text-foreground",children:W}),e[47]=W,e[48]=U):U=e[48];let Q;e[49]!==n?(Q=n?r.jsx(Gu,{size:14}):r.jsx(Pn,{size:14}),e[49]=n,e[50]=Q):Q=e[50];let q;e[51]!==s||e[52]!==Q?(q=r.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[51]=s,e[52]=Q,e[53]=q):q=e[53],e[54]!==U||e[55]!==q?(b=r.jsxs("div",{className:"flex h-11 shrink-0 items-center justify-between border-b border-border/50 px-4",children:[U,q]}),e[54]=U,e[55]=q,e[56]=b):b=e[56],f="flex flex-col gap-8 p-6",m=K.length>0&&r.jsxs("div",{className:"flex flex-col gap-3",children:[r.jsx("span",{className:"text-xs text-muted-foreground",children:o("chat.contextPanel.subtasksSection")}),r.jsx("div",{className:"flex flex-col gap-1",children:K.map(wS)})]}),p=r.jsx(pS,{items:H});let Z;e[57]!==o?(Z=o("chat.contextPanel.contextBreakdownSection"),e[57]=o,e[58]=Z):Z=e[58];let Y;e[59]!==Z?(Y=r.jsx("span",{className:"text-xs text-muted-foreground",children:Z}),e[59]=Z,e[60]=Y):Y=e[60];let ee;e[61]!==D||e[62]!==I||e[63]!==k?(ee=r.jsx(xS,{userTokens:k,assistantTokens:D,otherTokens:I}),e[61]=D,e[62]=I,e[63]=k,e[64]=ee):ee=e[64],e[65]!==Y||e[66]!==ee?(g=r.jsxs("div",{className:"flex flex-col gap-3",children:[Y,ee]}),e[65]=Y,e[66]=ee,e[67]=g):g=e[67],x=z.length>0&&r.jsxs("div",{className:"flex flex-col gap-3",children:[r.jsx("span",{className:"text-xs text-muted-foreground",children:o("chat.contextPanel.rawMessagesSection")}),r.jsx("div",{className:"flex flex-col gap-1",children:z.map(G=>{const te=G.metadata?.created_at,se=a?.id===G.id;return r.jsxs("div",{className:"rounded-md border border-border/50 overflow-hidden",children:[r.jsxs("button",{type:"button",onClick:()=>l(se?null:G),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:[r.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[r.jsx("span",{className:ie("shrink-0 font-medium",G.role==="user"?"text-chart-1":"text-chart-2"),children:G.role}),r.jsx("span",{className:"text-muted-foreground",children:"•"}),r.jsx("span",{className:"truncate text-muted-foreground font-mono",children:G.id})]}),te&&r.jsx("span",{className:"shrink-0 text-muted-foreground tabular-nums",children:Wc(te)})]}),se&&r.jsxs(r.Fragment,{children:[G.role==="assistant"&&(()=>{const ne=G.metadata?._request;if(!ne)return null;const de=ne.systemSections??[],xe=Math.max(1,...de.map(SS)),he=de.reduce(LS,0);return r.jsxs("div",{className:"border-t border-border/50 px-3 py-2.5 text-xs space-y-2.5",children:[r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsx("span",{className:"font-medium text-foreground",children:o("chat.contextPanel.requestLabel")}),r.jsxs("span",{className:"text-muted-foreground tabular-nums",children:[ne.activeTools??0," / ",ne.tools??0," ",o("chat.contextPanel.toolsActive")]})]}),de.length>0&&r.jsxs("div",{className:"space-y-1.5",children:[r.jsxs("div",{className:"text-muted-foreground",children:[o("chat.contextPanel.systemPromptLabel")," ",r.jsxs("span",{className:"tabular-nums",children:["~",Math.round(he/4).toLocaleString()," ",o("chat.contextPanel.tokAbbrev")]})]}),de.map((ce,oe)=>{const me=ce.preview.match(/^<([a-z-]+)/i)?.[1]??`section ${oe}`,pe=ce.chars/xe*100,we=Math.round(ce.chars/4);return r.jsxs("div",{className:"space-y-0.5",children:[r.jsxs("div",{className:"flex items-center justify-between gap-2",children:[r.jsx("span",{className:"font-mono text-foreground truncate",children:me}),r.jsxs("span",{className:"text-muted-foreground tabular-nums shrink-0",children:["~",we.toLocaleString()," ",o("chat.contextPanel.tokAbbrev")]})]}),r.jsx("div",{className:"h-1 w-full rounded-full bg-muted overflow-hidden",children:r.jsx("div",{className:"h-full rounded-full bg-chart-3",style:{width:`${pe}%`}})})]},oe)})]})]})})(),r.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(G,null,2)})]})]},G.id)})})]})}e[0]=d,e[1]=n,e[2]=i,e[3]=c,e[4]=s,e[5]=a?.id,e[6]=h,e[7]=u?.title,e[8]=o,e[9]=f,e[10]=m,e[11]=p,e[12]=g,e[13]=x,e[14]=v,e[15]=b,e[16]=_}else f=e[9],m=e[10],p=e[11],g=e[12],x=e[13],v=e[14],b=e[15],_=e[16];if(_!==Symbol.for("react.early_return_sentinel"))return _;let y;e[68]!==f||e[69]!==m||e[70]!==p||e[71]!==g||e[72]!==x?(y=r.jsxs("div",{className:f,children:[m,p,g,x]}),e[68]=f,e[69]=m,e[70]=p,e[71]=g,e[72]=x,e[73]=y):y=e[73];let L;return e[74]!==v||e[75]!==b||e[76]!==y?(L=r.jsxs("div",{className:v,children:[b,y]}),e[74]=v,e[75]=b,e[76]=y,e[77]=L):L=e[77],L}function LS(t,e){return t+e.chars}function SS(t){return t.chars}function wS(t,e){return r.jsx(yS,{part:t},e)}function jS(t){return(t.parts??[]).filter(CS)}function CS(t){return t.type==="tool-subtask"}function kS(t){return t.role!=="system"}function VS(t,e){const s=e.metadata?.usage;return t+(s?.outputTokens??0)}function NS(t){return t.role==="assistant"}function TS(t,e){const s=e.metadata?.usage;return t+(s?.inputTokens??0)}function AS(t){return t.role==="user"}function ES(t){return t.role==="assistant"&&t.metadata?.usage}function PS(t){const e=B.c(27),{onOpenContextPanel:s}=t,{org:n}=Fe(),{selectedVirtualMcp:i}=Ts(),{currentBranch:o}=Zt();let a;e[0]!==n.id?(a=Xo(n.id),e[0]=n.id,e[1]=a):a=e[1];const c=i??a,d=gs(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=r.jsx(Qn,{icon:f,name:u,size:"lg"}),e[2]=f,e[3]=u,e[4]=p):p=e[4];let g;e[5]!==u?(g=r.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?r.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=r.jsxs("div",{className:"space-y-1.5",children:[g,x]}),e[9]=g,e[10]=x,e[11]=v):v=e[11];let b;e[12]!==p||e[13]!==v?(b=r.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]=b):b=e[14];let _;e[15]===Symbol.for("react.memo_cache_sentinel")?(_=r.jsx(_t.IceBreakers,{className:"pb-3"}),e[15]=_):_=e[15];let y;e[16]!==o||e[17]!==d?(y=r.jsx("div",{"data-chat-above-row":"true",className:"@container/chat-bottom pb-1 flex justify-start gap-1",children:r.jsx(hp,{virtualMcp:d,currentBranch:o,showRuntimeLabel:!0})}),e[16]=o,e[17]=d,e[18]=y):y=e[18];let L;e[19]!==s?(L=r.jsx(_t.Input,{onOpenContextPanel:s}),e[19]=s,e[20]=L):L=e[20];let w;e[21]!==y||e[22]!==L?(w=r.jsxs(_t.Footer,{children:[_,y,L]}),e[21]=y,e[22]=L,e[23]=w):w=e[23];let j;return e[24]!==w||e[25]!==b?(j=r.jsxs(r.Fragment,{children:[b,w]}),e[24]=w,e[25]=b,e[26]=j):j=e[26],j}function Th(t){const e=B.c(17),{outputs:s,collapsed:n,onToggle:i,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=ie(a),e[0]=a,e[1]=l):l=e[1];let c;e[2]===Symbol.for("react.memo_cache_sentinel")?(c=r.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=ie("size-4 text-muted-foreground transition-transform",d),e[3]=d,e[4]=h):h=e[4];let u;e[5]!==h?(u=r.jsx(ss,{className:h}),e[5]=h,e[6]=u):u=e[6];let f;e[7]!==i||e[8]!==u?(f=r.jsxs("button",{type:"button",onClick:i,className:"flex w-full items-center justify-between px-3 py-2.5 text-left",children:[c,u]}),e[7]=i,e[8]=u,e[9]=f):f=e[9];let m;e[10]!==n||e[11]!==s?(m=!n&&r.jsx("div",{className:"flex max-h-72 flex-col gap-1.5 overflow-y-auto px-2 pb-2",children:s.map(RS)}),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=r.jsxs("div",{className:l,children:[f,m]}),e[13]=l,e[14]=f,e[15]=m,e[16]=p):p=e[16],p}function RS(t){return r.jsx(Fx,{file:t},t.key)}function DS(){const t=B.c(13),e=Ii()?.taskId??null,s=Bx();let n;t[0]!==s?(n={enabled:s},t[0]=s,t[1]=n):n=t[1];const{data:i}=wm(e,n),[o,a]=A.useState(!1),[l,c]=A.useState(!0);if(!e||!i||i.length===0)return null;let d;t[2]===Symbol.for("react.memo_cache_sentinel")?(d=()=>a(MS),t[2]=d):d=t[2];let h;t[3]!==o||t[4]!==i?(h=r.jsx("div",{className:"absolute top-2 right-2 z-10 hidden w-72 @[1280px]:block",children:r.jsx(Th,{variant:"card",outputs:i,collapsed:o,onToggle:d})}),t[3]=o,t[4]=i,t[5]=h):h=t[5];let u;t[6]===Symbol.for("react.memo_cache_sentinel")?(u=()=>c(IS),t[6]=u):u=t[6];let f;t[7]!==l||t[8]!==i?(f=r.jsx("div",{className:"shrink-0 @[1280px]:hidden",children:r.jsx(Th,{variant:"bar",outputs:i,collapsed:l,onToggle:u})}),t[7]=l,t[8]=i,t[9]=f):f=t[9];let m;return t[10]!==h||t[11]!==f?(m=r.jsxs(r.Fragment,{children:[h,f]}),t[10]=h,t[11]=f,t[12]=m):m=t[12],m}function IS(t){return!t}function MS(t){return!t}function OS(){const t=B.c(27),{org:e}=Fe(),{isChatEmpty:s}=Js(),{openTab:n}=ea(),[i,o]=A.useState("chat"),a=d9();if(fS()){let y;return t[0]!==n?(y=r.jsx(_t,{className:"animate-in fade-in-0 duration-200",children:r.jsx(_t.Main,{className:"flex flex-col items-center",children:r.jsx(_t.EmptyState,{children:r.jsx(_t.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&&!tS(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&&r.jsx(_t.CreditsEmptyState,{}),t[9]=d,t[10]=h):h=t[10];const u=i!=="chat"?"opacity-0 pointer-events-none":"opacity-100";let f;t[11]!==u?(f=ie("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?r.jsx(PS,{onOpenContextPanel:()=>o("context")}):r.jsxs(r.Fragment,{children:[r.jsxs(_t.Main,{className:"relative flex flex-col overflow-hidden @container",children:[r.jsx(DS,{}),r.jsx("div",{className:"min-h-0 flex-1",children:r.jsx(_t.Messages,{})})]}),r.jsx(_t.Footer,{children:r.jsx(_t.Input,{onOpenContextPanel:()=>o("context")})})]}),t[13]=s,t[14]=m):m=t[14];let p;t[15]!==f||t[16]!==m?(p=r.jsx("div",{className:f,children:m}),t[15]=f,t[16]=m,t[17]=p):p=t[17];const g=i==="context"?"opacity-100":"opacity-0 pointer-events-none";let x;t[18]!==g?(x=ie("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=r.jsx(_S,{back:!0,onClose:()=>o("chat")}),t[20]=v):v=t[20];let b;t[21]!==x?(b=r.jsx("div",{className:x,children:v}),t[21]=x,t[22]=b):b=t[22];let _;return t[23]!==h||t[24]!==p||t[25]!==b?(_=r.jsxs(_t,{className:"relative overflow-hidden animate-in fade-in-0 duration-200",children:[h,p,b]}),t[23]=h,t[24]=p,t[25]=b,t[26]=_):_=t[26],_}function Ap(){const t=B.c(2);let e;t[0]===Symbol.for("react.memo_cache_sentinel")?(e=r.jsx(_t.Skeleton,{}),t[0]=e):e=t[0];let s;return t[1]===Symbol.for("react.memo_cache_sentinel")?(s=r.jsx(_s,{fallback:e,children:r.jsx(A.Suspense,{fallback:r.jsx(_t.Skeleton,{}),children:r.jsx(OS,{})})}),t[1]=s):s=t[1],s}function Ah(t,e){return+(e.sidePanel!==null)+Number(e.mainOpen)<=1?!1:t==="side"?e.sidePanel!==null:e.mainOpen}function $S(t){return t.sidePanel!==null||t.mainOpen?t:{...t,sidePanel:"chat"}}function BS(t){const e=t.mainParamValue===0?"0":t.mainParamValue,s=t.entityMetadata?.defaultMainView??null,n=s==null||s.type==="chat",i=t.mainParamPresent?e!=="0":!n,o=n||t.entityMetadata?.chatDefaultOpen?"chat":null,a=t.sidePanelParamPresent?t.sidePanelParamValue===0?null:t.sidePanelParamValue??null:o;return $S({sidePanel:a,mainOpen:i})}function qc(t,e){switch(t.type){case"toggleSidePanel":return e.sidePanel===t.sidePanel?Ah("side",e)?{sidepanel:0}:null:{sidepanel:t.sidePanel};case"toggleMain":return e.mainOpen?Ah("main",e)?{main:0}:null:{main:t.openMainValue};case"openSidePanel":return e.sidePanel===t.sidePanel?null:{sidepanel:t.sidePanel}}}function FS(t){return t.sidePanel!==null&&t.mainOpen?{side:33,main:67}:t.sidePanel!==null?{side:100,main:0}:t.mainOpen?{side:0,main:100}:{side:0,main:0}}function zS(t,e){return t==="main"?{sidepanel:0,main:e}:{sidepanel:t,main:0}}function KS(t,e){const s=St(),n=wr({strict:!1}),i=Wl({strict:!1}),{create:o}=Gl(),{locator:a}=Fe(),{virtualMcpId:l,orgSlug:c,isAgentRoute:d}=e,h=n.main===0?"0":n.main,{sidePanel:u,mainOpen:f}=BS({entityMetadata:t,mainParamPresent:n.main!==void 0,mainParamValue:h,sidePanelParamPresent:n.sidepanel!==void 0,sidePanelParamValue:n.sidepanel}),m={sidePanel:u,mainOpen:f},p=A.useRef(crypto.randomUUID()),g=i.taskId??p.current,x="/$org/$taskId",v=V=>({org:c,taskId:V}),b=d?{virtualmcpid:l}:{},_=(V,E)=>{s({to:x,params:v(g),search:T=>({...T,...V}),replace:E?.replace??!1})};return{taskId:g,sidePanel:u,mainOpen:f,mainParam:h,setTaskId:(V,E)=>{s({to:x,params:v(V),search:T=>{const k={};return E?k.virtualmcpid=E:d&&(k.virtualmcpid=l),k}})},toggleMain:()=>{const V=qc({type:"toggleMain",openMainValue:ll(t)},m);V&&_(V,{replace:!0})},toggleSidePanel:V=>{const E=qc({type:"toggleSidePanel",sidePanel:V},m);E&&_(E,{replace:!0})},setMobileSurface:V=>{const E=h&&h!=="0"?h:ll(t);_(zS(V,E),{replace:!0})},openSidePanel:V=>{const E=qc({type:"openSidePanel",sidePanel:V},m);E&&_(E,{replace:!0})},createNewTask:async()=>{const V=crypto.randomUUID(),E=_v(c,a,g);try{await o({id:V,virtual_mcp_id:l,...E?{branch:E}:{}})}catch{}s({to:x,params:v(V),search:T=>({...b,sidepanel:"chat"})})},openTab:V=>{_({main:V==="0"?0:V},{replace:!0})}}}function Eh(t,e){const s=typeof t=="number"?t:Number(t);return!Number.isFinite(s)||s<=0||s>=100?e:s}function US(t,e){const s=B.c(8);let n;s[0]!==e?(n=c=>Eh(c,e),s[0]=e,s[1]=n):n=s[1];const[i,o]=cx(t,n);let a;s[2]!==e||s[3]!==i?(a=Eh(i,e),s[2]=e,s[3]=i,s[4]=a):a=s[4];let l;return s[5]!==o||s[6]!==a?(l=[a,o],s[5]=o,s[6]=a,s[7]=l):l=s[7],l}const HS=33;function WS(){const t=B.c(1);let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=dx.sidePanelWidth(),t[0]=e):e=t[0],US(e,HS)}function Pr(t,e){const s=(t??"").trim().replace(/^[/\\]+|[/\\]+$/g,"");return s?`${s}/${e}`:e}function Ep(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 qS(){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&&Ep(s))return s}return null}function Pp(t,e){const s=t.previewUrl??t.getFallbackPreviewUrl?.()??qS();if(s&&Ep(s))return new URL(e,s).toString();const n=new URLSearchParams({path:e});return`/api/${t.orgSlug}/sandbox/${encodeURIComponent(t.virtualMcpId)}/${encodeURIComponent(t.branch)}/preview-fetch?${n.toString()}`}function GS(t){return Pp(t,"/.decofile")}async function Rp(t,e){const s=`/api/${t.orgSlug}/sandbox/${encodeURIComponent(t.virtualMcpId)}/${encodeURIComponent(t.branch)}/read`,n=await fetch(s,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({path:e,full:!0})});if(n.status===400)return null;if(!n.ok){const o=new Error(`Failed to read ${e}: ${n.status}`);throw o.status=n.status,o}const i=await n.json();if(typeof i.content!="string")return null;try{return JSON.parse(z6(i.content))}catch{return null}}function lc(t,e){const s=B.c(10),n=t?`${t.orgSlug}/${t.virtualMcpId}/${t.branch}`:"",i=e?.fetchEnabled??!0,o=gs(t?.virtualMcpId)?.metadata?.runtime?.path??null;let a;s[0]!==n?(a=at.decofile(n),s[0]=n,s[1]=a):a=s[1];let l;s[2]!==i||s[3]!==o||s[4]!==t?(l=async()=>{const h=()=>Rp(t,Pr(o,".deco/blocks.gen.json"));if(i){const m=await fetch(GS(t),{cache:"no-store"}).catch(XS);if(m?.ok)return await m.json();const p=await h();if(p)return p;const g=new Error(`Failed to fetch decofile: ${m?.status??"network error"}`);throw g.status=m?.status??502,g}const u=await h();if(u)return u;const f=new Error("decofile unavailable (preview down, no committed snapshot)");throw f.status=502,f},s[2]=i,s[3]=o,s[4]=t,s[5]=l):l=s[5];const c=!!t;let d;return s[6]!==a||s[7]!==l||s[8]!==c?(d={queryKey:a,queryFn:l,enabled:c,staleTime:3e4,retry:JS,retryDelay:YS},s[6]=a,s[7]=l,s[8]=c,s[9]=d):d=s[9],Ft(d)}function YS(t){return _2(5e3,1e3,t,2,0)}function JS(t,e){return e.status!==502&&t<2}function XS(){return null}function cc(t,e){const s=B.c(13),n=e?.fetchEnabled??!0,i=t?.previewUrl,o=gs(t?.virtualMcpId)?.metadata?.runtime?.path??null;let a;s[0]!==t||s[1]!==i?(a=t?at.liveMeta(t.orgSlug,t.virtualMcpId,t.branch,i??""):at.liveMeta(""),s[0]=t,s[1]=i,s[2]=a):a=s[2];let l;s[3]!==n||s[4]!==o||s[5]!==t||s[6]!==i?(l=async()=>{const u=()=>Rp(t,Pr(o,".deco/meta.gen.json"));if(n&&i){const p=new URL("/live/_meta",i).href,g=await fetch(p,{cache:"no-store"}).catch(ew);if(g?.ok)return await g.json();const x=await u();if(x)return x;const v=new Error(`Failed to fetch live meta: ${g?.status??"network error"}`);throw v.status=g?.status??502,v}const f=await u();if(f)return f;const m=new Error("live meta unavailable (preview down, no committed snapshot)");throw m.status=502,m},s[3]=n,s[4]=o,s[5]=t,s[6]=i,s[7]=l):l=s[7];const c=!!t,d=e?.refetchInterval;let h;return s[8]!==a||s[9]!==l||s[10]!==c||s[11]!==d?(h={queryKey:a,queryFn:l,enabled:c,refetchInterval:d,refetchIntervalInBackground:!1,staleTime:3e5,retry:ZS,retryDelay:QS},s[8]=a,s[9]=l,s[10]=c,s[11]=d,s[12]=h):h=s[12],Ft(h)}function QS(t){return _2(5e3,1e3,t,2,0)}function ZS(t,e){return e.status!==502&&t<3}function ew(){return null}function Ph(t){if(!t.startsWith("#")||!t.includes("@"))return null;const e=t.indexOf("@");return{moduleResolveType:t.slice(1,e),blockId:t.slice(e+1)}}function yo(t){return t.includes("@")}function Fd(t){const e=t.lastIndexOf("@");return e<0||e===t.length-1?null:t.slice(e+1)}function Rh(t,e){if(t===e)return!0;const s=Fd(t);return s?e===s||Fd(e)===s:!1}function R9(t,e){const s=t.manifest?.blocks??{};for(const[n,i]of Object.entries(s))if(e in i)return n;return null}function Dp(t,e){const s=R9(t,e);return s!==null&&s.includes("sections")}function tw(t,e){const s=R9(t,e);return s!==null&&s.includes("apps")}function sw(t,e){const s=R9(t,e);return s!==null&&s.includes("matchers")}function yn(t){return!(/\.\w+$/.test(t)||t==="__proto__"||t==="constructor")}function dc(t){try{return decodeURIComponent(t).startsWith("Preview ")}catch{return t.startsWith("Preview ")}}const D9="oklch(0.7278 0.151 289)",Ip="website/matchers/always.ts",Rr="website/matchers/never.ts",Ki="website/flags/multivariate.ts",Dr="website/flags/multivariate/section.ts";function br(){return{__resolveType:Ip}}function Tt(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 nw=12,_a=8,iw=40;function rw(t){const e=t.type;return e==="array"||Array.isArray(e)&&e.includes("array")}function ow(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 i=s.properties?.__resolveType?.enum;return Array.isArray(i)&&typeof i[0]=="string"}const aw="VideoWidget";function Mp(t){return typeof btoa=="function"?btoa(t):Buffer.from(t).toString("base64")}function I9(t){const e=t.match(/^site\/apps\/([^/]+)\/([^/.]+)\.tsx?$/);return e?{vendor:e[1],app:e[2]}:null}function M9(t){const e=t.match(/^([^/]+)\/apps\/([^/.]+)\.tsx?$/);return e?{vendor:e[1],app:e[2]}:null}function Op(t,e){return[`site/apps/${t}/${e}.ts`,`site/apps/${t}/${e}.tsx`,`${t}/apps/${e}.ts`,`${t}/apps/${e}.tsx`]}function O9(t,e){const s=e.manifest?.blocks??{};for(const l of Object.values(s))if(l[t])return l[t];const n=I9(t)??M9(t);if(n){for(const l of Op(n.vendor,n.app))for(const c of Object.values(s))if(c[l])return c[l]}const i=Mp(t);for(const l of Object.values(s))if(l[i])return l[i];const o=e.schema??{};return(o.$defs??o.definitions??{})[i]?{$ref:`#/definitions/${i}`}:{}}function $p(t,e){if(tw(t,e))return!0;const s=I9(e)??M9(e);if(!s)return!1;const n=t.manifest?.blocks?.apps??{};if(Op(s.vendor,s.app).some(a=>a in n))return!0;const i=Mp(e),o=t.schema?.$defs??t.schema?.definitions??{};return i in o}function Bp(t){return t==="site/apps/site.ts"?!1:I9(t)!==null||M9(t)!==null}function _n(t,e){const s=e.schema??{},n=O9(t,e),i=s.$defs??s.definitions??{},o=s.root??{},a=v=>{if(v.startsWith("#/root/")){const _=v.slice(7);return o[_]??{}}const b=v.split("/").pop()??"";return i[b]??{}};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 _=c(v).properties?.type;if(_){if(typeof _.const=="string")return _.const;if(typeof _.default=="string")return _.default;if(Array.isArray(_.enum)&&typeof _.enum[0]=="string")return _.enum[0]}},h=(v,b)=>{const _=c(v);return typeof _.title=="string"&&!_.title.startsWith("#")?_.title:b},u=(v,b=new Set)=>{if(typeof v.$ref!="string"||v.properties||v.anyOf||v.allOf||v.oneOf||v.type)return v;const _=v.$ref.split("/").pop()??"";return!_||b.has(_)?v:u(a(v.$ref),new Set([...b,_]))},f=v=>{const b=v.hide;return b===!0||b==="true"},m=(v,b=new Set,_=0)=>{if(_>nw)return{};if(typeof v.$ref=="string"){const L=v.$ref.split("/").pop()??"";return b.has(L)?{}:m(a(v.$ref),new Set([...b,L]),_+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 j of w)y={...y,...m(j,b,_+1)}}return y},p=(v,b=0,_=new Set)=>{let y=v,L;if(typeof v.$ref=="string"){y=a(v.$ref);const P=v.$ref.split("/").pop()??"";L=P,P===aw&&!y.format&&(y={...y,format:"video-uri"})}y=u(y);const w=L!==void 0&&_.has(L),j=L!==void 0?new Set([..._,L]):_,S=(P,D,I,M=!0)=>!w&&(!M||I<=iw)&&D<_a?p(P,D,j):void 0;let C;{const P=y.anyOf??y.oneOf;if(Array.isArray(P)){const D=P.filter(M=>!(M.type==="null"||M.type===null)),I=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]};D.length>0&&D.every(M=>I(M)!==void 0)&&(C=D.map(M=>I(M)))}}let N,V;if(y.type)N=Array.isArray(y.type)?String(y.type.find(P=>P!=="null")??y.type[0]):String(y.type);else if(y.anyOf||y.allOf||y.oneOf){const D=(y.anyOf??y.allOf??y.oneOf).filter(I=>!(I.type==="null"||I.type===null));if(D.length===0)N="null";else if(D.length===1){const I=D[0];V=I,N=I.type?Array.isArray(I.type)?String(I.type[0]):String(I.type):typeof I.$ref=="string"?"object":"string"}else{if(C){const W=U=>typeof v[U]=="string"?v[U]:typeof y[U]=="string"?y[U]:void 0;return{type:"string",title:typeof y.title=="string"?y.title:void 0,description:typeof y.description=="string"?y.description:void 0,enum:C,format:W("format"),options:W("options")}}const I=D.filter(W=>{const U=W.properties?.__resolveType?.enum;return Array.isArray(U)&&typeof U[0]=="string"}),M=D.find(rw),O=I.some(W=>{const U=W.properties?.__resolveType?.enum;return Array.isArray(U)&&U[0]===Ki});if(M){if(!ow(M,a)&&D.length>1){const U=p(M,b+1,j);return{...U,type:"array",title:typeof y.title=="string"?y.title:U.title,description:typeof y.description=="string"?y.description:U.description}}if(O){const U=p(M,b+1,j);return{...U,type:"array",title:typeof y.title=="string"?y.title:U.title,description:typeof y.description=="string"?y.description:U.description}}}if(I.length>0){const W=I.map(ee=>{const te=ee.properties?.__resolveType?.enum??[],se=String(te[0]);return{resolveType:se,title:typeof ee.title=="string"?ee.title:Tt(se),description:typeof ee.description=="string"?ee.description:void 0,schema:S(ee,b+1,D.length)}}),U=[];for(const ee of D){if(I.includes(ee)||typeof ee.$ref!="string")continue;const G=a(ee.$ref);let te;const se=G.properties?.__resolveType;if(Array.isArray(se?.enum)&&typeof se.enum[0]=="string"&&(te=se.enum[0]),!te&&Array.isArray(G.allOf))for(const ne of G.allOf){const de=ne.properties?.__resolveType?.enum;if(Array.isArray(de)&&typeof de[0]=="string"){te=de[0];break}}te&&U.push({resolveType:te,title:typeof G.title=="string"&&!G.title.startsWith("#")?G.title:Tt(te),description:typeof G.description=="string"?G.description:void 0,schema:S(G,b+1,D.length)})}const Q=new Set(W.map(ee=>ee.resolveType)),q=[...W,...U.filter(ee=>!Q.has(ee.resolveType))],Z=D.filter(ee=>!I.includes(ee)),Y=Z.length===1?S(Z[0],b+1,D.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:q,plainSchema:Y,hidden:f(y)||f(v)?!0:void 0}}const F=D.map(W=>d(W));if(D.length>1&&F.every(W=>typeof W=="string")){const W=D.map((U,Q)=>{const q=c(U),Z=F[Q];return{resolveType:Z,title:h(U,Z),description:typeof q.description=="string"?q.description:void 0,discriminatorValue:Z,schema:S(q,b+1,D.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:W,hidden:f(y)||f(v)?!0:void 0}}const z=W=>{const U=c(W);if(typeof U.title=="string"&&Ph(U.title))return!0;const Q=U.properties?.__resolveType?.enum;if(Array.isArray(Q)&&typeof Q[0]=="string")return!0;if(Array.isArray(U.allOf))for(const q of U.allOf){const Z=q.properties?.__resolveType?.enum;if(Array.isArray(Z)&&typeof Z[0]=="string")return!0}return!1},K=W=>{if(z(W))return!1;const U=c(W);return U.type==="object"||!!U.properties},J=(Array.isArray(y.anyOf)||Array.isArray(y.oneOf))&&b<_a&&D.every(K);if(D.every(W=>typeof W.$ref=="string")&&!J){const W=[];for(const U of D){const Q=a(U.$ref);let q,Z;if(typeof Q.title=="string"){const ee=Ph(Q.title);ee&&(q=ee.blockId,Z=ee.blockId)}if(!q&&Array.isArray(Q.allOf))for(const ee of Q.allOf){const se=((ee.properties??{}).__resolveType??{}).enum;if(Array.isArray(se)&&typeof se[0]=="string"){q=se[0];break}}if(!q){const G=Q.properties?.__resolveType?.enum;Array.isArray(G)&&typeof G[0]=="string"&&(q=G[0])}q||(q=U.$ref.split("/").pop()??"");const Y=d(U);!Y&&!q.includes("/")||W.push({resolveType:Y??q,title:Z??(typeof Q.title=="string"&&!Q.title.startsWith("#")?Q.title:Tt(q)),description:typeof Q.description=="string"?Q.description:void 0,discriminatorValue:Y,schema:S(Q,b+1,D.length)})}return{type:"block-ref",title:typeof y.title=="string"?y.title:void 0,description:typeof y.description=="string"?y.description:void 0,anyOfRefs:W,hidden:f(y)||f(v)?!0:void 0}}if(J){const W=Q=>{if(typeof Q.const=="string"||typeof Q.const=="number"||typeof Q.const=="boolean")return Q.const;if(Array.isArray(Q.enum)&&Q.enum.length===1&&(typeof Q.enum[0]=="string"||typeof Q.enum[0]=="number"||typeof Q.enum[0]=="boolean"))return Q.enum[0]},U=D.map((Q,q)=>{const Z=c(Q).properties??{},Y={};for(const[ee,G]of Object.entries(Z)){const te=W(G);te!==void 0&&(Y[ee]=te)}return{title:h(Q,`Option ${q+1}`),schema:p(Q,b+1),discriminators:Object.keys(Y).length?Y: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:U,hidden:f(y)||f(v)?!0:void 0}}N="object"}}else typeof v.$ref=="string"&&(N="object");let E;if(b<_a){const P=m(y),D=Object.entries(P).filter(([I])=>!I.startsWith("__")&&I!=="@type");if(D.length>0){E={};for(const[I,M]of D)E[I]=p(M,b+1,j)}}let T;if((N==="array"||y.type==="array")&&b<_a){let P=y.items;P&&(typeof P.$ref=="string"&&(P=a(P.$ref)),T=p(P,b+1,j),typeof P.title=="string"&&P.title.includes("{{")&&(T.titleBy=P.title))}const k=P=>{const D=V?.[P];return typeof D=="string"?D:void 0},R=()=>{if("default"in v)return v.default;if("default"in y)return y.default;if(V&&"default"in V)return V.default};return{type:N??"string",title:typeof v.title=="string"?v.title:typeof y.title=="string"?y.title:k("title"),description:typeof v.description=="string"?v.description:typeof y.description=="string"?y.description:k("description"),default:R(),enum:Array.isArray(y.enum)?y.enum:C??void 0,format:typeof v.format=="string"?v.format:typeof y.format=="string"?y.format:k("format"),properties:E,items:T,hidden:f(y)||f(v)?!0:void 0,titleBy:typeof y.titleBy=="string"?y.titleBy:k("titleBy"),image:typeof y.image=="string"?y.image:k("image"),options:typeof v.options=="string"?v.options:typeof y.options=="string"?y.options:k("options")}},g=m(l),x={};for(const[v,b]of Object.entries(g))v.startsWith("__")||v==="@type"||(x[v]=p(b,0));return Object.keys(x).length===0?null:{type:"object",title:typeof l.title=="string"?l.title:void 0,properties:x}}function lw(t,e){const s=e.schema??{},n=O9(t,e),i=s.$defs??s.definitions??{},o=typeof n.$ref=="string"?i[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 cw(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 i={};for(const[o,a]of Object.entries(n))o.startsWith("__")||(i[o]=e(a));return{type:"object",properties:i}}default:return{type:"string"}}},s={};for(const[n,i]of Object.entries(t))n.startsWith("__")||(s[n]=e(i));return Object.keys(s).length===0?null:{type:"object",properties:s}}function ci(t,e){const s=e.schema??{},n=O9(t,e),i=s.$defs??s.definitions??{},o=typeof n.$ref=="string"?i[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 Yn(t){return t.replace(/\/+$/,"")||"/"}function Fp(t){return t.trim().replace(/^\/+|\/+$/g,"")}function dw(t){const e=t.trim();return!(!e.startsWith("/")||e.startsWith("//")||e.includes("..")||e.includes("\\"))}function $9(t){const e=t.trim();return e?dw(e)?null:"Path must start with / and must not contain .. or //.":"Path is required."}const zp=/:([A-Za-z0-9_-]+)|\*/g;function Kp(t){return t.replace(/\{([^{}]*)\}\?/g,"$1")}function wl(t){t=Kp(t);const e=[];let s=0;for(const n of t.matchAll(zp))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 Hn(t,e){return Kp(t).replace(zp,(s,n)=>{const i=e[n??"*"]?.trim();return i?n!==void 0?encodeURIComponent(i):i.split("/").filter(Boolean).map(encodeURIComponent).join("/")||s:s})}const uw=["website/sections/Rendering/Lazy.tsx","website/sections/Rendering/SingleDeferred.tsx"],Dh="website/sections/Rendering/Lazy.tsx";function fs(t){return uw.some(e=>t.endsWith(e))}const Up=["website/pages/Page.tsx","$live/pages/LivePage.tsx"],Hp=new Set(Up),hw=new Set(["site/sections/Theme/Theme.tsx"]);function uc(t){return!!(hw.has(t)||fs(t)||t.toLowerCase().includes("preview"))}function zd(t){const e=t.manifest?.blocks??{};for(const s of Object.values(e))for(const n of Object.keys(s))if(Hp.has(n))return n;return Up[0]}function Kd(t){if(!t)return[];if(t.anyOfRefs?.length)return t.anyOfRefs;if(t.items)return Kd(t.items);if(t.properties){const e=[];for(const s of Object.values(t.properties))e.push(...Kd(s));return e}return[]}function fw(t){const e=t.manifest?.blocks??{},s=[];for(const[n,i]of Object.entries(e))if(n.includes("sections"))for(const o of Object.keys(i)){if(uc(o))continue;const a=ci(o,t);s.push({resolveType:o,title:a.title??Tt(o),description:a.description,previewBlock:o,isSavedBlock:!1})}return s}function mw(t){const e=t.manifest?.blocks??{},s=[];for(const[n,i]of Object.entries(e))if(n.includes("sections"))for(const o of Object.keys(i))uc(o)||s.push({resolveType:o,title:Tt(o)});return s.sort((n,i)=>n.title.localeCompare(i.title))}function Wp(t,e){const s=[];for(const[n,i]of Object.entries(e)){if(n.includes("/")||dc(n)||!i||typeof i!="object"||Array.isArray(i))continue;const o=i,a=o.__resolveType;typeof a=="string"&&(Hp.has(a)||typeof o.path!="string"&&(uc(a)||Dp(t,a)&&s.push({resolveType:n,title:n,description:typeof o.name=="string"?o.name:void 0,previewBlock:n,isSavedBlock:!0})))}return s}function pw(t,e){const s=yn(e.resolveType),n=s?{}:ci(e.resolveType,t);return{resolveType:e.resolveType,title:e.title||n.title||Tt(e.resolveType),description:e.description??n.description,previewBlock:e.resolveType,isSavedBlock:s}}function GH(t,e){const s=zd(t),n=_n(s,t),i=Kd(n?.properties?.sections),o=new Map,a=l=>{if(!uc(l.resolveType)){if(yn(l.resolveType)){dc(l.resolveType)||o.set(l.resolveType,l);return}Dp(t,l.resolveType)&&(o.has(l.resolveType)||o.set(l.resolveType,l))}};for(const l of fw(t))a(l);for(const l of i)a(pw(t,l));for(const l of Wp(t,e))a(l);return[...o.values()].sort((l,c)=>l.title.localeCompare(c.title))}function YH(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}const B9="website/loaders/redirect.ts",qp=new Set([B9,"website/loaders/redirects.ts"]),gw={temporary:307,permanent:301},Ih=t=>typeof t=="string"?t:"",xw=t=>t==="permanent"?"permanent":"temporary";function Gp(t){const e=t&&typeof t.redirect=="object"&&t.redirect!==null&&!Array.isArray(t.redirect)?t.redirect:{};return{from:Ih(e.from),to:Ih(e.to),type:xw(e.type),discardQueryParameters:e.discardQueryParameters===!0}}function Yp(t){const e=[];for(const[s,n]of Object.entries(t)){if(!n||typeof n!="object"||Array.isArray(n))continue;const i=n;if(i.__resolveType!==B9)continue;const{from:o,to:a,type:l,discardQueryParameters:c}=Gp(i);e.push({key:s,from:o,to:a,type:l,discardQueryParameters:c})}return e}function JH(t){return Gp(t)}function vw(t){const e={from:t.from,to:t.to,type:t.type};return t.discardQueryParameters&&(e.discardQueryParameters=!0),{redirect:e,__resolveType:B9}}function bw(t){return(t.split(/[?#]/)[0]??"").replace(/^\/+/,"").replace(/[^a-zA-Z0-9]+/g,"-").replace(/^-+|-+$/g,"").slice(0,32)||"redirect"}const yw=1e3;function _w(t,e){const s=bw(e);for(let n=0;n<yw;n++){const i=`redirects-${s}-${crypto.randomUUID()}`;if(!Object.hasOwn(t,i))return i}throw new Error("Could not generate a unique redirect block key")}function Lw(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 Sw(t,e,s){const n=Yn;if(s){const o=t.find(a=>a.key===s);if(o)return o}const i=t.filter(o=>n(o.path)===n(e));return i.length===0?null:i.length===1?i[0]??null:[...i].sort((o,a)=>o.key.localeCompare(a.key))[0]??null}const Jp=new Set(["website/pages/Page.tsx","$live/pages/LivePage.tsx"]),co="site",F9="site/apps/site.ts";function jl(t,e){return t===co?!0:e.__resolveType===F9}function z9(t,e){return t?K9(t).length>0||Yp(t).length>0?!0:e?U9(t,e).length>0||Ud(t,e)?!0:ww(t,e).length>0:!1:!1}function K9(t){const e=[];for(const[s,n]of Object.entries(t))if(n&&typeof n=="object"&&!Array.isArray(n)){const i=n;typeof i.__resolveType=="string"&&Jp.has(i.__resolveType)&&typeof i.path=="string"&&e.push({key:s,name:typeof i.name=="string"?i.name:Lw(s),path:i.path})}return e}function hc(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 Cl(t,e,s){const n=typeof e.__resolveType=="string"?e.__resolveType:"",i=n?ci(n,s):{};if(i.title)return i.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 Ud(t,e){const s=t[co];if(s&&typeof s=="object"&&!Array.isArray(s)){const n=s,i=n.__resolveType;if(typeof i=="string"&&(jl(co,n)||$p(e,i)))return{key:co,name:Cl(co,n,e),resolveType:i}}for(const[n,i]of Object.entries(t)){if(n.includes("/")||!i||typeof i!="object"||Array.isArray(i))continue;const o=i;if(!jl(n,o))continue;const a=typeof o.__resolveType=="string"?o.__resolveType:F9;return{key:n,name:Cl(n,o,e),resolveType:a}}return null}function ww(t,e){const s=[];for(const[n,i]of Object.entries(t)){if(n.includes("/")||!i||typeof i!="object"||Array.isArray(i))continue;const o=i,a=o.__resolveType;typeof a=="string"&&(Jp.has(a)||typeof o.path!="string"&&(jl(n,o)||!$p(e,a)&&!Bp(a)||s.push({key:n,name:Cl(n,o,e),resolveType:a})))}return s.sort((n,i)=>n.name.localeCompare(i.name))}function U9(t,e){return Wp(e,t).map(s=>{const n=t[s.resolveType],i=typeof n.__resolveType=="string"?n.__resolveType:"";return{key:s.resolveType,name:s.description??hc(s.resolveType,n),resolveType:i}}).sort((s,n)=>s.name.localeCompare(n.name))}const jw={overview:qv,settings:Hm,automations:e9,preview:li,code:Wv,content:Um,git:Zs,files:ei};function Mh(t){const e=Jl(t);if(e.type==="icon"){const s=Oi(e.name);return s?{kind:"component",Component:s}:null}return e.type==="url"?{kind:"url",src:e.url}:null}function La(t){if(t.kind==="system")return{kind:"component",Component:jw[t.tabId]};const e=Mh(t.iconUrl);if(e)return e;if(!t.appId)return{kind:"fallback"};const s=t.connections.find(i=>i.id===t.appId);if(!s)return{kind:"fallback"};const n=Mh(s.icon);return n||{kind:"fallback"}}const Cw=[{id:"preview",title:"Preview"},{id:"code",title:"Code"}];function kw(t){return t?[...Cw]:[]}function Xp(t){return t.reportsOnly&&!t.onReportAgent&&(t.tabId==="preview"||t.tabId==="code")}function Vw(t){const{org:e}=Fe(),s=Bs(),n=Pm(),i=A.useSyncExternalStore(n.threads.subscribe,n.threads.get),o=t?i.find(l=>l.id===t)??null:null,{data:a}=mm({queryKey:at.ensureTask(e.id,t),queryFn:async()=>{if(!t)return null;try{const{item:l}=await s.call("COLLECTION_THREADS_GET",{id:t});return l??null}catch{return null}},select:l=>l?.metadata??null,staleTime:3e4});return o?.metadata??a??null}function H9(t){const e=B.c(35),s=re(),n=St();let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i={strict:!1},e[0]=i):i=e[0];const o=wr(i),a=gs(t.virtualMcpId),l=Vw(t.taskId),{org:c}=Fe(),{currentBranch:d}=Zt();let h;e[1]!==a?(h=ia(a),e[1]=a,e[2]=h):h=e[2];const u=h,f=u?.connectionId??"",m=u?.owner??"",p=u?.name??"",g=u?d:null;let x;e[3]!==c.id||e[4]!==c.slug||e[5]!==f||e[6]!==m||e[7]!==p||e[8]!==g?(x={orgId:c.id,orgSlug:c.slug,connectionId:f,owner:m,repo:p,branch:g},e[3]=c.id,e[4]=c.slug,e[5]=f,e[6]=m,e[7]=p,e[8]=g,e[9]=x):x=e[9];const v=N9(x),b=v.data?.state==="open",_=a?.metadata?.ui??null,y=_?.layout??null,L=y?.tabs??[],w=a?.id?Qx(a.id):null,j=l?.expanded_tools??[],S=n2(a),C=sn(a?.metadata)||sn(l),{granted:N}=Nb("agents:manage"),V=tc();let E;e[10]===Symbol.for("react.memo_cache_sentinel")?(E={includeVirtual:!0},e[10]=E):E=e[10];const T=Rn(E),k=Fs(),{vmEntry:R,previewUrl:P}=Er(),D=k.lifecycle.phase==="running";let I;e[11]!==P||e[12]!==R?.sandboxProviderKind?(I=R?.sandboxProviderKind==="user-desktop"&&P?`${P.replace(/\/+$/,"")}/api/mcp`:void 0,e[11]=P,e[12]=R?.sandboxProviderKind,e[13]=I):I=e[13];const M=I,O=Zx({connectionId:w??void 0,orgId:c.id,orgSlug:c.slug,mcpUrl:M}),F=O,$=!!O&&D;let z;e[14]!==$||e[15]!==F?(z={client:F,enabled:$},e[14]=$,e[15]=F,e[16]=z):z=e[16];const{data:K}=f9(z),X=w&&D?(K?.tools??[]).filter(Aw).map(ke=>({connectionId:w,toolName:ke.name,label:Ci(ke.name),icon:null})):[],J=X[0],H=J?X:_?.pinnedViews??[],W=J&&w?{type:"ext-apps",id:w,toolName:J.toolName}:y?.defaultMainView??null,U=C&&a?.id&&d?{orgSlug:c.slug,virtualMcpId:a.id,branch:d,previewUrl:P}:null;let Q;e[17]!==D?(Q={fetchEnabled:D},e[17]=D,e[18]=Q):Q=e[18];const{data:q}=lc(U,Q);let Z;e[19]!==D?(Z={fetchEnabled:D},e[19]=D,e[20]=Z):Z=e[20];const{data:Y}=cc(U,Z),ee=z9(q,Y),{activeTab:G,mainOpen:te}=fb({mainParam:o.main,metadata:W||y?{defaultMainView:W,tabs:L.map(Tw)}:null}),se=S&&(b||v.isPending&&G==="git"),ne=W||y?{defaultMainView:W,tabs:L.map(Nw)}:null,de=G==="git"&&!se&&!v.isPending?ll(ne):G==="content"&&!ee?ll(ne):G,xe=G==="git"&&!se&&!v.isPending?!1:te,he=f2(de),ce=[];(W?.type==="overview"||V)&&ce.push({id:"overview",title:s("common.mainPanelTabs.overview")});let oe;e[21]!==s?(oe=ke=>({id:ke.id,title:ke.id==="preview"?s("common.mainPanelTabs.preview"):ke.id==="code"?s("common.mainPanelTabs.code"):ke.title}),e[21]=s,e[22]=oe):oe=e[22],ce.push(...kw(C||V).map(oe));const me=[];C&&ee&&me.push({id:"content",title:s("common.mainPanelTabs.content")}),se&&me.push({id:"git",title:s("common.mainPanelTabs.reviewChanges")}),V||(me.push({id:"automations",title:s("common.mainPanelTabs.automations")}),N&&me.push({id:"settings",title:s("common.mainPanelTabs.settings")}));const pe=new Map;for(const ke of j){const ze=Ua(ke.appId,ke.toolName);pe.set(ze,{id:ze,title:ke.toolName,appId:ke.appId,iconKey:ke.toolName})}for(const ke of H){const ze=Ua(ke.connectionId,ke.toolName);pe.set(ze,{id:ze,title:ke.label||ke.toolName,appId:ke.connectionId,iconKey:ke.toolName,iconUrl:ke.icon??null})}if(V){const ke=ev.COMMERCE_DISCOVERY(c.id),ze=Ua(ke,Hu);pe.has(ze)||pe.set(ze,{id:ze,title:s("common.mainPanelTabs.report"),appId:ke,iconKey:Hu,iconUrl:tv})}const we=m2(de),Ne=we?we.key.split("/").pop()??we.key:null,Oe=Ne?[{id:de,title:Ne,kind:"file",icon:{kind:"component",Component:ke=>A.createElement(pr,{filename:Ne,...ke})}}]:[],ye=p2(de),je=ye?[{id:de,title:(ye.path.split("/").pop()??ye.path).replace(/\.html$/i,""),kind:"file",icon:{kind:"component",Component:ke=>A.createElement(ye.path.startsWith("pages/")?li:Nr,ke)}}]:[],Pe=g2(de),Ee=Pe?Pe.path.split("/").pop()??Pe.path:null,be=Ee?[{id:de,title:Ee,kind:"file",icon:{kind:"component",Component:ke=>A.createElement(pr,{filename:Ee,...ke})}}]:[];let Ve;e[23]!==T?(Ve=ke=>({id:ke.id,title:ke.title,kind:"agent",icon:La({tabId:ke.id,kind:"agent",appId:ke.view.appId,connections:T})}),e[23]=T,e[24]=Ve):Ve=e[24];const Re=[...ce.map(ke=>({id:ke.id,title:ke.title,kind:"system",icon:La({tabId:ke.id,kind:"system",connections:T})})),...Oe,...je,...be,...L.map(Ve),...Array.from(pe.values()).map(ke=>({id:ke.id,title:ke.title,kind:"expanded",icon:La({tabId:ke.iconKey,kind:"expanded",appId:ke.appId,iconUrl:ke.iconUrl,connections:T})})),...me.map(ke=>({id:ke.id,title:ke.title,kind:"system",icon:La({tabId:ke.id,kind:"system",connections:T})}))],Le=t.virtualMcpId;let ve;e[25]!==c.id?(ve=il(c.id),e[25]=c.id,e[26]=ve):ve=e[26];const Se=Le===ve;let Be;return e[27]!==de||e[28]!==xe||e[29]!==n||e[30]!==Se||e[31]!==c.id||e[32]!==c.slug||e[33]!==V?(Be=ke=>{if(Xp({reportsOnly:V,onReportAgent:Se,tabId:ke})){n({to:"/$org/$taskId",params:{org:c.slug,taskId:crypto.randomUUID()},search:{virtualmcpid:il(c.id),main:ke}});return}const ze=mb({clickedId:ke,activeTab:de,mainOpen:xe});n({to:".",search:nt=>({...nt,main:ze}),replace:!0})},e[27]=de,e[28]=xe,e[29]=n,e[30]=Se,e[31]=c.id,e[32]=c.slug,e[33]=V,e[34]=Be):Be=e[34],{activeTab:de,mainOpen:xe,setActiveTab:Be,systemTabs:[...ce,...me],layoutTabs:L,expandedTools:j,automationTabParsed:he,tabs:Re}}function Nw(t){return{id:t.id}}function Tw(t){return{id:t.id}}function Aw(t){return!!sc(t._meta)}function Qp(t){const{managerAgentId:e,managerName:s,kind:n,id:i,instructions:o}=t,a=` to improve the instructions of ${n} "${i}". Here are its current instructions.
|
|
8
|
+
<current_instructions>${o}</current_instructions>`;return{type:"doc",content:[{type:"paragraph",content:[{type:"text",text:"Use "},{type:"mention",attrs:{id:e,name:s,char:"@",metadata:{agentId:e,title:s}}},{type:"text",text:a}]}]}}function Ew(t){const e=B.c(9),s=Bs();let n;e[0]!==t?(n=at.user(t),e[0]=t,e[1]=n):n=e[1];let i;e[2]!==s||e[3]!==t?(i=async()=>{const{user:l}=await s.call("USER_GET",{id:t});return l},e[2]=s,e[3]=t,e[4]=i):i=e[4];const o=!!t;let a;return e[5]!==n||e[6]!==i||e[7]!==o?(a={queryKey:n,queryFn:i,staleTime:3e5,retry:1,enabled:o},e[5]=n,e[6]=i,e[7]=o,e[8]=a):a=e[8],Ft(a)}function Zp(t){const e=B.c(37),{id:s,size:n,showEmail:i,avatarOnly:o,className:a}=t,l=n===void 0?"xs":n,c=i===void 0?!1:i,d=o===void 0?!1:o,h=re(),{data:u,isLoading:f,isError:m}=Ew(s);if(f){let _;e[0]!==a?(_=ie("flex items-center gap-2",a),e[0]=a,e[1]=_):_=e[1];let y;e[2]!==l?(y=r.jsx(ir.Skeleton,{shape:"circle",size:l}),e[2]=l,e[3]=y):y=e[3];let L;e[4]!==d||e[5]!==c?(L=!d&&r.jsxs("div",{className:"flex flex-col gap-1",children:[r.jsx("div",{className:"h-3 w-24 bg-muted animate-pulse rounded"}),c&&r.jsx("div",{className:"h-2 w-32 bg-muted animate-pulse rounded"})]}),e[4]=d,e[5]=c,e[6]=L):L=e[6];let w;return e[7]!==_||e[8]!==y||e[9]!==L?(w=r.jsxs("div",{className:_,children:[y,L]}),e[7]=_,e[8]=y,e[9]=L,e[10]=w):w=e[10],w}if(m||!u){let _;e[11]!==a?(_=ie("flex items-center gap-2",a),e[11]=a,e[12]=_):_=e[12];let y;e[13]!==l?(y=r.jsx(ir,{shape:"circle",size:l,fallback:"?",muted:!0}),e[13]=l,e[14]=y):y=e[14];let L;e[15]!==d||e[16]!==h?(L=!d&&r.jsx("div",{className:"flex flex-col",children:r.jsx("div",{className:"text-sm text-muted-foreground",children:h("user.user.unknownUser")})}),e[15]=d,e[16]=h,e[17]=L):L=e[17];let w;return e[18]!==_||e[19]!==y||e[20]!==L?(w=r.jsxs("div",{className:_,children:[y,L]}),e[18]=_,e[19]=y,e[20]=L,e[21]=w):w=e[21],w}let p;e[22]!==a?(p=ie("flex items-center gap-2",a),e[22]=a,e[23]=p):p=e[23];const g=u.image??void 0;let x;e[24]!==l||e[25]!==g||e[26]!==u.name?(x=r.jsx(ir,{shape:"circle",size:l,url:g,fallback:u.name}),e[24]=l,e[25]=g,e[26]=u.name,e[27]=x):x=e[27];let v;e[28]!==d||e[29]!==c||e[30]!==u.email||e[31]!==u.name?(v=!d&&r.jsxs("div",{className:"flex flex-col",children:[r.jsx("div",{className:"text-sm font-medium",children:u.name}),c&&r.jsx("div",{className:"text-xs text-muted-foreground",children:u.email})]}),e[28]=d,e[29]=c,e[30]=u.email,e[31]=u.name,e[32]=v):v=e[32];let b;return e[33]!==p||e[34]!==x||e[35]!==v?(b=r.jsxs("div",{className:p,children:[x,v]}),e[33]=p,e[34]=x,e[35]=v,e[36]=b):b=e[36],b}function Pw(t){const e=B.c(8);let s,n;e[0]!==t?({className:s,...n}=t,e[0]=t,e[1]=s,e[2]=n):(s=e[1],n=e[2]);let i;e[3]!==s?(i=ie("grid gap-3",s),e[3]=s,e[4]=i):i=e[4];let o;return e[5]!==n||e[6]!==i?(o=r.jsx(Mb,{"data-slot":"radio-group",className:i,...n}),e[5]=n,e[6]=i,e[7]=o):o=e[7],o}function Rw(t){const e=B.c(9);let s,n;e[0]!==t?({className:s,...n}=t,e[0]=t,e[1]=s,e[2]=n):(s=e[1],n=e[2]);let i;e[3]!==s?(i=ie("border-input text-primary focus-visible:border-ring focus-visible:ring-ring/20 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive dark:bg-input/30 aspect-square size-4 shrink-0 rounded-full border shadow-xs transition-[color,box-shadow] outline-none focus-visible:ring-[2px] disabled:opacity-50",s),e[3]=s,e[4]=i):i=e[4];let o;e[5]===Symbol.for("react.memo_cache_sentinel")?(o=r.jsx(Ob,{"data-slot":"radio-group-indicator",className:"relative flex items-center justify-center",children:r.jsx($b,{className:"fill-primary absolute top-1/2 left-1/2 size-2 -translate-x-1/2 -translate-y-1/2"})}),e[5]=o):o=e[5];let a;return e[6]!==n||e[7]!==i?(a=r.jsx(Ib,{"data-slot":"radio-group-item",className:i,...n,children:o}),e[6]=n,e[7]=i,e[8]=a):a=e[8],a}function Dw(t){const e=B.c(82),{value:s,onChange:n,onColorChange:i,name:o,size:a,className:l,avatarClassName:c,showHoverOverlay:d,disabled:h}=t,u=a===void 0?"lg":a,f=d===void 0?!0:d,m=h===void 0?!1:h,p=re(),[g,x]=A.useState(!1),[v,b]=A.useState("icons"),[_,y]=A.useState(""),[L,w]=A.useState("blue");let j;e[0]!==s?(j=Jl(s),e[0]=s,e[1]=j):j=e[1];const S=j,C=S.type==="icon"||S.type==="url"&&S.color?S.color:L;let N;e[2]!==n||e[3]!==C?(N=pe=>{n($c(pe,C))},e[2]=n,e[3]=C,e[4]=N):N=e[4];const V=N;let E;e[5]!==n||e[6]!==i||e[7]!==S.name||e[8]!==S.type||e[9]!==S.url?(E=pe=>{w(pe),i?.(pe),S.type==="icon"?n($c(S.name,pe)):S.type==="url"&&n(Yu(S.url,pe))},e[5]=n,e[6]=i,e[7]=S.name,e[8]=S.type,e[9]=S.url,e[10]=E):E=e[10];const T=E;let k;e[11]!==n||e[12]!==C?(k=pe=>{n(Yu(pe,C)),x(!1)},e[11]=n,e[12]=C,e[13]=k):k=e[13];const R=k;let P;e[14]!==n||e[15]!==C?(P=()=>{const pe=t9(),we=pe[Math.floor(Math.random()*pe.length)];n($c(we,C))},e[14]=n,e[15]=C,e[16]=P):P=e[16];const D=P,I=m?!1:g,M=m?"cursor-default opacity-50":"cursor-pointer";let O;e[17]!==l||e[18]!==u||e[19]!==M?(O=ie("relative group overflow-hidden",M,Gv(u),l),e[17]=l,e[18]=u,e[19]=M,e[20]=O):O=e[20];let F;e[21]!==c||e[22]!==o||e[23]!==u||e[24]!==s?(F=r.jsx(Qn,{icon:s,name:o,size:u,className:c}),e[21]=c,e[22]=o,e[23]=u,e[24]=s,e[25]=F):F=e[25];let $;e[26]!==m||e[27]!==f?($=f&&!m&&r.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-black/50 opacity-0 group-hover:opacity-100 transition-opacity",children:r.jsx(Um,{size:16,className:"text-white"})}),e[26]=m,e[27]=f,e[28]=$):$=e[28];let z;e[29]!==m||e[30]!==O||e[31]!==F||e[32]!==$?(z=r.jsx(Es,{asChild:!0,children:r.jsxs("button",{type:"button","data-testid":"icon-picker-trigger","aria-label":"Change icon",disabled:m,className:O,children:[F,$]})}),e[29]=m,e[30]=O,e[31]=F,e[32]=$,e[33]=z):z=e[33];let K;e[34]!==o||e[35]!==s?(K=r.jsx("div",{className:"flex items-center justify-center py-4",children:r.jsx(Qn,{icon:s,name:o,size:"xl"})}),e[34]=o,e[35]=s,e[36]=K):K=e[36];let X;e[37]!==v?(X=pe=>{if(pe.key!=="ArrowLeft"&&pe.key!=="ArrowRight")return;pe.preventDefault();const we=v==="icons"?"upload":"icons";b(we),document.getElementById(`icon-picker-tab-${we}`)?.focus()},e[37]=v,e[38]=X):X=e[38];const J=v==="icons",H=v==="icons"?0:-1;let W;e[39]===Symbol.for("react.memo_cache_sentinel")?(W=()=>b("icons"),e[39]=W):W=e[39];const U=v==="icons"?"border-foreground text-foreground":"border-transparent text-muted-foreground hover:text-foreground";let Q;e[40]!==U?(Q=ie("px-3 py-2 text-sm font-medium border-b-2 -mb-px transition-colors",U),e[40]=U,e[41]=Q):Q=e[41];let q;e[42]!==p?(q=p("common.iconPicker.iconsTab"),e[42]=p,e[43]=q):q=e[43];let Z;e[44]!==J||e[45]!==H||e[46]!==Q||e[47]!==q?(Z=r.jsx("button",{id:"icon-picker-tab-icons",type:"button",role:"tab","aria-selected":J,"aria-controls":"icon-picker-panel-icons",tabIndex:H,onClick:W,className:Q,children:q}),e[44]=J,e[45]=H,e[46]=Q,e[47]=q,e[48]=Z):Z=e[48];const Y=v==="upload",ee=v==="upload"?0:-1;let G;e[49]===Symbol.for("react.memo_cache_sentinel")?(G=()=>b("upload"),e[49]=G):G=e[49];const te=v==="upload"?"border-foreground text-foreground":"border-transparent text-muted-foreground hover:text-foreground";let se;e[50]!==te?(se=ie("px-3 py-2 text-sm font-medium border-b-2 -mb-px transition-colors",te),e[50]=te,e[51]=se):se=e[51];let ne;e[52]!==p?(ne=p("common.iconPicker.uploadTab"),e[52]=p,e[53]=ne):ne=e[53];let de;e[54]!==Y||e[55]!==ee||e[56]!==se||e[57]!==ne?(de=r.jsx("button",{id:"icon-picker-tab-upload",type:"button",role:"tab","aria-selected":Y,"aria-controls":"icon-picker-panel-upload",tabIndex:ee,onClick:G,className:se,children:ne}),e[54]=Y,e[55]=ee,e[56]=se,e[57]=ne,e[58]=de):de=e[58];let xe;e[59]===Symbol.for("react.memo_cache_sentinel")?(xe=r.jsx("div",{className:"flex-1"}),e[59]=xe):xe=e[59];let he;e[60]!==X||e[61]!==Z||e[62]!==de?(he=r.jsxs("div",{role:"tablist","aria-label":"Icon source",className:"flex items-center border-b border-border px-3",onKeyDown:X,children:[Z,de,xe]}),e[60]=X,e[61]=Z,e[62]=de,e[63]=he):he=e[63];let ce;e[64]!==T||e[65]!==D||e[66]!==V||e[67]!==R||e[68]!==S.name||e[69]!==S.type||e[70]!==_||e[71]!==C||e[72]!==v?(ce=v==="icons"?r.jsx("div",{id:"icon-picker-panel-icons",role:"tabpanel","aria-labelledby":"icon-picker-tab-icons",children:r.jsx($w,{search:_,onSearchChange:y,selectedColor:C,onColorChange:T,onSelectIcon:V,onRandom:D,currentIconName:S.type==="icon"?S.name:null})}):r.jsx("div",{id:"icon-picker-panel-upload",role:"tabpanel","aria-labelledby":"icon-picker-tab-upload",children:r.jsx(Bw,{onUpload:R})}),e[64]=T,e[65]=D,e[66]=V,e[67]=R,e[68]=S.name,e[69]=S.type,e[70]=_,e[71]=C,e[72]=v,e[73]=ce):ce=e[73];let oe;e[74]!==K||e[75]!==he||e[76]!==ce?(oe=r.jsx(Ps,{align:"start",className:"w-80 p-0",onOpenAutoFocus:Iw,children:r.jsxs("div",{className:"flex flex-col",children:[K,he,ce]})}),e[74]=K,e[75]=he,e[76]=ce,e[77]=oe):oe=e[77];let me;return e[78]!==z||e[79]!==oe||e[80]!==I?(me=r.jsxs(As,{open:I,onOpenChange:x,children:[z,oe]}),e[78]=z,e[79]=oe,e[80]=I,e[81]=me):me=e[81],me}function Iw(t){return t.preventDefault()}function Mw(t){const e=B.c(33),{selectedColor:s,onColorChange:n}=t,i=re(),[o,a]=A.useState(!1);let l,c,d,h,u,f,m;if(e[0]!==o||e[1]!==s){const L=Wm(s);c=As,f=o,m=a,l=Es,u=!0,d="button",h=ie("h-6 w-6 rounded-full shrink-0 ring-2 ring-offset-2 ring-offset-background transition-all cursor-pointer hover:scale-110",L.dot,"ring-foreground/20"),e[0]=o,e[1]=s,e[2]=l,e[3]=c,e[4]=d,e[5]=h,e[6]=u,e[7]=f,e[8]=m}else l=e[2],c=e[3],d=e[4],h=e[5],u=e[6],f=e[7],m=e[8];let p;e[9]!==i?(p=i("common.iconPicker.changeColor"),e[9]=i,e[10]=p):p=e[10];let g;e[11]!==i?(g=i("common.iconPicker.changeColor"),e[11]=i,e[12]=g):g=e[12];let x;e[13]!==d||e[14]!==h||e[15]!==p||e[16]!==g?(x=r.jsx("button",{type:d,className:h,title:p,"aria-label":g}),e[13]=d,e[14]=h,e[15]=p,e[16]=g,e[17]=x):x=e[17];let v;e[18]!==l||e[19]!==u||e[20]!==x?(v=r.jsx(l,{asChild:u,children:x}),e[18]=l,e[19]=u,e[20]=x,e[21]=v):v=e[21];let b;e[22]!==n||e[23]!==s?(b=Jv.map(L=>r.jsx("button",{type:"button",onClick:()=>{n(L.name),a(!1)},className:ie("h-5 w-5 rounded-full transition-all shrink-0 cursor-pointer",L.dot,s===L.name?"ring-2 ring-offset-1 ring-offset-background ring-foreground/30 scale-110":"hover:scale-110"),title:L.name,"aria-label":L.name},L.name)),e[22]=n,e[23]=s,e[24]=b):b=e[24];let _;e[25]!==b?(_=r.jsx(Ps,{align:"start",side:"right",sideOffset:8,className:"w-auto p-2",onOpenAutoFocus:Ow,children:r.jsx("div",{className:"grid grid-cols-4 gap-1",children:b})}),e[25]=b,e[26]=_):_=e[26];let y;return e[27]!==c||e[28]!==_||e[29]!==f||e[30]!==m||e[31]!==v?(y=r.jsxs(c,{open:f,onOpenChange:m,children:[v,_]}),e[27]=c,e[28]=_,e[29]=f,e[30]=m,e[31]=v,e[32]=y):y=e[32],y}function Ow(t){return t.preventDefault()}function $w(t){const e=B.c(55),{search:s,onSearchChange:n,selectedColor:i,onColorChange:o,onSelectIcon:a,onRandom:l,currentIconName:c}=t,d=re();let h,u,f,m,p,g,x;if(e[0]!==c||e[1]!==o||e[2]!==l||e[3]!==n||e[4]!==a||e[5]!==s||e[6]!==i||e[7]!==d){const L=t9(),w=Wm(i);u=qm(L,s),g="flex flex-col";let j;e[15]===Symbol.for("react.memo_cache_sentinel")?(j=r.jsx(Oo,{size:14,className:"absolute left-2 top-1/2 -translate-y-1/2 text-muted-foreground pointer-events-none"}),e[15]=j):j=e[15];let S;e[16]!==n?(S=P=>n(P.target.value),e[16]=n,e[17]=S):S=e[17];let C;e[18]!==d?(C=d("common.iconPicker.filterPlaceholder"),e[18]=d,e[19]=C):C=e[19];let N;e[20]!==s||e[21]!==S||e[22]!==C?(N=r.jsxs("div",{className:"relative flex-1",children:[j,r.jsx(rt,{value:s,onChange:S,placeholder:C,className:"h-8 text-xs pl-7"})]}),e[20]=s,e[21]=S,e[22]=C,e[23]=N):N=e[23];let V;e[24]!==d?(V=d("common.iconPicker.randomIcon"),e[24]=d,e[25]=V):V=e[25];let E;e[26]!==d?(E=d("common.iconPicker.randomIcon"),e[26]=d,e[27]=E):E=e[27];let T;e[28]===Symbol.for("react.memo_cache_sentinel")?(T=r.jsx(Yv,{size:14,className:"text-muted-foreground"}),e[28]=T):T=e[28];let k;e[29]!==l||e[30]!==V||e[31]!==E?(k=r.jsx("button",{type:"button",onClick:l,className:"h-8 w-8 flex items-center justify-center rounded-md border border-border hover:bg-accent transition-colors shrink-0",title:V,"aria-label":E,children:T}),e[29]=l,e[30]=V,e[31]=E,e[32]=k):k=e[32];let R;e[33]!==o||e[34]!==i?(R=r.jsx(Mw,{selectedColor:i,onColorChange:o}),e[33]=o,e[34]=i,e[35]=R):R=e[35],e[36]!==k||e[37]!==R||e[38]!==N?(x=r.jsxs("div",{className:"flex items-center gap-2 px-3 py-2",children:[N,k,R]}),e[36]=k,e[37]=R,e[38]=N,e[39]=x):x=e[39],h=ri,p="h-56",f="grid grid-cols-9 gap-0.5 px-2 pb-2",m=u.map(P=>{const D=Oi(P);return D?r.jsx("button",{type:"button",onClick:()=>a(P),className:ie("h-8 w-8 flex items-center justify-center rounded-md transition-colors cursor-pointer",c===P?ie(w.bg,w.text):ie(w.text,"hover:bg-accent")),title:P,"aria-label":Ed(P),children:r.jsx(D,{size:18})},P):null}),e[0]=c,e[1]=o,e[2]=l,e[3]=n,e[4]=a,e[5]=s,e[6]=i,e[7]=d,e[8]=h,e[9]=u,e[10]=f,e[11]=m,e[12]=p,e[13]=g,e[14]=x}else h=e[8],u=e[9],f=e[10],m=e[11],p=e[12],g=e[13],x=e[14];let v;e[40]!==f||e[41]!==m?(v=r.jsx("div",{className:f,children:m}),e[40]=f,e[41]=m,e[42]=v):v=e[42];let b;e[43]!==u.length||e[44]!==d?(b=u.length===0&&r.jsx("div",{className:"flex items-center justify-center py-8 text-sm text-muted-foreground",children:d("common.iconPicker.noIconsFound")}),e[43]=u.length,e[44]=d,e[45]=b):b=e[45];let _;e[46]!==h||e[47]!==p||e[48]!==v||e[49]!==b?(_=r.jsxs(h,{className:p,children:[v,b]}),e[46]=h,e[47]=p,e[48]=v,e[49]=b,e[50]=_):_=e[50];let y;return e[51]!==g||e[52]!==x||e[53]!==_?(y=r.jsxs("div",{className:g,children:[x,_]}),e[51]=g,e[52]=x,e[53]=_,e[54]=y):y=e[54],y}function Bw(t){const e=B.c(46),{onUpload:s}=t,n=re(),i=A.useRef(null);let o;e[0]!==s||e[1]!==n?(o=k=>{const R=k.target.files?.[0];if(!R)return;if(R.size>2097152){ge.error(n("common.iconPicker.imageTooLarge")),k.target.value="";return}const P=new FileReader;P.onerror=()=>{ge.error(n("common.iconPicker.failedToReadImage")),i.current&&(i.current.value="")},P.onloadend=()=>{P.readyState===FileReader.DONE&&P.result&&s(P.result),i.current&&(i.current.value="")},P.readAsDataURL(R)},e[0]=s,e[1]=n,e[2]=o):o=e[2];const a=o,[l,c]=A.useState("");let d;e[3]!==s||e[4]!==l?(d=()=>{const k=l.trim();k&&(s(k),c(""))},e[3]=s,e[4]=l,e[5]=d):d=e[5];const h=d;let u;e[6]!==a?(u=r.jsx("input",{type:"file",ref:i,className:"hidden",accept:"image/*",onChange:a}),e[6]=a,e[7]=u):u=e[7];let f;e[8]===Symbol.for("react.memo_cache_sentinel")?(f=()=>i.current?.click(),e[8]=f):f=e[8];let m;e[9]===Symbol.for("react.memo_cache_sentinel")?(m=r.jsx($i,{size:20}),e[9]=m):m=e[9];let p;e[10]!==n?(p=n("common.iconPicker.uploadHint"),e[10]=n,e[11]=p):p=e[11];let g;e[12]!==p?(g=r.jsxs("button",{type:"button",onClick:f,className:"h-24 rounded-lg border-2 border-dashed border-border hover:border-foreground/50 hover:bg-accent/50 transition-colors flex flex-col items-center justify-center gap-2 text-muted-foreground hover:text-foreground",children:[m,r.jsx("span",{className:"text-xs",children:p})]}),e[12]=p,e[13]=g):g=e[13];let x;e[14]!==n?(x=n("common.iconPicker.or"),e[14]=n,e[15]=x):x=e[15];let v;e[16]!==x?(v=r.jsx("span",{className:"text-xs text-muted-foreground",children:x}),e[16]=x,e[17]=v):v=e[17];let b;e[18]===Symbol.for("react.memo_cache_sentinel")?(b=r.jsx("div",{className:"flex-1 h-px bg-border"}),e[18]=b):b=e[18];let _;e[19]!==v?(_=r.jsxs("div",{className:"flex items-center gap-2",children:[v,b]}),e[19]=v,e[20]=_):_=e[20];let y;e[21]===Symbol.for("react.memo_cache_sentinel")?(y=k=>c(k.target.value),e[21]=y):y=e[21];let L;e[22]!==n?(L=n("common.iconPicker.pasteUrlPlaceholder"),e[22]=n,e[23]=L):L=e[23];let w;e[24]!==h?(w=k=>{k.key==="Enter"&&(k.preventDefault(),h())},e[24]=h,e[25]=w):w=e[25];let j;e[26]!==l||e[27]!==L||e[28]!==w?(j=r.jsx(rt,{value:l,onChange:y,placeholder:L,className:"h-8 text-xs flex-1",onKeyDown:w}),e[26]=l,e[27]=L,e[28]=w,e[29]=j):j=e[29];let S;e[30]!==l?(S=l.trim(),e[30]=l,e[31]=S):S=e[31];const C=!S;let N;e[32]!==n?(N=n("common.iconPicker.apply"),e[32]=n,e[33]=N):N=e[33];let V;e[34]!==h||e[35]!==C||e[36]!==N?(V=r.jsx(le,{variant:"outline",size:"sm",className:"h-8 px-3 text-xs shrink-0",onClick:h,disabled:C,children:N}),e[34]=h,e[35]=C,e[36]=N,e[37]=V):V=e[37];let E;e[38]!==j||e[39]!==V?(E=r.jsxs("div",{className:"flex items-center gap-1.5",children:[j,V]}),e[38]=j,e[39]=V,e[40]=E):E=e[40];let T;return e[41]!==_||e[42]!==E||e[43]!==u||e[44]!==g?(T=r.jsxs("div",{className:"flex flex-col gap-3 p-4",children:[u,g,_,E]}),e[41]=_,e[42]=E,e[43]=u,e[44]=g,e[45]=T):T=e[45],T}const Fw=25*1024*1024,Gc="home",Yc="knowledge";function Oh(t){return t==null?"":t<1024?`${t} B`:t<1024*1024?`${(t/1024).toFixed(0)} KB`:`${(t/(1024*1024)).toFixed(1)} MB`}function hi(t){return t.split("/").pop()??t}function zw(t){const e=B.c(64),{form:s}=t,n=re(),{upload:i}=K6(Gc),o=U6(),a=A.useRef(null),[l,c]=A.useState(!1),[d,h]=A.useState(""),[u,f]=A.useState(!1);let m;e[0]!==l?(m={enabled:l},e[0]=l,e[1]=m):m=e[1];const{data:p}=H6(60,m),g=p===void 0?[]:p;let x;e[2]!==l?(x={enabled:l},e[2]=l,e[3]=x):x=e[3];const{data:v}=W6(x),b=v===void 0?[]:v;let _;e[4]!==s?(_=()=>s.getValues("metadata.knowledge")??[],e[4]=s,e[5]=_):_=e[5];const[y,L]=A.useState(_);let w;e[6]!==s?(w=oe=>{L(oe),s.setValue("metadata.knowledge",oe,{shouldDirty:!0})},e[6]=s,e[7]=w):w=e[7];const j=w;let S;e[8]!==o||e[9]!==y||e[10]!==j||e[11]!==n||e[12]!==i?(S=async oe=>{if(!oe||oe.length===0)return;const me=Array.from(oe).filter(qw);if(me.length!==0){try{await i.mutateAsync({dir:Yc,files:me})}catch(pe){const we=pe;ge.error(we instanceof Error?we.message:n("virtualMcp.filesSection.failedUploadFile"));return}j([...y,...me.map(pe=>({id:crypto.randomUUID(),name:pe.name,volume:Gc,path:`${Yc}/${pe.name}`,url:o(Gc,`${Yc}/${pe.name}`),contentType:pe.type||null,size:pe.size,addedAt:new Date().toISOString()}))])}},e[8]=o,e[9]=y,e[10]=j,e[11]=n,e[12]=i,e[13]=S):S=e[13];const C=S;let N;e[14]!==o||e[15]!==y||e[16]!==j?(N=oe=>{y.some(me=>me.volume===oe.volume&&me.path===oe.path)||(j([...y,{id:crypto.randomUUID(),name:hi(oe.path),volume:oe.volume,path:oe.path,url:o(oe.volume,oe.path),contentType:null,size:oe.size??null,addedAt:new Date().toISOString()}]),c(!1))},e[14]=o,e[15]=y,e[16]=j,e[17]=N):N=e[17];const V=N;let E;e[18]!==o||e[19]!==y||e[20]!==j?(E=oe=>{y.some(me=>me.volume===oe.volume&&me.path===oe.path)||(j([...y,{id:crypto.randomUUID(),name:hi(oe.path),kind:"skill",volume:oe.volume,path:oe.path,url:o(oe.volume,oe.path),contentType:null,size:null,addedAt:new Date().toISOString()}]),c(!1))},e[18]=o,e[19]=y,e[20]=j,e[21]=E):E=e[21];const T=E;let k;e[22]!==y||e[23]!==j?(k=oe=>{j(y.filter(me=>me.id!==oe))},e[22]=y,e[23]=j,e[24]=k):k=e[24];const R=k;let P;e[25]===Symbol.for("react.memo_cache_sentinel")?(P=oe=>{c(oe),oe&&h("")},e[25]=P):P=e[25];const D=P;let I;e[26]!==y?(I=new Set(y.map(Ww)),e[26]=y,e[27]=I):I=e[27];const M=I,O=d.toLowerCase();let F;e[28]!==M?(F=oe=>!M.has(`${oe.volume}/${oe.path}`),e[28]=M,e[29]=F):F=e[29];const $=g.filter(Hw).filter(F).filter(oe=>hi(oe.path).toLowerCase().includes(O)).slice(0,5);let z;e[30]!==M?(z=oe=>!M.has(`${oe.volume}/${oe.path}`),e[30]=M,e[31]=z):z=e[31];const K=b.filter(z).filter(oe=>hi(oe.path).toLowerCase().includes(O)).slice(0,5),X=oe=>r.jsxs(us,{open:l,onOpenChange:D,children:[r.jsx(ds,{asChild:!0,children:oe}),r.jsxs(hs,{align:"end",className:"w-56",children:[r.jsxs(Xe,{onSelect:()=>{a.current?.click()},children:[r.jsx(Xv,{size:16}),n("virtualMcp.filesSection.uploadFile")]}),r.jsxs(Po,{children:[r.jsxs(Ro,{className:"gap-2 [&_svg:not([class*='text-'])]:text-muted-foreground",children:[r.jsx(ei,{size:16}),n("virtualMcp.filesSection.selectFileOrFolder")]}),r.jsxs(Do,{className:"w-72 p-0",children:[r.jsxs("div",{className:"flex items-center gap-2 border-b px-3",children:[r.jsx(Oo,{size:16,className:"shrink-0 text-muted-foreground"}),r.jsx("input",{value:d,onChange:me=>h(me.target.value),onKeyDown:Uw,placeholder:n("virtualMcp.filesSection.searchFilesPlaceholder"),className:"h-10 w-full bg-transparent text-sm outline-none placeholder:text-muted-foreground"})]}),r.jsx("div",{className:"max-h-64 overflow-y-auto p-1",children:$.length===0?r.jsx("p",{className:"px-2 py-3 text-center text-sm text-muted-foreground",children:n("virtualMcp.filesSection.noFilesFound")}):$.map(me=>r.jsxs(Xe,{onSelect:()=>V(me),children:[r.jsx(pr,{filename:hi(me.path),className:"h-5 w-4 shrink-0"}),r.jsx("span",{className:"flex-1 truncate",children:hi(me.path)}),me.size!=null&&r.jsx("span",{className:"text-xs text-muted-foreground",children:Oh(me.size)})]},`${me.volume}/${me.path}`))})]})]}),r.jsxs(Po,{children:[r.jsxs(Ro,{className:"gap-2 [&_svg:not([class*='text-'])]:text-muted-foreground",children:[r.jsx(Gn,{size:16}),n("virtualMcp.filesSection.selectSkill")]}),r.jsxs(Do,{className:"w-72 p-0",children:[r.jsxs("div",{className:"flex items-center gap-2 border-b px-3",children:[r.jsx(Oo,{size:16,className:"shrink-0 text-muted-foreground"}),r.jsx("input",{value:d,onChange:me=>h(me.target.value),onKeyDown:Kw,placeholder:n("virtualMcp.filesSection.searchSkillsPlaceholder"),className:"h-10 w-full bg-transparent text-sm outline-none placeholder:text-muted-foreground"})]}),r.jsx("div",{className:"max-h-64 overflow-y-auto p-1",children:K.length===0?r.jsx("p",{className:"px-2 py-3 text-center text-sm text-muted-foreground",children:n("virtualMcp.filesSection.noSkillsFound")}):K.map(me=>r.jsxs(Xe,{onSelect:()=>T(me),children:[r.jsx(Gn,{size:16,className:"shrink-0"}),r.jsx("span",{className:"flex-1 truncate",children:hi(me.path)})]},`${me.volume}/${me.path}`))})]})]})]})]}),J="flex flex-col gap-3";let H;e[32]!==n?(H=n("virtualMcp.filesSection.filesAndSkills"),e[32]=n,e[33]=H):H=e[33];let W;e[34]!==H?(W=r.jsx("h2",{className:"text-sm font-medium text-foreground",children:H}),e[34]=H,e[35]=W):W=e[35];let U;e[36]!==n?(U=n("virtualMcp.filesSection.description"),e[36]=n,e[37]=U):U=e[37];let Q;e[38]!==U?(Q=r.jsx("p",{className:"text-sm text-muted-foreground",children:U}),e[38]=U,e[39]=Q):Q=e[39];let q;e[40]!==W||e[41]!==Q?(q=r.jsxs("div",{className:"flex flex-col gap-1",children:[W,Q]}),e[40]=W,e[41]=Q,e[42]=q):q=e[42];const Z=y.length>0&&X(r.jsxs(le,{variant:"outline",size:"sm",disabled:i.isPending,children:[i.isPending?r.jsx(wi,{size:"xs"}):r.jsx(kt,{size:14}),n("virtualMcp.filesSection.add")]}));let Y;e[43]!==q||e[44]!==Z?(Y=r.jsxs("div",{className:"flex items-center justify-between gap-3",children:[q,Z]}),e[43]=q,e[44]=Z,e[45]=Y):Y=e[45];let ee;e[46]!==C?(ee=r.jsx("input",{ref:a,type:"file",multiple:!0,className:"hidden",onChange:oe=>{C(oe.target.files),oe.target.value=""}}),e[46]=C,e[47]=ee):ee=e[47];let G,te;e[48]===Symbol.for("react.memo_cache_sentinel")?(G=oe=>{oe.preventDefault(),f(!0)},te=()=>f(!1),e[48]=G,e[49]=te):(G=e[48],te=e[49]);let se;e[50]!==C?(se=oe=>{oe.preventDefault(),f(!1),C(oe.dataTransfer.files)},e[50]=C,e[51]=se):se=e[51];const ne=u&&"outline outline-2 outline-dashed outline-primary";let de;e[52]!==ne?(de=ie("flex flex-col gap-2 rounded-lg",ne),e[52]=ne,e[53]=de):de=e[53];const xe=y.length===0?X(r.jsxs("button",{type:"button",className:"flex items-center gap-3 px-3 py-2.5 rounded-lg border border-dashed border-border hover:bg-accent/50 transition-colors w-full text-left cursor-pointer",children:[r.jsx("div",{className:"flex items-center justify-center size-8 rounded-md text-muted-foreground/75 border border-dashed border-border shrink-0",children:r.jsx(kt,{size:16})}),r.jsx("span",{className:"text-sm text-muted-foreground flex-1",children:n("virtualMcp.filesSection.noFilesOrSkillsYet")})]})):y.map(oe=>r.jsxs("div",{className:"flex items-center gap-3 px-4 py-3 rounded-xl border bg-card",children:[oe.kind==="skill"?r.jsx("div",{className:"flex items-center justify-center h-8 w-6.5 shrink-0 rounded-md bg-muted text-muted-foreground",children:r.jsx(Gn,{size:16})}):r.jsx(pr,{filename:oe.name,className:"h-8 w-6.5 shrink-0"}),r.jsxs("div",{className:"flex-1 min-w-0",children:[r.jsx("p",{className:"text-sm font-medium truncate",children:oe.name}),r.jsx("p",{className:"text-xs text-muted-foreground",children:oe.kind==="skill"?n("virtualMcp.filesSection.kindSkill"):oe.size!=null?Oh(oe.size):n("virtualMcp.filesSection.kindFile")})]}),r.jsx(le,{variant:"ghost",size:"icon",onClick:()=>R(oe.id),"aria-label":n("virtualMcp.filesSection.removeAriaLabel",{name:oe.name}),children:r.jsx(Ns,{size:16})})]},oe.id));let he;e[54]!==G||e[55]!==te||e[56]!==se||e[57]!==de||e[58]!==xe?(he=r.jsx("div",{onDragOver:G,onDragLeave:te,onDrop:se,className:de,children:xe}),e[54]=G,e[55]=te,e[56]=se,e[57]=de,e[58]=xe,e[59]=he):he=e[59];let ce;return e[60]!==Y||e[61]!==ee||e[62]!==he?(ce=r.jsxs("section",{className:J,children:[Y,ee,he]}),e[60]=Y,e[61]=ee,e[62]=he,e[63]=ce):ce=e[63],ce}function Kw(t){return t.stopPropagation()}function Uw(t){return t.stopPropagation()}function Hw(t){return t.kind!=="dir"}function Ww(t){return`${t.volume}/${t.path}`}function qw(t){return t.size<=Fw}function Gw(t){return t==null?"all":t.length===0?"self":"selected"}function Yw(t){const e=B.c(88),{form:s,currentAgentId:n}=t,i=re(),{org:o}=Fe(),a=ta(),[l,c]=A.useState(!1);let d;e[0]!==s?(d=s.getValues("metadata.subAgents")??null,e[0]=s,e[1]=d):d=e[1];const h=d;let u;e[2]!==h?(u=()=>Gw(h),e[2]=h,e[3]=u):u=e[3];const[f,m]=A.useState(u);let p;e[4]!==h?(p=h??[],e[4]=h,e[5]=p):p=e[5];const[g,x]=A.useState(p);let v,b,_,y,L,w;if(e[6]!==a||e[7]!==n||e[8]!==s||e[9]!==f||e[10]!==o||e[11]!==g||e[12]!==i){let N;e[19]!==n||e[20]!==o?(N=G=>G.id!==n&&G.id!==o.id&&G.status==="active",e[19]=n,e[20]=o,e[21]=N):N=e[21],v=a.filter(N);let V;e[22]!==g?(V=G=>g.includes(G.id),e[22]=g,e[23]=V):V=e[23];const E=v.filter(V);let T;e[24]!==s?(T=(G,te)=>s.setValue("metadata.subAgents",G==="all"?null:G==="self"?[]:te,{shouldDirty:!0}),e[24]=s,e[25]=T):T=e[25];const k=T;let R;e[26]!==k||e[27]!==g?(R=G=>{m(G),k(G,g)},e[26]=k,e[27]=g,e[28]=R):R=e[28];const P=R;let D;e[29]!==k||e[30]!==g?(D=G=>{const te=g.includes(G)?g.filter(se=>se!==G):[...g,G];x(te),k("selected",te)},e[29]=k,e[30]=g,e[31]=D):D=e[31],b=D,L="flex flex-col gap-3";let I;e[32]!==i?(I=i("virtualMcp.subAgentsSection.title"),e[32]=i,e[33]=I):I=e[33];let M;e[34]!==I?(M=r.jsx("h2",{className:"text-sm font-medium text-foreground",children:I}),e[34]=I,e[35]=M):M=e[35];let O;e[36]!==f||e[37]!==i?(O=f==="all"&&r.jsx("p",{className:"text-sm text-muted-foreground",children:i("virtualMcp.subAgentsSection.canDelegateToAnyAgent")}),e[36]=f,e[37]=i,e[38]=O):O=e[38];let F;e[39]!==f||e[40]!==i?(F=f==="self"&&r.jsx("p",{className:"text-sm text-muted-foreground",children:i("virtualMcp.subAgentsSection.canOnlyDelegateToItself")}),e[39]=f,e[40]=i,e[41]=F):F=e[41];let $;e[42]!==M||e[43]!==O||e[44]!==F?($=r.jsxs("div",{className:"flex flex-col gap-1",children:[M,O,F]}),e[42]=M,e[43]=O,e[44]=F,e[45]=$):$=e[45];const z=f==="selected"&&E.length>0&&r.jsxs(le,{variant:"outline",size:"sm",onClick:()=>c(!0),children:[r.jsx(kt,{size:14}),i("virtualMcp.subAgentsSection.addSubAgent")]});let K;e[46]!==P?(K=G=>P(G),e[46]=P,e[47]=K):K=e[47];let X;e[48]===Symbol.for("react.memo_cache_sentinel")?(X=r.jsx(Jt,{size:"sm",className:"w-auto",children:r.jsx(as,{})}),e[48]=X):X=e[48];let J;e[49]!==i?(J=i("virtualMcp.subAgentsSection.anyAgent"),e[49]=i,e[50]=J):J=e[50];let H;e[51]!==J?(H=r.jsx(vt,{value:"all",children:J}),e[51]=J,e[52]=H):H=e[52];let W;e[53]!==i?(W=i("virtualMcp.subAgentsSection.specificAgents"),e[53]=i,e[54]=W):W=e[54];let U;e[55]!==W?(U=r.jsx(vt,{value:"selected",children:W}),e[55]=W,e[56]=U):U=e[56];let Q;e[57]!==i?(Q=i("virtualMcp.subAgentsSection.onlyItself"),e[57]=i,e[58]=Q):Q=e[58];let q;e[59]!==Q?(q=r.jsx(vt,{value:"self",children:Q}),e[59]=Q,e[60]=q):q=e[60];let Z;e[61]!==H||e[62]!==U||e[63]!==q?(Z=r.jsxs(Xt,{align:"end",children:[H,U,q]}),e[61]=H,e[62]=U,e[63]=q,e[64]=Z):Z=e[64];let Y;e[65]!==f||e[66]!==K||e[67]!==Z?(Y=r.jsxs(Qt,{value:f,onValueChange:K,children:[X,Z]}),e[65]=f,e[66]=K,e[67]=Z,e[68]=Y):Y=e[68];let ee;e[69]!==z||e[70]!==Y?(ee=r.jsxs("div",{className:"flex items-center gap-2",children:[z,Y]}),e[69]=z,e[70]=Y,e[71]=ee):ee=e[71],e[72]!==$||e[73]!==ee?(w=r.jsxs("div",{className:"flex items-center justify-between gap-3",children:[$,ee]}),e[72]=$,e[73]=ee,e[74]=w):w=e[74],_="flex flex-col gap-2",y=f==="selected"&&(E.length>0?E.map(G=>r.jsxs("div",{className:"flex items-center gap-3 px-4 py-3 rounded-xl border bg-background",children:[r.jsx(an,{icon:G.icon,name:G.title,size:"sm",className:"shrink-0"}),r.jsxs("div",{className:"flex-1 min-w-0",children:[r.jsx("p",{className:"text-sm font-medium truncate",children:G.title}),G.description&&r.jsx("p",{className:"text-xs text-muted-foreground truncate",children:G.description})]}),r.jsx(le,{variant:"ghost",size:"icon",onClick:()=>b(G.id),children:r.jsx(Pn,{size:16})})]},G.id)):r.jsxs("button",{type:"button",onClick:()=>c(!0),className:"flex items-center gap-3 px-3 py-2.5 rounded-lg border border-dashed border-border hover:bg-accent/50 transition-colors w-full text-left cursor-pointer",children:[r.jsx("div",{className:"flex items-center justify-center size-8 rounded-md text-muted-foreground/75 border border-dashed border-border shrink-0",children:r.jsx(kt,{size:16})}),r.jsx("span",{className:"text-sm text-muted-foreground",children:i("virtualMcp.subAgentsSection.emptyStateMessage")})]})),e[6]=a,e[7]=n,e[8]=s,e[9]=f,e[10]=o,e[11]=g,e[12]=i,e[13]=v,e[14]=b,e[15]=_,e[16]=y,e[17]=L,e[18]=w}else v=e[13],b=e[14],_=e[15],y=e[16],L=e[17],w=e[18];let j;e[75]!==_||e[76]!==y?(j=r.jsx("div",{className:_,children:y}),e[75]=_,e[76]=y,e[77]=j):j=e[77];let S;e[78]!==v||e[79]!==b||e[80]!==l||e[81]!==g?(S=r.jsx(Jw,{open:l,onOpenChange:c,candidates:v,selectedIds:g,onToggle:b}),e[78]=v,e[79]=b,e[80]=l,e[81]=g,e[82]=S):S=e[82];let C;return e[83]!==L||e[84]!==w||e[85]!==j||e[86]!==S?(C=r.jsxs("section",{className:L,children:[w,j,S]}),e[83]=L,e[84]=w,e[85]=j,e[86]=S,e[87]=C):C=e[87],C}function Jw(t){const e=B.c(39),{open:s,onOpenChange:n,candidates:i,selectedIds:o,onToggle:a}=t,l=re(),[c,d]=A.useState("");let h,u,f,m,p,g,x,v,b;if(e[0]!==i||e[1]!==n||e[2]!==a||e[3]!==s||e[4]!==c||e[5]!==o||e[6]!==l){const w=c.toLowerCase(),j=i.filter(N=>N.title.toLowerCase().includes(w)||N.description?.toLowerCase().includes(w));u=ts,v=s,b=n,h=es,p="max-w-md";let S;e[16]!==l?(S=l("virtualMcp.subAgentsSection.title"),e[16]=l,e[17]=S):S=e[17],e[18]!==S?(g=r.jsx(ms,{children:r.jsx(ps,{children:S})}),e[18]=S,e[19]=g):g=e[19];let C;e[20]!==l?(C=l("virtualMcp.subAgentsSection.searchPlaceholder"),e[20]=l,e[21]=C):C=e[21],e[22]!==c||e[23]!==C?(x=r.jsx(v9,{value:c,onChange:d,placeholder:C,className:"w-full"}),e[22]=c,e[23]=C,e[24]=x):x=e[24],f="flex flex-col gap-1 max-h-80 overflow-y-auto",m=j.length===0?r.jsx("p",{className:"text-sm text-muted-foreground px-1 py-4 text-center",children:l("virtualMcp.subAgentsSection.noAgentsFound")}):j.map(N=>r.jsxs("button",{type:"button",onClick:()=>a(N.id),className:"flex items-center gap-3 px-2 py-2 rounded-lg hover:bg-accent/50 transition-colors cursor-pointer w-full text-left",children:[r.jsx(Ar,{checked:o.includes(N.id),className:"pointer-events-none",tabIndex:-1}),r.jsx(an,{icon:N.icon,name:N.title,size:"sm",className:"shrink-0"}),r.jsxs("div",{className:"flex-1 min-w-0",children:[r.jsx("p",{className:"text-sm font-medium truncate",children:N.title}),N.description&&r.jsx("p",{className:"text-xs text-muted-foreground truncate",children:N.description})]})]},N.id)),e[0]=i,e[1]=n,e[2]=a,e[3]=s,e[4]=c,e[5]=o,e[6]=l,e[7]=h,e[8]=u,e[9]=f,e[10]=m,e[11]=p,e[12]=g,e[13]=x,e[14]=v,e[15]=b}else h=e[7],u=e[8],f=e[9],m=e[10],p=e[11],g=e[12],x=e[13],v=e[14],b=e[15];let _;e[25]!==f||e[26]!==m?(_=r.jsx("div",{className:f,children:m}),e[25]=f,e[26]=m,e[27]=_):_=e[27];let y;e[28]!==h||e[29]!==p||e[30]!==g||e[31]!==x||e[32]!==_?(y=r.jsxs(h,{className:p,children:[g,x,_]}),e[28]=h,e[29]=p,e[30]=g,e[31]=x,e[32]=_,e[33]=y):y=e[33];let L;return e[34]!==u||e[35]!==v||e[36]!==b||e[37]!==y?(L=r.jsx(u,{open:v,onOpenChange:b,children:y}),e[34]=u,e[35]=v,e[36]=b,e[37]=y,e[38]=L):L=e[38],L}function uo(){const t=B.c(1);let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=r.jsx("div",{className:"flex items-center justify-center h-32",children:r.jsx(et,{className:"animate-spin text-muted-foreground",size:24})}),t[0]=e):e=t[0],e}function Sa(t,e){return({error:s})=>s?.message?.includes("Method not found")||s?.code===-32601?r.jsx("div",{className:"flex-1 overflow-auto px-4 py-3 space-y-1",children:r.jsx("div",{className:"flex items-center justify-center h-32 text-sm text-muted-foreground",children:t})}):r.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center h-full p-6 text-center space-y-4",children:[r.jsx("div",{className:"bg-destructive/10 p-3 rounded-full",children:r.jsx(Sr,{className:"h-6 w-6 text-destructive"})}),r.jsxs("div",{className:"space-y-2",children:[r.jsx("h3",{className:"text-lg font-medium",children:e("virtualMcp.dependencySelectionDialog.somethingWentWrong")}),r.jsx("p",{className:"text-sm text-muted-foreground max-w-xs mx-auto",children:s?.message?s.message.length>200?`${s.message.slice(0,200)}...`:s.message:e("virtualMcp.dependencySelectionDialog.unexpectedError")})]})]})}function e3(t){const e=B.c(23),{item:s,isSelected:n,onToggle:i,disabled:o}=t,a=o?"cursor-not-allowed opacity-50":"cursor-pointer",l=n?"bg-accent/25":"hover:bg-muted/50";let c;e[0]!==a||e[1]!==l?(c=ie("flex items-start gap-3 p-4 rounded-lg transition-colors",a,l),e[0]=a,e[1]=l,e[2]=c):c=e[2];let d;e[3]!==s.name?(d=r.jsx("p",{className:"text-sm font-medium leading-none truncate",children:s.name}),e[3]=s.name,e[4]=d):d=e[4];let h;e[5]!==s.tags?(h=s.tags&&r.jsx("span",{className:"shrink-0",children:s.tags}),e[5]=s.tags,e[6]=h):h=e[6];let u;e[7]!==d||e[8]!==h?(u=r.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[d,h]}),e[7]=d,e[8]=h,e[9]=u):u=e[9];let f;e[10]!==s.description?(f=s.description&&r.jsx("p",{className:"text-xs text-muted-foreground line-clamp-2",children:s.description}),e[10]=s.description,e[11]=f):f=e[11];let m;e[12]!==u||e[13]!==f?(m=r.jsxs("div",{className:"flex-1 min-w-0 space-y-2",children:[u,f]}),e[12]=u,e[13]=f,e[14]=m):m=e[14];let p;e[15]!==o||e[16]!==n||e[17]!==i?(p=r.jsx(Ar,{checked:n,onCheckedChange:i,disabled:o,className:"mt-0.5"}),e[15]=o,e[16]=n,e[17]=i,e[18]=p):p=e[18];let g;return e[19]!==c||e[20]!==m||e[21]!==p?(g=r.jsxs("label",{className:c,children:[m,p]}),e[19]=c,e[20]=m,e[21]=p,e[22]=g):g=e[22],g}function Xw(t){const e=B.c(35),{activeTab:s,onTabChange:n,showSelectAll:i,isAllSelected:o,handleSelectAll:a}=t,l=re();let c;e[0]!==l?(c=l("virtualMcp.dependencySelectionDialog.tabTools"),e[0]=l,e[1]=c):c=e[1];let d;e[2]!==c?(d={id:"tools",label:c},e[2]=c,e[3]=d):d=e[3];let h;e[4]!==l?(h=l("virtualMcp.dependencySelectionDialog.tabActive"),e[4]=l,e[5]=h):h=e[5];let u;e[6]!==h?(u={id:"active",label:h},e[6]=h,e[7]=u):u=e[7];let f;e[8]!==l?(f=l("virtualMcp.dependencySelectionDialog.tabResources"),e[8]=l,e[9]=f):f=e[9];let m;e[10]!==f?(m={id:"resources",label:f},e[10]=f,e[11]=m):m=e[11];let p;e[12]!==l?(p=l("virtualMcp.dependencySelectionDialog.tabPrompts"),e[12]=l,e[13]=p):p=e[13];let g;e[14]!==p?(g={id:"prompts",label:p},e[14]=p,e[15]=g):g=e[15];let x;e[16]!==d||e[17]!==u||e[18]!==m||e[19]!==g?(x=[d,u,m,g],e[16]=d,e[17]=u,e[18]=m,e[19]=g,e[20]=x):x=e[20];let v;e[21]!==n?(v=L=>n(L),e[21]=n,e[22]=v):v=e[22];let b;e[23]!==s||e[24]!==v||e[25]!==x?(b=r.jsx(j2,{tabs:x,activeTab:s,onTabChange:v}),e[23]=s,e[24]=v,e[25]=x,e[26]=b):b=e[26];let _;e[27]!==a||e[28]!==o||e[29]!==i||e[30]!==l?(_=i&&r.jsx("button",{type:"button",onClick:a,className:"text-xs text-muted-foreground hover:text-foreground transition-colors",children:l(o?"virtualMcp.dependencySelectionDialog.deselectAll":"virtualMcp.dependencySelectionDialog.selectAll")}),e[27]=a,e[28]=o,e[29]=i,e[30]=l,e[31]=_):_=e[31];let y;return e[32]!==b||e[33]!==_?(y=r.jsxs("div",{className:"flex items-center justify-between px-6 py-3 border-t border-border shrink-0",children:[b,_]}),e[32]=b,e[33]=_,e[34]=y):y=e[34],y}function W9(t){const e=B.c(13),{items:s,selections:n,onToggle:i,emptyMessage:o,disabled:a}=t;let l,c,d;if(e[0]!==a||e[1]!==o||e[2]!==s||e[3]!==i||e[4]!==n){d=Symbol.for("react.early_return_sentinel");e:{const u=s.map(Qw);if(s.length===0){let f;e[8]!==o?(f=r.jsx("div",{className:"flex-1 overflow-auto px-4 py-3 space-y-1",children:r.jsx("div",{className:"flex items-center justify-center h-32 text-sm text-muted-foreground",children:o})}),e[8]=o,e[9]=f):f=e[9],d=f;break e}l="flex-1 overflow-auto px-4 py-3 space-y-1",c=s.map(f=>r.jsx(e3,{item:f,isSelected:n===null||n?.includes(f.id),onToggle:()=>i(f.id,u),disabled:a},f.id))}e[0]=a,e[1]=o,e[2]=s,e[3]=i,e[4]=n,e[5]=l,e[6]=c,e[7]=d}else l=e[5],c=e[6],d=e[7];if(d!==Symbol.for("react.early_return_sentinel"))return d;let h;return e[10]!==l||e[11]!==c?(h=r.jsx("div",{className:l,children:c}),e[10]=l,e[11]=c,e[12]=h):h=e[12],h}function Qw(t){return t.id}function Zw(t){const e=B.c(22),{connectionId:s,toolSelections:n,onToggleTool:i}=t,o=re(),{org:a}=Fe();let l;e[0]!==s||e[1]!==a.id||e[2]!==a.slug?(l={connectionId:s,orgId:a.id,orgSlug:a.slug},e[0]=s,e[1]=a.id,e[2]=a.slug,e[3]=l):l=e[3];const c=ht(l);let d;e[4]!==c?(d={client:c},e[4]=c,e[5]=d):d=e[5];const{data:h}=a2(d),u=h.tools;let f,m,p;if(e[6]!==h.tools||e[7]!==i||e[8]!==o||e[9]!==n){p=Symbol.for("react.early_return_sentinel");e:{const x=u.map(tj);let v;e[13]!==n?(v=y=>n===null||n.includes(y.name),e[13]=n,e[14]=v):v=e[14];const _=h.tools.filter(v).map(ej);if(_.length===0){let y;e[15]!==o?(y=o("virtualMcp.dependencySelectionDialog.noActiveToolsSelected"),e[15]=o,e[16]=y):y=e[16];let L;e[17]!==y?(L=r.jsx("div",{className:"flex-1 overflow-auto px-4 py-3 space-y-1",children:r.jsx("div",{className:"flex items-center justify-center h-32 text-sm text-muted-foreground",children:y})}),e[17]=y,e[18]=L):L=e[18],p=L;break e}f="flex-1 overflow-auto px-4 py-3 space-y-1",m=_.map(y=>r.jsx(e3,{item:y,isSelected:!0,onToggle:()=>i(y.id,x)},y.id))}e[6]=h.tools,e[7]=i,e[8]=o,e[9]=n,e[10]=f,e[11]=m,e[12]=p}else f=e[10],m=e[11],p=e[12];if(p!==Symbol.for("react.early_return_sentinel"))return p;let g;return e[19]!==f||e[20]!==m?(g=r.jsx("div",{className:f,children:m}),e[19]=f,e[20]=m,e[21]=g):g=e[21],g}function ej(t){return{id:t.name,name:t.name,description:t.description,tags:r.jsx(L2,{annotations:t.annotations,_meta:t._meta})}}function tj(t){return t.name}function sj(t){const e=B.c(16),{connectionId:s,selections:n,onToggle:i,disabled:o}=t,{org:a}=Fe();let l;e[0]!==s||e[1]!==a.id||e[2]!==a.slug?(l={connectionId:s,orgId:a.id,orgSlug:a.slug},e[0]=s,e[1]=a.id,e[2]=a.slug,e[3]=l):l=e[3];const c=ht(l);let d;e[4]!==c?(d={client:c},e[4]=c,e[5]=d):d=e[5];const{data:h}=a2(d);let u;e[6]!==h.tools?(u=h.tools.map(nj),e[6]=h.tools,e[7]=u):u=e[7];const f=u,m=re();let p;e[8]!==m?(p=m("virtualMcp.dependencySelectionDialog.noToolsAvailable"),e[8]=m,e[9]=p):p=e[9];let g;return e[10]!==o||e[11]!==f||e[12]!==i||e[13]!==n||e[14]!==p?(g=r.jsx(W9,{items:f,selections:n,onToggle:i,emptyMessage:p,disabled:o}),e[10]=o,e[11]=f,e[12]=i,e[13]=n,e[14]=p,e[15]=g):g=e[15],g}function nj(t){return{id:t.name,name:t.name,description:t.description,tags:r.jsx(L2,{annotations:t.annotations,_meta:t._meta})}}function ij(t){const e=B.c(16),{connectionId:s,selections:n,onToggle:i,disabled:o}=t,{org:a}=Fe();let l;e[0]!==s||e[1]!==a.id||e[2]!==a.slug?(l={connectionId:s,orgId:a.id,orgSlug:a.slug},e[0]=s,e[1]=a.id,e[2]=a.slug,e[3]=l):l=e[3];const c=ht(l);let d;e[4]!==c?(d={client:c},e[4]=c,e[5]=d):d=e[5];const{data:h}=ux(d);let u;e[6]!==h.resources?(u=h.resources.map(rj),e[6]=h.resources,e[7]=u):u=e[7];const f=u,m=re();let p;e[8]!==m?(p=m("virtualMcp.dependencySelectionDialog.noResourcesAvailable"),e[8]=m,e[9]=p):p=e[9];let g;return e[10]!==o||e[11]!==f||e[12]!==i||e[13]!==n||e[14]!==p?(g=r.jsx(W9,{items:f,selections:n,onToggle:i,emptyMessage:p,disabled:o}),e[10]=o,e[11]=f,e[12]=i,e[13]=n,e[14]=p,e[15]=g):g=e[15],g}function rj(t){return{id:t.name||t.uri,name:t.name||t.uri,description:t.description}}function oj(t){const e=B.c(16),{connectionId:s,selections:n,onToggle:i,disabled:o}=t,{org:a}=Fe();let l;e[0]!==s||e[1]!==a.id||e[2]!==a.slug?(l={connectionId:s,orgId:a.id,orgSlug:a.slug},e[0]=s,e[1]=a.id,e[2]=a.slug,e[3]=l):l=e[3];const c=ht(l);let d;e[4]!==c?(d={client:c},e[4]=c,e[5]=d):d=e[5];const{data:h}=Tm(d);let u;e[6]!==h.prompts?(u=h.prompts.map(aj),e[6]=h.prompts,e[7]=u):u=e[7];const f=u,m=re();let p;e[8]!==m?(p=m("virtualMcp.dependencySelectionDialog.noPromptsAvailable"),e[8]=m,e[9]=p):p=e[9];let g;return e[10]!==o||e[11]!==f||e[12]!==i||e[13]!==n||e[14]!==p?(g=r.jsx(W9,{items:f,selections:n,onToggle:i,emptyMessage:p,disabled:o}),e[10]=o,e[11]=f,e[12]=i,e[13]=n,e[14]=p,e[15]=g):g=e[15],g}function aj(t){return{id:t.name,name:t.name,description:t.description}}function lj(t){const e=B.c(58),{currentConnection:s,activeTab:n,selectedId:i,formData:o,toggleTool:a,toggleResource:l,togglePrompt:c,toggleAllTools:d,toggleAllResources:h,toggleAllPrompts:u,onTabChange:f}=t,m=re(),p=o[i],g=n==="tools"?p?.tools===null:n==="resources"?p?.resources===null:n==="prompts"?p?.prompts===null:!1,x=n!=="active";let v;e[0]!==n||e[1]!==i||e[2]!==u||e[3]!==h||e[4]!==d?(v=()=>{n==="tools"?d(i):n==="resources"?h(i):n==="prompts"&&u(i)},e[0]=n,e[1]=i,e[2]=u,e[3]=h,e[4]=d,e[5]=v):v=e[5];const b=v;let _;e[6]!==s.icon||e[7]!==s.title?(_=r.jsx(an,{icon:s.icon,name:s.title,size:"sm",className:"shrink-0"}),e[6]=s.icon,e[7]=s.title,e[8]=_):_=e[8];let y;e[9]!==s.title?(y=r.jsx("h2",{className:"text-base font-semibold truncate",children:s.title}),e[9]=s.title,e[10]=y):y=e[10];let L;e[11]!==s.description?(L=s.description&&r.jsx("p",{className:"text-xs text-muted-foreground truncate",children:s.description}),e[11]=s.description,e[12]=L):L=e[12];let w;e[13]!==y||e[14]!==L?(w=r.jsxs("div",{className:"flex-1 min-w-0",children:[y,L]}),e[13]=y,e[14]=L,e[15]=w):w=e[15];let j;e[16]!==_||e[17]!==w?(j=r.jsx("div",{className:"px-6 pt-5 pb-4 shrink-0",children:r.jsxs("div",{className:"flex items-center gap-3",children:[_,w]})}),e[16]=_,e[17]=w,e[18]=j):j=e[18];let S;e[19]!==n||e[20]!==b||e[21]!==g||e[22]!==f||e[23]!==x?(S=r.jsx(Xw,{activeTab:n,onTabChange:f,showSelectAll:x,isAllSelected:g,handleSelectAll:b}),e[19]=n,e[20]=b,e[21]=g,e[22]=f,e[23]=x,e[24]=S):S=e[24];let C;e[25]!==n||e[26]!==o||e[27]!==i||e[28]!==m||e[29]!==a?(C=n==="active"&&r.jsx(_s,{fallback:Sa("Tools not supported by this server",m),children:r.jsx(A.Suspense,{fallback:r.jsx(uo,{}),children:r.jsx(Zw,{connectionId:i,toolSelections:o[i]?o[i].tools:[],onToggleTool:(R,P)=>a(i,R,P)})})}),e[25]=n,e[26]=o,e[27]=i,e[28]=m,e[29]=a,e[30]=C):C=e[30];let N;e[31]!==n||e[32]!==o||e[33]!==i||e[34]!==m||e[35]!==a?(N=n==="tools"&&r.jsx(_s,{fallback:Sa("Tools not supported by this server",m),children:r.jsx(A.Suspense,{fallback:r.jsx(uo,{}),children:r.jsx(sj,{connectionId:i,selections:o[i]?o[i].tools:[],onToggle:(R,P)=>a(i,R,P)})})}),e[31]=n,e[32]=o,e[33]=i,e[34]=m,e[35]=a,e[36]=N):N=e[36];let V;e[37]!==n||e[38]!==o||e[39]!==i||e[40]!==m||e[41]!==l?(V=n==="resources"&&r.jsx(_s,{fallback:Sa("Resources not supported by this server",m),children:r.jsx(A.Suspense,{fallback:r.jsx(uo,{}),children:r.jsx(ij,{connectionId:i,selections:o[i]?o[i].resources:[],onToggle:(R,P)=>l(i,R,P)})})}),e[37]=n,e[38]=o,e[39]=i,e[40]=m,e[41]=l,e[42]=V):V=e[42];let E;e[43]!==n||e[44]!==o||e[45]!==i||e[46]!==m||e[47]!==c?(E=n==="prompts"&&r.jsx(_s,{fallback:Sa("Prompts not supported by this server",m),children:r.jsx(A.Suspense,{fallback:r.jsx(uo,{}),children:r.jsx(oj,{connectionId:i,selections:o[i]?o[i].prompts:[],onToggle:(R,P)=>c(i,R,P)})})}),e[43]=n,e[44]=o,e[45]=i,e[46]=m,e[47]=c,e[48]=E):E=e[48];let T;e[49]!==V||e[50]!==E||e[51]!==C||e[52]!==N?(T=r.jsxs("div",{className:"flex-1 overflow-hidden flex flex-col",children:[C,N,V,E]}),e[49]=V,e[50]=E,e[51]=C,e[52]=N,e[53]=T):T=e[53];let k;return e[54]!==T||e[55]!==j||e[56]!==S?(k=r.jsxs(r.Fragment,{children:[j,S,T]}),e[54]=T,e[55]=j,e[56]=S,e[57]=k):k=e[57],k}function cj(t){const e=B.c(7),{onClose:s}=t,n=re();let i;e[0]!==s?(i=()=>s(!1),e[0]=s,e[1]=i):i=e[1];let o;e[2]!==n?(o=n("virtualMcp.dependencySelectionDialog.done"),e[2]=n,e[3]=o):o=e[3];let a;return e[4]!==i||e[5]!==o?(a=r.jsx(Mi,{className:"px-6 py-4 border-t border-border shrink-0",children:r.jsx(le,{variant:"outline",onClick:i,children:o})}),e[4]=i,e[5]=o,e[6]=a):a=e[6],a}function dj(t){const e=B.c(23),{connectionId:s,onAuthenticate:n,children:i}=t,o=re();let a;e[0]!==s?(a={connectionId:s},e[0]=s,e[1]=a):a=e[1];const l=S2(a);if(l.supportsOAuth&&!l.isAuthenticated){let h;e[2]===Symbol.for("react.memo_cache_sentinel")?(h=r.jsx("div",{className:"flex items-center justify-center size-12 rounded-full bg-muted",children:r.jsx(Qv,{size:22,className:"text-muted-foreground"})}),e[2]=h):h=e[2];let u;e[3]!==o?(u=o("virtualMcp.dependencySelectionDialog.authorizationRequired"),e[3]=o,e[4]=u):u=e[4];let f;e[5]!==u?(f=r.jsx("p",{className:"text-sm font-medium",children:u}),e[5]=u,e[6]=f):f=e[6];let m;e[7]!==o?(m=o("virtualMcp.dependencySelectionDialog.authorizationDescription"),e[7]=o,e[8]=m):m=e[8];let p;e[9]!==m?(p=r.jsx("p",{className:"text-xs text-muted-foreground max-w-xs",children:m}),e[9]=m,e[10]=p):p=e[10];let g;e[11]!==f||e[12]!==p?(g=r.jsxs("div",{className:"space-y-1",children:[f,p]}),e[11]=f,e[12]=p,e[13]=g):g=e[13];let x;e[14]!==s||e[15]!==n||e[16]!==o?(x=n&&r.jsx(le,{variant:"outline",size:"sm",onClick:()=>n(s),children:o("virtualMcp.dependencySelectionDialog.authorize")}),e[14]=s,e[15]=n,e[16]=o,e[17]=x):x=e[17];let v;return e[18]!==g||e[19]!==x?(v=r.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center gap-4 p-8 text-center",children:[h,g,x]}),e[18]=g,e[19]=x,e[20]=v):v=e[20],v}let d;return e[21]!==i?(d=r.jsx(r.Fragment,{children:i}),e[21]=i,e[22]=d):d=e[22],d}function uj(t){const e={};for(const s of t)e[s.connection_id]={tools:s.selected_tools,resources:s.selected_resources??null,prompts:s.selected_prompts??null};return e}function $h(t){return Object.entries(t).map(([e,s])=>({connection_id:e,selected_tools:s.tools,selected_resources:s.resources,selected_prompts:s.prompts}))}function Bh(t,e,s,n){const i=t[e]??{tools:null,resources:null,prompts:null};return{...t,[e]:{...i,[s]:n}}}function hj(t,e){return e.type==="SET_ACTIVE_TAB"?{...t,activeTab:e.payload}:t}function fj(t){const e=B.c(49),{open:s,onOpenChange:n,selectedId:i,form:o,connections:a,onAuthenticate:l}=t;let c;e[0]===Symbol.for("react.memo_cache_sentinel")?(c={activeTab:"tools"},e[0]=c):c=e[0];const[d,h]=A.useReducer(hj,c),u=p9(i??"");let f;e[1]!==a?(f=a??[],e[1]=a,e[2]=f):f=e[2];let m;e[3]!==f?(m=uj(f),e[3]=f,e[4]=m):m=e[4];const p=m;let g;e[5]!==o||e[6]!==p?(g=($,z,K,X)=>{const J=p[$]?.[z];let H;J===null?H=X.filter(W=>W!==K):J?.includes(K)?H=J.filter(W=>W!==K):(H=[...J??[],K],H.length===X.length&&(H=null)),o.setValue("connections",$h(Bh(p,$,z,H)),{shouldDirty:!0,shouldTouch:!0})},e[5]=o,e[6]=p,e[7]=g):g=e[7];const x=g;let v;e[8]!==o||e[9]!==p?(v=($,z)=>{const X=p[$]?.[z]===null?[]:null;o.setValue("connections",$h(Bh(p,$,z,X)),{shouldDirty:!0,shouldTouch:!0})},e[8]=o,e[9]=p,e[10]=v):v=e[10];const b=v;let _;e[11]!==x?(_=($,z,K)=>x($,"tools",z,K),e[11]=x,e[12]=_):_=e[12];const y=_;let L;e[13]!==x?(L=($,z,K)=>x($,"resources",z,K),e[13]=x,e[14]=L):L=e[14];const w=L;let j;e[15]!==x?(j=($,z,K)=>x($,"prompts",z,K),e[15]=x,e[16]=j):j=e[16];const S=j;let C;e[17]!==b?(C=$=>b($,"tools"),e[17]=b,e[18]=C):C=e[18];const N=C;let V;e[19]!==b?(V=$=>b($,"resources"),e[19]=b,e[20]=V):V=e[20];const E=V;let T;e[21]!==b?(T=$=>b($,"prompts"),e[21]=b,e[22]=T):T=e[22];const k=T;if(!i||!u)return null;let R;e[23]===Symbol.for("react.memo_cache_sentinel")?(R=r.jsx(uo,{}),e[23]=R):R=e[23];let P;e[24]===Symbol.for("react.memo_cache_sentinel")?(P=$=>h({type:"SET_ACTIVE_TAB",payload:$}),e[24]=P):P=e[24];let D;e[25]!==u||e[26]!==d.activeTab||e[27]!==p||e[28]!==i||e[29]!==k||e[30]!==E||e[31]!==N||e[32]!==S||e[33]!==w||e[34]!==y?(D=r.jsx(lj,{currentConnection:u,activeTab:d.activeTab,selectedId:i,formData:p,toggleTool:y,toggleResource:w,togglePrompt:S,toggleAllTools:N,toggleAllResources:E,toggleAllPrompts:k,onTabChange:P},i),e[25]=u,e[26]=d.activeTab,e[27]=p,e[28]=i,e[29]=k,e[30]=E,e[31]=N,e[32]=S,e[33]=w,e[34]=y,e[35]=D):D=e[35];let I;e[36]!==l||e[37]!==i||e[38]!==D?(I=r.jsx(A.Suspense,{fallback:R,children:r.jsx(dj,{connectionId:i,onAuthenticate:l,children:D})}),e[36]=l,e[37]=i,e[38]=D,e[39]=I):I=e[39];let M;e[40]!==n?(M=r.jsx(cj,{onClose:n}),e[40]=n,e[41]=M):M=e[41];let O;e[42]!==I||e[43]!==M?(O=r.jsxs(es,{className:"sm:max-w-2xl h-[75vh] max-h-[75vh] flex flex-col p-0 gap-0 overflow-hidden w-[95vw]",children:[I,M]}),e[42]=I,e[43]=M,e[44]=O):O=e[44];let F;return e[45]!==n||e[46]!==s||e[47]!==O?(F=r.jsx(ts,{open:s,onOpenChange:n,children:O}),e[45]=n,e[46]=s,e[47]=O,e[48]=F):F=e[48],F}const Fh="__new_instance__";function mj(t){const e=B.c(23),{connection_id:s,usedConnectionIds:n,onOpenSettings:i,onRemove:o,onAuthenticate:a,onSwitchInstance:l,onNewInstance:c}=t,d=p9(s),{org:h}=Fe();if(!d)return null;let u;e[0]!==d?(u=Bb(d),e[0]=d,e[1]=u):u=e[1];const f=u;let m;e[2]!==s?(m=r.jsx(xj,{connection_id:s}),e[2]=s,e[3]=m):m=e[3];let p;e[4]!==d.app_name||e[5]!==d.connection_type||e[6]!==d.description||e[7]!==d.icon||e[8]!==d.status||e[9]!==d.title||e[10]!==s||e[11]!==a||e[12]!==c||e[13]!==i||e[14]!==o||e[15]!==l||e[16]!==h.slug||e[17]!==f||e[18]!==n?(p=r.jsx(gj,{connection_id:s,connectionTitle:d.title,connectionDescription:d.description,connectionIcon:d.icon,connectionType:d.connection_type,connectionStatus:d.status,slug:f,orgSlug:h.slug,appName:d.app_name,usedConnectionIds:n,onOpenSettings:i,onRemove:o,onAuthenticate:a,onSwitchInstance:l,onNewInstance:c}),e[4]=d.app_name,e[5]=d.connection_type,e[6]=d.description,e[7]=d.icon,e[8]=d.status,e[9]=d.title,e[10]=s,e[11]=a,e[12]=c,e[13]=i,e[14]=o,e[15]=l,e[16]=h.slug,e[17]=f,e[18]=n,e[19]=p):p=e[19];let g;return e[20]!==m||e[21]!==p?(g=r.jsx(A.Suspense,{fallback:m,children:p}),e[20]=m,e[21]=p,e[22]=g):g=e[22],g}function pj(t){const e=B.c(24),{appName:s,connectionId:n,usedConnectionIds:i,onSwitchInstance:o,onNewInstance:a}=t,l=re();let c;e[0]!==s?(c={filters:[{column:"app_name",value:s}]},e[0]=s,e[1]=c):c=e[1];const d=Rn(c);if(d.length<=1)return null;let h;e[2]!==n||e[3]!==a||e[4]!==o?(h=x=>{x===Fh?a?.():o(n,x)},e[2]=n,e[3]=a,e[4]=o,e[5]=h):h=e[5];let u;e[6]===Symbol.for("react.memo_cache_sentinel")?(u=r.jsx(Jt,{size:"sm",className:"w-auto text-xs gap-1 px-2 shadow-none",children:r.jsx(as,{})}),e[6]=u):u=e[6];let f;if(e[7]!==n||e[8]!==d||e[9]!==i){let x;e[11]!==n||e[12]!==i?(x=v=>r.jsx(vt,{value:v.id,className:"text-xs",disabled:v.id!==n&&i.has(v.id),children:v.title},v.id),e[11]=n,e[12]=i,e[13]=x):x=e[13],f=d.map(x),e[7]=n,e[8]=d,e[9]=i,e[10]=f}else f=e[10];let m;e[14]!==a||e[15]!==l?(m=a&&r.jsxs(vt,{value:Fh,className:"text-xs text-muted-foreground",children:["+ ",l("virtualMcp.connectionItem.newInstance")]}),e[14]=a,e[15]=l,e[16]=m):m=e[16];let p;e[17]!==f||e[18]!==m?(p=r.jsxs(Xt,{children:[f,m]}),e[17]=f,e[18]=m,e[19]=p):p=e[19];let g;return e[20]!==n||e[21]!==h||e[22]!==p?(g=r.jsxs(Qt,{value:n,onValueChange:h,children:[u,p]}),e[20]=n,e[21]=h,e[22]=p,e[23]=g):g=e[23],g}function gj({connection_id:t,connectionTitle:e,connectionDescription:s,connectionIcon:n,connectionType:i,connectionStatus:o,slug:a,orgSlug:l,appName:c,usedConnectionIds:d,onOpenSettings:h,onRemove:u,onAuthenticate:f,onSwitchInstance:m,onNewInstance:p}){const g=S2({connectionId:t}),x=y2(),b=!(i==="VIRTUAL")&&g.supportsOAuth&&!g.isAuthenticated,_=o!=="active",y=re(),L=async w=>{try{await x.update.mutateAsync({id:t,data:{status:w}}),ge.success(y(w==="active"?"virtualMcp.connectionItem.connectionEnabled":"virtualMcp.connectionItem.connectionDisabled"))}catch{ge.error(y("virtualMcp.connectionItem.failedToUpdateConnection"))}};return r.jsxs("div",{className:ie("rounded-xl border overflow-hidden transition-colors",b||_?"border-destructive/50 bg-destructive/5":"border-border bg-card"),children:[r.jsxs(pm,{to:"/$org/settings/connections/$appSlug",params:{org:l,appSlug:a},className:"flex items-center gap-3 px-4 py-3 cursor-pointer hover:bg-muted/50 transition-colors",children:[r.jsx(an,{icon:n,name:e,size:"sm",className:"shrink-0"}),r.jsxs("div",{className:"flex-1 min-w-0",children:[r.jsx("p",{className:"text-sm font-medium truncate",children:e}),b?r.jsx("span",{className:"text-xs text-destructive font-medium",children:y("virtualMcp.connectionItem.needsAuthorization")}):_?r.jsx("span",{className:"text-xs text-destructive font-medium",children:y(o==="error"?"virtualMcp.connectionItem.disabledError":"virtualMcp.connectionItem.disabled")}):s&&r.jsx("p",{className:"text-xs text-muted-foreground truncate",children:s})]}),b?r.jsx(le,{variant:"outline",size:"sm",className:"h-7 text-xs shrink-0",onClick:w=>{w.preventDefault(),w.stopPropagation(),f(t)},children:y("virtualMcp.connectionItem.authorize")}):_?r.jsxs(le,{variant:"outline",size:"sm",className:"h-7 text-xs gap-1.5 shrink-0",onClick:w=>{w.preventDefault(),w.stopPropagation(),L("active")},children:[r.jsx(Zv,{size:13}),y("virtualMcp.connectionItem.enable")]}):r.jsxs(He,{delayDuration:0,children:[r.jsx(Ke,{asChild:!0,children:r.jsx("span",{className:"inline-flex items-center justify-center rounded-md h-7 w-7 hover:bg-accent text-muted-foreground shrink-0 transition-colors",children:r.jsx(w6,{size:16})})}),r.jsx(Ue,{side:"bottom",children:y("virtualMcp.connectionItem.connectionSettings")})]})]}),r.jsxs("div",{className:"flex items-center gap-3 px-4 py-2 border-t border-border bg-muted/25",children:[c&&r.jsx(pj,{appName:c,connectionId:t,usedConnectionIds:d,onSwitchInstance:m,onNewInstance:p}),r.jsxs("div",{className:"flex items-center gap-0.5 ml-auto",children:[r.jsxs(He,{delayDuration:0,children:[r.jsx(Ke,{asChild:!0,children:r.jsx(le,{variant:"ghost",size:"icon",className:"h-7 w-7",onClick:h,"aria-label":y("virtualMcp.connectionItem.configureResources"),children:r.jsx(Fm,{size:13})})}),r.jsx(Ue,{side:"bottom",children:y("virtualMcp.connectionItem.configureResources")})]}),!_&&r.jsxs(He,{delayDuration:0,children:[r.jsx(Ke,{asChild:!0,children:r.jsx(le,{variant:"ghost",size:"icon",className:"h-7 w-7 text-muted-foreground",onClick:()=>L("inactive"),"aria-label":y("virtualMcp.connectionItem.disableConnection"),children:r.jsx(e6,{size:13})})}),r.jsx(Ue,{side:"bottom",children:y("virtualMcp.connectionItem.disable")})]}),r.jsxs(He,{delayDuration:0,children:[r.jsx(Ke,{asChild:!0,children:r.jsx(le,{variant:"ghost",size:"icon",className:"h-7 w-7 text-muted-foreground hover:text-destructive",onClick:u,"aria-label":y("virtualMcp.connectionItem.removeConnection"),children:r.jsx(Pn,{size:13})})}),r.jsx(Ue,{side:"bottom",children:y("virtualMcp.connectionItem.remove")})]})]})]})]})}function xj(t){const e=B.c(17),{connection_id:s}=t,n=p9(s);if(!n){let u;return e[0]===Symbol.for("react.memo_cache_sentinel")?(u=r.jsx(t3,{}),e[0]=u):u=e[0],u}let i;e[1]!==n.icon||e[2]!==n.title?(i=r.jsx(an,{icon:n.icon,name:n.title,size:"sm",className:"shrink-0"}),e[1]=n.icon,e[2]=n.title,e[3]=i):i=e[3];let o;e[4]!==n.title?(o=r.jsx("p",{className:"text-sm font-medium truncate",children:n.title}),e[4]=n.title,e[5]=o):o=e[5];let a;e[6]!==n.description?(a=n.description&&r.jsx("p",{className:"text-xs text-muted-foreground truncate",children:n.description}),e[6]=n.description,e[7]=a):a=e[7];let l;e[8]!==o||e[9]!==a?(l=r.jsxs("div",{className:"flex-1 min-w-0",children:[o,a]}),e[8]=o,e[9]=a,e[10]=l):l=e[10];let c;e[11]!==i||e[12]!==l?(c=r.jsxs("div",{className:"flex items-center gap-3 px-4 py-3",children:[i,l]}),e[11]=i,e[12]=l,e[13]=c):c=e[13];let d;e[14]===Symbol.for("react.memo_cache_sentinel")?(d=r.jsx("div",{className:"flex items-center px-4 py-2 border-t border-border bg-muted/25",children:r.jsx("div",{className:"h-5 w-20 rounded bg-muted animate-pulse"})}),e[14]=d):d=e[14];let h;return e[15]!==c?(h=r.jsxs("div",{className:"rounded-xl border border-border overflow-hidden",children:[c,d]}),e[15]=c,e[16]=h):h=e[16],h}function t3(){const t=B.c(3);let e;t[0]===Symbol.for("react.memo_cache_sentinel")?(e=r.jsx("div",{className:"size-8 rounded-md bg-muted animate-pulse shrink-0"}),t[0]=e):e=t[0];let s;t[1]===Symbol.for("react.memo_cache_sentinel")?(s=r.jsxs("div",{className:"flex items-center gap-3 px-4 py-3",children:[e,r.jsxs("div",{className:"flex-1 space-y-1.5",children:[r.jsx("div",{className:"h-4 w-32 rounded bg-muted animate-pulse"}),r.jsx("div",{className:"h-3 w-48 rounded bg-muted animate-pulse"})]})]}),t[1]=s):s=t[1];let n;return t[2]===Symbol.for("react.memo_cache_sentinel")?(n=r.jsxs("div",{className:"rounded-xl border border-border overflow-hidden",children:[s,r.jsx("div",{className:"flex items-center px-4 py-2 border-t border-border bg-muted/25",children:r.jsx("div",{className:"h-5 w-20 rounded bg-muted animate-pulse"})})]}),t[2]=n):n=t[2],n}function vj(t){const e=B.c(5),{value:s}=t;let n;if(e[0]!==s){n=Symbol.for("react.early_return_sentinel");e:{const o=Jl(s);if(o.type==="icon"){const a=Oi(o.name);if(a){let l;e[2]!==a?(l=r.jsx(a,{size:16,className:"text-muted-foreground"}),e[2]=a,e[3]=l):l=e[3],n=l;break e}}}e[0]=s,e[1]=n}else n=e[1];if(n!==Symbol.for("react.early_return_sentinel"))return n;let i;return e[4]===Symbol.for("react.memo_cache_sentinel")?(i=r.jsx(Fb,{size:16,className:"text-muted-foreground"}),e[4]=i):i=e[4],i}function bj(t){const e=B.c(71),{value:s,onChange:n,className:i,disabled:o}=t,a=re(),[l,c]=A.useState(!1),[d,h]=A.useState("");let u;e[0]!==s?(u=Jl(s),e[0]=s,e[1]=u):u=e[1];const f=u,m=f.type==="icon"?f.name:null;let p,g,x,v,b,_,y,L,w,j,S,C,N,V,E;if(e[2]!==i||e[3]!==m||e[4]!==o||e[5]!==n||e[6]!==l||e[7]!==d||e[8]!==a||e[9]!==s){const M=t9();v=qm(M,d),x=As,b=o?!1:l,_=c;const O=o?"cursor-default opacity-50":"cursor-pointer hover:bg-accent";let F;e[25]!==i||e[26]!==O?(F=ie("size-7 shrink-0 rounded-md transition-colors flex items-center justify-center",O,i),e[25]=i,e[26]=O,e[27]=F):F=e[27];let $;e[28]!==s?($=r.jsx(vj,{value:s}),e[28]=s,e[29]=$):$=e[29],e[30]!==o||e[31]!==F||e[32]!==$?(y=r.jsx(Es,{asChild:!0,children:r.jsx("button",{type:"button",disabled:o,"aria-label":"Change icon",className:F,children:$})}),e[30]=o,e[31]=F,e[32]=$,e[33]=y):y=e[33],g=Ps,N="start",V="w-64 p-0",E=yj,S="flex flex-col";let z;e[34]===Symbol.for("react.memo_cache_sentinel")?(z=r.jsx(Oo,{size:14,className:"absolute left-2 top-1/2 -translate-y-1/2 text-muted-foreground pointer-events-none"}),e[34]=z):z=e[34];let K;e[35]===Symbol.for("react.memo_cache_sentinel")?(K=H=>h(H.target.value),e[35]=K):K=e[35];let X;e[36]!==a?(X=a("common.simpleIconPicker.filterPlaceholder"),e[36]=a,e[37]=X):X=e[37],e[38]!==d||e[39]!==X?(C=r.jsx("div",{className:"px-2 py-2",children:r.jsxs("div",{className:"relative",children:[z,r.jsx(rt,{value:d,onChange:K,placeholder:X,className:"h-7 text-xs pl-7"})]})}),e[38]=d,e[39]=X,e[40]=C):C=e[40],p=ri,j="h-48",L="grid grid-cols-8 gap-0.5 px-2 pb-2";let J;e[41]!==m||e[42]!==n?(J=H=>{const W=Oi(H);return W?r.jsx("button",{type:"button",onClick:()=>{n(`icon://${H}`),c(!1)},className:ie("h-7 w-7 flex items-center justify-center rounded-md transition-colors cursor-pointer",m===H?"bg-accent text-foreground":"text-muted-foreground hover:bg-accent hover:text-foreground"),title:Ed(H),"aria-label":Ed(H),children:r.jsx(W,{size:16})},H):null},e[41]=m,e[42]=n,e[43]=J):J=e[43],w=v.map(J),e[2]=i,e[3]=m,e[4]=o,e[5]=n,e[6]=l,e[7]=d,e[8]=a,e[9]=s,e[10]=p,e[11]=g,e[12]=x,e[13]=v,e[14]=b,e[15]=_,e[16]=y,e[17]=L,e[18]=w,e[19]=j,e[20]=S,e[21]=C,e[22]=N,e[23]=V,e[24]=E}else p=e[10],g=e[11],x=e[12],v=e[13],b=e[14],_=e[15],y=e[16],L=e[17],w=e[18],j=e[19],S=e[20],C=e[21],N=e[22],V=e[23],E=e[24];let T;e[44]!==L||e[45]!==w?(T=r.jsx("div",{className:L,children:w}),e[44]=L,e[45]=w,e[46]=T):T=e[46];let k;e[47]!==v.length||e[48]!==a?(k=v.length===0&&r.jsx("div",{className:"flex items-center justify-center py-6 text-xs text-muted-foreground",children:a("common.simpleIconPicker.noIconsFound")}),e[47]=v.length,e[48]=a,e[49]=k):k=e[49];let R;e[50]!==p||e[51]!==T||e[52]!==k||e[53]!==j?(R=r.jsxs(p,{className:j,children:[T,k]}),e[50]=p,e[51]=T,e[52]=k,e[53]=j,e[54]=R):R=e[54];let P;e[55]!==R||e[56]!==S||e[57]!==C?(P=r.jsxs("div",{className:S,children:[C,R]}),e[55]=R,e[56]=S,e[57]=C,e[58]=P):P=e[58];let D;e[59]!==g||e[60]!==P||e[61]!==N||e[62]!==V||e[63]!==E?(D=r.jsx(g,{align:N,className:V,onOpenAutoFocus:E,children:P}),e[59]=g,e[60]=P,e[61]=N,e[62]=V,e[63]=E,e[64]=D):D=e[64];let I;return e[65]!==x||e[66]!==b||e[67]!==_||e[68]!==y||e[69]!==D?(I=r.jsxs(x,{open:b,onOpenChange:_,children:[y,D]}),e[65]=x,e[66]=b,e[67]=_,e[68]=y,e[69]=D,e[70]=I):I=e[70],I}function yj(t){return t.preventDefault()}function _j({virtualMcpId:t,form:e,flushAndSave:s}){const n=re(),i=Bs(),o=gs(t),a=(o?.connections??[]).map(T=>T.connection_id).sort(),{data:l}=Ft({queryKey:at.projectConnectionDetails(t,a),enabled:a.length>0,queryFn:async()=>await Promise.all(a.map(async k=>{try{const{item:R}=await i.call("COLLECTION_CONNECTIONS_GET",{id:k}),P=(R?.tools??[]).flatMap(D=>{const I=sc(D._meta);return I?[{name:D.name,title:D.title,description:D.description,resourceUri:I}]:[]});return{fetchOk:!0,id:k,title:R?.title??k,icon:R?.icon??null,uiTools:P}}catch{return{fetchOk:!1,id:k,title:k,icon:null,uiTools:[]}}}))}),c=(l??[]).filter(T=>T.uiTools.length>0),d=new Set(pb),h=e.watch("metadata.ui.pinnedViews")??[],u=e.watch("metadata.ui.layout")??null,f=u?.defaultMainView??null,m=u?.chatDefaultOpen??!1,p=!f||f.type==="chat"?"chat":f.type==="instructions"||f.type==="connections"||f.type==="layout"?"settings":d.has(f.type)?f.type:`${f.type}:${f.id??""}:${f.toolName??""}`,g=T=>{const[k,R,P]=T.split(":");return k?k==="chat"?{type:k}:d.has(k)?{type:k}:k==="ext-apps"&&R?{type:"ext-apps",id:R,toolName:P||void 0}:null:null},x=T=>{e.setValue("metadata.ui.pinnedViews",T,{shouldDirty:!0})},v=T=>{e.setValue("metadata.ui.layout",{...u,...T},{shouldDirty:!0})},b=A.useRef(!1);if(l&&l.length>0&&!b.current){b.current=!0;const T=new Set((l??[]).filter(P=>P.fetchOk).map(P=>P.id)),k=new Set(c.flatMap(P=>P.uiTools.map(D=>`${P.id}:${D.name}`))),R=h.filter(P=>!T.has(P.connectionId)||k.has(`${P.connectionId}:${P.toolName}`));R.length!==h.length&&(x(R),f?.type==="ext-apps"&&!R.some(P=>P.connectionId===f.id&&P.toolName===f.toolName)&&v({defaultMainView:{type:"chat"}}))}const _=(T,k)=>{if(h.some(P=>P.connectionId===T&&P.toolName===k)){const P=h.filter(I=>!(I.connectionId===T&&I.toolName===k));x(P);const D=`ext-apps:${T}:${k}`;p===D&&v({defaultMainView:{type:"chat"}})}else{const P=c.find(D=>D.id===T)?.uiTools.find(D=>D.name===k)?.title;x([...h,{connectionId:T,toolName:k,label:P??Ci(k),icon:null}])}s()},y=(T,k,R)=>{x(h.map(P=>P.connectionId===T&&P.toolName===k?{...P,label:R}:P))},L=()=>{s()},w=(T,k,R)=>{x(h.map(P=>P.connectionId===T&&P.toolName===k?{...P,icon:R}:P)),s()},j=T=>{v({defaultMainView:g(T)}),s()},S=a.length===0,C=l&&c.length===0,N=sn(o?.metadata),V=[{value:"chat",label:n("virtualMcp.layoutTabContent.chat")},{value:"settings",label:n("virtualMcp.layoutTabContent.settings")},{value:"automations",label:n("virtualMcp.layoutTabContent.automations")}];N&&V.push({value:"preview",label:n("virtualMcp.layoutTabContent.preview")});for(const T of h)V.push({value:`ext-apps:${T.connectionId}:${T.toolName}`,label:T.label||T.toolName});const E=c.length>0||S||C;return r.jsxs("div",{className:"flex flex-col gap-3",children:[r.jsx("div",{className:"flex items-center justify-between gap-3",children:r.jsx("h2",{className:"text-sm font-medium text-foreground",children:n("virtualMcp.layoutTabContent.layout")})}),r.jsxs(vl,{className:"p-6 gap-5",children:[r.jsxs(Mo,{className:"p-0 space-y-5",children:[r.jsxs("div",{className:"flex items-center justify-between gap-4",children:[r.jsxs("div",{className:"space-y-0.5 min-w-0",children:[r.jsx(lt,{className:"font-normal text-foreground",children:n("virtualMcp.layoutTabContent.mainView")}),r.jsx("p",{className:"text-xs text-muted-foreground",children:n("virtualMcp.layoutTabContent.mainViewDescription")})]}),r.jsxs(Qt,{value:p,onValueChange:j,children:[r.jsx(Jt,{className:"w-44 h-8 text-sm capitalize shrink-0",children:r.jsx(as,{})}),r.jsx(Xt,{children:V.map(T=>r.jsx(vt,{value:T.value,className:"capitalize",children:T.label},T.value))})]})]}),r.jsxs("div",{className:"flex items-center justify-between gap-4",children:[r.jsxs("div",{className:"space-y-0.5 min-w-0",children:[r.jsx(lt,{className:"font-normal text-foreground",children:n("virtualMcp.layoutTabContent.showChat")}),r.jsx("p",{className:"text-xs text-muted-foreground",children:n("virtualMcp.layoutTabContent.showChatDescription")})]}),r.jsxs(He,{delayDuration:0,children:[r.jsx(Ke,{asChild:!0,children:r.jsx("span",{className:"shrink-0",children:r.jsx(xr,{checked:p==="chat"?!0:m,disabled:p==="chat",onCheckedChange:T=>{v({chatDefaultOpen:T}),s()}})})}),p==="chat"&&r.jsx(Ue,{side:"top",children:n("virtualMcp.layoutTabContent.chatAlwaysShown")})]})]})]}),E&&r.jsxs(r.Fragment,{children:[r.jsx("div",{className:"border-t border-border -mx-6"}),r.jsxs(Mo,{className:"p-0 space-y-3",children:[r.jsx("div",{className:"flex items-center justify-between gap-4",children:r.jsxs("div",{className:"space-y-0.5 min-w-0",children:[r.jsx(lt,{className:"font-normal text-foreground",children:n("virtualMcp.layoutTabContent.pinnedViews")}),r.jsx("p",{className:"text-xs text-muted-foreground",children:n("virtualMcp.layoutTabContent.pinnedViewsDescription")})]})}),S&&r.jsx("p",{className:"text-xs text-muted-foreground",children:n("virtualMcp.layoutTabContent.addConnectionMessage")}),C&&!S&&r.jsx("p",{className:"text-xs text-muted-foreground",children:n("virtualMcp.layoutTabContent.noInteractiveTools")}),c.length>0&&r.jsx("div",{className:"space-y-4 pt-1",children:c.map((T,k)=>r.jsxs("div",{children:[k>0&&r.jsx("div",{className:"border-t border-border -mx-6 mb-4"}),r.jsxs("div",{className:"flex items-center gap-2 mb-2.5",children:[r.jsx(an,{icon:T.icon,name:T.title,size:"xs",className:"shrink-0"}),r.jsx("span",{className:"text-xs font-medium text-muted-foreground",children:T.title})]}),r.jsx("div",{className:"space-y-1.5",children:T.uiTools.map(R=>{const P=h.some(I=>I.connectionId===T.id&&I.toolName===R.name),D=h.find(I=>I.connectionId===T.id&&I.toolName===R.name);return r.jsxs("div",{className:ie("flex items-center justify-between gap-3 px-3 py-2 rounded-lg border transition-colors",P?"bg-accent/40 border-border":"bg-transparent border-border"),children:[r.jsxs("div",{className:"min-w-0 flex-1 flex items-center gap-2",children:[r.jsx(bj,{value:D?.icon??null,onChange:I=>w(T.id,R.name,I),disabled:!P}),r.jsx(rt,{value:P&&D?D.label:R.title??Ci(R.name),onChange:I=>y(T.id,R.name,I.target.value),onBlur:L,className:"h-7 text-sm w-40",disabled:!P,readOnly:!P})]}),r.jsx(xr,{checked:P,onCheckedChange:()=>_(T.id,R.name)})]},R.name)})})]},T.id))})]})]})]})]})}const Jc={tools:null,resources:null,prompts:null},Lj=hx.pick({status:!0,title:!0,description:!0,icon:!0,metadata:!0,connections:!0});function Sj(t){const s=new TextEncoder().encode(t),n=Array.from(s,i=>String.fromCharCode(i)).join("");return btoa(n)}function wj(t){const e=B.c(15),{url:s,agentId:n}=t,i=re(),[o,a]=A.useState(!1);let l;e[0]!==n||e[1]!==i||e[2]!==s?(l=async()=>{$e("agent_connect_action",{agent_id:n,action:"copy_url"}),await navigator.clipboard.writeText(s),a(!0),ge.success(i("virtualMcp.virtualMcpShareModal.agentUrlCopied")),setTimeout(()=>a(!1),2e3)},e[0]=n,e[1]=i,e[2]=s,e[3]=l):l=e[3];const c=l;let d;e[4]!==o?(d=o?r.jsx(zt,{size:20,className:"text-success"}):r.jsx(Os,{size:20}),e[4]=o,e[5]=d):d=e[5];let h;e[6]!==o||e[7]!==i?(h=i(o?"virtualMcp.virtualMcpShareModal.copied":"virtualMcp.virtualMcpShareModal.copyUrl"),e[6]=o,e[7]=i,e[8]=h):h=e[8];let u;e[9]!==h?(u=r.jsx("span",{className:"text-xs font-medium",children:h}),e[9]=h,e[10]=u):u=e[10];let f;return e[11]!==c||e[12]!==d||e[13]!==u?(f=r.jsxs(le,{type:"button",variant:"outline",onClick:c,className:"h-auto py-3 px-4 flex flex-col items-center gap-2",children:[d,u]}),e[11]=c,e[12]=d,e[13]=u,e[14]=f):f=e[14],f}function jj(t){const e=B.c(13),{url:s,serverName:n,agentId:i}=t,o=re();let a;e[0]!==i||e[1]!==n||e[2]!==o||e[3]!==s?(a=()=>{$e("agent_connect_action",{agent_id:i,action:"install_cursor"});const f=C2(n),p=Sj(JSON.stringify({type:"http",url:s,headers:{"x-mesh-client":"Cursor"}},null,2)),g=`cursor://anysphere.cursor-deeplink/mcp/install?name=${encodeURIComponent(f)}&config=${encodeURIComponent(p)}`;window.open(g,"_blank"),ge.success(o("virtualMcp.virtualMcpShareModal.openingCursor"))},e[0]=i,e[1]=n,e[2]=o,e[3]=s,e[4]=a):a=e[4];const l=a;let c;e[5]===Symbol.for("react.memo_cache_sentinel")?(c=r.jsx("img",{src:"/logos/cursor.svg",alt:"Cursor",className:"h-5 w-5",style:{filter:"brightness(0) saturate(100%) invert(11%) sepia(8%) saturate(785%) hue-rotate(1deg) brightness(95%) contrast(89%)"}}),e[5]=c):c=e[5];let d;e[6]!==o?(d=o("virtualMcp.virtualMcpShareModal.installOnCursor"),e[6]=o,e[7]=d):d=e[7];let h;e[8]!==d?(h=r.jsx("span",{className:"text-xs font-medium",children:d}),e[8]=d,e[9]=h):h=e[9];let u;return e[10]!==l||e[11]!==h?(u=r.jsxs(le,{type:"button",variant:"outline",onClick:l,className:"h-auto py-3 px-4 flex flex-col items-center gap-2",children:[c,h]}),e[10]=l,e[11]=h,e[12]=u):u=e[12],u}function Cj(t){const e=B.c(16),{url:s,serverName:n,agentId:i}=t,o=re(),[a,l]=A.useState(!1);let c;e[0]!==i||e[1]!==n||e[2]!==o||e[3]!==s?(c=async()=>{$e("agent_connect_action",{agent_id:i,action:"install_claude_code"});const p=C2(n),x=JSON.stringify({type:"http",url:s,headers:{"x-mesh-client":"Claude Code"}},null,2),v=`claude mcp add-json "${p}" '${x.replace(/'/g,"'\\''")}' --scope user`;await navigator.clipboard.writeText(v),l(!0),ge.success(o("virtualMcp.virtualMcpShareModal.claudeCodeCommandCopied")),setTimeout(()=>l(!1),2e3)},e[0]=i,e[1]=n,e[2]=o,e[3]=s,e[4]=c):c=e[4];const d=c;let h;e[5]!==a?(h=a?r.jsx(zt,{size:20,className:"text-success"}):r.jsx("img",{src:"/logos/Claude Code.svg",alt:"Claude Code",className:"h-5 w-5",style:{filter:"brightness(0) saturate(100%) invert(55%) sepia(31%) saturate(1264%) hue-rotate(331deg) brightness(92%) contrast(86%)"}}),e[5]=a,e[6]=h):h=e[6];let u;e[7]!==a||e[8]!==o?(u=o(a?"virtualMcp.virtualMcpShareModal.copied":"virtualMcp.virtualMcpShareModal.installOnClaudeCode"),e[7]=a,e[8]=o,e[9]=u):u=e[9];let f;e[10]!==u?(f=r.jsx("span",{className:"text-xs font-medium",children:u}),e[10]=u,e[11]=f):f=e[11];let m;return e[12]!==d||e[13]!==h||e[14]!==f?(m=r.jsxs(le,{type:"button",variant:"outline",onClick:d,className:"h-auto py-3 px-4 flex flex-col items-center gap-2",children:[h,f]}),e[12]=d,e[13]=h,e[14]=f,e[15]=m):m=e[15],m}function kj({virtualMcp:t}){const e=re(),s=Bs(),[n,i]=A.useState(null),[o,a]=A.useState(!1),[l,c]=A.useState(!1),d=t.id,h=t.title||`agent-${d.slice(0,8)}`,u=n?`bunx @decocms/typegen@latest --mcp ${d} --key ${n} --output client.ts`:`bunx @decocms/typegen@latest --mcp ${d} --key <api-key> --output client.ts`,f=async()=>{a(!0);try{const{key:p}=await s.call("API_KEY_CREATE",{name:`typegen-${h}`,permissions:{[d]:["*"]}});if(!p)throw new Error("No key in response");i(p),$e("agent_typegen_key_generated",{agent_id:d})}catch{$e("agent_typegen_key_failed",{agent_id:d}),ge.error(e("virtualMcp.virtualMcpShareModal.failedGenerateApiKey"))}finally{a(!1)}},m=async()=>{$e("agent_connect_action",{agent_id:d,action:"typegen_copy_command",has_api_key:!!n}),await navigator.clipboard.writeText(u),c(!0),ge.success(e("virtualMcp.virtualMcpShareModal.commandCopied")),setTimeout(()=>c(!1),2e3)};return r.jsxs("div",{className:"flex min-w-0 flex-col gap-3",children:[r.jsxs("div",{className:"flex items-start justify-between gap-3",children:[r.jsxs("div",{className:"flex flex-col gap-0.5",children:[r.jsx("h4",{className:"text-sm font-medium text-foreground",children:e("virtualMcp.virtualMcpShareModal.generateTypedClient")}),r.jsx("p",{className:"text-xs text-muted-foreground",children:e("virtualMcp.virtualMcpShareModal.generateTypedClientDescription")})]}),!n&&r.jsxs(le,{type:"button",variant:"outline",size:"sm",className:"shrink-0 gap-1.5",onClick:f,disabled:o,children:[o?r.jsx(et,{size:14,className:"animate-spin"}):r.jsx(b9,{size:14}),r.jsx("span",{children:e(o?"virtualMcp.virtualMcpShareModal.generating":"virtualMcp.virtualMcpShareModal.generateApiKey")})]})]}),n&&r.jsx("p",{className:"rounded-md border border-warning/20 bg-warning/10 px-3 py-2 text-xs text-warning",children:e("virtualMcp.virtualMcpShareModal.storeKeySecurely")}),r.jsx("p",{className:"text-xs font-medium text-muted-foreground",children:e("virtualMcp.virtualMcpShareModal.generateClientLabel")}),r.jsx("div",{className:"rounded-md border border-input bg-muted/50 px-3 py-2.5",children:r.jsxs("div",{className:"flex items-start gap-2",children:[r.jsx("code",{className:"min-w-0 flex-1 break-all font-mono text-xs text-muted-foreground",children:u}),r.jsx(le,{type:"button",variant:"ghost",size:"icon",className:"size-6 shrink-0",onClick:m,children:l?r.jsx(zt,{size:12,className:"text-success"}):r.jsx(Os,{size:12})})]})}),r.jsx("p",{className:"text-xs font-medium text-muted-foreground",children:e("virtualMcp.virtualMcpShareModal.runtimeVariables")}),r.jsx(Vj,{apiKey:n,agentId:d})]})}function Vj(t){const e=B.c(21),{apiKey:s,agentId:n}=t,[i,o]=A.useState(!1),a=window.location.origin,l=s?`MESH_API_KEY=${s}`:"MESH_API_KEY=<api-key>",c=`MESH_BASE_URL=${a}`,d=`${l}
|
|
9
|
+
${c}`;let h;e[0]!==n||e[1]!==s||e[2]!==d?(h=async()=>{$e("agent_connect_action",{agent_id:n,action:"typegen_copy_env",has_api_key:!!s}),await navigator.clipboard.writeText(d),o(!0),setTimeout(()=>o(!1),2e3)},e[0]=n,e[1]=s,e[2]=d,e[3]=h):h=e[3];const u=h,f=!s;let m;e[4]!==f?(m=ie({"opacity-50":f}),e[4]=f,e[5]=m):m=e[5];let p;e[6]!==l||e[7]!==m?(p=r.jsx("span",{className:m,children:l}),e[6]=l,e[7]=m,e[8]=p):p=e[8];let g,x;e[9]===Symbol.for("react.memo_cache_sentinel")?(g=r.jsx("br",{}),x=r.jsx("span",{children:c}),e[9]=g,e[10]=x):(g=e[9],x=e[10]);let v;e[11]!==p?(v=r.jsxs("code",{className:"min-w-0 flex-1 font-mono text-xs text-muted-foreground",children:[p,g,x]}),e[11]=p,e[12]=v):v=e[12];let b;e[13]!==i?(b=i?r.jsx(zt,{size:12,className:"text-success"}):r.jsx(Os,{size:12}),e[13]=i,e[14]=b):b=e[14];let _;e[15]!==u||e[16]!==b?(_=r.jsx(le,{type:"button",variant:"ghost",size:"icon",className:"size-6 shrink-0",onClick:u,children:b}),e[15]=u,e[16]=b,e[17]=_):_=e[17];let y;return e[18]!==v||e[19]!==_?(y=r.jsx("div",{className:"rounded-md border border-input bg-muted/50 px-3 py-2.5",children:r.jsxs("div",{className:"flex items-start gap-2",children:[v,_]})}),e[18]=v,e[19]=_,e[20]=y):y=e[20],y}function Nj(t){const e=B.c(3),{virtualMcp:s}=t;let n;e[0]===Symbol.for("react.memo_cache_sentinel")?(n=r.jsx("div",{className:"h-20 animate-pulse rounded-md bg-muted"}),e[0]=n):n=e[0];let i;return e[1]!==s?(i=r.jsx(A.Suspense,{fallback:n,children:r.jsx(kj,{virtualMcp:s})}),e[1]=s,e[2]=i):i=e[2],i}const Tj={self:["COLLECTION_THREADS_CREATE","COLLECTION_THREADS_GET","COLLECTION_THREAD_MESSAGES_LIST","COLLECTION_THREADS_LIST"]},Aj=3600*24*90;function Ej({virtualMcp:t}){const e=re(),s=Bs(),{org:n}=Fe(),[i,o]=A.useState(null),[a,l]=A.useState(!1),[c,d]=A.useState(!1),h=t.id,u=t.title||`agent-${h.slice(0,8)}`,m=[`MESH_BASE_URL=${window.location.origin}`,`MESH_ORG=${n.slug}`,`MESH_AGENT_ID=${h}`,`MESH_API_KEY=${i??"<api-key>"}`].join(`
|
|
10
|
+
`),p=async()=>{l(!0);try{const{key:x}=await s.call("API_KEY_CREATE",{name:`chat-bridge-${u}`,permissions:Tj,expiresIn:Aj});if(!x)throw new Error("No key in response");o(x),$e("agent_chat_bridge_key_generated",{agent_id:h})}catch{$e("agent_chat_bridge_key_failed",{agent_id:h}),ge.error(e("virtualMcp.virtualMcpShareModal.failedCreateApiKey"))}finally{l(!1)}},g=async()=>{$e("agent_connect_action",{agent_id:h,action:"chat_bridge_copy_env",has_api_key:!!i}),await navigator.clipboard.writeText(m),d(!0),ge.success(e("virtualMcp.virtualMcpShareModal.connectionDetailsCopied")),setTimeout(()=>d(!1),2e3)};return r.jsxs("div",{className:"flex min-w-0 flex-col gap-3",children:[r.jsxs("div",{className:"flex items-start justify-between gap-3",children:[r.jsxs("div",{className:"flex flex-col gap-0.5",children:[r.jsx("h4",{className:"text-sm font-medium text-foreground",children:e("virtualMcp.virtualMcpShareModal.callFromYourApp")}),r.jsx("p",{className:"text-xs text-muted-foreground",children:e("virtualMcp.virtualMcpShareModal.callFromYourAppDescription")})]}),!i&&r.jsxs(le,{type:"button",variant:"outline",size:"sm",className:"shrink-0 gap-1.5",onClick:p,disabled:a,children:[a?r.jsx(et,{size:14,className:"animate-spin"}):r.jsx(b9,{size:14}),r.jsx("span",{children:e(a?"virtualMcp.virtualMcpShareModal.creating":"virtualMcp.virtualMcpShareModal.createApiKey")})]})]}),i&&r.jsx("p",{className:"rounded-md border border-warning/20 bg-warning/10 px-3 py-2 text-xs text-warning",children:e("virtualMcp.virtualMcpShareModal.storeKeySecurely")}),r.jsx("p",{className:"text-xs font-medium text-muted-foreground",children:e("virtualMcp.virtualMcpShareModal.connectionDetails")}),r.jsx("div",{className:"rounded-md border border-input bg-muted/50 px-3 py-2.5",children:r.jsxs("div",{className:"flex items-start gap-2",children:[r.jsx("code",{className:"min-w-0 flex-1 whitespace-pre-wrap break-all font-mono text-xs text-muted-foreground",children:m}),r.jsx(le,{type:"button",variant:"ghost",size:"icon",className:"size-6 shrink-0",onClick:g,children:c?r.jsx(zt,{size:12,className:"text-success"}):r.jsx(Os,{size:12})})]})})]})}function Pj(t){const e=B.c(3),{virtualMcp:s}=t;let n;e[0]===Symbol.for("react.memo_cache_sentinel")?(n=r.jsx("div",{className:"h-20 animate-pulse rounded-md bg-muted"}),e[0]=n):n=e[0];let i;return e[1]!==s?(i=r.jsx(A.Suspense,{fallback:n,children:r.jsx(Ej,{virtualMcp:s})}),e[1]=s,e[2]=i):i=e[2],i}function Rj(t){const e=B.c(49),{open:s,onOpenChange:n,virtualMcp:i}=t,o=re(),{org:a}=Fe(),l=`/api/${a.slug}/mcp/virtual-mcp/${i.id}`;let c;e[0]!==l?(c=new URL(l,window.location.origin),e[0]=l,e[1]=c):c=e[1];const d=c;let h;e[2]!==i.id||e[3]!==i.title?(h=i.title||`agent-${i.id?.slice(0,8)??"default"}`,e[2]=i.id,e[3]=i.title,e[4]=h):h=e[4];const u=h,f=Cr();let m;e[5]!==i.id||e[6]!==d.href?(m=r.jsx(wj,{url:d.href,agentId:i.id}),e[5]=i.id,e[6]=d.href,e[7]=m):m=e[7];let p,g;e[8]!==u||e[9]!==i.id||e[10]!==d.href?(p=r.jsx(jj,{url:d.href,serverName:u,agentId:i.id}),g=r.jsx(Cj,{url:d.href,serverName:u,agentId:i.id}),e[8]=u,e[9]=i.id,e[10]=d.href,e[11]=p,e[12]=g):(p=e[11],g=e[12]);let x;e[13]!==m||e[14]!==p||e[15]!==g?(x=r.jsx("div",{className:"flex flex-col gap-3 pt-2",children:r.jsxs("div",{className:"grid grid-cols-3 gap-2",children:[m,p,g]})}),e[13]=m,e[14]=p,e[15]=g,e[16]=x):x=e[16];let v;e[17]===Symbol.for("react.memo_cache_sentinel")?(v=r.jsx("div",{className:"border-t border-border"}),e[17]=v):v=e[17];let b;e[18]!==i?(b=r.jsx(Nj,{virtualMcp:i}),e[18]=i,e[19]=b):b=e[19];let _;e[20]===Symbol.for("react.memo_cache_sentinel")?(_=r.jsx("div",{className:"border-t border-border"}),e[20]=_):_=e[20];let y;e[21]!==i?(y=r.jsx(Pj,{virtualMcp:i}),e[21]=i,e[22]=y):y=e[22];let L;e[23]!==y||e[24]!==x||e[25]!==b?(L=r.jsxs("div",{className:"flex flex-col gap-6",children:[x,v,b,_,y]}),e[23]=y,e[24]=x,e[25]=b,e[26]=L):L=e[26];const w=L;if(f){let V;e[27]!==o?(V=o("virtualMcp.virtualMcpShareModal.connect"),e[27]=o,e[28]=V):V=e[28];let E;e[29]!==V?(E=r.jsx(Cm,{className:"mt-4 mb-4 text-base font-semibold",children:V}),e[29]=V,e[30]=E):E=e[30];let T;e[31]!==w||e[32]!==E?(T=r.jsx(km,{children:r.jsxs("div",{className:"flex-1 overflow-y-auto px-4 pb-6 [touch-action:pan-y]",children:[E,w]})}),e[31]=w,e[32]=E,e[33]=T):T=e[33];let k;return e[34]!==n||e[35]!==s||e[36]!==T?(k=r.jsx(Vm,{open:s,onOpenChange:n,children:T}),e[34]=n,e[35]=s,e[36]=T,e[37]=k):k=e[37],k}let j;e[38]!==o?(j=o("virtualMcp.virtualMcpShareModal.connect"),e[38]=o,e[39]=j):j=e[39];let S;e[40]!==j?(S=r.jsx(ms,{children:r.jsx(ps,{children:j})}),e[40]=j,e[41]=S):S=e[41];let C;e[42]!==w||e[43]!==S?(C=r.jsxs(es,{className:"max-h-[80vh] overflow-y-auto sm:max-w-2xl",children:[S,w]}),e[42]=w,e[43]=S,e[44]=C):C=e[44];let N;return e[45]!==n||e[46]!==s||e[47]!==C?(N=r.jsx(ts,{open:s,onOpenChange:n,children:C}),e[45]=n,e[46]=s,e[47]=C,e[48]=N):N=e[48],N}function Dj(t){const e=B.c(50),{virtualMcp:s}=t,n=re(),i=ta(),o=X0(),[a,l]=A.useState(!1);let c,d,h,u,f,m,p,g,x;if(e[0]!==o||e[1]!==i||e[2]!==n||e[3]!==s.id||e[4]!==s.metadata){x=Symbol.for("react.early_return_sentinel");e:{const j=u9(i);if(nl(s.id)||sn(s.metadata)||j.has(s.id)){x=null;break e}let S;e[14]!==i||e[15]!==s.id?(S=(i??[]).find(I=>I.metadata?.liveAgentId===s.id)??null,e[14]=i,e[15]=s.id,e[16]=S):S=e[16];const C=S,N=C?.id??null;let V;e[17]!==o.update?(V=(I,M)=>o.update.mutateAsync({id:I,data:{metadata:{liveAgentId:M}}}).catch(Mj),e[17]=o.update,e[18]=V):V=e[18];const E=V;let T;e[19]!==E||e[20]!==s.id?(T=I=>{E(I,s.id)},e[19]=E,e[20]=s.id,e[21]=T):T=e[21],h=T;let k;e[22]!==N||e[23]!==E?(k=()=>{N&&E(N,null)},e[22]=N,e[23]=E,e[24]=k):k=e[24];const R=k,P=(i??[]).filter(I=>I.id!==s.id&&sn(I.metadata)&&!j.has(I.id));p="flex flex-col gap-3";let D;e[25]!==n?(D=n("devAgent.devAgentSetup.title"),e[25]=n,e[26]=D):D=e[26],e[27]!==D?(g=r.jsx("h2",{className:"text-sm font-medium text-foreground",children:D}),e[27]=D,e[28]=g):g=e[28],d=vl,m="p-6 gap-4",c=Mo,u="p-0 space-y-4",f=N?r.jsxs("div",{className:"flex items-center justify-between gap-3",children:[r.jsxs("div",{className:"flex flex-col gap-0.5 min-w-0",children:[r.jsx("span",{className:"text-sm text-foreground truncate",children:C?C.title:N}),r.jsx("span",{className:"text-xs text-muted-foreground",children:n("devAgent.devAgentSetup.linkedDescription")})]}),r.jsx(le,{variant:"outline",size:"sm",className:"shrink-0",onClick:R,children:n("devAgent.devAgentSetup.unlinkButton")})]}):r.jsxs(r.Fragment,{children:[r.jsx("span",{className:"text-xs text-muted-foreground",children:n("devAgent.devAgentSetup.linkDescription")}),r.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[r.jsxs(le,{variant:"outline",size:"sm",className:"gap-2",onClick:()=>l(!0),children:[r.jsx($o,{className:"size-4"}),n("devAgent.devAgentSetup.importButton")]}),P.length>0?r.jsxs(Qt,{onValueChange:h,children:[r.jsx(Jt,{size:"sm",className:"w-56",children:r.jsx(as,{placeholder:n("devAgent.devAgentSetup.selectPlaceholder")})}),r.jsx(Xt,{children:P.map(Ij)})]}):null]})]})}e[0]=o,e[1]=i,e[2]=n,e[3]=s.id,e[4]=s.metadata,e[5]=c,e[6]=d,e[7]=h,e[8]=u,e[9]=f,e[10]=m,e[11]=p,e[12]=g,e[13]=x}else c=e[5],d=e[6],h=e[7],u=e[8],f=e[9],m=e[10],p=e[11],g=e[12],x=e[13];if(x!==Symbol.for("react.early_return_sentinel"))return x;let v;e[29]!==c||e[30]!==u||e[31]!==f?(v=r.jsx(c,{className:u,children:f}),e[29]=c,e[30]=u,e[31]=f,e[32]=v):v=e[32];let b;e[33]!==d||e[34]!==m||e[35]!==v?(b=r.jsx(d,{className:m,children:v}),e[33]=d,e[34]=m,e[35]=v,e[36]=b):b=e[36];let _;e[37]!==n?(_=n("devAgent.devAgentSetup.importDialogTitle"),e[37]=n,e[38]=_):_=e[38];let y;e[39]!==h?(y=j=>{const{virtualMcpId:S}=j;l(!1),h(S)},e[39]=h,e[40]=y):y=e[40];let L;e[41]!==a||e[42]!==y||e[43]!==_?(L=r.jsx(k2,{open:a,onOpenChange:l,title:_,onImportComplete:y}),e[41]=a,e[42]=y,e[43]=_,e[44]=L):L=e[44];let w;return e[45]!==L||e[46]!==p||e[47]!==g||e[48]!==b?(w=r.jsxs("div",{className:p,children:[g,b,L]}),e[45]=L,e[46]=p,e[47]=g,e[48]=b,e[49]=w):w=e[49],w}function Ij(t){return r.jsx(vt,{value:t.id,children:t.title},t.id)}function Mj(){}const Oj=/^[A-Za-z_][A-Za-z0-9_]*$/;function $j(t){const e={},s=t.split(/\r?\n/);for(let n=0;n<s.length;n++){let i=(s[n]??"").trim();if(!i||i.startsWith("#"))continue;i.startsWith("export ")&&(i=i.slice(7).trim());const o=i.indexOf("=");if(o<0)throw new Error(`Line ${n+1}: missing '='`);const a=i.slice(0,o).trim();if(!Oj.test(a))throw new Error(`Line ${n+1}: invalid key "${a}"`);let l=i.slice(o+1).trim();l.length>=2&&(l.startsWith('"')&&l.endsWith('"')||l.startsWith("'")&&l.endsWith("'"))&&(l=l.slice(1,-1)),e[a]=l}return e}const Bj=/^[A-Za-z0-9_.-]+$/;function Fj(t){const e=B.c(27),{control:s,form:n,virtualMcpId:i,orgSlug:o}=t,a=re();let l;e[0]!==a?(l=a("sandbox.envVarsField.title"),e[0]=a,e[1]=l):l=e[1];let c;e[2]!==l?(c=r.jsx("div",{className:"flex items-baseline justify-between gap-2",children:r.jsx(lt,{className:"font-normal text-foreground",children:l})}),e[2]=l,e[3]=c):c=e[3];let d;e[4]!==a?(d=a("sandbox.envVarsField.description"),e[4]=a,e[5]=d):d=e[5];let h;e[6]!==d?(h=r.jsx("p",{className:"text-xs text-muted-foreground",children:d}),e[6]=d,e[7]=h):h=e[7];let u;e[8]!==s||e[9]!==n||e[10]!==o||e[11]!==i?(u=r.jsx(zj,{control:s,form:n,virtualMcpId:i,orgSlug:o}),e[8]=s,e[9]=n,e[10]=o,e[11]=i,e[12]=u):u=e[12];let f;e[13]!==a?(f=v=>{const{error:b}=v;return r.jsx("div",{className:"rounded-md border border-destructive/40 bg-destructive/5 px-3 py-2 text-xs text-destructive",children:b?.message??a("sandbox.envVarsField.failedToLoadSecrets")})},e[13]=a,e[14]=f):f=e[14];let m;e[15]===Symbol.for("react.memo_cache_sentinel")?(m=r.jsx(Rt,{className:"h-9 w-full"}),e[15]=m):m=e[15];let p;e[16]!==s||e[17]!==n?(p=r.jsx(A.Suspense,{fallback:m,children:r.jsx(Uj,{control:s,form:n})}),e[16]=s,e[17]=n,e[18]=p):p=e[18];let g;e[19]!==f||e[20]!==p?(g=r.jsx(_s,{fallback:f,children:p}),e[19]=f,e[20]=p,e[21]=g):g=e[21];let x;return e[22]!==c||e[23]!==h||e[24]!==u||e[25]!==g?(x=r.jsxs("div",{className:"space-y-2",children:[c,h,u,g]}),e[22]=c,e[23]=h,e[24]=u,e[25]=g,e[26]=x):x=e[26],x}function zj(t){const e=B.c(35),{control:s,form:n,virtualMcpId:i,orgSlug:o}=t,a=re(),c=Di.useSession().data?.user?.id,d="metadata.runtime.env",h="metadata.sandboxMap";let u;e[0]!==n?(u=()=>JSON.stringify(zh(n.getValues(d))),e[0]=n,e[1]=u):u=e[1];const[f,m]=A.useState(u);let p;e[2]!==s?(p={control:s,name:d},e[2]=s,e[3]=p):p=e[3];const g=gm(p);let x;e[4]!==g?(x=JSON.stringify(zh(g)),e[4]=g,e[5]=x):x=e[5];const v=x,b=v!==f;let _;e[6]!==n?(_=n.getValues(h),e[6]=n,e[7]=_):_=e[7];const y=_;let L;e[8]!==y||e[9]!==c?(L=c?Object.keys(y?.[c]??{}):[],e[8]=y,e[9]=c,e[10]=L):L=e[10];const w=L,j=w.length>0,[S,C]=A.useState(!1);if(!b||!j)return null;let N;e[11]!==v||e[12]!==o||e[13]!==a||e[14]!==w||e[15]!==i?(N=async()=>{C(!0);const M=await Promise.allSettled(w.map(async F=>{const $=`/api/${encodeURIComponent(o)}/sandbox/${encodeURIComponent(i)}/${encodeURIComponent(F)}/setup/start`,z=await fetch($,{method:"POST"});if(!z.ok){const K=await z.text().catch(()=>z.statusText);throw new Error(K||z.statusText)}}));C(!1);const O=M.filter(Kj).length;O===0?(m(v),ge.success(w.length===1?a("sandbox.envVarsField.restartedSingle"):a("sandbox.envVarsField.restartedMultiple",{count:w.length}))):ge.error(a("sandbox.envVarsField.restartFailed",{failed:O,total:w.length}))},e[11]=v,e[12]=o,e[13]=a,e[14]=w,e[15]=i,e[16]=N):N=e[16];const V=N;let E;e[17]===Symbol.for("react.memo_cache_sentinel")?(E=r.jsx(Sr,{className:"size-3.5 shrink-0"}),e[17]=E):E=e[17];let T;e[18]!==a?(T=a("sandbox.envVarsField.sandboxRunningNotice"),e[18]=a,e[19]=T):T=e[19];let k;e[20]!==T?(k=r.jsxs("div",{className:"flex min-w-0 items-center gap-2 text-warning",children:[E,r.jsx("span",{className:"truncate",children:T})]}),e[20]=T,e[21]=k):k=e[21];let R;e[22]!==S?(R=S?r.jsx(et,{className:"size-3.5 animate-spin"}):r.jsx(dr,{className:"size-3.5"}),e[22]=S,e[23]=R):R=e[23];let P;e[24]!==S||e[25]!==a?(P=a(S?"sandbox.envVarsField.restarting":"sandbox.envVarsField.restartDev"),e[24]=S,e[25]=a,e[26]=P):P=e[26];let D;e[27]!==V||e[28]!==S||e[29]!==R||e[30]!==P?(D=r.jsxs(le,{type:"button",variant:"outline",size:"sm",onClick:V,disabled:S,className:"shrink-0",children:[R,P]}),e[27]=V,e[28]=S,e[29]=R,e[30]=P,e[31]=D):D=e[31];let I;return e[32]!==D||e[33]!==k?(I=r.jsxs("div",{className:"flex items-center justify-between gap-3 rounded-md border border-warning/20 bg-warning/10 px-3 py-2 text-xs",children:[k,D]}),e[32]=D,e[33]=k,e[34]=I):I=e[34],I}function Kj(t){return t.status==="rejected"}function Uj(t){const e=B.c(62),{control:s,form:n}=t,i=re(),o="metadata.runtime.env";let a;e[0]!==s?(a={control:s,name:o},e[0]=s,e[1]=a):a=e[1];const l=fx(a),{fields:c,append:d,remove:h}=l;let u;e[2]!==n?(u=(O,F)=>{n.setValue(`${o}.${O}`,F,{shouldDirty:!0,shouldTouch:!0})},e[2]=n,e[3]=u):u=e[3];const f=u,m=Kb();let p;if(e[4]!==m){p=new Map;for(const O of m)p.set(O.id,O);e[4]=m,e[5]=p}else p=e[5];const[g,x]=A.useState(null);let v;e[6]!==d?(v=()=>{d({key:"",kind:"literal",value:""})},e[6]=d,e[7]=v):v=e[7];const b=v;let _;e[8]!==d||e[9]!==n||e[10]!==i?(_=async()=>{let O;try{O=await navigator.clipboard.readText()}catch{ge.error(i("sandbox.envVarsField.clipboardReadFailed"));return}if(!O.trim()){ge.error(i("sandbox.envVarsField.clipboardEmpty"));return}let F;try{F=$j(O)}catch(H){const W=H;ge.error(W.message);return}const $=Object.entries(F);if($.length===0){ge.error(i("sandbox.envVarsField.nothingToAdd"));return}const z=n.getValues(o)??[],K=new Set;for(const H of z){const W=(H.key??"").trim();W&&K.add(W)}let X=0,J=0;for(const[H,W]of $){if(K.has(H)){J++;continue}d({key:H,kind:"literal",value:W}),K.add(H),X++}X===0&&J>0?ge.message(i("sandbox.envVarsField.allKeysExist",{count:J})):ge.success(J>0?i("sandbox.envVarsField.addedWithSkipped",{added:X,skipped:J}):i("sandbox.envVarsField.added",{added:X}))},e[8]=d,e[9]=n,e[10]=i,e[11]=_):_=e[11];const y=_;let L;if(e[12]!==s||e[13]!==c||e[14]!==n||e[15]!==h||e[16]!==p||e[17]!==m||e[18]!==f){let O;e[20]!==s||e[21]!==n||e[22]!==h||e[23]!==p||e[24]!==m||e[25]!==f?(O=(F,$)=>r.jsx("li",{className:"rounded-md border border-border bg-background",children:r.jsx(Hj,{index:$,control:s,form:n,onUpdateEntry:f,fieldPath:o,secrets:m,secretById:p,onSaveAsSecret:(z,K)=>x({kind:"save-literal",index:$,presetKey:z,presetValue:K}),onCreateNewSecret:z=>x({kind:"create-new",index:$,presetKey:z}),onRemove:()=>h($)})},F.id),e[20]=s,e[21]=n,e[22]=h,e[23]=p,e[24]=m,e[25]=f,e[26]=O):O=e[26],L=c.map(O),e[12]=s,e[13]=c,e[14]=n,e[15]=h,e[16]=p,e[17]=m,e[18]=f,e[19]=L}else L=e[19];let w;e[27]!==L?(w=r.jsx("ul",{className:"space-y-2",children:L}),e[27]=L,e[28]=w):w=e[28];let j;e[29]===Symbol.for("react.memo_cache_sentinel")?(j=r.jsx(kt,{className:"size-3.5"}),e[29]=j):j=e[29];let S;e[30]!==i?(S=i("sandbox.envVarsField.addEnvVar"),e[30]=i,e[31]=S):S=e[31];let C;e[32]!==b||e[33]!==S?(C=r.jsxs(le,{type:"button",variant:"outline",size:"sm",onClick:b,className:"flex-1",children:[j,S]}),e[32]=b,e[33]=S,e[34]=C):C=e[34];let N;e[35]!==i?(N=i("sandbox.envVarsField.pasteDotenvAriaLabel"),e[35]=i,e[36]=N):N=e[36];let V;e[37]===Symbol.for("react.memo_cache_sentinel")?(V=r.jsx($m,{className:"size-3.5"}),e[37]=V):V=e[37];let E;e[38]!==i?(E=i("sandbox.envVarsField.pasteDotenv"),e[38]=i,e[39]=E):E=e[39];let T;e[40]!==y||e[41]!==N||e[42]!==E?(T=r.jsx(Ke,{asChild:!0,children:r.jsxs(le,{type:"button",variant:"outline",size:"sm",onClick:y,"aria-label":N,children:[V,E]})}),e[40]=y,e[41]=N,e[42]=E,e[43]=T):T=e[43];let k;e[44]!==i?(k=i("sandbox.envVarsField.pasteDotenvTooltip"),e[44]=i,e[45]=k):k=e[45];let R;e[46]!==k?(R=r.jsx(Ue,{children:k}),e[46]=k,e[47]=R):R=e[47];let P;e[48]!==T||e[49]!==R?(P=r.jsxs(He,{children:[T,R]}),e[48]=T,e[49]=R,e[50]=P):P=e[50];let D;e[51]!==P||e[52]!==C?(D=r.jsxs("div",{className:"flex items-center gap-2",children:[C,P]}),e[51]=P,e[52]=C,e[53]=D):D=e[53];let I;e[54]!==g||e[55]!==n||e[56]!==f?(I=g!==null?r.jsx(Gj,{mode:g,onClose:()=>x(null),onSaved:O=>{const F=n.getValues(`${o}.${g.index}.key`)?.trim()??"";f(g.index,{key:F,kind:"secret",secretId:O}),x(null)}}):null,e[54]=g,e[55]=n,e[56]=f,e[57]=I):I=e[57];let M;return e[58]!==D||e[59]!==I||e[60]!==w?(M=r.jsxs("div",{className:"space-y-2",children:[w,D,I]}),e[58]=D,e[59]=I,e[60]=w,e[61]=M):M=e[61],M}function Hj(t){const e=B.c(77),{index:s,control:n,form:i,onUpdateEntry:o,fieldPath:a,secrets:l,secretById:c,onSaveAsSecret:d,onCreateNewSecret:h,onRemove:u}=t,f=re(),m=`${a}.${s}.key`,p=`${a}.${s}.value`,g=`${a}.${s}.secretId`,x=`${a}.${s}.kind`;let v;e[0]!==n||e[1]!==x?(v={control:n,name:x},e[0]=n,e[1]=x,e[2]=v):v=e[2];const _=gm(v)==="secret"?"secret":"literal";let y;e[3]!==i||e[4]!==s||e[5]!==m||e[6]!==d||e[7]!==o||e[8]!==p?(y=W=>{const U=i.getValues(m)?.trim()??"";if(W==="literal"){o(s,{key:U,kind:"literal",value:""});return}const Q=i.getValues(p)??"";if(Q.length>0){d(U,Q);return}o(s,{key:U,kind:"secret",secretId:""})},e[3]=i,e[4]=s,e[5]=m,e[6]=d,e[7]=o,e[8]=p,e[9]=y):y=e[9];const L=y;let w;e[10]!==s||e[11]!==f?(w=W=>{const{field:U}=W,Q=(U.value??"").trim(),q=Q.length>0&&!ql.test(Q);return r.jsxs("div",{className:"space-y-1",children:[r.jsx(rt,{...U,value:U.value??"",placeholder:f("sandbox.envVarsField.keyPlaceholder"),spellCheck:!1,autoComplete:"off",autoCapitalize:"off",autoCorrect:"off",className:ie("font-mono",q&&"border-destructive focus-visible:ring-destructive"),"aria-invalid":q,"aria-label":f("sandbox.envVarsField.envVarKeyLabel",{index:s+1}),onBlur:Z=>{const Y=Z.target.value.trim();U.onChange(Y),U.onBlur()}}),q?r.jsx("p",{className:"text-[11px] text-destructive",children:f("sandbox.envVarsField.invalidKeyMessage")}):null]})},e[10]=s,e[11]=f,e[12]=w):w=e[12];let j;e[13]!==n||e[14]!==m||e[15]!==w?(j=r.jsx("div",{className:"flex-1 min-w-0",children:r.jsx(ys,{control:n,name:m,render:w})}),e[13]=n,e[14]=m,e[15]=w,e[16]=j):j=e[16];let S;e[17]!==L?(S=W=>L(W),e[17]=L,e[18]=S):S=e[18];let C;e[19]===Symbol.for("react.memo_cache_sentinel")?(C=r.jsx(Jt,{className:"h-9 w-[110px]",children:r.jsx(as,{})}),e[19]=C):C=e[19];let N;e[20]===Symbol.for("react.memo_cache_sentinel")?(N=r.jsx(b9,{className:"size-3.5"}),e[20]=N):N=e[20];let V;e[21]!==f?(V=f("sandbox.envVarsField.literal"),e[21]=f,e[22]=V):V=e[22];let E;e[23]!==V?(E=r.jsx(vt,{value:"literal",children:r.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[N,V]})}),e[23]=V,e[24]=E):E=e[24];let T;e[25]===Symbol.for("react.memo_cache_sentinel")?(T=r.jsx(H0,{className:"size-3.5"}),e[25]=T):T=e[25];let k;e[26]!==f?(k=f("sandbox.envVarsField.secret"),e[26]=f,e[27]=k):k=e[27];let R;e[28]!==k?(R=r.jsx(vt,{value:"secret",children:r.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[T,k]})}),e[28]=k,e[29]=R):R=e[29];let P;e[30]!==R||e[31]!==E?(P=r.jsxs(Xt,{children:[E,R]}),e[30]=R,e[31]=E,e[32]=P):P=e[32];let D;e[33]!==_||e[34]!==P||e[35]!==S?(D=r.jsx("div",{className:"shrink-0",children:r.jsxs(Qt,{value:_,onValueChange:S,children:[C,P]})}),e[33]=_,e[34]=P,e[35]=S,e[36]=D):D=e[36];let I;e[37]!==n||e[38]!==i||e[39]!==s||e[40]!==m||e[41]!==_||e[42]!==h||e[43]!==c||e[44]!==g||e[45]!==l||e[46]!==f||e[47]!==p?(I=r.jsx("div",{className:"flex flex-[2] min-w-0 items-center gap-1",children:_==="literal"?r.jsx(ys,{control:n,name:p,render:W=>{const{field:U}=W;return r.jsx(rt,{...U,value:U.value??"",type:"password",placeholder:f("sandbox.envVarsField.valuePlaceholder"),spellCheck:!1,autoComplete:"off",className:"font-mono","aria-label":f("sandbox.envVarsField.envVarValueLabel",{index:s+1}),onBlur:Q=>{U.onChange(Q.target.value),U.onBlur()}})}}):r.jsxs(r.Fragment,{children:[r.jsx(ys,{control:n,name:g,render:W=>{const{field:U}=W;return r.jsxs(Qt,{value:U.value||"",onValueChange:Q=>U.onChange(Q),children:[r.jsx(Jt,{className:ie("h-9 w-full",!U.value&&"text-muted-foreground"),children:r.jsx(as,{placeholder:f("sandbox.envVarsField.pickSecretPlaceholder"),children:r.jsx(qj,{field:U,secretById:c})})}),r.jsx(Xt,{children:l.length===0?r.jsx("div",{className:"px-2 py-2 text-xs text-muted-foreground",children:f("sandbox.envVarsField.noSecretsYet")}):l.map(Wj)})]})}}),r.jsxs(He,{children:[r.jsx(Ke,{asChild:!0,children:r.jsx(le,{type:"button",variant:"ghost",size:"icon","aria-label":f("sandbox.envVarsField.createNewSecretAriaLabel"),onClick:()=>{const W=i.getValues(m)?.trim()??"";h(W)},children:r.jsx(kt,{className:"size-3.5"})})}),r.jsx(Ue,{children:f("sandbox.envVarsField.createNewSecret")})]})]})}),e[37]=n,e[38]=i,e[39]=s,e[40]=m,e[41]=_,e[42]=h,e[43]=c,e[44]=g,e[45]=l,e[46]=f,e[47]=p,e[48]=I):I=e[48];let M;e[49]!==i||e[50]!==m||e[51]!==_||e[52]!==d||e[53]!==f||e[54]!==p?(M=_==="literal"?r.jsxs(He,{children:[r.jsx(Ke,{asChild:!0,children:r.jsx(le,{type:"button",variant:"ghost",size:"icon","aria-label":f("sandbox.envVarsField.saveAsSecretAriaLabel"),onClick:()=>{const W=i.getValues(m)?.trim()??"",U=i.getValues(p)??"";d(W,U)},children:r.jsx(s9,{className:"size-3.5"})})}),r.jsx(Ue,{children:f("sandbox.envVarsField.saveAsSecret")})]}):null,e[49]=i,e[50]=m,e[51]=_,e[52]=d,e[53]=f,e[54]=p,e[55]=M):M=e[55];let O;e[56]!==f?(O=f("sandbox.envVarsField.removeEnvVarAriaLabel"),e[56]=f,e[57]=O):O=e[57];let F;e[58]===Symbol.for("react.memo_cache_sentinel")?(F=r.jsx(Ns,{className:"size-3.5"}),e[58]=F):F=e[58];let $;e[59]!==u||e[60]!==O?($=r.jsx(Ke,{asChild:!0,children:r.jsx(le,{type:"button",variant:"ghost",size:"icon","aria-label":O,onClick:u,children:F})}),e[59]=u,e[60]=O,e[61]=$):$=e[61];let z;e[62]!==f?(z=f("sandbox.envVarsField.remove"),e[62]=f,e[63]=z):z=e[63];let K;e[64]!==z?(K=r.jsx(Ue,{children:z}),e[64]=z,e[65]=K):K=e[65];let X;e[66]!==$||e[67]!==K?(X=r.jsxs(He,{children:[$,K]}),e[66]=$,e[67]=K,e[68]=X):X=e[68];let J;e[69]!==M||e[70]!==X?(J=r.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[M,X]}),e[69]=M,e[70]=X,e[71]=J):J=e[71];let H;return e[72]!==D||e[73]!==I||e[74]!==J||e[75]!==j?(H=r.jsxs("div",{className:"flex flex-col gap-2 p-2 sm:flex-row sm:items-center",children:[j,D,I,J]}),e[72]=D,e[73]=I,e[74]=J,e[75]=j,e[76]=H):H=e[76],H}function Wj(t){return r.jsx(vt,{value:t.id,children:r.jsxs("span",{className:"inline-flex items-center gap-2",children:[r.jsx(s3,{scope:t.scope}),r.jsx("span",{className:"font-mono",children:t.name})]})},t.id)}function qj(t){const e=B.c(15),{field:s,secretById:n}=t,i=re(),o=s.value||"";if(!o)return null;let a;e[0]!==o||e[1]!==n?(a=n.get(o),e[0]=o,e[1]=n,e[2]=a):a=e[2];const l=a;if(!l){let u;e[3]!==o||e[4]!==i?(u=i("sandbox.envVarsField.missingSecret",{id:o}),e[3]=o,e[4]=i,e[5]=u):u=e[5];let f;return e[6]!==u?(f=r.jsx("span",{className:"text-destructive",children:u}),e[6]=u,e[7]=f):f=e[7],f}let c;e[8]!==l.scope?(c=r.jsx(s3,{scope:l.scope}),e[8]=l.scope,e[9]=c):c=e[9];let d;e[10]!==l.name?(d=r.jsx("span",{className:"truncate font-mono",children:l.name}),e[10]=l.name,e[11]=d):d=e[11];let h;return e[12]!==c||e[13]!==d?(h=r.jsxs("span",{className:"inline-flex items-center gap-1.5 truncate",children:[c,d]}),e[12]=c,e[13]=d,e[14]=h):h=e[14],h}function s3(t){const e=B.c(2),{scope:s}=t,n=s==="user"?zb:nc;let i;return e[0]!==n?(i=r.jsx(n,{className:"size-3 text-muted-foreground"}),e[0]=n,e[1]=i):i=e[1],i}function Gj({mode:t,onClose:e,onSaved:s}){const n=re(),i=t.kind==="save-literal"?t.presetValue:"",o=t.presetKey,[a,l]=A.useState(()=>Yj(o)),[c,d]=A.useState("organization"),[h,u]=A.useState(i),[f,m]=A.useState(""),p=Ub(),g=a.trim(),x=h.length>0&&g.length>0&&Bj.test(g),v=async y=>{if(y.preventDefault(),!!x)try{const L=await p.mutateAsync({scope:c,name:g,value:h,description:f.trim()||void 0});ge.success(n("sandbox.envVarsField.secretSaved",{name:L.name})),s(L.id)}catch(L){ge.error(L instanceof Error?L.message:n("sandbox.envVarsField.failedToSaveSecret"))}},b=t.kind==="save-literal"?n("sandbox.envVarsField.saveValueAsSecretTitle"):n("sandbox.envVarsField.createNewSecretTitle"),_=t.kind==="save-literal"?n("sandbox.envVarsField.saveValueAsSecretDescription"):n("sandbox.envVarsField.createNewSecretDescription");return r.jsx(ts,{open:!0,onOpenChange:y=>{y||e()},children:r.jsxs(es,{className:"sm:max-w-md",children:[r.jsxs(ms,{children:[r.jsx(ps,{children:b}),r.jsx(oi,{children:_})]}),r.jsxs("form",{onSubmit:v,className:"space-y-4",children:[r.jsxs("div",{className:"space-y-1.5",children:[r.jsx(lt,{htmlFor:"save-secret-scope",children:n("sandbox.envVarsField.scopeLabel")}),r.jsxs(Qt,{value:c,onValueChange:y=>d(y),children:[r.jsx(Jt,{id:"save-secret-scope",children:r.jsx(as,{})}),r.jsxs(Xt,{children:[r.jsx(vt,{value:"organization",children:n("sandbox.envVarsField.scopeOrganization")}),r.jsx(vt,{value:"user",children:n("sandbox.envVarsField.scopePrivate")})]})]})]}),r.jsxs("div",{className:"space-y-1.5",children:[r.jsx(lt,{htmlFor:"save-secret-name",children:n("sandbox.envVarsField.nameLabel")}),r.jsx(rt,{id:"save-secret-name",value:a,onChange:y=>l(y.target.value),placeholder:n("sandbox.envVarsField.namePlaceholder"),autoComplete:"off",required:!0}),r.jsx("p",{className:"text-xs text-muted-foreground",children:n("sandbox.envVarsField.nameHelperText")})]}),r.jsxs("div",{className:"space-y-1.5",children:[r.jsx(lt,{htmlFor:"save-secret-value",children:n("sandbox.envVarsField.valueLabel")}),r.jsx(rt,{id:"save-secret-value",type:"password",value:h,onChange:y=>u(y.target.value),placeholder:n("sandbox.envVarsField.secretValuePlaceholder"),autoComplete:"new-password",required:!0})]}),r.jsxs("div",{className:"space-y-1.5",children:[r.jsx(lt,{htmlFor:"save-secret-description",children:n("sandbox.envVarsField.descriptionLabel")}),r.jsx(gr,{id:"save-secret-description",value:f,onChange:y=>m(y.target.value),rows:2,placeholder:n("sandbox.envVarsField.descriptionPlaceholder")})]}),r.jsxs(Mi,{children:[r.jsx(le,{type:"button",variant:"outline",onClick:e,disabled:p.isPending,children:n("sandbox.envVarsField.cancel")}),r.jsx(le,{type:"submit",disabled:!x||p.isPending,children:p.isPending?n("sandbox.envVarsField.saving"):n("sandbox.envVarsField.saveSecret")})]})]})]})})}function zh(t){if(!Array.isArray(t))return[];const e=[];for(const s of t){if(!s||typeof s!="object")continue;const n=s,i=(n.key??"").trim();if(!(!i||!ql.test(i))){if(n.kind==="literal"){e.push({key:i,kind:"literal",value:n.value??""});continue}n.kind==="secret"&&n.secretId&&e.push({key:i,kind:"secret",secretId:n.secretId})}}return e}function Yj(t){const e=t.trim();return e&&ql.test(e)?e:""}function Jj(t){const e=B.c(21),{repo:s,className:n}=t,i=re();let o;e[0]!==n?(o=ie("space-y-2",n),e[0]=n,e[1]=o):o=e[1];let a;e[2]!==i?(a=i("sandbox.repoRow.label"),e[2]=i,e[3]=a):a=e[3];let l;e[4]!==a?(l=r.jsx(lt,{children:a}),e[4]=a,e[5]=l):l=e[5];let c;e[6]===Symbol.for("react.memo_cache_sentinel")?(c=r.jsx($o,{size:20,className:"shrink-0 text-foreground/60"}),e[6]=c):c=e[6];let d;e[7]!==s||e[8]!==i?(d=r.jsx(Ke,{asChild:!0,children:r.jsxs("div",{className:"flex items-center gap-3 rounded-lg border border-border bg-background px-4 py-3",tabIndex:0,children:[c,r.jsx("div",{className:"min-w-0 flex-1",children:s?r.jsxs(r.Fragment,{children:[r.jsxs("div",{className:"truncate text-sm font-medium",children:[s.owner,"/",s.name]}),r.jsx("div",{className:"truncate text-xs text-muted-foreground",children:s.url})]}):r.jsx("div",{className:"text-sm text-muted-foreground",children:i("sandbox.repoRow.noRepositoryConnected")})})]})}),e[7]=s,e[8]=i,e[9]=d):d=e[9];let h;e[10]!==i?(h=i("sandbox.repoRow.tooltipContent"),e[10]=i,e[11]=h):h=e[11];let u;e[12]!==h?(u=r.jsx(Ue,{children:h}),e[12]=h,e[13]=u):u=e[13];let f;e[14]!==d||e[15]!==u?(f=r.jsxs(He,{children:[d,u]}),e[14]=d,e[15]=u,e[16]=f):f=e[16];let m;return e[17]!==o||e[18]!==l||e[19]!==f?(m=r.jsxs("div",{className:o,children:[l,f]}),e[17]=o,e[18]=l,e[19]=f,e[20]=m):m=e[20],m}const Xj={npm:{install:"npm install",run:t=>`npm run ${t}`,runtime:"node"},pnpm:{install:"pnpm install",run:t=>`pnpm run ${t}`,runtime:"node"},yarn:{install:"yarn install",run:t=>`yarn run ${t}`,runtime:"node"},bun:{install:"bun install",run:t=>`bun run ${t}`,runtime:"bun"},deno:{install:"deno install",run:t=>`deno task ${t}`,runtime:"deno"}};function Qj(t){const e=t.trim();if(e==="")return{ok:!0,value:null};if(!/^\d+$/.test(e))return{ok:!1};const s=Number(e);return s<1||s>65535?{ok:!1}:{ok:!0,value:String(s)}}const Zj=Object.keys(Xj),Xc="__none__";function eC(t){const e=B.c(47),{control:s}=t,n=re(),i=A.useRef(null);let o;e[0]!==n?(o=n("sandbox.runtimeFields.packageManager"),e[0]=n,e[1]=o):o=e[1];let a;e[2]!==o?(a=r.jsx(lt,{htmlFor:"runtime-pm",children:o}),e[2]=o,e[3]=a):a=e[3];let l;e[4]!==n?(l=S=>{const{field:C}=S;return r.jsxs(Qt,{value:C.value??Xc,onValueChange:N=>C.onChange(N===Xc?null:N),children:[r.jsx(Jt,{id:"runtime-pm",children:r.jsx(as,{placeholder:n("sandbox.runtimeFields.autoDetect")})}),r.jsxs(Xt,{children:[r.jsx(vt,{value:Xc,children:n("sandbox.runtimeFields.autoDetect")}),Zj.map(sC)]})]})},e[4]=n,e[5]=l):l=e[5];let c;e[6]!==s||e[7]!==l?(c=r.jsx(ys,{control:s,name:"metadata.runtime.selected",render:l}),e[6]=s,e[7]=l,e[8]=c):c=e[8];let d;e[9]!==a||e[10]!==c?(d=r.jsxs("div",{className:"space-y-2",children:[a,c]}),e[9]=a,e[10]=c,e[11]=d):d=e[11];let h;e[12]!==n?(h=n("sandbox.runtimeFields.packagePath"),e[12]=n,e[13]=h):h=e[13];let u;e[14]!==h?(u=r.jsx(lt,{htmlFor:"runtime-path",children:h}),e[14]=h,e[15]=u):u=e[15];let f;e[16]!==s?(f=r.jsx(ys,{control:s,name:"metadata.runtime.path",render:tC}),e[16]=s,e[17]=f):f=e[17];let m;e[18]!==n?(m=n("sandbox.runtimeFields.packagePathDescription"),e[18]=n,e[19]=m):m=e[19];let p;e[20]!==m?(p=r.jsx("p",{className:"text-xs text-muted-foreground",children:m}),e[20]=m,e[21]=p):p=e[21];let g;e[22]!==p||e[23]!==u||e[24]!==f?(g=r.jsxs("div",{className:"space-y-2",children:[u,f,p]}),e[22]=p,e[23]=u,e[24]=f,e[25]=g):g=e[25];let x;e[26]!==n?(x=n("sandbox.runtimeFields.devServerPort"),e[26]=n,e[27]=x):x=e[27];let v;e[28]!==x?(v=r.jsx(lt,{htmlFor:"runtime-port",children:x}),e[28]=x,e[29]=v):v=e[29];let b;e[30]!==n?(b=S=>{const{field:C}=S;return r.jsx(rt,{ref:i,id:"runtime-port",inputMode:"numeric",placeholder:n("sandbox.runtimeFields.auto"),defaultValue:C.value??"",onBlur:N=>{const V=Qj(N.target.value);V.ok?C.onChange(V.value):i.current&&(i.current.value=C.value??"")}})},e[30]=n,e[31]=b):b=e[31];let _;e[32]!==s||e[33]!==b?(_=r.jsx(ys,{control:s,name:"metadata.runtime.port",render:b}),e[32]=s,e[33]=b,e[34]=_):_=e[34];let y;e[35]!==n?(y=n("sandbox.runtimeFields.devServerPortDescription"),e[35]=n,e[36]=y):y=e[36];let L;e[37]!==y?(L=r.jsx("p",{className:"text-xs text-muted-foreground",children:y}),e[37]=y,e[38]=L):L=e[38];let w;e[39]!==v||e[40]!==_||e[41]!==L?(w=r.jsxs("div",{className:"space-y-2",children:[v,_,L]}),e[39]=v,e[40]=_,e[41]=L,e[42]=w):w=e[42];let j;return e[43]!==g||e[44]!==w||e[45]!==d?(j=r.jsxs("div",{className:"space-y-5",children:[d,g,w]}),e[43]=g,e[44]=w,e[45]=d,e[46]=j):j=e[46],j}function tC(t){const{field:e}=t;return r.jsx(rt,{id:"runtime-path",placeholder:".",defaultValue:e.value??"",onBlur:s=>{const n=s.target.value.trim();e.onChange(n===""?null:n)}})}function sC(t){return r.jsx(vt,{value:t,children:t},t)}function nC(t,e){switch(e.type){case"SET_SHARE_DIALOG_OPEN":return{...t,shareDialogOpen:e.payload};case"SET_ADD_DIALOG_OPEN":return{...t,addDialogOpen:e.payload};case"OPEN_SETTINGS":return{...t,settingsDialogOpen:!0,settingsConnectionId:e.payload};case"CLOSE_SETTINGS":return{...t,settingsDialogOpen:!1,settingsConnectionId:null};default:return t}}function iC(t,e){switch(e.type){case"accumulate":{const s=t??{start:e.now,fields:new Set,saveCount:0,instructionsLength:null},n=new Set(s.fields);for(const i of e.fields)n.add(i);return{...s,fields:n,saveCount:s.saveCount+1,instructionsLength:e.instructionsLength??s.instructionsLength}}case"reset":return null}}function rC(t){const e=t.metadata?.runtime?.env;if(!e||e.length===0)return t;const s=e.filter(n=>{if(!n||typeof n!="object")return!1;const i=(n.key??"").trim();return!i||!ql.test(i)?!1:n.kind==="literal"?!0:n.kind==="secret"?!!n.secretId:!1});return s.length===e.length?t:{...t,metadata:{...t.metadata,runtime:{...t.metadata?.runtime??{},env:s}}}}async function oC(t,e){const s=t?.idToken??null;if(s){const i=Kh(s);if(i)return i}const n=t?.userinfoEndpoint??null;if(n)try{const i=await fetch(n,{headers:{Authorization:`Bearer ${e}`}});if(i.ok){const o=await i.json(),a=typeof o.email=="string"?o.email:typeof o.upn=="string"?o.upn:typeof o.preferred_username=="string"?o.preferred_username:null;if(a)return a}}catch{}return Kh(e)}function Kh(t){try{const e=t.split(".");if(e.length===3&&e[1]){const s=JSON.parse(atob(e[1].replace(/-/g,"+").replace(/_/g,"/")));if(typeof s.email=="string")return s.email;if(typeof s.upn=="string")return s.upn;if(typeof s.preferred_username=="string")return s.preferred_username}}catch{}return null}function aC({virtualMcp:t,hideOwnTitle:e}){const s=re(),[n]=ii(),i=n.language==="pt-BR"?Eb:void 0,{org:o}=Fe(),a=X0(),{data:l}=Lv([t.id]),c=l?.get(t.id)?.last_used_at,d=y2(),h=Ls(),u=Bs(),f=U0({resolver:cm(Lj),defaultValues:t}),m=f.watch("connections"),p=n2(t),g=ia(t),x=g?{owner:g.owner,name:g.name,url:g.url}:null,[v,b]=A.useReducer(nC,{shareDialogOpen:!1,addDialogOpen:!1,settingsDialogOpen:!1,settingsConnectionId:null}),[_,y]=A.useState(!1),[L,w]=A.useState(!1),{createNewTask:j,openSidePanel:S}=ea(),{sendMessage:C}=Js(),N=async()=>{if(L)return;const Y=f.getValues("metadata.instructions");if(Y?.trim()){w(!0);try{P(),$e("agent_instructions_improve_clicked",{agent_id:t.id,instructions_length:Y.length}),S("chat"),await C({tiptapDoc:Qp({managerAgentId:Nm.AGENT_MANAGER(o.id),managerName:"Agent Manager",kind:"agent",id:t.id,instructions:Y})})}finally{w(!1)}}},V=()=>{P(),$e("agent_test_clicked",{agent_id:t.id}),j()},[E,T]=A.useReducer(iC,null),k=()=>{E!==null&&($e("agent_updated",{agent_id:t.id,fields:Array.from(E.fields),instructions_length:E.instructionsLength,save_count:E.saveCount,edit_duration_ms:Date.now()-E.start}),T({type:"reset"}))},{schedule:R,flush:P}=bl({delayMs:3e4,save:async()=>k()}),D=async()=>{const Y=Object.keys(f.control._formState.dirtyFields);if(Y.length===0)return;const ee=Y.includes("metadata"),G=f.getValues();f.reset(G,{keepValues:!0});const te=rC(G);await a.update.mutateAsync({id:t.id,data:te}),T({type:"accumulate",now:Date.now(),fields:Y,instructionsLength:ee?G.metadata?.instructions?.length??0:null}),R()},{schedule:I,flush:M}=bl({save:D});A.useEffect(()=>{const Y=f.watch(()=>I());return()=>Y.unsubscribe()},[]);const O=()=>{$e("connections_dialog_opened",{source:"agent_settings",mode:"add"}),b({type:"SET_ADD_DIALOG_OPEN",payload:!0})},F=async Y=>{const ee=f.getValues("connections");if(ee.some(se=>se.connection_id===Y))return;f.setValue("connections",[...ee,{connection_id:Y,selected_tools:Jc.tools,selected_resources:Jc.resources,selected_prompts:Jc.prompts}],{shouldDirty:!0}),b({type:"SET_ADD_DIALOG_OPEN",payload:!1});const G=new URL(`/api/${o.slug}/mcp/${Y}`,window.location.origin),te=await Zu({url:G.href,token:null,orgId:o.id});te.supportsOAuth&&!te.isAuthenticated&&await J(Y)},$=Y=>{const G=f.getValues("connections").filter(te=>te.connection_id!==Y);f.setValue("connections",G,{shouldDirty:!0})},z=(Y,ee)=>{const G=f.getValues("connections");if(G.some(te=>te.connection_id===ee)){ge.error(s("virtualMcp.virtualMcp.instanceAlreadyAdded"));return}f.setValue("connections",G.map(te=>te.connection_id===Y?{...te,connection_id:ee}:te),{shouldDirty:!0})},K=async Y=>{if(f.getValues("connections").find(G=>G.connection_id===Y))try{const{item:G}=await u.call("COLLECTION_CONNECTIONS_GET",{id:Y});if(!G)return;const te=G.title.replace(/\s*\(.*?\)\s*$/,""),se=Rb("conn"),ne=`${te} (${Date.now().toString(36).slice(-4)})`;await d.create.mutateAsync({id:se,title:ne,description:G.description??null,connection_type:G.connection_type,connection_url:G.connection_url??null,connection_token:null,icon:G.icon??null,app_name:G.app_name??null,app_id:G.app_id??null,connection_headers:G.connection_headers??null});const de=new URL(`/api/${o.slug}/mcp/${se}`,window.location.origin),xe=await Zu({url:de.href,token:null,orgId:o.id});if(xe.supportsOAuth&&!xe.isAuthenticated){const he=await J(se);if(!he){await d.delete.mutateAsync(se);return}await d.update.mutateAsync({id:se,data:{title:`${te} (${he})`}})}z(Y,se),ge.success(s("virtualMcp.virtualMcp.newInstanceCreated"))}catch(G){console.error("Failed to create instance:",G),ge.error(s("virtualMcp.virtualMcp.failedToCreateInstance"))}},X=Y=>{b({type:"OPEN_SETTINGS",payload:Y})},J=async Y=>{const{token:ee,tokenInfo:G,error:te}=await Db({connectionId:Y,orgSlug:o.slug,scope:"offline_access"});if(te||!ee)return ge.error(s("virtualMcp.virtualMcp.authenticationFailed",{error:te??""})),null;if(G)try{const ne=await fetch(`/api/${o.slug}/connections/${Y}/oauth-token`,{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({accessToken:G.accessToken,refreshToken:G.refreshToken,expiresIn:G.expiresIn,scope:G.scope,clientId:G.clientId,clientSecret:G.clientSecret,tokenEndpoint:G.tokenEndpoint})});if(!ne.ok)console.error("Failed to save OAuth token:",await ne.text()),await d.update.mutateAsync({id:Y,data:{connection_token:ee}});else try{await d.update.mutateAsync({id:Y,data:{}})}catch(de){console.warn("Failed to refresh connection tools after OAuth:",de)}}catch(ne){console.error("Error saving OAuth token:",ne),await d.update.mutateAsync({id:Y,data:{connection_token:ee}})}else await d.update.mutateAsync({id:Y,data:{connection_token:ee}});const se=new URL(`/api/${o.slug}/mcp/${Y}`,window.location.origin);return await h.invalidateQueries({queryKey:at.isMCPAuthenticated(se.href,null)}),ge.success(s("virtualMcp.virtualMcp.authenticationSuccessful")),oC(G,ee)},H=()=>{const Y=f.getValues("metadata.instructions")??"",ee=`<role>
|
|
11
|
+
Define who this agent is and what it specializes in.
|
|
12
|
+
Example: You are a support triage agent for B2B merchants.
|
|
13
|
+
</role>
|
|
14
|
+
|
|
15
|
+
<capabilities>
|
|
16
|
+
List what this agent can do using its connected tools.
|
|
17
|
+
- Investigate issues using connected data sources.
|
|
18
|
+
- Summarize findings and recommend next steps.
|
|
19
|
+
</capabilities>
|
|
20
|
+
|
|
21
|
+
<constraints>
|
|
22
|
+
Set clear boundaries on what the agent must not do.
|
|
23
|
+
- Do not perform destructive actions without confirmation.
|
|
24
|
+
- Escalate to a human when the request is outside your expertise.
|
|
25
|
+
</constraints>
|
|
26
|
+
|
|
27
|
+
<workflows>
|
|
28
|
+
Define step-by-step how the agent should handle requests.
|
|
29
|
+
|
|
30
|
+
## Default workflow
|
|
31
|
+
1. Read the user's request and gather context.
|
|
32
|
+
2. Use the appropriate tools to investigate or act.
|
|
33
|
+
3. Summarize the result and propose next steps.
|
|
34
|
+
4. Ask for confirmation before making any changes.
|
|
35
|
+
</workflows>`,G=Y.trim()?`${Y}
|
|
36
|
+
|
|
37
|
+
${ee}`:ee;f.setValue("metadata.instructions",G,{shouldDirty:!0})},W=new Set(m.map(Y=>Y.connection_id)),U=St(),[Q,q]=A.useState(!1),Z=async()=>{P();try{await a.delete.mutateAsync(t.id),$e("agent_deleted",{agent_id:t.id,source:"agent_detail"}),ge.success(s("virtualMcp.virtualMcp.agentDeleted",{title:t.title})),U({to:"/$org",params:{org:o.slug}})}catch{}};return r.jsxs(en,{children:[r.jsx(en.Content,{children:r.jsx(en.Body,{children:r.jsxs("div",{className:"flex flex-col gap-10",children:[!e&&r.jsx(en.Title,{actions:r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsxs(le,{variant:"outline",size:"sm",onClick:V,children:[r.jsx(Vi,{size:14,className:"size-[14px]!"}),s("virtualMcp.virtualMcp.testAgent")]}),r.jsx(le,{variant:"ghost",size:"icon",className:"text-muted-foreground hover:text-destructive",onClick:()=>q(!0),children:r.jsx(Ns,{size:14})})]}),children:s("virtualMcp.virtualMcp.settings")}),r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsx(ys,{name:"icon",control:f.control,render:({field:Y})=>r.jsx(Dw,{value:Y.value??null,onChange:ee=>{Y.onChange(ee),M()},onColorChange:ee=>{f.setValue("metadata.ui.themeColor",ee,{shouldDirty:!0}),M()},name:f.watch("title")||"Agent",size:"md",className:"shrink-0",avatarClassName:"[&_svg]:w-1/2 [&_svg]:h-1/2"})}),r.jsxs("div",{className:"flex flex-col flex-1 min-w-0",children:[r.jsx(ys,{name:"title",control:f.control,render:({field:Y})=>r.jsx("input",{...Y,type:"text",value:Y.value??"",onChange:ee=>{Y.onChange(ee)},onBlur:()=>{Y.onBlur(),M()},disabled:p,placeholder:s("virtualMcp.virtualMcp.agentNamePlaceholder"),className:"text-lg font-medium leading-tight text-foreground bg-transparent border-none outline-none px-1 -mx-1 rounded hover:bg-input/25 focus:bg-input/25 transition-colors w-full truncate disabled:hover:bg-transparent disabled:focus:bg-transparent disabled:opacity-50"})}),r.jsx(ys,{name:"description",control:f.control,render:({field:Y})=>r.jsx("input",{...Y,type:"text",value:Y.value??"",onChange:ee=>{Y.onChange(ee)},onBlur:()=>{Y.onBlur(),M()},disabled:p,placeholder:s("virtualMcp.virtualMcp.descriptionPlaceholder"),className:"text-sm text-muted-foreground bg-transparent border-none outline-none px-1 -mx-1 rounded hover:bg-input/25 focus:bg-input/25 transition-colors w-full truncate disabled:hover:bg-transparent disabled:focus:bg-transparent disabled:opacity-50"})})]}),r.jsxs(le,{variant:"outline",size:"sm",className:"shrink-0",onClick:()=>{$e("agent_connect_modal_opened",{agent_id:t.id}),b({type:"SET_SHARE_DIALOG_OPEN",payload:!0})},children:[r.jsxs("span",{className:"flex items-center -space-x-1.5 mr-0.5",children:[r.jsx("span",{className:"inline-flex items-center justify-center size-4 rounded-full bg-black ring-1 ring-white/20 shrink-0",children:r.jsx("img",{src:"/logos/cursor.svg",alt:"Cursor",className:"size-2.5 brightness-0 invert"})}),r.jsx("span",{className:"relative z-10 inline-flex items-center justify-center size-4 rounded-full ring-1 ring-background shrink-0",style:{backgroundColor:"#D97757"},children:r.jsx("img",{src:"/logos/Claude Code.svg",alt:"Claude",className:"size-2.5 brightness-0 invert"})})]}),s("virtualMcp.virtualMcp.connect")]})]}),r.jsxs("div",{className:"flex items-center gap-2 -mt-6 text-sm text-muted-foreground",children:[r.jsx(Zp,{id:t.created_by,size:"2xs",className:"text-sm text-muted-foreground"}),r.jsx("span",{className:"text-muted-foreground/50",children:"·"}),r.jsxs("span",{children:[s("virtualMcp.virtualMcp.created")," ",new Date(t.created_at).toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"})]}),r.jsx("span",{className:"text-muted-foreground/50",children:"·"}),r.jsx("span",{children:c?s("virtualMcp.virtualMcp.lastUsed",{time:Pb(new Date(c),{addSuffix:!0,locale:i})}):s("virtualMcp.virtualMcp.neverUsed")})]}),r.jsxs("section",{className:"flex flex-col gap-3",children:[r.jsxs("div",{className:"flex items-center justify-between gap-3",children:[r.jsx("h2",{className:"text-sm font-medium text-foreground",children:s("virtualMcp.virtualMcp.connections")}),m.length>0&&r.jsxs(le,{variant:"outline",size:"sm",onClick:O,children:[r.jsx(kt,{size:14}),s("virtualMcp.virtualMcp.addConnection")]})]}),r.jsx("div",{className:"flex flex-col gap-2",children:m.length===0?r.jsxs("button",{type:"button",onClick:O,className:"flex items-center gap-3 px-3 py-2.5 rounded-lg border border-dashed border-border hover:bg-accent/50 transition-colors w-full text-left cursor-pointer",children:[r.jsx("div",{className:"flex items-center justify-center size-8 rounded-md text-muted-foreground/75 border border-dashed border-border shrink-0",children:r.jsx(kt,{size:16})}),r.jsx("span",{className:"text-sm text-muted-foreground",children:s("virtualMcp.virtualMcp.noConnectionsYet")})]}):m.map(Y=>r.jsx(_s,{fallback:()=>null,children:r.jsx(A.Suspense,{fallback:r.jsx(t3,{}),children:r.jsx(mj,{connection_id:Y.connection_id,usedConnectionIds:W,onOpenSettings:()=>X(Y.connection_id),onRemove:()=>$(Y.connection_id),onAuthenticate:J,onSwitchInstance:z,onNewInstance:()=>K(Y.connection_id)})})},Y.connection_id))})]}),r.jsxs("section",{className:"flex flex-col gap-3",children:[r.jsxs("div",{className:"flex items-center justify-between gap-3",children:[r.jsx("h2",{className:"text-sm font-medium text-foreground",children:s("virtualMcp.virtualMcp.instructions")}),r.jsxs("div",{className:"flex items-center gap-2",children:[!f.watch("metadata.instructions")?.trim()&&r.jsx(le,{variant:"outline",size:"sm",onClick:H,children:s("virtualMcp.virtualMcp.promptTemplate")}),r.jsxs(le,{variant:"outline",size:"sm",disabled:L||!f.watch("metadata.instructions")?.trim(),onClick:N,children:[r.jsx(Gn,{size:13}),s("virtualMcp.virtualMcp.improve")]})]})]}),r.jsx(ys,{name:"metadata.instructions",control:f.control,render:({field:Y})=>r.jsxs("div",{className:"relative rounded-xl card-shadow bg-card focus-within:ring-1 focus-within:ring-ring",children:[r.jsx(gr,{...Y,value:Y.value??"",onChange:ee=>{Y.onChange(ee)},onBlur:()=>{Y.onBlur(),M()},placeholder:s("virtualMcp.virtualMcp.instructionsPlaceholder"),className:"min-h-[200px] max-h-[360px] overflow-auto resize-none text-base text-muted-foreground placeholder:text-muted-foreground/40 leading-relaxed border-0 shadow-none px-4 py-3 pr-11 focus-visible:ring-0 focus-visible:ring-offset-0 bg-transparent",style:{boxShadow:"none"}}),r.jsxs(He,{delayDuration:0,children:[r.jsx(Ke,{asChild:!0,children:r.jsx(le,{type:"button",variant:"ghost",size:"icon",className:"absolute top-2 right-2 h-7 w-7 text-muted-foreground",onClick:()=>y(!0),"aria-label":s("virtualMcp.virtualMcp.openFullscreenEditor"),children:r.jsx(Gm,{size:14})})}),r.jsx(Ue,{side:"left",children:s("virtualMcp.virtualMcp.fullscreen")})]})]})})]}),r.jsx(zw,{form:f}),r.jsx(_s,{fallback:()=>null,children:r.jsx(A.Suspense,{fallback:r.jsxs("section",{className:"flex flex-col gap-3",children:[r.jsx("h2",{className:"text-sm font-medium text-foreground",children:s("virtualMcp.virtualMcp.subAgents")}),r.jsx("div",{className:"h-16 rounded-lg border border-dashed border-border animate-pulse"})]}),children:r.jsx(Yw,{form:f,currentAgentId:t.id})})}),r.jsx(_j,{virtualMcpId:t.id,form:f,flushAndSave:M}),r.jsx(Dj,{virtualMcp:t}),p&&r.jsxs("div",{className:"flex flex-col gap-3",children:[r.jsxs("div",{className:"flex flex-col gap-1",children:[r.jsx("h2",{className:"text-sm font-medium text-foreground",children:s("virtualMcp.virtualMcp.publishing")}),r.jsx("p",{className:"text-sm text-muted-foreground",children:s("virtualMcp.virtualMcp.publishingDescription")})]}),r.jsx(vl,{className:"p-6",children:r.jsx(Mo,{className:"p-0",children:r.jsx(ys,{name:"metadata.publishPolicy",control:f.control,render:({field:Y})=>r.jsx(Pw,{value:Y.value??"smart",onValueChange:ee=>{Y.onChange(ee),M()},className:"gap-4",children:[{value:"smart",label:s("virtualMcp.virtualMcp.publishPolicySmart"),description:s("virtualMcp.virtualMcp.publishPolicySmartDescription")},{value:"code-review",label:s("virtualMcp.virtualMcp.publishPolicyCodeReview"),description:s("virtualMcp.virtualMcp.publishPolicyCodeReviewDescription")},{value:"open",label:s("virtualMcp.virtualMcp.publishPolicyOpen"),description:s("virtualMcp.virtualMcp.publishPolicyOpenDescription")}].map(ee=>r.jsxs("label",{htmlFor:`publish-policy-${ee.value}`,className:"flex cursor-pointer items-start gap-3",children:[r.jsx(Rw,{id:`publish-policy-${ee.value}`,value:ee.value,className:"mt-0.5"}),r.jsxs("div",{className:"flex flex-col gap-0.5",children:[r.jsx("span",{className:"text-sm font-medium text-foreground",children:ee.label}),r.jsx("span",{className:"text-sm text-muted-foreground",children:ee.description})]})]},ee.value))})})})})]}),r.jsxs("div",{className:"flex flex-col gap-3",children:[r.jsx("div",{className:"flex items-center justify-between gap-3",children:r.jsx("h2",{className:"text-sm font-medium text-foreground",children:s("virtualMcp.virtualMcp.sandbox")})}),r.jsx(vl,{className:"p-6 gap-5",children:r.jsxs(Mo,{className:"p-0 space-y-5",children:[r.jsx(Jj,{repo:x}),r.jsx(eC,{control:f.control}),r.jsx(Fj,{control:f.control,form:f,virtualMcpId:t.id,orgSlug:o.slug})]})})]}),r.jsxs("section",{className:"flex items-center justify-between border-t border-border pt-6",children:[r.jsxs("div",{children:[r.jsx("p",{className:"text-sm font-medium",children:s("virtualMcp.virtualMcp.deleteAgent")}),r.jsx("p",{className:"text-sm text-muted-foreground",children:s("virtualMcp.virtualMcp.deleteAgentDescription")})]}),r.jsxs(le,{variant:"outline",size:"sm",className:"text-destructive border-destructive/40 hover:bg-destructive/10 hover:text-destructive shrink-0",onClick:()=>q(!0),children:[r.jsx(Ns,{size:14}),s("virtualMcp.virtualMcp.deleteAgent")]})]})]})})}),r.jsx(dl,{open:Q,onOpenChange:q,children:r.jsxs(ul,{children:[r.jsxs(hl,{children:[r.jsx(fl,{children:s("virtualMcp.virtualMcp.deleteAgentConfirm")}),r.jsx(ml,{children:s("virtualMcp.virtualMcp.deleteAgentConfirmDescription",{title:t.title})})]}),r.jsxs(pl,{children:[r.jsx(gl,{children:s("virtualMcp.virtualMcp.cancel")}),r.jsx(xl,{onClick:Z,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:s("virtualMcp.virtualMcp.delete")})]})]})}),r.jsx(h9,{open:v.addDialogOpen,onOpenChange:Y=>b({type:"SET_ADD_DIALOG_OPEN",payload:Y}),agentId:t.id,addedConnectionIds:W,onAdd:F}),r.jsx(fj,{open:v.settingsDialogOpen,onOpenChange:Y=>{Y||b({type:"CLOSE_SETTINGS"})},selectedId:v.settingsConnectionId,form:f,connections:m,onAuthenticate:J}),r.jsx(Rj,{open:v.shareDialogOpen,onOpenChange:Y=>b({type:"SET_SHARE_DIALOG_OPEN",payload:Y}),virtualMcp:t}),r.jsx(ts,{open:_,onOpenChange:y,children:r.jsxs(es,{className:"w-[90vw] sm:max-w-6xl h-[85vh] flex flex-col p-0 gap-0",children:[r.jsx(ms,{className:"px-6 pt-6 pb-3 border-b border-border shrink-0",children:r.jsx(ps,{children:s("virtualMcp.virtualMcp.instructions")})}),r.jsx("div",{className:"flex-1 min-h-0 p-6",children:r.jsx(ys,{name:"metadata.instructions",control:f.control,render:({field:Y})=>r.jsx(gr,{...Y,value:Y.value??"",onChange:ee=>{Y.onChange(ee)},onBlur:()=>{Y.onBlur(),M()},disabled:p,placeholder:s("virtualMcp.virtualMcp.instructionsPlaceholder"),className:"w-full h-full resize-none text-base text-muted-foreground placeholder:text-muted-foreground/40 leading-relaxed rounded-xl card-shadow px-4 py-3 focus-visible:ring-1 focus-visible:ring-ring focus-visible:ring-offset-0 bg-card border-0",style:{boxShadow:"none"}})})})]})})]})}function lC(t){const e=B.c(22),{virtualMcpId:s,hideOwnTitle:n}=t,i=re(),o=St(),{org:a}=Fe(),l=gs(s);if(!l){let h;e[0]!==i?(h=i("virtualMcp.virtualMcp.spaceNotFound"),e[0]=i,e[1]=h):h=e[1];let u;e[2]!==i?(u=i("virtualMcp.virtualMcp.spaceNotFoundDescription"),e[2]=i,e[3]=u):u=e[3];let f;e[4]!==o||e[5]!==a.slug?(f=()=>o({to:"/$org",params:{org:a.slug}}),e[4]=o,e[5]=a.slug,e[6]=f):f=e[6];let m;e[7]!==i?(m=i("virtualMcp.virtualMcp.backToSpaces"),e[7]=i,e[8]=m):m=e[8];let p;e[9]!==f||e[10]!==m?(p=r.jsx(le,{variant:"outline",onClick:f,children:m}),e[9]=f,e[10]=m,e[11]=p):p=e[11];let g;return e[12]!==h||e[13]!==u||e[14]!==p?(g=r.jsx("div",{className:"flex h-full w-full bg-background",children:r.jsx(ki,{title:h,description:u,actions:p})}),e[12]=h,e[13]=u,e[14]=p,e[15]=g):g=e[15],g}let c;e[16]!==l?(c=ia(l)?.connectionId??"",e[16]=l,e[17]=c):c=e[17];let d;return e[18]!==n||e[19]!==c||e[20]!==l?(d=r.jsx(aC,{virtualMcp:l,hideOwnTitle:n},c),e[18]=n,e[19]=c,e[20]=l,e[21]=d):d=e[21],d}function Uh(t){const e=B.c(2),{virtualMcpId:s}=t;let n;return e[0]!==s?(n=r.jsx(lC,{virtualMcpId:s,hideOwnTitle:!0}),e[0]=s,e[1]=n):n=e[1],n}const yr=1,n3=`home-board.layout.v${yr}`;function i3(t){return`home-board.layout.v${yr}.${t}`}const r3={version:yr,tiles:{},hidden:[],shown:[]};function Hd(t){return!t||t.version!==yr?r3:{version:yr,tiles:t.tiles??{},hidden:Array.isArray(t.hidden)?t.hidden:[],shown:Array.isArray(t.shown)?t.shown:[]}}function cC(t){return Object.keys(t.tiles).length>0||t.hidden.length>0||(t.shown?.length??0)>0}function dC(t){try{const e=localStorage.getItem(i3(t));return e?Hd(JSON.parse(e)):void 0}catch{return}}function Hh(t,e){try{localStorage.setItem(i3(t),JSON.stringify(e))}catch{}}async function Wh(t,e){if(!(await fetch(`/api/${t}/kv/${n3}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})).ok)throw new Error("Failed to save board layout")}function uC(t){const e=B.c(24),s=Ls();let n;e[0]!==t?(n=at.boardLayout(t),e[0]=t,e[1]=n):n=e[1];const i=n;let o;e[2]!==t?(o=dC(t),e[2]=t,e[3]=o):o=e[3];const a=o;let l;e[4]!==a||e[5]!==t?(l=async()=>{const v=await fetch(`/api/${t}/kv/${n3}`);if(v.status===404)return a&&cC(a)?(await Wh(t,a),a):r3;if(!v.ok)throw new Error("Failed to load board layout");const b=await v.json(),_=Hd(b.value);return Hh(t,_),_},e[4]=a,e[5]=t,e[6]=l):l=e[6];let c;e[7]!==a||e[8]!==i||e[9]!==l?(c={queryKey:i,queryFn:l,initialData:a,staleTime:0,refetchOnWindowFocus:!1},e[7]=a,e[8]=i,e[9]=l,e[10]=c):c=e[10];const{data:d,isLoading:h}=Ft(c);let u;e[11]!==t?(u={mutationFn:v=>Wh(t,v)},e[11]=t,e[12]=u):u=e[12];const f=Ys(u);let m;e[13]!==f||e[14]!==t||e[15]!==s||e[16]!==i?(m=v=>{Hh(t,v),s.setQueryData(i,v),f.mutate(v)},e[13]=f,e[14]=t,e[15]=s,e[16]=i,e[17]=m):m=e[17];const p=m;let g;e[18]!==d?(g=Hd(d),e[18]=d,e[19]=g):g=e[19];let x;return e[20]!==h||e[21]!==p||e[22]!==g?(x={layout:g,isLoading:h,save:p},e[20]=h,e[21]=p,e[22]=g,e[23]=x):x=e[23],x}const o3=A.createContext(null);function hC(t){const e=B.c(24),{children:s}=t,{org:n}=Fe(),i=uC(n.slug),[o,a]=A.useState(!1),[l,c]=A.useState(null);let d;e[0]!==i.layout?(d=()=>{c(i.layout),a(!0)},e[0]=i.layout,e[1]=d):d=e[1];const h=d;let u;e[2]===Symbol.for("react.memo_cache_sentinel")?(u=()=>{c(null),a(!1)},e[2]=u):u=e[2];const f=u;let m;e[3]!==l||e[4]!==i?(m=()=>{l&&i.save(l),c(null),a(!1)},e[3]=l,e[4]=i,e[5]=m):m=e[5];const p=m,g=o&&l!==null,x=g?l:i.layout;let v;e[6]!==l||e[7]!==g||e[8]!==i.layout?(v=g?JSON.stringify(l)!==JSON.stringify(i.layout):!1,e[6]=l,e[7]=g,e[8]=i.layout,e[9]=v):v=e[9];const b=v;let _;e[10]!==o||e[11]!==i?(_=j=>{o?c(j):i.save(j)},e[10]=o,e[11]=i,e[12]=_):_=e[12];const y=_;let L;e[13]!==y||e[14]!==h||e[15]!==b||e[16]!==o||e[17]!==x||e[18]!==p||e[19]!==i.isLoading?(L={isEditMode:o,enter:h,cancel:f,save:p,hasChanges:b,layout:x,isLayoutLoading:i.isLoading,commitLayout:y},e[13]=y,e[14]=h,e[15]=b,e[16]=o,e[17]=x,e[18]=p,e[19]=i.isLoading,e[20]=L):L=e[20];let w;return e[21]!==s||e[22]!==L?(w=r.jsx(o3.Provider,{value:L,children:s}),e[21]=s,e[22]=L,e[23]=w):w=e[23],w}function q9(){const t=A.useContext(o3);if(!t)throw new Error("useHomeEdit must be used within a HomeEditProvider");return t}function fC(t){const e=B.c(30),{generating:s}=t;let n;e[0]===Symbol.for("react.memo_cache_sentinel")?(n=ie("pointer-events-none absolute -bottom-14 left-6 hidden h-48 w-36 -rotate-6 rounded-xl border border-border bg-background shadow-lg sm:block","transition-transform duration-500 ease-out group-hover:-translate-y-2 group-hover:-rotate-3"),e[0]=n):n=e[0];let i;e[1]===Symbol.for("react.memo_cache_sentinel")?(i=r.jsx("circle",{cx:"16",cy:"16",r:"12",fill:"none",strokeWidth:"4",className:"stroke-muted"}),e[1]=i):i=e[1];const o=s?"75.4":"22",a=s?"stroke-muted":"stroke-success";let l;e[2]!==a?(l=ie("transition-[stroke-dashoffset] duration-1000 ease-out",a),e[2]=a,e[3]=l):l=e[3];let c;e[4]!==o||e[5]!==l?(c=r.jsxs("svg",{viewBox:"0 0 32 32",className:"size-9 shrink-0 -rotate-90",children:[i,r.jsx("circle",{cx:"16",cy:"16",r:"12",fill:"none",strokeWidth:"4",strokeLinecap:"round",strokeDasharray:"75.4",strokeDashoffset:o,className:l})]}),e[4]=o,e[5]=l,e[6]=c):c=e[6];const d=s&&"animate-pulse";let h;e[7]!==d?(h=ie("h-1.5 w-full rounded-full bg-muted",d),e[7]=d,e[8]=h):h=e[8];let u;e[9]!==h?(u=r.jsx("div",{className:h}),e[9]=h,e[10]=u):u=e[10];const f=s&&"animate-pulse";let m;e[11]!==f?(m=ie("h-1.5 w-2/3 rounded-full bg-muted",f),e[11]=f,e[12]=m):m=e[12];let p;e[13]!==m?(p=r.jsx("div",{className:m}),e[13]=m,e[14]=p):p=e[14];let g;e[15]!==p||e[16]!==u?(g=r.jsxs("div",{className:"flex min-w-0 flex-1 flex-col gap-1.5",children:[u,p]}),e[15]=p,e[16]=u,e[17]=g):g=e[17];let x;e[18]!==g||e[19]!==c?(x=r.jsxs("div",{className:"flex items-center gap-2.5",children:[c,g]}),e[18]=g,e[19]=c,e[20]=x):x=e[20];let v;e[21]===Symbol.for("react.memo_cache_sentinel")?(v=[7,10,5,9,6,8],e[21]=v):v=e[21];let b;e[22]!==s?(b=r.jsx("div",{className:"flex h-10 items-end gap-1.5",children:v.map((L,w)=>r.jsx("div",{style:{height:`${L*4}px`},className:ie("flex-1 rounded-sm",s?"animate-pulse bg-muted":w%2===0?"bg-success/70":"bg-success/30")},`bar-${w}`))}),e[22]=s,e[23]=b):b=e[23];let _;e[24]!==s?(_=r.jsx("div",{className:"flex flex-col gap-1.5",children:["w-full","w-5/6","w-full","w-2/3","w-full"].map((L,w)=>r.jsx("div",{className:ie("h-1.5 rounded-full bg-muted",L,s&&"animate-pulse")},`line-${w}`))}),e[24]=s,e[25]=_):_=e[25];let y;return e[26]!==x||e[27]!==b||e[28]!==_?(y=r.jsx("div",{"aria-hidden":!0,className:n,children:r.jsxs("div",{className:"flex h-full flex-col gap-3 p-4",children:[x,b,_]})}),e[26]=x,e[27]=b,e[28]=_,e[29]=y):y=e[29],y}function mC(t){const e=B.c(25),{status:s,host:n,onOpen:i}=t,o=s==="generating",a=n??"sua loja";let l;e[0]===Symbol.for("react.memo_cache_sentinel")?(l=ie("group relative block w-full cursor-pointer overflow-hidden rounded-3xl border border-border bg-card card-shadow text-left","transition-colors duration-300 hover:bg-accent/30","animate-in fade-in slide-in-from-bottom-2 duration-500"),e[0]=l):l=e[0];const c=o?"bg-warning/15":"bg-success/15";let d;e[1]!==c?(d=ie("absolute -bottom-24 -left-10 size-64 rounded-full blur-3xl transition-colors duration-700",c),e[1]=c,e[2]=d):d=e[2];let h;e[3]!==d?(h=r.jsx("div",{"aria-hidden":!0,className:d}),e[3]=d,e[4]=h):h=e[4];let u;e[5]!==o?(u=r.jsx(fC,{generating:o}),e[5]=o,e[6]=u):u=e[6];const f=o?"Gerando seu diagnóstico":"Seu relatório está pronto";let m;e[7]!==f?(m=r.jsx("span",{className:"text-base font-medium leading-6 text-foreground sm:text-lg",children:f}),e[7]=f,e[8]=m):m=e[8];const p=o?`Analisando ${a}. Isso leva alguns minutos.`:`Veja a análise completa de ${a}.`;let g;e[9]!==p?(g=r.jsx("span",{className:"truncate text-sm text-muted-foreground",children:p}),e[9]=p,e[10]=g):g=e[10];let x;e[11]!==m||e[12]!==g?(x=r.jsxs("div",{className:"flex min-w-0 flex-1 flex-col gap-1",children:[m,g]}),e[11]=m,e[12]=g,e[13]=x):x=e[13];let v;e[14]===Symbol.for("react.memo_cache_sentinel")?(v=ie("flex size-11 shrink-0 items-center justify-center rounded-full border border-border bg-background","transition-transform duration-300 group-hover:translate-x-1"),e[14]=v):v=e[14];let b;e[15]!==o?(b=r.jsx("div",{className:v,children:o?r.jsxs("span",{className:"relative flex size-2.5",children:[r.jsx("span",{className:"absolute inline-flex h-full w-full animate-ping rounded-full bg-warning opacity-60"}),r.jsx("span",{className:"relative inline-flex size-2.5 rounded-full bg-warning"})]}):r.jsx(kr,{size:18,className:"text-foreground","aria-hidden":!0})}),e[15]=o,e[16]=b):b=e[16];let _;e[17]!==x||e[18]!==b?(_=r.jsxs("div",{className:"relative flex min-h-28 items-center gap-4 px-5 py-5 sm:h-36 sm:gap-6 sm:pr-6 sm:pl-52",children:[x,b]}),e[17]=x,e[18]=b,e[19]=_):_=e[19];let y;return e[20]!==i||e[21]!==_||e[22]!==h||e[23]!==u?(y=r.jsxs("button",{type:"button",onClick:i,className:l,children:[h,u,_]}),e[20]=i,e[21]=_,e[22]=h,e[23]=u,e[24]=y):y=e[24],y}function pC(){const t=B.c(13),{org:e}=Fe(),s=St(),{diagnostic:n,isSuccess:i,host:o,connectionId:a}=Ev();let l;t[0]!==n||t[1]!==i?(l=i?Pv(n):"none",t[0]=n,t[1]=i,t[2]=l):l=t[2];const c=l;if(c==="none")return null;let d;t[3]!==a||t[4]!==o||t[5]!==s||t[6]!==e||t[7]!==c?(d=()=>{$e("home_report_banner_clicked",{organization_id:e.id,status:c,domain:o??void 0}),s(Rv(e,a))},t[3]=a,t[4]=o,t[5]=s,t[6]=e,t[7]=c,t[8]=d):d=t[8];const h=d;let u;return t[9]!==o||t[10]!==h||t[11]!==c?(u=r.jsx(mC,{status:c,host:o,onOpen:h}),t[9]=o,t[10]=h,t[11]=c,t[12]=u):u=t[12],u}function gC(){const t=B.c(1);let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=r.jsx(_s,{fallback:null,children:r.jsx(pC,{})}),t[0]=e):e=t[0],e}function xC({agentId:t}){const e=re(),{org:s,locator:n}=Fe(),i=ht({connectionId:t,orgId:s.id,orgSlug:s.slug}),{create:o}=Gl(),{setTaskId:a}=ea(),[l,c]=A.useState(null),[d,h]=A.useState(!1),u=A.useRef(!1),f=async(v,b)=>{if(!i){ge.error(e("common.useStartThreadFromPrompt.mcpClientNotAvailable"));return}if(!u.current){u.current=!0,h(!0);try{const _=await Zo(i,v.name,b),y={type:"doc",content:[{type:"paragraph",content:[Y0({id:v.name,name:jr(v.name,pn(v._meta)),metadata:_.messages,char:"/",kind:"prompt",args:b}),{type:"text",text:" "}]}]},L=crypto.randomUUID();Im(sessionStorage,n,L,{tiptapDoc:y}),await o({id:L,virtual_mcp_id:t}),a(L,t,{autosend:!0})}catch(_){console.error("[start-thread-from-prompt] failed",_),ge.error(e("common.useStartThreadFromPrompt.failedToStartChat"))}finally{u.current=!1,h(!1)}}},m=async v=>{if(!u.current){if(v.arguments&&v.arguments.length>0){c(v);return}await f(v)}},p=async v=>{if(!l)return;const b=l;c(null),await f(b,v)};return{start:m,startBlank:async v=>{if(!u.current){u.current=!0,h(!0);try{const b=crypto.randomUUID();await o({id:b,virtual_mcp_id:t}),a(b,t,v?.main?{main:v.main}:void 0)}catch(b){console.error("[start-thread-from-prompt] startBlank failed",b),ge.error(e("common.useStartThreadFromPrompt.failedToStartChat"))}finally{u.current=!1,h(!1)}}},dialog:r.jsx(Ao,{prompt:l,setPrompt:v=>c(v),onSubmit:p}),dialogPrompt:l,starting:d}}function vC(){for(var t=arguments.length,e=new Array(t),s=0;s<t;s++)e[s]=arguments[s];return A.useMemo(()=>n=>{e.forEach(i=>i(n))},e)}const fc=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function Ir(t){const e=Object.prototype.toString.call(t);return e==="[object Window]"||e==="[object global]"}function G9(t){return"nodeType"in t}function Ss(t){var e,s;return t?Ir(t)?t:G9(t)&&(e=(s=t.ownerDocument)==null?void 0:s.defaultView)!=null?e:window:window}function Y9(t){const{Document:e}=Ss(t);return t instanceof e}function da(t){return Ir(t)?!1:t instanceof Ss(t).HTMLElement}function a3(t){return t instanceof Ss(t).SVGElement}function Mr(t){return t?Ir(t)?t.document:G9(t)?Y9(t)?t:da(t)||a3(t)?t.ownerDocument:document:document:document}const nn=fc?A.useLayoutEffect:A.useEffect;function mc(t){const e=A.useRef(t);return nn(()=>{e.current=t}),A.useCallback(function(){for(var s=arguments.length,n=new Array(s),i=0;i<s;i++)n[i]=arguments[i];return e.current==null?void 0:e.current(...n)},[])}function bC(){const t=A.useRef(null),e=A.useCallback((n,i)=>{t.current=setInterval(n,i)},[]),s=A.useCallback(()=>{t.current!==null&&(clearInterval(t.current),t.current=null)},[]);return[e,s]}function zo(t,e){e===void 0&&(e=[t]);const s=A.useRef(t);return nn(()=>{s.current!==t&&(s.current=t)},e),s}function ua(t,e){const s=A.useRef();return A.useMemo(()=>{const n=t(s.current);return s.current=n,n},[...e])}function kl(t){const e=mc(t),s=A.useRef(null),n=A.useCallback(i=>{i!==s.current&&e?.(i,s.current),s.current=i},[]);return[s,n]}function Vl(t){const e=A.useRef();return A.useEffect(()=>{e.current=t},[t]),e.current}let Qc={};function ha(t,e){return A.useMemo(()=>{if(e)return e;const s=Qc[t]==null?0:Qc[t]+1;return Qc[t]=s,t+"-"+s},[t,e])}function l3(t){return function(e){for(var s=arguments.length,n=new Array(s>1?s-1:0),i=1;i<s;i++)n[i-1]=arguments[i];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 or=l3(1),Ko=l3(-1);function yC(t){return"clientX"in t&&"clientY"in t}function pc(t){if(!t)return!1;const{KeyboardEvent:e}=Ss(t.target);return e&&t instanceof e}function _C(t){if(!t)return!1;const{TouchEvent:e}=Ss(t.target);return e&&t instanceof e}function Nl(t){if(_C(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 yC(t)?{x:t.clientX,y:t.clientY}:null}const Ln=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[Ln.Translate.toString(t),Ln.Scale.toString(t)].join(" ")}},Transition:{toString(t){let{property:e,duration:s,easing:n}=t;return e+" "+s+"ms "+n}}}),qh="a,frame,iframe,input:not([type=hidden]):not(:disabled),select:not(:disabled),textarea:not(:disabled),button:not(:disabled),*[tabindex]";function LC(t){return t.matches(qh)?t:t.querySelector(qh)}const SC={display:"none"};function wC(t){let{id:e,value:s}=t;return it.createElement("div",{id:e,style:SC},s)}function jC(t){let{id:e,announcement:s,ariaLiveType:n="assertive"}=t;const i={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 it.createElement("div",{id:e,style:i,role:"status","aria-live":n,"aria-atomic":!0},s)}function CC(){const[t,e]=A.useState("");return{announce:A.useCallback(n=>{n!=null&&e(n)},[]),announcement:t}}const c3=A.createContext(null);function kC(t){const e=A.useContext(c3);A.useEffect(()=>{if(!e)throw new Error("useDndMonitor must be used within a children of <DndContext>");return e(t)},[t,e])}function VC(){const[t]=A.useState(()=>new Set),e=A.useCallback(n=>(t.add(n),()=>t.delete(n)),[t]);return[A.useCallback(n=>{let{type:i,event:o}=n;t.forEach(a=>{var l;return(l=a[i])==null?void 0:l.call(a,o)})},[t]),e]}const NC={draggable:`
|
|
38
|
+
To pick up a draggable item, press the space bar.
|
|
39
|
+
While dragging, use the arrow keys to move the item.
|
|
40
|
+
Press space again to drop the item in its new position, or press escape to cancel.
|
|
41
|
+
`},TC={onDragStart(t){let{active:e}=t;return"Picked up draggable item "+e.id+"."},onDragOver(t){let{active:e,over:s}=t;return s?"Draggable item "+e.id+" was moved over droppable area "+s.id+".":"Draggable item "+e.id+" is no longer over a droppable area."},onDragEnd(t){let{active:e,over:s}=t;return s?"Draggable item "+e.id+" was dropped over droppable area "+s.id:"Draggable item "+e.id+" was dropped."},onDragCancel(t){let{active:e}=t;return"Dragging was cancelled. Draggable item "+e.id+" was dropped."}};function AC(t){let{announcements:e=TC,container:s,hiddenTextDescribedById:n,screenReaderInstructions:i=NC}=t;const{announce:o,announcement:a}=CC(),l=ha("DndLiveRegion"),[c,d]=A.useState(!1);if(A.useEffect(()=>{d(!0)},[]),kC(A.useMemo(()=>({onDragStart(u){let{active:f}=u;o(e.onDragStart({active:f}))},onDragMove(u){let{active:f,over:m}=u;e.onDragMove&&o(e.onDragMove({active:f,over:m}))},onDragOver(u){let{active:f,over:m}=u;o(e.onDragOver({active:f,over:m}))},onDragEnd(u){let{active:f,over:m}=u;o(e.onDragEnd({active:f,over:m}))},onDragCancel(u){let{active:f,over:m}=u;o(e.onDragCancel({active:f,over:m}))}}),[o,e])),!c)return null;const h=it.createElement(it.Fragment,null,it.createElement(wC,{id:n,value:i.draggable}),it.createElement(jC,{id:l,announcement:a}));return s?tr.createPortal(h,s):h}var $t;(function(t){t.DragStart="dragStart",t.DragMove="dragMove",t.DragEnd="dragEnd",t.DragCancel="dragCancel",t.DragOver="dragOver",t.RegisterDroppable="registerDroppable",t.SetDroppableDisabled="setDroppableDisabled",t.UnregisterDroppable="unregisterDroppable"})($t||($t={}));function Tl(){}function si(t,e){return A.useMemo(()=>({sensor:t,options:e??{}}),[t,e])}function gc(){for(var t=arguments.length,e=new Array(t),s=0;s<t;s++)e[s]=arguments[s];return A.useMemo(()=>[...e].filter(n=>n!=null),[...e])}const rn=Object.freeze({x:0,y:0});function d3(t,e){return Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2))}function EC(t,e){const s=Nl(t);if(!s)return"0 0";const n={x:(s.x-e.left)/e.width*100,y:(s.y-e.top)/e.height*100};return n.x+"% "+n.y+"%"}function u3(t,e){let{data:{value:s}}=t,{data:{value:n}}=e;return s-n}function PC(t,e){let{data:{value:s}}=t,{data:{value:n}}=e;return n-s}function Gh(t){let{left:e,top:s,height:n,width:i}=t;return[{x:e,y:s},{x:e+i,y:s},{x:e,y:s+n},{x:e+i,y:s+n}]}function h3(t,e){if(!t||t.length===0)return null;const[s]=t;return s[e]}function Yh(t,e,s){return e===void 0&&(e=t.left),s===void 0&&(s=t.top),{x:e+t.width*.5,y:s+t.height*.5}}const J9=t=>{let{collisionRect:e,droppableRects:s,droppableContainers:n}=t;const i=Yh(e,e.left,e.top),o=[];for(const a of n){const{id:l}=a,c=s.get(l);if(c){const d=d3(Yh(c),i);o.push({id:l,data:{droppableContainer:a,value:d}})}}return o.sort(u3)},RC=t=>{let{collisionRect:e,droppableRects:s,droppableContainers:n}=t;const i=Gh(e),o=[];for(const a of n){const{id:l}=a,c=s.get(l);if(c){const d=Gh(c),h=i.reduce((f,m,p)=>f+d3(d[p],m),0),u=Number((h/4).toFixed(4));o.push({id:l,data:{droppableContainer:a,value:u}})}}return o.sort(u3)};function DC(t,e){const s=Math.max(e.top,t.top),n=Math.max(e.left,t.left),i=Math.min(e.left+e.width,t.left+t.width),o=Math.min(e.top+e.height,t.top+t.height),a=i-n,l=o-s;if(n<i&&s<o){const c=e.width*e.height,d=t.width*t.height,h=a*l,u=h/(c+d-h);return Number(u.toFixed(4))}return 0}const IC=t=>{let{collisionRect:e,droppableRects:s,droppableContainers:n}=t;const i=[];for(const o of n){const{id:a}=o,l=s.get(a);if(l){const c=DC(l,e);c>0&&i.push({id:a,data:{droppableContainer:o,value:c}})}}return i.sort(PC)};function MC(t,e,s){return{...t,scaleX:e&&s?e.width/s.width:1,scaleY:e&&s?e.height/s.height:1}}function f3(t,e){return t&&e?{x:t.left-e.left,y:t.top-e.top}:rn}function OC(t){return function(s){for(var n=arguments.length,i=new Array(n>1?n-1:0),o=1;o<n;o++)i[o-1]=arguments[o];return i.reduce((a,l)=>({...a,top:a.top+t*l.y,bottom:a.bottom+t*l.y,left:a.left+t*l.x,right:a.right+t*l.x}),{...s})}}const $C=OC(1);function m3(t){if(t.startsWith("matrix3d(")){const e=t.slice(9,-1).split(/, /);return{x:+e[12],y:+e[13],scaleX:+e[0],scaleY:+e[5]}}else if(t.startsWith("matrix(")){const e=t.slice(7,-1).split(/, /);return{x:+e[4],y:+e[5],scaleX:+e[0],scaleY:+e[3]}}return null}function BC(t,e,s){const n=m3(e);if(!n)return t;const{scaleX:i,scaleY:o,x:a,y:l}=n,c=t.left-a-(1-i)*parseFloat(s),d=t.top-l-(1-o)*parseFloat(s.slice(s.indexOf(" ")+1)),h=i?t.width/i:t.width,u=o?t.height/o:t.height;return{width:h,height:u,top:d,right:c+h,bottom:d+u,left:c}}const FC={ignoreTransform:!1};function Or(t,e){e===void 0&&(e=FC);let s=t.getBoundingClientRect();if(e.ignoreTransform){const{transform:d,transformOrigin:h}=Ss(t).getComputedStyle(t);d&&(s=BC(s,d,h))}const{top:n,left:i,width:o,height:a,bottom:l,right:c}=s;return{top:n,left:i,width:o,height:a,bottom:l,right:c}}function Jh(t){return Or(t,{ignoreTransform:!0})}function zC(t){const e=t.innerWidth,s=t.innerHeight;return{top:0,left:0,right:e,bottom:s,width:e,height:s}}function KC(t,e){return e===void 0&&(e=Ss(t).getComputedStyle(t)),e.position==="fixed"}function UC(t,e){e===void 0&&(e=Ss(t).getComputedStyle(t));const s=/(auto|scroll|overlay)/;return["overflow","overflowX","overflowY"].some(i=>{const o=e[i];return typeof o=="string"?s.test(o):!1})}function xc(t,e){const s=[];function n(i){if(e!=null&&s.length>=e||!i)return s;if(Y9(i)&&i.scrollingElement!=null&&!s.includes(i.scrollingElement))return s.push(i.scrollingElement),s;if(!da(i)||a3(i)||s.includes(i))return s;const o=Ss(t).getComputedStyle(i);return i!==t&&UC(i,o)&&s.push(i),KC(i,o)?s:n(i.parentNode)}return t?n(t):s}function p3(t){const[e]=xc(t,1);return e??null}function Zc(t){return!fc||!t?null:Ir(t)?t:G9(t)?Y9(t)||t===Mr(t).scrollingElement?window:da(t)?t:null:null}function g3(t){return Ir(t)?t.scrollX:t.scrollLeft}function x3(t){return Ir(t)?t.scrollY:t.scrollTop}function Wd(t){return{x:g3(t),y:x3(t)}}var Wt;(function(t){t[t.Forward=1]="Forward",t[t.Backward=-1]="Backward"})(Wt||(Wt={}));function v3(t){return!fc||!t?!1:t===document.scrollingElement}function b3(t){const e={x:0,y:0},s=v3(t)?{height:window.innerHeight,width:window.innerWidth}:{height:t.clientHeight,width:t.clientWidth},n={x:t.scrollWidth-s.width,y:t.scrollHeight-s.height},i=t.scrollTop<=e.y,o=t.scrollLeft<=e.x,a=t.scrollTop>=n.y,l=t.scrollLeft>=n.x;return{isTop:i,isLeft:o,isBottom:a,isRight:l,maxScroll:n,minScroll:e}}const HC={x:.2,y:.2};function WC(t,e,s,n,i){let{top:o,left:a,right:l,bottom:c}=s;n===void 0&&(n=10),i===void 0&&(i=HC);const{isTop:d,isBottom:h,isLeft:u,isRight:f}=b3(t),m={x:0,y:0},p={x:0,y:0},g={height:e.height*i.y,width:e.width*i.x};return!d&&o<=e.top+g.height?(m.y=Wt.Backward,p.y=n*Math.abs((e.top+g.height-o)/g.height)):!h&&c>=e.bottom-g.height&&(m.y=Wt.Forward,p.y=n*Math.abs((e.bottom-g.height-c)/g.height)),!f&&l>=e.right-g.width?(m.x=Wt.Forward,p.x=n*Math.abs((e.right-g.width-l)/g.width)):!u&&a<=e.left+g.width&&(m.x=Wt.Backward,p.x=n*Math.abs((e.left+g.width-a)/g.width)),{direction:m,speed:p}}function qC(t){if(t===document.scrollingElement){const{innerWidth:o,innerHeight:a}=window;return{top:0,left:0,right:o,bottom:a,width:o,height:a}}const{top:e,left:s,right:n,bottom:i}=t.getBoundingClientRect();return{top:e,left:s,right:n,bottom:i,width:t.clientWidth,height:t.clientHeight}}function y3(t){return t.reduce((e,s)=>or(e,Wd(s)),rn)}function GC(t){return t.reduce((e,s)=>e+g3(s),0)}function YC(t){return t.reduce((e,s)=>e+x3(s),0)}function _3(t,e){if(e===void 0&&(e=Or),!t)return;const{top:s,left:n,bottom:i,right:o}=e(t);p3(t)&&(i<=0||o<=0||s>=window.innerHeight||n>=window.innerWidth)&&t.scrollIntoView({block:"center",inline:"center"})}const JC=[["x",["left","right"],GC],["y",["top","bottom"],YC]];class X9{constructor(e,s){this.rect=void 0,this.width=void 0,this.height=void 0,this.top=void 0,this.bottom=void 0,this.right=void 0,this.left=void 0;const n=xc(s),i=y3(n);this.rect={...e},this.width=e.width,this.height=e.height;for(const[o,a,l]of JC)for(const c of a)Object.defineProperty(this,c,{get:()=>{const d=l(n),h=i[o]-d;return this.rect[c]+h},enumerable:!0});Object.defineProperty(this,"rect",{enumerable:!1})}}class _o{constructor(e){this.target=void 0,this.listeners=[],this.removeAll=()=>{this.listeners.forEach(s=>{var n;return(n=this.target)==null?void 0:n.removeEventListener(...s)})},this.target=e}add(e,s,n){var i;(i=this.target)==null||i.addEventListener(e,s,n),this.listeners.push([e,s,n])}}function XC(t){const{EventTarget:e}=Ss(t);return t instanceof e?t:Mr(t)}function ed(t,e){const s=Math.abs(t.x),n=Math.abs(t.y);return typeof e=="number"?Math.sqrt(s**2+n**2)>e:"x"in e&&"y"in e?s>e.x&&n>e.y:"x"in e?s>e.x:"y"in e?n>e.y:!1}var Hs;(function(t){t.Click="click",t.DragStart="dragstart",t.Keydown="keydown",t.ContextMenu="contextmenu",t.Resize="resize",t.SelectionChange="selectionchange",t.VisibilityChange="visibilitychange"})(Hs||(Hs={}));function Xh(t){t.preventDefault()}function QC(t){t.stopPropagation()}var ot;(function(t){t.Space="Space",t.Down="ArrowDown",t.Right="ArrowRight",t.Left="ArrowLeft",t.Up="ArrowUp",t.Esc="Escape",t.Enter="Enter",t.Tab="Tab"})(ot||(ot={}));const L3={start:[ot.Space,ot.Enter],cancel:[ot.Esc],end:[ot.Space,ot.Enter,ot.Tab]},ZC=(t,e)=>{let{currentCoordinates:s}=e;switch(t.code){case ot.Right:return{...s,x:s.x+25};case ot.Left:return{...s,x:s.x-25};case ot.Down:return{...s,y:s.y+25};case ot.Up:return{...s,y:s.y-25}}};class $r{constructor(e){this.props=void 0,this.autoScrollEnabled=!1,this.referenceCoordinates=void 0,this.listeners=void 0,this.windowListeners=void 0,this.props=e;const{event:{target:s}}=e;this.props=e,this.listeners=new _o(Mr(s)),this.windowListeners=new _o(Ss(s)),this.handleKeyDown=this.handleKeyDown.bind(this),this.handleCancel=this.handleCancel.bind(this),this.attach()}attach(){this.handleStart(),this.windowListeners.add(Hs.Resize,this.handleCancel),this.windowListeners.add(Hs.VisibilityChange,this.handleCancel),setTimeout(()=>this.listeners.add(Hs.Keydown,this.handleKeyDown))}handleStart(){const{activeNode:e,onStart:s}=this.props,n=e.node.current;n&&_3(n),s(rn)}handleKeyDown(e){if(pc(e)){const{active:s,context:n,options:i}=this.props,{keyboardCodes:o=L3,coordinateGetter:a=ZC,scrollBehavior:l="smooth"}=i,{code:c}=e;if(o.end.includes(c)){this.handleEnd(e);return}if(o.cancel.includes(c)){this.handleCancel(e);return}const{collisionRect:d}=n.current,h=d?{x:d.left,y:d.top}:rn;this.referenceCoordinates||(this.referenceCoordinates=h);const u=a(e,{active:s,context:n.current,currentCoordinates:h});if(u){const f=Ko(u,h),m={x:0,y:0},{scrollableAncestors:p}=n.current;for(const g of p){const x=e.code,{isTop:v,isRight:b,isLeft:_,isBottom:y,maxScroll:L,minScroll:w}=b3(g),j=qC(g),S={x:Math.min(x===ot.Right?j.right-j.width/2:j.right,Math.max(x===ot.Right?j.left:j.left+j.width/2,u.x)),y:Math.min(x===ot.Down?j.bottom-j.height/2:j.bottom,Math.max(x===ot.Down?j.top:j.top+j.height/2,u.y))},C=x===ot.Right&&!b||x===ot.Left&&!_,N=x===ot.Down&&!y||x===ot.Up&&!v;if(C&&S.x!==u.x){const V=g.scrollLeft+f.x,E=x===ot.Right&&V<=L.x||x===ot.Left&&V>=w.x;if(E&&!f.y){g.scrollTo({left:V,behavior:l});return}E?m.x=g.scrollLeft-V:m.x=x===ot.Right?g.scrollLeft-L.x:g.scrollLeft-w.x,m.x&&g.scrollBy({left:-m.x,behavior:l});break}else if(N&&S.y!==u.y){const V=g.scrollTop+f.y,E=x===ot.Down&&V<=L.y||x===ot.Up&&V>=w.y;if(E&&!f.x){g.scrollTo({top:V,behavior:l});return}E?m.y=g.scrollTop-V:m.y=x===ot.Down?g.scrollTop-L.y:g.scrollTop-w.y,m.y&&g.scrollBy({top:-m.y,behavior:l});break}}this.handleMove(e,or(Ko(u,this.referenceCoordinates),m))}}}handleMove(e,s){const{onMove:n}=this.props;e.preventDefault(),n(s)}handleEnd(e){const{onEnd:s}=this.props;e.preventDefault(),this.detach(),s()}handleCancel(e){const{onCancel:s}=this.props;e.preventDefault(),this.detach(),s()}detach(){this.listeners.removeAll(),this.windowListeners.removeAll()}}$r.activators=[{eventName:"onKeyDown",handler:(t,e,s)=>{let{keyboardCodes:n=L3,onActivation:i}=e,{active:o}=s;const{code:a}=t.nativeEvent;if(n.start.includes(a)){const l=o.activatorNode.current;return l&&t.target!==l?!1:(t.preventDefault(),i?.({event:t.nativeEvent}),!0)}return!1}}];function Qh(t){return!!(t&&"distance"in t)}function Zh(t){return!!(t&&"delay"in t)}class Q9{constructor(e,s,n){var i;n===void 0&&(n=XC(e.event.target)),this.props=void 0,this.events=void 0,this.autoScrollEnabled=!0,this.document=void 0,this.activated=!1,this.initialCoordinates=void 0,this.timeoutId=null,this.listeners=void 0,this.documentListeners=void 0,this.windowListeners=void 0,this.props=e,this.events=s;const{event:o}=e,{target:a}=o;this.props=e,this.events=s,this.document=Mr(a),this.documentListeners=new _o(this.document),this.listeners=new _o(n),this.windowListeners=new _o(Ss(a)),this.initialCoordinates=(i=Nl(o))!=null?i:rn,this.handleStart=this.handleStart.bind(this),this.handleMove=this.handleMove.bind(this),this.handleEnd=this.handleEnd.bind(this),this.handleCancel=this.handleCancel.bind(this),this.handleKeydown=this.handleKeydown.bind(this),this.removeTextSelection=this.removeTextSelection.bind(this),this.attach()}attach(){const{events:e,props:{options:{activationConstraint:s,bypassActivationConstraint:n}}}=this;if(this.listeners.add(e.move.name,this.handleMove,{passive:!1}),this.listeners.add(e.end.name,this.handleEnd),e.cancel&&this.listeners.add(e.cancel.name,this.handleCancel),this.windowListeners.add(Hs.Resize,this.handleCancel),this.windowListeners.add(Hs.DragStart,Xh),this.windowListeners.add(Hs.VisibilityChange,this.handleCancel),this.windowListeners.add(Hs.ContextMenu,Xh),this.documentListeners.add(Hs.Keydown,this.handleKeydown),s){if(n!=null&&n({event:this.props.event,activeNode:this.props.activeNode,options:this.props.options}))return this.handleStart();if(Zh(s)){this.timeoutId=setTimeout(this.handleStart,s.delay),this.handlePending(s);return}if(Qh(s)){this.handlePending(s);return}}this.handleStart()}detach(){this.listeners.removeAll(),this.windowListeners.removeAll(),setTimeout(this.documentListeners.removeAll,50),this.timeoutId!==null&&(clearTimeout(this.timeoutId),this.timeoutId=null)}handlePending(e,s){const{active:n,onPending:i}=this.props;i(n,e,this.initialCoordinates,s)}handleStart(){const{initialCoordinates:e}=this,{onStart:s}=this.props;e&&(this.activated=!0,this.documentListeners.add(Hs.Click,QC,{capture:!0}),this.removeTextSelection(),this.documentListeners.add(Hs.SelectionChange,this.removeTextSelection),s(e))}handleMove(e){var s;const{activated:n,initialCoordinates:i,props:o}=this,{onMove:a,options:{activationConstraint:l}}=o;if(!i)return;const c=(s=Nl(e))!=null?s:rn,d=Ko(i,c);if(!n&&l){if(Qh(l)){if(l.tolerance!=null&&ed(d,l.tolerance))return this.handleCancel();if(ed(d,l.distance))return this.handleStart()}if(Zh(l)&&ed(d,l.tolerance))return this.handleCancel();this.handlePending(l,d);return}e.cancelable&&e.preventDefault(),a(c)}handleEnd(){const{onAbort:e,onEnd:s}=this.props;this.detach(),this.activated||e(this.props.active),s()}handleCancel(){const{onAbort:e,onCancel:s}=this.props;this.detach(),this.activated||e(this.props.active),s()}handleKeydown(e){e.code===ot.Esc&&this.handleCancel()}removeTextSelection(){var e;(e=this.document.getSelection())==null||e.removeAllRanges()}}const ek={cancel:{name:"pointercancel"},move:{name:"pointermove"},end:{name:"pointerup"}};class Br extends Q9{constructor(e){const{event:s}=e,n=Mr(s.target);super(e,ek,n)}}Br.activators=[{eventName:"onPointerDown",handler:(t,e)=>{let{nativeEvent:s}=t,{onActivation:n}=e;return!s.isPrimary||s.button!==0?!1:(n?.({event:s}),!0)}}];const tk={move:{name:"mousemove"},end:{name:"mouseup"}};var qd;(function(t){t[t.RightClick=2]="RightClick"})(qd||(qd={}));class sk extends Q9{constructor(e){super(e,tk,Mr(e.event.target))}}sk.activators=[{eventName:"onMouseDown",handler:(t,e)=>{let{nativeEvent:s}=t,{onActivation:n}=e;return s.button===qd.RightClick?!1:(n?.({event:s}),!0)}}];const td={cancel:{name:"touchcancel"},move:{name:"touchmove"},end:{name:"touchend"}};class nk extends Q9{constructor(e){super(e,td)}static setup(){return window.addEventListener(td.move.name,e,{capture:!1,passive:!1}),function(){window.removeEventListener(td.move.name,e)};function e(){}}}nk.activators=[{eventName:"onTouchStart",handler:(t,e)=>{let{nativeEvent:s}=t,{onActivation:n}=e;const{touches:i}=s;return i.length>1?!1:(n?.({event:s}),!0)}}];var Lo;(function(t){t[t.Pointer=0]="Pointer",t[t.DraggableRect=1]="DraggableRect"})(Lo||(Lo={}));var Al;(function(t){t[t.TreeOrder=0]="TreeOrder",t[t.ReversedTreeOrder=1]="ReversedTreeOrder"})(Al||(Al={}));function ik(t){let{acceleration:e,activator:s=Lo.Pointer,canScroll:n,draggingRect:i,enabled:o,interval:a=5,order:l=Al.TreeOrder,pointerCoordinates:c,scrollableAncestors:d,scrollableAncestorRects:h,delta:u,threshold:f}=t;const m=ok({delta:u,disabled:!o}),[p,g]=bC(),x=A.useRef({x:0,y:0}),v=A.useRef({x:0,y:0}),b=A.useMemo(()=>{switch(s){case Lo.Pointer:return c?{top:c.y,bottom:c.y,left:c.x,right:c.x}:null;case Lo.DraggableRect:return i}},[s,i,c]),_=A.useRef(null),y=A.useCallback(()=>{const w=_.current;if(!w)return;const j=x.current.x*v.current.x,S=x.current.y*v.current.y;w.scrollBy(j,S)},[]),L=A.useMemo(()=>l===Al.TreeOrder?[...d].reverse():d,[l,d]);A.useEffect(()=>{if(!o||!d.length||!b){g();return}for(const w of L){if(n?.(w)===!1)continue;const j=d.indexOf(w),S=h[j];if(!S)continue;const{direction:C,speed:N}=WC(w,S,b,e,f);for(const V of["x","y"])m[V][C[V]]||(N[V]=0,C[V]=0);if(N.x>0||N.y>0){g(),_.current=w,p(y,a),x.current=N,v.current=C;return}}x.current={x:0,y:0},v.current={x:0,y:0},g()},[e,y,n,g,o,a,JSON.stringify(b),JSON.stringify(m),p,d,L,h,JSON.stringify(f)])}const rk={x:{[Wt.Backward]:!1,[Wt.Forward]:!1},y:{[Wt.Backward]:!1,[Wt.Forward]:!1}};function ok(t){let{delta:e,disabled:s}=t;const n=Vl(e);return ua(i=>{if(s||!n||!i)return rk;const o={x:Math.sign(e.x-n.x),y:Math.sign(e.y-n.y)};return{x:{[Wt.Backward]:i.x[Wt.Backward]||o.x===-1,[Wt.Forward]:i.x[Wt.Forward]||o.x===1},y:{[Wt.Backward]:i.y[Wt.Backward]||o.y===-1,[Wt.Forward]:i.y[Wt.Forward]||o.y===1}}},[s,e,n])}function ak(t,e){const s=e!=null?t.get(e):void 0,n=s?s.node.current:null;return ua(i=>{var o;return e==null?null:(o=n??i)!=null?o:null},[n,e])}function lk(t,e){return A.useMemo(()=>t.reduce((s,n)=>{const{sensor:i}=n,o=i.activators.map(a=>({eventName:a.eventName,handler:e(a.handler,n)}));return[...s,...o]},[]),[t,e])}var Uo;(function(t){t[t.Always=0]="Always",t[t.BeforeDragging=1]="BeforeDragging",t[t.WhileDragging=2]="WhileDragging"})(Uo||(Uo={}));var Gd;(function(t){t.Optimized="optimized"})(Gd||(Gd={}));const ef=new Map;function ck(t,e){let{dragging:s,dependencies:n,config:i}=e;const[o,a]=A.useState(null),{frequency:l,measure:c,strategy:d}=i,h=A.useRef(t),u=x(),f=zo(u),m=A.useCallback(function(v){v===void 0&&(v=[]),!f.current&&a(b=>b===null?v:b.concat(v.filter(_=>!b.includes(_))))},[f]),p=A.useRef(null),g=ua(v=>{if(u&&!s)return ef;if(!v||v===ef||h.current!==t||o!=null){const b=new Map;for(let _ of t){if(!_)continue;if(o&&o.length>0&&!o.includes(_.id)&&_.rect.current){b.set(_.id,_.rect.current);continue}const y=_.node.current,L=y?new X9(c(y),y):null;_.rect.current=L,L&&b.set(_.id,L)}return b}return v},[t,o,s,u,c]);return A.useEffect(()=>{h.current=t},[t]),A.useEffect(()=>{u||m()},[s,u]),A.useEffect(()=>{o&&o.length>0&&a(null)},[JSON.stringify(o)]),A.useEffect(()=>{u||typeof l!="number"||p.current!==null||(p.current=setTimeout(()=>{m(),p.current=null},l))},[l,u,m,...n]),{droppableRects:g,measureDroppableContainers:m,measuringScheduled:o!=null};function x(){switch(d){case Uo.Always:return!1;case Uo.BeforeDragging:return s;default:return!s}}}function Z9(t,e){return ua(s=>t?s||(typeof e=="function"?e(t):t):null,[e,t])}function dk(t,e){return Z9(t,e)}function uk(t){let{callback:e,disabled:s}=t;const n=mc(e),i=A.useMemo(()=>{if(s||typeof window>"u"||typeof window.MutationObserver>"u")return;const{MutationObserver:o}=window;return new o(n)},[n,s]);return A.useEffect(()=>()=>i?.disconnect(),[i]),i}function vc(t){let{callback:e,disabled:s}=t;const n=mc(e),i=A.useMemo(()=>{if(s||typeof window>"u"||typeof window.ResizeObserver>"u")return;const{ResizeObserver:o}=window;return new o(n)},[s]);return A.useEffect(()=>()=>i?.disconnect(),[i]),i}function hk(t){return new X9(Or(t),t)}function tf(t,e,s){e===void 0&&(e=hk);const[n,i]=A.useState(null);function o(){i(c=>{if(!t)return null;if(t.isConnected===!1){var d;return(d=c??s)!=null?d:null}const h=e(t);return JSON.stringify(c)===JSON.stringify(h)?c:h})}const a=uk({callback(c){if(t)for(const d of c){const{type:h,target:u}=d;if(h==="childList"&&u instanceof HTMLElement&&u.contains(t)){o();break}}}}),l=vc({callback:o});return nn(()=>{o(),t?(l?.observe(t),a?.observe(document.body,{childList:!0,subtree:!0})):(l?.disconnect(),a?.disconnect())},[t]),n}function fk(t){const e=Z9(t);return f3(t,e)}const sf=[];function mk(t){const e=A.useRef(t),s=ua(n=>t?n&&n!==sf&&t&&e.current&&t.parentNode===e.current.parentNode?n:xc(t):sf,[t]);return A.useEffect(()=>{e.current=t},[t]),s}function pk(t){const[e,s]=A.useState(null),n=A.useRef(t),i=A.useCallback(o=>{const a=Zc(o.target);a&&s(l=>l?(l.set(a,Wd(a)),new Map(l)):null)},[]);return A.useEffect(()=>{const o=n.current;if(t!==o){a(o);const l=t.map(c=>{const d=Zc(c);return d?(d.addEventListener("scroll",i,{passive:!0}),[d,Wd(d)]):null}).filter(c=>c!=null);s(l.length?new Map(l):null),n.current=t}return()=>{a(t),a(o)};function a(l){l.forEach(c=>{const d=Zc(c);d?.removeEventListener("scroll",i)})}},[i,t]),A.useMemo(()=>t.length?e?Array.from(e.values()).reduce((o,a)=>or(o,a),rn):y3(t):rn,[t,e])}function nf(t,e){e===void 0&&(e=[]);const s=A.useRef(null);return A.useEffect(()=>{s.current=null},e),A.useEffect(()=>{const n=t!==rn;n&&!s.current&&(s.current=t),!n&&s.current&&(s.current=null)},[t]),s.current?Ko(t,s.current):rn}function gk(t){A.useEffect(()=>{if(!fc)return;const e=t.map(s=>{let{sensor:n}=s;return n.setup==null?void 0:n.setup()});return()=>{for(const s of e)s?.()}},t.map(e=>{let{sensor:s}=e;return s}))}function xk(t,e){return A.useMemo(()=>t.reduce((s,n)=>{let{eventName:i,handler:o}=n;return s[i]=a=>{o(a,e)},s},{}),[t,e])}function S3(t){return A.useMemo(()=>t?zC(t):null,[t])}const rf=[];function vk(t,e){e===void 0&&(e=Or);const[s]=t,n=S3(s?Ss(s):null),[i,o]=A.useState(rf);function a(){o(()=>t.length?t.map(c=>v3(c)?n:new X9(e(c),c)):rf)}const l=vc({callback:a});return nn(()=>{l?.disconnect(),a(),t.forEach(c=>l?.observe(c))},[t]),i}function w3(t){if(!t)return null;if(t.children.length>1)return t;const e=t.children[0];return da(e)?e:t}function bk(t){let{measure:e}=t;const[s,n]=A.useState(null),i=A.useCallback(d=>{for(const{target:h}of d)if(da(h)){n(u=>{const f=e(h);return u?{...u,width:f.width,height:f.height}:f});break}},[e]),o=vc({callback:i}),a=A.useCallback(d=>{const h=w3(d);o?.disconnect(),h&&o?.observe(h),n(h?e(h):null)},[e,o]),[l,c]=kl(a);return A.useMemo(()=>({nodeRef:l,rect:s,setRef:c}),[s,l,c])}const yk=[{sensor:Br,options:{}},{sensor:$r,options:{}}],_k={current:{}},qa={draggable:{measure:Jh},droppable:{measure:Jh,strategy:Uo.WhileDragging,frequency:Gd.Optimized},dragOverlay:{measure:Or}};class So extends Map{get(e){var s;return e!=null&&(s=super.get(e))!=null?s:void 0}toArray(){return Array.from(this.values())}getEnabled(){return this.toArray().filter(e=>{let{disabled:s}=e;return!s})}getNodeFor(e){var s,n;return(s=(n=this.get(e))==null?void 0:n.node.current)!=null?s:void 0}}const Lk={activatorEvent:null,active:null,activeNode:null,activeNodeRect:null,collisions:null,containerNodeRect:null,draggableNodes:new Map,droppableRects:new Map,droppableContainers:new So,over:null,dragOverlay:{nodeRef:{current:null},rect:null,setRef:Tl},scrollableAncestors:[],scrollableAncestorRects:[],measuringConfiguration:qa,measureDroppableContainers:Tl,windowRect:null,measuringScheduled:!1},j3={activatorEvent:null,activators:[],active:null,activeNodeRect:null,ariaDescribedById:{draggable:""},dispatch:Tl,draggableNodes:new Map,over:null,measureDroppableContainers:Tl},fa=A.createContext(j3),C3=A.createContext(Lk);function Sk(){return{draggable:{active:null,initialCoordinates:{x:0,y:0},nodes:new Map,translate:{x:0,y:0}},droppable:{containers:new So}}}function wk(t,e){switch(e.type){case $t.DragStart:return{...t,draggable:{...t.draggable,initialCoordinates:e.initialCoordinates,active:e.active}};case $t.DragMove:return t.draggable.active==null?t:{...t,draggable:{...t.draggable,translate:{x:e.coordinates.x-t.draggable.initialCoordinates.x,y:e.coordinates.y-t.draggable.initialCoordinates.y}}};case $t.DragEnd:case $t.DragCancel:return{...t,draggable:{...t.draggable,active:null,initialCoordinates:{x:0,y:0},translate:{x:0,y:0}}};case $t.RegisterDroppable:{const{element:s}=e,{id:n}=s,i=new So(t.droppable.containers);return i.set(n,s),{...t,droppable:{...t.droppable,containers:i}}}case $t.SetDroppableDisabled:{const{id:s,key:n,disabled:i}=e,o=t.droppable.containers.get(s);if(!o||n!==o.key)return t;const a=new So(t.droppable.containers);return a.set(s,{...o,disabled:i}),{...t,droppable:{...t.droppable,containers:a}}}case $t.UnregisterDroppable:{const{id:s,key:n}=e,i=t.droppable.containers.get(s);if(!i||n!==i.key)return t;const o=new So(t.droppable.containers);return o.delete(s),{...t,droppable:{...t.droppable,containers:o}}}default:return t}}function jk(t){let{disabled:e}=t;const{active:s,activatorEvent:n,draggableNodes:i}=A.useContext(fa),o=Vl(n),a=Vl(s?.id);return A.useEffect(()=>{if(!e&&!n&&o&&a!=null){if(!pc(o)||document.activeElement===o.target)return;const l=i.get(a);if(!l)return;const{activatorNode:c,node:d}=l;if(!c.current&&!d.current)return;requestAnimationFrame(()=>{for(const h of[c.current,d.current]){if(!h)continue;const u=LC(h);if(u){u.focus();break}}})}},[n,e,i,a,o]),null}function k3(t,e){let{transform:s,...n}=e;return t!=null&&t.length?t.reduce((i,o)=>o({transform:i,...n}),s):s}function Ck(t){return A.useMemo(()=>({draggable:{...qa.draggable,...t?.draggable},droppable:{...qa.droppable,...t?.droppable},dragOverlay:{...qa.dragOverlay,...t?.dragOverlay}}),[t?.draggable,t?.droppable,t?.dragOverlay])}function kk(t){let{activeNode:e,measure:s,initialRect:n,config:i=!0}=t;const o=A.useRef(!1),{x:a,y:l}=typeof i=="boolean"?{x:i,y:i}:i;nn(()=>{if(!a&&!l||!e){o.current=!1;return}if(o.current||!n)return;const d=e?.node.current;if(!d||d.isConnected===!1)return;const h=s(d),u=f3(h,n);if(a||(u.x=0),l||(u.y=0),o.current=!0,Math.abs(u.x)>0||Math.abs(u.y)>0){const f=p3(d);f&&f.scrollBy({top:u.y,left:u.x})}},[e,a,l,n,s])}const bc=A.createContext({...rn,scaleX:1,scaleY:1});var Kn;(function(t){t[t.Uninitialized=0]="Uninitialized",t[t.Initializing=1]="Initializing",t[t.Initialized=2]="Initialized"})(Kn||(Kn={}));const yc=A.memo(function(e){var s,n,i,o;let{id:a,accessibility:l,autoScroll:c=!0,children:d,sensors:h=yk,collisionDetection:u=IC,measuring:f,modifiers:m,...p}=e;const g=A.useReducer(wk,void 0,Sk),[x,v]=g,[b,_]=VC(),[y,L]=A.useState(Kn.Uninitialized),w=y===Kn.Initialized,{draggable:{active:j,nodes:S,translate:C},droppable:{containers:N}}=x,V=j!=null?S.get(j):null,E=A.useRef({initial:null,translated:null}),T=A.useMemo(()=>{var ze;return j!=null?{id:j,data:(ze=V?.data)!=null?ze:_k,rect:E}:null},[j,V]),k=A.useRef(null),[R,P]=A.useState(null),[D,I]=A.useState(null),M=zo(p,Object.values(p)),O=ha("DndDescribedBy",a),F=A.useMemo(()=>N.getEnabled(),[N]),$=Ck(f),{droppableRects:z,measureDroppableContainers:K,measuringScheduled:X}=ck(F,{dragging:w,dependencies:[C.x,C.y],config:$.droppable}),J=ak(S,j),H=A.useMemo(()=>D?Nl(D):null,[D]),W=ke(),U=dk(J,$.draggable.measure);kk({activeNode:j!=null?S.get(j):null,config:W.layoutShiftCompensation,initialRect:U,measure:$.draggable.measure});const Q=tf(J,$.draggable.measure,U),q=tf(J?J.parentElement:null),Z=A.useRef({activatorEvent:null,active:null,activeNode:J,collisionRect:null,collisions:null,droppableRects:z,draggableNodes:S,draggingNode:null,draggingNodeRect:null,droppableContainers:N,over:null,scrollableAncestors:[],scrollAdjustedTranslate:null}),Y=N.getNodeFor((s=Z.current.over)==null?void 0:s.id),ee=bk({measure:$.dragOverlay.measure}),G=(n=ee.nodeRef.current)!=null?n:J,te=w?(i=ee.rect)!=null?i:Q:null,se=!!(ee.nodeRef.current&&ee.rect),ne=fk(se?null:Q),de=S3(G?Ss(G):null),xe=mk(w?Y??J:null),he=vk(xe),ce=k3(m,{transform:{x:C.x-ne.x,y:C.y-ne.y,scaleX:1,scaleY:1},activatorEvent:D,active:T,activeNodeRect:Q,containerNodeRect:q,draggingNodeRect:te,over:Z.current.over,overlayNodeRect:ee.rect,scrollableAncestors:xe,scrollableAncestorRects:he,windowRect:de}),oe=H?or(H,C):null,me=pk(xe),pe=nf(me),we=nf(me,[Q]),Ne=or(ce,pe),Oe=te?$C(te,ce):null,ye=T&&Oe?u({active:T,collisionRect:Oe,droppableRects:z,droppableContainers:F,pointerCoordinates:oe}):null,je=h3(ye,"id"),[Pe,Ee]=A.useState(null),be=se?ce:or(ce,we),Ve=MC(be,(o=Pe?.rect)!=null?o:null,Q),Re=A.useRef(null),Le=A.useCallback((ze,nt)=>{let{sensor:pt,options:Je}=nt;if(k.current==null)return;const gt=S.get(k.current);if(!gt)return;const dt=ze.nativeEvent,st=new pt({active:k.current,activeNode:gt,event:dt,options:Je,context:Z,onAbort(fe){if(!S.get(fe))return;const{onDragAbort:Qe}=M.current,xt={id:fe};Qe?.(xt),b({type:"onDragAbort",event:xt})},onPending(fe,Me,Qe,xt){if(!S.get(fe))return;const{onDragPending:Vt}=M.current,Ut={id:fe,constraint:Me,initialCoordinates:Qe,offset:xt};Vt?.(Ut),b({type:"onDragPending",event:Ut})},onStart(fe){const Me=k.current;if(Me==null)return;const Qe=S.get(Me);if(!Qe)return;const{onDragStart:xt}=M.current,ls={activatorEvent:dt,active:{id:Me,data:Qe.data,rect:E}};tr.unstable_batchedUpdates(()=>{xt?.(ls),L(Kn.Initializing),v({type:$t.DragStart,initialCoordinates:fe,active:Me}),b({type:"onDragStart",event:ls}),P(Re.current),I(dt)})},onMove(fe){v({type:$t.DragMove,coordinates:fe})},onEnd:ft($t.DragEnd),onCancel:ft($t.DragCancel)});Re.current=st;function ft(fe){return async function(){const{active:Qe,collisions:xt,over:ls,scrollAdjustedTranslate:Vt}=Z.current;let Ut=null;if(Qe&&Vt){const{cancelDrop:is}=M.current;Ut={activatorEvent:dt,active:Qe,collisions:xt,delta:Vt,over:ls},fe===$t.DragEnd&&typeof is=="function"&&await Promise.resolve(is(Ut))&&(fe=$t.DragCancel)}k.current=null,tr.unstable_batchedUpdates(()=>{v({type:fe}),L(Kn.Uninitialized),Ee(null),P(null),I(null),Re.current=null;const is=fe===$t.DragEnd?"onDragEnd":"onDragCancel";if(Ut){const We=M.current[is];We?.(Ut),b({type:is,event:Ut})}})}}},[S]),ve=A.useCallback((ze,nt)=>(pt,Je)=>{const gt=pt.nativeEvent,dt=S.get(Je);if(k.current!==null||!dt||gt.dndKit||gt.defaultPrevented)return;const st={active:dt};ze(pt,nt.options,st)===!0&&(gt.dndKit={capturedBy:nt.sensor},k.current=Je,Le(pt,nt))},[S,Le]),Se=lk(h,ve);gk(h),nn(()=>{Q&&y===Kn.Initializing&&L(Kn.Initialized)},[Q,y]),A.useEffect(()=>{const{onDragMove:ze}=M.current,{active:nt,activatorEvent:pt,collisions:Je,over:gt}=Z.current;if(!nt||!pt)return;const dt={active:nt,activatorEvent:pt,collisions:Je,delta:{x:Ne.x,y:Ne.y},over:gt};tr.unstable_batchedUpdates(()=>{ze?.(dt),b({type:"onDragMove",event:dt})})},[Ne.x,Ne.y]),A.useEffect(()=>{const{active:ze,activatorEvent:nt,collisions:pt,droppableContainers:Je,scrollAdjustedTranslate:gt}=Z.current;if(!ze||k.current==null||!nt||!gt)return;const{onDragOver:dt}=M.current,st=Je.get(je),ft=st&&st.rect.current?{id:st.id,rect:st.rect.current,data:st.data,disabled:st.disabled}:null,fe={active:ze,activatorEvent:nt,collisions:pt,delta:{x:gt.x,y:gt.y},over:ft};tr.unstable_batchedUpdates(()=>{Ee(ft),dt?.(fe),b({type:"onDragOver",event:fe})})},[je]),nn(()=>{Z.current={activatorEvent:D,active:T,activeNode:J,collisionRect:Oe,collisions:ye,droppableRects:z,draggableNodes:S,draggingNode:G,draggingNodeRect:te,droppableContainers:N,over:Pe,scrollableAncestors:xe,scrollAdjustedTranslate:Ne},E.current={initial:te,translated:Oe}},[T,J,ye,Oe,S,G,te,z,N,Pe,xe,Ne]),ik({...W,delta:C,draggingRect:Oe,pointerCoordinates:oe,scrollableAncestors:xe,scrollableAncestorRects:he});const Be=A.useMemo(()=>({active:T,activeNode:J,activeNodeRect:Q,activatorEvent:D,collisions:ye,containerNodeRect:q,dragOverlay:ee,draggableNodes:S,droppableContainers:N,droppableRects:z,over:Pe,measureDroppableContainers:K,scrollableAncestors:xe,scrollableAncestorRects:he,measuringConfiguration:$,measuringScheduled:X,windowRect:de}),[T,J,Q,D,ye,q,ee,S,N,z,Pe,K,xe,he,$,X,de]),Ce=A.useMemo(()=>({activatorEvent:D,activators:Se,active:T,activeNodeRect:Q,ariaDescribedById:{draggable:O},dispatch:v,draggableNodes:S,over:Pe,measureDroppableContainers:K}),[D,Se,T,Q,v,O,S,Pe,K]);return it.createElement(c3.Provider,{value:_},it.createElement(fa.Provider,{value:Ce},it.createElement(C3.Provider,{value:Be},it.createElement(bc.Provider,{value:Ve},d)),it.createElement(jk,{disabled:l?.restoreFocus===!1})),it.createElement(AC,{...l,hiddenTextDescribedById:O}));function ke(){const ze=R?.autoScrollEnabled===!1,nt=typeof c=="object"?c.enabled===!1:c===!1,pt=w&&!ze&&!nt;return typeof c=="object"?{...c,enabled:pt}:{enabled:pt}}}),Vk=A.createContext(null),of="button",Nk="Draggable";function V3(t){let{id:e,data:s,disabled:n=!1,attributes:i}=t;const o=ha(Nk),{activators:a,activatorEvent:l,active:c,activeNodeRect:d,ariaDescribedById:h,draggableNodes:u,over:f}=A.useContext(fa),{role:m=of,roleDescription:p="draggable",tabIndex:g=0}=i??{},x=c?.id===e,v=A.useContext(x?bc:Vk),[b,_]=kl(),[y,L]=kl(),w=xk(a,e),j=zo(s);nn(()=>(u.set(e,{id:e,key:o,node:b,activatorNode:y,data:j}),()=>{const C=u.get(e);C&&C.key===o&&u.delete(e)}),[u,e]);const S=A.useMemo(()=>({role:m,tabIndex:g,"aria-disabled":n,"aria-pressed":x&&m===of?!0:void 0,"aria-roledescription":p,"aria-describedby":h.draggable}),[n,m,g,x,p,h.draggable]);return{active:c,activatorEvent:l,activeNodeRect:d,attributes:S,isDragging:x,listeners:n?void 0:w,node:b,over:f,setNodeRef:_,setActivatorNodeRef:L,transform:v}}function N3(){return A.useContext(C3)}const Tk="Droppable",Ak={timeout:25};function Ek(t){let{data:e,disabled:s=!1,id:n,resizeObserverConfig:i}=t;const o=ha(Tk),{active:a,dispatch:l,over:c,measureDroppableContainers:d}=A.useContext(fa),h=A.useRef({disabled:s}),u=A.useRef(!1),f=A.useRef(null),m=A.useRef(null),{disabled:p,updateMeasurementsFor:g,timeout:x}={...Ak,...i},v=zo(g??n),b=A.useCallback(()=>{if(!u.current){u.current=!0;return}m.current!=null&&clearTimeout(m.current),m.current=setTimeout(()=>{d(Array.isArray(v.current)?v.current:[v.current]),m.current=null},x)},[x]),_=vc({callback:b,disabled:p||!a}),y=A.useCallback((S,C)=>{_&&(C&&(_.unobserve(C),u.current=!1),S&&_.observe(S))},[_]),[L,w]=kl(y),j=zo(e);return A.useEffect(()=>{!_||!L.current||(_.disconnect(),u.current=!1,_.observe(L.current))},[L,_]),A.useEffect(()=>(l({type:$t.RegisterDroppable,element:{id:n,key:o,disabled:s,node:L,rect:f,data:j}}),()=>l({type:$t.UnregisterDroppable,key:o,id:n})),[n]),A.useEffect(()=>{s!==h.current.disabled&&(l({type:$t.SetDroppableDisabled,id:n,key:o,disabled:s}),h.current.disabled=s)},[n,o,s,l]),{active:a,rect:f,isOver:c?.id===n,node:L,over:c,setNodeRef:w}}function Pk(t){let{animation:e,children:s}=t;const[n,i]=A.useState(null),[o,a]=A.useState(null),l=Vl(s);return!s&&!n&&l&&i(l),nn(()=>{if(!o)return;const c=n?.key,d=n?.props.id;if(c==null||d==null){i(null);return}Promise.resolve(e(d,o)).then(()=>{i(null)})},[e,n,o]),it.createElement(it.Fragment,null,s,n?A.cloneElement(n,{ref:a}):null)}const Rk={x:0,y:0,scaleX:1,scaleY:1};function Dk(t){let{children:e}=t;return it.createElement(fa.Provider,{value:j3},it.createElement(bc.Provider,{value:Rk},e))}const Ik={position:"fixed",touchAction:"none"},Mk=t=>pc(t)?"transform 250ms ease":void 0,Ok=A.forwardRef((t,e)=>{let{as:s,activatorEvent:n,adjustScale:i,children:o,className:a,rect:l,style:c,transform:d,transition:h=Mk}=t;if(!l)return null;const u=i?d:{...d,scaleX:1,scaleY:1},f={...Ik,width:l.width,height:l.height,top:l.top,left:l.left,transform:Ln.Transform.toString(u),transformOrigin:i&&n?EC(n,l):void 0,transition:typeof h=="function"?h(n):h,...c};return it.createElement(s,{className:a,style:f,ref:e},o)}),$k=t=>e=>{let{active:s,dragOverlay:n}=e;const i={},{styles:o,className:a}=t;if(o!=null&&o.active)for(const[l,c]of Object.entries(o.active))c!==void 0&&(i[l]=s.node.style.getPropertyValue(l),s.node.style.setProperty(l,c));if(o!=null&&o.dragOverlay)for(const[l,c]of Object.entries(o.dragOverlay))c!==void 0&&n.node.style.setProperty(l,c);return a!=null&&a.active&&s.node.classList.add(a.active),a!=null&&a.dragOverlay&&n.node.classList.add(a.dragOverlay),function(){for(const[c,d]of Object.entries(i))s.node.style.setProperty(c,d);a!=null&&a.active&&s.node.classList.remove(a.active)}},Bk=t=>{let{transform:{initial:e,final:s}}=t;return[{transform:Ln.Transform.toString(e)},{transform:Ln.Transform.toString(s)}]},Fk={duration:250,easing:"ease",keyframes:Bk,sideEffects:$k({styles:{active:{opacity:"0"}}})};function zk(t){let{config:e,draggableNodes:s,droppableContainers:n,measuringConfiguration:i}=t;return mc((o,a)=>{if(e===null)return;const l=s.get(o);if(!l)return;const c=l.node.current;if(!c)return;const d=w3(a);if(!d)return;const{transform:h}=Ss(a).getComputedStyle(a),u=m3(h);if(!u)return;const f=typeof e=="function"?e:Kk(e);return _3(c,i.draggable.measure),f({active:{id:o,data:l.data,node:c,rect:i.draggable.measure(c)},draggableNodes:s,dragOverlay:{node:a,rect:i.dragOverlay.measure(d)},droppableContainers:n,measuringConfiguration:i,transform:u})})}function Kk(t){const{duration:e,easing:s,sideEffects:n,keyframes:i}={...Fk,...t};return o=>{let{active:a,dragOverlay:l,transform:c,...d}=o;if(!e)return;const h={x:l.rect.left-a.rect.left,y:l.rect.top-a.rect.top},u={scaleX:c.scaleX!==1?a.rect.width*c.scaleX/l.rect.width:1,scaleY:c.scaleY!==1?a.rect.height*c.scaleY/l.rect.height:1},f={x:c.x-h.x,y:c.y-h.y,...u},m=i({...d,active:a,dragOverlay:l,transform:{initial:c,final:f}}),[p]=m,g=m[m.length-1];if(JSON.stringify(p)===JSON.stringify(g))return;const x=n?.({active:a,dragOverlay:l,...d}),v=l.node.animate(m,{duration:e,easing:s,fill:"forwards"});return new Promise(b=>{v.onfinish=()=>{x?.(),b()}})}}let af=0;function Uk(t){return A.useMemo(()=>{if(t!=null)return af++,af},[t])}const eu=it.memo(t=>{let{adjustScale:e=!1,children:s,dropAnimation:n,style:i,transition:o,modifiers:a,wrapperElement:l="div",className:c,zIndex:d=999}=t;const{activatorEvent:h,active:u,activeNodeRect:f,containerNodeRect:m,draggableNodes:p,droppableContainers:g,dragOverlay:x,over:v,measuringConfiguration:b,scrollableAncestors:_,scrollableAncestorRects:y,windowRect:L}=N3(),w=A.useContext(bc),j=Uk(u?.id),S=k3(a,{activatorEvent:h,active:u,activeNodeRect:f,containerNodeRect:m,draggingNodeRect:x.rect,over:v,overlayNodeRect:x.rect,scrollableAncestors:_,scrollableAncestorRects:y,transform:w,windowRect:L}),C=Z9(f),N=zk({config:n,draggableNodes:p,droppableContainers:g,measuringConfiguration:b}),V=C?x.setRef:void 0;return it.createElement(Dk,null,it.createElement(Pk,{animation:N},u&&j?it.createElement(Ok,{key:j,id:u.id,ref:V,as:l,activatorEvent:h,adjustScale:e,className:c,transition:o,rect:C,style:{zIndex:d,...i},transform:S},s):null))}),on=6,Vn=100,lf=12,Hk=5,Wk={w:3,h:2};class Yd extends A.Component{state={hasError:!1,t:void 0};static getDerivedStateFromError(e){return{hasError:!0,message:e instanceof Error?e.message:"Unknown error"}}componentDidCatch(e,s){console.error("[home-tiles] tile crashed:",e,s.componentStack)}render(){return this.state.hasError?r.jsx(Gk,{message:this.state.message}):r.jsx(qk,{children:this.props.children})}}function qk(t){const e=B.c(2),{children:s}=t;let n;return e[0]!==s?(n=r.jsx(r.Fragment,{children:s}),e[0]=s,e[1]=n):n=e[1],n}function Gk(t){const e=B.c(13),{message:s}=t,n=re();let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i=r.jsx("span",{className:"flex size-8 items-center justify-center rounded-md bg-destructive/10 text-destructive",children:r.jsx(Sr,{size:16})}),e[0]=i):i=e[0];let o;e[1]!==n?(o=n("home.tileErrorBoundary.tileCrashed"),e[1]=n,e[2]=o):o=e[2];let a;e[3]!==o?(a=r.jsx("p",{className:"text-sm font-medium text-foreground",children:o}),e[3]=o,e[4]=a):a=e[4];let l;e[5]!==s||e[6]!==n?(l=s??n("home.tileErrorBoundary.defaultError"),e[5]=s,e[6]=n,e[7]=l):l=e[7];let c;e[8]!==l?(c=r.jsx("p",{className:"text-xs text-muted-foreground line-clamp-2",children:l}),e[8]=l,e[9]=c):c=e[9];let d;return e[10]!==a||e[11]!==c?(d=r.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-2 p-4 text-center",children:[i,a,c]}),e[10]=a,e[11]=c,e[12]=d):d=e[12],d}function Yk(t){const e=B.c(72),{tiles:s,isEditMode:n,renderTile:i,onMove:o,onResize:a,onRemove:l}=t,c=Cr(),d=A.useRef(null),[h,u]=A.useState(null),[f,m]=A.useState(null);let p;e[0]===Symbol.for("react.memo_cache_sentinel")?(p={activationConstraint:{distance:4}},e[0]=p):p=e[0];const g=gc(si(Br,p),si($r)),x=s.reduce(Jk,0),v=n?Math.max(x+2,4):Math.max(x,1);let b;e[1]===Symbol.for("react.memo_cache_sentinel")?(b=()=>{const M=d.current?.getBoundingClientRect();return M?{cellWidth:M.width/on,cellHeight:Vn}:null},e[1]=b):b=e[1];const _=b;let y;e[2]===Symbol.for("react.memo_cache_sentinel")?(y=M=>{u(String(M.active.id)),m(_())},e[2]=y):y=e[2];const L=y;let w;e[3]!==f||e[4]!==o||e[5]!==s?(w=M=>{const O=String(M.active.id),F=f??_();if(u(null),m(null),!F||F.cellWidth<=0)return;const $=s.find(X=>X.id===O);if(!$)return;const z=Math.round(M.delta.x/F.cellWidth),K=Math.round(M.delta.y/F.cellHeight);z===0&&K===0||o(O,{x:$.x+z,y:$.y+K})},e[3]=f,e[4]=o,e[5]=s,e[6]=w):w=e[6];const j=w;if(c){let M;if(e[7]!==i||e[8]!==s){let F;e[10]!==i?(F=$=>r.jsx("div",{className:"group bg-card card-shadow rounded-2xl overflow-hidden",style:{minHeight:Vn},children:r.jsx(Yd,{children:i($)})},$.id),e[10]=i,e[11]=F):F=e[11],M=s.map(F),e[7]=i,e[8]=s,e[9]=M}else M=e[9];let O;return e[12]!==M?(O=r.jsx("div",{className:"flex flex-col gap-3 px-4 pb-8",children:M}),e[12]=M,e[13]=O):O=e[13],O}let S,C,N,V,E,T,k,R,P;if(e[14]!==h||e[15]!==f||e[16]!==n||e[17]!==j||e[18]!==l||e[19]!==a||e[20]!==i||e[21]!==g||e[22]!==s||e[23]!==v){const M=h?s.find(H=>H.id===h):null;C=yc,R=g,P=L,N=j;const O=v*Vn,F=n?Vn*4:Vn;let $;e[33]!==O||e[34]!==F?($={height:O,minHeight:F},e[33]=O,e[34]=F,e[35]=$):$=e[35];let z;e[36]!==n||e[37]!==s||e[38]!==v?(z=n&&r.jsx(Xk,{rows:v,tiles:s}),e[36]=n,e[37]=s,e[38]=v,e[39]=z):z=e[39];let K;if(e[40]!==h||e[41]!==n||e[42]!==l||e[43]!==a||e[44]!==i||e[45]!==s){let H;e[47]!==h||e[48]!==n||e[49]!==l||e[50]!==a||e[51]!==i?(H=W=>r.jsx(Zk,{tile:W,isEditMode:n,isDragging:h===W.id,onResize:a,onRemove:l,children:i(W)},W.id),e[47]=h,e[48]=n,e[49]=l,e[50]=a,e[51]=i,e[52]=H):H=e[52],K=s.map(H),e[40]=h,e[41]=n,e[42]=l,e[43]=a,e[44]=i,e[45]=s,e[46]=K}else K=e[46];e[53]!==$||e[54]!==z||e[55]!==K?(V=r.jsxs("div",{ref:d,className:"relative w-full",style:$,children:[z,K]}),e[53]=$,e[54]=z,e[55]=K,e[56]=V):V=e[56],S=eu,E=null;const X=M&&f?M.w*f.cellWidth-lf:void 0,J=M&&f?M.h*f.cellHeight-lf:void 0;e[57]!==X||e[58]!==J?(T={width:X,height:J},e[57]=X,e[58]=J,e[59]=T):T=e[59],k=M&&r.jsx("div",{className:"bg-card card-shadow rounded-2xl shadow-2xl ring-2 ring-primary/40 h-full overflow-hidden opacity-95",children:r.jsx(Yd,{children:i(M)})}),e[14]=h,e[15]=f,e[16]=n,e[17]=j,e[18]=l,e[19]=a,e[20]=i,e[21]=g,e[22]=s,e[23]=v,e[24]=S,e[25]=C,e[26]=N,e[27]=V,e[28]=E,e[29]=T,e[30]=k,e[31]=R,e[32]=P}else S=e[24],C=e[25],N=e[26],V=e[27],E=e[28],T=e[29],k=e[30],R=e[31],P=e[32];let D;e[60]!==S||e[61]!==E||e[62]!==T||e[63]!==k?(D=r.jsx(S,{dropAnimation:E,style:T,children:k}),e[60]=S,e[61]=E,e[62]=T,e[63]=k,e[64]=D):D=e[64];let I;return e[65]!==C||e[66]!==N||e[67]!==V||e[68]!==D||e[69]!==R||e[70]!==P?(I=r.jsxs(C,{sensors:R,onDragStart:P,onDragEnd:N,children:[V,D]}),e[65]=C,e[66]=N,e[67]=V,e[68]=D,e[69]=R,e[70]=P,e[71]=I):I=e[71],I}function Jk(t,e){return Math.max(t,e.y+e.h)}function Xk(t){const e=B.c(7),{rows:s,tiles:n}=t;let i;e[0]!==n?(i=(c,d)=>n.some(h=>c>=h.x&&c<h.x+h.w&&d>=h.y&&d<h.y+h.h),e[0]=n,e[1]=i):i=e[1];const o=i;let a;if(e[2]!==o||e[3]!==s){a=[];for(let c=0;c<s;c++)for(let d=0;d<on;d++)o(d,c)||a.push({x:d,y:c});e[2]=o,e[3]=s,e[4]=a}else a=e[4];let l;return e[5]!==a?(l=r.jsx("div",{className:"absolute inset-0 pointer-events-none",children:a.map(Qk)}),e[5]=a,e[6]=l):l=e[6],l}function Qk(t){return r.jsx("div",{className:"absolute p-1",style:{left:`${t.x/on*100}%`,top:t.y*Vn,width:`${1/on*100}%`,height:Vn},children:r.jsx("div",{className:"h-full w-full rounded-2xl border border-dashed border-border/60"})},`${t.x}-${t.y}`)}function Zk(t){const e=B.c(32),{tile:s,isEditMode:n,isDragging:i,onResize:o,onRemove:a,children:l}=t,c=re(),d=!n;let h;e[0]!==d||e[1]!==s.id?(h={id:s.id,disabled:d},e[0]=d,e[1]=s.id,e[2]=h):h=e[2];const{setNodeRef:u,attributes:f,listeners:m,isDragging:p}=V3(h),g=`${s.x/on*100}%`,x=`${s.w/on*100}%`,v=s.y*Vn,b=s.h*Vn,_=p||i,y=!_&&"transition-[left,top,width,height,opacity] duration-200 ease-out",L=_&&"opacity-30";let w;e[3]!==y||e[4]!==L?(w=ie("absolute p-1 will-change-[left,top,width,height,opacity]",y,L),e[3]=y,e[4]=L,e[5]=w):w=e[5];let j;e[6]!==b||e[7]!==g||e[8]!==v||e[9]!==x?(j={left:g,top:v,width:x,height:b},e[6]=b,e[7]=g,e[8]=v,e[9]=x,e[10]=j):j=e[10];const S=n&&"outline outline-1 outline-transparent hover:outline-primary/40";let C;e[11]!==S?(C=ie("group relative h-full bg-card card-shadow rounded-2xl overflow-hidden",S),e[11]=S,e[12]=C):C=e[12];let N;e[13]!==f||e[14]!==n||e[15]!==m||e[16]!==a||e[17]!==o||e[18]!==c||e[19]!==s?(N=n&&r.jsxs(r.Fragment,{children:[r.jsx("button",{type:"button",...f,...m,className:"absolute top-2 left-2 z-10 flex size-8 items-center justify-center rounded-md bg-background/90 border border-border text-muted-foreground hover:text-foreground hover:bg-muted cursor-grab active:cursor-grabbing","aria-label":c("home.tileBoard.dragTileAriaLabel"),children:r.jsx(oa,{size:16})}),r.jsx("div",{className:"absolute top-2 right-2 z-10 flex items-center gap-1",children:r.jsx(eV,{tile:s,onResize:o,onRemove:a})})]}),e[13]=f,e[14]=n,e[15]=m,e[16]=a,e[17]=o,e[18]=c,e[19]=s,e[20]=N):N=e[20];let V;e[21]!==l?(V=r.jsx("div",{className:"h-full overflow-hidden",children:r.jsx(Yd,{children:l})}),e[21]=l,e[22]=V):V=e[22];let E;e[23]!==V||e[24]!==C||e[25]!==N?(E=r.jsxs("div",{className:C,children:[N,V]}),e[23]=V,e[24]=C,e[25]=N,e[26]=E):E=e[26];let T;return e[27]!==u||e[28]!==E||e[29]!==w||e[30]!==j?(T=r.jsx("div",{ref:u,className:w,style:j,children:E}),e[27]=u,e[28]=E,e[29]=w,e[30]=j,e[31]=T):T=e[31],T}function eV(t){const e=B.c(28),{tile:s,onResize:n,onRemove:i}=t,[o,a]=A.useState(!1),l=re();let c;e[0]!==l?(c=l("home.tileBoard.tileOptionsAriaLabel"),e[0]=l,e[1]=c):c=e[1];let d;e[2]===Symbol.for("react.memo_cache_sentinel")?(d=r.jsx(ai,{size:16}),e[2]=d):d=e[2];let h;e[3]!==c?(h=r.jsx(ds,{asChild:!0,children:r.jsx("button",{type:"button",className:"flex size-8 items-center justify-center rounded-md bg-background/90 border border-border text-muted-foreground hover:text-foreground hover:bg-muted","aria-label":c,children:d})}),e[3]=c,e[4]=h):h=e[4];let u;e[5]!==n||e[6]!==s.id?(u=y=>{n(s.id,y),a(!1)},e[5]=n,e[6]=s.id,e[7]=u):u=e[7];let f;e[8]!==u||e[9]!==s?(f=r.jsx(tV,{tile:s,onPick:u}),e[8]=u,e[9]=s,e[10]=f):f=e[10];let m;e[11]===Symbol.for("react.memo_cache_sentinel")?(m=r.jsx(rr,{}),e[11]=m):m=e[11];let p;e[12]!==i||e[13]!==s.id?(p=()=>i(s.id),e[12]=i,e[13]=s.id,e[14]=p):p=e[14];let g;e[15]===Symbol.for("react.memo_cache_sentinel")?(g=r.jsx(Ns,{size:14,className:"mr-2"}),e[15]=g):g=e[15];let x;e[16]!==l?(x=l("home.tileBoard.removeTile"),e[16]=l,e[17]=x):x=e[17];let v;e[18]!==p||e[19]!==x?(v=r.jsxs(Xe,{onSelect:p,className:"text-destructive focus:text-destructive",children:[g,x]}),e[18]=p,e[19]=x,e[20]=v):v=e[20];let b;e[21]!==v||e[22]!==f?(b=r.jsxs(hs,{align:"end",className:"w-auto",children:[f,m,v]}),e[21]=v,e[22]=f,e[23]=b):b=e[23];let _;return e[24]!==o||e[25]!==b||e[26]!==h?(_=r.jsxs(us,{open:o,onOpenChange:a,children:[h,b]}),e[24]=o,e[25]=b,e[26]=h,e[27]=_):_=e[27],_}function tV(t){const e=B.c(26),{tile:s,onPick:n}=t,i=s.minW??1,o=s.minH??1,[a,l]=A.useState(null);let c;e[0]!==a||e[1]!==s.h||e[2]!==s.w?(c=a??{w:s.w,h:s.h},e[0]=a,e[1]=s.h,e[2]=s.w,e[3]=c):c=e[3];const d=c,h=re();let u;e[4]!==h?(u=h("home.tileBoard.sizeLabel"),e[4]=h,e[5]=u):u=e[5];let f;e[6]!==u?(f=r.jsx("span",{className:"text-xs text-muted-foreground",children:u}),e[6]=u,e[7]=f):f=e[7];let m;e[8]!==d.h||e[9]!==d.w?(m=r.jsxs("span",{className:"text-xs font-medium tabular-nums",children:[d.w," × ",d.h]}),e[8]=d.h,e[9]=d.w,e[10]=m):m=e[10];let p;e[11]!==f||e[12]!==m?(p=r.jsxs("div",{className:"mb-2 flex items-center justify-between gap-4",children:[f,m]}),e[11]=f,e[12]=m,e[13]=p):p=e[13];let g,x;e[14]===Symbol.for("react.memo_cache_sentinel")?(g={gridTemplateColumns:`repeat(${on}, 1.25rem)`},x=()=>l(null),e[14]=g,e[15]=x):(g=e[14],x=e[15]);let v;e[16]!==d.h||e[17]!==d.w||e[18]!==o||e[19]!==i||e[20]!==n||e[21]!==h?(v=r.jsx("div",{className:"grid w-max gap-1",style:g,onPointerLeave:x,children:Array.from({length:Hk},(_,y)=>Array.from({length:on},(L,w)=>{const j=w+1,S=y+1,C=j<i||S<o,N=j<=d.w&&S<=d.h;return r.jsx("button",{type:"button",disabled:C,"aria-label":h("home.tileBoard.sizeGridCellAriaLabel",{w:j,h:S}),onPointerEnter:()=>l({w:j,h:S}),onClick:()=>n({w:j,h:S}),className:ie("size-5 rounded-sm border transition-colors",N?"border-primary bg-primary/30":"border-border bg-muted",C?"cursor-not-allowed opacity-40":"cursor-pointer hover:border-primary/60")},`${j}x${S}`)}))}),e[16]=d.h,e[17]=d.w,e[18]=o,e[19]=i,e[20]=n,e[21]=h,e[22]=v):v=e[22];let b;return e[23]!==p||e[24]!==v?(b=r.jsxs("div",{className:"px-2 py-1.5",children:[p,v]}),e[23]=p,e[24]=v,e[25]=b):b=e[25],b}function sV(t,e,s){return t.some(n=>e>=n.x&&e<n.x+n.w&&s>=n.y&&s<n.y+n.h)}function Jd(t,e,s){for(let n=0;n<100;n++)for(let i=0;i<=on-e;i++){let o=!0;for(let a=0;a<s&&o;a++)for(let l=0;l<e&&o;l++)sV(t,i+l,n+a)&&(o=!1);if(o)return{x:i,y:n}}return{x:0,y:0}}function sd(t,e,s={w:1,h:1}){const n=Math.max(s.w,Math.min(on,t)),i=Math.max(s.h,Math.min(6,e));return{w:n,h:i}}function nd(t,e,s){const n=Math.max(0,Math.min(on-s,t)),i=Math.max(0,e);return{x:n,y:i}}function nV(t,e,s){const n=t.find(c=>c.id===e);if(!n)return t;const i=t.filter(c=>c.id!==e),o=i.find(c=>s.x>=c.x&&s.x<c.x+c.w&&s.y>=c.y&&s.y<c.y+c.h);if(o&&o.w===n.w&&o.h===n.h)return t.map(c=>c.id===e?{...c,x:o.x,y:o.y}:c.id===o.id?{...c,x:n.x,y:n.y}:c);const l=[{...n,x:s.x,y:s.y}];for(const c of i){const d=Jd(l,c.w,c.h);l.push({...c,x:d.x,y:d.y})}return l}function iV(t){const e=B.c(42),{layout:s,isLayoutLoading:n,commitLayout:i}=q9();let o;e[0]!==s.hidden?(o=new Set(s.hidden),e[0]=s.hidden,e[1]=o):o=e[1];const a=o;let l;e[2]!==s.shown?(l=s.shown??[],e[2]=s.shown,e[3]=l):l=e[3];let c;e[4]!==l?(c=new Set(l),e[4]=l,e[5]=c):c=e[5];const d=c;let h,u;if(e[6]!==t||e[7]!==a||e[8]!==s.tiles||e[9]!==d){u=[];let L;e[12]!==a||e[13]!==d?(L=j=>j.pinned?!0:j.defaultHidden?d.has(j.id)&&!a.has(j.id):!a.has(j.id),e[12]=a,e[13]=d,e[14]=L):L=e[14];const w=t.filter(L);h=new Map;for(const j of t)j.minSize&&h.set(j.id,j.minSize);for(const j of w){const S=s.tiles[j.id];if(!S)continue;const C=h.get(j.id),{w:N,h:V}=sd(S.w,S.h,C),{x:E,y:T}=nd(S.x,S.y,N);u.push({id:j.id,x:E,y:T,w:N,h:V,minW:C?.w,minH:C?.h})}for(const j of w){if(u.some(T=>T.id===j.id))continue;const S=j.defaultSize??Wk,C=h.get(j.id),{w:N,h:V}=sd(S.w,S.h,C),E=Jd(u,N,V);u.push({id:j.id,x:E.x,y:E.y,w:N,h:V,minW:C?.w,minH:C?.h})}e[6]=t,e[7]=a,e[8]=s.tiles,e[9]=d,e[10]=h,e[11]=u}else h=e[10],u=e[11];let f;e[15]!==t?(f=new Set(t.map(rV)),e[15]=t,e[16]=f):f=e[16];const m=f;let p;e[17]!==m||e[18]!==i||e[19]!==s?(p=(L,w)=>{const j={};for(const S of L)j[S.id]={x:S.x,y:S.y,w:S.w,h:S.h};i({version:yr,tiles:j,hidden:w.filter(S=>m.has(S)),shown:(s.shown??[]).filter(S=>m.has(S))})},e[17]=m,e[18]=i,e[19]=s,e[20]=p):p=e[20];const g=p;let x;e[21]!==u?(x={visible:u},e[21]=u,e[22]=x):x=e[22];let v;e[23]!==g||e[24]!==s||e[25]!==u?(v=(L,w)=>{const j=u.find(N=>N.id===L);if(!j)return;const S=nd(w.x,w.y,j.w);if(S.x===j.x&&S.y===j.y)return;const C=nV(u,L,S);g(C,s.hidden)},e[23]=g,e[24]=s,e[25]=u,e[26]=v):v=e[26];let b;e[27]!==g||e[28]!==s||e[29]!==h||e[30]!==u?(b=(L,w)=>{const j=u.find(k=>k.id===L);if(!j)return;const S=h.get(L),{w:C,h:N}=sd(w.w,w.h,S);if(C===j.w&&N===j.h)return;const V={...j,w:C,h:N,x:nd(j.x,j.y,C).x},E=u.filter(k=>k.id!==L),T=[V];for(const k of E){const R=Jd(T,k.w,k.h);T.push({...k,x:R.x,y:R.y})}g(T,s.hidden)},e[27]=g,e[28]=s,e[29]=h,e[30]=u,e[31]=b):b=e[31];let _;e[32]!==g||e[33]!==s||e[34]!==u?(_=L=>{const w=u.filter(j=>j.id!==L);g(w,Array.from(new Set([...s.hidden,L])))},e[32]=g,e[33]=s,e[34]=u,e[35]=_):_=e[35];let y;return e[36]!==n||e[37]!==x||e[38]!==v||e[39]!==b||e[40]!==_?(y={snapshot:x,isLoading:n,moveTile:v,resizeTile:b,hideTile:_},e[36]=n,e[37]=x,e[38]=v,e[39]=b,e[40]=_,e[41]=y):y=e[41],y}function rV(t){return t.id}const oV=3,aV=5;function lV(t){const e=B.c(17),{org:s}=Fe();let n;e[0]!==s.id||e[1]!==s.slug?(n={connectionId:Qo,orgId:s.id,orgSlug:s.slug},e[0]=s.id,e[1]=s.slug,e[2]=n):n=e[2];const i=ht(n);let o;e[3]!==t||e[4]!==s.id||e[5]!==s.slug?(o={connectionId:t,orgId:s.id,orgSlug:s.slug},e[3]=t,e[4]=s.id,e[5]=s.slug,e[6]=o):o=e[6];const a=ht(o);let l;e[7]!==t||e[8]!==s.id?(l=at.homeGithubRecentPrs(s.id,t),e[7]=t,e[8]=s.id,e[9]=l):l=e[9];let c;e[10]!==t||e[11]!==a||e[12]!==i?(c=async()=>{const{installations:h}=await T2(b=>i.callTool(b),t),u=h[0];if(!u)return{repos:[]};const f=u.type==="User"?"user":"org",p=(await a.callTool({name:"search_repositories",arguments:{query:`${f}:${u.login}`,page:1,perPage:30}})).content?.[0]?.text,x=[...p?JSON.parse(p).items??[]:[]].sort(fV).filter(hV).slice(0,oV);return x.length===0?{repos:[]}:{repos:(await Promise.all(x.map(async b=>{const[_,y]=b.full_name.split("/"),L=await a.callTool({name:"list_pull_requests",arguments:{owner:_,repo:y,state:"all",perPage:aV}}),w=rc(L).map(uV).filter(dV);return{repo:b.full_name,prs:w}}))).filter(cV)}},e[10]=t,e[11]=a,e[12]=i,e[13]=c):c=e[13];let d;return e[14]!==l||e[15]!==c?(d={queryKey:l,queryFn:c,staleTime:6e4,retry:!1},e[14]=l,e[15]=c,e[16]=d):d=e[16],Ft(d)}function cV(t){return t.prs.length>0}function dV(t){return t.number>0}function uV(t){return{number:t.number??0,title:t.title??"",merged:t.merged_at!=null,state:t.state==="closed"?"closed":"open",htmlUrl:t.html_url??""}}function hV(t){return t.full_name}function fV(t,e){return(e.updated_at??"").localeCompare(t.updated_at??"")}const ar=26,mV=7;function pV(t){const e=B.c(17),{org:s}=Fe();let n;e[0]!==s.id||e[1]!==s.slug?(n={connectionId:Qo,orgId:s.id,orgSlug:s.slug},e[0]=s.id,e[1]=s.slug,e[2]=n):n=e[2];const i=ht(n);let o;e[3]!==t||e[4]!==s.id||e[5]!==s.slug?(o={connectionId:t,orgId:s.id,orgSlug:s.slug},e[3]=t,e[4]=s.id,e[5]=s.slug,e[6]=o):o=e[6];const a=ht(o);let l;e[7]!==t||e[8]!==s.id?(l=at.homeGithubContributions(s.id,t),e[7]=t,e[8]=s.id,e[9]=l):l=e[9];let c;e[10]!==t||e[11]!==a||e[12]!==i?(c=async()=>{const{installations:h}=await T2(C=>i.callTool(C),t),u=h[0];if(!u)return id();const f=u.type==="User"?"user":"org",p=(await a.callTool({name:"search_repositories",arguments:{query:`${f}:${u.login}`,page:1,perPage:30}})).content?.[0]?.text,x=[...p?JSON.parse(p).items??[]:[]].sort(gV)[0];if(!x?.full_name)return id();const[v,b]=x.full_name.split("/"),_=new Date(Date.now()-ar*7*864e5),L=(await a.callTool({name:"list_commits",arguments:{owner:v,repo:b,since:_.toISOString(),perPage:100}})).content?.[0]?.text,w=L?JSON.parse(L):[],j=id(),S=Date.now();for(const C of w){const N=C.commit?.committer?.date??C.commit?.author?.date??"",V=new Date(N);if(isNaN(V.getTime()))continue;const E=Math.floor((S-V.getTime())/864e5);if(E<0||E>=ar*7)continue;const T=ar-1-Math.floor(E/7),k=V.getDay(),R=j[T];R&&(R[k]=(R[k]??0)+1)}return j},e[10]=t,e[11]=a,e[12]=i,e[13]=c):c=e[13];let d;return e[14]!==l||e[15]!==c?(d={queryKey:l,queryFn:c,staleTime:3e5,retry:!1},e[14]=l,e[15]=c,e[16]=d):d=e[16],Ft(d)}function gV(t,e){return(e.updated_at??"").localeCompare(t.updated_at??"")}function id(){return Array.from({length:ar},()=>Array.from({length:mV},()=>0))}const T3="pageviews",A3="sessions",E3="orders",P3="coding",R3="revenue",D3="recent-conversations",tu=[{id:T3,titleKey:"home.nativeTiles.pageviews",defaultSize:{w:2,h:3},minSize:{w:1,h:2}},{id:A3,titleKey:"home.nativeTiles.sessions",defaultSize:{w:2,h:3},minSize:{w:1,h:2}},{id:E3,titleKey:"home.nativeTiles.orders",defaultSize:{w:2,h:3},minSize:{w:1,h:2}},{id:R3,titleKey:"home.nativeTiles.revenue",defaultSize:{w:3,h:3},minSize:{w:2,h:2}},{id:P3,titleKey:"home.nativeTiles.coding",defaultSize:{w:3,h:3},minSize:{w:2,h:2}},{id:D3,titleKey:"home.nativeTiles.recentConversations",defaultSize:{w:6,h:4},minSize:{w:2,h:2},defaultHidden:!0}];function I3(t){return`native:${t}`}function M3(t){const e=B.c(21),{points:s,metricLabel:n}=t,i=A.useId();let o;if(e[0]!==i){let b;e[2]===Symbol.for("react.memo_cache_sentinel")?(b=/:/g,e[2]=b):b=e[2],o=i.replace(b,""),e[0]=i,e[1]=o}else o=e[1];const a=o;let l;e[3]!==n?(l={value:{label:n,color:"var(--success)"}},e[3]=n,e[4]=l):l=e[4];let c;e[5]===Symbol.for("react.memo_cache_sentinel")?(c={top:6,right:0,bottom:0,left:0},e[5]=c):c=e[5];let d;e[6]===Symbol.for("react.memo_cache_sentinel")?(d=r.jsx("line",{x1:0,y1:0,x2:0,y2:8,stroke:"var(--success)",strokeOpacity:.22,strokeWidth:4}),e[6]=d):d=e[6];let h;e[7]!==a?(h=r.jsx("defs",{children:r.jsx("pattern",{id:a,width:6,height:8,patternUnits:"userSpaceOnUse",children:d})}),e[7]=a,e[8]=h):h=e[8];let u;e[9]===Symbol.for("react.memo_cache_sentinel")?(u=r.jsx(nv,{dataKey:"label",hide:!0}),e[9]=u):u=e[9];let f;e[10]===Symbol.for("react.memo_cache_sentinel")?(f=r.jsx(iv,{cursor:{stroke:"var(--border)"},content:r.jsx(rv,{indicator:"line"})}),e[10]=f):f=e[10];const m=`url(#${a})`;let p;e[11]===Symbol.for("react.memo_cache_sentinel")?(p={r:4,fill:"var(--success)",stroke:"var(--background)",strokeWidth:2},e[11]=p):p=e[11];let g;e[12]!==m?(g=r.jsx(ov,{type:"monotone",dataKey:"value",stroke:"var(--success)",strokeWidth:2,fill:m,fillOpacity:1,animationDuration:350,dot:!1,activeDot:p}),e[12]=m,e[13]=g):g=e[13];let x;e[14]!==s||e[15]!==g||e[16]!==h?(x=r.jsxs(av,{data:s,margin:c,children:[h,u,f,g]}),e[14]=s,e[15]=g,e[16]=h,e[17]=x):x=e[17];let v;return e[18]!==x||e[19]!==l?(v=r.jsx(lv,{config:l,className:"h-full w-full",children:x}),e[18]=x,e[19]=l,e[20]=v):v=e[20],v}const O3={pageviews:{value:"12.2k",delta:"+1.9%",series:[9800,10100,9950,10600,10400,11e3,11200,11500,11900,12200]},sessions:{value:"3.2k",delta:"+25.6%",series:[2100,2250,2200,2500,2600,2750,2900,3e3,3100,3200]},orders:{value:"142",delta:"+8.4%",series:[96,102,99,110,108,118,124,131,137,142]},revenue:{value:"$8,240",delta:"+12.0%",series:[6100,6400,6250,6800,6700,7100,7400,7700,8e3,8240]}};function $3(t,e){return t.map((s,n)=>{const i=t.length-1-n;return{label:i===0?e("home.nativeTiles.today"):i===1?e("home.nativeTiles.yesterday"):e("home.nativeTiles.daysAgo",{days:i}),value:s}})}function B3(t){const e=B.c(8),{value:s,delta:n}=t;let i;e[0]!==s?(i=r.jsx("span",{className:"text-2xl font-medium tabular-nums text-foreground",children:s}),e[0]=s,e[1]=i):i=e[1];let o;e[2]===Symbol.for("react.memo_cache_sentinel")?(o=r.jsx(N2,{className:"size-4"}),e[2]=o):o=e[2];let a;e[3]!==n?(a=r.jsxs("span",{className:"inline-flex items-center gap-1 text-sm font-medium tabular-nums text-success",children:[o,n]}),e[3]=n,e[4]=a):a=e[4];let l;return e[5]!==i||e[6]!==a?(l=r.jsxs("div",{className:"mt-3 flex items-center gap-2.5",children:[i,a]}),e[5]=i,e[6]=a,e[7]=l):l=e[7],l}function xV(t,e){const s=(t*31+e*17+7)%100;return s<38?0:s<60?1+s%2:s<80?3+s%3:s<93?6+s%3:9+s%4}function vV(t){return t===0?"bg-muted-foreground/15":t<=2?"bg-success/25":t<=5?"bg-success/45":t<=8?"bg-success/70":"bg-success"}function F3(t){const e=B.c(4),{grid:s}=t,n=re();let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i={gridTemplateColumns:`repeat(${ar}, 1fr)`},e[0]=i):i=e[0];let o;return e[1]!==s||e[2]!==n?(o=r.jsx(ji,{delayDuration:0,children:r.jsx("div",{className:"grid w-full gap-1",style:i,children:Array.from({length:ar},(a,l)=>r.jsx("div",{className:"flex flex-col gap-1",children:Array.from({length:5},(c,d)=>{const h=s?s[l]?.[d]??0:xV(l,d);return r.jsxs(He,{children:[r.jsx(Ke,{asChild:!0,children:r.jsx("div",{className:ie("aspect-square rounded-[2px]",vV(h))})}),r.jsx(Ue,{children:h===0?n("home.nativeTiles.noCommits"):n("home.nativeTiles.commits",{count:h})})]},d)})},l))})}),e[1]=s,e[2]=n,e[3]=o):o=e[3],o}function su(t){const e=B.c(8),{label:s,icon:n,onConnect:i,pending:o}=t;let a;e[0]!==n||e[1]!==o?(a=o?r.jsx(et,{className:"size-4 animate-spin"}):n,e[0]=n,e[1]=o,e[2]=a):a=e[2];let l;return e[3]!==s||e[4]!==i||e[5]!==o||e[6]!==a?(l=r.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-background/30 backdrop-blur-[2px]",children:r.jsxs(le,{size:"sm",onClick:i,disabled:o,className:"gap-2 shadow-sm",children:[a,s]})}),e[3]=s,e[4]=i,e[5]=o,e[6]=a,e[7]=l):l=e[7],l}function z3(t){const e=B.c(6),{label:s}=t,n=re();let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i=r.jsx(ec,{className:"size-6 text-success/60"}),e[0]=i):i=e[0];let o;e[1]!==s||e[2]!==n?(o=n("home.nativeTiles.connectedSoon",{label:s}),e[1]=s,e[2]=n,e[3]=o):o=e[3];let a;return e[4]!==o?(a=r.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-2 text-center",children:[i,r.jsx("p",{className:"text-xs text-muted-foreground",children:o})]}),e[4]=o,e[5]=a):a=e[5],a}function cf(t){const e=B.c(22),{metricKey:s}=t,n=re();let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i={slug:"google-analytics"},e[0]=i):i=e[0];const o=Rn(i).length>0,{connect:a,isConnecting:l}=Mm("deco/google-analytics"),c=O3[s];if(o||!c){let x;return e[1]===Symbol.for("react.memo_cache_sentinel")?(x=r.jsx(z3,{label:"Analytics"}),e[1]=x):x=e[1],x}let d;e[2]!==c.series||e[3]!==n?(d=$3(c.series,n),e[2]=c.series,e[3]=n,e[4]=d):d=e[4];let h;e[5]!==s||e[6]!==d?(h=r.jsx("div",{className:"min-h-0 flex-1",children:r.jsx(M3,{points:d,metricLabel:s})}),e[5]=s,e[6]=d,e[7]=h):h=e[7];let u;e[8]!==c.delta||e[9]!==c.value?(u=r.jsx(B3,{value:c.value,delta:c.delta}),e[8]=c.delta,e[9]=c.value,e[10]=u):u=e[10];let f;e[11]!==n?(f=n("home.nativeTiles.connectGoogleAnalytics"),e[11]=n,e[12]=f):f=e[12];let m;e[13]===Symbol.for("react.memo_cache_sentinel")?(m=r.jsx(Om,{className:"size-4"}),e[13]=m):m=e[13];let p;e[14]!==a||e[15]!==l||e[16]!==f?(p=r.jsx(su,{label:f,icon:m,onConnect:a,pending:l}),e[14]=a,e[15]=l,e[16]=f,e[17]=p):p=e[17];let g;return e[18]!==h||e[19]!==u||e[20]!==p?(g=r.jsxs("div",{className:"relative flex h-full flex-col",children:[h,u,p]}),e[18]=h,e[19]=u,e[20]=p,e[21]=g):g=e[21],g}function df(t){const e=B.c(27),{metricKey:s}=t,n=re();let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i={slug:"vtex"},e[0]=i):i=e[0];const o=Rn(i);let a;e[1]===Symbol.for("react.memo_cache_sentinel")?(a={slug:"shopify"},e[1]=a):a=e[1];const l=Rn(a),c=o.length>0||l.length>0,[d,h]=A.useState(!1),u=O3[s];if(c||!u){let w;return e[2]===Symbol.for("react.memo_cache_sentinel")?(w=r.jsx(z3,{label:"Commerce"}),e[2]=w):w=e[2],w}let f;e[3]!==u.series||e[4]!==n?(f=$3(u.series,n),e[3]=u.series,e[4]=n,e[5]=f):f=e[5];let m;e[6]!==s||e[7]!==f?(m=r.jsx("div",{className:"min-h-0 flex-1",children:r.jsx(M3,{points:f,metricLabel:s})}),e[6]=s,e[7]=f,e[8]=m):m=e[8];let p;e[9]!==u.delta||e[10]!==u.value?(p=r.jsx(B3,{value:u.value,delta:u.delta}),e[9]=u.delta,e[10]=u.value,e[11]=p):p=e[11];let g;e[12]!==n?(g=n("home.nativeTiles.connectCommercePlatform"),e[12]=n,e[13]=g):g=e[13];let x,v;e[14]===Symbol.for("react.memo_cache_sentinel")?(x=r.jsx(y9,{className:"size-4"}),v=()=>h(!0),e[14]=x,e[15]=v):(x=e[14],v=e[15]);let b;e[16]!==g?(b=r.jsx(su,{label:g,icon:x,onConnect:v}),e[16]=g,e[17]=b):b=e[17];let _;e[18]!==m||e[19]!==p||e[20]!==b?(_=r.jsxs("div",{className:"relative flex h-full flex-col",children:[m,p,b]}),e[18]=m,e[19]=p,e[20]=b,e[21]=_):_=e[21];let y;e[22]!==d?(y=r.jsx(h9,{mode:"browse",open:d,onOpenChange:h,defaultTab:"all",initialSearch:"shopify vtex"}),e[22]=d,e[23]=y):y=e[23];let L;return e[24]!==_||e[25]!==y?(L=r.jsxs(r.Fragment,{children:[_,y]}),e[24]=_,e[25]=y,e[26]=L):L=e[26],L}function bV(){const t=B.c(5);let e;t[0]===Symbol.for("react.memo_cache_sentinel")?(e={slug:"mcp-github"},t[0]=e):e=t[0];const s=Rn(e);let n;t[1]!==s?(n=Wb(s),t[1]=s,t[2]=n):n=t[2];const i=n[0];let o;return t[3]!==i?(o=i?r.jsx(_V,{connectionId:i.id}):r.jsx(yV,{}),t[3]=i,t[4]=o):o=t[4],o}function yV(){const t=B.c(8),e=re(),{connect:s,isConnecting:n}=Mm("deco/mcp-github");let i;t[0]===Symbol.for("react.memo_cache_sentinel")?(i=r.jsx("div",{className:"min-h-0 flex-1 overflow-hidden",children:r.jsx(F3,{})}),t[0]=i):i=t[0];let o;t[1]!==e?(o=e("home.nativeTiles.connectGithub"),t[1]=e,t[2]=o):o=t[2];let a;t[3]===Symbol.for("react.memo_cache_sentinel")?(a=r.jsx($o,{className:"size-4"}),t[3]=a):a=t[3];let l;return t[4]!==s||t[5]!==n||t[6]!==o?(l=r.jsxs("div",{className:"relative flex h-full flex-col",children:[i,r.jsx(su,{label:o,icon:a,onConnect:s,pending:n})]}),t[4]=s,t[5]=n,t[6]=o,t[7]=l):l=t[7],l}function _V(t){const e=B.c(9),{connectionId:s}=t,n=re(),{data:i,isLoading:o}=lV(s),{data:a}=pV(s);let l;e[0]!==a?(l=r.jsx(F3,{grid:a}),e[0]=a,e[1]=l):l=e[1];let c;e[2]!==i||e[3]!==o||e[4]!==n?(c=o?r.jsx("div",{className:"flex flex-col gap-1.5",children:Array.from({length:3},SV)}):!i||i.repos.length===0?r.jsx("p",{className:"text-xs text-muted-foreground",children:n("home.nativeTiles.noRecentPullRequests")}):r.jsx("div",{className:"flex min-h-0 flex-1 flex-col gap-3 overflow-y-auto",children:i.repos.map(LV)}),e[2]=i,e[3]=o,e[4]=n,e[5]=c):c=e[5];let d;return e[6]!==l||e[7]!==c?(d=r.jsxs("div",{className:"flex h-full flex-col gap-3 overflow-hidden",children:[l,c]}),e[6]=l,e[7]=c,e[8]=d):d=e[8],d}function LV(t){return r.jsxs("div",{className:"flex flex-col gap-0.5",children:[r.jsx("div",{className:"truncate text-xs text-muted-foreground",children:t.repo}),t.prs.map(e=>r.jsxs("a",{href:e.htmlUrl,target:"_blank",rel:"noreferrer",className:"flex items-center gap-2 rounded-md px-1.5 py-1.5 text-sm transition-colors hover:bg-accent/60",children:[r.jsx(Zs,{className:"size-4 shrink-0 text-muted-foreground"}),r.jsx("span",{className:"truncate text-foreground",children:e.title}),r.jsxs("span",{className:ie("ml-auto shrink-0 rounded-full px-1.5 py-0.5 text-xs font-medium",e.merged?"bg-success/10 text-success":"bg-muted text-muted-foreground"),children:["#",e.number]})]},`${t.repo}#${e.number}`))]},t.repo)}function SV(t,e){return r.jsx("div",{className:"h-5 w-full animate-pulse rounded-md bg-muted/40"},`pr-skeleton-${e}`)}const wV={completed:{labelKey:"home.nativeTiles.statusCompleted",className:"text-success"},in_progress:{labelKey:"home.nativeTiles.statusRunning",className:"text-foreground"},requires_action:{labelKey:"home.nativeTiles.statusNeedsInput",className:"text-foreground"},failed:{labelKey:"home.nativeTiles.statusFailed",className:"text-destructive"},expired:{labelKey:"home.nativeTiles.statusExpired",className:"text-muted-foreground"}};function jV(){const t=B.c(14),e=re(),{org:s,locator:n}=Fe(),i=Bs(),o=St(),{data:a}=r2(),l=a?.data?.members??[],c=new Map(l.map(CV));let d;t[0]!==n?(d=at.overviewThreads(n),t[0]=n,t[1]=d):d=t[1];let h;t[2]!==i?(h=async()=>(await i.call("COLLECTION_THREADS_LIST",{limit:12})).items??[],t[2]=i,t[3]=h):h=t[3];let u;t[4]!==d||t[5]!==h?(u={queryKey:d,queryFn:h,staleTime:3e4},t[4]=d,t[5]=h,t[6]=u):u=t[6];const{data:f}=mm(u);if(f.length===0){let x;t[7]===Symbol.for("react.memo_cache_sentinel")?(x=r.jsx(n9,{className:"size-6 text-muted-foreground/50"}),t[7]=x):x=t[7];let v;t[8]!==e?(v=e("home.nativeTiles.noConversationsYet"),t[8]=e,t[9]=v):v=t[9];let b;return t[10]!==v?(b=r.jsxs("div",{className:"flex flex-1 flex-col items-center justify-center gap-2 text-center",children:[x,r.jsx("p",{className:"text-xs text-muted-foreground",children:v})]}),t[10]=v,t[11]=b):b=t[11],b}const m="flex h-full flex-col gap-0.5 overflow-y-auto",p=f.map(x=>{const v=c.get(x.created_by),b=v?.user?.name??v?.user?.email?.split("@")[0]??"Someone",_=x.status?wV[x.status]:void 0,y=x.updated_at?V2(new Date(x.updated_at)):null;return r.jsxs("button",{type:"button",onClick:()=>o({to:"/$org/$taskId",params:{org:s.slug,taskId:x.id},search:x.virtual_mcp_id?{virtualmcpid:x.virtual_mcp_id}:{}}),className:"flex items-center gap-2.5 rounded-lg px-2.5 py-2 text-left transition-colors hover:bg-accent/60",children:[r.jsx(ir,{shape:"circle",size:"xs",url:v?.user?.image??void 0,fallback:b.slice(0,2).toUpperCase()}),r.jsxs("div",{className:"flex min-w-0 flex-1 flex-col",children:[r.jsx("span",{className:"truncate text-sm font-medium text-foreground",children:x.title||e("home.nativeTiles.untitledConversation")}),r.jsxs("span",{className:"truncate text-xs text-muted-foreground",children:[b,y?` · ${y}`:""]})]}),_&&r.jsx("span",{className:ie("shrink-0 text-xs",_.className),children:e(_.labelKey)})]},x.id)});let g;return t[12]!==p?(g=r.jsx("div",{className:m,children:p}),t[12]=p,t[13]=g):g=t[13],g}function CV(t){return[t.userId,t]}function kV(t){const e=B.c(6),{nativeId:s}=t;switch(s){case T3:{let n;return e[0]===Symbol.for("react.memo_cache_sentinel")?(n=r.jsx(cf,{metricKey:"pageviews"}),e[0]=n):n=e[0],n}case A3:{let n;return e[1]===Symbol.for("react.memo_cache_sentinel")?(n=r.jsx(cf,{metricKey:"sessions"}),e[1]=n):n=e[1],n}case E3:{let n;return e[2]===Symbol.for("react.memo_cache_sentinel")?(n=r.jsx(df,{metricKey:"orders"}),e[2]=n):n=e[2],n}case R3:{let n;return e[3]===Symbol.for("react.memo_cache_sentinel")?(n=r.jsx(df,{metricKey:"revenue"}),e[3]=n):n=e[3],n}case P3:{let n;return e[4]===Symbol.for("react.memo_cache_sentinel")?(n=r.jsx(bV,{}),e[4]=n):n=e[4],n}case D3:{let n;return e[5]===Symbol.for("react.memo_cache_sentinel")?(n=r.jsx(A.Suspense,{fallback:r.jsx("div",{className:"h-full animate-pulse bg-muted/30"}),children:r.jsx(jV,{})}),e[5]=n):n=e[5],n}default:return null}}function VV(t){const e=B.c(16),{nativeId:s}=t,n=re();let i,o,a;if(e[0]!==s||e[1]!==n){let h;e[5]!==s?(h=f=>f.id===s,e[5]=s,e[6]=h):h=e[6];const u=tu.find(h);a="flex h-full flex-col overflow-hidden p-4",i="shrink-0 text-xs font-medium text-muted-foreground",o=u?.titleKey?n(u.titleKey):n("home.nativeTiles.tile"),e[0]=s,e[1]=n,e[2]=i,e[3]=o,e[4]=a}else i=e[2],o=e[3],a=e[4];let l;e[7]!==i||e[8]!==o?(l=r.jsx("span",{className:i,children:o}),e[7]=i,e[8]=o,e[9]=l):l=e[9];let c;e[10]!==s?(c=r.jsx("div",{className:"relative mt-2 min-h-0 flex-1",children:r.jsx(kV,{nativeId:s})}),e[10]=s,e[11]=c):c=e[11];let d;return e[12]!==a||e[13]!==l||e[14]!==c?(d=r.jsxs("div",{className:a,children:[l,c]}),e[12]=a,e[13]=l,e[14]=c,e[15]=d):d=e[15],d}const NV={w:3,h:4},TV={w:1,h:2},AV={w:2,h:1};function EV(t){return`prompt:${t.agentId}:${t.promptName||"blank"}`}function PV(t){return t.tileId?`tile:${t.tileId}`:`tile:${t.agentId}:${t.resourceUri}`}function RV(t){return t.promptName?t.agentName:t.description}function DV(t){return{name:t.promptName,title:t.title,description:t.description,arguments:t.arguments,_meta:t._meta}}function K3(t){const e=B.c(14),{org:s}=Fe();let n;e[0]!==s.id||e[1]!==s.slug||e[2]!==t.connectionId?(n=sv({connectionId:t.connectionId,orgId:s.id,orgSlug:s.slug}),e[0]=s.id,e[1]=s.slug,e[2]=t.connectionId,e[3]=n):n=e[3];const{data:i}=Ft(n),o=!!i&&!t.toolName;let a;e[4]!==i||e[5]!==o?(a={client:i,enabled:o},e[4]=i,e[5]=o,e[6]=a):a=e[6];const{data:l}=f9(a);let c;e[7]!==t.resourceUri||e[8]!==t.toolName||e[9]!==l?.tools?(c=t.toolName??l?.tools.find(u=>sc(u._meta)===t.resourceUri)?.name,e[7]=t.resourceUri,e[8]=t.toolName,e[9]=l?.tools,e[10]=c):c=e[10];const d=c;let h;return e[11]!==t.connectionId||e[12]!==d?(h=d?Ua(t.connectionId,d):void 0,e[11]=t.connectionId,e[12]=d,e[13]=h):h=e[13],h}function nu(t){const e=B.c(10);let s;e[0]!==t?(s={agentId:t},e[0]=t,e[1]=s):s=e[1];const{start:n,startBlank:i,dialog:o,starting:a}=xC(s);let l;e[2]!==n||e[3]!==i?(l=h=>{if(!h.promptName){i();return}n(DV(h))},e[2]=n,e[3]=i,e[4]=l):l=e[4];const c=l;let d;return e[5]!==o||e[6]!==c||e[7]!==i||e[8]!==a?(d={open:c,startBlank:i,dialog:o,starting:a},e[5]=o,e[6]=c,e[7]=i,e[8]=a,e[9]=d):d=e[9],d}function IV(t){const e=B.c(32),{entry:s,isEditMode:n}=t,{open:i,dialog:o,starting:a}=nu(s.agentId);let l;e[0]!==s||e[1]!==i?(l=()=>i(s),e[0]=s,e[1]=i,e[2]=l):l=e[2];const c=a||n,d=!n&&"cursor-pointer transition-colors hover:bg-accent/40",h=n&&"cursor-default pl-12",u=a&&"opacity-60";let f;e[3]!==d||e[4]!==h||e[5]!==u?(f=ie("group/tile relative flex h-full w-full items-center gap-3 px-4 py-3 text-left bg-card",d,h,u),e[3]=d,e[4]=h,e[5]=u,e[6]=f):f=e[6];let m;e[7]!==s.agentIcon||e[8]!==s.agentName?(m=r.jsx(Qn,{icon:s.agentIcon,name:s.agentName,size:"sm+"}),e[7]=s.agentIcon,e[8]=s.agentName,e[9]=m):m=e[9];let p;e[10]!==s.title?(p=r.jsx("div",{className:"line-clamp-2 text-sm font-medium text-foreground leading-snug",children:s.title}),e[10]=s.title,e[11]=p):p=e[11];let g;e[12]!==s?(g=RV(s),e[12]=s,e[13]=g):g=e[13];let x;e[14]!==g?(x=r.jsx("div",{className:"truncate text-xs text-muted-foreground mt-0.5",children:g}),e[14]=g,e[15]=x):x=e[15];let v;e[16]!==x||e[17]!==p?(v=r.jsxs("div",{className:"min-w-0 flex-1",children:[p,x]}),e[16]=x,e[17]=p,e[18]=v):v=e[18];let b;e[19]!==n?(b=!n&&r.jsx(kr,{size:16,className:"shrink-0 text-muted-foreground opacity-0 -translate-x-1 transition-all duration-200 group-hover/tile:opacity-100 group-hover/tile:translate-x-0","aria-hidden":!0}),e[19]=n,e[20]=b):b=e[20];let _;e[21]!==a||e[22]!==l||e[23]!==v||e[24]!==b||e[25]!==c||e[26]!==f||e[27]!==m?(_=r.jsxs("button",{type:"button",onClick:l,disabled:c,"aria-busy":a,className:f,children:[m,v,b]}),e[21]=a,e[22]=l,e[23]=v,e[24]=b,e[25]=c,e[26]=f,e[27]=m,e[28]=_):_=e[28];let y;return e[29]!==o||e[30]!==_?(y=r.jsxs(r.Fragment,{children:[_,o]}),e[29]=o,e[30]=_,e[31]=y):y=e[31],y}function MV(){const t=B.c(1);let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=r.jsx("div",{className:"mt-4 grid w-full grid-cols-1 sm:grid-cols-2 lg:grid-cols-4 gap-3",children:Array.from({length:3},OV)}),t[0]=e):e=t[0],e}function OV(t,e){return r.jsxs("div",{className:"flex w-full items-center gap-3 rounded-2xl bg-card card-shadow px-3 py-2.5",children:[r.jsx(Rt,{className:"size-10 rounded-xl"}),r.jsxs("div",{className:"flex-1 space-y-1.5",children:[r.jsx(Rt,{className:"h-3 w-2/3"}),r.jsx(Rt,{className:"h-2.5 w-1/3"})]})]},`chip-skeleton-${e}`)}function $V(t){const e=B.c(18),{tile:s,prompts:n,isEditMode:i,tileWidth:o}=t,{org:a}=Fe(),{open:l,startBlank:c,dialog:d,starting:h}=nu(s.agentId),u=n.filter(BV),f=K3(s),m=re(),p="relative flex h-full w-full flex-col p-3";let g;e[0]!==i||e[1]!==f||e[2]!==c||e[3]!==h||e[4]!==m?(g=!i&&r.jsx("button",{type:"button",onClick:()=>{c(f?{main:f}:void 0)},disabled:h,"aria-busy":h,className:"mb-1 self-start rounded-md px-2 py-1 text-[10px] text-muted-foreground transition-colors hover:bg-accent/60 hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring disabled:cursor-progress disabled:opacity-60",children:m("home.homeGrid.openChat")}),e[0]=i,e[1]=f,e[2]=c,e[3]=h,e[4]=m,e[5]=g):g=e[5];const x="flex min-h-0 flex-1 gap-3 overflow-hidden";let v;e[6]===Symbol.for("react.memo_cache_sentinel")?(v=r.jsx(zV,{}),e[6]=v):v=e[6];let b;e[7]!==a.id||e[8]!==a.slug||e[9]!==s?(b=r.jsx("div",{className:"min-h-0 flex-1 overflow-hidden rounded-lg border border-border",children:r.jsx(A.Suspense,{fallback:v,children:r.jsx(FV,{tile:s,orgId:a.id,orgSlug:a.slug})})}),e[7]=a.id,e[8]=a.slug,e[9]=s,e[10]=b):b=e[10];const _=u.length>0&&!i&&o>=2&&r.jsx("div",{className:"flex w-44 shrink-0 flex-col gap-2 overflow-hidden",children:u.map(w=>r.jsx("button",{type:"button",onClick:()=>l(w),disabled:h,className:"shrink-0 rounded-lg border border-border bg-background px-2.5 py-2 text-left text-xs leading-snug text-foreground transition-colors hover:bg-accent/40 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:cursor-progress disabled:opacity-60",children:r.jsx("span",{className:"line-clamp-2",children:w.title})},w.promptName))});let y;e[11]!==b||e[12]!==_?(y=r.jsxs("div",{className:x,children:[b,_]}),e[11]=b,e[12]=_,e[13]=y):y=e[13];let L;return e[14]!==d||e[15]!==g||e[16]!==y?(L=r.jsxs("div",{className:p,children:[g,y,d]}),e[14]=d,e[15]=g,e[16]=y,e[17]=L):L=e[17],L}function BV(t){return!!t.promptName}function FV(t){const e=B.c(13),{tile:s,orgId:n,orgSlug:i}=t;let o;e[0]!==n||e[1]!==i||e[2]!==s.connectionId?(o={connectionId:s.connectionId,orgId:n,orgSlug:i},e[0]=n,e[1]=i,e[2]=s.connectionId,e[3]=o):o=e[3];const a=ht(o),l=s.minHeight??200,c=s.maxHeight??4e3;let d;return e[4]!==a||e[5]!==n||e[6]!==i||e[7]!==l||e[8]!==c||e[9]!==s.connectionId||e[10]!==s.resourceUri||e[11]!==s.toolInput?(d=r.jsx(kb,{resourceURI:s.resourceUri,orgId:n,orgSlug:i,connectionId:s.connectionId,client:a,toolInput:s.toolInput,displayMode:"fullscreen",minHeight:l,maxHeight:c,className:"h-full"}),e[4]=a,e[5]=n,e[6]=i,e[7]=l,e[8]=c,e[9]=s.connectionId,e[10]=s.resourceUri,e[11]=s.toolInput,e[12]=d):d=e[12],d}function zV(){const t=B.c(1);let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=r.jsxs("div",{className:"flex h-full w-full flex-col gap-2 p-4",children:[r.jsx(Rt,{className:"h-3 w-2/3"}),r.jsx(Rt,{className:"h-3 w-1/2"}),r.jsx(Rt,{className:"mt-1 h-full w-full rounded-md"})]}),t[0]=e):e=t[0],e}function KV(t){const e=B.c(18),{icon:s,name:n}=t,i=re();let o;e[0]!==s||e[1]!==n?(o=r.jsx(Qn,{icon:s,name:n,size:"sm+"}),e[0]=s,e[1]=n,e[2]=o):o=e[2];let a;e[3]!==n?(a=r.jsx("div",{className:"truncate text-sm font-medium text-foreground",children:n}),e[3]=n,e[4]=a):a=e[4];let l;e[5]!==i?(l=i("home.homeGrid.loadingTile"),e[5]=i,e[6]=l):l=e[6];let c;e[7]!==l?(c=r.jsx("div",{className:"truncate text-xs text-muted-foreground",children:l}),e[7]=l,e[8]=c):c=e[8];let d;e[9]!==a||e[10]!==c?(d=r.jsxs("div",{className:"min-w-0 flex-1",children:[a,c]}),e[9]=a,e[10]=c,e[11]=d):d=e[11];let h;e[12]!==o||e[13]!==d?(h=r.jsxs("div",{className:"flex items-center gap-2.5",children:[o,d]}),e[12]=o,e[13]=d,e[14]=h):h=e[14];let u;e[15]===Symbol.for("react.memo_cache_sentinel")?(u=r.jsxs("div",{className:"flex flex-1 flex-col gap-2 pt-1",children:[r.jsx(Rt,{className:"h-3 w-3/4"}),r.jsx(Rt,{className:"h-3 w-1/2"}),r.jsx(Rt,{className:"h-3 w-2/3"})]}),e[15]=u):u=e[15];let f;return e[16]!==h?(f=r.jsxs("div",{className:"flex h-full w-full flex-col gap-3 p-5 opacity-60",children:[h,u]}),e[16]=h,e[17]=f):f=e[17],f}function UV(t){const e=B.c(13),{tile:s,prompts:n,isEditMode:i}=t,o=re(),{open:a,startBlank:l,dialog:c,starting:d}=nu(s.agentId),h=n.filter(HV),u=K3(s),f="flex h-full w-full flex-col gap-3 p-4";let m;e[0]!==u||e[1]!==l?(m=()=>{l(u?{main:u}:void 0)},e[0]=u,e[1]=l,e[2]=m):m=e[2];const p=d||i;let g;e[3]!==o?(g=o("home.homeGrid.openChat"),e[3]=o,e[4]=g):g=e[4];let x;e[5]!==m||e[6]!==p||e[7]!==g?(x=r.jsx("button",{type:"button",onClick:m,disabled:p,className:"mb-1 self-start rounded-md px-2 py-1 text-[10px] text-muted-foreground transition-colors hover:bg-accent/60 hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring disabled:cursor-progress disabled:opacity-60",children:g}),e[5]=m,e[6]=p,e[7]=g,e[8]=x):x=e[8];const v=h.length>0&&!i&&r.jsx("div",{className:"grid grid-cols-1 gap-2 overflow-hidden sm:grid-cols-2",children:h.map(_=>r.jsx("button",{type:"button",onClick:()=>!i&&a(_),disabled:d,className:"rounded-lg border border-border bg-background px-2.5 py-2 text-left text-xs leading-snug text-foreground transition-colors hover:bg-accent/40 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:cursor-progress disabled:opacity-60",children:r.jsx("span",{className:"line-clamp-2",children:_.title})},_.promptName))});let b;return e[9]!==c||e[10]!==x||e[11]!==v?(b=r.jsxs("div",{className:f,children:[x,v,c]}),e[9]=c,e[10]=x,e[11]=v,e[12]=b):b=e[12],b}function HV(t){return!!t.promptName}function WV({isEditMode:t}){const e=re(),{org:s}=Fe(),{isLoading:n,prompts:i,tiles:o}=Dm(s.slug),a=i.filter(S=>!Wu(S.agentId)),l=o.filter(S=>!Wu(S.agentId)),c=v2()?.ids??[],d=new Set(c),h=b2(),u=Bs(),f=Ls(),m=new Set(l.map(S=>S.agentId)),p=new Map;for(const S of a){const C=p.get(S.agentId);C?C.push(S):p.set(S.agentId,[S])}const g=a.filter(S=>!m.has(S.agentId)),x=[...l.map(S=>({kind:"tile",id:PV(S),data:S})),...g.map(S=>({kind:"prompt",id:EV(S),data:S})),...tu.map(S=>({kind:"native",id:I3(S.id),data:S}))],v=new Map(x.map(S=>[S.id,S])),b=iV(x.map(S=>S.kind==="native"?{id:S.id,defaultSize:S.data.defaultSize,minSize:S.data.minSize,defaultHidden:S.data.defaultHidden}:{id:S.id,defaultSize:S.kind==="tile"?NV:AV,minSize:S.kind==="tile"?TV:void 0,pinned:d.has(S.data.agentId)})),_=S=>{h.apply(C=>C.filter(N=>N!==S)).catch(()=>ge.error(e("home.homeGrid.couldntRemoveFromHome")))},y=async S=>{if(l.filter(N=>N.agentId===S.agentId).length<=1){_(S.agentId);return}try{const V=(await u.call("COLLECTION_VIRTUAL_MCP_GET",{id:S.agentId})).item;if(!V)throw new Error("Agent not found");const E=ur(V.metadata?.ui),T=S.tileId?E.filter(k=>k.tileId!==S.tileId):E.filter(k=>k.connectionId!==S.connectionId||k.resourceUri!==S.resourceUri);await u.call("COLLECTION_VIRTUAL_MCP_UPDATE",{id:S.agentId,data:{metadata:{...V.metadata??{},ui:{...V.metadata?.ui??{},homeTile:null,homeTiles:T}}}}),f.invalidateQueries({queryKey:at.homeNextActions(s.slug)})}catch{ge.error(e("home.homeGrid.couldntRemoveTile"))}},L=S=>{const C=v.get(S);if(C){if(C.kind==="native"){b.hideTile(S);return}if(!d.has(C.data.agentId)){b.hideTile(S);return}C.kind==="tile"?y(C.data):_(C.data.agentId)}},w=S=>{const C=v.get(S.id);if(!C)return null;if(C.kind==="native")return r.jsx(VV,{nativeId:C.data.id});if(C.kind==="tile"){const N=p.get(C.data.agentId)??[];return r.jsx(_s,{fallback:r.jsx(UV,{tile:C.data,prompts:N,isEditMode:t}),children:r.jsx(A.Suspense,{fallback:r.jsx(KV,{icon:C.data.agentIcon,name:C.data.agentName}),children:r.jsx($V,{tile:C.data,prompts:N,isEditMode:t,tileWidth:S.w})})})}return r.jsx(IV,{entry:C.data,isEditMode:t})};return n||b.isLoading?r.jsx(MV,{}):b.snapshot.visible.length===0&&!t?null:r.jsx("div",{className:"mt-4 flex w-full max-w-7xl flex-col gap-4",children:r.jsx(Yk,{tiles:b.snapshot.visible,isEditMode:t,renderTile:w,onMove:b.moveTile,onResize:b.resizeTile,onRemove:L})})}function _r(t,e,s){const n=t.slice();return n.splice(s<0?n.length+s:s,0,n.splice(e,1)[0]),n}function qV(t,e){return t.reduce((s,n,i)=>{const o=e.get(n);return o&&(s[i]=o),s},Array(t.length))}function wa(t){return t!==null&&t>=0}function GV(t,e){if(t===e)return!0;if(t.length!==e.length)return!1;for(let s=0;s<t.length;s++)if(t[s]!==e[s])return!1;return!0}function YV(t){return typeof t=="boolean"?{draggable:t,droppable:t}:t}const U3=t=>{let{rects:e,activeIndex:s,overIndex:n,index:i}=t;const o=_r(e,n,s),a=e[i],l=o[i];return!l||!a?null:{x:l.left-a.left,y:l.top-a.top,scaleX:l.width/a.width,scaleY:l.height/a.height}},ja={scaleX:1,scaleY:1},iu=t=>{var e;let{activeIndex:s,activeNodeRect:n,index:i,rects:o,overIndex:a}=t;const l=(e=o[s])!=null?e:n;if(!l)return null;if(i===s){const d=o[a];return d?{x:0,y:s<a?d.top+d.height-(l.top+l.height):d.top-l.top,...ja}:null}const c=JV(o,i,s);return i>s&&i<=a?{x:0,y:-l.height-c,...ja}:i<s&&i>=a?{x:0,y:l.height+c,...ja}:{x:0,y:0,...ja}};function JV(t,e,s){const n=t[e],i=t[e-1],o=t[e+1];return n?s<e?i?n.top-(i.top+i.height):o?o.top-(n.top+n.height):0:o?o.top-(n.top+n.height):i?n.top-(i.top+i.height):0:0}const H3="Sortable",W3=it.createContext({activeIndex:-1,containerId:H3,disableTransforms:!1,items:[],overIndex:-1,useDragOverlay:!1,sortedRects:[],strategy:U3,disabled:{draggable:!1,droppable:!1}});function ru(t){let{children:e,id:s,items:n,strategy:i=U3,disabled:o=!1}=t;const{active:a,dragOverlay:l,droppableRects:c,over:d,measureDroppableContainers:h}=N3(),u=ha(H3,s),f=l.rect!==null,m=A.useMemo(()=>n.map(w=>typeof w=="object"&&"id"in w?w.id:w),[n]),p=a!=null,g=a?m.indexOf(a.id):-1,x=d?m.indexOf(d.id):-1,v=A.useRef(m),b=!GV(m,v.current),_=x!==-1&&g===-1||b,y=YV(o);nn(()=>{b&&p&&h(m)},[b,m,p,h]),A.useEffect(()=>{v.current=m},[m]);const L=A.useMemo(()=>({activeIndex:g,containerId:u,disabled:y,disableTransforms:_,items:m,overIndex:x,useDragOverlay:f,sortedRects:qV(m,c),strategy:i}),[g,u,y.draggable,y.droppable,_,m,x,c,f,i]);return it.createElement(W3.Provider,{value:L},e)}const XV=t=>{let{id:e,items:s,activeIndex:n,overIndex:i}=t;return _r(s,n,i).indexOf(e)},QV=t=>{let{containerId:e,isSorting:s,wasDragging:n,index:i,items:o,newIndex:a,previousItems:l,previousContainerId:c,transition:d}=t;return!d||!n||l!==o&&i===a?!1:s?!0:a!==i&&e===c},ZV={duration:200,easing:"ease"},q3="transform",eN=Ln.Transition.toString({property:q3,duration:0,easing:"linear"}),tN={roleDescription:"sortable"};function sN(t){let{disabled:e,index:s,node:n,rect:i}=t;const[o,a]=A.useState(null),l=A.useRef(s);return nn(()=>{if(!e&&s!==l.current&&n.current){const c=i.current;if(c){const d=Or(n.current,{ignoreTransform:!0}),h={x:c.left-d.left,y:c.top-d.top,scaleX:c.width/d.width,scaleY:c.height/d.height};(h.x||h.y)&&a(h)}}s!==l.current&&(l.current=s)},[e,s,n,i]),A.useEffect(()=>{o&&a(null)},[o]),o}function ou(t){let{animateLayoutChanges:e=QV,attributes:s,disabled:n,data:i,getNewIndex:o=XV,id:a,strategy:l,resizeObserverConfig:c,transition:d=ZV}=t;const{items:h,containerId:u,activeIndex:f,disabled:m,disableTransforms:p,sortedRects:g,overIndex:x,useDragOverlay:v,strategy:b}=A.useContext(W3),_=nN(n,m),y=h.indexOf(a),L=A.useMemo(()=>({sortable:{containerId:u,index:y,items:h},...i}),[u,i,y,h]),w=A.useMemo(()=>h.slice(h.indexOf(a)),[h,a]),{rect:j,node:S,isOver:C,setNodeRef:N}=Ek({id:a,data:L,disabled:_.droppable,resizeObserverConfig:{updateMeasurementsFor:w,...c}}),{active:V,activatorEvent:E,activeNodeRect:T,attributes:k,setNodeRef:R,listeners:P,isDragging:D,over:I,setActivatorNodeRef:M,transform:O}=V3({id:a,data:L,attributes:{...tN,...s},disabled:_.draggable}),F=vC(N,R),$=!!V,z=$&&!p&&wa(f)&&wa(x),K=!v&&D,X=K&&z?O:null,H=z?X??(l??b)({rects:g,activeNodeRect:T,activeIndex:f,overIndex:x,index:y}):null,W=wa(f)&&wa(x)?o({id:a,items:h,activeIndex:f,overIndex:x}):y,U=V?.id,Q=A.useRef({activeId:U,items:h,newIndex:W,containerId:u}),q=h!==Q.current.items,Z=e({active:V,containerId:u,isDragging:D,isSorting:$,id:a,index:y,items:h,newIndex:Q.current.newIndex,previousItems:Q.current.items,previousContainerId:Q.current.containerId,transition:d,wasDragging:Q.current.activeId!=null}),Y=sN({disabled:!Z,index:y,node:S,rect:j});return A.useEffect(()=>{$&&Q.current.newIndex!==W&&(Q.current.newIndex=W),u!==Q.current.containerId&&(Q.current.containerId=u),h!==Q.current.items&&(Q.current.items=h)},[$,W,u,h]),A.useEffect(()=>{if(U===Q.current.activeId)return;if(U!=null&&Q.current.activeId==null){Q.current.activeId=U;return}const G=setTimeout(()=>{Q.current.activeId=U},50);return()=>clearTimeout(G)},[U]),{active:V,activeIndex:f,attributes:k,data:L,rect:j,index:y,newIndex:W,items:h,isOver:C,isSorting:$,isDragging:D,listeners:P,node:S,overIndex:x,over:I,setNodeRef:F,setActivatorNodeRef:M,setDroppableNodeRef:N,setDraggableNodeRef:R,transform:Y??H,transition:ee()};function ee(){if(Y||q&&Q.current.newIndex===y)return eN;if(!(K&&!pc(E)||!d)&&($||Z))return Ln.Transition.toString({...d,property:q3})}}function nN(t,e){var s,n;return typeof t=="boolean"?{draggable:t,droppable:!1}:{draggable:(s=t?.draggable)!=null?s:e.draggable,droppable:(n=t?.droppable)!=null?n:e.droppable}}function El(t){if(!t)return!1;const e=t.data.current;return!!(e&&"sortable"in e&&typeof e.sortable=="object"&&"containerId"in e.sortable&&"items"in e.sortable&&"index"in e.sortable)}const iN=[ot.Down,ot.Right,ot.Up,ot.Left],au=(t,e)=>{let{context:{active:s,collisionRect:n,droppableRects:i,droppableContainers:o,over:a,scrollableAncestors:l}}=e;if(iN.includes(t.code)){if(t.preventDefault(),!s||!n)return;const c=[];o.getEnabled().forEach(u=>{if(!u||u!=null&&u.disabled)return;const f=i.get(u.id);if(f)switch(t.code){case ot.Down:n.top<f.top&&c.push(u);break;case ot.Up:n.top>f.top&&c.push(u);break;case ot.Left:n.left>f.left&&c.push(u);break;case ot.Right:n.left<f.left&&c.push(u);break}});const d=RC({collisionRect:n,droppableRects:i,droppableContainers:c});let h=h3(d,"id");if(h===a?.id&&d.length>1&&(h=d[1].id),h!=null){const u=o.get(s.id),f=o.get(h),m=f?i.get(f.id):null,p=f?.node.current;if(p&&m&&u&&f){const x=xc(p).some((w,j)=>l[j]!==w),v=G3(u,f),b=rN(u,f),_=x||!v?{x:0,y:0}:{x:b?n.width-m.width:0,y:b?n.height-m.height:0},y={x:m.left,y:m.top};return _.x&&_.y?y:Ko(y,_)}}}};function G3(t,e){return!El(t)||!El(e)?!1:t.data.current.sortable.containerId===e.data.current.sortable.containerId}function rN(t,e){return!El(t)||!El(e)||!G3(t,e)?!1:t.data.current.sortable.index<e.data.current.sortable.index}function lu(t){const e=B.c(11),{isPinned:s,submitting:n,onClick:i,label:o}=t,a=s?"text-muted-foreground hover:bg-destructive/10 hover:text-destructive":"bg-foreground text-background hover:opacity-90";let l;e[0]!==a?(l=ie("inline-flex size-7 shrink-0 items-center justify-center rounded-md text-xs transition-colors disabled:opacity-50 disabled:cursor-progress",a),e[0]=a,e[1]=l):l=e[1];let c;e[2]!==s||e[3]!==n?(c=n?r.jsx(et,{size:12,className:"animate-spin"}):s?r.jsx(Ym,{size:14}):r.jsx(kt,{size:14}),e[2]=s,e[3]=n,e[4]=c):c=e[4];let d;return e[5]!==o||e[6]!==i||e[7]!==n||e[8]!==l||e[9]!==c?(d=r.jsx("button",{type:"button",onClick:i,disabled:n,"aria-label":o,title:o,className:l,children:c}),e[5]=o,e[6]=i,e[7]=n,e[8]=l,e[9]=c,e[10]=d):d=e[10],d}function oN(t){const e=B.c(32),{agent:s,home:n,curated:i}=t,{org:o}=Fe();let a;e[0]!==s.id||e[1]!==o.id||e[2]!==o.slug?(a={connectionId:s.id,orgId:o.id,orgSlug:o.slug},e[0]=s.id,e[1]=o.id,e[2]=o.slug,e[3]=a):a=e[3];const l=ht(a);let c;e[4]!==s.id||e[5]!==o.id?(c=at.agentPrompts(o.id,s.id),e[4]=s.id,e[5]=o.id,e[6]=c):c=e[6];let d;e[7]!==l?(d=async()=>{const{prompts:L}=await l.listPrompts();return L.map(dN)},e[7]=l,e[8]=d):d=e[8];let h;e[9]!==c||e[10]!==d?(h={queryKey:c,queryFn:d,staleTime:3e4,retry:!1},e[9]=c,e[10]=d,e[11]=h):h=e[11];const{data:u,isLoading:f,error:m}=Ft(h),p=Dm(o.slug);let g,x;if(e[12]!==s.id||e[13]!==u||e[14]!==p.prompts){let L;e[17]!==s.id?(L=j=>j.agentId===s.id&&j.promptName,e[17]=s.id,e[18]=L):L=e[18],g=p.prompts.filter(L).map(cN);let w;e[19]!==u?(w=u??[],e[19]=u,e[20]=w):w=e[20],x=[...w];for(const j of g)x.some(S=>S.name===j.name)||x.push(j);e[12]=s.id,e[13]=u,e[14]=p.prompts,e[15]=g,e[16]=x}else g=e[15],x=e[16];if(f&&g.length===0){let L;return e[21]===Symbol.for("react.memo_cache_sentinel")?(L=r.jsxs("div",{className:"flex flex-col gap-1",children:[r.jsx(Rt,{className:"h-7 w-full"}),r.jsx(Rt,{className:"h-7 w-2/3"})]}),e[21]=L):L=e[21],L}if(m&&g.length===0)return console.error("[home-tiles] listPrompts failed for agent",s.id,m),null;if(x.length===0)return null;let v;e[22]!==i||e[23]!==x?(v=i??x.map(lN),e[22]=i,e[23]=x,e[24]=v):v=e[24];let b;e[25]!==v?(b=new Set(v),e[25]=v,e[26]=b):b=e[26];const _=b;let y;return e[27]!==s||e[28]!==n||e[29]!==x||e[30]!==_?(y=r.jsx("div",{className:"flex flex-col gap-0.5",children:x.map(L=>r.jsx(uN,{agent:s,home:n,prompt:L,allPromptNames:x.map(aN),isPinned:_.has(L.name)},L.name))}),e[27]=s,e[28]=n,e[29]=x,e[30]=_,e[31]=y):y=e[31],y}function aN(t){return t.name}function lN(t){return t.name}function cN(t){return{name:t.promptName,title:t.title,description:t.description}}function dN(t){return{name:t.name,title:t.title,description:t.description}}function uN({agent:t,home:e,prompt:s,allPromptNames:n,isPinned:i}){const o=re(),[a,l]=A.useState(!1),c=async()=>{if(!i&&!e.isOnHome(t.id)&&e.atLimit){ge.error(o("home.agentPromptList.homeIsFull",{limit:ma}));return}l(!0);try{const d=t.metadata?.ui?.homePrompts;let h;Array.isArray(d)?h=i?d.filter(f=>f!==s.name):[...d,s.name]:h=i?n.filter(f=>f!==s.name):n;const u={...t.metadata??{},ui:{...t.metadata?.ui??{},homePrompts:h}};await e.saveAgentMetadata(t,u)}catch(d){console.error("[home-tiles] failed to toggle prompt",d),ge.error(o("home.agentPromptList.couldntUpdateHome"))}finally{l(!1)}};return r.jsxs("div",{className:"flex items-center gap-2.5 rounded-md px-2 py-1 hover:bg-accent/40",children:[r.jsx("div",{className:"min-w-0 flex-1 truncate text-sm text-foreground",children:s.title??Ci(s.name)}),r.jsx(lu,{isPinned:i,submitting:a,onClick:c,label:o(i?"home.agentPromptList.removeFromHome":"home.agentPromptList.addToHome")})]})}function cu(t){const e=B.c(7),{title:s,hint:n}=t;let i;e[0]!==s?(i=r.jsx("span",{className:"text-xs font-medium uppercase tracking-wide text-muted-foreground",children:s}),e[0]=s,e[1]=i):i=e[1];let o;e[2]!==n?(o=n&&r.jsx("span",{className:"text-xs text-muted-foreground",children:n}),e[2]=n,e[3]=o):o=e[3];let a;return e[4]!==i||e[5]!==o?(a=r.jsxs("div",{className:"flex items-center justify-between px-1",children:[i,o]}),e[4]=i,e[5]=o,e[6]=a):a=e[6],a}const hN={tasks:ec,coding:Zs,analytics:Om,sales:y9,"recent-conversations":n9};function fN(){const t=B.c(19),e=re(),{layout:s,commitLayout:n}=q9();let i;t[0]!==s.hidden?(i=new Set(s.hidden),t[0]=s.hidden,t[1]=i):i=t[1];const o=i;let a;t[2]!==s.shown?(a=s.shown??[],t[2]=s.shown,t[3]=a):a=t[3];let l;t[4]!==a?(l=new Set(a),t[4]=a,t[5]=l):l=t[5];const c=l;let d;t[6]!==e?(d=e("home.nativeTilesSection.builtInTiles"),t[6]=e,t[7]=d):d=t[7];let h;t[8]!==d?(h=r.jsx(cu,{title:d}),t[8]=d,t[9]=h):h=t[9];let u;t[10]!==n||t[11]!==o||t[12]!==s||t[13]!==c||t[14]!==e?(u=tu.map(m=>{const p=I3(m.id),g=m.defaultHidden?c.has(p)&&!o.has(p):!o.has(p),x=hN[m.id]??n9,v=()=>{if(m.defaultHidden){n({...s,hidden:s.hidden.filter(b=>b!==p),shown:g?(s.shown??[]).filter(b=>b!==p):[...s.shown??[],p]});return}n({...s,hidden:g?[...s.hidden,p]:s.hidden.filter(b=>b!==p)})};return r.jsxs("div",{className:"flex items-center gap-3 rounded-lg border border-border/60 px-3 py-2.5",children:[r.jsx("span",{className:"flex size-8 shrink-0 items-center justify-center rounded-md bg-muted text-muted-foreground",children:r.jsx(x,{size:16})}),r.jsx("span",{className:"min-w-0 flex-1 truncate text-sm font-medium text-foreground",children:e(m.titleKey)}),r.jsxs(le,{type:"button",size:"sm",variant:g?"outline":"special",className:"h-8 gap-1.5",onClick:v,children:[g?r.jsx(Ym,{size:14}):r.jsx(kt,{size:14}),e(g?"home.nativeTilesSection.remove":"home.nativeTilesSection.add")]})]},m.id)}),t[10]=n,t[11]=o,t[12]=s,t[13]=c,t[14]=e,t[15]=u):u=t[15];let f;return t[16]!==h||t[17]!==u?(f=r.jsxs("div",{className:"flex flex-col gap-1.5",children:[h,u]}),t[16]=h,t[17]=u,t[18]=f):f=t[18],f}function mN(t,e,s){const n={};for(const[i,o]of Object.entries(t)){const a=e[i]?.type;if((a==="object"||a==="array")&&typeof o=="string"){if(!o.trim())continue;try{n[i]=JSON.parse(o)}catch{return null}}else if((a==="number"||a==="integer")&&(typeof o=="string"||typeof o=="number")){if(typeof o=="string"&&!o.trim())continue;const l=typeof o=="string"?Number(o):o;if(!Number.isFinite(l)||a==="integer"&&!Number.isInteger(l))return null;n[i]=l}else if(typeof o=="string"){if(!o.trim())continue;n[i]=o}else o!=null&&(n[i]=o)}return s?.some(i=>!(i in n))?null:n}function pN(t,e){if(!t||!e)return{};const s={};for(const[n,i]of Object.entries(t)){const o=e[n]?.type;(o==="object"||o==="array")&&i!=null&&typeof i!="string"?s[n]=JSON.stringify(i,null,2):s[n]=i}return s}function gN(t){if(!t)return"";const e=Object.entries(t).filter(([,s])=>s!=null&&s!=="");return e.length===0?"":e.slice(0,3).map(([s,n])=>{const i=typeof n=="object"?JSON.stringify(n):String(n);return`${s}=${i.length>20?`${i.slice(0,20)}…`:i}`}).join(", ")}function xN(t){const e=B.c(11),{properties:s,required:n,values:i,onChange:o}=t;let a;e[0]!==n?(a=n??[],e[0]=n,e[1]=a):a=e[1];let l;e[2]!==a?(l=new Set(a),e[2]=a,e[3]=l):l=e[3];const c=l;let d;e[4]!==s?(d=Object.entries(s),e[4]=s,e[5]=d):d=e[5];let h;return e[6]!==o||e[7]!==c||e[8]!==d||e[9]!==i?(h=r.jsx("div",{className:"flex flex-col gap-2",children:d.map(u=>{const[f,m]=u;return r.jsxs("div",{className:"flex flex-col gap-0.5",children:[r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsxs("label",{className:"text-xs font-medium leading-none flex items-center gap-1",children:[f,c.has(f)&&r.jsx("span",{className:"text-destructive text-[10px]",children:"*"})]}),r.jsx("span",{className:"text-[10px] text-muted-foreground font-mono",children:m.type})]}),m.description&&r.jsx("p",{className:"text-[10px] text-muted-foreground leading-snug",children:m.description}),r.jsx(vN,{type:m.type,fieldKey:f,value:i[f],onChange:p=>o(f,p)})]},f)})}),e[6]=o,e[7]=c,e[8]=d,e[9]=i,e[10]=h):h=e[10],h}function vN(t){const e=B.c(40),{type:s,fieldKey:n,value:i,onChange:o}=t,a=re();if(s==="object"||s==="array"){const u=i??"";let f;e[0]!==o?(f=g=>o(g.target.value),e[0]=o,e[1]=f):f=e[1];let m;e[2]!==n||e[3]!==a?(m=a("common.toolInputForm.jsonPlaceholder",{fieldKey:n}),e[2]=n,e[3]=a,e[4]=m):m=e[4];let p;return e[5]!==u||e[6]!==f||e[7]!==m?(p=r.jsx(gr,{className:"font-mono text-xs h-16",value:u,onChange:f,placeholder:m,rows:2}),e[5]=u,e[6]=f,e[7]=m,e[8]=p):p=e[8],p}if(s==="boolean"){const u=i!=null?String(i):"";let f;e[9]!==o?(f=L=>o(L==="true"),e[9]=o,e[10]=f):f=e[10];let m;e[11]!==a?(m=a("common.toolInputForm.selectPlaceholder"),e[11]=a,e[12]=m):m=e[12];let p;e[13]!==m?(p=r.jsx(Jt,{className:"h-7 text-xs",children:r.jsx(as,{placeholder:m})}),e[13]=m,e[14]=p):p=e[14];let g;e[15]!==a?(g=a("common.toolInputForm.true"),e[15]=a,e[16]=g):g=e[16];let x;e[17]!==g?(x=r.jsx(vt,{value:"true",children:g}),e[17]=g,e[18]=x):x=e[18];let v;e[19]!==a?(v=a("common.toolInputForm.false"),e[19]=a,e[20]=v):v=e[20];let b;e[21]!==v?(b=r.jsx(vt,{value:"false",children:v}),e[21]=v,e[22]=b):b=e[22];let _;e[23]!==x||e[24]!==b?(_=r.jsxs(Xt,{children:[x,b]}),e[23]=x,e[24]=b,e[25]=_):_=e[25];let y;return e[26]!==u||e[27]!==f||e[28]!==p||e[29]!==_?(y=r.jsxs(Qt,{value:u,onValueChange:f,children:[p,_]}),e[26]=u,e[27]=f,e[28]=p,e[29]=_,e[30]=y):y=e[30],y}const l=i??"";let c;e[31]!==o?(c=u=>o(u.target.value),e[31]=o,e[32]=c):c=e[32];let d;e[33]!==n||e[34]!==a?(d=a("common.toolInputForm.enterPlaceholder",{fieldKey:n}),e[33]=n,e[34]=a,e[35]=d):d=e[35];let h;return e[36]!==l||e[37]!==c||e[38]!==d?(h=r.jsx(rt,{className:"h-7 text-xs",value:l,onChange:c,placeholder:d}),e[36]=l,e[37]=c,e[38]=d,e[39]=h):h=e[39],h}const ma=8;function bN(t){const e=B.c(29),{open:s,onOpenChange:n}=t,[i,o]=A.useState(""),a=re();let l;e[0]!==a?(l=a("home.addTileDrawer.title"),e[0]=a,e[1]=l):l=e[1];let c;e[2]!==l?(c=r.jsx(qb,{children:l}),e[2]=l,e[3]=c):c=e[3];let d;e[4]!==a?(d=a("home.addTileDrawer.description"),e[4]=a,e[5]=d):d=e[5];let h;e[6]!==d?(h=r.jsx(Gb,{children:d}),e[6]=d,e[7]=h):h=e[7];let u;e[8]===Symbol.for("react.memo_cache_sentinel")?(u=r.jsx(i9,{size:14,className:"absolute left-2.5 top-1/2 -translate-y-1/2 text-muted-foreground pointer-events-none","aria-hidden":!0}),e[8]=u):u=e[8];let f;e[9]===Symbol.for("react.memo_cache_sentinel")?(f=y=>o(y.target.value),e[9]=f):f=e[9];let m;e[10]!==a?(m=a("home.addTileDrawer.searchPlaceholder"),e[10]=a,e[11]=m):m=e[11];let p;e[12]!==i||e[13]!==m?(p=r.jsxs("div",{className:"relative mt-3",children:[u,r.jsx(rt,{value:i,onChange:f,placeholder:m,className:"pl-8 h-8 text-sm"})]}),e[12]=i,e[13]=m,e[14]=p):p=e[14];let g;e[15]!==c||e[16]!==h||e[17]!==p?(g=r.jsxs(Yb,{className:"px-5 py-4 border-b border-border",children:[c,h,p]}),e[15]=c,e[16]=h,e[17]=p,e[18]=g):g=e[18];let x;e[19]===Symbol.for("react.memo_cache_sentinel")?(x=r.jsx(FN,{}),e[19]=x):x=e[19];let v;e[20]!==i?(v=r.jsx(ri,{className:"flex-1 min-h-0 [&_[data-slot=scroll-area-viewport]>div]:!block",children:r.jsx("div",{className:"p-3 flex flex-col gap-4",children:r.jsx(A.Suspense,{fallback:x,children:r.jsx(_N,{search:i})})})}),e[20]=i,e[21]=v):v=e[21];let b;e[22]!==v||e[23]!==g?(b=r.jsxs(Jb,{side:"right",className:"w-full sm:max-w-md p-0 flex flex-col",children:[g,v]}),e[22]=v,e[23]=g,e[24]=b):b=e[24];let _;return e[25]!==n||e[26]!==s||e[27]!==b?(_=r.jsx(Xb,{open:s,onOpenChange:n,children:b}),e[25]=n,e[26]=s,e[27]=b,e[28]=_):_=e[28],_}function yN(t){const e=B.c(32),{org:s}=Fe(),n=v2();let i;e[0]!==n?.ids?(i=n?.ids??[],e[0]=n?.ids,e[1]=i):i=e[1];const o=i,a=b2(),l=X0(),c=Ls();let d;e[2]!==s||e[3]!==c?(d=()=>c.refetchQueries({queryKey:at.homeNextActions(s.slug),type:"active"}),e[2]=s,e[3]=c,e[4]=d):d=e[4];const h=d;let u;e[5]!==o?(u=C=>o.includes(C),e[5]=o,e[6]=u):u=e[6];const f=u;let m;e[7]!==o||e[8]!==t?(m=t?o.filter(C=>t.has(C)).length:o.length,e[7]=o,e[8]=t,e[9]=m):m=e[9];const g=m>=ma;let x;e[10]!==g||e[11]!==f||e[12]!==a?(x=C=>f(C)||g?Promise.resolve():a.apply(N=>N.includes(C)?null:[...N,C]),e[10]=g,e[11]=f,e[12]=a,e[13]=x):x=e[13];const v=x;let b;e[14]!==a?(b=C=>a.apply(N=>N.filter(V=>V!==C)),e[14]=a,e[15]=b):b=e[15];const _=b;let y;e[16]!==a?(y=C=>a.apply(()=>C),e[16]=a,e[17]=y):y=e[17];const L=y;let w;e[18]!==l||e[19]!==g||e[20]!==f||e[21]!==h||e[22]!==a?(w=async(C,N)=>{await l.update.mutateAsync({id:C.id,data:{metadata:N}}),!f(C.id)&&!g&&await a.apply(V=>V.includes(C.id)?null:[...V,C.id]),await h()},e[18]=l,e[19]=g,e[20]=f,e[21]=h,e[22]=a,e[23]=w):w=e[23];const j=w;let S;return e[24]!==v||e[25]!==g||e[26]!==o||e[27]!==f||e[28]!==_||e[29]!==L||e[30]!==j?(S={homeIds:o,isOnHome:f,atLimit:g,addAgent:v,removeAgent:_,reorder:L,saveAgentMetadata:j},e[24]=v,e[25]=g,e[26]=o,e[27]=f,e[28]=_,e[29]=L,e[30]=j,e[31]=S):S=e[31],S}function _N(t){const e=B.c(24),{search:s}=t;let n;e[0]===Symbol.for("react.memo_cache_sentinel")?(n={pageSize:1e3},e[0]=n):n=e[0];const i=ta(n);let o;e[1]!==i?(o=new Set(i.map(CN)),e[1]=i,e[2]=o):o=e[2];const a=yN(o);let l,c,d;if(e[3]!==i||e[4]!==a||e[5]!==s){const x=new Map(i.map(jN));l=s.trim().toLowerCase();const v=y=>!l||y.title?.toLowerCase().includes(l);c=a.homeIds.map(y=>x.get(y)).filter(wN).filter(v);const b=u9(i);let _;e[9]!==a?(_=y=>!a.isOnHome(y.id),e[9]=a,e[10]=_):_=e[10],d=i.filter(SN).filter(y=>!b.has(y.id)).filter(_).filter(v).sort(LN),e[3]=i,e[4]=a,e[5]=s,e[6]=l,e[7]=c,e[8]=d}else l=e[6],c=e[7],d=e[8];const h=d;let u;e[11]!==a||e[12]!==c?(u=r.jsx(kN,{home:a,agents:c}),e[11]=a,e[12]=c,e[13]=u):u=e[13];let f;e[14]!==l?(f=!l&&r.jsx(fN,{}),e[14]=l,e[15]=f):f=e[15];const m=!!l;let p;e[16]!==h||e[17]!==a||e[18]!==m?(p=r.jsx(NN,{home:a,agents:h,hasSearch:m}),e[16]=h,e[17]=a,e[18]=m,e[19]=p):p=e[19];let g;return e[20]!==u||e[21]!==f||e[22]!==p?(g=r.jsxs(r.Fragment,{children:[u,f,p]}),e[20]=u,e[21]=f,e[22]=p,e[23]=g):g=e[23],g}function LN(t,e){return(t.title??"").localeCompare(e.title??"")}function SN(t){return t.id&&!nl(t.id)}function wN(t){return!!t}function jN(t){return[t.id,t]}function CN(t){return t.id}function kN(t){const e=B.c(19),{home:s,agents:n}=t;let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i={activationConstraint:{distance:5}},e[0]=i):i=e[0];let o;e[1]===Symbol.for("react.memo_cache_sentinel")?(o={coordinateGetter:au},e[1]=o):o=e[1];const a=gc(si(Br,i),si($r,o)),l=re();let c;e[2]!==s||e[3]!==l?(c=g=>{const{active:x,over:v}=g;if(!v||x.id===v.id)return;const b=s.homeIds,_=b.indexOf(x.id),y=b.indexOf(v.id);_===-1||y===-1||s.reorder(_r([...b],_,y)).catch(()=>ge.error(l("home.addTileDrawer.reorderError")))},e[2]=s,e[3]=l,e[4]=c):c=e[4];const d=c;let h;e[5]!==l?(h=l("home.addTileDrawer.onHomeTitle"),e[5]=l,e[6]=h):h=e[6];const u=`${s.homeIds.length}/${ma}`;let f;e[7]!==h||e[8]!==u?(f=r.jsx(cu,{title:h,hint:u}),e[7]=h,e[8]=u,e[9]=f):f=e[9];let m;e[10]!==n||e[11]!==d||e[12]!==s||e[13]!==a||e[14]!==l?(m=n.length===0?r.jsx("p",{className:"px-3 py-4 text-center text-xs text-muted-foreground",children:l("home.addTileDrawer.noAgentsOnHome")}):r.jsx(yc,{sensors:a,collisionDetection:J9,onDragEnd:d,children:r.jsx(ru,{items:n.map(VN),strategy:iu,children:r.jsx("div",{className:"flex flex-col gap-1",children:n.map(g=>r.jsx(EN,{agent:g,home:s},g.id))})})}),e[10]=n,e[11]=d,e[12]=s,e[13]=a,e[14]=l,e[15]=m):m=e[15];let p;return e[16]!==f||e[17]!==m?(p=r.jsxs("div",{className:"flex flex-col gap-1.5",children:[f,m]}),e[16]=f,e[17]=m,e[18]=p):p=e[18],p}function VN(t){return t.id}function NN(t){const e=B.c(7),{home:s,agents:n,hasSearch:i}=t,[o,a]=A.useState(20),l=n.slice(0,o),c=re(),d="flex flex-col gap-1.5";let h;e[0]!==c?(h=c("home.addTileDrawer.addToHomeTitle"),e[0]=c,e[1]=h):h=e[1];let u;e[2]!==h?(u=r.jsx(cu,{title:h}),e[2]=h,e[3]=u):u=e[3];const f=n.length===0?r.jsx("p",{className:"px-3 py-4 text-center text-xs text-muted-foreground",children:c(i?"home.addTileDrawer.noAgentsMatch":"home.addTileDrawer.allAgentsOnHome")}):r.jsxs(r.Fragment,{children:[r.jsx("div",{className:"flex flex-col gap-1",children:l.map(p=>r.jsx(RN,{agent:p,home:s},p.id))}),n.length>o&&r.jsx("button",{type:"button",onClick:()=>a(TN),className:"mt-1 self-center rounded-md px-3 py-1.5 text-xs text-muted-foreground hover:bg-accent/40 hover:text-foreground",children:c("home.addTileDrawer.loadMore",{count:n.length-o})})]});let m;return e[4]!==u||e[5]!==f?(m=r.jsxs("div",{className:d,children:[u,f]}),e[4]=u,e[5]=f,e[6]=m):m=e[6],m}function TN(t){return t+20}function Y3(t){const e=B.c(14),s=re();let n;e[0]!==t.metadata?.ui?(n=ur(t.metadata?.ui).filter(AN),e[0]=t.metadata?.ui,e[1]=n):n=e[1];const i=n.length,o=t.metadata?.ui?.homePrompts,a=Array.isArray(o)?o.length:null;let l;if(e[2]!==a||e[3]!==s||e[4]!==i){if(l=[],i>0){let c;e[6]!==s||e[7]!==i?(c=s("home.addTileDrawer.tileCountLabel",{count:i}),e[6]=s,e[7]=i,e[8]=c):c=e[8],l.push(c)}if(a!==null&&a>0){let c;e[9]!==a||e[10]!==s?(c=s("home.addTileDrawer.promptCountLabel",{count:a}),e[9]=a,e[10]=s,e[11]=c):c=e[11],l.push(c)}if(a===0){let c;e[12]!==s?(c=s("home.addTileDrawer.promptsOffLabel"),e[12]=s,e[13]=c):c=e[13],l.push(c)}e[2]=a,e[3]=s,e[4]=i,e[5]=l}else l=e[5];return l.join(" · ")}function AN(t){return!!t.resourceUri}function EN(t){const e=B.c(70),{agent:s,home:n}=t,[i,o]=A.useState(!1),a=re();let l;e[0]!==s.id?(l={id:s.id},e[0]=s.id,e[1]=l):l=e[1];const{attributes:c,listeners:d,setNodeRef:h,transform:u,transition:f,isDragging:m}=ou(l),p=Y3(s)||a("home.addTileDrawer.quickAccess"),g=`home-agent-expansion-${s.id}`;let x;e[2]!==u?(x=Ln.Transform.toString(u),e[2]=u,e[3]=x):x=e[3];const v=m?.5:void 0,b=m?100:void 0;let _;e[4]!==x||e[5]!==v||e[6]!==b||e[7]!==f?(_={transform:x,transition:f,opacity:v,zIndex:b},e[4]=x,e[5]=v,e[6]=b,e[7]=f,e[8]=_):_=e[8];const y=_,L=m&&"shadow-lg";let w;e[9]!==L?(w=ie("rounded-lg border border-border bg-card",L),e[9]=L,e[10]=w):w=e[10];const j=s.title??s.id;let S;e[11]!==a||e[12]!==j?(S=a("home.addTileDrawer.dragToReorder",{name:j}),e[11]=a,e[12]=j,e[13]=S):S=e[13];let C;e[14]===Symbol.for("react.memo_cache_sentinel")?(C=r.jsx(oa,{size:14}),e[14]=C):C=e[14];let N;e[15]!==c||e[16]!==d||e[17]!==S?(N=r.jsx("button",{type:"button",...c,...d,className:"shrink-0 text-muted-foreground hover:text-foreground cursor-grab active:cursor-grabbing outline-none focus-visible:ring-2 focus-visible:ring-ring rounded","aria-label":S,children:C}),e[15]=c,e[16]=d,e[17]=S,e[18]=N):N=e[18];let V;e[19]===Symbol.for("react.memo_cache_sentinel")?(V=()=>o(PN),e[19]=V):V=e[19];const E=s.title??s.id;let T;e[20]!==s.icon||e[21]!==E?(T=r.jsx(Qn,{icon:s.icon,name:E,size:"sm"}),e[20]=s.icon,e[21]=E,e[22]=T):T=e[22];const k=s.title??s.id;let R;e[23]!==k?(R=r.jsx("div",{className:"truncate text-sm font-medium text-foreground",children:k}),e[23]=k,e[24]=R):R=e[24];let P;e[25]!==p?(P=r.jsx("div",{className:"truncate text-xs text-muted-foreground",children:p}),e[25]=p,e[26]=P):P=e[26];let D;e[27]!==R||e[28]!==P?(D=r.jsxs("div",{className:"min-w-0 flex-1",children:[R,P]}),e[27]=R,e[28]=P,e[29]=D):D=e[29];const I=i&&"rotate-180";let M;e[30]!==I?(M=ie("shrink-0 text-muted-foreground transition-transform",I),e[30]=I,e[31]=M):M=e[31];let O;e[32]!==M?(O=r.jsx(ss,{size:16,className:M}),e[32]=M,e[33]=O):O=e[33];let F;e[34]!==i||e[35]!==g||e[36]!==T||e[37]!==D||e[38]!==O?(F=r.jsxs("button",{type:"button",onClick:V,className:"flex min-w-0 flex-1 items-center gap-2.5 text-left outline-none","aria-expanded":i,"aria-controls":g,children:[T,D,O]}),e[34]=i,e[35]=g,e[36]=T,e[37]=D,e[38]=O,e[39]=F):F=e[39];let $;e[40]!==s.id||e[41]!==n||e[42]!==a?($=()=>n.removeAgent(s.id).catch(()=>ge.error(a("home.addTileDrawer.removeError"))),e[40]=s.id,e[41]=n,e[42]=a,e[43]=$):$=e[43];const z=s.title??s.id;let K;e[44]!==a||e[45]!==z?(K=a("home.addTileDrawer.removeAgentFromHome",{name:z}),e[44]=a,e[45]=z,e[46]=K):K=e[46];const X=s.title??s.id;let J;e[47]!==a||e[48]!==X?(J=a("home.addTileDrawer.removeAgentFromHome",{name:X}),e[47]=a,e[48]=X,e[49]=J):J=e[49];let H;e[50]===Symbol.for("react.memo_cache_sentinel")?(H=r.jsx(ks,{size:14}),e[50]=H):H=e[50];let W;e[51]!==$||e[52]!==K||e[53]!==J?(W=r.jsx("button",{type:"button",onClick:$,"aria-label":K,title:J,className:"shrink-0 inline-flex size-7 items-center justify-center rounded-md text-muted-foreground hover:bg-destructive/10 hover:text-destructive",children:H}),e[51]=$,e[52]=K,e[53]=J,e[54]=W):W=e[54];let U;e[55]!==N||e[56]!==F||e[57]!==W?(U=r.jsxs("div",{className:"flex items-center gap-1.5 px-2 py-2.5",children:[N,F,W]}),e[55]=N,e[56]=F,e[57]=W,e[58]=U):U=e[58];let Q;e[59]!==s||e[60]!==i||e[61]!==g||e[62]!==n?(Q=i&&r.jsx(J3,{id:g,agent:s,home:n}),e[59]=s,e[60]=i,e[61]=g,e[62]=n,e[63]=Q):Q=e[63];let q;return e[64]!==h||e[65]!==y||e[66]!==U||e[67]!==Q||e[68]!==w?(q=r.jsxs("div",{ref:h,style:y,className:w,children:[U,Q]}),e[64]=h,e[65]=y,e[66]=U,e[67]=Q,e[68]=w,e[69]=q):q=e[69],q}function PN(t){return!t}function RN({agent:t,home:e}){const[s,n]=A.useState(!1),[i,o]=A.useState(!1),a=Y3(t),l=re(),c=`available-agent-expansion-${t.id}`,d=async()=>{if(!e.atLimit){o(!0);try{await e.addAgent(t.id)}catch{ge.error(l("home.addTileDrawer.addError"))}finally{o(!1)}}};return r.jsxs("div",{className:"rounded-lg border border-border bg-card",children:[r.jsxs("div",{className:"flex items-center gap-2 px-3 py-2.5",children:[r.jsxs("button",{type:"button",onClick:()=>n(h=>!h),className:"flex min-w-0 flex-1 items-center gap-3 text-left outline-none","aria-expanded":s,"aria-controls":c,children:[r.jsx(Qn,{icon:t.icon,name:t.title??t.id,size:"sm"}),r.jsxs("div",{className:"min-w-0 flex-1",children:[r.jsx("div",{className:"truncate text-sm font-medium text-foreground",children:t.title??t.id}),a&&r.jsx("div",{className:"truncate text-xs text-muted-foreground",children:a})]}),r.jsx(ss,{size:16,className:ie("shrink-0 text-muted-foreground transition-transform",s&&"rotate-180")})]}),r.jsx("button",{type:"button",onClick:d,disabled:i||e.atLimit,"aria-label":l("home.addTileDrawer.addToHomeTitle"),title:e.atLimit?l("home.addTileDrawer.homeFullMessage",{limit:ma}):l("home.addTileDrawer.addToHomeTitle"),className:"shrink-0 inline-flex size-7 items-center justify-center rounded-md bg-foreground text-background text-xs hover:opacity-90 disabled:opacity-40 disabled:cursor-not-allowed",children:i?r.jsx(et,{size:12,className:"animate-spin"}):r.jsx(kt,{size:14})})]}),s&&r.jsx(J3,{id:c,agent:t,home:e})]})}function J3(t){const e=B.c(18),{id:s,agent:n,home:i}=t,o=n.metadata?.ui;let a;e[0]!==o?(a=ur(o),e[0]=o,e[1]=a):a=e[1];const l=a;let c;e[2]!==n.connections?(c=(n.connections??[]).map(DN).sort(),e[2]=n.connections,e[3]=c):c=e[3];const d=c,h=n.metadata?.ui?.homePrompts;let u;e[4]!==n||e[5]!==d||e[6]!==i||e[7]!==l?(u=r.jsx(MN,{agent:n,home:i,connectionIds:d,pinnedTiles:l}),e[4]=n,e[5]=d,e[6]=i,e[7]=l,e[8]=u):u=e[8];let f;e[9]===Symbol.for("react.memo_cache_sentinel")?(f=r.jsx(IN,{}),e[9]=f):f=e[9];const m=h??null;let p;e[10]!==n||e[11]!==i||e[12]!==m?(p=r.jsx(A.Suspense,{fallback:f,children:r.jsx(oN,{agent:n,home:i,curated:m})}),e[10]=n,e[11]=i,e[12]=m,e[13]=p):p=e[13];let g;return e[14]!==s||e[15]!==u||e[16]!==p?(g=r.jsxs("div",{id:s,className:"border-t border-border px-3 py-2 flex flex-col gap-3",children:[u,p]}),e[14]=s,e[15]=u,e[16]=p,e[17]=g):g=e[17],g}function DN(t){return t.connection_id}function IN(){const t=B.c(1);let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=r.jsxs("div",{className:"flex flex-col gap-2 py-1",children:[r.jsx(Rt,{className:"h-8 w-full"}),r.jsx(Rt,{className:"h-8 w-2/3"})]}),t[0]=e):e=t[0],e}function MN({agent:t,home:e,connectionIds:s,pinnedTiles:n}){const i=re(),o=Bs(),{data:a,isLoading:l}=Ft({queryKey:at.projectConnectionDetails(t.id,s),enabled:s.length>0,queryFn:async()=>(await Promise.all(s.map(async f=>{try{const{item:m}=await o.call("COLLECTION_CONNECTIONS_GET",{id:f}),p=(m?.tools??[]).flatMap(g=>{const x=sc(g._meta);return x?[{name:g.name,description:g.description,resourceUri:x,inputSchema:g.inputSchema}]:[]});return{id:f,title:m?.title??f,icon:m?.icon??null,uiTools:p}}catch{return{id:f,title:f,icon:null,uiTools:[]}}}))).filter(f=>f.uiTools.length>0)});if(s.length===0)return null;if(l)return r.jsxs("div",{className:"flex flex-col gap-1 py-0.5",children:[r.jsx(Rt,{className:"h-7 w-full"}),r.jsx(Rt,{className:"h-7 w-2/3"})]});if(!a||a.length===0)return null;const c=new Map;for(const u of a)for(const f of u.uiTools)c.set(`${u.id}:${f.name}`,{conn:u,tool:f});const d=u=>{if(u.toolName&&u.connectionId)return c.get(`${u.connectionId}:${u.toolName}`);for(const[,f]of c)if(f.conn.id===u.connectionId&&f.tool.resourceUri===u.resourceUri)return f},h=n.some(u=>!!d(u));return r.jsxs("div",{className:"flex flex-col gap-2",children:[h&&r.jsxs("div",{className:"flex flex-col gap-0.5",children:[r.jsx("span",{className:"text-[10px] font-medium uppercase tracking-wide text-muted-foreground px-2",children:i("home.addTileDrawer.pinnedTiles")}),n.map(u=>{const f=d(u);return f?r.jsx(ON,{agent:t,home:e,connection:f.conn,tool:f.tool,tile:u},u.tileId??`${u.connectionId}:${u.resourceUri}:${u.toolName}`):null})]}),r.jsxs("div",{className:"flex flex-col gap-0.5",children:[r.jsx("span",{className:"text-[10px] font-medium uppercase tracking-wide text-muted-foreground px-2",children:i("home.addTileDrawer.addTileLabel")}),a.map(u=>u.uiTools.map(f=>r.jsx(BN,{agent:t,home:e,connection:u,tool:f},`add:${u.id}:${f.name}`)))]})]})}function Xd(t,e){return{...t.metadata??{},ui:{...t.metadata?.ui??{},homeTile:null,homeTiles:e}}}async function Qd(t,e,s){try{await e()}catch(n){console.error(`[home-tiles] failed to ${t} tile`,n),ge.error(s("home.addTileDrawer.updateError"))}}function X3(t,e,s,n){if(!e||Object.keys(e).length===0)return{};const i=mN(t,e,s);if(!i){ge.error(n("home.addTileDrawer.invalidFieldError"));return}return Object.keys(i).length>0?{toolInput:i}:{}}function Q3(t){const e=B.c(23),{properties:s,required:n,values:i,onChange:o,onCancel:a,onSubmit:l,submitting:c,submitLabel:d}=t,h=re();let u;e[0]!==o||e[1]!==s||e[2]!==n||e[3]!==i?(u=r.jsx(xN,{properties:s,required:n,values:i,onChange:o}),e[0]=o,e[1]=s,e[2]=n,e[3]=i,e[4]=u):u=e[4];let f;e[5]!==h?(f=h("home.addTileDrawer.cancel"),e[5]=h,e[6]=f):f=e[6];let m;e[7]!==a||e[8]!==f?(m=r.jsx(le,{variant:"ghost",size:"sm",className:"h-7 text-xs",onClick:a,children:f}),e[7]=a,e[8]=f,e[9]=m):m=e[9];let p;e[10]!==d||e[11]!==c?(p=c?r.jsx(et,{size:12,className:"animate-spin"}):d,e[10]=d,e[11]=c,e[12]=p):p=e[12];let g;e[13]!==l||e[14]!==c||e[15]!==p?(g=r.jsx(le,{size:"sm",className:"h-7 text-xs",disabled:c,onClick:l,children:p}),e[13]=l,e[14]=c,e[15]=p,e[16]=g):g=e[16];let x;e[17]!==m||e[18]!==g?(x=r.jsxs("div",{className:"flex items-center gap-2 justify-end",children:[m,g]}),e[17]=m,e[18]=g,e[19]=x):x=e[19];let v;return e[20]!==u||e[21]!==x?(v=r.jsxs("div",{className:"px-3 pb-2 pt-1 flex flex-col gap-2",children:[u,x]}),e[20]=u,e[21]=x,e[22]=v):v=e[22],v}function ON(t){const e=B.c(57),{agent:s,home:n,connection:i,tool:o,tile:a}=t,[l,c]=A.useState(!1),[d,h]=A.useState(!1),u=re();let f;e[0]!==o.inputSchema?(f=o.inputSchema?.properties&&Object.keys(o.inputSchema.properties).length>0,e[0]=o.inputSchema,e[1]=f):f=e[1];const m=f;let p;e[2]!==a.toolInput||e[3]!==o.inputSchema?.properties?(p=()=>pN(a.toolInput,o.inputSchema?.properties),e[2]=a.toolInput,e[3]=o.inputSchema?.properties,e[4]=p):p=e[4];const[g,x]=A.useState(p);let v;e[5]!==s||e[6]!==n||e[7]!==u||e[8]!==a?(v=async()=>{c(!0),await Qd("remove",async()=>{const I=ur(s.metadata?.ui),M=a.tileId?I.filter(O=>O.tileId!==a.tileId):I.filter(O=>O!==a);await n.saveAgentMetadata(s,Xd(s,M)),h(!1)},u),c(!1)},e[5]=s,e[6]=n,e[7]=u,e[8]=a,e[9]=v):v=e[9];const b=v;let _;e[10]!==s||e[11]!==g||e[12]!==n||e[13]!==u||e[14]!==a||e[15]!==o.inputSchema?.properties||e[16]!==o.inputSchema?.required?(_=async()=>{const I=X3(g,o.inputSchema?.properties,o.inputSchema?.required,u);if(!I)return;const{toolInput:M}=I;c(!0),await Qd("save",async()=>{const F=ur(s.metadata?.ui).map($=>(a.tileId?$.tileId===a.tileId:$===a)?{...$,toolInput:M}:$);await n.saveAgentMetadata(s,Xd(s,F)),h(!1)},u),c(!1)},e[10]=s,e[11]=g,e[12]=n,e[13]=u,e[14]=a,e[15]=o.inputSchema?.properties,e[16]=o.inputSchema?.required,e[17]=_):_=e[17];const y=_;let L;e[18]!==a.toolInput?(L=gN(a.toolInput),e[18]=a.toolInput,e[19]=L):L=e[19];const w=L;let j;e[20]!==i.icon||e[21]!==i.title?(j=r.jsx(an,{icon:i.icon,name:i.title,size:"xs"}),e[20]=i.icon,e[21]=i.title,e[22]=j):j=e[22];let S;e[23]!==o.name?(S=Ci(o.name),e[23]=o.name,e[24]=S):S=e[24];let C;e[25]!==S?(C=r.jsx("div",{className:"truncate text-sm text-foreground",children:S}),e[25]=S,e[26]=C):C=e[26];let N;e[27]!==w?(N=w&&r.jsx("div",{className:"truncate text-[10px] text-muted-foreground font-mono",children:w}),e[27]=w,e[28]=N):N=e[28];let V;e[29]!==C||e[30]!==N?(V=r.jsxs("div",{className:"min-w-0 flex-1",children:[C,N]}),e[29]=C,e[30]=N,e[31]=V):V=e[31];let E;e[32]!==m||e[33]!==u?(E=m&&r.jsx("button",{type:"button",onClick:()=>h($N),"aria-label":u("home.addTileDrawer.configureTile"),title:u("home.addTileDrawer.configureTile"),className:"inline-flex size-7 shrink-0 items-center justify-center rounded-md text-muted-foreground hover:bg-accent/60",children:r.jsx(Jm,{size:14})}),e[32]=m,e[33]=u,e[34]=E):E=e[34];let T;e[35]!==u?(T=u("home.addTileDrawer.removeFromHome"),e[35]=u,e[36]=T):T=e[36];let k;e[37]!==b||e[38]!==l||e[39]!==T?(k=r.jsx(lu,{isPinned:!0,submitting:l,onClick:b,label:T}),e[37]=b,e[38]=l,e[39]=T,e[40]=k):k=e[40];let R;e[41]!==V||e[42]!==E||e[43]!==k||e[44]!==j?(R=r.jsxs("div",{className:"flex items-center gap-2.5 px-2 py-1",children:[j,V,E,k]}),e[41]=V,e[42]=E,e[43]=k,e[44]=j,e[45]=R):R=e[45];let P;e[46]!==g||e[47]!==y||e[48]!==m||e[49]!==d||e[50]!==l||e[51]!==u||e[52]!==o.inputSchema?(P=d&&m&&o.inputSchema?.properties&&r.jsx(Q3,{properties:o.inputSchema.properties,required:o.inputSchema.required,values:g,onChange:(I,M)=>x(O=>({...O,[I]:M})),onCancel:()=>h(!1),onSubmit:y,submitting:l,submitLabel:u("home.addTileDrawer.save")}),e[46]=g,e[47]=y,e[48]=m,e[49]=d,e[50]=l,e[51]=u,e[52]=o.inputSchema,e[53]=P):P=e[53];let D;return e[54]!==R||e[55]!==P?(D=r.jsxs("div",{className:"flex flex-col rounded-md bg-accent/20",children:[R,P]}),e[54]=R,e[55]=P,e[56]=D):D=e[56],D}function $N(t){return!t}function BN(t){const e=B.c(44),{agent:s,home:n,connection:i,tool:o}=t,[a,l]=A.useState(!1),[c,d]=A.useState(!1),h=re();let u;e[0]!==o.inputSchema?(u=o.inputSchema?.properties&&Object.keys(o.inputSchema.properties).length>0,e[0]=o.inputSchema,e[1]=u):u=e[1];const f=u;let m;e[2]===Symbol.for("react.memo_cache_sentinel")?(m={},e[2]=m):m=e[2];const[p,g]=A.useState(m);let x,v;e[3]!==s||e[4]!==i.id||e[5]!==p||e[6]!==f||e[7]!==n||e[8]!==c||e[9]!==h||e[10]!==o.inputSchema?.properties||e[11]!==o.inputSchema?.required||e[12]!==o.name||e[13]!==o.resourceUri?(x=async()=>{if(f&&!c){d(!0);return}if(!n.isOnHome(s.id)&&n.atLimit){ge.error(h("home.addTileDrawer.homeFullMessage",{limit:ma}));return}await v()},v=async()=>{const N=X3(p,o.inputSchema?.properties,o.inputSchema?.required,h);if(!N)return;const{toolInput:V}=N;l(!0),await Qd("add",async()=>{const T=[...ur(s.metadata?.ui),{tileId:crypto.randomUUID(),connectionId:i.id,resourceUri:o.resourceUri,toolName:o.name,...V?{toolInput:V}:{}}];await n.saveAgentMetadata(s,Xd(s,T)),d(!1),g({})},h),l(!1)},e[3]=s,e[4]=i.id,e[5]=p,e[6]=f,e[7]=n,e[8]=c,e[9]=h,e[10]=o.inputSchema?.properties,e[11]=o.inputSchema?.required,e[12]=o.name,e[13]=o.resourceUri,e[14]=x,e[15]=v):(x=e[14],v=e[15]);let b;e[16]!==i.icon||e[17]!==i.title?(b=r.jsx(an,{icon:i.icon,name:i.title,size:"xs"}),e[16]=i.icon,e[17]=i.title,e[18]=b):b=e[18];let _;e[19]!==o.name?(_=Ci(o.name),e[19]=o.name,e[20]=_):_=e[20];let y;e[21]!==_?(y=r.jsx("div",{className:"min-w-0 flex-1 truncate text-sm text-foreground",children:_}),e[21]=_,e[22]=y):y=e[22];let L;e[23]!==h?(L=h("home.addTileDrawer.addToHomeTitle"),e[23]=h,e[24]=L):L=e[24];let w;e[25]!==x||e[26]!==a||e[27]!==L?(w=r.jsx(lu,{isPinned:!1,submitting:a,onClick:x,label:L}),e[25]=x,e[26]=a,e[27]=L,e[28]=w):w=e[28];let j;e[29]!==b||e[30]!==y||e[31]!==w?(j=r.jsxs("div",{className:"flex items-center gap-2.5 px-2 py-1",children:[b,y,w]}),e[29]=b,e[30]=y,e[31]=w,e[32]=j):j=e[32];let S;e[33]!==p||e[34]!==f||e[35]!==v||e[36]!==c||e[37]!==a||e[38]!==h||e[39]!==o.inputSchema?(S=c&&f&&o.inputSchema?.properties&&r.jsx(Q3,{properties:o.inputSchema.properties,required:o.inputSchema.required,values:p,onChange:(N,V)=>g(E=>({...E,[N]:V})),onCancel:()=>{d(!1),g({})},onSubmit:v,submitting:a,submitLabel:h("home.addTileDrawer.pin")}),e[33]=p,e[34]=f,e[35]=v,e[36]=c,e[37]=a,e[38]=h,e[39]=o.inputSchema,e[40]=S):S=e[40];let C;return e[41]!==j||e[42]!==S?(C=r.jsxs("div",{className:"flex flex-col rounded-md hover:bg-accent/40",children:[j,S]}),e[41]=j,e[42]=S,e[43]=C):C=e[43],C}function FN(){const t=B.c(1);let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=r.jsx("div",{className:"flex flex-col gap-2 p-2",children:Array.from({length:4},zN)}),t[0]=e):e=t[0],e}function zN(t,e){return r.jsxs("div",{className:"flex items-center gap-3 rounded-lg border border-border p-2.5",children:[r.jsx(Rt,{className:"size-8 rounded-md"}),r.jsxs("div",{className:"flex-1 space-y-1.5",children:[r.jsx(Rt,{className:"h-3 w-1/2"}),r.jsx(Rt,{className:"h-2.5 w-1/3"})]})]},e)}const KN=[{id:"all",labelKey:"home.homeTasks.tabAll"},{id:"in_progress",labelKey:"home.homeTasks.tabInProgress"},{id:"in_review",labelKey:"home.homeTasks.tabInReview"},{id:"done",labelKey:"home.homeTasks.tabDone"}],UN=4;function HN(t){const e=B.c(64),{task:s,assignee:n,onOpen:i}=t,o=Ov[s.status],a=o.icon,l=$v[s.priority];let c,d,h,u,f,m,p,g,x,v,b,_,y,L;if(e[0]!==a||e[1]!==n?.user?.email||e[2]!==n?.user?.image||e[3]!==n?.user?.name||e[4]!==i||e[5]!==o.iconClassName||e[6]!==s.dueDate||e[7]!==s.title||e[8]!==s.updatedAt){const k=n?.user?.name??n?.user?.email?.split("@")[0]??null;let R;e[23]!==s.updatedAt?(R=V2(new Date(s.updatedAt)),e[23]=s.updatedAt,e[24]=R):R=e[24],L=R;let P;e[25]!==s.dueDate?(P=s.dueDate?{label:new Intl.DateTimeFormat(void 0,{month:"short",day:"numeric"}).format(new Date(s.dueDate)),overdue:new Date(s.dueDate).getTime()<Date.now()}:null,e[25]=s.dueDate,e[26]=P):P=e[26],d=P,b="button",_=i,y="flex w-full items-center gap-3 rounded-2xl bg-card px-4 py-3.5 text-left card-shadow transition-colors hover:bg-accent/60";let D;e[27]!==o.iconClassName?(D=ie("size-4 shrink-0",o.iconClassName),e[27]=o.iconClassName,e[28]=D):D=e[28],e[29]!==a||e[30]!==D?(u=r.jsx(a,{className:D}),e[29]=a,e[30]=D,e[31]=u):u=e[31],e[32]!==s.title?(f=r.jsx("span",{className:"min-w-0 flex-1 truncate text-sm font-medium text-foreground",children:s.title}),e[32]=s.title,e[33]=f):f=e[33],v="flex shrink-0 items-center gap-3 text-xs text-muted-foreground",x="hidden @2xl:inline-flex",c=ir,h="circle",m="2xs",p=n?.user?.image??void 0,g=(k??"?").slice(0,2).toUpperCase(),e[0]=a,e[1]=n?.user?.email,e[2]=n?.user?.image,e[3]=n?.user?.name,e[4]=i,e[5]=o.iconClassName,e[6]=s.dueDate,e[7]=s.title,e[8]=s.updatedAt,e[9]=c,e[10]=d,e[11]=h,e[12]=u,e[13]=f,e[14]=m,e[15]=p,e[16]=g,e[17]=x,e[18]=v,e[19]=b,e[20]=_,e[21]=y,e[22]=L}else c=e[9],d=e[10],h=e[11],u=e[12],f=e[13],m=e[14],p=e[15],g=e[16],x=e[17],v=e[18],b=e[19],_=e[20],y=e[21],L=e[22];let w;e[34]!==c||e[35]!==h||e[36]!==m||e[37]!==p||e[38]!==g?(w=r.jsx(c,{shape:h,size:m,url:p,fallback:g}),e[34]=c,e[35]=h,e[36]=m,e[37]=p,e[38]=g,e[39]=w):w=e[39];let j;e[40]!==w||e[41]!==x?(j=r.jsx("span",{className:x,children:w}),e[40]=w,e[41]=x,e[42]=j):j=e[42];let S;e[43]!==l.flagClassName?(S=ie("size-3.5 shrink-0",l.flagClassName),e[43]=l.flagClassName,e[44]=S):S=e[44];let C;e[45]!==S?(C=r.jsx(_9,{className:S}),e[45]=S,e[46]=C):C=e[46];let N;e[47]!==d?(N=d&&r.jsxs("span",{className:ie("hidden items-center gap-1 @xl:inline-flex",d.overdue?"text-red-600":""),children:[r.jsx(r9,{className:"size-3"}),d.label]}),e[47]=d,e[48]=N):N=e[48];let V;e[49]!==L?(V=r.jsx("span",{className:"hidden @xl:inline",children:L}),e[49]=L,e[50]=V):V=e[50];let E;e[51]!==j||e[52]!==C||e[53]!==N||e[54]!==V||e[55]!==v?(E=r.jsxs("div",{className:v,children:[j,C,N,V]}),e[51]=j,e[52]=C,e[53]=N,e[54]=V,e[55]=v,e[56]=E):E=e[56];let T;return e[57]!==u||e[58]!==f||e[59]!==E||e[60]!==b||e[61]!==_||e[62]!==y?(T=r.jsxs("button",{type:b,onClick:_,className:y,children:[u,f,E]}),e[57]=u,e[58]=f,e[59]=E,e[60]=b,e[61]=_,e[62]=y,e[63]=T):T=e[63],T}function WN(t,e){const s=t.filter(h=>h.status!=="done");if(s.length===0)return"";const n=s.filter(h=>h.status==="in_progress").length,i=s.filter(h=>h.status==="in_review").length,o=s.filter(h=>h.priority==="urgent"||h.priority==="high").length,a=s.filter(h=>h.dueDate&&new Date(h.dueDate).getTime()<Date.now()).length,l=[];n>0&&l.push(e("home.homeTasks.breakdownInProgress",{count:n})),i>0&&l.push(e("home.homeTasks.breakdownNeedsReview",{count:i}));let c=e("home.homeTasks.summaryLead",{count:s.length});l.length>0&&(c+=` — ${l.join(", ")}`),c+=".";const d=[];return o>0&&d.push(e("home.homeTasks.noteHighPriority",{count:o})),a>0&&d.push(e("home.homeTasks.noteOverdue",{count:a})),d.length>0?`${c} ${d.join(" ")}`:c}function qN(t){const e=B.c(49),{afterSummary:s}=t,n=re(),i=St(),{items:o,error:a}=Dv(),l=Iv(),{data:c}=r2();let d;if(e[0]!==c?.data?.members){const N=c?.data?.members??[];d=new Map(N.map(JN)),e[0]=c?.data?.members,e[1]=d}else d=e[1];const h=d,[u,f]=A.useState("all"),[m,p]=A.useState(!1);let g,x,v,b,_,y;if(e[2]!==s||e[3]!==a||e[4]!==o||e[5]!==h||e[6]!==i||e[7]!==n||e[8]!==u){const N=a?[]:o,V=[...N].sort(YN);let E;e[15]!==n?(E=($,z)=>n($,z),e[15]=n,e[16]=E):E=e[16];const T=WN(N,E),k=u==="all"?V:V.filter($=>$.status===u);let R;e[17]!==i?(R=()=>i({to:".",search:GN}),e[17]=i,e[18]=R):R=e[18];const P=R;b="flex flex-col gap-10";let D;e[19]===Symbol.for("react.memo_cache_sentinel")?(D=r.jsx(Bv,{size:24,className:"mt-0.5"}),e[19]=D):D=e[19],_=r.jsxs("div",{className:"flex items-start gap-4 animate-in fade-in slide-in-from-top-1 duration-300",children:[D,r.jsx("p",{className:"max-w-3xl text-lg font-medium leading-snug text-foreground",children:T})]}),y=s,g="flex flex-col gap-4";let I;e[20]!==n?(I=n("home.homeTasks.tasksHeading"),e[20]=n,e[21]=I):I=e[21];let M;e[22]!==I?(M=r.jsx("h2",{className:"text-base font-medium text-foreground",children:I}),e[22]=I,e[23]=M):M=e[23];let O;e[24]!==n||e[25]!==u?(O=KN.map($=>r.jsx("button",{type:"button",onClick:()=>f($.id),className:ie("rounded-md px-2.5 py-1 text-xs font-medium transition-colors",u===$.id?"bg-accent text-foreground":"text-muted-foreground hover:text-foreground"),children:n($.labelKey)},$.id)),e[24]=n,e[25]=u,e[26]=O):O=e[26];let F;e[27]!==O?(F=r.jsx("div",{className:"flex items-center gap-1",children:O}),e[27]=O,e[28]=F):F=e[28],e[29]!==M||e[30]!==F?(x=r.jsxs("div",{className:"flex items-center gap-3",children:[M,F]}),e[29]=M,e[30]=F,e[31]=x):x=e[31],v=k.length===0?r.jsxs("div",{className:"flex flex-col items-center gap-3 rounded-2xl bg-card px-4 py-10 text-center card-shadow",children:[r.jsx("p",{className:"text-sm text-muted-foreground",children:u==="all"?n("home.homeTasks.emptyStateNoTasks"):n("home.homeTasks.emptyStateNothing",{status:n(u==="in_progress"?"home.homeTasks.statusInProgress":u==="in_review"?"home.homeTasks.statusInReview":"home.homeTasks.statusDone")})}),u==="all"&&r.jsxs(le,{variant:"outline",size:"sm",onClick:()=>p(!0),className:"gap-2",children:[r.jsx(kt,{className:"size-4"}),n("home.homeTasks.createNewTask")]})]}):r.jsxs("div",{className:"flex flex-col gap-2",children:[k.slice(0,UN).map($=>r.jsx(HN,{task:$,assignee:$.assigneeId?h.get($.assigneeId):void 0,onOpen:P},$.id)),r.jsxs("button",{type:"button",onClick:P,className:"flex w-full items-center justify-center gap-1.5 rounded-2xl bg-card px-4 py-3 text-sm font-medium text-muted-foreground card-shadow transition-colors hover:bg-accent/60 hover:text-foreground",children:[n("home.homeTasks.seeAllTasks"),r.jsx(N2,{className:"size-3.5"})]})]}),e[2]=s,e[3]=a,e[4]=o,e[5]=h,e[6]=i,e[7]=n,e[8]=u,e[9]=g,e[10]=x,e[11]=v,e[12]=b,e[13]=_,e[14]=y}else g=e[9],x=e[10],v=e[11],b=e[12],_=e[13],y=e[14];let L;e[32]!==g||e[33]!==x||e[34]!==v?(L=r.jsxs("section",{className:g,children:[x,v]}),e[32]=g,e[33]=x,e[34]=v,e[35]=L):L=e[35];let w;e[36]===Symbol.for("react.memo_cache_sentinel")?(w=()=>p(!1),e[36]=w):w=e[36];let j;e[37]!==l.create?(j=N=>{l.create.mutate(N),p(!1)},e[37]=l.create,e[38]=j):j=e[38];let S;e[39]!==l.create.isPending||e[40]!==m||e[41]!==j?(S=r.jsx(Mv,{open:m,onClose:w,isSaving:l.create.isPending,onSubmit:j}),e[39]=l.create.isPending,e[40]=m,e[41]=j,e[42]=S):S=e[42];let C;return e[43]!==S||e[44]!==b||e[45]!==_||e[46]!==y||e[47]!==L?(C=r.jsxs("div",{className:b,children:[_,y,L,S]}),e[43]=S,e[44]=b,e[45]=_,e[46]=y,e[47]=L,e[48]=C):C=e[48],C}function GN(t){return{...t,main:"board"}}function YN(t,e){return(e.updatedAt??"").localeCompare(t.updatedAt??"")}function JN(t){return[t.userId,t]}function XN(t){const e=B.c(29),{isEditMode:s,hasChanges:n,onEnter:i,onSave:o,onCancel:a,onAddTile:l}=t,c=re();if(!s){let y;e[0]===Symbol.for("react.memo_cache_sentinel")?(y=r.jsx(Hm,{size:14}),e[0]=y):y=e[0];let L;e[1]!==c?(L=c("home.customizeToolbar.label"),e[1]=c,e[2]=L):L=e[2];let w;return e[3]!==i||e[4]!==L?(w=r.jsxs(le,{type:"button",size:"sm",variant:"ghost",onClick:i,className:"h-8 gap-1.5 text-muted-foreground",children:[y,L]}),e[3]=i,e[4]=L,e[5]=w):w=e[5],w}let d;e[6]===Symbol.for("react.memo_cache_sentinel")?(d=r.jsx(kt,{size:14}),e[6]=d):d=e[6];let h;e[7]!==c?(h=c("home.customizeToolbar.addTile"),e[7]=c,e[8]=h):h=e[8];let u;e[9]!==l||e[10]!==h?(u=r.jsxs(le,{type:"button",size:"sm",variant:"ghost",onClick:l,className:"h-8 gap-1.5",children:[d,h]}),e[9]=l,e[10]=h,e[11]=u):u=e[11];let f;e[12]===Symbol.for("react.memo_cache_sentinel")?(f=r.jsx(ks,{size:14}),e[12]=f):f=e[12];let m;e[13]!==c?(m=c("home.customizeToolbar.cancel"),e[13]=c,e[14]=m):m=e[14];let p;e[15]!==a||e[16]!==m?(p=r.jsxs(le,{type:"button",size:"sm",variant:"ghost",onClick:a,className:"h-8 gap-1.5",children:[f,m]}),e[15]=a,e[16]=m,e[17]=p):p=e[17];const g=!n;let x;e[18]===Symbol.for("react.memo_cache_sentinel")?(x=r.jsx(zt,{size:14}),e[18]=x):x=e[18];let v;e[19]!==c?(v=c("home.customizeToolbar.save"),e[19]=c,e[20]=v):v=e[20];let b;e[21]!==o||e[22]!==g||e[23]!==v?(b=r.jsxs(le,{type:"button",size:"sm",onClick:o,disabled:g,className:"h-8 gap-1.5",children:[x,v]}),e[21]=o,e[22]=g,e[23]=v,e[24]=b):b=e[24];let _;return e[25]!==b||e[26]!==u||e[27]!==p?(_=r.jsxs("div",{className:"flex items-center gap-1",children:[u,p,b]}),e[25]=b,e[26]=u,e[27]=p,e[28]=_):_=e[28],_}function QN(){const t=B.c(18),{isEditMode:e,enter:s,save:n,cancel:i,hasChanges:o}=q9(),[a,l]=A.useState(!1),c=tc();let d;t[0]===Symbol.for("react.memo_cache_sentinel")?(d=r.jsx(qN,{afterSummary:r.jsx(gC,{})}),t[0]=d):d=t[0];let h;t[1]!==i||t[2]!==s||t[3]!==o||t[4]!==e||t[5]!==c||t[6]!==n?(h=!c&&r.jsx("div",{className:"flex justify-end",children:r.jsx(XN,{isEditMode:e,hasChanges:o,onEnter:s,onSave:n,onCancel:i,onAddTile:()=>l(!0)})}),t[1]=i,t[2]=s,t[3]=o,t[4]=e,t[5]=c,t[6]=n,t[7]=h):h=t[7];let u;t[8]!==e?(u=r.jsx(WV,{isEditMode:e}),t[8]=e,t[9]=u):u=t[9];let f;t[10]!==h||t[11]!==u?(f=r.jsxs("div",{className:"@container mx-auto flex max-w-5xl flex-col gap-10 px-6 py-8",children:[d,r.jsxs("div",{className:"flex flex-col gap-4",children:[h,u]})]}),t[10]=h,t[11]=u,t[12]=f):f=t[12];let m;t[13]!==a?(m=r.jsx(bN,{open:a,onOpenChange:l}),t[13]=a,t[14]=m):m=t[14];let p;return t[15]!==f||t[16]!==m?(p=r.jsxs("div",{className:"h-full overflow-y-auto",children:[f,m]}),t[15]=f,t[16]=m,t[17]=p):p=t[17],p}function ZN(){const t=B.c(1);let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=r.jsx(hC,{children:r.jsx(QN,{})}),t[0]=e):e=t[0],e}const eT=10,uf=100,tT=30;function sT(t){const e=t;if(e.isError)return null;const s=e.content?.find(i=>i.type==="resource"),n=s?.resource?.text??s?.text;if(!n)return null;try{const i=JSON.parse(n);return typeof i=="string"?i:i&&typeof i=="object"&&"content"in i&&typeof i.content=="string"?i.content:JSON.stringify(i,null,2)}catch{return n}}async function Ca(t,e,s){try{const n=await t.callTool({name:"get_file_contents",arguments:{owner:e.owner,repo:e.repo,path:e.path,...s}});return sT(n)}catch{return null}}function nT(t){const e=zi(t);return Array.isArray(e)?e.map(s=>{const n=Number(s.additions??0),i=Number(s.changes??n),o=Number(s.deletions??Math.max(0,i-n));return{filename:String(s.filename??""),status:s.status??"modified",additions:n,deletions:o,blobUrl:typeof s.blob_url=="string"?s.blob_url:null,previousFilename:typeof s.previous_filename=="string"?s.previous_filename:null}}):[]}async function iT(t,e,s){if(t.length===0)return;let n=0;async function i(){for(;n<t.length;){const o=n++;await s(t[o])}}await Promise.all(Array.from({length:Math.min(e,t.length)},()=>i()))}async function rT(t,e){const s=[];for(let n=1;n<=tT;n++){const i=await t.callTool({name:"pull_request_read",arguments:{method:"get_files",owner:e.owner,repo:e.repo,pullNumber:e.pullNumber,page:n,perPage:uf}}),o=nT(i);if(s.push(...o),o.length<uf)break}return s}async function hf(t,e){const n=(await rT(t,e)).filter(a=>a.filename.length>0),i={},o=e.mergeBaseSha?{sha:e.mergeBaseSha}:{ref:e.base};return await iT(n,eT,async a=>{const l=a.filename;if(a.status==="added"){i[l]={from:null,to:await Ca(t,{owner:e.owner,repo:e.repo,path:l},{sha:e.headSha})};return}if(a.status==="removed"){i[l]={from:await Ca(t,{owner:e.owner,repo:e.repo,path:l},o),to:null};return}const c=a.previousFilename??l,[d,h]=await Promise.all([Ca(t,{owner:e.owner,repo:e.repo,path:c},o),Ca(t,{owner:e.owner,repo:e.repo,path:l},{sha:e.headSha})]);i[l]={from:d,to:h}}),{diffs:i}}function Z3(t){return t?Object.keys(t.diffs).length:0}function Ui(t,e,s,n){return`/api/${t}/sandbox/${encodeURIComponent(e)}/${encodeURIComponent(s)}/git/${n}`}class eg extends Error{constructor(e,s){super(e),this.status=s,this.name="SandboxGitError"}status}function du(t){return t instanceof eg&&(t.status===503||t.status===410||t.status===404)}async function Hi(t){const e=await t.json();if(!t.ok)throw new eg(typeof e.error=="string"?e.error:`Request failed (${t.status})`,t.status);return e}function Wi(t,e){return fetch(t,{cache:"no-store",...e})}async function Ga(t,e,s){const n=await Wi(Ui(t,e,s,"status"));return Hi(n)}async function lr(t,e,s,n){const i=n?.base||n?.headSha?{...n.base?{base:n.base}:{},...n.headSha?{headSha:n.headSha}:{}}:void 0,o=await Wi(Ui(t,e,s,"diff"),{method:"POST",headers:i?{"content-type":"application/json"}:void 0,body:i?JSON.stringify(i):void 0});return Hi(o)}function tg(t){const e={};for(const[s,n]of Object.entries(t.diffs))sg(s)||ng(s)||(e[s]=n);return{...t,diffs:e}}async function ff(t,e,s,n){const i=n?{status:n.status,diff:tg(n.diff)}:{},o=await Wi(Ui(t,e,s,"suggest-commit"),{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(i)});return Hi(o)}async function mf(t,e,s,n){const i=await Wi(Ui(t,e,s,"publish"),{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({message:n})});await Hi(i)}async function oT(t,e,s,n){const i=await Wi(Ui(t,e,s,"rebase"),{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({base:n})});await Hi(i)}function sg(t){return t==="blocks.gen.json"||t.endsWith("/blocks.gen.json")}function ng(t){return t==="static/tailwind.css"||t.endsWith("/static/tailwind.css")}function aT(t){return t===".deco"||t.endsWith("/.deco")||t.startsWith(".deco/")||t.includes("/.deco/")}function ig(t){if(!t)return!1;const e=Object.keys(t.diffs);return e.length===0?!1:e.every(s=>aT(s)||sg(s)||ng(s))}const lT="smart";function cT(t){return t==="code-review"||t==="open"||t==="smart"?t:lT}function dT(t){let e=5381;const s=n=>{for(let i=0;i<n.length;i++)e=(e<<5)+e+n.charCodeAt(i)|0};for(const n of Object.keys(t.diffs).sort()){const i=t.diffs[n];s(n),s("\0from:"),s(i?.from??""),s("\0to:"),s(i?.to??""),s("\0\0")}return(e>>>0).toString(36)}async function uT(t,e,s,n){const i=await Wi(Ui(t,e,s,"judge-review"),{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({status:n.status,diff:tg(n.diff),...n.language?{language:n.language}:{}})});return Hi(i)}async function pf(t,e,s,n){const i=await Wi(Ui(t,e,s,"discard"),{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({filepaths:n})});await Hi(i)}const hT="current";function fT(t){return t?.[hT]??null}function XH(t,e,s){return["sandbox-git-status",t,e,s]}function rg(t){return t?t.modified.length+t.created.length+t.deleted.length+t.not_added.length+t.renamed.length:0}function _c(t){return t?rg(t)>0||t.staged.length>0||t.conflicted.length>0:!1}function og(t){return t?_c(t)||t.ahead>0||(t.unpushed??0)>0?!0:t.unpushed===void 0&&(t.aheadOfBase??0)>0&&t.tracking==null:!1}function mT(t,e){return t?og(t)||e!=null&&Object.keys(e.diffs).length>0:!1}function pT(t,e){return _c(t)?!1:e.openPrFromCommits||!e.commitToOpenPr&&(t?.aheadOfBase??0)>0}function ag(t,e){return{diffs:{...t?.diffs??{},...e?.diffs??{}},...t?.mergeBaseSha?{mergeBaseSha:t.mergeBaseSha}:{}}}function gT(t,e="code-review"){return e==="open"?{allowed:!0,reason:null}:ig(t)?{allowed:!0,reason:null}:{allowed:!1,reason:null}}function xT(t,e){return e!=="smart"||!t||Object.keys(t.diffs).length===0?!1:!ig(t)}function vT(t,e){if(e)return{allowed:!1,reason:null,pending:!0};if(!t)return{allowed:!0,reason:null};if(!t.requiresReview)return{allowed:!0,reason:null};const s=t.reason?.trim();return{allowed:!1,reason:s||null}}function bT(t,e,s,n,i,o,a){return["pr-diff",t,e,s,n,i,o,a]}function yT(t){const e=B.c(26),{orgSlug:s,orgId:n,virtualMcpId:i,branch:o,base:a,headSha:l,pullNumber:c,connectionId:d,owner:h,repo:u,enabled:f}=t,m=f===void 0?!0:f;let p;e[0]!==d||e[1]!==n||e[2]!==s?(p={connectionId:d,orgId:n,orgSlug:s},e[0]=d,e[1]=n,e[2]=s,e[3]=p):p=e[3];const g=ht(p);let x;e[4]!==a||e[5]!==o||e[6]!==d||e[7]!==l||e[8]!==s||e[9]!==c||e[10]!==i?(x=bT(s,i,o,a,l,c,d),e[4]=a,e[5]=o,e[6]=d,e[7]=l,e[8]=s,e[9]=c,e[10]=i,e[11]=x):x=e[11];let v;e[12]!==a||e[13]!==o||e[14]!==g||e[15]!==l||e[16]!==s||e[17]!==h||e[18]!==c||e[19]!==u||e[20]!==i?(v=async()=>{try{const y=await lr(s,i,o,{base:a,headSha:l});return Z3(y)>0?y:hf(g,{owner:h,repo:u,pullNumber:c,base:a,headSha:l,mergeBaseSha:y.mergeBaseSha})}catch{return hf(g,{owner:h,repo:u,pullNumber:c,base:a,headSha:l})}},e[12]=a,e[13]=o,e[14]=g,e[15]=l,e[16]=s,e[17]=h,e[18]=c,e[19]=u,e[20]=i,e[21]=v):v=e[21];const b=m&&!!o&&!!l&&!!d;let _;return e[22]!==x||e[23]!==v||e[24]!==b?(_={queryKey:x,queryFn:v,enabled:b,refetchInterval:3e4,staleTime:1e4},e[22]=x,e[23]=v,e[24]=b,e[25]=_):_=e[25],Ft(_)}Tb.config({paths:{vs:"https://cdn.jsdelivr.net/npm/monaco-editor@0.52.0/min/vs"}});function _T(){return document.documentElement.classList.contains("dark")?"vs-dark":"vs"}function lg(t){const e=B.c(9),{diff:s,emptyMessage:n,rowClassName:i,onDiscardFile:o}=t,a=n===void 0?"No file changes in the working tree":n,l=i===void 0?"px-6":i,[c,d]=A.useState(null),[h,u]=A.useState(null);let f;e[0]===Symbol.for("react.memo_cache_sentinel")?(f=_T(),e[0]=f):f=e[0];const m=f;if(!s||Object.keys(s.diffs).length===0){let g;return e[1]!==a?(g=r.jsx("div",{className:"flex items-center justify-center py-10 text-sm text-muted-foreground",children:a}),e[1]=a,e[2]=g):g=e[2],g}let p;return e[3]!==s.diffs||e[4]!==h||e[5]!==c||e[6]!==o||e[7]!==l?(p=r.jsx("div",{className:"divide-y",children:Object.entries(s.diffs).map(g=>{const[x,v]=g,{from:b,to:_}=v,y=c===x,L=b===null,w=_===null,j=x.startsWith("/")?x.slice(1):x,S=j.lastIndexOf("/"),C=S>=0?j.slice(S+1):j,N=S>=0?j.slice(0,S):null,V=q6(x),E=L?"bg-success":w?"bg-destructive":"bg-warning";return r.jsxs("div",{children:[r.jsxs("div",{className:ie("flex items-center gap-3 py-3 hover:bg-muted/30",l),children:[r.jsx("button",{type:"button",className:"flex h-4 w-4 shrink-0 items-center justify-center text-muted-foreground transition-transform hover:text-foreground",onClick:()=>d(y?null:x),children:r.jsx(bn,{className:ie("h-3.5 w-3.5 transition-transform",y&&"rotate-90")})}),r.jsx("div",{className:ie("h-2.5 w-2.5 shrink-0 rounded-full",E)}),r.jsx(x2,{className:"h-4 w-4 shrink-0 text-muted-foreground"}),r.jsx("span",{className:"min-w-0 flex-1 truncate text-sm font-medium",children:C}),N&&r.jsx("span",{className:"shrink-0 text-xs text-muted-foreground",children:N}),o?r.jsxs(us,{children:[r.jsx(ds,{asChild:!0,children:r.jsx("button",{type:"button",className:"flex h-6 w-6 shrink-0 items-center justify-center rounded text-muted-foreground hover:bg-accent hover:text-foreground",children:r.jsx(ai,{className:"h-3.5 w-3.5"})})}),r.jsx(hs,{align:"end",children:r.jsx(Xe,{className:"text-destructive focus:text-destructive",onSelect:()=>u(x),children:"Discard changes"})})]}):null]}),h===x&&o?r.jsxs("div",{className:ie("flex items-center justify-between gap-3 border-t bg-destructive/5 py-2.5",l),children:[r.jsxs("span",{className:"text-xs text-destructive",children:["Discard all changes to"," ",r.jsx("span",{className:"font-medium",children:C}),"? This cannot be undone."]}),r.jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[r.jsx(le,{type:"button",variant:"ghost",size:"sm",className:"h-7 px-2 text-xs",onClick:()=>u(null),children:"Cancel"}),r.jsx(le,{type:"button",size:"sm",className:"h-7 bg-destructive px-2 text-xs text-destructive-foreground hover:bg-destructive/90",onClick:()=>{u(null),o(x)},children:"Discard"})]})]}):null,y&&r.jsx("div",{className:"border-t",children:r.jsx(Ab,{original:b??"",modified:_??"",language:V,theme:m,height:"380px",options:{readOnly:!0,renderSideBySide:!1,minimap:{enabled:!1},scrollBeyondLastLine:!1,fontSize:12}})})]},x)})}),e[3]=s.diffs,e[4]=h,e[5]=c,e[6]=o,e[7]=l,e[8]=p):p=e[8],p}function LT(t){const e=B.c(14),{diffQuery:s}=t,n=re();if(s.isLoading){let l;e[0]===Symbol.for("react.memo_cache_sentinel")?(l=r.jsx(et,{className:"h-4 w-4 animate-spin"}),e[0]=l):l=e[0];let c;e[1]!==n?(c=n("thread.changesTab.loadingChanges"),e[1]=n,e[2]=c):c=e[2];let d;return e[3]!==c?(d=r.jsxs("div",{className:"flex items-center justify-center gap-2 py-16 text-muted-foreground",children:[l,r.jsx("span",{className:"text-sm",children:c})]}),e[3]=c,e[4]=d):d=e[4],d}if(s.isError){let l;e[5]!==n?(l=n("thread.changesTab.couldntLoadPrChanges"),e[5]=n,e[6]=l):l=e[6];let c;return e[7]!==l?(c=r.jsx("div",{className:"py-10 text-sm text-destructive",children:l}),e[7]=l,e[8]=c):c=e[8],c}const i=s.data;let o;e[9]!==n?(o=n("thread.changesTab.noCommittedChanges"),e[9]=n,e[10]=o):o=e[10];let a;return e[11]!==s.data||e[12]!==o?(a=r.jsx(lg,{diff:i,rowClassName:"px-0",emptyMessage:o}),e[11]=s.data,e[12]=o,e[13]=a):a=e[13],a}const qi="The user clicked this action deliberately — execute directly. Do not call user_ask unless you hit an actual problem outside the scope of this intent (missing auth, unresolvable conflict, a check with multiple plausible fixes).";function ST(t){return`Reopen PR #${t.prNumber}. ${qi}`}function wT(t){return`Rebase \`${t.branch}\` on the latest base and force-push with --force-with-lease. ${qi}`}function jT(t){return`Re-run the \`${t.checkName}\` check on PR #${t.prNumber}. If an empty commit is needed to retrigger CI, create and push one. ${qi}`}function CT(t){const e=(t.failingChecks??[]).map(s=>`\`${s}\``).join(", ");return`PR #${t.prNumber} has failing checks: ${e}. For each: read the logs, diagnose the root cause, apply the smallest fix that makes it pass, commit, and push. ${qi}`}function kT(t){return`Mark PR #${t.prNumber} ready for review. ${qi}`}function VT(t){return`Read the unresolved review threads on PR #${t.prNumber}. For each thread: understand the reviewer's ask, apply the needed changes, commit, push, reply explaining what changed, and resolve the thread. If a comment is a question that doesn't need a code change, reply with the answer and resolve. ${qi}`}function NT(t){return`Review PR #${t.prNumber}. Read the full diff, analyze every changed file for correctness, security, code quality, and alignment with the repo's patterns. Post specific line-level review comments on concerns, then submit an overall review (approve / request changes / comment) with a concise summary. Do not modify the code — this is a read-and-comment pass. ${qi}`}function TT(t){const e=B.c(35),{pr:s,connectionId:n,owner:i,repo:o}=t,{org:a}=Fe(),l=Js(),c=re();let d;e[0]!==n||e[1]!==a.id||e[2]!==a.slug||e[3]!==i||e[4]!==s.number||e[5]!==o?(d={orgId:a.id,orgSlug:a.slug,connectionId:n,owner:i,repo:o,prNumber:s.number},e[0]=n,e[1]=a.id,e[2]=a.slug,e[3]=i,e[4]=s.number,e[5]=o,e[6]=d):d=e[6];const h=np(d);let u;e[7]!==l||e[8]!==s.number?(u=v=>l.sendMessage({parts:[{type:"text",text:jT({prNumber:s.number,checkName:v})}]}),e[7]=l,e[8]=s.number,e[9]=u):u=e[9];const f=u;if(h.isLoading){let v;e[10]!==c?(v=c("thread.checksTab.loadingChecks"),e[10]=c,e[11]=v):v=e[11];let b;return e[12]!==v?(b=r.jsx("div",{className:"text-sm text-muted-foreground",children:v}),e[12]=v,e[13]=b):b=e[13],b}if(h.isError){let v;e[14]!==c?(v=c("thread.checksTab.couldntLoadCheckRuns"),e[14]=c,e[15]=v):v=e[15];let b;return e[16]!==v?(b=r.jsx("div",{className:"text-sm text-destructive",children:v}),e[16]=v,e[17]=b):b=e[17],b}let m;e[18]!==h.data?(m=h.data??[],e[18]=h.data,e[19]=m):m=e[19];const p=m;if(p.length===0){let v;e[20]!==c?(v=c("thread.checksTab.noCheckRunsOnPrHeadCommit"),e[20]=c,e[21]=v):v=e[21];let b;return e[22]!==v?(b=r.jsx("div",{className:"text-sm text-muted-foreground",children:v}),e[22]=v,e[23]=b):b=e[23],b}let g;if(e[24]!==l||e[25]!==p||e[26]!==f||e[27]!==c){let v;e[29]!==l||e[30]!==f||e[31]!==c?(v=b=>r.jsxs("li",{className:"flex items-center justify-between gap-2 rounded px-2 py-1.5 text-sm hover:bg-muted",children:[r.jsxs("span",{className:"flex min-w-0 items-center gap-2",children:[r.jsx(AT,{check:b}),r.jsx("span",{className:"truncate",children:b.name}),b.durationMs!=null&&r.jsx("span",{className:"text-xs text-muted-foreground",children:ET(b.durationMs)})]}),r.jsxs("span",{className:"flex shrink-0 items-center gap-1",children:[b.htmlUrl&&r.jsx("a",{href:b.htmlUrl,target:"_blank",rel:"noreferrer",className:"inline-flex h-7 items-center justify-center rounded px-2 text-xs text-muted-foreground hover:bg-background",title:c("thread.checksTab.viewRun"),children:r.jsx(Dn,{className:"h-3.5 w-3.5"})}),b.conclusion==="failure"&&r.jsx(le,{size:"sm",variant:"ghost",disabled:l.isStreaming,onClick:()=>f(b.name),children:c("thread.checksTab.rerun")})]})]},b.id),e[29]=l,e[30]=f,e[31]=c,e[32]=v):v=e[32],g=p.map(v),e[24]=l,e[25]=p,e[26]=f,e[27]=c,e[28]=g}else g=e[28];let x;return e[33]!==g?(x=r.jsx("ul",{className:"flex flex-col gap-0.5",children:g}),e[33]=g,e[34]=x):x=e[34],x}function AT(t){const e=B.c(14),{check:s}=t,n=re();if(s.status!=="completed"){let a;e[0]!==n?(a=n("thread.checksTab.inProgress"),e[0]=n,e[1]=a):a=e[1];let l;return e[2]!==a?(l=r.jsx("span",{className:"text-muted-foreground","aria-label":a,children:"○"}),e[2]=a,e[3]=l):l=e[3],l}if(s.conclusion==="success"){let a;e[4]!==n?(a=n("thread.checksTab.success"),e[4]=n,e[5]=a):a=e[5];let l;return e[6]!==a?(l=r.jsx("span",{className:"text-success","aria-label":a,children:"✓"}),e[6]=a,e[7]=l):l=e[7],l}if(s.conclusion==="failure"){let a;e[8]!==n?(a=n("thread.checksTab.failure"),e[8]=n,e[9]=a):a=e[9];let l;return e[10]!==a?(l=r.jsx("span",{className:"text-destructive","aria-label":a,children:"✗"}),e[10]=a,e[11]=l):l=e[11],l}const i=s.conclusion??"—";let o;return e[12]!==i?(o=r.jsx("span",{className:"text-muted-foreground","aria-label":i,children:"—"}),e[12]=i,e[13]=o):o=e[13],o}function ET(t){const e=Math.round(t/1e3);return e<60?`${e}s`:`${Math.round(e/60)}m`}var ln="Accordion",PT=["Home","End","ArrowDown","ArrowUp","ArrowLeft","ArrowRight"],[uu,RT,DT]=mx(ln),[Lc]=px(ln,[DT,jm]),hu=jm(),cg=it.forwardRef((t,e)=>{const{type:s,...n}=t,i=n,o=n;return r.jsx(uu.Provider,{scope:t.__scopeAccordion,children:s==="multiple"?r.jsx($T,{...o,ref:e}):r.jsx(OT,{...i,ref:e})})});cg.displayName=ln;var[dg,IT]=Lc(ln),[ug,MT]=Lc(ln,{collapsible:!1}),OT=it.forwardRef((t,e)=>{const{value:s,defaultValue:n,onValueChange:i=()=>{},collapsible:o=!1,...a}=t,[l,c]=vm({prop:s,defaultProp:n??"",onChange:i,caller:ln});return r.jsx(dg,{scope:t.__scopeAccordion,value:it.useMemo(()=>l?[l]:[],[l]),onItemOpen:c,onItemClose:it.useCallback(()=>o&&c(""),[o,c]),children:r.jsx(ug,{scope:t.__scopeAccordion,collapsible:o,children:r.jsx(hg,{...a,ref:e})})})}),$T=it.forwardRef((t,e)=>{const{value:s,defaultValue:n,onValueChange:i=()=>{},...o}=t,[a,l]=vm({prop:s,defaultProp:n??[],onChange:i,caller:ln}),c=it.useCallback(h=>l((u=[])=>[...u,h]),[l]),d=it.useCallback(h=>l((u=[])=>u.filter(f=>f!==h)),[l]);return r.jsx(dg,{scope:t.__scopeAccordion,value:a,onItemOpen:c,onItemClose:d,children:r.jsx(ug,{scope:t.__scopeAccordion,collapsible:!0,children:r.jsx(hg,{...o,ref:e})})})}),[BT,Sc]=Lc(ln),hg=it.forwardRef((t,e)=>{const{__scopeAccordion:s,disabled:n,dir:i,orientation:o="vertical",...a}=t,l=it.useRef(null),c=gx(l,e),d=RT(s),u=xx(i)==="ltr",f=vx(t.onKeyDown,m=>{if(!PT.includes(m.key))return;const p=m.target,g=d().filter(S=>!S.ref.current?.disabled),x=g.findIndex(S=>S.ref.current===p),v=g.length;if(x===-1)return;m.preventDefault();let b=x;const _=0,y=v-1,L=()=>{b=x+1,b>y&&(b=_)},w=()=>{b=x-1,b<_&&(b=y)};switch(m.key){case"Home":b=_;break;case"End":b=y;break;case"ArrowRight":o==="horizontal"&&(u?L():w());break;case"ArrowDown":o==="vertical"&&L();break;case"ArrowLeft":o==="horizontal"&&(u?w():L());break;case"ArrowUp":o==="vertical"&&w();break}const j=b%v;g[j].ref.current?.focus()});return r.jsx(BT,{scope:s,disabled:n,direction:i,orientation:o,children:r.jsx(uu.Slot,{scope:s,children:r.jsx(xm.div,{...a,"data-orientation":o,ref:c,onKeyDown:n?void 0:f})})})}),Pl="AccordionItem",[FT,fu]=Lc(Pl),fg=it.forwardRef((t,e)=>{const{__scopeAccordion:s,value:n,...i}=t,o=Sc(Pl,s),a=IT(Pl,s),l=hu(s),c=bx(),d=n&&a.value.includes(n)||!1,h=o.disabled||t.disabled;return r.jsx(FT,{scope:s,open:d,disabled:h,triggerId:c,children:r.jsx(Kx,{"data-orientation":o.orientation,"data-state":bg(d),...l,...i,ref:e,disabled:h,open:d,onOpenChange:u=>{u?a.onItemOpen(n):a.onItemClose(n)}})})});fg.displayName=Pl;var mg="AccordionHeader",pg=it.forwardRef((t,e)=>{const{__scopeAccordion:s,...n}=t,i=Sc(ln,s),o=fu(mg,s);return r.jsx(xm.h3,{"data-orientation":i.orientation,"data-state":bg(o.open),"data-disabled":o.disabled?"":void 0,...n,ref:e})});pg.displayName=mg;var Zd="AccordionTrigger",gg=it.forwardRef((t,e)=>{const{__scopeAccordion:s,...n}=t,i=Sc(ln,s),o=fu(Zd,s),a=MT(Zd,s),l=hu(s);return r.jsx(uu.ItemSlot,{scope:s,children:r.jsx(zx,{"aria-disabled":o.open&&!a.collapsible||void 0,"data-orientation":i.orientation,id:o.triggerId,...l,...n,ref:e})})});gg.displayName=Zd;var xg="AccordionContent",vg=it.forwardRef((t,e)=>{const{__scopeAccordion:s,...n}=t,i=Sc(ln,s),o=fu(xg,s),a=hu(s);return r.jsx(Ux,{role:"region","aria-labelledby":o.triggerId,"data-orientation":i.orientation,...a,...n,ref:e,style:{"--radix-accordion-content-height":"var(--radix-collapsible-content-height)","--radix-accordion-content-width":"var(--radix-collapsible-content-width)",...t.style}})});vg.displayName=xg;function bg(t){return t?"open":"closed"}var zT=cg,KT=fg,UT=pg,HT=gg,WT=vg;function qT(t){const e=B.c(4);let s;e[0]!==t?({...s}=t,e[0]=t,e[1]=s):s=e[1];let n;return e[2]!==s?(n=r.jsx(zT,{"data-slot":"accordion",...s}),e[2]=s,e[3]=n):n=e[3],n}function GT(t){const e=B.c(8);let s,n;e[0]!==t?({className:s,...n}=t,e[0]=t,e[1]=s,e[2]=n):(s=e[1],n=e[2]);let i;e[3]!==s?(i=ie("border-b last:border-b-0",s),e[3]=s,e[4]=i):i=e[4];let o;return e[5]!==n||e[6]!==i?(o=r.jsx(KT,{"data-slot":"accordion-item",className:i,...n}),e[5]=n,e[6]=i,e[7]=o):o=e[7],o}function YT(t){const e=B.c(11);let s,n,i;e[0]!==t?({className:n,children:s,...i}=t,e[0]=t,e[1]=s,e[2]=n,e[3]=i):(s=e[1],n=e[2],i=e[3]);let o;e[4]!==n?(o=ie("focus-visible:border-ring focus-visible:ring-ring/20 flex flex-1 items-center justify-between gap-4 py-4 text-left text-sm font-medium transition-all outline-none hover:bg-accent/50 focus-visible:ring-[2px] disabled:pointer-events-none disabled:opacity-50 [&[data-state=open]>svg]:rotate-90",n),e[4]=n,e[5]=o):o=e[5];let a;e[6]===Symbol.for("react.memo_cache_sentinel")?(a=r.jsx(bn,{className:"text-muted-foreground pointer-events-none size-4 shrink-0 transition-transform duration-200"}),e[6]=a):a=e[6];let l;return e[7]!==s||e[8]!==i||e[9]!==o?(l=r.jsx(UT,{className:"flex",children:r.jsxs(HT,{"data-slot":"accordion-trigger",className:o,...i,children:[s,a]})}),e[7]=s,e[8]=i,e[9]=o,e[10]=l):l=e[10],l}function JT(t){const e=B.c(12);let s,n,i;e[0]!==t?({className:n,children:s,...i}=t,e[0]=t,e[1]=s,e[2]=n,e[3]=i):(s=e[1],n=e[2],i=e[3]);let o;e[4]!==n?(o=ie("pt-0 pb-4",n),e[4]=n,e[5]=o):o=e[5];let a;e[6]!==s||e[7]!==o?(a=r.jsx("div",{className:o,children:s}),e[6]=s,e[7]=o,e[8]=a):a=e[8];let l;return e[9]!==i||e[10]!==a?(l=r.jsx(WT,{"data-slot":"accordion-content",className:"data-[state=closed]:animate-accordion-up data-[state=open]:animate-accordion-down overflow-hidden text-sm",...i,children:a}),e[9]=i,e[10]=a,e[11]=l):l=e[11],l}function XT(t){const e=B.c(10),{comments:s,isLoading:n,isError:i}=t;if(n||i||!s||s.length===0)return null;const o=s.length===1?"":"s";let a;e[0]!==s.length||e[1]!==o?(a=r.jsxs(YT,{className:"py-3 text-sm font-medium",children:[s.length," comment",o]}),e[0]=s.length,e[1]=o,e[2]=a):a=e[2];let l;e[3]!==s?(l=s.map(QT),e[3]=s,e[4]=l):l=e[4];let c;e[5]!==l?(c=r.jsx(JT,{className:"space-y-3 pb-3",children:l}),e[5]=l,e[6]=c):c=e[6];let d;return e[7]!==a||e[8]!==c?(d=r.jsx(qT,{type:"single",collapsible:!0,className:"border-t border-border",children:r.jsxs(GT,{value:"comments",className:"border-b-0",children:[a,c]})}),e[7]=a,e[8]=c,e[9]=d):d=e[9],d}function QT(t){return r.jsxs("div",{className:"rounded-md border border-border p-3",children:[r.jsxs("div",{className:"mb-1 text-xs text-muted-foreground",children:["@",t.author," · ",ZT(t.createdAt)]}),r.jsx(g9,{id:`pr-comment-${t.id}`,text:vr(t.body)})]},t.id)}function ZT(t){if(!t)return"";const e=new Date(t).getTime();if(!Number.isFinite(e))return"";const s=Date.now()-e;if(s<0)return"just now";const n=Math.floor(s/864e5);if(n>0)return`${n}d ago`;const i=Math.floor(s/36e5);if(i>0)return`${i}h ago`;const o=Math.floor(s/6e4);return`${Math.max(1,o)}m ago`}function eA(t){const e=B.c(19),{pr:s,connectionId:n,owner:i,repo:o}=t,{org:a}=Fe();let l;e[0]!==n||e[1]!==a.id||e[2]!==a.slug||e[3]!==i||e[4]!==s.number||e[5]!==o?(l={orgId:a.id,orgSlug:a.slug,connectionId:n,owner:i,repo:o,prNumber:s.number},e[0]=n,e[1]=a.id,e[2]=a.slug,e[3]=i,e[4]=s.number,e[5]=o,e[6]=l):l=e[6];const c=l_(l);let d;e[7]!==s.body||e[8]!==s.number?(d=s.body&&r.jsx("div",{className:"text-sm",children:r.jsx(g9,{id:`pr-body-${s.number}`,text:vr(s.body)})}),e[7]=s.body,e[8]=s.number,e[9]=d):d=e[9];let h;e[10]!==c.data?(h=c.data??[],e[10]=c.data,e[11]=h):h=e[11];let u;e[12]!==c.isError||e[13]!==c.isLoading||e[14]!==h?(u=r.jsx(XT,{comments:h,isLoading:c.isLoading,isError:c.isError}),e[12]=c.isError,e[13]=c.isLoading,e[14]=h,e[15]=u):u=e[15];let f;return e[16]!==d||e[17]!==u?(f=r.jsxs("div",{className:"space-y-8",children:[d,u]}),e[16]=d,e[17]=u,e[18]=f):f=e[18],f}function tA(t){const e=B.c(68),{pr:s,virtualMcpId:n,branch:i,connectionId:o,owner:a,repo:l}=t,{org:c}=Fe();let d;e[0]!==i||e[1]!==o||e[2]!==c.id||e[3]!==c.slug||e[4]!==a||e[5]!==s.base||e[6]!==s.headSha||e[7]!==s.number||e[8]!==l||e[9]!==n?(d={orgSlug:c.slug,orgId:c.id,virtualMcpId:n,branch:i,base:s.base,headSha:s.headSha,pullNumber:s.number,connectionId:o,owner:a,repo:l},e[0]=i,e[1]=o,e[2]=c.id,e[3]=c.slug,e[4]=a,e[5]=s.base,e[6]=s.headSha,e[7]=s.number,e[8]=l,e[9]=n,e[10]=d):d=e[10];const h=yT(d);let u;e[11]!==h.data?(u=h.data?Z3(h.data):void 0,e[11]=h.data,e[12]=u):u=e[12];const f=u,[m,p]=A.useState("changes");let g;e[13]!==s.title?(g=vr(s.title),e[13]=s.title,e[14]=g):g=e[14];let x;e[15]!==g?(x=r.jsx("h1",{className:"text-lg font-semibold leading-tight",children:g}),e[15]=g,e[16]=x):x=e[16];const v=`Open PR #${s.number} on GitHub`;let b;e[17]===Symbol.for("react.memo_cache_sentinel")?(b=r.jsx(Dn,{className:"h-3.5 w-3.5"}),e[17]=b):b=e[17];let _;e[18]!==s.htmlUrl||e[19]!==s.number||e[20]!==v?(_=r.jsxs("a",{href:s.htmlUrl,target:"_blank",rel:"noreferrer","aria-label":v,className:"inline-flex items-center gap-1 hover:text-foreground",children:["PR #",s.number,b]}),e[18]=s.htmlUrl,e[19]=s.number,e[20]=v,e[21]=_):_=e[21];let y;e[22]!==s.author?(y=s.author?r.jsxs(r.Fragment,{children:[r.jsx("span",{children:"·"}),r.jsxs("span",{children:["@",s.author]})]}):null,e[22]=s.author,e[23]=y):y=e[23];let L;e[24]===Symbol.for("react.memo_cache_sentinel")?(L=r.jsx("span",{children:"·"}),e[24]=L):L=e[24];let w;e[25]!==s.base?(w=r.jsx("span",{className:"font-mono text-xs",children:s.base}),e[25]=s.base,e[26]=w):w=e[26];let j;e[27]===Symbol.for("react.memo_cache_sentinel")?(j=r.jsx("span",{children:"←"}),e[27]=j):j=e[27];let S;e[28]!==s.head?(S=r.jsx("span",{className:"font-mono text-xs",children:s.head}),e[28]=s.head,e[29]=S):S=e[29];let C;e[30]!==w||e[31]!==S||e[32]!==_||e[33]!==y?(C=r.jsxs("div",{className:"flex flex-wrap items-center gap-x-1.5 text-sm text-muted-foreground",children:[_,y,L,w,j,S]}),e[30]=w,e[31]=S,e[32]=_,e[33]=y,e[34]=C):C=e[34];let N;e[35]!==C||e[36]!==x?(N=r.jsx("div",{className:"shrink-0 space-y-3 pb-4",children:r.jsxs("div",{className:"space-y-1",children:[x,C]})}),e[35]=C,e[36]=x,e[37]=N):N=e[37];let V;e[38]===Symbol.for("react.memo_cache_sentinel")?(V=z=>p(z),e[38]=V):V=e[38];let E;e[39]===Symbol.for("react.memo_cache_sentinel")?(E=r.jsx(xn,{value:"description",className:"px-3 text-xs",children:"Description"}),e[39]=E):E=e[39];const T=f!==void 0?` ${f}`:"";let k;e[40]!==T?(k=r.jsxs(xn,{value:"changes",className:"px-3 text-xs",children:["Changes",T]}),e[40]=T,e[41]=k):k=e[41];let R;e[42]===Symbol.for("react.memo_cache_sentinel")?(R=r.jsx(xn,{value:"checks",className:"px-3 text-xs",children:"Checks"}),e[42]=R):R=e[42];let P;e[43]!==k?(P=r.jsxs(na,{className:"h-8 w-fit max-w-[600px] shrink-0",variant:"pill",children:[E,k,R]}),e[43]=k,e[44]=P):P=e[44];let D;e[45]!==o||e[46]!==a||e[47]!==s||e[48]!==l?(D=r.jsx(yi,{value:"description",className:"mt-0",children:r.jsx(eA,{pr:s,connectionId:o,owner:a,repo:l})}),e[45]=o,e[46]=a,e[47]=s,e[48]=l,e[49]=D):D=e[49];let I;e[50]!==h?(I=r.jsx(yi,{value:"changes",className:"mt-0",children:r.jsx(LT,{diffQuery:h})}),e[50]=h,e[51]=I):I=e[51];let M;e[52]!==o||e[53]!==a||e[54]!==s||e[55]!==l?(M=r.jsx(yi,{value:"checks",className:"mt-0",children:r.jsx(TT,{pr:s,connectionId:o,owner:a,repo:l})}),e[52]=o,e[53]=a,e[54]=s,e[55]=l,e[56]=M):M=e[56];let O;e[57]!==D||e[58]!==I||e[59]!==M?(O=r.jsxs("div",{className:"min-h-0 flex-1 overflow-y-auto pt-5",children:[D,I,M]}),e[57]=D,e[58]=I,e[59]=M,e[60]=O):O=e[60];let F;e[61]!==m||e[62]!==P||e[63]!==O?(F=r.jsxs(Vr,{value:m,onValueChange:V,className:"flex min-h-0 flex-1 flex-col",children:[P,O]}),e[61]=m,e[62]=P,e[63]=O,e[64]=F):F=e[64];let $;return e[65]!==N||e[66]!==F?($=r.jsxs("div",{className:"flex min-h-0 flex-1 flex-col",children:[N,F]}),e[65]=N,e[66]=F,e[67]=$):$=e[67],$}function sA(t){const e=B.c(11),{pr:s}=t,n=re(),i=s.htmlUrl,o=String(s.number);let a;e[0]!==n||e[1]!==o?(a=n("thread.gitTab.openPrAriaLabel",{number:o}),e[0]=n,e[1]=o,e[2]=a):a=e[2];const l=String(s.number);let c;e[3]!==n||e[4]!==l?(c=n("thread.gitTab.prNumber",{number:l}),e[3]=n,e[4]=l,e[5]=c):c=e[5];let d;e[6]===Symbol.for("react.memo_cache_sentinel")?(d=r.jsx(Dn,{className:"h-4 w-4 text-muted-foreground"}),e[6]=d):d=e[6];let h;return e[7]!==s.htmlUrl||e[8]!==a||e[9]!==c?(h=r.jsx("div",{className:"flex h-12 items-center border-b border-border px-4 shrink-0",children:r.jsxs("a",{href:i,target:"_blank",rel:"noreferrer","aria-label":a,className:"inline-flex items-center gap-1.5 text-base font-medium text-foreground hover:underline",children:[c,d]})}),e[7]=s.htmlUrl,e[8]=a,e[9]=c,e[10]=h):h=e[10],h}function nA(t){const e=B.c(24),{virtualMcpId:s}=t,n=re(),{org:i}=Fe(),o=gs(s),{currentBranch:a}=Zt(),l=o?.metadata?.githubRepo??null;if(!l?.connectionId){let d;e[0]!==n?(d=n("thread.gitTab.notLinkedToGithub"),e[0]=n,e[1]=d):d=e[1];let h;return e[2]!==d?(h=r.jsx("div",{className:"flex h-full items-center justify-center p-8 text-sm text-muted-foreground",children:d}),e[2]=d,e[3]=h):h=e[3],h}if(!a){let d;e[4]===Symbol.for("react.memo_cache_sentinel")?(d=r.jsx(Zs,{className:"h-6 w-6 text-muted-foreground"}),e[4]=d):d=e[4];let h;e[5]!==n?(h=n("thread.gitTab.noBranchSelected"),e[5]=n,e[6]=h):h=e[6];let u;e[7]!==h?(u=r.jsx("div",{className:"text-muted-foreground",children:h}),e[7]=h,e[8]=u):u=e[8];let f;e[9]!==n?(f=n("thread.gitTab.pickBranchForPrStatus"),e[9]=n,e[10]=f):f=e[10];let m;e[11]!==f?(m=r.jsx("div",{className:"text-xs text-muted-foreground",children:f}),e[11]=f,e[12]=m):m=e[12];let p;return e[13]!==u||e[14]!==m?(p=r.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-3 p-8 text-sm",children:[d,u,m]}),e[13]=u,e[14]=m,e[15]=p):p=e[15],p}let c;return e[16]!==a||e[17]!==l.connectionId||e[18]!==l.name||e[19]!==l.owner||e[20]!==i.id||e[21]!==i.slug||e[22]!==s?(c=r.jsx(iA,{orgId:i.id,orgSlug:i.slug,virtualMcpId:s,connectionId:l.connectionId,owner:l.owner,repo:l.name,branch:a}),e[16]=a,e[17]=l.connectionId,e[18]=l.name,e[19]=l.owner,e[20]=i.id,e[21]=i.slug,e[22]=s,e[23]=c):c=e[23],c}function iA(t){const e=B.c(69),s=re(),{orgId:n,orgSlug:i,virtualMcpId:o,connectionId:a,owner:l,repo:c,branch:d}=t;let h;e[0]!==d||e[1]!==a||e[2]!==n||e[3]!==i||e[4]!==l||e[5]!==c?(h={orgId:n,orgSlug:i,connectionId:a,owner:l,repo:c,branch:d},e[0]=d,e[1]=a,e[2]=n,e[3]=i,e[4]=l,e[5]=c,e[6]=h):h=e[6];const{data:u,isLoading:f,isError:m}=N9(h),p=rA;if(f){let j;e[7]!==s?(j=s("thread.gitTab.loadingPrState"),e[7]=s,e[8]=j):j=e[8];let S;return e[9]!==j?(S=r.jsx("div",{className:"p-4 text-sm text-muted-foreground",children:j}),e[9]=j,e[10]=S):S=e[10],S}if(m){let j;e[11]!==s?(j=s("thread.gitTab.couldNotLoadPrState"),e[11]=s,e[12]=j):j=e[12];let S;return e[13]!==j?(S=r.jsx("div",{className:"p-4 text-sm text-destructive",children:j}),e[13]=j,e[14]=S):S=e[14],S}const g=`https://github.com/${l}/${c}/tree/${d}`;if(u&&u.state==="closed"){let j;e[15]!==u?(j=r.jsx(sA,{pr:u}),e[15]=u,e[16]=j):j=e[16];let S;e[17]!==u.merged||e[18]!==s?(S=u.merged?s("thread.gitTab.merged"):s("thread.gitTab.closed"),e[17]=u.merged,e[18]=s,e[19]=S):S=e[19];let C;e[20]!==u.base||e[21]!==s?(C=s("thread.gitTab.into",{base:u.base}),e[20]=u.base,e[21]=s,e[22]=C):C=e[22];let N;e[23]!==u.mergedAt?(N=u.mergedAt&&r.jsxs(r.Fragment,{children:[" · ",new Date(u.mergedAt).toLocaleDateString()]}),e[23]=u.mergedAt,e[24]=N):N=e[24];let V;e[25]!==u.author||e[26]!==s?(V=u.author&&r.jsxs(r.Fragment,{children:[" · ",s("thread.gitTab.by",{author:u.author})]}),e[25]=u.author,e[26]=s,e[27]=V):V=e[27];let E;e[28]!==S||e[29]!==C||e[30]!==N||e[31]!==V?(E=r.jsxs("div",{className:"text-sm text-success",children:[S," ",C,N,V]}),e[28]=S,e[29]=C,e[30]=N,e[31]=V,e[32]=E):E=e[32];let T;e[33]!==u.title?(T=vr(u.title),e[33]=u.title,e[34]=T):T=e[34];let k;e[35]!==T?(k=r.jsx("h1",{className:"text-lg font-semibold",children:T}),e[35]=T,e[36]=k):k=e[36];let R;e[37]!==u.body||e[38]!==u.number?(R=u.body&&r.jsx("div",{className:"rounded-md border border-border bg-muted/30 p-3 text-sm",children:r.jsx(g9,{id:`pr-body-${u.number}`,text:vr(u.body)})}),e[37]=u.body,e[38]=u.number,e[39]=R):R=e[39];let P;e[40]!==E||e[41]!==k||e[42]!==R?(P=r.jsxs("div",{className:"flex flex-col gap-4 p-4 overflow-auto",children:[E,k,R]}),e[40]=E,e[41]=k,e[42]=R,e[43]=P):P=e[43];let D;return e[44]!==j||e[45]!==P?(D=r.jsxs("div",{className:"flex min-h-0 flex-1 flex-col",children:[j,P]}),e[44]=j,e[45]=P,e[46]=D):D=e[46],D}if(u&&u.state==="open"){let j;return e[47]!==d||e[48]!==a||e[49]!==l||e[50]!==u||e[51]!==c||e[52]!==o?(j=r.jsx("div",{className:"flex min-h-0 flex-1 flex-col overflow-hidden",children:r.jsx("div",{className:"flex min-h-0 w-full flex-1 flex-col px-6 py-5",children:r.jsx(tA,{pr:u,virtualMcpId:o,branch:d,connectionId:a,owner:l,repo:c})})}),e[47]=d,e[48]=a,e[49]=l,e[50]=u,e[51]=c,e[52]=o,e[53]=j):j=e[53],j}let x;e[54]!==s?(x=s("thread.gitTab.noPrYet"),e[54]=s,e[55]=x):x=e[55];let v;e[56]!==x?(v=r.jsx("div",{className:"rounded-md border border-border bg-muted/30 p-4 text-sm",children:x}),e[56]=x,e[57]=v):v=e[57];let b;e[58]!==g?(b=()=>p(g),e[58]=g,e[59]=b):b=e[59];let _;e[60]===Symbol.for("react.memo_cache_sentinel")?(_=r.jsx(Dn,{className:"mr-1.5 h-4 w-4"}),e[60]=_):_=e[60];let y;e[61]!==s?(y=s("thread.gitTab.openBranchOnGithub"),e[61]=s,e[62]=y):y=e[62];let L;e[63]!==b||e[64]!==y?(L=r.jsx("div",{className:"flex items-center gap-2",children:r.jsxs(le,{size:"sm",variant:"outline",onClick:b,children:[_,y]})}),e[63]=b,e[64]=y,e[65]=L):L=e[65];let w;return e[66]!==v||e[67]!==L?(w=r.jsxs("div",{className:"flex flex-col gap-4 p-4",children:[v,L]}),e[66]=v,e[67]=L,e[68]=w):w=e[68],w}function rA(t){window.open(t,"_blank","noopener,noreferrer")}const oA=new Set(["website/pages/Page.tsx","$live/pages/LivePage.tsx"]);function aA(t){return t.includes("matchers")||t.includes("Match")}function yg(t,e){const s=t.__resolveType;return typeof s!="string"||!s||oA.has(s)?!1:e?sw(e,s):aA(s)}function lA(t,e){const s=[];for(const[n,i]of Object.entries(e)){if(n.includes("/")||!yn(n)||dc(n)||!i||typeof i!="object"||Array.isArray(i))continue;const o=i;yg(o,t)&&s.push({blockKey:n,matcherResolveType:o.__resolveType??"",name:typeof o.name=="string"?o.name:void 0})}return s.sort((n,i)=>(n.name??n.blockKey).localeCompare(i.name??i.blockKey))}function Fr(t,e,s){if(!t)return!1;const n=t.__resolveType;if(typeof n!="string"||!yn(n)||!Object.hasOwn(e,n))return!1;const i=e[n];return!i||typeof i!="object"||Array.isArray(i)?!1:yg(i,s)}function cA(t,e,s){return Fr(t,e,s)?t?.__resolveType??null:null}function _g(t,e,s){if(!t)return null;const n=t.__resolveType??"";if(!n)return null;if(Fr(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:i,...o}=t;return{resolveType:n,data:o}}function Lg(t,e,s){const n=_g(t,e,s);return n?{__resolveType:n.resolveType,...n.data}:{__resolveType:""}}function QH(t,e,s){if(t)return Fr(t,e,s)?Lg(t,e,s):t}function dA(t,e,s,n){if(!t)return"Default";if(Fr(t,e,n)){const i=t.__resolveType??"",o=e[i];return hc(i,o)}return s(t)}function ZH(t,e,s){return{__resolveType:t,...e,name:s}}function uA(t){return{__resolveType:t}}function eW(t,e,s){const n=_g(t,e,s);return n?{resolveType:n.resolveType,formValue:n.data}:{resolveType:"",formValue:{}}}const gf="x-deco-matchers-override";function Sg({pageKey:t,prefix:e,variants:s,selectedIndex:n,decofile:i,meta:o}){if(!t||n<0||n>=s.length)return[];const a=[];for(let l=0;l<=n;l++){const c=s[l];if(!c)continue;const d=c.rule,h=l===n?"1":"0",f=(Fr(d,i,o)?cA(d,i,o):null)??`${t}@${e}.${l}.rule`;a.push(`${f}=${h}`)}return a}function tW(t,e,s,n){return!e.multivariate||e.variants.length<=1?[]:Sg({pageKey:t,prefix:"sections.variants",variants:e.variants,selectedIndex:e.index,decofile:s,meta:n})}function sW({pageKey:t,page:e,sectionIndex:s,sectionLazy:n,mvObj:i,selectedVariantIndex:o,decofile:a,meta:l}){if(s<0)return[];const d=`${e.multivariate?`sections.variants.${e.index}.value`:"sections"}.${s}${n?".section":""}.variants`,h=Array.isArray(i.variants)?i.variants:[];return Sg({pageKey:t,prefix:d,variants:h,selectedIndex:o,decofile:a,meta:l})}function hA(t,e){if(e.length===0)return t;const s=new URL(t,"http://local");s.searchParams.delete(gf);for(const n of e)s.searchParams.append(gf,n);return t.startsWith("http")?s.toString():`${s.pathname}${s.search}${s.hash}`}function wg(t){return btoa(encodeURIComponent(t))}function xf(t,e,s){const n=new URL(t).origin,i=new URL(`/live/previews/${encodeURIComponent(e)}`,n);return i.searchParams.set("path","/"),i.searchParams.set("pathTemplate","/"),i.searchParams.set("props",wg(JSON.stringify({path:"/",sections:[{__resolveType:s}]}))),i.searchParams.set("__cb",crypto.randomUUID()),i.toString()}function nW(t,e,s,n){const i=new URL(t).origin,o=new URL(`/live/previews/${encodeURIComponent(e)}`,i);o.searchParams.set("__d","");const a=[{__resolveType:"preview",block:s}];return n&&a.push(n),o.searchParams.set("props",wg(JSON.stringify({sections:a}))),o.toString()}const vf={resolveType:"website/pages/Page.tsx",seoResolveType:"website/sections/Seo/SeoV2.tsx"};function mu(t){return`pages-${encodeURIComponent(t)}-${crypto.randomUUID()}`}function jg(t,e){return{name:t,path:e,sections:[],seo:{__resolveType:vf.seoResolveType},__resolveType:vf.resolveType}}const fA=700;function wc(t){const e=B.c(22),{orgSlug:s,virtualMcpId:n,branch:i}=t,o=Ls(),a=gs(n)?.metadata?.runtime?.path??null;let l;e[0]!==i||e[1]!==s||e[2]!==a||e[3]!==n?(l=async f=>{const{blockKey:m,data:p}=f,g=Pr(a,l2(m)),x=JSON.stringify(p,null,2),v=await fetch(`/api/${s}/sandbox/${encodeURIComponent(n)}/${encodeURIComponent(i)}/write`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({path:g,content:x})});if(!v.ok){const b=await v.json().catch(mA);throw new Error(b.error??`Write failed (${v.status})`)}return v.json()},e[0]=i,e[1]=s,e[2]=a,e[3]=n,e[4]=l):l=e[4];let c;e[5]!==i||e[6]!==s||e[7]!==o||e[8]!==n?(c=async f=>{const{blockKey:m,data:p}=f,g=`${s}/${n}/${i}`,x=at.decofile(g);await o.cancelQueries({queryKey:x});const v=o.getQueryData(x);return o.setQueryData(x,b=>({...b??{},[m]:p})),{previous:v,queryKey:x}},e[5]=i,e[6]=s,e[7]=o,e[8]=n,e[9]=c):c=e[9];let d;e[10]!==o?(d=(f,m,p)=>{p?.queryKey&&o.setQueryData(p.queryKey,p.previous)},e[10]=o,e[11]=d):d=e[11];let h;e[12]!==i||e[13]!==s||e[14]!==o||e[15]!==n?(h=(f,m)=>{const{blockKey:p,data:g}=m,x=`${s}/${n}/${i}`;o.setQueryData(at.decofile(x),v=>({...v??{},[p]:g}))},e[12]=i,e[13]=s,e[14]=o,e[15]=n,e[16]=h):h=e[16];let u;return e[17]!==l||e[18]!==c||e[19]!==d||e[20]!==h?(u={mutationFn:l,onMutate:c,onError:d,onSuccess:h},e[17]=l,e[18]=c,e[19]=d,e[20]=h,e[21]=u):u=e[21],Ys(u)}function mA(){return{}}function Cg(t,e){const s=B.c(15),n=wc(t);let i;s[0]===Symbol.for("react.memo_cache_sentinel")?(i=new Map,s[0]=i):i=s[0];const o=A.useRef(i);let a;s[1]===Symbol.for("react.memo_cache_sentinel")?(a=new Map,s[1]=a):a=s[1];const l=A.useRef(a);let c;s[2]!==e||s[3]!==n?(c=v=>{const b=o.current.get(v);if(!b)return;const _=typeof b=="function"?b():b;o.current.delete(v),_&&n.mutate({blockKey:v,data:_},{onSuccess:()=>e?.onSaved?.(),onError:pA})},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 b of v.values())clearTimeout(b)}},m=[],s[7]=f,s[8]=m):(f=s[7],m=s[8]),A.useEffect(f,m);let p;s[9]!==d?(p=(v,b)=>{o.current.set(v,b);const _=l.current.get(v);_&&clearTimeout(_),l.current.set(v,setTimeout(()=>{l.current.delete(v),d(v)},fA))},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 pA(t){return ge.error(`Save failed: ${t.message}`)}function gA(t){const e=B.c(5);let s;e[0]!==t?(s=t??{orgSlug:"",virtualMcpId:"",branch:""},e[0]=t,e[1]=s):s=e[1];const n=wc(s);let i;return e[2]!==t||e[3]!==n?(i={mutationFn:async o=>{const{name:a,path:l,template:c}=o;if(!t?.virtualMcpId||!t.branch)throw new Error("Sandbox not ready");const d=mu(a),h=c?{...c,name:a,path:l}:jg(a,l);return await n.mutateAsync({blockKey:d,data:h}),{key:d,name:a,path:l}}},e[2]=t,e[3]=n,e[4]=i):i=e[4],Ys(i)}const Jn="__blank__";function kg(t){const e=B.c(65),{id:s,value:n,onChange:i,templates:o,disabled:a}=t,l=re(),[c,d]=A.useState(!1);let h;if(e[0]!==o||e[1]!==n){let M;e[3]!==n?(M=O=>O.key===n,e[3]=n,e[4]=M):M=e[4],h=o.find(M),e[0]=o,e[1]=n,e[2]=h}else h=e[2];const u=h;let f;e[5]!==u?.name||e[6]!==l?(f=u?.name??l("sectionsEditor.pageTemplateSelect.blankPageDefaultLabel"),e[5]=u?.name,e[6]=l,e[7]=f):f=e[7];let m;e[8]!==f?(m=r.jsx("span",{className:"truncate",children:f}),e[8]=f,e[9]=m):m=e[9];let p;e[10]!==u?(p=u?.path?r.jsx("span",{className:"truncate text-muted-foreground",children:u.path}):null,e[10]=u,e[11]=p):p=e[11];let g;e[12]!==m||e[13]!==p?(g=r.jsxs("span",{className:"flex min-w-0 items-center gap-2",children:[m,p]}),e[12]=m,e[13]=p,e[14]=g):g=e[14];let x;e[15]===Symbol.for("react.memo_cache_sentinel")?(x=r.jsx(S9,{className:"shrink-0 opacity-50"}),e[15]=x):x=e[15];let v;e[16]!==a||e[17]!==s||e[18]!==c||e[19]!==g?(v=r.jsx(Es,{asChild:!0,children:r.jsxs(le,{id:s,type:"button",variant:"outline",role:"combobox","aria-expanded":c,disabled:a,className:"w-full justify-between font-normal",children:[g,x]})}),e[16]=a,e[17]=s,e[18]=c,e[19]=g,e[20]=v):v=e[20];let b;e[21]===Symbol.for("react.memo_cache_sentinel")?(b={width:"var(--radix-popover-trigger-width)"},e[21]=b):b=e[21];let _;e[22]!==l?(_=l("sectionsEditor.pageTemplateSelect.searchPlaceholder"),e[22]=l,e[23]=_):_=e[23];let y;e[24]!==_?(y=r.jsx(Bi,{placeholder:_,className:"h-9"}),e[24]=_,e[25]=y):y=e[25];let L;e[26]!==l?(L=l("sectionsEditor.pageTemplateSelect.noPagesFoundMessage"),e[26]=l,e[27]=L):L=e[27];let w;e[28]!==L?(w=r.jsx(Zn,{children:L}),e[28]=L,e[29]=w):w=e[29];let j;e[30]!==l?(j=l("sectionsEditor.pageTemplateSelect.blankPageLabel"),e[30]=l,e[31]=j):j=e[31];let S;e[32]!==i?(S=()=>{i(Jn),d(!1)},e[32]=i,e[33]=S):S=e[33];let C;e[34]!==l?(C=l("sectionsEditor.pageTemplateSelect.blankPageLabel"),e[34]=l,e[35]=C):C=e[35];const N=n===Jn?"opacity-100":"opacity-0";let V;e[36]!==N?(V=ie("ml-auto",N),e[36]=N,e[37]=V):V=e[37];let E;e[38]!==V?(E=r.jsx(zt,{className:V}),e[38]=V,e[39]=E):E=e[39];let T;e[40]!==j||e[41]!==S||e[42]!==C||e[43]!==E?(T=r.jsxs(Vs,{value:j,onSelect:S,children:[C,E]}),e[40]=j,e[41]=S,e[42]=C,e[43]=E,e[44]=T):T=e[44];let k;if(e[45]!==i||e[46]!==o||e[47]!==n){let M;e[49]!==i||e[50]!==n?(M=O=>r.jsxs(Vs,{value:`${O.name} ${O.path}`,onSelect:()=>{i(O.key),d(!1)},children:[r.jsxs("div",{className:"flex min-w-0 flex-col",children:[r.jsx("span",{className:"truncate",children:O.name}),r.jsx("span",{className:"truncate text-xs text-muted-foreground",children:O.path})]}),r.jsx(zt,{className:ie("ml-auto",n===O.key?"opacity-100":"opacity-0")})]},O.key),e[49]=i,e[50]=n,e[51]=M):M=e[51],k=o.map(M),e[45]=i,e[46]=o,e[47]=n,e[48]=k}else k=e[48];let R;e[52]!==T||e[53]!==k?(R=r.jsxs(Ms,{children:[T,k]}),e[52]=T,e[53]=k,e[54]=R):R=e[54];let P;e[55]!==w||e[56]!==R?(P=r.jsxs(Fi,{onWheel:xA,children:[w,R]}),e[55]=w,e[56]=R,e[57]=P):P=e[57];let D;e[58]!==y||e[59]!==P?(D=r.jsx(Ps,{className:"p-0",style:b,children:r.jsxs(Tr,{children:[y,P]})}),e[58]=y,e[59]=P,e[60]=D):D=e[60];let I;return e[61]!==c||e[62]!==D||e[63]!==v?(I=r.jsxs(As,{open:c,onOpenChange:d,children:[v,D]}),e[61]=c,e[62]=D,e[63]=v,e[64]=I):I=e[64],I}function xA(t){const e=t.deltaMode===1?16:1;t.currentTarget.scrollTop=t.currentTarget.scrollTop+t.deltaY*e}function vA(t){const e=B.c(89),{open:s,onOpenChange:n,isPending:i,error:o,templates:a,onSubmit:l}=t,c=i===void 0?!1:i,d=re();let h;e[0]!==d?(h=d("sectionsEditor.createPageModal.defaultPageName"),e[0]=d,e[1]=h):h=e[1];const[u,f]=A.useState(h);let m;e[2]!==d?(m=d("sectionsEditor.createPageModal.defaultPagePath"),e[2]=d,e[3]=m):m=e[3];const[p,g]=A.useState(m),[x,v]=A.useState(Jn),[b,_]=A.useState(null),[y,L]=A.useState(s);s!==y&&(L(s),s&&(f(d("sectionsEditor.createPageModal.defaultPageName")),g(d("sectionsEditor.createPageModal.defaultPagePath")),v(Jn),_(null)));const w=!!a?.length;let j;e[4]!==c||e[5]!==n?(j=ne=>{!ne&&!c&&(_(null),n(!1))},e[4]=c,e[5]=n,e[6]=j):j=e[6];const S=j;let C;e[7]!==c||e[8]!==u||e[9]!==l||e[10]!==p||e[11]!==w||e[12]!==x?(C=async ne=>{ne.preventDefault();const de=u.trim(),xe=p.trim();if(!de||!xe||c)return;const he=$9(xe);if(he){_(he);return}_(null),await l({name:de,path:xe,templateKey:w&&x!==Jn?x:null})},e[7]=c,e[8]=u,e[9]=l,e[10]=p,e[11]=w,e[12]=x,e[13]=C):C=e[13];const N=C,V=b??o;let E;e[14]!==d?(E=d("sectionsEditor.createPageModal.title"),e[14]=d,e[15]=E):E=e[15];let T;e[16]!==E?(T=r.jsx(ms,{children:r.jsx(ps,{children:E})}),e[16]=E,e[17]=T):T=e[17];let k;e[18]!==d?(k=d("sectionsEditor.createPageModal.nameLabel"),e[18]=d,e[19]=k):k=e[19];let R;e[20]!==k?(R=r.jsx("label",{htmlFor:"new-page-name",className:"text-xs font-medium text-muted-foreground",children:k}),e[20]=k,e[21]=R):R=e[21];let P;e[22]===Symbol.for("react.memo_cache_sentinel")?(P=ne=>f(ne.target.value),e[22]=P):P=e[22];let D;e[23]!==d?(D=d("sectionsEditor.createPageModal.namePlaceholder"),e[23]=d,e[24]=D):D=e[24];let I;e[25]!==c||e[26]!==u||e[27]!==D?(I=r.jsx(rt,{id:"new-page-name",value:u,onChange:P,placeholder:D,autoFocus:!0,disabled:c}),e[25]=c,e[26]=u,e[27]=D,e[28]=I):I=e[28];let M;e[29]!==I||e[30]!==R?(M=r.jsxs("div",{className:"space-y-1.5",children:[R,I]}),e[29]=I,e[30]=R,e[31]=M):M=e[31];let O;e[32]!==d?(O=d("sectionsEditor.createPageModal.pathLabel"),e[32]=d,e[33]=O):O=e[33];let F;e[34]!==O?(F=r.jsx("label",{htmlFor:"new-page-path",className:"text-xs font-medium text-muted-foreground",children:O}),e[34]=O,e[35]=F):F=e[35];let $;e[36]===Symbol.for("react.memo_cache_sentinel")?($=ne=>g(ne.target.value),e[36]=$):$=e[36];let z;e[37]!==d?(z=d("sectionsEditor.createPageModal.pathPlaceholder"),e[37]=d,e[38]=z):z=e[38];let K;e[39]!==c||e[40]!==p||e[41]!==z?(K=r.jsx(rt,{id:"new-page-path",value:p,onChange:$,placeholder:z,disabled:c}),e[39]=c,e[40]=p,e[41]=z,e[42]=K):K=e[42];let X;e[43]!==F||e[44]!==K?(X=r.jsxs("div",{className:"space-y-1.5",children:[F,K]}),e[43]=F,e[44]=K,e[45]=X):X=e[45];let J;e[46]!==c||e[47]!==w||e[48]!==d||e[49]!==x||e[50]!==a?(J=w&&r.jsxs("div",{className:"space-y-1.5",children:[r.jsx("label",{htmlFor:"new-page-template",className:"text-xs font-medium text-muted-foreground",children:d("sectionsEditor.createPageModal.templateLabel")}),r.jsx(kg,{id:"new-page-template",value:x,onChange:v,templates:a??[],disabled:c})]}),e[46]=c,e[47]=w,e[48]=d,e[49]=x,e[50]=a,e[51]=J):J=e[51];let H;e[52]!==V?(H=V&&r.jsx("p",{className:"text-xs text-destructive",children:V}),e[52]=V,e[53]=H):H=e[53];let W;e[54]!==M||e[55]!==X||e[56]!==J||e[57]!==H?(W=r.jsxs("div",{className:"space-y-4 py-4",children:[M,X,J,H]}),e[54]=M,e[55]=X,e[56]=J,e[57]=H,e[58]=W):W=e[58];let U;e[59]!==n?(U=()=>n(!1),e[59]=n,e[60]=U):U=e[60];let Q;e[61]!==d?(Q=d("sectionsEditor.createPageModal.cancelButton"),e[61]=d,e[62]=Q):Q=e[62];let q;e[63]!==c||e[64]!==U||e[65]!==Q?(q=r.jsx(le,{type:"button",variant:"outline",onClick:U,disabled:c,children:Q}),e[63]=c,e[64]=U,e[65]=Q,e[66]=q):q=e[66];let Z;e[67]!==c||e[68]!==u||e[69]!==p?(Z=!u.trim()||!p.trim()||c,e[67]=c,e[68]=u,e[69]=p,e[70]=Z):Z=e[70];let Y;e[71]!==c||e[72]!==d?(Y=c?r.jsxs(r.Fragment,{children:[r.jsx(et,{size:14,className:"animate-spin"}),d("sectionsEditor.createPageModal.creatingButton")]}):d("sectionsEditor.createPageModal.createButton"),e[71]=c,e[72]=d,e[73]=Y):Y=e[73];let ee;e[74]!==Z||e[75]!==Y?(ee=r.jsx(le,{type:"submit",disabled:Z,children:Y}),e[74]=Z,e[75]=Y,e[76]=ee):ee=e[76];let G;e[77]!==q||e[78]!==ee?(G=r.jsxs(Mi,{children:[q,ee]}),e[77]=q,e[78]=ee,e[79]=G):G=e[79];let te;e[80]!==N||e[81]!==W||e[82]!==G||e[83]!==T?(te=r.jsx(es,{className:"sm:max-w-md",children:r.jsxs("form",{onSubmit:N,children:[T,W,G]})}),e[80]=N,e[81]=W,e[82]=G,e[83]=T,e[84]=te):te=e[84];let se;return e[85]!==S||e[86]!==s||e[87]!==te?(se=r.jsx(ts,{open:s,onOpenChange:S,children:te}),e[85]=S,e[86]=s,e[87]=te,e[88]=se):se=e[88],se}const bA=tn({tag:rs(),id:rs(),classes:rs(),text:rs(),html:rs(),manifestKey:rs().nullable(),componentName:rs().nullable(),parents:rs(),url:rs(),path:rs(),viewport:tn({width:oo(),height:oo()}),position:tn({x:oo(),y:oo()})}),yA=`(function() {
|
|
42
|
+
if (window.__visualEditorActive) return;
|
|
43
|
+
window.__visualEditorActive = true;
|
|
44
|
+
|
|
45
|
+
var cursorStyle = document.createElement("style");
|
|
46
|
+
cursorStyle.textContent = "* { cursor: default !important; }";
|
|
47
|
+
document.head.appendChild(cursorStyle);
|
|
48
|
+
|
|
49
|
+
var highlight = document.createElement("div");
|
|
50
|
+
highlight.style.cssText = "position:fixed;pointer-events:none;outline:2px solid #a855f7;background:rgba(168,85,247,0.08);border-radius:2px;z-index:2147483647;display:none;";
|
|
51
|
+
document.body.appendChild(highlight);
|
|
52
|
+
|
|
53
|
+
var badge = document.createElement("div");
|
|
54
|
+
badge.style.cssText = "position:fixed;pointer-events:none;background:#a855f7;color:white;font:11px/1 monospace;padding:2px 6px;border-radius:2px;z-index:2147483647;display:none;white-space:nowrap;max-width:240px;overflow:hidden;text-overflow:ellipsis;";
|
|
55
|
+
document.body.appendChild(badge);
|
|
56
|
+
|
|
57
|
+
var lastTarget = null;
|
|
58
|
+
var rafPending = false;
|
|
59
|
+
var moveHandler = function(e) {
|
|
60
|
+
if (rafPending) return;
|
|
61
|
+
rafPending = true;
|
|
62
|
+
var target = e.target;
|
|
63
|
+
requestAnimationFrame(function() {
|
|
64
|
+
rafPending = false;
|
|
65
|
+
var el = target;
|
|
66
|
+
if (!el || el === highlight || el === badge) return;
|
|
67
|
+
if (el === lastTarget) return;
|
|
68
|
+
lastTarget = el;
|
|
69
|
+
var r = el.getBoundingClientRect();
|
|
70
|
+
highlight.style.display = "block";
|
|
71
|
+
highlight.style.top = r.top + "px";
|
|
72
|
+
highlight.style.left = r.left + "px";
|
|
73
|
+
highlight.style.width = r.width + "px";
|
|
74
|
+
highlight.style.height = r.height + "px";
|
|
75
|
+
var tag = el.tagName.toLowerCase();
|
|
76
|
+
var id = el.id ? "#" + el.id : "";
|
|
77
|
+
var cls = el.className && typeof el.className === "string"
|
|
78
|
+
? "." + el.className.trim().split(/\\s+/).slice(0, 2).join(".")
|
|
79
|
+
: "";
|
|
80
|
+
badge.textContent = tag + id + cls;
|
|
81
|
+
badge.style.display = "block";
|
|
82
|
+
badge.style.top = Math.max(0, r.top - 20) + "px";
|
|
83
|
+
badge.style.left = r.left + "px";
|
|
84
|
+
});
|
|
85
|
+
};
|
|
86
|
+
document.addEventListener("mousemove", moveHandler, true);
|
|
87
|
+
|
|
88
|
+
var outHandler = function(e) {
|
|
89
|
+
if (!e.relatedTarget || e.relatedTarget === document.documentElement) {
|
|
90
|
+
highlight.style.display = "none";
|
|
91
|
+
badge.style.display = "none";
|
|
92
|
+
lastTarget = null;
|
|
93
|
+
}
|
|
94
|
+
};
|
|
95
|
+
document.addEventListener("mouseout", outHandler, true);
|
|
96
|
+
|
|
97
|
+
var clickHandler = function(e) {
|
|
98
|
+
e.preventDefault();
|
|
99
|
+
e.stopImmediatePropagation();
|
|
100
|
+
var el = e.target;
|
|
101
|
+
if (!el || el === highlight || el === badge) return;
|
|
102
|
+
|
|
103
|
+
highlight.style.outline = "2px solid #a855f7";
|
|
104
|
+
highlight.style.background = "rgba(168,85,247,0.15)";
|
|
105
|
+
setTimeout(function() {
|
|
106
|
+
highlight.style.outline = "2px solid #a855f7";
|
|
107
|
+
highlight.style.background = "rgba(168,85,247,0.08)";
|
|
108
|
+
}, 400);
|
|
109
|
+
|
|
110
|
+
var tag = el.tagName.toLowerCase();
|
|
111
|
+
var id = el.id || "";
|
|
112
|
+
var classes = el.className && typeof el.className === "string" ? el.className.trim() : "";
|
|
113
|
+
var text = (el.textContent || "").trim().slice(0, 200);
|
|
114
|
+
var html = (el.outerHTML || "").slice(0, 800).replace(/\\svalue=("[^"]*"|'[^']*'|\\S+)/gi, "");
|
|
115
|
+
|
|
116
|
+
var closestSection = el.closest("section[data-manifest-key]");
|
|
117
|
+
var manifestKey = closestSection ? closestSection.getAttribute("data-manifest-key") : null;
|
|
118
|
+
|
|
119
|
+
var ancestor = el;
|
|
120
|
+
var componentName = null;
|
|
121
|
+
for (var i = 0; i < 10 && ancestor; i++) {
|
|
122
|
+
if (ancestor.dataset) componentName = ancestor.dataset.componentName || componentName;
|
|
123
|
+
ancestor = ancestor.parentElement;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
var parents = [];
|
|
127
|
+
var p = el.parentElement;
|
|
128
|
+
for (var j = 0; j < 4 && p && p !== document.body; j++) {
|
|
129
|
+
var pTag = p.tagName ? p.tagName.toLowerCase() : "";
|
|
130
|
+
var pId = p.id ? "#" + p.id : "";
|
|
131
|
+
var pCls = p.className && typeof p.className === "string"
|
|
132
|
+
? "." + p.className.trim().split(/\\s+/)[0]
|
|
133
|
+
: "";
|
|
134
|
+
parents.unshift(pTag + pId + pCls);
|
|
135
|
+
p = p.parentElement;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
window.parent.postMessage({
|
|
139
|
+
type: "visual-editor::element-clicked",
|
|
140
|
+
payload: {
|
|
141
|
+
tag: tag, id: id, classes: classes, text: text, html: html,
|
|
142
|
+
manifestKey: manifestKey, componentName: componentName,
|
|
143
|
+
parents: parents.join(" > "),
|
|
144
|
+
url: window.location.href, path: window.location.pathname,
|
|
145
|
+
viewport: { width: window.innerWidth, height: window.innerHeight },
|
|
146
|
+
position: { x: Math.round(e.clientX), y: Math.round(e.clientY) }
|
|
147
|
+
}
|
|
148
|
+
}, "*");
|
|
149
|
+
};
|
|
150
|
+
document.addEventListener("click", clickHandler, true);
|
|
151
|
+
|
|
152
|
+
window.addEventListener("message", function(e) {
|
|
153
|
+
if (e.data && e.data.type === "visual-editor::deactivate") {
|
|
154
|
+
highlight.remove();
|
|
155
|
+
badge.remove();
|
|
156
|
+
cursorStyle.remove();
|
|
157
|
+
document.removeEventListener("mousemove", moveHandler, true);
|
|
158
|
+
document.removeEventListener("mouseout", outHandler, true);
|
|
159
|
+
document.removeEventListener("click", clickHandler, true);
|
|
160
|
+
window.__visualEditorActive = false;
|
|
161
|
+
}
|
|
162
|
+
});
|
|
163
|
+
})();`,_A=tn({sectionIndex:oo(),manifestKey:rs()}),LA=`(function() {
|
|
164
|
+
if (window.__cmsEditorActive) return;
|
|
165
|
+
window.__cmsEditorActive = true;
|
|
166
|
+
|
|
167
|
+
// Preserve scroll across variant-override navigations and save-reloads.
|
|
168
|
+
// Selecting a variant rebuilds the iframe src (new x-deco-matchers-override)
|
|
169
|
+
// or reloads it, which would otherwise jump to the top. We persist the scroll
|
|
170
|
+
// offset to sessionStorage (survives reload, same-origin) keyed by pathname
|
|
171
|
+
// (the override only changes the query, so the key is stable), then restore it
|
|
172
|
+
// on the next load — retried for ~1s so it outlasts re-hydration and lazy
|
|
173
|
+
// sections that grow the page after load. The recency guard avoids restoring a
|
|
174
|
+
// stale offset on a genuinely fresh visit.
|
|
175
|
+
var SCROLL_KEY = "__cms_preview_scroll:" + location.pathname;
|
|
176
|
+
var saveScroll = function() {
|
|
177
|
+
try {
|
|
178
|
+
sessionStorage.setItem(SCROLL_KEY, JSON.stringify({
|
|
179
|
+
x: window.scrollX, y: window.scrollY, t: Date.now()
|
|
180
|
+
}));
|
|
181
|
+
} catch (_) {}
|
|
182
|
+
};
|
|
183
|
+
var saveScrollPending = false;
|
|
184
|
+
window.addEventListener("scroll", function() {
|
|
185
|
+
if (saveScrollPending) return;
|
|
186
|
+
saveScrollPending = true;
|
|
187
|
+
requestAnimationFrame(function() { saveScrollPending = false; saveScroll(); });
|
|
188
|
+
}, { passive: true });
|
|
189
|
+
(function restoreScroll() {
|
|
190
|
+
var raw = null;
|
|
191
|
+
try { raw = sessionStorage.getItem(SCROLL_KEY); } catch (_) {}
|
|
192
|
+
if (!raw) return;
|
|
193
|
+
var saved = null;
|
|
194
|
+
try { saved = JSON.parse(raw); } catch (_) { return; }
|
|
195
|
+
if (!saved || (Date.now() - saved.t) > 10000) return;
|
|
196
|
+
if (!saved.x && !saved.y) return;
|
|
197
|
+
var attempts = 0;
|
|
198
|
+
var apply = function() {
|
|
199
|
+
attempts++;
|
|
200
|
+
window.scrollTo(saved.x || 0, saved.y || 0);
|
|
201
|
+
if (attempts < 8) setTimeout(apply, 120);
|
|
202
|
+
};
|
|
203
|
+
apply();
|
|
204
|
+
})();
|
|
205
|
+
|
|
206
|
+
var highlight = document.createElement("div");
|
|
207
|
+
highlight.style.cssText = "position:absolute;pointer-events:none;outline:2px solid #06b6d4;background:rgba(6,182,212,0.06);border-radius:2px;z-index:2147483647;display:none;";
|
|
208
|
+
document.body.appendChild(highlight);
|
|
209
|
+
|
|
210
|
+
var badge = document.createElement("div");
|
|
211
|
+
badge.style.cssText = "position:absolute;pointer-events:none;background:#06b6d4;color:white;font:11px/1 monospace;padding:2px 6px;border-radius:2px;z-index:2147483647;display:none;white-space:nowrap;max-width:240px;overflow:hidden;text-overflow:ellipsis;";
|
|
212
|
+
document.body.appendChild(badge);
|
|
213
|
+
|
|
214
|
+
var isTopLevelSection = function(el) {
|
|
215
|
+
return el && el.parentElement
|
|
216
|
+
? !el.parentElement.closest("section[data-manifest-key]")
|
|
217
|
+
: true;
|
|
218
|
+
};
|
|
219
|
+
|
|
220
|
+
// All top-level page sections in DOM order (deco renders page sections as
|
|
221
|
+
// <section data-manifest-key>; nested islands/sections carry the attribute
|
|
222
|
+
// too, hence the top-level filter). This is the full DOM run, framework
|
|
223
|
+
// sections included — getAllSections() narrows it to the editable window.
|
|
224
|
+
var topLevelSections = function() {
|
|
225
|
+
return Array.from(document.querySelectorAll("section[data-manifest-key]"))
|
|
226
|
+
.filter(isTopLevelSection);
|
|
227
|
+
};
|
|
228
|
+
|
|
229
|
+
// Candidate manifest keys per editable section, sent by the editor. Each
|
|
230
|
+
// entry is an array of acceptable DOM keys: [] = wildcard (e.g. multivariate,
|
|
231
|
+
// whose rendered key we can't predict); null = renders NOTHING (hidden
|
|
232
|
+
// section — multivariate whose variants are all gated by never), so the
|
|
233
|
+
// alignment must not consume a DOM node for it; a Lazy lists both its loader
|
|
234
|
+
// key and the inner section's key, since the classic runtime keeps the Lazy
|
|
235
|
+
// wrapper at top level while TanStack renders the inner section directly.
|
|
236
|
+
var sectionCandidates = [];
|
|
237
|
+
|
|
238
|
+
// Best in-order assignment of editable sections to DOM sections, maximizing
|
|
239
|
+
// key matches (DP / LCS-style). deco injects framework sections (SEO, Theme,
|
|
240
|
+
// Session, …) that may lead, trail, OR interleave with the editable run; this
|
|
241
|
+
// skips whichever don't match, on any runtime — no hardcoded list. Hidden
|
|
242
|
+
// sections (null candidates) have no DOM node: only visible entries are
|
|
243
|
+
// aligned, then scattered back to their decofile positions (null-filled), so
|
|
244
|
+
// returned indexes still match the decofile array.
|
|
245
|
+
var computeAlignment = function(tops) {
|
|
246
|
+
var visible = [], k;
|
|
247
|
+
for (k = 0; k < sectionCandidates.length; k++) {
|
|
248
|
+
if (sectionCandidates[k] !== null) visible.push(k);
|
|
249
|
+
}
|
|
250
|
+
var N = visible.length, M = tops.length;
|
|
251
|
+
var res = new Array(sectionCandidates.length).fill(null);
|
|
252
|
+
if (!N) return res;
|
|
253
|
+
if (M < N) return tops.slice();
|
|
254
|
+
var domKeys = tops.map(function(s) { return s.getAttribute("data-manifest-key"); });
|
|
255
|
+
var match = function(i, j) {
|
|
256
|
+
var c = sectionCandidates[visible[i]];
|
|
257
|
+
if (!c || !c.length) return 1;
|
|
258
|
+
return c.indexOf(domKeys[j]) >= 0 ? 1 : 0;
|
|
259
|
+
};
|
|
260
|
+
var dp = [], bt = [], i, j;
|
|
261
|
+
for (i = 0; i <= N; i++) { dp.push(new Array(M + 1).fill(0)); bt.push(new Array(M + 1).fill(0)); }
|
|
262
|
+
for (i = 1; i <= N; i++) {
|
|
263
|
+
for (j = i; j <= M; j++) {
|
|
264
|
+
var assign = dp[i - 1][j - 1] + match(i - 1, j - 1);
|
|
265
|
+
var skip = dp[i][j - 1];
|
|
266
|
+
if (j - 1 >= i && skip >= assign) { dp[i][j] = skip; bt[i][j] = 0; }
|
|
267
|
+
else { dp[i][j] = assign; bt[i][j] = 1; }
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
i = N; j = M;
|
|
271
|
+
while (i > 0) {
|
|
272
|
+
if (bt[i][j] === 1) { res[visible[i - 1]] = tops[j - 1]; i--; j--; }
|
|
273
|
+
else { j--; }
|
|
274
|
+
}
|
|
275
|
+
return res;
|
|
276
|
+
};
|
|
277
|
+
|
|
278
|
+
// Editable sections, indexed to match the decofile array the panel uses.
|
|
279
|
+
// Recomputed from the live DOM each call (cheap, rAF-throttled) so it
|
|
280
|
+
// self-heals as client-rendered/lazy sections mount. Until the editor sends
|
|
281
|
+
// candidates, fall back to the full top-level run.
|
|
282
|
+
var getAllSections = function() {
|
|
283
|
+
var tops = topLevelSections();
|
|
284
|
+
return sectionCandidates.length ? computeAlignment(tops) : tops;
|
|
285
|
+
};
|
|
286
|
+
|
|
287
|
+
// Resolve to the OUTERMOST page-level section (clicking nested content still
|
|
288
|
+
// maps to the top-level section the panel indexes); null if it isn't in the
|
|
289
|
+
// aligned editable set (a framework section deco injected).
|
|
290
|
+
var findSection = function(el) {
|
|
291
|
+
var node = el;
|
|
292
|
+
var found = null;
|
|
293
|
+
while (node && node !== document.body) {
|
|
294
|
+
if (node.tagName === "SECTION" && node.hasAttribute && node.hasAttribute("data-manifest-key")) {
|
|
295
|
+
found = node;
|
|
296
|
+
}
|
|
297
|
+
node = node.parentElement;
|
|
298
|
+
}
|
|
299
|
+
if (!found) return null;
|
|
300
|
+
return getAllSections().indexOf(found) >= 0 ? found : null;
|
|
301
|
+
};
|
|
302
|
+
|
|
303
|
+
// Lazy sections async-render their real section inside a wrapper, so the
|
|
304
|
+
// wrapper's key is just the loader. Show the inner section's key instead
|
|
305
|
+
// (falling back to the wrapper while the content hasn't loaded yet).
|
|
306
|
+
var LAZY_KEY = "website/sections/Rendering/Lazy.tsx";
|
|
307
|
+
var displayKey = function(section) {
|
|
308
|
+
var key = section.getAttribute("data-manifest-key") || "section";
|
|
309
|
+
if (key === LAZY_KEY) {
|
|
310
|
+
var inner = section.querySelector("section[data-manifest-key]");
|
|
311
|
+
if (inner) return inner.getAttribute("data-manifest-key") || key;
|
|
312
|
+
}
|
|
313
|
+
return key;
|
|
314
|
+
};
|
|
315
|
+
|
|
316
|
+
// Per-section metadata sent by the editor, aligned by index with
|
|
317
|
+
// getAllSections(). labels: names the DOM can't carry (a global section or a
|
|
318
|
+
// global inside async rendering); kinds: section type that drives the color.
|
|
319
|
+
var sectionLabels = [];
|
|
320
|
+
var sectionKinds = [];
|
|
321
|
+
var labelFor = function(section) {
|
|
322
|
+
var idx = getAllSections().indexOf(section);
|
|
323
|
+
if (idx >= 0 && sectionLabels[idx]) return sectionLabels[idx];
|
|
324
|
+
return displayKey(section);
|
|
325
|
+
};
|
|
326
|
+
var kindFor = function(section) {
|
|
327
|
+
var idx = getAllSections().indexOf(section);
|
|
328
|
+
return (idx >= 0 && sectionKinds[idx]) || "normal";
|
|
329
|
+
};
|
|
330
|
+
|
|
331
|
+
// Highlight palette by section kind: global = light purple, variant = green,
|
|
332
|
+
// normal = blue.
|
|
333
|
+
var COLORS = {
|
|
334
|
+
normal: { solid: "#06b6d4", bg: "rgba(6,182,212,0.06)", active: "rgba(6,182,212,0.18)" },
|
|
335
|
+
global: { solid: "#c084fc", bg: "rgba(192,132,252,0.10)", active: "rgba(192,132,252,0.22)" },
|
|
336
|
+
variant: { solid: "#22c55e", bg: "rgba(34,197,94,0.08)", active: "rgba(34,197,94,0.20)" }
|
|
337
|
+
};
|
|
338
|
+
var applyColor = function(kind) {
|
|
339
|
+
var c = COLORS[kind] || COLORS.normal;
|
|
340
|
+
highlight.style.outline = "2px solid " + c.solid;
|
|
341
|
+
highlight.style.background = c.bg;
|
|
342
|
+
badge.style.background = c.solid;
|
|
343
|
+
};
|
|
344
|
+
|
|
345
|
+
var lastSection = null;
|
|
346
|
+
var lastLabel = "";
|
|
347
|
+
var lastKind = "normal";
|
|
348
|
+
var rafPending = false;
|
|
349
|
+
|
|
350
|
+
// Document-relative coordinates (rect + scroll) on absolutely-positioned
|
|
351
|
+
// nodes, so the browser scrolls the highlight together with the page
|
|
352
|
+
// natively — no per-frame JS repositioning, no scroll lag.
|
|
353
|
+
var positionHighlight = function(section) {
|
|
354
|
+
var r = section.getBoundingClientRect();
|
|
355
|
+
var top = r.top + window.scrollY;
|
|
356
|
+
var left = r.left + window.scrollX;
|
|
357
|
+
highlight.style.display = "block";
|
|
358
|
+
highlight.style.top = top + "px";
|
|
359
|
+
highlight.style.left = left + "px";
|
|
360
|
+
highlight.style.width = r.width + "px";
|
|
361
|
+
highlight.style.height = r.height + "px";
|
|
362
|
+
badge.textContent = lastLabel || displayKey(section);
|
|
363
|
+
badge.style.display = "block";
|
|
364
|
+
badge.style.top = Math.max(0, top - 20) + "px";
|
|
365
|
+
badge.style.left = left + "px";
|
|
366
|
+
};
|
|
367
|
+
|
|
368
|
+
var moveHandler = function(e) {
|
|
369
|
+
if (rafPending) return;
|
|
370
|
+
rafPending = true;
|
|
371
|
+
var target = e.target;
|
|
372
|
+
requestAnimationFrame(function() {
|
|
373
|
+
rafPending = false;
|
|
374
|
+
if (!target || target === highlight || target === badge) return;
|
|
375
|
+
var section = findSection(target);
|
|
376
|
+
if (section === lastSection) return;
|
|
377
|
+
lastSection = section;
|
|
378
|
+
if (!section) {
|
|
379
|
+
highlight.style.display = "none";
|
|
380
|
+
badge.style.display = "none";
|
|
381
|
+
return;
|
|
382
|
+
}
|
|
383
|
+
lastLabel = labelFor(section);
|
|
384
|
+
lastKind = kindFor(section);
|
|
385
|
+
applyColor(lastKind);
|
|
386
|
+
positionHighlight(section);
|
|
387
|
+
});
|
|
388
|
+
};
|
|
389
|
+
document.addEventListener("mousemove", moveHandler, true);
|
|
390
|
+
|
|
391
|
+
// Window scroll is handled natively by the absolute positioning above; this
|
|
392
|
+
// only re-syncs on resize and on scrolls inside nested scroll containers
|
|
393
|
+
// (capture=true catches those), where document coordinates do shift.
|
|
394
|
+
var reposition = function() {
|
|
395
|
+
if (!lastSection || highlight.style.display === "none") return;
|
|
396
|
+
if (rafPending) return;
|
|
397
|
+
rafPending = true;
|
|
398
|
+
requestAnimationFrame(function() {
|
|
399
|
+
rafPending = false;
|
|
400
|
+
if (lastSection && highlight.style.display !== "none") positionHighlight(lastSection);
|
|
401
|
+
});
|
|
402
|
+
};
|
|
403
|
+
window.addEventListener("scroll", reposition, { capture: true, passive: true });
|
|
404
|
+
window.addEventListener("resize", reposition, { passive: true });
|
|
405
|
+
|
|
406
|
+
var outHandler = function(e) {
|
|
407
|
+
if (!e.relatedTarget || e.relatedTarget === document.documentElement) {
|
|
408
|
+
highlight.style.display = "none";
|
|
409
|
+
badge.style.display = "none";
|
|
410
|
+
lastSection = null;
|
|
411
|
+
}
|
|
412
|
+
};
|
|
413
|
+
document.addEventListener("mouseout", outHandler, true);
|
|
414
|
+
|
|
415
|
+
var clickHandler = function(e) {
|
|
416
|
+
e.preventDefault();
|
|
417
|
+
e.stopImmediatePropagation();
|
|
418
|
+
var target = e.target;
|
|
419
|
+
if (!target || target === highlight || target === badge) return;
|
|
420
|
+
var section = findSection(target);
|
|
421
|
+
if (!section) return;
|
|
422
|
+
|
|
423
|
+
var sections = getAllSections();
|
|
424
|
+
var sectionIndex = sections.indexOf(section);
|
|
425
|
+
var manifestKey = section.getAttribute("data-manifest-key") || "";
|
|
426
|
+
|
|
427
|
+
var c = COLORS[lastKind] || COLORS.normal;
|
|
428
|
+
highlight.style.outline = "2px solid " + c.solid;
|
|
429
|
+
highlight.style.background = c.active;
|
|
430
|
+
setTimeout(function() {
|
|
431
|
+
highlight.style.background = c.bg;
|
|
432
|
+
}, 400);
|
|
433
|
+
|
|
434
|
+
window.parent.postMessage({
|
|
435
|
+
type: "cms-editor::section-clicked",
|
|
436
|
+
payload: { sectionIndex: sectionIndex, manifestKey: manifestKey }
|
|
437
|
+
}, "*");
|
|
438
|
+
};
|
|
439
|
+
document.addEventListener("click", clickHandler, true);
|
|
440
|
+
|
|
441
|
+
window.addEventListener("message", function(e) {
|
|
442
|
+
if (e.data && e.data.type === "cms-editor::set-labels" && Array.isArray(e.data.labels)) {
|
|
443
|
+
sectionLabels = e.data.labels;
|
|
444
|
+
if (Array.isArray(e.data.kinds)) sectionKinds = e.data.kinds;
|
|
445
|
+
if (Array.isArray(e.data.keys)) sectionCandidates = e.data.keys;
|
|
446
|
+
if (lastSection) {
|
|
447
|
+
lastLabel = labelFor(lastSection);
|
|
448
|
+
lastKind = kindFor(lastSection);
|
|
449
|
+
applyColor(lastKind);
|
|
450
|
+
if (highlight.style.display !== "none") positionHighlight(lastSection);
|
|
451
|
+
}
|
|
452
|
+
return;
|
|
453
|
+
}
|
|
454
|
+
if (e.data && e.data.type === "cms-editor::deactivate") {
|
|
455
|
+
highlight.remove();
|
|
456
|
+
badge.remove();
|
|
457
|
+
document.removeEventListener("mousemove", moveHandler, true);
|
|
458
|
+
document.removeEventListener("mouseout", outHandler, true);
|
|
459
|
+
document.removeEventListener("click", clickHandler, true);
|
|
460
|
+
window.removeEventListener("scroll", reposition, { capture: true });
|
|
461
|
+
window.removeEventListener("resize", reposition);
|
|
462
|
+
window.__cmsEditorActive = false;
|
|
463
|
+
}
|
|
464
|
+
});
|
|
465
|
+
})();`;function Vg(t,e){return t.map((s,n)=>{const i=s.__resolveType??"",o=fs(i);if(!o&&i!==""&&yn(i)&&i in e){const d=e[i],h=typeof d?.name=="string"&&d.name||i.replace(/[-_]/g," ").replace(/\b\w/g,u=>u.toUpperCase())||`Section ${n+1}`;return{index:n,resolveType:i,label:h,isLazy:!1,isSavedBlock:!0}}const a=o?s.section:void 0,l=o?a?.__resolveType??"":i;if(l===Ki||l===Dr){const d=o?a:s,h=Array.isArray(d?.variants)?d.variants:[];if(h.length===1&&(h[0]?.rule?.__resolveType??"")===Rr){const m=h[0]?.value??{};let p=m.__resolveType??"";const g=fs(p);return g&&(p=m.section?.__resolveType??p),{index:n,resolveType:i,label:Tt(p)||`Section ${n+1}`,isHidden:!0,isLazy:g}}const u=h[0]?.value?.__resolveType,f=u?Tt(u):"Section";return{index:n,resolveType:i,label:`Variants of ${f}`,isMultivariate:!0,isLazy:o}}const c=o?s.section?.__resolveType??i:i;if(o&&c!==""&&yn(c)&&c in e){const d=e[c],h=typeof d?.name=="string"&&d.name||c.replace(/[-_]/g," ").replace(/\b\w/g,u=>u.toUpperCase())||`Section ${n+1}`;return{index:n,resolveType:i,label:h,isLazy:!0,isSavedBlock:!0}}return{index:n,resolveType:i,label:Tt(c)||`Section ${n+1}`,isLazy:o}})}const SA="website/sections/Rendering/Lazy.tsx";function e0(t,e){let s=t,n=typeof s?.__resolveType=="string"?s.__resolveType:"";for(let i=0;n&&i<5;i++){const o=e[n];if(o&&typeof o=="object"&&"__resolveType"in o){const a=o.__resolveType;if(typeof a=="string"&&a&&a!==n){s=o,n=a;continue}}break}if(!n)return[];if(n.includes("flags/multivariate")){const i=Array.isArray(s.variants)?s.variants:[];if(i.length===0||i.every(l=>l?.rule?.__resolveType===Rr))return null;const a=[];for(const l of i){const c=l?.value;if(c&&typeof c=="object")for(const d of e0(c,e)??[])a.includes(d)||a.push(d)}return a}if(n===SA){const i=s.section&&typeof s.section=="object"?e0(s.section,e):[];return i===null?null:i.length?[n,...i]:[n]}return[n]}function Ng(t){const e=t.__resolveType??"";return fs(e)?t.section??t:t}function Rl(t){const i=(fs(t.__resolveType??"")?t.section:t)?.variants?.[0];return i?.rule?.__resolveType!==Rr?null:i?.value??null}function iW(t){const e=Ng(t);return{__resolveType:Dr,variants:[{value:e,rule:{__resolveType:Rr}}]}}function rW(t){const e=t.__resolveType??"";if(!e)return null;if(fs(e))return t.section??null;const s=Rl(t);return s?fs(s.__resolveType??"")?s:{__resolveType:Dh,section:Ng(s)}:{__resolveType:Dh,section:t}}function ka(t){const e=t.__resolveType??"";if(!e)return null;if(fs(e)){const s=t.section,n=s?.__resolveType??"";return!n||!s?null:{resolveType:n,data:s}}return{resolveType:e,data:t}}function oW(t){const e=Rl(t);if(e)return ka(e);if(fs(t.__resolveType??"")){const n=t.section;if(!n)return null;const i=Rl(n);return ka(i||n)}return ka(t)}function aW(t){return Rl(t)}const wA=["website/matchers/always.ts","$live/matchers/MatchAlways.ts"];function pu(t){if(!t)return!1;const e=t.__resolveType??"";return e===""?Object.keys(t).length===0:wA.includes(e)||e.includes("always")}function jA(t){const e=t.variants??[];if(e.length===0)return-1;const s=e.findIndex(n=>pu(n.rule));return s!==-1?s:e.length-1}function lW(t,e,s){const n=s.variants??[];if(n.length===0)return null;const i=jA(s),o=n[i]?.value;if(!o)return null;const a=structuredClone(o);return e.isLazy?{...t,section:a}:a}function Tg(t,e){return e.isMultivariate?e.isLazy?t.section??null:t:null}function cW(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 dW(t,e){const s=t.__resolveType??"";if(!s)return null;if(fs(s)){const n=t.section??t,i=n.__resolveType??s;if(!i.includes("/")&&i in e){const o=e[i]??{};return{data:{...o},resolveType:o.__resolveType??i}}return{data:{...n},resolveType:i}}if(!s.includes("/")&&s in e){const n=e[s]??{};return{data:{...n},resolveType:n.__resolveType??s}}return{data:{...t},resolveType:s}}function CA(t,e){const s=t.__resolveType??"";return fs(s)?{...t,section:e}:e}function kA(t,e,s){return e.isLazy?{...t,section:s}:s}function uW(t,e,s){const n=[...t.variants??[]],i=n[e];if(!i)return t;const o=i.value??{};return n[e]={...i,value:CA(o,s)},{...t,variants:n}}function hW(t,e,s){const n=[...t.variants??[]];return n[e]?(n[e]={...n[e],rule:s},{...t,variants:n}):t}function fW(t,e){const s=[...t.variants??[]],n=s[e];return n?(s.splice(e+1,0,structuredClone(n)),{...t,variants:s}):t}function mW(t,e,s){const n=[...t.variants??[]];if(e===s||e<0||s<0||e>=n.length||s>=n.length)return t;const[i]=n.splice(e,1);return i?(n.splice(s,0,i),{...t,variants:n}):t}function pW(t,e){const s=[...t.variants??[]];return s.length<=1?null:(s.splice(e,1),{...t,variants:s})}function t0(t){return{rule:br(),value:structuredClone(t)}}function Ag(t,e){return{...e,__resolveType:Dr,variants:t}}function gW(t){return t.isHidden!==!0&&t.isSavedBlock!==!0}function VA(t,e){if(e.isHidden)return null;if(e.isMultivariate){const n=Tg(t,e)?.variants??[],i=n[n.length-1]?.value;return i?structuredClone(i):null}if(e.isLazy){const s=t.section;return s?structuredClone(s):null}return structuredClone(t)}function NA(t,e,s){if(e.isMultivariate||e.isHidden)return null;const n=VA(t,e);if(!n)return null;const i=Ag([t0(n),t0(n)]);return e.isLazy?{...t,section:i}:i}function xW(t,e,s){if(e.isHidden||e.isSavedBlock)return null;if(e.isMultivariate){const i=Tg(t,e);if(!i)return null;const o=i.variants??[],a=o[o.length-1]?.value;if(!a)return null;const l=Ag([...o,t0(a)],i);return{section:kA(t,e,l),newVariantIndex:o.length}}const n=NA(t,e);return n?{section:n,newVariantIndex:1}:null}const TA=new Set(["website/pages/Page.tsx","$live/pages/LivePage.tsx"]);function jc(t){return t.anyOfRefs?.some(e=>e.resolveType!==Ki?!1:e.schema?.properties?.variants?.items?.properties?.value?.type==="array")??!1}function AA(t){if(!t||typeof t!="object"||Array.isArray(t))return!1;const e=t;return e.__resolveType===Dr&&Array.isArray(e.variants)}function Dl(t){return!t||typeof t!="object"||Array.isArray(t)?!1:t.__resolveType===Ki}function EA(t){if(!Dl(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 PA(t,e){if(!Dl(t))return e;const s=structuredClone(t),n=[...s.variants??[]];return n.length===0?n.push({rule:br(),value:e}):n[0]={...n[0],value:e},{...s,variants:n}}function RA(t){if(!t||typeof t!="object"||Array.isArray(t))return!1;const e=t;return typeof e.__resolveType=="string"&&TA.has(e.__resolveType)&&typeof e.path=="string"}function Eg(t,e){const n=t[e]?.sections;if(!n||Array.isArray(n))return 1;const i=n;return Array.isArray(i.variants)?i.variants.length:1}function Pg(t,e,s){const i=t[e]?.sections;if(Array.isArray(i))return s===0?i:[];if(i&&typeof i=="object"){const o=i.variants;if(Array.isArray(o)){const a=o[s];return Array.isArray(a?.value)?a.value:[]}}return[]}function vW(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 i=n.variants,o=i.map(c=>dA(c.rule,e,s)),a=o.reduce((c,d)=>(c[d]=(c[d]??0)+1,c),{}),l={};return i.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:br(),value:t}}function cr(t,e){return{...e,__resolveType:Ki,variants:t}}function DA(t,e){const s=structuredClone(e);if(Array.isArray(t))return cr([Wr(t),Wr(s)]);if(t&&typeof t=="object"){const n=t;return Array.isArray(n.variants)?cr([...n.variants,Wr(s)],n):null}return cr([Wr([]),Wr(s)])}function bW(t){const e=t.variants;return Array.isArray(e)?e.length-1:1}function yW(t,e){const s=t[e];if(!s)return null;const n=[...t];return n.splice(e+1,0,structuredClone(s)),n}function _W(t,e){if(e.length===0)return cr([],t);if(e.length===1){const s=e[0],n=s?.rule;if(!pu(n))return cr(e,t);if(Array.isArray(s?.value))return s.value}return cr(e,t)}function IA(t,e){for(const[s,n]of Object.entries(t)){if(!RA(n))continue;const i=n.sections;if(Array.isArray(i)){e(void 0,s,0);continue}if(!i||typeof i!="object")continue;const o=i.variants;if(Array.isArray(o))for(let a=0;a<o.length;a++){const l=o[a];e(l?.rule,s,a)}}}function LW(t,e,s){let n=0;return IA(t,i=>{if(!i)return;(i.__resolveType??"")===e&&Fr(i,t,s)&&n++}),n}function Yi(t){return t.replace(/[`*_]/g,"\\$&")}function MA(t,e){const s=[`The user selected an element on the live preview and asked: **"${Yi(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:** \`${Yi(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="${Yi(t.classes)}"`:""}>`;s.push(`**Clicked element:** \`${n}\``),t.parents&&s.push(`**DOM breadcrumb:** ${Yi(t.parents)} > ${t.tag}`),t.text&&s.push(`**Text content:** "${Yi(t.text)}"`),t.componentName&&s.push(`**Component name:** ${Yi(t.componentName)}`);const i=t.html.replace(/```/g,"`` `");return s.push("","**HTML snippet:**","```html",i,"```"),s.push("","Please read the source file, locate the element, and apply the requested change."),s.join(`
|
|
466
|
+
`)}function OA(t,e,s=320,n=44,i=12){const{x:o,y:a}=t,{width:l,height:c}=e,d=Math.max(i,Math.min(o-s/2,l-s-i)),u=a/c>.68?Math.max(i,a-n-18):Math.min(a+18,c-n-i);return{leftPct:d/l*100,topPct:u/c*100}}function $A(t){const e=B.c(45),{element:s,onDismiss:n}=t,[i,o]=A.useState(""),a=A.useRef(null),{sendMessage:l}=Js(),{openSidePanel:c}=ea(),d=re();let h;e[0]!==s||e[1]!==i||e[2]!==n||e[3]!==c||e[4]!==l?(h=()=>{if(!i.trim())return;const P=MA(s,i);c("chat"),l({parts:[{type:"text",text:P}]}),n()},e[0]=s,e[1]=i,e[2]=n,e[3]=c,e[4]=l,e[5]=h):h=e[5];const u=h;let f;e[6]!==s.position||e[7]!==s.viewport?(f=OA(s.position,s.viewport),e[6]=s.position,e[7]=s.viewport,e[8]=f):f=e[8];const m=f,p=`${m.leftPct}%`,g=`${m.topPct}%`;let x;e[9]!==p||e[10]!==g?(x={left:p,top:g,width:"320px"},e[9]=p,e[10]=g,e[11]=x):x=e[11];let v;e[12]!==u?(v=P=>{P.preventDefault(),u()},e[12]=u,e[13]=v):v=e[13];let b;e[14]===Symbol.for("react.memo_cache_sentinel")?(b=P=>o(P.target.value),e[14]=b):b=e[14];let _;e[15]!==n?(_=P=>{P.key==="Escape"&&n()},e[15]=n,e[16]=_):_=e[16];let y;e[17]!==d?(y=d("sandbox.visualEditorPrompt.inputPlaceholder"),e[17]=d,e[18]=y):y=e[18];let L;e[19]!==i||e[20]!==_||e[21]!==y?(L=r.jsx("input",{ref:a,autoFocus:!0,type:"text",value:i,onChange:b,onKeyDown:_,placeholder:y,className:"min-w-0 flex-1 bg-transparent text-sm outline-none placeholder:text-muted-foreground"}),e[19]=i,e[20]=_,e[21]=y,e[22]=L):L=e[22];let w;e[23]!==i?(w=i.trim(),e[23]=i,e[24]=w):w=e[24];const j=!w;let S;e[25]!==d?(S=d("sandbox.visualEditorPrompt.sendButton"),e[25]=d,e[26]=S):S=e[26];let C;e[27]!==d?(C=d("sandbox.visualEditorPrompt.sendButton"),e[27]=d,e[28]=C):C=e[28];let N;e[29]!==C?(N=r.jsx("title",{children:C}),e[29]=C,e[30]=N):N=e[30];let V;e[31]===Symbol.for("react.memo_cache_sentinel")?(V=r.jsx("path",{d:"M5 9V1M1 5l4-4 4 4",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"}),e[31]=V):V=e[31];let E;e[32]!==N?(E=r.jsxs("svg",{width:"10",height:"10",viewBox:"0 0 10 10",fill:"none","aria-hidden":"true",children:[N,V]}),e[32]=N,e[33]=E):E=e[33];let T;e[34]!==j||e[35]!==S||e[36]!==E?(T=r.jsx("button",{type:"submit",disabled:j,className:"flex h-6 w-6 shrink-0 items-center justify-center rounded-full bg-foreground text-background transition-opacity disabled:opacity-30",title:S,children:E}),e[34]=j,e[35]=S,e[36]=E,e[37]=T):T=e[37];let k;e[38]!==L||e[39]!==T||e[40]!==v?(k=r.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:v,children:[L,T]}),e[38]=L,e[39]=T,e[40]=v,e[41]=k):k=e[41];let R;return e[42]!==k||e[43]!==x?(R=r.jsx("div",{className:"absolute z-30 pointer-events-none",style:x,children:k}),e[42]=k,e[43]=x,e[44]=R):R=e[44],R}const Rg={claiming:{long:"Reserving sandbox",short:"Reserving sandbox"},"waiting-for-capacity":{long:"Waiting for cluster capacity",short:"Waiting for capacity"},"pulling-image":{long:"Downloading sandbox image",short:"Downloading image"},"starting-container":{long:"Starting your sandbox",short:"Starting container"},"warming-daemon":{long:"Connecting to your sandbox",short:"Connecting to sandbox"}},BA=["provision","cloning","install","dev"];function Dg(t){switch(t.lifecycle.phase){case"cloning":case"checking-out":return{step:"cloning",status:"doing"};case"clone-failed":return{step:"cloning",status:"failed"};case"installing":return{step:"install",status:"doing"};case"install-failed":return{step:"install",status:"failed"};case"starting":return{step:"dev",status:"doing"};case"running":return{step:"dev",status:"done"};case"start-failed":return{step:"dev",status:"failed"};case"crashed":return{step:"dev",status:"failed"};case"idle":return t.claimPhase&&t.claimPhase.kind!=="ready"&&t.claimPhase.kind!=="failed"?{step:"provision",status:"doing"}:{step:"cloning",status:"doing"}}}function bf(t){switch(t){case"starting":return"Starting your sandbox";case"suspended":return"Sandbox is paused";case"errored":return"Couldn't start the sandbox"}}function FA(t){return BA.indexOf(t.step)}const yf=48,Ig=28,Mg=3,zA=(()=>{const t=[];let e=0;for(let s=0;s<yf;s++)s===Ig?t.push(null):(t.push(e/(yf-1)*Mg),e++);return t})(),KA={provision:"Reserving sandbox",cloning:"Cloning your repo",install:"Installing packages",dev:"Starting your preview"};function UA(t,e){return t.step==="provision"&&e!=null&&e.kind!=="ready"&&e.kind!=="failed"?Rg[e.kind].long:KA[t.step]}const fn="bg-foreground/[0.05]",Ws="bg-foreground/[0.09]",HA=Array.from({length:35},()=>Math.random()*1.8),WA=Array.from({length:35},()=>Math.random()<.4);function qA(t){const e=B.c(30),{progress:s,claimPhase:n}=t;let i;e[0]!==s?(i=FA(s),e[0]=s,e[1]=i):i=e[1];const o=i;let a;e[2]!==n||e[3]!==s?(a=UA(s,n),e[2]=n,e[3]=s,e[4]=a):a=e[4];const l=a;let c;e[5]===Symbol.for("react.memo_cache_sentinel")?(c=r.jsx(Hx,{}),e[5]=c):c=e[5];const d=`${s.step}-${l}`;let h;e[6]!==l||e[7]!==d?(h=r.jsxs("div",{className:"flex items-center gap-2 rounded-full border border-foreground/10 bg-background px-3.5 py-1.5 shadow-[0_4px_20px_-4px_rgb(0_0_0_/_0.12)]",children:[c,r.jsxs("span",{className:"animate-in fade-in text-[13px] font-medium text-foreground/85 duration-500",children:[l,"…"]},d)]}),e[6]=l,e[7]=d,e[8]=h):h=e[8];let u;e[9]===Symbol.for("react.memo_cache_sentinel")?(u=r.jsx(GA,{}),e[9]=u):u=e[9];let f;e[10]!==o?(f=r.jsx(Va,{phase:0,current:o,children:u}),e[10]=o,e[11]=f):f=e[11];let m;e[12]===Symbol.for("react.memo_cache_sentinel")?(m=r.jsx(JA,{}),e[12]=m):m=e[12];let p;e[13]!==o?(p=r.jsx(Va,{phase:1,current:o,children:m}),e[13]=o,e[14]=p):p=e[14];let g;e[15]===Symbol.for("react.memo_cache_sentinel")?(g=r.jsx(XA,{}),e[15]=g):g=e[15];let x;e[16]!==o?(x=r.jsx(Va,{phase:2,current:o,children:g}),e[16]=o,e[17]=x):x=e[17];let v;e[18]===Symbol.for("react.memo_cache_sentinel")?(v=r.jsx(ZA,{}),e[18]=v):v=e[18];let b;e[19]!==o?(b=r.jsx(Va,{phase:3,current:o,children:v}),e[19]=o,e[20]=b):b=e[20];let _;e[21]!==x||e[22]!==b||e[23]!==f||e[24]!==p?(_=r.jsxs("div",{className:"relative aspect-[4/3] w-[min(78%,560px)]",children:[f,p,x,b]}),e[21]=x,e[22]=b,e[23]=f,e[24]=p,e[25]=_):_=e[25];let y;e[26]===Symbol.for("react.memo_cache_sentinel")?(y=r.jsx("style",{children:`
|
|
467
|
+
@keyframes vm-pulse-soft {
|
|
468
|
+
0%, 100% { opacity: 0.25; }
|
|
469
|
+
50% { opacity: 1; }
|
|
470
|
+
}
|
|
471
|
+
@keyframes vm-breathe {
|
|
472
|
+
0%, 100% { opacity: 0.5; }
|
|
473
|
+
50% { opacity: 1; }
|
|
474
|
+
}
|
|
475
|
+
@keyframes vm-rack-scan {
|
|
476
|
+
0%, 100% { opacity: 0; }
|
|
477
|
+
8% { opacity: 1; }
|
|
478
|
+
22% { opacity: 0; }
|
|
479
|
+
}
|
|
480
|
+
`}),e[26]=y):y=e[26];let L;return e[27]!==_||e[28]!==h?(L=r.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,_,y]}),e[27]=_,e[28]=h,e[29]=L):L=e[29],L}function Va(t){const e=B.c(10),{phase:s,current:n,children:i}=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=ie("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]!==i||e[7]!==f||e[8]!==x?(v=r.jsx("div",{"aria-hidden":f,className:m,style:x,children:i}),e[6]=i,e[7]=f,e[8]=x,e[9]=v):v=e[9],v}function Cc(t){const e=B.c(7),{showUrl:s}=t,n=s===void 0?!1:s;let i,o,a;e[0]===Symbol.for("react.memo_cache_sentinel")?(i=r.jsx("div",{className:ie("size-2.5 rounded-full",Ws)}),o=r.jsx("div",{className:ie("size-2.5 rounded-full",Ws)}),a=r.jsx("div",{className:ie("size-2.5 rounded-full",Ws)}),e[0]=i,e[1]=o,e[2]=a):(i=e[0],o=e[1],a=e[2]);let l;e[3]!==n?(l=n&&r.jsx("div",{className:ie("ml-3 h-3.5 max-w-[220px] flex-1 rounded-sm",fn)}),e[3]=n,e[4]=l):l=e[4];let c;return e[5]!==l?(c=r.jsxs("div",{className:"flex h-7 shrink-0 items-center gap-1.5 px-3",children:[i,o,a,l]}),e[5]=l,e[6]=c):c=e[6],c}function GA(){const t=B.c(2);let e;t[0]===Symbol.for("react.memo_cache_sentinel")?(e=r.jsx(Cc,{}),t[0]=e):e=t[0];let s;return t[1]===Symbol.for("react.memo_cache_sentinel")?(s=r.jsxs("div",{className:"flex h-full flex-col",children:[e,r.jsx("div",{className:"flex flex-1 px-8 py-5",children:r.jsx("div",{className:"grid h-full w-full grid-cols-8 grid-rows-6 gap-2",children:zA.map(YA)})})]}),t[1]=s):s=t[1],s}function YA(t,e){if(e===Ig)return r.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 r.jsx("div",{className:ie("relative rounded-md",Ws),children:r.jsx("div",{className:"absolute inset-0 rounded-md bg-chart-1/40 opacity-0",style:{animation:`vm-rack-scan ${Mg}s ease-in-out infinite`,animationDelay:`${s}s`}})},e)}function JA(){const t=B.c(5);let e;t[0]===Symbol.for("react.memo_cache_sentinel")?(e=r.jsx(Cc,{}),t[0]=e):e=t[0];let s;t[1]===Symbol.for("react.memo_cache_sentinel")?(s=r.jsx("div",{className:ie("w-[18%] rounded-md",fn),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=r.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 i;t[3]===Symbol.for("react.memo_cache_sentinel")?(i=r.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]=i):i=t[3];let o;return t[4]===Symbol.for("react.memo_cache_sentinel")?(o=r.jsxs("div",{className:"flex h-full flex-col",children:[e,r.jsxs("div",{className:"flex min-h-0 flex-1 gap-1.5 p-3",children:[s,r.jsxs("div",{className:"flex min-w-0 flex-1 flex-col gap-1.5",children:[n,r.jsxs("div",{className:"grid min-h-0 flex-1 grid-cols-5 gap-1.5",children:[i,r.jsxs("div",{className:"col-span-2 grid grid-rows-2 gap-1.5",children:[r.jsx("div",{className:ie("rounded-md",fn),style:{animation:"vm-breathe 3s ease-in-out 1.2s infinite"}}),r.jsx("div",{className:ie("rounded-md",fn),style:{animation:"vm-breathe 3s ease-in-out 1.6s infinite"}})]})]})]})]})]}),t[4]=o):o=t[4],o}function XA(){const t=B.c(2);let e;t[0]===Symbol.for("react.memo_cache_sentinel")?(e=r.jsx(Cc,{}),t[0]=e):e=t[0];let s;return t[1]===Symbol.for("react.memo_cache_sentinel")?(s=r.jsxs("div",{className:"flex h-full flex-col",children:[e,r.jsx("div",{className:"relative flex flex-1 items-center justify-center px-8 py-5",children:r.jsx("div",{className:"grid w-full gap-2",style:{gridTemplateColumns:"repeat(7, minmax(0, 1fr))"},children:HA.map(QA)})})]}),t[1]=s):s=t[1],s}function QA(t,e){return r.jsx("div",{className:ie("aspect-square rounded-md",WA[e]?"bg-chart-2/70":Ws),style:{animation:`vm-pulse-soft 2.2s ease-in-out ${t}s infinite`}},e)}function ZA(){const t=B.c(11);let e;t[0]===Symbol.for("react.memo_cache_sentinel")?(e=r.jsx(Cc,{showUrl:!0}),t[0]=e):e=t[0];let s,n,i,o,a;t[1]===Symbol.for("react.memo_cache_sentinel")?(s=r.jsx("div",{className:"mb-2 h-5 rounded-md bg-chart-1/[0.10]"}),n=r.jsx("div",{className:ie("h-1.5 w-[70%] rounded-sm",Ws)}),i=r.jsx("div",{className:ie("h-1.5 w-[55%] rounded-sm",Ws)}),o=r.jsx("div",{className:ie("h-1.5 w-[80%] rounded-sm",Ws)}),a=r.jsx("div",{className:ie("h-1.5 w-[50%] rounded-sm",Ws)}),t[1]=s,t[2]=n,t[3]=i,t[4]=o,t[5]=a):(s=t[1],n=t[2],i=t[3],o=t[4],a=t[5]);let l;t[6]===Symbol.for("react.memo_cache_sentinel")?(l=r.jsxs("div",{className:"flex w-[18%] shrink-0 flex-col gap-1.5 bg-chart-1/[0.05] p-2.5",children:[s,n,i,o,a,r.jsx("div",{className:"mt-auto",children:r.jsx("div",{className:ie("h-4 rounded-md",Ws)})})]}),t[6]=l):l=t[6];let c;t[7]===Symbol.for("react.memo_cache_sentinel")?(c=r.jsx("div",{className:"relative h-[42%] shrink-0 overflow-hidden bg-chart-1/[0.10]",children:r.jsxs("div",{className:"absolute right-3 bottom-3 left-3 space-y-1.5",children:[r.jsx("div",{className:"h-3 w-[35%] rounded-sm bg-chart-1/[0.15]"}),r.jsx("div",{className:ie("h-1.5 w-[55%] rounded-sm",fn)})]})}),t[7]=c):c=t[7];let d;t[8]===Symbol.for("react.memo_cache_sentinel")?(d=r.jsxs("div",{className:"flex shrink-0 gap-1.5",children:[r.jsx("div",{className:"h-4 w-12 rounded-full bg-chart-1/[0.12]"}),r.jsx("div",{className:ie("h-4 w-10 rounded-full",fn)}),r.jsx("div",{className:ie("h-4 w-14 rounded-full",fn)})]}),t[8]=d):d=t[8];let h;t[9]===Symbol.for("react.memo_cache_sentinel")?(h=r.jsxs("div",{className:ie("col-span-3 flex flex-col justify-end gap-1 rounded-md p-2",fn),children:[r.jsx("div",{className:ie("h-1.5 w-[50%] rounded-sm",Ws)}),r.jsx("div",{className:ie("h-1 w-[75%] rounded-sm",Ws)})]}),t[9]=h):h=t[9];let u;return t[10]===Symbol.for("react.memo_cache_sentinel")?(u=r.jsxs("div",{className:"flex h-full flex-col",children:[e,r.jsxs("div",{className:"flex min-h-0 flex-1",children:[l,r.jsxs("div",{className:"flex min-w-0 flex-1 flex-col",children:[c,r.jsxs("div",{className:"flex min-h-0 flex-1 flex-col gap-2.5 p-3",children:[d,r.jsxs("div",{className:"grid min-h-0 flex-1 grid-cols-5 gap-2",children:[h,r.jsxs("div",{className:"col-span-2 grid grid-rows-2 gap-2",children:[r.jsx("div",{className:ie("rounded-md",fn)}),r.jsx("div",{className:ie("rounded-md",fn)})]})]})]})]})]})]}),t[10]=u):u=t[10],u}function gi(t){const e=B.c(71),s=re();if(t.kind==="othersThread"){let f;e[0]===Symbol.for("react.memo_cache_sentinel")?(f=r.jsx(nc,{className:"size-12 text-muted-foreground"}),e[0]=f):f=e[0];let m;e[1]!==s?(m=s("sandbox.stateCard.othersThreadTitle"),e[1]=s,e[2]=m):m=e[2];let p;e[3]!==m?(p=r.jsx("h3",{className:"text-lg font-medium",children:m}),e[3]=m,e[4]=p):p=e[4];let g;e[5]!==t.label||e[6]!==s?(g=s("sandbox.stateCard.othersThreadMessage",{label:t.label}),e[5]=t.label,e[6]=s,e[7]=g):g=e[7];let x;e[8]!==g?(x=r.jsx("p",{className:"max-w-sm text-sm text-muted-foreground",children:g}),e[8]=g,e[9]=x):x=e[9];const v=t.onContinue;let b;e[10]===Symbol.for("react.memo_cache_sentinel")?(b=r.jsx(x9,{className:"size-4"}),e[10]=b):b=e[10];let _;e[11]!==s?(_=s("sandbox.stateCard.othersThreadContinue"),e[11]=s,e[12]=_):_=e[12];let y;e[13]!==t.onContinue||e[14]!==_?(y=r.jsxs(le,{variant:"outline",onClick:v,children:[b," ",_]}),e[13]=t.onContinue,e[14]=_,e[15]=y):y=e[15];const L=t.onStartNewThread;let w;e[16]===Symbol.for("react.memo_cache_sentinel")?(w=r.jsx(kt,{className:"size-4"}),e[16]=w):w=e[16];let j;e[17]!==s?(j=s("sandbox.stateCard.othersThreadNewChat"),e[17]=s,e[18]=j):j=e[18];let S;e[19]!==t.onStartNewThread||e[20]!==j?(S=r.jsxs(le,{onClick:L,children:[w," ",j]}),e[19]=t.onStartNewThread,e[20]=j,e[21]=S):S=e[21];let C;e[22]!==S||e[23]!==y?(C=r.jsxs("div",{className:"mt-2 flex items-center gap-2",children:[y,S]}),e[22]=S,e[23]=y,e[24]=C):C=e[24];let N;return e[25]!==C||e[26]!==p||e[27]!==x?(N=r.jsx("div",{className:"flex h-full w-full items-center justify-center bg-background p-6",children:r.jsxs("div",{className:"flex w-full max-w-md flex-col items-center gap-4 text-center",children:[f,p,x,C]})}),e[25]=C,e[26]=p,e[27]=x,e[28]=N):N=e[28],N}if(t.kind==="starting"){let f;return e[29]!==t.claimPhase||e[30]!==t.progress?(f=r.jsx("div",{className:"flex h-full w-full items-center justify-center bg-background p-6",children:r.jsx(qA,{progress:t.progress,claimPhase:t.claimPhase})}),e[29]=t.claimPhase,e[30]=t.progress,e[31]=f):f=e[31],f}if(t.kind==="errored"){const f=t.error.code===cp.githubNotAuthenticated;let m;e[32]===Symbol.for("react.memo_cache_sentinel")?(m=r.jsx(Sr,{className:"size-12 text-destructive"}),e[32]=m):m=e[32];let p;e[33]===Symbol.for("react.memo_cache_sentinel")?(p=r.jsx("h3",{className:"text-lg font-medium",children:bf("errored")}),e[33]=p):p=e[33];let g;e[34]!==f||e[35]!==t.error.message||e[36]!==s?(g=f?s("sandbox.stateCard.githubNotAuthenticatedMessage"):t.error.message,e[34]=f,e[35]=t.error.message,e[36]=s,e[37]=g):g=e[37];let x;e[38]!==g?(x=r.jsx("p",{className:"max-w-sm text-sm text-muted-foreground",children:g}),e[38]=g,e[39]=x):x=e[39];let v;e[40]!==f||e[41]!==t.connectionsHref||e[42]!==s?(v=f&&t.connectionsHref&&r.jsx(le,{asChild:!0,children:r.jsx("a",{href:t.connectionsHref,children:s("sandbox.stateCard.reconnectGithub")})}),e[40]=f,e[41]=t.connectionsHref,e[42]=s,e[43]=v):v=e[43];const b=t.onRetry;let _;e[44]===Symbol.for("react.memo_cache_sentinel")?(_=r.jsx(dr,{className:"size-4"}),e[44]=_):_=e[44];let y;e[45]!==s?(y=s("sandbox.stateCard.retry"),e[45]=s,e[46]=y):y=e[46];let L;e[47]!==t.onRetry||e[48]!==y?(L=r.jsxs(le,{variant:"outline",onClick:b,children:[_," ",y]}),e[47]=t.onRetry,e[48]=y,e[49]=L):L=e[49];let w;e[50]!==v||e[51]!==L?(w=r.jsxs("div",{className:"mt-2 flex items-center gap-2",children:[v,L]}),e[50]=v,e[51]=L,e[52]=w):w=e[52];let j;return e[53]!==x||e[54]!==w?(j=r.jsx("div",{className:"flex h-full w-full items-center justify-center bg-background p-6",children:r.jsxs("div",{className:"flex w-full max-w-md flex-col items-center gap-4 text-center",children:[m,p,x,w]})}),e[53]=x,e[54]=w,e[55]=j):j=e[55],j}let n;e[56]===Symbol.for("react.memo_cache_sentinel")?(n=r.jsx(t6,{className:"size-12 text-blue-500"}),e[56]=n):n=e[56];let i;e[57]===Symbol.for("react.memo_cache_sentinel")?(i=r.jsx("h3",{className:"text-lg font-medium",children:bf("suspended")}),e[57]=i):i=e[57];let o;e[58]!==s?(o=s("sandbox.stateCard.resumeToContinue"),e[58]=s,e[59]=o):o=e[59];let a;e[60]!==o?(a=r.jsx("p",{className:"max-w-sm text-sm text-muted-foreground",children:o}),e[60]=o,e[61]=a):a=e[61];const l=t.onResume;let c;e[62]===Symbol.for("react.memo_cache_sentinel")?(c=r.jsx(Vi,{className:"size-4"}),e[62]=c):c=e[62];let d;e[63]!==s?(d=s("sandbox.stateCard.resume"),e[63]=s,e[64]=d):d=e[64];let h;e[65]!==t.onResume||e[66]!==d?(h=r.jsxs(le,{onClick:l,className:"mt-2",children:[c," ",d]}),e[65]=t.onResume,e[66]=d,e[67]=h):h=e[67];let u;return e[68]!==a||e[69]!==h?(u=r.jsx("div",{className:"flex h-full w-full items-center justify-center bg-background p-6",children:r.jsxs("div",{className:"flex w-full max-w-md flex-col items-center gap-4 text-center",children:[n,i,a,h]})}),e[68]=a,e[69]=h,e[70]=u):u=e[70],u}function Og(t,e,s){return`deco:preview:last-page:${t}:${e}:${s}`}function eE(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[i,o]of Object.entries(e.params))typeof o=="string"&&(n[i]=o);return{path:e.path,pageKey:s,params:n}}catch{return null}}function $g(t){try{return eE(localStorage.getItem(t))}catch{return null}}function tE(t,e){try{localStorage.setItem(t,JSON.stringify(e))}catch{}}function Il(t,e){const n=e.replace(/\\/g,"/").replace(/^(?!\/)/,"/").split("/").map(i=>encodeURIComponent(i).replace(/%3A/gi,":")).join("/");return`${t}://file${n}?windowId=_blank`}const _f="site-links",sE=/details?page|\bpdp\b/i,nE=/listingpage|\bplp\b/i;function iE(t,e,s){const n=new Set;for(const l of s)sE.test(l)&&n.add("product"),nE.test(l)&&n.add("category");const i=wl(Yn(t)),o=i[i.length-1],a=i[i.length-2];return o?.type==="text"&&o.text==="/p"&&a?.type==="param"&&a.name===e&&n.add("product"),e==="*"&&i.some(l=>l.type==="param"&&l.name==="*")&&n.add("category"),n}const rE=["rosa","preto","pink","black"];function Na(t,e){const s=e.trim();return s?t(s):rE.flatMap(n=>t(n))}function oE(t,e){const s=e.trim(),n=[];/^\d+$/.test(s)&&n.push({resolveType:t,props:{ids:[s]}});const o=s.includes("-")&&!/\s/.test(s)?s.replace(/-+/g," "):s;return n.push({resolveType:t,props:{query:o,count:10}}),n}const Bg=new Set(["vtex","shopify","shopify-mcp","magento","wake","linx","linx-impulse","nuvemshop","vnda","wap","salesforce"]);function gu(t){return t.split("/")[0]??""}function aE(t){const e=new Set;for(const s of t){const n=gu(s);Bg.has(n)&&e.add(n)}return e}function lE(t,e){const s=gu(t);return!Bg.has(s)||e.size===0?!0:e.has(s)}const cE=[{kind:"product",test:t=>t==="vtex/loaders/intelligentSearch/productList.ts",clientFilter:!1,buildRequests:(t,e)=>Na(s=>oE(t,s),e),optionsFromPayload:Ta},{kind:"product",test:t=>/magento\/.*products?\/list(\.tsx?)?$/i.test(t),clientFilter:!1,buildRequests:(t,e)=>Na(s=>[{resolveType:t,props:{props:{search:s,pageSize:10,currentPage:1}}}],e),optionsFromPayload:Ta},{kind:"product",test:t=>/algolia\/.*products?\/(list|suggestions)(\.tsx?)?$/i.test(t),clientFilter:!1,buildRequests:(t,e)=>Na(s=>[{resolveType:t,props:{term:s,hitsPerPage:10}}],e),optionsFromPayload:Ta},{kind:"product",test:t=>/products?\/list(\.tsx?)?$/i.test(t),clientFilter:!1,buildRequests:(t,e)=>Na(s=>[{resolveType:t,props:{query:s,term:s,count:10,hitsPerPage:10}}],e),optionsFromPayload:Ta},{kind:"category",test:t=>t==="vtex/loaders/categories/tree.ts"||/categor(y|ies).*tree/i.test(t),clientFilter:!0,buildRequests:t=>[{resolveType:t,props:{}}],optionsFromPayload:gE}];function dE(t,e,s=new Set){const n=[...e],i=l=>{const c=[];for(const d of cE){if(d.kind!==l)continue;const h=n.find(u=>d.test(u)&&lE(u,s));h&&c.push({cand:d,resolveType:h})}return c.find(d=>s.has(gu(d.resolveType)))??c[0]},o=(l,c,d)=>({kind:l.kind,id:`${l.kind}:${c}`,resolveType:c,clientFilter:l.clientFilter,isFallback:d,buildRequests:h=>l.buildRequests(c,h),optionsFromPayload:l.optionsFromPayload}),a=[];for(const l of["product","category"]){if(!t.has(l))continue;const c=i(l);c&&a.push(o(c.cand,c.resolveType,!1))}return t.size>0&&a.push(uE(t.has("category")?"category":"product")),a}function uE(t){return{kind:t,id:_f,resolveType:_f,clientFilter:!0,isFallback:!0,homepageLinks:!0,optionsFromPayload:(e,s)=>_E(e,s)}}function xi(t){return t&&typeof t=="object"&&!Array.isArray(t)?t:null}function hE(t,e,s){const n=new Set,i=new Set,o=a=>{if(Array.isArray(a)){for(const d of a)o(d);return}const l=xi(a);if(!l)return;const c=l.__resolveType;if(typeof c=="string"){if(s(c))n.add(c);else if(c in e&&!i.has(c)){i.add(c);const d=xi(e[c])?.__resolveType;typeof d=="string"&&s(d)&&n.add(c),o(e[c])}}for(const d of Object.values(l))o(d)};return o(t),n}function Fg(t){const e=new Set,s=[];for(const n of t)for(const i of n)e.has(i.value)||(e.add(i.value),s.push(i));return s}function zg(t){try{return decodeURIComponent(t)}catch{return t}}function fE(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function mE(t){const e=[];let s="^";for(const n of t)n.type==="text"?s+=fE(n.text):(e.push(n.name),s+=n.name==="*"?"(.+)":"([^/]+)");return{pattern:new RegExp(`${s}$`),order:e}}function Kg(t,e,s){if(typeof t!="string"||!t)return null;let n;try{n=new URL(t,"https://placeholder.invalid").pathname}catch{return null}n=n.replace(/\/+$/,"");const i=wl(Yn(e)),{pattern:o,order:a}=mE(i),l=a.indexOf(s);if(l===-1)return null;const c=n.match(o);if(!c)return null;const d=c[l+1]?.replace(/^\/+|\/+$/g,"");return d?zg(d):null}function Ta(t,e){const s=xi(t),n=Array.isArray(t)?t:Array.isArray(s?.products)?s.products:Array.isArray(s?.list)?s.list:[],i=[],o=new Set;for(const a of n){const l=xi(a);if(!l)continue;const c=Kg(l.url,e.template,e.paramName);if(!c||o.has(c))continue;o.add(c);const d=xi(l.isVariantOf),h=typeof d?.name=="string"&&d.name||typeof l.name=="string"&&l.name||c,u=Array.isArray(l.image)?xi(l.image[0]):null,f=typeof u?.url=="string"?u.url:void 0;i.push({value:c,label:h,image:f})}return i}function pE(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?zg(s):null}function gE(t){const e=[],s=new Set,n=(i,o)=>{const a=xi(i);if(!a)return;const l=typeof a.name=="string"&&a.name?a.name:"",c=l?[...o,l]:o,d=pE(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 i of t)n(i,[]);return e}const xE=new Set(["login","logout","signin","sign-in","signup","sign-up","register","account","myaccount","my-account","minha-conta","conta","cart","carrinho","checkout","wishlist","favoritos","favorites","orders","pedidos","help","hc","sac","atendimento","contato","contact","institucional","newsletter","customer","sales","catalogsearch","search","busca","privacy-policy-cookie-restriction-mode"]);function vE(t){return(t.split("/").filter(Boolean).pop()??t).replace(/[-_]+/g," ").replace(/\s+/g," ").trim().replace(/\b\w/g,s=>s.toUpperCase())}function bE(t){if(typeof t!="string"||!t)return[];const e=[],s=/<a\b[^>]*?\bhref="([^"]+)"[^>]*>([\s\S]*?)<\/a>/gi;let n,i=0;for(;(n=s.exec(t))!==null&&i++<5e3;){const o=n[1]??"",a=(n[2]??"").replace(/<[^>]*>/g," ").replace(/\s+/g," ").trim();e.push({href:o,text:a})}return e}function yE(t){if(typeof t!="string"||!t)return[];const e=[],s=new Set,n=/"@type":"Product"[\s\S]{0,600}?(?:"url"|\burl):"([^"]+)"[\s\S]{0,300}?(?:"name"|\bname):"([^"]+)"/g,i=/(?:"image"|\bimage):\s*\[\s*\{[\s\S]{0,400}?(?:"url"|\burl):"([^"]+)"/;let o,a=0;for(;(o=n.exec(t))!==null&&a++<3e3;){const l=(o[1]??"").replace(/\\\//g,"/");if(!l||s.has(l))continue;s.add(l);const c=t.slice(o.index,o.index+900).match(i)?.[1]?.replace(/\\\//g,"/");e.push({url:l,name:o[2]??"",image:c||void 0})}return e}function _E(t,e){const s=[],n=new Set,i=(o,a,l,c)=>{if(s.length>=200)return;const d=Kg(o,e.template,e.paramName);!d||n.has(d)||e.paramName==="*"&&/(^|\/)p$/.test(d)||l==="category"&&xE.has(d.split("/")[0]??"")||(n.add(d),s.push({value:d,label:a&&a.length<=80?a:vE(d),kind:l,image:c}))};for(const{url:o,name:a,image:l}of yE(t))i(o,a,"product",l);for(const{href:o,text:a}of bE(t))o.startsWith("/")&&!o.startsWith("//")&&i(o,a,"category");return s}function qr(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 Lf=3e4;function Ug(t){return`/api/${t.orgSlug}/sandbox/${encodeURIComponent(t.virtualMcpId)}/${encodeURIComponent(t.branch)}/preview-invoke`}function LE(t,e){return`${`/api/${t.orgSlug}/sandbox/${encodeURIComponent(t.virtualMcpId)}/${encodeURIComponent(t.branch)}/preview-fetch`}?path=${encodeURIComponent(e)}`}function SE(t,e,s,n){const i=new URL(`/deco/invoke/${e}`,t);return i.searchParams.set("__cb",n.toString(36)),i.searchParams.set("__decoFBT","0"),i.searchParams.set("__d",`run-${n.toString(36)}`),i.searchParams.set("props",btoa(encodeURIComponent(JSON.stringify(s)))),i.href}async function wE(t,{resolveType:e,props:s}){let n;try{n=await fetch(Ug(t),{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({__resolveType:e,...s}),signal:AbortSignal.timeout(Lf)})}catch(l){throw l instanceof DOMException&&l.name==="TimeoutError"?new Error(`Run timed out after ${Lf/1e3}s — the block may be slow or the preview unresponsive.`):l}const i=await n.text();let o=null,a=!1;try{o=i?JSON.parse(i):null,a=!0}catch{}if(!n.ok){const l=a&&o&&typeof o=="object"&&"error"in o&&typeof o.error=="string"?o.error:i||`Run failed (${n.status})`;throw new Error(l)}return a?o:i}function jE(t){const e=B.c(2);let s;return e[0]!==t?(s={mutationFn:n=>wE(t,n)},e[0]=t,e[1]=s):s=e[1],Ys(s)}const Hg=1e4;function CE(t){return{product:{noun:t("sandbox.pathParamPickerChip.kindProductNoun"),heading:t("sandbox.pathParamPickerChip.kindProductHeading")},category:{noun:t("sandbox.pathParamPickerChip.kindCategoryNoun"),heading:t("sandbox.pathParamPickerChip.kindCategoryHeading")}}}async function kE(t,{resolveType:e,props:s}){const n=await fetch(Ug(t),{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({__resolveType:e,...s}),signal:AbortSignal.timeout(Hg)});if(!n.ok)throw new Error(`Failed to fetch options: ${n.status}`);return n.json()}async function Sf(t,e){const s=await fetch(LE(t,e),{signal:AbortSignal.timeout(Hg)});if(!s.ok)throw new Error(`Failed to fetch page: ${s.status}`);return s.text()}async function VE(t,e,s){const n=e.optionsFromPayload(await Sf(t,"/"),s),i=n.find(a=>a.kind==="category");if(!i)return n;const o=Hn(s.template,{[s.paramName]:i.value});if(o==="/")return n;try{const a=e.optionsFromPayload(await Sf(t,o),s).filter(l=>l.kind==="product");return Fg([n,a])}catch{return n}}function NE(t,e,s){return at.sandboxInvoke(`${t.orgSlug}/${t.virtualMcpId}/${t.branch}`,`path-param-${e.id}:${e.clientFilter?"":s}`)}async function TE(t,e,s,n){if(e.homepageLinks)return VE(t,e,n);const i=e.buildRequests?.(s)??[];if(i.length===0)return[];const o=await Promise.allSettled(i.map(l=>kE(t,l))),a=o.filter(l=>l.status==="fulfilled").map(l=>l.value);if(a.length===0){const l=o.find(c=>c.status==="rejected");throw l?l.reason:new Error("Failed to fetch options")}return Fg(a.map(l=>e.optionsFromPayload(l,n)))}function s0(t,e,s,n,i){return{queryKey:NE(t,e,s),queryFn:()=>TE(t,e,s,n),enabled:i,staleTime:6e4,retry:1}}function Gr(t){const e=B.c(16),{heading:s,iconKind:n,options:i,template:o,paramName:a,keyPrefix:l,onSelect:c}=t;if(i.length===0)return null;let d;if(e[0]!==n||e[1]!==l||e[2]!==c||e[3]!==i||e[4]!==a||e[5]!==o){let u;e[7]!==n||e[8]!==l||e[9]!==c||e[10]!==a||e[11]!==o?(u=f=>r.jsxs(Vs,{value:`${l}:${f.value}`,className:"gap-3 py-2",onSelect:()=>c(f.value),children:[n==="product"&&r.jsx("span",{className:"flex h-10 w-10 shrink-0 items-center justify-center overflow-hidden rounded-md border border-border bg-muted",children:f.image?r.jsx("img",{src:f.image,alt:"",referrerPolicy:"no-referrer",className:"h-full w-full object-cover"}):r.jsx(i9,{size:14,className:"text-muted-foreground"})}),r.jsxs("span",{className:"min-w-0 flex-1",children:[r.jsx("span",{className:"block truncate text-sm",children:f.label}),r.jsx("span",{className:"block truncate text-xs text-muted-foreground",children:Hn(o,{[a]:f.value})})]})]},`${l}:${f.value}`),e[7]=n,e[8]=l,e[9]=c,e[10]=a,e[11]=o,e[12]=u):u=e[12],d=i.map(u),e[0]=n,e[1]=l,e[2]=c,e[3]=i,e[4]=a,e[5]=o,e[6]=d}else d=e[6];let h;return e[13]!==s||e[14]!==d?(h=r.jsx(Ms,{heading:s,children:d}),e[13]=s,e[14]=d,e[15]=h):h=e[15],h}function wf(t){const e=B.c(2),{text:s}=t;let n;return e[0]!==s?(n=r.jsx("div",{className:"px-2 py-2 text-xs text-muted-foreground",children:s}),e[0]=s,e[1]=n):n=e[1],n}function AE(t){const e=B.c(89),{sources:s,template:n,paramName:i,value:o,sandboxRef:a,onCommit:l}=t,c=re(),[d,h]=A.useState(!1),[u,f]=A.useState(""),[m,p]=A.useState(""),g=A.useRef(null),x=i==="*"?"path":`:${i}`,v=CE(c),_=[...new Set(s.map(ye=>v[ye.kind].noun))].join(" or ");let y;e[0]!==c||e[1]!==_?(y=c("sandbox.pathParamPickerChip.searchPlaceholder",{options:_}),e[0]=c,e[1]=_,e[2]=y):y=e[2];const L=y,w={template:n,paramName:i};let j;e[3]!==u?(j=(ye,je)=>({source:ye,query:je,options:ye.clientFilter?qr(je.data??[],u):je.data??[]}),e[3]=u,e[4]=j):j=e[4];const S=j,C=s.filter($E),N=s.filter(OE),V=Md({queries:C.map(ye=>s0(a,ye,m,w,d))});let E;e[5]!==V||e[6]!==S?(E=(ye,je)=>S(ye,V[je]),e[5]=V,e[6]=S,e[7]=E):E=e[7];const T=C.map(E),k=T.length===0||T.every(ME),R=Md({queries:N.map(ye=>s0(a,ye,m,w,d&&k))});let P;e[8]!==R||e[9]!==S?(P=(ye,je)=>S(ye,R[je]),e[8]=R,e[9]=S,e[10]=P):P=e[10];const D=N.map(P),I=k?D:T,M=I.length===1&&I[0]?.source.homepageLinks?I[0]:null,F=M&&!M.query.isLoading&&!M.query.isError?M?.query.data??[]:[],$=qr(F.filter(IE),u),z=qr(F.filter(DE),u),K=$.length>0&&z.length>0;let X,J,H,W,U,Q,q,Z,Y,ee,G,te,se,ne,de,xe,he,ce;if(e[11]!==l||e[12]!==d||e[13]!==x||e[14]!==i||e[15]!==L||e[16]!==u||e[17]!==c||e[18]!==n||e[19]!==o){const ye=Ce=>{h(Ce),g.current&&clearTimeout(g.current),f(Ce?o:""),p(Ce?o:"")};let je;e[38]===Symbol.for("react.memo_cache_sentinel")?(je=Ce=>{f(Ce),g.current&&clearTimeout(g.current),g.current=setTimeout(()=>{p(Ce)},300)},e[38]=je):je=e[38];const Pe=je;U=Ce=>{l(Ce),ye(!1)};const Ee=Fp(u),be=Hn(n,{[i]:Ee});let Ve;e[39]!==x||e[40]!==c?(Ve=c("sandbox.pathParamPickerChip.buttonTitle",{paramLabel:x}),e[39]=x,e[40]=c,e[41]=Ve):Ve=e[41],ne=r.jsx("button",{type:"button",title:Ve,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:Ce=>{Ce.stopPropagation(),ye(!0)},children:o||x}),W=ts,te=d,se=ye,H=es,Z="flex h-[85svh] flex-col gap-0 overflow-hidden p-0 sm:h-[520px] sm:max-w-[560px]",Y=RE;let Re;e[42]!==x||e[43]!==c?(Re=c("sandbox.pathParamPickerChip.pickValueTitle",{paramLabel:x}),e[42]=x,e[43]=c,e[44]=Re):Re=e[44],e[45]!==Re?(ee=r.jsx(ms,{className:"sr-only",children:r.jsx(ps,{children:Re})}),e[45]=Re,e[46]=ee):ee=e[46];let Le;e[47]===Symbol.for("react.memo_cache_sentinel")?(Le=r.jsx(i9,{size:16,className:"shrink-0 text-foreground"}),e[47]=Le):Le=e[47];let ve;e[48]!==c?(ve=c("sandbox.pathParamPickerChip.pickValueHeading"),e[48]=c,e[49]=ve):ve=e[49];let Se;e[50]!==x?(Se=r.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:x}),e[50]=x,e[51]=Se):Se=e[51],e[52]!==ve||e[53]!==Se?(G=r.jsxs("div",{className:"flex h-12 shrink-0 items-center gap-3 border-b border-border px-4",children:[Le,r.jsxs("span",{className:"text-sm font-medium text-foreground",children:[ve," ",Se]})]}),e[52]=ve,e[53]=Se,e[54]=G):G=e[54],J=Tr,ce=!1,Q="min-h-0 flex-1",e[55]!==L||e[56]!==u?(q=r.jsx(Bi,{autoFocus:!0,placeholder:L,value:u,onValueChange:Pe}),e[55]=L,e[56]=u,e[57]=q):q=e[57],X=Fi,de="flex max-h-none min-h-0 flex-1 flex-col overflow-hidden";let Be;e[58]!==c?(Be=c("sandbox.pathParamPickerChip.noResults"),e[58]=c,e[59]=Be):Be=e[59],e[60]!==Be?(xe=r.jsx(Zn,{children:Be}),e[60]=Be,e[61]=xe):xe=e[61],he=Ee&&r.jsx(Ms,{className:"shrink-0",children:r.jsxs(Vs,{value:`__raw__:${Ee}`,className:"gap-3 py-2",onSelect:()=>U(Ee),children:[r.jsx("span",{className:"flex h-10 w-10 shrink-0 items-center justify-center rounded-md border border-dashed border-border bg-muted",children:r.jsx(kr,{size:14,className:"text-muted-foreground"})}),r.jsxs("span",{className:"min-w-0 flex-1",children:[r.jsx("span",{className:"block truncate text-sm",children:c("sandbox.pathParamPickerChip.useRawValue",{rawTerm:Ee,paramLabel:x})}),r.jsx("span",{className:"block truncate text-xs text-muted-foreground",children:be})]})]})}),e[11]=l,e[12]=d,e[13]=x,e[14]=i,e[15]=L,e[16]=u,e[17]=c,e[18]=n,e[19]=o,e[20]=X,e[21]=J,e[22]=H,e[23]=W,e[24]=U,e[25]=Q,e[26]=q,e[27]=Z,e[28]=Y,e[29]=ee,e[30]=G,e[31]=te,e[32]=se,e[33]=ne,e[34]=de,e[35]=xe,e[36]=he,e[37]=ce}else X=e[20],J=e[21],H=e[22],W=e[23],U=e[24],Q=e[25],q=e[26],Z=e[27],Y=e[28],ee=e[29],G=e[30],te=e[31],se=e[32],ne=e[33],de=e[34],xe=e[35],he=e[36],ce=e[37];const oe=K?r.jsxs("div",{className:"flex min-h-0 flex-1",children:[r.jsx("div",{className:"min-w-0 flex-1 overflow-y-auto border-r border-border",children:r.jsx(Gr,{heading:v.category.heading,iconKind:"category",options:$,template:n,paramName:i,keyPrefix:`${M?.source.id}:cat`,onSelect:U})}),r.jsx("div",{className:"min-w-0 flex-1 overflow-y-auto",children:r.jsx(Gr,{heading:v.product.heading,iconKind:"product",options:z,template:n,paramName:i,keyPrefix:`${M?.source.id}:prod`,onSelect:U})})]}):r.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto",children:I.map(ye=>{const{source:je,query:Pe,options:Ee}=ye,{noun:be}=v[je.kind];if(Pe.isLoading)return r.jsx(wf,{text:c("sandbox.pathParamPickerChip.loading",{noun:be})},je.id);if(Pe.isError)return r.jsx(wf,{text:c("sandbox.pathParamPickerChip.couldNotLoad")},je.id);if(je.homepageLinks){const Ve=Pe.data??[];return r.jsxs(A.Fragment,{children:[r.jsx(Gr,{heading:v.category.heading,iconKind:"category",options:qr(Ve.filter(PE),u),template:n,paramName:i,keyPrefix:`${je.id}:cat`,onSelect:U}),r.jsx(Gr,{heading:v.product.heading,iconKind:"product",options:qr(Ve.filter(EE),u),template:n,paramName:i,keyPrefix:`${je.id}:prod`,onSelect:U})]},je.id)}return r.jsx(Gr,{heading:I.length>1?v[je.kind].heading:void 0,iconKind:je.kind,options:Ee,template:n,paramName:i,keyPrefix:je.id,onSelect:U},je.id)})});let me;e[62]!==X||e[63]!==oe||e[64]!==de||e[65]!==xe||e[66]!==he?(me=r.jsxs(X,{className:de,children:[xe,he,oe]}),e[62]=X,e[63]=oe,e[64]=de,e[65]=xe,e[66]=he,e[67]=me):me=e[67];let pe;e[68]!==J||e[69]!==Q||e[70]!==q||e[71]!==me||e[72]!==ce?(pe=r.jsxs(J,{shouldFilter:ce,className:Q,children:[q,me]}),e[68]=J,e[69]=Q,e[70]=q,e[71]=me,e[72]=ce,e[73]=pe):pe=e[73];let we;e[74]!==H||e[75]!==Z||e[76]!==Y||e[77]!==ee||e[78]!==G||e[79]!==pe?(we=r.jsxs(H,{className:Z,onClick:Y,children:[ee,G,pe]}),e[74]=H,e[75]=Z,e[76]=Y,e[77]=ee,e[78]=G,e[79]=pe,e[80]=we):we=e[80];let Ne;e[81]!==W||e[82]!==te||e[83]!==se||e[84]!==we?(Ne=r.jsx(W,{open:te,onOpenChange:se,children:we}),e[81]=W,e[82]=te,e[83]=se,e[84]=we,e[85]=Ne):Ne=e[85];let Oe;return e[86]!==ne||e[87]!==Ne?(Oe=r.jsxs(r.Fragment,{children:[ne,Ne]}),e[86]=ne,e[87]=Ne,e[88]=Oe):Oe=e[88],Oe}function EE(t){return t.kind==="product"}function PE(t){return t.kind!=="product"}function RE(t){return t.stopPropagation()}function DE(t){return t.kind==="product"}function IE(t){return t.kind!=="product"}function ME(t){return!t.query.isLoading&&(t.query.isError||t.options.length===0)}function OE(t){return t.isFallback}function $E(t){return!t.isFallback}function BE(t){const e=B.c(8),{sources:s,template:n,paramName:i,sandboxRef:o,onFill:a}=t;let l,c;if(e[0]!==i||e[1]!==o||e[2]!==s||e[3]!==n){const m={template:n,paramName:i},p=s.filter(FE);c=Md,l=p.map(g=>s0(o,g,"",m,!0)),e[0]=i,e[1]=o,e[2]=s,e[3]=n,e[4]=l,e[5]=c}else l=e[4],c=e[5];let d;e[6]!==l?(d={queries:l},e[6]=l,e[7]=d):d=e[7];const h=c(d),[u,f]=A.useState(!1);if(!u)for(const m of h){if(m.isLoading)break;const p=m.data?.[0];if(p){f(!0),queueMicrotask(()=>a(p.value));break}}return null}function FE(t){return!t.isFallback}function zE(t){const e=B.c(28),{name:s,value:n,onCommit:i}=t,o=re(),[a,l]=A.useState(n),[c,d]=A.useState(!1),h=A.useRef(!1),u=s==="*"?"path":`:${s}`,f=a||u;let m;e[0]!==f?(m=r.jsx("span",{"aria-hidden":!0,className:"invisible whitespace-pre px-1 py-0.5 text-[12px]",children:f}),e[0]=f,e[1]=m):m=e[1];let p;e[2]!==u||e[3]!==o?(p=o("sandbox.preview.valueForParam",{label:u}),e[2]=u,e[3]=o,e[4]=p):p=e[4];let g,x;e[5]===Symbol.for("react.memo_cache_sentinel")?(g=j=>l(j.target.value),x=()=>d(!0),e[5]=g,e[6]=x):(g=e[5],x=e[6]);let v;e[7]!==n?(v=j=>{j.key==="Enter"&&j.currentTarget.blur(),j.key==="Escape"&&(h.current=!0,l(n),j.currentTarget.blur())},e[7]=n,e[8]=v):v=e[8];let b;e[9]!==a||e[10]!==i||e[11]!==n?(b=()=>{if(d(!1),h.current){h.current=!1;return}const j=Fp(a);l(j),j!==n&&i(j)},e[9]=a,e[10]=i,e[11]=n,e[12]=b):b=e[12];let _;e[13]!==a||e[14]!==u||e[15]!==p||e[16]!==v||e[17]!==b?(_=r.jsx("input",{type:"text",value:a,placeholder:u,title:p,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:KE,onChange:g,onFocus:x,onKeyDown:v,onBlur:b}),e[13]=a,e[14]=u,e[15]=p,e[16]=v,e[17]=b,e[18]=_):_=e[18];let y;e[19]!==m||e[20]!==_?(y=r.jsxs("span",{className:"relative inline-flex max-w-64 shrink-0 items-center overflow-hidden",children:[m,_]}),e[19]=m,e[20]=_,e[21]=y):y=e[21];let L;e[22]!==c||e[23]!==o?(L=c&&r.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:[r.jsx(s6,{size:10}),o("sandbox.preview.enterToGo")]}),e[22]=c,e[23]=o,e[24]=L):L=e[24];let w;return e[25]!==y||e[26]!==L?(w=r.jsxs(r.Fragment,{children:[y,L]}),e[25]=y,e[26]=L,e[27]=w):w=e[27],w}function KE(t){return t.stopPropagation()}const UE={loaders:"loader",actions:"action"},Wg=new Set(["workflows"]);function qg(t){return UE[t]}function HE(t,e,s){const n=t.manifest?.blocks??{};for(const[i,o]of Object.entries(n))if(i.includes(s)&&e in o)return!0;return!1}function WE(t,e){const s=new Set,n=t.manifest?.blocks??{};for(const[i,o]of Object.entries(n))if(i.includes(e))for(const a of Object.keys(o))s.add(a);return s}function qE(t,e){return/\.tsx?$/.test(t)?!1:e.has(`${t}.ts`)||e.has(`${t}.tsx`)}function Gg(t,e){const s=t.manifest?.blocks??{},n=[],i=new Set;for(const[o,a]of Object.entries(s))if(o.includes(e))for(const l of Object.keys(a))i.add(l);for(const o of i){if(o.toLowerCase().includes("preview")||qp.has(o)||Wg.has(xu(o))||qE(o,i))continue;const a=ci(o,t);if(a.hidden)continue;const l=a.title&&a.title!==o?a.title:Tt(o);n.push({resolveType:o,title:l})}return n.sort((o,a)=>o.title.localeCompare(a.title))}function jf(t,e){return Gg(t,e).length}function xu(t){return t.startsWith("deco-sites/")?t.split("/")[1]||"site":t.startsWith("$live")||t.startsWith("deco/")?"deco":t.split("/")[0]||"other"}const GE={deco:"Deco",std:"Deco Standard",website:"Website"};function YE(t){return GE[t]??t}function Yg(t){const e=xu(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 JE(t,e,s){const n=[];for(const[i,o]of Object.entries(e)){if(i.includes("/")||dc(i)||!o||typeof o!="object"||Array.isArray(o))continue;const a=o,l=a.__resolveType;typeof l=="string"&&(qp.has(l)||Wg.has(xu(l))||HE(t,l,s)&&n.push({key:i,resolveType:l,title:typeof a.name=="string"&&a.name?a.name:i}))}return n.sort((i,o)=>i.title.localeCompare(o.title))}function Jg(t){const e=B.c(12),{orgSlug:s,virtualMcpId:n,branch:i,enabled:o}=t,a=o===void 0?!0:o;let l;e[0]!==i||e[1]!==s||e[2]!==n?(l=at.sandboxRepoDir(s,n,i),e[0]=i,e[1]=s,e[2]=n,e[3]=l):l=e[3];let c;e[4]!==i||e[5]!==s||e[6]!==n?(c=async()=>{const u=`/api/${s}/sandbox/${encodeURIComponent(n)}/${encodeURIComponent(i)}/config`,f=await fetch(u);return f.ok?(await f.json()).repoDir??null:null},e[4]=i,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],Ft(d).data??null}const XE={target:null,editSeoPageKey:null,variantOverride:null};function QE(t,e){switch(e.type){case"select":return{...t,target:e.target,variantOverride:null};case"edit-seo":return{...t,target:e.target,editSeoPageKey:e.target.key};case"consume-edit-seo":return{...t,editSeoPageKey:null};case"variant-override":return{...t,variantOverride:e.params}}}const Xg=A.createContext(null);function ZE(t){const e=B.c(9),{children:s}=t,[n,i]=A.useReducer(QE,XE);let o,a,l,c;e[0]===Symbol.for("react.memo_cache_sentinel")?(o=u=>i({type:"select",target:u}),a=u=>i({type:"edit-seo",target:u}),l=()=>i({type:"consume-edit-seo"}),c=u=>i({type:"variant-override",params:u}),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,setVariantOverride:c},e[4]=n,e[5]=d):d=e[5];let h;return e[6]!==s||e[7]!==d?(h=r.jsx(Xg,{value:d,children:s}),e[6]=s,e[7]=d,e[8]=h):h=e[8],h}function vu(){const t=A.use(Xg);if(!t)throw new Error("useBlocksPreviewWorkspace must be used inside BlocksPreviewWorkspaceProvider");return t}function eP(t){switch(t){case"clone-failed":case"install-failed":case"start-failed":return"terminal-error";case"idle":case"cloning":return"booting";case"checking-out":case"installing":case"starting":case"running":case"crashed":return"snapshot-readable"}}function tP(t){const e=eP(t.lifecyclePhase);return e==="terminal-error"?{kind:"error",source:"sandbox"}:e==="booting"?{kind:"loading"}:[t.decofile,t.meta].some(i=>i.status==="error"&&!i.hasData&&i.errorStatus===404)?{kind:"empty"}:t.decofile.status==="error"&&!t.decofile.hasData||t.meta.status==="error"&&!t.meta.hasData?t.lifecyclePhase==="running"||t.lifecyclePhase==="crashed"?{kind:"error",source:"data"}:{kind:"loading"}:!t.decofile.hasData||!t.meta.hasData?{kind:"loading"}:t.hasEditableContent?{kind:"content"}:{kind:"empty"}}const sP="https://github.com/decocms/blocks";function nP(){const t=B.c(14),e=re();let s;t[0]===Symbol.for("react.memo_cache_sentinel")?(s=r.jsx(n6,{size:48,className:"text-muted-foreground"}),t[0]=s):s=t[0];let n;t[1]!==e?(n=e("mainPanelTabs.blocksTabStates.emptyStateTitle"),t[1]=e,t[2]=n):n=t[2];let i;t[3]!==e?(i=e("mainPanelTabs.blocksTabStates.emptyStateDescription"),t[3]=e,t[4]=i):i=t[4];let o;t[5]!==e?(o=e("mainPanelTabs.blocksTabStates.setupContentEditing"),t[5]=e,t[6]=o):o=t[6];let a;t[7]===Symbol.for("react.memo_cache_sentinel")?(a=r.jsx(Dn,{size:14}),t[7]=a):a=t[7];let l;t[8]!==o?(l=r.jsx(le,{size:"sm",asChild:!0,children:r.jsxs("a",{href:sP,target:"_blank",rel:"noreferrer",children:[o,a]})}),t[8]=o,t[9]=l):l=t[9];let c;return t[10]!==n||t[11]!==i||t[12]!==l?(c=r.jsx(ki,{className:"h-full w-full",image:s,title:n,description:i,actions:l}),t[10]=n,t[11]=i,t[12]=l,t[13]=c):c=t[13],c}function iP(t){const e=B.c(15),{source:s,onRetry:n}=t,i=re();let o;e[0]!==s||e[1]!==i?(o=i(s==="sandbox"?"mainPanelTabs.blocksTabStates.errorStateSandbox":"mainPanelTabs.blocksTabStates.errorStateData"),e[0]=s,e[1]=i,e[2]=o):o=e[2];const a=o;let l;e[3]===Symbol.for("react.memo_cache_sentinel")?(l=r.jsx(wn,{size:48,className:"text-muted-foreground"}),e[3]=l):l=e[3];let c;e[4]!==i?(c=i("mainPanelTabs.blocksTabStates.errorStateTitle"),e[4]=i,e[5]=c):c=e[5];let d;e[6]!==i?(d=i("mainPanelTabs.blocksTabStates.retry"),e[6]=i,e[7]=d):d=e[7];let h;e[8]!==n||e[9]!==d?(h=r.jsx(le,{variant:"outline",size:"sm",onClick:n,children:d}),e[8]=n,e[9]=d,e[10]=h):h=e[10];let u;return e[11]!==a||e[12]!==c||e[13]!==h?(u=r.jsx(ki,{image:l,title:c,description:a,actions:h}),e[11]=a,e[12]=c,e[13]=h,e[14]=u):u=e[14],u}function Ti(){const t=B.c(1);let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=r.jsx("div",{"data-testid":"main-panel-loading",className:"flex h-full w-full items-center justify-center",children:r.jsx(et,{size:20,className:"animate-spin text-muted-foreground"})}),t[0]=e):e=t[0],e}const rP=A.lazy(()=>$s(()=>import("./sections-editor-B9WQ_qSW.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,149,150,151,152,153,154,155,156])).then(t=>({default:t.SectionsEditor})));function Cf(t){if(t instanceof Error&&"status"in t&&typeof t.status=="number")return t.status}function kf(t){const e=B.c(47),{virtualMcpId:s,externalSelectedIndex:n}=t,i=n===void 0?null:n,{org:o}=Fe(),{currentBranch:a}=Zt(),l=Fs(),c=Er(),d=vu(),h=l.lifecycle.phase==="running",u=c.previewUrl;let f;e[0]!==a||e[1]!==o||e[2]!==u||e[3]!==s?(f=a?{orgSlug:o.slug,virtualMcpId:s,branch:a,previewUrl:u}:null,e[0]=a,e[1]=o,e[2]=u,e[3]=s,e[4]=f):f=e[4];const m=f;let p;e[5]!==h?(p={fetchEnabled:h},e[5]=h,e[6]=p):p=e[6];const g=lc(m,p);let x;e[7]!==h?(x={fetchEnabled:h},e[7]=h,e[8]=x):x=e[8];const v=cc(m,x),b=g.data!==void 0;let _;e[9]!==g.data||e[10]!==g.error||e[11]!==g.status||e[12]!==v.data||e[13]!==v.error||e[14]!==v.status||e[15]!==l.lifecycle.phase||e[16]!==b?(_=tP({lifecyclePhase:l.lifecycle.phase,decofile:{status:g.status,hasData:b,errorStatus:Cf(g.error)},meta:{status:v.status,hasData:v.data!==void 0,errorStatus:Cf(v.error)},hasEditableContent:z9(g.data,v.data)}),e[9]=g.data,e[10]=g.error,e[11]=g.status,e[12]=v.data,e[13]=v.error,e[14]=v.status,e[15]=l.lifecycle.phase,e[16]=b,e[17]=_):_=e[17];const y=_;if(y.kind==="loading"){let I;return e[18]===Symbol.for("react.memo_cache_sentinel")?(I=r.jsx(Ti,{}),e[18]=I):I=e[18],I}if(y.kind==="empty"){let I;return e[19]===Symbol.for("react.memo_cache_sentinel")?(I=r.jsx(nP,{}),e[19]=I):I=e[19],I}if(y.kind==="error"){let I;e[20]!==g||e[21]!==c||e[22]!==v||e[23]!==y.source?(I=()=>{if(y.source==="sandbox"){c.retry();return}Promise.all([g.refetch(),v.refetch()])},e[20]=g,e[21]=c,e[22]=v,e[23]=y.source,e[24]=I):I=e[24];const M=I;let O;return e[25]!==M||e[26]!==y.source?(O=r.jsx(iP,{source:y.source,onRetry:M}),e[25]=M,e[26]=y.source,e[27]=O):O=e[27],O}const L=d.state.target;let w;e[28]!==a||e[29]!==o.slug||e[30]!==L||e[31]!==s?(w=L||!a?null:$g(Og(o.slug,s,a)),e[28]=a,e[29]=o.slug,e[30]=L,e[31]=s,e[32]=w):w=e[32];const j=w;let S="/",C=null,N=null;L?.kind==="page"?(S=L.path,C=L.key):L?.kind==="section"?N=L.key:j&&(S=j.path,C=j.pageKey);const V=C?`page:${C}`:N?`section:${N}`:`path:${S}`;let E;e[33]===Symbol.for("react.memo_cache_sentinel")?(E=r.jsx("div",{className:"h-full flex items-center justify-center",children:r.jsx(et,{size:20,className:"animate-spin text-muted-foreground"})}),e[33]=E):E=e[33];const T=a??"",k=u??void 0,R=N?null:i,P=!!C&&d.state.editSeoPageKey===C;let D;return e[34]!==N||e[35]!==C||e[36]!==S||e[37]!==V||e[38]!==o.slug||e[39]!==k||e[40]!==R||e[41]!==P||e[42]!==T||e[43]!==s||e[44]!==d.consumeEditSeo||e[45]!==d.setVariantOverride?(D=r.jsx("div",{"data-testid":"blocks-panel",className:"h-full min-h-0 overflow-hidden",children:r.jsx(A.Suspense,{fallback:E,children:r.jsx(rP,{orgSlug:o.slug,virtualMcpId:s,branch:T,previewReady:!0,previewUrl:k,currentPath:S,activePageBlockKey:C,activeGlobalBlockKey:N,externalSelectedIndex:R,initialEditSeo:P,onExitSeo:d.consumeEditSeo,onVariantPreviewOverride:d.setVariantOverride},V)})}),e[34]=N,e[35]=C,e[36]=S,e[37]=V,e[38]=o.slug,e[39]=k,e[40]=R,e[41]=P,e[42]=T,e[43]=s,e[44]=d.consumeEditSeo,e[45]=d.setVariantOverride,e[46]=D):D=e[46],D}function oP(t,e){return t===e?"preview":e}const aP="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",cP=A.lazy(()=>$s(()=>import("./page-seo-sheet-D75ZAusC.js"),__vite__mapDeps([157,1,2,62,32,63,50,54,52,53,17,3,19,55,56,57,58,59,60,61,64,65,66,67,68,5,16,20,4,6,7,8,9,10,11,12,13,14,15,18,21,22,23,24,25,26,27,28,29,30,31,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,51,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,104,105,107,108,109,110,111,112,113,114,115,116,117,103,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,149,150,151,152,153,154,155,156])).then(t=>({default:t.SeoSheet}))),Vf=500,dP={mobile:375,tablet:768,desktop:null},rd=["desktop","mobile","tablet"],Nf={mobile:"sandbox.preview.deviceMobile",tablet:"sandbox.preview.deviceTablet",desktop:"sandbox.preview.deviceDesktop"};function uP(t,e){const s=new URL(t,window.location.href);return s.searchParams.set("deviceHint",e),s.href}function Yr(t){if(!t)return null;try{return new URL(t,window.location.href).origin}catch{return null}}function Tf(t,e){try{t.contentWindow?.location.reload()}catch{e&&(t.src=e)}}function hP({virtualMcpId:t}){const e=re(),s=Cr(),n=St(),{currentBranch:i}=Zt(),o=vu(),a=ue=>{n({to:".",search:Ae=>({...Ae,main:ue}),replace:!0})},[l,c]=A.useState("preview"),[d,h]=A.useState("desktop"),[u,f]=A.useState(null),[m,p]=A.useState(null),g=A.useRef(null),x=A.useRef(null),[v,b]=A.useState(!1),[_,y]=A.useState(""),L=A.useRef(null),[w,j]=A.useState(!1),[S,C]=A.useState(),[N,V]=A.useState(null),[E,T]=A.useState(null),[k,R]=A.useState("/"),[P,D]=A.useState(null),[I,M]=A.useState({}),[O,F]=A.useState(!1),$=A.useRef(null),z=()=>{F(!0),$.current&&clearTimeout($.current),$.current=setTimeout(()=>F(!1),15e3)},K=()=>{$.current&&(clearTimeout($.current),$.current=null),F(!1)},[X,J]=A.useState(!1),{org:H}=Fe(),W=Fs(),U=Er(),Q=U.vmEntry,q=U.previewUrl,Z=W.lifecycle.phase,Y=Z==="running",ee=Q?.sandboxProviderKind==="user-desktop",G=Jg({orgSlug:H.slug,virtualMcpId:t??"",branch:i??"",enabled:ee&&Y&&!!t&&!!i}),te=ee?G:null,se=t&&i?{orgSlug:H.slug,virtualMcpId:t,branch:i,previewUrl:q}:null,{data:ne}=lc(se,{fetchEnabled:Y}),{data:de}=cc(se,{fetchEnabled:Y}),xe=t&&i?{orgSlug:H.slug,virtualMcpId:t,branch:i}:null,he=gA(xe),ce=ne?K9(ne).sort((ue,Ae)=>ue.name.localeCompare(Ae.name)):[],oe=ne&&de?U9(ne,de):[],me=Yn,pe=ce.filter(ue=>{if(!_)return!0;const Ae=_.toLowerCase();return ue.name.toLowerCase().includes(Ae)||ue.path.toLowerCase().includes(Ae)}),we=oe.filter(ue=>{if(!_)return!0;const Ae=_.toLowerCase();return ue.name.toLowerCase().includes(Ae)||ue.key.toLowerCase().includes(Ae)||ue.resolveType.toLowerCase().includes(Ae)}),Ne=N?null:Sw(ce,k,P),Oe=N?N.name:Ne?.name,ye=Ne?.key??null,je=Ne?.path??null,Pe=(ye?I[ye]:void 0)??{},Ee=Hn(k,Pe),be={};if(Y&&q&&de&&ne){const ue=WE(de,"loaders"),Ae=ye?ne[ye]:void 0,ct=hE(Ae,ne,xs=>ue.has(xs)),bt=aE(ct);for(const xs of wl(k)){if(xs.type!=="param")continue;const jn=iE(k,xs.name,ct),Xs=dE(jn,ue,bt);Xs.length>0&&(be[xs.name]=Xs)}}const Ve=t&&i?{orgSlug:H.slug,virtualMcpId:t,branch:i}:null,Re=ne&&ye?Pg(ne,ye,0):[],Le=ne?Vg(Re,ne):[],ve=Le.map(ue=>ue.isSavedBlock?ue.label:""),Se=Le.map(ue=>ue.isSavedBlock?"global":ue.isMultivariate?"variant":"normal"),Be=Re.map(ue=>e0(ue,ne??{})),Ce=A.useRef(null),ke=A.useRef(null),ze=W.status.state==="paused",nt=W.phase,pt=Dg({claimPhase:nt,lifecycle:W.lifecycle}),Je=U.previewState,gt=U.userStopped,dt=Je.kind==="starting"||Je.kind==="iframe"&&pt.status==="doing",st=Je.kind==="iframe"?hA(uP(E??new URL(Ee,Je.previewUrl).href,d),o.state.variantOverride??[]):null,ft=t&&i?Og(H.slug,t,i):null,fe=ue=>{ft&&tE(ft,ue)},Me=o.state.target;A.useEffect(()=>{if(!(!Me||!q||!de))if(Me.kind==="page"){const ue=I[Me.key]??{};ke.current=Hn(Me.path,ue),V(null),T(null),D(Me.key),R(Me.path),fe({path:Me.path,pageKey:Me.key,params:ue})}else{const ue=oe.find(Ae=>Ae.key===Me.key);if(ue){ke.current=null;const Ae=zd(de);V(ue),T(xf(q,Ae,ue.key))}}},[Me,q,de,I]),A.useEffect(()=>{!ye||je===null||Me?.kind==="page"&&Me.key===ye&&Me.path===je||o.selectTarget({kind:"page",key:ye,path:je})},[ye,je,Me]);const[Qe,xt]=A.useState(null);if(Je.kind==="iframe"&&Qe!==Je.previewUrl){const ue=Qe!==null;xt(Je.previewUrl);const Ae=ft?$g(ft):null;if(Ae){if(ke.current=Hn(Ae.path,Ae.params),R(Ae.path),D(Ae.pageKey),T(null),V(null),Ae.pageKey&&Object.keys(Ae.params).length>0){const ct=Ae.pageKey;M(bt=>({...bt,[ct]:Ae.params}))}}else ue&&(ke.current=null,R("/"),T(null),D(null),V(null))}Ce.current=st;const ls=!!t&&!!i&&!W.notFound&&!gt&&!ze&&(nt?.kind==="ready"||Z!=="idle"),Vt=Je.kind!=="iframe"&&l==="visual"?"preview":l;A.useEffect(()=>{const ue=Yr(q);if(!ue)return;const Ae=ct=>{if(ct.origin===ue){if(ct.data?.type==="visual-editor::element-clicked"){const bt=bA.safeParse(ct.data.payload);bt.success&&f(bt.data)}else if(ct.data?.type==="cms-editor::section-clicked"){const bt=_A.safeParse(ct.data.payload);bt.success&&p(bt.data.sectionIndex)}}};return window.addEventListener("message",Ae),()=>window.removeEventListener("message",Ae)},[q]),A.useEffect(()=>{if(!v)return;const ue=Ae=>{L.current?.contains(Ae.target)||(b(!1),y(""))};return document.addEventListener("pointerdown",ue),()=>document.removeEventListener("pointerdown",ue)},[v]);const Ut=()=>{const ue=g.current?.contentWindow,Ae=Yr(q);!ue||!Ae||ue.postMessage({type:"visual-editor::activate",script:yA},Ae)},is=()=>{const ue=g.current?.contentWindow,Ae=Yr(q);!ue||!Ae||ue.postMessage({type:"visual-editor::deactivate"},Ae)},We=()=>{const ue=g.current?.contentWindow,Ae=Yr(q);!ue||!Ae||(ue.postMessage({type:"visual-editor::activate",script:LA},Ae),ue.postMessage({type:"cms-editor::set-labels",labels:ve,kinds:Se,keys:Be},Ae))},ae=()=>{const ue=g.current?.contentWindow,Ae=Yr(q);!ue||!Ae||ue.postMessage({type:"cms-editor::deactivate"},Ae)},De=ue=>{const Ae=l;!s&&ue!==Ae&&(ue==="blocks"?x.current?.resize(30):x.current?.collapse()),c(ue),f(null),p(null),Ae==="visual"&&is(),ue==="visual"&&Ut(),Ae==="blocks"&&ue!=="blocks"&&ae(),ue==="blocks"&&We()},qe=ue=>{De(oP(l,ue))},Ye=()=>{if(!g.current||!st)return;const ue=g.current;ue.src=st},mt=()=>{const ue=g.current;if(!ue)return;z();const Ae=document.activeElement,ct=ue.tabIndex;ue.tabIndex=-1,ue.style.pointerEvents="none",ue.blur(),Tf(ue,Ce.current);let bt;const xs=()=>{clearTimeout(bt),ue.tabIndex=ct,ue.style.pointerEvents="";const jn=document.activeElement;(!jn||jn===document.body||jn===ue)&&Ae?.focus(),ue.removeEventListener("load",xs)};ue.addEventListener("load",xs),bt=setTimeout(xs,3e3)};V_(()=>{mt()}),N_(()=>{z()});const wt=()=>{if(!g.current||!st)return;const ue=st.includes("?")?"&":"?";g.current.src=`${st}${ue}_r=${Date.now()}`},$n=()=>{const ue=rd.indexOf(d);h(rd[(ue+1)%rd.length])},ui=async()=>{let ue=null;try{ue=g.current?.contentWindow?.location?.href??null}catch{}const Ae=ue??st??q;if(Ae)try{await navigator.clipboard.writeText(Ae),ge.success(e("sandbox.preview.urlCopiedToClipboard"))}catch{ge.error(e("sandbox.preview.failedToCopyUrl"))}},z5=(()=>{if(!q)return e("sandbox.preview.noServerRunning");if(N)return N.name;try{const ue=new URL(q),Ae=Ee==="/"?"":Ee;return`${ue.host}${Ae}`}catch{return q}})(),Rc=ue=>{const Ae=I[ue.key]??{},ct=Hn(ue.path,Ae);(N||me(ct)!==me(Ee))&&z(),ke.current=ct,V(null),T(null),p(null),D(ue.key),R(ue.path),fe({path:ue.path,pageKey:ue.key,params:Ae}),o.selectTarget({kind:"page",key:ue.key,path:ue.path})},Dc=(ue,Ae)=>{if(!ye)return;const ct=ye,bt={...Pe,[ue]:Ae};ke.current=Hn(k,bt),M(xs=>({...xs,[ct]:bt})),fe({path:k,pageKey:ct,params:bt})},K5=ue=>{if(!q||!de){ge.error(e("sandbox.preview.previewMetadataNotReady"));return}z(),ke.current=null;const Ae=zd(de),ct=xf(q,Ae,ue.key);V(ue),T(ct),p(null),o.selectTarget({kind:"section",key:ue.key})},U5=async({name:ue,path:Ae,templateKey:ct})=>{if(!t||!i)return;const bt=$9(Ae);if(bt){C(bt);return}const xs=Ae.trim().startsWith("/")?Ae.trim():`/${Ae.trim()}`;if(ce.some(Xs=>me(Xs.path)===me(xs))){C(e("sandbox.preview.pageAlreadyExists",{path:xs}));return}let jn;if(ct&&(jn=ne?.[ct],!jn)){C(e("sandbox.preview.templateNoLongerExists"));return}C(void 0);try{const Xs=await he.mutateAsync({name:ue,path:xs,template:jn});j(!1),ge.success(e("sandbox.preview.pageCreated",{name:ue})),await Zb(Vf),Rc({key:Xs.key,name:Xs.name,path:Xs.path}),De("blocks")}catch(Xs){C(Xs instanceof Error?Xs.message:e("sandbox.preview.failedToCreatePage"))}},Ic=Je.kind==="iframe",zu=Ic?r.jsx("div",{className:"absolute bottom-4 left-1/2 z-20 -translate-x-1/2",children:r.jsxs("div",{className:"flex items-center gap-0.5 rounded-full border bg-background/90 p-1 shadow-lg backdrop-blur-sm",children:[r.jsxs(He,{children:[r.jsx(Ke,{asChild:!0,children:r.jsx(Id,{onClick:()=>qe("visual"),"aria-pressed":l==="visual","aria-label":e("sandbox.preview.visualEditor"),active:l==="visual",disabled:!Ic,children:r.jsx(Ju,{size:16})})}),r.jsx(Ue,{side:"top",children:e("sandbox.preview.visualEditor")})]}),r.jsx("div",{className:"mx-0.5 h-5 w-px bg-border"}),r.jsxs(He,{children:[r.jsx(Ke,{asChild:!0,children:r.jsx(Id,{onClick:$n,"aria-label":e(Nf[d]),disabled:!Ic,children:r.jsxs("span",{className:"flex items-center justify-center animate-device-icon-pop",children:[d==="mobile"&&r.jsx(i6,{size:16}),d==="tablet"&&r.jsx(r6,{size:16}),d==="desktop"&&r.jsx(o6,{size:16})]},d)})}),r.jsx(Ue,{side:"top",children:e(Nf[d])})]})]})}):null;return r.jsxs("div",{className:"flex flex-col w-full h-full",children:[Ve&&Object.entries(be).map(([ue,Ae])=>(Pe[ue]??"")===""?r.jsx(BE,{sources:Ae,template:k,paramName:ue,sandboxRef:Ve,onFill:ct=>Dc(ue,ct)},`${ye}:${ue}`):null),ls&&Je.kind==="iframe"&&r.jsx("div",{className:"relative flex h-12 shrink-0 items-center gap-4 border-b border-border/60 px-3 md:px-4",children:Je.kind==="iframe"&&r.jsxs("div",{className:"flex h-full w-full items-center justify-between gap-2",children:[r.jsxs(le,{variant:"outline",size:"sm","data-testid":"preview-blocks-toggle",onClick:()=>qe("blocks"),"aria-pressed":l==="blocks","aria-label":e("sandbox.preview.blocksEditor"),children:[r.jsx(a6,{size:14}),e("sandbox.preview.blocks")]}),r.jsxs("div",{className:"flex w-full min-w-0 max-w-[500px] items-center gap-0.5",children:[r.jsxs(He,{children:[r.jsx(Ke,{asChild:!0,children:r.jsx(le,{variant:"ghost",size:"icon",onClick:Ye,"aria-label":e("sandbox.preview.refresh"),children:r.jsx(dr,{size:14})})}),r.jsx(Ue,{side:"bottom",children:e("sandbox.preview.refresh")})]}),r.jsxs("div",{ref:L,className:"relative min-w-0 flex-1",children:[r.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:[r.jsxs("div",{className:"flex h-full min-w-0 flex-1 cursor-pointer items-center gap-1 pl-2 pr-1",onClick:()=>b(ue=>!ue),children:[N&&r.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:[r.jsx(gn,{size:11}),"Global"]}),r.jsx("span",{className:ie("text-[13px] font-medium text-foreground",Oe==null?"min-w-0 flex-1 truncate":"shrink-0"),children:Oe??z5}),!N&&Oe!=null&&k&&r.jsx("span",{className:"flex min-w-0 flex-1 items-center overflow-hidden whitespace-nowrap text-[12px] text-muted-foreground",children:wl(k).map((ue,Ae)=>{if(ue.type==="text")return r.jsx("span",{className:ie(Ae===0?"min-w-0 truncate":"shrink-0"),children:ue.text},`text-${Ae}`);const ct=be[ue.name];return ct&&Ve?r.jsx(AE,{sources:ct,template:k,paramName:ue.name,value:Pe[ue.name]??"",sandboxRef:Ve,onCommit:bt=>Dc(ue.name,bt)},`${ye}:${ue.name}`):r.jsx(zE,{name:ue.name,value:Pe[ue.name]??"",onCommit:bt=>Dc(ue.name,bt)},`${ye}:${ue.name}`)})})]}),r.jsx("button",{type:"button",className:"flex h-full shrink-0 items-center pl-1 pr-2",onClick:()=>b(ue=>!ue),"aria-label":e("sandbox.preview.choosePage"),children:r.jsx(ss,{size:12,className:ie("shrink-0 text-muted-foreground transition-transform",v&&"rotate-180")})})]}),v&&r.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:[r.jsxs("div",{className:"px-2 h-10 flex items-center gap-2 border-b",children:[r.jsx(L9,{size:14,className:"shrink-0 text-muted-foreground","aria-hidden":!0}),r.jsx("input",{type:"text",value:_,onChange:ue=>y(ue.target.value),onKeyDown:ue=>{if(ue.key!=="Enter")return;const Ae=_.trim();if(!Ae)return;const ct=pe.find(bt=>me(bt.path)===me(Ae));ct&&(ue.preventDefault(),b(!1),y(""),Rc(ct))},placeholder:e("sandbox.preview.searchPagesAndComponents"),className:"w-full bg-transparent text-sm outline-none placeholder:text-muted-foreground",autoFocus:!0})]}),r.jsx("div",{className:"p-1.5 border-b",children:r.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(),b(!1),y(""),C(void 0),j(!0)},children:[r.jsx(kt,{size:16,className:"shrink-0 text-muted-foreground"}),r.jsx("span",{className:"flex-1 font-medium",children:e("sandbox.preview.createNewPage")})]})}),pe.length===0&&we.length===0?r.jsx("div",{className:"px-4 py-5 text-center text-xs text-muted-foreground",children:ce.length===0&&oe.length===0?e("sandbox.preview.noPagesFound"):e("sandbox.preview.noSearchResults")}):r.jsxs("div",{className:"max-h-80 overflow-y-auto overscroll-contain",children:[pe.length>0&&r.jsx("div",{className:"p-1.5",children:pe.map(ue=>r.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:Ae=>{Ae.preventDefault(),b(!1),y(""),Rc(ue)},children:[r.jsx(Nn,{size:16,className:"shrink-0 text-muted-foreground"}),r.jsx("span",{className:"min-w-0 flex-1 truncate font-medium",children:ue.name}),r.jsx("span",{className:"shrink-0 text-xs text-muted-foreground",children:ue.path})]},ue.key))}),we.length>0&&r.jsxs("div",{className:ie("p-1.5",pe.length>0&&"border-t"),children:[r.jsx("div",{className:"px-3 py-2 text-xs font-medium text-muted-foreground",children:e("sandbox.preview.globalComponents")}),we.map(ue=>r.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:Ae=>{Ae.preventDefault(),b(!1),y(""),K5(ue)},children:[r.jsx(gn,{size:16,className:"shrink-0 text-muted-foreground"}),r.jsx("span",{className:"min-w-0 flex-1 truncate font-medium",children:ue.name}),r.jsx("span",{className:"shrink-0 text-xs text-muted-foreground",children:ue.resolveType.split("/").pop()?.replace(/\.tsx?$/,"")})]},ue.key))]})]})]})]}),r.jsxs(He,{children:[r.jsx(Ke,{asChild:!0,children:r.jsx(le,{variant:"ghost",size:"icon",onClick:()=>{const ue=st??Je.previewUrl;ue&&window.open(ue,"_blank","noopener")},"aria-label":e("sandbox.preview.openInNewTab"),children:r.jsx(Dn,{size:14})})}),r.jsx(Ue,{side:"bottom",children:e("sandbox.preview.openInNewTab")})]})]}),r.jsx("div",{className:"flex shrink-0 items-center",children:r.jsxs(us,{children:[r.jsx(ds,{asChild:!0,children:r.jsx(le,{variant:"ghost",size:"icon","aria-label":e("sandbox.preview.moreOptions"),children:r.jsx(ai,{size:14})})}),r.jsxs(hs,{align:"end",className:"w-44",children:[r.jsx(Xe,{onClick:wt,children:e("sandbox.preview.hardReload")}),r.jsx(Xe,{onClick:ui,children:e("sandbox.preview.copyCurrentUrl")}),ne&&de&&r.jsxs(r.Fragment,{children:[r.jsx(rr,{}),ye&&r.jsxs(Xe,{onClick:()=>{o.editSeo({kind:"page",key:ye,path:k}),De("blocks")},children:[r.jsx(rl,{size:14}),e("sandbox.preview.editSeo")]}),ye&&r.jsxs(Xe,{onClick:()=>{try{a(gb(G6(ye)))}catch{ge.error(e("sandbox.preview.invalidPageBlockKey"))}},children:[r.jsx(sa,{size:14}),e("sandbox.preview.viewJson")]}),r.jsxs(Xe,{onClick:()=>J(!0),children:[r.jsx(rl,{size:14}),e("sandbox.preview.siteSeo")]})]}),te&&r.jsxs(r.Fragment,{children:[r.jsx(rr,{}),r.jsxs(Xe,{onClick:()=>window.open(Il("vscode",te)),children:[r.jsx("img",{src:aP,alt:"VSCode",width:14,height:14}),e("sandbox.preview.openInVscode")]}),r.jsxs(Xe,{onClick:()=>window.open(Il("cursor",te)),children:[r.jsx("img",{src:lP,alt:"Cursor",width:14,height:14}),e("sandbox.preview.openInCursor")]})]})]})]})})]})}),r.jsx("div",{className:"flex-1 overflow-hidden",children:s&&Vt==="blocks"?r.jsxs("div",{className:"relative h-full min-h-0 overflow-hidden",children:[r.jsx(kf,{virtualMcpId:t,externalSelectedIndex:m}),zu]}):r.jsxs(c2,{direction:"horizontal",children:[r.jsx(al,{ref:x,id:"preview-blocks-editor",order:1,defaultSize:Vt==="blocks"?30:0,minSize:20,collapsible:!0,collapsedSize:0,className:"min-w-0 overflow-hidden",children:Vt==="blocks"&&r.jsx(kf,{virtualMcpId:t,externalSelectedIndex:m})}),r.jsx(d2,{withHandle:!0,className:ie(Vt!=="blocks"&&"hidden")}),r.jsx(al,{id:"preview-canvas",order:2,defaultSize:Vt==="blocks"?60:100,minSize:35,className:"min-w-0 overflow-hidden",children:r.jsxs("div",{className:ie("h-full relative overflow-hidden",d!=="desktop"&&Je.kind==="iframe"&&"flex justify-center bg-muted/30"),children:[O&&Je.kind==="iframe"&&r.jsx("div",{className:"absolute inset-x-0 top-0 z-40 h-0.5 overflow-hidden bg-primary/15",children:r.jsx("div",{className:"absolute inset-y-0 w-2/5 rounded-full bg-primary animate-preview-nav"})}),dt&&r.jsx("div",{className:"absolute inset-0 z-30",children:r.jsx(gi,{kind:"starting",progress:pt,claimPhase:nt})}),Je.kind==="othersThread"&&r.jsx("div",{className:"absolute inset-0 z-30",children:r.jsx(gi,{kind:"othersThread",label:Je.label,onContinue:U.acknowledgeOthersThread,onStartNewThread:()=>n({to:"/$org/$taskId",params:{org:H.slug,taskId:crypto.randomUUID()},search:ue=>({...ue,sidepanel:"chat"})})})}),Je.kind==="suspended"&&r.jsx("div",{className:"absolute inset-0 z-30",children:r.jsx(gi,{kind:"suspended",onResume:U.resume})}),Je.kind==="errored"&&r.jsx("div",{className:"absolute inset-0 z-30",children:r.jsx(gi,{kind:"errored",error:Je.error,onRetry:U.retry,connectionsHref:`/${H.slug}/settings/connections`})}),Vt==="visual"&&!u&&r.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:[r.jsx(Ju,{size:12}),e("sandbox.preview.clickElementToAsk")]}),Vt==="visual"&&u&&r.jsx($A,{element:u,onDismiss:()=>f(null)}),zu,Je.kind==="iframe"&&st&&r.jsx("div",{className:ie("h-full transition-[width] duration-250 [transition-timing-function:var(--ease-in-out-cubic)]",d!=="desktop"&&"w-full max-w-full border-x border-border bg-background shadow-sm"),style:{width:d==="desktop"?"100%":`${dP[d]}px`},children:r.jsx("iframe",{ref:g,src:st,className:"w-full h-full border-0",title:e("sandbox.preview.devServerPreviewTitle"),onLoad:()=>{if(K(),$e("vm_preview_loaded",{view_mode:l,vm_id:Q?.sandboxHandle??null}),!N)try{const ue=g.current?.contentWindow?.location?.pathname;if(!ue)return;const Ae=ke.current;if(Ae!==null&&(ke.current=null,me(ue)!==me(Ae))||me(ue)===me(Ee))return;R(ue),fe({path:ue,pageKey:P,params:Pe})}catch{}l==="visual"&&Ut(),l==="blocks"&&We()}},Je.previewUrl)})]})})]})}),r.jsx(vA,{open:w,onOpenChange:j,isPending:he.isPending,error:S,templates:ce,onSubmit:U5}),X&&ne&&de&&r.jsx(A.Suspense,{fallback:null,children:r.jsx(cP,{open:X,onOpenChange:J,orgSlug:H.slug,virtualMcpId:t??"",branch:i??"",decofile:ne,meta:de,onSaved:()=>{setTimeout(()=>{const ue=g.current;ue&&Tf(ue,Ce.current)},Vf)},target:{kind:"site"}})})]})}function fP(t){const e=B.c(22),{virtualMcpId:s}=t,n=re(),i=gs(s),{activeTask:o}=Zt(),[a,l]=A.useState(!1);if(!(sn(i?.metadata)||sn(o?.metadata))){let h;e[0]===Symbol.for("react.memo_cache_sentinel")?(h=r.jsx("div",{className:"flex size-14 items-center justify-center rounded-full bg-muted",children:r.jsx($o,{className:"size-7 text-foreground"})}),e[0]=h):h=e[0];let u;e[1]!==n?(u=n("mainPanelTabs.previewTab.noSourceToPreview"),e[1]=n,e[2]=u):u=e[2];let f;e[3]!==n?(f=n("mainPanelTabs.previewTab.connectGithubDescription"),e[3]=n,e[4]=f):f=e[4];let m,p;e[5]===Symbol.for("react.memo_cache_sentinel")?(m=()=>l(!0),p=r.jsx($o,{className:"size-4"}),e[5]=m,e[6]=p):(m=e[5],p=e[6]);let g;e[7]!==n?(g=n("mainPanelTabs.previewTab.connectGithub"),e[7]=n,e[8]=g):g=e[8];let x;e[9]!==g?(x=r.jsxs(le,{onClick:m,children:[p,g]}),e[9]=g,e[10]=x):x=e[10];let v;e[11]!==u||e[12]!==f||e[13]!==x?(v=r.jsx(ki,{className:"h-full",image:h,title:u,description:f,actions:x}),e[11]=u,e[12]=f,e[13]=x,e[14]=v):v=e[14];let b;e[15]!==a?(b=r.jsx(k2,{open:a,onOpenChange:l,mode:"agent"}),e[15]=a,e[16]=b):b=e[16];let _;return e[17]!==v||e[18]!==b?(_=r.jsxs(r.Fragment,{children:[v,b]}),e[17]=v,e[18]=b,e[19]=_):_=e[19],_}let d;return e[20]!==s?(d=r.jsx(hP,{virtualMcpId:s}),e[20]=s,e[21]=d):d=e[21],d}const mP="https://decoims.com/decocms/01b321bd-4613-4b2c-9348-35058444d210/Visual_Studio_Code_1.35_icon.svg.png",pP="https://decoims.com/decocms/7583d3b5-81d0-4afb-becf-6a59bbb3a68e/cursor-logo-icon-freelogovectors.net_.png",gP=A.lazy(()=>$s(()=>import("./file-explorer-CgJTQxdk.js"),__vite__mapDeps([158,1,2,90,4,5,6,7,8,9,10,11,12,13,14,15,16,17,3,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,91,92,93,94,95,96,97,98,99,100,101,102,139,138,140,141,135,128,111,103,107,108,109,110,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,129,130,131,132,133,134,136,137,142,143,144,145,146,147,148,149,150,105,151,152,153,154,155,156])).then(t=>({default:t.FileExplorer})));function xP(t){const e=B.c(21),{openPath:s}=t,n=re(),i=di(),{org:o}=Fe(),{currentBranch:a}=Zt(),l=i?.entity?.id??null,c=Er(),d=Fs(),h=c.vmEntry,u=d.lifecycle.phase==="running",f=h?.sandboxProviderKind==="user-desktop",m=l??"",p=a??"",g=f&&u&&!!l&&!!a;let x;e[0]!==o.slug||e[1]!==m||e[2]!==p||e[3]!==g?(x={orgSlug:o.slug,virtualMcpId:m,branch:p,enabled:g},e[0]=o.slug,e[1]=m,e[2]=p,e[3]=g,e[4]=x):x=e[4];const v=Jg(x),b=f?v:null;if(!l||!a){let j;e[5]!==n?(j=n("mainPanelTabs.codeTab.noSandboxToBrowse"),e[5]=n,e[6]=j):j=e[6];let S;return e[7]!==j?(S=r.jsx("div",{className:"flex-1 flex items-center justify-center text-sm text-muted-foreground",children:j}),e[7]=j,e[8]=S):S=e[8],S}let _;e[9]!==b||e[10]!==n?(_=b&&r.jsx("div",{className:"relative flex h-12 shrink-0 items-center border-b border-border/60 px-3 md:px-4",children:r.jsxs("div",{className:"ml-auto flex shrink-0 items-center gap-0.5",children:[r.jsxs(He,{children:[r.jsx(Ke,{asChild:!0,children:r.jsx(le,{variant:"ghost",size:"icon","aria-label":n("mainPanelTabs.codeTab.openInVscode"),onClick:()=>window.open(Il("vscode",b)),children:r.jsx("img",{src:mP,alt:"VSCode",width:14,height:14})})}),r.jsx(Ue,{side:"bottom",children:n("mainPanelTabs.codeTab.openInVscode")})]}),r.jsxs(He,{children:[r.jsx(Ke,{asChild:!0,children:r.jsx(le,{variant:"ghost",size:"icon","aria-label":n("mainPanelTabs.codeTab.openInCursor"),onClick:()=>window.open(Il("cursor",b)),children:r.jsx("img",{src:pP,alt:"Cursor",width:14,height:14})})}),r.jsx(Ue,{side:"bottom",children:n("mainPanelTabs.codeTab.openInCursor")})]})]})}),e[9]=b,e[10]=n,e[11]=_):_=e[11];let y;e[12]===Symbol.for("react.memo_cache_sentinel")?(y=r.jsx("div",{className:"h-full flex items-center justify-center",children:r.jsx(et,{size:20,className:"animate-spin text-muted-foreground"})}),e[12]=y):y=e[12];let L;e[13]!==a||e[14]!==s||e[15]!==o.slug||e[16]!==l?(L=r.jsx("div",{className:"flex-1 relative overflow-hidden bg-background",children:r.jsx(A.Suspense,{fallback:y,children:r.jsx(gP,{orgSlug:o.slug,virtualMcpId:l,branch:a,openPath:s})})}),e[13]=a,e[14]=s,e[15]=o.slug,e[16]=l,e[17]=L):L=e[17];let w;return e[18]!==_||e[19]!==L?(w=r.jsxs("div",{className:"flex flex-col w-full h-full",children:[_,L]}),e[18]=_,e[19]=L,e[20]=w):w=e[20],w}function vP(t){return gs(t)?.metadata?.runtime?.path??null}function bP(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 yP(t,e,s){return typeof t!="string"?null:bP(_n(t,e),s)}function Qg(t,e,s){if(!e||typeof t!="string")return!1;const n=yP(t,e,s);return!!n&&Object.keys(n.properties??{}).length>0}function _P({orgSlug:t,virtualMcpId:e,branch:s}){const n=Ls(),i=gs(e)?.metadata?.runtime?.path??null;return Ys({mutationFn:async({blockKey:o})=>{const a=Pr(i,l2(o)),l=await fetch(`/api/${t}/sandbox/${encodeURIComponent(e)}/${encodeURIComponent(s)}/unlink`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({path:a})});if(!l.ok){const c=await l.json().catch(()=>({}));throw new Error(c.error??`Delete failed (${l.status})`)}return l.json()},onMutate:async({blockKey:o})=>{const a=`${t}/${e}/${s}`,l=at.decofile(a);await n.cancelQueries({queryKey:l});const c=n.getQueryData(l);return n.setQueryData(l,d=>{if(!d)return d;const{[o]:h,...u}=d;return u}),{previous:c,queryKey:l}},onError:(o,a,l)=>{l?.queryKey&&n.setQueryData(l.queryKey,l.previous)},onSuccess:()=>{n.invalidateQueries({queryKey:at.liveMeta(t,e,s)})}})}function Ji(t){const e=B.c(6),{hasItems:s,emptyLabel:n,emptyHint:i}=t;let o;e[0]!==i||e[1]!==n||e[2]!==s?(o=s?"No results match your search.":r.jsxs(r.Fragment,{children:[r.jsx("div",{children:n}),r.jsx("div",{className:"mt-1 text-muted-foreground/80",children:i})]}),e[0]=i,e[1]=n,e[2]=s,e[3]=o):o=e[3];let a;return e[4]!==o?(a=r.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 kc(t,e){return`${t}-${e}`}function Zg(t,e){return`site/apps/${t}/${e}.ts`}function e4(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 LP(t){const e=t.match(/^([^-]+)-(.+)$/);return e?{vendor:e[1],app:e[2]}:null}function SP(t){return t==="local"?"Custom":"Installed"}function t4(t,e,s){const n=new Set([kc(t,e),e].map(o=>o.toLowerCase())),i=Zg(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===i)return o}return null}function wP(t,e){const s=t.vendor.alias,n=t.name,i=t4(s,n,e);return{id:kc(s,n),app:n,vendor:s,title:t.title||t.name,description:t.description,category:t.category??"Other",logo:t.logo||void 0,resolveType:Zg(s,n),blockKey:i,installed:i!==null}}function jP(t,e,s){if(t===F9)return null;const n=e4(t);if(!n)return null;const{vendor:i,app:o}=n,a=t4(i,o,s),l=ci(t,e);return{id:kc(i,o),app:o,vendor:i,title:l.title??o,description:l.description??"",category:"Others",logo:l.logo??l.icon,resolveType:t,blockKey:a,installed:a!==null}}function CP(t,e,s){const n=e.__resolveType;if(typeof n!="string"||jl(t,e)||!Bp(n))return null;const i=e4(n)??LP(t);if(!i)return null;const o=ci(n,s),{vendor:a,app:l}=i;return{id:kc(a,l),app:l,vendor:a,title:o.title??Cl(t,e,s),description:o.description??"",category:SP(a),logo:o.logo??o.icon,resolveType:n,blockKey:t,installed:!0}}function kP(t,e,s){const n=new Map;for(const o of t){const a=wP(o,s);n.set(a.id,a)}const i=e.manifest?.blocks?.apps??{};for(const o of Object.keys(i)){const a=jP(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=CP(o,a,e);!l||n.has(l.id)||n.set(l.id,l)}return[...n.values()].sort(VP)}function VP(t,e){return t.installed!==e.installed?t.installed?-1:1:t.title.localeCompare(e.title)}async function NP(){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 TP(t,e,s){const n=B.c(12),i=s?.enabled??!0;let o;n[0]===Symbol.for("react.memo_cache_sentinel")?(o=at.decoApps(),n[0]=o):o=n[0];let a;n[1]!==i?(a={queryKey:o,queryFn:NP,staleTime:3e5,retry:1,enabled:i},n[1]=i,n[2]=a):a=n[2];const l=Ft(a);let c;n[3]!==e||n[4]!==t||n[5]!==l.data?(c=t&&e?kP(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}function s4(t){return(e,s)=>{Y6(e),t(e,s)}}function AP(t){const e=B.c(86),{active:s,counts:n,showBlog:i,onSelect:o}=t,a=re();let l;e[0]!==a?(l=a("sandbox.collectionsSidebar.content"),e[0]=a,e[1]=l):l=e[1];let c;e[2]!==l?(c=r.jsx("div",{className:"px-3 h-12 flex items-center border-b shrink-0",children:r.jsx("span",{className:"text-sm font-medium",children:l})}),e[2]=l,e[3]=c):c=e[3];let d;e[4]!==a?(d=a("sandbox.collectionsSidebar.pages"),e[4]=a,e[5]=d):d=e[5];const h=s==="pages";let u;e[6]!==n.pages||e[7]!==o||e[8]!==d||e[9]!==h?(u=r.jsx(zs,{id:"pages",icon:Nn,label:d,count:n.pages,active:h,onSelect:o}),e[6]=n.pages,e[7]=o,e[8]=d,e[9]=h,e[10]=u):u=e[10];let f;e[11]!==a?(f=a("sandbox.collectionsSidebar.sections"),e[11]=a,e[12]=f):f=e[12];const m=s==="sections";let p;e[13]!==n.sections||e[14]!==o||e[15]!==f||e[16]!==m?(p=r.jsx(zs,{id:"sections",icon:gn,label:f,count:n.sections,active:m,onSelect:o}),e[13]=n.sections,e[14]=o,e[15]=f,e[16]=m,e[17]=p):p=e[17];let g;e[18]!==a?(g=a("sandbox.collectionsSidebar.apps"),e[18]=a,e[19]=g):g=e[19];const x=s==="apps";let v;e[20]!==n.apps||e[21]!==o||e[22]!==x||e[23]!==g?(v=r.jsx(zs,{id:"apps",icon:A2,label:g,count:n.apps,active:x,onSelect:o}),e[20]=n.apps,e[21]=o,e[22]=x,e[23]=g,e[24]=v):v=e[24];let b;e[25]!==a?(b=a("sandbox.collectionsSidebar.redirects"),e[25]=a,e[26]=b):b=e[26];const _=s==="redirects";let y;e[27]!==n.redirects||e[28]!==o||e[29]!==b||e[30]!==_?(y=r.jsx(zs,{id:"redirects",icon:Xm,label:b,count:n.redirects,active:_,onSelect:o}),e[27]=n.redirects,e[28]=o,e[29]=b,e[30]=_,e[31]=y):y=e[31];let L;e[32]!==a?(L=a("sandbox.collectionsSidebar.loaders"),e[32]=a,e[33]=L):L=e[33];const w=s==="loaders";let j;e[34]!==n.loaders||e[35]!==o||e[36]!==L||e[37]!==w?(j=r.jsx(zs,{id:"loaders",icon:ol,label:L,count:n.loaders,active:w,onSelect:o}),e[34]=n.loaders,e[35]=o,e[36]=L,e[37]=w,e[38]=j):j=e[38];let S;e[39]!==a?(S=a("sandbox.collectionsSidebar.actions"),e[39]=a,e[40]=S):S=e[40];const C=s==="actions";let N;e[41]!==n.actions||e[42]!==o||e[43]!==S||e[44]!==C?(N=r.jsx(zs,{id:"actions",icon:Ni,label:S,count:n.actions,active:C,onSelect:o}),e[41]=n.actions,e[42]=o,e[43]=S,e[44]=C,e[45]=N):N=e[45];let V;e[46]!==a?(V=a("sandbox.collectionsSidebar.site"),e[46]=a,e[47]=V):V=e[47];const E=s==="site";let T;e[48]!==o||e[49]!==V||e[50]!==E?(T=r.jsx(zs,{id:"site",icon:Jm,label:V,active:E,onSelect:o}),e[48]=o,e[49]=V,e[50]=E,e[51]=T):T=e[51];let k;e[52]!==a?(k=a("sandbox.collectionsSidebar.seo"),e[52]=a,e[53]=k):k=e[53];const R=s==="seo";let P;e[54]!==o||e[55]!==k||e[56]!==R?(P=r.jsx(zs,{id:"seo",icon:rl,label:k,active:R,onSelect:o}),e[54]=o,e[55]=k,e[56]=R,e[57]=P):P=e[57];let D;e[58]!==a?(D=a("sandbox.collectionsSidebar.calendar"),e[58]=a,e[59]=D):D=e[59];const I=s==="calendar";let M;e[60]!==o||e[61]!==D||e[62]!==I?(M=r.jsx(zs,{id:"calendar",icon:r9,label:D,active:I,onSelect:o}),e[60]=o,e[61]=D,e[62]=I,e[63]=M):M=e[63];let O;e[64]!==s||e[65]!==n.authors||e[66]!==n.categories||e[67]!==n.posts||e[68]!==o||e[69]!==i||e[70]!==a?(O=i&&r.jsxs(r.Fragment,{children:[r.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:[r.jsx(fr,{size:13,className:"shrink-0"}),a("sandbox.collectionsSidebar.blog")]}),r.jsx(zs,{id:"posts",icon:mr,label:a("sandbox.collectionsSidebar.posts"),count:n.posts,active:s==="posts",onSelect:o}),r.jsx(zs,{id:"authors",icon:nc,label:a("sandbox.collectionsSidebar.authors"),count:n.authors,active:s==="authors",onSelect:o}),r.jsx(zs,{id:"categories",icon:Qm,label:a("sandbox.collectionsSidebar.categories"),count:n.categories,active:s==="categories",onSelect:o})]}),e[64]=s,e[65]=n.authors,e[66]=n.categories,e[67]=n.posts,e[68]=o,e[69]=i,e[70]=a,e[71]=O):O=e[71];let F;e[72]!==v||e[73]!==y||e[74]!==j||e[75]!==N||e[76]!==T||e[77]!==P||e[78]!==M||e[79]!==O||e[80]!==u||e[81]!==p?(F=r.jsxs("nav",{className:"flex flex-col p-1.5 gap-0.5",children:[u,p,v,y,j,N,T,P,M,O]}),e[72]=v,e[73]=y,e[74]=j,e[75]=N,e[76]=T,e[77]=P,e[78]=M,e[79]=O,e[80]=u,e[81]=p,e[82]=F):F=e[82];let $;return e[83]!==c||e[84]!==F?($=r.jsxs("div",{className:"w-[208px] shrink-0 border-r flex flex-col",children:[c,F]}),e[83]=c,e[84]=F,e[85]=$):$=e[85],$}function zs(t){const e=B.c(18),{id:s,icon:n,label:i,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=ie("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=r.jsx(n,{size:16,className:"shrink-0"}),e[5]=n,e[6]=u):u=e[6];let f;e[7]!==i?(f=r.jsx("span",{className:"flex-1 truncate",children:i}),e[7]=i,e[8]=f):f=e[8];let m;e[9]!==a||e[10]!==o?(m=o!==void 0&&r.jsx("span",{className:ie("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=r.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 EP(t){const e=B.c(12),{state:s,claimPhase:n,lifecycle:i,onStart:o,connectionsHref:a}=t;switch(s.kind){case"starting":{let l;e[0]!==n||e[1]!==i?(l=Dg({claimPhase:n,lifecycle:i}),e[0]=n,e[1]=i,e[2]=l):l=e[2];let c;return e[3]!==n||e[4]!==l?(c=r.jsx(gi,{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=r.jsx(gi,{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=r.jsx(gi,{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 Af(t,e){const s=e.replace(/\s*\(copy(?:\s+\d+)?\)\s*$/,"").trim(),n=`${s} (copy)`;if(!t.has(n))return n;for(let i=2;i<1e3;i++){const o=`${s} (copy ${i})`;if(!t.has(o))return o}return`${s} (copy ${Date.now()})`}function PP(t,e){const s=Yn,n=e.replace(/-copy(?:-\d+)?$/,""),i=`${n}-copy`;if(!t.has(s(i)))return i;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 RP(t,e){const s=e.replace(/_copy(?:_\d+)?$/,""),n=`${s}_copy`;if(!Object.hasOwn(t,n))return n;for(let i=2;i<1e3;i++){const o=`${s}_copy_${i}`;if(!Object.hasOwn(t,o))return o}return`${s}_copy_${Date.now()}`}function DP(t){const e=mu(t.newName),s={...t.source,name:t.newName,path:t.newPath};return{key:e,data:s}}function IP(t,e){return jg(t,e)}const MP=1e3;function OP(t,e){for(let s=0;s<MP;s++){const n=mu(e);if(!Object.hasOwn(t,n))return n}throw new Error("Could not generate a unique page block key")}const $P={create:"sandbox.pageFormDialog.titleCreate",duplicate:"sandbox.pageFormDialog.titleDuplicate",rename:"sandbox.pageFormDialog.titleRename"},BP={create:"sandbox.pageFormDialog.submitCreate",duplicate:"sandbox.pageFormDialog.submitDuplicate",rename:"sandbox.pageFormDialog.submitSave"},FP={create:"sandbox.pageFormDialog.pendingCreate",duplicate:"sandbox.pageFormDialog.pendingDuplicate",rename:"sandbox.pageFormDialog.pendingSave"};function zP(t){const e=B.c(88),{open:s,mode:n,initialName:i,initialPath:o,isPending:a,error:l,templates:c,validate:d,onSubmit:h,onOpenChange:u}=t,f=a===void 0?!1:a,m=re(),[p,g]=A.useState(i),[x,v]=A.useState(o),[b,_]=A.useState(Jn),[y,L]=A.useState(null),[w,j]=A.useState(s);s!==w&&(j(s),s&&(g(i),v(o),_(Jn),L(null)));const S=n==="create"&&!!c?.length;let C;e[0]!==f||e[1]!==u?(C=he=>{!he&&!f&&(L(null),u(!1))},e[0]=f,e[1]=u,e[2]=C):C=e[2];const N=C;let V;e[3]!==f||e[4]!==p||e[5]!==h||e[6]!==x||e[7]!==S||e[8]!==b||e[9]!==d?(V=async he=>{he.preventDefault();const ce=p.trim(),oe=x.trim();if(!ce||!oe||f)return;const me=$9(oe);if(me){L(me);return}const pe=d?.({name:ce,path:oe});if(pe){L(pe);return}L(null),await h({name:ce,path:oe,templateKey:S&&b!==Jn?b:null})},e[3]=f,e[4]=p,e[5]=h,e[6]=x,e[7]=S,e[8]=b,e[9]=d,e[10]=V):V=e[10];const E=V,T=y??l,k=$P[n];let R;e[11]!==m||e[12]!==k?(R=m(k),e[11]=m,e[12]=k,e[13]=R):R=e[13];let P;e[14]!==R?(P=r.jsx(ms,{children:r.jsx(ps,{children:R})}),e[14]=R,e[15]=P):P=e[15];let D;e[16]!==f||e[17]!==S||e[18]!==m||e[19]!==b||e[20]!==c?(D=S&&r.jsxs("div",{className:"space-y-1.5",children:[r.jsx("label",{htmlFor:"page-form-template",className:"text-xs font-medium text-muted-foreground",children:m("sandbox.pageFormDialog.labelTemplate")}),r.jsx(kg,{id:"page-form-template",value:b,onChange:_,templates:c??[],disabled:f})]}),e[16]=f,e[17]=S,e[18]=m,e[19]=b,e[20]=c,e[21]=D):D=e[21];let I;e[22]!==m?(I=m("sandbox.pageFormDialog.labelName"),e[22]=m,e[23]=I):I=e[23];let M;e[24]!==I?(M=r.jsx("label",{htmlFor:"page-form-name",className:"text-xs font-medium text-muted-foreground",children:I}),e[24]=I,e[25]=M):M=e[25];let O;e[26]===Symbol.for("react.memo_cache_sentinel")?(O=he=>g(he.target.value),e[26]=O):O=e[26];let F;e[27]!==m?(F=m("sandbox.pageFormDialog.placeholderName"),e[27]=m,e[28]=F):F=e[28];let $;e[29]!==f||e[30]!==p||e[31]!==F?($=r.jsx(rt,{id:"page-form-name",value:p,onChange:O,placeholder:F,autoFocus:!0,disabled:f}),e[29]=f,e[30]=p,e[31]=F,e[32]=$):$=e[32];let z;e[33]!==$||e[34]!==M?(z=r.jsxs("div",{className:"space-y-1.5",children:[M,$]}),e[33]=$,e[34]=M,e[35]=z):z=e[35];let K;e[36]!==m?(K=m("sandbox.pageFormDialog.labelPath"),e[36]=m,e[37]=K):K=e[37];let X;e[38]!==K?(X=r.jsx("label",{htmlFor:"page-form-path",className:"text-xs font-medium text-muted-foreground",children:K}),e[38]=K,e[39]=X):X=e[39];let J;e[40]===Symbol.for("react.memo_cache_sentinel")?(J=he=>v(he.target.value),e[40]=J):J=e[40];let H;e[41]!==m?(H=m("sandbox.pageFormDialog.placeholderPath"),e[41]=m,e[42]=H):H=e[42];let W;e[43]!==f||e[44]!==x||e[45]!==H?(W=r.jsx(rt,{id:"page-form-path",value:x,onChange:J,placeholder:H,disabled:f}),e[43]=f,e[44]=x,e[45]=H,e[46]=W):W=e[46];let U;e[47]!==X||e[48]!==W?(U=r.jsxs("div",{className:"space-y-1.5",children:[X,W]}),e[47]=X,e[48]=W,e[49]=U):U=e[49];let Q;e[50]!==T?(Q=T&&r.jsx("p",{className:"text-xs text-destructive",children:T}),e[50]=T,e[51]=Q):Q=e[51];let q;e[52]!==z||e[53]!==U||e[54]!==Q||e[55]!==D?(q=r.jsxs("div",{className:"space-y-4 py-4",children:[D,z,U,Q]}),e[52]=z,e[53]=U,e[54]=Q,e[55]=D,e[56]=q):q=e[56];let Z;e[57]!==u?(Z=()=>u(!1),e[57]=u,e[58]=Z):Z=e[58];let Y;e[59]!==m?(Y=m("sandbox.pageFormDialog.buttonCancel"),e[59]=m,e[60]=Y):Y=e[60];let ee;e[61]!==f||e[62]!==Z||e[63]!==Y?(ee=r.jsx(le,{type:"button",variant:"outline",onClick:Z,disabled:f,children:Y}),e[61]=f,e[62]=Z,e[63]=Y,e[64]=ee):ee=e[64];let G;e[65]!==f||e[66]!==p||e[67]!==x?(G=!p.trim()||!x.trim()||f,e[65]=f,e[66]=p,e[67]=x,e[68]=G):G=e[68];let te;e[69]!==f||e[70]!==n||e[71]!==m?(te=f?r.jsxs(r.Fragment,{children:[r.jsx(et,{size:14,className:"animate-spin"}),m(FP[n])]}):m(BP[n]),e[69]=f,e[70]=n,e[71]=m,e[72]=te):te=e[72];let se;e[73]!==G||e[74]!==te?(se=r.jsx(le,{type:"submit",disabled:G,children:te}),e[73]=G,e[74]=te,e[75]=se):se=e[75];let ne;e[76]!==ee||e[77]!==se?(ne=r.jsxs(Mi,{children:[ee,se]}),e[76]=ee,e[77]=se,e[78]=ne):ne=e[78];let de;e[79]!==E||e[80]!==q||e[81]!==ne||e[82]!==P?(de=r.jsx(es,{className:"sm:max-w-md",children:r.jsxs("form",{onSubmit:E,children:[P,q,ne]})}),e[79]=E,e[80]=q,e[81]=ne,e[82]=P,e[83]=de):de=e[83];let xe;return e[84]!==N||e[85]!==s||e[86]!==de?(xe=r.jsx(ts,{open:s,onOpenChange:N,children:de}),e[84]=N,e[85]=s,e[86]=de,e[87]=xe):xe=e[87],xe}function KP(t){const e=B.c(70),{open:s,blockKey:n,initialName:i,isPending:o,onSubmit:a,onOpenChange:l}=t,c=o===void 0?!1:o,d=re(),[h,u]=A.useState(i),[f,m]=A.useState(s);s!==f&&(m(s),s&&u(i));let p;e[0]!==c||e[1]!==l?(p=J=>{!J&&!c&&l(!1)},e[0]=c,e[1]=l,e[2]=p):p=e[2];const g=p;let x;e[3]!==c||e[4]!==h||e[5]!==a?(x=async J=>{J.preventDefault();const H=h.trim();!H||c||await a(H)},e[3]=c,e[4]=h,e[5]=a,e[6]=x):x=e[6];const v=x;let b;e[7]!==d?(b=d("sandbox.sectionRenameDialog.title"),e[7]=d,e[8]=b):b=e[8];let _;e[9]!==b?(_=r.jsx(ps,{children:b}),e[9]=b,e[10]=_):_=e[10];let y;e[11]!==d?(y=d("sandbox.sectionRenameDialog.description"),e[11]=d,e[12]=y):y=e[12];let L;e[13]!==y?(L=r.jsx(oi,{children:y}),e[13]=y,e[14]=L):L=e[14];let w;e[15]!==_||e[16]!==L?(w=r.jsxs(ms,{children:[_,L]}),e[15]=_,e[16]=L,e[17]=w):w=e[17];let j;e[18]!==d?(j=d("sandbox.sectionRenameDialog.nameLabel"),e[18]=d,e[19]=j):j=e[19];let S;e[20]!==j?(S=r.jsx("label",{htmlFor:"section-rename-name",className:"text-xs font-medium text-muted-foreground",children:j}),e[20]=j,e[21]=S):S=e[21];let C;e[22]===Symbol.for("react.memo_cache_sentinel")?(C=J=>u(J.target.value),e[22]=C):C=e[22];let N;e[23]!==c||e[24]!==h?(N=r.jsx(rt,{id:"section-rename-name",value:h,onChange:C,autoFocus:!0,disabled:c}),e[23]=c,e[24]=h,e[25]=N):N=e[25];let V;e[26]!==S||e[27]!==N?(V=r.jsxs("div",{className:"space-y-1.5",children:[S,N]}),e[26]=S,e[27]=N,e[28]=V):V=e[28];let E;e[29]!==d?(E=d("sandbox.sectionRenameDialog.keyLabel"),e[29]=d,e[30]=E):E=e[30];let T;e[31]!==E?(T=r.jsx("span",{className:"text-xs font-medium text-muted-foreground",children:E}),e[31]=E,e[32]=T):T=e[32];let k;e[33]!==n?(k=r.jsx(rt,{value:n,readOnly:!0,disabled:!0,className:"font-mono"}),e[33]=n,e[34]=k):k=e[34];let R;e[35]!==T||e[36]!==k?(R=r.jsxs("div",{className:"space-y-1.5",children:[T,k]}),e[35]=T,e[36]=k,e[37]=R):R=e[37];let P;e[38]!==V||e[39]!==R?(P=r.jsxs("div",{className:"space-y-4 py-4",children:[V,R]}),e[38]=V,e[39]=R,e[40]=P):P=e[40];let D;e[41]!==l?(D=()=>l(!1),e[41]=l,e[42]=D):D=e[42];let I;e[43]!==d?(I=d("sandbox.sectionRenameDialog.cancel"),e[43]=d,e[44]=I):I=e[44];let M;e[45]!==c||e[46]!==D||e[47]!==I?(M=r.jsx(le,{type:"button",variant:"outline",onClick:D,disabled:c,children:I}),e[45]=c,e[46]=D,e[47]=I,e[48]=M):M=e[48];let O;e[49]!==c||e[50]!==h?(O=!h.trim()||c,e[49]=c,e[50]=h,e[51]=O):O=e[51];let F;e[52]!==c||e[53]!==d?(F=c?r.jsxs(r.Fragment,{children:[r.jsx(et,{size:14,className:"animate-spin"}),d("sandbox.sectionRenameDialog.saving")]}):d("sandbox.sectionRenameDialog.save"),e[52]=c,e[53]=d,e[54]=F):F=e[54];let $;e[55]!==O||e[56]!==F?($=r.jsx(le,{type:"submit",disabled:O,children:F}),e[55]=O,e[56]=F,e[57]=$):$=e[57];let z;e[58]!==M||e[59]!==$?(z=r.jsxs(Mi,{children:[M,$]}),e[58]=M,e[59]=$,e[60]=z):z=e[60];let K;e[61]!==v||e[62]!==P||e[63]!==z||e[64]!==w?(K=r.jsx(es,{className:"sm:max-w-md",children:r.jsxs("form",{onSubmit:v,children:[w,P,z]})}),e[61]=v,e[62]=P,e[63]=z,e[64]=w,e[65]=K):K=e[65];let X;return e[66]!==g||e[67]!==s||e[68]!==K?(X=r.jsx(ts,{open:s,onOpenChange:g,children:K}),e[66]=g,e[67]=s,e[68]=K,e[69]=X):X=e[69],X}function UP(t){const e=B.c(7),{type:s}=t,n=gw[s];let i;e[0]!==n?(i=r.jsx(Ke,{asChild:!0,children:r.jsx("span",{className:"shrink-0 rounded-full bg-muted px-1.5 py-0.5 text-[10px] font-medium tabular-nums text-muted-foreground",children:n})}),e[0]=n,e[1]=i):i=e[1];const o=s==="permanent"?"Permanent":"Temporary";let a;e[2]!==o?(a=r.jsx(Ue,{side:"left",children:o}),e[2]=o,e[3]=a):a=e[3];let l;return e[4]!==i||e[5]!==a?(l=r.jsxs(He,{children:[i,a]}),e[4]=i,e[5]=a,e[6]=l):l=e[6],l}const od={post:"blog/loaders/Blogpost.ts",author:"blog/loaders/Author.ts",category:"blog/loaders/Category.ts"},bu=["posts","authors","categories"],wo={posts:"post",authors:"author",categories:"category"};function jo(t){return bu.includes(t)}const yu={posts:"post",authors:"author",categories:"category"},n4={posts:od.post,authors:od.author,categories:od.category},HP=Object.fromEntries(Object.entries(n4).map(([t,e])=>[e,t]));function WP(t){return typeof t=="string"?HP[t]??null:null}function ni(t){return t&&typeof t=="object"&&!Array.isArray(t)?t:null}function Pt(t){return typeof t=="string"?t:""}function qP(t,e){switch(t){case"posts":return{label:Pt(e.title)||"Untitled post",subtitle:Pt(e.slug)};case"authors":return{label:Pt(e.name)||"Unnamed author",subtitle:Pt(e.email)};case"categories":return{label:Pt(e.name)||"Unnamed category",subtitle:Pt(e.slug)};default:{const s=t;throw new Error(`Unhandled blog kind: ${String(s)}`)}}}function i4(t){const e={posts:[],authors:[],categories:[]};for(const[s,n]of Object.entries(t)){const i=ni(n);if(!i)continue;const o=WP(i.__resolveType);if(!o)continue;const a=ni(i[yu[o]])??{},{label:l,subtitle:c}=qP(o,a);e[o].push({key:s,kind:o,label:l,subtitle:c})}for(const s of bu)e[s].sort((n,i)=>n.label.localeCompare(i.label));return e}function GP(t,e){return i4(t)[e]}function Ho(t,e){return GP(t,e).map(s=>({key:s.key,payload:Ya(ni(t[s.key])??void 0,e)}))}const Ef=Object.freeze({});function Ya(t,e){return t?ni(t[yu[e]])??Ef:Ef}function Aa(t,e,s){return{name:t,__resolveType:n4[e],[yu[e]]:s}}function r4(t){return`.deco/blocks/${encodeURIComponent(t)}.json`}function SW({records:t,selected:e,valueField:s,toRef:n}){const i=Array.isArray(e)?e:[],o=f=>typeof f=="string"?f:Pt(ni(f)?.[s]),a=f=>typeof f=="string"?f:Pt(ni(f)?.name),l=f=>{const m=o(f),p=m?t.find(({payload:x})=>Pt(x[s])===m):void 0;if(p)return p;const g=a(f);return g?t.find(({payload:x})=>Pt(x.name)===g):void 0},c=t.map(({key:f,payload:m})=>({value:f,label:Pt(m.name)||Pt(m[s])||f})),d=new Map,h=[];return i.forEach((f,m)=>{const p=l(f);if(p){h.includes(p.key)||h.push(p.key);return}const g=`unresolved:${m}`;d.set(g,f),h.push(g),c.push({value:g,label:a(f)||o(f)||"Unknown"})}),{options:c,selectedValues:h,refsForValues:f=>f.map(m=>{const p=t.find(g=>g.key===m);return p?n(p.payload):d.get(m)}).filter(m=>m!==void 0)}}function Ai(t){return Array.isArray(t)?t:[]}function An(t){if(typeof t=="string")return t;const e=ni(t);return e?Pt(e.slug):""}function YP(t){if(typeof t=="string")return t;const e=ni(t);return e?Pt(e.email):""}function JP(t){const e=[];return Pt(t.title).trim()||e.push("Title"),Pt(t.slug).trim()||e.push("Slug"),Ai(t.categories).map(An).filter(Boolean).length===0&&e.push("Category"),Pt(t.excerpt).trim()||e.push("Excerpt"),Pt(t.image).trim()||e.push("Cover image"),e}function o4(t){return Ho(t,"posts").map(({key:e,payload:s})=>({key:e,title:Pt(s.title)||"Untitled post",slug:Pt(s.slug),date:Pt(s.date),categorySlugs:Ai(s.categories).map(An).filter(Boolean),authorEmails:Ai(s.authors).map(YP).filter(Boolean),missing:JP(s)}))}function XP(t,e){const s=Ai(t.categories);return s.some(n=>An(n)===e.slug)?t:{...t,categories:[...s,{name:e.name,slug:e.slug}]}}function QP(t,e){const s=Ai(t.categories);return s.length===1&&An(s[0])===e.slug?t:{...t,categories:[{name:e.name,slug:e.slug}]}}function wW(t,e,s){const n=Ai(t.categories);if(!n.some(l=>An(l)===e))return t;const i=n.map(l=>{const c=An(l);return c===e||c===s.slug?{name:s.name,slug:s.slug}:l}),o=new Set,a=i.filter(l=>{const c=An(l);return c?o.has(c)?!1:(o.add(c),!0):!0});return{...t,categories:a}}function ZP(t,e){const s=Ai(t.categories);return s.some(n=>An(n)===e)?{...t,categories:s.filter(n=>An(n)!==e)}:t}function Pf(t){return{...t,dateModified:new Date().toISOString()}}function n0(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 Rf(t,e){const s=`collections/blog/${e}/${n0(12)}`;if(!Object.hasOwn(t,s))return s;throw new Error("Could not generate a unique blog block key")}function eR(t){switch(t){case"posts":return{title:"Untitled post",excerpt:"",slug:`untitled-${n0(8)}`,date:new Date().toISOString().slice(0,10),image:"",authors:[],categories:[],sections:[]};case"authors":return{name:"New author",type:"Person",email:"",jobTitle:"",company:"",avatar:""};case"categories":return{name:"New category",slug:`category-${n0(8)}`,description:"",sections:[]};default:{const e=t;throw new Error(`Unhandled blog kind: ${String(e)}`)}}}const tR={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"}},Df="Box";function sR(t){return t.startsWith("site/")?"site":"app"}function nR(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 jW(t){const e=new Set,s=[],n=t.manifest?.blocks??{};for(const i of Object.values(n))for(const o of Object.keys(i)){if(!oR(o)||e.has(o))continue;e.add(o);const a=ci(o,t),l=iR(o),c=tR[l],d=sR(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&&nR(f)?f:void 0,p=m!==void 0?c?.iconName??Df:Jr(f,c?.iconName)??Df;s.push({resolveType:o,title:h,description:u,iconName:p,iconUrl:m,source:d})}return s.sort((i,o)=>i.title.localeCompare(o.title))}function iR(t){return(t.split("/").pop()??t).replace(/\.(tsx?|jsx?)$/,"")}const rR=["blog/sections/blocks/","site/sections/Blog/Post/"];function oR(t){return rR.some(e=>t.startsWith(e))}function a4({orgSlug:t,virtualMcpId:e,branch:s}){return at.decofile(`${t}/${e}/${s}`)}function aR({orgSlug:t,virtualMcpId:e,branch:s}){return at.liveMeta(t,e,s)}function lR({orgSlug:t,virtualMcpId:e,branch:s},n){return`/api/${t}/sandbox/${encodeURIComponent(e)}/${encodeURIComponent(s)}/${n}`}async function l4(t,e,s,n){const i=await fetch(lR(t,e),{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(s)});if(!i.ok){const o=await i.json().catch(()=>({}));throw new Error(o.error??`${n} (${i.status})`)}return i.json()}function cR(t){const e=B.c(11),s=Ls();let n;e[0]!==t?(n=l=>{const{blockKey:c,data:d}=l;return l4(t,"write",{path:Pr(t.packagePath,r4(c)),content:JSON.stringify(d,null,2)},"Write failed")},e[0]=t,e[1]=n):n=e[1];let i;e[2]!==t||e[3]!==s?(i=async l=>{const{blockKey:c,data:d}=l,h=a4(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]=i):i=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]!==i||e[9]!==o?(a={mutationFn:n,onMutate:i,onError:o},e[7]=n,e[8]=i,e[9]=o,e[10]=a):a=e[10],Ys(a)}function dR(t){const e=Ls();return Ys({mutationFn:({blockKey:s})=>l4(t,"unlink",{path:Pr(t.packagePath,r4(s))},"Delete failed"),onMutate:async({blockKey:s})=>{const n=a4(t);await e.cancelQueries({queryKey:n});const i=e.getQueryData(n);return e.setQueryData(n,o=>{if(!o)return o;const{[s]:a,...l}=o;return l}),{previous:i,queryKey:n}},onError:(s,n,i)=>{i?.queryKey&&e.setQueryData(i.queryKey,i.previous)},onSuccess:()=>{e.invalidateQueries({queryKey:aR(t)})}})}function uR({open:t,onOpenChange:e,pageKey:s,decofile:n,onSave:i}){const o=re(),a=n[s],l=a===void 0,c=l?"":JSON.stringify(a,null,2),[d,h]=A.useState(!1),[u,f]=A.useState(c),[m,p]=A.useState(!1),g=!i||l,x=u!==c,v=()=>{navigator.clipboard.writeText(u).then(()=>{h(!0),setTimeout(()=>h(!1),2e3)})},b=async _=>{if(!i||m)return;let y;try{y=JSON.parse(_)}catch{ge.error(o("sectionsEditor.pageJsonDialog.invalidJsonError"));return}p(!0);try{await i(y),ge.success(o("sectionsEditor.pageJsonDialog.saveSuccess")),e(!1)}catch(L){ge.error(o("sectionsEditor.pageJsonDialog.saveError",{error:L instanceof Error?L.message:String(L)}))}finally{p(!1)}};return r.jsx(ts,{open:t,onOpenChange:e,children:r.jsxs(es,{className:"max-w-3xl p-0 gap-0",children:[r.jsxs(ms,{className:"px-4 py-3 border-b flex-row items-center justify-between space-y-0",children:[r.jsx(ps,{className:"text-sm font-semibold",children:o("sectionsEditor.pageJsonDialog.title")}),r.jsxs("div",{className:"flex items-center gap-2 mr-8",children:[r.jsxs(le,{variant:"ghost",size:"sm",onClick:v,className:"h-7 gap-1.5 text-xs",children:[d?r.jsx(ec,{size:12}):r.jsx(Os,{size:12}),o(d?"sectionsEditor.pageJsonDialog.copied":"sectionsEditor.pageJsonDialog.copy")]}),!g&&r.jsx(le,{size:"sm",onClick:()=>b(u),disabled:!x||m,className:"h-7 text-xs",children:o(m?"sectionsEditor.pageJsonDialog.saving":"sectionsEditor.pageJsonDialog.save")})]})]}),l?r.jsxs("div",{className:"p-4 text-xs font-mono text-foreground/60",children:["// ",o("sectionsEditor.pageJsonDialog.pageNotFound")]}):r.jsx("div",{className:"h-[70vh]",children:r.jsx(aa,{code:c,language:"json",readOnly:g,height:"100%",onChange:_=>f(_??""),onSave:_=>{b(_)}})})]})})}function Qs(t){const e=B.c(45),{icon:s,logoUrl:n,title:i,subtitle:o,active:a,accent:l,variantCount:c,trailing:d,selectable:h,selectionActive:u,selected:f,invalid:m,invalidReason:p,onToggleSelect:g,onClick:x,menu:v}=t,b=l==="global";let _;e[0]!==s||e[1]!==a||e[2]!==b||e[3]!==n||e[4]!==c?(_=c&&c>1?r.jsx("span",{className:"flex size-8 shrink-0 items-center justify-center",children:r.jsxs(He,{children:[r.jsx(Ke,{asChild:!0,children:r.jsx(s,{size:16,className:"shrink-0 text-success"})}),r.jsxs(Ue,{side:"right",children:[c," variants"]})]})}):n?r.jsx("img",{src:n,alt:"",className:"size-8 shrink-0 rounded-lg object-cover bg-muted"}):r.jsx("span",{className:ie("flex size-8 shrink-0 items-center justify-center rounded-lg",b?"bg-global-section/15":"bg-muted"),children:r.jsx(s,{size:16,className:ie("shrink-0",!b&&(a?"text-accent-foreground":"text-muted-foreground")),style:b?{color:D9}:void 0})}),e[0]=s,e[1]=a,e[2]=b,e[3]=n,e[4]=c,e[5]=_):_=e[5];const y=_,L=a?b?"bg-global-section/15 text-global-section-fg dark:text-global-section-fg-dark":"bg-accent text-accent-foreground":b?"hover:bg-global-section/10":"hover:bg-muted";let w;e[6]!==L?(w=ie("group relative flex min-w-0 items-center rounded-md transition-colors",L),e[6]=L,e[7]=w):w=e[7];let j;e[8]!==g||e[9]!==h||e[10]!==f||e[11]!==u||e[12]!==i?(j=h&&r.jsx("span",{className:ie("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:hR,children:r.jsx(Ar,{checked:f,onCheckedChange:()=>g?.(),"aria-label":`Select ${i}`})}),e[8]=g,e[9]=h,e[10]=f,e[11]=u,e[12]=i,e[13]=j):j=e[13];const S=m&&!a&&"text-destructive";let C;e[14]!==S?(C=ie("block truncate text-sm font-medium",S),e[14]=S,e[15]=C):C=e[15];let N;e[16]!==C||e[17]!==i?(N=r.jsx("span",{className:C,children:i}),e[16]=C,e[17]=i,e[18]=N):N=e[18];const V=a?"text-accent-foreground/70":"text-muted-foreground";let E;e[19]!==V?(E=ie("block truncate text-xs",V),e[19]=V,e[20]=E):E=e[20];let T;e[21]!==o||e[22]!==E?(T=r.jsx("span",{className:E,children:o}),e[21]=o,e[22]=E,e[23]=T):T=e[23];let k;e[24]!==T||e[25]!==N?(k=r.jsxs("span",{className:"min-w-0 flex-1",children:[N,T]}),e[24]=T,e[25]=N,e[26]=k):k=e[26];let R;e[27]!==a||e[28]!==m||e[29]!==p?(R=m&&r.jsxs(He,{children:[r.jsx(Ke,{asChild:!0,children:r.jsx("span",{className:ie("flex shrink-0 items-center",a?"text-accent-foreground":"text-destructive"),children:r.jsx(wn,{size:14})})}),p&&r.jsx(Ue,{side:"bottom",children:p})]}),e[27]=a,e[28]=m,e[29]=p,e[30]=R):R=e[30];let P;e[31]!==x||e[32]!==y||e[33]!==k||e[34]!==R||e[35]!==d?(P=r.jsxs("button",{type:"button",onClick:x,className:"flex min-w-0 flex-1 items-center gap-2.5 rounded-md px-2.5 py-2 text-left cursor-pointer",children:[y,k,R,d]}),e[31]=x,e[32]=y,e[33]=k,e[34]=R,e[35]=d,e[36]=P):P=e[36];let D;e[37]!==a||e[38]!==v?(D=v&&r.jsx("div",{className:ie("pr-1 opacity-0 transition-opacity group-hover:opacity-100",a&&"opacity-100"),children:v}),e[37]=a,e[38]=v,e[39]=D):D=e[39];let I;return e[40]!==P||e[41]!==D||e[42]!==w||e[43]!==j?(I=r.jsxs("div",{className:w,children:[j,P,D]}),e[40]=P,e[41]=D,e[42]=w,e[43]=j,e[44]=I):I=e[44],I}function hR(t){return t.stopPropagation()}function Wn(t){const e=B.c(10),{icon:s,title:n,description:i}=t;let o;e[0]!==s?(o=s&&r.jsx(s,{size:24,className:"text-muted-foreground/60"}),e[0]=s,e[1]=o):o=e[1];let a;e[2]!==n?(a=r.jsx("div",{children:n}),e[2]=n,e[3]=a):a=e[3];let l;e[4]!==i?(l=i&&r.jsx("div",{className:"text-xs text-muted-foreground/80 max-w-sm",children:i}),e[4]=i,e[5]=l):l=e[5];let c;return e[6]!==o||e[7]!==a||e[8]!==l?(c=r.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}var fR=pv.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")}}}),mR=fR;const pR=new Set(["http:","https:","mailto:","tel:","ftp:"]);function gR(t){if(t.startsWith("/")||t.startsWith(".")||t.startsWith("#"))return!0;try{const e=new URL(t,"https://placeholder.invalid");return pR.has(e.protocol)}catch{return!1}}function xR(t){const e=t.trim();return e?e.startsWith("/")||e.startsWith(".")||e.startsWith("#")||/^[a-zA-Z][a-zA-Z0-9+.-]*:/.test(e)?e:`https://${e}`:""}const vR="noopener noreferrer nofollow";function bs(t){const e=B.c(8),{active:s,label:n,onClick:i,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=ie("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]!==i||e[6]!==l?(c=r.jsx("button",{type:"button","aria-label":n,"aria-pressed":s,onMouseDown:bR,onClick:i,className:l,children:o}),e[2]=s,e[3]=o,e[4]=n,e[5]=i,e[6]=l,e[7]=c):c=e[7],c}function bR(t){return t.preventDefault()}function If(t){const e=B.c(7),{active:s,label:n,onSelect:i}=t,o=s?"bg-accent text-accent-foreground":"text-muted-foreground hover:bg-muted hover:text-foreground";let a;e[0]!==o?(a=ie("flex-1 rounded px-2 py-1 text-xs transition-colors cursor-pointer",o),e[0]=o,e[1]=a):a=e[1];let l;return e[2]!==s||e[3]!==n||e[4]!==i||e[5]!==a?(l=r.jsx("button",{type:"button","aria-pressed":s,onMouseDown:yR,onClick:i,className:a,children:n}),e[2]=s,e[3]=n,e[4]=i,e[5]=a,e[6]=l):l=e[6],l}function yR(t){return t.preventDefault()}function _R(t){const e=B.c(36),{editor:s,active:n,open:i,onOpenChange:o}=t,a=re(),[l,c]=A.useState(""),[d,h]=A.useState(!0),[u,f]=A.useState(!1);let m;e[0]!==n||e[1]!==s||e[2]!==o?(m=()=>{const V=s.getAttributes("link");c(typeof V.href=="string"?V.href:""),h(n?V.target==="_blank":!0),f(!1),o(!0)},e[0]=n,e[1]=s,e[2]=o,e[3]=m):m=e[3];const p=m;let g;e[4]!==s||e[5]!==o?(g=()=>{o(!1),s.chain().focus().run()},e[4]=s,e[5]=o,e[6]=g):g=e[6];const x=g;let v;e[7]!==l||e[8]!==s||e[9]!==d||e[10]!==o?(v=()=>{const V=xR(l);if(V===""){s.chain().focus().extendMarkRange("link").unsetLink().run(),o(!1);return}if(!gR(V)){f(!0);return}s.chain().focus().extendMarkRange("link").setLink({href:V,target:d?"_blank":null,rel:d?vR:null}).run(),o(!1)},e[7]=l,e[8]=s,e[9]=d,e[10]=o,e[11]=v):v=e[11];const b=v;let _;e[12]!==s||e[13]!==o?(_=()=>{s.chain().focus().extendMarkRange("link").unsetLink().run(),o(!1)},e[12]=s,e[13]=o,e[14]=_):_=e[14];const y=_;let L;e[15]!==a?(L=a("sectionsEditor.richTextLinkControl.linkButtonLabel"),e[15]=a,e[16]=L):L=e[16];const w=i?x:p;let j;e[17]===Symbol.for("react.memo_cache_sentinel")?(j=r.jsx(u2,{size:14}),e[17]=j):j=e[17];let S;e[18]!==n||e[19]!==L||e[20]!==w?(S=r.jsx(bs,{active:n,label:L,onClick:w,children:j}),e[18]=n,e[19]=L,e[20]=w,e[21]=S):S=e[21];let C;e[22]!==n||e[23]!==b||e[24]!==x||e[25]!==l||e[26]!==u||e[27]!==d||e[28]!==o||e[29]!==i||e[30]!==y||e[31]!==a?(C=i&&r.jsxs("div",{className:"absolute left-0 top-full z-20 mt-1.5 flex w-64 flex-col gap-1 rounded-md border bg-popover p-1 shadow-md",onBlur:V=>{V.currentTarget.contains(V.relatedTarget)||o(!1)},children:[r.jsxs("div",{className:"flex items-center gap-0.5",children:[r.jsx("input",{autoFocus:!0,type:"text","aria-label":a("sectionsEditor.richTextLinkControl.urlInputAriaLabel"),"aria-invalid":u,placeholder:a("sectionsEditor.richTextLinkControl.urlInputPlaceholder"),value:l,onChange:V=>{c(V.target.value),f(!1)},onKeyDown:V=>{V.key==="Enter"?(V.preventDefault(),b()):V.key==="Escape"&&(V.preventDefault(),x())},className:ie("h-7 flex-1 rounded bg-transparent px-2 text-sm text-foreground placeholder:text-muted-foreground focus:outline-none",u&&"text-destructive")}),r.jsx(bs,{active:!1,label:a("sectionsEditor.richTextLinkControl.applyLinkLabel"),onClick:b,children:r.jsx(zt,{size:14})}),n&&r.jsx(bs,{active:!1,label:a("sectionsEditor.richTextLinkControl.removeLinkLabel"),onClick:y,children:r.jsx(Ns,{size:14})})]}),r.jsxs("div",{className:"flex items-center gap-0.5 rounded bg-muted/40 p-0.5",children:[r.jsx(If,{active:!d,label:a("sectionsEditor.richTextLinkControl.sameTabLabel"),onSelect:()=>h(!1)}),r.jsx(If,{active:d,label:a("sectionsEditor.richTextLinkControl.newTabLabel"),onSelect:()=>h(!0)})]})]}),e[22]=n,e[23]=b,e[24]=x,e[25]=l,e[26]=u,e[27]=d,e[28]=o,e[29]=i,e[30]=y,e[31]=a,e[32]=C):C=e[32];let N;return e[33]!==S||e[34]!==C?(N=r.jsxs("div",{className:"relative",children:[S,C]}),e[33]=S,e[34]=C,e[35]=N):N=e[35],N}function LR({schema:t,value:e,onChange:s,path:n,label:i}){const o=typeof e=="string"?e:"",a=A.useRef(s);a.current=s;const[l,c]=A.useState(!1),d=Am({extensions:[Lm.configure({heading:{levels:[1,2,3]},link:{HTMLAttributes:{}}}),mR.configure({types:["heading","paragraph"]})],content:o||"",editorProps:{attributes:{class:ie("prose prose-sm dark:prose-invert max-w-none focus:outline-none","min-h-[80px] px-3 py-2")}},onUpdate:({editor:u})=>{const f=u.getHTML();a.current(f==="<p></p>"?"":f)}}),h=gv({editor:d,selector:({editor:u})=>({bold:u?.isActive("bold")??!1,italic:u?.isActive("italic")??!1,underline:u?.isActive("underline")??!1,strike:u?.isActive("strike")??!1,h1:u?.isActive("heading",{level:1})??!1,h2:u?.isActive("heading",{level:2})??!1,bulletList:u?.isActive("bulletList")??!1,orderedList:u?.isActive("orderedList")??!1,link:u?.isActive("link")??!1,alignLeft:u?.isActive({textAlign:"left"})??!1,alignCenter:u?.isActive({textAlign:"center"})??!1,alignRight:u?.isActive({textAlign:"right"})??!1,alignJustify:u?.isActive({textAlign:"justify"})??!1})});return d?r.jsxs("div",{className:"space-y-2",children:[r.jsxs("div",{className:"space-y-0.5",children:[r.jsx(lt,{htmlFor:n,children:i}),t.description&&r.jsx("p",{className:"text-xs leading-normal text-muted-foreground",children:t.description})]}),r.jsxs("div",{className:"overflow-hidden rounded-md border border-input",children:[r.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:[r.jsx(bs,{active:h.bold,label:"Bold",onClick:()=>d.chain().focus().toggleBold().run(),children:r.jsx(l6,{size:14})}),r.jsx(bs,{active:h.italic,label:"Italic",onClick:()=>d.chain().focus().toggleItalic().run(),children:r.jsx(c6,{size:14})}),r.jsx(bs,{active:h.underline,label:"Underline",onClick:()=>d.chain().focus().toggleUnderline().run(),children:r.jsx(d6,{size:14})}),r.jsx(bs,{active:h.strike,label:"Strikethrough",onClick:()=>d.chain().focus().toggleStrike().run(),children:r.jsx(u6,{size:14})}),r.jsx("div",{className:"mx-0.5 h-4 w-px bg-border"}),r.jsx(bs,{active:h.h1,label:"Heading 1",onClick:()=>d.chain().focus().toggleHeading({level:1}).run(),children:r.jsx(h6,{size:14})}),r.jsx(bs,{active:h.h2,label:"Heading 2",onClick:()=>d.chain().focus().toggleHeading({level:2}).run(),children:r.jsx(f6,{size:14})}),r.jsx("div",{className:"mx-0.5 h-4 w-px bg-border"}),r.jsx(bs,{active:h.bulletList,label:"Bullet list",onClick:()=>d.chain().focus().toggleBulletList().run(),children:r.jsx(e8,{size:14})}),r.jsx(bs,{active:h.orderedList,label:"Ordered list",onClick:()=>d.chain().focus().toggleOrderedList().run(),children:r.jsx("span",{className:"text-[11px] font-semibold leading-none",children:"1."})}),r.jsx("div",{className:"mx-0.5 h-4 w-px bg-border"}),r.jsx(_R,{editor:d,active:h.link,open:l,onOpenChange:c}),r.jsx("div",{className:"mx-0.5 h-4 w-px bg-border"}),r.jsx(bs,{active:h.alignLeft,label:"Align left",onClick:()=>d.chain().focus().setTextAlign("left").run(),children:r.jsx(Qb,{size:14})}),r.jsx(bs,{active:h.alignCenter,label:"Align center",onClick:()=>d.chain().focus().setTextAlign("center").run(),children:r.jsx(m6,{size:14})}),r.jsx(bs,{active:h.alignRight,label:"Align right",onClick:()=>d.chain().focus().setTextAlign("right").run(),children:r.jsx(p6,{size:14})}),r.jsx(bs,{active:h.alignJustify,label:"Justify",onClick:()=>d.chain().focus().setTextAlign("justify").run(),children:r.jsx(g6,{size:14})})]}),r.jsx(Em,{editor:d})]})]}):null}const sr=t=>String(t).padStart(2,"0"),SR="1900-01-01",wR="2099-12-31",jR="1900-01-01T00:00",CR="2099-12-31T23:59";function kR(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()}-${sr(s.getUTCMonth()+1)}-${sr(s.getUTCDate())}`}function VR(t){return!t||!/^\d{4}-\d{2}-\d{2}$/.test(t)?"":`${t}T00:00:00.000Z`}function NR(t){if(!t)return"";const e=new Date(t);return Number.isNaN(e.getTime())?"":`${e.getFullYear()}-${sr(e.getMonth()+1)}-${sr(e.getDate())}T${sr(e.getHours())}:${sr(e.getMinutes())}`}function TR(t){if(!t)return"";const e=new Date(t);return Number.isNaN(e.getTime())?"":e.toISOString()}function AR(t){const e=B.c(41),{id:s,withTime:n,value:i,onChange:o,calendarLabel:a}=t,[l,c]=A.useState(!1);let d;e[0]!==n?(d=M=>n?NR(M):kR(M),e[0]=n,e[1]=d):d=e[1];const h=d;let u;e[2]!==n?(u=M=>n?TR(M):VR(M),e[2]=n,e[3]=u):u=e[3];const f=u;let m;e[4]!==h||e[5]!==i?(m=()=>h(i),e[4]=h,e[5]=i,e[6]=m):m=e[6];const[p,g]=A.useState(m),[x,v]=A.useState(i);if(i!==x){v(i);const M=h(i);M!==p&&g(M)}let b;e[7]!==o||e[8]!==f?(b=M=>{g(M.target.value),o(f(M.target.value))},e[7]=o,e[8]=f,e[9]=b):b=e[9];const _=b;let y;if(e[10]!==i){const M=i?new Date(i):null;y=M&&!Number.isNaN(M.getTime())?M:null,e[10]=i,e[11]=y}else y=e[11];const L=y;let w;e[12]!==o||e[13]!==L||e[14]!==h||e[15]!==n?(w=M=>{if(!M)return;n&&L?M.setHours(L.getHours(),L.getMinutes(),0,0):M.setHours(0,0,0,0);const O=M.toISOString();g(h(O)),v(O),o(O),c(!1)},e[12]=o,e[13]=L,e[14]=h,e[15]=n,e[16]=w):w=e[16];const j=w,S=n?"datetime-local":"date",C=n?jR:SR,N=n?CR:wR;let V;e[17]!==h||e[18]!==i?(V=()=>g(h(i)),e[17]=h,e[18]=i,e[19]=V):V=e[19];let E;e[20]!==_||e[21]!==s||e[22]!==p||e[23]!==V||e[24]!==S||e[25]!==C||e[26]!==N?(E=r.jsx(rt,{id:s,type:S,min:C,max:N,value:p,onChange:_,onBlur:V,className:"h-10 flex-1 [&::-webkit-calendar-picker-indicator]:hidden [&::-webkit-calendar-picker-indicator]:opacity-0"}),e[20]=_,e[21]=s,e[22]=p,e[23]=V,e[24]=S,e[25]=C,e[26]=N,e[27]=E):E=e[27];let T;e[28]===Symbol.for("react.memo_cache_sentinel")?(T=r.jsx(r9,{className:"h-4 w-4"}),e[28]=T):T=e[28];let k;e[29]!==a?(k=r.jsx(Es,{asChild:!0,children:r.jsx(le,{type:"button",variant:"outline",size:"icon",className:"h-10 w-10 shrink-0","aria-label":a,children:T})}),e[29]=a,e[30]=k):k=e[30];const R=L??void 0;let P;e[31]!==j||e[32]!==R?(P=r.jsx(Ps,{className:"w-auto p-0",align:"end",onCloseAutoFocus:ER,children:r.jsx(xv,{mode:"single",selected:R,onSelect:j,initialFocus:!0})}),e[31]=j,e[32]=R,e[33]=P):P=e[33];let D;e[34]!==l||e[35]!==k||e[36]!==P?(D=r.jsxs(As,{open:l,onOpenChange:c,children:[k,P]}),e[34]=l,e[35]=k,e[36]=P,e[37]=D):D=e[37];let I;return e[38]!==E||e[39]!==D?(I=r.jsxs("div",{className:"flex gap-1",children:[E,D]}),e[38]=E,e[39]=D,e[40]=I):I=e[40],I}function ER(t){return t.preventDefault()}function Ea(t){const e=B.c(8),{htmlFor:s,label:n,description:i}=t;let o;e[0]!==s||e[1]!==n?(o=r.jsx(lt,{htmlFor:s,children:n}),e[0]=s,e[1]=n,e[2]=o):o=e[2];let a;e[3]!==i?(a=i&&r.jsx("p",{className:"text-xs leading-normal text-muted-foreground",children:i}),e[3]=i,e[4]=a):a=e[4];let l;return e[5]!==o||e[6]!==a?(l=r.jsxs("div",{className:"space-y-0.5",children:[o,a]}),e[5]=o,e[6]=a,e[7]=l):l=e[7],l}function Pa(t){const e=B.c(70),{schema:s,value:n,onChange:i,path:o,label:a}=t,l=re(),c=typeof n=="string"?n:"",d=s.format;if(d==="rich-text"||d==="rich-text-inline"||d==="html"){let x;return e[0]!==a||e[1]!==i||e[2]!==o||e[3]!==s||e[4]!==n?(x=r.jsx(LR,{schema:s,value:n,onChange:i,path:o,label:a}),e[0]=a,e[1]=i,e[2]=o,e[3]=s,e[4]=n,e[5]=x):x=e[5],x}if(d==="textarea"||d==="markdown"){let x;e[6]!==a||e[7]!==o||e[8]!==s.description?(x=r.jsx(Ea,{htmlFor:o,label:a,description:s.description}),e[6]=a,e[7]=o,e[8]=s.description,e[9]=x):x=e[9];let v;e[10]!==i?(v=y=>i(y.target.value),e[10]=i,e[11]=v):v=e[11];let b;e[12]!==o||e[13]!==c||e[14]!==v?(b=r.jsx(gr,{id:o,value:c,onChange:v,rows:4}),e[12]=o,e[13]=c,e[14]=v,e[15]=b):b=e[15];let _;return e[16]!==x||e[17]!==b?(_=r.jsxs("div",{className:"space-y-2",children:[x,b]}),e[16]=x,e[17]=b,e[18]=_):_=e[18],_}if(d==="date"||d==="date-time"){let x;e[19]!==a||e[20]!==o||e[21]!==s.description?(x=r.jsx(Ea,{htmlFor:o,label:a,description:s.description}),e[19]=a,e[20]=o,e[21]=s.description,e[22]=x):x=e[22];const v=d==="date-time";let b;e[23]!==l?(b=l("sectionsEditor.stringField.openCalendar"),e[23]=l,e[24]=b):b=e[24];let _;e[25]!==i||e[26]!==o||e[27]!==c||e[28]!==v||e[29]!==b?(_=r.jsx(AR,{id:o,withTime:v,value:c,onChange:i,calendarLabel:b}),e[25]=i,e[26]=o,e[27]=c,e[28]=v,e[29]=b,e[30]=_):_=e[30];let y;return e[31]!==x||e[32]!==_?(y=r.jsxs("div",{className:"space-y-2",children:[x,_]}),e[31]=x,e[32]=_,e[33]=y):y=e[33],y}if(d==="color-input"||d==="color"){let x;e[34]!==a||e[35]!==o||e[36]!==s.description?(x=r.jsx(Ea,{htmlFor:o,label:a,description:s.description}),e[34]=a,e[35]=o,e[36]=s.description,e[37]=x):x=e[37];const v=c||"#000000";let b;e[38]!==i?(b=S=>i(S.target.value),e[38]=i,e[39]=b):b=e[39];let _;e[40]!==v||e[41]!==b?(_=r.jsx("input",{type:"color",value:v,onChange:b,className:"h-10 w-10 cursor-pointer rounded-lg border border-border bg-background p-1"}),e[40]=v,e[41]=b,e[42]=_):_=e[42];let y;e[43]!==i?(y=S=>i(S.target.value),e[43]=i,e[44]=y):y=e[44];let L;e[45]!==o||e[46]!==c||e[47]!==y?(L=r.jsx(rt,{id:o,value:c,onChange:y,placeholder:"#000000",className:"h-10 flex-1"}),e[45]=o,e[46]=c,e[47]=y,e[48]=L):L=e[48];let w;e[49]!==_||e[50]!==L?(w=r.jsxs("div",{className:"flex items-center gap-2",children:[_,L]}),e[49]=_,e[50]=L,e[51]=w):w=e[51];let j;return e[52]!==x||e[53]!==w?(j=r.jsxs("div",{className:"space-y-2",children:[x,w]}),e[52]=x,e[53]=w,e[54]=j):j=e[54],j}let h;e[55]!==a||e[56]!==o||e[57]!==s.description?(h=r.jsx(Ea,{htmlFor:o,label:a,description:s.description}),e[55]=a,e[56]=o,e[57]=s.description,e[58]=h):h=e[58];const u=d==="url"?"url":"text";let f;e[59]!==i?(f=x=>i(x.target.value),e[59]=i,e[60]=f):f=e[60];const m=s.default!=null?String(s.default):void 0;let p;e[61]!==o||e[62]!==c||e[63]!==u||e[64]!==f||e[65]!==m?(p=r.jsx(rt,{id:o,type:u,value:c,onChange:f,placeholder:m,className:"h-10"}),e[61]=o,e[62]=c,e[63]=u,e[64]=f,e[65]=m,e[66]=p):p=e[66];let g;return e[67]!==h||e[68]!==p?(g=r.jsxs("div",{className:"space-y-2",children:[h,p]}),e[67]=h,e[68]=p,e[69]=g):g=e[69],g}const PR=/^[+-]?\d*\.?\d*(?:[eE][+-]?\d*)?$/;function RR(t){const e=B.c(18),{schema:s,value:n,onChange:i,path:o,label:a}=t,l=typeof n=="number"?String(n):"",[c,d]=A.useState(l),[h,u]=A.useState(l);l!==h&&(u(l),c!==""&&l!==""&&Number(c)===Number(l)||d(l));let f;e[0]!==a||e[1]!==o?(f=r.jsx(lt,{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&&r.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=r.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]!==i?(x=_=>{const y=_.target.value;if(y!==""&&!PR.test(y))return;d(y);const L=Number(y);i(y===""||Number.isNaN(L)?void 0:L)},e[8]=i,e[9]=x):x=e[9];let v;e[10]!==o||e[11]!==c||e[12]!==g||e[13]!==x?(v=r.jsx(rt,{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 b;return e[15]!==p||e[16]!==v?(b=r.jsxs("div",{className:"space-y-2",children:[p,v]}),e[15]=p,e[16]=v,e[17]=b):b=e[17],b}function DR(t){const e=B.c(17),{value:s,onChange:n,path:i,label:o,schema:a}=t,l=typeof s=="boolean"?s:!1;let c;e[0]!==o||e[1]!==i?(c=r.jsx(lt,{htmlFor:i,children:o}),e[0]=o,e[1]=i,e[2]=c):c=e[2];let d;e[3]!==a.description?(d=a.description&&r.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=r.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]!==i||e[12]!==u?(f=r.jsx(xr,{id:i,checked:l,onCheckedChange:u}),e[10]=l,e[11]=i,e[12]=u,e[13]=f):f=e[13];let m;return e[14]!==h||e[15]!==f?(m=r.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 _u="__enum_empty__";function Lu(t){return t===""?_u:String(t)}function IR(t,e){if(t===_u)return"";const s=e.find(n=>Lu(n)===t);return s!==void 0?s:t}function MR(t,e){return t==null?e.some(s=>s==="")?_u:void 0:Lu(t)}function OR(t){return t===""?"":String(t)}function $R(t){const e=B.c(32),{schema:s,value:n,onChange:i,path:o,label:a}=t,l=re();let c;e[0]!==s.enum?(c=s.enum??[],e[0]=s.enum,e[1]=c):c=e[1];const d=c;let h;e[2]!==d||e[3]!==n?(h=MR(n,d),e[2]=d,e[3]=n,e[4]=h):h=e[4];const u=h;let f;e[5]!==a||e[6]!==o?(f=r.jsx(lt,{htmlFor:o,children:a}),e[5]=a,e[6]=o,e[7]=f):f=e[7];let m;e[8]!==s.description?(m=s.description&&r.jsx("p",{className:"text-xs leading-normal text-muted-foreground",children:s.description}),e[8]=s.description,e[9]=m):m=e[9];let p;e[10]!==f||e[11]!==m?(p=r.jsxs("div",{className:"space-y-0.5",children:[f,m]}),e[10]=f,e[11]=m,e[12]=p):p=e[12];let g;e[13]!==i||e[14]!==d?(g=w=>i(IR(w,d)),e[13]=i,e[14]=d,e[15]=g):g=e[15];let x;e[16]!==l?(x=l("sectionsEditor.enumField.selectPlaceholder"),e[16]=l,e[17]=x):x=e[17];let v;e[18]!==x?(v=r.jsx(Jt,{className:"h-10",children:r.jsx(as,{placeholder:x})}),e[18]=x,e[19]=v):v=e[19];let b;e[20]!==d?(b=d.map(BR),e[20]=d,e[21]=b):b=e[21];let _;e[22]!==b?(_=r.jsx(Xt,{children:b}),e[22]=b,e[23]=_):_=e[23];let y;e[24]!==u||e[25]!==_||e[26]!==g||e[27]!==v?(y=r.jsxs(Qt,{value:u,onValueChange:g,children:[v,_]}),e[24]=u,e[25]=_,e[26]=g,e[27]=v,e[28]=y):y=e[28];let L;return e[29]!==y||e[30]!==p?(L=r.jsxs("div",{className:"space-y-2",children:[p,y]}),e[29]=y,e[30]=p,e[31]=L):L=e[31],L}function BR(t){const e=Lu(t);return r.jsx(vt,{value:e,children:OR(t)},e)}function c4(t){if(!t||typeof t!="object"||Array.isArray(t))return null;const e=t;return Array.isArray(e.variants)?e:null}function Co(t){return c4(t)?.variants?.[0]?.rule?.__resolveType===Rr}function Mf(t){return{__resolveType:Ki,variants:[{value:t,rule:{__resolveType:Rr}}]}}function d4(t){return Co(t)?c4(t)?.variants?.[0]?.value:t}function ho(t){return Co(t)?d4(t):t}function Su(t){const e=t.__resolveType;if(typeof e!="string")return null;if(fs(e)){const n=t.section?.__resolveType;return typeof n=="string"?n:e}return e}function FR(t){return t.includes("flags/multivariate")}function zR(t){return Tt(t)}function KR(t,e){const s=[...t],n=new Set(s.map(o=>o.resolveType)),i=(o,a)=>{!o||n.has(o)||(n.add(o),s.push({resolveType:o,title:a??zR(o)}))};if(e.savedBlockKey&&i(e.savedBlockKey,e.savedBlockKey),e.editorValue&&typeof e.editorValue=="object"&&!Array.isArray(e.editorValue)){const o=Su(e.editorValue);o?.includes("/")&&i(o)}return s}function UR(t,e,s){const n=e[0]?.resolveType??"";if(s)return s;if(!t||typeof t!="object"||Array.isArray(t))return n;const i=t,o=i.__resolveType;if(typeof o=="string"){if(yn(o)){const u=e.find(f=>f.resolveType===o);return u?u.resolveType:o}const d=e.find(u=>Rh(u.resolveType,o));if(d)return d.resolveType;const h=e.find(u=>u.resolveType===o);if(h)return h.resolveType;if(o.includes("/"))return o}const a=typeof i.type=="string"?i.type:void 0;if(a){const d=e.find(h=>h.discriminatorValue===a||h.resolveType===a||Rh(h.resolveType,a));if(d)return d.resolveType}let l=n,c=-1;for(const d of e){if(!d.schema?.properties)continue;const u=Object.keys(d.schema.properties).filter(f=>!f.startsWith("__")&&f!=="@type"&&f!=="action"&&f!=="alt").filter(f=>i[f]!==void 0).length;u>0&&u>c&&(c=u,l=d.resolveType)}return c>0,l}function Of(t,e,s){if(!t||typeof t!="object"||Array.isArray(t))return s??null;const n=Su(t);if(!n)return s??null;if(!e)return n.includes("/")?null:s??null;const i=_n(n,e);return i||(n.includes("/")?null:s??null)}function HR(t,e){if(!t?.properties||!e)return t??null;if(!(e in t.properties))return t;const s={...t.properties};return delete s[e],{...t,properties:s}}function u4(t){if(!t||typeof t!="object"||Array.isArray(t))return null;const e=t;if(typeof e.__resolveType!="string"||!fs(e.__resolveType))return null;const s=e.section;return!s||typeof s!="object"||Array.isArray(s)?null:s}function WR(t,e){if(e)return!0;if(!t||typeof t!="object"||Array.isArray(t))return!1;const s=t,n=Su(s);return n&&FR(n)?Array.isArray(s.variants)&&s.variants.length>0:Object.keys(s).some(i=>!i.startsWith("__")&&i!=="@type")}function wu(t){if(typeof t=="string")return t;if(!t||typeof t!="object")return"";const e=t;if(Array.isArray(e.variants)){const s=e.variants,n=s.find(o=>o.rule?.__resolveType?.includes("always"));if(typeof n?.value=="string")return n.value;const i=s.find(o=>typeof o.value=="string");if(i)return i.value}return typeof e.src=="string"?e.src:typeof e.url=="string"?e.url:typeof e.value=="string"?e.value:""}function qR(t){if(t?.trim())try{const e=new URL(t);return e.protocol!=="https:"?void 0:e.href}catch{return}}function GR(t){if(Array.isArray(t.variants)){const e=t.variants,s=e.find(i=>i.rule?.__resolveType?.includes("always"));if(typeof s?.value=="string")return s.value;const n=e.find(i=>typeof i.value=="string");if(n)return n.value}if(typeof t.src=="string")return t.src;if(typeof t.url=="string")return t.url;if(typeof t.value=="string")return t.value}function h4(t){if(typeof t=="string"||t==null||typeof t!="object")return t;if(Array.isArray(t))return t.map(h4);const e=t;return e.__resolveType?GR(e)??t:f4(e)}function f4(t){const e={};for(const[s,n]of Object.entries(t))e[s]=h4(n);return e}function YR(t,e){return e.split(".").reduce((s,n)=>{if(!(s==null||typeof s!="object"))return s[n]},t)}function m4(t){return t==null?"":Array.isArray(t)?t.map(m4).filter(Boolean).join(","):typeof t=="object"?"":String(t)}function ju(t,e){if(!t.includes("{"))return;const s=f4(e);return t.replace(/\{\{\{([^}]+)\}\}\}|\{\{([^}]+)\}\}/g,(i,o,a)=>{const l=(o??a??"").trim();return m4(YR(s,l))}).trim()||void 0}function JR(t){return t.replace(/<[^>]*>/g,"").trim()}function XR(t,e){if(e.includes("{"))return ju(e,t);const s=t[e];if(typeof s=="string"&&s)return s;if(Array.isArray(s)){const n=s.map(i=>i==null?"":String(i)).filter(Boolean).join(",");if(n)return n}}function vi(t,e,s){if(typeof t=="string")return t.trim()?t:`Item ${e+1}`;if(typeof t=="number"||typeof t=="boolean")return String(t);if(t&&typeof t=="object"&&!Array.isArray(t)){let n=ho(t);const i=u4(n);if(i&&(n=i),s?.titleBy){const a=XR(n,s.titleBy);if(a)return a}for(const a of["name","label","title","alt","text","href","id","key"]){const l=n[a];if(typeof l=="string"&&l.trim()){const c=s?.properties?.[a]?.format;if(c==="rich-text"||c==="html"){const d=JR(l);if(d)return d;continue}return l}if(Array.isArray(l)){const c=l.map(d=>d==null?"":String(d)).filter(Boolean).join(",");if(c)return c}}const o=n.__resolveType;if(typeof o=="string"&&o)return Tt(o);if(s?.title){const a=ju(s.title,n);if(a)return a;if(!s.title.includes("{"))return s.title}}return`Item ${e+1}`}function QR(t){if(!t)return;if(typeof t.image=="string"&&t.image.includes("{"))return t.image;const e=t.properties?.image;if(!e)return;if(e.format==="image-uri")return"{{{image}}}";const s=e.properties;return s?.mobile?"{{{image.mobile}}}":s?.desktop?"{{{image.desktop}}}":"{{{image}}}"}function $f(t,e){if(!t||typeof t!="object"||Array.isArray(t))return;const s=QR(e);if(!s)return;const n=ju(s,t);if(!n)return;const i=wu(n)||n;return qR(i)}function p4(t){return t.replace(/([a-z])([A-Z])/g,"$1 $2").replace(/[_-]/g," ").replace(/^\w/,e=>e.toUpperCase())}function Ei(t){return t.normalize("NFC").trim()}function Bt(t,e){return Ei(t)===Ei(e)}function Bf(t,e){return Ei(t).replace(/\s+/g,"").toLowerCase()===Ei(e).replace(/\s+/g,"").toLowerCase()}function ZR(t,e,s){return(s?.hasSiblingDrillDownFields??!1)||Bt(e,t)||s?.arrayKey!=null&&Bt(e,s.arrayKey)}function Ra(t,e,s,n){const i=Ei(s);if(t.some(a=>Bt(a,i)||Bt(a,s)))return t;const o=[...t];return ZR(e,s,n)&&!o.some(a=>Bt(a,e))&&o.push(e),o.push(s),o}function eD(t,e){return t.slice(0,t.length-e.length)}function tD(t,e,s){if(s.length===0)return s;const n=ko(t,e),i=s[0];return Bt(i,n)||Bt(i,t)?s.slice(1):s}function ko(t,e){return e.title??p4(t)}function CW(t,e){return e<=0?[]:t.slice(0,e)}function Ff(t,e){const s=Ei(e);return t.findIndex(n=>Ei(n)===s)}function i0(t,e){return t.type==="array"&&t.items||jc(t)?!0:Array.isArray(e)}function sD(t){return t!=null&&typeof t=="object"&&!Array.isArray(t)?t:{}}function Wo(t,e,s,n){if(n.length===0)return null;const i=n[0];for(const a of t){const l=e[a];if(!l||!i0(l,s[a]))continue;const c=ko(a,l);if(Bt(i,c)||Bt(i,a)||n.some(d=>Bt(d,c)||Bt(d,a)))return a}for(const a of t){const l=e[a];if(!l||!i0(l,s[a]))continue;const c=s[a];if(!Array.isArray(c))continue;const d=l.items;for(let h=0;h<c.length;h++){const u=vi(c[h],h,d);if(Bt(u,i))return a}}for(const a of t){const l=e[a];if(l?.type!=="object"||!l.properties)continue;const c=Object.keys(l.properties),d=sD(s[a]),h=ko(a,l);if(Wo(c,l.properties,d,n)||(Bt(i,h)||Bt(i,a))&&Wo(c,l.properties,d,n.slice(1)))return a}let o=null;for(const a of t){const l=e[a];if(l?.type!=="block-ref")continue;const c=ko(a,l);if(!(i!==c&&i!==a)){if(n.length>1){const d=s[a];if(d&&typeof d=="object"&&!Array.isArray(d)){const h=n[1];if(Object.keys(d).some(f=>!f.startsWith("__")&&(Bf(p4(f),h)||Bf(f,h))))return a}}o||(o=a)}}return o||null}function nD(t,e,s,n){return Wo(t,e,s,n)}function iD(t,e,s,n,i){if(i.length===0||!s.properties)return!1;const o=Object.keys(s.properties);if(Wo(o,s.properties,n,i))return!0;const a=i[0];return!Bt(a,e)&&!Bt(a,t)?!1:i.length>1||Wo(o,s.properties,n,i.slice(1))!==null}function zf(t,e,s,n){return n!=null&&n>=0&&n<t.length&&Bt(vi(t[n],n,e),s)?n:t.findIndex((i,o)=>Bt(vi(i,o,e),s))}function rD(t,e,s,n,i){if(e.length===0)return null;for(let a=0;a<e.length;a++){const l=e[a],c=zf(s,n,l,i);if(c>=0)return{index:c,innerPath:e.slice(a+1)}}const o=e.findIndex(a=>Bt(a,t));if(o>=0&&e.length>o+1){const a=e[o+1],l=zf(s,n,a,i);if(l>=0)return{index:l,innerPath:e.slice(o+2)}}return null}function ad(t){return t.includes("/sections/")||t.includes("multivariate/section")||t===Dr}function oD(t){if(t.type==="block-ref"&&t.anyOfRefs?.length)return t.anyOfRefs.some(s=>ad(s.resolveType));if(t.anyOfRefs?.length)return t.anyOfRefs.some(s=>ad(s.resolveType));const e=t.properties?.__resolveType;return e?.type==="block-ref"&&e.anyOfRefs?.length?e.anyOfRefs.some(s=>ad(s.resolveType)):!1}function aD(t,e){if(e==="global"||e==="sections"||jc(t))return!0;const s=t.type==="array"?t.items:void 0;return s?oD(s):!1}function Kf(t){return Array.from({length:t},(e,s)=>({id:crypto.randomUUID(),index:s}))}function g4(t){return t.map((e,s)=>({...e,index:s}))}function lD(t,e){if(e===t.length)return t;if(e<t.length)return g4(t.slice(0,e));const s=Array.from({length:e-t.length},(n,i)=>({id:crypto.randomUUID(),index:t.length+i}));return[...t,...s]}function cD(t,e){const s=t.findIndex(o=>o.index===e),n=t.map(o=>o.index>e?{...o,index:o.index+1}:o),i={id:crypto.randomUUID(),index:e+1};return s===-1?[...n,i]:[...n.slice(0,s+1),i,...n.slice(s+1)]}function dD(t,e){return t.filter(s=>s.index!==e).map(s=>s.index>e?{...s,index:s.index-1}:s)}function uD(t){const e=B.c(8),{labelText:s,imageSrc:n}=t;let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i=r.jsx(oa,{className:"size-3.5 shrink-0 text-muted-foreground/40"}),e[0]=i):i=e[0];let o;e[1]!==n?(o=n&&r.jsx("img",{src:n,alt:"",referrerPolicy:"no-referrer",className:"h-12 max-w-[100px] shrink-0 rounded object-cover"}),e[1]=n,e[2]=o):o=e[2];let a;e[3]!==s?(a=r.jsx("span",{className:"min-w-0 truncate",children:s}),e[3]=s,e[4]=a):a=e[4];let l;return e[5]!==o||e[6]!==a?(l=r.jsxs(r.Fragment,{children:[i,r.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-2.5 text-sm",children:[o,a]})]}),e[5]=o,e[6]=a,e[7]=l):l=e[7],l}function hD(t){const e=B.c(50),{sortableId:s,labelText:n,imageSrc:i,hidden:o,onToggleHidden:a,onOpen:l,onDuplicate:c,onRemove:d}=t;let h;e[0]!==s?(h={id:s,animateLayoutChanges:gD},e[0]=s,e[1]=h):h=e[1];const{attributes:u,listeners:f,setNodeRef:m,transform:p,isDragging:g}=ou(h);let x;e[2]!==p?(x=Ln.Transform.toString(p?{...p,x:0}:null),e[2]=p,e[3]=x):x=e[3];const v=g?0:void 0;let b;e[4]!==x||e[5]!==v?(b={transform:x,opacity:v},e[4]=x,e[5]=v,e[6]=b):b=e[6];const _=b;let y;e[7]!==l?(y=z=>{(z.key==="Enter"||z.key===" ")&&(z.preventDefault(),l())},e[7]=l,e[8]=y):y=e[8];const L=g?"cursor-grabbing":"cursor-pointer";let w;e[9]!==L?(w=ie("group flex min-w-0 items-center gap-2.5 rounded-lg px-2 py-2.5 hover:bg-accent hover:text-accent-foreground touch-none",L),e[9]=L,e[10]=w):w=e[10];let j;e[11]===Symbol.for("react.memo_cache_sentinel")?(j=r.jsx(oa,{className:"size-3.5 shrink-0 text-muted-foreground/40"}),e[11]=j):j=e[11];let S;e[12]!==i?(S=i&&r.jsx("img",{src:i,alt:"",referrerPolicy:"no-referrer",className:"h-12 max-w-[100px] shrink-0 rounded object-cover"}),e[12]=i,e[13]=S):S=e[13];const C=o&&"line-through opacity-50";let N;e[14]!==C?(N=ie("min-w-0 flex-1 truncate text-sm",C),e[14]=C,e[15]=N):N=e[15];let V;e[16]!==n||e[17]!==N?(V=r.jsx("span",{className:N,children:n}),e[16]=n,e[17]=N,e[18]=V):V=e[18];let E;e[19]!==o||e[20]!==a?(E=a&&r.jsxs(He,{children:[r.jsx(Ke,{asChild:!0,children:r.jsx(le,{type:"button",variant:"ghost",size:"icon","aria-label":o?"Show item":"Hide item",className:ie("size-6 shrink-0",o?"opacity-100":"opacity-0 transition-opacity group-hover:opacity-100"),onClick:z=>{z.stopPropagation(),a()},onPointerDown:pD,children:o?r.jsx(j6,{size:14}):r.jsx(x9,{size:14})})}),r.jsx(Ue,{side:"bottom",children:o?"Show item":"Hide item"})]}),e[19]=o,e[20]=a,e[21]=E):E=e[21];const T=`Open actions for ${n}`;let k;e[22]===Symbol.for("react.memo_cache_sentinel")?(k=r.jsx(ai,{size:14}),e[22]=k):k=e[22];let R;e[23]!==T?(R=r.jsx(ds,{asChild:!0,children:r.jsx(le,{type:"button",variant:"ghost",size:"icon","aria-label":T,className:"size-6 shrink-0 opacity-0 transition-opacity group-hover:opacity-100",onClick:mD,onPointerDown:fD,children:k})}),e[23]=T,e[24]=R):R=e[24];let P;e[25]===Symbol.for("react.memo_cache_sentinel")?(P=r.jsx(Os,{size:14}),e[25]=P):P=e[25];let D;e[26]!==c?(D=r.jsxs(Xe,{onClick:c,children:[P,"Duplicate"]}),e[26]=c,e[27]=D):D=e[27];let I;e[28]===Symbol.for("react.memo_cache_sentinel")?(I=r.jsx(Ns,{size:14}),e[28]=I):I=e[28];let M;e[29]!==d?(M=r.jsxs(Xe,{className:"text-destructive focus:text-destructive",onClick:d,children:[I,"Delete"]}),e[29]=d,e[30]=M):M=e[30];let O;e[31]!==D||e[32]!==M?(O=r.jsxs(hs,{align:"end",children:[D,M]}),e[31]=D,e[32]=M,e[33]=O):O=e[33];let F;e[34]!==R||e[35]!==O?(F=r.jsxs(us,{children:[R,O]}),e[34]=R,e[35]=O,e[36]=F):F=e[36];let $;return e[37]!==u||e[38]!==n||e[39]!==f||e[40]!==l||e[41]!==m||e[42]!==_||e[43]!==V||e[44]!==E||e[45]!==F||e[46]!==y||e[47]!==w||e[48]!==S?($=r.jsxs("div",{ref:m,style:_,...u,...f,role:"button",tabIndex:0,onClick:l,onKeyDown:y,className:w,title:n,children:[j,S,V,E,F]}),e[37]=u,e[38]=n,e[39]=f,e[40]=l,e[41]=m,e[42]=_,e[43]=V,e[44]=E,e[45]=F,e[46]=y,e[47]=w,e[48]=S,e[49]=$):$=e[49],$}function fD(t){return t.stopPropagation()}function mD(t){return t.stopPropagation()}function pD(t){return t.stopPropagation()}function gD(){return!1}function xD(t,e,s,n,i){if(e?.type==="object"&&e.properties&&Object.keys(e.properties).length>0||e?.type==="block-ref"&&e.anyOfRefs?.length)return e;if(t!=null&&typeof t=="object"&&!Array.isArray(t)){const o=t.__resolveType;if(typeof o=="string"&&s){const a=_n(o,s);if(a?.properties&&Object.keys(a.properties).length>0)return a}}if(s&&n&&i){const a=_n(n,s)?.properties?.[i]?.items;if(a?.properties&&Object.keys(a.properties).length>0)return{...a,titleBy:a.titleBy??e?.titleBy}}return e}function vD(t){const e=t.split(".").filter(s=>!/^\d+$/.test(s));return e[e.length-1]??t}function Da(t){const e=B.c(27),{schema:s,value:n,onChange:i,path:o,label:a,breadcrumbPath:l,onBreadcrumbChange:c,hasSiblingDrillDownFields:d,meta:h,decofile:u,onSaveReferencedBlock:f,containerResolveType:m,previewBaseUrl:p,onAddSectionItem:g,onRequestAddSection:x,sandbox:v}=t,b=l===void 0?[]:l,_=re(),y=Array.isArray(n)?n:[],L=s.items,w=vD(o),j={arrayKey:w,hasSiblingDrillDownFields:d},S=aD(s,w),C=!S&&L?.type==="object",[N,V]=A.useState(null),E=rD(a,b,y,L,N),T=E?.index??null;E===null?N!==null&&V(null):E.index!==N&&V(E.index);const[k,R]=A.useState(()=>Kf(y.length)),[P,D]=A.useState(null),[I,M]=A.useState(o),[O,F]=A.useState(y.length),$=A.useRef(!1);I!==o?(M(o),F(y.length),R(Kf(y.length)),V(null)):O!==y.length&&(F(y.length),R(ve=>lD(ve,y.length)));let z;e[0]!==L?(z=(ve,Se)=>vi(ho(ve),Se,L),e[0]=L,e[1]=z):z=e[1];const K=z,X=ve=>{if($.current)return;const Se=K(y[ve],ve);V(ve),c?.(Ra(b,a,Se,j))},J=ve=>{const Se=[...y,ve];i(Se);const Be=Se.length-1;V(Be);const Ce=vi(ve,Be,L);c?.(Ra(b,a,Ce,j))},H=()=>{const ve=L?.type,Se=L?.default!==void 0?L.default:ve==="object"?{}:ve==="block-ref"?(()=>{const ze=L?.anyOfRefs?.[0]?.resolveType;return typeof ze!="string"||yo(ze)?{}:{__resolveType:ze}})():ve==="number"||ve==="integer"?0:ve==="boolean"?!1:ve==="array"?[]:"",Be=[...y,Se];i(Be);const Ce=Be.length-1;V(Ce);const ke=vi(Se,Ce,L);c?.(Ra(b,a,ke,j))},W=()=>{if(S){if(!p){ge.error(_("sectionsEditor.arrayField.startPreviewServer"));return}if(x){x({append:J});return}ge.error(_("sectionsEditor.arrayField.sectionPickerNotAvailable"));return}H()},U=ve=>{const Se=y[ve],Be=typeof structuredClone=="function"?structuredClone(Se):JSON.parse(JSON.stringify(Se??null)),Ce=[...y.slice(0,ve+1),Be,...y.slice(ve+1)];i(Ce),R(ke=>cD(ke,ve))},Q=ve=>{const Se=y[ve],Be=[...y];Be[ve]=Co(Se)?d4(Se):Mf(Se),i(Be)},q=ve=>{i(y.filter((Se,Be)=>Be!==ve)),R(Se=>dD(Se,ve))},Z=(ve,Se)=>{const Be=[...y];if(Be[ve]=Co(y[ve])?Mf(Se):Se,i(Be),ve===T&&T!==null){const Ce=K(y[ve],ve),ke=vi(Se,ve,L);if(Ce!==ke){const ze=Ff(b,Ce);if(ze>=0){const nt=[...b];nt[ze]=ke,c?.(nt)}}}};let Y;e[2]===Symbol.for("react.memo_cache_sentinel")?(Y={activationConstraint:{distance:8}},e[2]=Y):Y=e[2];let ee;e[3]===Symbol.for("react.memo_cache_sentinel")?(ee={coordinateGetter:au},e[3]=ee):ee=e[3];const G=gc(si(Br,Y),si($r,ee)),te=k.map(bD);let se;e[4]===Symbol.for("react.memo_cache_sentinel")?(se=ve=>{D(String(ve.active.id))},e[4]=se):se=e[4];const ne=se,de=ve=>{D(null);const{active:Se,over:Be}=ve;if(!Be||Se.id===Be.id)return;const Ce=te.indexOf(String(Se.id)),ke=te.indexOf(String(Be.id));Ce===-1||ke===-1||(R(ze=>g4(_r([...ze],Ce,ke))),i(_r([...y],Ce,ke)),$.current=!0,requestAnimationFrame(()=>{$.current=!1}))};let xe;e[5]===Symbol.for("react.memo_cache_sentinel")?(xe=()=>{D(null)},e[5]=xe):xe=e[5];const he=xe,ce=P?k.find(ve=>ve.id===P):null,oe=ce!=null?y[ce.index]:void 0,me=ce!=null&&oe!==void 0?K(oe,ce.index):null,pe=ce!=null&&oe!==void 0?$f(ho(oe),L):void 0;if(T!==null&&T<y.length){const ve=ho(y[T]),Se=xD(ve,L,h,m,w),Be=()=>{const Ce=K(ve,T),ke=Ra(b,a,Ce,j),ze=Ff(ke,Ce);return ze>=0?ke.slice(0,ze+1):ke};return r.jsx("div",{className:"min-w-0",children:Se?.type==="object"&&Se.properties?r.jsx(In,{schema:Se,value:ve,onChange:Ce=>Z(T,Ce),basePath:`${o}.${T}`,breadcrumbPath:E?.innerPath??[],onBreadcrumbChange:Ce=>{c?.([...Be(),...Ce])},meta:h,decofile:u,onSaveReferencedBlock:f,previewBaseUrl:p,onAddSectionItem:g,onRequestAddSection:x,sandbox:v}):Se?qo({schema:Se,value:ve,onChange:Ce=>Z(T,Ce),path:`${o}.${T}`,label:Se.title&&!Se.title.includes("{{")?Se.title:K(ve,T),breadcrumbPath:E?.innerPath??[],onBreadcrumbChange:Ce=>{c?.([...Be(),...Ce])},meta:h,decofile:u,onSaveReferencedBlock:f,previewBaseUrl:p,onAddSectionItem:g,onRequestAddSection:x,sandbox:v}):null})}const we="space-y-2";let Ne;e[6]!==a?(Ne=r.jsx("span",{className:"min-w-0 truncate text-sm font-medium",children:a}),e[6]=a,e[7]=Ne):Ne=e[7];const Oe=y.length>0&&r.jsx("span",{className:"rounded-md bg-muted px-1.5 py-0.5 text-xs font-medium text-muted-foreground",children:y.length});let ye;e[8]!==Ne||e[9]!==Oe?(ye=r.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[Ne,Oe]}),e[8]=Ne,e[9]=Oe,e[10]=ye):ye=e[10];let je;e[11]!==s.description?(je=s.description&&r.jsx("p",{className:"break-words text-xs leading-normal text-muted-foreground",children:s.description}),e[11]=s.description,e[12]=je):je=e[12];let Pe;e[13]!==ye||e[14]!==je?(Pe=r.jsxs("div",{className:"min-w-0 space-y-0.5",children:[ye,je]}),e[13]=ye,e[14]=je,e[15]=Pe):Pe=e[15];const Ee=y.length>0&&r.jsx("div",{className:ie(P&&"cursor-grabbing"),children:r.jsxs(yc,{sensors:G,collisionDetection:J9,onDragStart:ne,onDragEnd:de,onDragCancel:he,children:[r.jsx(ru,{items:te,strategy:iu,children:r.jsx("div",{className:"min-w-0 overflow-hidden rounded-xl border border-border/50 p-1.5",children:k.map(ve=>{const Se=y[ve.index];if(Se===void 0)return null;const Be=K(Se,ve.index),Ce=$f(ho(Se),L);return r.jsx(hD,{sortableId:ve.id,labelText:Be,imageSrc:Ce,hidden:Co(Se),onToggleHidden:C?()=>Q(ve.index):void 0,onOpen:()=>X(ve.index),onDuplicate:()=>U(ve.index),onRemove:()=>q(ve.index)},ve.id)})})}),r.jsx(eu,{dropAnimation:null,children:me?r.jsx("div",{className:"flex min-w-0 items-center gap-2.5 rounded-lg border border-border/60 bg-background px-2 py-2.5 shadow-lg ring-1 ring-border/60",children:r.jsx(uD,{labelText:me,imageSrc:pe})}):null})]})});let be;e[16]===Symbol.for("react.memo_cache_sentinel")?(be=r.jsx(kt,{size:14}),e[16]=be):be=e[16];let Ve;e[17]!==_||e[18]!==S?(Ve=_(S?"sectionsEditor.arrayField.addSection":"sectionsEditor.arrayField.addItem"),e[17]=_,e[18]=S,e[19]=Ve):Ve=e[19];let Re;e[20]!==W||e[21]!==Ve?(Re=r.jsxs("button",{type:"button",onClick:W,className:"flex w-full items-center justify-center gap-1.5 rounded-xl border border-dashed border-border/60 py-2.5 text-sm text-muted-foreground transition-colors hover:border-border hover:bg-muted/30",children:[be,Ve]}),e[20]=W,e[21]=Ve,e[22]=Re):Re=e[22];let Le;return e[23]!==Pe||e[24]!==Ee||e[25]!==Re?(Le=r.jsxs("div",{className:we,children:[Pe,Ee,Re]}),e[23]=Pe,e[24]=Ee,e[25]=Re,e[26]=Le):Le=e[26],Le}function bD(t){return t.id}function yD(t){const e=B.c(44),{schema:s,value:n,onChange:i,path:o,label:a,breadcrumbPath:l,onBreadcrumbChange:c,meta:d,decofile:h,onSaveReferencedBlock:u,previewBaseUrl:f,onAddSectionItem:m,onRequestAddSection:p,sandbox:g}=t;let x;e[0]!==l?(x=l===void 0?[]:l,e[0]=l,e[1]=x):x=e[1];const v=x,[b,_]=A.useState(!1);let y;e[2]!==n?(y=n!=null&&typeof n=="object"&&!Array.isArray(n)?n:{},e[2]=n,e[3]=y):y=e[3];const L=y;if(!s.properties)return null;let w;e[4]!==o?(w=o.split(".").pop()??o,e[4]=o,e[5]=w):w=e[5];const j=w;let S;e[6]!==v||e[7]!==j||e[8]!==a||e[9]!==L||e[10]!==s?(S=iD(j,a,s,L,v),e[6]=v,e[7]=j,e[8]=a,e[9]=L,e[10]=s,e[11]=S):S=e[11];const N=b||S,V=`${o}-fields`;let E;e[12]===Symbol.for("react.memo_cache_sentinel")?(E=()=>_(_D),e[12]=E):E=e[12];let T;e[13]!==N?(T=r.jsx("span",{className:"flex size-7 shrink-0 items-center justify-center rounded-md text-muted-foreground transition-colors group-hover:text-accent-foreground",children:N?r.jsx(ss,{size:16}):r.jsx(bn,{size:16})}),e[13]=N,e[14]=T):T=e[14];let k;e[15]!==a?(k=r.jsx("span",{className:"min-w-0 truncate text-sm font-medium",children:a}),e[15]=a,e[16]=k):k=e[16];let R;e[17]!==V||e[18]!==N||e[19]!==T||e[20]!==k?(R=r.jsxs("button",{type:"button","aria-expanded":N,"aria-controls":V,onClick:E,className:"group flex w-full min-w-0 items-center gap-2 rounded-md py-1.5 pr-2 text-left transition-colors hover:bg-accent hover:text-accent-foreground",children:[T,k]}),e[17]=V,e[18]=N,e[19]=T,e[20]=k,e[21]=R):R=e[21];let P;e[22]!==s.description?(P=s.description&&r.jsx("p",{className:"break-words pl-9 text-xs leading-normal text-muted-foreground",children:s.description}),e[22]=s.description,e[23]=P):P=e[23];let D;e[24]!==v||e[25]!==V||e[26]!==h||e[27]!==N||e[28]!==d||e[29]!==L||e[30]!==m||e[31]!==c||e[32]!==i||e[33]!==p||e[34]!==u||e[35]!==o||e[36]!==f||e[37]!==g||e[38]!==s?(D=N&&r.jsx("div",{id:V,className:"ml-3 min-w-0 max-w-full overflow-hidden border-l border-border/80 pl-5",children:r.jsx(In,{schema:s,value:L,onChange:i,basePath:o,breadcrumbPath:v,onBreadcrumbChange:c,meta:d,decofile:h,onSaveReferencedBlock:u,previewBaseUrl:f,onAddSectionItem:m,onRequestAddSection:p,sandbox:g})}),e[24]=v,e[25]=V,e[26]=h,e[27]=N,e[28]=d,e[29]=L,e[30]=m,e[31]=c,e[32]=i,e[33]=p,e[34]=u,e[35]=o,e[36]=f,e[37]=g,e[38]=s,e[39]=D):D=e[39];let I;return e[40]!==P||e[41]!==D||e[42]!==R?(I=r.jsxs("div",{className:"min-w-0 space-y-2",children:[R,P,D]}),e[40]=P,e[41]=D,e[42]=R,e[43]=I):I=e[43],I}function _D(t){return!t}function kW(t,e,s,n,i){const o={...t[e]};if(i.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 VW(t){return structuredClone(t)}function NW(t){return!t.isSavedBlock&&!t.isMultivariate&&!t.isHidden}function x4(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 Cu(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 ku(t){const e=B.c(61),{open:s,onOpenChange:n,defaultBlockId:i,isPending:o,onSubmit:a}=t,l=i===void 0?"":i,c=o===void 0?!1:o,[d,h]=A.useState(l),[u,f]=A.useState(s);s!==u&&(f(s),s&&h(l));let m;e[0]!==c||e[1]!==n?(m=$=>{!$&&!c&&n(!1)},e[0]=c,e[1]=n,e[2]=m):m=e[2];const p=m;let g;e[3]!==d||e[4]!==c||e[5]!==a?(g=async $=>{$.preventDefault();const z=d.trim();!z||c||await a(z)},e[3]=d,e[4]=c,e[5]=a,e[6]=g):g=e[6];const x=g,v=re();let b;e[7]!==v?(b=v("sectionsEditor.makeReusableModal.title"),e[7]=v,e[8]=b):b=e[8];let _;e[9]!==b?(_=r.jsx(ps,{children:b}),e[9]=b,e[10]=_):_=e[10];let y;e[11]!==v?(y=v("sectionsEditor.makeReusableModal.description"),e[11]=v,e[12]=y):y=e[12];let L;e[13]!==y?(L=r.jsx(oi,{children:y}),e[13]=y,e[14]=L):L=e[14];let w;e[15]!==_||e[16]!==L?(w=r.jsxs(ms,{children:[_,L]}),e[15]=_,e[16]=L,e[17]=w):w=e[17];let j;e[18]!==v?(j=v("sectionsEditor.makeReusableModal.blockNameLabel"),e[18]=v,e[19]=j):j=e[19];let S;e[20]!==j?(S=r.jsx("label",{htmlFor:"block-id",className:"text-sm font-medium",children:j}),e[20]=j,e[21]=S):S=e[21];let C;e[22]===Symbol.for("react.memo_cache_sentinel")?(C=$=>h($.target.value),e[22]=C):C=e[22];let N;e[23]!==v?(N=v("sectionsEditor.makeReusableModal.blockNamePlaceholder"),e[23]=v,e[24]=N):N=e[24];let V;e[25]!==d||e[26]!==c||e[27]!==N?(V=r.jsx(rt,{id:"block-id",value:d,onChange:C,placeholder:N,autoFocus:!0,disabled:c}),e[25]=d,e[26]=c,e[27]=N,e[28]=V):V=e[28];let E;e[29]!==S||e[30]!==V?(E=r.jsxs("div",{className:"py-4 space-y-2",children:[S,V]}),e[29]=S,e[30]=V,e[31]=E):E=e[31];let T;e[32]!==n?(T=()=>n(!1),e[32]=n,e[33]=T):T=e[33];let k;e[34]!==v?(k=v("sectionsEditor.makeReusableModal.cancel"),e[34]=v,e[35]=k):k=e[35];let R;e[36]!==c||e[37]!==T||e[38]!==k?(R=r.jsx(le,{type:"button",variant:"outline",onClick:T,disabled:c,children:k}),e[36]=c,e[37]=T,e[38]=k,e[39]=R):R=e[39];let P;e[40]!==d||e[41]!==c?(P=!d.trim()||c,e[40]=d,e[41]=c,e[42]=P):P=e[42];let D;e[43]!==c||e[44]!==v?(D=c?r.jsxs(r.Fragment,{children:[r.jsx(et,{size:14,className:"animate-spin"}),v("sectionsEditor.makeReusableModal.saving")]}):v("sectionsEditor.makeReusableModal.save"),e[43]=c,e[44]=v,e[45]=D):D=e[45];let I;e[46]!==P||e[47]!==D?(I=r.jsx(le,{type:"submit",disabled:P,children:D}),e[46]=P,e[47]=D,e[48]=I):I=e[48];let M;e[49]!==R||e[50]!==I?(M=r.jsxs(Mi,{children:[R,I]}),e[49]=R,e[50]=I,e[51]=M):M=e[51];let O;e[52]!==x||e[53]!==E||e[54]!==M||e[55]!==w?(O=r.jsx(es,{className:"sm:max-w-md",children:r.jsxs("form",{onSubmit:x,children:[w,E,M]})}),e[52]=x,e[53]=E,e[54]=M,e[55]=w,e[56]=O):O=e[56];let F;return e[57]!==p||e[58]!==s||e[59]!==O?(F=r.jsx(ts,{open:s,onOpenChange:p,children:O}),e[57]=p,e[58]=s,e[59]=O,e[60]=F):F=e[60],F}function v4(t){return t===Dr||t===Ki}function Vc(t,e){if(!Object.hasOwn(e,t))return null;const s=e[t]??{},n=s.__resolveType??t;return{data:{...s},resolveType:n}}function Ml(t,e){const s=t.__resolveType??"";if(!s)return null;if(fs(s)){const n=t.section??{};return b4(n,e)}if(v4(s)){const n=t.variants?.[0]?.value;return n?Ml(n,e):null}return!yn(s)||!Object.hasOwn(e,s)?{data:{...t},resolveType:s}:Vc(s,e)}function b4(t,e){const s=t.__resolveType??"";if(!s)return null;if(v4(s)){const n=t.variants?.[0]?.value;return n?Ml(n,e):null}return!yn(s)||!Object.hasOwn(e,s)?{data:{...t},resolveType:s}:Vc(s,e)}function LD(t,e){if(!t||typeof t!="object"||Array.isArray(t))return null;const n=t.__resolveType;if(typeof n!="string"||!yn(n)||!Object.hasOwn(e,n))return null;const i=Vc(n,e);return i?{blockKey:n,...i}:null}function SD(t,e,s){if(e.isMultivariate)return null;if(e.isSavedBlock){const n=e.isLazy?t.section?.__resolveType??t.__resolveType:t.__resolveType;return Vc(n,s)}if(e.isHidden){const o=(fs(t.__resolveType)?t.section:t)?.variants?.[0]?.value??t;return Ml(o,s)}if(e.isLazy||fs(t.__resolveType)){const n=t.section??{};return b4(n,s)}return Ml(t,s)}function wD(t){if(!t?.properties)return{};const e={};for(const[s,n]of Object.entries(t.properties))s.startsWith("__")||s==="@type"||(n.default!==void 0?e[s]=n.default:n.type==="boolean"?e[s]=!1:n.type==="string"?e[s]="":n.type==="number"||n.type==="integer"?e[s]=0:n.type==="object"&&(e[s]={}));return e}function jD(t){const e=B.c(13),{blockKey:s}=t,n=re();let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i=r.jsx(li,{size:11}),e[0]=i):i=e[0];let o;e[1]!==n?(o=n("sectionsEditor.anyOfField.global"),e[1]=n,e[2]=o):o=e[2];let a;e[3]!==o?(a=r.jsx(Ke,{asChild:!0,children:r.jsxs("span",{className:"inline-flex shrink-0 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,o]})}),e[3]=o,e[4]=a):a=e[4];let l;e[5]!==s||e[6]!==n?(l=n("sectionsEditor.anyOfField.globalLoaderTooltip",{blockKey:s}),e[5]=s,e[6]=n,e[7]=l):l=e[7];let c;e[8]!==l?(c=r.jsx(Ue,{side:"top",className:"max-w-[260px]",children:l}),e[8]=l,e[9]=c):c=e[9];let d;return e[10]!==a||e[11]!==c?(d=r.jsxs(He,{children:[a,c]}),e[10]=a,e[11]=c,e[12]=d):d=e[12],d}function CD(t){const e=B.c(36),{path:s,open:n,onOpenChange:i,title:o,nested:a,nestedBlockRef:l,globalBlockKey:c,onDetach:d,onMakeGlobal:h}=t,u=re(),f=`${s}-loader-config`,m=l&&"ml-1";let p;e[0]!==m?(p=ie("rounded-lg border border-border/80 bg-muted/30",m),e[0]=m,e[1]=p):p=e[1];let g;e[2]!==i||e[3]!==n?(g=()=>i(!n),e[2]=i,e[3]=n,e[4]=g):g=e[4];let x;e[5]!==n?(x=r.jsx("span",{className:"flex size-6 shrink-0 items-center justify-center text-muted-foreground transition-colors group-hover:text-foreground",children:n?r.jsx(ss,{size:16}):r.jsx(bn,{size:16})}),e[5]=n,e[6]=x):x=e[6];let v;e[7]!==o?(v=r.jsx("span",{className:"truncate text-xs font-medium tracking-wide text-muted-foreground uppercase",children:o}),e[7]=o,e[8]=v):v=e[8];let b;e[9]!==c?(b=c&&r.jsx(jD,{blockKey:c}),e[9]=c,e[10]=b):b=e[10];let _;e[11]!==v||e[12]!==b?(_=r.jsxs("span",{className:"flex min-w-0 items-center gap-2",children:[v,b]}),e[11]=v,e[12]=b,e[13]=_):_=e[13];let y;e[14]!==f||e[15]!==n||e[16]!==g||e[17]!==x||e[18]!==_?(y=r.jsxs("button",{type:"button","aria-expanded":n,"aria-controls":f,onClick:g,className:"flex min-w-0 flex-1 items-center gap-2 rounded-lg px-3 py-2.5 text-left",children:[x,_]}),e[14]=f,e[15]=n,e[16]=g,e[17]=x,e[18]=_,e[19]=y):y=e[19];let L;e[20]!==c||e[21]!==d||e[22]!==h||e[23]!==u?(L=(d||h)&&r.jsxs(us,{children:[r.jsx(ds,{asChild:!0,children:r.jsx(le,{type:"button",variant:"ghost",size:"icon","aria-label":u("sectionsEditor.anyOfField.loaderActions"),className:"h-7 w-7 shrink-0 text-muted-foreground",children:r.jsx(ai,{size:16})})}),r.jsxs(hs,{align:"end",className:"w-48",children:[c&&d&&r.jsxs(Xe,{onClick:d,children:[r.jsx(Nn,{className:"h-4 w-4"}),u("sectionsEditor.anyOfField.detach")]}),!c&&h&&r.jsxs(Xe,{onClick:h,children:[r.jsx(li,{className:"h-4 w-4"}),u("sectionsEditor.anyOfField.makeGlobal")]})]})]}),e[20]=c,e[21]=d,e[22]=h,e[23]=u,e[24]=L):L=e[24];let w;e[25]!==y||e[26]!==L?(w=r.jsxs("div",{className:"group flex w-full min-w-0 items-center gap-1 rounded-lg pr-2 transition-colors hover:bg-accent/50",children:[y,L]}),e[25]=y,e[26]=L,e[27]=w):w=e[27];let j;e[28]!==f||e[29]!==a||e[30]!==n?(j=n&&r.jsx("div",{id:f,className:"border-t border-border/60 px-4 pb-4 pt-3",children:r.jsx("div",{className:"border-l border-border/80 pl-4",children:a})}),e[28]=f,e[29]=a,e[30]=n,e[31]=j):j=e[31];let S;return e[32]!==w||e[33]!==j||e[34]!==p?(S=r.jsxs("div",{className:p,children:[w,j]}),e[32]=w,e[33]=j,e[34]=p,e[35]=S):S=e[35],S}function Uf(t){const e=B.c(38),{schema:s,value:n,onChange:i,path:o,label:a,breadcrumbPath:l,onBreadcrumbChange:c,meta:d,decofile:h,onSaveReferencedBlock:u,sandbox:f}=t,m=re(),p=(s.anyOfRefs??[]).filter(ND),g=h&&n?LD(n,h):null,x=g?.data??n,v=g?null:u4(x),b=v??x,_=KR(p,{savedBlockKey:g?.blockKey,editorValue:x}),y=_.length>0?UR(x,_,g?.blockKey):_[0]?.resolveType??"",w=s.type==="block-ref"&&_.some(VD);let j;e[0]!==a||e[1]!==o?(j=a??(o.includes(".")?o.split(".")[0]:o),e[0]=a,e[1]=o,e[2]=j):j=e[2];const S=j;let C;e[3]!==l?(C=l??[],e[3]=l,e[4]=C):C=e[4];const N=C,V=w&&N[0]===S,E=V?N.slice(1):N,T=V?U=>{c?.([S,...U])}:c,[k,R]=A.useState(y),[P,D]=A.useState(y);P!==y&&(D(y),R(y));const[I,M]=A.useState(()=>WR(x,g?.blockKey)),[O,F]=A.useState(!1);if(_.length>0){const U=k||y;let Q;e[5]!==U?(Q=ye=>ye.resolveType===U,e[5]=U,e[6]=Q):Q=e[6];const q=_.find(Q),Z=Of(x,d,q?.schema),Y=HR(Z??q?.schema??null,s.discriminatorKey),ee=s.discriminatorKey,G=ye=>{R(ye);const je=_.find(Le=>Le.resolveType===ye),Pe=Of(x,d,je?.schema),Ee=new Set(Object.keys((Pe??je?.schema)?.properties??{})),be=n!==null&&typeof n=="object"&&!Array.isArray(n)?n:{},Ve=Object.fromEntries(Object.entries(be).filter(Le=>{const[ve]=Le;return Ee.has(ve)})),Re={...wD(je?.schema),...Ve};if(ee){const Le=je?.discriminatorValue??ye;i({...Re,[ee]:Le});return}if(yo(ye)){i(Re);return}i({...Re,__resolveType:ye})};let te;e[7]!==U||e[8]!==ee||e[9]!==i?(te=ye=>{if(ee||!yo(U)||ye===null||typeof ye!="object"||Array.isArray(ye)){i(ye);return}const{__resolveType:je,...Pe}=ye;i(Pe)},e[7]=U,e[8]=ee,e[9]=i,e[10]=te):te=e[10];const se=te,ne=Y?.properties?r.jsx(In,{schema:Y,value:b,onChange:ye=>{if(g&&u){u(g.blockKey,ye);return}if(v){i({...x,section:ye});return}se(ye)},basePath:o,breadcrumbPath:E,onBreadcrumbChange:T,meta:d,decofile:h,onSaveReferencedBlock:u,sandbox:f}):null;let de;e[11]!==o?(de=o.includes("."),e[11]=o,e[12]=de):de=e[12];const xe=de,he=g?()=>{const{name:ye,...je}=g.data;i(je)}:void 0,ce=!g&&!v&&!!u&&w&&!yo(U)&&U.includes("/"),oe=b&&typeof b=="object"&&!Array.isArray(b)?b:{},me=ye=>{if(!u)return;const je=ye.trim(),Pe=h?Cu(je,h):null;if(Pe){ge.error(Pe);return}u(je,{...oe,__resolveType:U,name:je}),i({__resolveType:je}),F(!1),ge.success(m("sectionsEditor.anyOfField.globalBlockSaved",{name:je}))};let pe;e[13]!==a||e[14]!==o?(pe=r.jsx(lt,{htmlFor:o,children:a}),e[13]=a,e[14]=o,e[15]=pe):pe=e[15];let we;e[16]!==m?(we=m("sectionsEditor.anyOfField.selectPlaceholder"),e[16]=m,e[17]=we):we=e[17];let Ne;e[18]!==we?(Ne=r.jsx(Jt,{children:r.jsx(as,{placeholder:we})}),e[18]=we,e[19]=Ne):Ne=e[19];let Oe;return e[20]!==s.description?(Oe=s.description&&r.jsx("p",{className:"text-xs text-muted-foreground",children:s.description}),e[20]=s.description,e[21]=Oe):Oe=e[21],r.jsxs("div",{className:"space-y-3",children:[r.jsxs("div",{className:"space-y-1.5",children:[pe,r.jsxs(Qt,{value:U||void 0,onValueChange:G,children:[Ne,r.jsx(Xt,{children:_.map(kD)})]}),Oe]}),ne&&(w?r.jsx(CD,{path:o,open:I,onOpenChange:M,title:m(xe?"sectionsEditor.anyOfField.configuration":"sectionsEditor.anyOfField.loaderConfiguration"),nested:ne,nestedBlockRef:xe,globalBlockKey:g?.blockKey,onDetach:he,onMakeGlobal:ce?()=>F(!0):void 0}):ne),ce&&r.jsx(ku,{open:O,onOpenChange:F,defaultBlockId:x4(Tt(U)),onSubmit:me})]})}if(s.anyOfRefs&&s.anyOfRefs.length>0)return null;let $;e[22]!==a||e[23]!==o?($=r.jsx(lt,{htmlFor:o,children:a}),e[22]=a,e[23]=o,e[24]=$):$=e[24];const z=n!=null?String(n):"";let K;e[25]!==i?(K=U=>i(U.target.value),e[25]=i,e[26]=K):K=e[26];const X=s.description??"";let J;e[27]!==o||e[28]!==z||e[29]!==K||e[30]!==X?(J=r.jsx("input",{id:o,type:"text",value:z,onChange:K,className:"w-full rounded-md border bg-background px-3 py-1.5 text-sm",placeholder:X}),e[27]=o,e[28]=z,e[29]=K,e[30]=X,e[31]=J):J=e[31];let H;e[32]!==s.description?(H=s.description&&r.jsx("p",{className:"text-xs text-muted-foreground",children:s.description}),e[32]=s.description,e[33]=H):H=e[33];let W;return e[34]!==$||e[35]!==J||e[36]!==H?(W=r.jsxs("div",{className:"space-y-1.5",children:[$,J,H]}),e[34]=$,e[35]=J,e[36]=H,e[37]=W):W=e[37],W}function kD(t){const e=t.title&&!t.title.includes("/")?t.title:Fd(t.resolveType)??Tt(t.resolveType);return r.jsx(vt,{value:t.resolveType,children:e},t.resolveType)}function VD(t){return t.resolveType.includes("/")&&!yo(t.resolveType)}function ND(t){return t.resolveType!==""}const ld=(t,e)=>t.match(new RegExp(`\\b${e}\\s*=\\s*"([^"]*)"`,"i"))?.[1];function TD(t){const e={};if(typeof t!="string")return e;const s=/<symbol\b((?:[^>"']|"[^"]*"|'[^']*')*)>([\s\S]*?)<\/symbol>/gi;for(const n of t.matchAll(s)){const i=n[1]??"",o=n[2]??"",a=ld(i,"id");if(!a)continue;const l=ld(i,"viewBox"),c=ld(i,"fill"),d=['xmlns="http://www.w3.org/2000/svg"',l?`viewBox="${l}"`:"",c?`fill="${c}"`:""].filter(Boolean).join(" ");e[a]=`<svg ${d}>${o}</svg>`}return e}async function AD(t){const e=await fetch(t);if(!e.ok)throw new Error(`Failed to fetch sprite sheet: ${e.status}`);return TD(await e.text())}function ED(t){if(!Array.isArray(t))return[];const e=[];for(const s of t)if(typeof s=="string")e.push({value:s,label:s});else if(s&&typeof s=="object"&&"value"in s){const n=s;e.push({value:String(n.value),label:typeof n.label=="string"?n.label:String(n.value),image:typeof n.image=="string"?n.image:void 0,icon:typeof n.icon=="string"?n.icon:void 0})}return e}function PD(t){if(!Array.isArray(t))return[];const e=[];for(const s of t)typeof s=="string"&&e.push({value:s,label:s});return e}function RD(t,e){return t.length>0?t:e}function DD(t,e){const s=e.trim().toLowerCase();return s?t.filter(n=>n.value.toLowerCase().includes(s)||(n.label??"").toLowerCase().includes(s)):t}function y4(t,e){const n=`<style>${e?`svg{color:${e}}`:""}.fill-current{fill:currentColor}.stroke-current{stroke:currentColor}.text-current{color:currentColor}</style>`,i=t.replace(/(<svg[^>]*>)/i,`$1${n}`);return`data:image/svg+xml;utf8,${encodeURIComponent(i)}`}function ID(){return getComputedStyle(document.documentElement).getPropertyValue("--foreground").trim()||void 0}function MD(t,e){if(t.previewSrc)return t.previewSrc;if(t.image)return t.image;if(t.icon)return y4(t.icon,e)}async function OD(t,e,s){const n={};s&&(n.term=s);const o=`${t.replace(/\/+$/,"")}/deco/invoke/${e}`,a=await fetch(o,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(n)});if(!a.ok)throw new Error(`Failed to fetch dynamic options: ${a.status}`);const l=await a.json();return ED(l)}function Hf(t){const e=B.c(9),{option:s,className:n,fg:i}=t;let o;e[0]!==i||e[1]!==s?(o=MD(s,i),e[0]=i,e[1]=s,e[2]=o):o=e[2];const a=o;if(!a)return null;const l=s.image?"rounded object-cover":"object-contain";let c;e[3]!==n||e[4]!==l?(c=ie("shrink-0",l,n),e[3]=n,e[4]=l,e[5]=c):c=e[5];let d;return e[6]!==a||e[7]!==c?(d=r.jsx("img",{src:a,alt:"",referrerPolicy:"no-referrer",className:c}),e[6]=a,e[7]=c,e[8]=d):d=e[8],d}function Wf(t){const e=B.c(8),{path:s,label:n,description:i}=t;let o;e[0]!==n||e[1]!==s?(o=r.jsx(lt,{htmlFor:s,children:n}),e[0]=n,e[1]=s,e[2]=o):o=e[2];let a;e[3]!==i?(a=i&&r.jsx("p",{className:"text-xs leading-normal text-muted-foreground",children:i}),e[3]=i,e[4]=a):a=e[4];let l;return e[5]!==o||e[6]!==a?(l=r.jsxs("div",{className:"space-y-0.5",children:[o,a]}),e[5]=o,e[6]=a,e[7]=l):l=e[7],l}function $D(t){const e=B.c(79),{schema:s,value:n,onChange:i,path:o,label:a,sandbox:l}=t,c=re(),d=s.options,h=l?.previewUrl,[u,f]=A.useState(!1),[m,p]=A.useState(""),[g,x]=A.useState(""),v=A.useRef(null);let b;e[0]===Symbol.for("react.memo_cache_sentinel")?(b=Ee=>{p(Ee),v.current&&clearTimeout(v.current),v.current=setTimeout(()=>{x(Ee)},300)},e[0]=b):b=e[0];const _=b,y=l?`${l.orgSlug}/${l.virtualMcpId}/${l.branch}`:"",L=typeof n=="string"?n:"",w=s.format==="icon-select";let j;e[1]!==g||e[2]!==d||e[3]!==y?(j=at.sandboxInvoke(y,`dynamic-options:${d??""}:${g}`),e[1]=g,e[2]=d,e[3]=y,e[4]=j):j=e[4];let S;e[5]!==g||e[6]!==d||e[7]!==h?(S=()=>OD(h,d,g||void 0),e[5]=g,e[6]=d,e[7]=h,e[8]=S):S=e[8];const C=!!h&&!!d&&(u||!!L);let N;e[9]!==j||e[10]!==S||e[11]!==C?(N={queryKey:j,queryFn:S,enabled:C,staleTime:6e4,retry:1},e[9]=j,e[10]=S,e[11]=C,e[12]=N):N=e[12];const V=Ft(N),E=V.data??[];let T;e[13]!==y?(T=at.sandboxSprite(y),e[13]=y,e[14]=T):T=e[14];let k;e[15]!==h||e[16]!==l?(k=()=>AD(Pp({orgSlug:l.orgSlug,virtualMcpId:l.virtualMcpId,branch:l.branch,previewUrl:h},"/sprites.svg")),e[15]=h,e[16]=l,e[17]=k):k=e[17];const R=w&&!!l&&(u||!!L)&&(!d||V.isFetched&&E.length===0);let P;e[18]!==T||e[19]!==k||e[20]!==R?(P={queryKey:T,queryFn:k,enabled:R,staleTime:3e5,retry:1},e[18]=T,e[19]=k,e[20]=R,e[21]=P):P=e[21];const D=Ft(P),I=PD(s.enum),M=D.data??{},O=ID(),F=Object.fromEntries(Object.entries(M).map(Ee=>{const[be,Ve]=Ee;return[be,y4(Ve,O)]})),$=w&&Object.keys(F).length>0?I.map(Ee=>({...Ee,previewSrc:F[Ee.value]})):I,z=RD(E,$),K=DD(z,m);let X;e[22]!==L?(X=Ee=>Ee.value===L,e[22]=L,e[23]=X):X=e[23];const J=z.find(X);if((!h||!d)&&I.length===0){let Ee;e[24]!==a||e[25]!==o||e[26]!==s.description?(Ee=r.jsx(Wf,{path:o,label:a,description:s.description}),e[24]=a,e[25]=o,e[26]=s.description,e[27]=Ee):Ee=e[27];let be;e[28]!==i?(be=Le=>i(Le.target.value),e[28]=i,e[29]=be):be=e[29];let Ve;e[30]!==L||e[31]!==o||e[32]!==be?(Ve=r.jsx(rt,{id:o,type:"text",value:L,onChange:be}),e[30]=L,e[31]=o,e[32]=be,e[33]=Ve):Ve=e[33];let Re;return e[34]!==Ee||e[35]!==Ve?(Re=r.jsxs("div",{className:"space-y-2",children:[Ee,Ve]}),e[34]=Ee,e[35]=Ve,e[36]=Re):Re=e[36],Re}const W="space-y-2";let U;e[37]!==a||e[38]!==o||e[39]!==s.description?(U=r.jsx(Wf,{path:o,label:a,description:s.description}),e[37]=a,e[38]=o,e[39]=s.description,e[40]=U):U=e[40];const Q=As,q=J?r.jsxs("span",{className:"flex min-w-0 items-center gap-2",children:[r.jsx(Hf,{option:J,className:"h-6 w-6",fg:O}),r.jsx("span",{className:"truncate",children:J.label??J.value})]}):L?r.jsx("span",{className:"truncate",children:L}):r.jsx("span",{className:"text-muted-foreground",children:c("sectionsEditor.dynamicOptionsField.selectPlaceholder")});let Z;e[41]===Symbol.for("react.memo_cache_sentinel")?(Z=r.jsx(S9,{className:"size-4 shrink-0 opacity-50"}),e[41]=Z):Z=e[41];let Y;e[42]!==u||e[43]!==q?(Y=r.jsx(Es,{asChild:!0,children:r.jsxs(le,{variant:"outline",role:"combobox","aria-expanded":u,className:"h-10 w-full justify-between font-normal",children:[q,Z]})}),e[42]=u,e[43]=q,e[44]=Y):Y=e[44];const ee=Ps,G="p-0";let te;e[45]===Symbol.for("react.memo_cache_sentinel")?(te={width:"var(--radix-popover-trigger-width)"},e[45]=te):te=e[45];const se=Tr,ne=!1;let de;e[46]!==c?(de=c("sectionsEditor.dynamicOptionsField.searchPlaceholder"),e[46]=c,e[47]=de):de=e[47];let xe;e[48]!==m||e[49]!==de?(xe=r.jsx(Bi,{placeholder:de,className:"h-9",value:m,onValueChange:_}),e[48]=m,e[49]=de,e[50]=xe):xe=e[50];const he=Fi;let ce;e[51]!==V.isLoading||e[52]!==c?(ce=V.isLoading?c("sectionsEditor.dynamicOptionsField.loading"):c("sectionsEditor.dynamicOptionsField.noResults"),e[51]=V.isLoading,e[52]=c,e[53]=ce):ce=e[53];let oe;e[54]!==ce?(oe=r.jsx(Zn,{children:ce}),e[54]=ce,e[55]=oe):oe=e[55];const me=Ms,pe=K.map(Ee=>r.jsxs(Vs,{value:Ee.value,onSelect:()=>{i(Ee.value===L?"":Ee.value),f(!1)},children:[r.jsxs("span",{className:"flex min-w-0 items-center gap-2",children:[r.jsx(Hf,{option:Ee,className:ie(Ee.image?"h-9 w-9":"h-6 w-6"),fg:O}),r.jsx("span",{className:"truncate",children:Ee.label??Ee.value})]}),r.jsx(zt,{className:ie("ml-auto size-4 shrink-0",L===Ee.value?"opacity-100":"opacity-0")})]},Ee.value));let we;e[56]!==me||e[57]!==pe?(we=r.jsx(me,{children:pe}),e[56]=me,e[57]=pe,e[58]=we):we=e[58];let Ne;e[59]!==he||e[60]!==oe||e[61]!==we?(Ne=r.jsxs(he,{children:[oe,we]}),e[59]=he,e[60]=oe,e[61]=we,e[62]=Ne):Ne=e[62];let Oe;e[63]!==se||e[64]!==xe||e[65]!==Ne?(Oe=r.jsxs(se,{shouldFilter:ne,children:[xe,Ne]}),e[63]=se,e[64]=xe,e[65]=Ne,e[66]=Oe):Oe=e[66];let ye;e[67]!==ee||e[68]!==te||e[69]!==Oe?(ye=r.jsx(ee,{className:G,style:te,children:Oe}),e[67]=ee,e[68]=te,e[69]=Oe,e[70]=ye):ye=e[70];let je;e[71]!==Q||e[72]!==u||e[73]!==Y||e[74]!==ye?(je=r.jsxs(Q,{open:u,onOpenChange:f,children:[Y,ye]}),e[71]=Q,e[72]=u,e[73]=Y,e[74]=ye,e[75]=je):je=e[75];let Pe;return e[76]!==U||e[77]!==je?(Pe=r.jsxs("div",{className:W,children:[U,je]}),e[76]=U,e[77]=je,e[78]=Pe):Pe=e[78],Pe}function BD(t){const e=B.c(17),{org:s}=Fe(),n=Bs();let i,o,a,l;e[0]!==s.id||e[1]!==t.configId||e[2]!==t.imageOnly||e[3]!==t.search?(o=t.search?.trim()||void 0,i=t.imageOnly??!1,l=o2,a=at.filePickerObjects(s.id,t.configId,o,i),e[0]=s.id,e[1]=t.configId,e[2]=t.imageOnly,e[3]=t.search,e[4]=i,e[5]=o,e[6]=a,e[7]=l):(i=e[4],o=e[5],a=e[6],l=e[7]);const c=t.enabled!==!1&&!!t.configId;let d;e[8]!==i||e[9]!==t.configId||e[10]!==o||e[11]!==n?(d=async u=>{const{pageParam:f}=u;return await n.call("FILE_OBJECTS_LIST",{configId:t.configId,cursor:f??void 0,search:o,imageOnly:i||void 0})},e[8]=i,e[9]=t.configId,e[10]=o,e[11]=n,e[12]=d):d=e[12];let h;return e[13]!==a||e[14]!==c||e[15]!==d?(h={queryKey:a,enabled:c,staleTime:3e4,initialPageParam:null,queryFn:d,getNextPageParam:FD},e[13]=a,e[14]=c,e[15]=d,e[16]=h):h=e[16],l(h)}function FD(t){return t.nextCursor??void 0}function Vu(){const t=B.c(2),{org:e}=Fe();let s;return t[0]!==e?(s={mutationFn:async n=>{const i=n.file.type||"application/octet-stream",o=await fetch(`/api/${encodeURIComponent(e.slug)}/file-configs/${encodeURIComponent(n.configId)}/upload?filename=${encodeURIComponent(n.file.name)}`,{method:"POST",headers:{"Content-Type":i},body:n.file});if(!o.ok){const a=await o.text().catch(zD);let l=`${o.status} ${o.statusText}`;try{const c=JSON.parse(a);c.message&&(l=c.message)}catch{a&&(l=a.slice(0,200))}throw new Error(`Upload failed: ${l}`)}return await o.json()}},t[0]=e,t[1]=s):s=t[1],Ys(s)}function zD(){return""}const Nc="file-picker:last-config-id";function _4(t){const e=B.c(31),s=re(),n=t.open,i=t.onOpenChange;let o;e[0]!==t.mode||e[1]!==s?(o=t.mode==="image"?s("filePicker.filePickerDialog.pickAnImage"):s("filePicker.filePickerDialog.pickAFile"),e[0]=t.mode,e[1]=s,e[2]=o):o=e[2];let a;e[3]!==o?(a=r.jsx(ps,{children:o}),e[3]=o,e[4]=a):a=e[4];let l;e[5]!==s?(l=s("filePicker.filePickerDialog.description"),e[5]=s,e[6]=l):l=e[6];let c;e[7]!==l?(c=r.jsx(oi,{children:l}),e[7]=l,e[8]=c):c=e[8];let d;e[9]!==a||e[10]!==c?(d=r.jsxs(ms,{children:[a,c]}),e[9]=a,e[10]=c,e[11]=d):d=e[11];let h;e[12]!==s?(h=v=>{const{error:b}=v;return r.jsx(KD,{error:b??new Error(s("filePicker.filePickerDialog.failedToLoadBuckets"))})},e[12]=s,e[13]=h):h=e[13];let u;e[14]===Symbol.for("react.memo_cache_sentinel")?(u=r.jsx(Rt,{className:"h-64 w-full"}),e[14]=u):u=e[14];let f;e[15]!==t?(f=v=>{t.onSelect(v),t.onOpenChange(!1)},e[15]=t,e[16]=f):f=e[16];let m;e[17]!==t.lockedConfigId||e[18]!==t.mode||e[19]!==f?(m=r.jsx(A.Suspense,{fallback:u,children:r.jsx(UD,{mode:t.mode,lockedConfigId:t.lockedConfigId,onSelect:f})}),e[17]=t.lockedConfigId,e[18]=t.mode,e[19]=f,e[20]=m):m=e[20];let p;e[21]!==m||e[22]!==h?(p=r.jsx(_s,{fallback:h,children:m}),e[21]=m,e[22]=h,e[23]=p):p=e[23];let g;e[24]!==p||e[25]!==d?(g=r.jsxs(es,{className:"sm:max-w-3xl max-h-[85vh] overflow-hidden flex flex-col",children:[d,p]}),e[24]=p,e[25]=d,e[26]=g):g=e[26];let x;return e[27]!==t.onOpenChange||e[28]!==t.open||e[29]!==g?(x=r.jsx(ts,{open:n,onOpenChange:i,children:g}),e[27]=t.onOpenChange,e[28]=t.open,e[29]=g,e[30]=x):x=e[30],x}function KD(t){const e=B.c(3),{error:s}=t;let n;e[0]===Symbol.for("react.memo_cache_sentinel")?(n=r.jsx(wn,{size:16}),e[0]=n):n=e[0];let i;return e[1]!==s.message?(i=r.jsxs("div",{className:"p-4 rounded-md bg-destructive/10 text-destructive flex items-center gap-2",children:[n,r.jsx("span",{className:"text-sm font-medium",children:s.message})]}),e[1]=s.message,e[2]=i):i=e[2],i}function UD(t){const e=B.c(32),{mode:s,lockedConfigId:n,onSelect:i}=t,o=s8();if(o.length===0){let p;return e[0]===Symbol.for("react.memo_cache_sentinel")?(p=r.jsx(qD,{}),e[0]=p):p=e[0],p}if(n){let p;if(e[1]!==o||e[2]!==n){let x;e[4]!==n?(x=v=>v.id===n,e[4]=n,e[5]=x):x=e[5],p=o.find(x),e[1]=o,e[2]=n,e[3]=p}else p=e[3];const g=p;if(g){let x;return e[6]!==g||e[7]!==s||e[8]!==i?(x=r.jsx(cd,{config:g,mode:s,onSelect:i}),e[6]=g,e[7]=s,e[8]=i,e[9]=x):x=e[9],x}}if(o.length===1){const p=o[0];let g;return e[10]!==p||e[11]!==s||e[12]!==i?(g=r.jsx(cd,{config:p,mode:s,onSelect:i}),e[10]=p,e[11]=s,e[12]=i,e[13]=g):g=e[13],g}let a;e[14]===Symbol.for("react.memo_cache_sentinel")?(a=typeof window<"u"?window.localStorage.getItem(Nc):null,e[14]=a):a=e[14];const l=a;let c;e[15]!==o?(c=o.find(p=>p.id===l)?.id??o[0].id,e[15]=o,e[16]=c):c=e[16];const d=c;let h;e[17]!==o?(h=o.map(HD),e[17]=o,e[18]=h):h=e[18];let u;e[19]!==h?(u=r.jsx(na,{className:"self-start",children:h}),e[19]=h,e[20]=u):u=e[20];let f;if(e[21]!==o||e[22]!==s||e[23]!==i){let p;e[25]!==s||e[26]!==i?(p=g=>r.jsx(yi,{value:g.id,className:"min-h-0 flex-1 overflow-hidden",children:r.jsx(cd,{config:g,mode:s,onSelect:i})},g.id),e[25]=s,e[26]=i,e[27]=p):p=e[27],f=o.map(p),e[21]=o,e[22]=s,e[23]=i,e[24]=f}else f=e[24];let m;return e[28]!==d||e[29]!==u||e[30]!==f?(m=r.jsxs(Vr,{defaultValue:d,onValueChange:WD,className:"min-h-0 flex-1 flex flex-col",children:[u,f]}),e[28]=d,e[29]=u,e[30]=f,e[31]=m):m=e[31],m}function HD(t){return r.jsx(xn,{value:t.id,children:t.name},t.id)}function WD(t){typeof window<"u"&&window.localStorage.setItem(Nc,t)}function qD(){const t=B.c(22),{org:e}=Fe(),s=re();let n;t[0]===Symbol.for("react.memo_cache_sentinel")?(n=r.jsx("div",{className:"size-12 rounded-full bg-muted flex items-center justify-center",children:r.jsx($i,{size:20,className:"text-muted-foreground"})}),t[0]=n):n=t[0];let i;t[1]!==s?(i=s("filePicker.filePickerDialog.noBucketConfigured"),t[1]=s,t[2]=i):i=t[2];let o;t[3]!==i?(o=r.jsx("p",{className:"font-medium text-sm",children:i}),t[3]=i,t[4]=o):o=t[4];let a;t[5]!==s?(a=s("filePicker.filePickerDialog.noBucketDescription"),t[5]=s,t[6]=a):a=t[6];let l;t[7]!==a?(l=r.jsx("p",{className:"text-xs text-muted-foreground mt-1 max-w-sm",children:a}),t[7]=a,t[8]=l):l=t[8];let c;t[9]!==o||t[10]!==l?(c=r.jsxs("div",{children:[o,l]}),t[9]=o,t[10]=l,t[11]=c):c=t[11];let d;t[12]!==e.slug?(d={org:e.slug},t[12]=e.slug,t[13]=d):d=t[13];let h;t[14]!==s?(h=s("filePicker.filePickerDialog.configureABucket"),t[14]=s,t[15]=h):h=t[15];let u;t[16]!==d||t[17]!==h?(u=r.jsx(le,{asChild:!0,size:"sm",className:"mt-2",children:r.jsx(pm,{to:"/$org/settings/files",params:d,children:h})}),t[16]=d,t[17]=h,t[18]=u):u=t[18];let f;return t[19]!==c||t[20]!==u?(f=r.jsxs("div",{className:"rounded-xl border border-dashed border-border/60 p-10 flex flex-col items-center justify-center text-center gap-3",children:[n,c,u]}),t[19]=c,t[20]=u,t[21]=f):f=t[21],f}function cd({config:t,mode:e,onSelect:s}){const n=re(),[i,o]=A.useState(""),a=t8(i,300),l=BD({configId:t.id,search:a,imageOnly:e==="image"}),c=Vu(),[d,h]=A.useState(!1),u=A.useRef(null),f=e==="image"?"image/*":void 0;async function m(j){if(!j)return;const S=Array.from(j);if(S.length===0)return;let C=null;const N=[];for(const V of S)try{const E=await c.mutateAsync({configId:t.id,file:V});C??=E.publicUrl}catch(E){N.push(`${V.name} (${E instanceof Error?E.message:"upload failed"})`)}await l.refetch(),N.length>0&&ge.error(N.length===S.length?n("filePicker.filePickerDialog.uploadFailedAll",{errors:N.join("; ")}):n("filePicker.filePickerDialog.uploadFailedSome",{errors:N.join("; ")})),C&&s(C)}function p(j){j.preventDefault(),h(!0)}function g(){h(!1)}function x(j){j.preventDefault(),h(!1),m(j.dataTransfer.files)}const b=(l.data?.pages??[]).flatMap(j=>j.items),_=b.filter(j=>e==="image"?L4(j.key):!0),y=a.trim(),L=b.length>0||i.trim().length>0,w=i!==a||l.isFetching&&!l.isFetchingNextPage;return r.jsxs("div",{className:"flex flex-col gap-3 min-h-0 h-full",children:[r.jsxs("button",{type:"button",onClick:()=>u.current?.click(),onDragOver:p,onDragLeave:g,onDrop:x,className:ie("rounded-xl border border-dashed border-border/60 p-6 flex flex-col items-center justify-center gap-2 text-center transition-colors",d&&"border-primary bg-primary/5",c.isPending&&"opacity-60 pointer-events-none"),children:[r.jsx($i,{size:18,className:"text-muted-foreground"}),r.jsx("p",{className:"text-sm font-medium",children:c.isPending?n("filePicker.filePickerDialog.uploading"):n("filePicker.filePickerDialog.dropFilesOrClick")}),r.jsxs("p",{className:"text-xs text-muted-foreground",children:[n("filePicker.filePickerDialog.uploadSizeLimit")," ",n(e==="image"?"filePicker.filePickerDialog.imagesOnlyTypes":"filePicker.filePickerDialog.commonMediaTypes")]}),r.jsx("input",{ref:u,type:"file",accept:f,multiple:!0,className:"hidden",onChange:j=>{const S=Array.from(j.target.files??[]);j.target.value="",m(S)}})]}),L?r.jsx(v9,{value:i,onChange:o,isSearching:w,placeholder:n(e==="image"?"filePicker.filePickerDialog.searchImagesPlaceholder":"filePicker.filePickerDialog.searchFilesPlaceholder"),className:"shrink-0"}):null,r.jsxs("div",{className:"min-h-0 flex-1 overflow-y-auto pr-1",children:[_.length===0?y?r.jsx(JD,{query:y}):e==="image"&&b.length>0?r.jsx(YD,{}):r.jsx(GD,{}):e==="image"?r.jsx(QD,{items:_,onSelect:s}):r.jsx(ZD,{items:_,onSelect:s}),l.hasNextPage&&r.jsx("div",{className:"flex justify-center py-4",children:r.jsx(le,{type:"button",variant:"outline",size:"sm",disabled:l.isFetchingNextPage,onClick:()=>l.fetchNextPage(),children:l.isFetchingNextPage?r.jsxs(r.Fragment,{children:[r.jsx(et,{size:14,className:"animate-spin"}),n("filePicker.filePickerDialog.loading")]}):n("filePicker.filePickerDialog.loadMore")})})]})]})}function GD(){const t=B.c(12),e=re();let s;t[0]===Symbol.for("react.memo_cache_sentinel")?(s=r.jsx("div",{className:"flex size-10 items-center justify-center rounded-full bg-muted",children:r.jsx(En,{size:18,className:"text-muted-foreground"})}),t[0]=s):s=t[0];let n;t[1]!==e?(n=e("filePicker.filePickerDialog.noFilesYet"),t[1]=e,t[2]=n):n=t[2];let i;t[3]!==n?(i=r.jsx("p",{className:"text-sm font-medium",children:n}),t[3]=n,t[4]=i):i=t[4];let o;t[5]!==e?(o=e("filePicker.filePickerDialog.dropFileToGetStarted"),t[5]=e,t[6]=o):o=t[6];let a;t[7]!==o?(a=r.jsx("p",{className:"text-xs text-muted-foreground",children:o}),t[7]=o,t[8]=a):a=t[8];let l;return t[9]!==i||t[10]!==a?(l=r.jsxs("div",{className:"flex h-full min-h-40 flex-col items-center justify-center gap-2 py-8 text-center",children:[s,i,a]}),t[9]=i,t[10]=a,t[11]=l):l=t[11],l}function YD(){const t=B.c(12),e=re();let s;t[0]===Symbol.for("react.memo_cache_sentinel")?(s=r.jsx("div",{className:"flex size-10 items-center justify-center rounded-full bg-muted",children:r.jsx(En,{size:18,className:"text-muted-foreground"})}),t[0]=s):s=t[0];let n;t[1]!==e?(n=e("filePicker.filePickerDialog.noImagesYet"),t[1]=e,t[2]=n):n=t[2];let i;t[3]!==n?(i=r.jsx("p",{className:"text-sm font-medium",children:n}),t[3]=n,t[4]=i):i=t[4];let o;t[5]!==e?(o=e("filePicker.filePickerDialog.noImagesFormatDesc"),t[5]=e,t[6]=o):o=t[6];let a;t[7]!==o?(a=r.jsx("p",{className:"text-xs text-muted-foreground",children:o}),t[7]=o,t[8]=a):a=t[8];let l;return t[9]!==i||t[10]!==a?(l=r.jsxs("div",{className:"flex h-full min-h-40 flex-col items-center justify-center gap-2 py-8 text-center",children:[s,i,a]}),t[9]=i,t[10]=a,t[11]=l):l=t[11],l}function JD(t){const e=B.c(13),{query:s}=t,n=re();let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i=r.jsx("div",{className:"flex size-10 items-center justify-center rounded-full bg-muted",children:r.jsx(En,{size:18,className:"text-muted-foreground"})}),e[0]=i):i=e[0];let o;e[1]!==s||e[2]!==n?(o=n("filePicker.filePickerDialog.noMatches",{query:s}),e[1]=s,e[2]=n,e[3]=o):o=e[3];let a;e[4]!==o?(a=r.jsx("p",{className:"text-sm font-medium",children:o}),e[4]=o,e[5]=a):a=e[5];let l;e[6]!==n?(l=n("filePicker.filePickerDialog.tryDifferentSearchOrLoadMore"),e[6]=n,e[7]=l):l=e[7];let c;e[8]!==l?(c=r.jsx("p",{className:"text-xs text-muted-foreground",children:l}),e[8]=l,e[9]=c):c=e[9];let d;return e[10]!==a||e[11]!==c?(d=r.jsxs("div",{className:"flex h-full min-h-40 flex-col items-center justify-center gap-2 py-8 text-center",children:[i,a,c]}),e[10]=a,e[11]=c,e[12]=d):d=e[12],d}function L4(t){return/\.(png|jpe?g|gif|webp|svg|avif|bmp)$/i.test(t)}function XD(t){const e=t.lastIndexOf(".");return e<0||e===t.length-1?"file":t.slice(e+1).toLowerCase()}function QD(t){const e=B.c(7),{items:s,onSelect:n}=t;let i;if(e[0]!==s||e[1]!==n){let a;e[3]!==n?(a=l=>r.jsx(S4,{item:l,variant:"image",onSelect:n},l.key),e[3]=n,e[4]=a):a=e[4],i=s.map(a),e[0]=s,e[1]=n,e[2]=i}else i=e[2];let o;return e[5]!==i?(o=r.jsx("div",{className:"grid grid-cols-2 sm:grid-cols-3 md:grid-cols-4 gap-3",children:i}),e[5]=i,e[6]=o):o=e[6],o}function ZD(t){const e=B.c(7),{items:s,onSelect:n}=t;let i;if(e[0]!==s||e[1]!==n){let a;e[3]!==n?(a=l=>r.jsx("li",{children:r.jsx(S4,{item:l,variant:"row",onSelect:n})},l.key),e[3]=n,e[4]=a):a=e[4],i=s.map(a),e[0]=s,e[1]=n,e[2]=i}else i=e[2];let o;return e[5]!==i?(o=r.jsx("ul",{className:"divide-y divide-border/60 rounded-lg border border-border/60",children:i}),e[5]=i,e[6]=o):o=e[6],o}function S4(t){const e=B.c(58),{item:s,variant:n,onSelect:i}=t;let o;e[0]!==s.key?(o=XD(s.key),e[0]=s.key,e[1]=o):o=e[1];const a=o;if(n==="image"){let _;e[2]!==s.publicUrl||e[3]!==i?(_=()=>i(s.publicUrl),e[2]=s.publicUrl,e[3]=i,e[4]=_):_=e[4];let y;e[5]!==s.key||e[6]!==s.publicUrl?(y=r.jsx("img",{src:s.publicUrl,alt:s.key,loading:"lazy",className:"h-full w-full object-cover",onError:eI}),e[5]=s.key,e[6]=s.publicUrl,e[7]=y):y=e[7];let L;e[8]!==s.key||e[9]!==_||e[10]!==y?(L=r.jsx("button",{type:"button",onClick:_,className:"block h-full w-full transition hover:ring-2 hover:ring-primary",title:s.key,children:y}),e[8]=s.key,e[9]=_,e[10]=y,e[11]=L):L=e[11];let w;e[12]!==a?(w=r.jsx("span",{className:"pointer-events-none absolute left-1.5 top-1.5 rounded bg-background/80 px-1.5 py-0.5 text-[10px] font-medium uppercase text-foreground opacity-0 backdrop-blur-sm transition-opacity group-hover:opacity-100",children:a}),e[12]=a,e[13]=w):w=e[13];let j;e[14]!==s||e[15]!==i?(j=r.jsx("div",{className:"absolute right-1.5 top-1.5 opacity-0 transition-opacity group-hover:opacity-100",children:r.jsx(qf,{item:s,onSelect:i})}),e[14]=s,e[15]=i,e[16]=j):j=e[16];let S;e[17]!==s.key?(S=Gf(s.key),e[17]=s.key,e[18]=S):S=e[18];let C;e[19]!==S?(C=r.jsx("div",{className:"pointer-events-none absolute inset-x-0 bottom-0 bg-gradient-to-t from-black/70 to-transparent p-2 opacity-0 transition-opacity group-hover:opacity-100",children:r.jsx("p",{className:"truncate text-xs text-white",children:S})}),e[19]=S,e[20]=C):C=e[20];let N;return e[21]!==L||e[22]!==w||e[23]!==j||e[24]!==C?(N=r.jsxs("div",{className:"group relative aspect-square overflow-hidden rounded-lg border border-border/60 bg-muted",children:[L,w,j,C]}),e[21]=L,e[22]=w,e[23]=j,e[24]=C,e[25]=N):N=e[25],N}let l;e[26]!==s.publicUrl||e[27]!==i?(l=()=>i(s.publicUrl),e[26]=s.publicUrl,e[27]=i,e[28]=l):l=e[28];let c;e[29]!==s.key?(c=r.jsx("div",{className:"flex size-9 shrink-0 items-center justify-center rounded-md bg-muted",children:L4(s.key)?r.jsx(En,{size:16,className:"text-muted-foreground"}):r.jsx(mr,{size:16,className:"text-muted-foreground"})}),e[29]=s.key,e[30]=c):c=e[30];let d;e[31]!==s.key?(d=Gf(s.key),e[31]=s.key,e[32]=d):d=e[32];let h;e[33]!==d?(h=r.jsx("p",{className:"truncate text-sm font-medium",children:d}),e[33]=d,e[34]=h):h=e[34];let u;e[35]!==s.key?(u=r.jsx("p",{className:"truncate font-mono text-xs text-muted-foreground",children:s.key}),e[35]=s.key,e[36]=u):u=e[36];let f;e[37]!==h||e[38]!==u?(f=r.jsxs("div",{className:"min-w-0 flex-1",children:[h,u]}),e[37]=h,e[38]=u,e[39]=f):f=e[39];let m;e[40]!==a?(m=r.jsx("span",{className:"shrink-0 rounded bg-muted px-1.5 py-0.5 text-[10px] font-medium uppercase text-muted-foreground",children:a}),e[40]=a,e[41]=m):m=e[41];let p;e[42]!==s.size?(p=iI(s.size),e[42]=s.size,e[43]=p):p=e[43];let g;e[44]!==p?(g=r.jsx("span",{className:"shrink-0 text-xs text-muted-foreground",children:p}),e[44]=p,e[45]=g):g=e[45];let x;e[46]!==g||e[47]!==l||e[48]!==c||e[49]!==f||e[50]!==m?(x=r.jsxs("button",{type:"button",onClick:l,className:"flex min-w-0 flex-1 items-center gap-3 text-left",children:[c,f,m,g]}),e[46]=g,e[47]=l,e[48]=c,e[49]=f,e[50]=m,e[51]=x):x=e[51];let v;e[52]!==s||e[53]!==i?(v=r.jsx(qf,{item:s,onSelect:i}),e[52]=s,e[53]=i,e[54]=v):v=e[54];let b;return e[55]!==x||e[56]!==v?(b=r.jsxs("div",{className:"group flex items-center gap-3 px-3 py-2 transition hover:bg-muted/50",children:[x,v]}),e[55]=x,e[56]=v,e[57]=b):b=e[57],b}function eI(t){t.target.style.display="none"}function qf(t){const e=B.c(39),{item:s,onSelect:n}=t,i=re(),[o,a]=A.useState(!1);let l;e[0]!==s.publicUrl||e[1]!==i?(l=async function(N){N.preventDefault(),N.stopPropagation();try{await navigator.clipboard.writeText(s.publicUrl),a(!0),window.setTimeout(()=>a(!1),1500)}catch{ge.error(i("filePicker.filePickerDialog.failedToCopyUrl"))}},e[0]=s.publicUrl,e[1]=i,e[2]=l):l=e[2];const c=l;let d;e[3]!==i?(d=i("filePicker.filePickerDialog.assetActions"),e[3]=i,e[4]=d):d=e[4];let h;e[5]===Symbol.for("react.memo_cache_sentinel")?(h=r.jsx(w2,{size:14}),e[5]=h):h=e[5];let u;e[6]!==d?(u=r.jsx(ds,{asChild:!0,children:r.jsx(le,{type:"button",variant:"ghost",size:"icon",className:"size-7 rounded-md bg-background/80 backdrop-blur-sm",onClick:nI,"aria-label":d,children:h})}),e[6]=d,e[7]=u):u=e[7];let f;e[8]!==s.publicUrl||e[9]!==n?(f=()=>n(s.publicUrl),e[8]=s.publicUrl,e[9]=n,e[10]=f):f=e[10];let m;e[11]===Symbol.for("react.memo_cache_sentinel")?(m=r.jsx(zt,{size:14}),e[11]=m):m=e[11];let p;e[12]!==i?(p=i("filePicker.filePickerDialog.useThis"),e[12]=i,e[13]=p):p=e[13];let g;e[14]!==f||e[15]!==p?(g=r.jsxs(Xe,{onClick:f,children:[m,p]}),e[14]=f,e[15]=p,e[16]=g):g=e[16];let x;e[17]!==o?(x=o?r.jsx(zt,{size:14}):r.jsx(Os,{size:14}),e[17]=o,e[18]=x):x=e[18];let v;e[19]!==o||e[20]!==i?(v=i(o?"filePicker.filePickerDialog.copied":"filePicker.filePickerDialog.copyUrl"),e[19]=o,e[20]=i,e[21]=v):v=e[21];let b;e[22]!==c||e[23]!==v||e[24]!==x?(b=r.jsxs(Xe,{onClick:c,children:[x,v]}),e[22]=c,e[23]=v,e[24]=x,e[25]=b):b=e[25];const _=s.publicUrl;let y;e[26]===Symbol.for("react.memo_cache_sentinel")?(y=r.jsx(Dn,{size:14}),e[26]=y):y=e[26];let L;e[27]!==i?(L=i("filePicker.filePickerDialog.openInNewTab"),e[27]=i,e[28]=L):L=e[28];let w;e[29]!==s.publicUrl||e[30]!==L?(w=r.jsx(Xe,{asChild:!0,children:r.jsxs("a",{href:_,target:"_blank",rel:"noreferrer",onClick:tI,children:[y,L]})}),e[29]=s.publicUrl,e[30]=L,e[31]=w):w=e[31];let j;e[32]!==b||e[33]!==w||e[34]!==g?(j=r.jsxs(hs,{align:"end",onClick:sI,children:[g,b,w]}),e[32]=b,e[33]=w,e[34]=g,e[35]=j):j=e[35];let S;return e[36]!==j||e[37]!==u?(S=r.jsxs(us,{children:[u,j]}),e[36]=j,e[37]=u,e[38]=S):S=e[38],S}function tI(t){return t.stopPropagation()}function sI(t){return t.stopPropagation()}function nI(t){return t.stopPropagation()}function Gf(t){const e=t.split("/");return e[e.length-1]??t}function iI(t){return t<1024?`${t} B`:t<1024*1024?`${(t/1024).toFixed(1)} KB`:`${(t/(1024*1024)).toFixed(1)} MB`}function w4(t,e){if(!e)return null;const s=e.toLowerCase();return t.find(n=>{const i=n.bucket.toLowerCase();return n.siteSlug?.toLowerCase()===s||i===s||i===`deco-assets-${s}`})??null}function j4(){const t=B.c(1);let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=r.jsx("div",{className:"pointer-events-none absolute inset-0 flex items-center justify-center bg-black/40 opacity-0 transition-opacity group-hover:opacity-100 group-focus-within:opacity-100",children:r.jsxs("span",{className:"flex items-center gap-1.5 rounded-md bg-background px-3 py-1.5 text-xs font-medium shadow",children:[r.jsx($i,{size:14}),"Click to replace"]})}),t[0]=e):e=t[0],e}function C4(t){try{const e=new URL(t).pathname;return decodeURIComponent(e.split("/").pop()??t)}catch{return t.split("/").pop()??t}}function k4(t){const e=t.lastIndexOf(".");return e<0||e===t.length-1?"":t.slice(e+1).toLowerCase()}const rI=["low","medium","high","original"];function V4(t){return t==="low"||t==="medium"||t==="high"||t==="original"}function N4(t,e){try{return new URL(t).searchParams.get(e)}catch{const s=oI(t);for(const n of s){const i=n.indexOf("=");if((i>=0?n.slice(0,i):n)===e)return i>=0?n.slice(i+1):""}return null}}function T4(t,e,s){const n=t.indexOf("#"),i=n>=0?t.slice(n):"",o=n>=0?t.slice(0,n):t,a=o.indexOf("?"),l=a>=0?o.slice(0,a):o,c=(a>=0?o.slice(a+1).split("&"):[]).filter(Boolean).filter(d=>{const h=d.indexOf("=");return(h>=0?d.slice(0,h):d)!==e});return s!==void 0&&c.push(`${e}=${s}`),`${l}${c.length?`?${c.join("&")}`:""}${i}`}function oI(t){const e=t.indexOf("#"),s=e>=0?t.slice(0,e):t,n=s.indexOf("?");return n<0?[]:s.slice(n+1).split("&").filter(Boolean)}function aI(t){if(!t)return;const e=N4(t,"quality");return V4(e)?e:void 0}function lI(t,e){return T4(t,"quality",e)}function cI(t){return t?N4(t,"muted")!=="false":!0}function dI(t,e){return T4(t,"muted",e?void 0:"false")}function A4(t){const e=B.c(36),{value:s,onChange:n,showMuted:i}=t,o=i===void 0?!1:i,a=re(),l=A.useId();let c;e[0]!==s?(c=aI(s),e[0]=s,e[1]=c):c=e[1];const d=c;let h;e[2]!==s?(h=cI(s),e[2]=s,e[3]=h):h=e[3];const u=h;let f;e[4]!==a?(f=a("sectionsEditor.mediaTransformControls.mediaOptionsLabel"),e[4]=a,e[5]=f):f=e[5];let m;e[6]===Symbol.for("react.memo_cache_sentinel")?(m=r.jsx(w2,{size:14}),e[6]=m):m=e[6];let p;e[7]!==f?(p=r.jsx(Es,{asChild:!0,children:r.jsx(le,{type:"button",variant:"outline",size:"sm",className:"h-9 shrink-0","aria-label":f,children:m})}),e[7]=f,e[8]=p):p=e[8];let g;e[9]!==a?(g=a("sectionsEditor.mediaTransformControls.qualityLabel"),e[9]=a,e[10]=g):g=e[10];let x;e[11]!==g?(x=r.jsx(lt,{className:"text-xs text-muted-foreground",children:g}),e[11]=g,e[12]=x):x=e[12];const v=d??"";let b;e[13]!==n||e[14]!==s?(b=C=>n(lI(s,V4(C)?C:void 0)),e[13]=n,e[14]=s,e[15]=b):b=e[15];let _;e[16]===Symbol.for("react.memo_cache_sentinel")?(_=rI.map(uI),e[16]=_):_=e[16];let y;e[17]!==b||e[18]!==v?(y=r.jsx(c9,{type:"single",variant:"outline",size:"sm",value:v,onValueChange:b,children:_}),e[17]=b,e[18]=v,e[19]=y):y=e[19];let L;e[20]!==y||e[21]!==x?(L=r.jsxs("div",{className:"flex flex-col gap-1.5",children:[x,y]}),e[20]=y,e[21]=x,e[22]=L):L=e[22];let w;e[23]!==u||e[24]!==l||e[25]!==n||e[26]!==o||e[27]!==a||e[28]!==s?(w=o&&r.jsxs("div",{className:"flex items-center justify-between gap-3",children:[r.jsx(lt,{htmlFor:l,className:"text-xs text-muted-foreground",children:a("sectionsEditor.mediaTransformControls.mutedLabel")}),r.jsx(xr,{id:l,checked:u,onCheckedChange:C=>n(dI(s,C))})]}),e[23]=u,e[24]=l,e[25]=n,e[26]=o,e[27]=a,e[28]=s,e[29]=w):w=e[29];let j;e[30]!==L||e[31]!==w?(j=r.jsx(Ps,{align:"end",className:"w-auto min-w-52 p-3",children:r.jsxs("div",{className:"flex flex-col gap-3",children:[L,w]})}),e[30]=L,e[31]=w,e[32]=j):j=e[32];let S;return e[33]!==j||e[34]!==p?(S=r.jsxs(As,{children:[p,j]}),e[33]=j,e[34]=p,e[35]=S):S=e[35],S}function uI(t){return r.jsx(Eo,{value:t,className:"h-8 px-3 text-xs capitalize",children:t},t)}function Yf(t){const e=B.c(2),{ext:s}=t;if(!s)return null;let n;return e[0]!==s?(n=r.jsx("span",{className:"shrink-0 rounded bg-muted px-1.5 py-0.5 text-[10px] font-medium uppercase text-muted-foreground",children:s}),e[0]=s,e[1]=n):n=e[1],n}function hI(t){const e=B.c(86),{schema:s,value:n,onChange:i,path:o,label:a,sandbox:l}=t,c=re(),d=s.format==="video-uri",h=wu(n),[u,f]=A.useState(!1),[m,p]=A.useState(!1),g=h?C4(h):"",x=g?k4(g):"",v=E2(),b=Vu();let _;e[0]!==v.data?.configs?(_=v.data?.configs??[],e[0]=v.data?.configs,e[1]=_):_=e[1];const y=l?.siteSlug;let L;e[2]!==_||e[3]!==y?(L=w4(_,y),e[2]=_,e[3]=y,e[4]=L):L=e[4];const w=L;let j;e[5]!==v.data?.configs||e[6]!==w?(j=function(){if(w)return w.id;const se=v.data?.configs??[];if(se.length===1)return se[0].id;if(se.length===0)return null;const ne=typeof window<"u"?window.localStorage.getItem(Nc):null;return se.some(de=>de.id===ne)?ne:null},e[5]=v.data?.configs,e[6]=w,e[7]=j):j=e[7];const S=j;let C;e[8]!==d||e[9]!==i||e[10]!==S||e[11]!==f||e[12]!==c||e[13]!==b?(C=async function(se){if(!se)return;let ne=Array.from(se);if(ne.length===0)return;if(d&&(ne=ne.filter(fI),ne.length===0)){ge.error(c("sectionsEditor.fileField.videoFileError"));return}const de=S();if(!de){f(!0);return}try{const xe=await b.mutateAsync({configId:de,file:ne[0]});i(xe.publicUrl),ne.length>1&&ge.info(c("sectionsEditor.fileField.multiFileWarning",{fileName:ne[0].name}))}catch(xe){const he=xe;ge.error(he instanceof Error?he.message:c("sectionsEditor.fileField.uploadFailed"))}},e[8]=d,e[9]=i,e[10]=S,e[11]=f,e[12]=c,e[13]=b,e[14]=C):C=e[14];const N=C;let V;e[15]!==p?(V=function(se){se.preventDefault(),se.dataTransfer.types.includes("Files")&&p(!0)},e[15]=p,e[16]=V):V=e[16];const E=V;let T;e[17]!==p?(T=function(se){se.currentTarget===se.target&&p(!1)},e[17]=p,e[18]=T):T=e[18];const k=T;let R;e[19]!==N||e[20]!==p?(R=function(se){se.preventDefault(),p(!1),N(se.dataTransfer.files)},e[19]=N,e[20]=p,e[21]=R):R=e[21];const P=R;let D;e[22]!==a||e[23]!==o?(D=r.jsx(lt,{htmlFor:o,className:"text-muted-foreground",children:a}),e[22]=a,e[23]=o,e[24]=D):D=e[24];let I;e[25]!==s.description?(I=s.description&&r.jsx("p",{className:"text-xs leading-normal text-muted-foreground",children:s.description}),e[25]=s.description,e[26]=I):I=e[26];let M;e[27]!==I||e[28]!==D?(M=r.jsxs("div",{className:"min-w-0 space-y-0.5",children:[D,I]}),e[27]=I,e[28]=D,e[29]=M):M=e[29];const O=m&&"border-primary ring-2 ring-primary/30",F=b.isPending&&"pointer-events-none opacity-60";let $;e[30]!==O||e[31]!==F?($=ie("group relative w-full overflow-hidden rounded-xl border border-border/60 bg-muted/30 transition",O,F),e[30]=O,e[31]=F,e[32]=$):$=e[32];let z;e[33]!==x||e[34]!==g||e[35]!==d||e[36]!==f||e[37]!==h||e[38]!==c||e[39]!==b.isPending?(z=h?d?r.jsxs(r.Fragment,{children:[r.jsxs("button",{type:"button",onClick:()=>f(!0),"aria-label":c("sectionsEditor.fileField.replaceVideoLabel"),className:"relative block h-40 w-full cursor-pointer overflow-hidden bg-black",children:[r.jsx("video",{src:h,preload:"metadata",className:"h-full w-full object-contain"},h),r.jsx(j4,{})]}),r.jsxs("div",{className:"flex items-center gap-2 border-t border-border/60 bg-background/50 px-3 py-2",children:[r.jsx(Xu,{size:14,className:"shrink-0 text-muted-foreground"}),r.jsx("p",{className:"min-w-0 flex-1 truncate text-xs text-muted-foreground",children:g}),r.jsx(Yf,{ext:x})]})]}):r.jsxs("button",{type:"button",onClick:()=>f(!0),"aria-label":c("sectionsEditor.fileField.replaceFileLabel"),className:"flex w-full cursor-pointer items-center gap-3 px-3 py-2.5 text-left hover:bg-muted/60",children:[r.jsx("div",{className:"flex size-10 shrink-0 items-center justify-center rounded-md bg-background",children:r.jsx(mr,{size:18,className:"text-muted-foreground"})}),r.jsxs("div",{className:"min-w-0 flex-1",children:[r.jsx("p",{className:"truncate text-sm font-medium",children:g}),r.jsx("p",{className:"truncate text-xs text-muted-foreground",children:h})]}),r.jsx(Yf,{ext:x})]}):r.jsxs("button",{type:"button",onClick:()=>f(!0),className:"flex w-full flex-col items-center justify-center gap-2 py-8 text-sm text-muted-foreground hover:bg-muted/60 hover:text-foreground",children:[d?r.jsx(Xu,{size:20}):r.jsx(mr,{size:20}),r.jsx("span",{className:"text-sm font-medium",children:b.isPending?c("sectionsEditor.fileField.uploading"):c(d?"sectionsEditor.fileField.dropVideoHint":"sectionsEditor.fileField.dropFileHint")}),r.jsx("span",{className:"text-xs text-muted-foreground",children:c("sectionsEditor.fileField.sizeLimit")})]}),e[33]=x,e[34]=g,e[35]=d,e[36]=f,e[37]=h,e[38]=c,e[39]=b.isPending,e[40]=z):z=e[40];let K;e[41]!==m||e[42]!==c?(K=m&&r.jsx("div",{className:"pointer-events-none absolute inset-0 flex items-center justify-center bg-primary/10 backdrop-blur-[1px]",children:r.jsx("span",{className:"rounded-md bg-background px-3 py-1.5 text-xs font-medium shadow",children:c("sectionsEditor.fileField.dropToUpload")})}),e[41]=m,e[42]=c,e[43]=K):K=e[43];let X;e[44]!==k||e[45]!==E||e[46]!==P||e[47]!==$||e[48]!==z||e[49]!==K?(X=r.jsxs("div",{onDragOver:E,onDragLeave:k,onDrop:P,className:$,children:[z,K]}),e[44]=k,e[45]=E,e[46]=P,e[47]=$,e[48]=z,e[49]=K,e[50]=X):X=e[50];let J;e[51]!==i?(J=te=>i(te.target.value),e[51]=i,e[52]=J):J=e[52];let H;e[53]!==o||e[54]!==h||e[55]!==J?(H=r.jsx(rt,{id:o,type:"url",value:h,onChange:J,placeholder:"https://...",className:"h-9 min-w-0 flex-1"}),e[53]=o,e[54]=h,e[55]=J,e[56]=H):H=e[56];let W;e[57]!==f||e[58]!==h||e[59]!==c?(W=!h&&r.jsxs(le,{type:"button",variant:"outline",size:"sm",onClick:()=>f(!0),className:"h-9 shrink-0",children:[r.jsx($i,{size:14}),c("sectionsEditor.fileField.browseButton")]}),e[57]=f,e[58]=h,e[59]=c,e[60]=W):W=e[60];let U;e[61]!==d||e[62]!==i||e[63]!==h?(U=d&&h&&r.jsx(A4,{value:h,onChange:i,showMuted:!0}),e[61]=d,e[62]=i,e[63]=h,e[64]=U):U=e[64];let Q;e[65]!==i||e[66]!==h||e[67]!==c?(Q=h&&r.jsx(le,{type:"button",variant:"ghost",size:"sm",onClick:()=>i(""),className:"h-9 shrink-0","aria-label":c("sectionsEditor.fileField.removeFileLabel"),children:r.jsx(Ns,{size:14})}),e[65]=i,e[66]=h,e[67]=c,e[68]=Q):Q=e[68];let q;e[69]!==H||e[70]!==W||e[71]!==U||e[72]!==Q?(q=r.jsxs("div",{className:"flex w-full min-w-0 items-center gap-2",children:[H,W,U,Q]}),e[69]=H,e[70]=W,e[71]=U,e[72]=Q,e[73]=q):q=e[73];let Z;e[74]!==i?(Z=te=>i(te),e[74]=i,e[75]=Z):Z=e[75];const Y=w?.id??null;let ee;e[76]!==u||e[77]!==f||e[78]!==Z||e[79]!==Y?(ee=r.jsx(_4,{open:u,onOpenChange:f,mode:"any",onSelect:Z,lockedConfigId:Y}),e[76]=u,e[77]=f,e[78]=Z,e[79]=Y,e[80]=ee):ee=e[80];let G;return e[81]!==M||e[82]!==X||e[83]!==q||e[84]!==ee?(G=r.jsxs("div",{className:"grid w-full min-w-0 grid-cols-[minmax(0,1fr)] gap-2",children:[M,X,q,ee]}),e[81]=M,e[82]=X,e[83]=q,e[84]=ee,e[85]=G):G=e[85],G}function fI(t){return t.type.startsWith("video/")}const mI=new Set(["image/png","image/jpeg","image/gif","image/webp","image/svg+xml","image/avif"]);function pI(t){const e=B.c(91),{schema:s,value:n,onChange:i,path:o,label:a,sandbox:l}=t,c=re(),d=wu(n),[h,u]=A.useState(!1),[f,m]=A.useState(!1),[p,g]=A.useState(!1),[x,v]=A.useState(!1),b=d?C4(d):"",_=b?k4(b):"",y=E2(),L=Vu();let w;e[0]!==y.data?.configs?(w=y.data?.configs??[],e[0]=y.data?.configs,e[1]=w):w=e[1];const j=l?.siteSlug;let S;e[2]!==w||e[3]!==j?(S=w4(w,j),e[2]=w,e[3]=j,e[4]=S):S=e[4];const C=S;let N;e[5]!==i||e[6]!==v||e[7]!==g?(N=function(ce){g(!1),v(!1),i(ce)},e[5]=i,e[6]=v,e[7]=g,e[8]=N):N=e[8];const V=N;let E;e[9]!==y.data?.configs||e[10]!==C?(E=function(){if(C)return C.id;const ce=y.data?.configs??[];if(ce.length===1)return ce[0].id;if(ce.length===0)return null;const oe=typeof window<"u"?window.localStorage.getItem(Nc):null;return ce.some(me=>me.id===oe)?oe:null},e[9]=y.data?.configs,e[10]=C,e[11]=E):E=e[11];const T=E;let k;e[12]!==T||e[13]!==u||e[14]!==V||e[15]!==c||e[16]!==L?(k=async function(ce){if(!ce)return;const oe=Array.from(ce).filter(gI);if(oe.length===0){ge.error(c("sectionsEditor.imageField.onlyImageFilesAccepted"));return}const me=T();if(!me){u(!0);return}try{const pe=await L.mutateAsync({configId:me,file:oe[0]});V(pe.publicUrl),oe.length>1&&ge.info(c("sectionsEditor.imageField.uploadedWithExtraFilesIgnored",{fileName:oe[0].name}))}catch(pe){const we=pe;ge.error(we instanceof Error?we.message:c("sectionsEditor.imageField.uploadFailed"))}},e[12]=T,e[13]=u,e[14]=V,e[15]=c,e[16]=L,e[17]=k):k=e[17];const R=k;let P;e[18]!==m?(P=function(ce){ce.preventDefault(),ce.dataTransfer.types.includes("Files")&&m(!0)},e[18]=m,e[19]=P):P=e[19];const D=P;let I;e[20]!==m?(I=function(ce){ce.currentTarget===ce.target&&m(!1)},e[20]=m,e[21]=I):I=e[21];const M=I;let O;e[22]!==R||e[23]!==m?(O=function(ce){ce.preventDefault(),m(!1),R(ce.dataTransfer.files)},e[22]=R,e[23]=m,e[24]=O):O=e[24];const F=O;let $;e[25]!==a||e[26]!==o?($=r.jsx(lt,{htmlFor:o,className:"text-muted-foreground",children:a}),e[25]=a,e[26]=o,e[27]=$):$=e[27];let z;e[28]!==s.description?(z=s.description&&r.jsx("p",{className:"text-xs leading-normal text-muted-foreground",children:s.description}),e[28]=s.description,e[29]=z):z=e[29];let K;e[30]!==$||e[31]!==z?(K=r.jsxs("div",{className:"min-w-0 space-y-0.5",children:[$,z]}),e[30]=$,e[31]=z,e[32]=K):K=e[32];const X=f&&"border-primary ring-2 ring-primary/30",J=L.isPending&&"pointer-events-none opacity-60";let H;e[33]!==X||e[34]!==J?(H=ie("group relative w-full overflow-hidden rounded-xl border border-border/60 bg-muted/30 transition",X,J),e[33]=X,e[34]=J,e[35]=H):H=e[35];let W;e[36]!==_||e[37]!==b||e[38]!==x||e[39]!==p||e[40]!==a||e[41]!==v||e[42]!==g||e[43]!==u||e[44]!==d||e[45]!==c||e[46]!==L.isPending?(W=d?r.jsxs(r.Fragment,{children:[r.jsxs("button",{type:"button",onClick:()=>u(!0),"aria-label":c("sectionsEditor.imageField.replaceImage"),className:"relative block h-40 w-full cursor-pointer bg-[image:linear-gradient(45deg,rgba(0,0,0,0.04)_25%,transparent_25%,transparent_75%,rgba(0,0,0,0.04)_75%),linear-gradient(45deg,rgba(0,0,0,0.04)_25%,transparent_25%,transparent_75%,rgba(0,0,0,0.04)_75%)] bg-[position:0_0,8px_8px] [background-size:16px_16px]",children:[!x&&r.jsx("img",{src:d,alt:a,className:ie("h-full w-full object-contain transition-opacity",!p&&"opacity-0"),onLoad:()=>g(!0),onError:()=>v(!0)},d),x&&r.jsxs("div",{className:"flex h-full w-full flex-col items-center justify-center gap-1 text-muted-foreground",children:[r.jsx(En,{size:20}),r.jsx("p",{className:"text-xs",children:c("sectionsEditor.imageField.previewUnavailable")})]}),!p&&!x&&r.jsx("div",{className:"absolute inset-0 animate-pulse bg-muted/60"}),r.jsx(j4,{})]}),r.jsxs("div",{className:"flex items-center gap-2 border-t border-border/60 bg-background/50 px-3 py-2",children:[r.jsx("span",{className:"min-w-0 flex-1 truncate text-xs font-medium",children:b}),_&&r.jsx("span",{className:"shrink-0 rounded bg-muted px-1.5 py-0.5 text-[10px] font-medium uppercase text-muted-foreground",children:_})]})]}):r.jsxs("button",{type:"button",onClick:()=>u(!0),className:"flex h-40 w-full flex-col items-center justify-center gap-2 text-sm text-muted-foreground hover:bg-muted/60 hover:text-foreground",children:[r.jsx(En,{size:20}),r.jsx("span",{className:"text-sm font-medium",children:L.isPending?c("sectionsEditor.imageField.uploading"):c("sectionsEditor.imageField.dropImageOrClickToBrowse")}),r.jsx("span",{className:"text-xs text-muted-foreground",children:c("sectionsEditor.imageField.supportedFormatsAndSize")})]}),e[36]=_,e[37]=b,e[38]=x,e[39]=p,e[40]=a,e[41]=v,e[42]=g,e[43]=u,e[44]=d,e[45]=c,e[46]=L.isPending,e[47]=W):W=e[47];let U;e[48]!==f||e[49]!==c?(U=f&&r.jsx("div",{className:"pointer-events-none absolute inset-0 flex items-center justify-center bg-primary/10 backdrop-blur-[1px]",children:r.jsx("span",{className:"rounded-md bg-background px-3 py-1.5 text-xs font-medium shadow",children:c("sectionsEditor.imageField.dropToUpload")})}),e[48]=f,e[49]=c,e[50]=U):U=e[50];let Q;e[51]!==M||e[52]!==D||e[53]!==F||e[54]!==H||e[55]!==W||e[56]!==U?(Q=r.jsxs("div",{onDragOver:D,onDragLeave:M,onDrop:F,className:H,children:[W,U]}),e[51]=M,e[52]=D,e[53]=F,e[54]=H,e[55]=W,e[56]=U,e[57]=Q):Q=e[57];let q;e[58]!==V?(q=he=>V(he.target.value),e[58]=V,e[59]=q):q=e[59];let Z;e[60]!==c?(Z=c("sectionsEditor.imageField.urlPlaceholder"),e[60]=c,e[61]=Z):Z=e[61];let Y;e[62]!==o||e[63]!==d||e[64]!==q||e[65]!==Z?(Y=r.jsx(rt,{id:o,type:"url",value:d,onChange:q,placeholder:Z,className:"h-9 min-w-0 flex-1"}),e[62]=o,e[63]=d,e[64]=q,e[65]=Z,e[66]=Y):Y=e[66];let ee;e[67]!==u||e[68]!==d||e[69]!==c?(ee=!d&&r.jsxs(le,{type:"button",variant:"outline",size:"sm",onClick:()=>u(!0),className:"h-9 shrink-0",children:[r.jsx($i,{size:14}),c("sectionsEditor.imageField.browse")]}),e[67]=u,e[68]=d,e[69]=c,e[70]=ee):ee=e[70];let G;e[71]!==V||e[72]!==d||e[73]!==c?(G=d&&r.jsxs(r.Fragment,{children:[r.jsx(A4,{value:d,onChange:V}),r.jsx(le,{type:"button",variant:"ghost",size:"sm",onClick:()=>V(""),className:"h-9 shrink-0","aria-label":c("sectionsEditor.imageField.removeImage"),children:r.jsx(Ns,{size:14})})]}),e[71]=V,e[72]=d,e[73]=c,e[74]=G):G=e[74];let te;e[75]!==Y||e[76]!==ee||e[77]!==G?(te=r.jsxs("div",{className:"flex w-full min-w-0 items-center gap-2",children:[Y,ee,G]}),e[75]=Y,e[76]=ee,e[77]=G,e[78]=te):te=e[78];let se;e[79]!==V?(se=he=>V(he),e[79]=V,e[80]=se):se=e[80];const ne=C?.id??null;let de;e[81]!==h||e[82]!==u||e[83]!==se||e[84]!==ne?(de=r.jsx(_4,{open:h,onOpenChange:u,mode:"image",onSelect:se,lockedConfigId:ne}),e[81]=h,e[82]=u,e[83]=se,e[84]=ne,e[85]=de):de=e[85];let xe;return e[86]!==K||e[87]!==Q||e[88]!==te||e[89]!==de?(xe=r.jsxs("div",{className:"grid w-full min-w-0 grid-cols-[minmax(0,1fr)] gap-2",children:[K,Q,te,de]}),e[86]=K,e[87]=Q,e[88]=te,e[89]=de,e[90]=xe):xe=e[90],xe}function gI(t){return mI.has(t.type||"")}function E4(t){return t&&typeof t=="object"&&!Array.isArray(t)?t:{}}function xI(t,e){if(e.length===0)return 0;const s=E4(t);for(let o=0;o<e.length;o++){const a=e[o].discriminators;if(a&&Object.keys(a).length>0&&Object.entries(a).every(([c,d])=>s[c]===d))return o}let n=0,i=-1;for(let o=0;o<e.length;o++){const a=e[o],l=new Set(Object.keys(a.discriminators??{})),d=a.propertyKeys.filter(h=>!l.has(h)).filter(h=>s[h]!==void 0&&s[h]!==null&&s[h]!=="").length;d>i&&(i=d,n=o)}return n}function vI(t,e){const s=E4(t),n=new Set(e);return Object.fromEntries(Object.entries(s).filter(([i])=>!n.has(i)))}const bI="0 0 1080 1080",yI="matrix(1 0 0 1 540 540)",Nu=[{code:"AC",name:"Acre",gTransform:"matrix(1 0 0 1 -248.53 -95.16)",pathTransform:"translate(-57.47, -224.1)",d:"M 30.47 237.77 L 28.39 237.73 L 28.93 235.92 L 28.72 235.09 L 28.47 234.6 L 27.22 233.9 L 27.08 233.45 L 27.35 232.3 L 26.58 230.35 L 25.49 229.71 L 19.89 228.46 L 12.55 228.27 L 12.82 227.71 L 15.31 225.45 L 16.2 224.22 L 16.49 223.02 L 16.27 221.79 L 15.59 220.88 L 14.76 220.44 L 13.08 217.49 L 12.31 217.05 L 11.41 216.86 L 10.28 215.73 L 9.36 213.35 L 7.36 211.82 L 6.38 208.2 L 5.51 206.56 L 3.63 205.48 L 3.55 204.31 L 4.36 204.41 L 4.78 203.89 L 4.85 203.22 L 4.65 202.8 L 2.53 201.87 L 2.17 201.21 L 0 199.32 L 0.04 198.95 L 0.66 198.9 L 1.16 197.58 L 1.15 196.27 L 4.16 195.88 L 4.66 195.49 L 4.44 194.14 L 3.27 192.57 L 3.27 192.57 L 21.22 200.05 L 44.88 205.71 L 57.02 208.85 L 83.46 223.02 L 111.97 235.15 L 111.97 235.15 L 114.94 236.41 L 114.94 236.41 L 114.64 236.89 L 113.07 237.55 L 110.98 239.14 L 108.12 241.93 L 106.47 242.79 L 105.81 242.61 L 104.28 242.79 L 104.23 243.35 L 102.31 244.65 L 100.23 245.64 L 98.79 247.47 L 98.35 248.65 L 97.74 248.93 L 96.57 248.18 L 95.81 248.05 L 93.44 248.1 L 92.76 248.36 L 92.13 248.81 L 91.77 249.67 L 89.33 253.15 L 85.56 254.4 L 84.72 255.09 L 82.78 255.6 L 81.75 255.63 L 81.83 253.52 L 80.47 253.72 L 76.92 252.95 L 71.68 252.48 L 66.59 252.86 L 65.93 252.28 L 63.66 252.11 L 60.1 253.94 L 57.37 254.56 L 55.69 253.89 L 54.29 252.45 L 52.65 253.61 L 52.69 236.06 L 52.74 234.96 L 53.21 234.25 L 53.28 231.9 L 53.02 231.02 L 53.99 229.84 L 54.47 228.7 L 53.31 228.9 L 50.34 231.49 L 48.74 232.5 L 46.68 234.88 L 44.73 235.55 L 44.08 236.63 L 42.27 237.62 z"},{code:"AL",name:"Alagoas",gTransform:"matrix(1 0 0 1 276.36 -86.82)",pathTransform:"translate(-582.36, -232.44)",d:"M 561.91 230.3 L 561.71 229.57 L 560.29 228.79 L 559.84 228.88 L 558.82 228.59 L 558.28 227.19 L 558.28 227.19 L 559.6 226.12 L 560.24 225.03 L 562.41 224.27 L 564.79 220.98 L 564.88 220.29 L 565.7 219.69 L 566.7 220.91 L 568.37 221.21 L 569.45 221.09 L 572 223.11 L 573.9 225.23 L 575.68 226.28 L 577.59 226.76 L 580.09 226.11 L 583.23 226.4 L 584.4 226.29 L 586.26 225.23 L 587.42 225.28 L 589.23 224.17 L 591.41 221.88 L 591.53 221.43 L 593.08 220.19 L 595.08 219.95 L 597.32 220.8 L 599.88 219.51 L 601.35 219.32 L 603.27 220.13 L 606.17 220.4 L 606.44 220.61 L 606.44 220.61 L 603.66 225.57 L 599.11 230.7 L 595.53 234.28 L 592.49 238.86 L 589.16 241.74 L 588.16 243.77 L 586.84 245.56 L 586.84 245.56 L 586.24 244.25 L 582.65 242.02 L 582.19 241.99 L 580.53 241.2 L 578.77 239.75 L 577.47 237.3 L 572.05 234.23 L 568.37 233.28 z"},{code:"AM",name:"Amazonas",gTransform:"matrix(1 0 0 1 -166.8 -178.05)",pathTransform:"translate(-139.2, -141.22)",d:"M 165.82 47.29 L 166.54 48.07 L 167.29 48.41 L 167.9 48.42 L 169.03 48 L 169.66 48.11 L 169.72 49.07 L 170.93 50.24 L 171.9 50.61 L 172.78 50.4 L 174.14 50.51 L 176.09 51.46 L 176.58 52.12 L 175.67 55.44 L 174.96 56.94 L 177.69 60.68 L 179.35 65.44 L 179.54 67.7 L 180.41 68.82 L 180.46 69.27 L 178.84 70.73 L 179.2 72.32 L 179.86 73.9 L 179.09 76.94 L 178.52 77.9 L 178.81 82.88 L 179.69 85.05 L 180.91 85.89 L 181.49 86.79 L 182.62 91.12 L 182.56 91.7 L 181.42 93.02 L 179.58 92.69 L 179.44 93.83 L 184.45 98.25 L 184.97 98.29 L 186.93 99.6 L 188.41 101.25 L 189.45 103.29 L 189.98 103.36 L 191.32 102.94 L 193.68 103.98 L 193.24 101.87 L 193.99 99.58 L 194.24 97.85 L 193.87 96.05 L 194.69 93.08 L 195.71 91.82 L 196.99 91.13 L 199.08 90.42 L 199.63 89.53 L 201.23 89.47 L 204.06 90.4 L 205.93 92.44 L 206.85 94.95 L 208.67 95.18 L 209.92 94.72 L 211.33 93.31 L 213.36 92.76 L 213.78 92.37 L 213.8 91.84 L 212.66 90.43 L 212.43 89.7 L 212.54 89.04 L 213.69 86.4 L 213.76 85.27 L 215.42 82.24 L 217.75 78.98 L 217.72 78.3 L 236.21 78.37 L 236.21 78.37 L 236.61 83.23 L 236.18 84.68 L 236.36 86.95 L 236.6 87.63 L 238.3 88.48 L 238.48 88.89 L 238.13 89.58 L 238.08 91.69 L 239.91 93.68 L 240.27 93.87 L 240.97 93.69 L 242.81 94.92 L 243.36 96.75 L 243.4 97.68 L 243.7 98.13 L 248.34 101.9 L 252.92 104.44 L 253.55 105.34 L 254.9 106.43 L 256.78 107.1 L 259.15 108.41 L 261.41 109.06 L 262.77 109.21 L 264.09 110.03 L 264.17 110.64 L 265.44 111.98 L 268.14 113.42 L 269.24 115.59 L 271.11 116.38 L 271.96 115.77 L 273.34 115.42 L 273.53 115.9 L 273.4 116.68 L 275.21 118.35 L 245.31 182.59 L 244.53 183.9 L 243.08 185.03 L 242.5 186 L 242.47 187.13 L 243.29 189.46 L 243.67 190.03 L 244.74 190.61 L 246.32 192.17 L 246.96 193.43 L 247.11 195.39 L 247.68 195.96 L 247.68 195.96 L 246.5 197.16 L 246.3 197.77 L 246.24 198.53 L 246.58 199.37 L 246.31 200.38 L 245.11 202.2 L 244.25 202.84 L 243.83 203.69 L 243.93 204.54 L 244.59 205.91 L 245.05 207.85 L 243.67 212.07 L 242.49 217.29 L 241.28 218.02 L 193.43 218.34 L 193.43 218.34 L 193.47 217.64 L 193.11 217.26 L 191.72 216.98 L 189.8 218.06 L 189.26 219.8 L 188.58 219.99 L 185.34 218.51 L 184.66 215.63 L 184.04 215.43 L 183.06 215.56 L 182.6 215.35 L 181.35 212.08 L 178.81 211.1 L 177.48 209.83 L 176.68 207.92 L 176.23 207.43 L 174.08 206.3 L 163.29 206.36 L 161.91 208.92 L 160.19 209.42 L 160.28 210.59 L 160.02 210.81 L 157.54 211.34 L 156.35 212.93 L 156.3 213.6 L 157.2 214.3 L 157.37 214.75 L 157.01 215.77 L 156.2 216.92 L 154.14 218.13 L 154.03 219.94 L 154.27 221.4 L 150.4 220.94 L 148.27 221.32 L 147.07 222.39 L 145.28 222.29 L 144.44 221.74 L 143.98 221.72 L 142.23 222.98 L 141.7 223.82 L 141.96 225.57 L 139.42 228.73 L 138.74 228.81 L 138.06 228.28 L 137.42 226.02 L 137.04 225.93 L 135.2 226.95 L 133.9 228.16 L 132.53 228.55 L 131.76 228.42 L 130.68 228.92 L 130.27 229.45 L 130.14 230.17 L 128.92 230.96 L 128.55 230.98 L 126.24 228.65 L 125.52 228.28 L 122.65 228.61 L 118.69 228.35 L 118.85 229.64 L 118.7 230.2 L 117.15 232.01 L 115.23 232.59 L 111.97 235.15 L 111.97 235.15 L 83.46 223.02 L 57.02 208.85 L 44.88 205.71 L 21.22 200.05 L 3.27 192.57 L 3.27 192.57 L 3.2 191.92 L 3.9 189 L 5.12 187.6 L 10.04 184.13 L 12.3 183.89 L 12.77 183.59 L 13.75 182.03 L 13.83 181 L 12.09 176.51 L 12.47 175.32 L 13.65 173.13 L 14.93 171.81 L 15.85 170.56 L 16.27 169.58 L 16.57 167.84 L 16.28 166.52 L 16.95 164.48 L 17.26 162.17 L 17.99 161.42 L 21.65 159.79 L 23.84 158.56 L 24.99 157.52 L 25.43 156.12 L 26.21 155.75 L 27.62 155.64 L 29.27 154.71 L 32.81 151.98 L 35.23 151.55 L 36.74 151.84 L 40.93 150.62 L 42.43 149.85 L 44.25 149.49 L 47.58 149.87 L 48.88 148.28 L 49.51 146.83 L 50.6 146.22 L 52.74 146.42 L 53.38 146.96 L 54.7 146.72 L 55.8 145.98 L 57.51 146.1 L 57.82 146.63 L 57.8 147.81 L 59.41 149.1 L 62.24 149.18 L 62.82 148.78 L 63.28 148 L 63.17 147.61 L 64.34 142.69 L 71.04 105.52 L 72.2 102.6 L 71.21 97.64 L 71.33 97.38 L 70.03 96.33 L 68.55 93.58 L 68.51 93.09 L 69.16 91.7 L 68.64 89.92 L 68.27 89.52 L 66.57 88.93 L 63.54 86.58 L 61.6 84.3 L 61.8 72.79 L 65.69 72.53 L 67.44 71.36 L 70.94 70.44 L 73.62 72.2 L 74.84 72.31 L 76.11 71.88 L 75.62 70.19 L 75.92 68.47 L 74.55 66.37 L 73.98 65.83 L 72.83 65.23 L 71.32 65.76 L 68.53 65.15 L 64.96 65.24 L 64.9 55.34 L 65.86 55.38 L 67.18 54.8 L 69.46 54.2 L 72.3 55.07 L 91.33 55.13 L 90.87 54.47 L 90.08 54.33 L 89.7 53.13 L 90.65 51.2 L 92.08 51.6 L 92.69 53.12 L 93.56 54.44 L 94.22 54.79 L 95.05 54.8 L 96.66 54.19 L 98.6 52.1 L 98.92 51.26 L 100.18 50.02 L 102.73 48.63 L 104.02 49.09 L 105.19 51.67 L 106.81 53.66 L 107.55 54.96 L 108.21 56.74 L 108.44 58.29 L 107.95 61.92 L 108.15 63.68 L 111.35 62.93 L 119.66 69.99 L 120.45 70.27 L 122.95 70.48 L 125.25 69.48 L 126.95 67.78 L 129.06 66.62 L 131.25 66.51 L 131.81 66.8 L 132.58 67.88 L 132.56 68.85 L 131.45 70.55 L 131.82 71.53 L 132.4 71.8 L 133.73 71.08 L 134.29 70.17 L 134.52 68.88 L 135.52 67.72 L 135.99 67.49 L 136.99 67.67 L 137.54 67.49 L 137.95 66.83 L 138.41 64.52 L 138.92 64.15 L 140.43 63.79 L 143.36 62.02 L 144.33 62.57 L 145.26 62.28 L 146.86 61.24 L 147.88 59.63 L 149.99 58.42 L 152.02 58.97 L 154.38 57.32 L 154.93 56.5 L 155.37 53.84 L 155.34 52.55 L 156.11 51.63 L 157.14 51.21 L 158.88 51.19 L 160.22 50.8 L 162.28 49.2 L 163.24 48.83 L 165.52 48.53 z"},{code:"AP",name:"Amapá",gTransform:"matrix(1 0 0 1 32.29 -262.31)",pathTransform:"translate(-338.29, -56.97)",d:"M 344.98 99.7 L 344.04 99.64 L 343.27000000000004 99.98 L 341.97 100.10000000000001 L 339.18 99.42 L 337.73 98.39 L 337.3 96.89 L 335.43 95.5 L 335.32 94.2 L 335.53 93.51 L 335.21999999999997 91.93 L 334.89 91.46000000000001 L 333.94 91.27000000000001 L 333.53 90.33000000000001 L 333.60999999999996 87.9 L 330.67999999999995 84.62 L 329.9 84.98 L 329.08 84.79 L 327.58 81.31 L 327.71 79.73 L 327.12 77.92 L 326.5 77.36 L 325.83 75.85 L 325.64 73.74 L 326.07 70.6 L 325.9 70.27 L 323.33 69.53999999999999 L 321.31 67.27999999999999 L 320.55 64.44999999999999 L 320.74 63.72999999999999 L 321.42 63.49999999999999 L 320.93 62.31999999999999 L 320.25 62.349999999999994 L 317.41 59.69 L 316.47 59.83 L 316.09000000000003 60.25 L 314.76000000000005 60.39 L 313.9200000000001 60.12 L 313.12000000000006 59.14 L 311.9800000000001 58.3 L 310.7900000000001 58.18 L 310.30000000000007 56.9 L 309.63000000000005 56.1 L 307.70000000000005 55.050000000000004 L 306.41 54.56 L 303.02000000000004 54.190000000000005 L 301.94000000000005 54.480000000000004 L 300.77000000000004 54.46 L 300.46000000000004 53.92 L 300.22 52.480000000000004 L 300.47 47.940000000000005 L 301.09000000000003 46.64000000000001 L 300.72 44.34000000000001 L 300.1 43.77000000000001 L 300.1 43.77000000000001 L 300.45000000000005 43.56000000000001 L 301.44000000000005 43.86000000000001 L 301.43000000000006 44.67000000000001 L 301.14000000000004 44.85000000000001 L 301.48 45.82000000000001 L 302.95000000000005 45.760000000000005 L 303.77000000000004 45.99 L 304.12000000000006 46.89 L 304.96000000000004 47.6 L 307.21000000000004 48.38 L 310.50000000000006 49.13 L 313.26000000000005 47.35 L 313.61000000000007 46.59 L 315.3400000000001 45.42 L 316.1700000000001 45.13 L 316.86000000000007 46.07 L 319.57000000000005 47.01 L 320.65000000000003 46.89 L 322.37000000000006 45.88 L 322.49000000000007 45.46 L 322.81000000000006 45.49 L 324.27000000000004 46.79 L 324.07000000000005 47.66 L 326.44000000000005 47.489999999999995 L 326.95000000000005 47.989999999999995 L 327.90000000000003 48.16 L 328.52000000000004 48.15 L 329.43000000000006 47.67 L 331.1000000000001 46.17 L 332.88000000000005 45.07 L 334.63000000000005 42.77 L 335.00000000000006 41.77 L 334.80000000000007 41.230000000000004 L 337.93000000000006 34.730000000000004 L 338.0400000000001 32.910000000000004 L 339.1500000000001 31.610000000000003 L 339.8800000000001 31.42 L 343.48000000000013 25.630000000000003 L 343.71000000000015 24.480000000000004 L 344.5500000000001 23.280000000000005 L 346.34000000000015 21.730000000000004 L 346.97000000000014 20.070000000000004 L 349.08000000000015 18.930000000000003 L 349.5500000000002 18.01 L 350.5900000000002 17.430000000000003 L 351.1500000000002 18.890000000000004 L 352.0300000000002 20.250000000000004 L 350.3600000000002 15.450000000000003 L 350.2900000000002 14.160000000000004 L 350.4700000000002 13.830000000000004 L 353.8400000000002 16.250000000000004 L 354.9800000000002 17.460000000000004 L 355.8900000000002 18.680000000000003 L 356.4100000000002 19.870000000000005 L 356.44000000000017 21.450000000000003 L 356.88000000000017 21.76 L 357.20000000000016 21.28 L 357.58000000000015 21.18 L 357.79000000000013 21.58 L 358.0000000000001 29.47 L 358.66000000000014 33.339999999999996 L 361.3700000000001 39.38999999999999 L 364.03000000000014 48.32999999999999 L 367.35000000000014 53.32999999999999 L 368.3600000000001 53.67999999999999 L 371.6300000000001 53.599999999999994 L 374.4100000000001 54.53999999999999 L 375.7000000000001 55.38999999999999 L 376.4700000000001 58.03999999999999 L 376.31000000000006 61.36999999999999 L 375.02000000000004 62.32999999999999 L 373.29 62.75999999999999 L 372.91 63.08999999999999 L 374.70000000000005 62.93999999999999 L 375.74000000000007 62.51999999999999 L 376.02000000000004 62.749999999999986 L 376.14000000000004 63.33999999999999 L 375.97 64.07 L 370.94000000000005 68.13 L 369.77000000000004 70.22999999999999 L 367.62000000000006 71.63999999999999 L 365.68000000000006 75.35999999999999 L 362.77000000000004 78.85999999999999 L 362.07000000000005 79.31999999999998 L 361.13000000000005 79.22999999999998 L 359.68000000000006 79.74999999999997 L 357.6000000000001 82.72999999999998 L 357.6000000000001 82.72999999999998 L 356.2600000000001 82.79999999999997 L 355.5100000000001 83.69999999999997 L 355.5100000000001 83.69999999999997 L 354.0400000000001 85.37999999999998 L 353.07000000000005 87.59999999999998 L 351.95000000000005 89.46999999999998 L 351.11000000000007 90.11999999999999 L 348.1000000000001 93.57 L 347.74000000000007 95.97 L 347.9100000000001 97.77 L 345.9600000000001 99.58 L 344.98 99.7 z M 368.34 52.71 L 367.89 52.38 L 366.78999999999996 50.52 L 366.85999999999996 49.64 L 367.09 49.230000000000004 L 368.75 48.78 L 369.18 49.17 L 370.01 51.440000000000005 L 369.02 52.540000000000006 L 368.34 52.71 z M 370.83 70.32 L 370.43 70.07 L 370.35 69.36 L 371.46000000000004 68.26 L 372.34000000000003 68.11 L 373.59000000000003 68.35 L 374.05 68.24 L 374.49 67.6 L 374.54 68.19 L 373.57 69.63 L 372.58 70.13 L 370.83 70.32 z M 374.27 67.45 L 373.49 67.22 L 373.49 66.66 L 374.21000000000004 65.61999999999999 L 375.46000000000004 65.52 L 375.64000000000004 65.86999999999999 L 375.54 66.38 L 374.27 67.45 z M 367.08 49.03 L 366.32 48.53 L 366.58 47.7 L 367.46 47.53 L 368.32 47.85 L 368.33 48.58 L 367.08 49.03 z"},{code:"BA",name:"Bahia",gTransform:"matrix(1 0 0 1 193.52 -26.39)",pathTransform:"translate(-499.52, -292.87)",d:"M 527.5 365.33 L 527.14 364.5 L 527.8199999999999 363.15 L 527.81 362.62 L 527.28 361.58 L 523.15 358.53 L 523 358.02 L 523.22 356.51 L 522.65 355.28 L 522 355.52 L 521.8 355.96999999999997 L 521.4599999999999 356.15 L 521.2399999999999 355.9 L 521.7699999999999 351.5 L 522.5899999999999 348.2 L 523.41 347.32 L 525.88 347.56 L 526.9 346.85 L 526.9 346.43 L 526.34 345.41 L 526.5 342.76000000000005 L 531.46 338.54 L 532.9300000000001 335.46000000000004 L 532.5100000000001 334.29 L 531.7300000000001 333.27000000000004 L 530.8400000000001 333.21000000000004 L 530.1100000000001 332.83000000000004 L 527.2800000000001 330.36 L 525.1600000000001 330.38 L 522.97 329.78 L 520.7 328.7 L 517.97 328.14 L 515.99 328 L 514.67 328.99 L 513.1999999999999 329.49 L 510.5899999999999 329.04 L 510.0199999999999 329.25 L 509.5799999999999 325.29 L 503.05999999999995 319.09000000000003 L 502.67999999999995 318.91 L 498.28999999999996 320.14000000000004 L 496.76 318.90000000000003 L 496.25 319.11 L 495.32 318.89 L 492.78 317.66999999999996 L 490.60999999999996 316.04999999999995 L 489.62999999999994 316.22999999999996 L 485.2799999999999 312.59999999999997 L 484.1799999999999 312.05999999999995 L 481.4499999999999 311.30999999999995 L 479.6799999999999 311.55999999999995 L 477.7999999999999 312.4599999999999 L 476.9899999999999 313.5799999999999 L 476.3499999999999 313.75999999999993 L 471.0199999999999 312.2899999999999 L 470.4099999999999 311.7999999999999 L 470.1499999999999 310.2999999999999 L 470.2899999999999 309.4099999999999 L 471.5799999999999 306.6699999999999 L 470.7199999999999 306.2099999999999 L 468.43999999999994 305.68999999999994 L 466.25999999999993 305.6499999999999 L 465.05999999999995 305.1499999999999 L 463.2699999999999 305.06999999999994 L 459.43999999999994 306.6499999999999 L 455.17999999999995 309.6799999999999 L 454.53999999999996 310.7899999999999 L 451.16999999999996 312.6599999999999 L 449.15 313.0599999999999 L 448.2 314.2399999999999 L 446.39 315.7899999999999 L 444.96 316.3099999999999 L 443.96 316.1599999999999 L 442.10999999999996 318.7399999999999 L 441.06999999999994 319.5099999999999 L 438.93999999999994 319.1299999999999 L 438.2199999999999 319.2599999999999 L 437.5299999999999 320.2599999999999 L 436.18999999999994 321.1799999999999 L 435.78999999999996 320.9399999999999 L 437.21999999999997 317.5099999999999 L 436.71 315.09999999999985 L 436.71 315.09999999999985 L 438.19 313.1299999999998 L 438.44 312.35999999999984 L 438.21 311.08999999999986 L 437.53999999999996 309.36999999999983 L 437.64 308.6999999999998 L 438.34999999999997 307.2799999999998 L 438.29999999999995 306.8199999999998 L 435.09 304.1999999999998 L 433.4 300.73999999999984 L 432.78 297.21999999999986 L 432.83 295.66999999999985 L 434.03 291.83999999999986 L 435.61999999999995 290.8099999999999 L 435.84999999999997 290.4299999999999 L 435.90999999999997 289.4899999999999 L 434.28 288.6499999999999 L 434.16999999999996 288.31999999999994 L 434.65 285.79999999999995 L 436.08 284.73999999999995 L 436.06 284.36999999999995 L 433.34 281.90999999999997 L 433.34 281.90999999999997 L 433.29999999999995 280.97999999999996 L 434.65999999999997 278.59999999999997 L 434.61999999999995 277.53 L 434.44999999999993 277.10999999999996 L 432.98999999999995 276.61999999999995 L 432.04999999999995 275.96999999999997 L 431.69999999999993 274.71 L 431.75999999999993 271.78999999999996 L 431.94999999999993 270.93999999999994 L 433.8999999999999 269.2699999999999 L 435.0399999999999 268.8499999999999 L 435.9999999999999 268.1299999999999 L 435.70999999999987 267.4999999999999 L 435.1299999999999 266.9799999999999 L 434.20999999999987 266.6899999999999 L 433.1799999999999 266.8699999999999 L 432.82999999999987 266.5399999999999 L 432.7399999999999 266.0399999999999 L 433.1599999999999 265.0799999999999 L 435.19999999999993 264.25999999999993 L 435.75999999999993 263.80999999999995 L 435.7199999999999 263.04999999999995 L 433.8399999999999 262.06999999999994 L 430.25999999999993 261.3999999999999 L 428.3999999999999 259.43999999999994 L 428.1699999999999 258.5199999999999 L 428.6699999999999 257.3599999999999 L 429.6799999999999 256.6299999999999 L 431.1999999999999 253.1499999999999 L 432.09999999999985 252.53999999999988 L 433.10999999999984 252.26999999999987 L 433.45999999999987 251.88999999999987 L 432.16999999999985 250.08999999999986 L 432.35999999999984 249.71999999999986 L 435.5699999999998 247.09999999999985 L 439.3899999999998 245.07999999999984 L 439.9499999999998 244.60999999999984 L 440.16999999999985 243.62999999999985 L 440.85999999999984 242.97999999999985 L 440.85999999999984 242.97999999999985 L 443.1899999999998 242.95999999999984 L 444.6299999999998 244.29999999999984 L 445.28999999999985 245.33999999999983 L 445.8199999999998 247.54999999999984 L 447.5799999999998 250.03999999999985 L 451.7599999999998 251.89999999999986 L 453.55999999999983 251.37999999999985 L 455.66999999999985 251.55999999999986 L 455.99999999999983 251.34999999999985 L 456.74999999999983 249.89999999999986 L 457.8899999999998 249.52999999999986 L 458.55999999999983 248.65999999999985 L 459.72999999999985 247.76999999999987 L 461.9399999999998 247.01999999999987 L 463.2699999999998 247.18999999999986 L 464.74999999999983 247.71999999999986 L 466.09999999999985 247.29999999999987 L 469.0699999999999 244.87999999999988 L 472.01999999999987 239.82999999999987 L 472.7399999999999 238.96999999999986 L 472.9799999999999 238.04999999999987 L 473.2799999999999 235.48999999999987 L 473.1599999999999 234.32999999999987 L 470.9199999999999 229.89999999999986 L 470.9699999999999 228.96999999999986 L 474.2099999999999 227.31999999999985 L 476.1599999999999 227.29999999999984 L 477.6599999999999 227.75999999999985 L 478.06999999999994 228.68999999999986 L 478.38999999999993 228.86999999999986 L 480.50999999999993 228.43999999999986 L 481.8999999999999 227.89999999999986 L 483.2299999999999 228.27999999999986 L 484.9399999999999 229.26999999999987 L 484.8099999999999 229.91999999999987 L 484.9999999999999 230.20999999999987 L 485.8199999999999 230.48999999999987 L 488.8199999999999 230.37999999999985 L 490.2899999999999 229.73999999999987 L 491.9899999999999 229.63999999999987 L 492.8099999999999 228.41999999999987 L 494.3199999999999 227.07999999999987 L 497.0499999999999 226.73999999999987 L 497.8199999999999 226.37999999999985 L 498.6299999999999 225.39999999999986 L 500.7999999999999 225.40999999999985 L 501.4199999999999 226.03999999999985 L 501.7299999999999 226.08999999999986 L 503.5899999999999 224.27999999999986 L 503.4899999999999 221.87999999999985 L 505.4799999999999 221.49999999999986 L 506.2699999999999 221.67999999999986 L 507.31999999999994 221.01999999999987 L 508.81999999999994 218.70999999999987 L 509.2799999999999 217.55999999999986 L 509.2799999999999 217.55999999999986 L 510.1699999999999 217.95999999999987 L 511.3299999999999 217.68999999999986 L 513.53 217.97999999999985 L 516.35 219.36999999999983 L 516.7900000000001 219.87999999999982 L 516.7300000000001 222.60999999999981 L 517.4500000000002 224.5499999999998 L 519.6600000000002 225.4599999999998 L 519.9300000000002 227.4599999999998 L 519.0100000000002 229.13999999999982 L 520.8400000000003 229.75999999999982 L 521.8000000000003 229.53999999999982 L 522.6200000000003 228.61999999999983 L 525.4900000000004 227.73999999999984 L 526.2600000000003 224.15999999999983 L 526.7600000000003 223.28999999999982 L 527.5100000000003 223.12999999999982 L 528.2900000000003 223.65999999999983 L 528.9200000000003 223.70999999999984 L 531.3100000000003 222.68999999999983 L 532.4100000000003 221.44999999999982 L 532.5800000000003 220.85999999999981 L 532.3300000000003 219.4999999999998 L 532.6200000000002 219.2499999999998 L 534.8600000000002 218.7999999999998 L 535.6300000000002 216.7499999999998 L 537.2800000000002 216.3099999999998 L 539.8100000000002 214.8499999999998 L 540.4000000000002 214.7499999999998 L 541.8900000000002 215.3099999999998 L 542.7200000000003 216.7499999999998 L 544.0800000000003 217.5599999999998 L 546.4400000000003 218.3399999999998 L 549.4300000000003 218.7399999999998 L 551.0100000000003 219.88999999999982 L 551.5500000000003 221.53999999999982 L 551.9400000000003 221.80999999999983 L 552.3700000000002 221.65999999999983 L 552.6600000000002 219.90999999999983 L 553.0900000000001 219.46999999999983 L 554.0900000000001 219.45999999999984 L 554.5400000000002 219.77999999999983 L 554.5600000000002 220.40999999999983 L 553.9400000000002 221.28999999999982 L 554.3900000000002 222.11999999999983 L 554.8900000000002 222.48999999999984 L 556.9900000000002 223.34999999999985 L 557.0100000000002 224.28999999999985 L 558.2300000000002 227.33999999999986 L 558.2300000000002 227.33999999999986 L 558.7700000000002 228.73999999999987 L 559.7900000000002 229.02999999999986 L 560.2400000000002 228.93999999999986 L 561.6700000000002 229.72999999999985 L 561.8700000000002 230.44999999999985 L 561.8700000000002 230.44999999999985 L 561.2000000000003 231.60999999999984 L 561.4100000000003 233.74999999999983 L 562.6900000000003 236.24999999999983 L 564.6800000000003 238.19999999999982 L 565.4300000000003 239.34999999999982 L 565.3500000000003 242.46999999999983 L 564.6900000000003 244.08999999999983 L 564.6000000000003 244.96999999999983 L 565.3600000000002 247.71999999999983 L 565.0600000000003 248.29999999999984 L 564.3700000000002 248.84999999999985 L 561.8200000000003 249.84999999999985 L 560.6900000000003 249.09999999999985 L 558.9800000000002 249.08999999999986 L 558.6600000000002 249.38999999999987 L 558.0700000000002 250.96999999999989 L 558.0900000000001 251.7399999999999 L 559.0400000000002 253.3399999999999 L 560.1400000000002 253.9999999999999 L 560.6600000000002 255.4899999999999 L 562.0900000000001 256.9999999999999 L 562.2400000000001 257.3899999999999 L 562.1100000000001 258.8099999999999 L 561.7700000000001 259.1999999999999 L 561.8900000000001 259.6199999999999 L 562.4800000000001 260.1399999999999 L 564.4100000000001 261.0599999999999 L 564.8900000000001 261.76999999999987 L 565.4300000000001 262.10999999999984 L 566.98 262.74999999999983 L 569.87 261.86999999999983 L 569.87 261.86999999999983 L 570.51 261.84999999999985 L 570.87 262.2599999999999 L 566.79 271.08999999999986 L 562.9599999999999 276.27999999999986 L 561.93 278.60999999999984 L 556.9 284.34999999999985 L 554.4499999999999 285.60999999999984 L 553.5799999999999 285.59999999999985 L 553.8799999999999 284.16999999999985 L 554.2499999999999 284.01999999999987 L 554.3899999999999 282.91999999999985 L 553.9399999999998 280.98999999999984 L 552.0699999999998 280.73999999999984 L 551.6399999999999 279.4399999999998 L 550.9599999999999 278.6899999999998 L 550.5899999999999 279.28999999999985 L 550.1299999999999 281.61999999999983 L 549.6299999999999 282.48999999999984 L 549.0799999999999 282.86999999999983 L 548.52 282.5799999999998 L 548.03 280.8399999999998 L 548.14 280.5199999999998 L 548.4499999999999 280.3899999999998 L 548.42 279.99999999999983 L 547.55 281.28999999999985 L 548.4799999999999 282.97999999999985 L 548.9399999999999 283.20999999999987 L 549.31 283.0599999999999 L 550.4599999999999 283.3199999999999 L 549.9999999999999 285.1299999999999 L 548.7899999999998 286.27999999999986 L 548.5399999999998 288.09999999999985 L 547.2899999999998 289.0699999999999 L 546.9399999999998 289.7399999999999 L 546.7399999999998 290.57999999999987 L 546.9199999999997 291.4299999999999 L 545.5699999999997 291.0399999999999 L 545.3599999999997 291.4299999999999 L 544.9999999999997 293.9499999999999 L 545.3599999999997 293.22999999999985 L 546.1099999999997 293.4399999999998 L 546.3499999999997 293.97999999999985 L 546.1199999999997 294.3899999999999 L 546.1799999999996 295.0099999999999 L 546.4799999999996 295.3099999999999 L 546.8099999999996 296.3099999999999 L 545.7699999999996 298.8199999999999 L 546.3399999999997 302.2599999999999 L 545.7899999999997 302.7499999999999 L 545.2199999999997 302.52999999999986 L 545.0799999999997 303.65999999999985 L 545.6699999999997 304.11999999999983 L 546.8799999999998 302.3999999999998 L 546.4099999999997 300.1899999999998 L 547.2299999999998 299.5799999999998 L 547.4799999999998 300.11999999999983 L 547.4199999999998 301.8799999999998 L 546.4599999999998 304.48999999999984 L 545.7199999999998 309.91999999999985 L 545.2099999999998 311.72999999999985 L 545.4099999999999 314.1999999999999 L 546.1899999999998 317.0499999999999 L 546.3799999999999 321.5899999999999 L 547.2499999999999 327.99999999999994 L 548.2399999999999 331.41999999999996 L 546.0299999999999 338.08 L 544.6799999999998 344.72999999999996 L 544.2099999999998 345.73999999999995 L 544.0499999999998 348.59999999999997 L 542.9899999999999 352.32 L 542.8999999999999 354.65 L 543.2899999999998 359.07 L 544.1799999999998 360.78 L 541.9399999999998 363.76 L 540.1299999999999 364.43 L 539.1899999999998 365.07 L 536.4699999999998 368.96 L 535.9 371 L 535.9 371 L 527.81 365.86 L 527.5 365.33 z M 549.78 287.33 L 549.55 286.13 L 550.29 285.71999999999997 L 551.3499999999999 284.67999999999995 L 551.5099999999999 284.03999999999996 L 551.1399999999999 283.30999999999995 L 551.8999999999999 283.44999999999993 L 552.7199999999999 284.49999999999994 L 552.67 285.0299999999999 L 549.78 287.33 z M 547.25 294.18 L 546.62 294.15000000000003 L 546.63 293.48 L 546.89 293.12 L 546.09 292.9 L 545.6700000000001 292.5 L 545.8000000000001 291.43 L 547.6700000000001 291.28000000000003 L 547.83 291.48 L 547.94 292.61 L 547.25 294.18 z"},{code:"CE",name:"Ceará",gTransform:"matrix(1 0 0 1 235.04 -154.64)",pathTransform:"translate(-541.04, -164.62)",d:"M 573.79 156.85 L 568.9 158.44 L 566.29 160.45 L 562.99 167.14 L 562.15 168.26 L 561.28 168.83 L 560.63 170.5 L 560.78 171.24 L 559.38 173.68 L 557.92 175.19 L 557.35 176.29 L 556.32 176.55 L 555.54 176.04 L 555.03 176.11 L 554.19 176.99 L 552.78 179.24 L 552.44 181.21 L 553.08 181.38 L 553.74 181 L 553.74 181 L 553.66 181.54 L 552.82 182.69 L 551.79 185.69 L 552.31 187 L 551.65 188.31 L 550.56 188.94 L 550.39 189.32 L 550.27 190.25 L 550.51 190.66 L 551.09 190.95 L 551.44 191.67 L 551.42 193.33 L 552.66 194.22 L 553.35 194.3 L 553.69 195.49 L 552.08 198.98 L 550.89 200.1 L 551.06 200.35 L 551.06 200.35 L 549.47 200.84 L 548.4 201.67 L 546.86 203.96 L 545.21 204.01 L 544.58 202.37 L 543.8 201.8 L 542.44 201.32 L 541.43 200.25 L 540.97 199.26 L 539.14 198.43 L 536.29 196.53 L 533.21 196.11 L 531.92 196.21 L 529.78 197.01 L 528.15 197.2 L 527.26 196.96 L 522.33 196.76 L 522.33 196.76 L 522.39 195.44 L 521.71 194.76 L 521.63 193.79 L 522.77 190.68 L 524.27 188.43 L 524.28 187.74 L 523.51 186.58 L 520.95 186.11 L 519.64 185.46 L 518.63 182.79 L 517.58 177.59 L 516.82 175.02 L 517.06 174.57 L 516.12 166.41 L 516.01 166.03 L 515.09 165.34 L 515.89 164.76 L 516.48 163.18 L 515.88 160.19 L 514.88 158.18 L 515.36 156.58 L 514.57 152.71 L 515.31 151.35 L 515.33 150.59 L 513.97 149 L 513.53 147.27 L 510.38 140.85 L 508.58 136.13 L 508.29 134.84 L 508.47 133.38 L 510.05 131.41 L 511.14 129.56 L 511.25 128.76 L 511.25 128.76 L 511.44 128.62 L 511.4 128 L 511 127.34 L 511.65 126.53 L 518.39 126.31 L 521.28 125.88 L 523.35 125.22 L 530.75 126.01 L 532.87 127.13 L 534.81 128.63 L 538.93 130.81 L 540.39 131.33 L 545.21 134.33 L 546.42 134.53 L 548.64 136.82 L 551.63 138.93 L 554.2 139.65 L 556.64 142.56 L 557.86 143.17 L 560.82 146.98 L 564.98 150.06 L 566.44 152.06 L 567.48 153.05 L 568.98 153.87 L 570.13 153.9 L 572.5 154.82 L 573.29 155.49 z"},{code:"DF",name:"Distrito Federal",gTransform:"matrix(1 0 0 1 103.1 10.18)",pathTransform:"translate(-409.11, -329.45)",d:"M 416.71 333.87 L 402.02 333.85 L 401.5 330.59 L 402.42 328.76 L 402.8 325.03 L 414.75 325.04 L 416.58 327.02 L 416.64 329.23 L 416.05 330.42 L 415.84 332.86 z"},{code:"ES",name:"Espírito Santo",gTransform:"matrix(1 0 0 1 212.62 72.56)",pathTransform:"translate(-518.62, -391.82)",d:"M 501.63 411.37 L 501.34 411.23 L 501.78 408.89 L 502.35 407.59 L 501.76 404.47 L 501.92 404.05 L 503.64 401.99 L 508.79 402.02 L 509.34 401.7 L 510.31 398.46 L 511.42 397.19 L 512.3 394.9 L 512.54 393.18 L 512.8 392.74 L 514.04 391.88 L 515.75 389.79 L 516.29 386.82 L 516 384.39 L 514.73 381.58 L 513.63 380.31 L 513.11 380.22 L 512.66 380.51 L 511.9 380.23 L 511.41 379.52 L 511.84 378.97 L 513.32 378.88 L 514.12 379.23 L 515.09 379.26 L 516.04 379.02 L 516.36 378.6 L 516.19 376.88 L 514.88 376.53 L 514.67 376.12 L 514.97 374.58 L 515 372.66 L 514.48 372 L 513.15 371.33 L 512.85 370.63 L 514.02 368.7 L 516.19 367.39 L 516.5 367.37 L 517.55 368.11 L 518.68 368.22 L 518.7 367.41 L 517.03 365.14 L 518.37 365.27 L 520.55 364.98 L 521.39 364.37 L 522.47 364.05 L 524.05 363.97 L 526.59 364.78 L 527.5 365.33 L 527.5 365.33 L 527.5 365.33 L 527.5 365.33 L 527.8 365.86 L 535.9 371 L 535.9 371 L 534.97 374.35 L 534.66 377.21 L 534.78 380.8 L 535.5 386.95 L 535.19 389.42 L 533.7 392.6 L 530.95 393.99 L 530.4 394.59 L 528.73 397.92 L 527.75 401.72 L 526.98 403.19 L 526.15 402.51 L 525.27 402.38 L 524.98 403.66 L 526.33 404.18 L 524.39 408.42 L 520.94 412.26 L 520.7 411.99 L 518.84 412.65 L 518.04 413.88 L 517.98 415.27 L 517.56 416.52 L 515.97 418.54 L 515.68 419.67 L 515.68 419.67 L 514.06 418.61 L 511.07 418.98 L 506.73 417.97 L 504.23 416.84 L 503.56 412.13 z"},{code:"GO",name:"Goiás",gTransform:"matrix(1 0 0 1 75.37 14.13)",pathTransform:"translate(-381.37, -333.38)",d:"M 416.71 333.87 L 415.84 332.86 L 416.05 330.42 L 416.64 329.23 L 416.58 327.02 L 414.75 325.04 L 402.8 325.03 L 402.42 328.76 L 401.5 330.59 L 402.02 333.85 L 416.71 333.87 L 416.71 333.87 L 416.71 333.87 L 416.71 333.87 L 416.18 335.39 L 416.49 336.96 L 415.81 338.55 L 414.77 339.8 L 414.36 341.27 L 415.21 342.48 L 416.06 342.82 L 417.48 343.85 L 419.13 348.41 L 419.13 349.01 L 416.81 351.72 L 413.57 354.73 L 413.14 356.87 L 414.23 357.98 L 415.13 357.51 L 416.71 358.08 L 417.18 358.69 L 417.36 359.69 L 417.19 360.4 L 416.46 361.3 L 415.95 363.19 L 417.14 366.65 L 414.05 368.71 L 412.89 368.91 L 412.03 369.81 L 411.55 370.93 L 406.66 373.67 L 405.96 372.9 L 401.61 371.04 L 401.06 371.52 L 400.48 371.61 L 398.73 371.62 L 397.25 371.34 L 393.39 371.5 L 391.38 370.61 L 387.25 373.25 L 384.34 376.17 L 384.01 376.17 L 382.7 374.75 L 381.18 374.45 L 377.99 376.09 L 374.28 375.47 L 371.8 376.43 L 369.57 376.97 L 368.16 379.07 L 366.95 381.53 L 367.01 382.53 L 366.17 383.83 L 365.35 384.11 L 364.51 383.95 L 364.06 384.09 L 363.12 384.83 L 361.48 386.93 L 360.91 388.83 L 361.47 389.44 L 361.46 389.78 L 361.1 390.01 L 360.24 389.55 L 360.24 389.55 L 360 389.1 L 357.34 386.86 L 354.19 386.25 L 352.57 384.7 L 350.67 384.27 L 349.18 384.23 L 345.83 382.89 L 345.15 382.04 L 342.08 380.48 L 341.41 379.87 L 339.97 379.16 L 338.83 378.99 L 336.13 377.31 L 333.35 377.47 L 329.55 376.77 L 329.42 376.44 L 329.68 375.6 L 330.25 374.43 L 331.56 372.67 L 331.48 372.25 L 329.23 371.35 L 328.09 372.02 L 327.43 371.83 L 327.15 371.42 L 326.92 370.31 L 327.18 367.73 L 326.99 365.96 L 326.99 365.96 L 326.04 363.76 L 325.86 360.33 L 324.45 358.14 L 324.29 357.43 L 324.69 354.02 L 327.24 350.17 L 327.62 347.26 L 328.32 346.49 L 330.34 345.65 L 332.26 343.88 L 333.51 341.86 L 333.84 339.91 L 334.34 338.9 L 335.62 337.86 L 336.44 336.43 L 336.52 334.89 L 338.27 333.92 L 339.67 331.3 L 342.32 331.17 L 345.04 330.31 L 345.36 330.03 L 347.34 325.84 L 348.05 324.88 L 348.69 320.78 L 349.07 320.04 L 350.99 318.1 L 352.64 317.09 L 353.71 316.83 L 354.94 317.51 L 356.15 316.78 L 357.54 315.35 L 358.38 312.42 L 359.55 309.55 L 359.54 308.75 L 359.06 307.61 L 359.64 304.87 L 361.24 301.78 L 361.12 296.6 L 362.33 295.82 L 363.36 293.19 L 365.36 290.02 L 365.75 288.95 L 365.59 286.23 L 365.94 285.33 L 366.91 284.47 L 367.18 283.34 L 367.1 282.71 L 367.1 282.71 L 367.44 282.26 L 367.64 280.38 L 368.3 279.15 L 370.11 277.06 L 370.67 276.76 L 370.64 278.47 L 369.42 280.35 L 368.9 282.69 L 371.3 283.09 L 373.5 284.12 L 377.43 284.52 L 380.52 286.23 L 384.59 287.66 L 385.22 287.43 L 386.85 281.49 L 388.32 279.1 L 389.5 278.13 L 390.65 279.44 L 391.69 281.32 L 392.8 285.03 L 393.41 288.13 L 394.55 288.18 L 395.3 287.43 L 395.6 286.43 L 396.16 285.89 L 398.92 286.23 L 403.45 285.7 L 403.67 286.44 L 403.11 288 L 406.24 289.47 L 409.59 290.15 L 410.28 290.07 L 410.79 286.77 L 411.34 286.8 L 412.85 289.42 L 413.31 289.66 L 415.09 288.76 L 417.61 286.68 L 422.14 285.68 L 423.69 285.68 L 426.25 284.58 L 427.99 283.24 L 433.35 281.82 L 433.35 281.82 L 436.07 284.28 L 436.09 284.66 L 434.66 285.72 L 434.18 288.24 L 434.28 288.57 L 435.91 289.41 L 435.85 290.35 L 435.62 290.73 L 434.03 291.76 L 432.84 295.59 L 432.79 297.14 L 433.41 300.66 L 435.11 304.12 L 438.32 306.74 L 438.37 307.21 L 437.65 308.63 L 437.55 309.3 L 438.22 311.02 L 438.45 312.3 L 438.2 313.07 L 436.72 315.04 L 436.72 315.04 L 435.72 316.05 L 432.49 315.71 L 431.59 313.95 L 429.17 312.47 L 428 313.96 L 428.58 317.73 L 428.01 318.27 L 427.61 318.4 L 424.83 317.26 L 423.66 317.49 L 423.29 317.77 L 422.57 320.95 L 423.29 321.05 L 423.78 322.21 L 423.21 323.15 L 422.48 323.85 L 422.52 325.75 L 422.94 326.36 L 423.47 326.55 L 424.16 330.81 L 423.63 331.34 L 420.27 332.24 L 417.98 333.75 z"},{code:"MA",name:"Maranhão",gTransform:"matrix(1 0 0 1 142.22 -148.63)",pathTransform:"translate(-448.22, -170.64)",d:"M 458.57 128.92 L 458.53 129.25 L 456.48999999999995 131.4 L 456.05999999999995 131.57 L 456.0199999999999 133.01 L 457.98999999999995 131.31 L 458.66999999999996 130.1 L 460.78999999999996 128.51999999999998 L 461.67999999999995 127.37999999999998 L 462.7099999999999 121.04999999999998 L 463.8599999999999 120.34999999999998 L 464.9699999999999 120.22999999999998 L 466.63999999999993 119.30999999999997 L 467.2899999999999 119.17999999999998 L 467.7499999999999 119.29999999999998 L 467.82999999999987 120.92999999999998 L 467.6299999999999 121.37999999999998 L 466.20999999999987 123.24999999999999 L 462.9999999999999 124.99999999999999 L 462.9699999999999 125.71999999999998 L 463.69999999999993 125.83999999999999 L 464.1499999999999 125.02999999999999 L 465.2999999999999 124.71999999999998 L 465.5199999999999 125.54999999999998 L 464.92999999999995 126.05999999999999 L 465.17999999999995 126.35999999999999 L 469.38999999999993 121.38999999999999 L 470.24999999999994 121.71999999999998 L 472.8299999999999 120.78999999999998 L 476.86999999999995 121.21999999999998 L 476.40999999999997 118.80999999999999 L 477.02 118.57999999999998 L 479.44 118.65999999999998 L 481.21999999999997 119.03999999999998 L 483.84999999999997 120.08999999999997 L 484.89 120.19999999999997 L 487.03999999999996 121.57999999999997 L 488.43999999999994 121.60999999999997 L 489.69999999999993 122.90999999999997 L 491.5899999999999 124.22999999999996 L 494.0899999999999 124.80999999999996 L 495.24999999999994 124.61999999999996 L 495.80999999999995 125.37999999999997 L 496.1499999999999 125.42999999999996 L 497.7399999999999 125.33999999999996 L 500.1999999999999 125.99999999999996 L 500.45999999999987 125.09999999999995 L 499.78999999999985 124.62999999999995 L 501.45999999999987 124.24999999999996 L 502.02999999999986 124.35999999999996 L 501.9399999999999 124.77999999999996 L 501.9399999999999 124.77999999999996 L 501.4799999999999 126.20999999999997 L 501.7099999999999 126.92999999999996 L 502.3399999999999 127.46999999999997 L 501.9599999999999 128.99999999999997 L 500.1699999999999 131.26999999999998 L 496.0399999999999 135.23999999999998 L 492.7199999999999 135.7 L 491.9199999999999 135.54 L 488.9999999999999 138.94 L 489.0399999999999 140.74 L 488.1599999999999 142.57000000000002 L 486.2699999999999 144.42000000000002 L 485.44999999999993 146.4 L 484.80999999999995 146.57 L 484.03999999999996 147.62 L 484.4 149.54 L 485.63 150.37 L 486.01 151.65 L 485.73 153.11 L 484.59000000000003 155.98000000000002 L 486.17 158.79000000000002 L 486.72 161.77 L 486.61 164.20000000000002 L 486.40000000000003 164.75000000000003 L 482.3 169.17000000000002 L 482.13 171.65 L 482.25 173.76000000000002 L 482.76 176.06000000000003 L 484.53999999999996 178.10000000000002 L 486.15 179.01000000000002 L 486.32 179.51000000000002 L 486.45 180.35000000000002 L 486.06 182.55 L 485.77 182.99 L 485.65 184.20000000000002 L 485.15 185.66000000000003 L 483.94 186.97000000000003 L 481.65 187.26000000000002 L 481 186.98000000000002 L 480.17 187.02 L 477.74 187.88000000000002 L 476.22 187.99000000000004 L 473.72 186.17000000000004 L 472.71000000000004 185.96000000000004 L 471.25000000000006 186.15000000000003 L 470.24000000000007 186.75000000000003 L 469.12000000000006 187.01000000000002 L 468.89000000000004 186.71 L 468.05000000000007 186.95000000000002 L 467.55000000000007 187.17000000000002 L 465.6500000000001 189.08 L 465.6600000000001 189.54000000000002 L 465.0300000000001 190.41000000000003 L 463.0200000000001 192.41000000000003 L 460.6800000000001 193.32000000000002 L 457.8100000000001 195.88000000000002 L 456.48000000000013 196.41000000000003 L 455.4300000000001 196.45000000000002 L 453.73000000000013 197.98000000000002 L 452.65000000000015 198.34000000000003 L 450.04000000000013 198.66000000000003 L 447.3200000000001 199.42000000000002 L 445.1900000000001 201.37 L 444.2100000000001 204.34 L 443.8200000000001 207.31 L 443.1900000000001 209.63 L 441.7400000000001 212.37 L 441.4400000000001 212.59 L 441.10000000000014 213.41 L 440.97000000000014 214.93 L 439.77000000000015 217.41 L 438.07000000000016 218.81 L 437.34000000000015 220.81 L 438.0500000000001 222.75 L 438.52000000000015 225.93 L 440.25000000000017 228.99 L 440.21000000000015 229.51000000000002 L 439.45000000000016 230.91000000000003 L 439.32000000000016 237.27000000000004 L 438.1700000000002 239.72000000000003 L 437.9100000000002 240.78000000000003 L 437.8600000000002 242.70000000000002 L 437.8600000000002 242.70000000000002 L 436.5800000000002 242.04000000000002 L 435.9700000000002 241.22000000000003 L 435.1500000000002 240.77000000000004 L 434.1600000000002 240.48000000000005 L 432.3800000000002 240.68000000000004 L 431.67000000000024 240.50000000000003 L 430.3200000000002 238.50000000000003 L 429.3300000000002 235.64000000000001 L 427.2000000000002 234.02 L 427.06000000000023 232.37 L 428.7000000000002 230.56 L 428.62000000000023 230.03 L 424.74000000000024 228.08 L 424.12000000000023 227.03 L 424.06000000000023 225.37 L 423.31000000000023 223.78 L 422.37000000000023 223.09 L 420.29000000000025 222.81 L 420.09000000000026 222.39000000000001 L 420.35000000000025 221.68 L 422.98000000000025 219.14000000000001 L 422.61000000000024 217.83 L 423.34000000000026 215.15 L 424.03000000000026 213.72 L 424.60000000000025 213.17 L 425.9400000000002 212.63 L 429.3300000000002 212.28 L 428.9400000000002 210.93 L 429.5800000000002 207.68 L 429.5000000000002 205.92000000000002 L 427.7000000000002 204.71 L 423.43000000000023 205.65 L 421.28000000000026 206.99 L 419.0100000000003 203.97 L 418.10000000000025 203.12 L 415.10000000000025 198.97 L 414.22000000000025 199.04 L 413.3800000000003 197.6 L 413.9900000000003 196.41 L 413.8800000000003 195.53 L 413.6300000000003 195.19 L 412.2600000000003 194.95 L 411.84000000000026 195.22 L 409.91000000000025 193.89 L 410.09000000000026 193.17999999999998 L 411.85000000000025 192.51999999999998 L 413.60000000000025 190.48 L 413.85000000000025 188.89 L 413.5700000000003 187.89 L 413.8800000000003 185.52999999999997 L 415.65000000000026 179.36999999999998 L 415.66000000000025 178.93999999999997 L 414.98000000000025 177.79999999999998 L 414.7500000000002 176.71999999999997 L 414.9600000000002 172.99999999999997 L 414.3200000000002 171.49999999999997 L 413.8500000000002 168.00999999999996 L 413.0100000000002 166.97999999999996 L 409.61000000000024 165.53999999999996 L 408.3900000000002 165.51999999999995 L 408.11000000000024 165.19999999999996 L 408.03000000000026 164.16999999999996 L 407.4400000000003 163.47999999999996 L 405.7000000000003 163.18999999999997 L 404.7400000000003 163.70999999999998 L 403.3400000000003 163.61999999999998 L 400.56000000000034 162.10999999999999 L 399.70000000000033 162.04999999999998 L 397.74000000000035 162.57999999999998 L 395.12000000000035 164.42999999999998 L 394.5900000000004 165.06999999999996 L 394.5900000000004 165.06999999999996 L 394.10000000000036 164.98999999999995 L 408.81000000000034 153.15999999999994 L 411.16000000000037 153.38999999999993 L 412.3300000000004 152.46999999999994 L 413.8800000000004 150.29999999999995 L 414.3100000000004 149.14999999999995 L 415.8600000000004 147.97999999999996 L 416.4800000000004 145.09999999999997 L 417.6000000000004 144.63999999999996 L 420.0400000000004 142.31999999999996 L 420.51000000000045 141.10999999999996 L 420.80000000000047 139.20999999999995 L 422.4000000000005 134.51999999999995 L 424.36000000000047 132.97999999999996 L 425.8400000000005 131.21999999999997 L 426.67000000000047 129.76999999999998 L 427.13000000000045 128.48999999999998 L 426.95000000000044 126.66999999999999 L 427.74000000000046 125.85999999999999 L 426.70000000000044 124.27999999999999 L 430.38000000000045 121.18999999999998 L 430.25000000000045 119.54999999999998 L 430.75000000000045 117.16999999999999 L 432.49000000000046 115.6 L 432.8500000000005 114.89 L 433.75000000000045 111.87 L 433.83000000000044 110.26 L 433.40000000000043 109.73 L 432.4100000000004 109.89 L 432.14000000000044 109.4 L 432.19000000000045 108.78 L 433.33000000000044 108.63 L 433.90000000000043 107.89 L 434.6100000000004 103.5 L 434.4500000000004 102.12 L 434.9200000000004 101.09 L 435.6900000000004 100.64 L 435.6900000000004 100.64 L 436.3200000000004 100.64 L 436.5600000000004 100.4 L 436.5000000000004 99.86 L 436.8400000000004 99.11 L 437.42000000000036 98.58 L 438.76000000000033 99.56 L 439.2100000000003 101.4 L 440.4000000000003 101.52000000000001 L 441.1700000000003 100.16000000000001 L 441.7800000000003 103.09000000000002 L 442.7700000000003 103.13000000000002 L 443.06000000000034 102.64000000000003 L 443.13000000000034 101.70000000000003 L 443.98000000000036 101.66000000000003 L 445.67000000000036 102.19000000000003 L 446.17000000000036 102.88000000000002 L 444.74000000000035 104.58000000000003 L 445.41000000000037 105.28000000000003 L 445.43000000000035 105.83000000000003 L 446.6400000000003 103.79000000000002 L 447.13000000000034 102.25000000000001 L 447.5800000000003 102.25000000000001 L 447.9800000000003 103.27000000000001 L 447.9800000000003 103.85000000000001 L 447.1100000000003 104.77000000000001 L 446.8400000000003 105.76 L 446.9200000000003 108.47 L 447.1800000000003 108.8 L 447.6500000000003 108.92 L 448.2300000000003 108.78 L 449.1900000000003 107.85 L 448.72000000000025 106.85 L 448.86000000000024 106.25 L 450.18000000000023 104.82 L 451.23000000000025 104.57 L 453.36000000000024 105.16 L 454.86000000000024 104.05 L 454.91000000000025 104.97 L 454.55000000000024 105.17999999999999 L 453.42000000000024 106.71 L 454.0100000000002 107.28999999999999 L 454.11000000000024 106.91999999999999 L 455.36000000000024 106.32 L 455.9400000000002 107.11 L 455.80000000000024 108.32 L 457.43000000000023 110.07 L 458.29000000000025 109.63 L 459.87000000000023 110.3 L 460.6400000000002 112.7 L 460.5300000000002 113.65 L 458.3400000000002 116.38000000000001 L 457.9600000000002 117.27000000000001 L 458.06000000000023 117.93 L 458.66000000000025 116.9 L 460.41000000000025 115.22 L 461.24000000000024 115.19 L 462.11000000000024 116 L 462.6300000000002 117.89 L 462.36000000000024 119.12 L 461.3900000000002 119.31 L 460.36000000000024 120.22 L 459.2000000000002 121.71 L 459.2700000000002 122.47999999999999 L 458.1100000000002 124.82999999999998 L 457.4900000000002 128.35 L 457.70000000000016 128.69 L 458.57 128.92 z M 459.09 129.37 L 459.03 128.58 L 459.55999999999995 127.05000000000001 L 459.1499999999999 125.98000000000002 L 459.2799999999999 125.32000000000002 L 460.18999999999994 124.08000000000003 L 460.73999999999995 123.89000000000003 L 460.78999999999996 126.24000000000002 L 460.56999999999994 127.58000000000003 L 459.7699999999999 128.18000000000004 L 459.09 129.37 z M 452.79 103.61 L 452.35 103.15 L 452.27000000000004 102.55000000000001 L 453.07000000000005 101.43 L 453.91 101.4 L 454.59000000000003 101.82000000000001 L 454.69000000000005 102.16000000000001 L 454.50000000000006 102.52000000000001 L 452.79 103.61 z M 456.29 107.79 L 456 107.49000000000001 L 456.06 106.96000000000001 L 457.12 106.07000000000001 L 457.6 106.14 L 458.1 106.99 L 457.96000000000004 107.6 L 457.56000000000006 107.42999999999999 L 456.29 107.79 z M 442.13 102.98 L 441.92 102.93 L 442.87 99.35000000000001 L 443.17 99.44000000000001 L 443.2 99.67000000000002 L 442.78999999999996 102.73000000000002 L 442.13 102.98 z"},{code:"MG",name:"Minas Gerais",gTransform:"matrix(1 0 0 1 139.79 56.66)",pathTransform:"translate(-445.79, -375.93)",d:"M 527.5 365.33 L 526.59 364.78 L 524.05 363.97 L 522.47 364.05 L 521.39 364.37 L 520.55 364.98 L 518.37 365.27 L 517.03 365.14 L 518.7 367.41 L 518.68 368.22 L 517.55 368.11 L 516.5 367.37 L 516.19 367.39 L 514.02 368.7 L 512.85 370.63 L 513.15 371.33 L 514.48 372 L 515 372.66 L 514.97 374.58 L 514.67 376.12 L 514.88 376.53 L 516.19 376.88 L 516.36 378.6 L 516.04 379.02 L 515.09 379.26 L 514.12 379.23 L 513.32 378.88 L 511.84 378.97 L 511.41 379.52 L 511.9 380.23 L 512.66 380.51 L 513.11 380.22 L 513.63 380.31 L 514.73 381.58 L 516 384.39 L 516.29 386.82 L 515.75 389.79 L 514.04 391.88 L 512.8 392.74 L 512.54 393.18 L 512.3 394.9 L 511.42 397.19 L 510.31 398.46 L 509.34 401.7 L 508.79 402.02 L 503.64 401.99 L 501.92 404.05 L 501.76 404.47 L 502.35 407.59 L 501.78 408.89 L 501.34 411.23 L 501.63 411.37 L 501.63 411.37 L 499.1 413.72 L 497.86 413.99 L 497.3 414.49 L 498.04 415.19 L 495.68 421.24 L 493.78 424.95 L 493.69 425.7 L 495.13 425.83 L 495.42 426.44 L 495.21 426.96 L 492.68 427.94 L 483.17 432.47 L 481.8 432.67 L 481.82 432.21 L 481.33 432.04 L 478.8 431.77 L 478.23 431.83 L 476.61 432.77 L 475.36 432.93 L 472.16 433.01 L 471.8 432.69 L 471.29 432.77 L 467.19 434.55 L 466.14 435.32 L 464.43 436.09 L 463.93 435.81 L 461.34 435.98 L 458.43 437.32 L 456.01 438.06 L 455.33 438.55 L 455.33 438.55 L 454.08 439.28 L 451.88 439.5 L 449.95 440.52 L 448.72 441.76 L 446.93 442.43 L 444.55 442.68 L 442.21 442.6 L 442.2 442.11 L 442.55 441.62 L 442.46 441.27 L 441.27 441.6 L 441.09 443.9 L 441.33 444.13 L 441.28 444.97 L 440.53 445.95 L 439.23 446.27 L 438.66 445.84 L 435.05 446.84 L 434.86 446.31 L 432.85 446.55 L 431.73 446.3 L 429.7 442.99 L 430.92 442.28 L 430.4 440.57 L 428.6 439.74 L 426.81 438.51 L 426.1 436.9 L 426.63 435.34 L 426.82 431.89 L 426.56 428.95 L 428.42 426.23 L 429.12 424.05 L 429.17 422.78 L 428.94 422.41 L 425.24 421.09 L 424.24 421.14 L 423.96 421.5 L 423.18 421.81 L 421.57 421.86 L 421.6 421.01 L 420.77 419.02 L 419.47 417.23 L 419.1 415.02 L 418.79 414.4 L 418 413.66 L 418.19 411.72 L 419.71 409.69 L 419.77 409.13 L 419.37 407.58 L 417.49 406.37 L 416.91 405.76 L 417.2 403.39 L 417.77 402.38 L 417.57 401.34 L 414.3 397.99 L 413 398.28 L 412.15 398.92 L 410.5 398.14 L 408.12 398.25 L 407.81 398.86 L 408.01 399.32 L 407.57 400.31 L 404.79 400.99 L 403.68 400.56 L 402.17 399.11 L 401.16 400.36 L 392.98 401.04 L 392.52 401.52 L 392.04 402.71 L 392.31 405.25 L 391.9 405.69 L 390.71 405.17 L 390.7 402.39 L 390.45 401.43 L 390.09 401.04 L 389.53 400.99 L 389.27 401.18 L 388.86 402.31 L 388.19 403.25 L 387.65 403.57 L 387.03 403.55 L 385.82 401.45 L 385.49 400.03 L 385.63 399.12 L 383.95 398.33 L 381.77 396.91 L 379.78 397.5 L 378.16 397.28 L 376.49 397.63 L 372.2 396.67 L 369.65 396.59 L 367.92 395.04 L 367.17 394.9 L 365.67 395.51 L 364.24 397.2 L 362.32 397.57 L 360.17 398.68 L 358.95 399.81 L 358.95 399.81 L 359.26 397.19 L 358.67 393.98 L 359.66 389.8 L 360.24 389.55 L 360.24 389.55 L 361.1 390.01 L 361.46 389.78 L 361.47 389.44 L 360.91 388.83 L 361.48 386.93 L 363.12 384.83 L 364.06 384.09 L 364.51 383.95 L 365.35 384.11 L 366.17 383.83 L 367.01 382.53 L 366.95 381.53 L 368.16 379.07 L 369.57 376.97 L 371.8 376.43 L 374.28 375.47 L 377.99 376.09 L 381.18 374.45 L 382.7 374.75 L 384.01 376.17 L 384.34 376.17 L 387.25 373.25 L 391.38 370.61 L 393.39 371.5 L 397.25 371.34 L 398.73 371.62 L 400.48 371.61 L 401.06 371.52 L 401.61 371.04 L 405.96 372.9 L 406.66 373.67 L 411.55 370.93 L 412.03 369.81 L 412.89 368.91 L 414.05 368.71 L 417.14 366.65 L 415.95 363.19 L 416.46 361.3 L 417.19 360.4 L 417.36 359.69 L 417.18 358.69 L 416.71 358.08 L 415.13 357.51 L 414.23 357.98 L 413.14 356.87 L 413.57 354.73 L 416.81 351.72 L 419.13 349.01 L 419.13 348.41 L 417.48 343.85 L 416.06 342.82 L 415.21 342.48 L 414.36 341.27 L 414.77 339.8 L 415.81 338.55 L 416.49 336.96 L 416.18 335.39 L 416.71 333.87 L 417.98 333.75 L 420.27 332.24 L 423.63 331.34 L 424.16 330.81 L 423.47 326.55 L 422.94 326.36 L 422.52 325.75 L 422.48 323.85 L 423.21 323.15 L 423.78 322.21 L 423.29 321.05 L 422.57 320.95 L 423.29 317.77 L 423.66 317.49 L 424.83 317.26 L 427.61 318.4 L 428.01 318.27 L 428.58 317.73 L 428 313.96 L 429.17 312.47 L 431.59 313.95 L 432.49 315.71 L 435.72 316.05 L 436.72 315.04 L 436.72 315.04 L 437.23 317.45 L 435.8 320.89 L 436.2 321.12 L 437.54 320.21 L 438.24 319.21 L 438.96 319.08 L 441.09 319.46 L 442.13 318.69 L 443.98 316.12 L 444.97 316.27 L 446.4 315.74 L 448.21 314.19 L 449.16 313.02 L 451.18 312.61 L 454.55 310.75 L 455.19 309.64 L 459.46 306.61 L 463.28 305.03 L 465.08 305.12 L 466.28 305.62 L 468.46 305.65 L 470.74 306.18 L 471.59 306.64 L 470.3 309.38 L 470.15 310.27 L 470.41 311.76 L 471.02 312.26 L 476.35 313.72 L 476.99 313.55 L 477.8 312.43 L 479.68 311.54 L 481.45 311.28 L 484.18 312.03 L 485.28 312.57 L 489.63 316.21 L 490.61 316.03 L 492.78 317.65 L 495.31 318.87 L 496.24 319.09 L 496.75 318.88 L 498.28 320.12 L 502.67 318.89 L 503.05 319.07 L 509.57 325.27 L 510.01 329.23 L 510.58 329.02 L 513.19 329.47 L 514.66 328.97 L 515.98 327.98 L 517.97 328.13 L 520.7 328.69 L 522.96 329.77 L 525.15 330.38 L 527.27 330.35 L 530.1 332.82 L 530.83 333.2 L 531.72 333.27 L 532.5 334.29 L 532.92 335.46 L 531.45 338.54 L 526.49 342.76 L 526.34 345.41 L 526.9 346.43 L 526.9 346.85 L 525.88 347.56 L 523.4 347.32 L 522.58 348.2 L 521.76 351.5 L 521.23 355.9 L 521.45 356.15 L 521.8 355.96 L 522 355.51 L 522.64 355.27 L 523.22 356.5 L 523 358.01 L 523.15 358.52 L 527.29 361.58 L 527.82 362.62 L 527.83 363.15 L 527.15 364.5 z"},{code:"MS",name:"Mato Grosso do Sul",gTransform:"matrix(1 0 0 1 -2.22 90.13)",pathTransform:"translate(-303.77, -409.4)",d:"M 358.95 399.81 L 358.55 402.27 L 358.27 402.67 L 356.77 403.45 L 355.45 403.49 L 354.98 403.71 L 353.76 404.74 L 351.77 407.42 L 351.04 408.07 L 350.03 408.37 L 349.41 410.05 L 349.25 412.98 L 346.66 416.62 L 345.7 417.14 L 345.47 417.52 L 345.78 419.45 L 345.7 420.4 L 344.49 422.74 L 342.49 425 L 342.84 425.85 L 342.56 427.06 L 341.12 428.09 L 340.72 429.3 L 338.99 430.99 L 337.73 433.43 L 335.78 435.3 L 328.22 439.83 L 326.96 440.97 L 326.22 442.51 L 325.38 443.59 L 325.38 443.59 L 319.97 445.86 L 318.86 446.68 L 317.93 449.01 L 317.95 450.16 L 316.5 453.72 L 315.83 454.4 L 314.17 455.41 L 313.06 455.73 L 312.73 456.08 L 311.16 464 L 310.8 464.82 L 308.42 466.38 L 308.42 466.38 L 305.87 464.05 L 302.46 462.16 L 298.47 464.13 L 297.79 464.88 L 296.13 465.37 L 293.55 465.8 L 291.19 465.34 L 290.18 464.69 L 289.71 460.42 L 289.39 459.72 L 288.49 458.77 L 288.26 456.3 L 288.77 454.96 L 288.13 454.17 L 288.04 453.73 L 288.04 450.86 L 287.15 448.89 L 286.55 446.15 L 286.5 445.43 L 287.09 444.07 L 287.11 442.46 L 285.54 441.37 L 285.16 440.57 L 285 438.41 L 283.35 436.59 L 281.18 436.33 L 279.67 436.64 L 277.84 436.35 L 275.38 434.39 L 274.82 432.9 L 273.28 433.23 L 271.11 435.97 L 270.11 435.37 L 268.39 436.18 L 267.31 436.34 L 265.57 435.65 L 263.01 435.16 L 259.55 435.39 L 255.89 434.68 L 255.41 433.77 L 253.42 433.64 L 252.53 434.16 L 250.03 433.28 L 250.94 426.01 L 250.51 423.63 L 251.11 422.21 L 252.09 420.75 L 252.69 414.72 L 252.03 412.39 L 251.98 410.66 L 251.22 409.7 L 250.79 409.61 L 250.3 410.26 L 249.66 407 L 248.87 405.13 L 247.66 403.11 L 247.31 401.28 L 251.34 398.98 L 252.1 398.1 L 247.9 394.24 L 253.28 382.82 L 254.4 382.76 L 254.12 380.63 L 253.38 380.5 L 256.61 370.17 L 257.27 369.01 L 254.18 363.16 L 254.21 361.25 L 254.21 361.25 L 254.91 361.45 L 255.93 362.55 L 258.08 364.07 L 263.7 362.1 L 265.75 360.1 L 267.77 357.15 L 267.86 355.98 L 269.26 354.53 L 271.85 354.56 L 273.41 354.34 L 274.18 354.68 L 275.84 354.17 L 277.19 352.92 L 279.21 352.43 L 280.48 352.63 L 281.24 353.78 L 284.03 355.03 L 286.65 355.5 L 287.3 355.85 L 287.57 356.71 L 288.35 357.73 L 291.38 358.89 L 292.64 360 L 293.88 360.57 L 298.4 359.94 L 299.66 359.14 L 300.15 358.29 L 301.58 357.68 L 304.02 357.75 L 305.61 358.79 L 305.91 360.16 L 306.15 360.41 L 307.14 360.45 L 309.27 359.57 L 310.28 359.63 L 315.9 353.62 L 317.24 353.49 L 316.01 360.1 L 314.21 360.8 L 312.55 363.63 L 312.36 364.09 L 312.51 364.62 L 313.81 364.73 L 315.55 366 L 320.17 366.27 L 320.74 365.7 L 323.4 365.62 L 324.27 365.7 L 325.44 366.27 L 326.99 365.96 L 326.99 365.96 L 327.18 367.73 L 326.92 370.31 L 327.15 371.42 L 327.43 371.83 L 328.09 372.02 L 329.23 371.35 L 331.48 372.25 L 331.56 372.67 L 330.25 374.43 L 329.68 375.6 L 329.42 376.44 L 329.55 376.77 L 333.35 377.47 L 336.13 377.31 L 338.83 378.99 L 339.97 379.16 L 341.41 379.87 L 342.08 380.48 L 345.15 382.04 L 345.83 382.89 L 349.18 384.23 L 350.67 384.27 L 352.57 384.7 L 354.19 386.25 L 357.34 386.86 L 360 389.1 L 360.24 389.55 L 360.24 389.55 L 359.66 389.8 L 358.67 393.98 L 359.26 397.19 z"},{code:"MT",name:"Mato Grosso",gTransform:"matrix(1 0 0 1 -23.8 -38.15)",pathTransform:"translate(-282.2, -281.12)",d:"M 206.96 296.05 L 208.43 294.62 L 212.54 292.05 L 213.06 289.6 L 214.49 285.82 L 215.42 284.74 L 217.06 284.21 L 217.49 283.8 L 218.07 282.96 L 218.59 280.71 L 220.25 278.7 L 220.81 276.46 L 220.88 274.75 L 220.3 273.26 L 220.34 271.21 L 218.81 267.87 L 217.91 267.9 L 217.33 267.39 L 216.9 264.14 L 217.04 262.82 L 218.4 261.74 L 219.8 259.99 L 219.97 259.24 L 218.56 255.65 L 217.49 255.22 L 216.38 255.11 L 212.88 255.2 L 211.66 254.09 L 211.9 253.53 L 194.74 253.48 L 195.64 244.48 L 194.14 241.73 L 193.87 239.97 L 193.9 239.17 L 194.9 235.65 L 194.52 233.72 L 195.46 232.05 L 194.63 229.78 L 194.48 228.39 L 194.22 227.78 L 193.44 227.31 L 193.38 226.96 L 194.67 221.97 L 195.43 220.55 L 194.83 219.31 L 193.43 218.34 L 193.43 218.34 L 241.28 218.02 L 242.49 217.29 L 243.67 212.07 L 245.05 207.85 L 244.59 205.91 L 243.93 204.54 L 243.83 203.69 L 244.25 202.84 L 245.11 202.2 L 246.31 200.38 L 246.58 199.37 L 246.24 198.53 L 246.3 197.77 L 246.5 197.16 L 247.68 195.96 L 247.68 195.96 L 248.85 197.04 L 251.3 201.1 L 251.7 202.86 L 253.07 206.82 L 254.39 208.75 L 255.16 210.37 L 254.93 212.81 L 255.41 215.21 L 256.14 217.41 L 257.67 218.52 L 260.67 221.27 L 264.05 222.97 L 264.28 223.91 L 264.24 225.01 L 264.47 225.5 L 265.42 225.9 L 266.24 225.73 L 267.87 226.18 L 268.41 226.9 L 268.61 227.98 L 268.96 228.3 L 270.33 227.85 L 274.02 229.34 L 308.06 231.76 L 371.03 235.24 L 371.03 235.24 L 370.38 236.26 L 369.82 238.15 L 368.72 239.4 L 368.28 242.54 L 367.85 243.39 L 367.48 243.66 L 365.54 248.95 L 365 251.92 L 364.96 254.87 L 363.08 260.86 L 363.14 261.72 L 364.53 263.06 L 364.37 263.93 L 363.55 264.82 L 363.5 265.32 L 364.6 267.57 L 364.13 270.88 L 364.14 272.45 L 364.66 273.03 L 365.1 276.08 L 364.36 278.84 L 365.34 282.18 L 366.3 282.69 L 367.1 282.71 L 367.1 282.71 L 367.18 283.34 L 366.91 284.47 L 365.94 285.33 L 365.59 286.23 L 365.75 288.95 L 365.36 290.02 L 363.36 293.19 L 362.33 295.82 L 361.12 296.6 L 361.24 301.78 L 359.64 304.87 L 359.06 307.61 L 359.54 308.75 L 359.55 309.55 L 358.38 312.42 L 357.54 315.35 L 356.15 316.78 L 354.94 317.51 L 353.71 316.83 L 352.64 317.09 L 350.99 318.1 L 349.07 320.04 L 348.69 320.78 L 348.05 324.88 L 347.34 325.84 L 345.36 330.03 L 345.04 330.31 L 342.32 331.17 L 339.67 331.3 L 338.27 333.92 L 336.52 334.89 L 336.44 336.43 L 335.62 337.86 L 334.34 338.9 L 333.84 339.91 L 333.51 341.86 L 332.26 343.88 L 330.34 345.65 L 328.32 346.49 L 327.62 347.26 L 327.24 350.17 L 324.69 354.02 L 324.29 357.43 L 324.45 358.14 L 325.86 360.33 L 326.04 363.76 L 326.99 365.96 L 326.99 365.96 L 325.44 366.27 L 324.27 365.7 L 323.4 365.62 L 320.74 365.7 L 320.17 366.27 L 315.55 366 L 313.81 364.73 L 312.51 364.62 L 312.36 364.09 L 312.55 363.63 L 314.21 360.8 L 316.01 360.1 L 317.24 353.49 L 315.9 353.62 L 310.28 359.63 L 309.27 359.57 L 307.14 360.45 L 306.15 360.41 L 305.91 360.16 L 305.61 358.79 L 304.02 357.75 L 301.58 357.68 L 300.15 358.29 L 299.66 359.14 L 298.4 359.94 L 293.88 360.57 L 292.64 360 L 291.38 358.89 L 288.35 357.73 L 287.57 356.71 L 287.3 355.85 L 286.65 355.5 L 284.03 355.03 L 281.24 353.78 L 280.48 352.63 L 279.21 352.43 L 277.19 352.92 L 275.84 354.17 L 274.18 354.68 L 273.41 354.34 L 271.85 354.56 L 269.26 354.53 L 267.86 355.98 L 267.77 357.15 L 265.75 360.1 L 263.7 362.1 L 258.08 364.07 L 255.93 362.55 L 254.91 361.45 L 254.21 361.25 L 254.21 361.25 L 253.55 360.58 L 253.23 359.78 L 253.77 359.07 L 251.33 356.92 L 250.05 357.55 L 249.53 357.5 L 248.36 356.82 L 247.91 356.12 L 245.89 354.71 L 244 353.95 L 243.7 353.63 L 243.4 352.51 L 243.17 349.58 L 242.56 347.81 L 242.37 344.15 L 243.25 342.51 L 244.39 341.42 L 244.73 339.64 L 244.68 337.75 L 243.72 337.81 L 243.32 338.41 L 242.94 338.57 L 216.08 337.49 L 215.03 324.84 L 209.66 318.71 L 214.54 318.65 L 214.19 311.1 L 211.55 305.78 L 211.06 303.81 L 211.32 302.75 L 211.93 302.2 L 212.58 300.92 L 211.14 297.99 L 208.03 296.95 z"},{code:"PA",name:"Pará",gTransform:"matrix(1 0 0 1 29.16 -180.48)",pathTransform:"translate(-335.15, -138.78)",d:"M 371.03 235.24 L 308.05999999999995 231.76000000000002 L 274.0199999999999 229.34000000000003 L 270.3299999999999 227.85000000000002 L 268.9599999999999 228.3 L 268.6099999999999 227.99 L 268.4099999999999 226.9 L 267.8599999999999 226.18 L 266.2299999999999 225.73000000000002 L 265.4099999999999 225.9 L 264.4599999999999 225.51000000000002 L 264.2299999999999 225.01000000000002 L 264.2699999999999 223.91000000000003 L 264.0399999999999 222.97000000000003 L 260.6599999999999 221.27000000000004 L 257.6599999999999 218.51000000000005 L 256.1199999999999 217.40000000000003 L 255.3999999999999 215.20000000000005 L 254.9199999999999 212.81000000000006 L 255.1499999999999 210.37000000000006 L 254.37999999999988 208.74000000000007 L 253.04999999999987 206.81000000000006 L 251.67999999999986 202.86000000000007 L 251.28999999999988 201.10000000000008 L 248.8399999999999 197.04000000000008 L 247.65999999999988 195.96000000000006 L 247.65999999999988 195.96000000000006 L 247.0899999999999 195.40000000000006 L 246.93999999999988 193.44000000000005 L 246.2999999999999 192.18000000000006 L 244.7099999999999 190.62000000000006 L 243.6399999999999 190.04000000000005 L 243.2699999999999 189.47000000000006 L 242.43999999999988 187.13000000000005 L 242.46999999999989 186.00000000000006 L 243.0499999999999 185.03000000000006 L 244.4999999999999 183.90000000000006 L 245.2799999999999 182.59000000000006 L 275.1799999999999 118.35000000000007 L 273.3699999999999 116.68000000000006 L 273.4999999999999 115.90000000000006 L 273.3099999999999 115.42000000000006 L 271.9199999999999 115.77000000000005 L 271.0699999999999 116.38000000000005 L 269.1999999999999 115.60000000000005 L 268.09999999999985 113.43000000000005 L 265.40999999999985 111.98000000000005 L 264.1399999999999 110.64000000000004 L 264.0599999999999 110.04000000000005 L 262.7399999999999 109.22000000000006 L 261.3699999999999 109.07000000000005 L 259.1199999999999 108.42000000000004 L 256.7399999999999 107.11000000000004 L 254.8599999999999 106.44000000000004 L 253.5099999999999 105.35000000000004 L 252.8799999999999 104.45000000000003 L 248.2999999999999 101.91000000000003 L 243.6599999999999 98.14000000000003 L 243.3599999999999 97.70000000000003 L 243.3199999999999 96.77000000000002 L 242.7699999999999 94.94000000000003 L 240.9299999999999 93.71000000000002 L 240.2299999999999 93.90000000000002 L 239.8699999999999 93.70000000000002 L 238.03999999999988 91.72000000000001 L 238.0899999999999 89.61000000000001 L 238.43999999999988 88.92000000000002 L 238.25999999999988 88.51000000000002 L 236.56999999999988 87.66000000000003 L 236.32999999999987 86.98000000000002 L 236.14999999999986 84.71000000000002 L 236.57999999999987 83.26000000000002 L 236.17999999999986 78.40000000000002 L 236.17999999999986 78.40000000000002 L 234.58999999999986 61.43000000000002 L 234.58999999999986 61.43000000000002 L 235.33999999999986 61.75000000000002 L 235.76999999999987 62.33000000000002 L 235.74999999999986 62.81000000000002 L 236.19999999999985 63.210000000000015 L 237.11999999999983 63.490000000000016 L 238.48999999999984 62.780000000000015 L 238.95999999999984 61.97000000000001 L 241.66999999999985 62.20000000000001 L 242.47999999999985 61.15000000000001 L 241.93999999999986 59.34000000000001 L 243.72999999999985 58.98000000000001 L 245.13999999999984 57.35000000000001 L 247.77999999999983 58.36000000000001 L 249.65999999999983 58.39000000000001 L 250.19999999999982 56.870000000000005 L 253.52999999999983 55.25000000000001 L 255.49999999999983 55.64000000000001 L 256.65999999999985 55.53000000000001 L 257.14999999999986 55.28000000000001 L 258.34999999999985 53.80000000000001 L 258.74999999999983 52.40000000000001 L 260.2099999999998 51.30000000000001 L 261.0699999999998 51.19000000000001 L 261.7199999999998 51.65000000000001 L 263.8299999999998 50.52000000000001 L 264.23999999999984 50.63000000000001 L 264.60999999999984 51.62000000000001 L 265.33999999999986 52.070000000000014 L 267.36999999999983 52.55000000000001 L 268.97999999999985 52.80000000000001 L 269.53999999999985 52.20000000000001 L 271.20999999999987 51.81000000000001 L 271.98999999999984 52.09000000000001 L 272.80999999999983 52.08000000000001 L 273.66999999999985 51.74000000000001 L 275.90999999999985 52.040000000000006 L 280.57999999999987 53.42000000000001 L 281.53999999999985 53.28000000000001 L 282.53999999999985 52.41000000000001 L 282.5099999999999 50.13000000000001 L 280.4399999999999 47.63000000000001 L 279.1999999999999 47.00000000000001 L 279.6899999999999 45.32000000000001 L 280.9999999999999 43.870000000000005 L 281.27999999999986 42.760000000000005 L 281.58999999999986 42.59 L 282.29999999999984 42.78 L 283.1299999999998 43.54 L 285.47999999999985 44.65 L 297.09999999999985 42.32 L 298.66999999999985 44.01 L 299.6899999999998 44.07 L 300.1299999999998 43.78 L 300.1299999999998 43.78 L 300.74999999999983 44.35 L 301.11999999999983 46.65 L 300.49999999999983 47.949999999999996 L 300.24999999999983 52.489999999999995 L 300.48999999999984 53.92999999999999 L 300.79999999999984 54.46999999999999 L 301.96999999999986 54.489999999999995 L 303.04999999999984 54.199999999999996 L 306.4399999999998 54.56999999999999 L 307.72999999999985 55.059999999999995 L 309.65999999999985 56.10999999999999 L 310.32999999999987 56.90999999999999 L 310.8199999999999 58.18999999999999 L 312.0099999999999 58.30999999999999 L 313.14999999999986 59.14999999999999 L 313.9499999999999 60.12999999999999 L 314.78999999999985 60.39999999999999 L 316.11999999999983 60.25999999999999 L 316.49999999999983 59.83999999999999 L 317.4399999999998 59.69999999999999 L 320.2799999999998 62.359999999999985 L 320.9599999999998 62.329999999999984 L 321.4499999999998 63.509999999999984 L 320.7699999999998 63.73999999999998 L 320.5799999999998 64.45999999999998 L 321.3399999999998 67.28999999999998 L 323.3599999999998 69.54999999999998 L 325.9299999999998 70.27999999999999 L 326.0999999999998 70.60999999999999 L 325.6699999999998 73.74999999999999 L 325.8599999999998 75.85999999999999 L 326.5299999999998 77.36999999999999 L 327.1499999999998 77.92999999999999 L 327.7399999999998 79.74 L 327.6099999999998 81.32 L 329.1099999999998 84.8 L 329.9299999999998 84.99 L 330.70999999999975 84.63 L 333.63999999999976 87.91 L 333.5599999999998 90.34 L 333.9699999999998 91.28 L 334.9199999999998 91.47 L 335.2499999999998 91.94 L 335.5599999999998 93.52 L 335.3499999999998 94.21 L 335.4599999999998 95.50999999999999 L 337.3299999999998 96.89999999999999 L 337.7599999999998 98.39999999999999 L 339.2099999999998 99.42999999999999 L 341.99999999999983 100.11 L 343.29999999999984 99.99 L 344.0699999999998 99.64999999999999 L 345.0099999999998 99.71 L 345.0099999999998 99.71 L 344.47999999999985 100.44999999999999 L 344.76999999999987 102.03999999999999 L 344.59999999999985 102.57 L 343.30999999999983 103.67999999999999 L 341.91999999999985 103.85 L 341.41999999999985 103.66999999999999 L 340.57999999999987 102.87999999999998 L 339.91999999999985 102.72999999999998 L 336.53999999999985 104.30999999999997 L 336.16999999999985 104.84999999999998 L 334.5699999999998 105.56999999999998 L 333.9399999999998 105.54999999999998 L 332.3899999999998 106.13999999999999 L 332.42999999999984 106.71999999999998 L 338.8899999999998 105.65999999999998 L 339.7699999999998 106.31999999999998 L 339.8999999999998 106.77999999999997 L 339.8999999999998 107.43999999999997 L 339.2799999999998 107.93999999999997 L 339.5799999999998 108.29999999999997 L 340.2099999999998 108.09999999999997 L 341.0699999999998 107.09999999999997 L 342.0899999999998 107.08999999999996 L 342.6199999999998 106.81999999999996 L 343.2199999999998 106.93999999999997 L 344.2899999999998 106.51999999999997 L 345.4299999999998 105.94999999999997 L 348.70999999999975 103.60999999999997 L 350.20999999999975 103.25999999999998 L 352.0499999999997 102.44999999999997 L 355.20999999999975 100.60999999999997 L 355.7499999999998 99.60999999999997 L 356.4199999999998 99.08999999999997 L 358.50999999999976 98.07999999999997 L 359.1699999999998 97.35999999999997 L 358.9199999999998 96.68999999999997 L 359.12999999999977 96.27999999999997 L 360.25999999999976 95.99999999999997 L 361.34999999999974 96.05999999999997 L 361.75999999999976 96.26999999999997 L 362.13999999999976 100.06999999999996 L 361.6199999999998 102.64999999999996 L 361.94999999999976 104.26999999999997 L 362.75999999999976 105.86999999999996 L 364.06999999999977 107.21999999999996 L 364.3699999999998 108.85999999999996 L 364.2499999999998 109.32999999999996 L 362.4099999999998 111.16999999999996 L 361.93999999999977 111.29999999999995 L 361.06999999999977 110.77999999999996 L 359.2499999999998 110.25999999999996 L 357.9899999999998 109.94999999999996 L 357.0599999999998 110.08999999999996 L 354.9299999999998 109.04999999999995 L 354.6699999999998 107.92999999999995 L 353.7899999999998 107.39999999999995 L 351.5099999999998 111.21999999999994 L 350.8999999999998 113.58999999999995 L 351.5799999999998 116.55999999999995 L 352.05999999999983 117.19999999999995 L 352.97999999999985 117.81999999999995 L 351.96999999999986 116.67999999999995 L 351.53999999999985 113.98999999999995 L 351.65999999999985 113.46999999999996 L 354.22999999999985 109.24999999999996 L 356.53999999999985 110.42999999999996 L 356.64999999999986 110.87999999999997 L 359.17999999999984 113.32999999999997 L 358.92999999999984 115.34999999999997 L 358.1899999999998 115.89999999999996 L 358.5899999999998 118.22999999999996 L 359.1099999999998 119.35999999999996 L 360.2299999999998 120.10999999999996 L 360.9699999999998 120.25999999999996 L 361.4899999999998 120.74999999999996 L 361.1499999999998 120.10999999999996 L 360.3799999999998 119.86999999999996 L 359.17999999999984 118.82999999999996 L 358.9599999999998 118.14999999999995 L 359.2999999999998 113.94999999999995 L 360.1199999999998 112.75999999999995 L 361.5499999999998 113.48999999999995 L 362.37999999999977 114.68999999999996 L 362.2899999999998 115.47999999999996 L 363.4899999999998 116.33999999999996 L 363.7399999999998 116.04999999999995 L 362.7399999999998 114.78999999999995 L 361.81999999999977 112.68999999999996 L 361.81999999999977 112.24999999999996 L 364.07999999999976 109.92999999999996 L 365.69999999999976 110.01999999999997 L 367.62999999999977 110.65999999999997 L 367.96999999999974 111.21999999999997 L 367.35999999999973 111.80999999999997 L 367.6799999999997 112.08999999999997 L 368.15999999999974 112.11999999999998 L 369.1899999999997 111.94999999999997 L 370.5199999999997 111.04999999999997 L 374.6099999999997 110.08999999999997 L 375.37999999999965 110.28999999999998 L 377.11999999999966 111.34999999999998 L 380.2899999999997 110.92999999999998 L 381.3599999999997 110.51999999999998 L 382.37999999999965 109.50999999999998 L 383.3599999999997 108.91999999999997 L 385.0999999999997 108.40999999999997 L 385.86999999999966 108.47999999999996 L 385.92999999999967 109.22999999999996 L 383.88999999999965 113.24999999999996 L 383.64999999999964 114.74999999999996 L 383.18999999999966 115.81999999999995 L 382.3599999999997 116.84999999999995 L 382.3499999999997 117.72999999999995 L 382.92999999999967 119.14999999999995 L 382.6099999999997 121.61999999999995 L 383.48999999999967 120.42999999999995 L 383.49999999999966 119.02999999999994 L 385.0399999999997 116.02999999999994 L 386.1699999999997 112.83999999999995 L 387.2899999999997 111.27999999999994 L 387.55999999999966 111.00999999999995 L 388.31999999999965 110.95999999999995 L 388.89999999999964 110.60999999999996 L 390.71999999999963 110.37999999999995 L 391.5999999999996 109.02999999999996 L 393.1099999999996 107.33999999999996 L 394.46999999999963 105.07999999999996 L 394.9899999999996 104.61999999999996 L 395.77999999999963 105.10999999999996 L 396.39999999999964 104.64999999999996 L 398.01999999999964 106.98999999999997 L 399.20999999999964 107.57999999999997 L 399.1599999999996 106.83999999999997 L 398.8099999999996 106.08999999999997 L 399.4299999999996 105.07999999999997 L 402.9399999999996 104.56999999999996 L 401.9099999999996 104.24999999999997 L 398.39999999999964 104.70999999999997 L 398.08999999999963 104.49999999999997 L 398.37999999999965 102.06999999999996 L 398.88999999999965 101.77999999999996 L 399.55999999999966 102.15999999999995 L 400.57999999999964 102.26999999999995 L 401.64999999999964 99.16999999999996 L 400.96999999999963 97.77999999999996 L 400.9999999999996 97.09999999999995 L 402.1699999999996 95.28999999999995 L 405.0099999999996 92.80999999999995 L 405.3699999999996 92.72999999999995 L 406.4799999999996 93.86999999999995 L 409.4099999999996 91.77999999999994 L 409.8699999999996 91.70999999999995 L 410.2699999999996 92.15999999999995 L 410.3699999999996 92.72999999999995 L 410.0499999999996 93.39999999999995 L 411.1199999999996 93.23999999999995 L 411.9299999999996 92.65999999999995 L 412.2899999999996 91.87999999999995 L 412.9199999999996 91.68999999999996 L 413.1999999999996 91.83999999999996 L 413.9399999999996 93.22999999999996 L 415.2699999999996 94.42999999999996 L 415.4699999999996 93.86999999999996 L 415.35999999999956 93.48999999999997 L 414.4 93 L 414.26 92.71 L 414.13 91.50999999999999 L 414.3 91.08999999999999 L 414.74 90.89999999999999 L 417.02 91.16 L 418.2 91.81 L 418.82 92.83 L 420.45 93.53999999999999 L 422.09999999999997 92.75999999999999 L 422.62999999999994 94.89999999999999 L 422.12999999999994 95.21 L 422.09999999999997 95.8 L 423.02 95.28 L 424.18 92.93 L 424.56 93.16000000000001 L 424.33 94.49000000000001 L 424.74 94.93 L 427.25 94.67 L 427.7 95.32000000000001 L 428.15999999999997 97.00000000000001 L 427.55999999999995 97.95000000000002 L 428.40999999999997 97.45000000000002 L 428.66999999999996 97.82000000000002 L 430.55999999999995 97.96000000000002 L 434.0899999999999 96.72000000000003 L 433.7799999999999 98.30000000000003 L 433.0299999999999 100.13000000000002 L 434.49999999999994 99.64000000000003 L 435.0899999999999 99.02000000000002 L 435.7199999999999 100.64000000000003 L 435.7199999999999 100.64000000000003 L 434.94999999999993 101.09000000000003 L 434.4799999999999 102.12000000000003 L 434.63999999999993 103.50000000000003 L 433.92999999999995 107.89000000000003 L 433.35999999999996 108.63000000000002 L 432.21999999999997 108.78000000000003 L 432.16999999999996 109.40000000000003 L 432.43999999999994 109.89000000000003 L 433.42999999999995 109.73000000000003 L 433.85999999999996 110.26000000000003 L 433.78 111.87000000000003 L 432.88 114.89000000000003 L 432.52 115.60000000000002 L 430.78 117.17000000000002 L 430.28 119.55000000000001 L 430.40999999999997 121.19000000000001 L 426.72999999999996 124.28000000000002 L 427.77 125.86000000000001 L 426.97999999999996 126.67000000000002 L 427.15999999999997 128.49 L 426.7 129.77 L 425.87 131.22 L 424.39 132.98 L 422.43 134.51999999999998 L 420.83 139.20999999999998 L 420.53999999999996 141.10999999999999 L 420.06999999999994 142.32 L 417.62999999999994 144.64 L 416.50999999999993 145.1 L 415.88999999999993 147.98 L 414.3399999999999 149.14999999999998 L 413.9099999999999 150.29999999999998 L 412.3599999999999 152.46999999999997 L 411.1899999999999 153.38999999999996 L 408.83999999999986 153.15999999999997 L 394.1299999999999 164.98999999999998 L 394.6199999999999 165.07 L 394.6199999999999 165.07 L 396.9099999999999 165.88 L 398.7799999999999 165.64 L 400.06999999999994 165.76 L 401.0899999999999 167.42 L 401.4799999999999 167.73 L 402.3499999999999 167.86999999999998 L 403.6099999999999 169.03999999999996 L 403.5699999999999 169.66999999999996 L 403.1999999999999 170.33999999999995 L 402.47999999999985 170.70999999999995 L 401.5099999999998 170.77999999999994 L 401.2199999999998 171.05999999999995 L 401.3099999999998 172.46999999999994 L 402.31999999999977 173.80999999999995 L 401.39999999999975 176.55999999999995 L 400.75999999999976 177.03999999999994 L 399.2999999999998 177.49999999999994 L 399.0499999999998 177.95999999999995 L 399.3399999999998 179.15999999999994 L 399.1499999999998 180.49999999999994 L 397.8499999999998 180.64999999999995 L 396.3399999999998 181.98999999999995 L 395.4899999999998 183.25999999999996 L 395.63999999999976 184.76999999999995 L 395.39999999999975 185.26999999999995 L 392.89999999999975 186.46999999999994 L 389.4899999999997 187.60999999999993 L 387.0199999999997 189.38999999999993 L 386.8299999999997 189.73999999999992 L 387.2599999999997 191.92999999999992 L 387.3199999999997 194.5999999999999 L 386.03999999999974 196.6999999999999 L 384.6299999999997 198.3799999999999 L 384.47999999999973 198.9499999999999 L 384.64999999999975 199.8299999999999 L 385.2399999999997 200.7899999999999 L 386.90999999999974 202.52999999999992 L 387.65999999999974 202.8499999999999 L 387.8099999999997 203.14999999999992 L 387.1499999999997 207.1899999999999 L 385.3899999999997 212.33999999999992 L 384.3099999999997 213.14999999999992 L 382.60999999999973 216.38999999999993 L 382.4299999999997 217.37999999999994 L 381.4899999999997 218.91999999999993 L 380.7499999999997 219.76999999999992 L 379.6999999999997 219.92999999999992 L 378.3299999999997 220.8499999999999 L 377.2999999999997 222.7699999999999 L 376.08999999999975 224.4499999999999 L 374.90999999999974 225.5399999999999 L 373.75999999999976 227.11999999999992 L 372.62999999999977 231.57999999999993 L 371.03 235.24 z M 392.19 104.93 L 387.67 106.89 L 384.28000000000003 107.41 L 382.26000000000005 107.1 L 381.61000000000007 108.22999999999999 L 379.7700000000001 109.41999999999999 L 379.05000000000007 108.80999999999999 L 378.44000000000005 107.27999999999999 L 378.21000000000004 107.55999999999999 L 378.63000000000005 108.78999999999999 L 378.2900000000001 109.6 L 377.5800000000001 110.00999999999999 L 373.8100000000001 108.36999999999999 L 373.0100000000001 109.08999999999999 L 368.8200000000001 110.35 L 365.6200000000001 109.78 L 364.8100000000001 109.17 L 364.5700000000001 107.32000000000001 L 364.3400000000001 106.91000000000001 L 363.2300000000001 105.89000000000001 L 362.1700000000001 104.29000000000002 L 361.9600000000001 102.51000000000002 L 362.4800000000001 99.76000000000002 L 363.1000000000001 99.38000000000002 L 364.86000000000007 99.74000000000002 L 365.7900000000001 98.99000000000002 L 365.87000000000006 98.43000000000002 L 364.57000000000005 98.86000000000003 L 363.35 98.73000000000003 L 362.41 98.02000000000004 L 362.23 96.97000000000004 L 362.57 91.89000000000004 L 363.3 91.13000000000004 L 363.65000000000003 91.88000000000004 L 365.41 92.48000000000003 L 365.96000000000004 92.42000000000003 L 365.50000000000006 92.00000000000003 L 364.2300000000001 91.78000000000003 L 363.3300000000001 89.62000000000003 L 363.6900000000001 87.94000000000003 L 364.5800000000001 85.97000000000003 L 365.9100000000001 84.64000000000003 L 366.87000000000006 84.07000000000004 L 368.21000000000004 83.58000000000004 L 369.53000000000003 83.45000000000005 L 372.99 83.97000000000004 L 380.2 85.74000000000004 L 383.9 85.28000000000004 L 384.01 84.98000000000005 L 385.15 84.36000000000004 L 387.31 83.99000000000004 L 390.2 84.28000000000004 L 393 85.10000000000004 L 399.48 85.95000000000003 L 400.11 86.42000000000003 L 400.06 87.65000000000003 L 399.36 88.39000000000003 L 398.68 89.89000000000003 L 398.32 92.54000000000003 L 397.46 95.84000000000003 L 396.16999999999996 96.52000000000004 L 395.81999999999994 97.21000000000004 L 396.04999999999995 98.40000000000003 L 394.06999999999994 100.98000000000003 L 392.67999999999995 104.48000000000003 L 392.19 104.93 z M 344.98 104.76 L 344.23 104.25 L 345.33000000000004 102 L 345.24000000000007 100.21 L 345.49000000000007 100 L 347.82000000000005 99.52 L 348.72 98.66 L 348.87 98.16 L 348.67 95.82 L 349.53000000000003 93.24 L 350.79 91.75 L 353.08000000000004 90.28 L 355.95000000000005 90.08 L 356.6700000000001 92.44 L 355.57000000000005 94.63 L 354.72 97.67 L 353.62 98.34 L 352.28000000000003 100.37 L 351.50000000000006 101.09 L 346.56000000000006 104.4 L 344.98 104.76 z M 373.46 81.86 L 372.43 81.61 L 369.98 81.69 L 369.19 81.53 L 368.9 81.27 L 368.52 80.17999999999999 L 368.53 78.94 L 370.03999999999996 78.52 L 371.92999999999995 78.56 L 374.11999999999995 77.27 L 378.92999999999995 76.67 L 379.69999999999993 76.93 L 380.37999999999994 77.61000000000001 L 380.19999999999993 78.63000000000001 L 377.63999999999993 80.02000000000001 L 375.85999999999996 82.50000000000001 L 374.76 83 L 373.46 81.86 z M 378.25 81.86 L 380.11 80.66 L 382.09000000000003 80.69 L 383.74 81.31 L 384.27 82.3 L 384.32 82.92 L 383.44 83.69 L 380.59 83.97 L 379.41999999999996 84.28999999999999 L 377.15999999999997 83.39999999999999 L 376.96 82.86999999999999 L 378.25 81.86 z M 361.27 86.25 L 360.77 85.99 L 360.15999999999997 86.03 L 358.61999999999995 85.34 L 358.8299999999999 84.18 L 359.4699999999999 83.26 L 361.38999999999993 82.86 L 363.74999999999994 81.96 L 365.06999999999994 82.03999999999999 L 365.86999999999995 82.72 L 365.9599999999999 82.85 L 364.0299999999999 84.46 L 362.9599999999999 84.8 L 361.27 86.25 z M 370.69 76.56 L 369.87 76.26 L 369.7 74.60000000000001 L 369.84999999999997 74.00000000000001 L 371.02 72.69000000000001 L 373.46999999999997 71.77000000000001 L 373.71999999999997 71.89000000000001 L 374.24999999999994 72.57000000000002 L 374.28999999999996 73.46000000000002 L 372.34 75.45000000000002 L 370.69 76.56 z M 356.86 96.78 L 356.72 96.37 L 356.91 95.44 L 357.95000000000005 92.63 L 360.54 90.94 L 361.26000000000005 90.66 L 361.95000000000005 90.8 L 361.79 92.59 L 360.23 93.03 L 358.61 95.22 L 356.86 96.78 z M 367.77 79.21 L 366.58 78.89999999999999 L 366.28 78.41999999999999 L 367.15999999999997 77.46 L 367.86999999999995 73.50999999999999 L 368.75999999999993 72.27999999999999 L 369.04999999999995 72.40999999999998 L 369.11999999999995 72.72999999999998 L 369.09999999999997 75.20999999999998 L 369.7 77.07999999999998 L 369.38 77.95999999999998 L 368.35 78.35999999999999 L 367.77 79.21 z M 352.96 89.4 L 352.69 89.21000000000001 L 352.81 88.60000000000001 L 353.36 88.24000000000001 L 354.55 86.53000000000002 L 355.31 84.99000000000001 L 356.04 84.33000000000001 L 357.49 83.79 L 357.29 85.28 L 356.89000000000004 86.28 L 355.17 87.94 L 352.96 89.4 z M 366.83 82.37 L 366.22999999999996 82.22 L 365.39 81.51 L 364.43 79.87 L 364.38 79.49000000000001 L 364.61 79.2 L 365.42 78.62 L 367.27000000000004 79.46000000000001 L 367.56000000000006 79.89000000000001 L 367.80000000000007 81.98000000000002 L 366.83 82.37 z M 361.45 112.93 L 360.8 112.82000000000001 L 359.92 112.30000000000001 L 359.23 112.76 L 358.48 112.48 L 356.8 110.74000000000001 L 356.8 110.13000000000001 L 358.08 110.12 L 361.14 111.44 L 361.45 112.93 z M 340.3 107.39 L 340.34000000000003 106.36 L 340.14000000000004 106.06 L 340.74000000000007 105.07000000000001 L 343.1000000000001 104.19000000000001 L 343.88000000000005 104.57000000000001 L 344.75000000000006 105.43 L 344.46000000000004 105.78 L 343.43000000000006 106.25 L 340.89000000000004 106.66 L 340.3 107.39 z M 353 100.7 L 352.82 100.67 L 352.83 100.32000000000001 L 353.37 99.38000000000001 L 355.16 97.76 L 355.58000000000004 96.52000000000001 L 355.63000000000005 95.22000000000001 L 355.87000000000006 94.92000000000002 L 356.19000000000005 95.36000000000001 L 356.19000000000005 96.87000000000002 L 355.30000000000007 99.60000000000002 L 354.68000000000006 100.25000000000003 L 353 100.7 z M 359.3 90.8 L 360.95 87.84 L 361.83 87.63000000000001 L 362.53999999999996 87.82000000000001 L 362.80999999999995 88.69000000000001 L 362.22999999999996 89.4 L 359.3 90.8 z M 390.72 109.77 L 389.88000000000005 109.42 L 389.5400000000001 108.36 L 390.5800000000001 106.64 L 391.6500000000001 106.31 L 391.8400000000001 106.41 L 391.8200000000001 107.14999999999999 L 391.0800000000001 109.38999999999999 L 390.72 109.77 z M 357.24 90.3 L 356.7 90.1 L 357.02 88.05999999999999 L 358.34999999999997 86.24999999999999 L 358.58 86.28999999999999 L 359.87 87.16999999999999 L 359.86 87.41999999999999 L 358.31 88.05999999999999 L 357.24 90.3 z M 359.47 95.33 L 360.19000000000005 95.36 L 359.7900000000001 95.81 L 358.8500000000001 96.12 L 358.74000000000007 97.24000000000001 L 357.95000000000005 97.95 L 356.26000000000005 98.79 L 356.1 98.61 L 356.37 97.78 L 356.84000000000003 97.15 L 358.57000000000005 95.48 L 359.47 95.33 z M 336.91 105.54 L 336.36 105.35000000000001 L 336.29 105.00000000000001 L 336.72 104.60000000000001 L 340.28000000000003 103.00000000000001 L 340.82000000000005 103.70000000000002 L 340.81000000000006 103.90000000000002 L 339.4100000000001 104.63000000000002 L 336.91 105.54 z M 400.44 100.76 L 399.41 100.57000000000001 L 398.59000000000003 99.78 L 399.46000000000004 98.53 L 400.8 98.52 L 400.99 99.71 L 400.89 100.3 L 400.44 100.76 z M 363.19 81.86 L 360.83 82.56 L 360.24 82.57000000000001 L 360.06 82.36000000000001 L 361.09 81.32000000000001 L 362.13 80.81 L 363.17 80.98 L 363.61 81.32000000000001 L 363.76 81.55000000000001 L 363.61 81.76 L 363.19 81.86 z M 357.92 90.45 L 357.84000000000003 89.69 L 358.09000000000003 89.19 L 360.57000000000005 87.73 L 359.6700000000001 89.73 L 358.86000000000007 90.36 L 357.92 90.45 z M 360.06 94.98 L 359.61 94.86 L 359.54 94.63 L 360.32 93.13 L 361.51 93.14999999999999 L 361.39 94.49999999999999 L 360.06 94.98 z M 388.1 110.81 L 387.82000000000005 110.58 L 388.72 108.98 L 389.40000000000003 108.58 L 389.63000000000005 109.33 L 390.14000000000004 109.7 L 389.88000000000005 110.22 L 389.45000000000005 110.56 L 388.82000000000005 110.38 L 388.1 110.81 z M 361.44 87.49 L 360.55 87.42 L 360.57 87.23 L 362.93 85.39 L 362.97 86.35 L 362.74 86.97999999999999 L 362.49 87.32 L 361.44 87.49 z M 428.9 97.71 L 428.52 97.17999999999999 L 428.71 96.41999999999999 L 429.72999999999996 95.50999999999999 L 429.97999999999996 95.66 L 430.21 97.41 L 428.9 97.71 z"},{code:"PB",name:"Paraíba",gTransform:"matrix(1 0 0 1 275.13 -126.21)",pathTransform:"translate(-581.13, -193.05)",d:"M 610.43 199.15 L 607.93 197.09 L 607.11 196.83 L 604.46 196.62 L 602.15 197.69 L 600.67 198.97 L 600.22 200.77 L 598.32 201.8 L 596.31 202.25 L 595.17 202.23 L 595.17 202.83 L 594.37 203.36 L 592.19 203.65 L 588.31 203.39 L 586.7 204.27 L 586.15 204.91 L 584.33 205.01 L 583.44 205.7 L 582.9 206.46 L 583.29 207.19 L 583.3 207.73 L 582.9 208.21 L 581.12 209.74 L 579.78 209.9 L 578.13 210.74 L 576.53 209.95 L 575.58 209.01 L 575.23 206.77 L 575.47 206.28 L 575.29 205.98 L 574.15 205.66 L 573.71 205.95 L 572.2 206.2 L 572.24 205.75 L 574.77 203.11 L 574.94 202.68 L 574.22 200.81 L 574.18 200.34 L 574.55 199.56 L 577.55 198.49 L 577.66 198.19 L 577.16 196.8 L 573.66 194.88 L 572.18 195.29 L 569.96 196.55 L 569.03 198.06 L 567.55 198.93 L 566.5 199.24 L 563.8 201.12 L 562.28 202.76 L 560.65 202.99 L 558.02 203.96 L 557.25 203.63 L 557.3 202.95 L 556.67 201.71 L 556.29 201.63 L 555.36 202.36 L 553.85 202.68 L 552.86 202.35 L 551.46 200.44 L 551.06 200.35 L 551.06 200.35 L 550.89 200.1 L 552.08 198.98 L 553.69 195.49 L 553.35 194.3 L 552.66 194.22 L 551.42 193.33 L 551.44 191.67 L 551.09 190.95 L 550.51 190.66 L 550.27 190.25 L 550.39 189.32 L 550.56 188.94 L 551.65 188.31 L 552.31 187 L 551.79 185.69 L 552.82 182.69 L 553.66 181.54 L 553.74 181 L 553.74 181 L 554.31 180.54 L 556.24 182.18 L 557.14 182.6 L 560.02 183.21 L 561.18 182.08 L 564.41 180.42 L 565.23 179.71 L 565.33 178.67 L 565.74 177.72 L 568.92 176.51 L 570.35 176.39 L 573.61 175.35 L 574.25 175.43 L 574.78 175.87 L 574.79 177.06 L 571.8 180.27 L 571.36 181.23 L 570.98 182.97 L 570.57 183.35 L 569.72 183.6 L 569.51 183.91 L 569.43 185.63 L 572.96 186.15 L 573.28 186.38 L 573.59 187.76 L 573.88 187.99 L 577.03 186.73 L 578.8 186.65 L 580.75 186.95 L 581.64 188.12 L 581.12 189.66 L 581.95 190.4 L 584.3 189.47 L 584.8 188.73 L 585.35 187.52 L 584.88 186.58 L 584.72 185.16 L 585.2 184.57 L 586.21 184.89 L 585.68 183.36 L 584.96 182.58 L 585.27 181.1 L 587.09 179.75 L 588.47 179.7 L 588.89 180.09 L 588.79 181.09 L 589.41 181.58 L 592.83 181.98 L 593.36 182.33 L 599.19 181.94 L 601.36 182.24 L 603.82 183.34 L 604.86 182.94 L 608.36 183.15 L 609.29 182.91 L 609.29 182.91 L 609.38 185.31 L 610.83 189.7 L 610.89 190.34 L 610.71 191.28 L 610.34 191.73 L 610.31 192.61 L 610.89 191.87 L 611.4 190.37 L 611.41 192.35 L 612 193.36 L 611.73 198.54 L 611.37 199.14 z"},{code:"PE",name:"Pernambuco",gTransform:"matrix(1 0 0 1 254.6 -106.99)",pathTransform:"translate(-560.6, -212.26)",d:"M 558.28 227.19 L 557.06 224.15 L 557.05 223.21 L 554.94 222.35 L 554.44 221.98 L 553.99 221.15 L 554.6 220.26 L 554.58 219.64 L 554.13 219.32 L 553.13 219.33 L 552.7 219.77 L 552.41 221.51 L 551.98 221.66 L 551.59 221.4 L 551.05 219.75 L 549.47 218.6 L 546.48 218.2 L 544.12 217.43 L 542.77 216.62 L 541.94 215.18 L 540.45 214.62 L 539.86 214.73 L 537.33 216.19 L 535.68 216.63 L 534.91 218.68 L 532.68 219.13 L 532.39 219.38 L 532.64 220.74 L 532.47 221.33 L 531.37 222.57 L 528.98 223.6 L 528.34 223.54 L 527.57 223.01 L 526.81 223.18 L 526.31 224.05 L 525.54 227.62 L 522.67 228.5 L 521.85 229.42 L 520.89 229.65 L 519.05 229.03 L 519.97 227.35 L 519.71 225.35 L 517.5 224.44 L 516.78 222.5 L 516.84 219.77 L 516.4 219.26 L 513.59 217.88 L 511.39 217.59 L 510.23 217.85 L 509.33 217.45 L 509.33 217.45 L 511.95 216.18 L 513.92 214.47 L 514.46 213.6 L 516.75 212.27 L 517.72 211.99 L 521.61 208.12 L 522.35 206.36 L 522.41 204.09 L 522.12 203.55 L 520.5 201.97 L 520.57 199.78 L 519.97 198.65 L 519.91 197.7 L 520.02 197.25 L 520.54 196.92 L 522.33 196.76 L 522.33 196.76 L 527.26 196.96 L 528.15 197.2 L 529.78 197.01 L 531.92 196.21 L 533.21 196.11 L 536.29 196.53 L 539.14 198.43 L 540.97 199.26 L 541.43 200.25 L 542.44 201.32 L 543.8 201.8 L 544.58 202.37 L 545.21 204.01 L 546.86 203.96 L 548.4 201.67 L 549.47 200.84 L 551.06 200.35 L 551.06 200.35 L 551.46 200.44 L 552.86 202.35 L 553.85 202.68 L 555.36 202.36 L 556.29 201.63 L 556.67 201.71 L 557.3 202.95 L 557.25 203.63 L 558.02 203.96 L 560.65 202.99 L 562.28 202.76 L 563.8 201.12 L 566.5 199.24 L 567.55 198.93 L 569.03 198.06 L 569.96 196.55 L 572.18 195.29 L 573.66 194.88 L 577.16 196.8 L 577.66 198.19 L 577.55 198.49 L 574.55 199.56 L 574.18 200.34 L 574.22 200.81 L 574.94 202.68 L 574.77 203.11 L 572.24 205.75 L 572.2 206.2 L 573.71 205.95 L 574.15 205.66 L 575.29 205.98 L 575.47 206.28 L 575.23 206.77 L 575.58 209.01 L 576.53 209.95 L 578.13 210.74 L 579.78 209.9 L 581.12 209.74 L 582.9 208.21 L 583.3 207.73 L 583.29 207.19 L 582.9 206.46 L 583.44 205.7 L 584.33 205.01 L 586.15 204.91 L 586.7 204.27 L 588.31 203.39 L 592.19 203.65 L 594.37 203.36 L 595.17 202.83 L 595.17 202.23 L 596.31 202.25 L 598.32 201.8 L 600.22 200.77 L 600.67 198.97 L 602.15 197.69 L 604.46 196.62 L 607.11 196.83 L 607.93 197.09 L 610.43 199.15 L 610.43 199.15 L 611.31 199.38 L 611.86 200.6 L 610.59 202.32 L 610.48 202.87 L 610.49 203.35 L 611.19 203.72 L 611.46 204.22 L 611.65 205.28 L 609.69 211.66 L 606.44 220.61 L 606.44 220.61 L 606.17 220.4 L 603.27 220.13 L 601.35 219.32 L 599.88 219.51 L 597.32 220.8 L 595.08 219.95 L 593.08 220.19 L 591.53 221.43 L 591.41 221.88 L 589.23 224.17 L 587.42 225.28 L 586.26 225.23 L 584.4 226.29 L 583.23 226.4 L 580.09 226.11 L 577.59 226.76 L 575.68 226.28 L 573.9 225.23 L 572 223.11 L 569.45 221.09 L 568.37 221.21 L 566.7 220.91 L 565.7 219.69 L 564.88 220.29 L 564.79 220.98 L 562.41 224.27 L 560.24 225.03 L 559.6 226.12 z"},{code:"PI",name:"Piauí",gTransform:"matrix(1 0 0 1 174.84 -130.97)",pathTransform:"translate(-480.85, -188.29)",d:"M 505.7 126.91 L 507.01 127.03 L 507.7 126.8 L 509.94 127.31 L 510.93 128.16 L 511.25 128.76 L 511.25 128.76 L 511.14 129.56 L 510.05 131.41 L 508.47 133.38 L 508.29 134.84 L 508.58 136.13 L 510.38 140.85 L 513.53 147.27 L 513.97 149 L 515.33 150.59 L 515.31 151.35 L 514.57 152.71 L 515.36 156.58 L 514.88 158.18 L 515.88 160.19 L 516.48 163.18 L 515.89 164.76 L 515.09 165.34 L 516.01 166.03 L 516.12 166.41 L 517.06 174.57 L 516.82 175.02 L 517.58 177.59 L 518.63 182.79 L 519.64 185.46 L 520.95 186.11 L 523.51 186.58 L 524.28 187.74 L 524.27 188.43 L 522.77 190.68 L 521.63 193.79 L 521.71 194.76 L 522.39 195.44 L 522.33 196.76 L 522.33 196.76 L 520.54 196.92 L 520.02 197.25 L 519.91 197.7 L 519.97 198.65 L 520.57 199.78 L 520.5 201.97 L 522.12 203.55 L 522.41 204.09 L 522.35 206.36 L 521.61 208.12 L 517.72 211.99 L 516.75 212.27 L 514.46 213.6 L 513.92 214.47 L 511.95 216.18 L 509.33 217.45 L 509.33 217.45 L 508.88 218.61 L 507.38 220.91 L 506.33 221.58 L 505.54 221.4 L 503.54 221.78 L 503.65 224.18 L 501.79 225.98 L 501.47 225.93 L 500.85 225.31 L 498.69 225.3 L 497.87 226.28 L 497.1 226.64 L 494.37 226.98 L 492.86 228.32 L 492.04 229.54 L 490.34 229.64 L 488.86 230.28 L 485.86 230.39 L 485.04 230.11 L 484.85 229.83 L 484.98 229.17 L 483.27 228.19 L 481.94 227.8 L 480.55 228.35 L 478.42 228.78 L 478.1 228.6 L 477.69 227.67 L 476.19 227.21 L 474.24 227.23 L 471 228.88 L 470.94 229.81 L 473.18 234.25 L 473.3 235.4 L 473.01 237.97 L 472.76 238.88 L 472.04 239.74 L 469.09 244.79 L 466.12 247.21 L 464.77 247.63 L 463.29 247.1 L 461.95 246.93 L 459.75 247.68 L 458.58 248.57 L 457.91 249.44 L 456.77 249.82 L 456.02 251.27 L 455.69 251.48 L 453.58 251.3 L 451.78 251.82 L 447.6 249.97 L 445.83 247.48 L 445.3 245.27 L 444.64 244.23 L 443.2 242.89 L 440.87 242.91 L 440.87 242.91 L 437.93 242.7 L 437.93 242.7 L 437.98 240.78 L 438.24 239.72 L 439.39 237.27 L 439.52 230.91 L 440.28 229.51 L 440.31 229 L 438.58 225.94 L 438.11 222.75 L 437.41 220.81 L 438.14 218.81 L 439.84 217.41 L 441.04 214.93 L 441.17 213.42 L 441.51 212.59 L 441.81 212.38 L 443.25 209.64 L 443.88 207.32 L 444.27 204.35 L 445.25 201.37 L 447.38 199.42 L 450.1 198.66 L 452.71 198.35 L 453.78 197.98 L 455.48 196.45 L 456.53 196.41 L 457.87 195.89 L 460.73 193.32 L 463.07 192.41 L 465.08 190.41 L 465.71 189.54 L 465.71 189.08 L 467.61 187.16 L 468.11 186.94 L 468.95 186.7 L 469.18 187 L 470.3 186.74 L 471.3 186.14 L 472.76 185.95 L 473.77 186.16 L 476.28 187.98 L 477.79 187.88 L 480.23 187.02 L 481.06 186.98 L 481.71 187.26 L 483.99 186.97 L 485.2 185.66 L 485.7 184.2 L 485.82 182.99 L 486.11 182.55 L 486.5 180.35 L 486.37 179.5 L 486.2 179 L 484.59 178.09 L 482.81 176.06 L 482.3 173.76 L 482.19 171.65 L 482.36 169.17 L 486.46 164.74 L 486.67 164.19 L 486.77 161.76 L 486.22 158.78 L 484.64 155.98 L 485.78 153.11 L 486.06 151.64 L 485.68 150.37 L 484.45 149.53 L 484.1 147.61 L 484.87 146.56 L 485.51 146.39 L 486.33 144.41 L 488.22 142.56 L 489.1 140.73 L 489.06 138.94 L 491.98 135.53 L 492.79 135.69 L 496.1 135.23 L 500.23 131.26 L 502.02 128.99 L 502.41 127.46 L 501.77 126.93 L 501.55 126.21 L 502.01 124.77 L 502.01 124.77 L 502.74 124.89 L 504.21 125.76 L 504.72 126.27 L 504.59 126.58 z"},{code:"PR",name:"Paraná",gTransform:"matrix(1 0 0 1 47.59 157)",pathTransform:"translate(-353.59, -476.27)",d:"M 396.75 499.4 L 391.51 499.37 L 391.18 499.81 L 389.44 500.05 L 388.68 499.98 L 388.57 499.59 L 387 500.16 L 385.65 501.59 L 382.3 503.72 L 380.86 503.56 L 379.63 502.94 L 376.5 500.34 L 375.47 499.95 L 374.71 499.94 L 371.87 500.67 L 369.54 500.84 L 368.73 500.81 L 367.31 500.05 L 366.2 500.19 L 364.67 500.84 L 364.08 502.31 L 363.35 503.18 L 361.48 504.16 L 357.91 503.75 L 355.91 504.9 L 355.19 505.67 L 354.5 507.26 L 355.35 510.25 L 354.48 511.11 L 353.56 511.13 L 352.81 511.51 L 352.64 512 L 351.31 510.11 L 347.06 510.24 L 343.3 509.81 L 341.72 508.63 L 341.56 508.22 L 340.53 507.59 L 336.27 507.23 L 330.98 505.55 L 328.64 506.12 L 325.95 506.09 L 323.93 504.68 L 323.61 504.17 L 322.55 503.93 L 322.02 503.92 L 321.31 504.29 L 317.68 504.27 L 317.68 504.27 L 317.46 503.06 L 314.93 498.88 L 314.95 496.29 L 313.96 493.41 L 310.54 491.04 L 309.45 492.17 L 307.33 492.06 L 306.23 492.49 L 305.16 493.39 L 303.7 492.31 L 302.88 492.37 L 302.6 490.17 L 303.26 488.6 L 304.33 487.33 L 305.55 485.15 L 305.61 484.81 L 305.12 484.06 L 305.14 482.82 L 306.04 479.18 L 307.3 476.16 L 307.05 473.86 L 308.33 471.48 L 308.12 470.46 L 307.28 469.58 L 306.97 467.98 L 307.63 466.92 L 308.42 466.38 L 308.42 466.38 L 310.8 464.82 L 311.16 464 L 312.73 456.08 L 313.06 455.73 L 314.17 455.41 L 315.83 454.4 L 316.5 453.72 L 317.95 450.16 L 317.93 449.01 L 318.86 446.68 L 319.97 445.86 L 325.38 443.59 L 325.38 443.59 L 328.64 441.3 L 332.47 441.95 L 336.48 441.84 L 339.75 442.13 L 340.96 441.51 L 341.31 440.91 L 342.04 440.54 L 343.21 440.83 L 344.69 441.61 L 347.21 442.07 L 349.85 443.16 L 351.16 443.29 L 352.23 442.75 L 354.81 442.74 L 355.59 443.74 L 357.34 444.58 L 360.85 445.38 L 361.48 445.89 L 362.19 447.21 L 363.92 447.28 L 364.34 446.94 L 365.99 447.09 L 366.65 447.63 L 371.96 447.76 L 374.93 446.91 L 376.06 448.46 L 379.65 451.29 L 380.54 453.05 L 380.55 455.79 L 380.16 456.37 L 380 457.18 L 380.38 459.02 L 381.68 460.53 L 381.6 462.29 L 381.24 462.85 L 382.73 465.85 L 383.94 467 L 384.61 467.28 L 385.11 467.96 L 385.06 468.85 L 385.98 470.82 L 386.58 471.11 L 386.83 471.55 L 386.58 472.6 L 385.31 474.73 L 385.63 476.77 L 386.23 477.15 L 387.24 477.36 L 389.62 477.24 L 393.04 476.71 L 393.54 477.1 L 395.12 476.91 L 396.71 477.04 L 398.32 478.3 L 398.18 478.71 L 397.29 479.36 L 396.6 482.66 L 396.95 483.44 L 398.02 483.97 L 398.67 483.12 L 399.77 480.36 L 400.53 480.19 L 402.67 480.77 L 402.27 482.72 L 403 486.02 L 404.42 486.6 L 404.58 487.92 L 404.58 487.92 L 403.23 488.94 L 402.62 490.42 L 402.07 490.3 L 402.34 488.36 L 403.78 487.41 L 402.37 487.69 L 401.48 488.18 L 400.61 488.16 L 400.27 487.77 L 399.7 487.6 L 399.16 487.97 L 398.88 488.9 L 399.4 489.7 L 398.67 490.66 L 398.37 490.76 L 395.89 490.23 L 395.1 489.69 L 394.65 489.81 L 394.47 490.71 L 394.81 491.08 L 396.42 491.64 L 397.82 491.39 L 399.95 491.99 L 400.22 492.47 L 399.25 493.15 L 397.71 495.93 L 396.47 496.7 L 394.05 497.27 L 393.85 497.72 L 396.8 497.52 L 396.95 498.71 z"},{code:"RJ",name:"Rio de Janeiro",gTransform:"matrix(1 0 0 1 179.27 113.69)",pathTransform:"translate(-485.28, -432.95)",d:"M 468.35 450.28 L 468.28000000000003 449.5 L 468.66 449.23 L 471.85 449.45000000000005 L 474.44 448.86000000000007 L 471.91 447.31000000000006 L 470.51000000000005 446.81000000000006 L 467.70000000000005 447.49000000000007 L 466.34000000000003 449.0900000000001 L 465.31000000000006 449.4100000000001 L 464.61000000000007 449.36000000000007 L 463.26000000000005 447.2100000000001 L 462.78000000000003 447.2100000000001 L 461.88000000000005 447.6300000000001 L 460.9200000000001 448.6900000000001 L 457.7700000000001 449.4900000000001 L 457.4300000000001 450.40000000000015 L 457.2400000000001 452.3000000000001 L 459.4300000000001 452.4300000000001 L 460.5000000000001 453.4400000000001 L 459.35000000000014 454.5200000000001 L 458.41000000000014 454.3500000000001 L 456.9900000000001 454.5200000000001 L 456.9900000000001 454.5200000000001 L 456.5100000000001 454.2600000000001 L 454.8800000000001 452.5300000000001 L 454.8300000000001 452.12000000000006 L 455.9200000000001 448.62000000000006 L 457.01000000000005 447.4700000000001 L 459.36000000000007 446.4600000000001 L 459.86000000000007 446.61000000000007 L 462.63000000000005 446.25000000000006 L 464.13000000000005 445.5400000000001 L 465.78000000000003 443.3900000000001 L 465.03000000000003 441.7500000000001 L 463.33000000000004 441.7400000000001 L 460.18000000000006 442.2700000000001 L 458.4100000000001 441.8800000000001 L 457.18000000000006 440.29000000000013 L 456.62000000000006 439.1200000000001 L 455.3500000000001 438.5800000000001 L 455.3500000000001 438.5800000000001 L 456.0300000000001 438.0900000000001 L 458.4500000000001 437.3500000000001 L 461.3600000000001 436.0100000000001 L 463.9400000000001 435.8400000000001 L 464.4400000000001 436.11000000000007 L 466.16000000000014 435.3400000000001 L 467.21000000000015 434.5700000000001 L 471.3000000000001 432.7800000000001 L 471.8200000000001 432.7100000000001 L 472.1800000000001 433.0200000000001 L 475.3800000000001 432.9500000000001 L 476.6300000000001 432.7800000000001 L 478.2600000000001 431.8400000000001 L 478.8300000000001 431.7800000000001 L 481.36000000000007 432.05000000000007 L 481.8500000000001 432.2200000000001 L 481.8300000000001 432.6900000000001 L 483.2100000000001 432.4900000000001 L 492.7200000000001 427.96000000000015 L 495.25000000000006 426.97000000000014 L 495.46000000000004 426.45000000000016 L 495.18000000000006 425.84000000000015 L 493.74000000000007 425.71000000000015 L 493.83000000000004 424.96000000000015 L 495.72 421.25000000000017 L 498.08000000000004 415.21000000000015 L 497.35 414.50000000000017 L 497.91 414.01000000000016 L 499.15000000000003 413.7400000000002 L 501.68 411.38000000000017 L 501.68 411.38000000000017 L 503.61 412.14000000000016 L 504.28000000000003 416.85000000000014 L 506.78000000000003 417.98000000000013 L 511.11 418.9900000000001 L 514.1 418.6200000000001 L 515.72 419.6800000000001 L 515.72 419.6800000000001 L 515.64 420.9500000000001 L 514.6999999999999 422.5600000000001 L 514.4799999999999 424.6900000000001 L 515.6199999999999 431.4700000000001 L 515.1199999999999 432.1500000000001 L 512.0399999999998 433.9000000000001 L 506.0699999999998 435.8400000000001 L 503.23999999999984 437.5600000000001 L 499.73999999999984 441.2500000000001 L 499.6299999999998 442.91000000000014 L 499.9399999999998 444.10000000000014 L 499.74999999999983 445.72000000000014 L 499.0199999999998 447.20000000000016 L 497.1999999999998 447.71000000000015 L 490.6499999999998 447.54000000000013 L 484.8599999999998 448.2400000000001 L 482.4699999999998 447.78000000000014 L 481.9799999999998 447.40000000000015 L 481.9199999999998 446.72000000000014 L 482.94999999999976 445.2400000000001 L 483.6199999999998 443.79000000000013 L 483.5299999999998 443.17000000000013 L 482.74999999999983 442.9900000000001 L 479.9599999999998 444.1400000000001 L 479.6999999999998 444.8300000000001 L 480.0099999999998 445.6200000000001 L 481.3899999999998 446.79000000000013 L 481.6399999999998 447.76000000000016 L 481.04999999999984 448.28000000000014 L 479.41999999999985 448.79000000000013 L 477.84999999999985 448.76000000000016 L 469.80999999999983 449.83000000000015 L 468.35 450.28 z M 463.24 452.27 L 462.57 451.29999999999995 L 464.68 449.74999999999994 L 466.54 450.68999999999994 L 466.97 451.38999999999993 L 464.51000000000005 451.88999999999993 L 464.1 451.5399999999999 L 463.63 451.5399999999999 L 463.24 452.27 z"},{code:"RN",name:"Rio Grande do Norte",gTransform:"matrix(1 0 0 1 274.86 -145.63)",pathTransform:"translate(-580.87, -173.63)",d:"M 609.29 182.91 L 608.36 183.15 L 604.86 182.94 L 603.82 183.34 L 601.36 182.24 L 599.19 181.94 L 593.36 182.33 L 592.83 181.98 L 589.41 181.58 L 588.79 181.09 L 588.89 180.09 L 588.47 179.7 L 587.09 179.75 L 585.27 181.1 L 584.96 182.58 L 585.68 183.36 L 586.21 184.89 L 585.2 184.57 L 584.72 185.16 L 584.88 186.58 L 585.35 187.52 L 584.8 188.73 L 584.3 189.47 L 581.95 190.4 L 581.12 189.66 L 581.64 188.12 L 580.75 186.95 L 578.8 186.65 L 577.03 186.73 L 573.88 187.99 L 573.59 187.76 L 573.28 186.38 L 572.96 186.15 L 569.43 185.63 L 569.51 183.91 L 569.72 183.6 L 570.57 183.35 L 570.98 182.97 L 571.36 181.23 L 571.8 180.27 L 574.79 177.06 L 574.78 175.87 L 574.25 175.43 L 573.61 175.35 L 570.35 176.39 L 568.92 176.51 L 565.74 177.72 L 565.33 178.67 L 565.23 179.71 L 564.41 180.42 L 561.18 182.08 L 560.02 183.21 L 557.14 182.6 L 556.24 182.18 L 554.31 180.54 L 553.74 181 L 553.74 181 L 553.08 181.38 L 552.44 181.21 L 552.78 179.24 L 554.19 176.99 L 555.03 176.11 L 555.54 176.04 L 556.32 176.55 L 557.35 176.29 L 557.92 175.19 L 559.38 173.68 L 560.78 171.24 L 560.63 170.5 L 561.28 168.83 L 562.15 168.26 L 562.99 167.14 L 566.29 160.45 L 568.9 158.44 L 573.79 156.85 L 573.79 156.85 L 574.26 157.61 L 575.12 158.36 L 578.25 158.35 L 579.47 158.76 L 581.16 160.51 L 582.48 161.01 L 585.81 160.69 L 588.69 161.21 L 591.23 160.97 L 593.56 160.24 L 598.06 161.16 L 599.33 161.2 L 601.28 162.06 L 602.3 162.88 L 602.94 163.82 L 605.25 168.56 L 605.75 170.35 L 605.71 171.1 L 607.19 176.48 L 607.4 178.16 L 608.12 178.7 L 609.08 181.39 z"},{code:"RO",name:"Rondônia",gTransform:"matrix(1 0 0 1 -139.57 -68.08)",pathTransform:"translate(-166.43, -251.18)",d:"M 187.32 290.95 L 186.03 289.5 L 185.59 287.62 L 184.03 287.1 L 183.17 287.42 L 181.36 287.5 L 177.29 285.69 L 177.28 285.29 L 176.62 284.68 L 175.35 285.27 L 173.37 283.59 L 171.85 282.62 L 170.99 281.16 L 170.71 279.77 L 169.67 279.38 L 167.9 280.5 L 166.68 280.47 L 165.27 279.67 L 164.4 278.34 L 161.27 276.76 L 159.31 276.59 L 158.17 277.13 L 157.27 277.98 L 155.84 277.81 L 155.53 277.51 L 153.39 277 L 150.33 276.72 L 149.57 276.29 L 148.39 275.1 L 148.09 273.13 L 146.51 272.64 L 144.62 271.67 L 143.8 269.95 L 143.51 269.75 L 140.79 269.47 L 140.41 269.12 L 139.57 265.41 L 138.69 264.52 L 138.21 265.68 L 137.55 265.36 L 137.28 264.72 L 137.9 263.19 L 137.06 261.67 L 135.7 261.28 L 134.44 257.81 L 134.27 256.15 L 135.82 253.24 L 135.61 251.58 L 134.45 249.61 L 133.7 247.45 L 133.64 245.16 L 134.26 244.66 L 134.64 243.29 L 135.68 242.24 L 136.04 240.77 L 135.8 239.28 L 135.38 238.39 L 135.29 236.86 L 135.83 235.21 L 134.66 233.03 L 133.64 232.65 L 132.55 233.63 L 132.49 234.14 L 131.65 235.1 L 131.08 235.1 L 128.9 234.08 L 123.72 234.16 L 118.11 235.94 L 116.42 235.93 L 114.94 236.41 L 114.94 236.41 L 111.97 235.15 L 111.97 235.15 L 115.23 232.59 L 117.15 232.01 L 118.7 230.2 L 118.85 229.64 L 118.69 228.35 L 122.65 228.61 L 125.52 228.28 L 126.24 228.65 L 128.55 230.98 L 128.92 230.96 L 130.14 230.17 L 130.27 229.45 L 130.68 228.92 L 131.76 228.42 L 132.53 228.55 L 133.9 228.16 L 135.2 226.95 L 137.04 225.93 L 137.42 226.02 L 138.06 228.28 L 138.74 228.81 L 139.42 228.73 L 141.96 225.57 L 141.7 223.82 L 142.23 222.98 L 143.98 221.72 L 144.44 221.74 L 145.28 222.29 L 147.07 222.39 L 148.27 221.32 L 150.4 220.94 L 154.27 221.4 L 154.03 219.94 L 154.14 218.13 L 156.2 216.92 L 157.01 215.77 L 157.37 214.75 L 157.2 214.3 L 156.3 213.6 L 156.35 212.93 L 157.54 211.34 L 160.02 210.81 L 160.28 210.59 L 160.19 209.42 L 161.91 208.92 L 163.29 206.36 L 174.08 206.3 L 176.23 207.43 L 176.68 207.92 L 177.48 209.83 L 178.81 211.1 L 181.35 212.08 L 182.6 215.35 L 183.06 215.56 L 184.04 215.43 L 184.66 215.63 L 185.34 218.51 L 188.58 219.99 L 189.26 219.8 L 189.8 218.06 L 191.72 216.98 L 193.11 217.26 L 193.47 217.64 L 193.43 218.34 L 193.43 218.34 L 194.83 219.31 L 195.43 220.55 L 194.67 221.97 L 193.38 226.96 L 193.44 227.31 L 194.22 227.78 L 194.48 228.39 L 194.63 229.78 L 195.46 232.05 L 194.52 233.72 L 194.9 235.65 L 193.9 239.17 L 193.87 239.97 L 194.14 241.73 L 195.64 244.48 L 194.74 253.48 L 211.9 253.53 L 211.66 254.09 L 212.88 255.2 L 216.38 255.11 L 217.49 255.22 L 218.56 255.65 L 219.97 259.24 L 219.8 259.99 L 218.4 261.74 L 217.04 262.82 L 216.9 264.14 L 217.33 267.39 L 217.91 267.9 L 218.81 267.87 L 220.34 271.21 L 220.3 273.26 L 220.88 274.75 L 220.81 276.46 L 220.25 278.7 L 218.59 280.71 L 218.07 282.96 L 217.49 283.8 L 217.06 284.21 L 215.42 284.74 L 214.49 285.82 L 213.06 289.6 L 212.54 292.05 L 208.43 294.62 L 206.96 296.05 L 206.96 296.05 L 206.22 296.01 L 203.63 294.46 L 202.36 293.03 L 195.28 293.99 L 193.96 293.56 L 193.71 293.26 L 190.33 293.92 L 189.85 293.76 L 189.33 292.41 z"},{code:"RR",name:"Roraima",gTransform:"matrix(1 0 0 1 -116.08 -267.27)",pathTransform:"translate(-189.92, -51.99)",d:"M 234.61 61.4 L 236.21 78.37 L 236.21 78.37 L 217.72 78.3 L 217.75 78.98 L 215.42 82.24 L 213.76 85.27 L 213.69 86.4 L 212.54 89.04 L 212.43 89.7 L 212.66 90.43 L 213.8 91.84 L 213.78 92.37 L 213.36 92.76 L 211.33 93.31 L 209.92 94.72 L 208.67 95.18 L 206.85 94.95 L 205.93 92.44 L 204.06 90.4 L 201.23 89.47 L 199.63 89.53 L 199.08 90.42 L 196.99 91.13 L 195.71 91.82 L 194.69 93.08 L 193.87 96.05 L 194.24 97.85 L 193.99 99.58 L 193.24 101.87 L 193.68 103.98 L 191.32 102.94 L 189.98 103.36 L 189.45 103.29 L 188.41 101.25 L 186.93 99.6 L 184.97 98.29 L 184.45 98.25 L 179.44 93.83 L 179.58 92.69 L 181.42 93.02 L 182.56 91.7 L 182.62 91.12 L 181.49 86.79 L 180.91 85.89 L 179.69 85.05 L 178.81 82.88 L 178.52 77.9 L 179.09 76.94 L 179.86 73.9 L 179.2 72.32 L 178.84 70.73 L 180.46 69.27 L 180.41 68.82 L 179.54 67.7 L 179.35 65.44 L 177.69 60.68 L 174.96 56.94 L 175.67 55.44 L 176.58 52.12 L 176.09 51.46 L 174.14 50.51 L 172.78 50.4 L 171.9 50.61 L 170.93 50.24 L 169.72 49.07 L 169.66 48.11 L 169.03 48 L 167.9 48.42 L 167.29 48.41 L 166.54 48.07 L 165.82 47.29 L 165.82 47.29 L 166.12 46.83 L 166.35 44.55 L 166.05 44.33 L 162.68 44.1 L 158.93 44.24 L 155.62 43.54 L 155.42 42.94 L 156.22 41.18 L 156.34 39.7 L 155.61 37.93 L 153.67 34.39 L 152.94 32.33 L 152.47 28.61 L 153.26 27.13 L 153.18 26.17 L 151.34 24.17 L 149.18 23.11 L 146.37 20.33 L 145.31 18.52 L 145.02 17.56 L 143.88 16.91 L 143.63 16.52 L 143.66 15.68 L 143.95 15.35 L 144.85 15.42 L 145.97 16.08 L 146.91 17.81 L 147.52 17.9 L 150.91 17.4 L 152.26 17.5 L 154.17 18.09 L 154.78 19.29 L 155.33 21.22 L 155.87 21.57 L 156.83 21.49 L 157.57 20.84 L 158.52 20.44 L 161.7 20.6 L 162.17 20.65 L 163.48 21.86 L 164.08 22.01 L 164.6 21.87 L 165.21 20.31 L 166.52 20.45 L 167.97 21.38 L 171.9 25.95 L 172.95 26.52 L 173.66 26.63 L 175.17 25.95 L 175.91 24.82 L 176.01 23.98 L 175.18 21.22 L 175.54 19.48 L 176 19.2 L 177.93 19.15 L 178.94 18.05 L 180.49 16.96 L 181.24 17.01 L 185.14 18.35 L 185.73 18.18 L 186.53 17.46 L 187.56 17.16 L 188.69 17.51 L 189.72 17.3 L 191.06 16.02 L 192.06 15.77 L 193.21 16 L 194.32 15.93 L 195 15.08 L 195.05 13.73 L 198.08 11.92 L 200.41 12.11 L 203.17 11.72 L 204.06 10.59 L 204.15 9.88 L 204.74 8.76 L 205.49 8.63 L 207.34 7.73 L 208.44 6.69 L 209.55 4.98 L 208.35 1.42 L 207.18 1.06 L 207.82 0.88 L 209.25 0.95 L 210.05 1.27 L 213.62 1.17 L 214.68 0.22 L 215.42 0 L 216.79 0.42 L 217.32 1.73 L 218.36 2.53 L 218.84 3.9 L 218.17 8.8 L 217.45 10.18 L 216.2 10.88 L 216.26 11.71 L 217.87 12.12 L 219.49 11.9 L 221.84 12.71 L 223.66 13.81 L 222.78 15.24 L 222.77 16.39 L 225.11 19.81 L 225.31 21.36 L 223.8 24.28 L 221.92 25.69 L 221.2 27.19 L 221.47 27.58 L 221.53 29.75 L 220.06 32.16 L 219.16 34.93 L 218.85 37.5 L 218.76 40.17 L 219.74 42.04 L 220.25 43.8 L 220.24 45.2 L 221.81 46.23 L 222.71 46.43 L 222.84 47.11 L 222.38 52.26 L 222.5 53 L 224.31 53.29 L 223.65 54.46 L 224.11 54.96 L 226.26 55.7 L 227.72 57.62 L 230.38 60.36 z"},{code:"RS",name:"Rio Grande do Sul",gTransform:"matrix(1 0 0 1 11.62 259.25)",pathTransform:"translate(-317.63, -578.5)",d:"M 321.99 638.52 L 321.63 638.53 L 319.69 637.42 L 319.49 636.96 L 320.01 632.69 L 319.55 628.44 L 319.7 627.37 L 320.33 626.13 L 323.17 623.75 L 324 622.19 L 326.3 619.63 L 324.84 617.98 L 323.77 617.36 L 321.52 616.76 L 319.2 614.51 L 317.99 612.89 L 317.89 611.3 L 317.46 610.12 L 316.23 608.09 L 314.17 605.85 L 313.5 605.26 L 311.11 604.05 L 309.66 604.26 L 307.76 602.75 L 306.24 601.12 L 304.99 600.34 L 304.85 598.64 L 302.95 596.48 L 299.63 596.02 L 298.71 595.55 L 296.98 593.89 L 295.22 594.02 L 293.05 592.64 L 291.14 588.93 L 290.03 587.44 L 287.5 585.32 L 286.8 585.4 L 286.13 587.19 L 283.54 589.43 L 280.87 589.55 L 280.97 586.69 L 281.37 585.41 L 280.98 584.41 L 277.33 580.12 L 274.96 578.35 L 272.78 576.29 L 271.03 574.18 L 268.34 571.97 L 266.44 571.83 L 264.29 572.04 L 263.15 573.4 L 263.09 574.36 L 262.06 575.33 L 260.95 575.35 L 260.37 574.87 L 257.21 575.01 L 256.56 574.53 L 256.4 573.62 L 255.91 573.4 L 256.76 573.18 L 257.8 572.46 L 260.32 569.69 L 260.43 567.85 L 261.03 566.6 L 261.85 566.15 L 263.14 566.08 L 263.78 565.82 L 264.7 564.82 L 270.15 558.34 L 270.78 556.92 L 270.95 555.81 L 271.77 554.74 L 272.97 553.89 L 274.34 553.48 L 276.3 549.26 L 276.4 548.65 L 276.71 548.28 L 278.35 547.42 L 279.98 545.62 L 280.83 544.47 L 281.34 543.18 L 282.68 541.08 L 283.61 540.79 L 285.18 540.97 L 285.73 541.76 L 286.2 540.48 L 285.99 539.9 L 284.64 539.08 L 284.59 538.72 L 284.94 538.39 L 286.02 538.01 L 286.84 537.05 L 289.63 536.1 L 290.68 535.03 L 290.78 534.11 L 291.6 533.2 L 293.81 532.05 L 296.28 531.65 L 298.05 529.84 L 298.2 528.78 L 299.52 526.42 L 299.85 526.38 L 299.9 526.74 L 300.19 526.94 L 301.52 526.77 L 303.96 525.64 L 306.64 525.05 L 307.85 524.48 L 309.95 522.13 L 310.45 522.14 L 311.12 521.75 L 312.13 520.4 L 314.44 519.67 L 314.74 520.05 L 314.74 520.05 L 318.26 520.44 L 321.52 519.29 L 322.08 518.48 L 323.43 519.06 L 323.28 519.98 L 326.36 519.95 L 327.99 520.94 L 330.55 520.57 L 332.47 521.72 L 335.05 521.31 L 336.59 521.49 L 339.39 521.33 L 341.65 522.25 L 344.13 523.65 L 345.13 526.09 L 346.72 526.28 L 346.81 525.8 L 348.62 525.45 L 354.18 528.99 L 355.55 530.54 L 356.26 530.51 L 357.82 531.49 L 360.85 534.98 L 362.49 537.19 L 362.97 538.67 L 365.14 541.33 L 366.31 541.88 L 373 542.94 L 375.11 542.54 L 378.46 542.88 L 379.34 545.22 L 377.26 546.8 L 375.99 547.21 L 375.26 549.07 L 375.48 551.26 L 375.1 552.82 L 374.58 554.12 L 373.4 554.32 L 372.11 556.01 L 372.08 557.42 L 373.88 558.59 L 374.15 558.39 L 373.87 557.42 L 373.88 556.46 L 375.37 555.64 L 376.95 556.28 L 377.68 557.19 L 378.85 558.04 L 379.3 558.01 L 379.3 558.01 L 377.9 559.74 L 374 566.78 L 369.79 578.38 L 363.49 588.86 L 358.05 595.52 L 351.54 601.48 L 345.45 605.16 L 342.35 609.47 L 342.17 609.04 L 342.82 607.46 L 343.16 605.28 L 341.98 603.57 L 342.08 603.15 L 343.01 602.98 L 344.02 603.38 L 344.58 603.96 L 345.6 604 L 348.18 602.59 L 349 601.91 L 351.85 598.2 L 352.6 597.51 L 353.05 597.7 L 354.07 597.51 L 355.12 596.67 L 356.05 595.4 L 356.42 593.92 L 356.6 592.99 L 356.37 590.89 L 356.57 589.52 L 358.14 589.45 L 358.88 589.75 L 359.15 590.58 L 359.5 590.32 L 359.21 588.92 L 359.72 586.85 L 360.2 586.28 L 362.94 584.69 L 363.67 583.61 L 364.14 580.86 L 363.93 578.58 L 364.49 577.9 L 364.99 578.7 L 365.36 578.73 L 365.79 578.31 L 366.26 575.23 L 366.16 574.79 L 365.21 573.57 L 364.54 573.54 L 364.28 574.23 L 364.45 574.62 L 364.31 575.19 L 363.96 575.39 L 362.45 575.37 L 360.44 575.77 L 360.1 577.38 L 359.57 577.43 L 358.76 576.99 L 358.86 575.28 L 358.04 574.39 L 357 574.72 L 356.4 574.24 L 355.67 572.98 L 355.27 571.53 L 355.39 570.96 L 354.75 570.27 L 354.14 572.98 L 354.58 575.23 L 355.83 577.34 L 355.26 578.15 L 354.52 580.69 L 354.9 583.72 L 354.72 584.49 L 354.24 584.12 L 354.5 583.88 L 354.47 583.17 L 354 581.89 L 353.55 581.5 L 353.02 582.16 L 352.99 583.53 L 351.58 586.8 L 351.53 588.69 L 351.75 589.21 L 351.03 589.91 L 349.42 590.55 L 348.81 592.13 L 344.72 593.7 L 344 594.23 L 343.47 595.82 L 343.37 598.09 L 342.4 600.36 L 340.04 601.66 L 339.93 603.42 L 340.41 604.25 L 340.66 605.27 L 339.71 605.83 L 339.46 607.34 L 339.89 607.94 L 340.57 607.8 L 341.87 608.43 L 342.02 609.34 L 339.89 610.99 L 337.57 615.51 L 335.64 622.39 L 333.63 626.88 L 331.95 629.4 L 324.16 636.93 z"},{code:"SC",name:"Santa Catarina",gTransform:"matrix(1 0 0 1 51.41 209.71)",pathTransform:"translate(-357.4, -528.97)",d:"M 379.3 558.01 L 378.85 558.04 L 377.68 557.1899999999999 L 376.95 556.27 L 375.36 555.64 L 373.88 556.46 L 373.87 557.4200000000001 L 374.15 558.3900000000001 L 373.88 558.5900000000001 L 372.08 557.4200000000002 L 372.12 556.0100000000002 L 373.4 554.3200000000002 L 374.58 554.1200000000001 L 375.10999999999996 552.8100000000002 L 375.47999999999996 551.2600000000002 L 375.25999999999993 549.0700000000002 L 375.98999999999995 547.2100000000002 L 377.25999999999993 546.7900000000002 L 379.3399999999999 545.2100000000002 L 378.4599999999999 542.8700000000001 L 375.1099999999999 542.5300000000001 L 372.9999999999999 542.9300000000001 L 366.3099999999999 541.8700000000001 L 365.14999999999986 541.3300000000002 L 362.97999999999985 538.6700000000002 L 362.48999999999984 537.1900000000002 L 360.85999999999984 534.9800000000001 L 357.82999999999987 531.4900000000001 L 356.2599999999999 530.5000000000001 L 355.5499999999999 530.5300000000001 L 354.1799999999999 528.9800000000001 L 348.6199999999999 525.4400000000002 L 346.8099999999999 525.7800000000002 L 346.7199999999999 526.2600000000002 L 345.1199999999999 526.0700000000002 L 344.1199999999999 523.6300000000001 L 341.64999999999986 522.2400000000001 L 339.3799999999999 521.3100000000002 L 336.58999999999986 521.4700000000001 L 335.04999999999984 521.2900000000002 L 332.45999999999987 521.7000000000002 L 330.54999999999984 520.5500000000002 L 327.97999999999985 520.9100000000002 L 326.34999999999985 519.9300000000002 L 323.26999999999987 519.9600000000002 L 323.41999999999985 519.0300000000002 L 322.0699999999998 518.4500000000002 L 321.5099999999998 519.2600000000001 L 318.24999999999983 520.4200000000001 L 314.72999999999985 520.0300000000001 L 314.72999999999985 520.0300000000001 L 316.17999999999984 517.1000000000001 L 316.90999999999985 515.0100000000001 L 316.32999999999987 511.7600000000001 L 316.7399999999999 508.5500000000001 L 316.6999999999999 506.0000000000001 L 317.65999999999985 504.2500000000001 L 317.65999999999985 504.2500000000001 L 321.28999999999985 504.2700000000001 L 321.99999999999983 503.8900000000001 L 322.5299999999998 503.9000000000001 L 323.5899999999998 504.1400000000001 L 323.8999999999998 504.6500000000001 L 325.9299999999998 506.0600000000001 L 328.6099999999998 506.0900000000001 L 330.94999999999976 505.5100000000001 L 336.2399999999998 507.1900000000001 L 340.4999999999998 507.5500000000001 L 341.51999999999975 508.1800000000001 L 341.68999999999977 508.59000000000015 L 343.25999999999976 509.77000000000015 L 347.02999999999975 510.19000000000017 L 351.27999999999975 510.0600000000002 L 352.60999999999973 511.96000000000015 L 352.78999999999974 511.46000000000015 L 353.52999999999975 511.08000000000015 L 354.44999999999976 511.0600000000002 L 355.31999999999977 510.20000000000016 L 354.46999999999974 507.21000000000015 L 355.15999999999974 505.63000000000017 L 355.87999999999977 504.8500000000002 L 357.87999999999977 503.7100000000002 L 361.44999999999976 504.1100000000002 L 363.31999999999977 503.14000000000016 L 364.0499999999998 502.27000000000015 L 364.63999999999976 500.79000000000013 L 366.16999999999973 500.14000000000016 L 367.27999999999975 500.00000000000017 L 368.69999999999976 500.76000000000016 L 369.50999999999976 500.79000000000013 L 371.83999999999975 500.6200000000001 L 374.6799999999997 499.8900000000001 L 375.4299999999997 499.9000000000001 L 376.46999999999974 500.30000000000007 L 379.58999999999975 502.9000000000001 L 380.81999999999977 503.5200000000001 L 382.25999999999976 503.6800000000001 L 385.6099999999998 501.5500000000001 L 386.9599999999998 500.1200000000001 L 388.5199999999998 499.5500000000001 L 388.6399999999998 499.9400000000001 L 389.3999999999998 500.0100000000001 L 391.1399999999998 499.7800000000001 L 391.4699999999998 499.3400000000001 L 396.7099999999998 499.37000000000006 L 396.7099999999998 499.37000000000006 L 396.3199999999998 500.69000000000005 L 396.8299999999998 502.34000000000003 L 396.7599999999998 502.73 L 395.2599999999998 503.87 L 394.2799999999998 503.39 L 393.4599999999998 500.86 L 393.4399999999998 501.98 L 394.0299999999998 504.70000000000005 L 395.7399999999998 506.36000000000007 L 396.2999999999998 507.31000000000006 L 395.2899999999998 509.6000000000001 L 395.12999999999977 511.9200000000001 L 395.2299999999998 512.35 L 395.9899999999998 513.08 L 396.2499999999998 518.94 L 396.5599999999998 519.49 L 396.9899999999998 519.69 L 397.75999999999976 519.1800000000001 L 398.1099999999998 519.9000000000001 L 398.2099999999998 520.7700000000001 L 397.7399999999998 520.83 L 397.3099999999998 520.5500000000001 L 396.1199999999998 521.1800000000001 L 395.7799999999998 525.0200000000001 L 396.3499999999998 527.6100000000001 L 395.7799999999998 528.3600000000001 L 396.0899999999998 530.2900000000001 L 396.99999999999983 532.1700000000001 L 396.1399999999998 534.5100000000001 L 395.61999999999983 538.5200000000001 L 393.90999999999985 543.2 L 393.5699999999999 543.1 L 393.20999999999987 542.34 L 393.41999999999985 541.37 L 392.49999999999983 540.19 L 392.23999999999984 540.5200000000001 L 392.41999999999985 542.95 L 393.57999999999987 543.7800000000001 L 392.65999999999985 545.44 L 391.01999999999987 546.09 L 386.8899999999999 549.13 L 384.08999999999986 551.6899999999999 L 380.33999999999986 556.13 L 379.3 558.01 z M 397.18 531.46 L 397.03000000000003 530.99 L 397.28000000000003 529.24 L 398.04 526.84 L 397.64000000000004 525.6600000000001 L 397.80000000000007 524.6400000000001 L 399.20000000000005 523.8800000000001 L 399.4200000000001 523.94 L 400.0800000000001 524.8800000000001 L 399.5400000000001 527.44 L 398.7200000000001 528.3000000000001 L 398.1300000000001 529.5200000000001 L 398.3300000000001 530.69 L 397.18 531.46 z M 396.73 507.09 L 394.86 505.07 L 397.41 502.63 L 397.66 502.67 L 398.31 503.72 L 397.45 505.04 L 396.73 507.09 z"},{code:"SE",name:"Sergipe",gTransform:"matrix(1 0 0 1 266.49 -72.82)",pathTransform:"translate(-572.49, -246.44)",d:"M 569.94 261.69 L 567.04 262.58 L 565.49 261.94 L 564.95 261.6 L 564.47 260.88 L 562.55 259.96 L 561.95 259.44 L 561.83 259.03 L 562.17 258.64 L 562.3 257.22 L 562.15 256.83 L 560.72 255.32 L 560.2 253.83 L 559.11 253.16 L 558.15 251.56 L 558.13 250.79 L 558.72 249.21 L 559.04 248.91 L 560.74 248.92 L 561.87 249.67 L 564.42 248.68 L 565.11 248.13 L 565.41 247.55 L 564.65 244.8 L 564.73 243.92 L 565.39 242.3 L 565.47 239.19 L 564.72 238.04 L 562.73 236.09 L 561.46 233.59 L 561.24 231.45 L 561.91 230.3 L 561.91 230.3 L 568.37 233.28 L 572.05 234.23 L 577.47 237.3 L 578.77 239.75 L 580.53 241.2 L 582.19 241.99 L 582.65 242.02 L 586.24 244.25 L 586.84 245.56 L 586.84 245.56 L 584.46 246.32 L 579.89 249.26 L 578.92 250.15 L 577.37 252.36 L 577.05 252.34 L 577.16 251.24 L 576.11 249.42 L 575.12 249.58 L 575.46 250.74 L 576.7 250.74 L 576.93 250.98 L 576.41 252.95 L 575.14 255.04 L 574.61 254.69 L 574.24 254.02 L 573.25 253.86 L 573.45 254.54 L 574.58 255.16 L 574.32 256.93 L 573.46 258.08 L 572.53 260.11 L 571.75 260.26 L 571.45 259.8 L 571.93 258.4 L 572.34 258.27 L 572.65 257.84 L 573.02 256.8 L 572.21 256.43 L 572.31 257.11 L 571.86 258.24 L 571.38 258.74 L 571.12 259.83 L 571.4 260.55 L 571.14 261.07 z"},{code:"SP",name:"São Paulo",gTransform:"matrix(1 0 0 1 89.6 122.15)",pathTransform:"translate(-395.6, -441.42)",d:"M 404.58 487.92 L 404.41999999999996 486.59000000000003 L 402.99999999999994 486.02000000000004 L 402.2699999999999 482.72 L 402.6699999999999 480.77000000000004 L 400.5299999999999 480.19000000000005 L 399.7699999999999 480.36000000000007 L 398.6699999999999 483.13000000000005 L 398.0099999999999 483.9800000000001 L 396.9499999999999 483.4500000000001 L 396.59999999999985 482.67000000000013 L 397.28999999999985 479.3700000000001 L 398.17999999999984 478.7100000000001 L 398.3199999999998 478.3100000000001 L 396.7099999999998 477.04000000000013 L 395.11999999999983 476.91000000000014 L 393.53999999999985 477.10000000000014 L 393.03999999999985 476.72000000000014 L 389.6299999999998 477.2500000000001 L 387.24999999999983 477.3700000000001 L 386.23999999999984 477.16000000000014 L 385.6399999999998 476.77000000000015 L 385.30999999999983 474.73000000000013 L 386.5899999999998 472.6100000000001 L 386.8399999999998 471.5600000000001 L 386.5899999999998 471.1200000000001 L 385.9899999999998 470.8200000000001 L 385.06999999999977 468.8500000000001 L 385.12999999999977 467.9600000000001 L 384.62999999999977 467.2800000000001 L 383.95999999999975 466.99000000000007 L 382.7499999999998 465.8500000000001 L 381.25999999999976 462.8400000000001 L 381.6199999999998 462.2900000000001 L 381.69999999999976 460.5300000000001 L 380.39999999999975 459.0100000000001 L 380.01999999999975 457.17000000000013 L 380.18999999999977 456.3600000000001 L 380.57999999999976 455.78000000000014 L 380.5599999999998 453.04000000000013 L 379.6699999999998 451.28000000000014 L 376.0799999999998 448.45000000000016 L 374.9499999999998 446.90000000000015 L 371.9799999999998 447.76000000000016 L 366.6699999999998 447.63000000000017 L 366.00999999999976 447.09000000000015 L 364.3599999999998 446.95000000000016 L 363.93999999999977 447.29000000000013 L 362.21999999999974 447.22000000000014 L 361.4999999999997 445.90000000000015 L 360.8699999999997 445.39000000000016 L 357.35999999999973 444.59000000000015 L 355.60999999999973 443.75000000000017 L 354.82999999999976 442.75000000000017 L 352.2499999999998 442.76000000000016 L 351.1799999999998 443.3000000000002 L 349.8599999999998 443.1700000000002 L 347.2199999999998 442.0800000000002 L 344.6899999999998 441.62000000000023 L 343.2099999999998 440.8300000000002 L 342.0399999999998 440.5400000000002 L 341.3099999999998 440.9100000000002 L 340.9699999999998 441.5100000000002 L 339.7599999999998 442.1300000000002 L 336.47999999999985 441.8400000000002 L 332.46999999999986 441.9500000000002 L 328.6399999999999 441.30000000000024 L 325.3899999999999 443.59000000000026 L 325.3899999999999 443.59000000000026 L 326.22999999999985 442.5100000000003 L 326.95999999999987 440.97000000000025 L 328.21999999999986 439.83000000000027 L 335.77999999999986 435.29000000000025 L 337.72999999999985 433.42000000000024 L 338.98999999999984 430.99000000000024 L 340.71999999999986 429.30000000000024 L 341.11999999999983 428.09000000000026 L 342.55999999999983 427.0600000000003 L 342.8399999999998 425.84000000000026 L 342.4899999999998 425.0000000000003 L 344.4899999999998 422.7400000000003 L 345.69999999999976 420.4000000000003 L 345.76999999999975 419.4600000000003 L 345.45999999999975 417.5300000000003 L 345.68999999999977 417.1400000000003 L 346.64999999999975 416.62000000000035 L 349.2499999999998 412.98000000000036 L 349.4099999999998 410.05000000000035 L 350.0299999999998 408.37000000000035 L 351.0399999999998 408.07000000000033 L 351.7699999999998 407.43000000000035 L 353.7599999999998 404.75000000000034 L 354.97999999999985 403.73000000000036 L 355.4499999999999 403.50000000000034 L 356.7599999999999 403.4600000000003 L 358.2599999999999 402.68000000000035 L 358.53999999999985 402.28000000000037 L 358.9399999999998 399.8200000000004 L 358.9399999999998 399.8200000000004 L 360.15999999999985 398.6900000000004 L 362.30999999999983 397.5800000000004 L 364.22999999999985 397.2100000000004 L 365.65999999999985 395.5200000000004 L 367.15999999999985 394.91000000000037 L 367.90999999999985 395.05000000000035 L 369.6399999999999 396.60000000000036 L 372.1899999999999 396.68000000000035 L 376.4799999999999 397.6400000000003 L 378.1499999999999 397.2800000000003 L 379.7699999999999 397.50000000000034 L 381.7699999999999 396.91000000000037 L 383.94999999999993 398.3300000000004 L 385.61999999999995 399.1200000000004 L 385.48999999999995 400.0400000000004 L 385.81999999999994 401.46000000000043 L 387.0299999999999 403.5500000000004 L 387.6599999999999 403.5800000000004 L 388.19999999999993 403.2600000000004 L 388.86999999999995 402.3200000000004 L 389.28 401.1900000000004 L 389.53999999999996 401.0000000000004 L 390.09 401.0500000000004 L 390.45 401.4400000000004 L 390.7 402.4000000000004 L 390.71 405.18000000000035 L 391.90999999999997 405.7100000000003 L 392.32 405.26000000000033 L 392.05 402.7200000000003 L 392.54 401.5300000000003 L 392.99 401.0500000000003 L 401.17 400.3800000000003 L 402.18 399.1300000000003 L 403.68 400.59000000000026 L 404.8 401.02000000000027 L 407.58 400.33000000000027 L 408.02 399.34000000000026 L 407.82 398.8800000000003 L 408.13 398.27000000000027 L 410.51 398.16000000000025 L 412.17 398.9400000000002 L 413.02000000000004 398.30000000000024 L 414.33000000000004 398.0100000000002 L 417.59000000000003 401.36000000000024 L 417.79 402.40000000000026 L 417.22 403.41000000000025 L 416.93 405.78000000000026 L 417.51 406.39000000000027 L 419.4 407.60000000000025 L 419.79999999999995 409.15000000000026 L 419.73999999999995 409.71000000000026 L 418.21999999999997 411.74000000000024 L 418.03999999999996 413.68000000000023 L 418.83 414.42000000000024 L 419.14 415.03000000000026 L 419.51 417.24000000000024 L 420.81 419.04000000000025 L 421.64 421.03000000000026 L 421.61 421.8800000000003 L 423.22 421.83000000000027 L 424 421.52000000000027 L 424.28 421.16000000000025 L 425.28 421.11000000000024 L 428.97999999999996 422.43000000000023 L 429.21 422.80000000000024 L 429.15999999999997 424.0700000000002 L 428.46 426.2500000000002 L 426.59999999999997 428.97000000000025 L 426.85999999999996 431.91000000000025 L 426.66999999999996 435.36000000000024 L 426.14 436.92000000000024 L 426.86 438.52000000000027 L 428.64 439.7600000000003 L 430.45 440.59000000000026 L 430.96 442.3100000000003 L 429.75 443.0100000000003 L 431.77 446.3200000000003 L 432.9 446.5700000000003 L 434.90999999999997 446.33000000000027 L 435.09 446.86000000000024 L 438.71 445.86000000000024 L 439.27 446.28000000000026 L 440.58 445.96000000000026 L 441.33 444.98000000000025 L 441.38 444.14000000000027 L 441.14 443.90000000000026 L 441.31 441.60000000000025 L 442.5 441.27000000000027 L 442.59 441.6200000000003 L 442.23999999999995 442.1100000000003 L 442.24999999999994 442.5900000000003 L 444.5899999999999 442.6700000000003 L 446.9799999999999 442.4200000000003 L 448.7699999999999 441.7500000000003 L 449.99999999999994 440.5100000000003 L 451.92999999999995 439.4900000000003 L 454.13999999999993 439.27000000000027 L 455.37999999999994 438.54000000000025 L 455.37999999999994 438.54000000000025 L 456.6499999999999 439.08000000000027 L 457.2099999999999 440.2500000000003 L 458.43999999999994 441.84000000000026 L 460.2099999999999 442.23000000000025 L 463.3599999999999 441.7000000000003 L 465.0599999999999 441.71000000000026 L 465.8099999999999 443.35000000000025 L 464.1599999999999 445.5000000000002 L 462.6599999999999 446.2100000000002 L 459.88999999999993 446.5700000000002 L 459.38999999999993 446.42000000000024 L 457.0399999999999 447.43000000000023 L 455.94999999999993 448.5800000000002 L 454.85999999999996 452.0800000000002 L 454.90999999999997 452.49000000000024 L 456.53999999999996 454.22000000000025 L 457.02 454.48000000000025 L 457.02 454.48000000000025 L 456.96 454.68000000000023 L 455.27 455.10000000000025 L 454.21 454.28000000000026 L 452.72999999999996 455.39000000000027 L 452.29999999999995 456.04000000000025 L 452.56999999999994 456.2600000000003 L 451.80999999999995 456.90000000000026 L 448.5899999999999 458.4500000000003 L 446.3399999999999 459.15000000000026 L 446.05999999999995 459.59000000000026 L 446.09999999999997 460.55000000000024 L 446.59999999999997 462.10000000000025 L 446.28 462.52000000000027 L 444.88 462.78000000000026 L 444.18 462.14000000000027 L 442.84000000000003 461.85000000000025 L 439.72 461.35000000000025 L 438.86 461.5000000000002 L 437.54 461.8400000000002 L 435.81 462.6600000000002 L 435.31 463.1700000000002 L 434.1 465.32000000000016 L 432.79 465.89000000000016 L 432.29 465.77000000000015 L 432.87 465.3000000000001 L 432.39 464.0800000000001 L 431.21999999999997 463.2300000000001 L 430.39 464.4600000000001 L 430.65 465.2100000000001 L 430.34999999999997 465.8200000000001 L 422.72999999999996 470.0600000000001 L 421.78 470.8800000000001 L 421.46999999999997 472.04000000000013 L 418.2 475.04000000000013 L 414.95 476.9900000000001 L 413.03 477.5200000000001 L 408.53 480.7300000000001 L 406.2 482.69000000000005 L 405.53 482.77000000000004 L 405.09 483.39000000000004 L 405.98999999999995 483.82000000000005 L 406.65 483.88000000000005 L 407.58 483.52000000000004 L 407.58 484.28000000000003 L 406.96 485.59000000000003 L 405.64 486.44000000000005 L 404.58 487.92 z M 448.89 464.91 L 447.34999999999997 464.26000000000005 L 446.18999999999994 464.44000000000005 L 445.69999999999993 464.06000000000006 L 445.79999999999995 463.2800000000001 L 446.74999999999994 462.6300000000001 L 447.8399999999999 460.7800000000001 L 448.55999999999995 461.0300000000001 L 449.21999999999997 461.68000000000006 L 449.34999999999997 464.5900000000001 L 448.89 464.91 z"},{code:"TO",name:"Tocantins",gTransform:"matrix(1 0 0 1 95.98 -93.17)",pathTransform:"translate(-401.98, -226.09)",d:"M 433.35 281.82 L 427.99 283.24 L 426.25 284.58 L 423.69 285.68 L 422.14 285.68 L 417.61 286.68 L 415.09 288.76 L 413.31 289.66 L 412.85 289.42 L 411.34 286.8 L 410.79 286.77 L 410.28 290.07 L 409.59 290.15 L 406.24 289.47 L 403.11 288 L 403.67 286.44 L 403.45 285.7 L 398.92 286.23 L 396.16 285.89 L 395.6 286.43 L 395.3 287.43 L 394.55 288.18 L 393.41 288.13 L 392.8 285.03 L 391.69 281.32 L 390.65 279.44 L 389.5 278.13 L 388.32 279.1 L 386.85 281.49 L 385.22 287.43 L 384.59 287.66 L 380.52 286.23 L 377.43 284.52 L 373.5 284.12 L 371.3 283.09 L 368.9 282.69 L 369.42 280.35 L 370.64 278.47 L 370.67 276.76 L 370.11 277.06 L 368.3 279.15 L 367.64 280.38 L 367.44 282.26 L 367.1 282.71 L 367.1 282.71 L 366.3 282.69 L 365.34 282.18 L 364.36 278.84 L 365.1 276.08 L 364.66 273.03 L 364.14 272.45 L 364.13 270.88 L 364.6 267.57 L 363.5 265.32 L 363.55 264.82 L 364.37 263.93 L 364.53 263.06 L 363.14 261.72 L 363.08 260.86 L 364.96 254.87 L 365 251.92 L 365.54 248.95 L 367.48 243.66 L 367.85 243.39 L 368.28 242.54 L 368.72 239.4 L 369.82 238.15 L 370.38 236.26 L 371.03 235.24 L 371.03 235.24 L 372.65 231.55 L 373.78 227.1 L 374.93 225.52 L 376.12 224.42 L 377.33 222.74 L 378.36 220.82 L 379.73 219.9 L 380.78 219.74 L 381.51 218.89 L 382.45 217.35 L 382.63 216.36 L 384.33 213.12 L 385.42 212.32 L 387.18 207.17 L 387.84 203.13 L 387.69 202.83 L 386.95 202.51 L 385.28 200.77 L 384.68 199.82 L 384.52 198.94 L 384.66 198.37 L 386.07 196.68 L 387.36 194.58 L 387.3 191.91 L 386.87 189.73 L 387.06 189.38 L 389.53 187.6 L 392.94 186.46 L 395.44 185.25 L 395.68 184.75 L 395.53 183.24 L 396.39 181.97 L 397.9 180.63 L 399.19 180.48 L 399.38 179.14 L 399.09 177.94 L 399.34 177.48 L 400.8 177.02 L 401.44 176.54 L 402.37 173.79 L 401.35 172.45 L 401.26 171.05 L 401.55 170.77 L 402.52 170.69 L 403.24 170.32 L 403.61 169.66 L 403.64 169.02 L 402.38 167.85 L 401.51 167.71 L 401.12 167.4 L 400.1 165.74 L 398.81 165.62 L 396.94 165.87 L 394.65 165.06 L 394.65 165.06 L 395.18 164.42 L 397.8 162.57 L 399.76 162.04 L 400.63 162.09 L 403.41 163.61 L 404.81 163.69 L 405.76 163.17 L 407.5 163.46 L 408.09 164.15 L 408.17 165.18 L 408.45 165.5 L 409.67 165.53 L 413.07 166.96 L 413.91 167.99 L 414.38 171.49 L 415.02 172.99 L 414.81 176.71 L 415.04 177.79 L 415.71 178.92 L 415.7 179.36 L 413.93 185.51 L 413.62 187.88 L 413.9 188.88 L 413.65 190.47 L 411.9 192.51 L 410.14 193.18 L 409.96 193.89 L 411.9 195.21 L 412.32 194.94 L 413.69 195.18 L 413.94 195.53 L 414.05 196.41 L 413.43 197.6 L 414.28 199.04 L 415.16 198.97 L 418.16 203.13 L 419.07 203.98 L 421.35 207 L 423.49 205.66 L 427.76 204.72 L 429.56 205.94 L 429.64 207.69 L 429 210.94 L 429.39 212.29 L 426 212.64 L 424.66 213.18 L 424.09 213.73 L 423.41 215.16 L 422.68 217.84 L 423.05 219.14 L 420.42 221.69 L 420.16 222.39 L 420.36 222.81 L 422.44 223.1 L 423.38 223.79 L 424.12 225.38 L 424.18 227.04 L 424.8 228.08 L 428.68 230.03 L 428.77 230.56 L 427.13 232.37 L 427.26 234.02 L 429.4 235.64 L 430.39 238.51 L 431.73 240.51 L 432.44 240.69 L 434.22 240.48 L 435.22 240.78 L 436.04 241.22 L 436.65 242.04 L 437.93 242.7 L 437.93 242.7 L 440.87 242.91 L 440.87 242.91 L 440.18 243.56 L 439.96 244.54 L 439.4 245.01 L 435.58 247.03 L 432.37 249.65 L 432.18 250.02 L 433.47 251.82 L 433.11 252.21 L 432.1 252.48 L 431.2 253.09 L 429.68 256.58 L 428.67 257.3 L 428.17 258.46 L 428.4 259.38 L 430.26 261.33 L 433.85 262 L 435.72 262.99 L 435.77 263.75 L 435.21 264.2 L 433.17 265.01 L 432.74 265.97 L 432.83 266.47 L 433.18 266.8 L 434.21 266.62 L 435.13 266.91 L 435.71 267.42 L 436 268.06 L 435.04 268.77 L 433.89 269.19 L 431.94 270.86 L 431.75 271.71 L 431.7 274.63 L 432.05 275.88 L 432.99 276.54 L 434.04 276.78 L 434.45 277.03 L 434.62 277.45 L 434.67 278.51 L 433.31 280.89 z"}];function _I({selected:t,onSelect:e}){const s=re(),[n,i]=A.useState(bI),o=a=>{if(a)try{const l=a.getBBox();if(!l.width||!l.height)return;const c=Math.max(l.width,l.height)*.04,d=`${l.x-c} ${l.y-c} ${l.width+c*2} ${l.height+c*2}`;i(h=>h===d?h:d)}catch{}};return r.jsx("svg",{ref:o,viewBox:n,role:"group","aria-label":s("sectionsEditor.brazilMap.ariaLabel"),className:"h-72 w-full rounded-md border border-border/60 bg-muted/20",children:r.jsx("g",{transform:yI,children:Nu.map(a=>{const l=a.code===t;return r.jsx("g",{transform:a.gTransform,children:r.jsx("path",{d:a.d,transform:a.pathTransform,role:"button",tabIndex:0,"aria-label":a.name,"aria-pressed":l,onClick:()=>e(a.code),onKeyDown:c=>{(c.key==="Enter"||c.key===" ")&&(c.preventDefault(),e(a.code))},className:ie("cursor-pointer stroke-background outline-none transition-colors [stroke-width:1] [vector-effect:non-scaling-stroke]","hover:fill-primary/50 focus-visible:fill-primary/50",l?"fill-primary":"fill-muted-foreground/40")})},a.code)})})})}const LI=[{code:"AF",name:"Afghanistan"},{code:"AX",name:"Åland Islands"},{code:"AL",name:"Albania"},{code:"DZ",name:"Algeria"},{code:"AS",name:"American Samoa"},{code:"AD",name:"Andorra"},{code:"AO",name:"Angola"},{code:"AI",name:"Anguilla"},{code:"AQ",name:"Antarctica"},{code:"AG",name:"Antigua & Barbuda"},{code:"AR",name:"Argentina"},{code:"AM",name:"Armenia"},{code:"AW",name:"Aruba"},{code:"AU",name:"Australia"},{code:"AT",name:"Austria"},{code:"AZ",name:"Azerbaijan"},{code:"BS",name:"Bahamas"},{code:"BH",name:"Bahrain"},{code:"BD",name:"Bangladesh"},{code:"BB",name:"Barbados"},{code:"BY",name:"Belarus"},{code:"BE",name:"Belgium"},{code:"BZ",name:"Belize"},{code:"BJ",name:"Benin"},{code:"BM",name:"Bermuda"},{code:"BT",name:"Bhutan"},{code:"BO",name:"Bolivia"},{code:"BA",name:"Bosnia & Herzegovina"},{code:"BW",name:"Botswana"},{code:"BV",name:"Bouvet Island"},{code:"BR",name:"Brazil"},{code:"VG",name:"British Virgin Islands"},{code:"BN",name:"Brunei"},{code:"BG",name:"Bulgaria"},{code:"BF",name:"Burkina Faso"},{code:"BI",name:"Burundi"},{code:"KH",name:"Cambodia"},{code:"CM",name:"Cameroon"},{code:"CA",name:"Canada"},{code:"CV",name:"Cape Verde"},{code:"BQ",name:"Caribbean Netherlands"},{code:"KY",name:"Cayman Islands"},{code:"CF",name:"Central African Republic"},{code:"TD",name:"Chad"},{code:"IO",name:"Chagos Archipelago"},{code:"CL",name:"Chile"},{code:"CN",name:"China mainland"},{code:"CX",name:"Christmas Island"},{code:"CC",name:"Cocos (Keeling) Islands"},{code:"CO",name:"Colombia"},{code:"KM",name:"Comoros"},{code:"CG",name:"Congo - Brazzaville"},{code:"CD",name:"Congo - Kinshasa"},{code:"CK",name:"Cook Islands"},{code:"CR",name:"Costa Rica"},{code:"CI",name:"Côte d’Ivoire"},{code:"HR",name:"Croatia"},{code:"CU",name:"Cuba"},{code:"CW",name:"Curaçao"},{code:"CY",name:"Cyprus"},{code:"CZ",name:"Czechia"},{code:"DK",name:"Denmark"},{code:"DJ",name:"Djibouti"},{code:"DM",name:"Dominica"},{code:"DO",name:"Dominican Republic"},{code:"EC",name:"Ecuador"},{code:"EG",name:"Egypt"},{code:"SV",name:"El Salvador"},{code:"GQ",name:"Equatorial Guinea"},{code:"ER",name:"Eritrea"},{code:"EE",name:"Estonia"},{code:"SZ",name:"Eswatini"},{code:"ET",name:"Ethiopia"},{code:"FK",name:"Falkland Islands"},{code:"FO",name:"Faroe Islands"},{code:"FJ",name:"Fiji"},{code:"FI",name:"Finland"},{code:"FR",name:"France"},{code:"GF",name:"French Guiana"},{code:"PF",name:"French Polynesia"},{code:"TF",name:"French Southern Territories"},{code:"GA",name:"Gabon"},{code:"GM",name:"Gambia"},{code:"GE",name:"Georgia"},{code:"DE",name:"Germany"},{code:"GH",name:"Ghana"},{code:"GI",name:"Gibraltar"},{code:"GR",name:"Greece"},{code:"GL",name:"Greenland"},{code:"GD",name:"Grenada"},{code:"GP",name:"Guadeloupe"},{code:"GU",name:"Guam"},{code:"GT",name:"Guatemala"},{code:"GG",name:"Guernsey"},{code:"GN",name:"Guinea"},{code:"GW",name:"Guinea-Bissau"},{code:"GY",name:"Guyana"},{code:"HT",name:"Haiti"},{code:"HM",name:"Heard & McDonald Islands"},{code:"HN",name:"Honduras"},{code:"HK",name:"Hong Kong"},{code:"HU",name:"Hungary"},{code:"IS",name:"Iceland"},{code:"IN",name:"India"},{code:"ID",name:"Indonesia"},{code:"IR",name:"Iran"},{code:"IQ",name:"Iraq"},{code:"IE",name:"Ireland"},{code:"IM",name:"Isle of Man"},{code:"IL",name:"Israel"},{code:"IT",name:"Italy"},{code:"JM",name:"Jamaica"},{code:"JP",name:"Japan"},{code:"JE",name:"Jersey"},{code:"JO",name:"Jordan"},{code:"KZ",name:"Kazakhstan"},{code:"KE",name:"Kenya"},{code:"KI",name:"Kiribati"},{code:"KW",name:"Kuwait"},{code:"KG",name:"Kyrgyzstan"},{code:"LA",name:"Laos"},{code:"LV",name:"Latvia"},{code:"LB",name:"Lebanon"},{code:"LS",name:"Lesotho"},{code:"LR",name:"Liberia"},{code:"LY",name:"Libya"},{code:"LI",name:"Liechtenstein"},{code:"LT",name:"Lithuania"},{code:"LU",name:"Luxembourg"},{code:"MO",name:"Macao"},{code:"MG",name:"Madagascar"},{code:"MW",name:"Malawi"},{code:"MY",name:"Malaysia"},{code:"MV",name:"Maldives"},{code:"ML",name:"Mali"},{code:"MT",name:"Malta"},{code:"MH",name:"Marshall Islands"},{code:"MQ",name:"Martinique"},{code:"MR",name:"Mauritania"},{code:"MU",name:"Mauritius"},{code:"YT",name:"Mayotte"},{code:"MX",name:"Mexico"},{code:"FM",name:"Micronesia"},{code:"MD",name:"Moldova"},{code:"MC",name:"Monaco"},{code:"MN",name:"Mongolia"},{code:"ME",name:"Montenegro"},{code:"MS",name:"Montserrat"},{code:"MA",name:"Morocco"},{code:"MZ",name:"Mozambique"},{code:"MM",name:"Myanmar (Burma)"},{code:"NA",name:"Namibia"},{code:"NR",name:"Nauru"},{code:"NP",name:"Nepal"},{code:"NL",name:"Netherlands"},{code:"NC",name:"New Caledonia"},{code:"NZ",name:"New Zealand"},{code:"NI",name:"Nicaragua"},{code:"NE",name:"Niger"},{code:"NG",name:"Nigeria"},{code:"NU",name:"Niue"},{code:"NF",name:"Norfolk Island"},{code:"KP",name:"North Korea"},{code:"MK",name:"North Macedonia"},{code:"MP",name:"Northern Mariana Islands"},{code:"NO",name:"Norway"},{code:"OM",name:"Oman"},{code:"PK",name:"Pakistan"},{code:"PW",name:"Palau"},{code:"PS",name:"Palestinian Territories"},{code:"PA",name:"Panama"},{code:"PG",name:"Papua New Guinea"},{code:"PY",name:"Paraguay"},{code:"PE",name:"Peru"},{code:"PH",name:"Philippines"},{code:"PN",name:"Pitcairn Islands"},{code:"PL",name:"Poland"},{code:"PT",name:"Portugal"},{code:"PR",name:"Puerto Rico"},{code:"QA",name:"Qatar"},{code:"RE",name:"Réunion"},{code:"RO",name:"Romania"},{code:"RU",name:"Russia"},{code:"RW",name:"Rwanda"},{code:"WS",name:"Samoa"},{code:"SM",name:"San Marino"},{code:"ST",name:"São Tomé & Príncipe"},{code:"SA",name:"Saudi Arabia"},{code:"SN",name:"Senegal"},{code:"RS",name:"Serbia"},{code:"SC",name:"Seychelles"},{code:"SL",name:"Sierra Leone"},{code:"SG",name:"Singapore"},{code:"SX",name:"Sint Maarten"},{code:"SK",name:"Slovakia"},{code:"SI",name:"Slovenia"},{code:"GS",name:"So. Georgia & So. Sandwich Isl."},{code:"SB",name:"Solomon Islands"},{code:"SO",name:"Somalia"},{code:"ZA",name:"South Africa"},{code:"KR",name:"South Korea"},{code:"SS",name:"South Sudan"},{code:"ES",name:"Spain"},{code:"LK",name:"Sri Lanka"},{code:"BL",name:"St. Barthélemy"},{code:"SH",name:"St. Helena"},{code:"KN",name:"St. Kitts & Nevis"},{code:"LC",name:"St. Lucia"},{code:"MF",name:"St. Martin"},{code:"PM",name:"St. Pierre & Miquelon"},{code:"VC",name:"St. Vincent & Grenadines"},{code:"SD",name:"Sudan"},{code:"SR",name:"Suriname"},{code:"SJ",name:"Svalbard & Jan Mayen"},{code:"SE",name:"Sweden"},{code:"CH",name:"Switzerland"},{code:"SY",name:"Syria"},{code:"TW",name:"Taiwan"},{code:"TJ",name:"Tajikistan"},{code:"TZ",name:"Tanzania"},{code:"TH",name:"Thailand"},{code:"TL",name:"Timor-Leste"},{code:"TG",name:"Togo"},{code:"TK",name:"Tokelau"},{code:"TO",name:"Tonga"},{code:"T1",name:"Tor network (Cloudflare)"},{code:"TT",name:"Trinidad & Tobago"},{code:"TN",name:"Tunisia"},{code:"TR",name:"Türkiye"},{code:"TM",name:"Turkmenistan"},{code:"TC",name:"Turks & Caicos Islands"},{code:"TV",name:"Tuvalu"},{code:"UM",name:"U.S. Outlying Islands"},{code:"VI",name:"U.S. Virgin Islands"},{code:"UG",name:"Uganda"},{code:"UA",name:"Ukraine"},{code:"AE",name:"United Arab Emirates"},{code:"GB",name:"United Kingdom"},{code:"US",name:"United States"},{code:"XX",name:"Unknown (Cloudflare could not determine)"},{code:"UY",name:"Uruguay"},{code:"UZ",name:"Uzbekistan"},{code:"VU",name:"Vanuatu"},{code:"VA",name:"Vatican City"},{code:"VE",name:"Venezuela"},{code:"VN",name:"Vietnam"},{code:"WF",name:"Wallis & Futuna"},{code:"EH",name:"Western Sahara"},{code:"YE",name:"Yemen"},{code:"ZM",name:"Zambia"},{code:"ZW",name:"Zimbabwe"}],SI="BR";function wI(t){if(!t)return!1;const e=Object.keys(t).sort();return e.length===3&&e[0]==="city"&&e[1]==="country"&&e[2]==="regionCode"}function jI(t){const e=t&&typeof t=="object"&&!Array.isArray(t)?t:{};return{city:typeof e.city=="string"?e.city:"",regionCode:typeof e.regionCode=="string"?e.regionCode:"",country:typeof e.country=="string"?e.country:""}}function CI(t,e){const s={...t,...e},n={};for(const i of["city","regionCode","country"])s[i]&&(n[i]=s[i]);return n}function Jf(t){const e=B.c(37),{id:s,options:n,value:i,placeholder:o,emptyMessage:a,onChange:l}=t,[c,d]=A.useState(!1);let h;if(e[0]!==n||e[1]!==i){let j;e[3]!==i?(j=S=>S.value===i,e[3]=i,e[4]=j):j=e[4],h=n.find(j),e[0]=n,e[1]=i,e[2]=h}else h=e[2];const u=h;let f;e[5]!==o||e[6]!==u?(f=u?r.jsx("span",{className:"truncate",children:u.label}):r.jsx("span",{className:"text-muted-foreground",children:o}),e[5]=o,e[6]=u,e[7]=f):f=e[7];let m;e[8]===Symbol.for("react.memo_cache_sentinel")?(m=r.jsx(S9,{className:"size-4 shrink-0 opacity-50"}),e[8]=m):m=e[8];let p;e[9]!==s||e[10]!==c||e[11]!==f?(p=r.jsx(Es,{asChild:!0,children:r.jsxs(le,{id:s,variant:"outline",role:"combobox","aria-expanded":c,className:"h-10 w-full justify-between font-normal",children:[f,m]})}),e[9]=s,e[10]=c,e[11]=f,e[12]=p):p=e[12];let g;e[13]===Symbol.for("react.memo_cache_sentinel")?(g={width:"var(--radix-popover-trigger-width)"},e[13]=g):g=e[13];let x;e[14]!==o?(x=r.jsx(Bi,{placeholder:o,className:"h-9"}),e[14]=o,e[15]=x):x=e[15];let v;e[16]!==a?(v=r.jsx(Zn,{children:a}),e[16]=a,e[17]=v):v=e[17];let b;if(e[18]!==l||e[19]!==n||e[20]!==i){let j;e[22]!==l||e[23]!==i?(j=S=>r.jsxs(Vs,{value:`${S.label} ${S.value}`,onSelect:()=>{l(S.value===i?"":S.value),d(!1)},children:[r.jsx("span",{className:"truncate",children:S.label}),r.jsx(zt,{className:ie("ml-auto size-4 shrink-0",i===S.value?"opacity-100":"opacity-0")})]},S.value),e[22]=l,e[23]=i,e[24]=j):j=e[24],b=n.map(j),e[18]=l,e[19]=n,e[20]=i,e[21]=b}else b=e[21];let _;e[25]!==b?(_=r.jsx(Ms,{children:b}),e[25]=b,e[26]=_):_=e[26];let y;e[27]!==v||e[28]!==_?(y=r.jsxs(Fi,{children:[v,_]}),e[27]=v,e[28]=_,e[29]=y):y=e[29];let L;e[30]!==y||e[31]!==x?(L=r.jsx(Ps,{className:"p-0",style:g,children:r.jsxs(Tr,{children:[x,y]})}),e[30]=y,e[31]=x,e[32]=L):L=e[32];let w;return e[33]!==c||e[34]!==L||e[35]!==p?(w=r.jsxs(As,{open:c,onOpenChange:d,children:[p,L]}),e[33]=c,e[34]=L,e[35]=p,e[36]=w):w=e[36],w}const kI=LI.map(t=>({value:t.code,label:`${t.name} (${t.code})`})),VI=Nu.map(t=>({value:t.code,label:`${t.name} (${t.code})`}));function P4(t){const e=B.c(68),{schema:s,value:n,onChange:i,path:o}=t,a=re();let l;e[0]!==n?(l=jI(n),e[0]=n,e[1]=l):l=e[1];const c=l,{city:d,regionCode:h,country:u}=c;let f;e[2]!==s.properties?(f=s.properties??{},e[2]=s.properties,e[3]=f):f=e[3];const m=f;let p;e[4]!==m.country?.title||e[5]!==a?(p=m.country?.title??a("sectionsEditor.locationField.countryDefault"),e[4]=m.country?.title,e[5]=a,e[6]=p):p=e[6];const g=p;let x;e[7]!==m.regionCode?.title||e[8]!==a?(x=m.regionCode?.title??a("sectionsEditor.locationField.regionDefault"),e[7]=m.regionCode?.title,e[8]=a,e[9]=x):x=e[9];const v=x;let b;e[10]!==m.city?.title||e[11]!==a?(b=m.city?.title??a("sectionsEditor.locationField.cityDefault"),e[10]=m.city?.title,e[11]=a,e[12]=b):b=e[12];const _=b;let y;e[13]!==c||e[14]!==i?(y=S=>{i(CI(c,S))},e[13]=c,e[14]=i,e[15]=y):y=e[15];const L=y,w=u===SI;let j;if(e[16]!==d||e[17]!==_||e[18]!==u||e[19]!==g||e[20]!==L||e[21]!==w||e[22]!==o||e[23]!==h||e[24]!==v||e[25]!==s.description||e[26]!==s.title||e[27]!==a){let S;e[29]!==h?(S=K=>K.code===h,e[29]=h,e[30]=S):S=e[30];const C=Nu.find(S),N=`${o}.country`;let V;e[31]!==s.title||e[32]!==a?(V=s.title??a("sectionsEditor.locationField.locationDefault"),e[31]=s.title,e[32]=a,e[33]=V):V=e[33];let E;e[34]!==V||e[35]!==N?(E=r.jsx(lt,{htmlFor:N,children:V}),e[34]=V,e[35]=N,e[36]=E):E=e[36];let T;e[37]!==s.description?(T=s.description&&r.jsx("p",{className:"text-xs leading-normal text-muted-foreground",children:s.description}),e[37]=s.description,e[38]=T):T=e[38];let k;e[39]!==E||e[40]!==T?(k=r.jsxs("div",{className:"space-y-0.5",children:[E,T]}),e[39]=E,e[40]=T,e[41]=k):k=e[41];const R=`${o}.country`;let P;e[42]!==g||e[43]!==R?(P=r.jsx(lt,{htmlFor:R,className:"text-xs",children:g}),e[42]=g,e[43]=R,e[44]=P):P=e[44];const D=`${o}.country`;let I;e[45]!==a?(I=a("sectionsEditor.locationField.selectCountryPlaceholder"),e[45]=a,e[46]=I):I=e[46];let M;e[47]!==a?(M=a("sectionsEditor.locationField.noCountryFound"),e[47]=a,e[48]=M):M=e[48];let O;e[49]!==L?(O=K=>L({country:K,regionCode:"",city:""}),e[49]=L,e[50]=O):O=e[50];let F;e[51]!==u||e[52]!==D||e[53]!==I||e[54]!==M||e[55]!==O?(F=r.jsx(Jf,{id:D,options:kI,value:u,placeholder:I,emptyMessage:M,onChange:O}),e[51]=u,e[52]=D,e[53]=I,e[54]=M,e[55]=O,e[56]=F):F=e[56];let $;e[57]!==P||e[58]!==F?($=r.jsxs("div",{className:"space-y-1.5",children:[P,F]}),e[57]=P,e[58]=F,e[59]=$):$=e[59];let z;e[60]!==u||e[61]!==L||e[62]!==w||e[63]!==o||e[64]!==h||e[65]!==v||e[66]!==a?(z=u&&r.jsxs("div",{className:"space-y-1.5",children:[r.jsx(lt,{htmlFor:`${o}.regionCode`,className:"text-xs",children:v}),w?r.jsxs("div",{className:"space-y-2",children:[r.jsx(_I,{selected:h,onSelect:K=>L({regionCode:K===h?"":K,city:""})}),r.jsx(Jf,{id:`${o}.regionCode`,options:VI,value:h,placeholder:a("sectionsEditor.locationField.selectStatePlaceholder"),emptyMessage:a("sectionsEditor.locationField.noStateFound"),onChange:K=>L({regionCode:K,city:""})})]}):r.jsxs(r.Fragment,{children:[r.jsx(rt,{id:`${o}.regionCode`,type:"text",value:h,placeholder:a("sectionsEditor.locationField.regionCodePlaceholder"),onChange:K=>L({regionCode:K.target.value})}),r.jsx("p",{className:"text-xs leading-normal text-muted-foreground",children:a("sectionsEditor.locationField.regionCodeHelperText")})]})]}),e[60]=u,e[61]=L,e[62]=w,e[63]=o,e[64]=h,e[65]=v,e[66]=a,e[67]=z):z=e[67],j=r.jsxs("div",{className:"space-y-4",children:[k,$,z,u&&r.jsxs("div",{className:"space-y-1.5",children:[r.jsx(lt,{htmlFor:`${o}.city`,className:"text-xs",children:_}),r.jsx(rt,{id:`${o}.city`,type:"text",value:d,placeholder:w&&C?a("sectionsEditor.locationField.cityPlaceholderWithState",{state:C.name}):a("sectionsEditor.locationField.cityPlaceholder"),onChange:K=>L({city:K.target.value})}),r.jsx("p",{className:"text-xs leading-normal text-muted-foreground",children:a("sectionsEditor.locationField.cityHelperText")})]})]}),e[16]=d,e[17]=_,e[18]=u,e[19]=g,e[20]=L,e[21]=w,e[22]=o,e[23]=h,e[24]=v,e[25]=s.description,e[26]=s.title,e[27]=a,e[28]=j}else j=e[28];return j}function NI(t){const e=t.schema;if(!e?.properties)return null;const s=new Set(Object.keys(t.discriminators??{}));if(s.size===0)return e;const n={};for(const[i,o]of Object.entries(e.properties))s.has(i)||(n[i]=o);return{...e,properties:n}}function TI(t){const e=B.c(50),s=re(),{schema:n,value:i,onChange:o,path:a,label:l}=t;let c,d;e[0]!==n.inlineUnionBranches||e[1]!==i?(c=n.inlineUnionBranches??[],d=xI(i,c.map(EI)),e[0]=n.inlineUnionBranches,e[1]=i,e[2]=c,e[3]=d):(c=e[2],d=e[3]);const h=d,[u,f]=A.useState(h),[m,p]=A.useState(h);m!==h&&(p(h),f(h));const g=Math.min(u,c.length-1),x=c[g];let v;e[4]!==c||e[5]!==o?(v=M=>{const O=Number(M);f(O),o({...c[O]?.discriminators??{}})},e[4]=c,e[5]=o,e[6]=v):v=e[6];const b=v;if(c.length===0)return null;let _;e[7]!==x?(_=x?NI(x):null,e[7]=x,e[8]=_):_=e[8];const y=_;let L;if(e[9]!==x?.schema?.properties||e[10]!==i){let M;e[12]!==x?.schema?.properties?(M=x?.schema?.properties??{},e[12]=x?.schema?.properties,e[13]=M):M=e[13],L=vI(i,Object.keys(M)),e[9]=x?.schema?.properties,e[10]=i,e[11]=L}else L=e[11];const w=L;let j;e[14]!==l||e[15]!==a?(j=r.jsx(lt,{htmlFor:a,children:l}),e[14]=l,e[15]=a,e[16]=j):j=e[16];const S=String(g);let C;e[17]!==s?(C=s("sectionsEditor.inlineUnionField.selectPlaceholder"),e[17]=s,e[18]=C):C=e[18];let N;e[19]!==C?(N=r.jsx(as,{placeholder:C}),e[19]=C,e[20]=N):N=e[20];let V;e[21]!==a||e[22]!==N?(V=r.jsx(Jt,{id:a,children:N}),e[21]=a,e[22]=N,e[23]=V):V=e[23];let E;e[24]!==c?(E=c.map(AI),e[24]=c,e[25]=E):E=e[25];let T;e[26]!==E?(T=r.jsx(Xt,{children:E}),e[26]=E,e[27]=T):T=e[27];let k;e[28]!==b||e[29]!==T||e[30]!==S||e[31]!==V?(k=r.jsxs(Qt,{value:S,onValueChange:b,children:[V,T]}),e[28]=b,e[29]=T,e[30]=S,e[31]=V,e[32]=k):k=e[32];let R;e[33]!==n.description?(R=n.description&&r.jsx("p",{className:"text-xs text-muted-foreground",children:n.description}),e[33]=n.description,e[34]=R):R=e[34];let P;e[35]!==k||e[36]!==R||e[37]!==j?(P=r.jsxs("div",{className:"space-y-1.5",children:[j,k,R]}),e[35]=k,e[36]=R,e[37]=j,e[38]=P):P=e[38];let D;e[39]!==x||e[40]!==y||e[41]!==o||e[42]!==a||e[43]!==w||e[44]!==t||e[45]!==i?(D=x&&(wI(x.schema?.properties)?r.jsx(P4,{...t,schema:x.schema,onChange:M=>o({...w,...M,...x.discriminators??{}})}):y?r.jsx(In,{schema:y,value:i,onChange:M=>o({...M,...x.discriminators??{}}),basePath:a,breadcrumbPath:t.breadcrumbPath,onBreadcrumbChange:t.onBreadcrumbChange,meta:t.meta,decofile:t.decofile,onSaveReferencedBlock:t.onSaveReferencedBlock,sandbox:t.sandbox,previewBaseUrl:t.previewBaseUrl,onAddSectionItem:t.onAddSectionItem,onRequestAddSection:t.onRequestAddSection}):null),e[39]=x,e[40]=y,e[41]=o,e[42]=a,e[43]=w,e[44]=t,e[45]=i,e[46]=D):D=e[46];let I;return e[47]!==P||e[48]!==D?(I=r.jsxs("div",{className:"space-y-3",children:[P,D]}),e[47]=P,e[48]=D,e[49]=I):I=e[49],I}function AI(t,e){return r.jsx(vt,{value:String(e),children:t.title},t.title)}function EI(t){return{discriminators:t.discriminators,propertyKeys:Object.keys(t.schema?.properties??{})}}const PI={lat:-21.9,lng:-41.42},r0=1e5;let Ia=null;function RI(t){return Ia||(Ia=new Promise((e,s)=>{if(typeof window>"u"){s(new Error("Google Maps requires a browser environment"));return}const n=window;if(n.google?.maps){e(n.google.maps);return}const i=()=>{const l=window.google?.maps;l?e(l):s(new Error("Google Maps script loaded without google.maps"))},o=document.querySelector("script[data-google-maps-loader]");if(o){o.addEventListener("load",i),o.addEventListener("error",()=>s(new Error("Failed to load Google Maps")));return}const a=document.createElement("script");a.src=`https://maps.googleapis.com/maps/api/js?key=${t}&v=weekly&libraries=maps`,a.async=!0,a.defer=!0,a.dataset.googleMapsLoader="true",a.addEventListener("load",i),a.addEventListener("error",()=>s(new Error("Failed to load Google Maps"))),document.head.appendChild(a)}),Ia)}function DI(t){if(typeof t!="string"||!t)return null;const e=t.split(",").map(Number),[s,n,i]=e;return!Number.isFinite(s)||!Number.isFinite(n)?null:{lat:s,lng:n,radius:Number.isFinite(i)?i:r0}}function II({schema:t,value:e,onChange:s,path:n,label:i}){const o=dm().googleMapsApiKey,a=A.useRef(s);a.current=s;const l=A.useRef(DI(e)),[c,d]=A.useState(null),h=A.useRef(null),u=f=>{if(!f||!o)return;const m={disposed:!1,circle:null,listeners:[]};return RI(o).then(p=>{if(m.disposed)return;const g=l.current,x=g?{lat:g.lat,lng:g.lng}:PI,v=g?.radius??r0,b=new p.Map(f,{center:x,zoom:v?Math.round(Math.log2(768e4/v))+1:4,draggable:!0,streetViewControl:!1,mapTypeControl:!1}),_=new p.Circle({strokeColor:"#2E6ED9",strokeOpacity:.8,strokeWeight:2,fillColor:"#2E6ED9",fillOpacity:.35,editable:!0,draggable:!0,map:b,center:x,radius:v});m.circle=_;const y=()=>{const w=_.getCenter(),j=_.getRadius();w&&a.current(`${w.lat()},${w.lng()},${j}`)},L=w=>{w&&m.listeners.push(w)};L(b.addListener("click",w=>{w.latLng&&(_.setCenter({lat:w.latLng.lat(),lng:w.latLng.lng()}),_.getRadius()||_.setRadius(r0),y())})),L(_.addListener("radius_changed",y)),L(_.addListener("dragend",y))},p=>{m.disposed||d(p instanceof Error?p.message:"Failed to load map")}),()=>{m.disposed=!0;for(const p of m.listeners)try{p?.remove()}catch{}if(m.listeners=[],m.circle){try{m.circle.setMap(null)}catch{}m.circle=null}}};return h.current||(h.current=u),r.jsxs("div",{className:"space-y-2",children:[r.jsxs("div",{className:"space-y-0.5",children:[r.jsx(lt,{htmlFor:n,children:i}),t.description&&r.jsx("p",{className:"text-xs leading-normal text-muted-foreground",children:t.description})]}),o?c?r.jsx("div",{className:"rounded-md border border-destructive/40 bg-destructive/5 px-3 py-2 text-xs text-destructive",children:c}):r.jsx("div",{ref:h.current,id:n,className:"h-72 w-full rounded-md border border-border/60"}):r.jsxs("div",{className:"rounded-md border border-border/60 bg-muted/30 px-3 py-2 text-xs text-muted-foreground",children:["The map picker is unavailable — set"," ",r.jsx("code",{className:"font-mono",children:"GOOGLE_MAPS_API_KEY"})," on the server to enable it."]})]})}const MI="oklch(0.65 0.15 160)",OI="text-[oklch(0.45_0.15_160)] hover:bg-[oklch(0.65_0.15_160/0.12)] dark:text-[oklch(0.78_0.15_160)] dark:hover:bg-[oklch(0.65_0.15_160/0.15)]",R4="text-[oklch(0.45_0.15_160)] bg-[oklch(0.65_0.15_160/0.18)] dark:text-[oklch(0.78_0.15_160)] dark:bg-[oklch(0.65_0.15_160/0.2)]",TW="text-[oklch(0.45_0.15_160)] focus:bg-[oklch(0.65_0.15_160/0.12)] focus:text-[oklch(0.45_0.15_160)] dark:text-[oklch(0.78_0.15_160)] dark:focus:bg-[oklch(0.65_0.15_160/0.15)] dark:focus:text-[oklch(0.78_0.15_160)]";function Xf(t){return t.map(e=>e.label).join(`
|
|
481
|
+
`)}function dd(t){return t.map(e=>({id:crypto.randomUUID(),index:e.index,label:e.label}))}function $I(t){return t.map((e,s)=>({...e,index:s}))}function D4(t){const e=B.c(19),{label:s,canDelete:n,dragging:i,onRename:o,onDuplicate:a,onDelete:l}=t,c=re(),d=i?"opacity-100":"opacity-0 group-hover:opacity-100";let h;e[0]!==d?(h=ie("h-4 w-4 shrink-0 text-muted-foreground/40 transition-opacity",d),e[0]=d,e[1]=h):h=e[1];let u;e[2]!==h?(u=r.jsx(oa,{className:h}),e[2]=h,e[3]=u):u=e[3];let f;e[4]===Symbol.for("react.memo_cache_sentinel")?(f=r.jsx(Nn,{className:"h-4 w-4 shrink-0",style:{color:MI}}),e[4]=f):f=e[4];let m;e[5]!==s?(m=r.jsx("span",{className:"min-w-0 flex-1 truncate text-sm font-medium",children:s}),e[5]=s,e[6]=m):m=e[6];let p;e[7]!==n||e[8]!==i||e[9]!==s||e[10]!==l||e[11]!==a||e[12]!==o||e[13]!==c?(p=!i&&r.jsxs(us,{children:[r.jsx(ds,{asChild:!0,children:r.jsx(le,{type:"button",variant:"ghost",size:"icon","aria-label":c("sectionsEditor.sectionVariantList.openActionsFor",{label:s}),className:"size-6 shrink-0 opacity-0 transition-opacity group-hover:opacity-100 data-[state=open]:opacity-100",onClick:FI,onPointerDown:BI,children:r.jsx(ai,{size:14})})}),r.jsxs(hs,{align:"end",children:[o&&r.jsxs(Xe,{onClick:x=>{x.stopPropagation(),o()},children:[r.jsx(wb,{size:14}),c("sectionsEditor.sectionVariantList.rename")]}),r.jsxs(Xe,{onClick:x=>{x.stopPropagation(),a?.()},children:[r.jsx(Os,{size:14}),c("sectionsEditor.sectionVariantList.duplicate")]}),r.jsxs(Xe,{variant:"destructive",disabled:!n,onClick:x=>{x.stopPropagation(),l?.()},children:[r.jsx(Ns,{size:14}),c("sectionsEditor.sectionVariantList.delete")]})]})]}),e[7]=n,e[8]=i,e[9]=s,e[10]=l,e[11]=a,e[12]=o,e[13]=c,e[14]=p):p=e[14];let g;return e[15]!==u||e[16]!==m||e[17]!==p?(g=r.jsxs(r.Fragment,{children:[u,f,m,p]}),e[15]=u,e[16]=m,e[17]=p,e[18]=g):g=e[18],g}function BI(t){return t.stopPropagation()}function FI(t){return t.stopPropagation()}function zI(t){const e=B.c(27),{entry:s,selected:n,canDelete:i,onSelect:o,onRename:a,onDuplicate:l,onDelete:c}=t;let d;e[0]!==s.id?(d={id:s.id,animateLayoutChanges:KI},e[0]=s.id,e[1]=d):d=e[1];const{attributes:h,listeners:u,setNodeRef:f,transform:m,isDragging:p}=ou(d);let g;e[2]!==m?(g=Ln.Transform.toString(m?{...m,x:0}:null),e[2]=m,e[3]=g):g=e[3];const x=p?0:void 0;let v;e[4]!==g||e[5]!==x?(v={transform:g,opacity:x},e[4]=g,e[5]=x,e[6]=v):v=e[6];const b=v;let _;e[7]!==o?(_=C=>{C.target===C.currentTarget&&(C.key==="Enter"||C.key===" ")&&(C.preventDefault(),o())},e[7]=o,e[8]=_):_=e[8];const y=p?"cursor-grabbing":"cursor-grab",L=n?R4:OI;let w;e[9]!==y||e[10]!==L?(w=ie("group flex select-none items-center gap-2 rounded-md px-2 py-2.5 transition-colors touch-none",y,L),e[9]=y,e[10]=L,e[11]=w):w=e[11];let j;e[12]!==i||e[13]!==s.label||e[14]!==c||e[15]!==l||e[16]!==a?(j=r.jsx(D4,{label:s.label,canDelete:i,onRename:a,onDuplicate:l,onDelete:c}),e[12]=i,e[13]=s.label,e[14]=c,e[15]=l,e[16]=a,e[17]=j):j=e[17];let S;return e[18]!==h||e[19]!==u||e[20]!==o||e[21]!==f||e[22]!==b||e[23]!==_||e[24]!==w||e[25]!==j?(S=r.jsx("div",{ref:f,style:b,...h,...u,onClick:o,onKeyDown:_,className:w,children:j}),e[18]=h,e[19]=u,e[20]=o,e[21]=f,e[22]=b,e[23]=_,e[24]=w,e[25]=j,e[26]=S):S=e[26],S}function KI(){return!1}function UI(t){const e=B.c(103),{listKey:s,variants:n,selectedIndex:i,onSelect:o,onRename:a,onDuplicate:l,onDelete:c,onRemoveAll:d,onReorder:h,onAdd:u}=t,f=re(),m=n.length>1;let p;e[0]!==n?(p=()=>dd(n),e[0]=n,e[1]=p):p=e[1];const[g,x]=A.useState(p),[v,b]=A.useState(null),[_,y]=A.useState(s),[L,w]=A.useState(n.length);let j;e[2]!==n?(j=()=>Xf(n),e[2]=n,e[3]=j):j=e[3];const[S,C]=A.useState(j),N=A.useRef(!1),V=Xf(n);_!==s?(y(s),w(n.length),C(V),x(dd(n))):L!==n.length?(w(n.length),C(V),x(dd(n))):S!==V&&(C(V),x(ce=>n.map((oe,me)=>({id:ce[me]?.id??crypto.randomUUID(),index:oe.index,label:oe.label}))));let E;e[4]===Symbol.for("react.memo_cache_sentinel")?(E={activationConstraint:{distance:8}},e[4]=E):E=e[4];let T;e[5]===Symbol.for("react.memo_cache_sentinel")?(T={coordinateGetter:au},e[5]=T):T=e[5];const k=gc(si(Br,E),si($r,T));let R;e[6]!==g?(R=g.map(HI),e[6]=g,e[7]=R):R=e[7];const P=R;let D;e[8]!==g?(D=ce=>{const oe=String(ce.active.id);b(g.find(me=>me.id===oe)??null)},e[8]=g,e[9]=D):D=e[9];const I=D;let M;e[10]!==P||e[11]!==h?(M=ce=>{b(null);const{active:oe,over:me}=ce;if(!me||oe.id===me.id)return;const pe=P.indexOf(String(oe.id)),we=P.indexOf(String(me.id));pe===-1||we===-1||(x(Ne=>$I(_r([...Ne],pe,we))),N.current=!0,requestAnimationFrame(()=>{N.current=!1}),h(pe,we))},e[10]=P,e[11]=h,e[12]=M):M=e[12];const O=M;let F;e[13]===Symbol.for("react.memo_cache_sentinel")?(F=()=>{b(null)},e[13]=F):F=e[13];const $=F;let z,K,X,J,H,W,U,Q,q,Z,Y,ee,G;if(e[14]!==m||e[15]!==g||e[16]!==P||e[17]!==O||e[18]!==I||e[19]!==u||e[20]!==c||e[21]!==l||e[22]!==d||e[23]!==a||e[24]!==o||e[25]!==i||e[26]!==k||e[27]!==f){const ce=Se=>{N.current||o(Se)};Y="space-y-1 border-b p-2";let oe;e[41]!==f?(oe=f("sectionsEditor.sectionVariantList.title"),e[41]=f,e[42]=oe):oe=e[42];let me;e[43]!==oe?(me=r.jsx("span",{className:"text-xs font-medium text-muted-foreground",children:oe}),e[43]=oe,e[44]=me):me=e[44];let pe;e[45]!==f?(pe=f("sectionsEditor.sectionVariantList.addVariantAriaLabel"),e[45]=f,e[46]=pe):pe=e[46];let we;e[47]===Symbol.for("react.memo_cache_sentinel")?(we=r.jsx(kt,{size:14}),e[47]=we):we=e[47];let Ne;e[48]!==u||e[49]!==pe?(Ne=r.jsx(Ke,{asChild:!0,children:r.jsx(le,{type:"button",variant:"ghost",size:"icon","aria-label":pe,className:"size-6",onClick:u,children:we})}),e[48]=u,e[49]=pe,e[50]=Ne):Ne=e[50];let Oe;e[51]!==f?(Oe=f("sectionsEditor.sectionVariantList.addVariant"),e[51]=f,e[52]=Oe):Oe=e[52];let ye;e[53]!==Oe?(ye=r.jsx(Ue,{children:Oe}),e[53]=Oe,e[54]=ye):ye=e[54];let je;e[55]!==Ne||e[56]!==ye?(je=r.jsxs(He,{children:[Ne,ye]}),e[55]=Ne,e[56]=ye,e[57]=je):je=e[57];let Pe;e[58]!==f?(Pe=f("sectionsEditor.sectionVariantList.removeAllVariantsAriaLabel"),e[58]=f,e[59]=Pe):Pe=e[59];let Ee;e[60]===Symbol.for("react.memo_cache_sentinel")?(Ee=r.jsx(Ns,{size:14}),e[60]=Ee):Ee=e[60];let be;e[61]!==d||e[62]!==Pe?(be=r.jsx(Ke,{asChild:!0,children:r.jsx(le,{type:"button",variant:"ghost",size:"icon","aria-label":Pe,className:"size-6 text-muted-foreground hover:text-destructive",onClick:d,children:Ee})}),e[61]=d,e[62]=Pe,e[63]=be):be=e[63];let Ve;e[64]!==f?(Ve=f("sectionsEditor.sectionVariantList.removeAllVariants"),e[64]=f,e[65]=Ve):Ve=e[65];let Re;e[66]!==Ve?(Re=r.jsx(Ue,{children:Ve}),e[66]=Ve,e[67]=Re):Re=e[67];let Le;e[68]!==be||e[69]!==Re?(Le=r.jsxs(He,{children:[be,Re]}),e[68]=be,e[69]=Re,e[70]=Le):Le=e[70];let ve;e[71]!==je||e[72]!==Le?(ve=r.jsxs("div",{className:"flex items-center gap-0.5",children:[je,Le]}),e[71]=je,e[72]=Le,e[73]=ve):ve=e[73],e[74]!==me||e[75]!==ve?(ee=r.jsxs("div",{className:"flex items-center justify-between",children:[me,ve]}),e[74]=me,e[75]=ve,e[76]=ee):ee=e[76],K=yc,W=k,U=J9,Q=I,q=O,Z=$,z=ru,J=P,H=iu,G="space-y-0.5",X=g.map(Se=>r.jsx(zI,{entry:Se,selected:Se.index===i,canDelete:m,onSelect:()=>ce(Se.index),onRename:a?()=>a(Se.index):void 0,onDuplicate:()=>l(Se.index),onDelete:()=>c(Se.index)},Se.id)),e[14]=m,e[15]=g,e[16]=P,e[17]=O,e[18]=I,e[19]=u,e[20]=c,e[21]=l,e[22]=d,e[23]=a,e[24]=o,e[25]=i,e[26]=k,e[27]=f,e[28]=z,e[29]=K,e[30]=X,e[31]=J,e[32]=H,e[33]=W,e[34]=U,e[35]=Q,e[36]=q,e[37]=Z,e[38]=Y,e[39]=ee,e[40]=G}else z=e[28],K=e[29],X=e[30],J=e[31],H=e[32],W=e[33],U=e[34],Q=e[35],q=e[36],Z=e[37],Y=e[38],ee=e[39],G=e[40];let te;e[77]!==X||e[78]!==G?(te=r.jsx("div",{className:G,children:X}),e[77]=X,e[78]=G,e[79]=te):te=e[79];let se;e[80]!==z||e[81]!==J||e[82]!==H||e[83]!==te?(se=r.jsx(z,{items:J,strategy:H,children:te}),e[80]=z,e[81]=J,e[82]=H,e[83]=te,e[84]=se):se=e[84];let ne;e[85]!==v||e[86]!==m?(ne=v?r.jsx("div",{className:ie("flex items-center gap-2 rounded-md px-2 py-2.5 shadow-lg ring-1 ring-border/60 cursor-grabbing",R4),children:r.jsx(D4,{label:v.label,canDelete:m,dragging:!0})}):null,e[85]=v,e[86]=m,e[87]=ne):ne=e[87];let de;e[88]!==ne?(de=r.jsx(eu,{dropAnimation:null,children:ne}),e[88]=ne,e[89]=de):de=e[89];let xe;e[90]!==K||e[91]!==W||e[92]!==U||e[93]!==Q||e[94]!==q||e[95]!==Z||e[96]!==se||e[97]!==de?(xe=r.jsxs(K,{sensors:W,collisionDetection:U,onDragStart:Q,onDragEnd:q,onDragCancel:Z,children:[se,de]}),e[90]=K,e[91]=W,e[92]=U,e[93]=Q,e[94]=q,e[95]=Z,e[96]=se,e[97]=de,e[98]=xe):xe=e[98];let he;return e[99]!==Y||e[100]!==ee||e[101]!==xe?(he=r.jsxs("div",{className:Y,children:[ee,xe]}),e[99]=Y,e[100]=ee,e[101]=xe,e[102]=he):he=e[102],he}function HI(t){return t.id}const WI=[[/always|matchalways/i,"Users03"],[/device|matchdevice/i,"Phone02"],[/date|matchdate/i,"Calendar"],[/random|matchrandom/i,"Shuffle01"],[/host|matchhost/i,"Globe02"],[/location|matchlocation/i,"MarkerPin01"],[/pathname/i,"Link03"],[/cron|matchcron/i,"Clock"],[/multi|matchmulti/i,"FilterLines"],[/never|matchnever/i,"EyeOff"],[/environment|matchenvironment/i,"Cloud01"],[/eq\.ts|\/eq$/i,"Brackets"],[/user|requser|isdecouser/i,"User01"],[/site|template/i,"LayoutAlt01"]],qI={"device-mobile":"Phone02","device-desktop":"Monitor01","device-tablet":"Tablet01","calendar-event":"Calendar","calendar-month":"Calendar",clock:"Clock","current-location":"MarkerPin01","map-2":"MarkerPin01","world-search":"Globe02",shuffle:"Shuffle01",filter:"FilterLines","eye-off":"EyeOff",flask:"Beaker02",link:"Link03","git-merge":"GitBranch01",users:"Users03",flag:"Flag01","cloud-storm":"Cloud01",campaign:"Announcement01",experiment:"Beaker02",language:"Globe02","hand-click":"CursorClick01"};function ud(t){return Oi(t)!==void 0}function Tu(t,e){if(e){if(ud(e))return e;const s=qI[e];if(s&&ud(s))return s}for(const[s,n]of WI)if(s.test(t)&&ud(n))return n;return"FilterLines"}function GI(t){return Oi(t)??n8}function hd(t){const e=B.c(11),{iconName:s,size:n,className:i}=t,o=n===void 0?"md":n;let a;e[0]!==s?(a=GI(s),e[0]=s,e[1]=a):a=e[1];const l=a,c=o==="sm"?"size-7":"size-9",d=o==="sm"?16:18;let h;e[2]!==c||e[3]!==i?(h=ie("flex shrink-0 items-center justify-center rounded-full bg-muted",c,i),e[2]=c,e[3]=i,e[4]=h):h=e[4];let u;e[5]!==l||e[6]!==d?(u=r.jsx(l,{size:d,className:"text-muted-foreground"}),e[5]=l,e[6]=d,e[7]=u):u=e[7];let f;return e[8]!==h||e[9]!==u?(f=r.jsx("div",{className:h,children:u}),e[8]=h,e[9]=u,e[10]=f):f=e[10],f}const YI=t=>t.charAt(0).toUpperCase()+t.slice(1).toLowerCase(),JI=5,XI=new Intl.DateTimeFormat("en",{dateStyle:"medium",timeStyle:"short"});function Qf(t){const{start:e,end:s}=t,n=typeof e=="string"?e:"",i=typeof s=="string"?s:"";if(!n&&!i)return null;const o=c=>{if(!c)return null;const d=new Date(c);return Number.isNaN(d.getTime())?null:XI.format(d)},a=o(n),l=o(i);return a&&l?`${a} → ${l}`:a?`From ${a}`:l?`Until ${l}`:null}function Ol(t,e=0){if(!t)return"Default";if(e>JI)return"...";const s=t.__resolveType??"";if(["website/matchers/always.ts","$live/matchers/MatchAlways.ts"].includes(s)||s==="")return"Default";switch(s){case"website/matchers/never.ts":return"Hidden";case"website/matchers/device.ts":case"$live/matchers/MatchDevice.ts":{const{mobile:i,tablet:o,desktop:a,devices:l=[]}=t,c=[...l];return i&&c.push("Mobile"),o&&c.push("Tablet"),a&&c.push("Desktop"),c.length>0?c.map(YI).join(" & "):Tt(s)}case"website/matchers/date.ts":case"$live/matchers/MatchDate.ts":return Qf(t)??Tt(s);case"website/matchers/random.ts":case"$live/matchers/MatchRandom.ts":{const{traffic:i}=t;return typeof i=="number"?`${Math.ceil(i*100)}% of sessions`:Tt(s)}case"website/matchers/host.ts":case"$live/matchers/MatchHost.ts":{const{includes:i,match:o}=t,a=[];return i&&a.push(i),o&&a.push(o),a.length>0?a.join(" - "):Tt(s)}case"website/matchers/pathname.ts":{const i=t.case,{type:o,pathname:a}=i??{};return o&&a?`Pathname ${o} ${a}`:Tt(s)}case"website/matchers/location.ts":case"$live/matchers/MatchLocation.ts":{const{includeLocations:i,excludeLocations:o}=t,a=d=>[d.city,d.regionCode,d.country].filter(Boolean).join(" - "),l=i?.[0];if(l){const d=(i?.length??0)-1;return`${a(l)}${d>0?` +${d}`:""}`}const c=o?.[0];if(c){const d=(o?.length??0)-1;return`Except ${a(c)}${d>0?` +${d}`:""}`}return"Any location"}case"website/matchers/multi.ts":case"$live/matchers/MatchMulti.ts":{const{matchers:i,op:o="AND"}=t;if(i&&i.length>0){const a=o==="OR"?"OR":"AND";return i.map(l=>Ol(l,e+1)).join(` ${a} `)}return Tt(s)}default:{const i=Qf(t);return i||Tt(s)||"Default"}}}function AW(t,e){return lA(t,e).map(s=>{const n=e[s.blockKey]??{},i=Lg(uA(s.blockKey),e,t);return{blockKey:s.blockKey,title:hc(s.blockKey,n),description:Ol(i),iconName:Tu(s.matcherResolveType)}})}const I4="Users03";function QI(t){const e=t.manifest?.blocks??{},s=[];for(const[n,i]of Object.entries(e))if(n.includes("matchers"))for(const o of Object.keys(i)){if(o.includes("always"))continue;const a=ci(o,t);s.push({resolveType:o,title:a.title??Tt(o),description:a.description,iconName:Tu(o,a.icon)})}return s}function ZI(t,e){if(!t)return I4;const s=e.find(n=>n.resolveType===t);return s?s.iconName:Tu(t)}function eM(t){const e=B.c(80),{currentRt:s,currentLabel:n,currentGlobalKey:i,matchers:o,globals:a,onSelect:l,onSelectGlobal:c}=t,d=a===void 0?[]:a,[h,u]=A.useState(!1),f=re(),p=(i?d.find(q=>q.blockKey===i):void 0)?.iconName??ZI(s,o),g=Oi(p);let x;e[0]!==l||e[1]!==u?(x=q=>{l(q),u(!1)},e[0]=l,e[1]=u,e[2]=x):x=e[2];const v=x;let b;e[3]!==c||e[4]!==u?(b=q=>{c?.(q),u(!1)},e[3]=c,e[4]=u,e[5]=b):b=e[5];const _=b;let y;e[6]!==u?(y=()=>u(!0),e[6]=u,e[7]=y):y=e[7];let L;e[8]!==g?(L=g&&r.jsx(g,{className:"h-4 w-4 shrink-0 text-muted-foreground"}),e[8]=g,e[9]=L):L=e[9];let w;e[10]!==n?(w=r.jsx("span",{className:"flex-1 truncate",children:n}),e[10]=n,e[11]=w):w=e[11];let j;e[12]===Symbol.for("react.memo_cache_sentinel")?(j=r.jsx(ss,{className:"h-3.5 w-3.5 shrink-0 text-muted-foreground"}),e[12]=j):j=e[12];let S;e[13]!==y||e[14]!==L||e[15]!==w?(S=r.jsxs("button",{type:"button",onClick:y,className:"flex h-10 w-full items-center gap-2 rounded-md border border-input bg-transparent px-3 text-left text-sm shadow-xs transition-colors hover:bg-accent/40 cursor-pointer",children:[L,w,j]}),e[13]=y,e[14]=L,e[15]=w,e[16]=S):S=e[16];let C;e[17]!==f?(C=f("sectionsEditor.matcherPicker.chooseRuleTitle"),e[17]=f,e[18]=C):C=e[18];let N;e[19]!==f?(N=f("sectionsEditor.matcherPicker.chooseRuleDescription"),e[19]=f,e[20]=N):N=e[20];let V;e[21]!==f?(V=f("sectionsEditor.matcherPicker.searchRulesPlaceholder"),e[21]=f,e[22]=V):V=e[22];let E;e[23]!==V?(E=r.jsx(Bi,{placeholder:V}),e[23]=V,e[24]=E):E=e[24];let T;e[25]!==f?(T=f("sectionsEditor.matcherPicker.noRulesFound"),e[25]=f,e[26]=T):T=e[26];let k;e[27]!==T?(k=r.jsx(Zn,{children:T}),e[27]=T,e[28]=k):k=e[28];let R;e[29]!==v?(R=()=>v(""),e[29]=v,e[30]=R):R=e[30];const P=!s&&!i&&"bg-accent/60";let D;e[31]!==P?(D=ie("gap-2.5",P),e[31]=P,e[32]=D):D=e[32];let I;e[33]===Symbol.for("react.memo_cache_sentinel")?(I=r.jsx(hd,{iconName:I4,size:"sm"}),e[33]=I):I=e[33];let M;e[34]!==f?(M=f("sectionsEditor.matcherPicker.alwaysLabel"),e[34]=f,e[35]=M):M=e[35];let O;e[36]!==M?(O=r.jsx("span",{className:"text-sm",children:M}),e[36]=M,e[37]=O):O=e[37];let F;e[38]!==f?(F=f("sectionsEditor.matcherPicker.targetAllUsers"),e[38]=f,e[39]=F):F=e[39];let $;e[40]!==F?($=r.jsx("span",{className:"text-xs text-muted-foreground",children:F}),e[40]=F,e[41]=$):$=e[41];let z;e[42]!==O||e[43]!==$?(z=r.jsxs("div",{className:"flex min-w-0 flex-1 flex-col",children:[O,$]}),e[42]=O,e[43]=$,e[44]=z):z=e[44];let K;e[45]!==R||e[46]!==D||e[47]!==z?(K=r.jsxs(Vs,{value:"always Target all users",onSelect:R,className:D,children:[I,z]}),e[45]=R,e[46]=D,e[47]=z,e[48]=K):K=e[48];let X;if(e[49]!==i||e[50]!==s||e[51]!==v||e[52]!==o){let q;e[54]!==i||e[55]!==s||e[56]!==v?(q=Z=>r.jsxs(Vs,{value:`${Z.title} ${Z.resolveType} ${Z.description??""}`,onSelect:()=>v(Z.resolveType),className:ie("gap-2.5",!i&&s===Z.resolveType&&"bg-accent/60"),children:[r.jsx(hd,{iconName:Z.iconName,size:"sm"}),r.jsxs("div",{className:"flex min-w-0 flex-1 flex-col",children:[r.jsx("span",{className:"text-sm",children:Z.title}),Z.description&&r.jsx("span",{className:"truncate text-xs text-muted-foreground",children:Z.description})]})]},Z.resolveType),e[54]=i,e[55]=s,e[56]=v,e[57]=q):q=e[57],X=o.map(q),e[49]=i,e[50]=s,e[51]=v,e[52]=o,e[53]=X}else X=e[53];let J;e[58]!==K||e[59]!==X?(J=r.jsxs(Ms,{children:[K,X]}),e[58]=K,e[59]=X,e[60]=J):J=e[60];let H;e[61]!==i||e[62]!==d||e[63]!==_||e[64]!==f?(H=d.length>0&&r.jsx(Ms,{heading:f("sectionsEditor.matcherPicker.savedRulesHeading"),children:d.map(q=>r.jsxs(Vs,{value:`${q.title} ${q.blockKey} ${q.description??""}`,onSelect:()=>_(q.blockKey),className:ie("gap-2.5",i===q.blockKey&&"bg-accent/60"),children:[r.jsx(hd,{iconName:q.iconName,size:"sm"}),r.jsxs("div",{className:"flex min-w-0 flex-1 flex-col",children:[r.jsx("span",{className:"truncate text-sm",children:q.title}),q.description&&r.jsx("span",{className:"truncate text-xs text-muted-foreground",children:q.description})]})]},q.blockKey))}),e[61]=i,e[62]=d,e[63]=_,e[64]=f,e[65]=H):H=e[65];let W;e[66]!==k||e[67]!==J||e[68]!==H?(W=r.jsxs(Fi,{children:[k,J,H]}),e[66]=k,e[67]=J,e[68]=H,e[69]=W):W=e[69];let U;e[70]!==h||e[71]!==u||e[72]!==N||e[73]!==E||e[74]!==W||e[75]!==C?(U=r.jsxs($6,{open:h,onOpenChange:u,title:C,description:N,className:"sm:max-w-lg",children:[E,W]}),e[70]=h,e[71]=u,e[72]=N,e[73]=E,e[74]=W,e[75]=C,e[76]=U):U=e[76];let Q;return e[77]!==U||e[78]!==S?(Q=r.jsxs(r.Fragment,{children:[S,U]}),e[77]=U,e[78]=S,e[79]=Q):Q=e[79],Q}function tM(t){if(!t||typeof t!="object")return!1;const e=t;return typeof e.__resolveType=="string"&&Array.isArray(e.variants)}function sM(t,e){return{__resolveType:e,variants:[{rule:br(),value:structuredClone(t)},{rule:br(),value:structuredClone(t)}]}}function nM(t){const e=t.variants;if(e.length===0)return;const s=e.find(n=>pu(n.rule));return s?s.value:e[e.length-1]?.value}function iM(t){const e=[...t.variants],s=e[e.length-1],n={rule:br(),value:s?structuredClone(s.value):void 0};return{...t,variants:[...e,n]}}function rM(t,e){if(t.variants.length<=1)return null;const s=[...t.variants];return s.splice(e,1),{...t,variants:s}}function oM(t,e){const s=[...t.variants],n=s[e];return n?(s.splice(e+1,0,structuredClone(n)),{...t,variants:s}):t}function aM(t,e,s){const n=[...t.variants];if(e===s||e<0||s<0||e>=n.length||s>=n.length)return t;const[i]=n.splice(e,1);return i?(n.splice(s,0,i),{...t,variants:n}):t}function lM(t,e,s){const n=[...t.variants],i=n[e];return i?(n[e]={...i,value:s},{...t,variants:n}):t}function Zf(t,e,s){const n=[...t.variants],i=n[e];return i?(n[e]={...i,rule:s},{...t,variants:n}):t}const e1=new WeakMap,t1=new Map;function cM(t){let e=e1.get(t);return e||(e=QI(t),e1.set(t,e)),e}function dM(t,e){let s=t1.get(t);return s===void 0&&(s=_n(t,e),t1.set(t,s)),s}function M4(t){const e=B.c(10),{multivariateResolveType:s,renderInnerField:n,...i}=t,o=re(),{value:a,onChange:l,meta:c,path:d}=i,[h,u]=A.useState(0);if(!tM(a)){let M;e[0]!==o?(M=o("sectionsEditor.multivariateFieldWrapper.addVariant"),e[0]=o,e[1]=M):M=e[1];let O;e[2]===Symbol.for("react.memo_cache_sentinel")?(O=r.jsx(_9,{size:14}),e[2]=O):O=e[2];let F;e[3]!==o?(F=o("sectionsEditor.multivariateFieldWrapper.addVariant"),e[3]=o,e[4]=F):F=e[4];let $;return e[5]!==F?($=r.jsx(Ue,{children:F}),e[5]=F,e[6]=$):$=e[6],r.jsxs("div",{className:"relative grid w-full min-w-0 grid-cols-[minmax(0,1fr)] gap-2",children:[r.jsxs(He,{children:[r.jsx(Ke,{asChild:!0,children:r.jsx(le,{type:"button",variant:"ghost",size:"icon",className:"absolute right-0 top-0 size-6 text-muted-foreground hover:text-foreground","aria-label":M,onClick:()=>{l(sM(a,s)),u(0)},children:O})}),$]}),n(i)]})}const f=a,m=f.variants,p=Math.min(h,m.length-1);let g;e[7]!==o?(g=(M,O)=>({index:O,label:Ol(M.rule)||o("sectionsEditor.multivariateFieldWrapper.variantN",{n:String(O+1)})}),e[7]=o,e[8]=g):g=e[8];const x=m.map(g),v=m[p],b=v?.rule??{},_=b.__resolveType??"",y=v?.value,L=c?cM(c):[],w=_&&c?dM(_,c):null,{__resolveType:j,...S}=b,C=()=>{l(nM(f)),u(0)},N=()=>{const M=iM(f);l(M),u(M.variants.length-1)},V=M=>{const O=rM(f,M);O&&(l(O),p>=O.variants.length&&u(O.variants.length-1))},E=M=>{const O=oM(f,M);l(O),u(M+1)},T=(M,O)=>{const F=aM(f,M,O);l(F),p===M&&u(O)},k=M=>{l(Zf(f,p,M?{__resolveType:M}:{__resolveType:Ip}))},R=M=>{const O=M,F=_?{...O,__resolveType:_}:{...O};l(Zf(f,p,F))},P=M=>{l(lM(f,p,M))},D=`${d}-${f.__resolveType}`;let I;return e[9]===Symbol.for("react.memo_cache_sentinel")?(I=r.jsx(lt,{className:"text-xs text-muted-foreground",children:"Rule"}),e[9]=I):I=e[9],r.jsxs("div",{className:"grid w-full min-w-0 grid-cols-[minmax(0,1fr)] gap-0",children:[r.jsx(UI,{listKey:D,variants:x,selectedIndex:p,onSelect:u,onDuplicate:E,onDelete:V,onRemoveAll:C,onReorder:T,onAdd:N}),r.jsxs("div",{className:"space-y-4 px-2 pt-3",children:[r.jsxs("div",{className:"space-y-1.5",children:[I,r.jsx(eM,{currentRt:_,currentLabel:Ol(b),matchers:L,onSelect:k}),w&&r.jsx("div",{className:"pt-1",children:r.jsx(In,{schema:w,value:S,onChange:R,basePath:""})})]}),n({...i,value:y,onChange:P})]})]})}const uM="website/loaders/secret.ts";function Vo(t){if(!t||typeof t!="object"||Array.isArray(t))return!1;const e=t.__resolveType;return typeof e=="string"&&(e.endsWith("/secret.ts")||e.includes("loaders/secret"))}function hM(){return{__resolveType:uM,name:"",encrypted:""}}function fM(t){const{value:e,...s}=t;return s}function fd(t){const e=B.c(55),{schema:s,value:n,onChange:i,label:o,path:a}=t,l=re();if(typeof n=="string"||n==null&&!Vo(n)){const C=typeof n=="string"?n:"";let N;e[0]!==o||e[1]!==a?(N=r.jsx(lt,{htmlFor:a,className:"text-sm font-medium",children:o}),e[0]=o,e[1]=a,e[2]=N):N=e[2];let V;e[3]!==s.description?(V=s.description&&r.jsx("p",{className:"text-xs text-muted-foreground",children:s.description}),e[3]=s.description,e[4]=V):V=e[4];let E;e[5]!==l?(E=l("sectionsEditor.secretField.secretValuePlaceholder"),e[5]=l,e[6]=E):E=e[6];let T;e[7]!==i?(T=P=>i(P.target.value),e[7]=i,e[8]=T):T=e[8];let k;e[9]!==a||e[10]!==C||e[11]!==E||e[12]!==T?(k=r.jsx(rt,{id:a,type:"password",value:C,autoComplete:"new-password",autoCorrect:"off",spellCheck:!1,placeholder:E,onChange:T,className:"h-10"}),e[9]=a,e[10]=C,e[11]=E,e[12]=T,e[13]=k):k=e[13];let R;return e[14]!==N||e[15]!==V||e[16]!==k?(R=r.jsxs("div",{className:"space-y-2",children:[N,V,k]}),e[14]=N,e[15]=V,e[16]=k,e[17]=R):R=e[17],R}let c;e[18]!==n?(c=Vo(n)?n:hM(),e[18]=n,e[19]=c):c=e[19];const d=c,h=typeof d.name=="string"?d.name:"",u=typeof d.encrypted=="string"&&d.encrypted,f=`${a}-name`;let m;e[20]!==o||e[21]!==f?(m=r.jsx(lt,{htmlFor:f,className:"text-sm font-medium",children:o}),e[20]=o,e[21]=f,e[22]=m):m=e[22];let p;e[23]!==s.description?(p=s.description&&r.jsx("p",{className:"text-xs text-muted-foreground",children:s.description}),e[23]=s.description,e[24]=p):p=e[24];const g=`${a}-name`;let x;e[25]!==l?(x=l("sectionsEditor.secretField.secretNamePlaceholder"),e[25]=l,e[26]=x):x=e[26];let v;e[27]!==d||e[28]!==i?(v=C=>i({...d,name:C.target.value}),e[27]=d,e[28]=i,e[29]=v):v=e[29];let b;e[30]!==h||e[31]!==g||e[32]!==x||e[33]!==v?(b=r.jsx(rt,{id:g,value:h,placeholder:x,onChange:v,className:"h-10"}),e[30]=h,e[31]=g,e[32]=x,e[33]=v,e[34]=b):b=e[34];const _=`${a}-value`;let y;e[35]!==u||e[36]!==l?(y=l(u?"sectionsEditor.secretField.leaveBlankPlaceholder":"sectionsEditor.secretField.secretValuePlaceholder"),e[35]=u,e[36]=l,e[37]=y):y=e[37];let L;e[38]!==d||e[39]!==u||e[40]!==i?(L=C=>{const N=C.target.value;if(!N){i(u?fM(d):d);return}i({...d,value:N})},e[38]=d,e[39]=u,e[40]=i,e[41]=L):L=e[41];let w;e[42]!==y||e[43]!==L||e[44]!==_?(w=r.jsx(rt,{id:_,type:"password",autoComplete:"new-password",autoCorrect:"off",spellCheck:!1,placeholder:y,onChange:L,className:"h-10"}),e[42]=y,e[43]=L,e[44]=_,e[45]=w):w=e[45];let j;e[46]!==u||e[47]!==l?(j=u&&r.jsx("p",{className:"text-xs text-muted-foreground",children:l("sectionsEditor.secretField.storedSecretMessage")}),e[46]=u,e[47]=l,e[48]=j):j=e[48];let S;return e[49]!==w||e[50]!==j||e[51]!==m||e[52]!==p||e[53]!==b?(S=r.jsxs("div",{className:"space-y-2",children:[m,p,b,w,j]}),e[49]=w,e[50]=j,e[51]=m,e[52]=p,e[53]=b,e[54]=S):S=e[54],S}function mM(t,e){const s=t.anyOfRefs;if(!s?.length)return;const n=e.find(d=>d!=null&&typeof d=="object"&&!Array.isArray(d)),i=n?Object.keys(n).filter(d=>!d.startsWith("__")):[],o=[],a=d=>{d?.type==="object"&&d.properties&&o.push(d)};for(const d of s){const h=d.schema;if(h&&(h.type==="array"&&a(h.items),h.properties))for(const u of Object.values(h.properties))u?.type==="array"&&a(u.items)}if(o.length===0)return;if(i.length===0)return o.length===1?o[0]:void 0;let l,c=-1;for(const d of o){const h=d.properties??{},u=i.filter(f=>f in h).length*2+(d.titleBy?1:0);u>c&&(c=u,l=d)}return c>=2?l:void 0}function pM(t){const e=t.length>0?t[0]:void 0;if(e==null||typeof e!="object"||Array.isArray(e))return;const s={};for(const[n,i]of Object.entries(e))n.startsWith("__")||(typeof i=="string"?s[n]={type:"string"}:typeof i=="number"?s[n]={type:"number"}:typeof i=="boolean"&&(s[n]={type:"boolean"}));return Object.keys(s).length>0?{type:"object",properties:s}:void 0}const gM=new Set(["__resolveType","@type"]);function xM(t){if(t.type!=="block-ref"||!t.anyOfRefs?.length||t.anyOfRefs.length!==1)return!1;const e=t.anyOfRefs[0].schema;return!!(e?.properties?.variants||!e&&t.plainSchema)}function vM(t){if(jc(t))for(const e of t.anyOfRefs??[]){const i=e.schema?.properties?.variants?.items?.properties?.value;if(i?.type==="array"&&i.items)return i.items}}function s1(t){if(t.type==="array"&&t.items)return t;const e=t.items??vM(t);return e?{...t,type:"array",items:e}:null}function bM(t,e){if(e!==void 0)return e;switch(t){case"string":return"";case"number":case"integer":return 0;case"boolean":return!1;case"array":return[];case"object":return{};default:return null}}function qo(t){const{schema:e,value:s}=t;if(Dl(s)){const a=EA(s),l=s1(e);if(a!==null&&l)return r.jsx(Da,{...t,schema:l,value:a,onChange:c=>t.onChange(PA(s,c))},t.path)}if(Array.isArray(s)&&e.type==="block-ref"&&jc(e)){const a=s1(e);if(a)return r.jsx(Da,{...t,schema:a,value:s,onChange:t.onChange},t.path)}if(Array.isArray(s)&&!Dl(s)&&e.type==="block-ref"){const a=mM(e,s)??pM(s);if(a){const l={...e,type:"array",items:a};return r.jsx(Da,{...t,schema:l,value:s,onChange:t.onChange},t.path)}}if(e.type==="block-ref"||s!==null&&typeof s=="object"&&!Array.isArray(s)&&typeof s.__resolveType=="string"&&e.anyOfRefs){if(xM(e)){const a=e.anyOfRefs[0],l=a.schema?.properties?.variants?.items?.properties?.value,c=l&&l.type!=="block-ref"?l:e.plainSchema??l?.plainSchema??{type:"string"},d=h=>qo({...h,schema:c});return r.jsx(M4,{...t,multivariateResolveType:a.resolveType,renderInnerField:d},t.path)}return e.anyOfRefs?r.jsx(Uf,{...t},t.path):null}if(e.type==="inline-union")return r.jsx(TI,{...t},t.path);if(e.format==="image-uri")return r.jsx(pI,{...t},t.path);if(e.format==="file-uri"||e.format==="video-uri")return r.jsx(hI,{...t},t.path);if(e.format==="map")return r.jsx(II,{...t},t.path);if(e.format==="icon-select"||e.format==="dynamic-options"&&e.options)return r.jsx($D,{...t},t.path);if(e.format==="location")return r.jsx(P4,{...t},t.path);if(e.enum&&e.enum.length>0)return r.jsx($R,{...t},t.path);if(e.type==="anyOf")return r.jsx(Uf,{...t},t.path);if(Vo(s)||e.format==="password"||s==null&&e.format==="password")return r.jsx(fd,{...t},t.path);const n=s??bM(e.type,e.default);if(n==null)return Vo(s)?r.jsx(fd,{...t},t.path):null;if(Vo(n))return r.jsx(fd,{...t,value:n},t.path);const i={...t,value:n},o=s==null?e.type??typeof n:Array.isArray(n)?"array":typeof n;if(o==="array"||Array.isArray(n))return r.jsx(Da,{...i},t.path);switch(o){case"boolean":return r.jsx(DR,{...i},t.path);case"number":case"integer":return r.jsx(RR,{...i},t.path);case"string":{const a=e.format;return a==="color-input"||a==="color"?r.jsx(Pa,{...i},t.path):a==="textarea"||a==="rich-text"||a==="html"?r.jsx(Pa,{...i},t.path):r.jsx(Pa,{...i},t.path)}case"object":return n!==null&&typeof n=="object"&&!Array.isArray(n)?r.jsx(yD,{...i},t.path):null;default:return r.jsx(Pa,{...i},t.path)}}function yM(t,e){if(e&&(e.type==="block-ref"||e.anyOfRefs||e.properties))return qo({...t,schema:e});const s=t.value;if(s&&typeof s=="object"&&!Array.isArray(s)&&typeof s.__resolveType=="string"&&t.meta){const n=_n(s.__resolveType,t.meta);if(n)return r.jsx(In,{schema:n,value:s,onChange:t.onChange,basePath:t.path,breadcrumbPath:t.breadcrumbPath,onBreadcrumbChange:t.onBreadcrumbChange,meta:t.meta,decofile:t.decofile,onSaveReferencedBlock:t.onSaveReferencedBlock,sandbox:t.sandbox})}return qo(e?{...t,schema:e}:t)}function In(t){const e=B.c(18),{schema:s,value:n,onChange:i,basePath:o,breadcrumbPath:a,onBreadcrumbChange:l,meta:c,decofile:d,onSaveReferencedBlock:h,previewBaseUrl:u,onAddSectionItem:f,onRequestAddSection:m,sandbox:p}=t;let g,x;if(e[0]!==o||e[1]!==d||e[2]!==c||e[3]!==f||e[4]!==l||e[5]!==i||e[6]!==m||e[7]!==h||e[8]!==u||e[9]!==p||e[10]!==s||e[11]!==a||e[12]!==n){x=Symbol.for("react.early_return_sentinel");e:{const v=a===void 0?[]:a,b=s.properties;if(!b){x=null;break e}if(AA(n)&&b.variants){const k=b.variants.items?.properties?.value;let R;e[15]!==k?(R=P=>yM(P,k),e[15]=k,e[16]=R):R=e[16],x=r.jsx(M4,{schema:s,value:n,onChange:i,path:o,label:s.title??"",breadcrumbPath:v,onBreadcrumbChange:l,meta:c,decofile:d,onSaveReferencedBlock:h,previewBaseUrl:u,onAddSectionItem:f,onRequestAddSection:m,sandbox:p,multivariateResolveType:n.__resolveType,renderInnerField:R},o);break e}const _=n!=null&&typeof n=="object"&&!Array.isArray(n)?n:{},y=Object.keys(b).filter(k=>!gM.has(k)&&b[k]?.hidden!==!0);if(y.length===0){let k;e[17]===Symbol.for("react.memo_cache_sentinel")?(k=r.jsx("div",{className:"px-3 py-6 text-center text-xs text-muted-foreground",children:"No editable fields on this section."}),e[17]=k):k=e[17],x=k;break e}const L=(k,R)=>{i({..._,[k]:R})},w=typeof _.__resolveType=="string"?_.__resolveType:void 0,j=y.filter(k=>{const R=b[k];return R!=null&&i0(R,_[k])}).length>1,S=v.length>0?nD(y,b,_,v):null,C=S?b[S]:null,N=S&&C?[S]:y,V=S&&C?tD(S,C,v):v,E=eD(v,V),T=E.length>0&&l?k=>l([...E,...k]):l;g=r.jsx("div",{className:"min-w-0 space-y-6",children:N.map(k=>{const R=b[k];if(!R)return null;const P=o?`${o}.${k}`:k,D=ko(k,R);return qo({schema:R,value:_[k],onChange:I=>L(k,I),path:P,label:D,breadcrumbPath:V,onBreadcrumbChange:T,hasSiblingDrillDownFields:j,meta:c,decofile:d,onSaveReferencedBlock:h,containerResolveType:w,previewBaseUrl:u,onAddSectionItem:f,onRequestAddSection:m,sandbox:p})})})}e[0]=o,e[1]=d,e[2]=c,e[3]=f,e[4]=l,e[5]=i,e[6]=m,e[7]=h,e[8]=u,e[9]=p,e[10]=s,e[11]=a,e[12]=n,e[13]=g,e[14]=x}else g=e[13],x=e[14];return x!==Symbol.for("react.early_return_sentinel")?x:g}function _M(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=r.jsxs("span",{className:"flex items-center gap-1.5 text-xs text-destructive",children:[r.jsx(wn,{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=r.jsxs("span",{className:"flex items-center gap-1.5 text-xs text-muted-foreground",children:[r.jsx(et,{size:13,className:"animate-spin"}),"Saving…"]}),e[1]=o):o=e[1],o}let i;return e[2]===Symbol.for("react.memo_cache_sentinel")?(i=r.jsxs("span",{className:"flex items-center gap-1.5 text-xs text-muted-foreground/70",children:[r.jsx(zt,{size:13}),"Saved"]}),e[2]=i):i=e[2],i}function LM({orgSlug:t,virtualMcpId:e,branch:s,previewUrl:n,meta:i,decofile:o,kind:a,target:l,initialValue:c,isCreating:d,onCreate:h,onSaveReferencedBlock:u,onBack:f}){const m=re(),p=di(),g=p?.entity?.id===e?p.entity.metadata?.siteSlug??null:null,x=_n(l.resolveType,i),v=!x&&lw(l.resolveType,i),b=v?cw(c):null,_=x??b,[y,L]=A.useState(c),[w,j]=A.useState([]),[S,C]=A.useState(0),[N,V]=A.useState(!1),[E,T]=A.useState(null),[k,R]=A.useState(!1),[P,D]=A.useState(!1),[I,M]=A.useState(!1),O=E!==null,{save:F,flush:$,isPending:z}=Cg({orgSlug:t,virtualMcpId:e,branch:s}),K=jE({orgSlug:t,virtualMcpId:e,branch:s});A.useEffect(()=>()=>{$()},[]);const X=qg(a),J=l.resolveType.split("/").pop()?.replace(/\.tsx?$/,"")??l.resolveType,H={orgSlug:t,virtualMcpId:e,branch:s,previewUrl:n??void 0,siteSlug:g},W=te=>{L(te),l.mode==="saved"&&F(l.blockKey,{__resolveType:l.resolveType,...te})},U=()=>{O?(T(null),V(!1),C(te=>te+1)):T(JSON.stringify(y,null,2))},Q=te=>{const se=te??"";try{const ne=JSON.parse(se);if(ne&&typeof ne=="object"&&!Array.isArray(ne)){V(!1),W(ne);return}V(!0)}catch{V(!0)}},q=async te=>{const se=Cu(te,o);if(se){ge.error(se);return}await h(te,{__resolveType:l.resolveType,...y}),R(!1)},Z=()=>{D(!0),K.mutate({resolveType:l.resolveType,props:y})},Y=()=>{n&&window.open(SE(n,l.resolveType,y,Date.now()),"_blank","noopener")},ee=[l.title,...w],G=te=>{j(w.slice(0,te)),C(se=>se+1)};return r.jsxs("div",{className:"flex h-full w-full min-w-0 flex-col",children:[r.jsxs("div",{className:"shrink-0 border-b px-3 py-2.5",children:[r.jsxs("div",{className:"flex min-w-0 items-center gap-2 overflow-hidden",children:[f&&r.jsx(le,{variant:"ghost",size:"icon",className:"size-8 shrink-0",onClick:f,"aria-label":m("sandbox.runnableBlockEditor.backToList"),children:r.jsx(Xl,{size:14})}),r.jsx("nav",{"aria-label":m("sandbox.runnableBlockEditor.editingBreadcrumb"),className:"flex min-w-0 flex-1 items-center gap-1 overflow-hidden text-sm",children:ee.map((te,se)=>{const ne=se===ee.length-1;return r.jsxs("span",{className:"flex min-w-0 items-center gap-1 overflow-hidden",children:[se>0&&r.jsx(bn,{className:"size-3 shrink-0 text-muted-foreground/60"}),r.jsx("button",{type:"button",onClick:()=>G(se),title:te,className:ie("min-w-0 truncate rounded-md px-1 py-0.5 text-left transition-colors hover:bg-accent hover:text-accent-foreground",ne?"font-medium text-foreground":"text-muted-foreground"),children:te})]},`${te}-${se}`)})}),l.mode==="saved"&&r.jsx(_M,{isPending:z,isError:!1}),r.jsxs(le,{size:"sm",variant:"outline",className:"h-8 shrink-0 gap-1.5",onClick:Z,disabled:K.isPending,"aria-label":m("sandbox.runnableBlockEditor.runAriaLabel",{singular:X}),children:[K.isPending?r.jsx(et,{size:14,className:"animate-spin"}):r.jsx(Vi,{size:14}),m("sandbox.runnableBlockEditor.run")]}),l.mode==="available"&&r.jsxs(He,{children:[r.jsx(Ke,{asChild:!0,children:r.jsx(le,{size:"icon",className:"size-8 shrink-0",disabled:d,onClick:()=>R(!0),"aria-label":m("sandbox.runnableBlockEditor.saveAsGlobalAriaLabel",{singular:X}),children:r.jsx(s9,{size:14})})}),r.jsx(Ue,{side:"bottom",children:m("sandbox.runnableBlockEditor.saveAsGlobal",{singular:X})})]}),r.jsxs(He,{children:[r.jsx(Ke,{asChild:!0,children:r.jsx(le,{variant:O?"default":"ghost",size:"icon",className:"size-8 shrink-0",onClick:U,"aria-label":m(O?"sandbox.runnableBlockEditor.closeJsonEditor":"sandbox.runnableBlockEditor.editAsJson"),"aria-pressed":O,children:O?r.jsx(ks,{size:14}):r.jsx(sa,{size:14})})}),r.jsx(Ue,{side:"bottom",children:m(O?"sandbox.runnableBlockEditor.closeJsonEditor":"sandbox.runnableBlockEditor.editAsJson")})]})]}),r.jsx("p",{className:"mt-1.5 py-1 pl-1 text-sm leading-snug text-muted-foreground",children:l.mode==="saved"?m("sandbox.runnableBlockEditor.savedModeDescription",{singular:X}):m("sandbox.runnableBlockEditor.availableModeDescription",{typeLabel:J,singular:X})})]}),r.jsxs("div",{className:"flex min-h-0 flex-1 flex-col",children:[r.jsxs("div",{className:ie("relative min-h-0 flex-1",P&&I&&"hidden"),children:[r.jsx(ri,{className:"h-full [&_[data-slot=scroll-area-viewport]>div]:!block",children:r.jsx("div",{className:"min-w-0 max-w-full overflow-x-hidden px-6 py-4",children:r.jsxs("div",{className:"mx-auto max-w-2xl",children:[b&&_===b&&r.jsx("p",{className:"mb-3 rounded-md bg-muted px-3 py-2 text-xs leading-snug text-muted-foreground",children:m("sandbox.runnableBlockEditor.inferredSchemaNotice",{singular:X})}),_?r.jsx(In,{schema:_,value:y,onChange:te=>W(te),basePath:"",breadcrumbPath:w,onBreadcrumbChange:j,meta:i,decofile:o,onSaveReferencedBlock:u,sandbox:H},S):r.jsx("div",{className:"px-3 py-6 text-center text-xs text-muted-foreground",children:v?m("sandbox.runnableBlockEditor.freeformPropsEmptyState",{singular:X}):m("sandbox.runnableBlockEditor.noInputEmptyState",{singular:X})})]})})}),E!==null&&r.jsxs("div",{className:"absolute inset-0 flex flex-col bg-background",children:[N&&r.jsx("div",{className:"shrink-0 border-b bg-destructive/10 px-3 py-1.5 text-xs text-destructive",children:m("sandbox.runnableBlockEditor.invalidJsonError")}),r.jsx("div",{className:"min-h-0 flex-1",children:r.jsx(aa,{language:"json",height:"100%",code:E,onChange:Q,onSave:te=>{Q(te),$()}})})]})]}),P&&r.jsx(SM,{singular:X,result:{isPending:K.isPending,error:K.error,data:K.data,hasRun:K.status!=="idle"},expanded:I,onToggleExpand:()=>M(te=>!te),onOpenInNewTab:n?Y:void 0,onClose:()=>{D(!1),M(!1)}})]}),r.jsx(ku,{open:k,onOpenChange:R,defaultBlockId:"",isPending:d,onSubmit:q})]})}function SM(t){const e=B.c(54),{singular:s,result:n,expanded:i,onToggleExpand:o,onOpenInNewTab:a,onClose:l}=t,c=re();let d;e[0]!==n.data?(d=typeof n.data=="string"?n.data:JSON.stringify(n.data??null,null,2),e[0]=n.data,e[1]=d):d=e[1];const h=d,u=i?"flex-1":"h-[45%] shrink-0";let f;e[2]!==u?(f=ie("flex min-h-0 flex-col border-t",u),e[2]=u,e[3]=f):f=e[3];let m;e[4]!==c?(m=c("sandbox.runnableBlockEditor.resultPanelTitle"),e[4]=c,e[5]=m):m=e[5];let p;e[6]!==m?(p=r.jsx("span",{className:"text-xs font-medium text-muted-foreground",children:m}),e[6]=m,e[7]=p):p=e[7];let g;e[8]!==a||e[9]!==s||e[10]!==c?(g=a&&r.jsxs(He,{children:[r.jsx(Ke,{asChild:!0,children:r.jsx(le,{variant:"ghost",size:"icon",className:"size-7",onClick:a,"aria-label":c("sandbox.runnableBlockEditor.openResultInNewTabAriaLabel"),children:r.jsx(Dn,{size:14})})}),r.jsx(Ue,{side:"bottom",children:c("sandbox.runnableBlockEditor.openInNewTabTooltip",{singular:s})})]}),e[8]=a,e[9]=s,e[10]=c,e[11]=g):g=e[11];let x;e[12]!==i||e[13]!==c?(x=c(i?"sandbox.runnableBlockEditor.collapseResult":"sandbox.runnableBlockEditor.expandResult"),e[12]=i,e[13]=c,e[14]=x):x=e[14];let v;e[15]!==i?(v=i?r.jsx(x6,{size:14}):r.jsx(Gm,{size:14}),e[15]=i,e[16]=v):v=e[16];let b;e[17]!==i||e[18]!==o||e[19]!==x||e[20]!==v?(b=r.jsx(Ke,{asChild:!0,children:r.jsx(le,{variant:"ghost",size:"icon",className:"size-7",onClick:o,"aria-label":x,"aria-pressed":i,children:v})}),e[17]=i,e[18]=o,e[19]=x,e[20]=v,e[21]=b):b=e[21];let _;e[22]!==i||e[23]!==c?(_=c(i?"sandbox.runnableBlockEditor.collapse":"sandbox.runnableBlockEditor.expand"),e[22]=i,e[23]=c,e[24]=_):_=e[24];let y;e[25]!==_?(y=r.jsx(Ue,{side:"bottom",children:_}),e[25]=_,e[26]=y):y=e[26];let L;e[27]!==y||e[28]!==b?(L=r.jsxs(He,{children:[b,y]}),e[27]=y,e[28]=b,e[29]=L):L=e[29];let w;e[30]!==c?(w=c("sandbox.runnableBlockEditor.closeResult"),e[30]=c,e[31]=w):w=e[31];let j;e[32]===Symbol.for("react.memo_cache_sentinel")?(j=r.jsx(ks,{size:14}),e[32]=j):j=e[32];let S;e[33]!==l||e[34]!==w?(S=r.jsx(le,{variant:"ghost",size:"icon",className:"size-7",onClick:l,"aria-label":w,children:j}),e[33]=l,e[34]=w,e[35]=S):S=e[35];let C;e[36]!==L||e[37]!==S||e[38]!==g?(C=r.jsxs("div",{className:"flex items-center gap-0.5",children:[g,L,S]}),e[36]=L,e[37]=S,e[38]=g,e[39]=C):C=e[39];let N;e[40]!==C||e[41]!==p?(N=r.jsxs("div",{className:"flex h-9 shrink-0 items-center justify-between border-b px-3",children:[p,C]}),e[40]=C,e[41]=p,e[42]=N):N=e[42];let V;e[43]!==n.error||e[44]!==n.hasRun||e[45]!==n.isPending||e[46]!==h||e[47]!==s||e[48]!==c?(V=r.jsx("div",{className:"min-h-0 flex-1",children:n.isPending?r.jsxs("div",{className:"flex h-full items-center justify-center gap-2 text-xs text-muted-foreground",children:[r.jsx(et,{size:16,className:"animate-spin"}),c("sandbox.runnableBlockEditor.running",{singular:s})]}):n.error?r.jsxs("div",{className:"h-full overflow-auto px-4 py-3",children:[r.jsx("p",{className:"text-xs font-medium text-destructive",children:c("sandbox.runnableBlockEditor.failedToRun",{singular:s})}),r.jsx("pre",{className:"mt-1 whitespace-pre-wrap break-words text-xs text-destructive/90",children:n.error.message})]}):n.hasRun?r.jsx(aa,{language:"json",height:"100%",code:h,readOnly:!0}):r.jsx("div",{className:"flex h-full items-center justify-center text-xs text-muted-foreground",children:c("sandbox.runnableBlockEditor.pressRunToInvoke",{singular:s})})}),e[43]=n.error,e[44]=n.hasRun,e[45]=n.isPending,e[46]=h,e[47]=s,e[48]=c,e[49]=V):V=e[49];let E;return e[50]!==N||e[51]!==V||e[52]!==f?(E=r.jsxs("div",{className:f,children:[N,V]}),e[50]=N,e[51]=V,e[52]=f,e[53]=E):E=e[53],E}const wM={loaders:ol,actions:Ni},jM={loaders:"Loaders",actions:"Actions"},CM={analytics:Hb,blog:fr,commerce:y9,site:jb,website:li};function kM(t,e){return e===0?CM[t.toLowerCase()]??ei:ei}function Ma(t,e){return e===0?YE(t):t}function VM(t){const e=B.c(98),{orgSlug:s,virtualMcpId:n,branch:i,previewUrl:o,meta:a,decofile:l,kind:c}=t,d=re();let h;e[0]===Symbol.for("react.memo_cache_sentinel")?(h=[],e[0]=h):h=e[0];const[u,f]=A.useState(h),[m,p]=A.useState(null),[g,x]=A.useState(""),[v,b]=A.useState(IM),[_,y]=A.useState(c);_!==c&&(y(c),f([]),p(null),x(""),b(new Set));let L;e[1]===Symbol.for("react.memo_cache_sentinel")?(L=K=>{b(X=>{const J=new Set(X);return J.has(K)?J.delete(K):J.add(K),J})},e[1]=L):L=e[1];const w=L;let j;e[2]!==i||e[3]!==s||e[4]!==n?(j={orgSlug:s,virtualMcpId:n,branch:i},e[2]=i,e[3]=s,e[4]=n,e[5]=j):j=e[5];const S=wc(j);let C;e[6]!==S?(C=s4((K,X)=>S.mutate({blockKey:K,data:X})),e[6]=S,e[7]=C):C=e[7];const N=C;let V;e[8]!==c?(V=qg(c),e[8]=c,e[9]=V):V=e[9];const E=V,T=wM[c];let k,R,P,D,I,M,O;if(e[10]!==T||e[11]!==i||e[12]!==l||e[13]!==c||e[14]!==a||e[15]!==v||e[16]!==s||e[17]!==u||e[18]!==o||e[19]!==S||e[20]!==N||e[21]!==g||e[22]!==m||e[23]!==E||e[24]!==d||e[25]!==n){P=Symbol.for("react.early_return_sentinel");e:{const K=[...JE(a,l,c).map(DM),...Gg(a,c).map(RM)],X=g.trim().toLowerCase(),J=X.length>0,H=J?K.filter(be=>be.title.toLowerCase().includes(X)||be.resolveType.toLowerCase().includes(X)):[],W=new Map,U=[],Q=new Map;if(!J){for(const be of K){const Ve=be.folderPath;if(!(Ve.length<u.length)&&u.every((Re,Le)=>Ve[Le]===Re))if(Ve.length===u.length)if(be.savedKey!==void 0){const Re=Q.get(be.resolveType);Re?Re.push(be):Q.set(be.resolveType,[be])}else U.push(be);else{const Re=Ve[u.length],Le=W.get(Re)??{count:0,savedCount:0};be.savedKey!==void 0?Le.savedCount=Le.savedCount+1:Le.count=Le.count+1,W.set(Re,Le)}}U.sort(PM);for(const be of Q.values())be.sort(EM)}const q=[...Q.entries()].filter(be=>{const[Ve]=be;return!U.some(Re=>Re.resolveType===Ve)}).flatMap(AM).sort(TM);let Z;e[33]!==u?(Z=(be,Ve)=>Ma(be.name,u.length).localeCompare(Ma(Ve.name,u.length)),e[33]=u,e[34]=Z):Z=e[34];const Y=[...W.entries()].map(NM).sort(Z);let ee;e[35]===Symbol.for("react.memo_cache_sentinel")?(ee=be=>{p(be.savedKey!==void 0?{mode:"saved",key:be.savedKey}:{mode:"available",resolveType:be.resolveType,title:be.title})},e[35]=ee):ee=e[35];const G=ee;let te;e[36]!==S||e[37]!==E||e[38]!==d?(te=async(be,Ve)=>{await S.mutateAsync({blockKey:be,data:Ve}),ge.success(d("sandbox.runnableBlocksBrowser.savedBlockToast",{singular:E,blockId:be})),p({mode:"saved",key:be})},e[36]=S,e[37]=E,e[38]=d,e[39]=te):te=e[39];const se=te;let ne;e[40]!==l||e[41]!==m?(ne=MM(m,l),e[40]=l,e[41]=m,e[42]=ne):ne=e[42];const de=ne;if(de){const be=`${de.mode}:${de.mode==="saved"?de.blockKey:de.resolveType}`;let Ve;e[43]===Symbol.for("react.memo_cache_sentinel")?(Ve=()=>p(null),e[43]=Ve):Ve=e[43];let Re;e[44]!==i||e[45]!==l||e[46]!==se||e[47]!==c||e[48]!==a||e[49]!==s||e[50]!==o||e[51]!==S.isPending||e[52]!==N||e[53]!==be||e[54]!==de.editorTarget||e[55]!==de.initialValue||e[56]!==n?(Re=r.jsx(LM,{orgSlug:s,virtualMcpId:n,branch:i,previewUrl:o,meta:a,decofile:l,kind:c,target:de.editorTarget,initialValue:de.initialValue,isCreating:S.isPending,onCreate:se,onSaveReferencedBlock:N,onBack:Ve},be),e[44]=i,e[45]=l,e[46]=se,e[47]=c,e[48]=a,e[49]=s,e[50]=o,e[51]=S.isPending,e[52]=N,e[53]=be,e[54]=de.editorTarget,e[55]=de.initialValue,e[56]=n,e[57]=Re):Re=e[57],P=Re;break e}O="flex h-full w-full min-w-0 flex-col";let xe;e[58]!==d?(xe=d("sandbox.runnableBlocksBrowser.folderBreadcrumb"),e[58]=d,e[59]=xe):xe=e[59];let he;e[60]===Symbol.for("react.memo_cache_sentinel")?(he=()=>f([]),e[60]=he):he=e[60];const ce=u.length===0?"font-medium text-foreground":"text-muted-foreground";let oe;e[61]!==ce?(oe=ie("min-w-0 truncate rounded-md px-1 py-0.5 transition-colors hover:bg-accent hover:text-accent-foreground",ce),e[61]=ce,e[62]=oe):oe=e[62];const me=jM[c];let pe;e[63]!==oe||e[64]!==me?(pe=r.jsx("button",{type:"button",onClick:he,className:oe,children:me}),e[63]=oe,e[64]=me,e[65]=pe):pe=e[65];let we;e[66]!==u?(we=u.map((be,Ve)=>{const Re=Ve===u.length-1;return r.jsxs("span",{className:"flex min-w-0 items-center gap-1 overflow-hidden",children:[r.jsx(bn,{className:"size-3 shrink-0 text-muted-foreground/60"}),r.jsx("button",{type:"button",onClick:()=>f(u.slice(0,Ve+1)),className:ie("min-w-0 truncate rounded-md px-1 py-0.5 transition-colors hover:bg-accent hover:text-accent-foreground",Re?"font-medium text-foreground":"text-muted-foreground"),children:Ma(be,Ve)})]},`${be}-${Ve}`)}),e[66]=u,e[67]=we):we=e[67];let Ne;e[68]!==xe||e[69]!==pe||e[70]!==we?(Ne=r.jsxs("nav",{"aria-label":xe,className:"flex min-w-0 flex-1 items-center gap-1 overflow-hidden text-sm",children:[pe,we]}),e[68]=xe,e[69]=pe,e[70]=we,e[71]=Ne):Ne=e[71];let Oe;e[72]===Symbol.for("react.memo_cache_sentinel")?(Oe=r.jsx(L9,{size:14,className:"shrink-0 text-muted-foreground","aria-hidden":!0}),e[72]=Oe):Oe=e[72];let ye;e[73]===Symbol.for("react.memo_cache_sentinel")?(ye=be=>x(be.target.value),e[73]=ye):ye=e[73];let je;e[74]!==c||e[75]!==d?(je=d("sandbox.runnableBlocksBrowser.searchPlaceholder",{kind:c}),e[74]=c,e[75]=d,e[76]=je):je=e[76];let Pe;e[77]!==c||e[78]!==d?(Pe=d("sandbox.runnableBlocksBrowser.searchAriaLabel",{kind:c}),e[77]=c,e[78]=d,e[79]=Pe):Pe=e[79];let Ee;e[80]!==g||e[81]!==je||e[82]!==Pe?(Ee=r.jsxs("div",{className:"flex w-56 shrink-0 items-center gap-2",children:[Oe,r.jsx("input",{type:"text",value:g,onChange:ye,placeholder:je,"aria-label":Pe,className:"w-full bg-transparent text-sm outline-none placeholder:text-muted-foreground"})]}),e[80]=g,e[81]=je,e[82]=Pe,e[83]=Ee):Ee=e[83],e[84]!==Ne||e[85]!==Ee?(R=r.jsxs("div",{className:"flex h-12 shrink-0 items-center gap-2 border-b px-4",children:[Ne,Ee]}),e[84]=Ne,e[85]=Ee,e[86]=R):R=e[86],k=ri,M="min-h-0 flex-1 [&_[data-slot=scroll-area-viewport]>div]:!block",D="mx-auto w-full max-w-4xl px-6 py-5",I=J?H.length===0?r.jsx(Wn,{title:d("sandbox.runnableBlocksBrowser.noSearchResults",{kind:c,query:g.trim()}),description:d("sandbox.runnableBlocksBrowser.noSearchResultsDescription")}):r.jsx("div",{className:"flex flex-col gap-1",children:H.map(be=>r.jsx(Qs,{icon:T,accent:be.savedKey!==void 0?"global":void 0,title:be.title,subtitle:be.resolveType,active:!1,onClick:()=>G(be)},be.savedKey??be.resolveType))}):Y.length===0&&U.length===0&&q.length===0?r.jsx(Wn,{title:d("sandbox.runnableBlocksBrowser.emptyFolderTitle",{kind:c}),description:u.length===0?d("sandbox.runnableBlocksBrowser.emptyFolderNoManifest"):d("sandbox.runnableBlocksBrowser.emptyFolder")}):r.jsxs(r.Fragment,{children:[Y.length>0&&r.jsx("div",{className:"grid grid-cols-[repeat(auto-fill,minmax(180px,1fr))] gap-2",children:Y.map(be=>{const Ve=kM(be.name,u.length);return r.jsxs("button",{type:"button",onClick:()=>f([...u,be.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:[r.jsx(Ve,{size:18,className:"shrink-0 text-muted-foreground"}),r.jsxs("span",{className:"min-w-0 flex-1",children:[r.jsx("span",{className:"block truncate text-sm font-medium",children:Ma(be.name,u.length)}),r.jsxs("span",{className:"block truncate text-xs text-muted-foreground",children:[be.count," ",be.count===1?E:c,be.savedCount>0&&r.jsxs(r.Fragment,{children:[" ","·"," ",d("sandbox.runnableBlocksBrowser.savedCountLabel",{count:be.savedCount})]})]})]})]},be.name)})}),(U.length>0||q.length>0)&&r.jsxs("div",{className:ie("flex flex-col gap-1",Y.length>0&&"mt-4"),children:[U.map(be=>{const Ve=Q.get(be.resolveType)??[],Re=v.has(be.resolveType);return r.jsxs("div",{className:"flex flex-col",children:[r.jsx(Qs,{icon:T,title:be.title,subtitle:be.resolveType,active:!1,onClick:()=>G(be)}),Ve.length>0&&r.jsxs(r.Fragment,{children:[r.jsxs("button",{type:"button",onClick:()=>w(be.resolveType),"aria-expanded":Re,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:D9},children:[Re?r.jsx(ss,{size:12,className:"shrink-0"}):r.jsx(bn,{size:12,className:"shrink-0"}),d(Re?"sandbox.runnableBlocksBrowser.hideSaved":"sandbox.runnableBlocksBrowser.seeSaved")," ","(",Ve.length,")"]}),Re&&r.jsx("div",{className:"ml-11 flex flex-col gap-1 pb-1",children:Ve.map(Le=>r.jsx(Qs,{icon:T,accent:"global",title:Le.title,subtitle:Le.resolveType,active:!1,onClick:()=>G(Le)},Le.savedKey))})]})]},be.resolveType)}),q.map(be=>r.jsx(Qs,{icon:T,accent:"global",title:be.title,subtitle:be.resolveType,active:!1,onClick:()=>G(be)},be.savedKey))]})]})}e[10]=T,e[11]=i,e[12]=l,e[13]=c,e[14]=a,e[15]=v,e[16]=s,e[17]=u,e[18]=o,e[19]=S,e[20]=N,e[21]=g,e[22]=m,e[23]=E,e[24]=d,e[25]=n,e[26]=k,e[27]=R,e[28]=P,e[29]=D,e[30]=I,e[31]=M,e[32]=O}else k=e[26],R=e[27],P=e[28],D=e[29],I=e[30],M=e[31],O=e[32];if(P!==Symbol.for("react.early_return_sentinel"))return P;let F;e[87]!==D||e[88]!==I?(F=r.jsx("div",{className:D,children:I}),e[87]=D,e[88]=I,e[89]=F):F=e[89];let $;e[90]!==k||e[91]!==F||e[92]!==M?($=r.jsx(k,{className:M,children:F}),e[90]=k,e[91]=F,e[92]=M,e[93]=$):$=e[93];let z;return e[94]!==R||e[95]!==$||e[96]!==O?(z=r.jsxs("div",{className:O,children:[R,$]}),e[94]=R,e[95]=$,e[96]=O,e[97]=z):z=e[97],z}function NM(t){const[e,s]=t;return{name:e,...s}}function TM(t,e){return t.title.localeCompare(e.title)}function AM(t){const[,e]=t;return e}function EM(t,e){return t.title.localeCompare(e.title)}function PM(t,e){return t.title.localeCompare(e.title)}function RM(t){return{resolveType:t.resolveType,title:t.title,folderPath:Yg(t.resolveType)}}function DM(t){return{resolveType:t.resolveType,title:t.title,folderPath:Yg(t.resolveType),savedKey:t.key}}function IM(){return new Set}function MM(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:i,...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}}function OM(t){const e=B.c(96),{orgSlug:s,virtualMcpId:n,branch:i,previewUrl:o,meta:a,decofile:l,resolveType:c,title:d,defaultBlockId:h,isCreating:u,onCreate:f,onSaveReferencedBlock:m}=t,p=re(),g=di(),x=g?.entity?.id===n?g.entity.metadata?.siteSlug??null:null;let v;e[0]===Symbol.for("react.memo_cache_sentinel")?(v={},e[0]=v):v=e[0];const[b,_]=A.useState(v);let y;e[1]===Symbol.for("react.memo_cache_sentinel")?(y=[],e[1]=y):y=e[1];const[L,w]=A.useState(y),[j,S]=A.useState(0),[C,N]=A.useState(!1);let V;e[2]!==a||e[3]!==c?(V=_n(c,a),e[2]=a,e[3]=c,e[4]=V):V=e[4];const E=V;let T,k,R,P,D,I,M,O;if(e[5]!==x||e[6]!==i||e[7]!==l||e[8]!==L||e[9]!==b||e[10]!==u||e[11]!==f||e[12]!==s||e[13]!==o||e[14]!==c||e[15]!==p||e[16]!==d||e[17]!==n){const H=c.split("/").pop()?.replace(/\.tsx?$/,"")??c,W=o??void 0;let U;e[26]!==x||e[27]!==i||e[28]!==s||e[29]!==W||e[30]!==n?(U={orgSlug:s,virtualMcpId:n,branch:i,previewUrl:W,siteSlug:x},e[26]=x,e[27]=i,e[28]=s,e[29]=W,e[30]=n,e[31]=U):U=e[31],k=U;let Q;e[32]!==L||e[33]!==d?(Q=[d,...L],e[32]=L,e[33]=d,e[34]=Q):Q=e[34];const q=Q;let Z;e[35]!==L?(Z=pe=>{w(L.slice(0,pe)),S($M)},e[35]=L,e[36]=Z):Z=e[36];const Y=Z;let ee;e[37]!==l||e[38]!==b||e[39]!==f?(ee=async pe=>{const we=Cu(pe,l);if(we){ge.error(we);return}await f(pe,b),N(!1)},e[37]=l,e[38]=b,e[39]=f,e[40]=ee):ee=e[40],T=ee,O="flex h-full w-full min-w-0",M="flex min-w-0 flex-1 flex-col",D="shrink-0 border-b px-3 py-2.5";let G;e[41]!==p?(G=p("sandbox.availableSectionEditor.editingBreadcrumb"),e[41]=p,e[42]=G):G=e[42];let te;e[43]!==Y||e[44]!==q?(te=q.map((pe,we)=>{const Ne=we===q.length-1;return r.jsxs("span",{className:"flex min-w-0 items-center gap-1 overflow-hidden",children:[we>0&&r.jsx(bn,{className:"size-3 shrink-0 text-muted-foreground/60"}),r.jsx("button",{type:"button",onClick:()=>Y(we),title:pe,className:ie("min-w-0 truncate rounded-md px-1 py-0.5 text-left transition-colors hover:bg-accent hover:text-accent-foreground",Ne?"font-medium text-foreground":"text-muted-foreground"),children:pe})]},`${pe}-${we}`)}),e[43]=Y,e[44]=q,e[45]=te):te=e[45];let se;e[46]!==G||e[47]!==te?(se=r.jsx("nav",{"aria-label":G,className:"flex min-w-0 flex-1 items-center gap-1 overflow-hidden text-sm",children:te}),e[46]=G,e[47]=te,e[48]=se):se=e[48];let ne;e[49]===Symbol.for("react.memo_cache_sentinel")?(ne=()=>N(!0),e[49]=ne):ne=e[49];let de;e[50]!==p?(de=p("sandbox.availableSectionEditor.saveAsGlobalSection"),e[50]=p,e[51]=de):de=e[51];let xe;e[52]===Symbol.for("react.memo_cache_sentinel")?(xe=r.jsx(s9,{size:14}),e[52]=xe):xe=e[52];let he;e[53]!==u||e[54]!==de?(he=r.jsx(Ke,{asChild:!0,children:r.jsx(le,{size:"icon",className:"size-8 shrink-0",disabled:u,onClick:ne,"aria-label":de,children:xe})}),e[53]=u,e[54]=de,e[55]=he):he=e[55];let ce;e[56]!==p?(ce=p("sandbox.availableSectionEditor.saveAsGlobalSection"),e[56]=p,e[57]=ce):ce=e[57];let oe;e[58]!==ce?(oe=r.jsx(Ue,{side:"bottom",children:ce}),e[58]=ce,e[59]=oe):oe=e[59];let me;e[60]!==he||e[61]!==oe?(me=r.jsxs(He,{children:[he,oe]}),e[60]=he,e[61]=oe,e[62]=me):me=e[62],e[63]!==se||e[64]!==me?(I=r.jsxs("div",{className:"flex min-w-0 items-center gap-2 overflow-hidden",children:[se,me]}),e[63]=se,e[64]=me,e[65]=I):I=e[65],R="mt-1.5 py-1 pl-1 text-sm leading-snug text-muted-foreground",P=p("sandbox.availableSectionEditor.localEditsHint",{typeLabel:H}),e[5]=x,e[6]=i,e[7]=l,e[8]=L,e[9]=b,e[10]=u,e[11]=f,e[12]=s,e[13]=o,e[14]=c,e[15]=p,e[16]=d,e[17]=n,e[18]=T,e[19]=k,e[20]=R,e[21]=P,e[22]=D,e[23]=I,e[24]=M,e[25]=O}else T=e[18],k=e[19],R=e[20],P=e[21],D=e[22],I=e[23],M=e[24],O=e[25];let F;e[66]!==R||e[67]!==P?(F=r.jsx("p",{className:R,children:P}),e[66]=R,e[67]=P,e[68]=F):F=e[68];let $;e[69]!==F||e[70]!==D||e[71]!==I?($=r.jsxs("div",{className:D,children:[I,F]}),e[69]=F,e[70]=D,e[71]=I,e[72]=$):$=e[72];let z;e[73]!==l||e[74]!==L||e[75]!==j||e[76]!==b||e[77]!==a||e[78]!==m||e[79]!==k||e[80]!==E||e[81]!==p?(z=r.jsx(ri,{className:"min-h-0 flex-1 [&_[data-slot=scroll-area-viewport]>div]:!block",children:r.jsx("div",{className:"min-w-0 max-w-full overflow-x-hidden px-6 py-4",children:r.jsx("div",{className:"mx-auto max-w-2xl",children:E?r.jsx(In,{schema:E,value:b,onChange:H=>_(H),basePath:"",breadcrumbPath:L,onBreadcrumbChange:w,meta:a,decofile:l,onSaveReferencedBlock:m,sandbox:k},j):r.jsx("div",{className:"px-3 py-6 text-center text-xs text-muted-foreground",children:p("sandbox.availableSectionEditor.noEditableFields")})})})}),e[73]=l,e[74]=L,e[75]=j,e[76]=b,e[77]=a,e[78]=m,e[79]=k,e[80]=E,e[81]=p,e[82]=z):z=e[82];let K;e[83]!==$||e[84]!==z||e[85]!==M?(K=r.jsxs("div",{className:M,children:[$,z]}),e[83]=$,e[84]=z,e[85]=M,e[86]=K):K=e[86];let X;e[87]!==h||e[88]!==T||e[89]!==u||e[90]!==C?(X=r.jsx(ku,{open:C,onOpenChange:N,defaultBlockId:h,isPending:u,onSubmit:T}),e[87]=h,e[88]=T,e[89]=u,e[90]=C,e[91]=X):X=e[91];let J;return e[92]!==K||e[93]!==X||e[94]!==O?(J=r.jsxs("div",{className:O,children:[K,X]}),e[92]=K,e[93]=X,e[94]=O,e[95]=J):J=e[95],J}function $M(t){return t+1}function BM(t,e){const s={__resolveType:t},n=Vg([s],e)[0];return n?SD(s,n,e):null}function FM({orgSlug:t,virtualMcpId:e,branch:s,previewUrl:n,meta:i,decofile:o,blockKey:a,onSaveReferencedBlock:l}){const c=re(),d=di(),h=d?.entity?.id===e?d.entity.metadata?.siteSlug??null:null,[u]=A.useState(()=>BM(a,o)),[f,m]=A.useState(u?.data??{}),[p,g]=A.useState([]),[x,v]=A.useState(0),[b,_]=A.useState(!1),[y,L]=A.useState(null),w=y!==null,{save:j,flush:S}=Cg({orgSlug:t,virtualMcpId:e,branch:s}),C=u?.resolveType?_n(u.resolveType,i):null,N=o[a],V=N?hc(a,N):a,E={orgSlug:t,virtualMcpId:e,branch:s,previewUrl:n??void 0,siteSlug:h},T=I=>{m(I),j(a,I)},k=()=>{w?(L(null),_(!1),v(I=>I+1)):L(JSON.stringify(f,null,2))},R=I=>{const M=I??"";try{const O=JSON.parse(M);if(O&&typeof O=="object"&&!Array.isArray(O)){_(!1),T(O);return}_(!0)}catch{_(!0)}},P=[V,...p],D=I=>{g(p.slice(0,I)),v(M=>M+1)};return r.jsx("div",{className:"flex h-full w-full min-w-0",children:r.jsxs("div",{className:"flex min-w-0 flex-1 flex-col",children:[r.jsxs("div",{className:"shrink-0 border-b px-3 py-2.5",children:[r.jsxs("div",{className:"flex min-w-0 items-center gap-2 overflow-hidden",children:[r.jsx("span",{className:"size-2 shrink-0 rounded-full",style:{backgroundColor:D9},"aria-hidden":!0}),r.jsx("nav",{"aria-label":"Editing breadcrumb",className:"flex min-w-0 flex-1 items-center gap-1 overflow-hidden text-sm",children:P.map((I,M)=>{const O=M===P.length-1;return r.jsxs("span",{className:"flex min-w-0 items-center gap-1 overflow-hidden",children:[M>0&&r.jsx(bn,{className:"size-3 shrink-0 text-muted-foreground/60"}),r.jsx("button",{type:"button",onClick:()=>D(M),title:I,className:ie("min-w-0 truncate rounded-md px-1 py-0.5 text-left transition-colors hover:bg-accent hover:text-accent-foreground",O?"font-medium text-foreground":"text-muted-foreground"),children:I})]},`${I}-${M}`)})}),r.jsxs(He,{children:[r.jsx(Ke,{asChild:!0,children:r.jsx(le,{variant:w?"default":"ghost",size:"icon",className:"size-8 shrink-0",onClick:k,"aria-label":c(w?"sandbox.savedSectionEditor.closeJsonEditor":"sandbox.savedSectionEditor.editAsJson"),"aria-pressed":w,children:w?r.jsx(ks,{size:14}):r.jsx(sa,{size:14})})}),r.jsx(Ue,{side:"bottom",children:c(w?"sandbox.savedSectionEditor.closeJsonEditor":"sandbox.savedSectionEditor.editAsJson")})]})]}),r.jsx("p",{className:"mt-1.5 py-1 pl-1 text-sm leading-snug text-muted-foreground",children:c("sandbox.savedSectionEditor.globalSectionDescription")})]}),r.jsxs("div",{className:"relative min-h-0 flex-1",children:[r.jsx(ri,{className:"h-full [&_[data-slot=scroll-area-viewport]>div]:!block",children:r.jsx("div",{className:"min-w-0 max-w-full overflow-x-hidden px-6 py-4",children:r.jsx("div",{className:"mx-auto max-w-2xl",children:C?r.jsx(In,{schema:C,value:f,onChange:I=>T(I),basePath:"",breadcrumbPath:p,onBreadcrumbChange:g,meta:i,decofile:o,onSaveReferencedBlock:l,sandbox:E},x):r.jsx("div",{className:"px-3 py-6 text-center text-xs text-muted-foreground",children:c("sandbox.savedSectionEditor.noEditableFields")})})})}),y!==null&&r.jsxs("div",{className:"absolute inset-0 flex flex-col bg-background",children:[b&&r.jsx("div",{className:"shrink-0 border-b bg-destructive/10 px-3 py-1.5 text-xs text-destructive",children:c("sandbox.savedSectionEditor.invalidJsonError")}),r.jsx("div",{className:"min-h-0 flex-1",children:r.jsx(aa,{language:"json",height:"100%",code:y,onChange:R,onSave:I=>{R(I),S()}})})]})]})]})})}function zM(t){const e=B.c(36),{selection:s,orgSlug:n,virtualMcpId:i,branch:o,previewUrl:a,meta:l,decofile:c,isCreating:d,onCreateAvailable:h,onSaveReferencedBlock:u}=t,f=re();if(!s){let g;e[0]!==f?(g=f("sandbox.sectionsRightPane.selectSectionTitle"),e[0]=f,e[1]=g):g=e[1];let x;e[2]!==f?(x=f("sandbox.sectionsRightPane.selectSectionDescription"),e[2]=f,e[3]=x):x=e[3];let v;return e[4]!==g||e[5]!==x?(v=r.jsx(Wn,{title:g,description:x}),e[4]=g,e[5]=x,e[6]=v):v=e[6],v}if(s.collection==="available-section"){const g=`available:${s.resolveType}`,x=s.resolveType,v=s.title;let b;e[7]!==s.title?(b=x4(s.title),e[7]=s.title,e[8]=b):b=e[8];let _;e[9]!==h||e[10]!==s.resolveType?(_=(L,w)=>h(s.resolveType,L,w),e[9]=h,e[10]=s.resolveType,e[11]=_):_=e[11];let y;return e[12]!==o||e[13]!==c||e[14]!==d||e[15]!==l||e[16]!==u||e[17]!==n||e[18]!==a||e[19]!==s.resolveType||e[20]!==s.title||e[21]!==g||e[22]!==b||e[23]!==_||e[24]!==i?(y=r.jsx(OM,{orgSlug:n,virtualMcpId:i,branch:o,previewUrl:a,meta:l,decofile:c,resolveType:x,title:v,defaultBlockId:b,isCreating:d,onCreate:_,onSaveReferencedBlock:u},g),e[12]=o,e[13]=c,e[14]=d,e[15]=l,e[16]=u,e[17]=n,e[18]=a,e[19]=s.resolveType,e[20]=s.title,e[21]=g,e[22]=b,e[23]=_,e[24]=i,e[25]=y):y=e[25],y}const m=`saved:${s.key}`;let p;return e[26]!==o||e[27]!==c||e[28]!==l||e[29]!==u||e[30]!==n||e[31]!==a||e[32]!==s.key||e[33]!==m||e[34]!==i?(p=r.jsx(FM,{orgSlug:n,virtualMcpId:i,branch:o,previewUrl:a,meta:l,decofile:c,blockKey:s.key,onSaveReferencedBlock:u},m),e[26]=o,e[27]=c,e[28]=l,e[29]=u,e[30]=n,e[31]=a,e[32]=s.key,e[33]=m,e[34]=i,e[35]=p):p=e[35],p}const n1="__all__",i1={"date-desc":"sandbox.postToolbar.sortNewestFirst","date-asc":"sandbox.postToolbar.sortOldestFirst",az:"sandbox.postToolbar.sortTitleAZ",za:"sandbox.postToolbar.sortTitleZA"},KM={"date-desc":"sandbox.postToolbar.sortNewest","date-asc":"sandbox.postToolbar.sortOldest",az:"sandbox.postToolbar.sortAZ",za:"sandbox.postToolbar.sortZA"},r1=A.forwardRef(function(e,s){const n=B.c(20);let i,o,a,l,c;n[0]!==e?({icon:i,active:o,value:c,className:a,...l}=e,n[0]=e,n[1]=i,n[2]=o,n[3]=a,n[4]=l,n[5]=c):(i=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=ie("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]!==i?(u=r.jsx(i,{size:14,className:"shrink-0"}),n[9]=i,n[10]=u):u=n[10];let f;n[11]!==c?(f=c&&r.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=r.jsx(ss,{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=r.jsxs(le,{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 O4(t){const e=B.c(2),{count:s}=t;let n;return e[0]!==s?(n=r.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 UM(t){const e=B.c(88),{categories:s,authors:n,categoryFilter:i,authorFilter:o,sort:a,onCategoryFilterChange:l,onAuthorFilterChange:c,onSortChange:d}=t,h=re();let u;if(e[0]!==s||e[1]!==i){let Z;e[3]!==i?(Z=Y=>Y.slug===i,e[3]=i,e[4]=Z):Z=e[4],u=s.find(Z),e[0]=s,e[1]=i,e[2]=u}else u=e[2];const f=u;let m;if(e[5]!==o||e[6]!==n){let Z;e[8]!==o?(Z=Y=>Y.email===o,e[8]=o,e[9]=Z):Z=e[9],m=n.find(Z),e[5]=o,e[6]=n,e[7]=m}else m=e[7];const p=m,g=!!(i||o);let x;e[10]!==p?.name||e[11]!==f?.name||e[12]!==h?(x=f?.name??p?.name??h("sandbox.postToolbar.filterLabel"),e[10]=p?.name,e[11]=f?.name,e[12]=h,e[13]=x):x=e[13];const v=x,b=i?`cat:${i}`:o?`author:${o}`:n1;let _;e[14]!==c||e[15]!==l?(_=()=>{l(null),c(null)},e[14]=c,e[15]=l,e[16]=_):_=e[16];const y=_;let L;e[17]!==y||e[18]!==c||e[19]!==l?(L=Z=>{Z.startsWith("cat:")?(c(null),l(Z.slice(4))):Z.startsWith("author:")?(l(null),c(Z.slice(7))):y()},e[17]=y,e[18]=c,e[19]=l,e[20]=L):L=e[20];const w=L;let j;e[21]!==v||e[22]!==g?(j=r.jsx(ds,{asChild:!0,children:r.jsx(r1,{icon:v6,active:g,value:v,className:"min-w-0 shrink"})}),e[21]=v,e[22]=g,e[23]=j):j=e[23];let S;e[24]!==h?(S=h("sandbox.postToolbar.filterBy"),e[24]=h,e[25]=S):S=e[25];let C;e[26]!==S?(C=r.jsx(ao,{children:S}),e[26]=S,e[27]=C):C=e[27];let N;e[28]!==h?(N=h("sandbox.postToolbar.allPosts"),e[28]=h,e[29]=N):N=e[29];let V;e[30]!==N?(V=r.jsx(Io,{value:n1,children:N}),e[30]=N,e[31]=V):V=e[31];let E;e[32]!==s.length||e[33]!==h?(E=s.length>0&&r.jsx(ao,{className:"text-muted-foreground/70",children:h("sandbox.postToolbar.categoryLabel")}),e[32]=s.length,e[33]=h,e[34]=E):E=e[34];let T;e[35]!==s?(T=s.map(WM),e[35]=s,e[36]=T):T=e[36];let k;e[37]!==n.length||e[38]!==h?(k=n.length>0&&r.jsx(ao,{className:"text-muted-foreground/70",children:h("sandbox.postToolbar.authorLabel")}),e[37]=n.length,e[38]=h,e[39]=k):k=e[39];let R;e[40]!==n?(R=n.map(HM),e[40]=n,e[41]=R):R=e[41];let P;e[42]!==b||e[43]!==w||e[44]!==V||e[45]!==E||e[46]!==T||e[47]!==k||e[48]!==R?(P=r.jsxs(Dd,{value:b,onValueChange:w,children:[V,E,T,k,R]}),e[42]=b,e[43]=w,e[44]=V,e[45]=E,e[46]=T,e[47]=k,e[48]=R,e[49]=P):P=e[49];let D;e[50]!==P||e[51]!==C?(D=r.jsxs(hs,{align:"start",className:"max-h-96 w-60 overflow-y-auto",children:[C,P]}),e[50]=P,e[51]=C,e[52]=D):D=e[52];let I;e[53]!==D||e[54]!==j?(I=r.jsxs(us,{children:[j,D]}),e[53]=D,e[54]=j,e[55]=I):I=e[55];let M;e[56]!==y||e[57]!==g||e[58]!==h?(M=g&&r.jsx(qM,{label:h("sandbox.postToolbar.clearFilter"),onClick:y}),e[56]=y,e[57]=g,e[58]=h,e[59]=M):M=e[59];const O=KM[a];let F;e[60]!==h||e[61]!==O?(F=h(O),e[60]=h,e[61]=O,e[62]=F):F=e[62];let $;e[63]!==F?($=r.jsx(ds,{asChild:!0,children:r.jsx(r1,{icon:b6,active:!0,value:F})}),e[63]=F,e[64]=$):$=e[64];let z;e[65]!==h?(z=h("sandbox.postToolbar.sortBy"),e[65]=h,e[66]=z):z=e[66];let K;e[67]!==z?(K=r.jsx(ao,{children:z}),e[67]=z,e[68]=K):K=e[68];let X;e[69]!==d?(X=Z=>d(Z),e[69]=d,e[70]=X):X=e[70];let J;e[71]===Symbol.for("react.memo_cache_sentinel")?(J=Object.keys(i1),e[71]=J):J=e[71];let H;e[72]!==h?(H=J.map(Z=>r.jsx(Io,{value:Z,children:h(i1[Z])},Z)),e[72]=h,e[73]=H):H=e[73];let W;e[74]!==a||e[75]!==X||e[76]!==H?(W=r.jsx(Dd,{value:a,onValueChange:X,children:H}),e[74]=a,e[75]=X,e[76]=H,e[77]=W):W=e[77];let U;e[78]!==K||e[79]!==W?(U=r.jsxs(hs,{align:"end",className:"w-44",children:[K,W]}),e[78]=K,e[79]=W,e[80]=U):U=e[80];let Q;e[81]!==$||e[82]!==U?(Q=r.jsx("div",{className:"ml-auto shrink-0",children:r.jsxs(us,{children:[$,U]})}),e[81]=$,e[82]=U,e[83]=Q):Q=e[83];let q;return e[84]!==I||e[85]!==M||e[86]!==Q?(q=r.jsxs("div",{className:"flex min-w-0 items-center gap-1 overflow-hidden border-b px-2 py-1.5",children:[I,M,Q]}),e[84]=I,e[85]=M,e[86]=Q,e[87]=q):q=e[87],q}function HM(t){return r.jsxs(Io,{value:`author:${t.email}`,children:[r.jsx("span",{className:"min-w-0 flex-1 truncate",children:t.name}),r.jsx(O4,{count:t.count})]},`author:${t.email}`)}function WM(t){return r.jsxs(Io,{value:`cat:${t.slug}`,children:[r.jsx("span",{className:"min-w-0 flex-1 truncate",children:t.name}),r.jsx(O4,{count:t.count})]},`cat:${t.slug}`)}function qM(t){const e=B.c(4),{label:s,onClick:n}=t;let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i=r.jsx(ks,{size:12}),e[0]=i):i=e[0];let o;return e[1]!==s||e[2]!==n?(o=r.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:i}),e[1]=s,e[2]=n,e[3]=o):o=e[3],o}function GM(t){const e=B.c(18),{checked:s,disabled:n,onToggle:i}=t,o=re();let a;e[0]!==i?(a=()=>i(),e[0]=i,e[1]=a):a=e[1];let l;e[2]!==s||e[3]!==o?(l=o(s?"sandbox.postToolbar.deselectAllPosts":"sandbox.postToolbar.selectAllPosts"),e[2]=s,e[3]=o,e[4]=l):l=e[4];let c;e[5]!==s||e[6]!==n||e[7]!==a||e[8]!==l?(c=r.jsx(Ke,{asChild:!0,children:r.jsx("span",{className:"flex shrink-0 items-center px-1.5",onClick:YM,children:r.jsx(Ar,{checked:s,disabled:n,onCheckedChange:a,"aria-label":l})})}),e[5]=s,e[6]=n,e[7]=a,e[8]=l,e[9]=c):c=e[9];let d;e[10]!==s||e[11]!==o?(d=o(s?"sandbox.postToolbar.deselectAll":"sandbox.postToolbar.selectAll"),e[10]=s,e[11]=o,e[12]=d):d=e[12];let h;e[13]!==d?(h=r.jsx(Ue,{side:"bottom",children:d}),e[13]=d,e[14]=h):h=e[14];let u;return e[15]!==c||e[16]!==h?(u=r.jsxs(He,{children:[c,h]}),e[15]=c,e[16]=h,e[17]=u):u=e[17],u}function YM(t){return t.stopPropagation()}function JM(t){const e=B.c(42),{count:s,allSelected:n,onToggleSelectAll:i,onDelete:o,onExit:a}=t,l=re();let c;e[0]!==n||e[1]!==i?(c=r.jsx(GM,{checked:n,onToggle:i}),e[0]=n,e[1]=i,e[2]=c):c=e[2];let d;e[3]!==s||e[4]!==l?(d=l("sandbox.postToolbar.itemsSelected",{count:s}),e[3]=s,e[4]=l,e[5]=d):d=e[5];let h;e[6]!==d?(h=r.jsx("span",{className:"text-xs font-medium tabular-nums",children:d}),e[6]=d,e[7]=h):h=e[7];const u=s===0;let f;e[8]!==l?(f=l("sandbox.postToolbar.deleteSelectedPosts"),e[8]=l,e[9]=f):f=e[9];let m;e[10]===Symbol.for("react.memo_cache_sentinel")?(m=r.jsx(Ns,{size:14}),e[10]=m):m=e[10];let p;e[11]!==o||e[12]!==u||e[13]!==f?(p=r.jsx(Ke,{asChild:!0,children:r.jsx(le,{type:"button",variant:"ghost",size:"icon",className:"h-7 w-7 text-destructive hover:text-destructive",disabled:u,onClick:o,"aria-label":f,children:m})}),e[11]=o,e[12]=u,e[13]=f,e[14]=p):p=e[14];let g;e[15]!==l?(g=l("sandbox.postToolbar.deleteSelected"),e[15]=l,e[16]=g):g=e[16];let x;e[17]!==g?(x=r.jsx(Ue,{side:"bottom",children:g}),e[17]=g,e[18]=x):x=e[18];let v;e[19]!==p||e[20]!==x?(v=r.jsxs(He,{children:[p,x]}),e[19]=p,e[20]=x,e[21]=v):v=e[21];let b;e[22]!==l?(b=l("sandbox.postToolbar.exitSelection"),e[22]=l,e[23]=b):b=e[23];let _;e[24]===Symbol.for("react.memo_cache_sentinel")?(_=r.jsx(ks,{size:14}),e[24]=_):_=e[24];let y;e[25]!==a||e[26]!==b?(y=r.jsx(Ke,{asChild:!0,children:r.jsx(le,{type:"button",variant:"ghost",size:"icon",className:"h-7 w-7",onClick:a,"aria-label":b,children:_})}),e[25]=a,e[26]=b,e[27]=y):y=e[27];let L;e[28]!==l?(L=l("sandbox.postToolbar.exitSelection"),e[28]=l,e[29]=L):L=e[29];let w;e[30]!==L?(w=r.jsx(Ue,{side:"bottom",children:L}),e[30]=L,e[31]=w):w=e[31];let j;e[32]!==y||e[33]!==w?(j=r.jsxs(He,{children:[y,w]}),e[32]=y,e[33]=w,e[34]=j):j=e[34];let S;e[35]!==v||e[36]!==j?(S=r.jsxs("div",{className:"ml-auto flex items-center gap-0.5",children:[v,j]}),e[35]=v,e[36]=j,e[37]=S):S=e[37];let C;return e[38]!==c||e[39]!==S||e[40]!==h?(C=r.jsxs("div",{className:"flex items-center gap-0.5 border-b bg-accent/40 px-2 py-1.5",children:[c,h,S]}),e[38]=c,e[39]=S,e[40]=h,e[41]=C):C=e[41],C}function Xr(t){const e=B.c(34),{onDuplicate:s,onRename:n,onAddVariant:i,onEditSeo:o,onViewJson:a,onDelete:l}=t,c=re();let d;e[0]!==c?(d=c("sandbox.itemActions.moreActions"),e[0]=c,e[1]=d):d=e[1];let h;e[2]===Symbol.for("react.memo_cache_sentinel")?(h=r.jsx(ai,{size:14}),e[2]=h):h=e[2];let u;e[3]!==d?(u=r.jsx(ds,{asChild:!0,children:r.jsx("button",{type:"button","aria-label":d,className:"flex h-7 w-7 items-center justify-center rounded-md text-muted-foreground hover:bg-background hover:text-foreground cursor-pointer",onClick:XM,children:h})}),e[3]=d,e[4]=u):u=e[4];let f;e[5]!==n||e[6]!==c?(f=n&&r.jsxs(Xe,{onClick:n,children:[r.jsx(w9,{size:14}),c("sandbox.itemActions.rename")]}),e[5]=n,e[6]=c,e[7]=f):f=e[7];let m;e[8]!==s||e[9]!==c?(m=s&&r.jsxs(Xe,{onClick:s,children:[r.jsx(Os,{size:14}),c("sandbox.itemActions.duplicate")]}),e[8]=s,e[9]=c,e[10]=m):m=e[10];let p;e[11]!==i||e[12]!==c?(p=i&&r.jsxs(r.Fragment,{children:[r.jsx(rr,{}),r.jsxs(Xe,{onClick:i,className:"cursor-pointer text-success focus:text-success",children:[r.jsx(_9,{size:14}),c("sandbox.itemActions.addVariant")]})]}),e[11]=i,e[12]=c,e[13]=p):p=e[13];let g;e[14]!==o||e[15]!==a||e[16]!==c?(g=(o||a)&&r.jsxs(r.Fragment,{children:[r.jsx(rr,{}),o&&r.jsxs(Xe,{onClick:o,children:[r.jsx(rl,{size:14}),c("sandbox.itemActions.editSeo")]}),a&&r.jsxs(Xe,{onClick:a,children:[r.jsx(sa,{size:14}),c("sandbox.itemActions.viewJson")]})]}),e[14]=o,e[15]=a,e[16]=c,e[17]=g):g=e[17];let x;e[18]===Symbol.for("react.memo_cache_sentinel")?(x=r.jsx(rr,{}),e[18]=x):x=e[18];let v;e[19]===Symbol.for("react.memo_cache_sentinel")?(v=r.jsx(Ns,{size:14}),e[19]=v):v=e[19];let b;e[20]!==c?(b=c("sandbox.itemActions.delete"),e[20]=c,e[21]=b):b=e[21];let _;e[22]!==l||e[23]!==b?(_=r.jsxs(Xe,{onClick:l,className:"text-destructive focus:text-destructive",children:[v,b]}),e[22]=l,e[23]=b,e[24]=_):_=e[24];let y;e[25]!==_||e[26]!==f||e[27]!==m||e[28]!==p||e[29]!==g?(y=r.jsxs(hs,{align:"end",className:"w-44",children:[f,m,p,g,x,_]}),e[25]=_,e[26]=f,e[27]=m,e[28]=p,e[29]=g,e[30]=y):y=e[30];let L;return e[31]!==y||e[32]!==u?(L=r.jsxs(us,{children:[u,y]}),e[31]=y,e[32]=u,e[33]=L):L=e[33],L}function XM(t){return t.stopPropagation()}function QM(t){return t.split("/").pop()?.replace(/\.tsx?$/,"")||t||"Section"}function ZM(t){const e=new Map;for(const s of t){const n=QM(s.resolveType),i=e.get(n);i?i.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 o1(t){const e=B.c(8),{icon:s,label:n,className:i}=t;let o;e[0]!==i?(o=ie("flex items-center gap-1.5 px-2.5 pb-1 pt-1 text-xs font-medium text-muted-foreground/70",i),e[0]=i,e[1]=o):o=e[1];let a;e[2]!==s?(a=r.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=r.jsxs("div",{className:o,children:[a,n]}),e[4]=n,e[5]=o,e[6]=a,e[7]=l):l=e[7],l}const a1=A.lazy(()=>$s(()=>import("./app-editor-CLJXkmZ1.js"),__vite__mapDeps([159,1,2,18,52,53,54,17,3,19,55,56,57,58,59,60,61,62,32,63,50,64,65,66,67,68,5,16,20,4,6,7,8,9,10,11,12,13,14,15,21,22,23,24,25,26,27,28,29,30,31,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,51,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,106,107,108,109,110,111,112,113,114,115,116,117,103,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,149,150,105,151,152,153,154,155,156])).then(t=>({default:t.AppEditor}))),eO=A.lazy(()=>$s(()=>import("./post-editor-MhFXsnxa.js"),__vite__mapDeps([160,1,2,5,34,4,6,7,8,9,10,11,12,13,14,15,16,17,3,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,102,101,161,131,134,118,119,77,111,121,128,54,162,92,52,53,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,78,79,80,81,82,83,84,85,86,87,88,89,90,91,93,94,95,96,97,98,99,100,163,164,107,108,109,110,112,113,114,115,116,117,103,120,122,123,124,125,126,127,129,130,132,133,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,105,151,152,153,154,155,156])).then(t=>({default:t.PostEditor}))),tO=A.lazy(()=>$s(()=>import("./record-editor-DwE3lAwY.js"),__vite__mapDeps([165,1,2,102,101,53,54,17,3,19,128,163,4,5,6,7,8,9,10,11,12,13,14,15,16,18,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,164,83,84,79,58,59,80,81,82,70,60,85,86,78,87,88,52,55,56,57,61,62,63,64,65,66,67,68,69,71,72,73,74,75,76,77,89,90,91,92,93,94,95,96,97,98,99,100,107,108,109,110,111,112,113,114,115,116,117,103,118,119,120,121,122,123,124,125,126,127,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,105,151,152,153,154,155,156])).then(t=>({default:t.RecordEditor}))),sO=A.lazy(()=>$s(()=>import("./category-editor-BH2HxeFP.js"),__vite__mapDeps([166,1,2,10,14,34,4,5,6,7,8,9,11,12,13,15,16,17,3,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,139,102,101,162,118,119,77,111,92,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,78,79,80,81,82,83,84,85,86,87,88,89,90,91,93,94,95,96,97,98,99,100,163,164,107,108,109,110,112,113,114,115,116,117,103,120,121,122,123,124,125,126,127,128,129,130,131,132,133,134,135,136,137,138,140,141,142,143,144,145,146,147,148,149,150,105,151,152,153,154,155,156])).then(t=>({default:t.CategoryEditor}))),nO=A.lazy(()=>$s(()=>import("./bulk-category-panel-Ca_By5bp.js"),__vite__mapDeps([167,1,2,14,50,101,53,54,17,3,19,7,83,84,79,58,59,80,81,82,70,60,85,86,78,87,88,52,55,56,57,61,62,32,63,64,65,66,67,68,5,16,20,4,6,8,9,10,11,12,13,15,18,21,22,23,24,25,26,27,28,29,30,31,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,51,69,71,72,73,74,75,76,77,89,90,91,92,93,94,95,96,97,98,99,100,102,107,108,109,110,111,112,113,114,115,116,117,103,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,149,150,105,151,152,153,154,155,156])).then(t=>({default:t.BulkCategoryPanel}))),iO=A.lazy(()=>$s(()=>import("./sections-editor-B9WQ_qSW.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,149,150,151,152,153,154,155,156])).then(t=>({default:t.SectionsEditor}))),rO=A.lazy(()=>$s(()=>import("./seo-editor-Cv-AlrO0.js"),__vite__mapDeps([168,1,2,18,4,5,6,7,8,9,10,11,12,13,14,15,16,17,3,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,104,105,107,108,109,110,111,112,113,114,115,116,117,103,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,149,150,151,152,153,154,155,156])).then(t=>({default:t.SeoEditor}))),oO=A.lazy(()=>$s(()=>import("./variant-calendar-BlplYmKq.js"),__vite__mapDeps([169,1,2,4,5,6,7,8,9,10,11,12,13,14,15,16,17,3,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,101,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,102,105,170])).then(t=>({default:t.VariantCalendar}))),aO=A.lazy(()=>$s(()=>import("./redirect-editor-BGHY1mAE.js"),__vite__mapDeps([171,1,2,134,17,102,101,53,54,3,19,164,7,83,84,79,58,59,80,81,82,70,60,85,86,78,87,88,52,55,56,57,61,62,32,63,50,64,65,66,67,68,5,16,20,4,6,8,9,10,11,12,13,14,15,18,21,22,23,24,25,26,27,28,29,30,31,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,51,69,71,72,73,74,75,76,77,89,90,91,92,93,94,95,96,97,98,99,100,107,108,109,110,111,112,113,114,115,116,117,103,118,119,120,121,122,123,124,125,126,127,128,129,130,131,132,133,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,105,151,152,153,154,155,156])).then(t=>({default:t.RedirectEditor})));function md(t){return t?t.kind==="page"?{collection:"pages",key:t.key,path:t.path}:{collection:"sections",key:t.key}:null}function lO(t){return t?t.kind==="page"?`page:${t.key}:${t.path}`:`section:${t.key}`:null}function cO(t){const e=B.c(21),{mode:s}=t,n=s===void 0?"content":s,i=di(),{data:o}=Di.useSession(),{currentBranch:a}=Zt(),{org:l}=Fe(),c=i?.entity?.id??null,d=o?.user?.id,h=i?.entity?.metadata,u=d&&a?Hl(h?.sandboxMap?.[d]?.[a]):{},f=Object.values(u),p=(f.find(dO)??f[0])?.previewUrl??null,g=Fs(),x=i?.entity?.organization_id??"";let v;e[0]!==l.slug||e[1]!==x?(v={connectionId:Qo,orgId:x,orgSlug:l.slug},e[0]=l.slug,e[1]=x,e[2]=v):v=e[2];const b=ht(v),_=T9(b);let y;e[3]!==a||e[4]!==_||e[5]!==c?(y=()=>{if(!c)return;const N={virtualMcpId:c};a&&(N.branch=a),_.mutate(N)},e[3]=a,e[4]=_,e[5]=c,e[6]=y):y=e[6];const L=y,w=!!c&&!!a&&_l.isStopped(c,a),j=lp({previewUrl:p,appPaused:g.status.state==="paused",userStopped:w,startError:_.isError&&_.error?dp(_.error.message):null});if(j.kind==="othersThread")return null;if(j.kind!=="iframe"){const N=`/${l.slug}/settings/connections`;let V;return e[7]!==j||e[8]!==N||e[9]!==L||e[10]!==g.lifecycle||e[11]!==g.phase?(V=r.jsx(EP,{state:j,claimPhase:g.phase,lifecycle:g.lifecycle,onStart:L,connectionsHref:N}),e[7]=j,e[8]=N,e[9]=L,e[10]=g.lifecycle,e[11]=g.phase,e[12]=V):V=e[12],V}if(!c||!a){let N;return e[13]===Symbol.for("react.memo_cache_sentinel")?(N=r.jsx(Wn,{title:"Waiting for sandbox context…"}),e[13]=N):N=e[13],N}const S=g.lifecycle.phase==="running";let C;return e[14]!==a||e[15]!==n||e[16]!==l.slug||e[17]!==p||e[18]!==S||e[19]!==c?(C=r.jsx(hO,{orgSlug:l.slug,virtualMcpId:c,branch:a,previewUrl:p,mode:n,devServerReady:S}),e[14]=a,e[15]=n,e[16]=l.slug,e[17]=p,e[18]=S,e[19]=c,e[20]=C):C=e[20],C}function dO(t){return t.sandboxProviderKind!=="user-desktop"}const l1=2e3,uO=15;function c1(t,e,s,n){return typeof e!="string"||s&&(Qg(e,s,n)||t.state.dataUpdateCount>=uO)?!1:l1}function hO({orgSlug:t,virtualMcpId:e,branch:s,previewUrl:n,mode:i,devServerReady:o}){const a=vu(),l={orgSlug:t,virtualMcpId:e,branch:s,previewUrl:n},c=vP(e),{data:d,isLoading:h}=lc(l,{fetchEnabled:o}),[u,f]=A.useState("pages"),[m,p]=A.useState(()=>i==="blocks"?md(a.state.target):null),[g,x]=A.useState(()=>i==="blocks"?a.state.editSeoPageKey:null),v=lO(a.state.target),[b,_]=A.useState(v);if(i==="blocks"&&b!==v){_(v);const ae=md(a.state.target);p(ae),(ae?.collection==="pages"||ae?.collection==="sections")&&f(ae.collection)}const[y,L]=A.useState(a.state.editSeoPageKey);if(i==="blocks"&&y!==a.state.editSeoPageKey&&(L(a.state.editSeoPageKey),a.state.editSeoPageKey)){const ae=a.state.target;ae?.kind==="page"&&(f("pages"),p(md(ae)),x(ae.key))}const[w,j]=A.useState(""),[S,C]=A.useState(null),[N,V]=A.useState(null),[E,T]=A.useState("date-desc"),[k,R]=A.useState(()=>new Set),[P,D]=A.useState(null),I=()=>{R(new Set),D(null)},M=ae=>{p(ae),x(null),!(i!=="blocks"||!ae)&&(ae.collection==="pages"?a.selectTarget({kind:"page",key:ae.key,path:ae.path}):ae.collection==="sections"&&a.selectTarget({kind:"section",key:ae.key}))},[O,F]=A.useState(u);O!==u&&(F(u),j(""),C(null),V(null),T("date-desc"),R(new Set),D(null));const{data:$,isLoading:z,isFetching:K}=cc(l,{fetchEnabled:o,refetchInterval:ae=>{const De=ae.state.data;if(u==="apps"&&m&&m.collection==="apps"){const qe=d?.[m.key];return c1(ae,typeof qe?.__resolveType=="string"?qe.__resolveType:void 0,De)}if(u==="site"&&d){const qe=De?Ud(d,De):null,Ye=d.site,mt=qe?.resolveType??(typeof Ye?.__resolveType=="string"?Ye.__resolveType:void 0);return c1(ae,mt,De,["seo"])}return!1}}),X=(ae,De)=>!Qg(ae,$,De)&&(z||K),{catalog:J,isLoading:H}=TP($??void 0,d??void 0,{enabled:u==="apps"}),W=wc(l),U=_P(l),Q=cR({...l,packagePath:c}),q=dR({...l,packagePath:c}),[Z,Y]=A.useState(null),[ee,G]=A.useState(),[te,se]=A.useState(null),[ne,de]=A.useState(null),[xe,he]=A.useState(null);if(h||z)return r.jsx("div",{className:"h-full w-full flex items-center justify-center",children:r.jsx(et,{size:20,className:"animate-spin text-muted-foreground"})});if(!d||!$)return r.jsx(Wn,{title:"Could not load site data."});const ce=K9(d).sort((ae,De)=>ae.name.localeCompare(De.name)),oe=Yp(d).sort((ae,De)=>ae.from.localeCompare(De.from)),me=U9(d,$),pe=u==="sections"?mw($):[],we=Ud(d,$),Ne=i4(d),Oe=bu.some(ae=>Ne[ae].length>0),ye=jo(u)?Ne[u]:[],je=(Oe?Ho(d,"categories"):[]).map(({key:ae,payload:De})=>{const qe=typeof De.slug=="string"?De.slug:"",Ye=typeof De.name=="string"?De.name:"";return{slug:qe||ae,name:Ye||qe||ae}}).filter(ae=>ae.slug).sort((ae,De)=>ae.name.localeCompare(De.name)),Pe=u==="posts"&&(k.size>0||P!==null),Ee=Pe?o4(d).filter(ae=>k.has(ae.key)):[],be=jf($,"loaders"),Ve=jf($,"actions");if(!z9(d,$)&&!Oe&&be===0&&Ve===0)return r.jsx(Wn,{icon:wn,title:"No editable content",description:"This project doesn't expose any Deco pages, sections, apps, loaders, or actions."});const Re={pages:ce.length,sections:me.length,apps:J.length,loaders:be,actions:Ve,redirects:oe.length,posts:Ne.posts.length,authors:Ne.authors.length,categories:Ne.categories.length},Le=new Set(ce.map(ae=>Yn(ae.path))),ve=new Set(ce.map(ae=>ae.name)),Se=new Set(me.map(ae=>ae.name)),Be=async ae=>{const De=d[ae.key];if(!De)return;const qe=Eg(d,ae.key),Ye=Pg(d,ae.key,Math.max(0,qe-1)),mt=DA(De.sections,Ye);if(mt)try{await W.mutateAsync({blockKey:ae.key,data:{...De,sections:mt}}),ge.success(`Variant added to "${ae.name}"`),p({collection:"pages",key:ae.key,path:ae.path})}catch(wt){ge.error(wt instanceof Error?wt.message:"Could not add variant")}},Ce=()=>{G(void 0),Y({mode:"create",sourceKey:null,initialName:"My new page",initialPath:"/example"})},ke=ae=>{G(void 0),Y({mode:"duplicate",sourceKey:ae.key,initialName:Af(ve,ae.name),initialPath:PP(Le,ae.path)})},ze=ae=>{G(void 0),Y({mode:"rename",sourceKey:ae.key,initialName:ae.name,initialPath:ae.path})},nt=async ae=>{if(!Z)return;const{mode:De,sourceKey:qe}=Z;try{if(De==="create"){let Ye;if(ae.templateKey){const wt=d[ae.templateKey];if(!wt)throw new Error("Selected template no longer exists.");Ye={...wt,name:ae.name,path:ae.path}}else Ye=IP(ae.name,ae.path);const mt=OP(d,ae.name);await W.mutateAsync({blockKey:mt,data:Ye}),ge.success(`Created "${ae.name}"`),p({collection:"pages",key:mt,path:ae.path})}else if(De==="duplicate"&&qe){const Ye=d[qe];if(!Ye)throw new Error("Source page not found");const{key:mt,data:wt}=DP({source:Ye,pages:ce,newName:ae.name,newPath:ae.path});await W.mutateAsync({blockKey:mt,data:wt}),ge.success(`Duplicated as "${ae.name}"`),p({collection:"pages",key:mt,path:ae.path})}else if(De==="rename"&&qe){const Ye=d[qe];if(!Ye)throw new Error("Page not found");const mt={...Ye,name:ae.name,path:ae.path};await W.mutateAsync({blockKey:qe,data:mt}),ge.success("Page updated"),m?.collection==="pages"&&m.key===qe&&p({collection:"pages",key:qe,path:ae.path})}Y(null)}catch(Ye){G(Ye instanceof Error?Ye.message:"Save failed")}},pt=({path:ae})=>{if(!Z)return null;const De=Yn(ae);return(Z.mode==="rename"?Yn(Z.initialPath):null)!==De&&Le.has(De)?`A page with path "${ae}" already exists.`:null},Je=async(ae,De,qe)=>{await W.mutateAsync({blockKey:De,data:{...qe,name:De,__resolveType:ae}}),ge.success(`Created section "${De}"`),p({collection:"sections",key:De})},gt=s4((ae,De)=>W.mutate({blockKey:ae,data:De})),dt=async ae=>{const De=d[ae.key];if(!De){ge.error("Section not found.");return}const qe=RP(d,ae.key),Ye=Af(Se,ae.name),mt={...De,name:Ye};try{await W.mutateAsync({blockKey:qe,data:mt}),ge.success(`Duplicated "${ae.name}"`),p({collection:"sections",key:qe})}catch(wt){ge.error(wt instanceof Error?wt.message:"Duplicate failed")}},st=async ae=>{if(!te)return;const De=d[te];if(!De){ge.error("Section not found.");return}try{await W.mutateAsync({blockKey:te,data:{...De,name:ae}}),ge.success("Section renamed"),se(null)}catch(qe){ge.error(qe instanceof Error?qe.message:"Rename failed")}},ft=async()=>{const ae="/redirect-from",De=_w(d,ae),qe=vw({from:ae,to:"/redirect-to",type:"temporary",discardQueryParameters:!1});try{await W.mutateAsync({blockKey:De,data:qe}),ge.success("Created redirect"),p({collection:"redirects",key:De})}catch(Ye){ge.error(Ye instanceof Error?Ye.message:"Could not create redirect")}},fe=async ae=>{const De=Rf(d,ae),qe=Aa(De,ae,eR(ae));try{await Q.mutateAsync({blockKey:De,data:qe}),ge.success(`Created ${wo[ae]}`),p({collection:ae,key:De})}catch(Ye){ge.error(Ye instanceof Error?Ye.message:"Could not create")}},Me=async ae=>{const De=d[ae.key];if(!De){ge.error("Record not found.");return}const qe=Rf(d,ae.kind),Ye=ae.kind==="posts"?"title":"name",mt={...structuredClone(Ya(De,ae.kind)),[Ye]:`${ae.label} (copy)`};try{await Q.mutateAsync({blockKey:qe,data:Aa(qe,ae.kind,mt)}),ge.success(`Duplicated "${ae.label}"`),p({collection:ae.kind,key:qe})}catch(wt){ge.error(wt instanceof Error?wt.message:"Duplicate failed")}},Qe=ae=>{R(De=>{const qe=new Set(De);return qe.has(ae)?qe.delete(ae):qe.add(ae),qe})},xt=ae=>{f("posts"),F("posts"),p(null),x(null),j(""),C(null),V(null),T("date-desc"),R(new Set),D(ae||null)},ls=async(ae,De)=>{const qe=[...k];let Ye=0;for(const mt of qe){const wt=d[mt],$n=Ya(wt,"posts"),ui=ae==="add"?XP($n,De):QP($n,De);ui!==$n&&(await Q.mutateAsync({blockKey:mt,data:Aa(mt,"posts",Pf(ui))}),Ye+=1)}return Ye},Vt=async(ae,De)=>{const qe=k.size;try{const Ye=await ls(ae,De),mt=ae==="add"?"Added to":"Moved",wt=qe-Ye;ge.success(`${mt} ${Ye} ${Ye===1?"post":"posts"}`+(wt>0?` (${wt} already set)`:"")),I()}catch(Ye){ge.error(Ye instanceof Error?Ye.message:"Bulk update failed")}},Ut=async()=>{if(ne)try{if(ne.kind==="blog-bulk"){for(const Ye of ne.keys)await q.mutateAsync({blockKey:Ye});ge.success(`Deleted ${ne.count} ${ne.count===1?"post":"posts"}`),m&&m.collection!=="available-section"&&ne.keys.includes(m.key)&&p(null),I(),de(null);return}const{kind:ae,key:De,label:qe}=ne;if(ae==="blog"){if(ne.blogKind==="categories"){const Ye=Ya(d[De],"categories").slug,mt=typeof Ye=="string"?Ye:"";if(mt)for(const{key:wt,payload:$n}of Ho(d,"posts")){const ui=ZP($n,mt);ui!==$n&&await Q.mutateAsync({blockKey:wt,data:Aa(wt,"posts",Pf(ui))})}}await q.mutateAsync({blockKey:De})}else await U.mutateAsync({blockKey:De});ge.success(`Deleted "${qe}"`),m&&m.collection!=="available-section"&&m.key===De&&p(null),de(null)}catch(ae){ge.error(ae instanceof Error?ae.message:"Delete failed")}},is=U.isPending||q.isPending||Q.isPending,We=ne?.kind==="blog"?wo[ne.blogKind]:ne?.kind==="blog-bulk"?`${ne.count} ${ne.count===1?"post":"posts"}`:ne?.kind??"item";return r.jsxs("div",{className:"flex h-full w-full",children:[i==="content"&&r.jsx(AP,{active:u,counts:Re,showBlog:Oe,onSelect:ae=>{f(ae),p(null),x(null)}}),u!=="seo"&&u!=="site"&&u!=="calendar"&&u!=="loaders"&&u!=="actions"&&r.jsx(fO,{blocksMode:i==="blocks",activeCollection:u,pages:ce,redirects:oe,sections:me,availableSections:pe,appCatalog:J,appCatalogLoading:H,blogEntries:ye,decofile:d,searchQuery:w,onSearchChange:j,postCategoryFilter:S,postAuthorFilter:N,postSort:E,onPostCategoryFilterChange:ae=>{C(ae),R(new Set)},onPostAuthorFilterChange:ae=>{V(ae),R(new Set)},onPostSortChange:T,selectedPostKeys:k,postBulkPanelOpen:Pe,onTogglePostSelect:Qe,onSelectAllPosts:ae=>R(new Set(ae)),onClearPostSelection:()=>R(new Set),onExitPostSelection:I,onBulkDeletePosts:()=>de({kind:"blog-bulk",keys:[...k],count:k.size}),selection:m,onSelect:M,onCollectionSelect:ae=>{f(ae),p(null),x(null)},onCreate:()=>{u==="pages"?Ce():u==="redirects"?ft():jo(u)&&fe(u)},onDuplicatePage:ke,onRenamePage:ze,onAddPageVariant:Be,onDeletePage:ae=>de({kind:"page",key:ae.key,label:ae.name}),onEditPageSeo:ae=>{const De={collection:"pages",key:ae.key,path:ae.path};p(De),x(ae.key),i==="blocks"&&a.editSeo({kind:"page",key:ae.key,path:ae.path})},onViewPageJson:ae=>he(ae.key),onDuplicateSection:dt,onRenameSection:ae=>se(ae.key),onDeleteSection:ae=>de({kind:"section",key:ae.key,label:ae.name}),onDeleteRedirect:ae=>de({kind:"redirect",key:ae.key,label:ae.from||ae.key}),onDuplicateBlog:Me,onDeleteBlog:ae=>de({kind:"blog",blogKind:ae.kind,key:ae.key,label:ae.label})}),r.jsx("div",{className:"flex-1 min-w-0",children:u==="loaders"||u==="actions"?r.jsx(VM,{orgSlug:t,virtualMcpId:e,branch:s,previewUrl:n,meta:$,decofile:d,kind:u}):r.jsx(A.Suspense,{fallback:r.jsx("div",{className:"h-full flex items-center justify-center",children:r.jsx(et,{size:20,className:"animate-spin text-muted-foreground"})}),children:u==="calendar"?r.jsx(oO,{decofile:d}):u==="site"?we?r.jsx(a1,{orgSlug:t,virtualMcpId:e,branch:s,blockKey:we.key,block:d[we.key],decofile:d,meta:$,title:"Site",excludeFields:["seo"],schemaPending:X(we.resolveType,["seo"]),previewBaseUrl:n},`site:${we.key}`):r.jsx(Wn,{title:"Site settings not found",description:"This project doesn't have a site app block (site/apps/site.ts)."}):u==="seo"?r.jsx(rO,{orgSlug:t,virtualMcpId:e,branch:s,decofile:d,meta:$,target:{kind:"site"},previewBaseUrl:n}):u==="sections"?r.jsx(zM,{selection:m?.collection==="sections"||m?.collection==="available-section"?m:null,orgSlug:t,virtualMcpId:e,branch:s,previewUrl:n,meta:$,decofile:d,isCreating:W.isPending,onCreateAvailable:Je,onSaveReferencedBlock:gt}):Pe?r.jsx(nO,{posts:Ee,categories:je,initialSlug:P,isPending:Q.isPending,onApply:(ae,De)=>{Vt(ae,De)},onClose:I},P??"selection"):m&&m.collection!=="available-section"?m.collection==="apps"?r.jsx(a1,{orgSlug:t,virtualMcpId:e,branch:s,blockKey:m.key,block:d[m.key],decofile:d,meta:$,previewBaseUrl:n,schemaPending:X(typeof d[m.key]?.__resolveType=="string"?String(d[m.key].__resolveType):void 0)},`app:${m.key}`):m.collection==="posts"?r.jsx(eO,{orgSlug:t,virtualMcpId:e,branch:s,blockKey:m.key,block:d[m.key],decofile:d,meta:$,previewBaseUrl:n},`post:${m.key}`):m.collection==="categories"?r.jsx(sO,{orgSlug:t,virtualMcpId:e,branch:s,blockKey:m.key,block:d[m.key],decofile:d,meta:$,onManagePosts:xt,onOpenPost:ae=>{f("posts"),F("posts"),p({collection:"posts",key:ae}),x(null)},previewBaseUrl:n},`category:${m.key}`):m.collection==="authors"?r.jsx(tO,{orgSlug:t,virtualMcpId:e,branch:s,kind:"authors",blockKey:m.key,block:d[m.key]},`authors:${m.key}`):m.collection==="redirects"?r.jsx(aO,{orgSlug:t,virtualMcpId:e,branch:s,blockKey:m.key,block:d[m.key]},`redirect:${m.key}`):r.jsx(iO,{orgSlug:t,virtualMcpId:e,branch:s,previewReady:!0,previewUrl:n??void 0,currentPath:m.collection==="pages"?m.path:"/",activePageBlockKey:m.collection==="pages"?m.key:null,activeGlobalBlockKey:m.collection==="sections"?m.key:null,initialEditSeo:m.collection==="pages"&&g===m.key,onExitSeo:()=>{x(null),i==="blocks"&&a.consumeEditSeo()}},m.collection==="pages"?`page:${m.key}`:`section:${m.key}`):r.jsx(Wn,{title:`Select ${jo(u)?`a ${wo[u]}`:u==="pages"?"a page":u==="apps"?"an app":u==="redirects"?"a redirect":"a section"} to edit`,description:u==="apps"?"Browse all apps and select an installed one to edit its settings.":'Pick an item from the list, or click "+" to create one.'})})}),Z&&r.jsx(zP,{open:!!Z,mode:Z.mode,initialName:Z.initialName,initialPath:Z.initialPath,isPending:W.isPending,error:ee,templates:ce,validate:pt,onSubmit:nt,onOpenChange:ae=>{ae||(Y(null),G(void 0))}}),te&&r.jsx(KP,{open:!!te,blockKey:te,initialName:me.find(ae=>ae.key===te)?.name??te,isPending:W.isPending,onSubmit:st,onOpenChange:ae=>{ae||se(null)}}),xe&&r.jsx(uR,{open:!!xe,onOpenChange:ae=>{ae||he(null)},pageKey:xe,decofile:d,onSave:ae=>W.mutateAsync({blockKey:xe,data:ae})}),r.jsx(dl,{open:!!ne,onOpenChange:ae=>{!ae&&!is&&de(null)},children:r.jsxs(ul,{children:[r.jsxs(hl,{children:[r.jsx(fl,{children:`Delete ${We}?`}),r.jsx(ml,{children:ne?.kind==="section"?`"${ne.label}" will be removed. Pages that still reference it will lose this section.`:ne?.kind==="blog-bulk"?`${ne.count} ${ne.count===1?"post":"posts"} will be removed permanently. This can't be undone.`:ne?`"${ne.label}" will be removed permanently. This can't be undone.`:null})]}),r.jsxs(pl,{children:[r.jsx(gl,{disabled:is,children:"Cancel"}),r.jsx(xl,{onClick:ae=>{ae.preventDefault(),Ut()},disabled:is,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:is?r.jsxs(r.Fragment,{children:[r.jsx(et,{size:14,className:"animate-spin"}),"Deleting…"]}):"Delete"})]})]})})]})}function fO(t){const e=B.c(88),{blocksMode:s,activeCollection:n,pages:i,redirects:o,sections:a,availableSections:l,appCatalog:c,appCatalogLoading:d,blogEntries:h,decofile:u,searchQuery:f,onSearchChange:m,postCategoryFilter:p,postAuthorFilter:g,postSort:x,onPostCategoryFilterChange:v,onPostAuthorFilterChange:b,onPostSortChange:_,selectedPostKeys:y,postBulkPanelOpen:L,onTogglePostSelect:w,onSelectAllPosts:j,onClearPostSelection:S,onExitPostSelection:C,onBulkDeletePosts:N,selection:V,onSelect:E,onCollectionSelect:T,onCreate:k,onDuplicatePage:R,onRenamePage:P,onAddPageVariant:D,onDeletePage:I,onEditPageSeo:M,onViewPageJson:O,onDuplicateSection:F,onRenameSection:$,onDeleteSection:z,onDeleteRedirect:K,onDuplicateBlog:X,onDeleteBlog:J}=t;let H,W,U,Q,q,Z,Y,ee;if(e[0]!==n||e[1]!==c||e[2]!==d||e[3]!==l||e[4]!==s||e[5]!==h||e[6]!==u||e[7]!==D||e[8]!==N||e[9]!==S||e[10]!==T||e[11]!==k||e[12]!==J||e[13]!==I||e[14]!==K||e[15]!==z||e[16]!==X||e[17]!==R||e[18]!==F||e[19]!==M||e[20]!==C||e[21]!==b||e[22]!==v||e[23]!==_||e[24]!==P||e[25]!==$||e[26]!==m||e[27]!==E||e[28]!==j||e[29]!==w||e[30]!==O||e[31]!==i||e[32]!==g||e[33]!==L||e[34]!==p||e[35]!==x||e[36]!==o||e[37]!==f||e[38]!==a||e[39]!==y||e[40]!==V){const ne=f.toLowerCase(),de=i.filter(fe=>!ne||fe.name.toLowerCase().includes(ne)||fe.path.toLowerCase().includes(ne)),xe=o.filter(fe=>!ne||fe.from.toLowerCase().includes(ne)||fe.to.toLowerCase().includes(ne)),he=a.filter(fe=>!ne||fe.name.toLowerCase().includes(ne)||fe.key.toLowerCase().includes(ne)||fe.resolveType.toLowerCase().includes(ne)),ce=l.filter(fe=>!ne||fe.title.toLowerCase().includes(ne)||fe.resolveType.toLowerCase().includes(ne)||(fe.description?.toLowerCase().includes(ne)??!1)),oe=ZM(he),me=c.filter(fe=>!ne||fe.title.toLowerCase().includes(ne)||fe.app.toLowerCase().includes(ne)||fe.vendor.toLowerCase().includes(ne)||fe.category.toLowerCase().includes(ne)),pe=h.filter(fe=>!ne||fe.label.toLowerCase().includes(ne)||fe.subtitle.toLowerCase().includes(ne)),we=n==="posts",Ne=xO,Oe=we?o4(u):[],ye=new Map,je=new Map;for(const fe of Oe){for(const Me of fe.categorySlugs)ye.set(Me,(ye.get(Me)??0)+1);for(const Me of fe.authorEmails)je.set(Me,(je.get(Me)??0)+1)}const Pe=(we?Ho(u,"categories"):[]).map(fe=>{const{key:Me,payload:Qe}=fe,xt=Ne(Qe.slug)||Me;return{slug:xt,name:Ne(Qe.name)||Ne(Qe.slug)||Me,count:ye.get(xt)??0}}).filter(gO),Ee=(we?Ho(u,"authors"):[]).map(fe=>{const{key:Me,payload:Qe}=fe,xt=Ne(Qe.email);return{email:xt,name:Ne(Qe.name)||Ne(Qe.email)||Me,count:je.get(xt)??0}}).filter(pO);let be;e[49]!==p?(be=fe=>!p||fe.categorySlugs.includes(p),e[49]=p,e[50]=be):be=e[50];let Ve;e[51]!==g?(Ve=fe=>!g||fe.authorEmails.includes(g),e[51]=g,e[52]=Ve):Ve=e[52];let Re;e[53]!==x?(Re=(fe,Me)=>{if(x==="az")return fe.title.localeCompare(Me.title);if(x==="za")return Me.title.localeCompare(fe.title);const Qe=fe.date.localeCompare(Me.date);return x==="date-asc"?Qe:-Qe},e[53]=x,e[54]=Re):Re=e[54];const Le=Oe.filter(fe=>!ne||fe.title.toLowerCase().includes(ne)||fe.slug.toLowerCase().includes(ne)).filter(be).filter(Ve).sort(Re),ve=y.size,Se=Le.map(mO),Be=Se.length>0&&Se.every(fe=>y.has(fe)),Ce=ve>0||L,ke=()=>{Be?S():j(Se)},ze=`Search ${n}…`,nt=jo(n)?`Create new ${wo[n]}`:n==="redirects"?"Create new redirect":"Create new page",pt=n!=="apps"&&n!=="sections",Je=s?"w-[240px]":"w-[300px]";e[55]!==Je?(q=ie("shrink-0 border-r flex flex-col min-h-0",Je),e[55]=Je,e[56]=q):q=e[56],e[57]!==n||e[58]!==s||e[59]!==T?(Z=s&&r.jsxs("div",{className:"flex h-10 shrink-0 items-center gap-1 border-b px-2",children:[r.jsxs(le,{variant:n==="pages"?"secondary":"ghost",size:"sm",className:"h-7 flex-1",onClick:()=>T("pages"),children:[r.jsx(Nn,{size:14}),"Pages"]}),r.jsxs(le,{variant:n==="sections"?"secondary":"ghost",size:"sm",className:"h-7 flex-1",onClick:()=>T("sections"),children:[r.jsx(gn,{size:14}),"Sections"]})]}),e[57]=n,e[58]=s,e[59]=T,e[60]=Z):Z=e[60];let gt;e[61]===Symbol.for("react.memo_cache_sentinel")?(gt=r.jsx(L9,{size:14,className:"shrink-0 text-muted-foreground","aria-hidden":!0}),e[61]=gt):gt=e[61];let dt;e[62]!==m?(dt=fe=>m(fe.target.value),e[62]=m,e[63]=dt):dt=e[63];let st;e[64]!==ze||e[65]!==f||e[66]!==dt?(st=r.jsxs("div",{className:"flex flex-1 items-center gap-2 pl-1",children:[gt,r.jsx("input",{type:"text",value:f,onChange:dt,placeholder:ze,"aria-label":ze,className:"w-full bg-transparent text-sm outline-none placeholder:text-muted-foreground"})]}),e[64]=ze,e[65]=f,e[66]=dt,e[67]=st):st=e[67];let ft;e[68]!==nt||e[69]!==k||e[70]!==pt?(ft=pt&&r.jsxs(He,{children:[r.jsx(Ke,{asChild:!0,children:r.jsx(le,{variant:"ghost",size:"icon",onClick:k,"aria-label":nt,children:r.jsx(kt,{size:14})})}),r.jsx(Ue,{side:"bottom",children:nt})]}),e[68]=nt,e[69]=k,e[70]=pt,e[71]=ft):ft=e[71],e[72]!==st||e[73]!==ft?(Y=r.jsxs("div",{className:"px-2 h-12 flex items-center gap-1 border-b shrink-0",children:[st,ft]}),e[72]=st,e[73]=ft,e[74]=Y):Y=e[74],ee=we&&(Ce?r.jsx(JM,{count:ve,allSelected:Be,onToggleSelectAll:ke,onDelete:N,onExit:C}):r.jsx(UM,{categories:Pe,authors:Ee,categoryFilter:p,authorFilter:g,sort:x,onCategoryFilterChange:v,onAuthorFilterChange:b,onSortChange:_})),H=ri,Q="flex-1 min-h-0 [&_[data-slot=scroll-area-viewport]>div]:!block",W="flex flex-col gap-1 p-1.5",U=n==="pages"?de.length===0?r.jsx(Ji,{hasItems:i.length>0,emptyLabel:"No pages yet.",emptyHint:'Click "+" to create your first page.'}):de.map(fe=>{const Me=V?.collection==="pages"&&V.key===fe.key,Qe=Eg(u,fe.key);return r.jsx(Qs,{icon:Nn,title:fe.name,subtitle:fe.path,active:Me,variantCount:Qe,onClick:()=>E({collection:"pages",key:fe.key,path:fe.path}),menu:r.jsx(Xr,{onDuplicate:()=>R(fe),onRename:()=>P(fe),onAddVariant:()=>D(fe),onEditSeo:()=>M(fe),onViewJson:()=>O(fe),onDelete:()=>I(fe)})},fe.key)}):n==="sections"?he.length===0&&ce.length===0?r.jsx(Ji,{hasItems:a.length>0||l.length>0,emptyLabel:"No sections yet.",emptyHint:"Save a section from a page, or start the preview dev server."}):r.jsxs(r.Fragment,{children:[oe.length>0&&r.jsxs(r.Fragment,{children:[r.jsx(o1,{icon:gn,label:"Saved sections"}),oe.map(fe=>r.jsxs("div",{className:"flex flex-col gap-1",children:[r.jsx("div",{className:"px-2.5 pt-1 pb-0.5 text-[11px] font-medium uppercase tracking-wide text-muted-foreground/60",children:fe.label}),fe.sections.map(Me=>{const Qe=V?.collection==="sections"&&V.key===Me.key;return r.jsx(Qs,{icon:gn,accent:"global",title:Me.name,subtitle:fe.label,active:Qe,onClick:()=>E({collection:"sections",key:Me.key}),menu:r.jsx(Xr,{onDuplicate:()=>F(Me),onRename:()=>$(Me),onDelete:()=>z(Me)})},Me.key)})]},fe.label))]}),ce.length>0&&r.jsxs(r.Fragment,{children:[r.jsx(o1,{icon:Nn,label:"Available sections",className:ie(oe.length>0&&"mt-3")}),ce.map(fe=>{const Me=V?.collection==="available-section"&&V.resolveType===fe.resolveType,Qe=fe.resolveType.split("/").pop()?.replace(/\.tsx?$/,"");return r.jsx(Qs,{icon:Nn,title:fe.title,subtitle:Qe??fe.resolveType,active:Me,onClick:()=>E({collection:"available-section",resolveType:fe.resolveType,title:fe.title})},fe.resolveType)})]})]}):n==="apps"?d?r.jsx("div",{className:"flex items-center justify-center py-8",children:r.jsx(et,{size:18,className:"animate-spin text-muted-foreground"})}):me.length===0?r.jsx(Ji,{hasItems:c.length>0,emptyLabel:"No apps found.",emptyHint:"Try a different search term."}):me.map(fe=>{const Me=V?.collection==="apps"&&fe.blockKey!==null&&V.key===fe.blockKey;return r.jsx(Qs,{icon:A2,logoUrl:fe.logo,title:fe.title,subtitle:fe.category,active:Me,trailing:fe.installed?r.jsx("span",{className:"shrink-0 rounded-full bg-success/15 px-1.5 py-0.5 text-[10px] font-medium text-success",children:"Installed"}):void 0,onClick:()=>{if(!fe.installed||!fe.blockKey){ge.message(`${fe.title} is not installed on this site.`);return}E({collection:"apps",key:fe.blockKey})}},fe.id)}):n==="redirects"?xe.length===0?r.jsx(Ji,{hasItems:o.length>0,emptyLabel:"No redirects yet.",emptyHint:'Click "+" to create your first redirect.'}):xe.map(fe=>r.jsx(Qs,{icon:Xm,title:fe.from||"(no source)",subtitle:`→ ${fe.to||"(no target)"}`,active:V?.collection==="redirects"&&V.key===fe.key,trailing:r.jsx(UP,{type:fe.type}),onClick:()=>E({collection:"redirects",key:fe.key}),menu:r.jsx(Xr,{onDelete:()=>K(fe)})},fe.key)):we?Le.length===0?r.jsx(Ji,{hasItems:Oe.length>0,emptyLabel:"No posts yet.",emptyHint:'Click "+" to create your first post.'}):Le.map(fe=>{const Me={key:fe.key,kind:"posts",label:fe.title,subtitle:fe.slug};return r.jsx(Qs,{icon:mr,title:fe.title,subtitle:fe.slug||"no slug",invalid:fe.missing.length>0,invalidReason:`Missing: ${fe.missing.join(", ")}`,active:V?.collection==="posts"&&V.key===fe.key,selectable:!0,selectionActive:Ce,selected:y.has(fe.key),onToggleSelect:()=>w(fe.key),onClick:()=>Ce?w(fe.key):E({collection:"posts",key:fe.key}),menu:r.jsx(Xr,{onDuplicate:()=>X(Me),onDelete:()=>J(Me)})},fe.key)}):pe.length===0?r.jsx(Ji,{hasItems:h.length>0,emptyLabel:`No ${n} yet.`,emptyHint:`Click "+" to create your first ${jo(n)?wo[n]:"item"}.`}):pe.map(fe=>{const Me=V?.collection===fe.kind&&V.key===fe.key;return r.jsx(Qs,{icon:fe.kind==="posts"?mr:fe.kind==="authors"?nc:Qm,title:fe.label,subtitle:fe.subtitle,active:Me,onClick:()=>E({collection:fe.kind,key:fe.key}),menu:r.jsx(Xr,{onDuplicate:()=>X(fe),onDelete:()=>J(fe)})},fe.key)}),e[0]=n,e[1]=c,e[2]=d,e[3]=l,e[4]=s,e[5]=h,e[6]=u,e[7]=D,e[8]=N,e[9]=S,e[10]=T,e[11]=k,e[12]=J,e[13]=I,e[14]=K,e[15]=z,e[16]=X,e[17]=R,e[18]=F,e[19]=M,e[20]=C,e[21]=b,e[22]=v,e[23]=_,e[24]=P,e[25]=$,e[26]=m,e[27]=E,e[28]=j,e[29]=w,e[30]=O,e[31]=i,e[32]=g,e[33]=L,e[34]=p,e[35]=x,e[36]=o,e[37]=f,e[38]=a,e[39]=y,e[40]=V,e[41]=H,e[42]=W,e[43]=U,e[44]=Q,e[45]=q,e[46]=Z,e[47]=Y,e[48]=ee}else H=e[41],W=e[42],U=e[43],Q=e[44],q=e[45],Z=e[46],Y=e[47],ee=e[48];let G;e[75]!==W||e[76]!==U?(G=r.jsx("div",{className:W,children:U}),e[75]=W,e[76]=U,e[77]=G):G=e[77];let te;e[78]!==H||e[79]!==Q||e[80]!==G?(te=r.jsx(H,{className:Q,children:G}),e[78]=H,e[79]=Q,e[80]=G,e[81]=te):te=e[81];let se;return e[82]!==q||e[83]!==Z||e[84]!==Y||e[85]!==ee||e[86]!==te?(se=r.jsxs("div",{className:q,children:[Z,Y,ee,te]}),e[82]=q,e[83]=Z,e[84]=Y,e[85]=ee,e[86]=te,e[87]=se):se=e[87],se}function mO(t){return t.key}function pO(t){return t.email}function gO(t){return t.slug}function xO(t){return typeof t=="string"?t:""}function vO(t){const e=B.c(13),{virtualMcpId:s}=t,n=re(),i=gs(s);if(!sn(i?.metadata)){let l;e[0]===Symbol.for("react.memo_cache_sentinel")?(l=r.jsx(wn,{size:24,className:"text-muted-foreground/60"}),e[0]=l):l=e[0];let c;e[1]!==n?(c=n("mainPanelTabs.contentTab.noContentToEdit"),e[1]=n,e[2]=c):c=e[2];let d;e[3]!==c?(d=r.jsx("div",{children:c}),e[3]=c,e[4]=d):d=e[4];let h;e[5]!==n?(h=n("mainPanelTabs.contentTab.connectGithubDescription"),e[5]=n,e[6]=h):h=e[6];let u;e[7]!==h?(u=r.jsx("div",{className:"text-xs text-muted-foreground/80",children:h}),e[7]=h,e[8]=u):u=e[8];let f;return e[9]!==d||e[10]!==u?(f=r.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center gap-2 text-center text-sm text-muted-foreground p-6",children:[l,d,u]}),e[9]=d,e[10]=u,e[11]=f):f=e[11],f}let a;return e[12]===Symbol.for("react.memo_cache_sentinel")?(a=r.jsx(cO,{}),e[12]=a):a=e[12],a}const pd={fast:{labelKey:"automations.automationConfig.tierFast",subtitleKey:"automations.automationConfig.tierFastSubtitle",icon:e9},smart:{labelKey:"automations.automationConfig.tierSmart",subtitleKey:"automations.automationConfig.tierSmartSubtitle",icon:Gn},thinking:{labelKey:"automations.automationConfig.tierThinking",subtitleKey:"automations.automationConfig.tierThinkingSubtitle",icon:Bm}},bO=["fast","smart","thinking"];function yO(t){const e=B.c(19),{tier:s,onSelect:n}=t,i=re(),[o,a]=A.useState(!1),l=pd[s].icon;let c;e[0]!==l?(c=r.jsx(l,{size:14,className:"text-muted-foreground"}),e[0]=l,e[1]=c):c=e[1];const d=pd[s];let h;e[2]!==i||e[3]!==d.labelKey?(h=i(d.labelKey),e[2]=i,e[3]=d.labelKey,e[4]=h):h=e[4];let u;e[5]===Symbol.for("react.memo_cache_sentinel")?(u=r.jsx(ss,{size:14,className:"text-muted-foreground"}),e[5]=u):u=e[5];let f;e[6]!==c||e[7]!==h?(f=r.jsx(Es,{asChild:!0,children:r.jsxs(le,{variant:"outline",size:"sm",className:"w-fit gap-1.5",children:[c,h,u]})}),e[6]=c,e[7]=h,e[8]=f):f=e[8];let m;e[9]!==n||e[10]!==i||e[11]!==s?(m=bO.map(x=>{const v=pd[x],b=v.icon;return r.jsxs("button",{type:"button",onClick:()=>{n(x),a(!1)},className:ie("flex items-start gap-2 px-2 py-1.5 rounded-md text-left hover:bg-muted"),children:[r.jsx(b,{size:16,className:"shrink-0 text-muted-foreground mt-0.5"}),r.jsxs("div",{className:"flex-1",children:[r.jsx("div",{className:"text-sm",children:i(v.labelKey)}),r.jsx("div",{className:"text-xs text-muted-foreground",children:i(v.subtitleKey)})]}),x===s&&r.jsx(zt,{size:14,className:"text-foreground mt-0.5"})]},x)}),e[9]=n,e[10]=i,e[11]=s,e[12]=m):m=e[12];let p;e[13]!==m?(p=r.jsx(Ps,{align:"start",className:"p-1 w-64",children:r.jsx("div",{className:"flex flex-col",children:m})}),e[13]=m,e[14]=p):p=e[14];let g;return e[15]!==o||e[16]!==f||e[17]!==p?(g=r.jsxs(As,{open:o,onOpenChange:a,children:[f,p]}),e[15]=o,e[16]=f,e[17]=p,e[18]=g):g=e[18],g}function _O(t){const e=B.c(27),{tier:s,onTierChange:n,override:i,onOverrideChange:o}=t,a=re(),[l,c]=A.useState(i!==null);let d;e[0]!==a?(d=a("automations.automationConfig.modelLabel"),e[0]=a,e[1]=d):d=e[1];let h;e[2]!==d?(h=r.jsx("span",{className:"text-xs font-semibold text-muted-foreground/60",children:d}),e[2]=d,e[3]=h):h=e[3];let u;e[4]!==o||e[5]!==n||e[6]!==i||e[7]!==a||e[8]!==s||e[9]!==l?(u=l?r.jsx(A.Suspense,{fallback:r.jsx(le,{variant:"outline",size:"sm",disabled:!0,className:"w-fit",children:a("automations.automationConfig.loadingModels")}),children:r.jsx(LO,{override:i,onOverrideChange:o})}):r.jsx(yO,{tier:s,onSelect:n}),e[4]=o,e[5]=n,e[6]=i,e[7]=a,e[8]=s,e[9]=l,e[10]=u):u=e[10];let f;e[11]!==o?(f=b=>{c(b),b||o(null)},e[11]=o,e[12]=f):f=e[12];let m;e[13]!==f||e[14]!==l?(m=r.jsx(xr,{checked:l,onCheckedChange:f,className:"cursor-pointer"}),e[13]=f,e[14]=l,e[15]=m):m=e[15];let p;e[16]!==a?(p=a("automations.automationConfig.specificModel"),e[16]=a,e[17]=p):p=e[17];let g;e[18]!==m||e[19]!==p?(g=r.jsxs("label",{className:"flex items-center gap-2 text-xs text-muted-foreground cursor-pointer select-none",children:[m,p]}),e[18]=m,e[19]=p,e[20]=g):g=e[20];let x;e[21]!==u||e[22]!==g?(x=r.jsxs("div",{className:"flex items-center gap-3 flex-wrap",children:[u,g]}),e[21]=u,e[22]=g,e[23]=x):x=e[23];let v;return e[24]!==h||e[25]!==x?(v=r.jsxs("div",{className:"flex flex-col gap-2",children:[h,x]}),e[24]=h,e[25]=x,e[26]=v):v=e[26],v}function LO(t){const e=B.c(16),{override:s,onOverrideChange:n}=t,i=re(),o=h2(),a=o[0]?.id??null,[l,c]=A.useState(s?.credentialId??a);let d;e[0]!==s?(d=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]=d):d=e[1];const h=d;if(o.length===0){let p;e[2]!==i?(p=i("automations.automationConfig.connectAiProviderHint"),e[2]=i,e[3]=p):p=e[3];let g;return e[4]!==p?(g=r.jsx("span",{className:"text-xs text-muted-foreground italic",children:p}),e[4]=p,e[5]=g):g=e[5],g}let u;e[6]!==i?(u=i("automations.automationConfig.pickModelPlaceholder"),e[6]=i,e[7]=u):u=e[7];let f;e[8]!==l||e[9]!==n?(f=p=>{const g=p.keyId??l??"";c(g),n({modelId:p.modelId,credentialId:g,title:p.title??p.modelId})},e[8]=l,e[9]=n,e[10]=f):f=e[10];let m;return e[11]!==l||e[12]!==h||e[13]!==u||e[14]!==f?(m=r.jsx("div",{className:"w-fit max-w-full [&_button]:rounded-md",children:r.jsx(I6,{variant:"bordered",placeholder:u,model:h,credentialId:l,onCredentialChange:c,onModelChange:f})}),e[11]=l,e[12]=h,e[13]=u,e[14]=f,e[15]=m):m=e[15],m}const $4=[{key:"capabilities",headingKey:"automations.automationConfig.builtinCapabilities",icon:j9,tools:[{name:"web_search",titleKey:"automations.automationConfig.toolWebSearch",descriptionKey:"automations.automationConfig.toolWebSearchDesc",icon:li},{name:"generate_image",titleKey:"automations.automationConfig.toolGenerateImage",descriptionKey:"automations.automationConfig.toolGenerateImageDesc",icon:En},{name:"subtask",titleKey:"automations.automationConfig.toolSubtask",descriptionKey:"automations.automationConfig.toolSubtaskDesc",icon:Zs},{name:"user_ask",titleKey:"automations.automationConfig.toolAskUser",descriptionKey:"automations.automationConfig.toolAskUserDesc",icon:y6}]},{key:"files",headingKey:"automations.automationConfig.filesCode",icon:ei,tools:[{name:"read",titleKey:"automations.automationConfig.toolReadFile",descriptionKey:"automations.automationConfig.toolReadFileDesc",icon:x2},{name:"write",titleKey:"automations.automationConfig.toolWriteFile",descriptionKey:"automations.automationConfig.toolWriteFileDesc",icon:w9},{name:"edit",titleKey:"automations.automationConfig.toolEditFile",descriptionKey:"automations.automationConfig.toolEditFileDesc",icon:Q0},{name:"grep",titleKey:"automations.automationConfig.toolSearchContent",descriptionKey:"automations.automationConfig.toolSearchContentDesc",icon:Oo},{name:"glob",titleKey:"automations.automationConfig.toolFindFiles",descriptionKey:"automations.automationConfig.toolFindFilesDesc",icon:ei},{name:"bash",titleKey:"automations.automationConfig.toolRunCommand",descriptionKey:"automations.automationConfig.toolRunCommandDesc",icon:_6}]},{key:"context",headingKey:"automations.automationConfig.context",icon:ol,tools:[{name:"read_resource",titleKey:"automations.automationConfig.toolReadResource",descriptionKey:"automations.automationConfig.toolReadResourceDesc",icon:ol},{name:"read_prompt",titleKey:"automations.automationConfig.toolReadPrompt",descriptionKey:"automations.automationConfig.toolReadPromptDesc",icon:fr},{name:"skill",titleKey:"automations.automationConfig.toolLoadSkill",descriptionKey:"automations.automationConfig.toolLoadSkillDesc",icon:fr}]},{key:"browser",headingKey:"automations.automationConfig.browser",icon:gn,tools:[{name:"take_screenshot",titleKey:"automations.automationConfig.toolTakeScreenshot",descriptionKey:"automations.automationConfig.toolTakeScreenshotDesc",icon:Nr},{name:"scrape_url",titleKey:"automations.automationConfig.toolScrapeUrl",descriptionKey:"automations.automationConfig.toolScrapeUrlDesc",icon:gn},{name:"inspect_page",titleKey:"automations.automationConfig.toolInspectPage",descriptionKey:"automations.automationConfig.toolInspectPageDesc",icon:sa}]}],SO=$4.flatMap(t=>t.tools.map(e=>e.name));function wO(t){const e=t.replace(/[_-]+/g," ").trim();return e?e.toLowerCase().replace(/\b\w/g,s=>s.toUpperCase()):t}function jO(t){const e=B.c(12),{agentId:s,value:n,onChange:i}=t,o=re();let a;e[0]!==o?(a=o("automations.automationConfig.toolsLabel"),e[0]=o,e[1]=a):a=e[1];let l;e[2]!==a?(l=r.jsx("span",{className:"text-xs font-semibold text-muted-foreground/60",children:a}),e[2]=a,e[3]=l):l=e[3];let c;e[4]!==s||e[5]!==i||e[6]!==o||e[7]!==n?(c=s?r.jsx(A.Suspense,{fallback:r.jsxs(le,{variant:"outline",size:"sm",disabled:!0,className:"w-fit",children:[r.jsx(j9,{size:14}),o("automations.automationConfig.loadingTools")]}),children:r.jsx(CO,{agentId:s,value:n,onChange:i})}):r.jsx("span",{className:"text-xs text-muted-foreground italic",children:o("automations.automationConfig.pickAgentFirst")}),e[4]=s,e[5]=i,e[6]=o,e[7]=n,e[8]=c):c=e[8];let d;return e[9]!==l||e[10]!==c?(d=r.jsxs("div",{className:"flex flex-col gap-2",children:[l,c]}),e[9]=l,e[10]=c,e[11]=d):d=e[11],d}function d1(t){const e=B.c(17),{value:s,checked:n,onToggle:i,title:o,description:a,leading:l}=t;let c;e[0]!==n?(c=r.jsx(Ar,{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&&r.jsx("span",{className:"mt-px shrink-0",children:l}),e[2]=l,e[3]=d):d=e[3];let h;e[4]!==o?(h=r.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&&r.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=r.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]!==i||e[12]!==c||e[13]!==d||e[14]!==f||e[15]!==s?(m=r.jsxs(Vs,{value:s,onSelect:i,className:"items-start gap-2.5 py-2",children:[c,d,f]}),e[11]=i,e[12]=c,e[13]=d,e[14]=f,e[15]=s,e[16]=m):m=e[16],m}function u1(t){const e=B.c(27),{conn:s,label:n,icon:i,on:o,total:a,onToggle:l}=t,c=re(),d=o===a;let h;e[0]!==i||e[1]!==s?(h=s?r.jsx(an,{icon:s.icon,name:s.title,size:"2xs"}):i?r.jsx(i,{size:14,className:"text-muted-foreground"}):r.jsx(L6,{size:14,className:"text-muted-foreground"}),e[0]=i,e[1]=s,e[2]=h):h=e[2];let u;e[3]!==s?.title||e[4]!==n||e[5]!==c?(u=s?.title??n??c("automations.automationConfig.otherTools"),e[3]=s?.title,e[4]=n,e[5]=c,e[6]=u):u=e[6];let f;e[7]!==u?(f=r.jsx("span",{className:"truncate",children:u}),e[7]=u,e[8]=f):f=e[8];let m;e[9]!==o||e[10]!==a?(m=r.jsxs("span",{className:"text-[11px] font-normal tabular-nums text-muted-foreground/70",children:[o,"/",a]}),e[9]=o,e[10]=a,e[11]=m):m=e[11];let p;e[12]!==l?(p=_=>{_.stopPropagation(),l()},e[12]=l,e[13]=p):p=e[13];let g;e[14]!==d||e[15]!==c?(g=c(d?"automations.automationConfig.none":"automations.automationConfig.all"),e[14]=d,e[15]=c,e[16]=g):g=e[16];let x;e[17]!==p||e[18]!==g?(x=r.jsx("button",{type:"button",onClick:p,className:"text-[11px] font-medium text-primary hover:underline",children:g}),e[17]=p,e[18]=g,e[19]=x):x=e[19];let v;e[20]!==m||e[21]!==x?(v=r.jsxs("span",{className:"ml-auto flex items-center gap-2",children:[m,x]}),e[20]=m,e[21]=x,e[22]=v):v=e[22];let b;return e[23]!==h||e[24]!==f||e[25]!==v?(b=r.jsxs("div",{className:"flex items-center gap-2",children:[h,f,v]}),e[23]=h,e[24]=f,e[25]=v,e[26]=b):b=e[26],b}function CO(t){const e=B.c(83),{agentId:s,value:n,onChange:i}=t,o=re(),{org:a}=Fe(),[l,c]=A.useState(!1);let d;e[0]!==s||e[1]!==a.id||e[2]!==a.slug?(d={connectionId:s,orgId:a.id,orgSlug:a.slug},e[0]=s,e[1]=a.id,e[2]=a.slug,e[3]=d):d=e[3];const h=ht(d);let u;e[4]!==h?(u={client:h},e[4]=h,e[5]=u):u=e[5];const{data:f,isLoading:m}=f9(u),p=Rn();let g,x,v,b,_,y,L,w,j,S,C,N,V;if(e[6]!==p||e[7]!==f?.tools||e[8]!==m||e[9]!==i||e[10]!==l||e[11]!==o||e[12]!==n){const P=new Map(p.map(AO)),D=new Map;for(const ce of f?.tools??[]){const oe=pn(ce._meta)??"__other__",me=jr(ce.name,oe==="__other__"?void 0:oe),pe=ce.title,we=pe&&pe!==ce.name?pe:wO(me);D.has(oe)||D.set(oe,{clientId:oe,conn:P.get(oe),tools:[]}),D.get(oe).tools.push({name:ce.name,display:we,description:ce.description})}const I=[...D.values()].sort(TO),M=(f?.tools??[]).map(NO),O=[...SO,...M],F=n===null?new Set(O):new Set(n),$=O.every(ce=>F.has(ce)),z=ce=>i(O.every(oe=>ce.has(oe))?null:[...ce]),K=ce=>{const oe=new Set(F);oe.has(ce)?oe.delete(ce):oe.add(ce),z(oe)},X=(ce,oe)=>{const me=new Set(F);for(const pe of ce)oe?me.add(pe):me.delete(pe);z(me)};b=As,V=l,_=c;let J;e[26]===Symbol.for("react.memo_cache_sentinel")?(J=r.jsx(j9,{size:14,className:"text-muted-foreground"}),e[26]=J):J=e[26];let H;e[27]!==$||e[28]!==o?(H=o($?"automations.automationConfig.allTools":"automations.automationConfig.tools"),e[27]=$,e[28]=o,e[29]=H):H=e[29];const W=!$&&r.jsxs(i8,{variant:"secondary",className:"ml-0.5 h-5 px-1.5 text-[11px] tabular-nums",children:[F.size,"/",O.length]});let U;e[30]===Symbol.for("react.memo_cache_sentinel")?(U=r.jsx(ss,{size:14,className:"text-muted-foreground"}),e[30]=U):U=e[30],e[31]!==H||e[32]!==W?(y=r.jsx(Es,{asChild:!0,children:r.jsxs(le,{variant:"outline",size:"sm",className:"w-fit gap-1.5",children:[J,H,W,U]})}),e[31]=H,e[32]=W,e[33]=y):y=e[33],v=Ps,C="p-0 w-80",N="start",x=Tr;let Q;e[34]!==o?(Q=o("automations.automationConfig.searchToolsPlaceholder"),e[34]=o,e[35]=Q):Q=e[35],e[36]!==Q?(j=r.jsx(Bi,{placeholder:Q}),e[36]=Q,e[37]=j):j=e[37];const q=$?o("automations.automationConfig.allToolsEnabled",{count:O.length}):o("automations.automationConfig.toolsEnabledCount",{enabled:F.size,total:O.length});let Z;e[38]!==q?(Z=r.jsx("span",{className:"text-xs text-muted-foreground",children:q}),e[38]=q,e[39]=Z):Z=e[39];let Y;e[40]!==i?(Y=()=>i(null),e[40]=i,e[41]=Y):Y=e[41];let ee;e[42]!==o?(ee=o("automations.automationConfig.selectAll"),e[42]=o,e[43]=ee):ee=e[43];let G;e[44]!==$||e[45]!==Y||e[46]!==ee?(G=r.jsx("button",{type:"button",onClick:Y,disabled:$,className:"text-xs font-medium text-primary hover:underline disabled:cursor-default disabled:opacity-40 disabled:no-underline",children:ee}),e[44]=$,e[45]=Y,e[46]=ee,e[47]=G):G=e[47];let te;e[48]===Symbol.for("react.memo_cache_sentinel")?(te=r.jsx("span",{className:"text-muted-foreground/30",children:"·"}),e[48]=te):te=e[48];let se;e[49]!==i?(se=()=>i([]),e[49]=i,e[50]=se):se=e[50];const ne=F.size===0;let de;e[51]!==o?(de=o("automations.automationConfig.clear"),e[51]=o,e[52]=de):de=e[52];let xe;e[53]!==se||e[54]!==ne||e[55]!==de?(xe=r.jsx("button",{type:"button",onClick:se,disabled:ne,className:"text-xs font-medium text-muted-foreground hover:underline disabled:cursor-default disabled:opacity-40 disabled:no-underline",children:de}),e[53]=se,e[54]=ne,e[55]=de,e[56]=xe):xe=e[56];let he;e[57]!==G||e[58]!==xe?(he=r.jsxs("div",{className:"flex items-center gap-2",children:[G,te,xe]}),e[57]=G,e[58]=xe,e[59]=he):he=e[59],e[60]!==Z||e[61]!==he?(S=r.jsxs("div",{className:"flex items-center justify-between border-b px-3 py-2",children:[Z,he]}),e[60]=Z,e[61]=he,e[62]=S):S=e[62],g=Fi,L="max-h-80",w=m?r.jsx("div",{className:"px-3 py-6 text-center text-xs text-muted-foreground",children:o("automations.automationConfig.loadingTools")}):r.jsxs(r.Fragment,{children:[r.jsx(Zn,{children:o("automations.automationConfig.noToolsFound")}),$4.map(ce=>{const oe=ce.tools.map(VO),me=oe.filter(pe=>F.has(pe)).length;return r.jsx(Ms,{heading:r.jsx(u1,{label:o(ce.headingKey),icon:ce.icon,on:me,total:oe.length,onToggle:()=>X(oe,me!==oe.length)}),children:ce.tools.map(pe=>r.jsx(d1,{value:`${o(pe.titleKey)} ${pe.name}`,checked:F.has(pe.name),onToggle:()=>K(pe.name),title:o(pe.titleKey),description:o(pe.descriptionKey),leading:r.jsx(pe.icon,{size:16,className:"text-muted-foreground"})},pe.name))},ce.key)}),I.map(ce=>{const oe=ce.tools.map(kO),me=oe.filter(pe=>F.has(pe)).length;return r.jsx(Ms,{heading:r.jsx(u1,{conn:ce.conn,on:me,total:oe.length,onToggle:()=>X(oe,me!==oe.length)}),children:ce.tools.map(pe=>r.jsx(d1,{value:`${pe.display} ${pe.name} ${ce.conn?.title??""}`,checked:F.has(pe.name),onToggle:()=>K(pe.name),title:pe.display,description:pe.description},pe.name))},ce.clientId)})]}),e[6]=p,e[7]=f?.tools,e[8]=m,e[9]=i,e[10]=l,e[11]=o,e[12]=n,e[13]=g,e[14]=x,e[15]=v,e[16]=b,e[17]=_,e[18]=y,e[19]=L,e[20]=w,e[21]=j,e[22]=S,e[23]=C,e[24]=N,e[25]=V}else g=e[13],x=e[14],v=e[15],b=e[16],_=e[17],y=e[18],L=e[19],w=e[20],j=e[21],S=e[22],C=e[23],N=e[24],V=e[25];let E;e[63]!==g||e[64]!==L||e[65]!==w?(E=r.jsx(g,{className:L,children:w}),e[63]=g,e[64]=L,e[65]=w,e[66]=E):E=e[66];let T;e[67]!==x||e[68]!==E||e[69]!==j||e[70]!==S?(T=r.jsxs(x,{children:[j,S,E]}),e[67]=x,e[68]=E,e[69]=j,e[70]=S,e[71]=T):T=e[71];let k;e[72]!==v||e[73]!==T||e[74]!==C||e[75]!==N?(k=r.jsx(v,{className:C,align:N,children:T}),e[72]=v,e[73]=T,e[74]=C,e[75]=N,e[76]=k):k=e[76];let R;return e[77]!==b||e[78]!==_||e[79]!==y||e[80]!==k||e[81]!==V?(R=r.jsxs(b,{open:V,onOpenChange:_,children:[y,k]}),e[77]=b,e[78]=_,e[79]=y,e[80]=k,e[81]=V,e[82]=R):R=e[82],R}function kO(t){return t.name}function VO(t){return t.name}function NO(t){return t.name}function TO(t,e){return(t.conn?.title??t.clientId).localeCompare(e.conn?.title??e.clientId)}function AO(t){return[t.id,t]}function No(t){const e=t.trim().split(/\s+/);return e.length!==5?!1:e.every(s=>/^[\d*/,-]+$/.test(s))}function EO(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 i=e.match(/^0\s+0\s+\*\/(\d+)\s+\*\s+\*$/);if(i){const l=parseInt(i[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 PO(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 RO(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 i=e.match(/^0\s+0\s+\*\/(\d+)\s+\*\s+\*$/);return i?{count:parseInt(i[1]),unit:"days"}:null}function DO(t,e){return e===1?{minutes:"minute",hours:"hour",days:"day",weeks:"week"}[t]??t:t}const IO=[{label:"5 minutes",cron:"*/5 * * * *"},{label:"Hour",cron:"0 * * * *"},{label:"Day",cron:"0 0 * * *"},{label:"Week",cron:"0 0 * * 1"}];function MO({automationId:t,open:e,onOpenChange:s,onCustomSelect:n,onEventSelect:i,onWebhookCreated:o}){const a=re(),{triggerAdd:l}=la(),[c,d]=A.useState(!1),h=e??c,u=p=>{s?s(p):d(p)},f=async p=>{try{await l.mutateAsync({automation_id:t,type:"cron",cron_expression:p}),ge.success(a("automations.addStarterPopover.starterAdded")),u(!1)}catch(g){const x=g instanceof Error?g.message:a("automations.addStarterPopover.failedAddStarter");ge.error(x)}},m=async()=>{try{const p=await l.mutateAsync({automation_id:t,type:"webhook"});u(!1),p.webhook?o?.(p.webhook):ge.success(a("automations.addStarterPopover.webhookStarterAdded"))}catch(p){const g=p instanceof Error?p.message:a("automations.addStarterPopover.failedAddWebhookStarter");ge.error(g)}};return r.jsxs(us,{open:h,onOpenChange:u,children:[r.jsx(ds,{asChild:!0,children:r.jsxs(le,{variant:"outline",size:"sm",children:[r.jsx(kt,{size:14}),a("automations.addStarterPopover.addStarter")]})}),r.jsxs(hs,{align:"end",className:"w-[200px]",children:[r.jsxs(Po,{children:[r.jsxs(Ro,{className:"gap-2.5",children:[r.jsx(bo,{size:14,className:"text-muted-foreground shrink-0"}),a("automations.addStarterPopover.every")]}),r.jsx(Do,{className:"w-[160px]",children:IO.map(p=>r.jsxs(Xe,{className:"gap-2.5",onSelect:()=>f(p.cron),disabled:l.isPending,children:[r.jsx(bo,{size:14,className:"text-muted-foreground shrink-0"}),a("automations.addStarterPopover.everyUnit",{unit:p.label})]},p.cron))})]}),r.jsxs(Xe,{className:"gap-2.5",onSelect:()=>{u(!1),n?.()},children:[r.jsx(bo,{size:14,className:"text-muted-foreground shrink-0"}),a("automations.addStarterPopover.customCron")]}),r.jsxs(Xe,{className:"gap-2.5",onSelect:()=>{u(!1),i?.()},children:[r.jsx(Ni,{size:14,className:"text-muted-foreground shrink-0"}),a("automations.addStarterPopover.event")]}),r.jsxs(Xe,{className:"gap-2.5",onSelect:()=>{m()},disabled:l.isPending,children:[r.jsx(li,{size:14,className:"text-muted-foreground shrink-0"}),a("automations.addStarterPopover.webhook")]})]})]})}function B4(t){const e=B.c(39),{open:s,onOpenChange:n,url:i,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=re(),[u,f]=A.useState(null),[m,p]=A.useState("curl"),[g,x]=A.useState("header"),v=A.useId();let b;e[0]!==h?(b=async(I,M)=>{try{await navigator.clipboard.writeText(I),f(M),ge.success(h("automations.webhookSecretDialog.copied")),setTimeout(()=>f(null),1500)}catch{ge.error(h("automations.webhookSecretDialog.failedCopy"))}},e[0]=h,e[1]=b):b=e[1];const _=b;let y;e[2]!==g||e[3]!==o||e[4]!==i?(y=i&&o&&g==="url"?`${i.replace(/\/$/,"")}/${o}`:i??"",e[2]=g,e[3]=o,e[4]=i,e[5]=y):y=e[5];const L=y,w=i&&o?g==="header"?`curl -X POST "${L}" \\
|
|
482
|
+
-H "Authorization: Bearer ${o}" \\
|
|
483
|
+
-H "Content-Type: application/json" \\
|
|
484
|
+
-d '{"hello":"world"}'`:`curl -X POST "${L}" \\
|
|
485
|
+
-H "Content-Type: application/json" \\
|
|
486
|
+
-d '{"hello":"world"}'`:"",j=i&&o?g==="header"?`await fetch("${L}", {
|
|
487
|
+
method: "POST",
|
|
488
|
+
headers: {
|
|
489
|
+
Authorization: "Bearer ${o}",
|
|
490
|
+
"Content-Type": "application/json",
|
|
491
|
+
},
|
|
492
|
+
body: JSON.stringify({ hello: "world" }),
|
|
493
|
+
});`:`await fetch("${L}", {
|
|
494
|
+
method: "POST",
|
|
495
|
+
headers: {
|
|
496
|
+
"Content-Type": "application/json",
|
|
497
|
+
},
|
|
498
|
+
body: JSON.stringify({ hello: "world" }),
|
|
499
|
+
});`:"",S=m==="curl"?w:j;let C;e[6]!==c?(C=r.jsx(ps,{children:c}),e[6]=c,e[7]=C):C=e[7];let N;e[8]!==d?(N=r.jsx(oi,{children:d}),e[8]=d,e[9]=N):N=e[9];let V;e[10]!==C||e[11]!==N?(V=r.jsxs(ms,{children:[C,N]}),e[10]=C,e[11]=N,e[12]=V):V=e[12];let E;e[13]!==g||e[14]!==u||e[15]!==_||e[16]!==L||e[17]!==m||e[18]!==S||e[19]!==h||e[20]!==o||e[21]!==v||e[22]!==i?(E=i&&o?r.jsxs("div",{className:"flex flex-col gap-3 min-w-0",children:[r.jsxs("div",{className:"flex flex-col gap-1",children:[r.jsx("span",{className:"text-xs font-semibold text-muted-foreground",children:h("automations.webhookSecretDialog.url")}),r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("code",{className:"flex-1 min-w-0 text-xs font-mono bg-muted rounded-md px-2 py-1.5 truncate",children:L}),r.jsxs(le,{size:"sm",variant:"outline",onClick:()=>_(L,"url"),children:[r.jsx(Os,{size:13}),h(u==="url"?"automations.webhookSecretDialog.copied":"automations.webhookSecretDialog.copy")]})]})]}),r.jsxs("div",{className:"flex flex-col gap-1",children:[r.jsx("span",{className:"text-xs font-semibold text-muted-foreground",children:h("automations.webhookSecretDialog.tokenLabel")}),r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("code",{className:"flex-1 min-w-0 text-xs font-mono bg-muted rounded-md px-2 py-1.5 truncate",children:o}),r.jsxs(le,{size:"sm",variant:"outline",onClick:()=>_(o,"token"),children:[r.jsx(Os,{size:13}),h(u==="token"?"automations.webhookSecretDialog.copied":"automations.webhookSecretDialog.copy")]})]})]}),r.jsxs("div",{className:"flex flex-col gap-2",children:[r.jsx("span",{className:"text-xs font-semibold text-muted-foreground",children:h("automations.webhookSecretDialog.snippet")}),r.jsxs("div",{className:"flex items-center justify-between gap-3",children:[r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsx(Vr,{value:m,onValueChange:I=>p(I),children:r.jsxs(na,{className:"h-8 p-[2px]",children:[r.jsx(xn,{value:"curl",className:"h-7 px-2.5 text-xs",children:"curl"}),r.jsx(xn,{value:"fetch",className:"h-7 px-2.5 text-xs",children:"fetch"})]})}),r.jsxs("label",{htmlFor:v,className:"flex items-center gap-1.5 text-xs text-muted-foreground cursor-pointer select-none",children:[r.jsx(Ar,{id:v,checked:g==="url",onCheckedChange:I=>x(I?"url":"header")}),h("automations.webhookSecretDialog.tokenInUrl")]})]}),r.jsxs(le,{size:"sm",variant:"outline",onClick:()=>_(S,"example"),children:[r.jsx(Os,{size:13}),h(u==="example"?"automations.webhookSecretDialog.copied":"automations.webhookSecretDialog.copy")]})]}),r.jsx("div",{className:"rounded-md border overflow-hidden min-w-0",children:r.jsx(aa,{code:S,language:m==="curl"?"shell":"typescript",readOnly:!0,disableDiagnostics:!0,height:180})})]})]}):null,e[13]=g,e[14]=u,e[15]=_,e[16]=L,e[17]=m,e[18]=S,e[19]=h,e[20]=o,e[21]=v,e[22]=i,e[23]=E):E=e[23];let T;e[24]!==n?(T=()=>n(!1),e[24]=n,e[25]=T):T=e[25];let k;e[26]!==h?(k=h("automations.webhookSecretDialog.done"),e[26]=h,e[27]=k):k=e[27];let R;e[28]!==k||e[29]!==T?(R=r.jsx(Mi,{children:r.jsx(le,{onClick:T,children:k})}),e[28]=k,e[29]=T,e[30]=R):R=e[30];let P;e[31]!==R||e[32]!==V||e[33]!==E?(P=r.jsxs(es,{className:"max-w-lg",children:[V,E,R]}),e[31]=R,e[32]=V,e[33]=E,e[34]=P):P=e[34];let D;return e[35]!==n||e[36]!==s||e[37]!==P?(D=r.jsx(ts,{open:s,onOpenChange:n,children:P}),e[35]=n,e[36]=s,e[37]=P,e[38]=D):D=e[38],D}function OO(t){const e=B.c(137),{trigger:s,automationId:n,connectionName:i}=t,o=re(),{triggerAdd:a,triggerRemove:l,triggerRotateToken:c}=la(),[d,h]=A.useState(!1),[u,f]=A.useState(!1),[m,p]=A.useState(null);let g;e[0]!==s.cron_expression?(g=s.cron_expression?RO(s.cron_expression):null,e[0]=s.cron_expression,e[1]=g):g=e[1];const x=g,[v,b]=A.useState(x?.count??1),[_,y]=A.useState(!1),[L,w]=A.useState(s.cron_expression??""),j=l.isPending||a.isPending||c.isPending,S=s.type==="cron",C=s.type==="webhook";let N;e[2]!==n||e[3]!==l||e[4]!==o||e[5]!==s.id?(N=async()=>{try{await l.mutateAsync({trigger_id:s.id,automation_id:n}),ge.success(o("automations.triggerCard.starterRemoved"))}catch{ge.error(o("automations.triggerCard.failedToRemoveStarter"))}h(!1)},e[2]=n,e[3]=l,e[4]=o,e[5]=s.id,e[6]=N):N=e[6];const V=N;let E;e[7]!==a||e[8]!==n||e[9]!==l||e[10]!==s.id?(E=async Ce=>{await a.mutateAsync({automation_id:n,type:"cron",cron_expression:Ce}),await l.mutateAsync({trigger_id:s.id,automation_id:n})},e[7]=a,e[8]=n,e[9]=l,e[10]=s.id,e[11]=E):E=e[11];const T=E;let k;e[12]!==L||e[13]!==T||e[14]!==o||e[15]!==s.cron_expression?(k=async()=>{const Ce=L.trim();if(!Ce||!No(Ce)||Ce===s.cron_expression){y(!1),w(s.cron_expression??"");return}try{await T(Ce),y(!1)}catch{ge.error(o("automations.triggerCard.failedToUpdateStarter")),w(s.cron_expression??""),y(!1)}},e[12]=L,e[13]=T,e[14]=o,e[15]=s.cron_expression,e[16]=k):k=e[16];const R=k;let P;e[17]!==n||e[18]!==c||e[19]!==s.id?(P=async()=>{f(!1);try{const Ce=await c.mutateAsync({trigger_id:s.id,automation_id:n});p({url:Ce.url,token:Ce.token})}catch(Ce){const ke=Ce,ze=ke instanceof Error?ke.message:"Failed to rotate token";ge.error(ze)}},e[17]=n,e[18]=c,e[19]=s.id,e[20]=P):P=e[20];const D=P;let I;e[21]!==x||e[22]!==T||e[23]!==o||e[24]!==s.cron_expression?(I=async Ce=>{if(!x)return;const ke=x.unit==="minutes"?5:1,ze=Math.max(ke,Ce);ze!==Ce&&b(ze);const nt=PO(ze,x.unit);if(nt!==s.cron_expression)try{await T(nt)}catch{ge.error(o("automations.triggerCard.failedToUpdateStarter")),b(x.count)}},e[21]=x,e[22]=T,e[23]=o,e[24]=s.cron_expression,e[25]=I):I=e[25];const M=I;let O;e[26]!==S||e[27]!==C?(O=S?r.jsx(bo,{size:14,className:"text-muted-foreground shrink-0"}):C?r.jsx(li,{size:14,className:"text-muted-foreground shrink-0"}):r.jsx(Ni,{size:14,className:"text-muted-foreground shrink-0"}),e[26]=S,e[27]=C,e[28]=O):O=e[28];let F;e[29]!==i||e[30]!==v||e[31]!==L||e[32]!==M||e[33]!==R||e[34]!==x||e[35]!==S||e[36]!==_||e[37]!==j||e[38]!==C||e[39]!==o||e[40]!==s.cron_expression||e[41]!==s.event_type||e[42]!==s.params?(F=x&&S?r.jsxs(r.Fragment,{children:[r.jsx("span",{className:"text-sm text-muted-foreground",children:o("automations.triggerCard.every")}),r.jsx("input",{type:"number",min:x.unit==="minutes"?5:1,value:v,onChange:Ce=>b(parseInt(Ce.target.value)||1),onBlur:()=>M(v),onKeyDown:Ce=>{Ce.key==="Enter"&&Ce.target.blur(),Ce.key==="Escape"&&b(x.count)},disabled:j,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"}),r.jsx("span",{className:"text-sm",children:DO(x.unit,v)})]}):S&&_?r.jsxs(r.Fragment,{children:[r.jsx("input",{type:"text",value:L,onChange:Ce=>w(Ce.target.value),onBlur:R,onKeyDown:Ce=>{Ce.key==="Enter"&&Ce.target.blur(),Ce.key==="Escape"&&(y(!1),w(s.cron_expression??""))},className:"flex-1 text-sm font-mono bg-transparent outline-none",autoFocus:!0}),L&&!No(L)&&r.jsx("span",{className:"text-xs text-muted-foreground/60 shrink-0",children:o("automations.triggerCard.invalid")})]}):r.jsxs("div",{className:"flex flex-col gap-0.5 flex-1 min-w-0",children:[r.jsx("span",{className:"text-sm font-mono text-xs text-muted-foreground truncate",children:S?EO(s.cron_expression??""):C?o("automations.triggerCard.webhookPostToFire"):`${s.event_type}${i?` · ${i}`:""}`}),!S&&!C&&s.params&&Object.keys(s.params).length>0&&r.jsx("span",{className:"text-xs text-muted-foreground/60 truncate",children:Object.entries(s.params).map($O).join(", ")})]}),e[29]=i,e[30]=v,e[31]=L,e[32]=M,e[33]=R,e[34]=x,e[35]=S,e[36]=_,e[37]=j,e[38]=C,e[39]=o,e[40]=s.cron_expression,e[41]=s.event_type,e[42]=s.params,e[43]=F):F=e[43];let $;e[44]!==j?($=j&&r.jsx(et,{size:13,className:"animate-spin text-muted-foreground"}),e[44]=j,e[45]=$):$=e[45];let z;e[46]!==x||e[47]!==S||e[48]!==_||e[49]!==s.cron_expression?(z=S&&!x&&!_&&r.jsx(le,{variant:"ghost",size:"sm",className:"h-7 w-7 p-0 opacity-0 group-hover:opacity-100 transition-opacity",onClick:()=>{w(s.cron_expression??""),y(!0)},children:r.jsx(w9,{size:13,className:"text-muted-foreground"})}),e[46]=x,e[47]=S,e[48]=_,e[49]=s.cron_expression,e[50]=z):z=e[50];let K;e[51]!==C||e[52]!==o?(K=C&&r.jsx(le,{variant:"ghost",size:"sm",className:"h-7 w-7 p-0 opacity-0 group-hover:opacity-100 transition-opacity",title:o("automations.triggerCard.rotateToken"),onClick:()=>f(!0),children:r.jsx(dr,{size:13,className:"text-muted-foreground"})}),e[51]=C,e[52]=o,e[53]=K):K=e[53];let X;e[54]===Symbol.for("react.memo_cache_sentinel")?(X=r.jsx(le,{variant:"ghost",size:"sm",className:"h-7 w-7 p-0 opacity-0 group-hover:opacity-100 transition-opacity",onClick:()=>h(!0),children:r.jsx(Pn,{size:13,className:"text-muted-foreground"})}),e[54]=X):X=e[54];let J;e[55]!==z||e[56]!==K||e[57]!==$?(J=r.jsxs("div",{className:"ml-auto flex items-center gap-1",children:[$,z,K,X]}),e[55]=z,e[56]=K,e[57]=$,e[58]=J):J=e[58];let H;e[59]!==J||e[60]!==O||e[61]!==F?(H=r.jsxs("div",{className:"flex items-center gap-2.5 px-3 py-2.5 rounded-lg border border-border bg-background group",children:[O,F,J]}),e[59]=J,e[60]=O,e[61]=F,e[62]=H):H=e[62];let W;e[63]!==o?(W=o("automations.triggerCard.removeStarter"),e[63]=o,e[64]=W):W=e[64];let U;e[65]!==W?(U=r.jsx(fl,{children:W}),e[65]=W,e[66]=U):U=e[66];let Q;e[67]!==o?(Q=o("automations.triggerCard.confirmRemoveStarter"),e[67]=o,e[68]=Q):Q=e[68];let q;e[69]!==Q?(q=r.jsx(ml,{children:Q}),e[69]=Q,e[70]=q):q=e[70];let Z;e[71]!==U||e[72]!==q?(Z=r.jsxs(hl,{children:[U,q]}),e[71]=U,e[72]=q,e[73]=Z):Z=e[73];let Y;e[74]!==o?(Y=o("automations.triggerCard.cancel"),e[74]=o,e[75]=Y):Y=e[75];let ee;e[76]!==Y?(ee=r.jsx(gl,{children:Y}),e[76]=Y,e[77]=ee):ee=e[77];let G;e[78]!==o?(G=o("automations.triggerCard.remove"),e[78]=o,e[79]=G):G=e[79];let te;e[80]!==V||e[81]!==G?(te=r.jsx(xl,{onClick:V,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:G}),e[80]=V,e[81]=G,e[82]=te):te=e[82];let se;e[83]!==ee||e[84]!==te?(se=r.jsxs(pl,{children:[ee,te]}),e[83]=ee,e[84]=te,e[85]=se):se=e[85];let ne;e[86]!==Z||e[87]!==se?(ne=r.jsxs(ul,{children:[Z,se]}),e[86]=Z,e[87]=se,e[88]=ne):ne=e[88];let de;e[89]!==d||e[90]!==ne?(de=r.jsx(dl,{open:d,onOpenChange:h,children:ne}),e[89]=d,e[90]=ne,e[91]=de):de=e[91];let xe;e[92]!==o?(xe=o("automations.triggerCard.rotateWebhookToken"),e[92]=o,e[93]=xe):xe=e[93];let he;e[94]!==xe?(he=r.jsx(fl,{children:xe}),e[94]=xe,e[95]=he):he=e[95];let ce;e[96]!==o?(ce=o("automations.triggerCard.rotateWebhookTokenDescription"),e[96]=o,e[97]=ce):ce=e[97];let oe;e[98]!==ce?(oe=r.jsx(ml,{children:ce}),e[98]=ce,e[99]=oe):oe=e[99];let me;e[100]!==he||e[101]!==oe?(me=r.jsxs(hl,{children:[he,oe]}),e[100]=he,e[101]=oe,e[102]=me):me=e[102];let pe;e[103]!==o?(pe=o("automations.triggerCard.cancel"),e[103]=o,e[104]=pe):pe=e[104];let we;e[105]!==pe?(we=r.jsx(gl,{children:pe}),e[105]=pe,e[106]=we):we=e[106];let Ne;e[107]!==o?(Ne=o("automations.triggerCard.rotate"),e[107]=o,e[108]=Ne):Ne=e[108];let Oe;e[109]!==D||e[110]!==Ne?(Oe=r.jsx(xl,{onClick:D,children:Ne}),e[109]=D,e[110]=Ne,e[111]=Oe):Oe=e[111];let ye;e[112]!==we||e[113]!==Oe?(ye=r.jsxs(pl,{children:[we,Oe]}),e[112]=we,e[113]=Oe,e[114]=ye):ye=e[114];let je;e[115]!==me||e[116]!==ye?(je=r.jsxs(ul,{children:[me,ye]}),e[115]=me,e[116]=ye,e[117]=je):je=e[117];let Pe;e[118]!==u||e[119]!==je?(Pe=r.jsx(dl,{open:u,onOpenChange:f,children:je}),e[118]=u,e[119]=je,e[120]=Pe):Pe=e[120];const Ee=m!==null;let be;e[121]===Symbol.for("react.memo_cache_sentinel")?(be=Ce=>{Ce||p(null)},e[121]=be):be=e[121];const Ve=m?.url??null,Re=m?.token??null;let Le;e[122]!==o?(Le=o("automations.triggerCard.newWebhookToken"),e[122]=o,e[123]=Le):Le=e[123];let ve;e[124]!==o?(ve=o("automations.triggerCard.newWebhookTokenDescription"),e[124]=o,e[125]=ve):ve=e[125];let Se;e[126]!==Ee||e[127]!==Ve||e[128]!==Re||e[129]!==Le||e[130]!==ve?(Se=r.jsx(B4,{open:Ee,onOpenChange:be,url:Ve,token:Re,title:Le,description:ve}),e[126]=Ee,e[127]=Ve,e[128]=Re,e[129]=Le,e[130]=ve,e[131]=Se):Se=e[131];let Be;return e[132]!==H||e[133]!==de||e[134]!==Pe||e[135]!==Se?(Be=r.jsxs(r.Fragment,{children:[H,de,Pe,Se]}),e[132]=H,e[133]=de,e[134]=Pe,e[135]=Se,e[136]=Be):Be=e[136],Be}function $O(t){const[e,s]=t;return`${e}: ${s}`}function BO(t){const e=B.c(70),{automationId:s,onDone:n}=t,i=re();let o;e[0]===Symbol.for("react.memo_cache_sentinel")?(o={binding:"TRIGGER"},e[0]=o):o=e[0];const a=Rn(o),[l,c]=A.useState(),[d,h]=A.useState();let u;e[1]===Symbol.for("react.memo_cache_sentinel")?(u={},e[1]=u):u=e[1];const[f,m]=A.useState(u),{triggerAdd:p}=la(),{data:g,isLoading:x}=r8(l);let v,b,_,y,L,w;if(e[2]!==p||e[3]!==s||e[4]!==l||e[5]!==d||e[6]!==x||e[7]!==n||e[8]!==f||e[9]!==i||e[10]!==a||e[11]!==g){const C=g?.find($=>$.type===d);let N;e[18]!==p||e[19]!==s||e[20]!==l||e[21]!==d||e[22]!==n||e[23]!==f||e[24]!==i?(N=async()=>{if(!(!l||!d))try{await p.mutateAsync({automation_id:s,type:"event",event_type:d,connection_id:l,params:f}),$e("automation_trigger_added",{automation_id:s,trigger_type:"event",connection_id:l,event_type:d}),ge.success(i("automations.eventTriggerForm.successAdded")),n()}catch{ge.error(i("automations.eventTriggerForm.errorFailed"))}},e[18]=p,e[19]=s,e[20]=l,e[21]=d,e[22]=n,e[23]=f,e[24]=i,e[25]=N):N=e[25],v=N,b="flex flex-col gap-3 px-3 py-3 rounded-lg border border-border bg-background";let V;e[26]===Symbol.for("react.memo_cache_sentinel")?(V=r.jsx(Ni,{size:14,className:"text-muted-foreground shrink-0"}),e[26]=V):V=e[26];let E;e[27]!==i?(E=i("automations.eventTriggerForm.title"),e[27]=i,e[28]=E):E=e[28];let T;e[29]!==E?(T=r.jsx("span",{className:"text-sm font-medium",children:E}),e[29]=E,e[30]=T):T=e[30];let k;e[31]===Symbol.for("react.memo_cache_sentinel")?(k=r.jsx(Pn,{size:13}),e[31]=k):k=e[31];let R;e[32]!==n?(R=r.jsx("button",{type:"button",className:"ml-auto shrink-0 p-0.5 rounded text-muted-foreground hover:text-foreground",onClick:n,children:k}),e[32]=n,e[33]=R):R=e[33],e[34]!==T||e[35]!==R?(_=r.jsxs("div",{className:"flex items-center gap-2",children:[V,T,R]}),e[34]=T,e[35]=R,e[36]=_):_=e[36];const P=l??"";let D;e[37]===Symbol.for("react.memo_cache_sentinel")?(D=$=>{c($),h(void 0),m({})},e[37]=D):D=e[37];let I;e[38]!==i?(I=i("automations.eventTriggerForm.selectConnectionPlaceholder"),e[38]=i,e[39]=I):I=e[39];let M;e[40]!==I?(M=r.jsx(Jt,{className:"w-full",children:r.jsx(as,{placeholder:I})}),e[40]=I,e[41]=M):M=e[41];let O;e[42]!==i||e[43]!==a?(O=a.length===0?r.jsx("div",{className:"px-2 py-3 text-center text-xs text-muted-foreground",children:i("automations.eventTriggerForm.noConnectionsWithTrigger")}):a.map(KO),e[42]=i,e[43]=a,e[44]=O):O=e[44];let F;e[45]!==O?(F=r.jsx(Xt,{children:O}),e[45]=O,e[46]=F):F=e[46],e[47]!==P||e[48]!==M||e[49]!==F?(y=r.jsxs(Qt,{value:P,onValueChange:D,children:[M,F]}),e[47]=P,e[48]=M,e[49]=F,e[50]=y):y=e[50],e[51]!==l||e[52]!==d||e[53]!==x||e[54]!==i||e[55]!==g?(L=l&&r.jsxs(Qt,{value:d??"",onValueChange:$=>{h($),m({})},children:[r.jsx(Jt,{className:"w-full",children:x?r.jsxs("span",{className:"flex items-center gap-2 text-muted-foreground",children:[r.jsx(et,{size:13,className:"animate-spin"}),i("automations.eventTriggerForm.loadingEvents")]}):r.jsx(as,{placeholder:i("automations.eventTriggerForm.selectEventTypePlaceholder"),children:d??i("automations.eventTriggerForm.selectEventTypePlaceholder")})}),r.jsx(Xt,{children:g?.map(zO)})]}),e[51]=l,e[52]=d,e[53]=x,e[54]=i,e[55]=g,e[56]=L):L=e[56],w=C?.paramsSchema&&Object.keys(C.paramsSchema).length>0&&r.jsx("div",{className:"flex flex-col gap-2",children:Object.entries(C.paramsSchema).map($=>{const[z,K]=$;return r.jsxs("div",{className:"flex flex-col gap-1",children:[r.jsxs("label",{className:"text-xs text-muted-foreground",children:[z,K.description&&r.jsxs("span",{className:"text-muted-foreground/60",children:[" ","— ",K.description]})]}),K.enum?r.jsxs(Qt,{value:f[z]??"",onValueChange:X=>m(J=>({...J,[z]:X})),children:[r.jsx(Jt,{className:"w-full",children:r.jsx(as,{placeholder:i("automations.eventTriggerForm.selectParamPlaceholder",{key:z})})}),r.jsx(Xt,{children:K.enum.map(FO)})]}):r.jsx("input",{type:"text",value:f[z]??"",onChange:X=>m(J=>({...J,[z]:X.target.value})),placeholder:K.description??z,className:"text-sm border border-border rounded-md bg-background px-2 py-1.5 focus:outline-none focus:ring-1 focus:ring-ring"})]},z)})}),e[2]=p,e[3]=s,e[4]=l,e[5]=d,e[6]=x,e[7]=n,e[8]=f,e[9]=i,e[10]=a,e[11]=g,e[12]=v,e[13]=b,e[14]=_,e[15]=y,e[16]=L,e[17]=w}else v=e[12],b=e[13],_=e[14],y=e[15],L=e[16],w=e[17];let j;e[57]!==p||e[58]!==l||e[59]!==d||e[60]!==v||e[61]!==i?(j=l&&d&&r.jsx(le,{size:"sm",onClick:v,disabled:p.isPending,children:p.isPending?r.jsx(et,{size:13,className:"animate-spin"}):i("automations.eventTriggerForm.addTriggerButton")}),e[57]=p,e[58]=l,e[59]=d,e[60]=v,e[61]=i,e[62]=j):j=e[62];let S;return e[63]!==b||e[64]!==_||e[65]!==y||e[66]!==L||e[67]!==w||e[68]!==j?(S=r.jsxs("div",{className:b,children:[_,y,L,w,j]}),e[63]=b,e[64]=_,e[65]=y,e[66]=L,e[67]=w,e[68]=j,e[69]=S):S=e[69],S}function FO(t){return r.jsx(vt,{value:t,children:t},t)}function zO(t){return r.jsx(vt,{value:t.type,children:r.jsxs("div",{className:"flex flex-col",children:[r.jsx("span",{children:t.type}),r.jsx("span",{className:"text-xs text-muted-foreground",children:t.description})]})},t.type)}function KO(t){return r.jsx(vt,{value:t.id,children:t.title},t.id)}const UO=30;function HO(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 i of e.fields)n.add(i);return{...s,fields:n,saveCount:s.saveCount+1}}case"reset":return null}}function WO({automationId:t,automation:e,onBack:s,onDelete:n}){const i=re(),o=e.virtual_mcp_id,{org:a}=Fe(),{update:l,triggerAdd:c,run:d}=la(),h=Rn(),u=new Map(h.map(G=>[G.id,G.title])),{openTask:f}=Zt(),{openSidePanel:m}=ea(),{sendMessage:p}=Js(),g=e.messages?.[0]?.metadata?.tiptapDoc??void 0,[x,v]=A.useState(g),[b,_]=A.useState(!1),[y,L]=A.useState(!1),[w,j]=A.useState(!1),[S,C]=A.useState(""),[N,V]=A.useState(!1),[E,T]=A.useState(null),[k,R]=A.useState(!1),[P,D]=A.useState(!1),[I,M]=A.useState(!1),O=async()=>{if(k)return;const te=Nx(x).filter(se=>se.type==="text").map(se=>se.text).join(`
|
|
500
|
+
`);if(te.trim()){R(!0);try{Z(),$e("automation_improve_clicked",{automation_id:t,agent_id:o,instructions_length:te.length}),m("chat"),await p({tiptapDoc:Qp({managerAgentId:Nm.AUTOMATION_MANAGER(a.id),managerName:"Automation Manager",kind:"automation",id:t,instructions:te})})}finally{R(!1)}}},F=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,z=U0({defaultValues:{name:e.name,active:e.active,tier:F,modelOverride:$,tools:e.tools??null,maxAgentSteps:e.maxAgentSteps??null}}),K=z.watch("active"),[X,J]=A.useReducer(HO,null),H=()=>{X!==null&&($e("automation_updated",{automation_id:t,agent_id:o,fields:Array.from(X.fields),save_count:X.saveCount,edit_duration_ms:Date.now()-X.start}),J({type:"reset"}))},W=async()=>{const G=z.control._formState.dirtyFields,te=Object.keys(G);if(te.length===0&&!I)return!0;const se=z.getValues(),ne=z.control._defaultValues;z.reset(se,{keepValues:!0});const de=I;M(!1);const xe={tier:se.tier,...se.modelOverride?{modelId:se.modelOverride.modelId,credentialId:se.modelOverride.credentialId,modelTitle:se.modelOverride.title}:{}},he={id:t,name:se.name,active:se.active,models:xe,tools:se.tools,maxAgentSteps:se.maxAgentSteps,messages:Vx(x),temperature:0};try{await l.mutateAsync(he)}catch{return z.reset(ne,{keepValues:!0}),de&&M(!0),!1}const ce=[...te];return de&&ce.push("messages"),J({type:"accumulate",now:Date.now(),fields:ce}),q(),!0},{schedule:U,flush:Q}=bl({save:W}),{schedule:q,flush:Z}=bl({delayMs:3e4,save:async()=>H()});A.useEffect(()=>{const G=z.watch(()=>U());return()=>G.unsubscribe()},[]);const Y=G=>{if(v(G),!P){D(!0);return}M(!0),U()},ee=async()=>{$e("automation_test_clicked",{automation_id:t,agent_id:o});const G=await Q();if(Z(),!!G){if(!x){ge.error(i("automations.automationDetail.noInstructionsConfigured"));return}try{const te=await d.mutateAsync(t);te.threadId&&(m("chat"),f(te.threadId))}catch{}}};return r.jsxs(r.Fragment,{children:[s&&r.jsx("div",{className:"flex items-center pb-4 shrink-0",children:r.jsxs(le,{variant:"ghost",size:"sm",onClick:s,children:[r.jsx(Xl,{size:14}),i("automations.automationDetail.backToList")]})}),r.jsxs("div",{className:"flex flex-col gap-8",children:[r.jsxs("div",{className:"flex flex-col gap-1.5",children:[r.jsxs("div",{className:"flex items-center justify-between gap-4",children:[r.jsx(ys,{control:z.control,name:"name",render:({field:G})=>r.jsx(rt,{...G,placeholder:i("automations.automationDetail.automationNamePlaceholder"),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&&r.jsx(le,{variant:"ghost",size:"icon",className:"text-muted-foreground hover:text-destructive shrink-0",onClick:n,children:r.jsx(Ns,{size:14})})]}),r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx(ys,{control:z.control,name:"active",render:({field:G})=>r.jsx(xr,{checked:G.value,onCheckedChange:te=>{G.onChange(te),Q()},className:"cursor-pointer"})}),r.jsx("span",{className:"text-sm text-muted-foreground",children:i(K?"automations.automationDetail.active":"automations.automationDetail.inactive")}),r.jsx("span",{className:"text-muted-foreground/50 text-sm",children:"·"}),r.jsx(Zp,{id:e.created_by,size:"2xs",className:"text-sm text-muted-foreground"})]})]}),r.jsxs("div",{className:"flex flex-col gap-2.5",children:[r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsx("span",{className:"text-xs font-semibold text-muted-foreground/60",children:i("automations.automationDetail.starter")}),r.jsx(MO,{automationId:t,open:b,onOpenChange:_,onCustomSelect:()=>{j(!0),V(!1),C("")},onEventSelect:()=>{V(!0),j(!1)},onWebhookCreated:G=>{$e("automation_trigger_added",{automation_id:t,trigger_type:"webhook"}),T(G)}})]}),e.triggers.length===0&&!w?r.jsx("div",{className:"rounded-lg border border-dashed border-border px-4 py-6 text-center",children:r.jsxs("p",{className:"text-sm text-muted-foreground",children:[i("automations.automationDetail.whenShouldRun")," ",r.jsx("button",{type:"button",className:"text-foreground underline underline-offset-2 cursor-pointer hover:text-foreground/80 transition-colors",onClick:()=>_(!0),children:i("automations.automationDetail.addStarter")})," ",i("automations.automationDetail.toGetGoing")]})}):r.jsx("div",{className:"flex flex-col gap-2",children:e.triggers.map(G=>r.jsx(OO,{trigger:G,automationId:t,connectionName:G.connection_id?u.get(G.connection_id):void 0},G.id))}),w&&r.jsxs("div",{className:"flex items-center gap-2.5 px-3 py-2.5 rounded-lg border border-border bg-background group",children:[r.jsx(bo,{size:14,className:"text-muted-foreground shrink-0"}),r.jsx("input",{type:"text",value:S,onChange:G=>C(G.target.value),onBlur:async()=>{const G=S.trim();if(!(!G||!No(G)))try{await c.mutateAsync({automation_id:t,type:"cron",cron_expression:G}),$e("automation_trigger_added",{automation_id:t,trigger_type:"cron"}),ge.success(i("automations.automationDetail.starterAdded")),j(!1),C("")}catch{ge.error(i("automations.automationDetail.failedToAddStarter"))}},onKeyDown:async G=>{const te=S.trim();G.key==="Enter"&&te&&No(te)&&G.target.blur(),G.key==="Escape"&&(j(!1),C(""))},placeholder:"0 9 * * 1-5",className:"flex-1 text-sm font-mono bg-transparent outline-none placeholder:text-muted-foreground/40",autoFocus:!0}),S&&!No(S)&&r.jsx("span",{className:"text-xs text-muted-foreground/60 shrink-0",children:i("automations.automationDetail.invalid")}),c.isPending&&r.jsx(et,{size:13,className:"animate-spin text-muted-foreground shrink-0"}),r.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:()=>{j(!1),C("")},children:r.jsx(Pn,{size:13})})]}),N&&r.jsx(A.Suspense,{fallback:r.jsxs("div",{className:"flex items-center gap-2 px-3 py-3 rounded-lg border border-border bg-background",children:[r.jsx(et,{size:13,className:"animate-spin text-muted-foreground"}),r.jsx("span",{className:"text-sm text-muted-foreground",children:i("automations.automationDetail.loadingConnections")})]}),children:r.jsx(BO,{automationId:t,onDone:()=>V(!1)})}),r.jsx(B4,{open:E!==null,onOpenChange:G=>{G||T(null)},url:E?.url??null,token:E?.token??null})]}),r.jsxs("div",{className:"flex flex-col gap-2.5",children:[r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsx("span",{className:"text-xs font-semibold text-muted-foreground/60",children:i("automations.automationDetail.instructions")}),r.jsxs(le,{variant:"outline",size:"sm",className:"h-7 gap-1.5 px-2 text-xs",disabled:k||!x,onClick:O,children:[r.jsx(Gn,{size:13}),i("automations.automationDetail.improve")]})]}),r.jsx(kp,{tiptapDoc:x,setTiptapDoc:Y,placeholder:i("automations.automationDetail.instructionsPlaceholder"),children:r.jsxs("div",{className:"rounded-xl border border-border min-h-[120px] flex flex-col",children:[r.jsx(Vp,{virtualMcpId:o||null,className:"max-h-[45vh]"}),r.jsx("div",{className:"@container/chat-bottom flex items-center justify-end gap-1.5 p-2.5",children:r.jsxs(He,{children:[r.jsx(Ke,{asChild:!0,children:r.jsxs(le,{type:"button",variant:"default",className:"h-8 gap-1.5 rounded-md px-3 text-sm font-medium",onClick:ee,disabled:!o,children:[r.jsx(W0,{size:16}),i("automations.automationDetail.test")]})}),r.jsx(Ue,{children:i("automations.automationDetail.testAutomation")})]})})]})})]}),r.jsxs(Wx,{open:y,onOpenChange:L,className:"flex flex-col gap-2.5",children:[r.jsxs(qx,{className:"group flex w-fit cursor-pointer items-center gap-1.5",children:[r.jsx("span",{className:"text-xs font-semibold text-muted-foreground/60",children:i("automations.automationDetail.advanced")}),r.jsx(ss,{size:14,className:"text-muted-foreground/60 transition-transform group-data-[state=open]:rotate-180"})]}),r.jsxs(Gx,{className:"flex flex-col gap-5 pt-0.5",children:[r.jsx(_O,{tier:z.watch("tier"),onTierChange:G=>z.setValue("tier",G,{shouldDirty:!0}),override:z.watch("modelOverride"),onOverrideChange:G=>z.setValue("modelOverride",G,{shouldDirty:!0})}),r.jsx(jO,{agentId:o||null,value:z.watch("tools"),onChange:G=>z.setValue("tools",G,{shouldDirty:!0})}),r.jsxs("div",{className:"flex flex-col gap-2",children:[r.jsx("span",{className:"text-xs font-semibold text-muted-foreground/60",children:i("automations.automationDetail.maxSteps")}),r.jsx(rt,{type:"number",min:1,max:100,className:"w-40",placeholder:i("automations.automationDetail.maxStepsPlaceholder",{default:UO}),value:z.watch("maxAgentSteps")??"",onChange:G=>{const te=G.target.value.trim(),se=te===""?null:Number(te);z.setValue("maxAgentSteps",se===null||Number.isNaN(se)?null:se,{shouldDirty:!0})}})]})]})]})]})]})}const F4=[{key:"24h",labelKey:"mainPanelTabs.automationTab.last24hours",ms:1440*60*1e3},{key:"7d",labelKey:"mainPanelTabs.automationTab.last7days",ms:10080*60*1e3},{key:"30d",labelKey:"mainPanelTabs.automationTab.last30days",ms:720*60*60*1e3}];function z4(t){const e=F4.find(n=>n.key===t).ms,s=Date.now();return{startDate:new Date(s-e).toISOString(),endDate:new Date(s).toISOString()}}function qO(t){const e=B.c(16),{automationId:s,triggerIds:n}=t,i=re(),[o,a]=A.useState("30d"),[l,c]=A.useState(GO);let d;e[0]===Symbol.for("react.memo_cache_sentinel")?(d=x=>{const v=x;a(v),c(z4(v))},e[0]=d):d=e[0];let h;e[1]===Symbol.for("react.memo_cache_sentinel")?(h=r.jsx(Jt,{className:"w-44",children:r.jsx(as,{})}),e[1]=h):h=e[1];let u;e[2]!==i?(u=F4.map(x=>r.jsx(vt,{value:x.key,children:i(x.labelKey)},x.key)),e[2]=i,e[3]=u):u=e[3];let f;e[4]!==u?(f=r.jsx(Xt,{children:u}),e[4]=u,e[5]=f):f=e[5];let m;e[6]!==f||e[7]!==o?(m=r.jsx("div",{className:"flex items-center justify-end",children:r.jsxs(Qt,{value:o,onValueChange:d,children:[h,f]})}),e[6]=f,e[7]=o,e[8]=m):m=e[8];let p;e[9]!==s||e[10]!==l||e[11]!==n?(p=r.jsx(Yx,{automationId:s,triggerIds:n,range:l}),e[9]=s,e[10]=l,e[11]=n,e[12]=p):p=e[12];let g;return e[13]!==m||e[14]!==p?(g=r.jsxs("div",{className:"flex flex-col gap-5",children:[m,p]}),e[13]=m,e[14]=p,e[15]=g):g=e[15],g}function GO(){return z4("30d")}function YO(t){const e=B.c(5),{tabId:s}=t;let n;e[0]!==s?(n=f2(s),e[0]=s,e[1]=n):n=e[1];const i=n;if(!i)return null;let o;e[2]===Symbol.for("react.memo_cache_sentinel")?(o=r.jsx(Ti,{}),e[2]=o):o=e[2];let a;return e[3]!==i.id?(a=r.jsx(A.Suspense,{fallback:o,children:r.jsx(JO,{id:i.id})}),e[3]=i.id,e[4]=a):a=e[4],a}function JO(t){const e=B.c(41),{id:s}=t,n=re(),i=St(),{data:o,isLoading:a}=o8(s),[l,c]=A.useState("settings");let d;e[0]!==i?(d=()=>{i({to:".",search:QO,replace:!0})},e[0]=i,e[1]=d):d=e[1];const h=d;if(a){let N;return e[2]===Symbol.for("react.memo_cache_sentinel")?(N=r.jsx(Ti,{}),e[2]=N):N=e[2],N}if(!o){let N;e[3]!==n?(N=n("mainPanelTabs.automationTab.automationNotFound"),e[3]=n,e[4]=N):N=e[4];let V;return e[5]!==N?(V=r.jsx("div",{className:"flex h-full w-full items-center justify-center text-sm text-muted-foreground",children:N}),e[5]=N,e[6]=V):V=e[6],V}let u;e[7]!==o.triggers?(u=o.triggers.map(XO),e[7]=o.triggers,e[8]=u):u=e[8];const f=u;let m;e[9]===Symbol.for("react.memo_cache_sentinel")?(m=r.jsx(Xl,{size:14}),e[9]=m):m=e[9];let p;e[10]!==n?(p=n("mainPanelTabs.automationTab.backToList"),e[10]=n,e[11]=p):p=e[11];let g;e[12]!==h||e[13]!==p?(g=r.jsxs(le,{variant:"ghost",size:"sm",onClick:h,children:[m,p]}),e[12]=h,e[13]=p,e[14]=g):g=e[14];let x;e[15]!==n?(x=n("mainPanelTabs.automationTab.settings"),e[15]=n,e[16]=x):x=e[16];let v;e[17]!==x?(v={id:"settings",label:x},e[17]=x,e[18]=v):v=e[18];let b;e[19]!==n?(b=n("mainPanelTabs.automationTab.runs"),e[19]=n,e[20]=b):b=e[20];let _;e[21]!==b?(_={id:"runs",label:b},e[21]=b,e[22]=_):_=e[22];let y;e[23]!==v||e[24]!==_?(y=[v,_],e[23]=v,e[24]=_,e[25]=y):y=e[25];let L;e[26]===Symbol.for("react.memo_cache_sentinel")?(L=N=>c(N),e[26]=L):L=e[26];let w;e[27]!==y||e[28]!==l?(w=r.jsx(j2,{tabs:y,activeTab:l,onTabChange:L}),e[27]=y,e[28]=l,e[29]=w):w=e[29];let j;e[30]!==w||e[31]!==g?(j=r.jsxs("div",{className:"flex items-center justify-between pb-4 shrink-0",children:[g,w]}),e[30]=w,e[31]=g,e[32]=j):j=e[32];let S;e[33]!==o||e[34]!==s||e[35]!==l||e[36]!==f?(S=l==="settings"?r.jsx(WO,{automationId:s,automation:o}):r.jsx(qO,{automationId:s,triggerIds:f}),e[33]=o,e[34]=s,e[35]=l,e[36]=f,e[37]=S):S=e[37];let C;return e[38]!==j||e[39]!==S?(C=r.jsx(en,{children:r.jsx(en.Content,{children:r.jsxs(en.Body,{children:[j,S]})})}),e[38]=j,e[39]=S,e[40]=C):C=e[40],C}function XO(t){return t.id}function QO(t){return{...t,main:"automations"}}function ZO(t){const e=B.c(29),{virtualMcpId:s}=t,n=re(),i=St(),{data:o}=a8(s),a=o===void 0?[]:o,{create:l}=la(),[c,d]=A.useState(""),h=c.toLowerCase(),u=a.filter(P=>P.name.toLowerCase().includes(h));let f;e[0]!==i?(f=P=>i({to:".",search:D=>({...D,main:"automation:"+P}),replace:!0}),e[0]=i,e[1]=f):f=e[1];const m=f,p=async()=>{if(l.isPending)return;$e("automation_new_clicked",{virtual_mcp_id:s,existing_count:a.length});const P=await l.mutateAsync(l8(s));m(P.id)},g=l.isPending;let x;e[2]===Symbol.for("react.memo_cache_sentinel")?(x=r.jsx(kt,{size:14}),e[2]=x):x=e[2];let v;e[3]!==n?(v=n("automations.automationsList.newAutomation"),e[3]=n,e[4]=v):v=e[4];let b;e[5]!==l.isPending||e[6]!==p||e[7]!==v?(b=r.jsxs(le,{size:"sm",onClick:p,disabled:g,children:[x,v]}),e[5]=l.isPending,e[6]=p,e[7]=v,e[8]=b):b=e[8];const _=b,y=en,L=en,w=en;let j;e[9]!==n?(j=n("automations.automationsList.title"),e[9]=n,e[10]=j):j=e[10];let S;e[11]!==j?(S=r.jsx(en.Title,{children:j}),e[11]=j,e[12]=S):S=e[12];const C=a.length>0&&r.jsx(v9,{value:c,onChange:d,placeholder:n("automations.automationsList.searchPlaceholder"),className:"w-full md:w-[375px]"});let N;e[13]!==_||e[14]!==C?(N=r.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[C,_]}),e[13]=_,e[14]=C,e[15]=N):N=e[15];let V;e[16]!==S||e[17]!==N?(V=r.jsxs("div",{className:"flex flex-col gap-6",children:[S,N]}),e[16]=S,e[17]=N,e[18]=V):V=e[18];const E=a.length===0?r.jsx("div",{className:"flex items-center justify-center py-20",children:r.jsx(ki,{image:r.jsx(Ni,{size:48,className:"text-muted-foreground"}),title:n("automations.automationsList.emptyTitle"),description:n("automations.automationsList.emptyDescription"),actions:_})}):u.length===0?r.jsx("div",{className:"flex items-center justify-center py-20",children:r.jsx(ki,{image:r.jsx(Ni,{size:48,className:"text-muted-foreground"}),title:n("automations.automationsList.noResultsTitle"),description:n("automations.automationsList.noResultsDescription",{search:c})})}):r.jsx("div",{className:"mt-6 rounded-xl border border-border overflow-hidden",children:u.map(P=>r.jsx(c8,{automation:P,onClick:()=>m(P.id)},P.id))});let T;e[19]!==V||e[20]!==E||e[21]!==w.Body?(T=r.jsxs(w.Body,{children:[V,E]}),e[19]=V,e[20]=E,e[21]=w.Body,e[22]=T):T=e[22];let k;e[23]!==T||e[24]!==L.Content?(k=r.jsx(L.Content,{children:T}),e[23]=T,e[24]=L.Content,e[25]=k):k=e[25];let R;return e[26]!==y||e[27]!==k?(R=r.jsx(y,{children:k}),e[26]=y,e[27]=k,e[28]=R):R=e[28],R}function e$(t){const e=B.c(3),{virtualMcpId:s}=t;let n;e[0]===Symbol.for("react.memo_cache_sentinel")?(n=r.jsx(Ti,{}),e[0]=n):n=e[0];let i;return e[1]!==s?(i=r.jsx(A.Suspense,{fallback:n,children:r.jsx(ZO,{virtualMcpId:s})}),e[1]=s,e[2]=i):i=e[2],i}function t$(t){const e=B.c(49),{file:s,onClose:n}=t,i=re();let o,a;e[0]!==s.filename?(o=r.jsx(pr,{filename:s.filename,className:"h-4.5 w-3.5 shrink-0"}),a=r.jsx("span",{className:"truncate text-xs font-medium text-foreground",children:s.filename}),e[0]=s.filename,e[1]=o,e[2]=a):(o=e[1],a=e[2]);let l;e[3]!==s.size?(l=Q6(s.size),e[3]=s.size,e[4]=l):l=e[4];let c;e[5]!==l?(c=r.jsx("span",{className:"shrink-0 text-xs text-muted-foreground",children:l}),e[5]=l,e[6]=c):c=e[6];let d;e[7]!==o||e[8]!==a||e[9]!==c?(d=r.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-2 px-2",children:[o,a,c]}),e[7]=o,e[8]=a,e[9]=c,e[10]=d):d=e[10];let h;e[11]===Symbol.for("react.memo_cache_sentinel")?(h=r.jsx(Cb,{size:14}),e[11]=h):h=e[11];let u;e[12]!==s.downloadUrl||e[13]!==s.filename?(u=r.jsx(Ke,{asChild:!0,children:r.jsx(le,{variant:"ghost",size:"icon",asChild:!0,children:r.jsx("a",{href:s.downloadUrl,download:s.filename,children:h})})}),e[12]=s.downloadUrl,e[13]=s.filename,e[14]=u):u=e[14];let f;e[15]!==i?(f=i("mainPanelTabs.fileTab.download"),e[15]=i,e[16]=f):f=e[16];let m;e[17]!==f?(m=r.jsx(Ue,{side:"bottom",children:f}),e[17]=f,e[18]=m):m=e[18];let p;e[19]!==u||e[20]!==m?(p=r.jsxs(He,{children:[u,m]}),e[19]=u,e[20]=m,e[21]=p):p=e[21];let g;e[22]!==s.downloadUrl?(g=()=>window.open(s.downloadUrl,"_blank","noopener"),e[22]=s.downloadUrl,e[23]=g):g=e[23];let x;e[24]===Symbol.for("react.memo_cache_sentinel")?(x=r.jsx(Dn,{size:14}),e[24]=x):x=e[24];let v;e[25]!==g?(v=r.jsx(Ke,{asChild:!0,children:r.jsx(le,{variant:"ghost",size:"icon",onClick:g,children:x})}),e[25]=g,e[26]=v):v=e[26];let b;e[27]!==i?(b=i("mainPanelTabs.fileTab.openInNewTab"),e[27]=i,e[28]=b):b=e[28];let _;e[29]!==b?(_=r.jsx(Ue,{side:"bottom",children:b}),e[29]=b,e[30]=_):_=e[30];let y;e[31]!==v||e[32]!==_?(y=r.jsxs(He,{children:[v,_]}),e[31]=v,e[32]=_,e[33]=y):y=e[33];let L;e[34]===Symbol.for("react.memo_cache_sentinel")?(L=r.jsx(Pn,{size:14}),e[34]=L):L=e[34];let w;e[35]!==n?(w=r.jsx(Ke,{asChild:!0,children:r.jsx(le,{variant:"ghost",size:"icon",onClick:n,children:L})}),e[35]=n,e[36]=w):w=e[36];let j;e[37]!==i?(j=i("mainPanelTabs.fileTab.close"),e[37]=i,e[38]=j):j=e[38];let S;e[39]!==j?(S=r.jsx(Ue,{side:"bottom",children:j}),e[39]=j,e[40]=S):S=e[40];let C;e[41]!==w||e[42]!==S?(C=r.jsxs(He,{children:[w,S]}),e[41]=w,e[42]=S,e[43]=C):C=e[43];let N;return e[44]!==p||e[45]!==y||e[46]!==C||e[47]!==d?(N=r.jsxs("div",{className:"flex h-9 shrink-0 items-center gap-1 border-b border-border/60 px-2",children:[d,p,y,C]}),e[44]=p,e[45]=y,e[46]=C,e[47]=d,e[48]=N):N=e[48],N}function s$(t){const e=B.c(31),{fileKey:s,taskId:n}=t,i=re(),o=St(),{data:a,isPending:l}=wm(n);let c;e[0]!==s||e[1]!==a?(c=a?.find(g=>g.key===s)??null,e[0]=s,e[1]=a,e[2]=c):c=e[2];const d=c;let h;e[3]!==o?(h=()=>o({to:".",search:n$,replace:!0}),e[3]=o,e[4]=h):h=e[4];const u=h;if(!d){if(l){let w;return e[5]===Symbol.for("react.memo_cache_sentinel")?(w=r.jsx("div",{className:"h-full w-full bg-background",children:r.jsx(J6,{})}),e[5]=w):w=e[5],w}let g;e[6]!==s?(g=s.split("/").pop()??s,e[6]=s,e[7]=g):g=e[7];let x;e[8]!==g?(x=r.jsx(pr,{filename:g,className:"h-7.5 w-6"}),e[8]=g,e[9]=x):x=e[9];let v;e[10]!==i?(v=i("mainPanelTabs.fileTab.fileNotAvailable"),e[10]=i,e[11]=v):v=e[11];let b;e[12]!==v?(b=r.jsx("span",{className:"text-sm text-muted-foreground",children:v}),e[12]=v,e[13]=b):b=e[13];let _;e[14]!==i?(_=i("mainPanelTabs.fileTab.close"),e[14]=i,e[15]=_):_=e[15];let y;e[16]!==u||e[17]!==_?(y=r.jsx(le,{variant:"ghost",size:"sm",onClick:u,children:_}),e[16]=u,e[17]=_,e[18]=y):y=e[18];let L;return e[19]!==x||e[20]!==b||e[21]!==y?(L=r.jsxs("div",{className:"flex h-full w-full flex-col items-center justify-center gap-2 bg-background",children:[x,b,y]}),e[19]=x,e[20]=b,e[21]=y,e[22]=L):L=e[22],L}let f;e[23]!==d||e[24]!==u?(f=r.jsx(t$,{file:d,onClose:u}),e[23]=d,e[24]=u,e[25]=f):f=e[25];let m;e[26]!==d?(m=r.jsx("div",{className:"relative min-h-0 flex-1",children:r.jsx(X6,{file:d})}),e[26]=d,e[27]=m):m=e[27];let p;return e[28]!==f||e[29]!==m?(p=r.jsxs("div",{className:"flex h-full w-full flex-col bg-background",children:[f,m]}),e[28]=f,e[29]=m,e[30]=p):p=e[30],p}function n$(t){return{...t,main:0}}const gd="home";function i$(t){const e=B.c(5),{label:s}=t;let n;e[0]===Symbol.for("react.memo_cache_sentinel")?(n=r.jsx(Rt,{className:"aspect-video w-2/3 max-w-xl"}),e[0]=n):n=e[0];let i;e[1]!==s?(i=s&&r.jsx("p",{className:"text-xs text-muted-foreground",children:s}),e[1]=s,e[2]=i):i=e[2];let o;return e[3]!==i?(o=r.jsxs("div",{className:"flex h-full w-full flex-col items-center justify-center gap-3 bg-background",children:[n,i]}),e[3]=i,e[4]=o):o=e[4],o}function r$(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 i=Z6(gd,s,n),o=eb(gd)(s);if(i.isPending||!i.data){const f=!i.isPending&&!i.data?"Waiting for the deck to sync…":void 0;let m;return e[1]!==f?(m=r.jsx(i$,{label:f}),e[1]=f,e[2]=m):m=e[2],m}let a;e[3]!==i.data?(a=tb(i.data),e[3]=i.data,e[4]=a):a=e[4];const l=i.data.shareMode??"private",c=i.data.effectivePublic??!1,d=window.location.origin+o;let h;e[5]!==s||e[6]!==l||e[7]!==c||e[8]!==d?(h=r.jsx(sb,{volume:gd,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=r.jsx(nb,{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 o$(t){const e=B.c(5),{path:s}=t,n=St();let i;e[0]!==n?(i=()=>n({to:".",search:a$,replace:!0}),e[0]=n,e[1]=i):i=e[1];const o=i;let a;return e[2]!==o||e[3]!==s?(a=r.jsx(ib,{previewPath:s,onClose:o,showSeeInLibrary:!0}),e[2]=o,e[3]=s,e[4]=a):a=e[4],a}function a$(t){return{...t,main:0}}function l$(){const t=B.c(12),e=St(),[s,n]=A.useState(null),[i,o]=A.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=r.jsx(rb,{onOpenFile:f=>l(xb(f)),onOpenSkill:n,onOpenBrand:o}),t[2]=l,t[3]=c):c=t[3];let d;t[4]!==s?(d=s&&r.jsx(ob,{skillPath:s,onClose:()=>n(null)},s),t[4]=s,t[5]=d):d=t[5];let h;t[6]!==i?(h=i&&r.jsx(ab,{brandPath:i,onClose:()=>o(null)},i),t[6]=i,t[7]=h):h=t[7];let u;return t[8]!==c||t[9]!==d||t[10]!==h?(u=r.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 h1=A.lazy(()=>$s(()=>import("./project-app-view-CRipBtzb.js"),__vite__mapDeps([172,1,2,52,53,54,17,3,19,55,56,57,58,59,60,61,62,32,63,50,64,65,66,67,68,5,16,20,4,6,7,8,9,10,11,12,13,14,15,18,21,22,23,24,25,26,27,28,29,30,31,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,51,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,113,107,108,109,110,111,112,114,115,116,117,103,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,149,150,105,151,152,153,154,155,156])).then(t=>({default:t.AppViewContent})));function c$(t){const e=B.c(60),{activeTab:s,virtualMcpId:n,taskId:i,layoutTabs:o,expandedTools:a,automationTabParsed:l}=t;if(s==="overview"){let L;return e[0]===Symbol.for("react.memo_cache_sentinel")?(L=r.jsx(ZN,{}),e[0]=L):L=e[0],L}if(s==="board"){let L;return e[1]===Symbol.for("react.memo_cache_sentinel")?(L=r.jsx("div",{className:"flex h-full min-h-0 flex-col overflow-hidden",children:r.jsx(Fv,{})}),e[1]=L):L=e[1],L}if(vb(s)){let L;return e[2]!==n?(L=r.jsx(Uh,{virtualMcpId:n}),e[2]=n,e[3]=L):L=e[3],L}if(s==="git"){let L;return e[4]!==n?(L=r.jsx(nA,{virtualMcpId:n}),e[4]=n,e[5]=L):L=e[5],L}if(s==="automations"){let L;return e[6]!==n?(L=r.jsx(e$,{virtualMcpId:n}),e[6]=n,e[7]=L):L=e[7],L}if(s==="preview"){let L;return e[8]!==n?(L=r.jsx(fP,{virtualMcpId:n}),e[8]=n,e[9]=L):L=e[9],L}let c;e[10]!==s?(c=bb(s),e[10]=s,e[11]=c):c=e[11];const d=c;if(d){let L;return e[12]!==d.path?(L=r.jsx(xP,{openPath:d.path}),e[12]=d.path,e[13]=L):L=e[13],L}if(s==="content"){let L;return e[14]!==n?(L=r.jsx(vO,{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=r.jsx(l$,{}),e[16]=L):L=e[16],L}if(l){let L;return e[17]!==s?(L=r.jsx(YO,{tabId:s}),e[17]=s,e[18]=L):L=e[18],L}let h;e[19]!==s?(h=p2(s),e[19]=s,e[20]=h):h=e[20];const u=h;if(u){let L;return e[21]!==u.path?(L=r.jsx(r$,{path:u.path},u.path),e[21]=u.path,e[22]=L):L=e[22],L}let f;e[23]!==s?(f=m2(s),e[23]=s,e[24]=f):f=e[24];const m=f;if(m){let L;return e[25]!==m.key||e[26]!==i?(L=r.jsx(s$,{fileKey:m.key,taskId:i}),e[25]=m.key,e[26]=i,e[27]=L):L=e[27],L}let p;e[28]!==s?(p=g2(s),e[28]=s,e[29]=p):p=e[29];const g=p;if(g){let L;return e[30]!==g.path?(L=r.jsx(o$,{path:g.path},g.path),e[30]=g.path,e[31]=L):L=e[31],L}let x;e[32]!==s?(x=yb(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 N;e[38]!==v.connectionId||e[39]!==v.toolName?(N=V=>V.appId===v.connectionId&&V.toolName===v.toolName,e[38]=v.connectionId,e[39]=v.toolName,e[40]=N):N=e[40],L=a.find(N),e[34]=a,e[35]=v.connectionId,e[36]=v.toolName,e[37]=L}else L=e[37];const w=L;let j;e[41]===Symbol.for("react.memo_cache_sentinel")?(j=r.jsx(Ti,{}),e[41]=j):j=e[41];const S=w?.args;let C;return e[42]!==s||e[43]!==v.connectionId||e[44]!==v.toolName||e[45]!==S?(C=r.jsx(A.Suspense,{fallback:j,children:r.jsx(h1,{connectionId:v.connectionId,toolName:v.toolName,args:S},s)}),e[42]=s,e[43]=v.connectionId,e[44]=v.toolName,e[45]=S,e[46]=C):C=e[46],C}let b;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],b=o.find(L),e[47]=s,e[48]=o,e[49]=b}else b=e[49];const _=b;if(_){let L;e[52]===Symbol.for("react.memo_cache_sentinel")?(L=r.jsx(Ti,{}),e[52]=L):L=e[52];let w;return e[53]!==s||e[54]!==_.id||e[55]!==_.view.appId||e[56]!==_.view.args?(w=r.jsx(A.Suspense,{fallback:L,children:r.jsx(h1,{connectionId:_.view.appId,toolName:_.id,args:_.view.args},s)}),e[53]=s,e[54]=_.id,e[55]=_.view.appId,e[56]=_.view.args,e[57]=w):w=e[57],w}let y;return e[58]!==n?(y=r.jsx(Uh,{virtualMcpId:n}),e[58]=n,e[59]=y):y=e[59],y}function d$(t){const e=B.c(14),{taskId:s,virtualMcpId:n}=t;let i;e[0]!==s||e[1]!==n?(i={virtualMcpId:n,taskId:s},e[0]=s,e[1]=n,e[2]=i):i=e[2];const{activeTab:o,layoutTabs:a,expandedTools:l,automationTabParsed:c}=H9(i);let d;e[3]===Symbol.for("react.memo_cache_sentinel")?(d=r.jsx(Ti,{}),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=r.jsx(A.Suspense,{fallback:d,children:r.jsx(c$,{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=r.jsx(_s,{children:h},o),e[11]=o,e[12]=h,e[13]=u):u=e[13],u}const Li="setup";function u$(t){const e=B.c(38),s=re();let n;if(e[0]!==t.scriptTabs||e[1]!==t.scripts){let p;e[3]!==t.scriptTabs?(p=g=>!t.scriptTabs.includes(g),e[3]=t.scriptTabs,e[4]=p):p=e[4],n=t.scripts.filter(p),e[0]=t.scriptTabs,e[1]=t.scripts,e[2]=n}else n=e[2];const i=n;let o;e[5]!==t?(o=()=>{t.active===Li?t.onToggle():t.onSelectTab(Li)},e[5]=t,e[6]=o):o=e[6];const a=o,l=t.active===Li;let c;e[7]!==a||e[8]!==t.open||e[9]!==s||e[10]!==l?(c=r.jsx(h$,{active:l,open:t.open,onClick:a,t:s}),e[7]=a,e[8]=t.open,e[9]=s,e[10]=l,e[11]=c):c=e[11];let d;e[12]!==t||e[13]!==s?(d=t.scriptTabs.map(p=>r.jsx(m$,{active:t.active===p,onClick:()=>{t.active===p?t.onToggle():t.onSelectTab(p)},onClose:()=>t.onCloseScript(p),t:s,children:p},p)),e[12]=t,e[13]=s,e[14]=d):d=e[14];let h;e[15]!==i||e[16]!==t.onAddScript?(h=r.jsx(p$,{scripts:i,onRun:t.onAddScript}),e[15]=i,e[16]=t.onAddScript,e[17]=h):h=e[17];let u;e[18]!==c||e[19]!==d||e[20]!==h?(u=r.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-1 overflow-x-auto",children:[c,d,h]}),e[18]=c,e[19]=d,e[20]=h,e[21]=u):u=e[21];let f;e[22]!==t.onRestart||e[23]!==t.onResume||e[24]!==t.onRetry||e[25]!==t.onRunActiveScript||e[26]!==t.onStart||e[27]!==t.onStop||e[28]!==t.onStopActiveScript||e[29]!==t.scriptIsKilling||e[30]!==t.scriptIsRunning||e[31]!==t.showScriptControls||e[32]!==t.status||e[33]!==s?(f=t.showScriptControls?r.jsx(g$,{isRunning:t.scriptIsRunning,isKilling:t.scriptIsKilling,onRun:t.onRunActiveScript,onStop:t.onStopActiveScript,t:s}):r.jsx(f$,{status:t.status,onStart:t.onStart,onStop:t.onStop,onRestart:t.onRestart,onResume:t.onResume,onRetry:t.onRetry,t:s}),e[22]=t.onRestart,e[23]=t.onResume,e[24]=t.onRetry,e[25]=t.onRunActiveScript,e[26]=t.onStart,e[27]=t.onStop,e[28]=t.onStopActiveScript,e[29]=t.scriptIsKilling,e[30]=t.scriptIsRunning,e[31]=t.showScriptControls,e[32]=t.status,e[33]=s,e[34]=f):f=e[34];let m;return e[35]!==u||e[36]!==f?(m=r.jsxs("div",{className:"flex h-10 shrink-0 items-center gap-1 border-t border-b border-border bg-muted/60 px-3",children:[u,f]}),e[35]=u,e[36]=f,e[37]=m):m=e[37],m}function h$(t){const e=B.c(11),{active:s,open:n,onClick:i,t:o}=t,a=s&&n,l=s&&n,c=s?"border-border bg-background font-medium text-foreground shadow-sm":"border-transparent text-muted-foreground hover:bg-background/50 hover:text-foreground";let d;e[0]!==c?(d=ie("flex h-7 items-center gap-1.5 rounded-md border px-2.5 text-xs",c),e[0]=c,e[1]=d):d=e[1];let h;e[2]===Symbol.for("react.memo_cache_sentinel")?(h=r.jsx(S6,{className:"size-3.5"}),e[2]=h):h=e[2];let u;e[3]!==o?(u=o("sandbox.toolbar.setupTab"),e[3]=o,e[4]=u):u=e[4];let f;return e[5]!==i||e[6]!==a||e[7]!==l||e[8]!==d||e[9]!==u?(f=r.jsxs("button",{type:"button","aria-pressed":a,"aria-expanded":l,onClick:i,className:d,children:[h,u]}),e[5]=i,e[6]=a,e[7]=l,e[8]=d,e[9]=u,e[10]=f):f=e[10],f}function f$(t){const e=B.c(41),{status:s,onStart:n,onStop:i,onRestart:o,onResume:a,onRetry:l,t:c}=t;if(s==="idle"&&n){let d;e[0]===Symbol.for("react.memo_cache_sentinel")?(d=r.jsx(Vi,{className:"size-3.5"}),e[0]=d):d=e[0];let h;e[1]!==c?(h=c("sandbox.toolbar.start"),e[1]=c,e[2]=h):h=e[2];let u;return e[3]!==n||e[4]!==h?(u=r.jsxs(le,{variant:"outline",size:"sm",onClick:n,children:[d," ",h]}),e[3]=n,e[4]=h,e[5]=u):u=e[5],u}if(s==="suspended"&&a){let d;e[6]===Symbol.for("react.memo_cache_sentinel")?(d=r.jsx(Vi,{className:"size-3.5"}),e[6]=d):d=e[6];let h;e[7]!==c?(h=c("sandbox.toolbar.resume"),e[7]=c,e[8]=h):h=e[8];let u;return e[9]!==a||e[10]!==h?(u=r.jsxs(le,{variant:"outline",size:"sm",onClick:a,children:[d," ",h]}),e[9]=a,e[10]=h,e[11]=u):u=e[11],u}if(s==="errored"&&l){let d;e[12]===Symbol.for("react.memo_cache_sentinel")?(d=r.jsx(dr,{className:"size-3.5"}),e[12]=d):d=e[12];let h;e[13]!==c?(h=c("sandbox.toolbar.retry"),e[13]=c,e[14]=h):h=e[14];let u;return e[15]!==l||e[16]!==h?(u=r.jsxs(le,{variant:"outline",size:"sm",onClick:l,children:[d," ",h]}),e[15]=l,e[16]=h,e[17]=u):u=e[17],u}if(s==="starting"||s==="running"){const d=s==="running"&&!!o,h=d?"rounded-r-none border-r-0":void 0;let u;e[18]!==h?(u=ie(h),e[18]=h,e[19]=u):u=e[19];let f;e[20]===Symbol.for("react.memo_cache_sentinel")?(f=r.jsx(Zm,{className:"size-3.5"}),e[20]=f):f=e[20];let m;e[21]!==c?(m=c("sandbox.toolbar.stop"),e[21]=c,e[22]=m):m=e[22];let p;e[23]!==i||e[24]!==u||e[25]!==m?(p=r.jsx(Ke,{asChild:!0,children:r.jsxs(le,{variant:"outline",size:"sm",onClick:i,className:u,children:[f," ",m]})}),e[23]=i,e[24]=u,e[25]=m,e[26]=p):p=e[26];let g;e[27]!==c?(g=c("sandbox.toolbar.stopSandboxTooltip"),e[27]=c,e[28]=g):g=e[28];let x;e[29]!==g?(x=r.jsx(Ue,{children:g}),e[29]=g,e[30]=x):x=e[30];let v;e[31]!==p||e[32]!==x?(v=r.jsxs(He,{children:[p,x]}),e[31]=p,e[32]=x,e[33]=v):v=e[33];let b;e[34]!==o||e[35]!==d||e[36]!==c?(b=d&&r.jsxs(us,{children:[r.jsx(ds,{asChild:!0,children:r.jsx(le,{variant:"outline",size:"sm",className:"rounded-l-none px-1",children:r.jsx(ss,{className:"size-3"})})}),r.jsx(hs,{align:"end",children:r.jsxs(Xe,{onClick:o,children:[r.jsx(dr,{className:"size-3.5"})," ",c("sandbox.toolbar.restart")]})})]}),e[34]=o,e[35]=d,e[36]=c,e[37]=b):b=e[37];let _;return e[38]!==v||e[39]!==b?(_=r.jsxs("div",{className:"flex items-center",children:[v,b]}),e[38]=v,e[39]=b,e[40]=_):_=e[40],_}return null}function m$(t){const e=B.c(17),{active:s,onClick:n,onClose:i,children:o,t:a}=t,l=s?"border-border bg-background shadow-sm":"border-transparent hover:bg-background/50";let c;e[0]!==l?(c=ie("flex h-7 items-center rounded-md border text-xs",l),e[0]=l,e[1]=c):c=e[1];const d=i?"pl-2.5 pr-1":"px-2.5",h=s?"font-medium text-foreground":"text-muted-foreground hover:text-foreground";let u;e[2]!==d||e[3]!==h?(u=ie("flex h-full items-center",d,h),e[2]=d,e[3]=h,e[4]=u):u=e[4];let f;e[5]!==o||e[6]!==n||e[7]!==u?(f=r.jsx("button",{type:"button",onClick:n,className:u,children:o}),e[5]=o,e[6]=n,e[7]=u,e[8]=f):f=e[8];let m;e[9]!==o||e[10]!==i||e[11]!==a?(m=i&&r.jsx("button",{type:"button","aria-label":a("sandbox.toolbar.closeTab",{tab:String(o)}),onClick:i,className:"pr-1.5 text-muted-foreground hover:text-foreground",children:r.jsx(ks,{className:"size-3"})}),e[9]=o,e[10]=i,e[11]=a,e[12]=m):m=e[12];let p;return e[13]!==c||e[14]!==f||e[15]!==m?(p=r.jsxs("div",{className:c,children:[f,m]}),e[13]=c,e[14]=f,e[15]=m,e[16]=p):p=e[16],p}function p$(t){const e=B.c(27),{scripts:s,onRun:n}=t,i=re(),[o,a]=A.useState(!1);let l;e[0]!==i?(l=i("sandbox.toolbar.runScript"),e[0]=i,e[1]=l):l=e[1];let c;e[2]===Symbol.for("react.memo_cache_sentinel")?(c=r.jsx(kt,{className:"size-3.5"}),e[2]=c):c=e[2];let d;e[3]!==l?(d=r.jsx(Ke,{asChild:!0,children:r.jsx(Es,{asChild:!0,children:r.jsx(le,{variant:"ghost",size:"sm","aria-label":l,children:c})})}),e[3]=l,e[4]=d):d=e[4];let h;e[5]!==i?(h=i("sandbox.toolbar.runScript"),e[5]=i,e[6]=h):h=e[6];let u;e[7]!==h?(u=r.jsx(Ue,{children:h}),e[7]=h,e[8]=u):u=e[8];let f;e[9]!==d||e[10]!==u?(f=r.jsxs(He,{children:[d,u]}),e[9]=d,e[10]=u,e[11]=f):f=e[11];let m;e[12]!==i?(m=i("sandbox.toolbar.runAScript"),e[12]=i,e[13]=m):m=e[13];let p;e[14]!==m?(p=r.jsx("div",{className:"px-2 py-1 text-[10px] uppercase tracking-wide text-muted-foreground",children:m}),e[14]=m,e[15]=p):p=e[15];let g;e[16]!==n||e[17]!==s||e[18]!==i?(g=s.length===0?r.jsx("div",{className:"px-2 py-2 text-xs text-muted-foreground",children:i("sandbox.toolbar.noScriptsFound")}):s.map(b=>r.jsxs("button",{type:"button",onClick:()=>{a(!1),n(b)},className:"w-full rounded-md px-2 py-1.5 text-left text-xs hover:bg-accent",children:["▸ ",b]},b)),e[16]=n,e[17]=s,e[18]=i,e[19]=g):g=e[19];let x;e[20]!==p||e[21]!==g?(x=r.jsxs(Ps,{align:"start",className:"p-1 w-56",children:[p,g]}),e[20]=p,e[21]=g,e[22]=x):x=e[22];let v;return e[23]!==o||e[24]!==x||e[25]!==f?(v=r.jsxs(As,{open:o,onOpenChange:a,children:[f,x]}),e[23]=o,e[24]=x,e[25]=f,e[26]=v):v=e[26],v}function g$(t){const e=B.c(31),{isRunning:s,isKilling:n,onRun:i,onStop:o,t:a}=t;if(n){let m;e[0]===Symbol.for("react.memo_cache_sentinel")?(m=r.jsx(et,{className:"size-3.5 animate-spin"}),e[0]=m):m=e[0];let p;e[1]!==a?(p=a("sandbox.toolbar.stopping"),e[1]=a,e[2]=p):p=e[2];let g;return e[3]!==p?(g=r.jsxs(le,{variant:"outline",size:"sm",disabled:!0,children:[m," ",p]}),e[3]=p,e[4]=g):g=e[4],g}if(!s){let m;e[5]===Symbol.for("react.memo_cache_sentinel")?(m=r.jsx(Vi,{className:"size-3.5"}),e[5]=m):m=e[5];let p;e[6]!==a?(p=a("sandbox.toolbar.run"),e[6]=a,e[7]=p):p=e[7];let g;e[8]!==i||e[9]!==p?(g=r.jsx(Ke,{asChild:!0,children:r.jsxs(le,{variant:"outline",size:"sm",onClick:i,children:[m," ",p]})}),e[8]=i,e[9]=p,e[10]=g):g=e[10];let x;e[11]!==a?(x=a("sandbox.toolbar.startProcess"),e[11]=a,e[12]=x):x=e[12];let v;e[13]!==x?(v=r.jsx(Ue,{children:x}),e[13]=x,e[14]=v):v=e[14];let b;return e[15]!==g||e[16]!==v?(b=r.jsxs(He,{children:[g,v]}),e[15]=g,e[16]=v,e[17]=b):b=e[17],b}let l;e[18]===Symbol.for("react.memo_cache_sentinel")?(l=r.jsx(Zm,{className:"size-3.5"}),e[18]=l):l=e[18];let c;e[19]!==a?(c=a("sandbox.toolbar.stop"),e[19]=a,e[20]=c):c=e[20];let d;e[21]!==o||e[22]!==c?(d=r.jsx(Ke,{asChild:!0,children:r.jsxs(le,{variant:"outline",size:"sm",onClick:o,children:[l," ",c]})}),e[21]=o,e[22]=c,e[23]=d):d=e[23];let h;e[24]!==a?(h=a("sandbox.toolbar.stopProcess"),e[24]=a,e[25]=h):h=e[25];let u;e[26]!==h?(u=r.jsx(Ue,{children:h}),e[26]=h,e[27]=u):u=e[27];let f;return e[28]!==d||e[29]!==u?(f=r.jsxs(He,{children:[d,u]}),e[28]=d,e[29]=u,e[30]=f):f=e[30],f}var K4=Object.defineProperty,x$=Object.getOwnPropertyDescriptor,v$=(t,e)=>{for(var s in e)K4(t,s,{get:e[s],enumerable:!0})},At=(t,e,s,n)=>{for(var i=n>1?void 0:n?x$(e,s):e,o=t.length-1,a;o>=0;o--)(a=t[o])&&(i=(n?a(e,s,i):a(i))||i);return n&&i&&K4(e,s,i),i},Ie=(t,e)=>(s,n)=>e(s,n,t),f1="Terminal input",o0={get:()=>f1,set:t=>f1=t},m1="Too much output to announce, navigate to rows manually to read",a0={get:()=>m1,set:t=>m1=t};function b$(t){return t.replace(/\r?\n/g,"\r")}function y$(t,e){return e?"\x1B[200~"+t+"\x1B[201~":t}function _$(t,e){t.clipboardData&&t.clipboardData.setData("text/plain",e.selectionText),t.preventDefault()}function L$(t,e,s,n){if(t.stopPropagation(),t.clipboardData){let i=t.clipboardData.getData("text/plain");U4(i,e,s,n)}}function U4(t,e,s,n){t=b$(t),t=y$(t,s.decPrivateModes.bracketedPasteMode&&n.rawOptions.ignoreBracketedPasteMode!==!0),s.triggerDataEvent(t,!0),e.value=""}function H4(t,e,s){let n=s.getBoundingClientRect(),i=t.clientX-n.left-10,o=t.clientY-n.top-10;e.style.width="20px",e.style.height="20px",e.style.left=`${i}px`,e.style.top=`${o}px`,e.style.zIndex="1000",e.focus()}function p1(t,e,s,n,i){H4(t,e,s),i&&n.rightClickSelect(t),e.value=n.selectionText,e.select()}function Un(t){return t>65535?(t-=65536,String.fromCharCode((t>>10)+55296)+String.fromCharCode(t%1024+56320)):String.fromCharCode(t)}function Tc(t,e=0,s=t.length){let n="";for(let i=e;i<s;++i){let o=t[i];o>65535?(o-=65536,n+=String.fromCharCode((o>>10)+55296)+String.fromCharCode(o%1024+56320)):n+=String.fromCharCode(o)}return n}var S$=class{constructor(){this._interim=0}clear(){this._interim=0}decode(t,e){let s=t.length;if(!s)return 0;let n=0,i=0;if(this._interim){let o=t.charCodeAt(i++);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=i;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}},w$=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,i,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&&!((i=t[u])&128)&&!((o=t[u+1])&128)&&!((a=t[u+2])&128)&&!((l=t[u+3])&128);)e[n++]=i,e[n++]=o,e[n++]=a,e[n++]=l,u+=4;if(i=t[u++],i<128)e[n++]=i;else if((i&224)===192){if(u>=s)return this.interim[0]=i,n;if(o=t[u++],(o&192)!==128){u--;continue}if(c=(i&31)<<6|o&63,c<128){u--;continue}e[n++]=c}else if((i&240)===224){if(u>=s)return this.interim[0]=i,n;if(o=t[u++],(o&192)!==128){u--;continue}if(u>=s)return this.interim[0]=i,this.interim[1]=o,n;if(a=t[u++],(a&192)!==128){u--;continue}if(c=(i&15)<<12|(o&63)<<6|a&63,c<2048||c>=55296&&c<=57343||c===65279)continue;e[n++]=c}else if((i&248)===240){if(u>=s)return this.interim[0]=i,n;if(o=t[u++],(o&192)!==128){u--;continue}if(u>=s)return this.interim[0]=i,this.interim[1]=o,n;if(a=t[u++],(a&192)!==128){u--;continue}if(u>=s)return this.interim[0]=i,this.interim[1]=o,this.interim[2]=a,n;if(l=t[u++],(l&192)!==128){u--;continue}if(c=(i&7)<<18|(o&63)<<12|(a&63)<<6|l&63,c<65536||c>1114111)continue;e[n++]=c}}return n}},W4="",qn=" ",pa=class q4{constructor(){this.fg=0,this.bg=0,this.extended=new $l}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 q4;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}},$l=class G4{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 G4(this._ext,this._urlId)}isEmpty(){return this.underlineStyle===0&&this._urlId===0}},Gs=class Y4 extends pa{constructor(){super(...arguments),this.content=0,this.fg=0,this.bg=0,this.extended=new $l,this.combinedData=""}static fromCharData(e){let s=new Y4;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?Un(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 i=e[1].charCodeAt(1);56320<=i&&i<=57343?this.content=(n-55296)*1024+i-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()]}},g1="di$target",l0="di$dependencies",xd=new Map;function j$(t){return t[l0]||[]}function ns(t){if(xd.has(t))return xd.get(t);let e=function(s,n,i){if(arguments.length!==3)throw new Error("@IServiceName-decorator can only be used to decorate a parameter");C$(e,s,i)};return e._id=t,xd.set(t,e),e}function C$(t,e,s){e[g1]===e?e[l0].push({id:t,index:s}):(e[l0]=[{id:t,index:s}],e[g1]=e)}var ws=ns("BufferService"),J4=ns("CoreMouseService"),Gi=ns("CoreService"),k$=ns("CharsetService"),Au=ns("InstantiationService"),X4=ns("LogService"),js=ns("OptionsService"),Q4=ns("OscLinkService"),V$=ns("UnicodeService"),ga=ns("DecorationService"),c0=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=[],i=this._optionsService.rawOptions.linkHandler,o=new Gs,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(!i?.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)=>i?i.activate(p,g,f):N$(p,g),hover:(p,g)=>i?.hover?.(p,g,f),leave:(p,g)=>i?.leave?.(p,g,f)})}d=!1,o.hasExtendedAttrs()&&o.extended.urlId?(c=h,l=o.extended.urlId):(c=-1,l=-1)}}e(n)}};c0=At([Ie(0,ws),Ie(1,js),Ie(2,Q4)],c0);function N$(t,e){if(confirm(`Do you want to navigate to ${e}?
|
|
501
|
+
|
|
502
|
+
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 Ac=ns("CharSizeService"),Mn=ns("CoreBrowserService"),Eu=ns("MouseService"),On=ns("RenderService"),T$=ns("SelectionService"),Z4=ns("CharacterJoinerService"),zr=ns("ThemeService"),e5=ns("LinkProviderService"),A$=class{constructor(){this.listeners=[],this.unexpectedErrorHandler=function(t){setTimeout(()=>{throw t.stack?x1.isErrorNoTelemetry(t)?new x1(t.message+`
|
|
503
|
+
|
|
504
|
+
`+t.stack):new Error(t.message+`
|
|
505
|
+
|
|
506
|
+
`+t.stack):t},0)}}addListener(t){return this.listeners.push(t),()=>{this._removeListener(t)}}emit(t){this.listeners.forEach(e=>{e(t)})}_removeListener(t){this.listeners.splice(this.listeners.indexOf(t),1)}setUnexpectedErrorHandler(t){this.unexpectedErrorHandler=t}getUnexpectedErrorHandler(){return this.unexpectedErrorHandler}onUnexpectedError(t){this.unexpectedErrorHandler(t),this.emit(t)}onUnexpectedExternalError(t){this.unexpectedErrorHandler(t)}},E$=new A$;function Ja(t){P$(t)||E$.onUnexpectedError(t)}var d0="Canceled";function P$(t){return t instanceof R$?!0:t instanceof Error&&t.name===d0&&t.message===d0}var R$=class extends Error{constructor(){super(d0),this.name=this.message}};function D$(t){return new Error(`Illegal argument: ${t}`)}var x1=class u0 extends Error{constructor(e){super(e),this.name="CodeExpectedError"}static fromError(e){if(e instanceof u0)return e;let s=new u0;return s.message=e.message,s.stack=e.stack,s}static isErrorNoTelemetry(e){return e.name==="CodeExpectedError"}},h0=class t5 extends Error{constructor(e){super(e||"An unexpected bug occurred."),Object.setPrototypeOf(this,t5.prototype)}};function Rs(t,e=0){return t[t.length-(1+e)]}var I$;(t=>{function e(o){return o<0}t.isLessThan=e;function s(o){return o<=0}t.isLessThanOrEqual=s;function n(o){return o>0}t.isGreaterThan=n;function i(o){return o===0}t.isNeitherLessOrGreaterThan=i,t.greaterThan=1,t.lessThan=-1,t.neitherLessOrGreaterThan=0})(I$||={});function M$(t,e){let s=this,n=!1,i;return function(){return n||(n=!0,e||(i=t.apply(s,arguments))),i}}var s5;(t=>{function e(y){return y&&typeof y=="object"&&typeof y[Symbol.iterator]=="function"}t.is=e;let s=Object.freeze([]);function n(){return s}t.empty=n;function*i(y){yield y}t.single=i;function o(y){return e(y)?y:i(y)}t.wrap=o;function a(y){return y||s}t.from=a;function*l(y){for(let L=y.length-1;L>=0;L--)yield y[L]}t.reverse=l;function c(y){return!y||y[Symbol.iterator]().next().done===!0}t.isEmpty=c;function d(y){return y[Symbol.iterator]().next().value}t.first=d;function h(y,L){let w=0;for(let j of y)if(L(j,w++))return!0;return!1}t.some=h;function u(y,L){for(let w of y)if(L(w))return w}t.find=u;function*f(y,L){for(let w of y)L(w)&&(yield w)}t.filter=f;function*m(y,L){let w=0;for(let j of y)yield L(j,w++)}t.map=m;function*p(y,L){let w=0;for(let j of y)yield*L(j,w++)}t.flatMap=p;function*g(...y){for(let L of y)yield*L}t.concat=g;function x(y,L,w){let j=w;for(let S of y)j=L(j,S);return j}t.reduce=x;function*v(y,L,w=y.length){for(L<0&&(L+=y.length),w<0?w+=y.length:w>y.length&&(w=y.length);L<w;L++)yield y[L]}t.slice=v;function b(y,L=Number.POSITIVE_INFINITY){let w=[];if(L===0)return[w,y];let j=y[Symbol.iterator]();for(let S=0;S<L;S++){let C=j.next();if(C.done)return[w,t.empty()];w.push(C.value)}return[w,{[Symbol.iterator](){return j}}]}t.consume=b;async function _(y){let L=[];for await(let w of y)L.push(w);return Promise.resolve(L)}t.asyncToArray=_})(s5||={});function Pi(t){if(s5.is(t)){let e=[];for(let s of t)if(s)try{s.dispose()}catch(n){e.push(n)}if(e.length===1)throw e[0];if(e.length>1)throw new AggregateError(e,"Encountered errors while disposing of store");return Array.isArray(t)?[]:t}else if(t)return t.dispose(),t}function O$(...t){return Lt(()=>Pi(t))}function Lt(t){return{dispose:M$(()=>{t()})}}var n5=class i5{constructor(){this._toDispose=new Set,this._isDisposed=!1}dispose(){this._isDisposed||(this._isDisposed=!0,this.clear())}get isDisposed(){return this._isDisposed}clear(){if(this._toDispose.size!==0)try{Pi(this._toDispose)}finally{this._toDispose.clear()}}add(e){if(!e)return e;if(e===this)throw new Error("Cannot register a disposable on itself!");return this._isDisposed?i5.DISABLE_DISPOSED_WARNING||console.warn(new Error("Trying to add a disposable to a DisposableStore that has already been disposed of. The added object will be leaked!").stack):this._toDispose.add(e),e}delete(e){if(e){if(e===this)throw new Error("Cannot dispose a disposable on itself!");this._toDispose.delete(e),e.dispose()}}deleteAndLeak(e){e&&this._toDispose.has(e)&&(this._toDispose.delete(e),void 0)}};n5.DISABLE_DISPOSED_WARNING=!1;var Xn=n5,tt=class{constructor(){this._store=new Xn,this._store}dispose(){this._store.dispose()}_register(t){if(t===this)throw new Error("Cannot register a disposable on itself!");return this._store.add(t)}};tt.None=Object.freeze({dispose(){}});var Lr=class{constructor(){this._isDisposed=!1}get value(){return this._isDisposed?void 0:this._value}set value(t){this._isDisposed||t===this._value||(this._value?.dispose(),this._value=t)}clear(){this.value=void 0}dispose(){this._isDisposed=!0,this._value?.dispose(),this._value=void 0}clearAndLeak(){let t=this._value;return this._value=void 0,t}},Tn=typeof window=="object"?window:globalThis,f0=class m0{constructor(e){this.element=e,this.next=m0.Undefined,this.prev=m0.Undefined}};f0.Undefined=new f0(void 0);var jt=f0,v1=class{constructor(){this._first=jt.Undefined,this._last=jt.Undefined,this._size=0}get size(){return this._size}isEmpty(){return this._first===jt.Undefined}clear(){let t=this._first;for(;t!==jt.Undefined;){let e=t.next;t.prev=jt.Undefined,t.next=jt.Undefined,t=e}this._first=jt.Undefined,this._last=jt.Undefined,this._size=0}unshift(t){return this._insert(t,!1)}push(t){return this._insert(t,!0)}_insert(t,e){let s=new jt(t);if(this._first===jt.Undefined)this._first=s,this._last=s;else if(e){let i=this._last;this._last=s,s.prev=i,i.next=s}else{let i=this._first;this._first=s,s.next=i,i.prev=s}this._size+=1;let n=!1;return()=>{n||(n=!0,this._remove(s))}}shift(){if(this._first!==jt.Undefined){let t=this._first.element;return this._remove(this._first),t}}pop(){if(this._last!==jt.Undefined){let t=this._last.element;return this._remove(this._last),t}}_remove(t){if(t.prev!==jt.Undefined&&t.next!==jt.Undefined){let e=t.prev;e.next=t.next,t.next.prev=e}else t.prev===jt.Undefined&&t.next===jt.Undefined?(this._first=jt.Undefined,this._last=jt.Undefined):t.next===jt.Undefined?(this._last=this._last.prev,this._last.next=jt.Undefined):t.prev===jt.Undefined&&(this._first=this._first.next,this._first.prev=jt.Undefined);this._size-=1}*[Symbol.iterator](){let t=this._first;for(;t!==jt.Undefined;)yield t.element,t=t.next}},$$=globalThis.performance&&typeof globalThis.performance.now=="function",B$=class r5{static create(e){return new r5(e)}constructor(e){this._now=$$&&e===!1?Date.now:globalThis.performance.now.bind(globalThis.performance),this._startTime=this._now(),this._stopTime=-1}stop(){this._stopTime=this._now()}reset(){this._startTime=this._now(),this._stopTime=-1}elapsed(){return this._stopTime!==-1?this._stopTime-this._startTime:this._now()-this._startTime}},os;(t=>{t.None=()=>tt.None;function e(E,T){return u(E,()=>{},0,void 0,!0,void 0,T)}t.defer=e;function s(E){return(T,k=null,R)=>{let P=!1,D;return D=E(I=>{if(!P)return D?D.dispose():P=!0,T.call(k,I)},null,R),P&&D.dispose(),D}}t.once=s;function n(E,T,k){return d((R,P=null,D)=>E(I=>R.call(P,T(I)),null,D),k)}t.map=n;function i(E,T,k){return d((R,P=null,D)=>E(I=>{T(I),R.call(P,I)},null,D),k)}t.forEach=i;function o(E,T,k){return d((R,P=null,D)=>E(I=>T(I)&&R.call(P,I),null,D),k)}t.filter=o;function a(E){return E}t.signal=a;function l(...E){return(T,k=null,R)=>{let P=O$(...E.map(D=>D(I=>T.call(k,I))));return h(P,R)}}t.any=l;function c(E,T,k,R){let P=k;return n(E,D=>(P=T(P,D),P),R)}t.reduce=c;function d(E,T){let k,R={onWillAddFirstListener(){k=E(P.fire,P)},onDidRemoveLastListener(){k?.dispose()}},P=new Te(R);return T?.add(P),P.event}function h(E,T){return T instanceof Array?T.push(E):T&&T.add(E),E}function u(E,T,k=100,R=!1,P=!1,D,I){let M,O,F,$=0,z,K={leakWarningThreshold:D,onWillAddFirstListener(){M=E(J=>{$++,O=T(O,J),R&&!F&&(X.fire(O),O=void 0),z=()=>{let H=O;O=void 0,F=void 0,(!R||$>1)&&X.fire(H),$=0},typeof k=="number"?(clearTimeout(F),F=setTimeout(z,k)):F===void 0&&(F=0,queueMicrotask(z))})},onWillRemoveListener(){P&&$>0&&z?.()},onDidRemoveLastListener(){z=void 0,M.dispose()}},X=new Te(K);return I?.add(X),X.event}t.debounce=u;function f(E,T=0,k){return t.debounce(E,(R,P)=>R?(R.push(P),R):[P],T,void 0,!0,void 0,k)}t.accumulate=f;function m(E,T=(R,P)=>R===P,k){let R=!0,P;return o(E,D=>{let I=R||!T(D,P);return R=!1,P=D,I},k)}t.latch=m;function p(E,T,k){return[t.filter(E,T,k),t.filter(E,R=>!T(R),k)]}t.split=p;function g(E,T=!1,k=[],R){let P=k.slice(),D=E(O=>{P?P.push(O):M.fire(O)});R&&R.add(D);let I=()=>{P?.forEach(O=>M.fire(O)),P=null},M=new Te({onWillAddFirstListener(){D||(D=E(O=>M.fire(O)),R&&R.add(D))},onDidAddFirstListener(){P&&(T?setTimeout(I):I())},onDidRemoveLastListener(){D&&D.dispose(),D=null}});return R&&R.add(M),M.event}t.buffer=g;function x(E,T){return(k,R,P)=>{let D=T(new b);return E(function(I){let M=D.evaluate(I);M!==v&&k.call(R,M)},void 0,P)}}t.chain=x;let v=Symbol("HaltChainable");class b{constructor(){this.steps=[]}map(T){return this.steps.push(T),this}forEach(T){return this.steps.push(k=>(T(k),k)),this}filter(T){return this.steps.push(k=>T(k)?k:v),this}reduce(T,k){let R=k;return this.steps.push(P=>(R=T(R,P),R)),this}latch(T=(k,R)=>k===R){let k=!0,R;return this.steps.push(P=>{let D=k||!T(P,R);return k=!1,R=P,D?P:v}),this}evaluate(T){for(let k of this.steps)if(T=k(T),T===v)break;return T}}function _(E,T,k=R=>R){let R=(...M)=>I.fire(k(...M)),P=()=>E.on(T,R),D=()=>E.removeListener(T,R),I=new Te({onWillAddFirstListener:P,onDidRemoveLastListener:D});return I.event}t.fromNodeEventEmitter=_;function y(E,T,k=R=>R){let R=(...M)=>I.fire(k(...M)),P=()=>E.addEventListener(T,R),D=()=>E.removeEventListener(T,R),I=new Te({onWillAddFirstListener:P,onDidRemoveLastListener:D});return I.event}t.fromDOMEventEmitter=y;function L(E){return new Promise(T=>s(E)(T))}t.toPromise=L;function w(E){let T=new Te;return E.then(k=>{T.fire(k)},()=>{T.fire(void 0)}).finally(()=>{T.dispose()}),T.event}t.fromPromise=w;function j(E,T){return E(k=>T.fire(k))}t.forward=j;function S(E,T,k){return T(k),E(R=>T(R))}t.runAndSubscribe=S;class C{constructor(T,k){this._observable=T,this._counter=0,this._hasChanged=!1;let R={onWillAddFirstListener:()=>{T.addObserver(this)},onDidRemoveLastListener:()=>{T.removeObserver(this)}};this.emitter=new Te(R),k&&k.add(this.emitter)}beginUpdate(T){this._counter++}handlePossibleChange(T){}handleChange(T,k){this._hasChanged=!0}endUpdate(T){this._counter--,this._counter===0&&(this._observable.reportChanges(),this._hasChanged&&(this._hasChanged=!1,this.emitter.fire(this._observable.get())))}}function N(E,T){return new C(E,T).emitter.event}t.fromObservable=N;function V(E){return(T,k,R)=>{let P=0,D=!1,I={beginUpdate(){P++},endUpdate(){P--,P===0&&(E.reportChanges(),D&&(D=!1,T.call(k)))},handlePossibleChange(){},handleChange(){D=!0}};E.addObserver(I),E.reportChanges();let M={dispose(){E.removeObserver(I)}};return R instanceof Xn?R.add(M):Array.isArray(R)&&R.push(M),M}}t.fromObservableLight=V})(os||={});var p0=class g0{constructor(e){this.listenerCount=0,this.invocationCount=0,this.elapsedOverall=0,this.durations=[],this.name=`${e}_${g0._idPool++}`,g0.all.add(this)}start(e){this._stopWatch=new B$,this.listenerCount=e}stop(){if(this._stopWatch){let e=this._stopWatch.elapsed();this.durations.push(e),this.elapsedOverall+=e,this.invocationCount+=1,this._stopWatch=void 0}}};p0.all=new Set,p0._idPool=0;var F$=p0,z$=-1,o5=class a5{constructor(e,s,n=(a5._idPool++).toString(16).padStart(3,"0")){this._errorHandler=e,this.threshold=s,this.name=n,this._warnCountdown=0}dispose(){this._stacks?.clear()}check(e,s){let n=this.threshold;if(n<=0||s<n)return;this._stacks||(this._stacks=new Map);let i=this._stacks.get(e.value)||0;if(this._stacks.set(e.value,i+1),this._warnCountdown-=1,this._warnCountdown<=0){this._warnCountdown=n*.5;let[o,a]=this.getMostFrequentStack(),l=`[${this.name}] potential listener LEAK detected, having ${s} listeners already. MOST frequent listener (${a}):`;console.warn(l),console.warn(o);let c=new H$(l,o);this._errorHandler(c)}return()=>{let o=this._stacks.get(e.value)||0;this._stacks.set(e.value,o-1)}}getMostFrequentStack(){if(!this._stacks)return;let e,s=0;for(let[n,i]of this._stacks)(!e||s<i)&&(e=[n,i],s=i);return e}};o5._idPool=1;var K$=o5,U$=class l5{constructor(e){this.value=e}static create(){let e=new Error;return new l5(e.stack??"")}print(){console.warn(this.value.split(`
|
|
507
|
+
`).slice(2).join(`
|
|
508
|
+
`))}},H$=class extends Error{constructor(t,e){super(t),this.name="ListenerLeakError",this.stack=e}},W$=class extends Error{constructor(t,e){super(t),this.name="ListenerRefusalError",this.stack=e}},q$=0,vd=class{constructor(t){this.value=t,this.id=q$++}},G$=2,Y$,Te=class{constructor(t){this._size=0,this._options=t,this._leakageMon=this._options?.leakWarningThreshold?new K$(t?.onListenerError??Ja,this._options?.leakWarningThreshold??z$):void 0,this._perfMon=this._options?._profName?new F$(this._options._profName):void 0,this._deliveryQueue=this._options?.deliveryQueue}dispose(){this._disposed||(this._disposed=!0,this._deliveryQueue?.current===this&&this._deliveryQueue.reset(),this._listeners&&(this._listeners=void 0,this._size=0),this._options?.onDidRemoveLastListener?.(),this._leakageMon?.dispose())}get event(){return this._event??=(t,e,s)=>{if(this._leakageMon&&this._size>this._leakageMon.threshold**2){let a=`[${this._leakageMon.name}] REFUSES to accept new listeners because it exceeded its threshold by far (${this._size} vs ${this._leakageMon.threshold})`;console.warn(a);let l=this._leakageMon.getMostFrequentStack()??["UNKNOWN stack",-1],c=new W$(`${a}. HINT: Stack shows most frequent listener (${l[1]}-times)`,l[0]);return(this._options?.onListenerError||Ja)(c),tt.None}if(this._disposed)return tt.None;e&&(t=t.bind(e));let n=new vd(t),i;this._leakageMon&&this._size>=Math.ceil(this._leakageMon.threshold*.2)&&(n.stack=U$.create(),i=this._leakageMon.check(n.stack,this._size+1)),this._listeners?this._listeners instanceof vd?(this._deliveryQueue??=new J$,this._listeners=[this._listeners,n]):this._listeners.push(n):(this._options?.onWillAddFirstListener?.(this),this._listeners=n,this._options?.onDidAddFirstListener?.(this)),this._size++;let o=Lt(()=>{i?.(),this._removeListener(n)});return s instanceof Xn?s.add(o):Array.isArray(s)&&s.push(o),o},this._event}_removeListener(t){if(this._options?.onWillRemoveListener?.(this),!this._listeners)return;if(this._size===1){this._listeners=void 0,this._options?.onDidRemoveLastListener?.(this),this._size=0;return}let e=this._listeners,s=e.indexOf(t);if(s===-1)throw console.log("disposed?",this._disposed),console.log("size?",this._size),console.log("arr?",JSON.stringify(this._listeners)),new Error("Attempted to dispose unknown listener");this._size--,e[s]=void 0;let n=this._deliveryQueue.current===this;if(this._size*G$<=e.length){let i=0;for(let o=0;o<e.length;o++)e[o]?e[i++]=e[o]:n&&(this._deliveryQueue.end--,i<this._deliveryQueue.i&&this._deliveryQueue.i--);e.length=i}}_deliver(t,e){if(!t)return;let s=this._options?.onListenerError||Ja;if(!s){t.value(e);return}try{t.value(e)}catch(n){s(n)}}_deliverQueue(t){let e=t.current._listeners;for(;t.i<t.end;)this._deliver(e[t.i++],t.value);t.reset()}fire(t){if(this._deliveryQueue?.current&&(this._deliverQueue(this._deliveryQueue),this._perfMon?.stop()),this._perfMon?.start(this._size),this._listeners)if(this._listeners instanceof vd)this._deliver(this._listeners,t);else{let e=this._deliveryQueue;e.enqueue(this,t,this._listeners.length),this._deliverQueue(e)}this._perfMon?.stop()}hasListeners(){return this._size>0}},J$=class{constructor(){this.i=-1,this.end=0}enqueue(t,e,s){this.i=0,this.end=s,this.current=t,this.value=e}reset(){this.i=this.end,this.current=void 0,this.value=void 0}},x0=class{constructor(){this.mapWindowIdToZoomLevel=new Map,this._onDidChangeZoomLevel=new Te,this.onDidChangeZoomLevel=this._onDidChangeZoomLevel.event,this.mapWindowIdToZoomFactor=new Map,this._onDidChangeFullscreen=new Te,this.onDidChangeFullscreen=this._onDidChangeFullscreen.event,this.mapWindowIdToFullScreen=new Map}getZoomLevel(e){return this.mapWindowIdToZoomLevel.get(this.getWindowId(e))??0}setZoomLevel(e,s){if(this.getZoomLevel(s)===e)return;let n=this.getWindowId(s);this.mapWindowIdToZoomLevel.set(n,e),this._onDidChangeZoomLevel.fire(n)}getZoomFactor(e){return this.mapWindowIdToZoomFactor.get(this.getWindowId(e))??1}setZoomFactor(e,s){this.mapWindowIdToZoomFactor.set(this.getWindowId(s),e)}setFullscreen(e,s){if(this.isFullscreen(s)===e)return;let n=this.getWindowId(s);this.mapWindowIdToFullScreen.set(n,e),this._onDidChangeFullscreen.fire(n)}isFullscreen(e){return!!this.mapWindowIdToFullScreen.get(this.getWindowId(e))}getWindowId(e){return e.vscodeWindowId}};x0.INSTANCE=new x0;var Pu=x0;function X$(t,e,s){typeof e=="string"&&(e=t.matchMedia(e)),e.addEventListener("change",s)}Pu.INSTANCE.onDidChangeZoomLevel;function Q$(t){return Pu.INSTANCE.getZoomFactor(t)}Pu.INSTANCE.onDidChangeFullscreen;var Kr=typeof navigator=="object"?navigator.userAgent:"",v0=Kr.indexOf("Firefox")>=0,Z$=Kr.indexOf("AppleWebKit")>=0,Ru=Kr.indexOf("Chrome")>=0,eB=!Ru&&Kr.indexOf("Safari")>=0;Kr.indexOf("Electron/")>=0;Kr.indexOf("Android")>=0;var bd=!1;if(typeof Tn.matchMedia=="function"){let t=Tn.matchMedia("(display-mode: standalone) or (display-mode: window-controls-overlay)"),e=Tn.matchMedia("(display-mode: fullscreen)");bd=t.matches,X$(Tn,t,({matches:s})=>{bd&&e.matches||(bd=s)})}var nr="en",b0=!1,y0=!1,Xa=!1,c5=!1,Oa,Qa=nr,b1=nr,tB,kn,Si=globalThis,Is;typeof Si.vscode<"u"&&typeof Si.vscode.process<"u"?Is=Si.vscode.process:typeof process<"u"&&typeof process?.versions?.node=="string"&&(Is=process);var sB=typeof Is?.versions?.electron=="string",nB=sB&&Is?.type==="renderer";if(typeof Is=="object"){b0=Is.platform==="win32",y0=Is.platform==="darwin",Xa=Is.platform==="linux",Xa&&Is.env.SNAP&&Is.env.SNAP_REVISION,Is.env.CI||Is.env.BUILD_ARTIFACTSTAGINGDIRECTORY,Oa=nr,Qa=nr;let t=Is.env.VSCODE_NLS_CONFIG;if(t)try{let e=JSON.parse(t);Oa=e.userLocale,b1=e.osLocale,Qa=e.resolvedLanguage||nr,tB=e.languagePack?.translationsConfigFile}catch{}c5=!0}else typeof navigator=="object"&&!nB?(kn=navigator.userAgent,b0=kn.indexOf("Windows")>=0,y0=kn.indexOf("Macintosh")>=0,(kn.indexOf("Macintosh")>=0||kn.indexOf("iPad")>=0||kn.indexOf("iPhone")>=0)&&navigator.maxTouchPoints&&navigator.maxTouchPoints>0,Xa=kn.indexOf("Linux")>=0,kn?.indexOf("Mobi")>=0,Qa=globalThis._VSCODE_NLS_LANGUAGE||nr,Oa=navigator.language.toLowerCase(),b1=Oa):console.error("Unable to resolve platform.");var d5=b0,vn=y0,iB=Xa,y1=c5,Sn=kn,Bn=Qa,rB;(t=>{function e(){return Bn}t.value=e;function s(){return Bn.length===2?Bn==="en":Bn.length>=3?Bn[0]==="e"&&Bn[1]==="n"&&Bn[2]==="-":!1}t.isDefaultVariant=s;function n(){return Bn==="en"}t.isDefault=n})(rB||={});var oB=typeof Si.postMessage=="function"&&!Si.importScripts;(()=>{if(oB){let t=[];Si.addEventListener("message",s=>{if(s.data&&s.data.vscodeScheduleAsyncWork)for(let n=0,i=t.length;n<i;n++){let o=t[n];if(o.id===s.data.vscodeScheduleAsyncWork){t.splice(n,1),o.callback();return}}});let e=0;return s=>{let n=++e;t.push({id:n,callback:s}),Si.postMessage({vscodeScheduleAsyncWork:n},"*")}}return t=>setTimeout(t)})();var aB=!!(Sn&&Sn.indexOf("Chrome")>=0);Sn&&Sn.indexOf("Firefox")>=0;!aB&&Sn&&Sn.indexOf("Safari")>=0;Sn&&Sn.indexOf("Edg/")>=0;Sn&&Sn.indexOf("Android")>=0;var Xi=typeof navigator=="object"?navigator:{};y1||document.queryCommandSupported&&document.queryCommandSupported("copy")||Xi&&Xi.clipboard&&Xi.clipboard.writeText,y1||Xi&&Xi.clipboard&&Xi.clipboard.readText;var Du=class{constructor(){this._keyCodeToStr=[],this._strToKeyCode=Object.create(null)}define(t,e){this._keyCodeToStr[t]=e,this._strToKeyCode[e.toLowerCase()]=t}keyCodeToStr(t){return this._keyCodeToStr[t]}strToKeyCode(t){return this._strToKeyCode[t.toLowerCase()]||0}},yd=new Du,_1=new Du,L1=new Du,lB=new Array(230),u5;(t=>{function e(l){return yd.keyCodeToStr(l)}t.toString=e;function s(l){return yd.strToKeyCode(l)}t.fromString=s;function n(l){return _1.keyCodeToStr(l)}t.toUserSettingsUS=n;function i(l){return L1.keyCodeToStr(l)}t.toUserSettingsGeneral=i;function o(l){return _1.strToKeyCode(l)||L1.strToKeyCode(l)}t.fromUserSettings=o;function a(l){if(l>=98&&l<=113)return null;switch(l){case 16:return"Up";case 18:return"Down";case 15:return"Left";case 17:return"Right"}return yd.keyCodeToStr(l)}t.toElectronAccelerator=a})(u5||={});var cB=class h5{constructor(e,s,n,i,o){this.ctrlKey=e,this.shiftKey=s,this.altKey=n,this.metaKey=i,this.keyCode=o}equals(e){return e instanceof h5&&this.ctrlKey===e.ctrlKey&&this.shiftKey===e.shiftKey&&this.altKey===e.altKey&&this.metaKey===e.metaKey&&this.keyCode===e.keyCode}getHashCode(){let e=this.ctrlKey?"1":"0",s=this.shiftKey?"1":"0",n=this.altKey?"1":"0",i=this.metaKey?"1":"0";return`K${e}${s}${n}${i}${this.keyCode}`}isModifierKey(){return this.keyCode===0||this.keyCode===5||this.keyCode===57||this.keyCode===6||this.keyCode===4}toKeybinding(){return new dB([this])}isDuplicateModifierCase(){return this.ctrlKey&&this.keyCode===5||this.shiftKey&&this.keyCode===4||this.altKey&&this.keyCode===6||this.metaKey&&this.keyCode===57}},dB=class{constructor(t){if(t.length===0)throw D$("chords");this.chords=t}getHashCode(){let t="";for(let e=0,s=this.chords.length;e<s;e++)e!==0&&(t+=";"),t+=this.chords[e].getHashCode();return t}equals(t){if(t===null||this.chords.length!==t.chords.length)return!1;for(let e=0;e<this.chords.length;e++)if(!this.chords[e].equals(t.chords[e]))return!1;return!0}};function uB(t){if(t.charCode){let s=String.fromCharCode(t.charCode).toUpperCase();return u5.fromString(s)}let e=t.keyCode;if(e===3)return 7;if(v0)switch(e){case 59:return 85;case 60:if(iB)return 97;break;case 61:return 86;case 107:return 109;case 109:return 111;case 173:return 88;case 224:if(vn)return 57;break}else if(Z$&&(vn&&e===93||!vn&&e===92))return 57;return lB[e]||0}var hB=vn?256:2048,fB=512,mB=1024,pB=vn?2048:256,S1=class{constructor(t){this._standardKeyboardEventBrand=!0;let e=t;this.browserEvent=e,this.target=e.target,this.ctrlKey=e.ctrlKey,this.shiftKey=e.shiftKey,this.altKey=e.altKey,this.metaKey=e.metaKey,this.altGraphKey=e.getModifierState?.("AltGraph"),this.keyCode=uB(e),this.code=e.code,this.ctrlKey=this.ctrlKey||this.keyCode===5,this.altKey=this.altKey||this.keyCode===6,this.shiftKey=this.shiftKey||this.keyCode===4,this.metaKey=this.metaKey||this.keyCode===57,this._asKeybinding=this._computeKeybinding(),this._asKeyCodeChord=this._computeKeyCodeChord()}preventDefault(){this.browserEvent&&this.browserEvent.preventDefault&&this.browserEvent.preventDefault()}stopPropagation(){this.browserEvent&&this.browserEvent.stopPropagation&&this.browserEvent.stopPropagation()}toKeyCodeChord(){return this._asKeyCodeChord}equals(t){return this._asKeybinding===t}_computeKeybinding(){let t=0;this.keyCode!==5&&this.keyCode!==4&&this.keyCode!==6&&this.keyCode!==57&&(t=this.keyCode);let e=0;return this.ctrlKey&&(e|=hB),this.altKey&&(e|=fB),this.shiftKey&&(e|=mB),this.metaKey&&(e|=pB),e|=t,e}_computeKeyCodeChord(){let t=0;return this.keyCode!==5&&this.keyCode!==4&&this.keyCode!==6&&this.keyCode!==57&&(t=this.keyCode),new cB(this.ctrlKey,this.shiftKey,this.altKey,this.metaKey,t)}},w1=new WeakMap;function gB(t){if(!t.parent||t.parent===t)return null;try{let e=t.location,s=t.parent.location;if(e.origin!=="null"&&s.origin!=="null"&&e.origin!==s.origin)return null}catch{return null}return t.parent}var xB=class{static getSameOriginWindowChain(t){let e=w1.get(t);if(!e){e=[],w1.set(t,e);let s=t,n;do n=gB(s),n?e.push({window:new WeakRef(s),iframeElement:s.frameElement||null}):e.push({window:new WeakRef(s),iframeElement:null}),s=n;while(s)}return e.slice(0)}static getPositionOfChildWindowRelativeToAncestorWindow(t,e){if(!e||t===e)return{top:0,left:0};let s=0,n=0,i=this.getSameOriginWindowChain(t);for(let o of i){let a=o.window.deref();if(s+=a?.scrollY??0,n+=a?.scrollX??0,a===e||!o.iframeElement)break;let l=o.iframeElement.getBoundingClientRect();s+=l.top,n+=l.left}return{top:s,left:n}}},$a=class{constructor(t,e){this.timestamp=Date.now(),this.browserEvent=e,this.leftButton=e.button===0,this.middleButton=e.button===1,this.rightButton=e.button===2,this.buttons=e.buttons,this.target=e.target,this.detail=e.detail||1,e.type==="dblclick"&&(this.detail=2),this.ctrlKey=e.ctrlKey,this.shiftKey=e.shiftKey,this.altKey=e.altKey,this.metaKey=e.metaKey,typeof e.pageX=="number"?(this.posx=e.pageX,this.posy=e.pageY):(this.posx=e.clientX+this.target.ownerDocument.body.scrollLeft+this.target.ownerDocument.documentElement.scrollLeft,this.posy=e.clientY+this.target.ownerDocument.body.scrollTop+this.target.ownerDocument.documentElement.scrollTop);let s=xB.getPositionOfChildWindowRelativeToAncestorWindow(t,e.view);this.posx-=s.left,this.posy-=s.top}preventDefault(){this.browserEvent.preventDefault()}stopPropagation(){this.browserEvent.stopPropagation()}},j1=class{constructor(t,e=0,s=0){this.browserEvent=t||null,this.target=t?t.target||t.targetNode||t.srcElement:null,this.deltaY=s,this.deltaX=e;let n=!1;if(Ru){let i=navigator.userAgent.match(/Chrome\/(\d+)/);n=(i?parseInt(i[1]):123)<=122}if(t){let i=t,o=t,a=t.view?.devicePixelRatio||1;if(typeof i.wheelDeltaY<"u")n?this.deltaY=i.wheelDeltaY/(120*a):this.deltaY=i.wheelDeltaY/120;else if(typeof o.VERTICAL_AXIS<"u"&&o.axis===o.VERTICAL_AXIS)this.deltaY=-o.detail/3;else if(t.type==="wheel"){let l=t;l.deltaMode===l.DOM_DELTA_LINE?v0&&!vn?this.deltaY=-t.deltaY/3:this.deltaY=-t.deltaY:this.deltaY=-t.deltaY/40}if(typeof i.wheelDeltaX<"u")eB&&d5?this.deltaX=-(i.wheelDeltaX/120):n?this.deltaX=i.wheelDeltaX/(120*a):this.deltaX=i.wheelDeltaX/120;else if(typeof o.HORIZONTAL_AXIS<"u"&&o.axis===o.HORIZONTAL_AXIS)this.deltaX=-t.detail/3;else if(t.type==="wheel"){let l=t;l.deltaMode===l.DOM_DELTA_LINE?v0&&!vn?this.deltaX=-t.deltaX/3:this.deltaX=-t.deltaX:this.deltaX=-t.deltaX/40}this.deltaY===0&&this.deltaX===0&&t.wheelDelta&&(n?this.deltaY=t.wheelDelta/(120*a):this.deltaY=t.wheelDelta/120)}}preventDefault(){this.browserEvent?.preventDefault()}stopPropagation(){this.browserEvent?.stopPropagation()}},f5=Object.freeze(function(t,e){let s=setTimeout(t.bind(e),0);return{dispose(){clearTimeout(s)}}}),vB;(t=>{function e(s){return s===t.None||s===t.Cancelled||s instanceof bB?!0:!s||typeof s!="object"?!1:typeof s.isCancellationRequested=="boolean"&&typeof s.onCancellationRequested=="function"}t.isCancellationToken=e,t.None=Object.freeze({isCancellationRequested:!1,onCancellationRequested:os.None}),t.Cancelled=Object.freeze({isCancellationRequested:!0,onCancellationRequested:f5})})(vB||={});var bB=class{constructor(){this._isCancelled=!1,this._emitter=null}cancel(){this._isCancelled||(this._isCancelled=!0,this._emitter&&(this._emitter.fire(void 0),this.dispose()))}get isCancellationRequested(){return this._isCancelled}get onCancellationRequested(){return this._isCancelled?f5:(this._emitter||(this._emitter=new Te),this._emitter.event)}dispose(){this._emitter&&(this._emitter.dispose(),this._emitter=null)}},Iu=class{constructor(t,e){this._isDisposed=!1,this._token=-1,typeof t=="function"&&typeof e=="number"&&this.setIfNotSet(t,e)}dispose(){this.cancel(),this._isDisposed=!0}cancel(){this._token!==-1&&(clearTimeout(this._token),this._token=-1)}cancelAndSet(t,e){if(this._isDisposed)throw new h0("Calling 'cancelAndSet' on a disposed TimeoutTimer");this.cancel(),this._token=setTimeout(()=>{this._token=-1,t()},e)}setIfNotSet(t,e){if(this._isDisposed)throw new h0("Calling 'setIfNotSet' on a disposed TimeoutTimer");this._token===-1&&(this._token=setTimeout(()=>{this._token=-1,t()},e))}},yB=class{constructor(){this.disposable=void 0,this.isDisposed=!1}cancel(){this.disposable?.dispose(),this.disposable=void 0}cancelAndSet(t,e,s=globalThis){if(this.isDisposed)throw new h0("Calling 'cancelAndSet' on a disposed IntervalTimer");this.cancel();let n=s.setInterval(()=>{t()},e);this.disposable=Lt(()=>{s.clearInterval(n),this.disposable=void 0})}dispose(){this.cancel(),this.isDisposed=!0}},_B;(t=>{async function e(n){let i,o=await Promise.all(n.map(a=>a.then(l=>l,l=>{i||(i=l)})));if(typeof i<"u")throw i;return o}t.settled=e;function s(n){return new Promise(async(i,o)=>{try{await n(i,o)}catch(a){o(a)}})}t.withAsyncBody=s})(_B||={});var C1=class Us{static fromArray(e){return new Us(s=>{s.emitMany(e)})}static fromPromise(e){return new Us(async s=>{s.emitMany(await e)})}static fromPromises(e){return new Us(async s=>{await Promise.all(e.map(async n=>s.emitOne(await n)))})}static merge(e){return new Us(async s=>{await Promise.all(e.map(async n=>{for await(let i of n)s.emitOne(i)}))})}constructor(e,s){this._state=0,this._results=[],this._error=null,this._onReturn=s,this._onStateChanged=new Te,queueMicrotask(async()=>{let n={emitOne:i=>this.emitOne(i),emitMany:i=>this.emitMany(i),reject:i=>this.reject(i)};try{await Promise.resolve(e(n)),this.resolve()}catch(i){this.reject(i)}finally{n.emitOne=void 0,n.emitMany=void 0,n.reject=void 0}})}[Symbol.asyncIterator](){let e=0;return{next:async()=>{do{if(this._state===2)throw this._error;if(e<this._results.length)return{done:!1,value:this._results[e++]};if(this._state===1)return{done:!0,value:void 0};await os.toPromise(this._onStateChanged.event)}while(!0)},return:async()=>(this._onReturn?.(),{done:!0,value:void 0})}}static map(e,s){return new Us(async n=>{for await(let i of e)n.emitOne(s(i))})}map(e){return Us.map(this,e)}static filter(e,s){return new Us(async n=>{for await(let i of e)s(i)&&n.emitOne(i)})}filter(e){return Us.filter(this,e)}static coalesce(e){return Us.filter(e,s=>!!s)}coalesce(){return Us.coalesce(this)}static async toPromise(e){let s=[];for await(let n of e)s.push(n);return s}toPromise(){return Us.toPromise(this)}emitOne(e){this._state===0&&(this._results.push(e),this._onStateChanged.fire())}emitMany(e){this._state===0&&(this._results=this._results.concat(e),this._onStateChanged.fire())}resolve(){this._state===0&&(this._state=1,this._onStateChanged.fire())}reject(e){this._state===0&&(this._state=2,this._error=e,this._onStateChanged.fire())}};C1.EMPTY=C1.fromArray([]);var{getWindow:mn,getWindowId:LB,onDidRegisterWindow:SB}=(function(){let t=new Map,e={window:Tn,disposables:new Xn};t.set(Tn.vscodeWindowId,e);let s=new Te,n=new Te,i=new Te;function o(a,l){return(typeof a=="number"?t.get(a):void 0)??(l?e:void 0)}return{onDidRegisterWindow:s.event,onWillUnregisterWindow:i.event,onDidUnregisterWindow:n.event,registerWindow(a){if(t.has(a.vscodeWindowId))return tt.None;let l=new Xn,c={window:a,disposables:l.add(new Xn)};return t.set(a.vscodeWindowId,c),l.add(Lt(()=>{t.delete(a.vscodeWindowId),n.fire(a)})),l.add(Ge(a,Ht.BEFORE_UNLOAD,()=>{i.fire(a)})),s.fire(c),l},getWindows(){return t.values()},getWindowsCount(){return t.size},getWindowId(a){return a.vscodeWindowId},hasWindow(a){return t.has(a)},getWindowById:o,getWindow(a){let l=a;if(l?.ownerDocument?.defaultView)return l.ownerDocument.defaultView.window;let c=a;return c?.view?c.view.window:Tn},getDocument(a){return mn(a).document}}})(),wB=class{constructor(t,e,s,n){this._node=t,this._type=e,this._handler=s,this._options=n||!1,this._node.addEventListener(this._type,this._handler,this._options)}dispose(){this._handler&&(this._node.removeEventListener(this._type,this._handler,this._options),this._node=null,this._handler=null)}};function Ge(t,e,s,n){return new wB(t,e,s,n)}var k1=function(t,e,s,n){return Ge(t,e,s,n)},Mu,jB=class extends yB{constructor(t){super(),this.defaultTarget=t&&mn(t)}cancelAndSet(t,e,s){return super.cancelAndSet(t,e,s??this.defaultTarget)}},V1=class{constructor(t,e=0){this._runner=t,this.priority=e,this._canceled=!1}dispose(){this._canceled=!0}execute(){if(!this._canceled)try{this._runner()}catch(t){Ja(t)}}static sort(t,e){return e.priority-t.priority}};(function(){let t=new Map,e=new Map,s=new Map,n=new Map,i=o=>{s.set(o,!1);let a=t.get(o)??[];for(e.set(o,a),t.set(o,[]),n.set(o,!0);a.length>0;)a.sort(V1.sort),a.shift().execute();n.set(o,!1)};Mu=(o,a,l=0)=>{let c=LB(o),d=new V1(a,l),h=t.get(c);return h||(h=[],t.set(c,h)),h.push(d),s.get(c)||(s.set(c,!0),o.requestAnimationFrame(()=>i(c))),d}})();function CB(t){let e=t.getBoundingClientRect(),s=mn(t);return{left:e.left+s.scrollX,top:e.top+s.scrollY,width:e.width,height:e.height}}var Ht={CLICK:"click",MOUSE_DOWN:"mousedown",MOUSE_OVER:"mouseover",MOUSE_LEAVE:"mouseleave",MOUSE_WHEEL:"wheel",POINTER_UP:"pointerup",POINTER_DOWN:"pointerdown",POINTER_MOVE:"pointermove",KEY_DOWN:"keydown",KEY_UP:"keyup",BEFORE_UNLOAD:"beforeunload",CHANGE:"change",FOCUS:"focus",BLUR:"blur",INPUT:"input"},kB=class{constructor(t){this.domNode=t,this._maxWidth="",this._width="",this._height="",this._top="",this._left="",this._bottom="",this._right="",this._paddingTop="",this._paddingLeft="",this._paddingBottom="",this._paddingRight="",this._fontFamily="",this._fontWeight="",this._fontSize="",this._fontStyle="",this._fontFeatureSettings="",this._fontVariationSettings="",this._textDecoration="",this._lineHeight="",this._letterSpacing="",this._className="",this._display="",this._position="",this._visibility="",this._color="",this._backgroundColor="",this._layerHint=!1,this._contain="none",this._boxShadow=""}setMaxWidth(t){let e=Cs(t);this._maxWidth!==e&&(this._maxWidth=e,this.domNode.style.maxWidth=this._maxWidth)}setWidth(t){let e=Cs(t);this._width!==e&&(this._width=e,this.domNode.style.width=this._width)}setHeight(t){let e=Cs(t);this._height!==e&&(this._height=e,this.domNode.style.height=this._height)}setTop(t){let e=Cs(t);this._top!==e&&(this._top=e,this.domNode.style.top=this._top)}setLeft(t){let e=Cs(t);this._left!==e&&(this._left=e,this.domNode.style.left=this._left)}setBottom(t){let e=Cs(t);this._bottom!==e&&(this._bottom=e,this.domNode.style.bottom=this._bottom)}setRight(t){let e=Cs(t);this._right!==e&&(this._right=e,this.domNode.style.right=this._right)}setPaddingTop(t){let e=Cs(t);this._paddingTop!==e&&(this._paddingTop=e,this.domNode.style.paddingTop=this._paddingTop)}setPaddingLeft(t){let e=Cs(t);this._paddingLeft!==e&&(this._paddingLeft=e,this.domNode.style.paddingLeft=this._paddingLeft)}setPaddingBottom(t){let e=Cs(t);this._paddingBottom!==e&&(this._paddingBottom=e,this.domNode.style.paddingBottom=this._paddingBottom)}setPaddingRight(t){let e=Cs(t);this._paddingRight!==e&&(this._paddingRight=e,this.domNode.style.paddingRight=this._paddingRight)}setFontFamily(t){this._fontFamily!==t&&(this._fontFamily=t,this.domNode.style.fontFamily=this._fontFamily)}setFontWeight(t){this._fontWeight!==t&&(this._fontWeight=t,this.domNode.style.fontWeight=this._fontWeight)}setFontSize(t){let e=Cs(t);this._fontSize!==e&&(this._fontSize=e,this.domNode.style.fontSize=this._fontSize)}setFontStyle(t){this._fontStyle!==t&&(this._fontStyle=t,this.domNode.style.fontStyle=this._fontStyle)}setFontFeatureSettings(t){this._fontFeatureSettings!==t&&(this._fontFeatureSettings=t,this.domNode.style.fontFeatureSettings=this._fontFeatureSettings)}setFontVariationSettings(t){this._fontVariationSettings!==t&&(this._fontVariationSettings=t,this.domNode.style.fontVariationSettings=this._fontVariationSettings)}setTextDecoration(t){this._textDecoration!==t&&(this._textDecoration=t,this.domNode.style.textDecoration=this._textDecoration)}setLineHeight(t){let e=Cs(t);this._lineHeight!==e&&(this._lineHeight=e,this.domNode.style.lineHeight=this._lineHeight)}setLetterSpacing(t){let e=Cs(t);this._letterSpacing!==e&&(this._letterSpacing=e,this.domNode.style.letterSpacing=this._letterSpacing)}setClassName(t){this._className!==t&&(this._className=t,this.domNode.className=this._className)}toggleClassName(t,e){this.domNode.classList.toggle(t,e),this._className=this.domNode.className}setDisplay(t){this._display!==t&&(this._display=t,this.domNode.style.display=this._display)}setPosition(t){this._position!==t&&(this._position=t,this.domNode.style.position=this._position)}setVisibility(t){this._visibility!==t&&(this._visibility=t,this.domNode.style.visibility=this._visibility)}setColor(t){this._color!==t&&(this._color=t,this.domNode.style.color=this._color)}setBackgroundColor(t){this._backgroundColor!==t&&(this._backgroundColor=t,this.domNode.style.backgroundColor=this._backgroundColor)}setLayerHinting(t){this._layerHint!==t&&(this._layerHint=t,this.domNode.style.transform=this._layerHint?"translate3d(0px, 0px, 0px)":"")}setBoxShadow(t){this._boxShadow!==t&&(this._boxShadow=t,this.domNode.style.boxShadow=t)}setContain(t){this._contain!==t&&(this._contain=t,this.domNode.style.contain=this._contain)}setAttribute(t,e){this.domNode.setAttribute(t,e)}removeAttribute(t){this.domNode.removeAttribute(t)}appendChild(t){this.domNode.appendChild(t.domNode)}removeChild(t){this.domNode.removeChild(t.domNode)}};function Cs(t){return typeof t=="number"?`${t}px`:t}function To(t){return new kB(t)}var m5=class{constructor(){this._hooks=new Xn,this._pointerMoveCallback=null,this._onStopCallback=null}dispose(){this.stopMonitoring(!1),this._hooks.dispose()}stopMonitoring(t,e){if(!this.isMonitoring())return;this._hooks.clear(),this._pointerMoveCallback=null;let s=this._onStopCallback;this._onStopCallback=null,t&&s&&s(e)}isMonitoring(){return!!this._pointerMoveCallback}startMonitoring(t,e,s,n,i){this.isMonitoring()&&this.stopMonitoring(!1),this._pointerMoveCallback=n,this._onStopCallback=i;let o=t;try{t.setPointerCapture(e),this._hooks.add(Lt(()=>{try{t.releasePointerCapture(e)}catch{}}))}catch{o=mn(t)}this._hooks.add(Ge(o,Ht.POINTER_MOVE,a=>{if(a.buttons!==s){this.stopMonitoring(!0);return}a.preventDefault(),this._pointerMoveCallback(a)})),this._hooks.add(Ge(o,Ht.POINTER_UP,a=>this.stopMonitoring(!0)))}};function VB(t,e,s){let n=null,i=null;if(typeof s.value=="function"?(n="value",i=s.value,i.length!==0&&console.warn("Memoize should only be used in functions with zero parameters")):typeof s.get=="function"&&(n="get",i=s.get),!i)throw new Error("not supported");let o=`$memoize$${e}`;s[n]=function(...a){return this.hasOwnProperty(o)||Object.defineProperty(this,o,{configurable:!1,enumerable:!1,writable:!1,value:i.apply(this,a)}),this[o]}}var un;(t=>(t.Tap="-xterm-gesturetap",t.Change="-xterm-gesturechange",t.Start="-xterm-gesturestart",t.End="-xterm-gesturesend",t.Contextmenu="-xterm-gesturecontextmenu"))(un||={});var fo=class cs extends tt{constructor(){super(),this.dispatched=!1,this.targets=new v1,this.ignoreTargets=new v1,this.activeTouches={},this.handle=null,this._lastSetTapCountTime=0,this._register(os.runAndSubscribe(SB,({window:e,disposables:s})=>{s.add(Ge(e.document,"touchstart",n=>this.onTouchStart(n),{passive:!1})),s.add(Ge(e.document,"touchend",n=>this.onTouchEnd(e,n))),s.add(Ge(e.document,"touchmove",n=>this.onTouchMove(n),{passive:!1}))},{window:Tn,disposables:this._store}))}static addTarget(e){if(!cs.isTouchDevice())return tt.None;cs.INSTANCE||(cs.INSTANCE=new cs);let s=cs.INSTANCE.targets.push(e);return Lt(s)}static ignoreTarget(e){if(!cs.isTouchDevice())return tt.None;cs.INSTANCE||(cs.INSTANCE=new cs);let s=cs.INSTANCE.ignoreTargets.push(e);return Lt(s)}static isTouchDevice(){return"ontouchstart"in Tn||navigator.maxTouchPoints>0}dispose(){this.handle&&(this.handle.dispose(),this.handle=null),super.dispose()}onTouchStart(e){let s=Date.now();this.handle&&(this.handle.dispose(),this.handle=null);for(let n=0,i=e.targetTouches.length;n<i;n++){let o=e.targetTouches.item(n);this.activeTouches[o.identifier]={id:o.identifier,initialTarget:o.target,initialTimeStamp:s,initialPageX:o.pageX,initialPageY:o.pageY,rollingTimestamps:[s],rollingPageX:[o.pageX],rollingPageY:[o.pageY]};let a=this.newGestureEvent(un.Start,o.target);a.pageX=o.pageX,a.pageY=o.pageY,this.dispatchEvent(a)}this.dispatched&&(e.preventDefault(),e.stopPropagation(),this.dispatched=!1)}onTouchEnd(e,s){let n=Date.now(),i=Object.keys(this.activeTouches).length;for(let o=0,a=s.changedTouches.length;o<a;o++){let l=s.changedTouches.item(o);if(!this.activeTouches.hasOwnProperty(String(l.identifier))){console.warn("move of an UNKNOWN touch",l);continue}let c=this.activeTouches[l.identifier],d=Date.now()-c.initialTimeStamp;if(d<cs.HOLD_DELAY&&Math.abs(c.initialPageX-Rs(c.rollingPageX))<30&&Math.abs(c.initialPageY-Rs(c.rollingPageY))<30){let h=this.newGestureEvent(un.Tap,c.initialTarget);h.pageX=Rs(c.rollingPageX),h.pageY=Rs(c.rollingPageY),this.dispatchEvent(h)}else if(d>=cs.HOLD_DELAY&&Math.abs(c.initialPageX-Rs(c.rollingPageX))<30&&Math.abs(c.initialPageY-Rs(c.rollingPageY))<30){let h=this.newGestureEvent(un.Contextmenu,c.initialTarget);h.pageX=Rs(c.rollingPageX),h.pageY=Rs(c.rollingPageY),this.dispatchEvent(h)}else if(i===1){let h=Rs(c.rollingPageX),u=Rs(c.rollingPageY),f=Rs(c.rollingTimestamps)-c.rollingTimestamps[0],m=h-c.rollingPageX[0],p=u-c.rollingPageY[0],g=[...this.targets].filter(x=>c.initialTarget instanceof Node&&x.contains(c.initialTarget));this.inertia(e,g,n,Math.abs(m)/f,m>0?1:-1,h,Math.abs(p)/f,p>0?1:-1,u)}this.dispatchEvent(this.newGestureEvent(un.End,c.initialTarget)),delete this.activeTouches[l.identifier]}this.dispatched&&(s.preventDefault(),s.stopPropagation(),this.dispatched=!1)}newGestureEvent(e,s){let n=document.createEvent("CustomEvent");return n.initEvent(e,!1,!0),n.initialTarget=s,n.tapCount=0,n}dispatchEvent(e){if(e.type===un.Tap){let s=new Date().getTime(),n=0;s-this._lastSetTapCountTime>cs.CLEAR_TAP_COUNT_TIME?n=1:n=2,this._lastSetTapCountTime=s,e.tapCount=n}else(e.type===un.Change||e.type===un.Contextmenu)&&(this._lastSetTapCountTime=0);if(e.initialTarget instanceof Node){for(let n of this.ignoreTargets)if(n.contains(e.initialTarget))return;let s=[];for(let n of this.targets)if(n.contains(e.initialTarget)){let i=0,o=e.initialTarget;for(;o&&o!==n;)i++,o=o.parentElement;s.push([i,n])}s.sort((n,i)=>n[0]-i[0]);for(let[n,i]of s)i.dispatchEvent(e),this.dispatched=!0}}inertia(e,s,n,i,o,a,l,c,d){this.handle=Mu(e,()=>{let h=Date.now(),u=h-n,f=0,m=0,p=!0;i+=cs.SCROLL_FRICTION*u,l+=cs.SCROLL_FRICTION*u,i>0&&(p=!1,f=o*i*u),l>0&&(p=!1,m=c*l*u);let g=this.newGestureEvent(un.Change);g.translationX=f,g.translationY=m,s.forEach(x=>x.dispatchEvent(g)),p||this.inertia(e,s,h,i,o,a+f,l,c,d+m)})}onTouchMove(e){let s=Date.now();for(let n=0,i=e.changedTouches.length;n<i;n++){let o=e.changedTouches.item(n);if(!this.activeTouches.hasOwnProperty(String(o.identifier))){console.warn("end of an UNKNOWN touch",o);continue}let a=this.activeTouches[o.identifier],l=this.newGestureEvent(un.Change,a.initialTarget);l.translationX=o.pageX-Rs(a.rollingPageX),l.translationY=o.pageY-Rs(a.rollingPageY),l.pageX=o.pageX,l.pageY=o.pageY,this.dispatchEvent(l),a.rollingPageX.length>3&&(a.rollingPageX.shift(),a.rollingPageY.shift(),a.rollingTimestamps.shift()),a.rollingPageX.push(o.pageX),a.rollingPageY.push(o.pageY),a.rollingTimestamps.push(s)}this.dispatched&&(e.preventDefault(),e.stopPropagation(),this.dispatched=!1)}};fo.SCROLL_FRICTION=-.005,fo.HOLD_DELAY=700,fo.CLEAR_TAP_COUNT_TIME=400,At([VB],fo,"isTouchDevice",1);var NB=fo,Ou=class extends tt{onclick(t,e){this._register(Ge(t,Ht.CLICK,s=>e(new $a(mn(t),s))))}onmousedown(t,e){this._register(Ge(t,Ht.MOUSE_DOWN,s=>e(new $a(mn(t),s))))}onmouseover(t,e){this._register(Ge(t,Ht.MOUSE_OVER,s=>e(new $a(mn(t),s))))}onmouseleave(t,e){this._register(Ge(t,Ht.MOUSE_LEAVE,s=>e(new $a(mn(t),s))))}onkeydown(t,e){this._register(Ge(t,Ht.KEY_DOWN,s=>e(new S1(s))))}onkeyup(t,e){this._register(Ge(t,Ht.KEY_UP,s=>e(new S1(s))))}oninput(t,e){this._register(Ge(t,Ht.INPUT,e))}onblur(t,e){this._register(Ge(t,Ht.BLUR,e))}onfocus(t,e){this._register(Ge(t,Ht.FOCUS,e))}onchange(t,e){this._register(Ge(t,Ht.CHANGE,e))}ignoreGesture(t){return NB.ignoreTarget(t)}},N1=11,TB=class extends Ou{constructor(t){super(),this._onActivate=t.onActivate,this.bgDomNode=document.createElement("div"),this.bgDomNode.className="arrow-background",this.bgDomNode.style.position="absolute",this.bgDomNode.style.width=t.bgWidth+"px",this.bgDomNode.style.height=t.bgHeight+"px",typeof t.top<"u"&&(this.bgDomNode.style.top="0px"),typeof t.left<"u"&&(this.bgDomNode.style.left="0px"),typeof t.bottom<"u"&&(this.bgDomNode.style.bottom="0px"),typeof t.right<"u"&&(this.bgDomNode.style.right="0px"),this.domNode=document.createElement("div"),this.domNode.className=t.className,this.domNode.style.position="absolute",this.domNode.style.width=N1+"px",this.domNode.style.height=N1+"px",typeof t.top<"u"&&(this.domNode.style.top=t.top+"px"),typeof t.left<"u"&&(this.domNode.style.left=t.left+"px"),typeof t.bottom<"u"&&(this.domNode.style.bottom=t.bottom+"px"),typeof t.right<"u"&&(this.domNode.style.right=t.right+"px"),this._pointerMoveMonitor=this._register(new m5),this._register(k1(this.bgDomNode,Ht.POINTER_DOWN,e=>this._arrowPointerDown(e))),this._register(k1(this.domNode,Ht.POINTER_DOWN,e=>this._arrowPointerDown(e))),this._pointerdownRepeatTimer=this._register(new jB),this._pointerdownScheduleRepeatTimer=this._register(new Iu)}_arrowPointerDown(t){if(!t.target||!(t.target instanceof Element))return;let e=()=>{this._pointerdownRepeatTimer.cancelAndSet(()=>this._onActivate(),1e3/24,mn(t))};this._onActivate(),this._pointerdownRepeatTimer.cancel(),this._pointerdownScheduleRepeatTimer.cancelAndSet(e,200),this._pointerMoveMonitor.startMonitoring(t.target,t.pointerId,t.buttons,s=>{},()=>{this._pointerdownRepeatTimer.cancel(),this._pointerdownScheduleRepeatTimer.cancel()}),t.preventDefault()}},AB=class _0{constructor(e,s,n,i,o,a,l){this._forceIntegerValues=e,this._scrollStateBrand=void 0,this._forceIntegerValues&&(s=s|0,n=n|0,i=i|0,o=o|0,a=a|0,l=l|0),this.rawScrollLeft=i,this.rawScrollTop=l,s<0&&(s=0),i+s>n&&(i=n-s),i<0&&(i=0),o<0&&(o=0),l+o>a&&(l=a-o),l<0&&(l=0),this.width=s,this.scrollWidth=n,this.scrollLeft=i,this.height=o,this.scrollHeight=a,this.scrollTop=l}equals(e){return this.rawScrollLeft===e.rawScrollLeft&&this.rawScrollTop===e.rawScrollTop&&this.width===e.width&&this.scrollWidth===e.scrollWidth&&this.scrollLeft===e.scrollLeft&&this.height===e.height&&this.scrollHeight===e.scrollHeight&&this.scrollTop===e.scrollTop}withScrollDimensions(e,s){return new _0(this._forceIntegerValues,typeof e.width<"u"?e.width:this.width,typeof e.scrollWidth<"u"?e.scrollWidth:this.scrollWidth,s?this.rawScrollLeft:this.scrollLeft,typeof e.height<"u"?e.height:this.height,typeof e.scrollHeight<"u"?e.scrollHeight:this.scrollHeight,s?this.rawScrollTop:this.scrollTop)}withScrollPosition(e){return new _0(this._forceIntegerValues,this.width,this.scrollWidth,typeof e.scrollLeft<"u"?e.scrollLeft:this.rawScrollLeft,this.height,this.scrollHeight,typeof e.scrollTop<"u"?e.scrollTop:this.rawScrollTop)}createScrollEvent(e,s){let n=this.width!==e.width,i=this.scrollWidth!==e.scrollWidth,o=this.scrollLeft!==e.scrollLeft,a=this.height!==e.height,l=this.scrollHeight!==e.scrollHeight,c=this.scrollTop!==e.scrollTop;return{inSmoothScrolling:s,oldWidth:e.width,oldScrollWidth:e.scrollWidth,oldScrollLeft:e.scrollLeft,width:this.width,scrollWidth:this.scrollWidth,scrollLeft:this.scrollLeft,oldHeight:e.height,oldScrollHeight:e.scrollHeight,oldScrollTop:e.scrollTop,height:this.height,scrollHeight:this.scrollHeight,scrollTop:this.scrollTop,widthChanged:n,scrollWidthChanged:i,scrollLeftChanged:o,heightChanged:a,scrollHeightChanged:l,scrollTopChanged:c}}},EB=class extends tt{constructor(t){super(),this._scrollableBrand=void 0,this._onScroll=this._register(new Te),this.onScroll=this._onScroll.event,this._smoothScrollDuration=t.smoothScrollDuration,this._scheduleAtNextAnimationFrame=t.scheduleAtNextAnimationFrame,this._state=new AB(t.forceIntegerValues,0,0,0,0,0,0),this._smoothScrolling=null}dispose(){this._smoothScrolling&&(this._smoothScrolling.dispose(),this._smoothScrolling=null),super.dispose()}setSmoothScrollDuration(t){this._smoothScrollDuration=t}validateScrollPosition(t){return this._state.withScrollPosition(t)}getScrollDimensions(){return this._state}setScrollDimensions(t,e){let s=this._state.withScrollDimensions(t,e);this._setState(s,!!this._smoothScrolling),this._smoothScrolling?.acceptScrollDimensions(this._state)}getFutureScrollPosition(){return this._smoothScrolling?this._smoothScrolling.to:this._state}getCurrentScrollPosition(){return this._state}setScrollPositionNow(t){let e=this._state.withScrollPosition(t);this._smoothScrolling&&(this._smoothScrolling.dispose(),this._smoothScrolling=null),this._setState(e,!1)}setScrollPositionSmooth(t,e){if(this._smoothScrollDuration===0)return this.setScrollPositionNow(t);if(this._smoothScrolling){t={scrollLeft:typeof t.scrollLeft>"u"?this._smoothScrolling.to.scrollLeft:t.scrollLeft,scrollTop:typeof t.scrollTop>"u"?this._smoothScrolling.to.scrollTop:t.scrollTop};let s=this._state.withScrollPosition(t);if(this._smoothScrolling.to.scrollLeft===s.scrollLeft&&this._smoothScrolling.to.scrollTop===s.scrollTop)return;let n;e?n=new A1(this._smoothScrolling.from,s,this._smoothScrolling.startTime,this._smoothScrolling.duration):n=this._smoothScrolling.combine(this._state,s,this._smoothScrollDuration),this._smoothScrolling.dispose(),this._smoothScrolling=n}else{let s=this._state.withScrollPosition(t);this._smoothScrolling=A1.start(this._state,s,this._smoothScrollDuration)}this._smoothScrolling.animationFrameDisposable=this._scheduleAtNextAnimationFrame(()=>{this._smoothScrolling&&(this._smoothScrolling.animationFrameDisposable=null,this._performSmoothScrolling())})}hasPendingScrollAnimation(){return!!this._smoothScrolling}_performSmoothScrolling(){if(!this._smoothScrolling)return;let t=this._smoothScrolling.tick(),e=this._state.withScrollPosition(t);if(this._setState(e,!0),!!this._smoothScrolling){if(t.isDone){this._smoothScrolling.dispose(),this._smoothScrolling=null;return}this._smoothScrolling.animationFrameDisposable=this._scheduleAtNextAnimationFrame(()=>{this._smoothScrolling&&(this._smoothScrolling.animationFrameDisposable=null,this._performSmoothScrolling())})}}_setState(t,e){let s=this._state;s.equals(t)||(this._state=t,this._onScroll.fire(this._state.createScrollEvent(s,e)))}},T1=class{constructor(t,e,s){this.scrollLeft=t,this.scrollTop=e,this.isDone=s}};function _d(t,e){let s=e-t;return function(n){return t+s*DB(n)}}function PB(t,e,s){return function(n){return n<s?t(n/s):e((n-s)/(1-s))}}var A1=class L0{constructor(e,s,n,i){this.from=e,this.to=s,this.duration=i,this.startTime=n,this.animationFrameDisposable=null,this._initAnimations()}_initAnimations(){this.scrollLeft=this._initAnimation(this.from.scrollLeft,this.to.scrollLeft,this.to.width),this.scrollTop=this._initAnimation(this.from.scrollTop,this.to.scrollTop,this.to.height)}_initAnimation(e,s,n){if(Math.abs(e-s)>2.5*n){let i,o;return e<s?(i=e+.75*n,o=s-.75*n):(i=e-.75*n,o=s+.75*n),PB(_d(e,i),_d(o,s),.33)}return _d(e,s)}dispose(){this.animationFrameDisposable!==null&&(this.animationFrameDisposable.dispose(),this.animationFrameDisposable=null)}acceptScrollDimensions(e){this.to=e.withScrollPosition(this.to),this._initAnimations()}tick(){return this._tick(Date.now())}_tick(e){let s=(e-this.startTime)/this.duration;if(s<1){let n=this.scrollLeft(s),i=this.scrollTop(s);return new T1(n,i,!1)}return new T1(this.to.scrollLeft,this.to.scrollTop,!0)}combine(e,s,n){return L0.start(e,s,n)}static start(e,s,n){n=n+10;let i=Date.now()-10;return new L0(e,s,i,n)}};function RB(t){return Math.pow(t,3)}function DB(t){return 1-RB(1-t)}var IB=class extends tt{constructor(t,e,s){super(),this._visibility=t,this._visibleClassName=e,this._invisibleClassName=s,this._domNode=null,this._isVisible=!1,this._isNeeded=!1,this._rawShouldBeVisible=!1,this._shouldBeVisible=!1,this._revealTimer=this._register(new Iu)}setVisibility(t){this._visibility!==t&&(this._visibility=t,this._updateShouldBeVisible())}setShouldBeVisible(t){this._rawShouldBeVisible=t,this._updateShouldBeVisible()}_applyVisibilitySetting(){return this._visibility===2?!1:this._visibility===3?!0:this._rawShouldBeVisible}_updateShouldBeVisible(){let t=this._applyVisibilitySetting();this._shouldBeVisible!==t&&(this._shouldBeVisible=t,this.ensureVisibility())}setIsNeeded(t){this._isNeeded!==t&&(this._isNeeded=t,this.ensureVisibility())}setDomNode(t){this._domNode=t,this._domNode.setClassName(this._invisibleClassName),this.setShouldBeVisible(!1)}ensureVisibility(){if(!this._isNeeded){this._hide(!1);return}this._shouldBeVisible?this._reveal():this._hide(!0)}_reveal(){this._isVisible||(this._isVisible=!0,this._revealTimer.setIfNotSet(()=>{this._domNode?.setClassName(this._visibleClassName)},0))}_hide(t){this._revealTimer.cancel(),this._isVisible&&(this._isVisible=!1,this._domNode?.setClassName(this._invisibleClassName+(t?" fade":"")))}},MB=140,p5=class extends Ou{constructor(t){super(),this._lazyRender=t.lazyRender,this._host=t.host,this._scrollable=t.scrollable,this._scrollByPage=t.scrollByPage,this._scrollbarState=t.scrollbarState,this._visibilityController=this._register(new IB(t.visibility,"visible scrollbar "+t.extraScrollbarClassName,"invisible scrollbar "+t.extraScrollbarClassName)),this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._pointerMoveMonitor=this._register(new m5),this._shouldRender=!0,this.domNode=To(document.createElement("div")),this.domNode.setAttribute("role","presentation"),this.domNode.setAttribute("aria-hidden","true"),this._visibilityController.setDomNode(this.domNode),this.domNode.setPosition("absolute"),this._register(Ge(this.domNode.domNode,Ht.POINTER_DOWN,e=>this._domNodePointerDown(e)))}_createArrow(t){let e=this._register(new TB(t));this.domNode.domNode.appendChild(e.bgDomNode),this.domNode.domNode.appendChild(e.domNode)}_createSlider(t,e,s,n){this.slider=To(document.createElement("div")),this.slider.setClassName("slider"),this.slider.setPosition("absolute"),this.slider.setTop(t),this.slider.setLeft(e),typeof s=="number"&&this.slider.setWidth(s),typeof n=="number"&&this.slider.setHeight(n),this.slider.setLayerHinting(!0),this.slider.setContain("strict"),this.domNode.domNode.appendChild(this.slider.domNode),this._register(Ge(this.slider.domNode,Ht.POINTER_DOWN,i=>{i.button===0&&(i.preventDefault(),this._sliderPointerDown(i))})),this.onclick(this.slider.domNode,i=>{i.leftButton&&i.stopPropagation()})}_onElementSize(t){return this._scrollbarState.setVisibleSize(t)&&(this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._shouldRender=!0,this._lazyRender||this.render()),this._shouldRender}_onElementScrollSize(t){return this._scrollbarState.setScrollSize(t)&&(this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._shouldRender=!0,this._lazyRender||this.render()),this._shouldRender}_onElementScrollPosition(t){return this._scrollbarState.setScrollPosition(t)&&(this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._shouldRender=!0,this._lazyRender||this.render()),this._shouldRender}beginReveal(){this._visibilityController.setShouldBeVisible(!0)}beginHide(){this._visibilityController.setShouldBeVisible(!1)}render(){this._shouldRender&&(this._shouldRender=!1,this._renderDomNode(this._scrollbarState.getRectangleLargeSize(),this._scrollbarState.getRectangleSmallSize()),this._updateSlider(this._scrollbarState.getSliderSize(),this._scrollbarState.getArrowSize()+this._scrollbarState.getSliderPosition()))}_domNodePointerDown(t){t.target===this.domNode.domNode&&this._onPointerDown(t)}delegatePointerDown(t){let e=this.domNode.domNode.getClientRects()[0].top,s=e+this._scrollbarState.getSliderPosition(),n=e+this._scrollbarState.getSliderPosition()+this._scrollbarState.getSliderSize(),i=this._sliderPointerPosition(t);s<=i&&i<=n?t.button===0&&(t.preventDefault(),this._sliderPointerDown(t)):this._onPointerDown(t)}_onPointerDown(t){let e,s;if(t.target===this.domNode.domNode&&typeof t.offsetX=="number"&&typeof t.offsetY=="number")e=t.offsetX,s=t.offsetY;else{let i=CB(this.domNode.domNode);e=t.pageX-i.left,s=t.pageY-i.top}let n=this._pointerDownRelativePosition(e,s);this._setDesiredScrollPositionNow(this._scrollByPage?this._scrollbarState.getDesiredScrollPositionFromOffsetPaged(n):this._scrollbarState.getDesiredScrollPositionFromOffset(n)),t.button===0&&(t.preventDefault(),this._sliderPointerDown(t))}_sliderPointerDown(t){if(!t.target||!(t.target instanceof Element))return;let e=this._sliderPointerPosition(t),s=this._sliderOrthogonalPointerPosition(t),n=this._scrollbarState.clone();this.slider.toggleClassName("active",!0),this._pointerMoveMonitor.startMonitoring(t.target,t.pointerId,t.buttons,i=>{let o=this._sliderOrthogonalPointerPosition(i),a=Math.abs(o-s);if(d5&&a>MB){this._setDesiredScrollPositionNow(n.getScrollPosition());return}let l=this._sliderPointerPosition(i)-e;this._setDesiredScrollPositionNow(n.getDesiredScrollPositionFromDelta(l))},()=>{this.slider.toggleClassName("active",!1),this._host.onDragEnd()}),this._host.onDragStart()}_setDesiredScrollPositionNow(t){let e={};this.writeScrollPosition(e,t),this._scrollable.setScrollPositionNow(e)}updateScrollbarSize(t){this._updateScrollbarSize(t),this._scrollbarState.setScrollbarSize(t),this._shouldRender=!0,this._lazyRender||this.render()}isNeeded(){return this._scrollbarState.isNeeded()}},g5=class S0{constructor(e,s,n,i,o,a){this._scrollbarSize=Math.round(s),this._oppositeScrollbarSize=Math.round(n),this._arrowSize=Math.round(e),this._visibleSize=i,this._scrollSize=o,this._scrollPosition=a,this._computedAvailableSize=0,this._computedIsNeeded=!1,this._computedSliderSize=0,this._computedSliderRatio=0,this._computedSliderPosition=0,this._refreshComputedValues()}clone(){return new S0(this._arrowSize,this._scrollbarSize,this._oppositeScrollbarSize,this._visibleSize,this._scrollSize,this._scrollPosition)}setVisibleSize(e){let s=Math.round(e);return this._visibleSize!==s?(this._visibleSize=s,this._refreshComputedValues(),!0):!1}setScrollSize(e){let s=Math.round(e);return this._scrollSize!==s?(this._scrollSize=s,this._refreshComputedValues(),!0):!1}setScrollPosition(e){let s=Math.round(e);return this._scrollPosition!==s?(this._scrollPosition=s,this._refreshComputedValues(),!0):!1}setScrollbarSize(e){this._scrollbarSize=Math.round(e)}setOppositeScrollbarSize(e){this._oppositeScrollbarSize=Math.round(e)}static _computeValues(e,s,n,i,o){let a=Math.max(0,n-e),l=Math.max(0,a-2*s),c=i>0&&i>n;if(!c)return{computedAvailableSize:Math.round(a),computedIsNeeded:c,computedSliderSize:Math.round(l),computedSliderRatio:0,computedSliderPosition:0};let d=Math.round(Math.max(20,Math.floor(n*l/i))),h=(l-d)/(i-n),u=o*h;return{computedAvailableSize:Math.round(a),computedIsNeeded:c,computedSliderSize:Math.round(d),computedSliderRatio:h,computedSliderPosition:Math.round(u)}}_refreshComputedValues(){let e=S0._computeValues(this._oppositeScrollbarSize,this._arrowSize,this._visibleSize,this._scrollSize,this._scrollPosition);this._computedAvailableSize=e.computedAvailableSize,this._computedIsNeeded=e.computedIsNeeded,this._computedSliderSize=e.computedSliderSize,this._computedSliderRatio=e.computedSliderRatio,this._computedSliderPosition=e.computedSliderPosition}getArrowSize(){return this._arrowSize}getScrollPosition(){return this._scrollPosition}getRectangleLargeSize(){return this._computedAvailableSize}getRectangleSmallSize(){return this._scrollbarSize}isNeeded(){return this._computedIsNeeded}getSliderSize(){return this._computedSliderSize}getSliderPosition(){return this._computedSliderPosition}getDesiredScrollPositionFromOffset(e){if(!this._computedIsNeeded)return 0;let s=e-this._arrowSize-this._computedSliderSize/2;return Math.round(s/this._computedSliderRatio)}getDesiredScrollPositionFromOffsetPaged(e){if(!this._computedIsNeeded)return 0;let s=e-this._arrowSize,n=this._scrollPosition;return s<this._computedSliderPosition?n-=this._visibleSize:n+=this._visibleSize,n}getDesiredScrollPositionFromDelta(e){if(!this._computedIsNeeded)return 0;let s=this._computedSliderPosition+e;return Math.round(s/this._computedSliderRatio)}},OB=class extends p5{constructor(t,e,s){let n=t.getScrollDimensions(),i=t.getCurrentScrollPosition();if(super({lazyRender:e.lazyRender,host:s,scrollbarState:new g5(e.horizontalHasArrows?e.arrowSize:0,e.horizontal===2?0:e.horizontalScrollbarSize,e.vertical===2?0:e.verticalScrollbarSize,n.width,n.scrollWidth,i.scrollLeft),visibility:e.horizontal,extraScrollbarClassName:"horizontal",scrollable:t,scrollByPage:e.scrollByPage}),e.horizontalHasArrows)throw new Error("horizontalHasArrows is not supported in xterm.js");this._createSlider(Math.floor((e.horizontalScrollbarSize-e.horizontalSliderSize)/2),0,void 0,e.horizontalSliderSize)}_updateSlider(t,e){this.slider.setWidth(t),this.slider.setLeft(e)}_renderDomNode(t,e){this.domNode.setWidth(t),this.domNode.setHeight(e),this.domNode.setLeft(0),this.domNode.setBottom(0)}onDidScroll(t){return this._shouldRender=this._onElementScrollSize(t.scrollWidth)||this._shouldRender,this._shouldRender=this._onElementScrollPosition(t.scrollLeft)||this._shouldRender,this._shouldRender=this._onElementSize(t.width)||this._shouldRender,this._shouldRender}_pointerDownRelativePosition(t,e){return t}_sliderPointerPosition(t){return t.pageX}_sliderOrthogonalPointerPosition(t){return t.pageY}_updateScrollbarSize(t){this.slider.setHeight(t)}writeScrollPosition(t,e){t.scrollLeft=e}updateOptions(t){this.updateScrollbarSize(t.horizontal===2?0:t.horizontalScrollbarSize),this._scrollbarState.setOppositeScrollbarSize(t.vertical===2?0:t.verticalScrollbarSize),this._visibilityController.setVisibility(t.horizontal),this._scrollByPage=t.scrollByPage}},$B=class extends p5{constructor(t,e,s){let n=t.getScrollDimensions(),i=t.getCurrentScrollPosition();if(super({lazyRender:e.lazyRender,host:s,scrollbarState:new g5(e.verticalHasArrows?e.arrowSize:0,e.vertical===2?0:e.verticalScrollbarSize,0,n.height,n.scrollHeight,i.scrollTop),visibility:e.vertical,extraScrollbarClassName:"vertical",scrollable:t,scrollByPage:e.scrollByPage}),e.verticalHasArrows)throw new Error("horizontalHasArrows is not supported in xterm.js");this._createSlider(0,Math.floor((e.verticalScrollbarSize-e.verticalSliderSize)/2),e.verticalSliderSize,void 0)}_updateSlider(t,e){this.slider.setHeight(t),this.slider.setTop(e)}_renderDomNode(t,e){this.domNode.setWidth(e),this.domNode.setHeight(t),this.domNode.setRight(0),this.domNode.setTop(0)}onDidScroll(t){return this._shouldRender=this._onElementScrollSize(t.scrollHeight)||this._shouldRender,this._shouldRender=this._onElementScrollPosition(t.scrollTop)||this._shouldRender,this._shouldRender=this._onElementSize(t.height)||this._shouldRender,this._shouldRender}_pointerDownRelativePosition(t,e){return e}_sliderPointerPosition(t){return t.pageY}_sliderOrthogonalPointerPosition(t){return t.pageX}_updateScrollbarSize(t){this.slider.setWidth(t)}writeScrollPosition(t,e){t.scrollTop=e}updateOptions(t){this.updateScrollbarSize(t.vertical===2?0:t.verticalScrollbarSize),this._scrollbarState.setOppositeScrollbarSize(0),this._visibilityController.setVisibility(t.vertical),this._scrollByPage=t.scrollByPage}},BB=500,E1=50,FB=class{constructor(t,e,s){this.timestamp=t,this.deltaX=e,this.deltaY=s,this.score=0}},w0=class{constructor(){this._capacity=5,this._memory=[],this._front=-1,this._rear=-1}isPhysicalMouseWheel(){if(this._front===-1&&this._rear===-1)return!1;let e=1,s=0,n=1,i=this._rear;do{let o=i===this._front?e:Math.pow(2,-n);if(e-=o,s+=this._memory[i].score*o,i===this._front)break;i=(this._capacity+i-1)%this._capacity,n++}while(!0);return s<=.5}acceptStandardWheelEvent(e){if(Ru){let s=mn(e.browserEvent),n=Q$(s);this.accept(Date.now(),e.deltaX*n,e.deltaY*n)}else this.accept(Date.now(),e.deltaX,e.deltaY)}accept(e,s,n){let i=null,o=new FB(e,s,n);this._front===-1&&this._rear===-1?(this._memory[0]=o,this._front=0,this._rear=0):(i=this._memory[this._rear],this._rear=(this._rear+1)%this._capacity,this._rear===this._front&&(this._front=(this._front+1)%this._capacity),this._memory[this._rear]=o),o.score=this._computeScore(o,i)}_computeScore(e,s){if(Math.abs(e.deltaX)>0&&Math.abs(e.deltaY)>0)return 1;let n=.5;if((!this._isAlmostInt(e.deltaX)||!this._isAlmostInt(e.deltaY))&&(n+=.25),s){let i=Math.abs(e.deltaX),o=Math.abs(e.deltaY),a=Math.abs(s.deltaX),l=Math.abs(s.deltaY),c=Math.max(Math.min(i,a),1),d=Math.max(Math.min(o,l),1),h=Math.max(i,a),u=Math.max(o,l);h%c===0&&u%d===0&&(n-=.5)}return Math.min(Math.max(n,0),1)}_isAlmostInt(e){return Math.abs(Math.round(e)-e)<.01}};w0.INSTANCE=new w0;var zB=w0,KB=class extends Ou{constructor(t,e,s){super(),this._onScroll=this._register(new Te),this.onScroll=this._onScroll.event,this._onWillScroll=this._register(new Te),this.onWillScroll=this._onWillScroll.event,this._options=HB(e),this._scrollable=s,this._register(this._scrollable.onScroll(i=>{this._onWillScroll.fire(i),this._onDidScroll(i),this._onScroll.fire(i)}));let n={onMouseWheel:i=>this._onMouseWheel(i),onDragStart:()=>this._onDragStart(),onDragEnd:()=>this._onDragEnd()};this._verticalScrollbar=this._register(new $B(this._scrollable,this._options,n)),this._horizontalScrollbar=this._register(new OB(this._scrollable,this._options,n)),this._domNode=document.createElement("div"),this._domNode.className="xterm-scrollable-element "+this._options.className,this._domNode.setAttribute("role","presentation"),this._domNode.style.position="relative",this._domNode.appendChild(t),this._domNode.appendChild(this._horizontalScrollbar.domNode.domNode),this._domNode.appendChild(this._verticalScrollbar.domNode.domNode),this._options.useShadows?(this._leftShadowDomNode=To(document.createElement("div")),this._leftShadowDomNode.setClassName("shadow"),this._domNode.appendChild(this._leftShadowDomNode.domNode),this._topShadowDomNode=To(document.createElement("div")),this._topShadowDomNode.setClassName("shadow"),this._domNode.appendChild(this._topShadowDomNode.domNode),this._topLeftShadowDomNode=To(document.createElement("div")),this._topLeftShadowDomNode.setClassName("shadow"),this._domNode.appendChild(this._topLeftShadowDomNode.domNode)):(this._leftShadowDomNode=null,this._topShadowDomNode=null,this._topLeftShadowDomNode=null),this._listenOnDomNode=this._options.listenOnDomNode||this._domNode,this._mouseWheelToDispose=[],this._setListeningToMouseWheel(this._options.handleMouseWheel),this.onmouseover(this._listenOnDomNode,i=>this._onMouseOver(i)),this.onmouseleave(this._listenOnDomNode,i=>this._onMouseLeave(i)),this._hideTimeout=this._register(new Iu),this._isDragging=!1,this._mouseIsOver=!1,this._shouldRender=!0,this._revealOnScroll=!0}get options(){return this._options}dispose(){this._mouseWheelToDispose=Pi(this._mouseWheelToDispose),super.dispose()}getDomNode(){return this._domNode}getOverviewRulerLayoutInfo(){return{parent:this._domNode,insertBefore:this._verticalScrollbar.domNode.domNode}}delegateVerticalScrollbarPointerDown(t){this._verticalScrollbar.delegatePointerDown(t)}getScrollDimensions(){return this._scrollable.getScrollDimensions()}setScrollDimensions(t){this._scrollable.setScrollDimensions(t,!1)}updateClassName(t){this._options.className=t,vn&&(this._options.className+=" mac"),this._domNode.className="xterm-scrollable-element "+this._options.className}updateOptions(t){typeof t.handleMouseWheel<"u"&&(this._options.handleMouseWheel=t.handleMouseWheel,this._setListeningToMouseWheel(this._options.handleMouseWheel)),typeof t.mouseWheelScrollSensitivity<"u"&&(this._options.mouseWheelScrollSensitivity=t.mouseWheelScrollSensitivity),typeof t.fastScrollSensitivity<"u"&&(this._options.fastScrollSensitivity=t.fastScrollSensitivity),typeof t.scrollPredominantAxis<"u"&&(this._options.scrollPredominantAxis=t.scrollPredominantAxis),typeof t.horizontal<"u"&&(this._options.horizontal=t.horizontal),typeof t.vertical<"u"&&(this._options.vertical=t.vertical),typeof t.horizontalScrollbarSize<"u"&&(this._options.horizontalScrollbarSize=t.horizontalScrollbarSize),typeof t.verticalScrollbarSize<"u"&&(this._options.verticalScrollbarSize=t.verticalScrollbarSize),typeof t.scrollByPage<"u"&&(this._options.scrollByPage=t.scrollByPage),this._horizontalScrollbar.updateOptions(this._options),this._verticalScrollbar.updateOptions(this._options),this._options.lazyRender||this._render()}setRevealOnScroll(t){this._revealOnScroll=t}delegateScrollFromMouseWheelEvent(t){this._onMouseWheel(new j1(t))}_setListeningToMouseWheel(t){if(this._mouseWheelToDispose.length>0!==t&&(this._mouseWheelToDispose=Pi(this._mouseWheelToDispose),t)){let e=s=>{this._onMouseWheel(new j1(s))};this._mouseWheelToDispose.push(Ge(this._listenOnDomNode,Ht.MOUSE_WHEEL,e,{passive:!1}))}}_onMouseWheel(t){if(t.browserEvent?.defaultPrevented)return;let e=zB.INSTANCE;e.acceptStandardWheelEvent(t);let s=!1;if(t.deltaY||t.deltaX){let i=t.deltaY*this._options.mouseWheelScrollSensitivity,o=t.deltaX*this._options.mouseWheelScrollSensitivity;this._options.scrollPredominantAxis&&(this._options.scrollYToX&&o+i===0?o=i=0:Math.abs(i)>=Math.abs(o)?o=0:i=0),this._options.flipAxes&&([i,o]=[o,i]);let a=!vn&&t.browserEvent&&t.browserEvent.shiftKey;(this._options.scrollYToX||a)&&!o&&(o=i,i=0),t.browserEvent&&t.browserEvent.altKey&&(o=o*this._options.fastScrollSensitivity,i=i*this._options.fastScrollSensitivity);let l=this._scrollable.getFutureScrollPosition(),c={};if(i){let d=E1*i,h=l.scrollTop-(d<0?Math.floor(d):Math.ceil(d));this._verticalScrollbar.writeScrollPosition(c,h)}if(o){let d=E1*o,h=l.scrollLeft-(d<0?Math.floor(d):Math.ceil(d));this._horizontalScrollbar.writeScrollPosition(c,h)}c=this._scrollable.validateScrollPosition(c),(l.scrollLeft!==c.scrollLeft||l.scrollTop!==c.scrollTop)&&(this._options.mouseWheelSmoothScroll&&e.isPhysicalMouseWheel()?this._scrollable.setScrollPositionSmooth(c):this._scrollable.setScrollPositionNow(c),s=!0)}let n=s;!n&&this._options.alwaysConsumeMouseWheel&&(n=!0),!n&&this._options.consumeMouseWheelIfScrollbarIsNeeded&&(this._verticalScrollbar.isNeeded()||this._horizontalScrollbar.isNeeded())&&(n=!0),n&&(t.preventDefault(),t.stopPropagation())}_onDidScroll(t){this._shouldRender=this._horizontalScrollbar.onDidScroll(t)||this._shouldRender,this._shouldRender=this._verticalScrollbar.onDidScroll(t)||this._shouldRender,this._options.useShadows&&(this._shouldRender=!0),this._revealOnScroll&&this._reveal(),this._options.lazyRender||this._render()}renderNow(){if(!this._options.lazyRender)throw new Error("Please use `lazyRender` together with `renderNow`!");this._render()}_render(){if(this._shouldRender&&(this._shouldRender=!1,this._horizontalScrollbar.render(),this._verticalScrollbar.render(),this._options.useShadows)){let t=this._scrollable.getCurrentScrollPosition(),e=t.scrollTop>0,s=t.scrollLeft>0,n=s?" left":"",i=e?" top":"",o=s||e?" top-left-corner":"";this._leftShadowDomNode.setClassName(`shadow${n}`),this._topShadowDomNode.setClassName(`shadow${i}`),this._topLeftShadowDomNode.setClassName(`shadow${o}${i}${n}`)}}_onDragStart(){this._isDragging=!0,this._reveal()}_onDragEnd(){this._isDragging=!1,this._hide()}_onMouseLeave(t){this._mouseIsOver=!1,this._hide()}_onMouseOver(t){this._mouseIsOver=!0,this._reveal()}_reveal(){this._verticalScrollbar.beginReveal(),this._horizontalScrollbar.beginReveal(),this._scheduleHide()}_hide(){!this._mouseIsOver&&!this._isDragging&&(this._verticalScrollbar.beginHide(),this._horizontalScrollbar.beginHide())}_scheduleHide(){!this._mouseIsOver&&!this._isDragging&&this._hideTimeout.cancelAndSet(()=>this._hide(),BB)}},UB=class extends KB{constructor(t,e,s){super(t,e,s)}setScrollPosition(t){t.reuseAnimation?this._scrollable.setScrollPositionSmooth(t,t.reuseAnimation):this._scrollable.setScrollPositionNow(t)}getScrollPosition(){return this._scrollable.getCurrentScrollPosition()}};function HB(t){let e={lazyRender:typeof t.lazyRender<"u"?t.lazyRender:!1,className:typeof t.className<"u"?t.className:"",useShadows:typeof t.useShadows<"u"?t.useShadows:!0,handleMouseWheel:typeof t.handleMouseWheel<"u"?t.handleMouseWheel:!0,flipAxes:typeof t.flipAxes<"u"?t.flipAxes:!1,consumeMouseWheelIfScrollbarIsNeeded:typeof t.consumeMouseWheelIfScrollbarIsNeeded<"u"?t.consumeMouseWheelIfScrollbarIsNeeded:!1,alwaysConsumeMouseWheel:typeof t.alwaysConsumeMouseWheel<"u"?t.alwaysConsumeMouseWheel:!1,scrollYToX:typeof t.scrollYToX<"u"?t.scrollYToX:!1,mouseWheelScrollSensitivity:typeof t.mouseWheelScrollSensitivity<"u"?t.mouseWheelScrollSensitivity:1,fastScrollSensitivity:typeof t.fastScrollSensitivity<"u"?t.fastScrollSensitivity:5,scrollPredominantAxis:typeof t.scrollPredominantAxis<"u"?t.scrollPredominantAxis:!0,mouseWheelSmoothScroll:typeof t.mouseWheelSmoothScroll<"u"?t.mouseWheelSmoothScroll:!0,arrowSize:typeof t.arrowSize<"u"?t.arrowSize:11,listenOnDomNode:typeof t.listenOnDomNode<"u"?t.listenOnDomNode:null,horizontal:typeof t.horizontal<"u"?t.horizontal:1,horizontalScrollbarSize:typeof t.horizontalScrollbarSize<"u"?t.horizontalScrollbarSize:10,horizontalSliderSize:typeof t.horizontalSliderSize<"u"?t.horizontalSliderSize:0,horizontalHasArrows:typeof t.horizontalHasArrows<"u"?t.horizontalHasArrows:!1,vertical:typeof t.vertical<"u"?t.vertical:1,verticalScrollbarSize:typeof t.verticalScrollbarSize<"u"?t.verticalScrollbarSize:10,verticalHasArrows:typeof t.verticalHasArrows<"u"?t.verticalHasArrows:!1,verticalSliderSize:typeof t.verticalSliderSize<"u"?t.verticalSliderSize:0,scrollByPage:typeof t.scrollByPage<"u"?t.scrollByPage:!1};return e.horizontalSliderSize=typeof t.horizontalSliderSize<"u"?t.horizontalSliderSize:e.horizontalScrollbarSize,e.verticalSliderSize=typeof t.verticalSliderSize<"u"?t.verticalSliderSize:e.verticalScrollbarSize,vn&&(e.className+=" mac"),e}var j0=class extends tt{constructor(t,e,s,n,i,o,a,l){super(),this._bufferService=s,this._optionsService=a,this._renderService=l,this._onRequestScrollLines=this._register(new Te),this.onRequestScrollLines=this._onRequestScrollLines.event,this._isSyncing=!1,this._isHandlingScroll=!1,this._suppressOnScrollHandler=!1;let c=this._register(new EB({forceIntegerValues:!1,smoothScrollDuration:this._optionsService.rawOptions.smoothScrollDuration,scheduleAtNextAnimationFrame:d=>Mu(n.window,d)}));this._register(this._optionsService.onSpecificOptionChange("smoothScrollDuration",()=>{c.setSmoothScrollDuration(this._optionsService.rawOptions.smoothScrollDuration)})),this._scrollableElement=this._register(new UB(e,{vertical:1,horizontal:2,useShadows:!1,mouseWheelSmoothScroll:!0,...this._getChangeOptions()},c)),this._register(this._optionsService.onMultipleOptionChange(["scrollSensitivity","fastScrollSensitivity","overviewRuler"],()=>this._scrollableElement.updateOptions(this._getChangeOptions()))),this._register(i.onProtocolChange(d=>{this._scrollableElement.updateOptions({handleMouseWheel:!(d&16)})})),this._scrollableElement.setScrollDimensions({height:0,scrollHeight:0}),this._register(os.runAndSubscribe(o.onChangeColors,()=>{this._scrollableElement.getDomNode().style.backgroundColor=o.colors.background.css})),t.appendChild(this._scrollableElement.getDomNode()),this._register(Lt(()=>this._scrollableElement.getDomNode().remove())),this._styleElement=n.mainDocument.createElement("style"),e.appendChild(this._styleElement),this._register(Lt(()=>this._styleElement.remove())),this._register(os.runAndSubscribe(o.onChangeColors,()=>{this._styleElement.textContent=[".xterm .xterm-scrollable-element > .scrollbar > .slider {",` background: ${o.colors.scrollbarSliderBackground.css};`,"}",".xterm .xterm-scrollable-element > .scrollbar > .slider:hover {",` background: ${o.colors.scrollbarSliderHoverBackground.css};`,"}",".xterm .xterm-scrollable-element > .scrollbar > .slider.active {",` background: ${o.colors.scrollbarSliderActiveBackground.css};`,"}"].join(`
|
|
509
|
+
`)})),this._register(this._bufferService.onResize(()=>this.queueSync())),this._register(this._bufferService.buffers.onBufferActivate(()=>{this._latestYDisp=void 0,this.queueSync()})),this._register(this._bufferService.onScroll(()=>this._sync())),this._register(this._scrollableElement.onScroll(d=>this._handleScroll(d)))}scrollLines(t){let e=this._scrollableElement.getScrollPosition();this._scrollableElement.setScrollPosition({reuseAnimation:!0,scrollTop:e.scrollTop+t*this._renderService.dimensions.css.cell.height})}scrollToLine(t,e){e&&(this._latestYDisp=t),this._scrollableElement.setScrollPosition({reuseAnimation:!e,scrollTop:t*this._renderService.dimensions.css.cell.height})}_getChangeOptions(){return{mouseWheelScrollSensitivity:this._optionsService.rawOptions.scrollSensitivity,fastScrollSensitivity:this._optionsService.rawOptions.fastScrollSensitivity,verticalScrollbarSize:this._optionsService.rawOptions.overviewRuler?.width||14}}queueSync(t){t!==void 0&&(this._latestYDisp=t),this._queuedAnimationFrame===void 0&&(this._queuedAnimationFrame=this._renderService.addRefreshCallback(()=>{this._queuedAnimationFrame=void 0,this._sync(this._latestYDisp)}))}_sync(t=this._bufferService.buffer.ydisp){!this._renderService||this._isSyncing||(this._isSyncing=!0,this._suppressOnScrollHandler=!0,this._scrollableElement.setScrollDimensions({height:this._renderService.dimensions.css.canvas.height,scrollHeight:this._renderService.dimensions.css.cell.height*this._bufferService.buffer.lines.length}),this._suppressOnScrollHandler=!1,t!==this._latestYDisp&&this._scrollableElement.setScrollPosition({scrollTop:t*this._renderService.dimensions.css.cell.height}),this._isSyncing=!1)}_handleScroll(t){if(!this._renderService||this._isHandlingScroll||this._suppressOnScrollHandler)return;this._isHandlingScroll=!0;let e=Math.round(t.scrollTop/this._renderService.dimensions.css.cell.height),s=e-this._bufferService.buffer.ydisp;s!==0&&(this._latestYDisp=e,this._onRequestScrollLines.fire(s)),this._isHandlingScroll=!1}};j0=At([Ie(2,ws),Ie(3,Mn),Ie(4,J4),Ie(5,zr),Ie(6,js),Ie(7,On)],j0);var C0=class extends tt{constructor(t,e,s,n,i){super(),this._screenElement=t,this._bufferService=e,this._coreBrowserService=s,this._decorationService=n,this._renderService=i,this._decorationElements=new Map,this._altBufferIsActive=!1,this._dimensionsChanged=!1,this._container=document.createElement("div"),this._container.classList.add("xterm-decoration-container"),this._screenElement.appendChild(this._container),this._register(this._renderService.onRenderedViewportChange(()=>this._doRefreshDecorations())),this._register(this._renderService.onDimensionsChange(()=>{this._dimensionsChanged=!0,this._queueRefresh()})),this._register(this._coreBrowserService.onDprChange(()=>this._queueRefresh())),this._register(this._bufferService.buffers.onBufferActivate(()=>{this._altBufferIsActive=this._bufferService.buffer===this._bufferService.buffers.alt})),this._register(this._decorationService.onDecorationRegistered(()=>this._queueRefresh())),this._register(this._decorationService.onDecorationRemoved(o=>this._removeDecoration(o))),this._register(Lt(()=>{this._container.remove(),this._decorationElements.clear()}))}_queueRefresh(){this._animationFrame===void 0&&(this._animationFrame=this._renderService.addRefreshCallback(()=>{this._doRefreshDecorations(),this._animationFrame=void 0}))}_doRefreshDecorations(){for(let t of this._decorationService.decorations)this._renderDecoration(t);this._dimensionsChanged=!1}_renderDecoration(t){this._refreshStyle(t),this._dimensionsChanged&&this._refreshXPosition(t)}_createElement(t){let e=this._coreBrowserService.mainDocument.createElement("div");e.classList.add("xterm-decoration"),e.classList.toggle("xterm-decoration-top-layer",t?.options?.layer==="top"),e.style.width=`${Math.round((t.options.width||1)*this._renderService.dimensions.css.cell.width)}px`,e.style.height=`${(t.options.height||1)*this._renderService.dimensions.css.cell.height}px`,e.style.top=`${(t.marker.line-this._bufferService.buffers.active.ydisp)*this._renderService.dimensions.css.cell.height}px`,e.style.lineHeight=`${this._renderService.dimensions.css.cell.height}px`;let s=t.options.x??0;return s&&s>this._bufferService.cols&&(e.style.display="none"),this._refreshXPosition(t,e),e}_refreshStyle(t){let e=t.marker.line-this._bufferService.buffers.active.ydisp;if(e<0||e>=this._bufferService.rows)t.element&&(t.element.style.display="none",t.onRenderEmitter.fire(t.element));else{let s=this._decorationElements.get(t);s||(s=this._createElement(t),t.element=s,this._decorationElements.set(t,s),this._container.appendChild(s),t.onDispose(()=>{this._decorationElements.delete(t),s.remove()})),s.style.display=this._altBufferIsActive?"none":"block",this._altBufferIsActive||(s.style.width=`${Math.round((t.options.width||1)*this._renderService.dimensions.css.cell.width)}px`,s.style.height=`${(t.options.height||1)*this._renderService.dimensions.css.cell.height}px`,s.style.top=`${e*this._renderService.dimensions.css.cell.height}px`,s.style.lineHeight=`${this._renderService.dimensions.css.cell.height}px`),t.onRenderEmitter.fire(s)}}_refreshXPosition(t,e=t.element){if(!e)return;let s=t.options.x??0;(t.options.anchor||"left")==="right"?e.style.right=s?`${s*this._renderService.dimensions.css.cell.width}px`:"":e.style.left=s?`${s*this._renderService.dimensions.css.cell.width}px`:""}_removeDecoration(t){this._decorationElements.get(t)?.remove(),this._decorationElements.delete(t),t.dispose()}};C0=At([Ie(1,ws),Ie(2,Mn),Ie(3,ga),Ie(4,On)],C0);var WB=class{constructor(){this._zones=[],this._zonePool=[],this._zonePoolIndex=0,this._linePadding={full:0,left:0,center:0,right:0}}get zones(){return this._zonePool.length=Math.min(this._zonePool.length,this._zones.length),this._zones}clear(){this._zones.length=0,this._zonePoolIndex=0}addDecoration(t){if(t.options.overviewRulerOptions){for(let e of this._zones)if(e.color===t.options.overviewRulerOptions.color&&e.position===t.options.overviewRulerOptions.position){if(this._lineIntersectsZone(e,t.marker.line))return;if(this._lineAdjacentToZone(e,t.marker.line,t.options.overviewRulerOptions.position)){this._addLineToZone(e,t.marker.line);return}}if(this._zonePoolIndex<this._zonePool.length){this._zonePool[this._zonePoolIndex].color=t.options.overviewRulerOptions.color,this._zonePool[this._zonePoolIndex].position=t.options.overviewRulerOptions.position,this._zonePool[this._zonePoolIndex].startBufferLine=t.marker.line,this._zonePool[this._zonePoolIndex].endBufferLine=t.marker.line,this._zones.push(this._zonePool[this._zonePoolIndex++]);return}this._zones.push({color:t.options.overviewRulerOptions.color,position:t.options.overviewRulerOptions.position,startBufferLine:t.marker.line,endBufferLine:t.marker.line}),this._zonePool.push(this._zones[this._zones.length-1]),this._zonePoolIndex++}}setPadding(t){this._linePadding=t}_lineIntersectsZone(t,e){return e>=t.startBufferLine&&e<=t.endBufferLine}_lineAdjacentToZone(t,e,s){return e>=t.startBufferLine-this._linePadding[s||"full"]&&e<=t.endBufferLine+this._linePadding[s||"full"]}_addLineToZone(t,e){t.startBufferLine=Math.min(t.startBufferLine,e),t.endBufferLine=Math.max(t.endBufferLine,e)}},cn={full:0,left:0,center:0,right:0},Fn={full:0,left:0,center:0,right:0},Qr={full:0,left:0,center:0,right:0},Bl=class extends tt{constructor(t,e,s,n,i,o,a,l){super(),this._viewportElement=t,this._screenElement=e,this._bufferService=s,this._decorationService=n,this._renderService=i,this._optionsService=o,this._themeService=a,this._coreBrowserService=l,this._colorZoneStore=new WB,this._shouldUpdateDimensions=!0,this._shouldUpdateAnchor=!0,this._lastKnownBufferLength=0,this._canvas=this._coreBrowserService.mainDocument.createElement("canvas"),this._canvas.classList.add("xterm-decoration-overview-ruler"),this._refreshCanvasDimensions(),this._viewportElement.parentElement?.insertBefore(this._canvas,this._viewportElement),this._register(Lt(()=>this._canvas?.remove()));let c=this._canvas.getContext("2d");if(c)this._ctx=c;else throw new Error("Ctx cannot be null");this._register(this._decorationService.onDecorationRegistered(()=>this._queueRefresh(void 0,!0))),this._register(this._decorationService.onDecorationRemoved(()=>this._queueRefresh(void 0,!0))),this._register(this._renderService.onRenderedViewportChange(()=>this._queueRefresh())),this._register(this._bufferService.buffers.onBufferActivate(()=>{this._canvas.style.display=this._bufferService.buffer===this._bufferService.buffers.alt?"none":"block"})),this._register(this._bufferService.onScroll(()=>{this._lastKnownBufferLength!==this._bufferService.buffers.normal.lines.length&&(this._refreshDrawHeightConstants(),this._refreshColorZonePadding())})),this._register(this._renderService.onRender(()=>{(!this._containerHeight||this._containerHeight!==this._screenElement.clientHeight)&&(this._queueRefresh(!0),this._containerHeight=this._screenElement.clientHeight)})),this._register(this._coreBrowserService.onDprChange(()=>this._queueRefresh(!0))),this._register(this._optionsService.onSpecificOptionChange("overviewRuler",()=>this._queueRefresh(!0))),this._register(this._themeService.onChangeColors(()=>this._queueRefresh())),this._queueRefresh(!0)}get _width(){return this._optionsService.options.overviewRuler?.width||0}_refreshDrawConstants(){let t=Math.floor((this._canvas.width-1)/3),e=Math.ceil((this._canvas.width-1)/3);Fn.full=this._canvas.width,Fn.left=t,Fn.center=e,Fn.right=t,this._refreshDrawHeightConstants(),Qr.full=1,Qr.left=1,Qr.center=1+Fn.left,Qr.right=1+Fn.left+Fn.center}_refreshDrawHeightConstants(){cn.full=Math.round(2*this._coreBrowserService.dpr);let t=this._canvas.height/this._bufferService.buffer.lines.length,e=Math.round(Math.max(Math.min(t,12),6)*this._coreBrowserService.dpr);cn.left=e,cn.center=e,cn.right=e}_refreshColorZonePadding(){this._colorZoneStore.setPadding({full:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*cn.full),left:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*cn.left),center:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*cn.center),right:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*cn.right)}),this._lastKnownBufferLength=this._bufferService.buffers.normal.lines.length}_refreshCanvasDimensions(){this._canvas.style.width=`${this._width}px`,this._canvas.width=Math.round(this._width*this._coreBrowserService.dpr),this._canvas.style.height=`${this._screenElement.clientHeight}px`,this._canvas.height=Math.round(this._screenElement.clientHeight*this._coreBrowserService.dpr),this._refreshDrawConstants(),this._refreshColorZonePadding()}_refreshDecorations(){this._shouldUpdateDimensions&&this._refreshCanvasDimensions(),this._ctx.clearRect(0,0,this._canvas.width,this._canvas.height),this._colorZoneStore.clear();for(let e of this._decorationService.decorations)this._colorZoneStore.addDecoration(e);this._ctx.lineWidth=1,this._renderRulerOutline();let t=this._colorZoneStore.zones;for(let e of t)e.position!=="full"&&this._renderColorZone(e);for(let e of t)e.position==="full"&&this._renderColorZone(e);this._shouldUpdateDimensions=!1,this._shouldUpdateAnchor=!1}_renderRulerOutline(){this._ctx.fillStyle=this._themeService.colors.overviewRulerBorder.css,this._ctx.fillRect(0,0,1,this._canvas.height),this._optionsService.rawOptions.overviewRuler.showTopBorder&&this._ctx.fillRect(1,0,this._canvas.width-1,1),this._optionsService.rawOptions.overviewRuler.showBottomBorder&&this._ctx.fillRect(1,this._canvas.height-1,this._canvas.width-1,this._canvas.height)}_renderColorZone(t){this._ctx.fillStyle=t.color,this._ctx.fillRect(Qr[t.position||"full"],Math.round((this._canvas.height-1)*(t.startBufferLine/this._bufferService.buffers.active.lines.length)-cn[t.position||"full"]/2),Fn[t.position||"full"],Math.round((this._canvas.height-1)*((t.endBufferLine-t.startBufferLine)/this._bufferService.buffers.active.lines.length)+cn[t.position||"full"]))}_queueRefresh(t,e){this._shouldUpdateDimensions=t||this._shouldUpdateDimensions,this._shouldUpdateAnchor=e||this._shouldUpdateAnchor,this._animationFrame===void 0&&(this._animationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>{this._refreshDecorations(),this._animationFrame=void 0}))}};Bl=At([Ie(2,ws),Ie(3,ga),Ie(4,On),Ie(5,js),Ie(6,zr),Ie(7,Mn)],Bl);var _e;(t=>(t.NUL="\0",t.SOH="",t.STX="",t.ETX="",t.EOT="",t.ENQ="",t.ACK="",t.BEL="\x07",t.BS="\b",t.HT=" ",t.LF=`
|
|
510
|
+
`,t.VT="\v",t.FF="\f",t.CR="\r",t.SO="",t.SI="",t.DLE="",t.DC1="",t.DC2="",t.DC3="",t.DC4="",t.NAK="",t.SYN="",t.ETB="",t.CAN="",t.EM="",t.SUB="",t.ESC="\x1B",t.FS="",t.GS="",t.RS="",t.US="",t.SP=" ",t.DEL=""))(_e||={});var Za;(t=>(t.PAD="",t.HOP="",t.BPH="",t.NBH="",t.IND="",t.NEL="
",t.SSA="",t.ESA="",t.HTS="",t.HTJ="",t.VTS="",t.PLD="",t.PLU="",t.RI="",t.SS2="",t.SS3="",t.DCS="",t.PU1="",t.PU2="",t.STS="",t.CCH="",t.MW="",t.SPA="",t.EPA="",t.SOS="",t.SGCI="",t.SCI="",t.CSI="",t.ST="",t.OSC="",t.PM="",t.APC=""))(Za||={});var x5;(t=>t.ST=`${_e.ESC}\\`)(x5||={});var k0=class{constructor(t,e,s,n,i,o){this._textarea=t,this._compositionView=e,this._bufferService=s,this._optionsService=n,this._coreService=i,this._renderService=o,this._isComposing=!1,this._isSendingComposition=!1,this._compositionPosition={start:0,end:0},this._dataAlreadySent=""}get isComposing(){return this._isComposing}compositionstart(){this._isComposing=!0,this._compositionPosition.start=this._textarea.value.length,this._compositionView.textContent="",this._dataAlreadySent="",this._compositionView.classList.add("active")}compositionupdate(t){this._compositionView.textContent=t.data,this.updateCompositionElements(),setTimeout(()=>{this._compositionPosition.end=this._textarea.value.length},0)}compositionend(){this._finalizeComposition(!0)}keydown(t){if(this._isComposing||this._isSendingComposition){if(t.keyCode===20||t.keyCode===229||t.keyCode===16||t.keyCode===17||t.keyCode===18)return!1;this._finalizeComposition(!1)}return t.keyCode===229?(this._handleAnyTextareaChanges(),!1):!0}_finalizeComposition(t){if(this._compositionView.classList.remove("active"),this._isComposing=!1,t){let e={start:this._compositionPosition.start,end:this._compositionPosition.end};this._isSendingComposition=!0,setTimeout(()=>{if(this._isSendingComposition){this._isSendingComposition=!1;let s;e.start+=this._dataAlreadySent.length,this._isComposing?s=this._textarea.value.substring(e.start,this._compositionPosition.start):s=this._textarea.value.substring(e.start),s.length>0&&this._coreService.triggerDataEvent(s,!0)}},0)}else{this._isSendingComposition=!1;let e=this._textarea.value.substring(this._compositionPosition.start,this._compositionPosition.end);this._coreService.triggerDataEvent(e,!0)}}_handleAnyTextareaChanges(){let t=this._textarea.value;setTimeout(()=>{if(!this._isComposing){let e=this._textarea.value,s=e.replace(t,"");this._dataAlreadySent=s,e.length>t.length?this._coreService.triggerDataEvent(s,!0):e.length<t.length?this._coreService.triggerDataEvent(`${_e.DEL}`,!0):e.length===t.length&&e!==t&&this._coreService.triggerDataEvent(e,!0)}},0)}updateCompositionElements(t){if(this._isComposing){if(this._bufferService.buffer.isCursorInViewport){let e=Math.min(this._bufferService.buffer.x,this._bufferService.cols-1),s=this._renderService.dimensions.css.cell.height,n=this._bufferService.buffer.y*this._renderService.dimensions.css.cell.height,i=e*this._renderService.dimensions.css.cell.width;this._compositionView.style.left=i+"px",this._compositionView.style.top=n+"px",this._compositionView.style.height=s+"px",this._compositionView.style.lineHeight=s+"px",this._compositionView.style.fontFamily=this._optionsService.rawOptions.fontFamily,this._compositionView.style.fontSize=this._optionsService.rawOptions.fontSize+"px";let o=this._compositionView.getBoundingClientRect();this._textarea.style.left=i+"px",this._textarea.style.top=n+"px",this._textarea.style.width=Math.max(o.width,1)+"px",this._textarea.style.height=Math.max(o.height,1)+"px",this._textarea.style.lineHeight=o.height+"px"}t||setTimeout(()=>this.updateCompositionElements(!0),0)}}};k0=At([Ie(2,ws),Ie(3,js),Ie(4,Gi),Ie(5,On)],k0);var qt=0,Gt=0,Yt=0,Nt=0,P1={css:"#00000000",rgba:0},It;(t=>{function e(i,o,a,l){return l!==void 0?`#${fi(i)}${fi(o)}${fi(a)}${fi(l)}`:`#${fi(i)}${fi(o)}${fi(a)}`}t.toCss=e;function s(i,o,a,l=255){return(i<<24|o<<16|a<<8|l)>>>0}t.toRgba=s;function n(i,o,a,l){return{css:t.toCss(i,o,a,l),rgba:t.toRgba(i,o,a,l)}}t.toColor=n})(It||={});var yt;(t=>{function e(c,d){if(Nt=(d.rgba&255)/255,Nt===1)return{css:d.css,rgba:d.rgba};let h=d.rgba>>24&255,u=d.rgba>>16&255,f=d.rgba>>8&255,m=c.rgba>>24&255,p=c.rgba>>16&255,g=c.rgba>>8&255;qt=m+Math.round((h-m)*Nt),Gt=p+Math.round((u-p)*Nt),Yt=g+Math.round((f-g)*Nt);let x=It.toCss(qt,Gt,Yt),v=It.toRgba(qt,Gt,Yt);return{css:x,rgba:v}}t.blend=e;function s(c){return(c.rgba&255)===255}t.isOpaque=s;function n(c,d,h){let u=el.ensureContrastRatio(c.rgba,d.rgba,h);if(u)return It.toColor(u>>24&255,u>>16&255,u>>8&255)}t.ensureContrastRatio=n;function i(c){let d=(c.rgba|255)>>>0;return[qt,Gt,Yt]=el.toChannels(d),{css:It.toCss(qt,Gt,Yt),rgba:d}}t.opaque=i;function o(c,d){return Nt=Math.round(d*255),[qt,Gt,Yt]=el.toChannels(c.rgba),{css:It.toCss(qt,Gt,Yt,Nt),rgba:It.toRgba(qt,Gt,Yt,Nt)}}t.opacity=o;function a(c,d){return Nt=c.rgba&255,o(c,Nt*d/255)}t.multiplyOpacity=a;function l(c){return[c.rgba>>24&255,c.rgba>>16&255,c.rgba>>8&255]}t.toColorRGB=l})(yt||={});var Ct;(t=>{let e,s;try{let i=document.createElement("canvas");i.width=1,i.height=1;let o=i.getContext("2d",{willReadFrequently:!0});o&&(e=o,e.globalCompositeOperation="copy",s=e.createLinearGradient(0,0,1,1))}catch{}function n(i){if(i.match(/#[\da-f]{3,8}/i))switch(i.length){case 4:return qt=parseInt(i.slice(1,2).repeat(2),16),Gt=parseInt(i.slice(2,3).repeat(2),16),Yt=parseInt(i.slice(3,4).repeat(2),16),It.toColor(qt,Gt,Yt);case 5:return qt=parseInt(i.slice(1,2).repeat(2),16),Gt=parseInt(i.slice(2,3).repeat(2),16),Yt=parseInt(i.slice(3,4).repeat(2),16),Nt=parseInt(i.slice(4,5).repeat(2),16),It.toColor(qt,Gt,Yt,Nt);case 7:return{css:i,rgba:(parseInt(i.slice(1),16)<<8|255)>>>0};case 9:return{css:i,rgba:parseInt(i.slice(1),16)>>>0}}let o=i.match(/rgba?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*(,\s*(0|1|\d?\.(\d+))\s*)?\)/);if(o)return qt=parseInt(o[1]),Gt=parseInt(o[2]),Yt=parseInt(o[3]),Nt=Math.round((o[5]===void 0?1:parseFloat(o[5]))*255),It.toColor(qt,Gt,Yt,Nt);if(!e||!s)throw new Error("css.toColor: Unsupported css format");if(e.fillStyle=s,e.fillStyle=i,typeof e.fillStyle!="string")throw new Error("css.toColor: Unsupported css format");if(e.fillRect(0,0,1,1),[qt,Gt,Yt,Nt]=e.getImageData(0,0,1,1).data,Nt!==255)throw new Error("css.toColor: Unsupported css format");return{rgba:It.toRgba(qt,Gt,Yt,Nt),css:i}}t.toColor=n})(Ct||={});var vs;(t=>{function e(n){return s(n>>16&255,n>>8&255,n&255)}t.relativeLuminance=e;function s(n,i,o){let a=n/255,l=i/255,c=o/255,d=a<=.03928?a/12.92:Math.pow((a+.055)/1.055,2.4),h=l<=.03928?l/12.92:Math.pow((l+.055)/1.055,2.4),u=c<=.03928?c/12.92:Math.pow((c+.055)/1.055,2.4);return d*.2126+h*.7152+u*.0722}t.relativeLuminance2=s})(vs||={});var el;(t=>{function e(a,l){if(Nt=(l&255)/255,Nt===1)return l;let c=l>>24&255,d=l>>16&255,h=l>>8&255,u=a>>24&255,f=a>>16&255,m=a>>8&255;return qt=u+Math.round((c-u)*Nt),Gt=f+Math.round((d-f)*Nt),Yt=m+Math.round((h-m)*Nt),It.toRgba(qt,Gt,Yt)}t.blend=e;function s(a,l,c){let d=vs.relativeLuminance(a>>8),h=vs.relativeLuminance(l>>8);if(Cn(d,h)<c){if(h<d){let m=n(a,l,c),p=Cn(d,vs.relativeLuminance(m>>8));if(p<c){let g=i(a,l,c),x=Cn(d,vs.relativeLuminance(g>>8));return p>x?m:g}return m}let u=i(a,l,c),f=Cn(d,vs.relativeLuminance(u>>8));if(f<c){let m=n(a,l,c),p=Cn(d,vs.relativeLuminance(m>>8));return f>p?u:m}return u}}t.ensureContrastRatio=s;function n(a,l,c){let d=a>>24&255,h=a>>16&255,u=a>>8&255,f=l>>24&255,m=l>>16&255,p=l>>8&255,g=Cn(vs.relativeLuminance2(f,m,p),vs.relativeLuminance2(d,h,u));for(;g<c&&(f>0||m>0||p>0);)f-=Math.max(0,Math.ceil(f*.1)),m-=Math.max(0,Math.ceil(m*.1)),p-=Math.max(0,Math.ceil(p*.1)),g=Cn(vs.relativeLuminance2(f,m,p),vs.relativeLuminance2(d,h,u));return(f<<24|m<<16|p<<8|255)>>>0}t.reduceLuminance=n;function i(a,l,c){let d=a>>24&255,h=a>>16&255,u=a>>8&255,f=l>>24&255,m=l>>16&255,p=l>>8&255,g=Cn(vs.relativeLuminance2(f,m,p),vs.relativeLuminance2(d,h,u));for(;g<c&&(f<255||m<255||p<255);)f=Math.min(255,f+Math.ceil((255-f)*.1)),m=Math.min(255,m+Math.ceil((255-m)*.1)),p=Math.min(255,p+Math.ceil((255-p)*.1)),g=Cn(vs.relativeLuminance2(f,m,p),vs.relativeLuminance2(d,h,u));return(f<<24|m<<16|p<<8|255)>>>0}t.increaseLuminance=i;function o(a){return[a>>24&255,a>>16&255,a>>8&255,a&255]}t.toChannels=o})(el||={});function fi(t){let e=t.toString(16);return e.length<2?"0"+e:e}function Cn(t,e){return t<e?(e+.05)/(t+.05):(t+.05)/(e+.05)}var qB=class extends pa{constructor(t,e,s){super(),this.content=0,this.combinedData="",this.fg=t.fg,this.bg=t.bg,this.combinedData=e,this._width=s}isCombined(){return 2097152}getWidth(){return this._width}getChars(){return this.combinedData}getCode(){return 2097151}setFromCharData(t){throw new Error("not implemented")}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}},Fl=class{constructor(t){this._bufferService=t,this._characterJoiners=[],this._nextCharacterJoinerId=0,this._workCell=new Gs}register(t){let e={id:this._nextCharacterJoinerId++,handler:t};return this._characterJoiners.push(e),e.id}deregister(t){for(let e=0;e<this._characterJoiners.length;e++)if(this._characterJoiners[e].id===t)return this._characterJoiners.splice(e,1),!0;return!1}getJoinedCharacters(t){if(this._characterJoiners.length===0)return[];let e=this._bufferService.buffer.lines.get(t);if(!e||e.length===0)return[];let s=[],n=e.translateToString(!0),i=0,o=0,a=0,l=e.getFg(0),c=e.getBg(0);for(let d=0;d<e.getTrimmedLength();d++)if(e.loadCell(d,this._workCell),this._workCell.getWidth()!==0){if(this._workCell.fg!==l||this._workCell.bg!==c){if(d-i>1){let h=this._getJoinedRanges(n,a,o,e,i);for(let u=0;u<h.length;u++)s.push(h[u])}i=d,a=o,l=this._workCell.fg,c=this._workCell.bg}o+=this._workCell.getChars().length||qn.length}if(this._bufferService.cols-i>1){let d=this._getJoinedRanges(n,a,o,e,i);for(let h=0;h<d.length;h++)s.push(d[h])}return s}_getJoinedRanges(t,e,s,n,i){let o=t.substring(e,s),a=[];try{a=this._characterJoiners[0].handler(o)}catch(l){console.error(l)}for(let l=1;l<this._characterJoiners.length;l++)try{let c=this._characterJoiners[l].handler(o);for(let d=0;d<c.length;d++)Fl._mergeRanges(a,c[d])}catch(c){console.error(c)}return this._stringRangesToCellRanges(a,n,i),a}_stringRangesToCellRanges(t,e,s){let n=0,i=!1,o=0,a=t[n];if(a){for(let l=s;l<this._bufferService.cols;l++){let c=e.getWidth(l),d=e.getString(l).length||qn.length;if(c!==0){if(!i&&a[0]<=o&&(a[0]=l,i=!0),a[1]<=o){if(a[1]=l,a=t[++n],!a)break;a[0]<=o?(a[0]=l,i=!0):i=!1}o+=d}}a&&(a[1]=this._bufferService.cols)}}static _mergeRanges(t,e){let s=!1;for(let n=0;n<t.length;n++){let i=t[n];if(s){if(e[1]<=i[0])return t[n-1][1]=e[1],t;if(e[1]<=i[1])return t[n-1][1]=Math.max(e[1],i[1]),t.splice(n,1),t;t.splice(n,1),n--}else{if(e[1]<=i[0])return t.splice(n,0,e),t;if(e[1]<=i[1])return i[0]=Math.min(e[0],i[0]),t;e[0]<i[1]&&(i[0]=Math.min(e[0],i[0]),s=!0);continue}}return s?t[t.length-1][1]=e[1]:t.push(e),t}};Fl=At([Ie(0,ws)],Fl);function GB(t){return 57508<=t&&t<=57558}function YB(t){return 9472<=t&&t<=9631}function JB(t){return GB(t)||YB(t)}function XB(){return{css:{canvas:Ba(),cell:Ba()},device:{canvas:Ba(),cell:Ba(),char:{width:0,height:0,left:0,top:0}}}}function Ba(){return{width:0,height:0}}var V0=class{constructor(t,e,s,n,i,o,a){this._document=t,this._characterJoinerService=e,this._optionsService=s,this._coreBrowserService=n,this._coreService=i,this._decorationService=o,this._themeService=a,this._workCell=new Gs,this._columnSelectMode=!1,this.defaultSpacing=0}handleSelectionChanged(t,e,s){this._selectionStart=t,this._selectionEnd=e,this._columnSelectMode=s}createRow(t,e,s,n,i,o,a,l,c,d,h){let u=[],f=this._characterJoinerService.getJoinedCharacters(e),m=this._themeService.colors,p=t.getNoBgTrimmedLength();s&&p<o+1&&(p=o+1);let g,x=0,v="",b=0,_=0,y=0,L=0,w=!1,j=0,S=!1,C=0,N=0,V=[],E=d!==-1&&h!==-1;for(let T=0;T<p;T++){t.loadCell(T,this._workCell);let k=this._workCell.getWidth();if(k===0)continue;let R=!1,P=T>=N,D=T,I=this._workCell;if(f.length>0&&T===f[0][0]&&P){let Y=f.shift(),ee=this._isCellInSelection(Y[0],e);for(b=Y[0]+1;b<Y[1];b++)P&&=ee===this._isCellInSelection(b,e);P&&=!s||o<Y[0]||o>=Y[1],P?(R=!0,I=new qB(this._workCell,t.translateToString(!0,Y[0],Y[1]),Y[1]-Y[0]),D=Y[1]-1,k=I.getWidth()):N=Y[1]}let M=this._isCellInSelection(T,e),O=s&&T===o,F=E&&T>=d&&T<=h,$=!1;this._decorationService.forEachDecorationAtCell(T,e,void 0,Y=>{$=!0});let z=I.getChars()||qn;if(z===" "&&(I.isUnderline()||I.isOverline())&&(z=" "),C=k*l-c.get(z,I.isBold(),I.isItalic()),!g)g=this._document.createElement("span");else if(x&&(M&&S||!M&&!S&&I.bg===_)&&(M&&S&&m.selectionForeground||I.fg===y)&&I.extended.ext===L&&F===w&&C===j&&!O&&!R&&!$&&P){I.isInvisible()?v+=qn:v+=z,x++;continue}else x&&(g.textContent=v),g=this._document.createElement("span"),x=0,v="";if(_=I.bg,y=I.fg,L=I.extended.ext,w=F,j=C,S=M,R&&o>=T&&o<=D&&(o=T),!this._coreService.isCursorHidden&&O&&this._coreService.isCursorInitialized){if(V.push("xterm-cursor"),this._coreBrowserService.isFocused)a&&V.push("xterm-cursor-blink"),V.push(n==="bar"?"xterm-cursor-bar":n==="underline"?"xterm-cursor-underline":"xterm-cursor-block");else if(i)switch(i){case"outline":V.push("xterm-cursor-outline");break;case"block":V.push("xterm-cursor-block");break;case"bar":V.push("xterm-cursor-bar");break;case"underline":V.push("xterm-cursor-underline");break}}if(I.isBold()&&V.push("xterm-bold"),I.isItalic()&&V.push("xterm-italic"),I.isDim()&&V.push("xterm-dim"),I.isInvisible()?v=qn:v=I.getChars()||qn,I.isUnderline()&&(V.push(`xterm-underline-${I.extended.underlineStyle}`),v===" "&&(v=" "),!I.isUnderlineColorDefault()))if(I.isUnderlineColorRGB())g.style.textDecorationColor=`rgb(${pa.toColorRGB(I.getUnderlineColor()).join(",")})`;else{let Y=I.getUnderlineColor();this._optionsService.rawOptions.drawBoldTextInBrightColors&&I.isBold()&&Y<8&&(Y+=8),g.style.textDecorationColor=m.ansi[Y].css}I.isOverline()&&(V.push("xterm-overline"),v===" "&&(v=" ")),I.isStrikethrough()&&V.push("xterm-strikethrough"),F&&(g.style.textDecoration="underline");let K=I.getFgColor(),X=I.getFgColorMode(),J=I.getBgColor(),H=I.getBgColorMode(),W=!!I.isInverse();if(W){let Y=K;K=J,J=Y;let ee=X;X=H,H=ee}let U,Q,q=!1;this._decorationService.forEachDecorationAtCell(T,e,void 0,Y=>{Y.options.layer!=="top"&&q||(Y.backgroundColorRGB&&(H=50331648,J=Y.backgroundColorRGB.rgba>>8&16777215,U=Y.backgroundColorRGB),Y.foregroundColorRGB&&(X=50331648,K=Y.foregroundColorRGB.rgba>>8&16777215,Q=Y.foregroundColorRGB),q=Y.options.layer==="top")}),!q&&M&&(U=this._coreBrowserService.isFocused?m.selectionBackgroundOpaque:m.selectionInactiveBackgroundOpaque,J=U.rgba>>8&16777215,H=50331648,q=!0,m.selectionForeground&&(X=50331648,K=m.selectionForeground.rgba>>8&16777215,Q=m.selectionForeground)),q&&V.push("xterm-decoration-top");let Z;switch(H){case 16777216:case 33554432:Z=m.ansi[J],V.push(`xterm-bg-${J}`);break;case 50331648:Z=It.toColor(J>>16,J>>8&255,J&255),this._addStyle(g,`background-color:#${R1((J>>>0).toString(16),"0",6)}`);break;default:W?(Z=m.foreground,V.push("xterm-bg-257")):Z=m.background}switch(U||I.isDim()&&(U=yt.multiplyOpacity(Z,.5)),X){case 16777216:case 33554432:I.isBold()&&K<8&&this._optionsService.rawOptions.drawBoldTextInBrightColors&&(K+=8),this._applyMinimumContrast(g,Z,m.ansi[K],I,U,void 0)||V.push(`xterm-fg-${K}`);break;case 50331648:let Y=It.toColor(K>>16&255,K>>8&255,K&255);this._applyMinimumContrast(g,Z,Y,I,U,Q)||this._addStyle(g,`color:#${R1(K.toString(16),"0",6)}`);break;default:this._applyMinimumContrast(g,Z,m.foreground,I,U,Q)||W&&V.push("xterm-fg-257")}V.length&&(g.className=V.join(" "),V.length=0),!O&&!R&&!$&&P?x++:g.textContent=v,C!==this.defaultSpacing&&(g.style.letterSpacing=`${C}px`),u.push(g),T=D}return g&&x&&(g.textContent=v),u}_applyMinimumContrast(t,e,s,n,i,o){if(this._optionsService.rawOptions.minimumContrastRatio===1||JB(n.getCode()))return!1;let a=this._getContrastCache(n),l;if(!i&&!o&&(l=a.getColor(e.rgba,s.rgba)),l===void 0){let c=this._optionsService.rawOptions.minimumContrastRatio/(n.isDim()?2:1);l=yt.ensureContrastRatio(i||e,o||s,c),a.setColor((i||e).rgba,(o||s).rgba,l??null)}return l?(this._addStyle(t,`color:${l.css}`),!0):!1}_getContrastCache(t){return t.isDim()?this._themeService.colors.halfContrastCache:this._themeService.colors.contrastCache}_addStyle(t,e){t.setAttribute("style",`${t.getAttribute("style")||""}${e};`)}_isCellInSelection(t,e){let s=this._selectionStart,n=this._selectionEnd;return!s||!n?!1:this._columnSelectMode?s[0]<=n[0]?t>=s[0]&&e>=s[1]&&t<n[0]&&e<=n[1]:t<s[0]&&e>=s[1]&&t>=n[0]&&e<=n[1]:e>s[1]&&e<n[1]||s[1]===n[1]&&e===s[1]&&t>=s[0]&&t<n[0]||s[1]<n[1]&&e===n[1]&&t<n[0]||s[1]<n[1]&&e===s[1]&&t>=s[0]}};V0=At([Ie(1,Z4),Ie(2,js),Ie(3,Mn),Ie(4,Gi),Ie(5,ga),Ie(6,zr)],V0);function R1(t,e,s){for(;t.length<s;)t=e+t;return t}var QB=class{constructor(t,e){this._flat=new Float32Array(256),this._font="",this._fontSize=0,this._weight="normal",this._weightBold="bold",this._measureElements=[],this._container=t.createElement("div"),this._container.classList.add("xterm-width-cache-measure-container"),this._container.setAttribute("aria-hidden","true"),this._container.style.whiteSpace="pre",this._container.style.fontKerning="none";let s=t.createElement("span");s.classList.add("xterm-char-measure-element");let n=t.createElement("span");n.classList.add("xterm-char-measure-element"),n.style.fontWeight="bold";let i=t.createElement("span");i.classList.add("xterm-char-measure-element"),i.style.fontStyle="italic";let o=t.createElement("span");o.classList.add("xterm-char-measure-element"),o.style.fontWeight="bold",o.style.fontStyle="italic",this._measureElements=[s,n,i,o],this._container.appendChild(s),this._container.appendChild(n),this._container.appendChild(i),this._container.appendChild(o),e.appendChild(this._container),this.clear()}dispose(){this._container.remove(),this._measureElements.length=0,this._holey=void 0}clear(){this._flat.fill(-9999),this._holey=new Map}setFont(t,e,s,n){t===this._font&&e===this._fontSize&&s===this._weight&&n===this._weightBold||(this._font=t,this._fontSize=e,this._weight=s,this._weightBold=n,this._container.style.fontFamily=this._font,this._container.style.fontSize=`${this._fontSize}px`,this._measureElements[0].style.fontWeight=`${s}`,this._measureElements[1].style.fontWeight=`${n}`,this._measureElements[2].style.fontWeight=`${s}`,this._measureElements[3].style.fontWeight=`${n}`,this.clear())}get(t,e,s){let n=0;if(!e&&!s&&t.length===1&&(n=t.charCodeAt(0))<256){if(this._flat[n]!==-9999)return this._flat[n];let a=this._measure(t,0);return a>0&&(this._flat[n]=a),a}let i=t;e&&(i+="B"),s&&(i+="I");let o=this._holey.get(i);if(o===void 0){let a=0;e&&(a|=1),s&&(a|=2),o=this._measure(t,a),o>0&&this._holey.set(i,o)}return o}_measure(t,e){let s=this._measureElements[e];return s.textContent=t.repeat(32),s.offsetWidth/32}},ZB=class{constructor(){this.clear()}clear(){this.hasSelection=!1,this.columnSelectMode=!1,this.viewportStartRow=0,this.viewportEndRow=0,this.viewportCappedStartRow=0,this.viewportCappedEndRow=0,this.startCol=0,this.endCol=0,this.selectionStart=void 0,this.selectionEnd=void 0}update(t,e,s,n=!1){if(this.selectionStart=e,this.selectionEnd=s,!e||!s||e[0]===s[0]&&e[1]===s[1]){this.clear();return}let i=t.buffers.active.ydisp,o=e[1]-i,a=s[1]-i,l=Math.max(o,0),c=Math.min(a,t.rows-1);if(l>=t.rows||c<0){this.clear();return}this.hasSelection=!0,this.columnSelectMode=n,this.viewportStartRow=o,this.viewportEndRow=a,this.viewportCappedStartRow=l,this.viewportCappedEndRow=c,this.startCol=e[0],this.endCol=s[0]}isCellSelected(t,e,s){return this.hasSelection?(s-=t.buffer.active.viewportY,this.columnSelectMode?this.startCol<=this.endCol?e>=this.startCol&&s>=this.viewportCappedStartRow&&e<this.endCol&&s<=this.viewportCappedEndRow:e<this.startCol&&s>=this.viewportCappedStartRow&&e>=this.endCol&&s<=this.viewportCappedEndRow:s>this.viewportStartRow&&s<this.viewportEndRow||this.viewportStartRow===this.viewportEndRow&&s===this.viewportStartRow&&e>=this.startCol&&e<this.endCol||this.viewportStartRow<this.viewportEndRow&&s===this.viewportEndRow&&e<this.endCol||this.viewportStartRow<this.viewportEndRow&&s===this.viewportStartRow&&e>=this.startCol):!1}};function eF(){return new ZB}var Ld="xterm-dom-renderer-owner-",Ks="xterm-rows",Fa="xterm-fg-",D1="xterm-bg-",Zr="xterm-focus",za="xterm-selection",tF=1,N0=class extends tt{constructor(t,e,s,n,i,o,a,l,c,d,h,u,f,m){super(),this._terminal=t,this._document=e,this._element=s,this._screenElement=n,this._viewportElement=i,this._helperContainer=o,this._linkifier2=a,this._charSizeService=c,this._optionsService=d,this._bufferService=h,this._coreService=u,this._coreBrowserService=f,this._themeService=m,this._terminalClass=tF++,this._rowElements=[],this._selectionRenderModel=eF(),this.onRequestRedraw=this._register(new Te).event,this._rowContainer=this._document.createElement("div"),this._rowContainer.classList.add(Ks),this._rowContainer.style.lineHeight="normal",this._rowContainer.setAttribute("aria-hidden","true"),this._refreshRowElements(this._bufferService.cols,this._bufferService.rows),this._selectionContainer=this._document.createElement("div"),this._selectionContainer.classList.add(za),this._selectionContainer.setAttribute("aria-hidden","true"),this.dimensions=XB(),this._updateDimensions(),this._register(this._optionsService.onOptionChange(()=>this._handleOptionsChanged())),this._register(this._themeService.onChangeColors(p=>this._injectCss(p))),this._injectCss(this._themeService.colors),this._rowFactory=l.createInstance(V0,document),this._element.classList.add(Ld+this._terminalClass),this._screenElement.appendChild(this._rowContainer),this._screenElement.appendChild(this._selectionContainer),this._register(this._linkifier2.onShowLinkUnderline(p=>this._handleLinkHover(p))),this._register(this._linkifier2.onHideLinkUnderline(p=>this._handleLinkLeave(p))),this._register(Lt(()=>{this._element.classList.remove(Ld+this._terminalClass),this._rowContainer.remove(),this._selectionContainer.remove(),this._widthCache.dispose(),this._themeStyleElement.remove(),this._dimensionsStyleElement.remove()})),this._widthCache=new QB(this._document,this._helperContainer),this._widthCache.setFont(this._optionsService.rawOptions.fontFamily,this._optionsService.rawOptions.fontSize,this._optionsService.rawOptions.fontWeight,this._optionsService.rawOptions.fontWeightBold),this._setDefaultSpacing()}_updateDimensions(){let t=this._coreBrowserService.dpr;this.dimensions.device.char.width=this._charSizeService.width*t,this.dimensions.device.char.height=Math.ceil(this._charSizeService.height*t),this.dimensions.device.cell.width=this.dimensions.device.char.width+Math.round(this._optionsService.rawOptions.letterSpacing),this.dimensions.device.cell.height=Math.floor(this.dimensions.device.char.height*this._optionsService.rawOptions.lineHeight),this.dimensions.device.char.left=0,this.dimensions.device.char.top=0,this.dimensions.device.canvas.width=this.dimensions.device.cell.width*this._bufferService.cols,this.dimensions.device.canvas.height=this.dimensions.device.cell.height*this._bufferService.rows,this.dimensions.css.canvas.width=Math.round(this.dimensions.device.canvas.width/t),this.dimensions.css.canvas.height=Math.round(this.dimensions.device.canvas.height/t),this.dimensions.css.cell.width=this.dimensions.css.canvas.width/this._bufferService.cols,this.dimensions.css.cell.height=this.dimensions.css.canvas.height/this._bufferService.rows;for(let s of this._rowElements)s.style.width=`${this.dimensions.css.canvas.width}px`,s.style.height=`${this.dimensions.css.cell.height}px`,s.style.lineHeight=`${this.dimensions.css.cell.height}px`,s.style.overflow="hidden";this._dimensionsStyleElement||(this._dimensionsStyleElement=this._document.createElement("style"),this._screenElement.appendChild(this._dimensionsStyleElement));let e=`${this._terminalSelector} .${Ks} span { display: inline-block; height: 100%; vertical-align: top;}`;this._dimensionsStyleElement.textContent=e,this._selectionContainer.style.height=this._viewportElement.style.height,this._screenElement.style.width=`${this.dimensions.css.canvas.width}px`,this._screenElement.style.height=`${this.dimensions.css.canvas.height}px`}_injectCss(t){this._themeStyleElement||(this._themeStyleElement=this._document.createElement("style"),this._screenElement.appendChild(this._themeStyleElement));let e=`${this._terminalSelector} .${Ks} { pointer-events: none; color: ${t.foreground.css}; font-family: ${this._optionsService.rawOptions.fontFamily}; font-size: ${this._optionsService.rawOptions.fontSize}px; font-kerning: none; white-space: pre}`;e+=`${this._terminalSelector} .${Ks} .xterm-dim { color: ${yt.multiplyOpacity(t.foreground,.5).css};}`,e+=`${this._terminalSelector} span:not(.xterm-bold) { font-weight: ${this._optionsService.rawOptions.fontWeight};}${this._terminalSelector} span.xterm-bold { font-weight: ${this._optionsService.rawOptions.fontWeightBold};}${this._terminalSelector} span.xterm-italic { font-style: italic;}`;let s=`blink_underline_${this._terminalClass}`,n=`blink_bar_${this._terminalClass}`,i=`blink_block_${this._terminalClass}`;e+=`@keyframes ${s} { 50% { border-bottom-style: hidden; }}`,e+=`@keyframes ${n} { 50% { box-shadow: none; }}`,e+=`@keyframes ${i} { 0% { background-color: ${t.cursor.css}; color: ${t.cursorAccent.css}; } 50% { background-color: inherit; color: ${t.cursor.css}; }}`,e+=`${this._terminalSelector} .${Ks}.${Zr} .xterm-cursor.xterm-cursor-blink.xterm-cursor-underline { animation: ${s} 1s step-end infinite;}${this._terminalSelector} .${Ks}.${Zr} .xterm-cursor.xterm-cursor-blink.xterm-cursor-bar { animation: ${n} 1s step-end infinite;}${this._terminalSelector} .${Ks}.${Zr} .xterm-cursor.xterm-cursor-blink.xterm-cursor-block { animation: ${i} 1s step-end infinite;}${this._terminalSelector} .${Ks} .xterm-cursor.xterm-cursor-block { background-color: ${t.cursor.css}; color: ${t.cursorAccent.css};}${this._terminalSelector} .${Ks} .xterm-cursor.xterm-cursor-block:not(.xterm-cursor-blink) { background-color: ${t.cursor.css} !important; color: ${t.cursorAccent.css} !important;}${this._terminalSelector} .${Ks} .xterm-cursor.xterm-cursor-outline { outline: 1px solid ${t.cursor.css}; outline-offset: -1px;}${this._terminalSelector} .${Ks} .xterm-cursor.xterm-cursor-bar { box-shadow: ${this._optionsService.rawOptions.cursorWidth}px 0 0 ${t.cursor.css} inset;}${this._terminalSelector} .${Ks} .xterm-cursor.xterm-cursor-underline { border-bottom: 1px ${t.cursor.css}; border-bottom-style: solid; height: calc(100% - 1px);}`,e+=`${this._terminalSelector} .${za} { position: absolute; top: 0; left: 0; z-index: 1; pointer-events: none;}${this._terminalSelector}.focus .${za} div { position: absolute; background-color: ${t.selectionBackgroundOpaque.css};}${this._terminalSelector} .${za} div { position: absolute; background-color: ${t.selectionInactiveBackgroundOpaque.css};}`;for(let[o,a]of t.ansi.entries())e+=`${this._terminalSelector} .${Fa}${o} { color: ${a.css}; }${this._terminalSelector} .${Fa}${o}.xterm-dim { color: ${yt.multiplyOpacity(a,.5).css}; }${this._terminalSelector} .${D1}${o} { background-color: ${a.css}; }`;e+=`${this._terminalSelector} .${Fa}257 { color: ${yt.opaque(t.background).css}; }${this._terminalSelector} .${Fa}257.xterm-dim { color: ${yt.multiplyOpacity(yt.opaque(t.background),.5).css}; }${this._terminalSelector} .${D1}257 { background-color: ${t.foreground.css}; }`,this._themeStyleElement.textContent=e}_setDefaultSpacing(){let t=this.dimensions.css.cell.width-this._widthCache.get("W",!1,!1);this._rowContainer.style.letterSpacing=`${t}px`,this._rowFactory.defaultSpacing=t}handleDevicePixelRatioChange(){this._updateDimensions(),this._widthCache.clear(),this._setDefaultSpacing()}_refreshRowElements(t,e){for(let s=this._rowElements.length;s<=e;s++){let n=this._document.createElement("div");this._rowContainer.appendChild(n),this._rowElements.push(n)}for(;this._rowElements.length>e;)this._rowContainer.removeChild(this._rowElements.pop())}handleResize(t,e){this._refreshRowElements(t,e),this._updateDimensions(),this.handleSelectionChanged(this._selectionRenderModel.selectionStart,this._selectionRenderModel.selectionEnd,this._selectionRenderModel.columnSelectMode)}handleCharSizeChanged(){this._updateDimensions(),this._widthCache.clear(),this._setDefaultSpacing()}handleBlur(){this._rowContainer.classList.remove(Zr),this.renderRows(0,this._bufferService.rows-1)}handleFocus(){this._rowContainer.classList.add(Zr),this.renderRows(this._bufferService.buffer.y,this._bufferService.buffer.y)}handleSelectionChanged(t,e,s){if(this._selectionContainer.replaceChildren(),this._rowFactory.handleSelectionChanged(t,e,s),this.renderRows(0,this._bufferService.rows-1),!t||!e||(this._selectionRenderModel.update(this._terminal,t,e,s),!this._selectionRenderModel.hasSelection))return;let n=this._selectionRenderModel.viewportStartRow,i=this._selectionRenderModel.viewportEndRow,o=this._selectionRenderModel.viewportCappedStartRow,a=this._selectionRenderModel.viewportCappedEndRow,l=this._document.createDocumentFragment();if(s){let c=t[0]>e[0];l.appendChild(this._createSelectionElement(o,c?e[0]:t[0],c?t[0]:e[0],a-o+1))}else{let c=n===o?t[0]:0,d=o===i?e[0]:this._bufferService.cols;l.appendChild(this._createSelectionElement(o,c,d));let h=a-o-1;if(l.appendChild(this._createSelectionElement(o+1,0,this._bufferService.cols,h)),o!==a){let u=i===a?e[0]:this._bufferService.cols;l.appendChild(this._createSelectionElement(a,0,u))}}this._selectionContainer.appendChild(l)}_createSelectionElement(t,e,s,n=1){let i=this._document.createElement("div"),o=e*this.dimensions.css.cell.width,a=this.dimensions.css.cell.width*(s-e);return o+a>this.dimensions.css.canvas.width&&(a=this.dimensions.css.canvas.width-o),i.style.height=`${n*this.dimensions.css.cell.height}px`,i.style.top=`${t*this.dimensions.css.cell.height}px`,i.style.left=`${o}px`,i.style.width=`${a}px`,i}handleCursorMove(){}_handleOptionsChanged(){this._updateDimensions(),this._injectCss(this._themeService.colors),this._widthCache.setFont(this._optionsService.rawOptions.fontFamily,this._optionsService.rawOptions.fontSize,this._optionsService.rawOptions.fontWeight,this._optionsService.rawOptions.fontWeightBold),this._setDefaultSpacing()}clear(){for(let t of this._rowElements)t.replaceChildren()}renderRows(t,e){let s=this._bufferService.buffer,n=s.ybase+s.y,i=Math.min(s.x,this._bufferService.cols-1),o=this._coreService.decPrivateModes.cursorBlink??this._optionsService.rawOptions.cursorBlink,a=this._coreService.decPrivateModes.cursorStyle??this._optionsService.rawOptions.cursorStyle,l=this._optionsService.rawOptions.cursorInactiveStyle;for(let c=t;c<=e;c++){let d=c+s.ydisp,h=this._rowElements[c],u=s.lines.get(d);if(!h||!u)break;h.replaceChildren(...this._rowFactory.createRow(u,d,d===n,a,l,i,o,this.dimensions.css.cell.width,this._widthCache,-1,-1))}}get _terminalSelector(){return`.${Ld}${this._terminalClass}`}_handleLinkHover(t){this._setCellUnderline(t.x1,t.x2,t.y1,t.y2,t.cols,!0)}_handleLinkLeave(t){this._setCellUnderline(t.x1,t.x2,t.y1,t.y2,t.cols,!1)}_setCellUnderline(t,e,s,n,i,o){s<0&&(t=0),n<0&&(e=0);let a=this._bufferService.rows-1;s=Math.max(Math.min(s,a),0),n=Math.max(Math.min(n,a),0),i=Math.min(i,this._bufferService.cols);let l=this._bufferService.buffer,c=l.ybase+l.y,d=Math.min(l.x,i-1),h=this._optionsService.rawOptions.cursorBlink,u=this._optionsService.rawOptions.cursorStyle,f=this._optionsService.rawOptions.cursorInactiveStyle;for(let m=s;m<=n;++m){let p=m+l.ydisp,g=this._rowElements[m],x=l.lines.get(p);if(!g||!x)break;g.replaceChildren(...this._rowFactory.createRow(x,p,p===c,u,f,d,h,this.dimensions.css.cell.width,this._widthCache,o?m===s?t:0:-1,o?(m===n?e:i)-1:-1))}}};N0=At([Ie(7,Au),Ie(8,Ac),Ie(9,js),Ie(10,ws),Ie(11,Gi),Ie(12,Mn),Ie(13,zr)],N0);var T0=class extends tt{constructor(t,e,s){super(),this._optionsService=s,this.width=0,this.height=0,this._onCharSizeChange=this._register(new Te),this.onCharSizeChange=this._onCharSizeChange.event;try{this._measureStrategy=this._register(new nF(this._optionsService))}catch{this._measureStrategy=this._register(new sF(t,e,this._optionsService))}this._register(this._optionsService.onMultipleOptionChange(["fontFamily","fontSize"],()=>this.measure()))}get hasValidSize(){return this.width>0&&this.height>0}measure(){let t=this._measureStrategy.measure();(t.width!==this.width||t.height!==this.height)&&(this.width=t.width,this.height=t.height,this._onCharSizeChange.fire())}};T0=At([Ie(2,js)],T0);var v5=class extends tt{constructor(){super(...arguments),this._result={width:0,height:0}}_validateAndSet(t,e){t!==void 0&&t>0&&e!==void 0&&e>0&&(this._result.width=t,this._result.height=e)}},sF=class extends v5{constructor(t,e,s){super(),this._document=t,this._parentElement=e,this._optionsService=s,this._measureElement=this._document.createElement("span"),this._measureElement.classList.add("xterm-char-measure-element"),this._measureElement.textContent="W".repeat(32),this._measureElement.setAttribute("aria-hidden","true"),this._measureElement.style.whiteSpace="pre",this._measureElement.style.fontKerning="none",this._parentElement.appendChild(this._measureElement)}measure(){return this._measureElement.style.fontFamily=this._optionsService.rawOptions.fontFamily,this._measureElement.style.fontSize=`${this._optionsService.rawOptions.fontSize}px`,this._validateAndSet(Number(this._measureElement.offsetWidth)/32,Number(this._measureElement.offsetHeight)),this._result}},nF=class extends v5{constructor(t){super(),this._optionsService=t,this._canvas=new OffscreenCanvas(100,100),this._ctx=this._canvas.getContext("2d");let e=this._ctx.measureText("W");if(!("width"in e&&"fontBoundingBoxAscent"in e&&"fontBoundingBoxDescent"in e))throw new Error("Required font metrics not supported")}measure(){this._ctx.font=`${this._optionsService.rawOptions.fontSize}px ${this._optionsService.rawOptions.fontFamily}`;let t=this._ctx.measureText("W");return this._validateAndSet(t.width,t.fontBoundingBoxAscent+t.fontBoundingBoxDescent),this._result}},iF=class extends tt{constructor(t,e,s){super(),this._textarea=t,this._window=e,this.mainDocument=s,this._isFocused=!1,this._cachedIsFocused=void 0,this._screenDprMonitor=this._register(new rF(this._window)),this._onDprChange=this._register(new Te),this.onDprChange=this._onDprChange.event,this._onWindowChange=this._register(new Te),this.onWindowChange=this._onWindowChange.event,this._register(this.onWindowChange(n=>this._screenDprMonitor.setWindow(n))),this._register(os.forward(this._screenDprMonitor.onDprChange,this._onDprChange)),this._register(Ge(this._textarea,"focus",()=>this._isFocused=!0)),this._register(Ge(this._textarea,"blur",()=>this._isFocused=!1))}get window(){return this._window}set window(t){this._window!==t&&(this._window=t,this._onWindowChange.fire(this._window))}get dpr(){return this.window.devicePixelRatio}get isFocused(){return this._cachedIsFocused===void 0&&(this._cachedIsFocused=this._isFocused&&this._textarea.ownerDocument.hasFocus(),queueMicrotask(()=>this._cachedIsFocused=void 0)),this._cachedIsFocused}},rF=class extends tt{constructor(t){super(),this._parentWindow=t,this._windowResizeListener=this._register(new Lr),this._onDprChange=this._register(new Te),this.onDprChange=this._onDprChange.event,this._outerListener=()=>this._setDprAndFireIfDiffers(),this._currentDevicePixelRatio=this._parentWindow.devicePixelRatio,this._updateDpr(),this._setWindowResizeListener(),this._register(Lt(()=>this.clearListener()))}setWindow(t){this._parentWindow=t,this._setWindowResizeListener(),this._setDprAndFireIfDiffers()}_setWindowResizeListener(){this._windowResizeListener.value=Ge(this._parentWindow,"resize",()=>this._setDprAndFireIfDiffers())}_setDprAndFireIfDiffers(){this._parentWindow.devicePixelRatio!==this._currentDevicePixelRatio&&this._onDprChange.fire(this._parentWindow.devicePixelRatio),this._updateDpr()}_updateDpr(){this._outerListener&&(this._resolutionMediaMatchList?.removeListener(this._outerListener),this._currentDevicePixelRatio=this._parentWindow.devicePixelRatio,this._resolutionMediaMatchList=this._parentWindow.matchMedia(`screen and (resolution: ${this._parentWindow.devicePixelRatio}dppx)`),this._resolutionMediaMatchList.addListener(this._outerListener))}clearListener(){!this._resolutionMediaMatchList||!this._outerListener||(this._resolutionMediaMatchList.removeListener(this._outerListener),this._resolutionMediaMatchList=void 0,this._outerListener=void 0)}},oF=class extends tt{constructor(){super(),this.linkProviders=[],this._register(Lt(()=>this.linkProviders.length=0))}registerLinkProvider(t){return this.linkProviders.push(t),{dispose:()=>{let e=this.linkProviders.indexOf(t);e!==-1&&this.linkProviders.splice(e,1)}}}};function $u(t,e,s){let n=s.getBoundingClientRect(),i=t.getComputedStyle(s),o=parseInt(i.getPropertyValue("padding-left")),a=parseInt(i.getPropertyValue("padding-top"));return[e.clientX-n.left-o,e.clientY-n.top-a]}function aF(t,e,s,n,i,o,a,l,c){if(!o)return;let d=$u(t,e,s);if(d)return d[0]=Math.ceil((d[0]+(c?a/2:0))/a),d[1]=Math.ceil(d[1]/l),d[0]=Math.min(Math.max(d[0],1),n+(c?1:0)),d[1]=Math.min(Math.max(d[1],1),i),d}var A0=class{constructor(t,e){this._renderService=t,this._charSizeService=e}getCoords(t,e,s,n,i){return aF(window,t,e,s,n,this._charSizeService.hasValidSize,this._renderService.dimensions.css.cell.width,this._renderService.dimensions.css.cell.height,i)}getMouseReportCoords(t,e){let s=$u(window,t,e);if(this._charSizeService.hasValidSize)return s[0]=Math.min(Math.max(s[0],0),this._renderService.dimensions.css.canvas.width-1),s[1]=Math.min(Math.max(s[1],0),this._renderService.dimensions.css.canvas.height-1),{col:Math.floor(s[0]/this._renderService.dimensions.css.cell.width),row:Math.floor(s[1]/this._renderService.dimensions.css.cell.height),x:Math.floor(s[0]),y:Math.floor(s[1])}}};A0=At([Ie(0,On),Ie(1,Ac)],A0);var lF=class{constructor(t,e){this._renderCallback=t,this._coreBrowserService=e,this._refreshCallbacks=[]}dispose(){this._animationFrame&&(this._coreBrowserService.window.cancelAnimationFrame(this._animationFrame),this._animationFrame=void 0)}addRefreshCallback(t){return this._refreshCallbacks.push(t),this._animationFrame||(this._animationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>this._innerRefresh())),this._animationFrame}refresh(t,e,s){this._rowCount=s,t=t!==void 0?t:0,e=e!==void 0?e:this._rowCount-1,this._rowStart=this._rowStart!==void 0?Math.min(this._rowStart,t):t,this._rowEnd=this._rowEnd!==void 0?Math.max(this._rowEnd,e):e,!this._animationFrame&&(this._animationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>this._innerRefresh()))}_innerRefresh(){if(this._animationFrame=void 0,this._rowStart===void 0||this._rowEnd===void 0||this._rowCount===void 0){this._runRefreshCallbacks();return}let t=Math.max(this._rowStart,0),e=Math.min(this._rowEnd,this._rowCount-1);this._rowStart=void 0,this._rowEnd=void 0,this._renderCallback(t,e),this._runRefreshCallbacks()}_runRefreshCallbacks(){for(let t of this._refreshCallbacks)t(0);this._refreshCallbacks=[]}},b5={};v$(b5,{getSafariVersion:()=>dF,isChromeOS:()=>S5,isFirefox:()=>y5,isIpad:()=>uF,isIphone:()=>hF,isLegacyEdge:()=>cF,isLinux:()=>Bu,isMac:()=>zl,isNode:()=>Ec,isSafari:()=>_5,isWindows:()=>L5});var Ec=typeof process<"u"&&"title"in process,xa=Ec?"node":navigator.userAgent,va=Ec?"node":navigator.platform,y5=xa.includes("Firefox"),cF=xa.includes("Edge"),_5=/^((?!chrome|android).)*safari/i.test(xa);function dF(){if(!_5)return 0;let t=xa.match(/Version\/(\d+)/);return t===null||t.length<2?0:parseInt(t[1])}var zl=["Macintosh","MacIntel","MacPPC","Mac68K"].includes(va),uF=va==="iPad",hF=va==="iPhone",L5=["Windows","Win16","Win32","WinCE"].includes(va),Bu=va.indexOf("Linux")>=0,S5=/\bCrOS\b/.test(xa),w5=class{constructor(){this._tasks=[],this._i=0}enqueue(t){this._tasks.push(t),this._start()}flush(){for(;this._i<this._tasks.length;)this._tasks[this._i]()||this._i++;this.clear()}clear(){this._idleCallback&&(this._cancelCallback(this._idleCallback),this._idleCallback=void 0),this._i=0,this._tasks.length=0}_start(){this._idleCallback||(this._idleCallback=this._requestCallback(this._process.bind(this)))}_process(t){this._idleCallback=void 0;let e=0,s=0,n=t.timeRemaining(),i=0;for(;this._i<this._tasks.length;){if(e=performance.now(),this._tasks[this._i]()||this._i++,e=Math.max(1,performance.now()-e),s=Math.max(e,s),i=t.timeRemaining(),s*1.5>i){n-e<-20&&console.warn(`task queue exceeded allotted deadline by ${Math.abs(Math.round(n-e))}ms`),this._start();return}n=i}this.clear()}},fF=class extends w5{_requestCallback(t){return setTimeout(()=>t(this._createDeadline(16)))}_cancelCallback(t){clearTimeout(t)}_createDeadline(t){let e=performance.now()+t;return{timeRemaining:()=>Math.max(0,e-performance.now())}}},mF=class extends w5{_requestCallback(t){return requestIdleCallback(t)}_cancelCallback(t){cancelIdleCallback(t)}},Kl=!Ec&&"requestIdleCallback"in window?mF:fF,pF=class{constructor(){this._queue=new Kl}set(t){this._queue.clear(),this._queue.enqueue(t)}flush(){this._queue.flush()}},E0=class extends tt{constructor(t,e,s,n,i,o,a,l,c){super(),this._rowCount=t,this._optionsService=s,this._charSizeService=n,this._coreService=i,this._coreBrowserService=l,this._renderer=this._register(new Lr),this._pausedResizeTask=new pF,this._observerDisposable=this._register(new Lr),this._isPaused=!1,this._needsFullRefresh=!1,this._isNextRenderRedrawOnly=!0,this._needsSelectionRefresh=!1,this._canvasWidth=0,this._canvasHeight=0,this._selectionState={start:void 0,end:void 0,columnSelectMode:!1},this._onDimensionsChange=this._register(new Te),this.onDimensionsChange=this._onDimensionsChange.event,this._onRenderedViewportChange=this._register(new Te),this.onRenderedViewportChange=this._onRenderedViewportChange.event,this._onRender=this._register(new Te),this.onRender=this._onRender.event,this._onRefreshRequest=this._register(new Te),this.onRefreshRequest=this._onRefreshRequest.event,this._renderDebouncer=new lF((d,h)=>this._renderRows(d,h),this._coreBrowserService),this._register(this._renderDebouncer),this._syncOutputHandler=new gF(this._coreBrowserService,this._coreService,()=>this._fullRefresh()),this._register(Lt(()=>this._syncOutputHandler.dispose())),this._register(this._coreBrowserService.onDprChange(()=>this.handleDevicePixelRatioChange())),this._register(a.onResize(()=>this._fullRefresh())),this._register(a.buffers.onBufferActivate(()=>this._renderer.value?.clear())),this._register(this._optionsService.onOptionChange(()=>this._handleOptionsChanged())),this._register(this._charSizeService.onCharSizeChange(()=>this.handleCharSizeChanged())),this._register(o.onDecorationRegistered(()=>this._fullRefresh())),this._register(o.onDecorationRemoved(()=>this._fullRefresh())),this._register(this._optionsService.onMultipleOptionChange(["customGlyphs","drawBoldTextInBrightColors","letterSpacing","lineHeight","fontFamily","fontSize","fontWeight","fontWeightBold","minimumContrastRatio","rescaleOverlappingGlyphs"],()=>{this.clear(),this.handleResize(a.cols,a.rows),this._fullRefresh()})),this._register(this._optionsService.onMultipleOptionChange(["cursorBlink","cursorStyle"],()=>this.refreshRows(a.buffer.y,a.buffer.y,!0))),this._register(c.onChangeColors(()=>this._fullRefresh())),this._registerIntersectionObserver(this._coreBrowserService.window,e),this._register(this._coreBrowserService.onWindowChange(d=>this._registerIntersectionObserver(d,e)))}get dimensions(){return this._renderer.value.dimensions}_registerIntersectionObserver(t,e){if("IntersectionObserver"in t){let s=new t.IntersectionObserver(n=>this._handleIntersectionChange(n[n.length-1]),{threshold:0});s.observe(e),this._observerDisposable.value=Lt(()=>s.disconnect())}}_handleIntersectionChange(t){this._isPaused=t.isIntersecting===void 0?t.intersectionRatio===0:!t.isIntersecting,!this._isPaused&&!this._charSizeService.hasValidSize&&this._charSizeService.measure(),!this._isPaused&&this._needsFullRefresh&&(this._pausedResizeTask.flush(),this.refreshRows(0,this._rowCount-1),this._needsFullRefresh=!1)}refreshRows(t,e,s=!1){if(this._isPaused){this._needsFullRefresh=!0;return}if(this._coreService.decPrivateModes.synchronizedOutput){this._syncOutputHandler.bufferRows(t,e);return}let n=this._syncOutputHandler.flush();n&&(t=Math.min(t,n.start),e=Math.max(e,n.end)),s||(this._isNextRenderRedrawOnly=!1),this._renderDebouncer.refresh(t,e,this._rowCount)}_renderRows(t,e){if(this._renderer.value){if(this._coreService.decPrivateModes.synchronizedOutput){this._syncOutputHandler.bufferRows(t,e);return}t=Math.min(t,this._rowCount-1),e=Math.min(e,this._rowCount-1),this._renderer.value.renderRows(t,e),this._needsSelectionRefresh&&(this._renderer.value.handleSelectionChanged(this._selectionState.start,this._selectionState.end,this._selectionState.columnSelectMode),this._needsSelectionRefresh=!1),this._isNextRenderRedrawOnly||this._onRenderedViewportChange.fire({start:t,end:e}),this._onRender.fire({start:t,end:e}),this._isNextRenderRedrawOnly=!0}}resize(t,e){this._rowCount=e,this._fireOnCanvasResize()}_handleOptionsChanged(){this._renderer.value&&(this.refreshRows(0,this._rowCount-1),this._fireOnCanvasResize())}_fireOnCanvasResize(){this._renderer.value&&(this._renderer.value.dimensions.css.canvas.width===this._canvasWidth&&this._renderer.value.dimensions.css.canvas.height===this._canvasHeight||this._onDimensionsChange.fire(this._renderer.value.dimensions))}hasRenderer(){return!!this._renderer.value}setRenderer(t){this._renderer.value=t,this._renderer.value&&(this._renderer.value.onRequestRedraw(e=>this.refreshRows(e.start,e.end,!0)),this._needsSelectionRefresh=!0,this._fullRefresh())}addRefreshCallback(t){return this._renderDebouncer.addRefreshCallback(t)}_fullRefresh(){this._isPaused?this._needsFullRefresh=!0:this.refreshRows(0,this._rowCount-1)}clearTextureAtlas(){this._renderer.value&&(this._renderer.value.clearTextureAtlas?.(),this._fullRefresh())}handleDevicePixelRatioChange(){this._charSizeService.measure(),this._renderer.value&&(this._renderer.value.handleDevicePixelRatioChange(),this.refreshRows(0,this._rowCount-1))}handleResize(t,e){this._renderer.value&&(this._isPaused?this._pausedResizeTask.set(()=>this._renderer.value?.handleResize(t,e)):this._renderer.value.handleResize(t,e),this._fullRefresh())}handleCharSizeChanged(){this._renderer.value?.handleCharSizeChanged()}handleBlur(){this._renderer.value?.handleBlur()}handleFocus(){this._renderer.value?.handleFocus()}handleSelectionChanged(t,e,s){this._selectionState.start=t,this._selectionState.end=e,this._selectionState.columnSelectMode=s,this._renderer.value?.handleSelectionChanged(t,e,s)}handleCursorMove(){this._renderer.value?.handleCursorMove()}clear(){this._renderer.value?.clear()}};E0=At([Ie(2,js),Ie(3,Ac),Ie(4,Gi),Ie(5,ga),Ie(6,ws),Ie(7,Mn),Ie(8,zr)],E0);var gF=class{constructor(t,e,s){this._coreBrowserService=t,this._coreService=e,this._onTimeout=s,this._start=0,this._end=0,this._isBuffering=!1}bufferRows(t,e){this._isBuffering?(this._start=Math.min(this._start,t),this._end=Math.max(this._end,e)):(this._start=t,this._end=e,this._isBuffering=!0),this._timeout===void 0&&(this._timeout=this._coreBrowserService.window.setTimeout(()=>{this._timeout=void 0,this._coreService.decPrivateModes.synchronizedOutput=!1,this._onTimeout()},1e3))}flush(){if(this._timeout!==void 0&&(this._coreBrowserService.window.clearTimeout(this._timeout),this._timeout=void 0),!this._isBuffering)return;let t={start:this._start,end:this._end};return this._isBuffering=!1,t}dispose(){this._timeout!==void 0&&(this._coreBrowserService.window.clearTimeout(this._timeout),this._timeout=void 0)}};function xF(t,e,s,n){let i=s.buffer.x,o=s.buffer.y;if(!s.buffer.hasScrollback)return yF(i,o,t,e,s,n)+Pc(o,e,s,n)+_F(i,o,t,e,s,n);let a;if(o===e)return a=i>t?"D":"C",Yo(Math.abs(i-t),Go(a,n));a=o>e?"D":"C";let l=Math.abs(o-e),c=bF(o>e?t:i,s)+(l-1)*s.cols+1+vF(o>e?i:t);return Yo(c,Go(a,n))}function vF(t,e){return t-1}function bF(t,e){return e.cols-t}function yF(t,e,s,n,i,o){return Pc(e,n,i,o).length===0?"":Yo(C5(t,e,t,e-Ri(e,i),!1,i).length,Go("D",o))}function Pc(t,e,s,n){let i=t-Ri(t,s),o=e-Ri(e,s),a=Math.abs(i-o)-LF(t,e,s);return Yo(a,Go(j5(t,e),n))}function _F(t,e,s,n,i,o){let a;Pc(e,n,i,o).length>0?a=n-Ri(n,i):a=e;let l=n,c=SF(t,e,s,n,i,o);return Yo(C5(t,a,s,l,c==="C",i).length,Go(c,o))}function LF(t,e,s){let n=0,i=t-Ri(t,s),o=e-Ri(e,s);for(let a=0;a<Math.abs(i-o);a++){let l=j5(t,e)==="A"?-1:1;s.buffer.lines.get(i+l*a)?.isWrapped&&n++}return n}function Ri(t,e){let s=0,n=e.buffer.lines.get(t),i=n?.isWrapped;for(;i&&t>=0&&t<e.rows;)s++,n=e.buffer.lines.get(--t),i=n?.isWrapped;return s}function SF(t,e,s,n,i,o){let a;return Pc(s,n,i,o).length>0?a=n-Ri(n,i):a=e,t<s&&a<=n||t>=s&&a<n?"C":"D"}function j5(t,e){return t>e?"A":"B"}function C5(t,e,s,n,i,o){let a=t,l=e,c="";for(;(a!==s||l!==n)&&l>=0&&l<o.buffer.lines.length;)a+=i?1:-1,i&&a>o.cols-1?(c+=o.buffer.translateBufferLineToString(l,!1,t,a),a=0,t=0,l++):!i&&a<0&&(c+=o.buffer.translateBufferLineToString(l,!1,0,t+1),a=o.cols-1,t=a,l--);return c+o.buffer.translateBufferLineToString(l,!1,t,a)}function Go(t,e){let s=e?"O":"[";return _e.ESC+s+t}function Yo(t,e){t=Math.floor(t);let s="";for(let n=0;n<t;n++)s+=e;return s}var wF=class{constructor(t){this._bufferService=t,this.isSelectAllActive=!1,this.selectionStartLength=0}clearSelection(){this.selectionStart=void 0,this.selectionEnd=void 0,this.isSelectAllActive=!1,this.selectionStartLength=0}get finalSelectionStart(){return this.isSelectAllActive?[0,0]:!this.selectionEnd||!this.selectionStart?this.selectionStart:this.areSelectionValuesReversed()?this.selectionEnd:this.selectionStart}get finalSelectionEnd(){if(this.isSelectAllActive)return[this._bufferService.cols,this._bufferService.buffer.ybase+this._bufferService.rows-1];if(this.selectionStart){if(!this.selectionEnd||this.areSelectionValuesReversed()){let t=this.selectionStart[0]+this.selectionStartLength;return t>this._bufferService.cols?t%this._bufferService.cols===0?[this._bufferService.cols,this.selectionStart[1]+Math.floor(t/this._bufferService.cols)-1]:[t%this._bufferService.cols,this.selectionStart[1]+Math.floor(t/this._bufferService.cols)]:[t,this.selectionStart[1]]}if(this.selectionStartLength&&this.selectionEnd[1]===this.selectionStart[1]){let t=this.selectionStart[0]+this.selectionStartLength;return t>this._bufferService.cols?[t%this._bufferService.cols,this.selectionStart[1]+Math.floor(t/this._bufferService.cols)]:[Math.max(t,this.selectionEnd[0]),this.selectionEnd[1]]}return this.selectionEnd}}areSelectionValuesReversed(){let t=this.selectionStart,e=this.selectionEnd;return!t||!e?!1:t[1]>e[1]||t[1]===e[1]&&t[0]>e[0]}handleTrim(t){return this.selectionStart&&(this.selectionStart[1]-=t),this.selectionEnd&&(this.selectionEnd[1]-=t),this.selectionEnd&&this.selectionEnd[1]<0?(this.clearSelection(),!0):(this.selectionStart&&this.selectionStart[1]<0&&(this.selectionStart[1]=0),!1)}};function I1(t,e){if(t.start.y>t.end.y)throw new Error(`Buffer range end (${t.end.x}, ${t.end.y}) cannot be before start (${t.start.x}, ${t.start.y})`);return e*(t.end.y-t.start.y)+(t.end.x-t.start.x+1)}var Sd=50,jF=15,CF=50,kF=500,VF=" ",NF=new RegExp(VF,"g"),P0=class extends tt{constructor(t,e,s,n,i,o,a,l,c){super(),this._element=t,this._screenElement=e,this._linkifier=s,this._bufferService=n,this._coreService=i,this._mouseService=o,this._optionsService=a,this._renderService=l,this._coreBrowserService=c,this._dragScrollAmount=0,this._enabled=!0,this._workCell=new Gs,this._mouseDownTimeStamp=0,this._oldHasSelection=!1,this._oldSelectionStart=void 0,this._oldSelectionEnd=void 0,this._onLinuxMouseSelection=this._register(new Te),this.onLinuxMouseSelection=this._onLinuxMouseSelection.event,this._onRedrawRequest=this._register(new Te),this.onRequestRedraw=this._onRedrawRequest.event,this._onSelectionChange=this._register(new Te),this.onSelectionChange=this._onSelectionChange.event,this._onRequestScrollLines=this._register(new Te),this.onRequestScrollLines=this._onRequestScrollLines.event,this._mouseMoveListener=d=>this._handleMouseMove(d),this._mouseUpListener=d=>this._handleMouseUp(d),this._coreService.onUserInput(()=>{this.hasSelection&&this.clearSelection()}),this._trimListener=this._bufferService.buffer.lines.onTrim(d=>this._handleTrim(d)),this._register(this._bufferService.buffers.onBufferActivate(d=>this._handleBufferActivate(d))),this.enable(),this._model=new wF(this._bufferService),this._activeSelectionMode=0,this._register(Lt(()=>{this._removeMouseDownListeners()})),this._register(this._bufferService.onResize(d=>{d.rowsChanged&&this.clearSelection()}))}reset(){this.clearSelection()}disable(){this.clearSelection(),this._enabled=!1}enable(){this._enabled=!0}get selectionStart(){return this._model.finalSelectionStart}get selectionEnd(){return this._model.finalSelectionEnd}get hasSelection(){let t=this._model.finalSelectionStart,e=this._model.finalSelectionEnd;return!t||!e?!1:t[0]!==e[0]||t[1]!==e[1]}get selectionText(){let t=this._model.finalSelectionStart,e=this._model.finalSelectionEnd;if(!t||!e)return"";let s=this._bufferService.buffer,n=[];if(this._activeSelectionMode===3){if(t[0]===e[0])return"";let i=t[0]<e[0]?t[0]:e[0],o=t[0]<e[0]?e[0]:t[0];for(let a=t[1];a<=e[1];a++){let l=s.translateBufferLineToString(a,!0,i,o);n.push(l)}}else{let i=t[1]===e[1]?e[0]:void 0;n.push(s.translateBufferLineToString(t[1],!0,t[0],i));for(let o=t[1]+1;o<=e[1]-1;o++){let a=s.lines.get(o),l=s.translateBufferLineToString(o,!0);a?.isWrapped?n[n.length-1]+=l:n.push(l)}if(t[1]!==e[1]){let o=s.lines.get(e[1]),a=s.translateBufferLineToString(e[1],!0,0,e[0]);o&&o.isWrapped?n[n.length-1]+=a:n.push(a)}}return n.map(i=>i.replace(NF," ")).join(L5?`\r
|
|
511
|
+
`:`
|
|
512
|
+
`)}clearSelection(){this._model.clearSelection(),this._removeMouseDownListeners(),this.refresh(),this._onSelectionChange.fire()}refresh(t){this._refreshAnimationFrame||(this._refreshAnimationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>this._refresh())),Bu&&t&&this.selectionText.length&&this._onLinuxMouseSelection.fire(this.selectionText)}_refresh(){this._refreshAnimationFrame=void 0,this._onRedrawRequest.fire({start:this._model.finalSelectionStart,end:this._model.finalSelectionEnd,columnSelectMode:this._activeSelectionMode===3})}_isClickInSelection(t){let e=this._getMouseBufferCoords(t),s=this._model.finalSelectionStart,n=this._model.finalSelectionEnd;return!s||!n||!e?!1:this._areCoordsInSelection(e,s,n)}isCellInSelection(t,e){let s=this._model.finalSelectionStart,n=this._model.finalSelectionEnd;return!s||!n?!1:this._areCoordsInSelection([t,e],s,n)}_areCoordsInSelection(t,e,s){return t[1]>e[1]&&t[1]<s[1]||e[1]===s[1]&&t[1]===e[1]&&t[0]>=e[0]&&t[0]<s[0]||e[1]<s[1]&&t[1]===s[1]&&t[0]<s[0]||e[1]<s[1]&&t[1]===e[1]&&t[0]>=e[0]}_selectWordAtCursor(t,e){let s=this._linkifier.currentLink?.link?.range;if(s)return this._model.selectionStart=[s.start.x-1,s.start.y-1],this._model.selectionStartLength=I1(s,this._bufferService.cols),this._model.selectionEnd=void 0,!0;let n=this._getMouseBufferCoords(t);return n?(this._selectWordAt(n,e),this._model.selectionEnd=void 0,!0):!1}selectAll(){this._model.isSelectAllActive=!0,this.refresh(),this._onSelectionChange.fire()}selectLines(t,e){this._model.clearSelection(),t=Math.max(t,0),e=Math.min(e,this._bufferService.buffer.lines.length-1),this._model.selectionStart=[0,t],this._model.selectionEnd=[this._bufferService.cols,e],this.refresh(),this._onSelectionChange.fire()}_handleTrim(t){this._model.handleTrim(t)&&this.refresh()}_getMouseBufferCoords(t){let e=this._mouseService.getCoords(t,this._screenElement,this._bufferService.cols,this._bufferService.rows,!0);if(e)return e[0]--,e[1]--,e[1]+=this._bufferService.buffer.ydisp,e}_getMouseEventScrollAmount(t){let e=$u(this._coreBrowserService.window,t,this._screenElement)[1],s=this._renderService.dimensions.css.canvas.height;return e>=0&&e<=s?0:(e>s&&(e-=s),e=Math.min(Math.max(e,-Sd),Sd),e/=Sd,e/Math.abs(e)+Math.round(e*(jF-1)))}shouldForceSelection(t){return zl?t.altKey&&this._optionsService.rawOptions.macOptionClickForcesSelection:t.shiftKey}handleMouseDown(t){if(this._mouseDownTimeStamp=t.timeStamp,!(t.button===2&&this.hasSelection)&&t.button===0){if(!this._enabled){if(!this.shouldForceSelection(t))return;t.stopPropagation()}t.preventDefault(),this._dragScrollAmount=0,this._enabled&&t.shiftKey?this._handleIncrementalClick(t):t.detail===1?this._handleSingleClick(t):t.detail===2?this._handleDoubleClick(t):t.detail===3&&this._handleTripleClick(t),this._addMouseDownListeners(),this.refresh(!0)}}_addMouseDownListeners(){this._screenElement.ownerDocument&&(this._screenElement.ownerDocument.addEventListener("mousemove",this._mouseMoveListener),this._screenElement.ownerDocument.addEventListener("mouseup",this._mouseUpListener)),this._dragScrollIntervalTimer=this._coreBrowserService.window.setInterval(()=>this._dragScroll(),CF)}_removeMouseDownListeners(){this._screenElement.ownerDocument&&(this._screenElement.ownerDocument.removeEventListener("mousemove",this._mouseMoveListener),this._screenElement.ownerDocument.removeEventListener("mouseup",this._mouseUpListener)),this._coreBrowserService.window.clearInterval(this._dragScrollIntervalTimer),this._dragScrollIntervalTimer=void 0}_handleIncrementalClick(t){this._model.selectionStart&&(this._model.selectionEnd=this._getMouseBufferCoords(t))}_handleSingleClick(t){if(this._model.selectionStartLength=0,this._model.isSelectAllActive=!1,this._activeSelectionMode=this.shouldColumnSelect(t)?3:0,this._model.selectionStart=this._getMouseBufferCoords(t),!this._model.selectionStart)return;this._model.selectionEnd=void 0;let e=this._bufferService.buffer.lines.get(this._model.selectionStart[1]);e&&e.length!==this._model.selectionStart[0]&&e.hasWidth(this._model.selectionStart[0])===0&&this._model.selectionStart[0]++}_handleDoubleClick(t){this._selectWordAtCursor(t,!0)&&(this._activeSelectionMode=1)}_handleTripleClick(t){let e=this._getMouseBufferCoords(t);e&&(this._activeSelectionMode=2,this._selectLineAt(e[1]))}shouldColumnSelect(t){return t.altKey&&!(zl&&this._optionsService.rawOptions.macOptionClickForcesSelection)}_handleMouseMove(t){if(t.stopImmediatePropagation(),!this._model.selectionStart)return;let e=this._model.selectionEnd?[this._model.selectionEnd[0],this._model.selectionEnd[1]]:null;if(this._model.selectionEnd=this._getMouseBufferCoords(t),!this._model.selectionEnd){this.refresh(!0);return}this._activeSelectionMode===2?this._model.selectionEnd[1]<this._model.selectionStart[1]?this._model.selectionEnd[0]=0:this._model.selectionEnd[0]=this._bufferService.cols:this._activeSelectionMode===1&&this._selectToWordAt(this._model.selectionEnd),this._dragScrollAmount=this._getMouseEventScrollAmount(t),this._activeSelectionMode!==3&&(this._dragScrollAmount>0?this._model.selectionEnd[0]=this._bufferService.cols:this._dragScrollAmount<0&&(this._model.selectionEnd[0]=0));let s=this._bufferService.buffer;if(this._model.selectionEnd[1]<s.lines.length){let n=s.lines.get(this._model.selectionEnd[1]);n&&n.hasWidth(this._model.selectionEnd[0])===0&&this._model.selectionEnd[0]<this._bufferService.cols&&this._model.selectionEnd[0]++}(!e||e[0]!==this._model.selectionEnd[0]||e[1]!==this._model.selectionEnd[1])&&this.refresh(!0)}_dragScroll(){if(!(!this._model.selectionEnd||!this._model.selectionStart)&&this._dragScrollAmount){this._onRequestScrollLines.fire({amount:this._dragScrollAmount,suppressScrollEvent:!1});let t=this._bufferService.buffer;this._dragScrollAmount>0?(this._activeSelectionMode!==3&&(this._model.selectionEnd[0]=this._bufferService.cols),this._model.selectionEnd[1]=Math.min(t.ydisp+this._bufferService.rows,t.lines.length-1)):(this._activeSelectionMode!==3&&(this._model.selectionEnd[0]=0),this._model.selectionEnd[1]=t.ydisp),this.refresh()}}_handleMouseUp(t){let e=t.timeStamp-this._mouseDownTimeStamp;if(this._removeMouseDownListeners(),this.selectionText.length<=1&&e<kF&&t.altKey&&this._optionsService.rawOptions.altClickMovesCursor){if(this._bufferService.buffer.ybase===this._bufferService.buffer.ydisp){let s=this._mouseService.getCoords(t,this._element,this._bufferService.cols,this._bufferService.rows,!1);if(s&&s[0]!==void 0&&s[1]!==void 0){let n=xF(s[0]-1,s[1]-1,this._bufferService,this._coreService.decPrivateModes.applicationCursorKeys);this._coreService.triggerDataEvent(n,!0)}}}else this._fireEventIfSelectionChanged()}_fireEventIfSelectionChanged(){let t=this._model.finalSelectionStart,e=this._model.finalSelectionEnd,s=!!t&&!!e&&(t[0]!==e[0]||t[1]!==e[1]);if(!s){this._oldHasSelection&&this._fireOnSelectionChange(t,e,s);return}!t||!e||(!this._oldSelectionStart||!this._oldSelectionEnd||t[0]!==this._oldSelectionStart[0]||t[1]!==this._oldSelectionStart[1]||e[0]!==this._oldSelectionEnd[0]||e[1]!==this._oldSelectionEnd[1])&&this._fireOnSelectionChange(t,e,s)}_fireOnSelectionChange(t,e,s){this._oldSelectionStart=t,this._oldSelectionEnd=e,this._oldHasSelection=s,this._onSelectionChange.fire()}_handleBufferActivate(t){this.clearSelection(),this._trimListener.dispose(),this._trimListener=t.activeBuffer.lines.onTrim(e=>this._handleTrim(e))}_convertViewportColToCharacterIndex(t,e){let s=e;for(let n=0;e>=n;n++){let i=t.loadCell(n,this._workCell).getChars().length;this._workCell.getWidth()===0?s--:i>1&&e!==n&&(s+=i-1)}return s}setSelection(t,e,s){this._model.clearSelection(),this._removeMouseDownListeners(),this._model.selectionStart=[t,e],this._model.selectionStartLength=s,this.refresh(),this._fireEventIfSelectionChanged()}rightClickSelect(t){this._isClickInSelection(t)||(this._selectWordAtCursor(t,!1)&&this.refresh(!0),this._fireEventIfSelectionChanged())}_getWordAt(t,e,s=!0,n=!0){if(t[0]>=this._bufferService.cols)return;let i=this._bufferService.buffer,o=i.lines.get(t[1]);if(!o)return;let a=i.translateBufferLineToString(t[1],!1),l=this._convertViewportColToCharacterIndex(o,t[0]),c=l,d=t[0]-l,h=0,u=0,f=0,m=0;if(a.charAt(l)===" "){for(;l>0&&a.charAt(l-1)===" ";)l--;for(;c<a.length&&a.charAt(c+1)===" ";)c++}else{let x=t[0],v=t[0];o.getWidth(x)===0&&(h++,x--),o.getWidth(v)===2&&(u++,v++);let b=o.getString(v).length;for(b>1&&(m+=b-1,c+=b-1);x>0&&l>0&&!this._isCharWordSeparator(o.loadCell(x-1,this._workCell));){o.loadCell(x-1,this._workCell);let _=this._workCell.getChars().length;this._workCell.getWidth()===0?(h++,x--):_>1&&(f+=_-1,l-=_-1),l--,x--}for(;v<o.length&&c+1<a.length&&!this._isCharWordSeparator(o.loadCell(v+1,this._workCell));){o.loadCell(v+1,this._workCell);let _=this._workCell.getChars().length;this._workCell.getWidth()===2?(u++,v++):_>1&&(m+=_-1,c+=_-1),c++,v++}}c++;let p=l+d-h+f,g=Math.min(this._bufferService.cols,c-l+h+u-f-m);if(!(!e&&a.slice(l,c).trim()==="")){if(s&&p===0&&o.getCodePoint(0)!==32){let x=i.lines.get(t[1]-1);if(x&&o.isWrapped&&x.getCodePoint(this._bufferService.cols-1)!==32){let v=this._getWordAt([this._bufferService.cols-1,t[1]-1],!1,!0,!1);if(v){let b=this._bufferService.cols-v.start;p-=b,g+=b}}}if(n&&p+g===this._bufferService.cols&&o.getCodePoint(this._bufferService.cols-1)!==32){let x=i.lines.get(t[1]+1);if(x?.isWrapped&&x.getCodePoint(0)!==32){let v=this._getWordAt([0,t[1]+1],!1,!1,!0);v&&(g+=v.length)}}return{start:p,length:g}}}_selectWordAt(t,e){let s=this._getWordAt(t,e);if(s){for(;s.start<0;)s.start+=this._bufferService.cols,t[1]--;this._model.selectionStart=[s.start,t[1]],this._model.selectionStartLength=s.length}}_selectToWordAt(t){let e=this._getWordAt(t,!0);if(e){let s=t[1];for(;e.start<0;)e.start+=this._bufferService.cols,s--;if(!this._model.areSelectionValuesReversed())for(;e.start+e.length>this._bufferService.cols;)e.length-=this._bufferService.cols,s++;this._model.selectionEnd=[this._model.areSelectionValuesReversed()?e.start:e.start+e.length,s]}}_isCharWordSeparator(t){return t.getWidth()===0?!1:this._optionsService.rawOptions.wordSeparator.indexOf(t.getChars())>=0}_selectLineAt(t){let e=this._bufferService.buffer.getWrappedRangeForLine(t),s={start:{x:0,y:e.first},end:{x:this._bufferService.cols-1,y:e.last}};this._model.selectionStart=[0,e.first],this._model.selectionEnd=void 0,this._model.selectionStartLength=I1(s,this._bufferService.cols)}};P0=At([Ie(3,ws),Ie(4,Gi),Ie(5,Eu),Ie(6,js),Ie(7,On),Ie(8,Mn)],P0);var M1=class{constructor(){this._data={}}set(t,e,s){this._data[t]||(this._data[t]={}),this._data[t][e]=s}get(t,e){return this._data[t]?this._data[t][e]:void 0}clear(){this._data={}}},O1=class{constructor(){this._color=new M1,this._css=new M1}setCss(t,e,s){this._css.set(t,e,s)}getCss(t,e){return this._css.get(t,e)}setColor(t,e,s){this._color.set(t,e,s)}getColor(t,e){return this._color.get(t,e)}clear(){this._color.clear(),this._css.clear()}},Mt=Object.freeze((()=>{let t=[Ct.toColor("#2e3436"),Ct.toColor("#cc0000"),Ct.toColor("#4e9a06"),Ct.toColor("#c4a000"),Ct.toColor("#3465a4"),Ct.toColor("#75507b"),Ct.toColor("#06989a"),Ct.toColor("#d3d7cf"),Ct.toColor("#555753"),Ct.toColor("#ef2929"),Ct.toColor("#8ae234"),Ct.toColor("#fce94f"),Ct.toColor("#729fcf"),Ct.toColor("#ad7fa8"),Ct.toColor("#34e2e2"),Ct.toColor("#eeeeec")],e=[0,95,135,175,215,255];for(let s=0;s<216;s++){let n=e[s/36%6|0],i=e[s/6%6|0],o=e[s%6];t.push({css:It.toCss(n,i,o),rgba:It.toRgba(n,i,o)})}for(let s=0;s<24;s++){let n=8+s*10;t.push({css:It.toCss(n,n,n),rgba:It.toRgba(n,n,n)})}return t})()),mi=Ct.toColor("#ffffff"),mo=Ct.toColor("#000000"),$1=Ct.toColor("#ffffff"),B1=mo,eo={css:"rgba(255, 255, 255, 0.3)",rgba:4294967117},TF=mi,R0=class extends tt{constructor(t){super(),this._optionsService=t,this._contrastCache=new O1,this._halfContrastCache=new O1,this._onChangeColors=this._register(new Te),this.onChangeColors=this._onChangeColors.event,this._colors={foreground:mi,background:mo,cursor:$1,cursorAccent:B1,selectionForeground:void 0,selectionBackgroundTransparent:eo,selectionBackgroundOpaque:yt.blend(mo,eo),selectionInactiveBackgroundTransparent:eo,selectionInactiveBackgroundOpaque:yt.blend(mo,eo),scrollbarSliderBackground:yt.opacity(mi,.2),scrollbarSliderHoverBackground:yt.opacity(mi,.4),scrollbarSliderActiveBackground:yt.opacity(mi,.5),overviewRulerBorder:mi,ansi:Mt.slice(),contrastCache:this._contrastCache,halfContrastCache:this._halfContrastCache},this._updateRestoreColors(),this._setTheme(this._optionsService.rawOptions.theme),this._register(this._optionsService.onSpecificOptionChange("minimumContrastRatio",()=>this._contrastCache.clear())),this._register(this._optionsService.onSpecificOptionChange("theme",()=>this._setTheme(this._optionsService.rawOptions.theme)))}get colors(){return this._colors}_setTheme(t={}){let e=this._colors;if(e.foreground=ut(t.foreground,mi),e.background=ut(t.background,mo),e.cursor=yt.blend(e.background,ut(t.cursor,$1)),e.cursorAccent=yt.blend(e.background,ut(t.cursorAccent,B1)),e.selectionBackgroundTransparent=ut(t.selectionBackground,eo),e.selectionBackgroundOpaque=yt.blend(e.background,e.selectionBackgroundTransparent),e.selectionInactiveBackgroundTransparent=ut(t.selectionInactiveBackground,e.selectionBackgroundTransparent),e.selectionInactiveBackgroundOpaque=yt.blend(e.background,e.selectionInactiveBackgroundTransparent),e.selectionForeground=t.selectionForeground?ut(t.selectionForeground,P1):void 0,e.selectionForeground===P1&&(e.selectionForeground=void 0),yt.isOpaque(e.selectionBackgroundTransparent)&&(e.selectionBackgroundTransparent=yt.opacity(e.selectionBackgroundTransparent,.3)),yt.isOpaque(e.selectionInactiveBackgroundTransparent)&&(e.selectionInactiveBackgroundTransparent=yt.opacity(e.selectionInactiveBackgroundTransparent,.3)),e.scrollbarSliderBackground=ut(t.scrollbarSliderBackground,yt.opacity(e.foreground,.2)),e.scrollbarSliderHoverBackground=ut(t.scrollbarSliderHoverBackground,yt.opacity(e.foreground,.4)),e.scrollbarSliderActiveBackground=ut(t.scrollbarSliderActiveBackground,yt.opacity(e.foreground,.5)),e.overviewRulerBorder=ut(t.overviewRulerBorder,TF),e.ansi=Mt.slice(),e.ansi[0]=ut(t.black,Mt[0]),e.ansi[1]=ut(t.red,Mt[1]),e.ansi[2]=ut(t.green,Mt[2]),e.ansi[3]=ut(t.yellow,Mt[3]),e.ansi[4]=ut(t.blue,Mt[4]),e.ansi[5]=ut(t.magenta,Mt[5]),e.ansi[6]=ut(t.cyan,Mt[6]),e.ansi[7]=ut(t.white,Mt[7]),e.ansi[8]=ut(t.brightBlack,Mt[8]),e.ansi[9]=ut(t.brightRed,Mt[9]),e.ansi[10]=ut(t.brightGreen,Mt[10]),e.ansi[11]=ut(t.brightYellow,Mt[11]),e.ansi[12]=ut(t.brightBlue,Mt[12]),e.ansi[13]=ut(t.brightMagenta,Mt[13]),e.ansi[14]=ut(t.brightCyan,Mt[14]),e.ansi[15]=ut(t.brightWhite,Mt[15]),t.extendedAnsi){let s=Math.min(e.ansi.length-16,t.extendedAnsi.length);for(let n=0;n<s;n++)e.ansi[n+16]=ut(t.extendedAnsi[n],Mt[n+16])}this._contrastCache.clear(),this._halfContrastCache.clear(),this._updateRestoreColors(),this._onChangeColors.fire(this.colors)}restoreColor(t){this._restoreColor(t),this._onChangeColors.fire(this.colors)}_restoreColor(t){if(t===void 0){for(let e=0;e<this._restoreColors.ansi.length;++e)this._colors.ansi[e]=this._restoreColors.ansi[e];return}switch(t){case 256:this._colors.foreground=this._restoreColors.foreground;break;case 257:this._colors.background=this._restoreColors.background;break;case 258:this._colors.cursor=this._restoreColors.cursor;break;default:this._colors.ansi[t]=this._restoreColors.ansi[t]}}modifyColors(t){t(this._colors),this._onChangeColors.fire(this.colors)}_updateRestoreColors(){this._restoreColors={foreground:this._colors.foreground,background:this._colors.background,cursor:this._colors.cursor,ansi:this._colors.ansi.slice()}}};R0=At([Ie(0,js)],R0);function ut(t,e){if(t!==void 0)try{return Ct.toColor(t)}catch{}return e}var AF=class{constructor(...t){this._entries=new Map;for(let[e,s]of t)this.set(e,s)}set(t,e){let s=this._entries.get(t);return this._entries.set(t,e),s}forEach(t){for(let[e,s]of this._entries.entries())t(e,s)}has(t){return this._entries.has(t)}get(t){return this._entries.get(t)}},EF=class{constructor(){this._services=new AF,this._services.set(Au,this)}setService(t,e){this._services.set(t,e)}getService(t){return this._services.get(t)}createInstance(t,...e){let s=j$(t).sort((o,a)=>o.index-a.index),n=[];for(let o of s){let a=this._services.get(o.id);if(!a)throw new Error(`[createInstance] ${t.name} depends on UNKNOWN service ${o.id._id}.`);n.push(a)}let i=s.length>0?s[0].index:e.length;if(e.length!==i)throw new Error(`[createInstance] First service dependency of ${t.name} at position ${i+1} conflicts with ${e.length} static arguments`);return new t(...e,...n)}},PF={trace:0,debug:1,info:2,warn:3,error:4,off:5},RF="xterm.js: ",D0=class extends tt{constructor(t){super(),this._optionsService=t,this._logLevel=5,this._updateLogLevel(),this._register(this._optionsService.onSpecificOptionChange("logLevel",()=>this._updateLogLevel()))}get logLevel(){return this._logLevel}_updateLogLevel(){this._logLevel=PF[this._optionsService.rawOptions.logLevel]}_evalLazyOptionalParams(t){for(let e=0;e<t.length;e++)typeof t[e]=="function"&&(t[e]=t[e]())}_log(t,e,s){this._evalLazyOptionalParams(s),t.call(console,(this._optionsService.options.logger?"":RF)+e,...s)}trace(t,...e){this._logLevel<=0&&this._log(this._optionsService.options.logger?.trace.bind(this._optionsService.options.logger)??console.log,t,e)}debug(t,...e){this._logLevel<=1&&this._log(this._optionsService.options.logger?.debug.bind(this._optionsService.options.logger)??console.log,t,e)}info(t,...e){this._logLevel<=2&&this._log(this._optionsService.options.logger?.info.bind(this._optionsService.options.logger)??console.info,t,e)}warn(t,...e){this._logLevel<=3&&this._log(this._optionsService.options.logger?.warn.bind(this._optionsService.options.logger)??console.warn,t,e)}error(t,...e){this._logLevel<=4&&this._log(this._optionsService.options.logger?.error.bind(this._optionsService.options.logger)??console.error,t,e)}};D0=At([Ie(0,js)],D0);var F1=class extends tt{constructor(t){super(),this._maxLength=t,this.onDeleteEmitter=this._register(new Te),this.onDelete=this.onDeleteEmitter.event,this.onInsertEmitter=this._register(new Te),this.onInsert=this.onInsertEmitter.event,this.onTrimEmitter=this._register(new Te),this.onTrim=this.onTrimEmitter.event,this._array=new Array(this._maxLength),this._startIndex=0,this._length=0}get maxLength(){return this._maxLength}set maxLength(t){if(this._maxLength===t)return;let e=new Array(t);for(let s=0;s<Math.min(t,this.length);s++)e[s]=this._array[this._getCyclicIndex(s)];this._array=e,this._maxLength=t,this._startIndex=0}get length(){return this._length}set length(t){if(t>this._length)for(let e=this._length;e<t;e++)this._array[e]=void 0;this._length=t}get(t){return this._array[this._getCyclicIndex(t)]}set(t,e){this._array[this._getCyclicIndex(t)]=e}push(t){this._array[this._getCyclicIndex(this._length)]=t,this._length===this._maxLength?(this._startIndex=++this._startIndex%this._maxLength,this.onTrimEmitter.fire(1)):this._length++}recycle(){if(this._length!==this._maxLength)throw new Error("Can only recycle when the buffer is full");return this._startIndex=++this._startIndex%this._maxLength,this.onTrimEmitter.fire(1),this._array[this._getCyclicIndex(this._length-1)]}get isFull(){return this._length===this._maxLength}pop(){return this._array[this._getCyclicIndex(this._length---1)]}splice(t,e,...s){if(e){for(let n=t;n<this._length-e;n++)this._array[this._getCyclicIndex(n)]=this._array[this._getCyclicIndex(n+e)];this._length-=e,this.onDeleteEmitter.fire({index:t,amount:e})}for(let n=this._length-1;n>=t;n--)this._array[this._getCyclicIndex(n+s.length)]=this._array[this._getCyclicIndex(n)];for(let n=0;n<s.length;n++)this._array[this._getCyclicIndex(t+n)]=s[n];if(s.length&&this.onInsertEmitter.fire({index:t,amount:s.length}),this._length+s.length>this._maxLength){let n=this._length+s.length-this._maxLength;this._startIndex+=n,this._length=this._maxLength,this.onTrimEmitter.fire(n)}else this._length+=s.length}trimStart(t){t>this._length&&(t=this._length),this._startIndex+=t,this._length-=t,this.onTrimEmitter.fire(t)}shiftElements(t,e,s){if(!(e<=0)){if(t<0||t>=this._length)throw new Error("start argument out of range");if(t+s<0)throw new Error("Cannot shift elements in list beyond index 0");if(s>0){for(let i=e-1;i>=0;i--)this.set(t+i+s,this.get(t+i));let n=t+e+s-this._length;if(n>0)for(this._length+=n;this._length>this._maxLength;)this._length--,this._startIndex++,this.onTrimEmitter.fire(1)}else for(let n=0;n<e;n++)this.set(t+n+s,this.get(t+n))}}_getCyclicIndex(t){return(this._startIndex+t)%this._maxLength}},Ze=3,Dt=Object.freeze(new pa),Ka=0,wd=2,po=class k5{constructor(e,s,n=!1){this.isWrapped=n,this._combined={},this._extendedAttrs={},this._data=new Uint32Array(e*Ze);let i=s||Gs.fromCharData([0,W4,1,0]);for(let o=0;o<e;++o)this.setCell(o,i);this.length=e}get(e){let s=this._data[e*Ze+0],n=s&2097151;return[this._data[e*Ze+1],s&2097152?this._combined[e]:n?Un(n):"",s>>22,s&2097152?this._combined[e].charCodeAt(this._combined[e].length-1):n]}set(e,s){this._data[e*Ze+1]=s[0],s[1].length>1?(this._combined[e]=s[1],this._data[e*Ze+0]=e|2097152|s[2]<<22):this._data[e*Ze+0]=s[1].charCodeAt(0)|s[2]<<22}getWidth(e){return this._data[e*Ze+0]>>22}hasWidth(e){return this._data[e*Ze+0]&12582912}getFg(e){return this._data[e*Ze+1]}getBg(e){return this._data[e*Ze+2]}hasContent(e){return this._data[e*Ze+0]&4194303}getCodePoint(e){let s=this._data[e*Ze+0];return s&2097152?this._combined[e].charCodeAt(this._combined[e].length-1):s&2097151}isCombined(e){return this._data[e*Ze+0]&2097152}getString(e){let s=this._data[e*Ze+0];return s&2097152?this._combined[e]:s&2097151?Un(s&2097151):""}isProtected(e){return this._data[e*Ze+2]&536870912}loadCell(e,s){return Ka=e*Ze,s.content=this._data[Ka+0],s.fg=this._data[Ka+1],s.bg=this._data[Ka+2],s.content&2097152&&(s.combinedData=this._combined[e]),s.bg&268435456&&(s.extended=this._extendedAttrs[e]),s}setCell(e,s){s.content&2097152&&(this._combined[e]=s.combinedData),s.bg&268435456&&(this._extendedAttrs[e]=s.extended),this._data[e*Ze+0]=s.content,this._data[e*Ze+1]=s.fg,this._data[e*Ze+2]=s.bg}setCellFromCodepoint(e,s,n,i){i.bg&268435456&&(this._extendedAttrs[e]=i.extended),this._data[e*Ze+0]=s|n<<22,this._data[e*Ze+1]=i.fg,this._data[e*Ze+2]=i.bg}addCodepointToCell(e,s,n){let i=this._data[e*Ze+0];i&2097152?this._combined[e]+=Un(s):i&2097151?(this._combined[e]=Un(i&2097151)+Un(s),i&=-2097152,i|=2097152):i=s|1<<22,n&&(i&=-12582913,i|=n<<22),this._data[e*Ze+0]=i}insertCells(e,s,n){if(e%=this.length,e&&this.getWidth(e-1)===2&&this.setCellFromCodepoint(e-1,0,1,n),s<this.length-e){let i=new Gs;for(let o=this.length-e-s-1;o>=0;--o)this.setCell(e+s+o,this.loadCell(e+o,i));for(let o=0;o<s;++o)this.setCell(e+o,n)}else for(let i=e;i<this.length;++i)this.setCell(i,n);this.getWidth(this.length-1)===2&&this.setCellFromCodepoint(this.length-1,0,1,n)}deleteCells(e,s,n){if(e%=this.length,s<this.length-e){let i=new Gs;for(let o=0;o<this.length-e-s;++o)this.setCell(e+o,this.loadCell(e+s+o,i));for(let o=this.length-s;o<this.length;++o)this.setCell(o,n)}else for(let i=e;i<this.length;++i)this.setCell(i,n);e&&this.getWidth(e-1)===2&&this.setCellFromCodepoint(e-1,0,1,n),this.getWidth(e)===0&&!this.hasContent(e)&&this.setCellFromCodepoint(e,0,1,n)}replaceCells(e,s,n,i=!1){if(i){for(e&&this.getWidth(e-1)===2&&!this.isProtected(e-1)&&this.setCellFromCodepoint(e-1,0,1,n),s<this.length&&this.getWidth(s-1)===2&&!this.isProtected(s)&&this.setCellFromCodepoint(s,0,1,n);e<s&&e<this.length;)this.isProtected(e)||this.setCell(e,n),e++;return}for(e&&this.getWidth(e-1)===2&&this.setCellFromCodepoint(e-1,0,1,n),s<this.length&&this.getWidth(s-1)===2&&this.setCellFromCodepoint(s,0,1,n);e<s&&e<this.length;)this.setCell(e++,n)}resize(e,s){if(e===this.length)return this._data.length*4*wd<this._data.buffer.byteLength;let n=e*Ze;if(e>this.length){if(this._data.buffer.byteLength>=n*4)this._data=new Uint32Array(this._data.buffer,0,n);else{let i=new Uint32Array(n);i.set(this._data),this._data=i}for(let i=this.length;i<e;++i)this.setCell(i,s)}else{this._data=this._data.subarray(0,n);let i=Object.keys(this._combined);for(let a=0;a<i.length;a++){let l=parseInt(i[a],10);l>=e&&delete this._combined[l]}let o=Object.keys(this._extendedAttrs);for(let a=0;a<o.length;a++){let l=parseInt(o[a],10);l>=e&&delete this._extendedAttrs[l]}}return this.length=e,n*4*wd<this._data.buffer.byteLength}cleanupMemory(){if(this._data.length*4*wd<this._data.buffer.byteLength){let e=new Uint32Array(this._data.length);return e.set(this._data),this._data=e,1}return 0}fill(e,s=!1){if(s){for(let n=0;n<this.length;++n)this.isProtected(n)||this.setCell(n,e);return}this._combined={},this._extendedAttrs={};for(let n=0;n<this.length;++n)this.setCell(n,e)}copyFrom(e){this.length!==e.length?this._data=new Uint32Array(e._data):this._data.set(e._data),this.length=e.length,this._combined={};for(let s in e._combined)this._combined[s]=e._combined[s];this._extendedAttrs={};for(let s in e._extendedAttrs)this._extendedAttrs[s]=e._extendedAttrs[s];this.isWrapped=e.isWrapped}clone(){let e=new k5(0);e._data=new Uint32Array(this._data),e.length=this.length;for(let s in this._combined)e._combined[s]=this._combined[s];for(let s in this._extendedAttrs)e._extendedAttrs[s]=this._extendedAttrs[s];return e.isWrapped=this.isWrapped,e}getTrimmedLength(){for(let e=this.length-1;e>=0;--e)if(this._data[e*Ze+0]&4194303)return e+(this._data[e*Ze+0]>>22);return 0}getNoBgTrimmedLength(){for(let e=this.length-1;e>=0;--e)if(this._data[e*Ze+0]&4194303||this._data[e*Ze+2]&50331648)return e+(this._data[e*Ze+0]>>22);return 0}copyCellsFrom(e,s,n,i,o){let a=e._data;if(o)for(let c=i-1;c>=0;c--){for(let d=0;d<Ze;d++)this._data[(n+c)*Ze+d]=a[(s+c)*Ze+d];a[(s+c)*Ze+2]&268435456&&(this._extendedAttrs[n+c]=e._extendedAttrs[s+c])}else for(let c=0;c<i;c++){for(let d=0;d<Ze;d++)this._data[(n+c)*Ze+d]=a[(s+c)*Ze+d];a[(s+c)*Ze+2]&268435456&&(this._extendedAttrs[n+c]=e._extendedAttrs[s+c])}let l=Object.keys(e._combined);for(let c=0;c<l.length;c++){let d=parseInt(l[c],10);d>=s&&(this._combined[d-s+n]=e._combined[d])}}translateToString(e,s,n,i){s=s??0,n=n??this.length,e&&(n=Math.min(n,this.getTrimmedLength())),i&&(i.length=0);let o="";for(;s<n;){let a=this._data[s*Ze+0],l=a&2097151,c=a&2097152?this._combined[s]:l?Un(l):qn;if(o+=c,i)for(let d=0;d<c.length;++d)i.push(s);s+=a>>22||1}return i&&i.push(s),o}};function DF(t,e,s,n,i,o){let a=[];for(let l=0;l<t.length-1;l++){let c=l,d=t.get(++c);if(!d.isWrapped)continue;let h=[t.get(l)];for(;c<t.length&&d.isWrapped;)h.push(d),d=t.get(++c);if(!o&&n>=l&&n<c){l+=h.length-1;continue}let u=0,f=Jo(h,u,e),m=1,p=0;for(;m<h.length;){let x=Jo(h,m,e),v=x-p,b=s-f,_=Math.min(v,b);h[u].copyCellsFrom(h[m],p,f,_,!1),f+=_,f===s&&(u++,f=0),p+=_,p===x&&(m++,p=0),f===0&&u!==0&&h[u-1].getWidth(s-1)===2&&(h[u].copyCellsFrom(h[u-1],s-1,f++,1,!1),h[u-1].setCell(s-1,i))}h[u].replaceCells(f,s,i);let g=0;for(let x=h.length-1;x>0&&(x>u||h[x].getTrimmedLength()===0);x--)g++;g>0&&(a.push(l+h.length-g),a.push(g)),l+=h.length-1}return a}function IF(t,e){let s=[],n=0,i=e[n],o=0;for(let a=0;a<t.length;a++)if(i===a){let l=e[++n];t.onDeleteEmitter.fire({index:a-o,amount:l}),a+=l-1,o+=l,i=e[++n]}else s.push(a);return{layout:s,countRemoved:o}}function MF(t,e){let s=[];for(let n=0;n<e.length;n++)s.push(t.get(e[n]));for(let n=0;n<s.length;n++)t.set(n,s[n]);t.length=e.length}function OF(t,e,s){let n=[],i=t.map((c,d)=>Jo(t,d,e)).reduce((c,d)=>c+d),o=0,a=0,l=0;for(;l<i;){if(i-l<s){n.push(i-l);break}o+=s;let c=Jo(t,a,e);o>c&&(o-=c,a++);let d=t[a].getWidth(o-1)===2;d&&o--;let h=d?s-1:s;n.push(h),l+=h}return n}function Jo(t,e,s){if(e===t.length-1)return t[e].getTrimmedLength();let n=!t[e].hasContent(s-1)&&t[e].getWidth(s-1)===1,i=t[e+1].getWidth(0)===2;return n&&i?s-1:s}var V5=class N5{constructor(e){this.line=e,this.isDisposed=!1,this._disposables=[],this._id=N5._nextId++,this._onDispose=this.register(new Te),this.onDispose=this._onDispose.event}get id(){return this._id}dispose(){this.isDisposed||(this.isDisposed=!0,this.line=-1,this._onDispose.fire(),Pi(this._disposables),this._disposables.length=0)}register(e){return this._disposables.push(e),e}};V5._nextId=1;var $F=V5,Kt={},pi=Kt.B;Kt[0]={"`":"◆",a:"▒",b:"␉",c:"␌",d:"␍",e:"␊",f:"°",g:"±",h:"",i:"␋",j:"┘",k:"┐",l:"┌",m:"└",n:"┼",o:"⎺",p:"⎻",q:"─",r:"⎼",s:"⎽",t:"├",u:"┤",v:"┴",w:"┬",x:"│",y:"≤",z:"≥","{":"π","|":"≠","}":"£","~":"·"};Kt.A={"#":"£"};Kt.B=void 0;Kt[4]={"#":"£","@":"¾","[":"ij","\\":"½","]":"|","{":"¨","|":"f","}":"¼","~":"´"};Kt.C=Kt[5]={"[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"};Kt.R={"#":"£","@":"à","[":"°","\\":"ç","]":"§","{":"é","|":"ù","}":"è","~":"¨"};Kt.Q={"@":"à","[":"â","\\":"ç","]":"ê","^":"î","`":"ô","{":"é","|":"ù","}":"è","~":"û"};Kt.K={"@":"§","[":"Ä","\\":"Ö","]":"Ü","{":"ä","|":"ö","}":"ü","~":"ß"};Kt.Y={"#":"£","@":"§","[":"°","\\":"ç","]":"é","`":"ù","{":"à","|":"ò","}":"è","~":"ì"};Kt.E=Kt[6]={"@":"Ä","[":"Æ","\\":"Ø","]":"Å","^":"Ü","`":"ä","{":"æ","|":"ø","}":"å","~":"ü"};Kt.Z={"#":"£","@":"§","[":"¡","\\":"Ñ","]":"¿","{":"°","|":"ñ","}":"ç"};Kt.H=Kt[7]={"@":"É","[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"};Kt["="]={"#":"ù","@":"à","[":"é","\\":"ç","]":"ê","^":"î",_:"è","`":"ô","{":"ä","|":"ö","}":"ü","~":"û"};var z1=4294967295,K1=class{constructor(t,e,s){this._hasScrollback=t,this._optionsService=e,this._bufferService=s,this.ydisp=0,this.ybase=0,this.y=0,this.x=0,this.tabs={},this.savedY=0,this.savedX=0,this.savedCurAttrData=Dt.clone(),this.savedCharset=pi,this.markers=[],this._nullCell=Gs.fromCharData([0,W4,1,0]),this._whitespaceCell=Gs.fromCharData([0,qn,1,32]),this._isClearing=!1,this._memoryCleanupQueue=new Kl,this._memoryCleanupPosition=0,this._cols=this._bufferService.cols,this._rows=this._bufferService.rows,this.lines=new F1(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}getNullCell(t){return t?(this._nullCell.fg=t.fg,this._nullCell.bg=t.bg,this._nullCell.extended=t.extended):(this._nullCell.fg=0,this._nullCell.bg=0,this._nullCell.extended=new $l),this._nullCell}getWhitespaceCell(t){return t?(this._whitespaceCell.fg=t.fg,this._whitespaceCell.bg=t.bg,this._whitespaceCell.extended=t.extended):(this._whitespaceCell.fg=0,this._whitespaceCell.bg=0,this._whitespaceCell.extended=new $l),this._whitespaceCell}getBlankLine(t,e){return new po(this._bufferService.cols,this.getNullCell(t),e)}get hasScrollback(){return this._hasScrollback&&this.lines.maxLength>this._rows}get isCursorInViewport(){let t=this.ybase+this.y-this.ydisp;return t>=0&&t<this._rows}_getCorrectBufferLength(t){if(!this._hasScrollback)return t;let e=t+this._optionsService.rawOptions.scrollback;return e>z1?z1:e}fillViewportRows(t){if(this.lines.length===0){t===void 0&&(t=Dt);let e=this._rows;for(;e--;)this.lines.push(this.getBlankLine(t))}}clear(){this.ydisp=0,this.ybase=0,this.y=0,this.x=0,this.lines=new F1(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}resize(t,e){let s=this.getNullCell(Dt),n=0,i=this._getCorrectBufferLength(e);if(i>this.lines.maxLength&&(this.lines.maxLength=i),this.lines.length>0){if(this._cols<t)for(let a=0;a<this.lines.length;a++)n+=+this.lines.get(a).resize(t,s);let o=0;if(this._rows<e)for(let a=this._rows;a<e;a++)this.lines.length<e+this.ybase&&(this._optionsService.rawOptions.windowsMode||this._optionsService.rawOptions.windowsPty.backend!==void 0||this._optionsService.rawOptions.windowsPty.buildNumber!==void 0?this.lines.push(new po(t,s)):this.ybase>0&&this.lines.length<=this.ybase+this.y+o+1?(this.ybase--,o++,this.ydisp>0&&this.ydisp--):this.lines.push(new po(t,s)));else for(let a=this._rows;a>e;a--)this.lines.length>e+this.ybase&&(this.lines.length>this.ybase+this.y+1?this.lines.pop():(this.ybase++,this.ydisp++));if(i<this.lines.maxLength){let a=this.lines.length-i;a>0&&(this.lines.trimStart(a),this.ybase=Math.max(this.ybase-a,0),this.ydisp=Math.max(this.ydisp-a,0),this.savedY=Math.max(this.savedY-a,0)),this.lines.maxLength=i}this.x=Math.min(this.x,t-1),this.y=Math.min(this.y,e-1),o&&(this.y+=o),this.savedX=Math.min(this.savedX,t-1),this.scrollTop=0}if(this.scrollBottom=e-1,this._isReflowEnabled&&(this._reflow(t,e),this._cols>t))for(let o=0;o<this.lines.length;o++)n+=+this.lines.get(o).resize(t,s);this._cols=t,this._rows=e,this._memoryCleanupQueue.clear(),n>.1*this.lines.length&&(this._memoryCleanupPosition=0,this._memoryCleanupQueue.enqueue(()=>this._batchedMemoryCleanup()))}_batchedMemoryCleanup(){let t=!0;this._memoryCleanupPosition>=this.lines.length&&(this._memoryCleanupPosition=0,t=!1);let e=0;for(;this._memoryCleanupPosition<this.lines.length;)if(e+=this.lines.get(this._memoryCleanupPosition++).cleanupMemory(),e>100)return!0;return t}get _isReflowEnabled(){let t=this._optionsService.rawOptions.windowsPty;return t&&t.buildNumber?this._hasScrollback&&t.backend==="conpty"&&t.buildNumber>=21376:this._hasScrollback&&!this._optionsService.rawOptions.windowsMode}_reflow(t,e){this._cols!==t&&(t>this._cols?this._reflowLarger(t,e):this._reflowSmaller(t,e))}_reflowLarger(t,e){let s=this._optionsService.rawOptions.reflowCursorLine,n=DF(this.lines,this._cols,t,this.ybase+this.y,this.getNullCell(Dt),s);if(n.length>0){let i=IF(this.lines,n);MF(this.lines,i.layout),this._reflowLargerAdjustViewport(t,e,i.countRemoved)}}_reflowLargerAdjustViewport(t,e,s){let n=this.getNullCell(Dt),i=s;for(;i-- >0;)this.ybase===0?(this.y>0&&this.y--,this.lines.length<e&&this.lines.push(new po(t,n))):(this.ydisp===this.ybase&&this.ydisp--,this.ybase--);this.savedY=Math.max(this.savedY-s,0)}_reflowSmaller(t,e){let s=this._optionsService.rawOptions.reflowCursorLine,n=this.getNullCell(Dt),i=[],o=0;for(let a=this.lines.length-1;a>=0;a--){let l=this.lines.get(a);if(!l||!l.isWrapped&&l.getTrimmedLength()<=t)continue;let c=[l];for(;l.isWrapped&&a>0;)l=this.lines.get(--a),c.unshift(l);if(!s){let _=this.ybase+this.y;if(_>=a&&_<a+c.length)continue}let d=c[c.length-1].getTrimmedLength(),h=OF(c,this._cols,t),u=h.length-c.length,f;this.ybase===0&&this.y!==this.lines.length-1?f=Math.max(0,this.y-this.lines.maxLength+u):f=Math.max(0,this.lines.length-this.lines.maxLength+u);let m=[];for(let _=0;_<u;_++){let y=this.getBlankLine(Dt,!0);m.push(y)}m.length>0&&(i.push({start:a+c.length+o,newLines:m}),o+=m.length),c.push(...m);let p=h.length-1,g=h[p];g===0&&(p--,g=h[p]);let x=c.length-u-1,v=d;for(;x>=0;){let _=Math.min(v,g);if(c[p]===void 0)break;if(c[p].copyCellsFrom(c[x],v-_,g-_,_,!0),g-=_,g===0&&(p--,g=h[p]),v-=_,v===0){x--;let y=Math.max(x,0);v=Jo(c,y,this._cols)}}for(let _=0;_<c.length;_++)h[_]<t&&c[_].setCell(h[_],n);let b=u-f;for(;b-- >0;)this.ybase===0?this.y<e-1?(this.y++,this.lines.pop()):(this.ybase++,this.ydisp++):this.ybase<Math.min(this.lines.maxLength,this.lines.length+o)-e&&(this.ybase===this.ydisp&&this.ydisp++,this.ybase++);this.savedY=Math.min(this.savedY+u,this.ybase+e-1)}if(i.length>0){let a=[],l=[];for(let g=0;g<this.lines.length;g++)l.push(this.lines.get(g));let c=this.lines.length,d=c-1,h=0,u=i[h];this.lines.length=Math.min(this.lines.maxLength,this.lines.length+o);let f=0;for(let g=Math.min(this.lines.maxLength-1,c+o-1);g>=0;g--)if(u&&u.start>d+f){for(let x=u.newLines.length-1;x>=0;x--)this.lines.set(g--,u.newLines[x]);g++,a.push({index:d+1,amount:u.newLines.length}),f+=u.newLines.length,u=i[++h]}else this.lines.set(g,l[d--]);let m=0;for(let g=a.length-1;g>=0;g--)a[g].index+=m,this.lines.onInsertEmitter.fire(a[g]),m+=a[g].amount;let p=Math.max(0,c+o-this.lines.maxLength);p>0&&this.lines.onTrimEmitter.fire(p)}}translateBufferLineToString(t,e,s=0,n){let i=this.lines.get(t);return i?i.translateToString(e,s,n):""}getWrappedRangeForLine(t){let e=t,s=t;for(;e>0&&this.lines.get(e).isWrapped;)e--;for(;s+1<this.lines.length&&this.lines.get(s+1).isWrapped;)s++;return{first:e,last:s}}setupTabStops(t){for(t!=null?this.tabs[t]||(t=this.prevStop(t)):(this.tabs={},t=0);t<this._cols;t+=this._optionsService.rawOptions.tabStopWidth)this.tabs[t]=!0}prevStop(t){for(t==null&&(t=this.x);!this.tabs[--t]&&t>0;);return t>=this._cols?this._cols-1:t<0?0:t}nextStop(t){for(t==null&&(t=this.x);!this.tabs[++t]&&t<this._cols;);return t>=this._cols?this._cols-1:t<0?0:t}clearMarkers(t){this._isClearing=!0;for(let e=0;e<this.markers.length;e++)this.markers[e].line===t&&(this.markers[e].dispose(),this.markers.splice(e--,1));this._isClearing=!1}clearAllMarkers(){this._isClearing=!0;for(let t=0;t<this.markers.length;t++)this.markers[t].dispose();this.markers.length=0,this._isClearing=!1}addMarker(t){let e=new $F(t);return this.markers.push(e),e.register(this.lines.onTrim(s=>{e.line-=s,e.line<0&&e.dispose()})),e.register(this.lines.onInsert(s=>{e.line>=s.index&&(e.line+=s.amount)})),e.register(this.lines.onDelete(s=>{e.line>=s.index&&e.line<s.index+s.amount&&e.dispose(),e.line>s.index&&(e.line-=s.amount)})),e.register(e.onDispose(()=>this._removeMarker(e))),e}_removeMarker(t){this._isClearing||this.markers.splice(this.markers.indexOf(t),1)}},BF=class extends tt{constructor(t,e){super(),this._optionsService=t,this._bufferService=e,this._onBufferActivate=this._register(new Te),this.onBufferActivate=this._onBufferActivate.event,this.reset(),this._register(this._optionsService.onSpecificOptionChange("scrollback",()=>this.resize(this._bufferService.cols,this._bufferService.rows))),this._register(this._optionsService.onSpecificOptionChange("tabStopWidth",()=>this.setupTabStops()))}reset(){this._normal=new K1(!0,this._optionsService,this._bufferService),this._normal.fillViewportRows(),this._alt=new K1(!1,this._optionsService,this._bufferService),this._activeBuffer=this._normal,this._onBufferActivate.fire({activeBuffer:this._normal,inactiveBuffer:this._alt}),this.setupTabStops()}get alt(){return this._alt}get active(){return this._activeBuffer}get normal(){return this._normal}activateNormalBuffer(){this._activeBuffer!==this._normal&&(this._normal.x=this._alt.x,this._normal.y=this._alt.y,this._alt.clearAllMarkers(),this._alt.clear(),this._activeBuffer=this._normal,this._onBufferActivate.fire({activeBuffer:this._normal,inactiveBuffer:this._alt}))}activateAltBuffer(t){this._activeBuffer!==this._alt&&(this._alt.fillViewportRows(t),this._alt.x=this._normal.x,this._alt.y=this._normal.y,this._activeBuffer=this._alt,this._onBufferActivate.fire({activeBuffer:this._alt,inactiveBuffer:this._normal}))}resize(t,e){this._normal.resize(t,e),this._alt.resize(t,e),this.setupTabStops(t)}setupTabStops(t){this._normal.setupTabStops(t),this._alt.setupTabStops(t)}},T5=2,A5=1,I0=class extends tt{constructor(t){super(),this.isUserScrolling=!1,this._onResize=this._register(new Te),this.onResize=this._onResize.event,this._onScroll=this._register(new Te),this.onScroll=this._onScroll.event,this.cols=Math.max(t.rawOptions.cols||0,T5),this.rows=Math.max(t.rawOptions.rows||0,A5),this.buffers=this._register(new BF(t,this)),this._register(this.buffers.onBufferActivate(e=>{this._onScroll.fire(e.activeBuffer.ydisp)}))}get buffer(){return this.buffers.active}resize(t,e){let s=this.cols!==t,n=this.rows!==e;this.cols=t,this.rows=e,this.buffers.resize(t,e),this._onResize.fire({cols:t,rows:e,colsChanged:s,rowsChanged:n})}reset(){this.buffers.reset(),this.isUserScrolling=!1}scroll(t,e=!1){let s=this.buffer,n;n=this._cachedBlankLine,(!n||n.length!==this.cols||n.getFg(0)!==t.fg||n.getBg(0)!==t.bg)&&(n=s.getBlankLine(t,e),this._cachedBlankLine=n),n.isWrapped=e;let i=s.ybase+s.scrollTop,o=s.ybase+s.scrollBottom;if(s.scrollTop===0){let a=s.lines.isFull;o===s.lines.length-1?a?s.lines.recycle().copyFrom(n):s.lines.push(n.clone()):s.lines.splice(o+1,0,n.clone()),a?this.isUserScrolling&&(s.ydisp=Math.max(s.ydisp-1,0)):(s.ybase++,this.isUserScrolling||s.ydisp++)}else{let a=o-i+1;s.lines.shiftElements(i+1,a-1,-1),s.lines.set(o,n.clone())}this.isUserScrolling||(s.ydisp=s.ybase),this._onScroll.fire(s.ydisp)}scrollLines(t,e){let s=this.buffer;if(t<0){if(s.ydisp===0)return;this.isUserScrolling=!0}else t+s.ydisp>=s.ybase&&(this.isUserScrolling=!1);let n=s.ydisp;s.ydisp=Math.max(Math.min(s.ydisp+t,s.ybase),0),n!==s.ydisp&&(e||this._onScroll.fire(s.ydisp))}};I0=At([Ie(0,js)],I0);var Qi={cols:80,rows:24,cursorBlink:!1,cursorStyle:"block",cursorWidth:1,cursorInactiveStyle:"outline",customGlyphs:!0,drawBoldTextInBrightColors:!0,documentOverride:null,fastScrollModifier:"alt",fastScrollSensitivity:5,fontFamily:"monospace",fontSize:15,fontWeight:"normal",fontWeightBold:"bold",ignoreBracketedPasteMode:!1,lineHeight:1,letterSpacing:0,linkHandler:null,logLevel:"info",logger:null,scrollback:1e3,scrollOnEraseInDisplay:!1,scrollOnUserInput:!0,scrollSensitivity:1,screenReaderMode:!1,smoothScrollDuration:0,macOptionIsMeta:!1,macOptionClickForcesSelection:!1,minimumContrastRatio:1,disableStdin:!1,allowProposedApi:!1,allowTransparency:!1,tabStopWidth:8,theme:{},reflowCursorLine:!1,rescaleOverlappingGlyphs:!1,rightClickSelectsWord:zl,windowOptions:{},windowsMode:!1,windowsPty:{},wordSeparator:" ()[]{}',\"`",altClickMovesCursor:!0,convertEol:!1,termName:"xterm",cancelEvents:!1,overviewRuler:{}},FF=["normal","bold","100","200","300","400","500","600","700","800","900"],zF=class extends tt{constructor(t){super(),this._onOptionChange=this._register(new Te),this.onOptionChange=this._onOptionChange.event;let e={...Qi};for(let s in t)if(s in e)try{let n=t[s];e[s]=this._sanitizeAndValidateOption(s,n)}catch(n){console.error(n)}this.rawOptions=e,this.options={...e},this._setupOptions(),this._register(Lt(()=>{this.rawOptions.linkHandler=null,this.rawOptions.documentOverride=null}))}onSpecificOptionChange(t,e){return this.onOptionChange(s=>{s===t&&e(this.rawOptions[t])})}onMultipleOptionChange(t,e){return this.onOptionChange(s=>{t.indexOf(s)!==-1&&e()})}_setupOptions(){let t=s=>{if(!(s in Qi))throw new Error(`No option with key "${s}"`);return this.rawOptions[s]},e=(s,n)=>{if(!(s in Qi))throw new Error(`No option with key "${s}"`);n=this._sanitizeAndValidateOption(s,n),this.rawOptions[s]!==n&&(this.rawOptions[s]=n,this._onOptionChange.fire(s))};for(let s in this.rawOptions){let n={get:t.bind(this,s),set:e.bind(this,s)};Object.defineProperty(this.options,s,n)}}_sanitizeAndValidateOption(t,e){switch(t){case"cursorStyle":if(e||(e=Qi[t]),!KF(e))throw new Error(`"${e}" is not a valid value for ${t}`);break;case"wordSeparator":e||(e=Qi[t]);break;case"fontWeight":case"fontWeightBold":if(typeof e=="number"&&1<=e&&e<=1e3)break;e=FF.includes(e)?e:Qi[t];break;case"cursorWidth":e=Math.floor(e);case"lineHeight":case"tabStopWidth":if(e<1)throw new Error(`${t} cannot be less than 1, value: ${e}`);break;case"minimumContrastRatio":e=Math.max(1,Math.min(21,Math.round(e*10)/10));break;case"scrollback":if(e=Math.min(e,4294967295),e<0)throw new Error(`${t} cannot be less than 0, value: ${e}`);break;case"fastScrollSensitivity":case"scrollSensitivity":if(e<=0)throw new Error(`${t} cannot be less than or equal to 0, value: ${e}`);break;case"rows":case"cols":if(!e&&e!==0)throw new Error(`${t} must be numeric, value: ${e}`);break;case"windowsPty":e=e??{};break}return e}};function KF(t){return t==="block"||t==="underline"||t==="bar"}function go(t,e=5){if(typeof t!="object")return t;let s=Array.isArray(t)?[]:{};for(let n in t)s[n]=e<=1?t[n]:t[n]&&go(t[n],e-1);return s}var U1=Object.freeze({insertMode:!1}),H1=Object.freeze({applicationCursorKeys:!1,applicationKeypad:!1,bracketedPasteMode:!1,cursorBlink:void 0,cursorStyle:void 0,origin:!1,reverseWraparound:!1,sendFocus:!1,synchronizedOutput:!1,wraparound:!0}),M0=class extends tt{constructor(t,e,s){super(),this._bufferService=t,this._logService=e,this._optionsService=s,this.isCursorInitialized=!1,this.isCursorHidden=!1,this._onData=this._register(new Te),this.onData=this._onData.event,this._onUserInput=this._register(new Te),this.onUserInput=this._onUserInput.event,this._onBinary=this._register(new Te),this.onBinary=this._onBinary.event,this._onRequestScrollToBottom=this._register(new Te),this.onRequestScrollToBottom=this._onRequestScrollToBottom.event,this.modes=go(U1),this.decPrivateModes=go(H1)}reset(){this.modes=go(U1),this.decPrivateModes=go(H1)}triggerDataEvent(t,e=!1){if(this._optionsService.rawOptions.disableStdin)return;let s=this._bufferService.buffer;e&&this._optionsService.rawOptions.scrollOnUserInput&&s.ybase!==s.ydisp&&this._onRequestScrollToBottom.fire(),e&&this._onUserInput.fire(),this._logService.debug(`sending data "${t}"`),this._logService.trace("sending data (codes)",()=>t.split("").map(n=>n.charCodeAt(0))),this._onData.fire(t)}triggerBinaryEvent(t){this._optionsService.rawOptions.disableStdin||(this._logService.debug(`sending binary "${t}"`),this._logService.trace("sending binary (codes)",()=>t.split("").map(e=>e.charCodeAt(0))),this._onBinary.fire(t))}};M0=At([Ie(0,ws),Ie(1,X4),Ie(2,js)],M0);var W1={NONE:{events:0,restrict:()=>!1},X10:{events:1,restrict:t=>t.button===4||t.action!==1?!1:(t.ctrl=!1,t.alt=!1,t.shift=!1,!0)},VT200:{events:19,restrict:t=>t.action!==32},DRAG:{events:23,restrict:t=>!(t.action===32&&t.button===3)},ANY:{events:31,restrict:t=>!0}};function jd(t,e){let s=(t.ctrl?16:0)|(t.shift?4:0)|(t.alt?8:0);return t.button===4?(s|=64,s|=t.action):(s|=t.button&3,t.button&4&&(s|=64),t.button&8&&(s|=128),t.action===32?s|=32:t.action===0&&!e&&(s|=3)),s}var Cd=String.fromCharCode,q1={DEFAULT:t=>{let e=[jd(t,!1)+32,t.col+32,t.row+32];return e[0]>255||e[1]>255||e[2]>255?"":`\x1B[M${Cd(e[0])}${Cd(e[1])}${Cd(e[2])}`},SGR:t=>{let e=t.action===0&&t.button!==4?"m":"M";return`\x1B[<${jd(t,!0)};${t.col};${t.row}${e}`},SGR_PIXELS:t=>{let e=t.action===0&&t.button!==4?"m":"M";return`\x1B[<${jd(t,!0)};${t.x};${t.y}${e}`}},O0=class extends tt{constructor(t,e,s){super(),this._bufferService=t,this._coreService=e,this._optionsService=s,this._protocols={},this._encodings={},this._activeProtocol="",this._activeEncoding="",this._lastEvent=null,this._wheelPartialScroll=0,this._onProtocolChange=this._register(new Te),this.onProtocolChange=this._onProtocolChange.event;for(let n of Object.keys(W1))this.addProtocol(n,W1[n]);for(let n of Object.keys(q1))this.addEncoding(n,q1[n]);this.reset()}addProtocol(t,e){this._protocols[t]=e}addEncoding(t,e){this._encodings[t]=e}get activeProtocol(){return this._activeProtocol}get areMouseEventsActive(){return this._protocols[this._activeProtocol].events!==0}set activeProtocol(t){if(!this._protocols[t])throw new Error(`unknown protocol "${t}"`);this._activeProtocol=t,this._onProtocolChange.fire(this._protocols[t].events)}get activeEncoding(){return this._activeEncoding}set activeEncoding(t){if(!this._encodings[t])throw new Error(`unknown encoding "${t}"`);this._activeEncoding=t}reset(){this.activeProtocol="NONE",this.activeEncoding="DEFAULT",this._lastEvent=null,this._wheelPartialScroll=0}consumeWheelEvent(t,e,s){if(t.deltaY===0||t.shiftKey||e===void 0||s===void 0)return 0;let n=e/s,i=this._applyScrollModifier(t.deltaY,t);return t.deltaMode===WheelEvent.DOM_DELTA_PIXEL?(i/=n+0,Math.abs(t.deltaY)<50&&(i*=.3),this._wheelPartialScroll+=i,i=Math.floor(Math.abs(this._wheelPartialScroll))*(this._wheelPartialScroll>0?1:-1),this._wheelPartialScroll%=1):t.deltaMode===WheelEvent.DOM_DELTA_PAGE&&(i*=this._bufferService.rows),i}_applyScrollModifier(t,e){return e.altKey||e.ctrlKey||e.shiftKey?t*this._optionsService.rawOptions.fastScrollSensitivity*this._optionsService.rawOptions.scrollSensitivity:t*this._optionsService.rawOptions.scrollSensitivity}triggerMouseEvent(t){if(t.col<0||t.col>=this._bufferService.cols||t.row<0||t.row>=this._bufferService.rows||t.button===4&&t.action===32||t.button===3&&t.action!==32||t.button!==4&&(t.action===2||t.action===3)||(t.col++,t.row++,t.action===32&&this._lastEvent&&this._equalEvents(this._lastEvent,t,this._activeEncoding==="SGR_PIXELS"))||!this._protocols[this._activeProtocol].restrict(t))return!1;let e=this._encodings[this._activeEncoding](t);return e&&(this._activeEncoding==="DEFAULT"?this._coreService.triggerBinaryEvent(e):this._coreService.triggerDataEvent(e,!0)),this._lastEvent=t,!0}explainEvents(t){return{down:!!(t&1),up:!!(t&2),drag:!!(t&4),move:!!(t&8),wheel:!!(t&16)}}_equalEvents(t,e,s){if(s){if(t.x!==e.x||t.y!==e.y)return!1}else if(t.col!==e.col||t.row!==e.row)return!1;return!(t.button!==e.button||t.action!==e.action||t.ctrl!==e.ctrl||t.alt!==e.alt||t.shift!==e.shift)}};O0=At([Ie(0,ws),Ie(1,Gi),Ie(2,js)],O0);var kd=[[768,879],[1155,1158],[1160,1161],[1425,1469],[1471,1471],[1473,1474],[1476,1477],[1479,1479],[1536,1539],[1552,1557],[1611,1630],[1648,1648],[1750,1764],[1767,1768],[1770,1773],[1807,1807],[1809,1809],[1840,1866],[1958,1968],[2027,2035],[2305,2306],[2364,2364],[2369,2376],[2381,2381],[2385,2388],[2402,2403],[2433,2433],[2492,2492],[2497,2500],[2509,2509],[2530,2531],[2561,2562],[2620,2620],[2625,2626],[2631,2632],[2635,2637],[2672,2673],[2689,2690],[2748,2748],[2753,2757],[2759,2760],[2765,2765],[2786,2787],[2817,2817],[2876,2876],[2879,2879],[2881,2883],[2893,2893],[2902,2902],[2946,2946],[3008,3008],[3021,3021],[3134,3136],[3142,3144],[3146,3149],[3157,3158],[3260,3260],[3263,3263],[3270,3270],[3276,3277],[3298,3299],[3393,3395],[3405,3405],[3530,3530],[3538,3540],[3542,3542],[3633,3633],[3636,3642],[3655,3662],[3761,3761],[3764,3769],[3771,3772],[3784,3789],[3864,3865],[3893,3893],[3895,3895],[3897,3897],[3953,3966],[3968,3972],[3974,3975],[3984,3991],[3993,4028],[4038,4038],[4141,4144],[4146,4146],[4150,4151],[4153,4153],[4184,4185],[4448,4607],[4959,4959],[5906,5908],[5938,5940],[5970,5971],[6002,6003],[6068,6069],[6071,6077],[6086,6086],[6089,6099],[6109,6109],[6155,6157],[6313,6313],[6432,6434],[6439,6440],[6450,6450],[6457,6459],[6679,6680],[6912,6915],[6964,6964],[6966,6970],[6972,6972],[6978,6978],[7019,7027],[7616,7626],[7678,7679],[8203,8207],[8234,8238],[8288,8291],[8298,8303],[8400,8431],[12330,12335],[12441,12442],[43014,43014],[43019,43019],[43045,43046],[64286,64286],[65024,65039],[65056,65059],[65279,65279],[65529,65531]],UF=[[68097,68099],[68101,68102],[68108,68111],[68152,68154],[68159,68159],[119143,119145],[119155,119170],[119173,119179],[119210,119213],[119362,119364],[917505,917505],[917536,917631],[917760,917999]],Ot;function HF(t,e){let s=0,n=e.length-1,i;if(t<e[0][0]||t>e[n][1])return!1;for(;n>=s;)if(i=s+n>>1,t>e[i][1])s=i+1;else if(t<e[i][0])n=i-1;else return!0;return!1}var WF=class{constructor(){if(this.version="6",!Ot){Ot=new Uint8Array(65536),Ot.fill(1),Ot[0]=0,Ot.fill(0,1,32),Ot.fill(0,127,160),Ot.fill(2,4352,4448),Ot[9001]=2,Ot[9002]=2,Ot.fill(2,11904,42192),Ot[12351]=1,Ot.fill(2,44032,55204),Ot.fill(2,63744,64256),Ot.fill(2,65040,65050),Ot.fill(2,65072,65136),Ot.fill(2,65280,65377),Ot.fill(2,65504,65511);for(let t=0;t<kd.length;++t)Ot.fill(0,kd[t][0],kd[t][1]+1)}}wcwidth(t){return t<32?0:t<127?1:t<65536?Ot[t]:HF(t,UF)?0:t>=131072&&t<=196605||t>=196608&&t<=262141?2:1}charProperties(t,e){let s=this.wcwidth(t),n=s===0&&e!==0;if(n){let i=bi.extractWidth(e);i===0?n=!1:i>s&&(s=i)}return bi.createPropertyValue(0,s,n)}},bi=class tl{constructor(){this._providers=Object.create(null),this._active="",this._onChange=new Te,this.onChange=this._onChange.event;let e=new WF;this.register(e),this._active=e.version,this._activeProvider=e}static extractShouldJoin(e){return(e&1)!==0}static extractWidth(e){return e>>1&3}static extractCharKind(e){return e>>3}static createPropertyValue(e,s,n=!1){return(e&16777215)<<3|(s&3)<<1|(n?1:0)}dispose(){this._onChange.dispose()}get versions(){return Object.keys(this._providers)}get activeVersion(){return this._active}set activeVersion(e){if(!this._providers[e])throw new Error(`unknown Unicode version "${e}"`);this._active=e,this._activeProvider=this._providers[e],this._onChange.fire(e)}register(e){this._providers[e.version]=e}wcwidth(e){return this._activeProvider.wcwidth(e)}getStringCellWidth(e){let s=0,n=0,i=e.length;for(let o=0;o<i;++o){let a=e.charCodeAt(o);if(55296<=a&&a<=56319){if(++o>=i)return s+this.wcwidth(a);let d=e.charCodeAt(o);56320<=d&&d<=57343?a=(a-55296)*1024+d-56320+65536:s+=this.wcwidth(d)}let l=this.charProperties(a,n),c=tl.extractWidth(l);tl.extractShouldJoin(l)&&(c-=tl.extractWidth(n)),s+=c,n=l}return s}charProperties(e,s){return this._activeProvider.charProperties(e,s)}},qF=class{constructor(){this.glevel=0,this._charsets=[]}reset(){this.charset=void 0,this._charsets=[],this.glevel=0}setgLevel(t){this.glevel=t,this.charset=this._charsets[t]}setgCharset(t,e){this._charsets[t]=e,this.glevel===t&&(this.charset=e)}};function G1(t){let e=t.buffer.lines.get(t.buffer.ybase+t.buffer.y-1)?.get(t.cols-1),s=t.buffer.lines.get(t.buffer.ybase+t.buffer.y);s&&e&&(s.isWrapped=e[3]!==0&&e[3]!==32)}var to=2147483647,GF=256,E5=class $0{constructor(e=32,s=32){if(this.maxLength=e,this.maxSubParamsLength=s,s>GF)throw new Error("maxSubParamsLength must not be greater than 256");this.params=new Int32Array(e),this.length=0,this._subParams=new Int32Array(s),this._subParamsLength=0,this._subParamsIdx=new Uint16Array(e),this._rejectDigits=!1,this._rejectSubDigits=!1,this._digitIsSub=!1}static fromArray(e){let s=new $0;if(!e.length)return s;for(let n=Array.isArray(e[0])?1:0;n<e.length;++n){let i=e[n];if(Array.isArray(i))for(let o=0;o<i.length;++o)s.addSubParam(i[o]);else s.addParam(i)}return s}clone(){let e=new $0(this.maxLength,this.maxSubParamsLength);return e.params.set(this.params),e.length=this.length,e._subParams.set(this._subParams),e._subParamsLength=this._subParamsLength,e._subParamsIdx.set(this._subParamsIdx),e._rejectDigits=this._rejectDigits,e._rejectSubDigits=this._rejectSubDigits,e._digitIsSub=this._digitIsSub,e}toArray(){let e=[];for(let s=0;s<this.length;++s){e.push(this.params[s]);let n=this._subParamsIdx[s]>>8,i=this._subParamsIdx[s]&255;i-n>0&&e.push(Array.prototype.slice.call(this._subParams,n,i))}return e}reset(){this.length=0,this._subParamsLength=0,this._rejectDigits=!1,this._rejectSubDigits=!1,this._digitIsSub=!1}addParam(e){if(this._digitIsSub=!1,this.length>=this.maxLength){this._rejectDigits=!0;return}if(e<-1)throw new Error("values lesser than -1 are not allowed");this._subParamsIdx[this.length]=this._subParamsLength<<8|this._subParamsLength,this.params[this.length++]=e>to?to:e}addSubParam(e){if(this._digitIsSub=!0,!!this.length){if(this._rejectDigits||this._subParamsLength>=this.maxSubParamsLength){this._rejectSubDigits=!0;return}if(e<-1)throw new Error("values lesser than -1 are not allowed");this._subParams[this._subParamsLength++]=e>to?to:e,this._subParamsIdx[this.length-1]++}}hasSubParams(e){return(this._subParamsIdx[e]&255)-(this._subParamsIdx[e]>>8)>0}getSubParams(e){let s=this._subParamsIdx[e]>>8,n=this._subParamsIdx[e]&255;return n-s>0?this._subParams.subarray(s,n):null}getSubParamsAll(){let e={};for(let s=0;s<this.length;++s){let n=this._subParamsIdx[s]>>8,i=this._subParamsIdx[s]&255;i-n>0&&(e[s]=this._subParams.slice(n,i))}return e}addDigit(e){let s;if(this._rejectDigits||!(s=this._digitIsSub?this._subParamsLength:this.length)||this._digitIsSub&&this._rejectSubDigits)return;let n=this._digitIsSub?this._subParams:this.params,i=n[s-1];n[s-1]=~i?Math.min(i*10+e,to):e}},so=[],YF=class{constructor(){this._state=0,this._active=so,this._id=-1,this._handlers=Object.create(null),this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}registerHandler(t,e){this._handlers[t]===void 0&&(this._handlers[t]=[]);let s=this._handlers[t];return s.push(e),{dispose:()=>{let n=s.indexOf(e);n!==-1&&s.splice(n,1)}}}clearHandler(t){this._handlers[t]&&delete this._handlers[t]}setHandlerFallback(t){this._handlerFb=t}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=so}reset(){if(this._state===2)for(let t=this._stack.paused?this._stack.loopPosition-1:this._active.length-1;t>=0;--t)this._active[t].end(!1);this._stack.paused=!1,this._active=so,this._id=-1,this._state=0}_start(){if(this._active=this._handlers[this._id]||so,!this._active.length)this._handlerFb(this._id,"START");else for(let t=this._active.length-1;t>=0;t--)this._active[t].start()}_put(t,e,s){if(!this._active.length)this._handlerFb(this._id,"PUT",Tc(t,e,s));else for(let n=this._active.length-1;n>=0;n--)this._active[n].put(t,e,s)}start(){this.reset(),this._state=1}put(t,e,s){if(this._state!==3){if(this._state===1)for(;e<s;){let n=t[e++];if(n===59){this._state=2,this._start();break}if(n<48||57<n){this._state=3;return}this._id===-1&&(this._id=0),this._id=this._id*10+n-48}this._state===2&&s-e>0&&this._put(t,e,s)}}end(t,e=!0){if(this._state!==0){if(this._state!==3)if(this._state===1&&this._start(),!this._active.length)this._handlerFb(this._id,"END",t);else{let s=!1,n=this._active.length-1,i=!1;if(this._stack.paused&&(n=this._stack.loopPosition-1,s=e,i=this._stack.fallThrough,this._stack.paused=!1),!i&&s===!1){for(;n>=0&&(s=this._active[n].end(t),s!==!0);n--)if(s instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=n,this._stack.fallThrough=!1,s;n--}for(;n>=0;n--)if(s=this._active[n].end(!1),s instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=n,this._stack.fallThrough=!0,s}this._active=so,this._id=-1,this._state=0}}},Ds=class{constructor(t){this._handler=t,this._data="",this._hitLimit=!1}start(){this._data="",this._hitLimit=!1}put(t,e,s){this._hitLimit||(this._data+=Tc(t,e,s),this._data.length>1e7&&(this._data="",this._hitLimit=!0))}end(t){let e=!1;if(this._hitLimit)e=!1;else if(t&&(e=this._handler(this._data),e instanceof Promise))return e.then(s=>(this._data="",this._hitLimit=!1,s));return this._data="",this._hitLimit=!1,e}},no=[],JF=class{constructor(){this._handlers=Object.create(null),this._active=no,this._ident=0,this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=no}registerHandler(t,e){this._handlers[t]===void 0&&(this._handlers[t]=[]);let s=this._handlers[t];return s.push(e),{dispose:()=>{let n=s.indexOf(e);n!==-1&&s.splice(n,1)}}}clearHandler(t){this._handlers[t]&&delete this._handlers[t]}setHandlerFallback(t){this._handlerFb=t}reset(){if(this._active.length)for(let t=this._stack.paused?this._stack.loopPosition-1:this._active.length-1;t>=0;--t)this._active[t].unhook(!1);this._stack.paused=!1,this._active=no,this._ident=0}hook(t,e){if(this.reset(),this._ident=t,this._active=this._handlers[t]||no,!this._active.length)this._handlerFb(this._ident,"HOOK",e);else for(let s=this._active.length-1;s>=0;s--)this._active[s].hook(e)}put(t,e,s){if(!this._active.length)this._handlerFb(this._ident,"PUT",Tc(t,e,s));else for(let n=this._active.length-1;n>=0;n--)this._active[n].put(t,e,s)}unhook(t,e=!0){if(!this._active.length)this._handlerFb(this._ident,"UNHOOK",t);else{let s=!1,n=this._active.length-1,i=!1;if(this._stack.paused&&(n=this._stack.loopPosition-1,s=e,i=this._stack.fallThrough,this._stack.paused=!1),!i&&s===!1){for(;n>=0&&(s=this._active[n].unhook(t),s!==!0);n--)if(s instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=n,this._stack.fallThrough=!1,s;n--}for(;n>=0;n--)if(s=this._active[n].unhook(!1),s instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=n,this._stack.fallThrough=!0,s}this._active=no,this._ident=0}},xo=new E5;xo.addParam(0);var Y1=class{constructor(t){this._handler=t,this._data="",this._params=xo,this._hitLimit=!1}hook(t){this._params=t.length>1||t.params[0]?t.clone():xo,this._data="",this._hitLimit=!1}put(t,e,s){this._hitLimit||(this._data+=Tc(t,e,s),this._data.length>1e7&&(this._data="",this._hitLimit=!0))}unhook(t){let e=!1;if(this._hitLimit)e=!1;else if(t&&(e=this._handler(this._data,this._params),e instanceof Promise))return e.then(s=>(this._params=xo,this._data="",this._hitLimit=!1,s));return this._params=xo,this._data="",this._hitLimit=!1,e}},XF=class{constructor(t){this.table=new Uint8Array(t)}setDefault(t,e){this.table.fill(t<<4|e)}add(t,e,s,n){this.table[e<<8|t]=s<<4|n}addMany(t,e,s,n){for(let i=0;i<t.length;i++)this.table[e<<8|t[i]]=s<<4|n}},qs=160,QF=(function(){let t=new XF(4095),e=Array.apply(null,Array(256)).map((l,c)=>c),s=(l,c)=>e.slice(l,c),n=s(32,127),i=s(0,24);i.push(25),i.push.apply(i,s(28,32));let o=s(0,14),a;t.setDefault(1,0),t.addMany(n,0,2,0);for(a in o)t.addMany([24,26,153,154],a,3,0),t.addMany(s(128,144),a,3,0),t.addMany(s(144,152),a,3,0),t.add(156,a,0,0),t.add(27,a,11,1),t.add(157,a,4,8),t.addMany([152,158,159],a,0,7),t.add(155,a,11,3),t.add(144,a,11,9);return t.addMany(i,0,3,0),t.addMany(i,1,3,1),t.add(127,1,0,1),t.addMany(i,8,0,8),t.addMany(i,3,3,3),t.add(127,3,0,3),t.addMany(i,4,3,4),t.add(127,4,0,4),t.addMany(i,6,3,6),t.addMany(i,5,3,5),t.add(127,5,0,5),t.addMany(i,2,3,2),t.add(127,2,0,2),t.add(93,1,4,8),t.addMany(n,8,5,8),t.add(127,8,5,8),t.addMany([156,27,24,26,7],8,6,0),t.addMany(s(28,32),8,0,8),t.addMany([88,94,95],1,0,7),t.addMany(n,7,0,7),t.addMany(i,7,0,7),t.add(156,7,0,0),t.add(127,7,0,7),t.add(91,1,11,3),t.addMany(s(64,127),3,7,0),t.addMany(s(48,60),3,8,4),t.addMany([60,61,62,63],3,9,4),t.addMany(s(48,60),4,8,4),t.addMany(s(64,127),4,7,0),t.addMany([60,61,62,63],4,0,6),t.addMany(s(32,64),6,0,6),t.add(127,6,0,6),t.addMany(s(64,127),6,0,0),t.addMany(s(32,48),3,9,5),t.addMany(s(32,48),5,9,5),t.addMany(s(48,64),5,0,6),t.addMany(s(64,127),5,7,0),t.addMany(s(32,48),4,9,5),t.addMany(s(32,48),1,9,2),t.addMany(s(32,48),2,9,2),t.addMany(s(48,127),2,10,0),t.addMany(s(48,80),1,10,0),t.addMany(s(81,88),1,10,0),t.addMany([89,90,92],1,10,0),t.addMany(s(96,127),1,10,0),t.add(80,1,11,9),t.addMany(i,9,0,9),t.add(127,9,0,9),t.addMany(s(28,32),9,0,9),t.addMany(s(32,48),9,9,12),t.addMany(s(48,60),9,8,10),t.addMany([60,61,62,63],9,9,10),t.addMany(i,11,0,11),t.addMany(s(32,128),11,0,11),t.addMany(s(28,32),11,0,11),t.addMany(i,10,0,10),t.add(127,10,0,10),t.addMany(s(28,32),10,0,10),t.addMany(s(48,60),10,8,10),t.addMany([60,61,62,63],10,0,11),t.addMany(s(32,48),10,9,12),t.addMany(i,12,0,12),t.add(127,12,0,12),t.addMany(s(28,32),12,0,12),t.addMany(s(32,48),12,9,12),t.addMany(s(48,64),12,0,11),t.addMany(s(64,127),12,12,13),t.addMany(s(64,127),10,12,13),t.addMany(s(64,127),9,12,13),t.addMany(i,13,13,13),t.addMany(n,13,13,13),t.add(127,13,0,13),t.addMany([27,156,24,26],13,14,0),t.add(qs,0,2,0),t.add(qs,8,5,8),t.add(qs,6,0,6),t.add(qs,11,0,11),t.add(qs,13,13,13),t})(),ZF=class extends tt{constructor(t=QF){super(),this._transitions=t,this._parseStack={state:0,handlers:[],handlerPos:0,transition:0,chunkPos:0},this.initialState=0,this.currentState=this.initialState,this._params=new E5,this._params.addParam(0),this._collect=0,this.precedingJoinState=0,this._printHandlerFb=(e,s,n)=>{},this._executeHandlerFb=e=>{},this._csiHandlerFb=(e,s)=>{},this._escHandlerFb=e=>{},this._errorHandlerFb=e=>e,this._printHandler=this._printHandlerFb,this._executeHandlers=Object.create(null),this._csiHandlers=Object.create(null),this._escHandlers=Object.create(null),this._register(Lt(()=>{this._csiHandlers=Object.create(null),this._executeHandlers=Object.create(null),this._escHandlers=Object.create(null)})),this._oscParser=this._register(new YF),this._dcsParser=this._register(new JF),this._errorHandler=this._errorHandlerFb,this.registerEscHandler({final:"\\"},()=>!0)}_identifier(t,e=[64,126]){let s=0;if(t.prefix){if(t.prefix.length>1)throw new Error("only one byte as prefix supported");if(s=t.prefix.charCodeAt(0),s&&60>s||s>63)throw new Error("prefix must be in range 0x3c .. 0x3f")}if(t.intermediates){if(t.intermediates.length>2)throw new Error("only two bytes as intermediates are supported");for(let i=0;i<t.intermediates.length;++i){let o=t.intermediates.charCodeAt(i);if(32>o||o>47)throw new Error("intermediate must be in range 0x20 .. 0x2f");s<<=8,s|=o}}if(t.final.length!==1)throw new Error("final must be a single byte");let n=t.final.charCodeAt(0);if(e[0]>n||n>e[1])throw new Error(`final must be in range ${e[0]} .. ${e[1]}`);return s<<=8,s|=n,s}identToString(t){let e=[];for(;t;)e.push(String.fromCharCode(t&255)),t>>=8;return e.reverse().join("")}setPrintHandler(t){this._printHandler=t}clearPrintHandler(){this._printHandler=this._printHandlerFb}registerEscHandler(t,e){let s=this._identifier(t,[48,126]);this._escHandlers[s]===void 0&&(this._escHandlers[s]=[]);let n=this._escHandlers[s];return n.push(e),{dispose:()=>{let i=n.indexOf(e);i!==-1&&n.splice(i,1)}}}clearEscHandler(t){this._escHandlers[this._identifier(t,[48,126])]&&delete this._escHandlers[this._identifier(t,[48,126])]}setEscHandlerFallback(t){this._escHandlerFb=t}setExecuteHandler(t,e){this._executeHandlers[t.charCodeAt(0)]=e}clearExecuteHandler(t){this._executeHandlers[t.charCodeAt(0)]&&delete this._executeHandlers[t.charCodeAt(0)]}setExecuteHandlerFallback(t){this._executeHandlerFb=t}registerCsiHandler(t,e){let s=this._identifier(t);this._csiHandlers[s]===void 0&&(this._csiHandlers[s]=[]);let n=this._csiHandlers[s];return n.push(e),{dispose:()=>{let i=n.indexOf(e);i!==-1&&n.splice(i,1)}}}clearCsiHandler(t){this._csiHandlers[this._identifier(t)]&&delete this._csiHandlers[this._identifier(t)]}setCsiHandlerFallback(t){this._csiHandlerFb=t}registerDcsHandler(t,e){return this._dcsParser.registerHandler(this._identifier(t),e)}clearDcsHandler(t){this._dcsParser.clearHandler(this._identifier(t))}setDcsHandlerFallback(t){this._dcsParser.setHandlerFallback(t)}registerOscHandler(t,e){return this._oscParser.registerHandler(t,e)}clearOscHandler(t){this._oscParser.clearHandler(t)}setOscHandlerFallback(t){this._oscParser.setHandlerFallback(t)}setErrorHandler(t){this._errorHandler=t}clearErrorHandler(){this._errorHandler=this._errorHandlerFb}reset(){this.currentState=this.initialState,this._oscParser.reset(),this._dcsParser.reset(),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0,this._parseStack.state!==0&&(this._parseStack.state=2,this._parseStack.handlers=[])}_preserveStack(t,e,s,n,i){this._parseStack.state=t,this._parseStack.handlers=e,this._parseStack.handlerPos=s,this._parseStack.transition=n,this._parseStack.chunkPos=i}parse(t,e,s){let n=0,i=0,o=0,a;if(this._parseStack.state)if(this._parseStack.state===2)this._parseStack.state=0,o=this._parseStack.chunkPos+1;else{if(s===void 0||this._parseStack.state===1)throw this._parseStack.state=1,new Error("improper continuation due to previous async handler, giving up parsing");let l=this._parseStack.handlers,c=this._parseStack.handlerPos-1;switch(this._parseStack.state){case 3:if(s===!1&&c>-1){for(;c>=0&&(a=l[c](this._params),a!==!0);c--)if(a instanceof Promise)return this._parseStack.handlerPos=c,a}this._parseStack.handlers=[];break;case 4:if(s===!1&&c>-1){for(;c>=0&&(a=l[c](),a!==!0);c--)if(a instanceof Promise)return this._parseStack.handlerPos=c,a}this._parseStack.handlers=[];break;case 6:if(n=t[this._parseStack.chunkPos],a=this._dcsParser.unhook(n!==24&&n!==26,s),a)return a;n===27&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0;break;case 5:if(n=t[this._parseStack.chunkPos],a=this._oscParser.end(n!==24&&n!==26,s),a)return a;n===27&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0;break}this._parseStack.state=0,o=this._parseStack.chunkPos+1,this.precedingJoinState=0,this.currentState=this._parseStack.transition&15}for(let l=o;l<e;++l){switch(n=t[l],i=this._transitions.table[this.currentState<<8|(n<160?n:qs)],i>>4){case 2:for(let f=l+1;;++f){if(f>=e||(n=t[f])<32||n>126&&n<qs){this._printHandler(t,l,f),l=f-1;break}if(++f>=e||(n=t[f])<32||n>126&&n<qs){this._printHandler(t,l,f),l=f-1;break}if(++f>=e||(n=t[f])<32||n>126&&n<qs){this._printHandler(t,l,f),l=f-1;break}if(++f>=e||(n=t[f])<32||n>126&&n<qs){this._printHandler(t,l,f),l=f-1;break}}break;case 3:this._executeHandlers[n]?this._executeHandlers[n]():this._executeHandlerFb(n),this.precedingJoinState=0;break;case 0:break;case 1:if(this._errorHandler({position:l,code:n,currentState:this.currentState,collect:this._collect,params:this._params,abort:!1}).abort)return;break;case 7:let c=this._csiHandlers[this._collect<<8|n],d=c?c.length-1:-1;for(;d>=0&&(a=c[d](this._params),a!==!0);d--)if(a instanceof Promise)return this._preserveStack(3,c,d,i,l),a;d<0&&this._csiHandlerFb(this._collect<<8|n,this._params),this.precedingJoinState=0;break;case 8:do switch(n){case 59:this._params.addParam(0);break;case 58:this._params.addSubParam(-1);break;default:this._params.addDigit(n-48)}while(++l<e&&(n=t[l])>47&&n<60);l--;break;case 9:this._collect<<=8,this._collect|=n;break;case 10:let h=this._escHandlers[this._collect<<8|n],u=h?h.length-1:-1;for(;u>=0&&(a=h[u](),a!==!0);u--)if(a instanceof Promise)return this._preserveStack(4,h,u,i,l),a;u<0&&this._escHandlerFb(this._collect<<8|n),this.precedingJoinState=0;break;case 11:this._params.reset(),this._params.addParam(0),this._collect=0;break;case 12:this._dcsParser.hook(this._collect<<8|n,this._params);break;case 13:for(let f=l+1;;++f)if(f>=e||(n=t[f])===24||n===26||n===27||n>127&&n<qs){this._dcsParser.put(t,l,f),l=f-1;break}break;case 14:if(a=this._dcsParser.unhook(n!==24&&n!==26),a)return this._preserveStack(6,[],0,i,l),a;n===27&&(i|=1),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0;break;case 4:this._oscParser.start();break;case 5:for(let f=l+1;;f++)if(f>=e||(n=t[f])<32||n>127&&n<qs){this._oscParser.put(t,l,f),l=f-1;break}break;case 6:if(a=this._oscParser.end(n!==24&&n!==26),a)return this._preserveStack(5,[],0,i,l),a;n===27&&(i|=1),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0;break}this.currentState=i&15}}},ez=/^([\da-f])\/([\da-f])\/([\da-f])$|^([\da-f]{2})\/([\da-f]{2})\/([\da-f]{2})$|^([\da-f]{3})\/([\da-f]{3})\/([\da-f]{3})$|^([\da-f]{4})\/([\da-f]{4})\/([\da-f]{4})$/,tz=/^[\da-f]+$/;function J1(t){if(!t)return;let e=t.toLowerCase();if(e.indexOf("rgb:")===0){e=e.slice(4);let s=ez.exec(e);if(s){let n=s[1]?15:s[4]?255:s[7]?4095:65535;return[Math.round(parseInt(s[1]||s[4]||s[7]||s[10],16)/n*255),Math.round(parseInt(s[2]||s[5]||s[8]||s[11],16)/n*255),Math.round(parseInt(s[3]||s[6]||s[9]||s[12],16)/n*255)]}}else if(e.indexOf("#")===0&&(e=e.slice(1),tz.exec(e)&&[3,6,9,12].includes(e.length))){let s=e.length/3,n=[0,0,0];for(let i=0;i<3;++i){let o=parseInt(e.slice(s*i,s*i+s),16);n[i]=s===1?o<<4:s===2?o:s===3?o>>4:o>>8}return n}}function Vd(t,e){let s=t.toString(16),n=s.length<2?"0"+s:s;switch(e){case 4:return s[0];case 8:return n;case 12:return(n+n).slice(0,3);default:return n+n}}function sz(t,e=16){let[s,n,i]=t;return`rgb:${Vd(s,e)}/${Vd(n,e)}/${Vd(i,e)}`}var nz={"(":0,")":1,"*":2,"+":3,"-":1,".":2},zn=131072,X1=10;function Q1(t,e){if(t>24)return e.setWinLines||!1;switch(t){case 1:return!!e.restoreWin;case 2:return!!e.minimizeWin;case 3:return!!e.setWinPosition;case 4:return!!e.setWinSizePixels;case 5:return!!e.raiseWin;case 6:return!!e.lowerWin;case 7:return!!e.refreshWin;case 8:return!!e.setWinSizeChars;case 9:return!!e.maximizeWin;case 10:return!!e.fullscreenWin;case 11:return!!e.getWinState;case 13:return!!e.getWinPosition;case 14:return!!e.getWinSizePixels;case 15:return!!e.getScreenSizePixels;case 16:return!!e.getCellSizePixels;case 18:return!!e.getWinSizeChars;case 19:return!!e.getScreenSizeChars;case 20:return!!e.getIconTitle;case 21:return!!e.getWinTitle;case 22:return!!e.pushTitle;case 23:return!!e.popTitle;case 24:return!!e.setWinLines}return!1}var Z1=5e3,em=0,iz=class extends tt{constructor(t,e,s,n,i,o,a,l,c=new ZF){super(),this._bufferService=t,this._charsetService=e,this._coreService=s,this._logService=n,this._optionsService=i,this._oscLinkService=o,this._coreMouseService=a,this._unicodeService=l,this._parser=c,this._parseBuffer=new Uint32Array(4096),this._stringDecoder=new S$,this._utf8Decoder=new w$,this._windowTitle="",this._iconName="",this._windowTitleStack=[],this._iconNameStack=[],this._curAttrData=Dt.clone(),this._eraseAttrDataInternal=Dt.clone(),this._onRequestBell=this._register(new Te),this.onRequestBell=this._onRequestBell.event,this._onRequestRefreshRows=this._register(new Te),this.onRequestRefreshRows=this._onRequestRefreshRows.event,this._onRequestReset=this._register(new Te),this.onRequestReset=this._onRequestReset.event,this._onRequestSendFocus=this._register(new Te),this.onRequestSendFocus=this._onRequestSendFocus.event,this._onRequestSyncScrollBar=this._register(new Te),this.onRequestSyncScrollBar=this._onRequestSyncScrollBar.event,this._onRequestWindowsOptionsReport=this._register(new Te),this.onRequestWindowsOptionsReport=this._onRequestWindowsOptionsReport.event,this._onA11yChar=this._register(new Te),this.onA11yChar=this._onA11yChar.event,this._onA11yTab=this._register(new Te),this.onA11yTab=this._onA11yTab.event,this._onCursorMove=this._register(new Te),this.onCursorMove=this._onCursorMove.event,this._onLineFeed=this._register(new Te),this.onLineFeed=this._onLineFeed.event,this._onScroll=this._register(new Te),this.onScroll=this._onScroll.event,this._onTitleChange=this._register(new Te),this.onTitleChange=this._onTitleChange.event,this._onColor=this._register(new Te),this.onColor=this._onColor.event,this._parseStack={paused:!1,cursorStartX:0,cursorStartY:0,decodedLength:0,position:0},this._specialColors=[256,257,258],this._register(this._parser),this._dirtyRowTracker=new B0(this._bufferService),this._activeBuffer=this._bufferService.buffer,this._register(this._bufferService.buffers.onBufferActivate(d=>this._activeBuffer=d.activeBuffer)),this._parser.setCsiHandlerFallback((d,h)=>{this._logService.debug("Unknown CSI code: ",{identifier:this._parser.identToString(d),params:h.toArray()})}),this._parser.setEscHandlerFallback(d=>{this._logService.debug("Unknown ESC code: ",{identifier:this._parser.identToString(d)})}),this._parser.setExecuteHandlerFallback(d=>{this._logService.debug("Unknown EXECUTE code: ",{code:d})}),this._parser.setOscHandlerFallback((d,h,u)=>{this._logService.debug("Unknown OSC code: ",{identifier:d,action:h,data:u})}),this._parser.setDcsHandlerFallback((d,h,u)=>{h==="HOOK"&&(u=u.toArray()),this._logService.debug("Unknown DCS code: ",{identifier:this._parser.identToString(d),action:h,payload:u})}),this._parser.setPrintHandler((d,h,u)=>this.print(d,h,u)),this._parser.registerCsiHandler({final:"@"},d=>this.insertChars(d)),this._parser.registerCsiHandler({intermediates:" ",final:"@"},d=>this.scrollLeft(d)),this._parser.registerCsiHandler({final:"A"},d=>this.cursorUp(d)),this._parser.registerCsiHandler({intermediates:" ",final:"A"},d=>this.scrollRight(d)),this._parser.registerCsiHandler({final:"B"},d=>this.cursorDown(d)),this._parser.registerCsiHandler({final:"C"},d=>this.cursorForward(d)),this._parser.registerCsiHandler({final:"D"},d=>this.cursorBackward(d)),this._parser.registerCsiHandler({final:"E"},d=>this.cursorNextLine(d)),this._parser.registerCsiHandler({final:"F"},d=>this.cursorPrecedingLine(d)),this._parser.registerCsiHandler({final:"G"},d=>this.cursorCharAbsolute(d)),this._parser.registerCsiHandler({final:"H"},d=>this.cursorPosition(d)),this._parser.registerCsiHandler({final:"I"},d=>this.cursorForwardTab(d)),this._parser.registerCsiHandler({final:"J"},d=>this.eraseInDisplay(d,!1)),this._parser.registerCsiHandler({prefix:"?",final:"J"},d=>this.eraseInDisplay(d,!0)),this._parser.registerCsiHandler({final:"K"},d=>this.eraseInLine(d,!1)),this._parser.registerCsiHandler({prefix:"?",final:"K"},d=>this.eraseInLine(d,!0)),this._parser.registerCsiHandler({final:"L"},d=>this.insertLines(d)),this._parser.registerCsiHandler({final:"M"},d=>this.deleteLines(d)),this._parser.registerCsiHandler({final:"P"},d=>this.deleteChars(d)),this._parser.registerCsiHandler({final:"S"},d=>this.scrollUp(d)),this._parser.registerCsiHandler({final:"T"},d=>this.scrollDown(d)),this._parser.registerCsiHandler({final:"X"},d=>this.eraseChars(d)),this._parser.registerCsiHandler({final:"Z"},d=>this.cursorBackwardTab(d)),this._parser.registerCsiHandler({final:"`"},d=>this.charPosAbsolute(d)),this._parser.registerCsiHandler({final:"a"},d=>this.hPositionRelative(d)),this._parser.registerCsiHandler({final:"b"},d=>this.repeatPrecedingCharacter(d)),this._parser.registerCsiHandler({final:"c"},d=>this.sendDeviceAttributesPrimary(d)),this._parser.registerCsiHandler({prefix:">",final:"c"},d=>this.sendDeviceAttributesSecondary(d)),this._parser.registerCsiHandler({final:"d"},d=>this.linePosAbsolute(d)),this._parser.registerCsiHandler({final:"e"},d=>this.vPositionRelative(d)),this._parser.registerCsiHandler({final:"f"},d=>this.hVPosition(d)),this._parser.registerCsiHandler({final:"g"},d=>this.tabClear(d)),this._parser.registerCsiHandler({final:"h"},d=>this.setMode(d)),this._parser.registerCsiHandler({prefix:"?",final:"h"},d=>this.setModePrivate(d)),this._parser.registerCsiHandler({final:"l"},d=>this.resetMode(d)),this._parser.registerCsiHandler({prefix:"?",final:"l"},d=>this.resetModePrivate(d)),this._parser.registerCsiHandler({final:"m"},d=>this.charAttributes(d)),this._parser.registerCsiHandler({final:"n"},d=>this.deviceStatus(d)),this._parser.registerCsiHandler({prefix:"?",final:"n"},d=>this.deviceStatusPrivate(d)),this._parser.registerCsiHandler({intermediates:"!",final:"p"},d=>this.softReset(d)),this._parser.registerCsiHandler({intermediates:" ",final:"q"},d=>this.setCursorStyle(d)),this._parser.registerCsiHandler({final:"r"},d=>this.setScrollRegion(d)),this._parser.registerCsiHandler({final:"s"},d=>this.saveCursor(d)),this._parser.registerCsiHandler({final:"t"},d=>this.windowOptions(d)),this._parser.registerCsiHandler({final:"u"},d=>this.restoreCursor(d)),this._parser.registerCsiHandler({intermediates:"'",final:"}"},d=>this.insertColumns(d)),this._parser.registerCsiHandler({intermediates:"'",final:"~"},d=>this.deleteColumns(d)),this._parser.registerCsiHandler({intermediates:'"',final:"q"},d=>this.selectProtected(d)),this._parser.registerCsiHandler({intermediates:"$",final:"p"},d=>this.requestMode(d,!0)),this._parser.registerCsiHandler({prefix:"?",intermediates:"$",final:"p"},d=>this.requestMode(d,!1)),this._parser.setExecuteHandler(_e.BEL,()=>this.bell()),this._parser.setExecuteHandler(_e.LF,()=>this.lineFeed()),this._parser.setExecuteHandler(_e.VT,()=>this.lineFeed()),this._parser.setExecuteHandler(_e.FF,()=>this.lineFeed()),this._parser.setExecuteHandler(_e.CR,()=>this.carriageReturn()),this._parser.setExecuteHandler(_e.BS,()=>this.backspace()),this._parser.setExecuteHandler(_e.HT,()=>this.tab()),this._parser.setExecuteHandler(_e.SO,()=>this.shiftOut()),this._parser.setExecuteHandler(_e.SI,()=>this.shiftIn()),this._parser.setExecuteHandler(Za.IND,()=>this.index()),this._parser.setExecuteHandler(Za.NEL,()=>this.nextLine()),this._parser.setExecuteHandler(Za.HTS,()=>this.tabSet()),this._parser.registerOscHandler(0,new Ds(d=>(this.setTitle(d),this.setIconName(d),!0))),this._parser.registerOscHandler(1,new Ds(d=>this.setIconName(d))),this._parser.registerOscHandler(2,new Ds(d=>this.setTitle(d))),this._parser.registerOscHandler(4,new Ds(d=>this.setOrReportIndexedColor(d))),this._parser.registerOscHandler(8,new Ds(d=>this.setHyperlink(d))),this._parser.registerOscHandler(10,new Ds(d=>this.setOrReportFgColor(d))),this._parser.registerOscHandler(11,new Ds(d=>this.setOrReportBgColor(d))),this._parser.registerOscHandler(12,new Ds(d=>this.setOrReportCursorColor(d))),this._parser.registerOscHandler(104,new Ds(d=>this.restoreIndexedColor(d))),this._parser.registerOscHandler(110,new Ds(d=>this.restoreFgColor(d))),this._parser.registerOscHandler(111,new Ds(d=>this.restoreBgColor(d))),this._parser.registerOscHandler(112,new Ds(d=>this.restoreCursorColor(d))),this._parser.registerEscHandler({final:"7"},()=>this.saveCursor()),this._parser.registerEscHandler({final:"8"},()=>this.restoreCursor()),this._parser.registerEscHandler({final:"D"},()=>this.index()),this._parser.registerEscHandler({final:"E"},()=>this.nextLine()),this._parser.registerEscHandler({final:"H"},()=>this.tabSet()),this._parser.registerEscHandler({final:"M"},()=>this.reverseIndex()),this._parser.registerEscHandler({final:"="},()=>this.keypadApplicationMode()),this._parser.registerEscHandler({final:">"},()=>this.keypadNumericMode()),this._parser.registerEscHandler({final:"c"},()=>this.fullReset()),this._parser.registerEscHandler({final:"n"},()=>this.setgLevel(2)),this._parser.registerEscHandler({final:"o"},()=>this.setgLevel(3)),this._parser.registerEscHandler({final:"|"},()=>this.setgLevel(3)),this._parser.registerEscHandler({final:"}"},()=>this.setgLevel(2)),this._parser.registerEscHandler({final:"~"},()=>this.setgLevel(1)),this._parser.registerEscHandler({intermediates:"%",final:"@"},()=>this.selectDefaultCharset()),this._parser.registerEscHandler({intermediates:"%",final:"G"},()=>this.selectDefaultCharset());for(let d in Kt)this._parser.registerEscHandler({intermediates:"(",final:d},()=>this.selectCharset("("+d)),this._parser.registerEscHandler({intermediates:")",final:d},()=>this.selectCharset(")"+d)),this._parser.registerEscHandler({intermediates:"*",final:d},()=>this.selectCharset("*"+d)),this._parser.registerEscHandler({intermediates:"+",final:d},()=>this.selectCharset("+"+d)),this._parser.registerEscHandler({intermediates:"-",final:d},()=>this.selectCharset("-"+d)),this._parser.registerEscHandler({intermediates:".",final:d},()=>this.selectCharset("."+d)),this._parser.registerEscHandler({intermediates:"/",final:d},()=>this.selectCharset("/"+d));this._parser.registerEscHandler({intermediates:"#",final:"8"},()=>this.screenAlignmentPattern()),this._parser.setErrorHandler(d=>(this._logService.error("Parsing error: ",d),d)),this._parser.registerDcsHandler({intermediates:"$",final:"q"},new Y1((d,h)=>this.requestStatusString(d,h)))}getAttrData(){return this._curAttrData}_preserveStack(t,e,s,n){this._parseStack.paused=!0,this._parseStack.cursorStartX=t,this._parseStack.cursorStartY=e,this._parseStack.decodedLength=s,this._parseStack.position=n}_logSlowResolvingAsync(t){this._logService.logLevel<=3&&Promise.race([t,new Promise((e,s)=>setTimeout(()=>s("#SLOW_TIMEOUT"),Z1))]).catch(e=>{if(e!=="#SLOW_TIMEOUT")throw e;console.warn(`async parser handler taking longer than ${Z1} ms`)})}_getCurrentLinkId(){return this._curAttrData.extended.urlId}parse(t,e){let s,n=this._activeBuffer.x,i=this._activeBuffer.y,o=0,a=this._parseStack.paused;if(a){if(s=this._parser.parse(this._parseBuffer,this._parseStack.decodedLength,e))return this._logSlowResolvingAsync(s),s;n=this._parseStack.cursorStartX,i=this._parseStack.cursorStartY,this._parseStack.paused=!1,t.length>zn&&(o=this._parseStack.position+zn)}if(this._logService.logLevel<=1&&this._logService.debug(`parsing data ${typeof t=="string"?` "${t}"`:` "${Array.prototype.map.call(t,d=>String.fromCharCode(d)).join("")}"`}`),this._logService.logLevel===0&&this._logService.trace("parsing data (codes)",typeof t=="string"?t.split("").map(d=>d.charCodeAt(0)):t),this._parseBuffer.length<t.length&&this._parseBuffer.length<zn&&(this._parseBuffer=new Uint32Array(Math.min(t.length,zn))),a||this._dirtyRowTracker.clearRange(),t.length>zn)for(let d=o;d<t.length;d+=zn){let h=d+zn<t.length?d+zn:t.length,u=typeof t=="string"?this._stringDecoder.decode(t.substring(d,h),this._parseBuffer):this._utf8Decoder.decode(t.subarray(d,h),this._parseBuffer);if(s=this._parser.parse(this._parseBuffer,u))return this._preserveStack(n,i,u,d),this._logSlowResolvingAsync(s),s}else if(!a){let d=typeof t=="string"?this._stringDecoder.decode(t,this._parseBuffer):this._utf8Decoder.decode(t,this._parseBuffer);if(s=this._parser.parse(this._parseBuffer,d))return this._preserveStack(n,i,d,0),this._logSlowResolvingAsync(s),s}(this._activeBuffer.x!==n||this._activeBuffer.y!==i)&&this._onCursorMove.fire();let l=this._dirtyRowTracker.end+(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp),c=this._dirtyRowTracker.start+(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp);c<this._bufferService.rows&&this._onRequestRefreshRows.fire({start:Math.min(c,this._bufferService.rows-1),end:Math.min(l,this._bufferService.rows-1)})}print(t,e,s){let n,i,o=this._charsetService.charset,a=this._optionsService.rawOptions.screenReaderMode,l=this._bufferService.cols,c=this._coreService.decPrivateModes.wraparound,d=this._coreService.modes.insertMode,h=this._curAttrData,u=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._activeBuffer.x&&s-e>0&&u.getWidth(this._activeBuffer.x-1)===2&&u.setCellFromCodepoint(this._activeBuffer.x-1,0,1,h);let f=this._parser.precedingJoinState;for(let m=e;m<s;++m){if(n=t[m],n<127&&o){let v=o[String.fromCharCode(n)];v&&(n=v.charCodeAt(0))}let p=this._unicodeService.charProperties(n,f);i=bi.extractWidth(p);let g=bi.extractShouldJoin(p),x=g?bi.extractWidth(f):0;if(f=p,a&&this._onA11yChar.fire(Un(n)),this._getCurrentLinkId()&&this._oscLinkService.addLineToLink(this._getCurrentLinkId(),this._activeBuffer.ybase+this._activeBuffer.y),this._activeBuffer.x+i-x>l){if(c){let v=u,b=this._activeBuffer.x-x;for(this._activeBuffer.x=x,this._activeBuffer.y++,this._activeBuffer.y===this._activeBuffer.scrollBottom+1?(this._activeBuffer.y--,this._bufferService.scroll(this._eraseAttrData(),!0)):(this._activeBuffer.y>=this._bufferService.rows&&(this._activeBuffer.y=this._bufferService.rows-1),this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!0),u=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y),x>0&&u instanceof po&&u.copyCellsFrom(v,b,0,x,!1);b<l;)v.setCellFromCodepoint(b++,0,1,h)}else if(this._activeBuffer.x=l-1,i===2)continue}if(g&&this._activeBuffer.x){let v=u.getWidth(this._activeBuffer.x-1)?1:2;u.addCodepointToCell(this._activeBuffer.x-v,n,i);for(let b=i-x;--b>=0;)u.setCellFromCodepoint(this._activeBuffer.x++,0,0,h);continue}if(d&&(u.insertCells(this._activeBuffer.x,i-x,this._activeBuffer.getNullCell(h)),u.getWidth(l-1)===2&&u.setCellFromCodepoint(l-1,0,1,h)),u.setCellFromCodepoint(this._activeBuffer.x++,n,i,h),i>0)for(;--i;)u.setCellFromCodepoint(this._activeBuffer.x++,0,0,h)}this._parser.precedingJoinState=f,this._activeBuffer.x<l&&s-e>0&&u.getWidth(this._activeBuffer.x)===0&&!u.hasContent(this._activeBuffer.x)&&u.setCellFromCodepoint(this._activeBuffer.x,0,1,h),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}registerCsiHandler(t,e){return t.final==="t"&&!t.prefix&&!t.intermediates?this._parser.registerCsiHandler(t,s=>Q1(s.params[0],this._optionsService.rawOptions.windowOptions)?e(s):!0):this._parser.registerCsiHandler(t,e)}registerDcsHandler(t,e){return this._parser.registerDcsHandler(t,new Y1(e))}registerEscHandler(t,e){return this._parser.registerEscHandler(t,e)}registerOscHandler(t,e){return this._parser.registerOscHandler(t,new Ds(e))}bell(){return this._onRequestBell.fire(),!0}lineFeed(){return this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._optionsService.rawOptions.convertEol&&(this._activeBuffer.x=0),this._activeBuffer.y++,this._activeBuffer.y===this._activeBuffer.scrollBottom+1?(this._activeBuffer.y--,this._bufferService.scroll(this._eraseAttrData())):this._activeBuffer.y>=this._bufferService.rows?this._activeBuffer.y=this._bufferService.rows-1:this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!1,this._activeBuffer.x>=this._bufferService.cols&&this._activeBuffer.x--,this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._onLineFeed.fire(),!0}carriageReturn(){return this._activeBuffer.x=0,!0}backspace(){if(!this._coreService.decPrivateModes.reverseWraparound)return this._restrictCursor(),this._activeBuffer.x>0&&this._activeBuffer.x--,!0;if(this._restrictCursor(this._bufferService.cols),this._activeBuffer.x>0)this._activeBuffer.x--;else if(this._activeBuffer.x===0&&this._activeBuffer.y>this._activeBuffer.scrollTop&&this._activeBuffer.y<=this._activeBuffer.scrollBottom&&this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y)?.isWrapped){this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!1,this._activeBuffer.y--,this._activeBuffer.x=this._bufferService.cols-1;let t=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);t.hasWidth(this._activeBuffer.x)&&!t.hasContent(this._activeBuffer.x)&&this._activeBuffer.x--}return this._restrictCursor(),!0}tab(){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let t=this._activeBuffer.x;return this._activeBuffer.x=this._activeBuffer.nextStop(),this._optionsService.rawOptions.screenReaderMode&&this._onA11yTab.fire(this._activeBuffer.x-t),!0}shiftOut(){return this._charsetService.setgLevel(1),!0}shiftIn(){return this._charsetService.setgLevel(0),!0}_restrictCursor(t=this._bufferService.cols-1){this._activeBuffer.x=Math.min(t,Math.max(0,this._activeBuffer.x)),this._activeBuffer.y=this._coreService.decPrivateModes.origin?Math.min(this._activeBuffer.scrollBottom,Math.max(this._activeBuffer.scrollTop,this._activeBuffer.y)):Math.min(this._bufferService.rows-1,Math.max(0,this._activeBuffer.y)),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}_setCursor(t,e){this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._coreService.decPrivateModes.origin?(this._activeBuffer.x=t,this._activeBuffer.y=this._activeBuffer.scrollTop+e):(this._activeBuffer.x=t,this._activeBuffer.y=e),this._restrictCursor(),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}_moveCursor(t,e){this._restrictCursor(),this._setCursor(this._activeBuffer.x+t,this._activeBuffer.y+e)}cursorUp(t){let e=this._activeBuffer.y-this._activeBuffer.scrollTop;return e>=0?this._moveCursor(0,-Math.min(e,t.params[0]||1)):this._moveCursor(0,-(t.params[0]||1)),!0}cursorDown(t){let e=this._activeBuffer.scrollBottom-this._activeBuffer.y;return e>=0?this._moveCursor(0,Math.min(e,t.params[0]||1)):this._moveCursor(0,t.params[0]||1),!0}cursorForward(t){return this._moveCursor(t.params[0]||1,0),!0}cursorBackward(t){return this._moveCursor(-(t.params[0]||1),0),!0}cursorNextLine(t){return this.cursorDown(t),this._activeBuffer.x=0,!0}cursorPrecedingLine(t){return this.cursorUp(t),this._activeBuffer.x=0,!0}cursorCharAbsolute(t){return this._setCursor((t.params[0]||1)-1,this._activeBuffer.y),!0}cursorPosition(t){return this._setCursor(t.length>=2?(t.params[1]||1)-1:0,(t.params[0]||1)-1),!0}charPosAbsolute(t){return this._setCursor((t.params[0]||1)-1,this._activeBuffer.y),!0}hPositionRelative(t){return this._moveCursor(t.params[0]||1,0),!0}linePosAbsolute(t){return this._setCursor(this._activeBuffer.x,(t.params[0]||1)-1),!0}vPositionRelative(t){return this._moveCursor(0,t.params[0]||1),!0}hVPosition(t){return this.cursorPosition(t),!0}tabClear(t){let e=t.params[0];return e===0?delete this._activeBuffer.tabs[this._activeBuffer.x]:e===3&&(this._activeBuffer.tabs={}),!0}cursorForwardTab(t){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let e=t.params[0]||1;for(;e--;)this._activeBuffer.x=this._activeBuffer.nextStop();return!0}cursorBackwardTab(t){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let e=t.params[0]||1;for(;e--;)this._activeBuffer.x=this._activeBuffer.prevStop();return!0}selectProtected(t){let e=t.params[0];return e===1&&(this._curAttrData.bg|=536870912),(e===2||e===0)&&(this._curAttrData.bg&=-536870913),!0}_eraseInBufferLine(t,e,s,n=!1,i=!1){let o=this._activeBuffer.lines.get(this._activeBuffer.ybase+t);o.replaceCells(e,s,this._activeBuffer.getNullCell(this._eraseAttrData()),i),n&&(o.isWrapped=!1)}_resetBufferLine(t,e=!1){let s=this._activeBuffer.lines.get(this._activeBuffer.ybase+t);s&&(s.fill(this._activeBuffer.getNullCell(this._eraseAttrData()),e),this._bufferService.buffer.clearMarkers(this._activeBuffer.ybase+t),s.isWrapped=!1)}eraseInDisplay(t,e=!1){this._restrictCursor(this._bufferService.cols);let s;switch(t.params[0]){case 0:for(s=this._activeBuffer.y,this._dirtyRowTracker.markDirty(s),this._eraseInBufferLine(s++,this._activeBuffer.x,this._bufferService.cols,this._activeBuffer.x===0,e);s<this._bufferService.rows;s++)this._resetBufferLine(s,e);this._dirtyRowTracker.markDirty(s);break;case 1:for(s=this._activeBuffer.y,this._dirtyRowTracker.markDirty(s),this._eraseInBufferLine(s,0,this._activeBuffer.x+1,!0,e),this._activeBuffer.x+1>=this._bufferService.cols&&(this._activeBuffer.lines.get(s+1).isWrapped=!1);s--;)this._resetBufferLine(s,e);this._dirtyRowTracker.markDirty(0);break;case 2:if(this._optionsService.rawOptions.scrollOnEraseInDisplay){for(s=this._bufferService.rows,this._dirtyRowTracker.markRangeDirty(0,s-1);s--&&!this._activeBuffer.lines.get(this._activeBuffer.ybase+s)?.getTrimmedLength(););for(;s>=0;s--)this._bufferService.scroll(this._eraseAttrData())}else{for(s=this._bufferService.rows,this._dirtyRowTracker.markDirty(s-1);s--;)this._resetBufferLine(s,e);this._dirtyRowTracker.markDirty(0)}break;case 3:let n=this._activeBuffer.lines.length-this._bufferService.rows;n>0&&(this._activeBuffer.lines.trimStart(n),this._activeBuffer.ybase=Math.max(this._activeBuffer.ybase-n,0),this._activeBuffer.ydisp=Math.max(this._activeBuffer.ydisp-n,0),this._onScroll.fire(0));break}return!0}eraseInLine(t,e=!1){switch(this._restrictCursor(this._bufferService.cols),t.params[0]){case 0:this._eraseInBufferLine(this._activeBuffer.y,this._activeBuffer.x,this._bufferService.cols,this._activeBuffer.x===0,e);break;case 1:this._eraseInBufferLine(this._activeBuffer.y,0,this._activeBuffer.x+1,!1,e);break;case 2:this._eraseInBufferLine(this._activeBuffer.y,0,this._bufferService.cols,!0,e);break}return this._dirtyRowTracker.markDirty(this._activeBuffer.y),!0}insertLines(t){this._restrictCursor();let e=t.params[0]||1;if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let s=this._activeBuffer.ybase+this._activeBuffer.y,n=this._bufferService.rows-1-this._activeBuffer.scrollBottom,i=this._bufferService.rows-1+this._activeBuffer.ybase-n+1;for(;e--;)this._activeBuffer.lines.splice(i-1,1),this._activeBuffer.lines.splice(s,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.y,this._activeBuffer.scrollBottom),this._activeBuffer.x=0,!0}deleteLines(t){this._restrictCursor();let e=t.params[0]||1;if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let s=this._activeBuffer.ybase+this._activeBuffer.y,n;for(n=this._bufferService.rows-1-this._activeBuffer.scrollBottom,n=this._bufferService.rows-1+this._activeBuffer.ybase-n;e--;)this._activeBuffer.lines.splice(s,1),this._activeBuffer.lines.splice(n,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.y,this._activeBuffer.scrollBottom),this._activeBuffer.x=0,!0}insertChars(t){this._restrictCursor();let e=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return e&&(e.insertCells(this._activeBuffer.x,t.params[0]||1,this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}deleteChars(t){this._restrictCursor();let e=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return e&&(e.deleteCells(this._activeBuffer.x,t.params[0]||1,this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}scrollUp(t){let e=t.params[0]||1;for(;e--;)this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollTop,1),this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollBottom,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollDown(t){let e=t.params[0]||1;for(;e--;)this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollBottom,1),this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollTop,0,this._activeBuffer.getBlankLine(Dt));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollLeft(t){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let e=t.params[0]||1;for(let s=this._activeBuffer.scrollTop;s<=this._activeBuffer.scrollBottom;++s){let n=this._activeBuffer.lines.get(this._activeBuffer.ybase+s);n.deleteCells(0,e,this._activeBuffer.getNullCell(this._eraseAttrData())),n.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollRight(t){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let e=t.params[0]||1;for(let s=this._activeBuffer.scrollTop;s<=this._activeBuffer.scrollBottom;++s){let n=this._activeBuffer.lines.get(this._activeBuffer.ybase+s);n.insertCells(0,e,this._activeBuffer.getNullCell(this._eraseAttrData())),n.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}insertColumns(t){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let e=t.params[0]||1;for(let s=this._activeBuffer.scrollTop;s<=this._activeBuffer.scrollBottom;++s){let n=this._activeBuffer.lines.get(this._activeBuffer.ybase+s);n.insertCells(this._activeBuffer.x,e,this._activeBuffer.getNullCell(this._eraseAttrData())),n.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}deleteColumns(t){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let e=t.params[0]||1;for(let s=this._activeBuffer.scrollTop;s<=this._activeBuffer.scrollBottom;++s){let n=this._activeBuffer.lines.get(this._activeBuffer.ybase+s);n.deleteCells(this._activeBuffer.x,e,this._activeBuffer.getNullCell(this._eraseAttrData())),n.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}eraseChars(t){this._restrictCursor();let e=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return e&&(e.replaceCells(this._activeBuffer.x,this._activeBuffer.x+(t.params[0]||1),this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}repeatPrecedingCharacter(t){let e=this._parser.precedingJoinState;if(!e)return!0;let s=t.params[0]||1,n=bi.extractWidth(e),i=this._activeBuffer.x-n,o=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).getString(i),a=new Uint32Array(o.length*s),l=0;for(let d=0;d<o.length;){let h=o.codePointAt(d)||0;a[l++]=h,d+=h>65535?2:1}let c=l;for(let d=1;d<s;++d)a.copyWithin(c,0,l),c+=l;return this.print(a,0,c),!0}sendDeviceAttributesPrimary(t){return t.params[0]>0||(this._is("xterm")||this._is("rxvt-unicode")||this._is("screen")?this._coreService.triggerDataEvent(_e.ESC+"[?1;2c"):this._is("linux")&&this._coreService.triggerDataEvent(_e.ESC+"[?6c")),!0}sendDeviceAttributesSecondary(t){return t.params[0]>0||(this._is("xterm")?this._coreService.triggerDataEvent(_e.ESC+"[>0;276;0c"):this._is("rxvt-unicode")?this._coreService.triggerDataEvent(_e.ESC+"[>85;95;0c"):this._is("linux")?this._coreService.triggerDataEvent(t.params[0]+"c"):this._is("screen")&&this._coreService.triggerDataEvent(_e.ESC+"[>83;40003;0c")),!0}_is(t){return(this._optionsService.rawOptions.termName+"").indexOf(t)===0}setMode(t){for(let e=0;e<t.length;e++)switch(t.params[e]){case 4:this._coreService.modes.insertMode=!0;break;case 20:this._optionsService.options.convertEol=!0;break}return!0}setModePrivate(t){for(let e=0;e<t.length;e++)switch(t.params[e]){case 1:this._coreService.decPrivateModes.applicationCursorKeys=!0;break;case 2:this._charsetService.setgCharset(0,pi),this._charsetService.setgCharset(1,pi),this._charsetService.setgCharset(2,pi),this._charsetService.setgCharset(3,pi);break;case 3:this._optionsService.rawOptions.windowOptions.setWinLines&&(this._bufferService.resize(132,this._bufferService.rows),this._onRequestReset.fire());break;case 6:this._coreService.decPrivateModes.origin=!0,this._setCursor(0,0);break;case 7:this._coreService.decPrivateModes.wraparound=!0;break;case 12:this._optionsService.options.cursorBlink=!0;break;case 45:this._coreService.decPrivateModes.reverseWraparound=!0;break;case 66:this._logService.debug("Serial port requested application keypad."),this._coreService.decPrivateModes.applicationKeypad=!0,this._onRequestSyncScrollBar.fire();break;case 9:this._coreMouseService.activeProtocol="X10";break;case 1e3:this._coreMouseService.activeProtocol="VT200";break;case 1002:this._coreMouseService.activeProtocol="DRAG";break;case 1003:this._coreMouseService.activeProtocol="ANY";break;case 1004:this._coreService.decPrivateModes.sendFocus=!0,this._onRequestSendFocus.fire();break;case 1005:this._logService.debug("DECSET 1005 not supported (see #2507)");break;case 1006:this._coreMouseService.activeEncoding="SGR";break;case 1015:this._logService.debug("DECSET 1015 not supported (see #2507)");break;case 1016:this._coreMouseService.activeEncoding="SGR_PIXELS";break;case 25:this._coreService.isCursorHidden=!1;break;case 1048:this.saveCursor();break;case 1049:this.saveCursor();case 47:case 1047:this._bufferService.buffers.activateAltBuffer(this._eraseAttrData()),this._coreService.isCursorInitialized=!0,this._onRequestRefreshRows.fire(void 0),this._onRequestSyncScrollBar.fire();break;case 2004:this._coreService.decPrivateModes.bracketedPasteMode=!0;break;case 2026:this._coreService.decPrivateModes.synchronizedOutput=!0;break}return!0}resetMode(t){for(let e=0;e<t.length;e++)switch(t.params[e]){case 4:this._coreService.modes.insertMode=!1;break;case 20:this._optionsService.options.convertEol=!1;break}return!0}resetModePrivate(t){for(let e=0;e<t.length;e++)switch(t.params[e]){case 1:this._coreService.decPrivateModes.applicationCursorKeys=!1;break;case 3:this._optionsService.rawOptions.windowOptions.setWinLines&&(this._bufferService.resize(80,this._bufferService.rows),this._onRequestReset.fire());break;case 6:this._coreService.decPrivateModes.origin=!1,this._setCursor(0,0);break;case 7:this._coreService.decPrivateModes.wraparound=!1;break;case 12:this._optionsService.options.cursorBlink=!1;break;case 45:this._coreService.decPrivateModes.reverseWraparound=!1;break;case 66:this._logService.debug("Switching back to normal keypad."),this._coreService.decPrivateModes.applicationKeypad=!1,this._onRequestSyncScrollBar.fire();break;case 9:case 1e3:case 1002:case 1003:this._coreMouseService.activeProtocol="NONE";break;case 1004:this._coreService.decPrivateModes.sendFocus=!1;break;case 1005:this._logService.debug("DECRST 1005 not supported (see #2507)");break;case 1006:this._coreMouseService.activeEncoding="DEFAULT";break;case 1015:this._logService.debug("DECRST 1015 not supported (see #2507)");break;case 1016:this._coreMouseService.activeEncoding="DEFAULT";break;case 25:this._coreService.isCursorHidden=!0;break;case 1048:this.restoreCursor();break;case 1049:case 47:case 1047:this._bufferService.buffers.activateNormalBuffer(),t.params[e]===1049&&this.restoreCursor(),this._coreService.isCursorInitialized=!0,this._onRequestRefreshRows.fire(void 0),this._onRequestSyncScrollBar.fire();break;case 2004:this._coreService.decPrivateModes.bracketedPasteMode=!1;break;case 2026:this._coreService.decPrivateModes.synchronizedOutput=!1,this._onRequestRefreshRows.fire(void 0);break}return!0}requestMode(t,e){let s;(g=>(g[g.NOT_RECOGNIZED=0]="NOT_RECOGNIZED",g[g.SET=1]="SET",g[g.RESET=2]="RESET",g[g.PERMANENTLY_SET=3]="PERMANENTLY_SET",g[g.PERMANENTLY_RESET=4]="PERMANENTLY_RESET"))(s||={});let n=this._coreService.decPrivateModes,{activeProtocol:i,activeEncoding:o}=this._coreMouseService,a=this._coreService,{buffers:l,cols:c}=this._bufferService,{active:d,alt:h}=l,u=this._optionsService.rawOptions,f=(g,x)=>(a.triggerDataEvent(`${_e.ESC}[${e?"":"?"}${g};${x}$y`),!0),m=g=>g?1:2,p=t.params[0];return e?p===2?f(p,4):p===4?f(p,m(a.modes.insertMode)):p===12?f(p,3):p===20?f(p,m(u.convertEol)):f(p,0):p===1?f(p,m(n.applicationCursorKeys)):p===3?f(p,u.windowOptions.setWinLines?c===80?2:c===132?1:0:0):p===6?f(p,m(n.origin)):p===7?f(p,m(n.wraparound)):p===8?f(p,3):p===9?f(p,m(i==="X10")):p===12?f(p,m(u.cursorBlink)):p===25?f(p,m(!a.isCursorHidden)):p===45?f(p,m(n.reverseWraparound)):p===66?f(p,m(n.applicationKeypad)):p===67?f(p,4):p===1e3?f(p,m(i==="VT200")):p===1002?f(p,m(i==="DRAG")):p===1003?f(p,m(i==="ANY")):p===1004?f(p,m(n.sendFocus)):p===1005?f(p,4):p===1006?f(p,m(o==="SGR")):p===1015?f(p,4):p===1016?f(p,m(o==="SGR_PIXELS")):p===1048?f(p,1):p===47||p===1047||p===1049?f(p,m(d===h)):p===2004?f(p,m(n.bracketedPasteMode)):p===2026?f(p,m(n.synchronizedOutput)):f(p,0)}_updateAttrColor(t,e,s,n,i){return e===2?(t|=50331648,t&=-16777216,t|=pa.fromColorRGB([s,n,i])):e===5&&(t&=-50331904,t|=33554432|s&255),t}_extractColor(t,e,s){let n=[0,0,-1,0,0,0],i=0,o=0;do{if(n[o+i]=t.params[e+o],t.hasSubParams(e+o)){let a=t.getSubParams(e+o),l=0;do n[1]===5&&(i=1),n[o+l+1+i]=a[l];while(++l<a.length&&l+o+1+i<n.length);break}if(n[1]===5&&o+i>=2||n[1]===2&&o+i>=5)break;n[1]&&(i=1)}while(++o+e<t.length&&o+i<n.length);for(let a=2;a<n.length;++a)n[a]===-1&&(n[a]=0);switch(n[0]){case 38:s.fg=this._updateAttrColor(s.fg,n[1],n[3],n[4],n[5]);break;case 48:s.bg=this._updateAttrColor(s.bg,n[1],n[3],n[4],n[5]);break;case 58:s.extended=s.extended.clone(),s.extended.underlineColor=this._updateAttrColor(s.extended.underlineColor,n[1],n[3],n[4],n[5])}return o}_processUnderline(t,e){e.extended=e.extended.clone(),(!~t||t>5)&&(t=1),e.extended.underlineStyle=t,e.fg|=268435456,t===0&&(e.fg&=-268435457),e.updateExtended()}_processSGR0(t){t.fg=Dt.fg,t.bg=Dt.bg,t.extended=t.extended.clone(),t.extended.underlineStyle=0,t.extended.underlineColor&=-67108864,t.updateExtended()}charAttributes(t){if(t.length===1&&t.params[0]===0)return this._processSGR0(this._curAttrData),!0;let e=t.length,s,n=this._curAttrData;for(let i=0;i<e;i++)s=t.params[i],s>=30&&s<=37?(n.fg&=-50331904,n.fg|=16777216|s-30):s>=40&&s<=47?(n.bg&=-50331904,n.bg|=16777216|s-40):s>=90&&s<=97?(n.fg&=-50331904,n.fg|=16777216|s-90|8):s>=100&&s<=107?(n.bg&=-50331904,n.bg|=16777216|s-100|8):s===0?this._processSGR0(n):s===1?n.fg|=134217728:s===3?n.bg|=67108864:s===4?(n.fg|=268435456,this._processUnderline(t.hasSubParams(i)?t.getSubParams(i)[0]:1,n)):s===5?n.fg|=536870912:s===7?n.fg|=67108864:s===8?n.fg|=1073741824:s===9?n.fg|=2147483648:s===2?n.bg|=134217728:s===21?this._processUnderline(2,n):s===22?(n.fg&=-134217729,n.bg&=-134217729):s===23?n.bg&=-67108865:s===24?(n.fg&=-268435457,this._processUnderline(0,n)):s===25?n.fg&=-536870913:s===27?n.fg&=-67108865:s===28?n.fg&=-1073741825:s===29?n.fg&=2147483647:s===39?(n.fg&=-67108864,n.fg|=Dt.fg&16777215):s===49?(n.bg&=-67108864,n.bg|=Dt.bg&16777215):s===38||s===48||s===58?i+=this._extractColor(t,i,n):s===53?n.bg|=1073741824:s===55?n.bg&=-1073741825:s===59?(n.extended=n.extended.clone(),n.extended.underlineColor=-1,n.updateExtended()):s===100?(n.fg&=-67108864,n.fg|=Dt.fg&16777215,n.bg&=-67108864,n.bg|=Dt.bg&16777215):this._logService.debug("Unknown SGR attribute: %d.",s);return!0}deviceStatus(t){switch(t.params[0]){case 5:this._coreService.triggerDataEvent(`${_e.ESC}[0n`);break;case 6:let e=this._activeBuffer.y+1,s=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${_e.ESC}[${e};${s}R`);break}return!0}deviceStatusPrivate(t){if(t.params[0]===6){let e=this._activeBuffer.y+1,s=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${_e.ESC}[?${e};${s}R`)}return!0}softReset(t){return this._coreService.isCursorHidden=!1,this._onRequestSyncScrollBar.fire(),this._activeBuffer.scrollTop=0,this._activeBuffer.scrollBottom=this._bufferService.rows-1,this._curAttrData=Dt.clone(),this._coreService.reset(),this._charsetService.reset(),this._activeBuffer.savedX=0,this._activeBuffer.savedY=this._activeBuffer.ybase,this._activeBuffer.savedCurAttrData.fg=this._curAttrData.fg,this._activeBuffer.savedCurAttrData.bg=this._curAttrData.bg,this._activeBuffer.savedCharset=this._charsetService.charset,this._coreService.decPrivateModes.origin=!1,!0}setCursorStyle(t){let e=t.length===0?1:t.params[0];if(e===0)this._coreService.decPrivateModes.cursorStyle=void 0,this._coreService.decPrivateModes.cursorBlink=void 0;else{switch(e){case 1:case 2:this._coreService.decPrivateModes.cursorStyle="block";break;case 3:case 4:this._coreService.decPrivateModes.cursorStyle="underline";break;case 5:case 6:this._coreService.decPrivateModes.cursorStyle="bar";break}let s=e%2===1;this._coreService.decPrivateModes.cursorBlink=s}return!0}setScrollRegion(t){let e=t.params[0]||1,s;return(t.length<2||(s=t.params[1])>this._bufferService.rows||s===0)&&(s=this._bufferService.rows),s>e&&(this._activeBuffer.scrollTop=e-1,this._activeBuffer.scrollBottom=s-1,this._setCursor(0,0)),!0}windowOptions(t){if(!Q1(t.params[0],this._optionsService.rawOptions.windowOptions))return!0;let e=t.length>1?t.params[1]:0;switch(t.params[0]){case 14:e!==2&&this._onRequestWindowsOptionsReport.fire(0);break;case 16:this._onRequestWindowsOptionsReport.fire(1);break;case 18:this._bufferService&&this._coreService.triggerDataEvent(`${_e.ESC}[8;${this._bufferService.rows};${this._bufferService.cols}t`);break;case 22:(e===0||e===2)&&(this._windowTitleStack.push(this._windowTitle),this._windowTitleStack.length>X1&&this._windowTitleStack.shift()),(e===0||e===1)&&(this._iconNameStack.push(this._iconName),this._iconNameStack.length>X1&&this._iconNameStack.shift());break;case 23:(e===0||e===2)&&this._windowTitleStack.length&&this.setTitle(this._windowTitleStack.pop()),(e===0||e===1)&&this._iconNameStack.length&&this.setIconName(this._iconNameStack.pop());break}return!0}saveCursor(t){return this._activeBuffer.savedX=this._activeBuffer.x,this._activeBuffer.savedY=this._activeBuffer.ybase+this._activeBuffer.y,this._activeBuffer.savedCurAttrData.fg=this._curAttrData.fg,this._activeBuffer.savedCurAttrData.bg=this._curAttrData.bg,this._activeBuffer.savedCharset=this._charsetService.charset,!0}restoreCursor(t){return this._activeBuffer.x=this._activeBuffer.savedX||0,this._activeBuffer.y=Math.max(this._activeBuffer.savedY-this._activeBuffer.ybase,0),this._curAttrData.fg=this._activeBuffer.savedCurAttrData.fg,this._curAttrData.bg=this._activeBuffer.savedCurAttrData.bg,this._charsetService.charset=this._savedCharset,this._activeBuffer.savedCharset&&(this._charsetService.charset=this._activeBuffer.savedCharset),this._restrictCursor(),!0}setTitle(t){return this._windowTitle=t,this._onTitleChange.fire(t),!0}setIconName(t){return this._iconName=t,!0}setOrReportIndexedColor(t){let e=[],s=t.split(";");for(;s.length>1;){let n=s.shift(),i=s.shift();if(/^\d+$/.exec(n)){let o=parseInt(n);if(tm(o))if(i==="?")e.push({type:0,index:o});else{let a=J1(i);a&&e.push({type:1,index:o,color:a})}}}return e.length&&this._onColor.fire(e),!0}setHyperlink(t){let e=t.indexOf(";");if(e===-1)return!0;let s=t.slice(0,e).trim(),n=t.slice(e+1);return n?this._createHyperlink(s,n):s.trim()?!1:this._finishHyperlink()}_createHyperlink(t,e){this._getCurrentLinkId()&&this._finishHyperlink();let s=t.split(":"),n,i=s.findIndex(o=>o.startsWith("id="));return i!==-1&&(n=s[i].slice(3)||void 0),this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=this._oscLinkService.registerLink({id:n,uri:e}),this._curAttrData.updateExtended(),!0}_finishHyperlink(){return this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=0,this._curAttrData.updateExtended(),!0}_setOrReportSpecialColor(t,e){let s=t.split(";");for(let n=0;n<s.length&&!(e>=this._specialColors.length);++n,++e)if(s[n]==="?")this._onColor.fire([{type:0,index:this._specialColors[e]}]);else{let i=J1(s[n]);i&&this._onColor.fire([{type:1,index:this._specialColors[e],color:i}])}return!0}setOrReportFgColor(t){return this._setOrReportSpecialColor(t,0)}setOrReportBgColor(t){return this._setOrReportSpecialColor(t,1)}setOrReportCursorColor(t){return this._setOrReportSpecialColor(t,2)}restoreIndexedColor(t){if(!t)return this._onColor.fire([{type:2}]),!0;let e=[],s=t.split(";");for(let n=0;n<s.length;++n)if(/^\d+$/.exec(s[n])){let i=parseInt(s[n]);tm(i)&&e.push({type:2,index:i})}return e.length&&this._onColor.fire(e),!0}restoreFgColor(t){return this._onColor.fire([{type:2,index:256}]),!0}restoreBgColor(t){return this._onColor.fire([{type:2,index:257}]),!0}restoreCursorColor(t){return this._onColor.fire([{type:2,index:258}]),!0}nextLine(){return this._activeBuffer.x=0,this.index(),!0}keypadApplicationMode(){return this._logService.debug("Serial port requested application keypad."),this._coreService.decPrivateModes.applicationKeypad=!0,this._onRequestSyncScrollBar.fire(),!0}keypadNumericMode(){return this._logService.debug("Switching back to normal keypad."),this._coreService.decPrivateModes.applicationKeypad=!1,this._onRequestSyncScrollBar.fire(),!0}selectDefaultCharset(){return this._charsetService.setgLevel(0),this._charsetService.setgCharset(0,pi),!0}selectCharset(t){return t.length!==2?(this.selectDefaultCharset(),!0):(t[0]==="/"||this._charsetService.setgCharset(nz[t[0]],Kt[t[1]]||pi),!0)}index(){return this._restrictCursor(),this._activeBuffer.y++,this._activeBuffer.y===this._activeBuffer.scrollBottom+1?(this._activeBuffer.y--,this._bufferService.scroll(this._eraseAttrData())):this._activeBuffer.y>=this._bufferService.rows&&(this._activeBuffer.y=this._bufferService.rows-1),this._restrictCursor(),!0}tabSet(){return this._activeBuffer.tabs[this._activeBuffer.x]=!0,!0}reverseIndex(){if(this._restrictCursor(),this._activeBuffer.y===this._activeBuffer.scrollTop){let t=this._activeBuffer.scrollBottom-this._activeBuffer.scrollTop;this._activeBuffer.lines.shiftElements(this._activeBuffer.ybase+this._activeBuffer.y,t,1),this._activeBuffer.lines.set(this._activeBuffer.ybase+this._activeBuffer.y,this._activeBuffer.getBlankLine(this._eraseAttrData())),this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom)}else this._activeBuffer.y--,this._restrictCursor();return!0}fullReset(){return this._parser.reset(),this._onRequestReset.fire(),!0}reset(){this._curAttrData=Dt.clone(),this._eraseAttrDataInternal=Dt.clone()}_eraseAttrData(){return this._eraseAttrDataInternal.bg&=-67108864,this._eraseAttrDataInternal.bg|=this._curAttrData.bg&67108863,this._eraseAttrDataInternal}setgLevel(t){return this._charsetService.setgLevel(t),!0}screenAlignmentPattern(){let t=new Gs;t.content=1<<22|69,t.fg=this._curAttrData.fg,t.bg=this._curAttrData.bg,this._setCursor(0,0);for(let e=0;e<this._bufferService.rows;++e){let s=this._activeBuffer.ybase+this._activeBuffer.y+e,n=this._activeBuffer.lines.get(s);n&&(n.fill(t),n.isWrapped=!1)}return this._dirtyRowTracker.markAllDirty(),this._setCursor(0,0),!0}requestStatusString(t,e){let s=a=>(this._coreService.triggerDataEvent(`${_e.ESC}${a}${_e.ESC}\\`),!0),n=this._bufferService.buffer,i=this._optionsService.rawOptions;return s(t==='"q'?`P1$r${this._curAttrData.isProtected()?1:0}"q`:t==='"p'?'P1$r61;1"p':t==="r"?`P1$r${n.scrollTop+1};${n.scrollBottom+1}r`:t==="m"?"P1$r0m":t===" q"?`P1$r${{block:2,underline:4,bar:6}[i.cursorStyle]-(i.cursorBlink?1:0)} q`:"P0$r")}markRangeDirty(t,e){this._dirtyRowTracker.markRangeDirty(t,e)}},B0=class{constructor(t){this._bufferService=t,this.clearRange()}clearRange(){this.start=this._bufferService.buffer.y,this.end=this._bufferService.buffer.y}markDirty(t){t<this.start?this.start=t:t>this.end&&(this.end=t)}markRangeDirty(t,e){t>e&&(em=t,t=e,e=em),t<this.start&&(this.start=t),e>this.end&&(this.end=e)}markAllDirty(){this.markRangeDirty(0,this._bufferService.rows-1)}};B0=At([Ie(0,ws)],B0);function tm(t){return 0<=t&&t<256}var rz=5e7,sm=12,oz=50,az=class extends tt{constructor(t){super(),this._action=t,this._writeBuffer=[],this._callbacks=[],this._pendingData=0,this._bufferOffset=0,this._isSyncWriting=!1,this._syncCalls=0,this._didUserInput=!1,this._onWriteParsed=this._register(new Te),this.onWriteParsed=this._onWriteParsed.event}handleUserInput(){this._didUserInput=!0}writeSync(t,e){if(e!==void 0&&this._syncCalls>e){this._syncCalls=0;return}if(this._pendingData+=t.length,this._writeBuffer.push(t),this._callbacks.push(void 0),this._syncCalls++,this._isSyncWriting)return;this._isSyncWriting=!0;let s;for(;s=this._writeBuffer.shift();){this._action(s);let n=this._callbacks.shift();n&&n()}this._pendingData=0,this._bufferOffset=2147483647,this._isSyncWriting=!1,this._syncCalls=0}write(t,e){if(this._pendingData>rz)throw new Error("write data discarded, use flow control to avoid losing data");if(!this._writeBuffer.length){if(this._bufferOffset=0,this._didUserInput){this._didUserInput=!1,this._pendingData+=t.length,this._writeBuffer.push(t),this._callbacks.push(e),this._innerWrite();return}setTimeout(()=>this._innerWrite())}this._pendingData+=t.length,this._writeBuffer.push(t),this._callbacks.push(e)}_innerWrite(t=0,e=!0){let s=t||performance.now();for(;this._writeBuffer.length>this._bufferOffset;){let n=this._writeBuffer[this._bufferOffset],i=this._action(n,e);if(i){let a=l=>performance.now()-s>=sm?setTimeout(()=>this._innerWrite(0,l)):this._innerWrite(s,l);i.catch(l=>(queueMicrotask(()=>{throw l}),Promise.resolve(!1))).then(a);return}let o=this._callbacks[this._bufferOffset];if(o&&o(),this._bufferOffset++,this._pendingData-=n.length,performance.now()-s>=sm)break}this._writeBuffer.length>this._bufferOffset?(this._bufferOffset>oz&&(this._writeBuffer=this._writeBuffer.slice(this._bufferOffset),this._callbacks=this._callbacks.slice(this._bufferOffset),this._bufferOffset=0),setTimeout(()=>this._innerWrite())):(this._writeBuffer.length=0,this._callbacks.length=0,this._pendingData=0,this._bufferOffset=0),this._onWriteParsed.fire()}},F0=class{constructor(t){this._bufferService=t,this._nextId=1,this._entriesWithId=new Map,this._dataByLinkId=new Map}registerLink(t){let e=this._bufferService.buffer;if(t.id===void 0){let l=e.addMarker(e.ybase+e.y),c={data:t,id:this._nextId++,lines:[l]};return l.onDispose(()=>this._removeMarkerFromLink(c,l)),this._dataByLinkId.set(c.id,c),c.id}let s=t,n=this._getEntryIdKey(s),i=this._entriesWithId.get(n);if(i)return this.addLineToLink(i.id,e.ybase+e.y),i.id;let o=e.addMarker(e.ybase+e.y),a={id:this._nextId++,key:this._getEntryIdKey(s),data:s,lines:[o]};return o.onDispose(()=>this._removeMarkerFromLink(a,o)),this._entriesWithId.set(a.key,a),this._dataByLinkId.set(a.id,a),a.id}addLineToLink(t,e){let s=this._dataByLinkId.get(t);if(s&&s.lines.every(n=>n.line!==e)){let n=this._bufferService.buffer.addMarker(e);s.lines.push(n),n.onDispose(()=>this._removeMarkerFromLink(s,n))}}getLinkData(t){return this._dataByLinkId.get(t)?.data}_getEntryIdKey(t){return`${t.id};;${t.uri}`}_removeMarkerFromLink(t,e){let s=t.lines.indexOf(e);s!==-1&&(t.lines.splice(s,1),t.lines.length===0&&(t.data.id!==void 0&&this._entriesWithId.delete(t.key),this._dataByLinkId.delete(t.id)))}};F0=At([Ie(0,ws)],F0);var nm=!1,lz=class extends tt{constructor(t){super(),this._windowsWrappingHeuristics=this._register(new Lr),this._onBinary=this._register(new Te),this.onBinary=this._onBinary.event,this._onData=this._register(new Te),this.onData=this._onData.event,this._onLineFeed=this._register(new Te),this.onLineFeed=this._onLineFeed.event,this._onResize=this._register(new Te),this.onResize=this._onResize.event,this._onWriteParsed=this._register(new Te),this.onWriteParsed=this._onWriteParsed.event,this._onScroll=this._register(new Te),this._instantiationService=new EF,this.optionsService=this._register(new zF(t)),this._instantiationService.setService(js,this.optionsService),this._bufferService=this._register(this._instantiationService.createInstance(I0)),this._instantiationService.setService(ws,this._bufferService),this._logService=this._register(this._instantiationService.createInstance(D0)),this._instantiationService.setService(X4,this._logService),this.coreService=this._register(this._instantiationService.createInstance(M0)),this._instantiationService.setService(Gi,this.coreService),this.coreMouseService=this._register(this._instantiationService.createInstance(O0)),this._instantiationService.setService(J4,this.coreMouseService),this.unicodeService=this._register(this._instantiationService.createInstance(bi)),this._instantiationService.setService(V$,this.unicodeService),this._charsetService=this._instantiationService.createInstance(qF),this._instantiationService.setService(k$,this._charsetService),this._oscLinkService=this._instantiationService.createInstance(F0),this._instantiationService.setService(Q4,this._oscLinkService),this._inputHandler=this._register(new iz(this._bufferService,this._charsetService,this.coreService,this._logService,this.optionsService,this._oscLinkService,this.coreMouseService,this.unicodeService)),this._register(os.forward(this._inputHandler.onLineFeed,this._onLineFeed)),this._register(this._inputHandler),this._register(os.forward(this._bufferService.onResize,this._onResize)),this._register(os.forward(this.coreService.onData,this._onData)),this._register(os.forward(this.coreService.onBinary,this._onBinary)),this._register(this.coreService.onRequestScrollToBottom(()=>this.scrollToBottom(!0))),this._register(this.coreService.onUserInput(()=>this._writeBuffer.handleUserInput())),this._register(this.optionsService.onMultipleOptionChange(["windowsMode","windowsPty"],()=>this._handleWindowsPtyOptionChange())),this._register(this._bufferService.onScroll(()=>{this._onScroll.fire({position:this._bufferService.buffer.ydisp}),this._inputHandler.markRangeDirty(this._bufferService.buffer.scrollTop,this._bufferService.buffer.scrollBottom)})),this._writeBuffer=this._register(new az((e,s)=>this._inputHandler.parse(e,s))),this._register(os.forward(this._writeBuffer.onWriteParsed,this._onWriteParsed))}get onScroll(){return this._onScrollApi||(this._onScrollApi=this._register(new Te),this._onScroll.event(t=>{this._onScrollApi?.fire(t.position)})),this._onScrollApi.event}get cols(){return this._bufferService.cols}get rows(){return this._bufferService.rows}get buffers(){return this._bufferService.buffers}get options(){return this.optionsService.options}set options(t){for(let e in t)this.optionsService.options[e]=t[e]}write(t,e){this._writeBuffer.write(t,e)}writeSync(t,e){this._logService.logLevel<=3&&!nm&&(this._logService.warn("writeSync is unreliable and will be removed soon."),nm=!0),this._writeBuffer.writeSync(t,e)}input(t,e=!0){this.coreService.triggerDataEvent(t,e)}resize(t,e){isNaN(t)||isNaN(e)||(t=Math.max(t,T5),e=Math.max(e,A5),this._bufferService.resize(t,e))}scroll(t,e=!1){this._bufferService.scroll(t,e)}scrollLines(t,e){this._bufferService.scrollLines(t,e)}scrollPages(t){this.scrollLines(t*(this.rows-1))}scrollToTop(){this.scrollLines(-this._bufferService.buffer.ydisp)}scrollToBottom(t){this.scrollLines(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp)}scrollToLine(t){let e=t-this._bufferService.buffer.ydisp;e!==0&&this.scrollLines(e)}registerEscHandler(t,e){return this._inputHandler.registerEscHandler(t,e)}registerDcsHandler(t,e){return this._inputHandler.registerDcsHandler(t,e)}registerCsiHandler(t,e){return this._inputHandler.registerCsiHandler(t,e)}registerOscHandler(t,e){return this._inputHandler.registerOscHandler(t,e)}_setup(){this._handleWindowsPtyOptionChange()}reset(){this._inputHandler.reset(),this._bufferService.reset(),this._charsetService.reset(),this.coreService.reset(),this.coreMouseService.reset()}_handleWindowsPtyOptionChange(){let t=!1,e=this.optionsService.rawOptions.windowsPty;e&&e.buildNumber!==void 0&&e.buildNumber!==void 0?t=e.backend==="conpty"&&e.buildNumber<21376:this.optionsService.rawOptions.windowsMode&&(t=!0),t?this._enableWindowsWrappingHeuristics():this._windowsWrappingHeuristics.clear()}_enableWindowsWrappingHeuristics(){if(!this._windowsWrappingHeuristics.value){let t=[];t.push(this.onLineFeed(G1.bind(null,this._bufferService))),t.push(this.registerCsiHandler({final:"H"},()=>(G1(this._bufferService),!1))),this._windowsWrappingHeuristics.value=Lt(()=>{for(let e of t)e.dispose()})}}},cz={48:["0",")"],49:["1","!"],50:["2","@"],51:["3","#"],52:["4","$"],53:["5","%"],54:["6","^"],55:["7","&"],56:["8","*"],57:["9","("],186:[";",":"],187:["=","+"],188:[",","<"],189:["-","_"],190:[".",">"],191:["/","?"],192:["`","~"],219:["[","{"],220:["\\","|"],221:["]","}"],222:["'",'"']};function dz(t,e,s,n){let i={type:0,cancel:!1,key:void 0},o=(t.shiftKey?1:0)|(t.altKey?2:0)|(t.ctrlKey?4:0)|(t.metaKey?8:0);switch(t.keyCode){case 0:t.key==="UIKeyInputUpArrow"?e?i.key=_e.ESC+"OA":i.key=_e.ESC+"[A":t.key==="UIKeyInputLeftArrow"?e?i.key=_e.ESC+"OD":i.key=_e.ESC+"[D":t.key==="UIKeyInputRightArrow"?e?i.key=_e.ESC+"OC":i.key=_e.ESC+"[C":t.key==="UIKeyInputDownArrow"&&(e?i.key=_e.ESC+"OB":i.key=_e.ESC+"[B");break;case 8:i.key=t.ctrlKey?"\b":_e.DEL,t.altKey&&(i.key=_e.ESC+i.key);break;case 9:if(t.shiftKey){i.key=_e.ESC+"[Z";break}i.key=_e.HT,i.cancel=!0;break;case 13:i.key=t.altKey?_e.ESC+_e.CR:_e.CR,i.cancel=!0;break;case 27:i.key=_e.ESC,t.altKey&&(i.key=_e.ESC+_e.ESC),i.cancel=!0;break;case 37:if(t.metaKey)break;o?i.key=_e.ESC+"[1;"+(o+1)+"D":e?i.key=_e.ESC+"OD":i.key=_e.ESC+"[D";break;case 39:if(t.metaKey)break;o?i.key=_e.ESC+"[1;"+(o+1)+"C":e?i.key=_e.ESC+"OC":i.key=_e.ESC+"[C";break;case 38:if(t.metaKey)break;o?i.key=_e.ESC+"[1;"+(o+1)+"A":e?i.key=_e.ESC+"OA":i.key=_e.ESC+"[A";break;case 40:if(t.metaKey)break;o?i.key=_e.ESC+"[1;"+(o+1)+"B":e?i.key=_e.ESC+"OB":i.key=_e.ESC+"[B";break;case 45:!t.shiftKey&&!t.ctrlKey&&(i.key=_e.ESC+"[2~");break;case 46:o?i.key=_e.ESC+"[3;"+(o+1)+"~":i.key=_e.ESC+"[3~";break;case 36:o?i.key=_e.ESC+"[1;"+(o+1)+"H":e?i.key=_e.ESC+"OH":i.key=_e.ESC+"[H";break;case 35:o?i.key=_e.ESC+"[1;"+(o+1)+"F":e?i.key=_e.ESC+"OF":i.key=_e.ESC+"[F";break;case 33:t.shiftKey?i.type=2:t.ctrlKey?i.key=_e.ESC+"[5;"+(o+1)+"~":i.key=_e.ESC+"[5~";break;case 34:t.shiftKey?i.type=3:t.ctrlKey?i.key=_e.ESC+"[6;"+(o+1)+"~":i.key=_e.ESC+"[6~";break;case 112:o?i.key=_e.ESC+"[1;"+(o+1)+"P":i.key=_e.ESC+"OP";break;case 113:o?i.key=_e.ESC+"[1;"+(o+1)+"Q":i.key=_e.ESC+"OQ";break;case 114:o?i.key=_e.ESC+"[1;"+(o+1)+"R":i.key=_e.ESC+"OR";break;case 115:o?i.key=_e.ESC+"[1;"+(o+1)+"S":i.key=_e.ESC+"OS";break;case 116:o?i.key=_e.ESC+"[15;"+(o+1)+"~":i.key=_e.ESC+"[15~";break;case 117:o?i.key=_e.ESC+"[17;"+(o+1)+"~":i.key=_e.ESC+"[17~";break;case 118:o?i.key=_e.ESC+"[18;"+(o+1)+"~":i.key=_e.ESC+"[18~";break;case 119:o?i.key=_e.ESC+"[19;"+(o+1)+"~":i.key=_e.ESC+"[19~";break;case 120:o?i.key=_e.ESC+"[20;"+(o+1)+"~":i.key=_e.ESC+"[20~";break;case 121:o?i.key=_e.ESC+"[21;"+(o+1)+"~":i.key=_e.ESC+"[21~";break;case 122:o?i.key=_e.ESC+"[23;"+(o+1)+"~":i.key=_e.ESC+"[23~";break;case 123:o?i.key=_e.ESC+"[24;"+(o+1)+"~":i.key=_e.ESC+"[24~";break;default:if(t.ctrlKey&&!t.shiftKey&&!t.altKey&&!t.metaKey)t.keyCode>=65&&t.keyCode<=90?i.key=String.fromCharCode(t.keyCode-64):t.keyCode===32?i.key=_e.NUL:t.keyCode>=51&&t.keyCode<=55?i.key=String.fromCharCode(t.keyCode-51+27):t.keyCode===56?i.key=_e.DEL:t.keyCode===219?i.key=_e.ESC:t.keyCode===220?i.key=_e.FS:t.keyCode===221&&(i.key=_e.GS);else if((!s||n)&&t.altKey&&!t.metaKey){let a=cz[t.keyCode]?.[t.shiftKey?1:0];if(a)i.key=_e.ESC+a;else if(t.keyCode>=65&&t.keyCode<=90){let l=t.ctrlKey?t.keyCode-64:t.keyCode+32,c=String.fromCharCode(l);t.shiftKey&&(c=c.toUpperCase()),i.key=_e.ESC+c}else if(t.keyCode===32)i.key=_e.ESC+(t.ctrlKey?_e.NUL:" ");else if(t.key==="Dead"&&t.code.startsWith("Key")){let l=t.code.slice(3,4);t.shiftKey||(l=l.toLowerCase()),i.key=_e.ESC+l,i.cancel=!0}}else s&&!t.altKey&&!t.ctrlKey&&!t.shiftKey&&t.metaKey?t.keyCode===65&&(i.type=1):t.key&&!t.ctrlKey&&!t.altKey&&!t.metaKey&&t.keyCode>=48&&t.key.length===1?i.key=t.key:t.key&&t.ctrlKey&&(t.key==="_"&&(i.key=_e.US),t.key==="@"&&(i.key=_e.NUL));break}return i}var Et=0,uz=class{constructor(t){this._getKey=t,this._array=[],this._insertedValues=[],this._flushInsertedTask=new Kl,this._isFlushingInserted=!1,this._deletedIndices=[],this._flushDeletedTask=new Kl,this._isFlushingDeleted=!1}clear(){this._array.length=0,this._insertedValues.length=0,this._flushInsertedTask.clear(),this._isFlushingInserted=!1,this._deletedIndices.length=0,this._flushDeletedTask.clear(),this._isFlushingDeleted=!1}insert(t){this._flushCleanupDeleted(),this._insertedValues.length===0&&this._flushInsertedTask.enqueue(()=>this._flushInserted()),this._insertedValues.push(t)}_flushInserted(){let t=this._insertedValues.sort((i,o)=>this._getKey(i)-this._getKey(o)),e=0,s=0,n=new Array(this._array.length+this._insertedValues.length);for(let i=0;i<n.length;i++)s>=this._array.length||this._getKey(t[e])<=this._getKey(this._array[s])?(n[i]=t[e],e++):n[i]=this._array[s++];this._array=n,this._insertedValues.length=0}_flushCleanupInserted(){!this._isFlushingInserted&&this._insertedValues.length>0&&this._flushInsertedTask.flush()}delete(t){if(this._flushCleanupInserted(),this._array.length===0)return!1;let e=this._getKey(t);if(e===void 0||(Et=this._search(e),Et===-1)||this._getKey(this._array[Et])!==e)return!1;do if(this._array[Et]===t)return this._deletedIndices.length===0&&this._flushDeletedTask.enqueue(()=>this._flushDeleted()),this._deletedIndices.push(Et),!0;while(++Et<this._array.length&&this._getKey(this._array[Et])===e);return!1}_flushDeleted(){this._isFlushingDeleted=!0;let t=this._deletedIndices.sort((i,o)=>i-o),e=0,s=new Array(this._array.length-t.length),n=0;for(let i=0;i<this._array.length;i++)t[e]===i?e++:s[n++]=this._array[i];this._array=s,this._deletedIndices.length=0,this._isFlushingDeleted=!1}_flushCleanupDeleted(){!this._isFlushingDeleted&&this._deletedIndices.length>0&&this._flushDeletedTask.flush()}*getKeyIterator(t){if(this._flushCleanupInserted(),this._flushCleanupDeleted(),this._array.length!==0&&(Et=this._search(t),!(Et<0||Et>=this._array.length)&&this._getKey(this._array[Et])===t))do yield this._array[Et];while(++Et<this._array.length&&this._getKey(this._array[Et])===t)}forEachByKey(t,e){if(this._flushCleanupInserted(),this._flushCleanupDeleted(),this._array.length!==0&&(Et=this._search(t),!(Et<0||Et>=this._array.length)&&this._getKey(this._array[Et])===t))do e(this._array[Et]);while(++Et<this._array.length&&this._getKey(this._array[Et])===t)}values(){return this._flushCleanupInserted(),this._flushCleanupDeleted(),[...this._array].values()}_search(t){let e=0,s=this._array.length-1;for(;s>=e;){let n=e+s>>1,i=this._getKey(this._array[n]);if(i>t)s=n-1;else if(i<t)e=n+1;else{for(;n>0&&this._getKey(this._array[n-1])===t;)n--;return n}}return e}},Nd=0,im=0,hz=class extends tt{constructor(){super(),this._decorations=new uz(t=>t?.marker.line),this._onDecorationRegistered=this._register(new Te),this.onDecorationRegistered=this._onDecorationRegistered.event,this._onDecorationRemoved=this._register(new Te),this.onDecorationRemoved=this._onDecorationRemoved.event,this._register(Lt(()=>this.reset()))}get decorations(){return this._decorations.values()}registerDecoration(t){if(t.marker.isDisposed)return;let e=new fz(t);if(e){let s=e.marker.onDispose(()=>e.dispose()),n=e.onDispose(()=>{n.dispose(),e&&(this._decorations.delete(e)&&this._onDecorationRemoved.fire(e),s.dispose())});this._decorations.insert(e),this._onDecorationRegistered.fire(e)}return e}reset(){for(let t of this._decorations.values())t.dispose();this._decorations.clear()}*getDecorationsAtCell(t,e,s){let n=0,i=0;for(let o of this._decorations.getKeyIterator(e))n=o.options.x??0,i=n+(o.options.width??1),t>=n&&t<i&&(!s||(o.options.layer??"bottom")===s)&&(yield o)}forEachDecorationAtCell(t,e,s,n){this._decorations.forEachByKey(e,i=>{Nd=i.options.x??0,im=Nd+(i.options.width??1),t>=Nd&&t<im&&(!s||(i.options.layer??"bottom")===s)&&n(i)})}},fz=class extends Xn{constructor(t){super(),this.options=t,this.onRenderEmitter=this.add(new Te),this.onRender=this.onRenderEmitter.event,this._onDispose=this.add(new Te),this.onDispose=this._onDispose.event,this._cachedBg=null,this._cachedFg=null,this.marker=t.marker,this.options.overviewRulerOptions&&!this.options.overviewRulerOptions.position&&(this.options.overviewRulerOptions.position="full")}get backgroundColorRGB(){return this._cachedBg===null&&(this.options.backgroundColor?this._cachedBg=Ct.toColor(this.options.backgroundColor):this._cachedBg=void 0),this._cachedBg}get foregroundColorRGB(){return this._cachedFg===null&&(this.options.foregroundColor?this._cachedFg=Ct.toColor(this.options.foregroundColor):this._cachedFg=void 0),this._cachedFg}dispose(){this._onDispose.fire(),super.dispose()}},mz=1e3,pz=class{constructor(t,e=mz){this._renderCallback=t,this._debounceThresholdMS=e,this._lastRefreshMs=0,this._additionalRefreshRequested=!1}dispose(){this._refreshTimeoutID&&clearTimeout(this._refreshTimeoutID)}refresh(t,e,s){this._rowCount=s,t=t!==void 0?t:0,e=e!==void 0?e:this._rowCount-1,this._rowStart=this._rowStart!==void 0?Math.min(this._rowStart,t):t,this._rowEnd=this._rowEnd!==void 0?Math.max(this._rowEnd,e):e;let n=performance.now();if(n-this._lastRefreshMs>=this._debounceThresholdMS)this._lastRefreshMs=n,this._innerRefresh();else if(!this._additionalRefreshRequested){let i=n-this._lastRefreshMs,o=this._debounceThresholdMS-i;this._additionalRefreshRequested=!0,this._refreshTimeoutID=window.setTimeout(()=>{this._lastRefreshMs=performance.now(),this._innerRefresh(),this._additionalRefreshRequested=!1,this._refreshTimeoutID=void 0},o)}}_innerRefresh(){if(this._rowStart===void 0||this._rowEnd===void 0||this._rowCount===void 0)return;let t=Math.max(this._rowStart,0),e=Math.min(this._rowEnd,this._rowCount-1);this._rowStart=void 0,this._rowEnd=void 0,this._renderCallback(t,e)}},rm=20,Ul=class extends tt{constructor(t,e,s,n){super(),this._terminal=t,this._coreBrowserService=s,this._renderService=n,this._rowColumns=new WeakMap,this._liveRegionLineCount=0,this._charsToConsume=[],this._charsToAnnounce="";let i=this._coreBrowserService.mainDocument;this._accessibilityContainer=i.createElement("div"),this._accessibilityContainer.classList.add("xterm-accessibility"),this._rowContainer=i.createElement("div"),this._rowContainer.setAttribute("role","list"),this._rowContainer.classList.add("xterm-accessibility-tree"),this._rowElements=[];for(let o=0;o<this._terminal.rows;o++)this._rowElements[o]=this._createAccessibilityTreeNode(),this._rowContainer.appendChild(this._rowElements[o]);if(this._topBoundaryFocusListener=o=>this._handleBoundaryFocus(o,0),this._bottomBoundaryFocusListener=o=>this._handleBoundaryFocus(o,1),this._rowElements[0].addEventListener("focus",this._topBoundaryFocusListener),this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._accessibilityContainer.appendChild(this._rowContainer),this._liveRegion=i.createElement("div"),this._liveRegion.classList.add("live-region"),this._liveRegion.setAttribute("aria-live","assertive"),this._accessibilityContainer.appendChild(this._liveRegion),this._liveRegionDebouncer=this._register(new pz(this._renderRows.bind(this))),!this._terminal.element)throw new Error("Cannot enable accessibility before Terminal.open");this._terminal.element.insertAdjacentElement("afterbegin",this._accessibilityContainer),this._register(this._terminal.onResize(o=>this._handleResize(o.rows))),this._register(this._terminal.onRender(o=>this._refreshRows(o.start,o.end))),this._register(this._terminal.onScroll(()=>this._refreshRows())),this._register(this._terminal.onA11yChar(o=>this._handleChar(o))),this._register(this._terminal.onLineFeed(()=>this._handleChar(`
|
|
513
|
+
`))),this._register(this._terminal.onA11yTab(o=>this._handleTab(o))),this._register(this._terminal.onKey(o=>this._handleKey(o.key))),this._register(this._terminal.onBlur(()=>this._clearLiveRegion())),this._register(this._renderService.onDimensionsChange(()=>this._refreshRowsDimensions())),this._register(Ge(i,"selectionchange",()=>this._handleSelectionChange())),this._register(this._coreBrowserService.onDprChange(()=>this._refreshRowsDimensions())),this._refreshRowsDimensions(),this._refreshRows(),this._register(Lt(()=>{this._accessibilityContainer.remove(),this._rowElements.length=0}))}_handleTab(t){for(let e=0;e<t;e++)this._handleChar(" ")}_handleChar(t){this._liveRegionLineCount<rm+1&&(this._charsToConsume.length>0?this._charsToConsume.shift()!==t&&(this._charsToAnnounce+=t):this._charsToAnnounce+=t,t===`
|
|
514
|
+
`&&(this._liveRegionLineCount++,this._liveRegionLineCount===rm+1&&(this._liveRegion.textContent+=a0.get())))}_clearLiveRegion(){this._liveRegion.textContent="",this._liveRegionLineCount=0}_handleKey(t){this._clearLiveRegion(),new RegExp("\\p{Control}","u").test(t)||this._charsToConsume.push(t)}_refreshRows(t,e){this._liveRegionDebouncer.refresh(t,e,this._terminal.rows)}_renderRows(t,e){let s=this._terminal.buffer,n=s.lines.length.toString();for(let i=t;i<=e;i++){let o=s.lines.get(s.ydisp+i),a=[],l=o?.translateToString(!0,void 0,void 0,a)||"",c=(s.ydisp+i+1).toString(),d=this._rowElements[i];d&&(l.length===0?(d.textContent=" ",this._rowColumns.set(d,[0,1])):(d.textContent=l,this._rowColumns.set(d,a)),d.setAttribute("aria-posinset",c),d.setAttribute("aria-setsize",n),this._alignRowWidth(d))}this._announceCharacters()}_announceCharacters(){this._charsToAnnounce.length!==0&&(this._liveRegion.textContent+=this._charsToAnnounce,this._charsToAnnounce="")}_handleBoundaryFocus(t,e){let s=t.target,n=this._rowElements[e===0?1:this._rowElements.length-2],i=s.getAttribute("aria-posinset"),o=e===0?"1":`${this._terminal.buffer.lines.length}`;if(i===o||t.relatedTarget!==n)return;let a,l;if(e===0?(a=s,l=this._rowElements.pop(),this._rowContainer.removeChild(l)):(a=this._rowElements.shift(),l=s,this._rowContainer.removeChild(a)),a.removeEventListener("focus",this._topBoundaryFocusListener),l.removeEventListener("focus",this._bottomBoundaryFocusListener),e===0){let c=this._createAccessibilityTreeNode();this._rowElements.unshift(c),this._rowContainer.insertAdjacentElement("afterbegin",c)}else{let c=this._createAccessibilityTreeNode();this._rowElements.push(c),this._rowContainer.appendChild(c)}this._rowElements[0].addEventListener("focus",this._topBoundaryFocusListener),this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._terminal.scrollLines(e===0?-1:1),this._rowElements[e===0?1:this._rowElements.length-2].focus(),t.preventDefault(),t.stopImmediatePropagation()}_handleSelectionChange(){if(this._rowElements.length===0)return;let t=this._coreBrowserService.mainDocument.getSelection();if(!t)return;if(t.isCollapsed){this._rowContainer.contains(t.anchorNode)&&this._terminal.clearSelection();return}if(!t.anchorNode||!t.focusNode){console.error("anchorNode and/or focusNode are null");return}let e={node:t.anchorNode,offset:t.anchorOffset},s={node:t.focusNode,offset:t.focusOffset};if((e.node.compareDocumentPosition(s.node)&Node.DOCUMENT_POSITION_PRECEDING||e.node===s.node&&e.offset>s.offset)&&([e,s]=[s,e]),e.node.compareDocumentPosition(this._rowElements[0])&(Node.DOCUMENT_POSITION_CONTAINED_BY|Node.DOCUMENT_POSITION_FOLLOWING)&&(e={node:this._rowElements[0].childNodes[0],offset:0}),!this._rowContainer.contains(e.node))return;let n=this._rowElements.slice(-1)[0];if(s.node.compareDocumentPosition(n)&(Node.DOCUMENT_POSITION_CONTAINED_BY|Node.DOCUMENT_POSITION_PRECEDING)&&(s={node:n,offset:n.textContent?.length??0}),!this._rowContainer.contains(s.node))return;let i=({node:l,offset:c})=>{let d=l instanceof Text?l.parentNode:l,h=parseInt(d?.getAttribute("aria-posinset"),10)-1;if(isNaN(h))return console.warn("row is invalid. Race condition?"),null;let u=this._rowColumns.get(d);if(!u)return console.warn("columns is null. Race condition?"),null;let f=c<u.length?u[c]:u.slice(-1)[0]+1;return f>=this._terminal.cols&&(++h,f=0),{row:h,column:f}},o=i(e),a=i(s);if(!(!o||!a)){if(o.row>a.row||o.row===a.row&&o.column>=a.column)throw new Error("invalid range");this._terminal.select(o.column,o.row,(a.row-o.row)*this._terminal.cols-o.column+a.column)}}_handleResize(t){this._rowElements[this._rowElements.length-1].removeEventListener("focus",this._bottomBoundaryFocusListener);for(let e=this._rowContainer.children.length;e<this._terminal.rows;e++)this._rowElements[e]=this._createAccessibilityTreeNode(),this._rowContainer.appendChild(this._rowElements[e]);for(;this._rowElements.length>t;)this._rowContainer.removeChild(this._rowElements.pop());this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._refreshRowsDimensions()}_createAccessibilityTreeNode(){let t=this._coreBrowserService.mainDocument.createElement("div");return t.setAttribute("role","listitem"),t.tabIndex=-1,this._refreshRowDimensions(t),t}_refreshRowsDimensions(){if(this._renderService.dimensions.css.cell.height){Object.assign(this._accessibilityContainer.style,{width:`${this._renderService.dimensions.css.canvas.width}px`,fontSize:`${this._terminal.options.fontSize}px`}),this._rowElements.length!==this._terminal.rows&&this._handleResize(this._terminal.rows);for(let t=0;t<this._terminal.rows;t++)this._refreshRowDimensions(this._rowElements[t]),this._alignRowWidth(this._rowElements[t])}}_refreshRowDimensions(t){t.style.height=`${this._renderService.dimensions.css.cell.height}px`}_alignRowWidth(t){t.style.transform="";let e=t.getBoundingClientRect().width,s=this._rowColumns.get(t)?.slice(-1)?.[0];if(!s)return;let n=s*this._renderService.dimensions.css.cell.width;t.style.transform=`scaleX(${n/e})`}};Ul=At([Ie(1,Au),Ie(2,Mn),Ie(3,On)],Ul);var z0=class extends tt{constructor(t,e,s,n,i){super(),this._element=t,this._mouseService=e,this._renderService=s,this._bufferService=n,this._linkProviderService=i,this._linkCacheDisposables=[],this._isMouseOut=!0,this._wasResized=!1,this._activeLine=-1,this._onShowLinkUnderline=this._register(new Te),this.onShowLinkUnderline=this._onShowLinkUnderline.event,this._onHideLinkUnderline=this._register(new Te),this.onHideLinkUnderline=this._onHideLinkUnderline.event,this._register(Lt(()=>{Pi(this._linkCacheDisposables),this._linkCacheDisposables.length=0,this._lastMouseEvent=void 0,this._activeProviderReplies?.clear()})),this._register(this._bufferService.onResize(()=>{this._clearCurrentLink(),this._wasResized=!0})),this._register(Ge(this._element,"mouseleave",()=>{this._isMouseOut=!0,this._clearCurrentLink()})),this._register(Ge(this._element,"mousemove",this._handleMouseMove.bind(this))),this._register(Ge(this._element,"mousedown",this._handleMouseDown.bind(this))),this._register(Ge(this._element,"mouseup",this._handleMouseUp.bind(this)))}get currentLink(){return this._currentLink}_handleMouseMove(t){this._lastMouseEvent=t;let e=this._positionFromMouseEvent(t,this._element,this._mouseService);if(!e)return;this._isMouseOut=!1;let s=t.composedPath();for(let n=0;n<s.length;n++){let i=s[n];if(i.classList.contains("xterm"))break;if(i.classList.contains("xterm-hover"))return}(!this._lastBufferCell||e.x!==this._lastBufferCell.x||e.y!==this._lastBufferCell.y)&&(this._handleHover(e),this._lastBufferCell=e)}_handleHover(t){if(this._activeLine!==t.y||this._wasResized){this._clearCurrentLink(),this._askForLink(t,!1),this._wasResized=!1;return}this._currentLink&&this._linkAtPosition(this._currentLink.link,t)||(this._clearCurrentLink(),this._askForLink(t,!0))}_askForLink(t,e){(!this._activeProviderReplies||!e)&&(this._activeProviderReplies?.forEach(n=>{n?.forEach(i=>{i.link.dispose&&i.link.dispose()})}),this._activeProviderReplies=new Map,this._activeLine=t.y);let s=!1;for(let[n,i]of this._linkProviderService.linkProviders.entries())e?this._activeProviderReplies?.get(n)&&(s=this._checkLinkProviderResult(n,t,s)):i.provideLinks(t.y,o=>{if(this._isMouseOut)return;let a=o?.map(l=>({link:l}));this._activeProviderReplies?.set(n,a),s=this._checkLinkProviderResult(n,t,s),this._activeProviderReplies?.size===this._linkProviderService.linkProviders.length&&this._removeIntersectingLinks(t.y,this._activeProviderReplies)})}_removeIntersectingLinks(t,e){let s=new Set;for(let n=0;n<e.size;n++){let i=e.get(n);if(i)for(let o=0;o<i.length;o++){let a=i[o],l=a.link.range.start.y<t?0:a.link.range.start.x,c=a.link.range.end.y>t?this._bufferService.cols:a.link.range.end.x;for(let d=l;d<=c;d++){if(s.has(d)){i.splice(o--,1);break}s.add(d)}}}}_checkLinkProviderResult(t,e,s){if(!this._activeProviderReplies)return s;let n=this._activeProviderReplies.get(t),i=!1;for(let o=0;o<t;o++)(!this._activeProviderReplies.has(o)||this._activeProviderReplies.get(o))&&(i=!0);if(!i&&n){let o=n.find(a=>this._linkAtPosition(a.link,e));o&&(s=!0,this._handleNewLink(o))}if(this._activeProviderReplies.size===this._linkProviderService.linkProviders.length&&!s)for(let o=0;o<this._activeProviderReplies.size;o++){let a=this._activeProviderReplies.get(o)?.find(l=>this._linkAtPosition(l.link,e));if(a){s=!0,this._handleNewLink(a);break}}return s}_handleMouseDown(){this._mouseDownLink=this._currentLink}_handleMouseUp(t){if(!this._currentLink)return;let e=this._positionFromMouseEvent(t,this._element,this._mouseService);e&&this._mouseDownLink&&gz(this._mouseDownLink.link,this._currentLink.link)&&this._linkAtPosition(this._currentLink.link,e)&&this._currentLink.link.activate(t,this._currentLink.link.text)}_clearCurrentLink(t,e){!this._currentLink||!this._lastMouseEvent||(!t||!e||this._currentLink.link.range.start.y>=t&&this._currentLink.link.range.end.y<=e)&&(this._linkLeave(this._element,this._currentLink.link,this._lastMouseEvent),this._currentLink=void 0,Pi(this._linkCacheDisposables),this._linkCacheDisposables.length=0)}_handleNewLink(t){if(!this._lastMouseEvent)return;let e=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);e&&this._linkAtPosition(t.link,e)&&(this._currentLink=t,this._currentLink.state={decorations:{underline:t.link.decorations===void 0?!0:t.link.decorations.underline,pointerCursor:t.link.decorations===void 0?!0:t.link.decorations.pointerCursor},isHovered:!0},this._linkHover(this._element,t.link,this._lastMouseEvent),t.link.decorations={},Object.defineProperties(t.link.decorations,{pointerCursor:{get:()=>this._currentLink?.state?.decorations.pointerCursor,set:s=>{this._currentLink?.state&&this._currentLink.state.decorations.pointerCursor!==s&&(this._currentLink.state.decorations.pointerCursor=s,this._currentLink.state.isHovered&&this._element.classList.toggle("xterm-cursor-pointer",s))}},underline:{get:()=>this._currentLink?.state?.decorations.underline,set:s=>{this._currentLink?.state&&this._currentLink?.state?.decorations.underline!==s&&(this._currentLink.state.decorations.underline=s,this._currentLink.state.isHovered&&this._fireUnderlineEvent(t.link,s))}}}),this._linkCacheDisposables.push(this._renderService.onRenderedViewportChange(s=>{if(!this._currentLink)return;let n=s.start===0?0:s.start+1+this._bufferService.buffer.ydisp,i=this._bufferService.buffer.ydisp+1+s.end;if(this._currentLink.link.range.start.y>=n&&this._currentLink.link.range.end.y<=i&&(this._clearCurrentLink(n,i),this._lastMouseEvent)){let o=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);o&&this._askForLink(o,!1)}})))}_linkHover(t,e,s){this._currentLink?.state&&(this._currentLink.state.isHovered=!0,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(e,!0),this._currentLink.state.decorations.pointerCursor&&t.classList.add("xterm-cursor-pointer")),e.hover&&e.hover(s,e.text)}_fireUnderlineEvent(t,e){let s=t.range,n=this._bufferService.buffer.ydisp,i=this._createLinkUnderlineEvent(s.start.x-1,s.start.y-n-1,s.end.x,s.end.y-n-1,void 0);(e?this._onShowLinkUnderline:this._onHideLinkUnderline).fire(i)}_linkLeave(t,e,s){this._currentLink?.state&&(this._currentLink.state.isHovered=!1,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(e,!1),this._currentLink.state.decorations.pointerCursor&&t.classList.remove("xterm-cursor-pointer")),e.leave&&e.leave(s,e.text)}_linkAtPosition(t,e){let s=t.range.start.y*this._bufferService.cols+t.range.start.x,n=t.range.end.y*this._bufferService.cols+t.range.end.x,i=e.y*this._bufferService.cols+e.x;return s<=i&&i<=n}_positionFromMouseEvent(t,e,s){let n=s.getCoords(t,e,this._bufferService.cols,this._bufferService.rows);if(n)return{x:n[0],y:n[1]+this._bufferService.buffer.ydisp}}_createLinkUnderlineEvent(t,e,s,n,i){return{x1:t,y1:e,x2:s,y2:n,cols:this._bufferService.cols,fg:i}}};z0=At([Ie(1,Eu),Ie(2,On),Ie(3,ws),Ie(4,e5)],z0);function gz(t,e){return t.text===e.text&&t.range.start.x===e.range.start.x&&t.range.start.y===e.range.start.y&&t.range.end.x===e.range.end.x&&t.range.end.y===e.range.end.y}var xz=class extends lz{constructor(t={}){super(t),this._linkifier=this._register(new Lr),this.browser=b5,this._keyDownHandled=!1,this._keyDownSeen=!1,this._keyPressHandled=!1,this._unprocessedDeadKey=!1,this._accessibilityManager=this._register(new Lr),this._onCursorMove=this._register(new Te),this.onCursorMove=this._onCursorMove.event,this._onKey=this._register(new Te),this.onKey=this._onKey.event,this._onRender=this._register(new Te),this.onRender=this._onRender.event,this._onSelectionChange=this._register(new Te),this.onSelectionChange=this._onSelectionChange.event,this._onTitleChange=this._register(new Te),this.onTitleChange=this._onTitleChange.event,this._onBell=this._register(new Te),this.onBell=this._onBell.event,this._onFocus=this._register(new Te),this._onBlur=this._register(new Te),this._onA11yCharEmitter=this._register(new Te),this._onA11yTabEmitter=this._register(new Te),this._onWillOpen=this._register(new Te),this._setup(),this._decorationService=this._instantiationService.createInstance(hz),this._instantiationService.setService(ga,this._decorationService),this._linkProviderService=this._instantiationService.createInstance(oF),this._instantiationService.setService(e5,this._linkProviderService),this._linkProviderService.registerLinkProvider(this._instantiationService.createInstance(c0)),this._register(this._inputHandler.onRequestBell(()=>this._onBell.fire())),this._register(this._inputHandler.onRequestRefreshRows(e=>this.refresh(e?.start??0,e?.end??this.rows-1))),this._register(this._inputHandler.onRequestSendFocus(()=>this._reportFocus())),this._register(this._inputHandler.onRequestReset(()=>this.reset())),this._register(this._inputHandler.onRequestWindowsOptionsReport(e=>this._reportWindowsOptions(e))),this._register(this._inputHandler.onColor(e=>this._handleColorEvent(e))),this._register(os.forward(this._inputHandler.onCursorMove,this._onCursorMove)),this._register(os.forward(this._inputHandler.onTitleChange,this._onTitleChange)),this._register(os.forward(this._inputHandler.onA11yChar,this._onA11yCharEmitter)),this._register(os.forward(this._inputHandler.onA11yTab,this._onA11yTabEmitter)),this._register(this._bufferService.onResize(e=>this._afterResize(e.cols,e.rows))),this._register(Lt(()=>{this._customKeyEventHandler=void 0,this.element?.parentNode?.removeChild(this.element)}))}get linkifier(){return this._linkifier.value}get onFocus(){return this._onFocus.event}get onBlur(){return this._onBlur.event}get onA11yChar(){return this._onA11yCharEmitter.event}get onA11yTab(){return this._onA11yTabEmitter.event}get onWillOpen(){return this._onWillOpen.event}_handleColorEvent(t){if(this._themeService)for(let e of t){let s,n="";switch(e.index){case 256:s="foreground",n="10";break;case 257:s="background",n="11";break;case 258:s="cursor",n="12";break;default:s="ansi",n="4;"+e.index}switch(e.type){case 0:let i=yt.toColorRGB(s==="ansi"?this._themeService.colors.ansi[e.index]:this._themeService.colors[s]);this.coreService.triggerDataEvent(`${_e.ESC}]${n};${sz(i)}${x5.ST}`);break;case 1:if(s==="ansi")this._themeService.modifyColors(o=>o.ansi[e.index]=It.toColor(...e.color));else{let o=s;this._themeService.modifyColors(a=>a[o]=It.toColor(...e.color))}break;case 2:this._themeService.restoreColor(e.index);break}}}_setup(){super._setup(),this._customKeyEventHandler=void 0}get buffer(){return this.buffers.active}focus(){this.textarea&&this.textarea.focus({preventScroll:!0})}_handleScreenReaderModeOptionChange(t){t?!this._accessibilityManager.value&&this._renderService&&(this._accessibilityManager.value=this._instantiationService.createInstance(Ul,this)):this._accessibilityManager.clear()}_handleTextAreaFocus(t){this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent(_e.ESC+"[I"),this.element.classList.add("focus"),this._showCursor(),this._onFocus.fire()}blur(){return this.textarea?.blur()}_handleTextAreaBlur(){this.textarea.value="",this.refresh(this.buffer.y,this.buffer.y),this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent(_e.ESC+"[O"),this.element.classList.remove("focus"),this._onBlur.fire()}_syncTextArea(){if(!this.textarea||!this.buffer.isCursorInViewport||this._compositionHelper.isComposing||!this._renderService)return;let t=this.buffer.ybase+this.buffer.y,e=this.buffer.lines.get(t);if(!e)return;let s=Math.min(this.buffer.x,this.cols-1),n=this._renderService.dimensions.css.cell.height,i=e.getWidth(s),o=this._renderService.dimensions.css.cell.width*i,a=this.buffer.y*this._renderService.dimensions.css.cell.height,l=s*this._renderService.dimensions.css.cell.width;this.textarea.style.left=l+"px",this.textarea.style.top=a+"px",this.textarea.style.width=o+"px",this.textarea.style.height=n+"px",this.textarea.style.lineHeight=n+"px",this.textarea.style.zIndex="-5"}_initGlobal(){this._bindKeys(),this._register(Ge(this.element,"copy",e=>{this.hasSelection()&&_$(e,this._selectionService)}));let t=e=>L$(e,this.textarea,this.coreService,this.optionsService);this._register(Ge(this.textarea,"paste",t)),this._register(Ge(this.element,"paste",t)),y5?this._register(Ge(this.element,"mousedown",e=>{e.button===2&&p1(e,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})):this._register(Ge(this.element,"contextmenu",e=>{p1(e,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})),Bu&&this._register(Ge(this.element,"auxclick",e=>{e.button===1&&H4(e,this.textarea,this.screenElement)}))}_bindKeys(){this._register(Ge(this.textarea,"keyup",t=>this._keyUp(t),!0)),this._register(Ge(this.textarea,"keydown",t=>this._keyDown(t),!0)),this._register(Ge(this.textarea,"keypress",t=>this._keyPress(t),!0)),this._register(Ge(this.textarea,"compositionstart",()=>this._compositionHelper.compositionstart())),this._register(Ge(this.textarea,"compositionupdate",t=>this._compositionHelper.compositionupdate(t))),this._register(Ge(this.textarea,"compositionend",()=>this._compositionHelper.compositionend())),this._register(Ge(this.textarea,"input",t=>this._inputEvent(t),!0)),this._register(this.onRender(()=>this._compositionHelper.updateCompositionElements()))}open(t){if(!t)throw new Error("Terminal requires a parent element.");if(t.isConnected||this._logService.debug("Terminal.open was called on an element that was not attached to the DOM"),this.element?.ownerDocument.defaultView&&this._coreBrowserService){this.element.ownerDocument.defaultView!==this._coreBrowserService.window&&(this._coreBrowserService.window=this.element.ownerDocument.defaultView);return}this._document=t.ownerDocument,this.options.documentOverride&&this.options.documentOverride instanceof Document&&(this._document=this.optionsService.rawOptions.documentOverride),this.element=this._document.createElement("div"),this.element.dir="ltr",this.element.classList.add("terminal"),this.element.classList.add("xterm"),t.appendChild(this.element);let e=this._document.createDocumentFragment();this._viewportElement=this._document.createElement("div"),this._viewportElement.classList.add("xterm-viewport"),e.appendChild(this._viewportElement),this.screenElement=this._document.createElement("div"),this.screenElement.classList.add("xterm-screen"),this._register(Ge(this.screenElement,"mousemove",i=>this.updateCursorStyle(i))),this._helperContainer=this._document.createElement("div"),this._helperContainer.classList.add("xterm-helpers"),this.screenElement.appendChild(this._helperContainer),e.appendChild(this.screenElement);let s=this.textarea=this._document.createElement("textarea");this.textarea.classList.add("xterm-helper-textarea"),this.textarea.setAttribute("aria-label",o0.get()),S5||this.textarea.setAttribute("aria-multiline","false"),this.textarea.setAttribute("autocorrect","off"),this.textarea.setAttribute("autocapitalize","off"),this.textarea.setAttribute("spellcheck","false"),this.textarea.tabIndex=0,this._register(this.optionsService.onSpecificOptionChange("disableStdin",()=>s.readOnly=this.optionsService.rawOptions.disableStdin)),this.textarea.readOnly=this.optionsService.rawOptions.disableStdin,this._coreBrowserService=this._register(this._instantiationService.createInstance(iF,this.textarea,t.ownerDocument.defaultView??window,this._document??typeof window<"u"?window.document:null)),this._instantiationService.setService(Mn,this._coreBrowserService),this._register(Ge(this.textarea,"focus",i=>this._handleTextAreaFocus(i))),this._register(Ge(this.textarea,"blur",()=>this._handleTextAreaBlur())),this._helperContainer.appendChild(this.textarea),this._charSizeService=this._instantiationService.createInstance(T0,this._document,this._helperContainer),this._instantiationService.setService(Ac,this._charSizeService),this._themeService=this._instantiationService.createInstance(R0),this._instantiationService.setService(zr,this._themeService),this._characterJoinerService=this._instantiationService.createInstance(Fl),this._instantiationService.setService(Z4,this._characterJoinerService),this._renderService=this._register(this._instantiationService.createInstance(E0,this.rows,this.screenElement)),this._instantiationService.setService(On,this._renderService),this._register(this._renderService.onRenderedViewportChange(i=>this._onRender.fire(i))),this.onResize(i=>this._renderService.resize(i.cols,i.rows)),this._compositionView=this._document.createElement("div"),this._compositionView.classList.add("composition-view"),this._compositionHelper=this._instantiationService.createInstance(k0,this.textarea,this._compositionView),this._helperContainer.appendChild(this._compositionView),this._mouseService=this._instantiationService.createInstance(A0),this._instantiationService.setService(Eu,this._mouseService);let n=this._linkifier.value=this._register(this._instantiationService.createInstance(z0,this.screenElement));this.element.appendChild(e);try{this._onWillOpen.fire(this.element)}catch{}this._renderService.hasRenderer()||this._renderService.setRenderer(this._createRenderer()),this._register(this.onCursorMove(()=>{this._renderService.handleCursorMove(),this._syncTextArea()})),this._register(this.onResize(()=>this._renderService.handleResize(this.cols,this.rows))),this._register(this.onBlur(()=>this._renderService.handleBlur())),this._register(this.onFocus(()=>this._renderService.handleFocus())),this._viewport=this._register(this._instantiationService.createInstance(j0,this.element,this.screenElement)),this._register(this._viewport.onRequestScrollLines(i=>{super.scrollLines(i,!1),this.refresh(0,this.rows-1)})),this._selectionService=this._register(this._instantiationService.createInstance(P0,this.element,this.screenElement,n)),this._instantiationService.setService(T$,this._selectionService),this._register(this._selectionService.onRequestScrollLines(i=>this.scrollLines(i.amount,i.suppressScrollEvent))),this._register(this._selectionService.onSelectionChange(()=>this._onSelectionChange.fire())),this._register(this._selectionService.onRequestRedraw(i=>this._renderService.handleSelectionChanged(i.start,i.end,i.columnSelectMode))),this._register(this._selectionService.onLinuxMouseSelection(i=>{this.textarea.value=i,this.textarea.focus(),this.textarea.select()})),this._register(os.any(this._onScroll.event,this._inputHandler.onScroll)(()=>{this._selectionService.refresh(),this._viewport?.queueSync()})),this._register(this._instantiationService.createInstance(C0,this.screenElement)),this._register(Ge(this.element,"mousedown",i=>this._selectionService.handleMouseDown(i))),this.coreMouseService.areMouseEventsActive?(this._selectionService.disable(),this.element.classList.add("enable-mouse-events")):this._selectionService.enable(),this.options.screenReaderMode&&(this._accessibilityManager.value=this._instantiationService.createInstance(Ul,this)),this._register(this.optionsService.onSpecificOptionChange("screenReaderMode",i=>this._handleScreenReaderModeOptionChange(i))),this.options.overviewRuler.width&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(Bl,this._viewportElement,this.screenElement))),this.optionsService.onSpecificOptionChange("overviewRuler",i=>{!this._overviewRulerRenderer&&i&&this._viewportElement&&this.screenElement&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(Bl,this._viewportElement,this.screenElement)))}),this._charSizeService.measure(),this.refresh(0,this.rows-1),this._initGlobal(),this.bindMouse()}_createRenderer(){return this._instantiationService.createInstance(N0,this,this._document,this.element,this.screenElement,this._viewportElement,this._helperContainer,this.linkifier)}bindMouse(){let t=this,e=this.element;function s(o){let a=t._mouseService.getMouseReportCoords(o,t.screenElement);if(!a)return!1;let l,c;switch(o.overrideType||o.type){case"mousemove":c=32,o.buttons===void 0?(l=3,o.button!==void 0&&(l=o.button<3?o.button:3)):l=o.buttons&1?0:o.buttons&4?1:o.buttons&2?2:3;break;case"mouseup":c=0,l=o.button<3?o.button:3;break;case"mousedown":c=1,l=o.button<3?o.button:3;break;case"wheel":if(t._customWheelEventHandler&&t._customWheelEventHandler(o)===!1)return!1;let d=o.deltaY;if(d===0||t.coreMouseService.consumeWheelEvent(o,t._renderService?.dimensions?.device?.cell?.height,t._coreBrowserService?.dpr)===0)return!1;c=d<0?0:1,l=4;break;default:return!1}return c===void 0||l===void 0||l>4?!1:t.coreMouseService.triggerMouseEvent({col:a.col,row:a.row,x:a.x,y:a.y,button:l,action:c,ctrl:o.ctrlKey,alt:o.altKey,shift:o.shiftKey})}let n={mouseup:null,wheel:null,mousedrag:null,mousemove:null},i={mouseup:o=>(s(o),o.buttons||(this._document.removeEventListener("mouseup",n.mouseup),n.mousedrag&&this._document.removeEventListener("mousemove",n.mousedrag)),this.cancel(o)),wheel:o=>(s(o),this.cancel(o,!0)),mousedrag:o=>{o.buttons&&s(o)},mousemove:o=>{o.buttons||s(o)}};this._register(this.coreMouseService.onProtocolChange(o=>{o?(this.optionsService.rawOptions.logLevel==="debug"&&this._logService.debug("Binding to mouse events:",this.coreMouseService.explainEvents(o)),this.element.classList.add("enable-mouse-events"),this._selectionService.disable()):(this._logService.debug("Unbinding from mouse events."),this.element.classList.remove("enable-mouse-events"),this._selectionService.enable()),o&8?n.mousemove||(e.addEventListener("mousemove",i.mousemove),n.mousemove=i.mousemove):(e.removeEventListener("mousemove",n.mousemove),n.mousemove=null),o&16?n.wheel||(e.addEventListener("wheel",i.wheel,{passive:!1}),n.wheel=i.wheel):(e.removeEventListener("wheel",n.wheel),n.wheel=null),o&2?n.mouseup||(n.mouseup=i.mouseup):(this._document.removeEventListener("mouseup",n.mouseup),n.mouseup=null),o&4?n.mousedrag||(n.mousedrag=i.mousedrag):(this._document.removeEventListener("mousemove",n.mousedrag),n.mousedrag=null)})),this.coreMouseService.activeProtocol=this.coreMouseService.activeProtocol,this._register(Ge(e,"mousedown",o=>{if(o.preventDefault(),this.focus(),!(!this.coreMouseService.areMouseEventsActive||this._selectionService.shouldForceSelection(o)))return s(o),n.mouseup&&this._document.addEventListener("mouseup",n.mouseup),n.mousedrag&&this._document.addEventListener("mousemove",n.mousedrag),this.cancel(o)})),this._register(Ge(e,"wheel",o=>{if(!n.wheel){if(this._customWheelEventHandler&&this._customWheelEventHandler(o)===!1)return!1;if(!this.buffer.hasScrollback){if(o.deltaY===0)return!1;if(t.coreMouseService.consumeWheelEvent(o,t._renderService?.dimensions?.device?.cell?.height,t._coreBrowserService?.dpr)===0)return this.cancel(o,!0);let a=_e.ESC+(this.coreService.decPrivateModes.applicationCursorKeys?"O":"[")+(o.deltaY<0?"A":"B");return this.coreService.triggerDataEvent(a,!0),this.cancel(o,!0)}}},{passive:!1}))}refresh(t,e){this._renderService?.refreshRows(t,e)}updateCursorStyle(t){this._selectionService?.shouldColumnSelect(t)?this.element.classList.add("column-select"):this.element.classList.remove("column-select")}_showCursor(){this.coreService.isCursorInitialized||(this.coreService.isCursorInitialized=!0,this.refresh(this.buffer.y,this.buffer.y))}scrollLines(t,e){this._viewport?this._viewport.scrollLines(t):super.scrollLines(t,e),this.refresh(0,this.rows-1)}scrollPages(t){this.scrollLines(t*(this.rows-1))}scrollToTop(){this.scrollLines(-this._bufferService.buffer.ydisp)}scrollToBottom(t){t&&this._viewport?this._viewport.scrollToLine(this.buffer.ybase,!0):this.scrollLines(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp)}scrollToLine(t){let e=t-this._bufferService.buffer.ydisp;e!==0&&this.scrollLines(e)}paste(t){U4(t,this.textarea,this.coreService,this.optionsService)}attachCustomKeyEventHandler(t){this._customKeyEventHandler=t}attachCustomWheelEventHandler(t){this._customWheelEventHandler=t}registerLinkProvider(t){return this._linkProviderService.registerLinkProvider(t)}registerCharacterJoiner(t){if(!this._characterJoinerService)throw new Error("Terminal must be opened first");let e=this._characterJoinerService.register(t);return this.refresh(0,this.rows-1),e}deregisterCharacterJoiner(t){if(!this._characterJoinerService)throw new Error("Terminal must be opened first");this._characterJoinerService.deregister(t)&&this.refresh(0,this.rows-1)}get markers(){return this.buffer.markers}registerMarker(t){return this.buffer.addMarker(this.buffer.ybase+this.buffer.y+t)}registerDecoration(t){return this._decorationService.registerDecoration(t)}hasSelection(){return this._selectionService?this._selectionService.hasSelection:!1}select(t,e,s){this._selectionService.setSelection(t,e,s)}getSelection(){return this._selectionService?this._selectionService.selectionText:""}getSelectionPosition(){if(!(!this._selectionService||!this._selectionService.hasSelection))return{start:{x:this._selectionService.selectionStart[0],y:this._selectionService.selectionStart[1]},end:{x:this._selectionService.selectionEnd[0],y:this._selectionService.selectionEnd[1]}}}clearSelection(){this._selectionService?.clearSelection()}selectAll(){this._selectionService?.selectAll()}selectLines(t,e){this._selectionService?.selectLines(t,e)}_keyDown(t){if(this._keyDownHandled=!1,this._keyDownSeen=!0,this._customKeyEventHandler&&this._customKeyEventHandler(t)===!1)return!1;let e=this.browser.isMac&&this.options.macOptionIsMeta&&t.altKey;if(!e&&!this._compositionHelper.keydown(t))return this.options.scrollOnUserInput&&this.buffer.ybase!==this.buffer.ydisp&&this.scrollToBottom(!0),!1;!e&&(t.key==="Dead"||t.key==="AltGraph")&&(this._unprocessedDeadKey=!0);let s=dz(t,this.coreService.decPrivateModes.applicationCursorKeys,this.browser.isMac,this.options.macOptionIsMeta);if(this.updateCursorStyle(t),s.type===3||s.type===2){let n=this.rows-1;return this.scrollLines(s.type===2?-n:n),this.cancel(t,!0)}if(s.type===1&&this.selectAll(),this._isThirdLevelShift(this.browser,t)||(s.cancel&&this.cancel(t,!0),!s.key)||t.key&&!t.ctrlKey&&!t.altKey&&!t.metaKey&&t.key.length===1&&t.key.charCodeAt(0)>=65&&t.key.charCodeAt(0)<=90)return!0;if(this._unprocessedDeadKey)return this._unprocessedDeadKey=!1,!0;if((s.key===_e.ETX||s.key===_e.CR)&&(this.textarea.value=""),this._onKey.fire({key:s.key,domEvent:t}),this._showCursor(),this.coreService.triggerDataEvent(s.key,!0),!this.optionsService.rawOptions.screenReaderMode||t.altKey||t.ctrlKey)return this.cancel(t,!0);this._keyDownHandled=!0}_isThirdLevelShift(t,e){let s=t.isMac&&!this.options.macOptionIsMeta&&e.altKey&&!e.ctrlKey&&!e.metaKey||t.isWindows&&e.altKey&&e.ctrlKey&&!e.metaKey||t.isWindows&&e.getModifierState("AltGraph");return e.type==="keypress"?s:s&&(!e.keyCode||e.keyCode>47)}_keyUp(t){this._keyDownSeen=!1,!(this._customKeyEventHandler&&this._customKeyEventHandler(t)===!1)&&(vz(t)||this.focus(),this.updateCursorStyle(t),this._keyPressHandled=!1)}_keyPress(t){let e;if(this._keyPressHandled=!1,this._keyDownHandled||this._customKeyEventHandler&&this._customKeyEventHandler(t)===!1)return!1;if(this.cancel(t),t.charCode)e=t.charCode;else if(t.which===null||t.which===void 0)e=t.keyCode;else if(t.which!==0&&t.charCode!==0)e=t.which;else return!1;return!e||(t.altKey||t.ctrlKey||t.metaKey)&&!this._isThirdLevelShift(this.browser,t)?!1:(e=String.fromCharCode(e),this._onKey.fire({key:e,domEvent:t}),this._showCursor(),this.coreService.triggerDataEvent(e,!0),this._keyPressHandled=!0,this._unprocessedDeadKey=!1,!0)}_inputEvent(t){if(t.data&&t.inputType==="insertText"&&(!t.composed||!this._keyDownSeen)&&!this.optionsService.rawOptions.screenReaderMode){if(this._keyPressHandled)return!1;this._unprocessedDeadKey=!1;let e=t.data;return this.coreService.triggerDataEvent(e,!0),this.cancel(t),!0}return!1}resize(t,e){if(t===this.cols&&e===this.rows){this._charSizeService&&!this._charSizeService.hasValidSize&&this._charSizeService.measure();return}super.resize(t,e)}_afterResize(t,e){this._charSizeService?.measure()}clear(){if(!(this.buffer.ybase===0&&this.buffer.y===0)){this.buffer.clearAllMarkers(),this.buffer.lines.set(0,this.buffer.lines.get(this.buffer.ybase+this.buffer.y)),this.buffer.lines.length=1,this.buffer.ydisp=0,this.buffer.ybase=0,this.buffer.y=0;for(let t=1;t<this.rows;t++)this.buffer.lines.push(this.buffer.getBlankLine(Dt));this._onScroll.fire({position:this.buffer.ydisp}),this.refresh(0,this.rows-1)}}reset(){this.options.rows=this.rows,this.options.cols=this.cols;let t=this._customKeyEventHandler;this._setup(),super.reset(),this._selectionService?.reset(),this._decorationService.reset(),this._customKeyEventHandler=t,this.refresh(0,this.rows-1)}clearTextureAtlas(){this._renderService?.clearTextureAtlas()}_reportFocus(){this.element?.classList.contains("focus")?this.coreService.triggerDataEvent(_e.ESC+"[I"):this.coreService.triggerDataEvent(_e.ESC+"[O")}_reportWindowsOptions(t){if(this._renderService)switch(t){case 0:let e=this._renderService.dimensions.css.canvas.width.toFixed(0),s=this._renderService.dimensions.css.canvas.height.toFixed(0);this.coreService.triggerDataEvent(`${_e.ESC}[4;${s};${e}t`);break;case 1:let n=this._renderService.dimensions.css.cell.width.toFixed(0),i=this._renderService.dimensions.css.cell.height.toFixed(0);this.coreService.triggerDataEvent(`${_e.ESC}[6;${i};${n}t`);break}}cancel(t,e){if(!(!this.options.cancelEvents&&!e))return t.preventDefault(),t.stopPropagation(),!1}};function vz(t){return t.keyCode===16||t.keyCode===17||t.keyCode===18}var bz=class{constructor(){this._addons=[]}dispose(){for(let t=this._addons.length-1;t>=0;t--)this._addons[t].instance.dispose()}loadAddon(t,e){let s={instance:e,dispose:e.dispose,isDisposed:!1};this._addons.push(s),e.dispose=()=>this._wrappedAddonDispose(s),e.activate(t)}_wrappedAddonDispose(t){if(t.isDisposed)return;let e=-1;for(let s=0;s<this._addons.length;s++)if(this._addons[s]===t){e=s;break}if(e===-1)throw new Error("Could not dispose an addon that has not been loaded");t.isDisposed=!0,t.dispose.apply(t.instance),this._addons.splice(e,1)}},yz=class{constructor(t){this._line=t}get isWrapped(){return this._line.isWrapped}get length(){return this._line.length}getCell(t,e){if(!(t<0||t>=this._line.length))return e?(this._line.loadCell(t,e),e):this._line.loadCell(t,new Gs)}translateToString(t,e,s){return this._line.translateToString(t,e,s)}},om=class{constructor(t,e){this._buffer=t,this.type=e}init(t){return this._buffer=t,this}get cursorY(){return this._buffer.y}get cursorX(){return this._buffer.x}get viewportY(){return this._buffer.ydisp}get baseY(){return this._buffer.ybase}get length(){return this._buffer.lines.length}getLine(t){let e=this._buffer.lines.get(t);if(e)return new yz(e)}getNullCell(){return new Gs}},_z=class extends tt{constructor(t){super(),this._core=t,this._onBufferChange=this._register(new Te),this.onBufferChange=this._onBufferChange.event,this._normal=new om(this._core.buffers.normal,"normal"),this._alternate=new om(this._core.buffers.alt,"alternate"),this._core.buffers.onBufferActivate(()=>this._onBufferChange.fire(this.active))}get active(){if(this._core.buffers.active===this._core.buffers.normal)return this.normal;if(this._core.buffers.active===this._core.buffers.alt)return this.alternate;throw new Error("Active buffer is neither normal nor alternate")}get normal(){return this._normal.init(this._core.buffers.normal)}get alternate(){return this._alternate.init(this._core.buffers.alt)}},Lz=class{constructor(t){this._core=t}registerCsiHandler(t,e){return this._core.registerCsiHandler(t,s=>e(s.toArray()))}addCsiHandler(t,e){return this.registerCsiHandler(t,e)}registerDcsHandler(t,e){return this._core.registerDcsHandler(t,(s,n)=>e(s,n.toArray()))}addDcsHandler(t,e){return this.registerDcsHandler(t,e)}registerEscHandler(t,e){return this._core.registerEscHandler(t,e)}addEscHandler(t,e){return this.registerEscHandler(t,e)}registerOscHandler(t,e){return this._core.registerOscHandler(t,e)}addOscHandler(t,e){return this.registerOscHandler(t,e)}},Sz=class{constructor(t){this._core=t}register(t){this._core.unicodeService.register(t)}get versions(){return this._core.unicodeService.versions}get activeVersion(){return this._core.unicodeService.activeVersion}set activeVersion(t){this._core.unicodeService.activeVersion=t}},wz=["cols","rows"],dn=0,jz=class extends tt{constructor(t){super(),this._core=this._register(new xz(t)),this._addonManager=this._register(new bz),this._publicOptions={...this._core.options};let e=n=>this._core.options[n],s=(n,i)=>{this._checkReadonlyOptions(n),this._core.options[n]=i};for(let n in this._core.options){let i={get:e.bind(this,n),set:s.bind(this,n)};Object.defineProperty(this._publicOptions,n,i)}}_checkReadonlyOptions(t){if(wz.includes(t))throw new Error(`Option "${t}" can only be set in the constructor`)}_checkProposedApi(){if(!this._core.optionsService.rawOptions.allowProposedApi)throw new Error("You must set the allowProposedApi option to true to use proposed API")}get onBell(){return this._core.onBell}get onBinary(){return this._core.onBinary}get onCursorMove(){return this._core.onCursorMove}get onData(){return this._core.onData}get onKey(){return this._core.onKey}get onLineFeed(){return this._core.onLineFeed}get onRender(){return this._core.onRender}get onResize(){return this._core.onResize}get onScroll(){return this._core.onScroll}get onSelectionChange(){return this._core.onSelectionChange}get onTitleChange(){return this._core.onTitleChange}get onWriteParsed(){return this._core.onWriteParsed}get element(){return this._core.element}get parser(){return this._parser||(this._parser=new Lz(this._core)),this._parser}get unicode(){return this._checkProposedApi(),new Sz(this._core)}get textarea(){return this._core.textarea}get rows(){return this._core.rows}get cols(){return this._core.cols}get buffer(){return this._buffer||(this._buffer=this._register(new _z(this._core))),this._buffer}get markers(){return this._checkProposedApi(),this._core.markers}get modes(){let t=this._core.coreService.decPrivateModes,e="none";switch(this._core.coreMouseService.activeProtocol){case"X10":e="x10";break;case"VT200":e="vt200";break;case"DRAG":e="drag";break;case"ANY":e="any";break}return{applicationCursorKeysMode:t.applicationCursorKeys,applicationKeypadMode:t.applicationKeypad,bracketedPasteMode:t.bracketedPasteMode,insertMode:this._core.coreService.modes.insertMode,mouseTrackingMode:e,originMode:t.origin,reverseWraparoundMode:t.reverseWraparound,sendFocusMode:t.sendFocus,synchronizedOutputMode:t.synchronizedOutput,wraparoundMode:t.wraparound}}get options(){return this._publicOptions}set options(t){for(let e in t)this._publicOptions[e]=t[e]}blur(){this._core.blur()}focus(){this._core.focus()}input(t,e=!0){this._core.input(t,e)}resize(t,e){this._verifyIntegers(t,e),this._core.resize(t,e)}open(t){this._core.open(t)}attachCustomKeyEventHandler(t){this._core.attachCustomKeyEventHandler(t)}attachCustomWheelEventHandler(t){this._core.attachCustomWheelEventHandler(t)}registerLinkProvider(t){return this._core.registerLinkProvider(t)}registerCharacterJoiner(t){return this._checkProposedApi(),this._core.registerCharacterJoiner(t)}deregisterCharacterJoiner(t){this._checkProposedApi(),this._core.deregisterCharacterJoiner(t)}registerMarker(t=0){return this._verifyIntegers(t),this._core.registerMarker(t)}registerDecoration(t){return this._checkProposedApi(),this._verifyPositiveIntegers(t.x??0,t.width??0,t.height??0),this._core.registerDecoration(t)}hasSelection(){return this._core.hasSelection()}select(t,e,s){this._verifyIntegers(t,e,s),this._core.select(t,e,s)}getSelection(){return this._core.getSelection()}getSelectionPosition(){return this._core.getSelectionPosition()}clearSelection(){this._core.clearSelection()}selectAll(){this._core.selectAll()}selectLines(t,e){this._verifyIntegers(t,e),this._core.selectLines(t,e)}dispose(){super.dispose()}scrollLines(t){this._verifyIntegers(t),this._core.scrollLines(t)}scrollPages(t){this._verifyIntegers(t),this._core.scrollPages(t)}scrollToTop(){this._core.scrollToTop()}scrollToBottom(){this._core.scrollToBottom()}scrollToLine(t){this._verifyIntegers(t),this._core.scrollToLine(t)}clear(){this._core.clear()}write(t,e){this._core.write(t,e)}writeln(t,e){this._core.write(t),this._core.write(`\r
|
|
515
|
+
`,e)}paste(t){this._core.paste(t)}refresh(t,e){this._verifyIntegers(t,e),this._core.refresh(t,e)}reset(){this._core.reset()}clearTextureAtlas(){this._core.clearTextureAtlas()}loadAddon(t){this._addonManager.loadAddon(this,t)}static get strings(){return{get promptLabel(){return o0.get()},set promptLabel(t){o0.set(t)},get tooMuchOutput(){return a0.get()},set tooMuchOutput(t){a0.set(t)}}}_verifyIntegers(...t){for(dn of t)if(dn===1/0||isNaN(dn)||dn%1!==0)throw new Error("This API only accepts integers")}_verifyPositiveIntegers(...t){for(dn of t)if(dn&&(dn===1/0||isNaN(dn)||dn%1!==0||dn<0))throw new Error("This API only accepts positive integers")}};var Cz=2,kz=1,Vz=class{activate(t){this._terminal=t}dispose(){}fit(){let t=this.proposeDimensions();if(!t||!this._terminal||isNaN(t.cols)||isNaN(t.rows))return;let e=this._terminal._core;(this._terminal.rows!==t.rows||this._terminal.cols!==t.cols)&&(e._renderService.clear(),this._terminal.resize(t.cols,t.rows))}proposeDimensions(){if(!this._terminal||!this._terminal.element||!this._terminal.element.parentElement)return;let t=this._terminal._core._renderService.dimensions;if(t.css.cell.width===0||t.css.cell.height===0)return;let e=this._terminal.options.scrollback===0?0:this._terminal.options.overviewRuler?.width||14,s=window.getComputedStyle(this._terminal.element.parentElement),n=parseInt(s.getPropertyValue("height")),i=Math.max(0,parseInt(s.getPropertyValue("width"))),o=window.getComputedStyle(this._terminal.element),a={top:parseInt(o.getPropertyValue("padding-top")),bottom:parseInt(o.getPropertyValue("padding-bottom")),right:parseInt(o.getPropertyValue("padding-right")),left:parseInt(o.getPropertyValue("padding-left"))},l=a.top+a.bottom,c=a.right+a.left,d=n-l,h=i-c-e;return{cols:Math.max(Cz,Math.floor(h/t.css.cell.width)),rows:Math.max(kz,Math.floor(d/t.css.cell.height))}}};function Nz({source:t,onReady:e,onSelectionChange:s,className:n}){const i=A.useRef(null),o=A.useRef(null),a=A.useRef(s);a.current=s;const l=Fs(),c=A.useRef(t);return c.current=t,ap((d,h)=>{d===c.current&&o.current?.write(h)}),A.useEffect(()=>{const d=i.current;if(!d)return;const h=getComputedStyle(document.documentElement),u=v=>h.getPropertyValue(v).trim()||void 0,f=new jz({allowTransparency:!1,fontFamily:u("--font-mono")||"ui-monospace, SFMono-Regular, Menlo, Consolas, monospace",fontSize:12.5,lineHeight:1.5,scrollback:5e3,cursorBlink:!1,disableStdin:!0,theme:{background:u("--sidebar")||u("--card")||u("--background")||"#1e1e1e",cursor:"transparent",foreground:u("--foreground")||"#d4d4d4",selectionBackground:u("--accent"),selectionForeground:u("--accent-foreground"),black:u("--muted"),red:u("--destructive"),green:u("--success"),yellow:u("--warning"),blue:u("--chart-1"),magenta:u("--chart-3"),cyan:u("--chart-5"),white:u("--foreground"),brightBlack:u("--muted-foreground"),brightRed:u("--destructive"),brightGreen:u("--success"),brightYellow:u("--warning"),brightBlue:u("--chart-1"),brightMagenta:u("--chart-3"),brightCyan:u("--chart-5"),brightWhite:u("--foreground")}}),m=new Vz;f.loadAddon(m),f.open(d),m.fit();const p=l.getBuffer(t);p&&f.write(p),o.current=f,e?.(f);const g=f.onSelectionChange(()=>{const v=!!f.getSelection();a.current?.(v,()=>f.getSelection())}),x=new ResizeObserver(()=>{m.fit()});return x.observe(d),()=>{g.dispose(),x.disconnect(),o.current=null,f.dispose()}},[]),r.jsx("div",{className:ie("h-full bg-sidebar p-3",n),children:r.jsx("div",{ref:i,className:"h-full"})})}function Tz(t){const e=re(),s=Fs(),[n,i]=A.useState(Li),[o,a]=A.useState([]),[l,c]=A.useState(new Set),d=A.useRef(!1);if(!d.current&&s.scripts.length>0){const w=Wy.find(j=>s.scripts.includes(j));w&&(d.current=!0,a(j=>j.includes(w)?j:[...j,w]),i(w))}if(l.size>0){let w=!1;const j=new Set(l);for(const S of l)s.activeProcesses.includes(S)||(j.delete(S),w=!0);w&&c(j)}const h=()=>t.onOpenChange(!t.open),u=w=>{i(w),t.open||t.onOpenChange(!0)},f=w=>!t.virtualMcpId||!t.branch?Promise.resolve(null):fetch(`/api/${encodeURIComponent(t.orgSlug)}/sandbox/${encodeURIComponent(t.virtualMcpId)}/${encodeURIComponent(t.branch)}/exec/${encodeURIComponent(w)}`,{method:"POST"}),m=w=>!t.virtualMcpId||!t.branch?Promise.resolve(null):fetch(`/api/${encodeURIComponent(t.orgSlug)}/sandbox/${encodeURIComponent(t.virtualMcpId)}/${encodeURIComponent(t.branch)}/exec/${encodeURIComponent(w)}/kill`,{method:"POST"}),p=async(w,j)=>{try{const S=await f(w);if(S===null)return;if(!S.ok)throw new Error(`Exec failed: ${S.statusText}`)}catch{ge.error(j)}},g=async w=>{a(j=>j.includes(w)?j:[...j,w]),i(w),t.onOpenChange(!0),await p(w,e("sandbox.drawer.failedToRun",{name:w}))},x=async w=>{await m(w),a(j=>j.filter(S=>S!==w)),n===w&&i(Li)},v=async()=>{const j=s.activeProcesses.includes(n)?e("sandbox.drawer.failedToRestart",{name:n}):e("sandbox.drawer.failedToRun",{name:n});await p(n,j)},b=async()=>{if(!l.has(n)){c(w=>new Set(w).add(n));try{const w=await m(n);if(w===null){c(j=>{const S=new Set(j);return S.delete(n),S});return}if(!w.ok)throw new Error(`Kill failed: ${w.statusText}`)}catch{c(w=>{const j=new Set(w);return j.delete(n),j}),ge.error(e("sandbox.drawer.failedToStop",{name:n}))}}},_=n!==Li&&o.includes(n),y=_&&s.activeProcesses.includes(n),L=_&&l.has(n);return r.jsxs("div",{className:"flex shrink-0 flex-col",style:{height:t.open?"50%":"auto"},children:[r.jsx(u$,{status:t.status,open:t.open,onToggle:h,onStart:t.status==="idle"?t.onStart:void 0,onStop:t.status==="running"||t.status==="starting"?t.onStop:void 0,onRestart:t.status==="running"?t.onRestart:void 0,onResume:t.status==="suspended"?t.onResume:void 0,onRetry:t.status==="errored"?t.onRetry:void 0,scripts:t.scripts,active:n,scriptTabs:o,onSelectTab:u,onAddScript:g,onCloseScript:x,showScriptControls:_,scriptIsRunning:y,scriptIsKilling:L,onRunActiveScript:v,onStopActiveScript:b}),t.open&&r.jsx("div",{className:"flex-1 overflow-hidden",children:r.jsx(Az,{vmId:t.vmId,active:n,hasData:s.hasData(n),onRunActive:v})})]})}function Az(t){const e=B.c(16),{vmId:s,active:n,hasData:i,onRunActive:o}=t,a=re();if(!s)return null;if(n===Li||i){let m;return e[0]!==n?(m=r.jsx(Nz,{source:n,className:"h-full"},n),e[0]=n,e[1]=m):m=e[1],m}let l;e[2]!==n||e[3]!==a?(l=a("sandbox.drawer.scriptNotRunning",{name:n}),e[2]=n,e[3]=a,e[4]=l):l=e[4];let c;e[5]!==l?(c=r.jsx("p",{children:l}),e[5]=l,e[6]=c):c=e[6];let d;e[7]===Symbol.for("react.memo_cache_sentinel")?(d=r.jsx(Vi,{className:"size-3.5"}),e[7]=d):d=e[7];let h;e[8]!==a?(h=a("sandbox.drawer.run"),e[8]=a,e[9]=h):h=e[9];let u;e[10]!==o||e[11]!==h?(u=r.jsxs("button",{type:"button",onClick:o,className:"flex items-center gap-1.5 rounded-md border border-border px-3 py-1.5 text-xs text-foreground hover:bg-accent",children:[d," ",h]}),e[10]=o,e[11]=h,e[12]=u):u=e[12];let f;return e[13]!==c||e[14]!==u?(f=r.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-3 text-sm text-muted-foreground",children:[c,u]}),e[13]=c,e[14]=u,e[15]=f):f=e[15],f}const P5=t=>`preview-drawer:${t}`,Ez=/Authentication failed for|Invalid username or token|Password authentication is not supported/i;function Pz(t){try{const e=localStorage.getItem(P5(t));return e?!!JSON.parse(e).open:!1}catch{return!1}}function Rz(t,e){try{localStorage.setItem(P5(t),JSON.stringify({open:e}))}catch{}}function Dz(){const t=B.c(21),e=di(),{org:s}=Fe(),n=e?.virtualMcpId??null,i=Er(),o=Fs(),a=A.useRef(null);let l;t[0]!==o||t[1]!==i||t[2]!==n?(l=b=>{b!=="setup"||!n||a.current!==n&&Ez.test(o.getBuffer("setup"))&&(a.current=n,i.restart())},t[0]=o,t[1]=i,t[2]=n,t[3]=l):l=t[3],ap(l);const c=n??"__no-vmcp__",[d,h]=A.useState(null),u=A.useRef(null);u.current!==c&&(u.current=c,h(Pz(c)));const f=d??!1;let m;t[4]!==c?(m=b=>{h(b),Rz(c,b)},t[4]=c,t[5]=m):m=t[5];const p=m,g=i.vmEntry?.sandboxHandle??"no-vm",x=i.vmEntry?.sandboxHandle??null;let v;return t[6]!==o.scripts||t[7]!==p||t[8]!==i.branch||t[9]!==i.restart||t[10]!==i.resume||t[11]!==i.retry||t[12]!==i.start||t[13]!==i.status||t[14]!==i.stop||t[15]!==f||t[16]!==s.slug||t[17]!==g||t[18]!==x||t[19]!==n?(v=r.jsx(Tz,{vmId:x,orgSlug:s.slug,virtualMcpId:n,branch:i.branch,status:i.status,scripts:o.scripts,open:f,onOpenChange:p,onStart:i.start,onStop:i.stop,onRestart:i.restart,onResume:i.resume,onRetry:i.retry},g),t[6]=o.scripts,t[7]=p,t[8]=i.branch,t[9]=i.restart,t[10]=i.resume,t[11]=i.retry,t[12]=i.start,t[13]=i.status,t[14]=i.stop,t[15]=f,t[16]=s.slug,t[17]=g,t[18]=x,t[19]=n,t[20]=v):v=t[20],v}function R5(t){const e=B.c(15),{virtualMcpId:s,taskId:n}=t,i=di(),{activeTask:o}=Zt();let a;e[0]===Symbol.for("react.memo_cache_sentinel")?(a={strict:!1},e[0]=a):a=e[0];const{main:l}=wr(a);let c;e[1]!==o?.metadata||e[2]!==i?.entity?.metadata?(c=sn(i?.entity?.metadata)||sn(o?.metadata),e[1]=o?.metadata,e[2]=i?.entity?.metadata,e[3]=c):c=e[3];const d=c;let h;e[4]!==d||e[5]!==l?(h=d&&!(typeof l=="string"&&_b.has(l)),e[4]=d,e[5]=l,e[6]=h):h=e[6];const u=h;let f;e[7]!==n||e[8]!==s?(f=r.jsx("div",{className:"flex-1 min-h-0 overflow-hidden",children:r.jsx(d$,{taskId:n,virtualMcpId:s})}),e[7]=n,e[8]=s,e[9]=f):f=e[9];let m;e[10]!==u?(m=u&&r.jsx(Dz,{}),e[10]=u,e[11]=m):m=e[11];let p;return e[12]!==f||e[13]!==m?(p=r.jsxs("div",{className:"flex h-full min-h-0 flex-col",children:[f,m]}),e[12]=f,e[13]=m,e[14]=p):p=e[14],p}function D5(t){const e=B.c(4),{chatContent:s}=t;let n;e[0]!==s?(n=s??r.jsx(Ap,{}),e[0]=s,e[1]=n):n=e[1];let i;return e[2]!==n?(i=r.jsx("div",{"data-testid":"chat-panel",className:"h-full min-h-0",children:n}),e[2]=n,e[3]=i):i=e[3],i}function am(t){const e=B.c(3),{children:s,testId:n}=t;let i;return e[0]!==s||e[1]!==n?(i=r.jsx("div",{className:"h-full p-0.5 pt-0.25",children:r.jsx("div",{"data-testid":n,className:"h-full min-h-0 overflow-hidden rounded-[0.75rem] bg-background card-shadow",children:s})}),e[0]=s,e[1]=n,e[2]=i):i=e[2],i}function Iz(t){const e=B.c(38),{virtualMcpId:s,taskId:n,sidePanel:i,mainOpen:o,chatContent:a}=t,[,l]=A.useTransition(),[c,d]=WS(),h=A.useRef(null);let u;e[0]!==o||e[1]!==i?(u=FS({sidePanel:i,mainOpen:o}),e[0]=o,e[1]=i,e[2]=u):u=e[2];const f=u,m=i!==null&&o?c:f.side,p=100-m;let g,x;e[3]!==p||e[4]!==m?(g=()=>{h.current?.setLayout([m,p])},x=[m,p],e[3]=p,e[4]=m,e[5]=g,e[6]=x):(g=e[5],x=e[6]),A.useEffect(g,x);const v=`${s}-${n}`;let b;e[7]===Symbol.for("react.memo_cache_sentinel")?(b={overflow:"visible"},e[7]=b):b=e[7];const _=f.side,y=i!==null?"min-w-[320px]":"min-w-0";let L;e[8]!==y?(L=ie("overflow-hidden bg-sidebar",y),e[8]=y,e[9]=L):L=e[9];let w;e[10]!==o||e[11]!==d||e[12]!==i?(w=D=>l(()=>{i!==null&&o&&D>0&&D<100&&d(D)}),e[10]=o,e[11]=d,e[12]=i,e[13]=w):w=e[13];let j;e[14]!==a||e[15]!==i?(j=i!==null&&r.jsx(D5,{chatContent:a}),e[14]=a,e[15]=i,e[16]=j):j=e[16];let S;e[17]!==j?(S=r.jsx(am,{testId:"side-panel",children:j}),e[17]=j,e[18]=S):S=e[18];let C;e[19]!==f.side||e[20]!==S||e[21]!==L||e[22]!==w?(C=r.jsx(al,{order:1,defaultSize:_,minSize:20,collapsible:!0,collapsedSize:0,className:L,onResize:w,children:S}),e[19]=f.side,e[20]=S,e[21]=L,e[22]=w,e[23]=C):C=e[23];let N;e[24]===Symbol.for("react.memo_cache_sentinel")?(N=r.jsx(d2,{className:"bg-sidebar"}),e[24]=N):N=e[24];const V=f.main,E=o?"min-w-[320px]":"min-w-0";let T;e[25]!==E?(T=ie("min-w-0 overflow-hidden bg-sidebar",E),e[25]=E,e[26]=T):T=e[26];let k;e[27]!==n||e[28]!==s?(k=r.jsx(am,{testId:"main-panel",children:r.jsx(R5,{taskId:n,virtualMcpId:s})}),e[27]=n,e[28]=s,e[29]=k):k=e[29];let R;e[30]!==f.main||e[31]!==T||e[32]!==k?(R=r.jsx(al,{order:2,defaultSize:V,minSize:20,collapsible:!0,collapsedSize:0,className:T,children:k}),e[30]=f.main,e[31]=T,e[32]=k,e[33]=R):R=e[33];let P;return e[34]!==C||e[35]!==R||e[36]!==v?(P=r.jsxs(c2,{ref:h,direction:"horizontal",className:"flex-1 min-h-0 pb-1 pr-1 pl-0 pt-0",style:b,children:[C,N,R]},v),e[34]=C,e[35]=R,e[36]=v,e[37]=P):P=e[37],P}function I5(t){const e=B.c(13),s=St();let n;e[0]===Symbol.for("react.memo_cache_sentinel")?(n={strict:!1},e[0]=n):n=e[0];const i=Wl(n);let o;e[1]===Symbol.for("react.memo_cache_sentinel")?(o={strict:!1},e[1]=o):o=e[1];const a=wr(o),l=a.main===t,c=A.useRef(void 0),d=!!(i.org&&i.taskId);let h;e[2]!==l||e[3]!==s||e[4]!==t||e[5]!==i.org||e[6]!==i.taskId||e[7]!==a.main?(h=()=>{if(!i.org||!i.taskId)return;const m=i.org,p=i.taskId;s({to:"/$org/$taskId",params:{org:m,taskId:p},search:g=>{const x={...g};if(l){const v=c.current;v&&v!==t?x.main=v:delete x.main}else c.current=a.main===0?void 0:a.main,x.main=t;return x},replace:!0})},e[2]=l,e[3]=s,e[4]=t,e[5]=i.org,e[6]=i.taskId,e[7]=a.main,e[8]=h):h=e[8];const u=h;let f;return e[9]!==l||e[10]!==d||e[11]!==u?(f={active:l,enabled:d,toggle:u},e[9]=l,e[10]=d,e[11]=u,e[12]=f):f=e[12],f}function Mz(){const t=B.c(10),e=re(),s=tc(),{active:n,enabled:i,toggle:o}=I5("files");if(!i||s)return null;let a;t[0]!==e?(a=e("agentShellLayout.libraryToggle.library"),t[0]=e,t[1]=a):a=t[1];let l;t[2]===Symbol.for("react.memo_cache_sentinel")?(l={kind:"component",Component:ei},t[2]=l):l=t[2];let c;t[3]!==n||t[4]!==o?(c=()=>{$e("agent_toolbar_toggled",{button:"library",next_state:n?"closed":"open"}),o()},t[3]=n,t[4]=o,t[5]=c):c=t[5];let d;return t[6]!==n||t[7]!==a||t[8]!==c?(d=r.jsx(Zl,{title:a,icon:l,active:n,className:"wco-no-drag h-10 md:h-8 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/50",onClick:c}),t[6]=n,t[7]=a,t[8]=c,t[9]=d):d=t[9],d}function Oz(){const t=B.c(10),e=re(),{active:s,enabled:n,toggle:i}=I5("board");if(!n)return null;let o;t[0]!==e?(o=e("agentShellLayout.tasksToggle.tasks"),t[0]=e,t[1]=o):o=t[1];let a;t[2]===Symbol.for("react.memo_cache_sentinel")?(a={kind:"component",Component:e2},t[2]=a):a=t[2];let l;t[3]!==s||t[4]!==i?(l=()=>{$e("agent_toolbar_toggled",{button:"tasks",next_state:s?"closed":"open"}),i()},t[3]=s,t[4]=i,t[5]=l):l=t[5];let c;return t[6]!==s||t[7]!==o||t[8]!==l?(c=r.jsx(Zl,{title:o,icon:a,active:s,className:"wco-no-drag h-10 md:h-8 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/50",onClick:l}),t[6]=s,t[7]=o,t[8]=l,t[9]=c):c=t[9],c}function $z(t){const e=B.c(15),{sidePanel:s,toggleSidePanel:n,disableActiveSidePanelToggle:i}=t,o=i===void 0?!1:i,a=re();let l;e[0]!==a?(l=a("agentShellLayout.toggleButtons.chat"),e[0]=a,e[1]=l):l=e[1];let c;e[2]===Symbol.for("react.memo_cache_sentinel")?(c={kind:"component",Component:t2},e[2]=c):c=e[2];const d=s==="chat",h=o&&s==="chat";let u;e[3]!==s||e[4]!==n?(u=()=>{$e("agent_toolbar_toggled",{button:"chat",next_state:s==="chat"?"closed":"open"}),n("chat")},e[3]=s,e[4]=n,e[5]=u):u=e[5];let f;e[6]!==l||e[7]!==d||e[8]!==h||e[9]!==u?(f=r.jsx(Zl,{title:l,icon:c,active:d,disabled:h,className:"wco-no-drag h-10 md:h-8 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/50 disabled:opacity-50",onClick:u}),e[6]=l,e[7]=d,e[8]=h,e[9]=u,e[10]=f):f=e[10];let m,p;e[11]===Symbol.for("react.memo_cache_sentinel")?(m=r.jsx(Oz,{}),p=r.jsx(Mz,{}),e[11]=m,e[12]=p):(m=e[11],p=e[12]);let g;return e[13]!==f?(g=r.jsxs(r.Fragment,{children:[f,m,p]}),e[13]=f,e[14]=g):g=e[14],g}function Bz(t,e,s){if(t.length<=s)return{visible:t,overflow:[]};const n=t.slice(0,s),i=t.slice(s);if(e==null)return{visible:n,overflow:i};if(n.some(u=>u.id===e))return{visible:n,overflow:i};const a=i.findIndex(u=>u.id===e);if(a===-1)return{visible:n,overflow:i};const l=n[n.length-1],c=i[a],d=[...n.slice(0,-1),c],h=[l,...i.slice(0,a),...i.slice(a+1)];return{visible:d,overflow:h}}function Fz(t){const e=B.c(21),{overflow:s,onSelect:n}=t,i=re(),[o,a]=A.useState(!1);let l;e[0]!==n?(l=x=>{a(!1),n(x)},e[0]=n,e[1]=l):l=e[1];const c=l;let d;e[2]!==i?(d=i("mainPanelTabs.tabOverflowMenu.moreTabs"),e[2]=i,e[3]=d):d=e[3];let h;e[4]!==i?(h=i("mainPanelTabs.tabOverflowMenu.moreTabs"),e[4]=i,e[5]=h):h=e[5];let u;e[6]===Symbol.for("react.memo_cache_sentinel")?(u=r.jsx(ai,{className:"size-4"}),e[6]=u):u=e[6];let f;e[7]!==d||e[8]!==h?(f=r.jsx(Es,{asChild:!0,children:r.jsx("button",{type:"button",title:d,"aria-label":h,className:"shrink-0 flex size-8 items-center justify-center rounded-md text-muted-foreground hover:bg-accent hover:text-foreground transition-colors",children:u})}),e[7]=d,e[8]=h,e[9]=f):f=e[9];let m;if(e[10]!==c||e[11]!==s){let x;e[13]!==c?(x=v=>r.jsx("li",{children:r.jsxs("button",{type:"button",onClick:()=>c(v.id),className:"w-full flex items-center gap-2 px-3 py-2 rounded-md hover:bg-accent text-sm text-foreground",children:[r.jsx("span",{className:"flex size-5 items-center justify-center shrink-0",children:r.jsx(m9,{icon:v.icon})}),r.jsx("span",{className:"truncate",children:v.title})]})},v.id),e[13]=c,e[14]=x):x=e[14],m=s.map(x),e[10]=c,e[11]=s,e[12]=m}else m=e[12];let p;e[15]!==m?(p=r.jsx(Ps,{align:"end",className:"w-56 p-1",children:r.jsx("ul",{className:"flex flex-col",children:m})}),e[15]=m,e[16]=p):p=e[16];let g;return e[17]!==o||e[18]!==f||e[19]!==p?(g=r.jsxs(As,{open:o,onOpenChange:a,children:[f,p]}),e[17]=o,e[18]=f,e[19]=p,e[20]=g):g=e[20],g}const zz=6;function Kz(t){const e=B.c(21),{virtualMcpId:s,taskId:n,disableActiveMainToggle:i}=t,o=i===void 0?!1:i,a=St();let l;e[0]!==n||e[1]!==s?(l={virtualMcpId:s,taskId:n},e[0]=n,e[1]=s,e[2]=l):l=e[2];const{tabs:c,activeTab:d,mainOpen:h,setActiveTab:u}=H9(l);let f,m,p,g;if(e[3]!==d||e[4]!==o||e[5]!==h||e[6]!==a||e[7]!==u||e[8]!==c||e[9]!==s){const b=Lb({activeTab:d,mainOpen:h}),_=S=>S.id==="automations"?b:h&&S.id===d,L=c.find(S=>_(S))?.id??null,{visible:w,overflow:j}=Bz(c,L,zz);m=j,f=S=>{const C=c.find(V=>V.id===S);if(o&&C&&_(C))return;const N=L===S&&h;if($e("main_panel_tab_clicked",{virtual_mcp_id:s,tab_id:S,tab_kind:C?.kind??null,was_active:N}),S==="automations"){const V=Sb({activeTab:d,mainOpen:h});a({to:".",search:E=>({...E,main:V}),replace:!0});return}u(S)},p="flex items-center min-w-0 gap-0.5",g=w.map(S=>r.jsx(Zl,{title:S.title,icon:S.icon,active:_(S),locked:o&&_(S),onClick:()=>f(S.id)},S.id)),e[3]=d,e[4]=o,e[5]=h,e[6]=a,e[7]=u,e[8]=c,e[9]=s,e[10]=f,e[11]=m,e[12]=p,e[13]=g}else f=e[10],m=e[11],p=e[12],g=e[13];let x;e[14]!==f||e[15]!==m?(x=m.length>0&&r.jsx(Fz,{overflow:m,onSelect:f}),e[14]=f,e[15]=m,e[16]=x):x=e[16];let v;return e[17]!==p||e[18]!==g||e[19]!==x?(v=r.jsxs("div",{className:p,children:[g,x]}),e[17]=p,e[18]=g,e[19]=x,e[20]=v):v=e[20],v}const Td="__mobile-main-panel-tab-select__";function Uz({tabs:t,activeTab:e,mainOpen:s,t:n}){const i=t.find(a=>a.id===e),o=n("mainPanelTabs.mobileMainPanelTabSelect.mainView");return s?i?.title??o:i?.title??t[0]?.title??o}const Hz={kind:"component",Component:t2},Wz={kind:"component",Component:e2},qz={kind:"component",Component:ei};function Gz(t){const e=B.c(62),{virtualMcpId:s,taskId:n}=t,i=re(),o=St();let a;e[0]===Symbol.for("react.memo_cache_sentinel")?(a={strict:!1},e[0]=a):a=e[0];const l=Wl(a);let c;e[1]!==n||e[2]!==s?(c={virtualMcpId:s,taskId:n},e[1]=n,e[2]=s,e[3]=c):c=e[3];const{tabs:d,activeTab:h,mainOpen:u}=H9(c),{org:f}=Fe(),m=tc();let p;e[4]!==f.id?(p=il(f.id),e[4]=f.id,e[5]=p):p=e[5];const g=s===p,x=!!(l.org&&l.taskId);let v;e[6]!==i?(v=i("mainPanelTabs.mobileMainPanelTabSelect.chat"),e[6]=i,e[7]=v):v=e[7];let b;e[8]!==v?(b={value:"chat",title:v,icon:Hz},e[8]=v,e[9]=b):b=e[9];let _;if(e[10]!==x||e[11]!==i||e[12]!==b||e[13]!==d){let $,z;e[15]!==x||e[16]!==i?($=x?[{value:"board",title:i("mainPanelTabs.mobileMainPanelTabSelect.tasks"),icon:Wz}]:[],z=x?[{value:"files",title:i("mainPanelTabs.mobileMainPanelTabSelect.library"),icon:qz}]:[],e[15]=x,e[16]=i,e[17]=$,e[18]=z):($=e[17],z=e[18]),_=[b,...d.map(Jz),...$,...z],e[10]=x,e[11]=i,e[12]=b,e[13]=d,e[14]=_}else _=e[14];const y=_;let L;e[19]!==h||e[20]!==u||e[21]!==y?(L=u?y.find($=>$.value===h)?.value??h:"chat",e[19]=h,e[20]=u,e[21]=y,e[22]=L):L=e[22];const w=L;let j;e[23]!==w||e[24]!==y?(j=y.find($=>$.value===w),e[23]=w,e[24]=y,e[25]=j):j=e[25];const S=j;let C;e[26]!==h||e[27]!==u||e[28]!==S?.title||e[29]!==i||e[30]!==d?(C=S?.title??Uz({tabs:d,activeTab:h,mainOpen:u,t:i}),e[26]=h,e[27]=u,e[28]=S?.title,e[29]=i,e[30]=d,e[31]=C):C=e[31];const N=C;let V;e[32]!==o||e[33]!==g||e[34]!==f.id||e[35]!==f.slug||e[36]!==m||e[37]!==s?(V=$=>{if($!==Td){if($e("main_panel_tab_clicked",{virtual_mcp_id:s,tab_id:$,source:"mobile_select"}),Xp({reportsOnly:m,onReportAgent:g,tabId:$})){o({to:"/$org/$taskId",params:{org:f.slug,taskId:crypto.randomUUID()},search:{virtualmcpid:il(f.id),main:$}});return}o({to:".",search:z=>$==="chat"?{...z,sidepanel:"chat",main:0}:{...z,sidepanel:0,main:$},replace:!0})}},e[32]=o,e[33]=g,e[34]=f.id,e[35]=f.slug,e[36]=m,e[37]=s,e[38]=V):V=e[38];const E=V;let T;e[39]!==i?(T=i("mainPanelTabs.mobileMainPanelTabSelect.view"),e[39]=i,e[40]=T):T=e[40];let k;e[41]!==S?(k=S&&r.jsx("span",{className:"flex size-5 shrink-0 items-center justify-center",children:r.jsx(m9,{icon:S.icon,className:"size-5"})}),e[41]=S,e[42]=k):k=e[42];let R;e[43]!==N?(R=r.jsx("span",{className:"min-w-0 truncate",children:N}),e[43]=N,e[44]=R):R=e[44];let P;e[45]!==k||e[46]!==R?(P=r.jsxs("span",{className:"flex min-w-0 items-center gap-1.5",children:[k,R]}),e[45]=k,e[46]=R,e[47]=P):P=e[47];let D;e[48]!==T||e[49]!==P?(D=r.jsx(Jt,{"aria-label":T,className:"h-10! w-full min-w-0 max-w-[7.5rem] rounded-md border-0 bg-transparent px-1.5 text-xs shadow-none [--card-shadow:none]",children:P}),e[48]=T,e[49]=P,e[50]=D):D=e[50];let I;e[51]!==N?(I=r.jsx(vt,{value:Td,disabled:!0,hideCheck:!0,className:"hidden",children:N}),e[51]=N,e[52]=I):I=e[52];let M;e[53]!==y?(M=y.map(Yz),e[53]=y,e[54]=M):M=e[54];let O;e[55]!==I||e[56]!==M?(O=r.jsxs(Xt,{align:"end",className:"w-56",children:[I,M]}),e[55]=I,e[56]=M,e[57]=O):O=e[57];let F;return e[58]!==E||e[59]!==D||e[60]!==O?(F=r.jsxs(Qt,{value:Td,onValueChange:E,children:[D,O]}),e[58]=E,e[59]=D,e[60]=O,e[61]=F):F=e[61],F}function Yz(t){return r.jsx(vt,{value:t.value,children:r.jsxs("span",{className:"flex min-w-0 items-center gap-2",children:[r.jsx("span",{className:"flex size-5 shrink-0 items-center justify-center",children:r.jsx(m9,{icon:t.icon})}),r.jsx("span",{className:"min-w-0 truncate",children:t.title})]})},t.value)}function Jz(t){return{value:t.id,title:t.title,icon:t.icon}}function M5(t){return ca({userName:t?.name,userEmail:t?.email})??void 0}const Xz=new Set(["main","master"]);function Fu(t,e){return Xz.has(t.trim().toLowerCase())?e("thread.headerActions.publishToProduction"):e("thread.headerActions.publish")}function Qz(t){const e=B.c(29),{baseBranch:s,disabled:n,loading:i,onPublish:o,onReview:a}=t,l=i===void 0?!1:i,c=re();let d;e[0]!==s||e[1]!==c?(d=Fu(s,c),e[0]=s,e[1]=c,e[2]=d):d=e[2];const h=d;let u;e[3]!==o?(u=()=>{o()},e[3]=o,e[4]=u):u=e[4];let f;e[5]!==l?(f=l?r.jsx(wi,{size:"xs",variant:"default"}):null,e[5]=l,e[6]=f):f=e[6];let m;e[7]!==n||e[8]!==h||e[9]!==u||e[10]!==f?(m=r.jsxs(le,{size:"sm",variant:"success",className:"rounded-r-none border-r border-success-foreground/20",disabled:n,onClick:u,children:[f,h]}),e[7]=n,e[8]=h,e[9]=u,e[10]=f,e[11]=m):m=e[11];let p;e[12]!==c?(p=c("thread.mergeSplitButton.moreActionsAriaLabel"),e[12]=c,e[13]=p):p=e[13];let g;e[14]===Symbol.for("react.memo_cache_sentinel")?(g=r.jsx(ss,{className:"h-3.5 w-3.5"}),e[14]=g):g=e[14];let x;e[15]!==n||e[16]!==p?(x=r.jsx(ds,{asChild:!0,children:r.jsx(le,{size:"sm",variant:"success",className:"rounded-l-none px-2",disabled:n,"aria-label":p,children:g})}),e[15]=n,e[16]=p,e[17]=x):x=e[17];let v;e[18]!==a||e[19]!==c?(v=a?r.jsx(Xe,{onClick:a,children:c("thread.mergeSplitButton.review")}):null,e[18]=a,e[19]=c,e[20]=v):v=e[20];let b;e[21]!==v?(b=r.jsx(hs,{align:"end",children:v}),e[21]=v,e[22]=b):b=e[22];let _;e[23]!==b||e[24]!==x?(_=r.jsxs(us,{children:[x,b]}),e[23]=b,e[24]=x,e[25]=_):_=e[25];let y;return e[26]!==_||e[27]!==m?(y=r.jsxs("div",{className:"inline-flex items-stretch rounded-md",children:[m,_]}),e[26]=_,e[27]=m,e[28]=y):y=e[28],y}function Zz(t,e,s,n,i){return["smart-review-verdict",t,e,s,n,i]}function eK(t){const e=B.c(24),{orgSlug:s,virtualMcpId:n,branch:i,status:o,diff:a,enabled:l}=t,[c]=ii(),{language:d}=c;let h,u,f;if(e[0]!==i||e[1]!==a||e[2]!==l||e[3]!==d||e[4]!==s||e[5]!==o||e[6]!==n){const _=a?dT(a):"";h=l&&!!i&&!!o&&!!a&&_!=="",f=Ft,u=Zz(s,n,i,_,d),e[0]=i,e[1]=a,e[2]=l,e[3]=d,e[4]=s,e[5]=o,e[6]=n,e[7]=h,e[8]=u,e[9]=f}else h=e[7],u=e[8],f=e[9];let m;e[10]!==i||e[11]!==a||e[12]!==d||e[13]!==s||e[14]!==o||e[15]!==n?(m=()=>uT(s,n,i,{status:o,diff:a,language:d}),e[10]=i,e[11]=a,e[12]=d,e[13]=s,e[14]=o,e[15]=n,e[16]=m):m=e[16];let p;e[17]!==h||e[18]!==u||e[19]!==m?(p={queryKey:u,queryFn:m,enabled:h,staleTime:1/0,gcTime:6e5,retry:tK},e[17]=h,e[18]=u,e[19]=m,e[20]=p):p=e[20];const g=f(p),x=g.data??null,v=h&&g.isFetching&&!g.data;let b;return e[21]!==x||e[22]!==v?(b={verdict:x,loading:v},e[21]=x,e[22]=v,e[23]=b):b=e[23],b}function tK(t,e){return!du(e)&&t<1}function sK(t,e,s,n,i){return["publish-gate",t,e,s,n,i]}function nK(t){const e=B.c(23),{orgSlug:s,virtualMcpId:n,branch:i,base:o,headSha:a,signature:l,policy:c,enabled:d}=t,h=d===void 0?!0:d;let u;e[0]!==o||e[1]!==i||e[2]!==s||e[3]!==l||e[4]!==n?(u=sK(s,n,i,o,l),e[0]=o,e[1]=i,e[2]=s,e[3]=l,e[4]=n,e[5]=u):u=e[5];let f;e[6]!==o||e[7]!==i||e[8]!==a||e[9]!==s||e[10]!==n?(f=async()=>{const _=await Ga(s,n,i),y=(_.aheadOfBase??0)>0?await lr(s,n,i,{base:o,...a?{headSha:a}:{}}):null,L=_c(_)?await lr(s,n,i):null;return{status:_,diff:ag(y,L)}},e[6]=o,e[7]=i,e[8]=a,e[9]=s,e[10]=n,e[11]=f):f=e[11];const m=h&&!!i;let p;e[12]!==u||e[13]!==f||e[14]!==m?(p={queryKey:u,queryFn:f,enabled:m,refetchInterval:1e4,staleTime:5e3,retry:iK},e[12]=u,e[13]=f,e[14]=m,e[15]=p):p=e[15];const g=Ft(p),x=g.data?.status??null,v=g.data?.diff??null;let b;return e[16]!==i||e[17]!==s||e[18]!==c||e[19]!==x||e[20]!==v||e[21]!==n?(b={orgSlug:s,virtualMcpId:n,branch:i,status:x,diff:v,policy:c},e[16]=i,e[17]=s,e[18]=c,e[19]=x,e[20]=v,e[21]=n,e[22]=b):b=e[22],O5(b)}function iK(t,e){return!du(e)&&t<2}function O5(t){const e=B.c(23),{orgSlug:s,virtualMcpId:n,branch:i,status:o,diff:a,policy:l,judgeEnabled:c}=t,d=c===void 0?!0:c;let h;e[0]!==a||e[1]!==d||e[2]!==l?(h=d&&xT(a,l),e[0]=a,e[1]=d,e[2]=l,e[3]=h):h=e[3];const u=h;let f;e[4]!==i||e[5]!==a||e[6]!==u||e[7]!==s||e[8]!==o||e[9]!==n?(f={orgSlug:s,virtualMcpId:n,branch:i,status:o,diff:a,enabled:u},e[4]=i,e[5]=a,e[6]=u,e[7]=s,e[8]=o,e[9]=n,e[10]=f):f=e[10];const{verdict:m,loading:p}=eK(f);if(!a){let b;return e[11]===Symbol.for("react.memo_cache_sentinel")?(b={gate:{allowed:!0,reason:null},ready:!1},e[11]=b):b=e[11],b}if(!u){let b;e[12]!==a||e[13]!==l?(b=gT(a,l),e[12]=a,e[13]=l,e[14]=b):b=e[14];let _;return e[15]!==b?(_={gate:b,ready:!0},e[15]=b,e[16]=_):_=e[16],_}let g;e[17]!==p||e[18]!==m?(g=vT(m,p),e[17]=p,e[18]=m,e[19]=g):g=e[19];const x=!p;let v;return e[20]!==g||e[21]!==x?(v={gate:g,ready:x},e[20]=g,e[21]=x,e[22]=v):v=e[22],v}class io extends Error{constructor(e,s,n){super(e),this.step=s,this.pr=n,this.name="PublishFlowError"}step;pr}function rK(t){const e=B.c(10),[s,n]=A.useState(0);let i;e[0]!==t?(i=c=>{c&&n(oK),t.onOpenChange(c)},e[0]=t,e[1]=i):i=e[1];const o=i;let a;e[2]!==o||e[3]!==t||e[4]!==s?(a=t.open?r.jsx(aK,{...t,onOpenChange:o},s):null,e[2]=o,e[3]=t,e[4]=s,e[5]=a):a=e[5];let l;return e[6]!==o||e[7]!==t.open||e[8]!==a?(l=r.jsx(ts,{open:t.open,onOpenChange:o,children:a}),e[6]=o,e[7]=t.open,e[8]=a,e[9]=l):l=e[9],l}function oK(t){return t+1}function aK({onOpenChange:t,orgSlug:e,orgId:s,virtualMcpId:n,branch:i,baseBranch:o,githubConnectionId:a,owner:l,repo:c,previewUrl:d,publishPolicy:h,dialogIntent:u="open-pr",headSha:f=null,openPullRequest:m=null,onPullRequestChanged:p,onPublished:g}){const x=re(),v=ht({connectionId:a,orgId:s,orgSlug:e}),b=ht({connectionId:Qo,orgId:s,orgSlug:e}),{data:_}=Di.useSession(),y=T9(b),L=M5(_?.user),w=m?.state==="open",j=u==="open-pr"&&!w,S=u==="publish-only",[C,N]=A.useState(null),[V,E]=A.useState(null),[T,k]=A.useState(!0),[R,P]=A.useState(!1),[D,I]=A.useState(""),[M,O]=A.useState(""),[F,$]=A.useState(),[z,K]=A.useState(!1),[X,J]=A.useState(),[H,W]=A.useState(!1),[U,Q]=A.useState(!1),[q,Z]=A.useState(!1),Y=A.useRef(!1),ee=A.useRef(!1),G={base:o,...f?{headSha:f}:{}},te=async Le=>{const ve=(Le.aheadOfBase??0)>0?await lr(e,n,i,G):null,Se=_c(Le)?await lr(e,n,i):null;return ag(ve,Se)},se=async()=>{const Le=await Ga(e,n,i),ve=S?await te(Le):await lr(e,n,i,pT(Le,{openPrFromCommits:j,commitToOpenPr:w})?G:void 0);N(Le),E(ve),I(x("thread.publishDialog.changesFrom",{branch:Le.current??i})),Z(!0),ff(e,n,i,{status:Le,diff:ve}).then(Se=>{I(Se.title),O(Se.body)}).catch(()=>{}).finally(()=>Z(!1))};Y.current||(Y.current=!0,(async()=>{k(!0),$(void 0),E(null),I(""),O(""),J(void 0);try{await se()}catch(Le){if(du(Le)&&!ee.current){ee.current=!0;try{await y.mutateAsync({virtualMcpId:n,branch:i}),await se();return}catch(ve){$(ve instanceof Error?ve.message:x("thread.publishDialog.failedLoadAfterReprovision"));return}}$(Le instanceof Error?Le.message:x("thread.publishDialog.failedLoad"))}finally{k(!1)}})());const ne=fT(C)??i,de=Fu(o,x),xe=()=>{!C||!V||(Z(!0),ff(e,n,i,{status:C,diff:V}).then(Le=>{I(Le.title),O(Le.body)}).catch(()=>{}).finally(()=>Z(!1)))},he=rg(C),ce=V?Object.keys(V.diffs).length:he,{gate:oe}=O5({orgSlug:e,virtualMcpId:n,branch:i,status:C,diff:V,policy:h,judgeEnabled:S}),me=j?og(C):mT(C,V),pe=!T&&(me||j),we=pe&&oe.allowed,Ne=!pe||oe.allowed?null:oe.pending?x("thread.publishDialog.reviewingChanges"):oe.reason??x("thread.publishDialog.publishNeedsReview"),Oe=j||!w&&(C?.aheadOfBase??0)>0,ye=!T&&(Oe||me)&&(ce>0||me),je=()=>[D.trim(),M.trim()].filter(Boolean).join(`
|
|
516
|
+
|
|
517
|
+
`),Pe=Le=>{R||z||t(Le)},Ee=async()=>{P(!0),$(void 0);let Le;try{const ve=D.trim()||x("thread.publishDialog.changesFrom",{branch:ne}),Se=M.trim()||void 0,Be=je()||ve;try{await mf(e,n,i,Be)}catch(Ce){throw new io(Ce instanceof Error?Ce.message:x("thread.publishDialog.failedPushChanges"),"push")}try{await oT(e,n,i,o)}catch(Ce){throw new io(Ce instanceof Error?Ce.message:x("thread.publishDialog.failedRebase"),"rebase")}try{Le=await lh(v,{owner:l,repo:c,branch:ne,title:ve,body:Se,base:o,coAuthor:L})}catch(Ce){throw new io(Ce instanceof Error?Ce.message:x("thread.publishDialog.failedOpenPullRequest"),"open-pr")}try{await tp(v,{owner:l,repo:c,pullNumber:Le.number,commitTitle:ve,commitMessage:Se,coAuthor:L})}catch(Ce){throw new io(Ce instanceof Error?Ce.message:x("thread.publishDialog.failedMergePullRequest"),"merge",Le)}ge.success(x("thread.publishDialog.publishedTo",{baseBranch:o})),Pe(!1),E(null),I(""),O(""),await p?.(),await g?.()}catch(ve){if(ve instanceof io&&ve.step==="merge"&&ve.pr){const Se=x("thread.publishDialog.mergeFailed",{prNumber:ve.pr.number,message:ve.message});$(Se),ge.error(Se,{action:{label:x("thread.publishDialog.viewPr"),onClick:()=>window.open(ve.pr.htmlUrl,"_blank","noopener,noreferrer")}}),await p?.();return}$(ve instanceof Error?ve.message:x("thread.publishDialog.failedPublish"))}finally{P(!1)}},be=async Le=>{try{await pf(e,n,i,[Le]),ge.success(x("thread.publishDialog.discardedChanges",{filepath:Le})),E(Se=>{if(!Se)return Se;const Be={...Se,diffs:{...Se.diffs}};return delete Be.diffs[Le],Be});const ve=await Ga(e,n,i);N(ve)}catch(ve){ge.error(ve instanceof Error?ve.message:x("thread.publishDialog.failedDiscardChanges"))}},Ve=async()=>{if(V){W(!1),Q(!0);try{const Le=Object.keys(V.diffs);if(Le.length===0)return;await pf(e,n,i,Le),ge.success(x("thread.publishDialog.allChangesDiscarded")),E(null);const ve=await Ga(e,n,i);N(ve),Pe(!1)}catch(Le){ge.error(Le instanceof Error?Le.message:x("thread.publishDialog.failedDiscardChanges"))}finally{Q(!1)}}},Re=async()=>{K(!0),J(void 0);try{const Le=D.trim()||x("thread.publishDialog.changesFrom",{branch:ne}),ve=M.trim()||void 0,Se=je()||Le;await mf(e,n,i,Se);const Be=await lh(v,{owner:l,repo:c,branch:ne,title:Le,body:ve,base:o,coAuthor:L});ge.success(x("thread.publishDialog.submittedForReview",{prNumber:Be.number}),{action:{label:x("thread.publishDialog.viewOnGithub"),onClick:()=>window.open(Be.htmlUrl,"_blank","noopener,noreferrer")}}),Pe(!1),await p?.()}catch(Le){J(Le instanceof Error?Le.message:x("thread.publishDialog.failedSubmitForReview"))}finally{K(!1)}};return r.jsx(es,{className:"top-14 left-auto right-4 flex h-[90%] max-h-[85vh] w-[90vw] max-w-[600px] translate-x-0 translate-y-0 flex-col gap-0 overflow-hidden p-0",children:r.jsxs(Vr,{defaultValue:"description",className:"flex h-full flex-col gap-0",children:[r.jsxs("div",{className:"shrink-0 space-y-3 px-6 pt-5 pb-4",children:[r.jsxs("div",{className:"space-y-1",children:[r.jsx("p",{className:"text-xs font-medium text-muted-foreground",children:j?x("thread.publishDialog.submitForReview"):de}),r.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[r.jsx("span",{className:"inline-block h-2.5 w-2.5 shrink-0 rounded-full bg-success"}),ce," ",x(ce===1?"thread.publishDialog.change":"thread.publishDialog.changes")," ",x(j?"thread.publishDialog.inThisPr":"thread.publishDialog.toPublish")]})]}),H?r.jsxs("div",{className:"flex items-center justify-between gap-3 rounded-md bg-destructive/5 px-3 py-2",children:[r.jsx("span",{className:"text-xs text-destructive",children:x("thread.publishDialog.discardConfirmMessage")}),r.jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[r.jsx(le,{type:"button",variant:"ghost",size:"sm",className:"h-7 px-2 text-xs",onClick:()=>W(!1),children:x("thread.publishDialog.cancel")}),r.jsxs(le,{type:"button",size:"sm",className:"h-7 bg-destructive px-2 text-xs text-destructive-foreground hover:bg-destructive/90",onClick:Ve,disabled:U,children:[U?r.jsx(et,{className:"h-3 w-3 animate-spin"}):null,x("thread.publishDialog.discardAll")]})]})]}):r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsxs(na,{className:"h-8 w-auto",variant:"pill",children:[r.jsx(xn,{value:"description",className:"px-3 text-xs",children:x("thread.publishDialog.description")}),r.jsx(xn,{value:"changes",className:"px-3 text-xs",children:x("thread.publishDialog.changesTab")})]}),ce>0&&!j&&r.jsx("button",{type:"button",className:"text-xs text-muted-foreground transition-colors hover:text-destructive disabled:opacity-50",onClick:()=>W(!0),disabled:R||U,children:x("thread.publishDialog.discardAll")})]})]}),r.jsx("div",{className:"border-t"}),r.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto",children:T?r.jsxs("div",{className:"flex items-center justify-center gap-2 py-16 text-muted-foreground",children:[r.jsx(et,{className:"h-4 w-4 animate-spin"}),r.jsx("span",{className:"text-sm",children:x("thread.publishDialog.loadingChanges")})]}):r.jsxs(r.Fragment,{children:[r.jsx(yi,{value:"description",className:"mt-0 px-6 py-5",children:r.jsxs("div",{className:"space-y-4",children:[r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsx("p",{className:"text-sm font-medium",children:x(j?"thread.publishDialog.pullRequest":"thread.publishDialog.commitMessage")}),r.jsxs("button",{type:"button",className:"flex items-center gap-1.5 text-xs text-muted-foreground transition-colors hover:text-foreground disabled:opacity-50",disabled:q||R||z,onClick:xe,children:[q?r.jsx(et,{className:"h-3 w-3 animate-spin"}):r.jsx(Gn,{className:"h-3 w-3"}),x(q?"thread.publishDialog.generating":"thread.publishDialog.regenerate")]})]}),r.jsxs("div",{className:"space-y-1.5",children:[r.jsx("label",{htmlFor:"publish-title",className:"text-xs font-medium text-muted-foreground",children:x("thread.publishDialog.title")}),r.jsx(rt,{id:"publish-title",value:D,onChange:Le=>I(Le.target.value),placeholder:x(q?"thread.publishDialog.generating":"thread.publishDialog.commitTitlePlaceholder"),disabled:R||z||q,className:"text-sm"})]}),r.jsxs("div",{className:"space-y-1.5",children:[r.jsx("label",{htmlFor:"publish-body",className:"text-xs font-medium text-muted-foreground",children:x("thread.publishDialog.descriptionLabel")}),r.jsx(gr,{id:"publish-body",value:M,onChange:Le=>O(Le.target.value),placeholder:x(q?"thread.publishDialog.generating":"thread.publishDialog.descriptionPlaceholder"),disabled:R||z||q,rows:5,className:"resize-none text-sm"})]}),r.jsxs("p",{className:"text-xs text-muted-foreground",children:[x("thread.publishDialog.branchLabel")," ",r.jsx("span",{className:"font-mono",children:i})," → ",r.jsx("span",{className:"font-mono",children:o})," · ",r.jsx("span",{className:"text-foreground/80",children:S?x("thread.publishDialog.squashMergesInto",{publishLabel:de,baseBranch:o}):x("thread.publishDialog.opensPullRequestInto",{baseBranch:o})})]})]})}),r.jsx(yi,{value:"changes",className:"mt-0",children:r.jsx(lg,{diff:V,onDiscardFile:be})})]})}),r.jsx("div",{className:"shrink-0 border-t",children:r.jsxs("button",{type:"button",className:"flex w-full items-center justify-between px-6 py-3.5 text-sm transition-colors hover:bg-muted/50 disabled:opacity-50",onClick:()=>{d&&window.open(d,"_blank","noopener,noreferrer")},disabled:!d,children:[r.jsxs("span",{className:"flex items-center gap-3",children:[r.jsx(x9,{className:"h-4 w-4 text-muted-foreground"}),x("thread.publishDialog.visitPreview")]}),r.jsx(kr,{className:"h-4 w-4 text-muted-foreground"})]})}),r.jsx("div",{className:"shrink-0 border-t px-6 py-3",children:S?r.jsxs(r.Fragment,{children:[r.jsx(lK,{label:de,canPublish:we,disabledReason:Ne,isPublishing:R,onPublish:Ee}),F&&r.jsx("p",{className:"mt-2 text-xs text-destructive",children:F})]}):r.jsxs(r.Fragment,{children:[r.jsxs(le,{type:"button",className:"w-full",onClick:Re,disabled:!ye||z,children:[z?r.jsx(et,{className:"h-4 w-4 animate-spin"}):r.jsx(Zs,{className:"h-4 w-4"}),x("thread.publishDialog.submitForReviewButton")]}),X&&r.jsx("p",{className:"mt-2 text-xs text-destructive",children:X})]})})]})})}function lK(t){const e=B.c(14),{label:s,canPublish:n,disabledReason:i,isPublishing:o,onPublish:a}=t,l=!n||o;let c;e[0]!==o?(c=o?r.jsx(et,{className:"h-4 w-4 animate-spin"}):null,e[0]=o,e[1]=c):c=e[1];let d;e[2]!==s||e[3]!==a||e[4]!==l||e[5]!==c?(d=r.jsxs(le,{type:"button",variant:"success",className:"w-full",onClick:a,disabled:l,children:[c,s]}),e[2]=s,e[3]=a,e[4]=l,e[5]=c,e[6]=d):d=e[6];const h=d;if(!i)return h;let u;e[7]!==h?(u=r.jsx(Ke,{asChild:!0,children:r.jsx("span",{className:"flex w-full",children:h})}),e[7]=h,e[8]=u):u=e[8];let f;e[9]!==i?(f=r.jsx(Ue,{children:i}),e[9]=i,e[10]=f):f=e[10];let m;return e[11]!==u||e[12]!==f?(m=r.jsx(ji,{children:r.jsxs(He,{children:[u,f]})}),e[11]=u,e[12]=f,e[13]=m):m=e[13],m}function cK(){return!1}function $5(t,e){cK()&&console.log(`[github-header] ${t}`,e??"")}function dK(t){if(!(t==="claiming"||t==="ready"||t==="failed"))return Rg[t].short}const uK=new Set(["failure","timed_out","cancelled","action_required"]);function hK(t){return t.status==="completed"&&uK.has(t.conclusion)}function fK(t){return t.status==="queued"||t.status==="in_progress"}function mK(t){return t.isPending&&t.fetchStatus!=="idle"}function pK(t){const{lifecycle:e,branch:s,pr:n,checks:i,reviews:o,loading:a,t:l}=t;if(a)return{label:l("thread.headerActions.loading"),disabled:!0,loading:!0,variant:"outline",tooltip:l("thread.headerActions.loadingBranchTooltip")};switch(e.phase){case"idle":return{label:t.claimPhase&&dK(t.claimPhase.kind)||l("thread.headerActions.startingSandbox"),disabled:!0,loading:!0,variant:"outline",tooltip:l("thread.headerActions.waitingForDaemonTooltip")};case"cloning":return{label:l("thread.headerActions.cloningRepo"),disabled:!0,loading:!0,variant:"outline",tooltip:l("thread.headerActions.cloningRepoTooltip")};case"clone-failed":return{label:l("thread.headerActions.cloneFailed"),disabled:!0,variant:"outline",tooltip:e.error||l("thread.headerActions.cloneFailedDefaultTooltip")};case"checking-out":return{label:l("thread.headerActions.switchingTo",{branch:e.to}),disabled:!0,loading:!0,variant:"outline",tooltip:l("thread.headerActions.checkingOutTooltip",{branch:e.to})}}if(s.kind!=="ready")return{label:l("thread.headerActions.loadingBranch"),disabled:!0,loading:!0,variant:"outline",tooltip:l("thread.headerActions.waitingForBranchTooltip")};const c=s;if(c.workingTreeDirty)return{label:l("thread.headerActions.submitForReview"),action:"create-pr",variant:"default",tooltip:l("thread.headerActions.pushAndOpenPrTooltip",{branch:c.branch,base:c.base}),showPublishSide:!0};if(c.unpushed>0&&!(n&&c.headSha&&n.headSha&&c.headSha===n.headSha))return n?{label:l("thread.headerActions.submitForReview"),action:"create-pr",variant:"default",tooltip:l("thread.headerActions.pushLocalCommitsTooltip",{prNumber:String(n.number)}),showPublishSide:!0}:{label:l("thread.headerActions.submitForReview"),action:"create-pr",variant:"default",tooltip:l("thread.headerActions.pushAndOpenPrTooltip",{branch:c.branch,base:c.base}),showPublishSide:!0};if($5("no local work — checking PR/sync state",{workingTreeDirty:c.workingTreeDirty,unpushed:c.unpushed,aheadOfBase:c.aheadOfBase,behindBase:c.behindBase,branch:c.branch,base:c.base,prMerged:n?.merged??null,prState:n?.state??null}),n?.merged)return!!c.headSha&&!!n.headSha&&c.headSha!==n.headSha?{label:l("thread.headerActions.continue"),action:"create-pr",variant:"special",tooltip:l("thread.headerActions.openNewPrTooltip"),showPublishSide:!0}:{label:l("thread.headerActions.published"),disabled:!0,variant:"outline",tooltip:l("thread.headerActions.prMergedTooltip",{prNumber:String(n.number),base:n.base})};if(c.aheadOfBase>0){if(n&&n.state==="closed"&&!n.merged)return{label:l("thread.headerActions.reopen"),action:"reopen",variant:"default",tooltip:l("thread.headerActions.reopenPrTooltip",{prNumber:String(n.number)})};if(!n)return{label:l("thread.headerActions.submitForReview"),action:"create-pr",variant:"default",tooltip:l("thread.headerActions.openPrForBranchTooltip",{branch:c.branch,base:c.base}),showPublishSide:!0};if((o?.mergeableState??"unknown")==="dirty")return{label:l("thread.headerActions.syncWith",{base:n.base}),action:"rebase",variant:"default",tooltip:l("thread.headerActions.resolveConflictsTooltip",{base:n.base})};const u=i.filter(hK).map(p=>p.name);if(u.length>0)return{label:l("thread.headerActions.fixTests"),action:"fix-checks",variant:"default",tooltip:l("thread.headerActions.failingChecksTooltip",{checks:u.join(", ")}),meta:{failingChecks:u}};const f=i.filter(fK);if(f.length>0)return{label:l("thread.headerActions.runningTests"),disabled:!0,loading:!0,variant:"outline",tooltip:l("thread.headerActions.waitingOnChecksTooltip",{count:String(f.length)})};if(o?.draft)return{label:l("thread.headerActions.markReady"),action:"mark-ready",variant:"default",tooltip:l("thread.headerActions.markDraftReadyTooltip")};const m=o?.unresolvedConversations??0;return m>0?{label:l("thread.headerActions.addressFeedback"),action:"resolve-comments",variant:"default",tooltip:l("thread.headerActions.unresolvedConversationsTooltip",{count:String(m)})}:o?.missingRequiredApprovals?{label:l("thread.headerActions.awaitingReview"),disabled:!0,variant:"outline",tooltip:l("thread.headerActions.waitingForApprovalsTooltip")}:{label:Fu(n.base,l),action:"merge-split",variant:"success",tooltip:l("thread.headerActions.squashMergeTooltip",{prNumber:String(n.number),base:n.base})}}return{label:l("thread.headerActions.upToDate"),disabled:!0,variant:"outline",tooltip:l("thread.headerActions.branchInSyncTooltip",{base:c.base})}}function gK(t,e,s){if(!e)return s??null;const n=t?.[e];if(!n)return s??null;if(s&&n[s])return s;for(const[i,o]of Object.entries(n))if(o&&Object.keys(o).length>0)return i;return s??null}const xK=6e4,vK=3e4;function bK(t){const e=B.c(12);let s;e[0]!==t.connectionId||e[1]!==t.orgId||e[2]!==t.orgSlug?(s={connectionId:t.connectionId,orgId:t.orgId,orgSlug:t.orgSlug},e[0]=t.connectionId,e[1]=t.orgId,e[2]=t.orgSlug,e[3]=s):s=e[3];const n=ht(s),i=t.prNumber??0;let o;e[4]!==t.owner||e[5]!==t.repo||e[6]!==i?(o={method:"get",owner:t.owner,repo:t.repo,pullNumber:i},e[4]=t.owner,e[5]=t.repo,e[6]=i,e[7]=o):o=e[7];const a=!!t.prNumber;let l;return e[8]!==n||e[9]!==o||e[10]!==a?(l={client:n,toolName:"pull_request_read",toolArguments:o,enabled:a,refetchInterval:xK,refetchIntervalInBackground:!1,staleTime:vK,select:yK},e[8]=n,e[9]=o,e[10]=a,e[11]=l):l=e[11],ra(l)}function yK(t){const e=zi(t);if(!e)return null;const s=e.mergeable_state??"unknown",n=!!(e.draft??!1),i=Number(e.review_comments??0),o=s==="blocked"&&i>0?i:0;return{draft:n,mergeableState:s,unresolvedConversations:o,missingRequiredApprovals:s==="blocked"&&o===0}}function _K(t){return{label:t("thread.headerActions.loadingBranch"),disabled:!0,loading:!0,variant:"outline",tooltip:t("thread.headerActions.waitingForSandboxBranchTooltip")}}function LK({virtualMcpId:t}){const e=re(),{org:s}=Fe(),{data:n}=Di.useSession(),i=gs(t),{currentBranch:o,setCurrentTaskBranch:a}=Zt(),l=Js(),[c,d]=A.useState(!1),[h,u]=A.useState("open-pr"),[f,m]=A.useState(!1),p=A.useRef(""),g=C6(i),x=g.status==="attached"||g.status==="public-clone"?g.repo:null,v=n?.user?.id,b=ht({connectionId:x?.connectionId??"",orgId:s.id,orgSlug:s.slug}),{lifecycle:_,branch:y,phase:L}=Fs(),w=y.kind==="ready"?y.branch:null,j=gK(i?.metadata?.sandboxMap,v,o??w),S=o??w??j??void 0,C=(y.kind==="ready"?y.branch:null)??S??null,N=N9({orgId:s.id,orgSlug:s.slug,connectionId:x?.connectionId??"",owner:x?.owner??"",repo:x?.name??"",branch:C}),V=N.data??null,E=np({orgId:s.id,orgSlug:s.slug,connectionId:x?.connectionId??"",owner:x?.owner??"",repo:x?.name??"",prNumber:V&&V.state==="open"?V.number:null}),T=bK({orgId:s.id,orgSlug:s.slug,connectionId:x?.connectionId??"",owner:x?.owner??"",repo:x?.name??"",prNumber:V&&V.state==="open"?V.number:null}),k=y,R=k.kind==="ready"?k.base:"main",P=k.kind==="ready"&&!!S&&(k.workingTreeDirty||k.unpushed>0||k.aheadOfBase>0),D=k.kind==="ready"?`${k.headSha}:${k.workingTreeDirty}:${k.unpushed}:${k.aheadOfBase}`:"unknown",I=cT(i?.metadata?.publishPolicy),{gate:M}=nK({orgSlug:s.slug,virtualMcpId:t,branch:S??"",base:R,headSha:k.kind==="ready"?k.headSha:null,signature:D,policy:I,enabled:P});if(g.status==="detached")return r.jsx(sl,{label:e("thread.headerActions.githubConnectionRemoved"),children:r.jsx(le,{size:"sm",variant:"outline",disabled:!0,children:e("thread.headerActions.reconnectGithub")})});if(!x)return null;const O=v&&C?Hl(i?.metadata?.sandboxMap?.[v]?.[C]):{},F=Object.values(O),z=(F.find(te=>te.sandboxProviderKind!=="user-desktop")??F[0])?.previewUrl??null,K=C?pK({lifecycle:_,branch:k,claimPhase:L,pr:V,checks:E.data??[],reviews:T.data??null,loading:mK(N),t:e}):_K(e),X=JSON.stringify({label:K.label,branchKind:k.kind,workingTreeDirty:k.kind==="ready"?k.workingTreeDirty:null,unpushed:k.kind==="ready"?k.unpushed:null,aheadOfBase:k.kind==="ready"?k.aheadOfBase:null,lifecycle:_.phase,githubHeadBranch:C});p.current!==X&&(p.current=X,$5("header button",{label:K.label,tooltip:K.tooltip,action:K.action,chatBranch:o,sandboxBranch:w,sandboxMapBranch:j,sandboxRouteBranch:S,githubHeadBranch:C,branchMeta:y,effectiveBranchMeta:k,lifecyclePhase:_.phase,prNumber:V?.number??null,prState:V?.state??null}));const J=te=>l.sendMessage({parts:[{type:"text",text:te}]}),H=l.isStreaming,W=k.kind==="ready"?k.base:"main",U=async()=>{await Promise.all([N.refetch(),E.refetch(),T.refetch()])},Q=async()=>{const te=J2(n?.user?.name??n?.user?.email?.split("@")[0]);await a(te)},q=async te=>{if(!(!x?.connectionId||f)){m(!0);try{const se=M5(n?.user);await tp(b,{owner:x.owner,repo:x.name,pullNumber:te,coAuthor:se}),ge.success(e("thread.headerActions.publishedPr",{prNumber:String(te)})),await U(),await Q()}catch(se){ge.error(se instanceof Error?se.message:e("thread.headerActions.failedToMergePullRequest"))}finally{m(!1)}}},Z=te=>{if(!(!te||!C))switch(te){case"create-pr":u("open-pr"),d(!0);return;case"reopen":if(H)return;V&&J(ST({prNumber:V.number}));return;case"rebase":if(H)return;J(wT({branch:C}));return;case"fix-checks":if(H)return;V&&J(CT({prNumber:V.number,failingChecks:K.meta?.failingChecks??[]}));return;case"mark-ready":if(H)return;V&&J(kT({prNumber:V.number}));return;case"resolve-comments":if(H)return;V&&J(VT({prNumber:V.number}));return;case"merge-split":return}},Y=()=>{u("publish-only"),d(!0)},ee=K.showPublishSide??!1,G=f||H;return r.jsxs(r.Fragment,{children:[r.jsx(SK,{t:e,button:K,actionBusy:G,githubActionPending:f,onActivate:Z,showPublishSide:ee,onPublishSide:Y,publishGate:M,prNumber:V?.number,prBase:V?.base,onSquashMerge:q,onReview:V?()=>{H||J(NT({prNumber:V.number}))}:void 0}),S&&r.jsx(rK,{open:c,onOpenChange:d,orgSlug:s.slug,orgId:s.id,virtualMcpId:t,branch:S,baseBranch:W,githubConnectionId:x.connectionId??"",owner:x.owner,repo:x.name,previewUrl:z,publishPolicy:I,dialogIntent:h,headSha:k.kind==="ready"?k.headSha:null,openPullRequest:h==="publish-only"?null:V?.state==="open"?V:null,onPullRequestChanged:U,onPublished:Q})]})}function SK(t){const e=B.c(38),{t:s,button:n,actionBusy:i,githubActionPending:o}=t,a=i&&n.action!=="create-pr"&&n.action!=="merge-split",l=!!n.disabled||a||o&&n.action==="merge-split",c=!!n.loading||o&&n.action==="merge-split";let d;e[0]!==n.tooltip||e[1]!==a||e[2]!==s?(d=a?s("thread.headerActions.chatIsRunning"):n.tooltip??null,e[0]=n.tooltip,e[1]=a,e[2]=s,e[3]=d):d=e[3];const h=d;if(n.action==="merge-split"&&t.prNumber!=null&&t.prBase!=null){let v;e[4]!==t?(v=()=>t.onSquashMerge(t.prNumber),e[4]=t,e[5]=v):v=e[5];let b;e[6]!==l||e[7]!==c||e[8]!==t.onReview||e[9]!==t.prBase||e[10]!==v?(b=r.jsx(Qz,{baseBranch:t.prBase,disabled:l,loading:c,onPublish:v,onReview:t.onReview}),e[6]=l,e[7]=c,e[8]=t.onReview,e[9]=t.prBase,e[10]=v,e[11]=b):b=e[11];let _;return e[12]!==b||e[13]!==h?(_=r.jsx(sl,{label:h,children:b}),e[12]=b,e[13]=h,e[14]=_):_=e[14],_}let u;e[15]!==n.action||e[16]!==t?(u=()=>{n.action&&t.onActivate(n.action)},e[15]=n.action,e[16]=t,e[17]=u):u=e[17];let f;e[18]!==c?(f=c?r.jsx(wi,{size:"xs",variant:"default"}):null,e[18]=c,e[19]=f):f=e[19];let m;e[20]!==n.label||e[21]!==n.variant||e[22]!==l||e[23]!==u||e[24]!==f?(m=r.jsxs(le,{size:"sm",variant:n.variant,disabled:l,onClick:u,children:[f,n.label]}),e[20]=n.label,e[21]=n.variant,e[22]=l,e[23]=u,e[24]=f,e[25]=m):m=e[25];let p;e[26]!==m||e[27]!==h?(p=r.jsx(sl,{label:h,children:m}),e[26]=m,e[27]=h,e[28]=p):p=e[28];let g;e[29]!==t.githubActionPending||e[30]!==t.onPublishSide||e[31]!==t.publishGate||e[32]!==t.showPublishSide||e[33]!==s?(g=t.showPublishSide?r.jsx(sl,{label:t.publishGate.pending?s("thread.headerActions.reviewingChanges"):t.publishGate.allowed?s("thread.headerActions.publishDirectlySkipReview"):t.publishGate.reason??s("thread.headerActions.publishNeedsReview"),children:r.jsxs(le,{size:"sm",variant:"success",disabled:t.githubActionPending||!t.publishGate.allowed,onClick:t.onPublishSide,children:[t.publishGate.pending?r.jsx(wi,{size:"xs",variant:"default"}):null,s("thread.headerActions.publish")]})}):null,e[29]=t.githubActionPending,e[30]=t.onPublishSide,e[31]=t.publishGate,e[32]=t.showPublishSide,e[33]=s,e[34]=g):g=e[34];let x;return e[35]!==p||e[36]!==g?(x=r.jsxs("div",{className:"flex items-center gap-2",children:[p,g]}),e[35]=p,e[36]=g,e[37]=x):x=e[37],x}function sl(t){const e=B.c(9),{label:s,children:n}=t;if(!s){let l;return e[0]!==n?(l=r.jsx(r.Fragment,{children:n}),e[0]=n,e[1]=l):l=e[1],l}let i;e[2]!==n?(i=r.jsx(Ke,{asChild:!0,children:r.jsx("span",{children:n})}),e[2]=n,e[3]=i):i=e[3];let o;e[4]!==s?(o=r.jsx(Ue,{children:s}),e[4]=s,e[5]=o):o=e[5];let a;return e[6]!==i||e[7]!==o?(a=r.jsx(ji,{children:r.jsxs(He,{children:[i,o]})}),e[6]=i,e[7]=o,e[8]=a):a=e[8],a}function wK(t){const e=B.c(9),{virtualMcp:s}=t,n=ta(),{navigateToTask:i}=Tx(),{create:o}=Gl();let a,l;if(e[0]!==n||e[1]!==o||e[2]!==i||e[3]!==s){l=Symbol.for("react.early_return_sentinel");e:{const c=k6(s,n);if(!c){l=null;break e}const d=c.mode==="dev";let h;e[6]!==o||e[7]!==i?(h=async m=>{const p=crypto.randomUUID();try{await o({id:p,virtual_mcp_id:m})}catch{}i(p,{virtualMcpId:m})},e[6]=o,e[7]=i,e[8]=h):h=e[8];const u=h,f=(m,p)=>r.jsx("button",{type:"button","aria-pressed":p,onClick:()=>{p||u(c.targetId)},className:ie("px-2.5 py-1 rounded-md transition-colors",p?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"),children:m});a=r.jsxs("div",{className:"inline-flex items-center rounded-lg border border-border bg-muted p-0.5 text-xs font-medium",children:[f("Develop",d),f("Live",!d)]})}e[0]=n,e[1]=o,e[2]=i,e[3]=s,e[4]=a,e[5]=l}else a=e[4],l=e[5];return l!==Symbol.for("react.early_return_sentinel")?l:a}function jK(t){const e=B.c(10),{locator:s}=Fe(),n=Bs();let i;e[0]!==s?(i=at.taskBoardItems(s),e[0]=s,e[1]=i):i=e[1];let o;e[2]!==n?(o=async()=>(await n.call("TASK_BOARD_ITEM_LIST",{})).items,e[2]=n,e[3]=o):o=e[3];let a;e[4]!==i||e[5]!==o?(a={queryKey:i,queryFn:o},e[4]=i,e[5]=o,e[6]=a):a=e[6];const{data:l}=Ft(a);if(!t||!l)return null;let c;return e[7]!==l||e[8]!==t?(c=l.find(d=>d.threads.some(h=>h.threadId===t))?.id??null,e[7]=l,e[8]=t,e[9]=c):c=e[9],c}function CK(){const t=B.c(17),e=re(),{org:s}=Fe(),{taskId:n}=Zt(),i=St(),o=jK(n);if(!o)return null;let a;t[0]!==e?(a=e("thread.openInBoardButton.openTaskAriaLabel"),t[0]=e,t[1]=a):a=t[1];let l;t[2]!==o||t[3]!==i||t[4]!==s.slug?(l=()=>i({to:"/$org/board",params:{org:s.slug},search:{task:o}}),t[2]=o,t[3]=i,t[4]=s.slug,t[5]=l):l=t[5];let c;t[6]===Symbol.for("react.memo_cache_sentinel")?(c=r.jsx(Nn,{size:16}),t[6]=c):c=t[6];let d;t[7]!==a||t[8]!==l?(d=r.jsx(Ke,{asChild:!0,children:r.jsx(Id,{"aria-label":a,onClick:l,children:c})}),t[7]=a,t[8]=l,t[9]=d):d=t[9];let h;t[10]!==e?(h=e("thread.openInBoardButton.openTaskInBoard"),t[10]=e,t[11]=h):h=t[11];let u;t[12]!==h?(u=r.jsx(Ue,{children:h}),t[12]=h,t[13]=u):u=t[13];let f;return t[14]!==d||t[15]!==u?(f=r.jsx(ji,{children:r.jsxs(He,{children:[d,u]})}),t[14]=d,t[15]=u,t[16]=f):f=t[16],f}function kK(t){const e=B.c(9),{virtualMcp:s,inline:n}=t,i=n===void 0?!1:n;let o;e[0]===Symbol.for("react.memo_cache_sentinel")?(o=r.jsx(CK,{}),e[0]=o):o=e[0];let a,l;e[1]!==s?(a=r.jsx(wK,{virtualMcp:s}),l=V6(s)?r.jsx(LK,{virtualMcpId:s.id}):null,e[1]=s,e[2]=a,e[3]=l):(a=e[2],l=e[3]);let c;e[4]!==a||e[5]!==l?(c=r.jsxs("div",{className:"flex items-center gap-2",children:[o,a,l]}),e[4]=a,e[5]=l,e[6]=c):c=e[6];const d=c;if(i)return d;let h;return e[7]!==d?(h=r.jsx(cl.Right,{children:d}),e[7]=d,e[8]=h):h=e[8],h}function VK(t,e){const s=B.c(34),n=Pm(),i=A.useSyncExternalStore(n.threads.subscribe,n.threads.get),o=A.useSyncExternalStore(n.threadsStatus.subscribe,n.threadsStatus.get);let a;s[0]!==t||s[1]!==i?(a=t?i.find(_=>_.id===t)??null:null,s[0]=t,s[1]=i,s[2]=a):a=s[2];const l=a,[c,d]=A.useState(void 0);let h;s[3]===Symbol.for("react.memo_cache_sentinel")?(h=()=>{d(void 0)},s[3]=h):h=s[3];let u;s[4]!==t?(u=[t],s[4]=t,s[5]=u):u=s[5],A.useEffect(h,u);let f,m;s[6]!==c||s[7]!==t||s[8]!==l||s[9]!==n||s[10]!==o.kind?(f=()=>{t&&(l||o.kind!=="loading"&&c===void 0&&(d("pending"),n.fetchThread(t).then(_=>{d(_)})))},m=[t,l,o.kind,c,n],s[6]=c,s[7]=t,s[8]=l,s[9]=n,s[10]=o.kind,s[11]=f,s[12]=m):(f=s[11],m=s[12]),A.useEffect(f,m);let p;s[13]!==n||s[14]!==e?(p={mutationFn:async _=>n.create({id:_,virtual_mcp_id:e})},s[13]=n,s[14]=e,s[15]=p):p=s[15];const g=Ys(p);let x,v;if(s[16]!==g||s[17]!==c||s[18]!==t||s[19]!==l||s[20]!==o.kind?(x=()=>{t&&(l||c===null&&o.kind!=="loading"&&(g.isPending||g.variables!==t&&g.mutate(t)))},v=[t,l,c,o.kind,g],s[16]=g,s[17]=c,s[18]=t,s[19]=l,s[20]=o.kind,s[21]=x,s[22]=v):(x=s[21],v=s[22]),A.useEffect(x,v),!t){let _;return s[23]===Symbol.for("react.memo_cache_sentinel")?(_={status:"ready",task:null},s[23]=_):_=s[23],_}if(l){let _;return s[24]!==l?(_={status:"ready",task:l},s[24]=l,s[25]=_):_=s[25],_}if(c&&typeof c=="object"){let _;return s[26]!==c?(_={status:"ready",task:c},s[26]=c,s[27]=_):_=s[27],_}if(g.data){let _;return s[28]!==g.data?(_={status:"ready",task:g.data},s[28]=g.data,s[29]=_):_=s[29],_}if(g.isError){let _;return s[30]!==g.error?(_={status:"error",error:g.error},s[30]=g.error,s[31]=_):_=s[31],_}if(g.isPending||o.kind!=="loading"){let _;return s[32]===Symbol.for("react.memo_cache_sentinel")?(_={status:"creating"},s[32]=_):_=s[32],_}let b;return s[33]===Symbol.for("react.memo_cache_sentinel")?(b={status:"loading"},s[33]=b):b=s[33],b}function NK(){const t=B.c(6),e=Cr(),s=St();let n;t[0]===Symbol.for("react.memo_cache_sentinel")?(n={strict:!1},t[0]=n):n=t[0];const{preview:i}=wr(n);if(!e||!i)return null;let o;t[1]!==s?(o=()=>s({to:".",search:TK}),t[1]=s,t[2]=o):o=t[2];let a;return t[3]!==i||t[4]!==o?(a=r.jsx(lb,{previewPath:i,showSeeInLibrary:!0,onClose:o}),t[3]=i,t[4]=o,t[5]=a):a=t[5],a}function TK(t){const{preview:e,...s}=t;return s}const er=A.createContext(null);function di(){return A.use(er)}function B5(t){const e=B.c(12),{children:s}=t,n=re();let i;e[0]!==n?(i=n("agentShellLayout.agentShellLayout.chatLoadingError"),e[0]=n,e[1]=i):i=e[1];let o;e[2]!==i?(o=r.jsx("div",{className:"flex-1 flex items-center justify-center text-sm text-muted-foreground",children:i}),e[2]=i,e[3]=o):o=e[3];let a;e[4]===Symbol.for("react.memo_cache_sentinel")?(a=r.jsx(_t.Skeleton,{}),e[4]=a):a=e[4];let l;e[5]!==s?(l=s??r.jsx(Ap,{}),e[5]=s,e[6]=l):l=e[6];let c;e[7]!==l?(c=r.jsx(A.Suspense,{fallback:a,children:l}),e[7]=l,e[8]=c):c=e[8];let d;return e[9]!==o||e[10]!==c?(d=r.jsx(_s,{fallback:o,children:c}),e[9]=o,e[10]=c,e[11]=d):d=e[11],d}function F5(t){const e=B.c(3),{onNewTaskRef:s,createNewTask:n}=t;let i;return e[0]!==n||e[1]!==s?(i=()=>(s.current=n,()=>{s.current=null}),e[0]=n,e[1]=s,e[2]=i):i=e[2],A.useLayoutEffect(i),null}function lm(t){const e=B.c(30),{virtualMcpId:s,hasActiveGithubRepo:n,sandboxMap:i,children:o}=t,{currentBranch:a,activeTask:l}=Zt(),{pendingSandboxProviderKind:c}=Ts(),{data:d}=Di.useSession(),h=d?.user?.id,u=l?.metadata?.sandboxMap,f=h&&a&&u?.[h]?.[a]?{...i??{},[h]:{...i?.[h]??{},[a]:u[h][a]}}:i;let m;e[0]!==l?.metadata||e[1]!==n?(m=n||sn(l?.metadata),e[0]=l?.metadata,e[1]=n,e[2]=m):m=e[2];const p=m,g=h??null,x=l?.created_by,v=l?.branch,b=l?.title;let _;e[3]!==g||e[4]!==x||e[5]!==v||e[6]!==b?(_=E_({userId:g,createdBy:x,branch:v,title:b}),e[3]=g,e[4]=x,e[5]=v,e[6]=b,e[7]=_):_=e[7];const y=_,L=x_(s,a??void 0),w=h&&a?Hl(f?.[h]?.[a]):{},S=(c?w[c]??null:ip(w))?.previewUrl??null;let C;e[8]!==w||e[9]!==L?(C=Object.keys(w).length>0||L,e[8]=w,e[9]=L,e[10]=C):C=e[10];const N=C,V=a??null,E=a??null,T=h??null,k=l?.id??null,R=`${s}:${a??"no-branch"}`;let P;e[11]!==o||e[12]!==R?(P=r.jsx(ZE,{children:o},R),e[11]=o,e[12]=R,e[13]=P):P=e[13];let D;e[14]!==p||e[15]!==f||e[16]!==y||e[17]!==c||e[18]!==T||e[19]!==k||e[20]!==P||e[21]!==E||e[22]!==s?(D=r.jsx(I_,{virtualMcpId:s,branch:E,userId:T,hasActiveGithubRepo:p,sandboxMap:f,sandboxProviderKind:c,othersThreadLabel:y,othersThreadId:k,children:P}),e[14]=p,e[15]=f,e[16]=y,e[17]=c,e[18]=T,e[19]=k,e[20]=P,e[21]=E,e[22]=s,e[23]=D):D=e[23];let I;return e[24]!==S||e[25]!==N||e[26]!==D||e[27]!==V||e[28]!==s?(I=r.jsx(k_,{virtualMcpId:s,branch:V,previewUrl:S,enabled:N,children:D}),e[24]=S,e[25]=N,e[26]=D,e[27]=V,e[28]=s,e[29]=I):I=e[29],I}function AK(t){const e=B.c(26),{entity:s,virtualMcpId:n,layout:i,onNewTaskRef:o}=t,a=!i.mainOpen;let l;e[0]!==i.sidePanel||e[1]!==i.toggleSidePanel||e[2]!==a?(l=r.jsx(cl.Toggles,{children:r.jsx($z,{sidePanel:i.sidePanel,toggleSidePanel:i.toggleSidePanel,disableActiveSidePanelToggle:a})}),e[0]=i.sidePanel,e[1]=i.toggleSidePanel,e[2]=a,e[3]=l):l=e[3];const c=i.sidePanel===null;let d;e[4]!==i.taskId||e[5]!==c||e[6]!==n?(d=r.jsx(cl.Tabs,{children:r.jsx(Kz,{virtualMcpId:n,taskId:i.taskId,disableActiveMainToggle:c})}),e[4]=i.taskId,e[5]=c,e[6]=n,e[7]=d):d=e[7];let h;e[8]!==i.createNewTask||e[9]!==o?(h=r.jsx(F5,{onNewTaskRef:o,createNewTask:i.createNewTask}),e[8]=i.createNewTask,e[9]=o,e[10]=h):h=e[10];let u;e[11]!==s?(u=r.jsx(kK,{virtualMcp:s}),e[11]=s,e[12]=u):u=e[12];let f;e[13]===Symbol.for("react.memo_cache_sentinel")?(f=r.jsx(_t.Skeleton,{}),e[13]=f):f=e[13];let m;e[14]===Symbol.for("react.memo_cache_sentinel")?(m=r.jsx(B5,{}),e[14]=m):m=e[14];let p;e[15]!==i.mainOpen||e[16]!==i.sidePanel||e[17]!==i.taskId||e[18]!==n?(p=r.jsx(A.Suspense,{fallback:f,children:r.jsx(Iz,{virtualMcpId:n,taskId:i.taskId,sidePanel:i.sidePanel,mainOpen:i.mainOpen,chatContent:m})}),e[15]=i.mainOpen,e[16]=i.sidePanel,e[17]=i.taskId,e[18]=n,e[19]=p):p=e[19];let g;return e[20]!==l||e[21]!==d||e[22]!==h||e[23]!==u||e[24]!==p?(g=r.jsxs(r.Fragment,{children:[l,d,h,u,p]}),e[20]=l,e[21]=d,e[22]=h,e[23]=u,e[24]=p,e[25]=g):g=e[25],g}function EK(t){const e=B.c(16),{virtualMcpId:s,layout:n,onNewTaskRef:i}=t,o=re(),a=n.mainOpen?"main":n.sidePanel??"chat";let l;e[0]!==n.taskId||e[1]!==s?(l=r.jsx(cl.Tabs,{children:r.jsx(Gz,{virtualMcpId:s,taskId:n.taskId})}),e[0]=n.taskId,e[1]=s,e[2]=l):l=e[2];let c;e[3]!==n.createNewTask||e[4]!==i?(c=r.jsx(F5,{onNewTaskRef:i,createNewTask:n.createNewTask}),e[3]=n.createNewTask,e[4]=i,e[5]=c):c=e[5];let d;e[6]===Symbol.for("react.memo_cache_sentinel")?(d=r.jsx(_t.Skeleton,{}),e[6]=d):d=e[6];let h;e[7]!==n.taskId||e[8]!==a||e[9]!==o||e[10]!==s?(h=r.jsx(A.Suspense,{fallback:d,children:r.jsx("div",{className:"flex-1 min-h-0 overflow-hidden",children:a==="main"?r.jsx(_s,{fallback:r.jsx("div",{className:"flex-1 flex items-center justify-center text-sm text-muted-foreground",children:o("agentShellLayout.agentShellLayout.somethingWentWrong")}),children:r.jsx(A.Suspense,{fallback:r.jsx("div",{className:"h-full flex items-center justify-center",children:r.jsx(et,{size:20,className:"animate-spin text-muted-foreground"})}),children:r.jsx("div",{"data-testid":"main-panel",className:"h-full",children:r.jsx(R5,{taskId:n.taskId,virtualMcpId:s})})})}):r.jsx(D5,{chatContent:r.jsx(B5,{})})})}),e[7]=n.taskId,e[8]=a,e[9]=o,e[10]=s,e[11]=h):h=e[11];let u;return e[12]!==l||e[13]!==c||e[14]!==h?(u=r.jsxs(r.Fragment,{children:[l,c,h]}),e[12]=l,e[13]=c,e[14]=h,e[15]=u):u=e[15],u}function PK(){const t=B.c(97),e=re(),s=Cr(),n=St(),{org:i}=Fe();hb(i.slug);let o;t[0]===Symbol.for("react.memo_cache_sentinel")?(o={strict:!1},t[0]=o):o=t[0];const a=Wl(o),l=a.org??"";let c;t[1]===Symbol.for("react.memo_cache_sentinel")?(c={strict:!1},t[1]=c):c=t[1];const d=wr(c);let h;t[2]!==i.id||t[3]!==d.virtualmcpid?(h=d.virtualmcpid??Xo(i.id).id,t[2]=i.id,t[3]=d.virtualmcpid,t[4]=h):h=t[4];const u=h,f=VK(a.taskId??"",u),m=gs(u),p=m?.metadata?.ui?.layout??null;let g;t[5]!==p?(g=p?{defaultMainView:p.defaultMainView??null,chatDefaultOpen:p.chatDefaultOpen??null}:null,t[5]=p,t[6]=g):g=t[6];const x=g;let v;t[7]!==m?(v=m&&ia(m),t[7]=m,t[8]=v):v=t[8];const b=!!v;let _;t[9]!==l||t[10]!==u?(_={virtualMcpId:u,orgSlug:l,isAgentRoute:!0},t[9]=l,t[10]=u,t[11]=_):_=t[11];const y=KS(x,_),L=A.useRef(null);let w,j;t[12]===Symbol.for("react.memo_cache_sentinel")?(w=()=>{const M=O=>{Rm(O)&&O.shiftKey&&O.code==="KeyS"&&!O.repeat&&(O.preventDefault(),L.current?.())};return document.addEventListener("keydown",M),()=>document.removeEventListener("keydown",M)},j=[],t[12]=w,t[13]=j):(w=t[12],j=t[13]),A.useEffect(w,j);const S=u;let C;t[14]!==m||t[15]!==u?(C={virtualMcpId:u,entity:m},t[14]=m,t[15]=u,t[16]=C):C=t[16];const N=C;if(f.status==="creating"||f.status==="loading"){let M;t[17]===Symbol.for("react.memo_cache_sentinel")?(M=r.jsx(et,{className:"size-4 animate-spin mr-2"}),t[17]=M):M=t[17];let O;t[18]!==e?(O=e("agentShellLayout.agentShellLayout.creatingTask"),t[18]=e,t[19]=O):O=t[19];let F;t[20]!==O?(F=r.jsx("div",{className:"flex-1 min-h-0 pr-1.5 pb-1.5 overflow-hidden",children:r.jsxs("div",{className:"flex h-full items-center justify-center bg-background card-shadow rounded-[0.75rem] text-sm text-muted-foreground",children:[M,O]})}),t[20]=O,t[21]=F):F=t[21];let $;return t[22]!==N||t[23]!==F?($=r.jsx(er,{value:N,children:F}),t[22]=N,t[23]=F,t[24]=$):$=t[24],$}if(f.status==="error"){let M;t[25]!==e?(M=e("agentShellLayout.agentShellLayout.taskUnavailable"),t[25]=e,t[26]=M):M=t[26];let O;t[27]!==M?(O=r.jsx("div",{className:"font-medium",children:M}),t[27]=M,t[28]=O):O=t[28];let F;t[29]!==f.error.message?(F=r.jsx("div",{className:"text-muted-foreground",children:f.error.message}),t[29]=f.error.message,t[30]=F):F=t[30];let $;t[31]!==O||t[32]!==F?($=r.jsx("div",{className:"flex-1 min-h-0 pr-1.5 pb-1.5 overflow-hidden",children:r.jsxs("div",{className:"flex flex-col h-full items-center justify-center gap-2 bg-background card-shadow rounded-[0.75rem] p-8 text-sm",children:[O,F]})}),t[31]=O,t[32]=F,t[33]=$):$=t[33];let z;return t[34]!==N||t[35]!==$?(z=r.jsx(er,{value:N,children:$}),t[34]=N,t[35]=$,t[36]=z):z=t[36],z}if(!m){let M;t[37]===Symbol.for("react.memo_cache_sentinel")?(M=r.jsx(wn,{size:48,className:"text-muted-foreground"}),t[37]=M):M=t[37];let O;t[38]!==e?(O=e("agentShellLayout.agentShellLayout.agentNotFound"),t[38]=e,t[39]=O):O=t[39];let F;t[40]!==e||t[41]!==u?(F=e("agentShellLayout.agentShellLayout.agentNotFoundDescription",{virtualMcpId:u}),t[40]=e,t[41]=u,t[42]=F):F=t[42];let $;t[43]!==n||t[44]!==l?($=()=>n({to:"/$org",params:{org:l}}),t[43]=n,t[44]=l,t[45]=$):$=t[45];let z;t[46]!==e?(z=e("agentShellLayout.agentShellLayout.goToOrgHome"),t[46]=e,t[47]=z):z=t[47];let K;t[48]!==$||t[49]!==z?(K=r.jsx(le,{variant:"outline",onClick:$,children:z}),t[48]=$,t[49]=z,t[50]=K):K=t[50];let X;t[51]!==O||t[52]!==F||t[53]!==K?(X=r.jsx("div",{className:"flex-1 min-h-0 pr-1.5 pb-1.5 overflow-hidden",children:r.jsx("div",{className:"flex flex-col h-full bg-background overflow-hidden card-shadow rounded-[0.75rem]",children:r.jsx(ki,{image:M,title:O,description:F,actions:K})})}),t[51]=O,t[52]=F,t[53]=K,t[54]=X):X=t[54];let J;return t[55]!==N||t[56]!==X?(J=r.jsx(er,{value:N,children:X}),t[55]=N,t[56]=X,t[57]=J):J=t[57],J}if(s){const M=f.status==="ready"?f.task:null,O=m?.metadata?.sandboxMap;let F;t[58]===Symbol.for("react.memo_cache_sentinel")?(F=r.jsx(_t.Skeleton,{}),t[58]=F):F=t[58];let $;t[59]!==S||t[60]!==y?($=r.jsx(A.Suspense,{fallback:F,children:r.jsx(EK,{virtualMcpId:S,layout:y,onNewTaskRef:L})}),t[59]=S,t[60]=y,t[61]=$):$=t[61];let z;t[62]!==y.taskId||t[63]!==$?(z=r.jsx(_t.ActiveTaskProvider,{taskId:y.taskId,children:$},y.taskId),t[62]=y.taskId,t[63]=$,t[64]=z):z=t[64];let K;t[65]!==b||t[66]!==O||t[67]!==z||t[68]!==u?(K=r.jsx(lm,{virtualMcpId:u,hasActiveGithubRepo:b,sandboxMap:O,children:z}),t[65]=b,t[66]=O,t[67]=z,t[68]=u,t[69]=K):K=t[69];let X;t[70]!==S||t[71]!==K||t[72]!==M?(X=r.jsx("div",{className:"flex flex-col flex-1 min-w-0 bg-background min-h-0",children:r.jsx(_t.Provider,{virtualMcpId:S,task:M,children:K},S)}),t[70]=S,t[71]=K,t[72]=M,t[73]=X):X=t[73];let J;return t[74]!==N||t[75]!==X?(J=r.jsx(er,{value:N,children:X}),t[74]=N,t[75]=X,t[76]=J):J=t[76],J}const V=f.status==="ready"?f.task:null,E=m?.metadata?.sandboxMap;let T;t[77]===Symbol.for("react.memo_cache_sentinel")?(T=r.jsx(_t.Skeleton,{}),t[77]=T):T=t[77];let k;t[78]!==m||t[79]!==y||t[80]!==u?(k=r.jsx(A.Suspense,{fallback:T,children:r.jsx(AK,{entity:m,virtualMcpId:u,layout:y,onNewTaskRef:L})}),t[78]=m,t[79]=y,t[80]=u,t[81]=k):k=t[81];let R;t[82]!==y.taskId||t[83]!==k?(R=r.jsx(_t.ActiveTaskProvider,{taskId:y.taskId,children:k},y.taskId),t[82]=y.taskId,t[83]=k,t[84]=R):R=t[84];let P;t[85]!==b||t[86]!==E||t[87]!==R||t[88]!==u?(P=r.jsx(lm,{virtualMcpId:u,hasActiveGithubRepo:b,sandboxMap:E,children:R}),t[85]=b,t[86]=E,t[87]=R,t[88]=u,t[89]=P):P=t[89];let D;t[90]!==S||t[91]!==P||t[92]!==V?(D=r.jsx(_t.Provider,{virtualMcpId:S,task:V,children:P},S),t[90]=S,t[91]=P,t[92]=V,t[93]=D):D=t[93];let I;return t[94]!==N||t[95]!==D?(I=r.jsx("div",{className:"flex-1 min-w-0 flex flex-col",children:r.jsx(er,{value:N,children:D})}),t[94]=N,t[95]=D,t[96]=I):I=t[96],I}function RK(){const t=B.c(2);let e;t[0]===Symbol.for("react.memo_cache_sentinel")?(e=r.jsx(yx,{}),t[0]=e):e=t[0];let s;return t[1]===Symbol.for("react.memo_cache_sentinel")?(s=r.jsx(A.Suspense,{fallback:e,children:r.jsxs(Vb,{children:[r.jsx(PK,{}),r.jsx(NK,{})]})}),t[1]=s):s=t[1],s}const RW=Object.freeze(Object.defineProperty({__proto__:null,default:RK,useInsetContext:di},Symbol.toStringTag,{value:"Module"}));export{o4 as $,Pf as A,SW as B,Ho as C,Pa as D,c7 as E,Ug as F,D9 as G,gc as H,pI as I,si as J,$r as K,au as L,_r as M,ru as N,U3 as O,Br as P,yc as Q,_R as R,In as S,bs as T,J9 as U,ou as V,Ln as W,iR as X,oR as Y,jW as Z,iu as _,XH as a,Ip as a$,wW as a0,Rw as a1,Pw as a2,oW as a3,ju as a4,qR as a5,gW as a6,NW as a7,TW as a8,eu as a9,Fr as aA,dW as aB,xW as aC,DA as aD,bW as aE,mW as aF,kA as aG,lW as aH,pW as aI,fW as aJ,hW as aK,kW as aL,rW as aM,aW as aN,iW as aO,VW as aP,Cu as aQ,Lg as aR,_g as aS,ZH as aT,uA as aU,tW as aV,sW as aW,fA as aX,LW as aY,uW as aZ,_W as a_,Tu as aa,QH as ab,vW as ac,Ol as ad,eM as ae,lc as af,cc as ag,di as ah,_P as ai,K9 as aj,Sw as ak,hc as al,Vg as am,Dl as an,SD as ao,eW as ap,QI as aq,AW as ar,Tg as as,cW as at,UI as au,cA as av,dA as aw,ku as ax,x4 as ay,uR as az,zd as b,yW as b0,JH as b1,gw as b2,vw as b3,RW as b4,Kd as c,yn as d,Cg as e,Ga as f,qo as g,yP as h,fs as i,Cl as j,wc as k,CW as l,s4 as m,RP as n,_M as o,GH as p,YH as q,_n as r,$5 as s,nW as t,Er as u,vP as v,cR as w,Ya as x,JP as y,Aa as z};
|