@lobu/runtime-server 20.1.0 → 20.2.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/component.json +1 -1
- package/dist/connectors/chat-user-identity.ts +41 -0
- package/dist/connectors/google-identity.ts +11 -0
- package/dist/connectors/slack-identity.ts +19 -0
- package/dist/db/migrations/20260915030000_owner_dm_delivery_request_platform.sql +51 -0
- package/dist/dependencies.bun.lock +28 -30
- package/dist/owletto/dist/assets/{_-DdvHIadV.js → _-Ds4DyQjj.js} +2 -2
- package/dist/owletto/dist/assets/_-VmyR6aN_.js +1 -0
- package/dist/owletto/dist/assets/{_agentId-DbTBU4KZ.js → _agentId-BAVnp0c7.js} +1 -1
- package/dist/owletto/dist/assets/_agentId-Df-3rGi5.js +1 -0
- package/dist/owletto/dist/assets/{_automationId-C7dZzg6X.js → _automationId-D696vOjd.js} +1 -1
- package/dist/owletto/dist/assets/{_connectorKey._connectionId-NQf43Ew3.js → _connectorKey._connectionId-BAJGfcy7.js} +1 -1
- package/dist/owletto/dist/assets/{_connectorKey.index-D-0ZNsgM.js → _connectorKey.index-BBF8vGJS.js} +1 -1
- package/dist/owletto/dist/assets/{_conversationId-F5YmyLV9.js → _conversationId-Ci4rgrHm.js} +1 -1
- package/dist/owletto/dist/assets/{_deploymentId-3LTMi0ZT.js → _deploymentId-Iy-D5PDq.js} +1 -1
- package/dist/owletto/dist/assets/_name-CeGwb0oK.js +1 -0
- package/dist/owletto/dist/assets/{_owner-DglbbDEx.js → _owner-CFR1G8OX.js} +1 -1
- package/dist/owletto/dist/assets/_skillKey-DuLcQWBu.js +1 -0
- package/dist/owletto/dist/assets/{_slug-CnQDfsCE.js → _slug-CDSO20ac.js} +1 -1
- package/dist/owletto/dist/assets/{accept-invitation-Dgoyublh.js → accept-invitation-Db5jklHT.js} +1 -1
- package/dist/owletto/dist/assets/{activity-route-view-BNzKO6aD.js → activity-route-view-DVW3DoB7.js} +1 -1
- package/dist/owletto/dist/assets/{agent-card-controls-VJgcB5-0.js → agent-card-controls-CZO6GI0s.js} +1 -1
- package/dist/owletto/dist/assets/{agent-client-setup-list-C5KRNRw3.js → agent-client-setup-list-_chLOorY.js} +1 -1
- package/dist/owletto/dist/assets/{agent-connect-pages-BFSb6vmW.js → agent-connect-pages-DWBgSIYT.js} +1 -1
- package/dist/owletto/dist/assets/{agent-editor-form-CajEehVn.js → agent-editor-form-BTNlg0kQ.js} +1 -1
- package/dist/owletto/dist/assets/{agent-guardrails-route-CZ_rXj-3.js → agent-guardrails-route-B5uoMC6o.js} +1 -1
- package/dist/owletto/dist/assets/{agent-loading-shells-Dczhk067.js → agent-loading-shells-CLoLeFcB.js} +1 -1
- package/dist/owletto/dist/assets/{agent-permissions-matrix-DIVHvpZG.js → agent-permissions-matrix-TP00-MYL.js} +1 -1
- package/dist/owletto/dist/assets/{agent-skill-context-CxglCznW.js → agent-skill-context-D4a2QCoZ.js} +1 -1
- package/dist/owletto/dist/assets/{agent-skills-route-CatU8soC.js → agent-skills-route-KVDDTbJB.js} +1 -1
- package/dist/owletto/dist/assets/{agent-subpage-shell-DVSUdIBn.js → agent-subpage-shell-DuVYZvBE.js} +1 -1
- package/dist/owletto/dist/assets/{agent-thread-DnLUOzXk.js → agent-thread-CzCJU3-R.js} +1 -1
- package/dist/owletto/dist/assets/agents-DFs57C3c.js +1 -0
- package/dist/owletto/dist/assets/{agents-workbench-BOKifKIO.js → agents-workbench-C2bUlJP2.js} +1 -1
- package/dist/owletto/dist/assets/{app._appId-BXmITXO7.js → app._appId-D0_LQTJU.js} +1 -1
- package/dist/owletto/dist/assets/{automation-detail-content-wJC9hhmA.js → automation-detail-content-DWkdhnv2.js} +1 -1
- package/dist/owletto/dist/assets/automations-DFs57C3c.js +1 -0
- package/dist/owletto/dist/assets/{calendar-taCoBmAh.js → calendar-C0XpOHd8.js} +1 -1
- package/dist/owletto/dist/assets/{callback-CJxC8u_x.js → callback-CO_K9eR-.js} +1 -1
- package/dist/owletto/dist/assets/{card-kpw3EaKC.js → card-DeFQuU_J.js} +1 -1
- package/dist/owletto/dist/assets/{claim-DLHRN0bA.js → claim-CUpWOSie.js} +1 -1
- package/dist/owletto/dist/assets/{clients-R4JsT_Fz.js → clients-DhYr4lyL.js} +1 -1
- package/dist/owletto/dist/assets/{code-editor-D3X0yQdI.js → code-editor-BqGUZFt6.js} +1 -1
- package/dist/owletto/dist/assets/connect-Dtb-E5An.js +1 -0
- package/dist/owletto/dist/assets/connect._clientId-DWtceAAw.js +1 -0
- package/dist/owletto/dist/assets/{connected._clientId-ByH4etku.js → connected._clientId-CMe-wTuV.js} +1 -1
- package/dist/owletto/dist/assets/{connection-DdBkXNbX.js → connection-BgAlYjeV.js} +1 -1
- package/dist/owletto/dist/assets/{connection-feed-detail-DF93zx0A.js → connection-feed-detail-B3ePAinf.js} +1 -1
- package/dist/owletto/dist/assets/{connector-provenance-N3sc0nbo.js → connector-provenance-DgsDg0Z9.js} +1 -1
- package/dist/owletto/dist/assets/{connectors-Ckn_aoNE.js → connectors-CqPQPo9U.js} +1 -1
- package/dist/owletto/dist/assets/{consent-Bi6KCVtT.js → consent-bswcIzsf.js} +1 -1
- package/dist/owletto/dist/assets/{core.esm-CFYXLQXH.js → core.esm-DsLgjoel.js} +1 -1
- package/dist/owletto/dist/assets/create-CcXUdke7.js +1 -0
- package/dist/owletto/dist/assets/create-Cp6hMoeU.js +1 -0
- package/dist/owletto/dist/assets/{create-BiHpu2f4.js → create-Dwo04oWV.js} +1 -1
- package/dist/owletto/dist/assets/{create-automation-form-Cv2RHsQ6.js → create-automation-form-CJ4meayB.js} +1 -1
- package/dist/owletto/dist/assets/{create._connectorKey-Qynix_hA.js → create._connectorKey-CCBb2pil.js} +1 -1
- package/dist/owletto/dist/assets/{cronstrue-D7xlYtGk.js → cronstrue-ChFyC9ps.js} +1 -1
- package/dist/owletto/dist/assets/deployments-CjfFxyDA.js +1 -0
- package/dist/owletto/dist/assets/{deployments-body-BPCALbQe.js → deployments-body-Cg0KiWGr.js} +1 -1
- package/dist/owletto/dist/assets/device-DpY67Jaj.js +1 -0
- package/dist/owletto/dist/assets/{device-pin-tombstone-DrTJYNKG.js → device-pin-tombstone-1ikyqSdb.js} +1 -1
- package/dist/owletto/dist/assets/{device-rows-fVm-zAiU.js → device-rows-Cp3yMcuV.js} +1 -1
- package/dist/owletto/dist/assets/{device._deviceId-CIe7taim.js → device._deviceId-DTYKGBY8.js} +1 -1
- package/dist/owletto/dist/assets/{entity-options-DOGD_EyZ.js → entity-options-1EaSGMX4.js} +1 -1
- package/dist/owletto/dist/assets/{entity-page-C8oDszRY.js → entity-page-DJmM70dv.js} +1 -1
- package/dist/owletto/dist/assets/{entity-type-page-BfxIgJLq.js → entity-type-page-C3mT7tXn.js} +1 -1
- package/dist/owletto/dist/assets/{events-feed-B9OqmSBy.js → events-feed-iliGfjit.js} +1 -1
- package/dist/owletto/dist/assets/{full-page-spinner-DTSqneUO.js → full-page-spinner-BN2G_YiM.js} +1 -1
- package/dist/owletto/dist/assets/guardrails-CLlnRRy9.js +1 -0
- package/dist/owletto/dist/assets/identity-MSLryUi8.js +1 -0
- package/dist/owletto/dist/assets/index-3o4Eepb4.js +1 -0
- package/dist/owletto/dist/assets/{index-Bfux0kHb.js → index-BUr8321-.js} +3 -3
- package/dist/owletto/dist/assets/{index-CK2-iHcz.js → index-Bulu5ldM.js} +1 -1
- package/dist/owletto/dist/assets/{index-DcWyuLQS.js → index-BvbfITqH.js} +1 -1
- package/dist/owletto/dist/assets/{index-Bq4m-sK0.js → index-C-u4yR8Z.js} +1 -1
- package/dist/owletto/dist/assets/{index-DkKALC2l.js → index-C2oCgDX7.js} +1 -1
- package/dist/owletto/dist/assets/{index-jGZeANLE.js → index-C6VAJ8Ku.js} +1 -1
- package/dist/owletto/dist/assets/index-Clw9ZBj-.js +1 -0
- package/dist/owletto/dist/assets/index-D2oL4Ydo.js +1 -0
- package/dist/owletto/dist/assets/index-D7wulT4y.js +1 -0
- package/dist/owletto/dist/assets/{index-COgBJ_ab.js → index-DOLFe19K.js} +1 -1
- package/dist/owletto/dist/assets/index-DTSA0Xh1.js +1 -0
- package/dist/owletto/dist/assets/index-DxXXVPU0.js +1 -0
- package/dist/owletto/dist/assets/{index-CMOHHdFH.js → index-hSE2E46p.js} +1 -1
- package/dist/owletto/dist/assets/index-nzvsA3hT.js +1 -0
- package/dist/owletto/dist/assets/{index-DYe_DVHa.js → index-vdqhlocx.js} +1 -1
- package/dist/owletto/dist/assets/{json-diff-CANZD4MQ.js → json-diff-DnsW7Pin.js} +1 -1
- package/dist/owletto/dist/assets/{list-skeleton-DZTUxpBx.js → list-skeleton-CHzLN7GK.js} +1 -1
- package/dist/owletto/dist/assets/{login-D53geSP7.js → login-CCKNM0gV.js} +1 -1
- package/dist/owletto/dist/assets/{logout-DKQS25qd.js → logout-B-N2aodZ.js} +1 -1
- package/dist/owletto/dist/assets/{member-scope-gate-C4QyRm2Q.js → member-scope-gate-B560Wg-t.js} +1 -1
- package/dist/owletto/dist/assets/{memory-browse-page-DOpV3vht.js → memory-browse-page-DMDqKJn7.js} +1 -1
- package/dist/owletto/dist/assets/{model-selector-CvU3VP90.js → model-selector-DfbmHjLu.js} +1 -1
- package/dist/owletto/dist/assets/models-M51OGDRE.js +1 -0
- package/dist/owletto/dist/assets/{new-B8_sRMYD.js → new-BVQS9H-Y.js} +1 -1
- package/dist/owletto/dist/assets/{new-DIjOVXrQ.js → new-Df_dY6Z5.js} +1 -1
- package/dist/owletto/dist/assets/{new-Df1q7GEj.js → new-DxDVE9nL.js} +1 -1
- package/dist/owletto/dist/assets/{oauth-workspace-access-DWfiekRz.js → oauth-workspace-access-D9GmiMfK.js} +1 -1
- package/dist/owletto/dist/assets/{organization-DHEC7kDq.js → organization-uSDYkJpX.js} +1 -1
- package/dist/owletto/dist/assets/{permissions-i7iwnE1a.js → permissions-Fe0DP6b8.js} +1 -1
- package/dist/owletto/dist/assets/{proposal-review-shell-C_LcyUEF.js → proposal-review-shell-D9HwnDda.js} +1 -1
- package/dist/owletto/dist/assets/{recent-By19_Buq.js → recent-C03LhMD7.js} +1 -1
- package/dist/owletto/dist/assets/{renderer-B1UThnk2.js → renderer-CHNejd95.js} +1 -1
- package/dist/owletto/dist/assets/{reset-password-Dsz5-Xeo.js → reset-password-CuISnlG_.js} +1 -1
- package/dist/owletto/dist/assets/{runs-BQ11PAQT.js → runs-BnYdToDc.js} +1 -1
- package/dist/owletto/dist/assets/{runs-panel-wkV1aGD9.js → runs-panel-DsdESupx.js} +1 -1
- package/dist/owletto/dist/assets/{runs-table-DzSWYkaf.js → runs-table-B7jKuILd.js} +1 -1
- package/dist/owletto/dist/assets/{schema-value-normalization--DhnhJNf.js → schema-value-normalization-B--OWDL8.js} +1 -1
- package/dist/owletto/dist/assets/settings-Bg9yCCoN.js +1 -0
- package/dist/owletto/dist/assets/{settings-Bu239SXe.js → settings-wGNHtsDP.js} +1 -1
- package/dist/owletto/dist/assets/skills-CN5Ube7A.js +1 -0
- package/dist/owletto/dist/assets/{switch-CCKllS7w.js → switch-Dzse_XFM.js} +1 -1
- package/dist/owletto/dist/assets/{use-mention-search-CldNZTiT.js → use-mention-search-uyW1Uwf6.js} +1 -1
- package/dist/owletto/dist/index.html +1 -1
- package/dist/server-main.bundle.mjs +9903 -9541
- package/npm-shrinkwrap.json +116 -140
- package/package.json +1 -1
- package/vendor/connector-sdk/package.json +1 -1
- package/vendor/core/dist/credentials.d.ts +16 -1
- package/vendor/core/dist/credentials.js +10 -1
- package/vendor/core/package.json +1 -1
- package/dist/owletto/dist/assets/_-CfcfHJO8.js +0 -1
- package/dist/owletto/dist/assets/_agentId-BTmFhpb6.js +0 -1
- package/dist/owletto/dist/assets/_name-BKeZbc-h.js +0 -1
- package/dist/owletto/dist/assets/_skillKey-DhiGYYFq.js +0 -1
- package/dist/owletto/dist/assets/agents-OLmcj-qM.js +0 -1
- package/dist/owletto/dist/assets/automations-OLmcj-qM.js +0 -1
- package/dist/owletto/dist/assets/connect-1ysEq9l0.js +0 -1
- package/dist/owletto/dist/assets/connect._clientId-BbMPs6l3.js +0 -1
- package/dist/owletto/dist/assets/create-C37QtjbJ.js +0 -1
- package/dist/owletto/dist/assets/create-kAQa5_Q7.js +0 -1
- package/dist/owletto/dist/assets/deployments-C5kSeowq.js +0 -1
- package/dist/owletto/dist/assets/device-DToHXxDM.js +0 -1
- package/dist/owletto/dist/assets/guardrails-9Mr6avxk.js +0 -1
- package/dist/owletto/dist/assets/identity-DMfCjdBz.js +0 -1
- package/dist/owletto/dist/assets/index-CkwwaMrx.js +0 -1
- package/dist/owletto/dist/assets/index-D0lZrXrY.js +0 -1
- package/dist/owletto/dist/assets/index-DZadnZpq.js +0 -1
- package/dist/owletto/dist/assets/index-DlqjyZKQ.js +0 -1
- package/dist/owletto/dist/assets/index-Dv0huHrO.js +0 -1
- package/dist/owletto/dist/assets/index-DxIDxgPJ.js +0 -1
- package/dist/owletto/dist/assets/index-bKUccXCc.js +0 -1
- package/dist/owletto/dist/assets/models-ooBIWFuB.js +0 -1
- package/dist/owletto/dist/assets/settings-FxbIvOhH.js +0 -1
- package/dist/owletto/dist/assets/skills-MBZ5ilDK.js +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/_owner-
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/_owner-CFR1G8OX.js","assets/automation-detail-content-DWkdhnv2.js","assets/create-automation-form-CJ4meayB.js","assets/cronstrue-ChFyC9ps.js","assets/entity-options-1EaSGMX4.js","assets/connection-label-BobuYiAG.js","assets/switch-Dzse_XFM.js","assets/device-automation-BIjs7DZJ.js","assets/model-selector-DfbmHjLu.js","assets/skill-editor-D_W3QlRz.js","assets/code-editor-BqGUZFt6.js","assets/index-OUb5Mlez.js","assets/index-Vcq4gwWv.js","assets/use-mention-search-uyW1Uwf6.js","assets/proposal-review-shell-D9HwnDda.js","assets/runs-BnYdToDc.js","assets/agent-loading-shells-CLoLeFcB.js","assets/agent-thread-CzCJU3-R.js","assets/pending-seed-CPbfgnLX.js","assets/events-feed-iliGfjit.js","assets/clients-DhYr4lyL.js","assets/renderer-CHNejd95.js","assets/card-DeFQuU_J.js","assets/json-diff-DnsW7Pin.js","assets/connection-feed-detail-B3ePAinf.js","assets/runs-table-B7jKuILd.js","assets/index-C2oCgDX7.js","assets/full-page-spinner-BN2G_YiM.js","assets/index-Clw9ZBj-.js","assets/activity-route-view-DVW3DoB7.js","assets/agent-thread-storage-U6htL3ad.js","assets/client-rows-EJSKR6z1.js","assets/calendar-C0XpOHd8.js","assets/member-scope-gate-B560Wg-t.js","assets/new-Df_dY6Z5.js","assets/device-DpY67Jaj.js","assets/oauth-workspace-access-D9GmiMfK.js","assets/consent-bswcIzsf.js","assets/reset-password-CuISnlG_.js","assets/login-CCKNM0gV.js","assets/index-hSE2E46p.js","assets/accept-invitation-Db5jklHT.js","assets/settings-wGNHtsDP.js","assets/index-D2oL4Ydo.js","assets/memory-browse-page-DMDqKJn7.js","assets/entity-type-page-C3mT7tXn.js","assets/schema-value-normalization-B--OWDL8.js","assets/core.esm-DsLgjoel.js","assets/memory-browse-page-BnuhLJ6X.css","assets/index-Bulu5ldM.js","assets/index-C-u4yR8Z.js","assets/device-rows-Cp3yMcuV.js","assets/index-C6VAJ8Ku.js","assets/index-DOLFe19K.js","assets/list-skeleton-CHzLN7GK.js","assets/index-BvbfITqH.js","assets/agent-client-setup-list-_chLOorY.js","assets/index-nzvsA3hT.js","assets/connection-BgAlYjeV.js","assets/organization-uSDYkJpX.js","assets/agent-permissions-matrix-TP00-MYL.js","assets/_-VmyR6aN_.js","assets/_slug-CDSO20ac.js","assets/_agentId-BAVnp0c7.js","assets/new-BVQS9H-Y.js","assets/_automationId-D696vOjd.js","assets/new-DxDVE9nL.js","assets/agent-editor-form-BTNlg0kQ.js","assets/_agentId-Df-3rGi5.js","assets/agents-workbench-C2bUlJP2.js","assets/index-3o4Eepb4.js","assets/deployments-body-Cg0KiWGr.js","assets/_connectorKey.index-BBF8vGJS.js","assets/connector-provenance-DgsDg0Z9.js","assets/runs-panel-DsdESupx.js","assets/index-D7wulT4y.js","assets/agent-connect-pages-DWBgSIYT.js","assets/device._deviceId-DTYKGBY8.js","assets/device-pin-tombstone-1ikyqSdb.js","assets/_deploymentId-Iy-D5PDq.js","assets/app._appId-D0_LQTJU.js","assets/_connectorKey._connectionId-BAJGfcy7.js","assets/connected._clientId-CMe-wTuV.js","assets/connect._clientId-DWtceAAw.js","assets/skills-CN5Ube7A.js","assets/agent-skill-context-D4a2QCoZ.js","assets/settings-Bg9yCCoN.js","assets/permissions-Fe0DP6b8.js","assets/agent-subpage-shell-DuVYZvBE.js","assets/models-M51OGDRE.js","assets/identity-MSLryUi8.js","assets/index-DTSA0Xh1.js","assets/agent-skills-route-KVDDTbJB.js","assets/agent-card-controls-CZO6GI0s.js","assets/index-DxXXVPU0.js","assets/agent-guardrails-route-B5uoMC6o.js","assets/create-Cp6hMoeU.js","assets/_skillKey-DuLcQWBu.js","assets/create-CcXUdke7.js","assets/_name-CeGwb0oK.js","assets/_conversationId-Ci4rgrHm.js"])))=>i.map(i=>d[i]);
|
|
2
2
|
function $j(e,t){for(var n=0;n<t.length;n++){const a=t[n];if(typeof a!="string"&&!Array.isArray(a)){for(const o in a)if(o!=="default"&&!(o in e)){const s=Object.getOwnPropertyDescriptor(a,o);s&&Object.defineProperty(e,o,s.get?s:{enumerable:!0,get:()=>a[o]})}}}return Object.freeze(Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}))}(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const o of document.querySelectorAll('link[rel="modulepreload"]'))a(o);new MutationObserver(o=>{for(const s of o)if(s.type==="childList")for(const l of s.addedNodes)l.tagName==="LINK"&&l.rel==="modulepreload"&&a(l)}).observe(document,{childList:!0,subtree:!0});function n(o){const s={};return o.integrity&&(s.integrity=o.integrity),o.referrerPolicy&&(s.referrerPolicy=o.referrerPolicy),o.crossOrigin==="use-credentials"?s.credentials="include":o.crossOrigin==="anonymous"?s.credentials="omit":s.credentials="same-origin",s}function a(o){if(o.ep)return;o.ep=!0;const s=n(o);fetch(o.href,s)}})();var aCe=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function tc(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var Np={exports:{}},ou={};/**
|
|
3
3
|
* @license React
|
|
4
4
|
* react-jsx-runtime.production.js
|
|
@@ -7883,7 +7883,7 @@ For more information, see https://radix-ui.com/primitives/docs/components/${t.do
|
|
|
7883
7883
|
`,inConstruct:"tableCell"},{atBreak:!0,character:"|",after:"[ :-]"},{character:"|",inConstruct:"tableCell"},{atBreak:!0,character:":",after:"-"},{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{inlineCode:k,table:l,tableCell:d,tableRow:c}};function l(v,w,S,_){return f(p(v,S,_),v.align)}function c(v,w,S,_){const C=y(v,S,_),A=f([C]);return A.slice(0,A.indexOf(`
|
|
7884
7884
|
`))}function d(v,w,S,_){const C=S.enter("tableCell"),A=S.enter("phrasing"),j=S.containerPhrasing(v,{..._,before:s,after:s});return A(),C(),j}function f(v,w){return yke(v,{align:w,alignDelimiters:a,padding:n,stringLength:o})}function p(v,w,S){const _=v.children;let C=-1;const A=[],j=w.enter("table");for(;++C<_.length;)A[C]=y(_[C],w,S);return j(),A}function y(v,w,S){const _=v.children;let C=-1;const A=[],j=w.enter("tableRow");for(;++C<_.length;)A[C]=d(_[C],v,w,S);return j(),A}function k(v,w,S){let _=GS.inlineCode(v,w,S);return S.stack.includes("tableCell")&&(_=_.replace(/\|/g,"\\$&")),_}}function nve(){return{exit:{taskListCheckValueChecked:X6,taskListCheckValueUnchecked:X6,paragraph:rve}}}function ave(){return{unsafe:[{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{listItem:ove}}}function X6(e){const t=this.stack[this.stack.length-2];t.type,t.checked=e.type==="taskListCheckValueChecked"}function rve(e){const t=this.stack[this.stack.length-2];if(t&&t.type==="listItem"&&typeof t.checked=="boolean"){const n=this.stack[this.stack.length-1];n.type;const a=n.children[0];if(a&&a.type==="text"){const o=t.children;let s=-1,l;for(;++s<o.length;){const c=o[s];if(c.type==="paragraph"){l=c;break}}l===n&&(a.value=a.value.slice(1),a.value.length===0?n.children.shift():n.position&&a.position&&typeof a.position.start.offset=="number"&&(a.position.start.column++,a.position.start.offset++,n.position.start=Object.assign({},a.position.start)))}}this.exit(e)}function ove(e,t,n,a){const o=e.children[0],s=typeof e.checked=="boolean"&&o&&o.type==="paragraph",l="["+(e.checked?"x":" ")+"] ",c=n.createTracker(a);s&&c.move(l);let d=GS.listItem(e,t,n,{...a,...c.current()});return s&&(d=d.replace(/^(?:[*+-]|\d+\.)([\r\n]| {1,3})/,f)),d;function f(p){return p+l}}function ive(){return[Ige(),oke(),cke(),Wke(),nve()]}function sve(e){return{extensions:[qge(),ike(e),uke(),tve(e),ave()]}}const lve={tokenize:pve,partial:!0},YS={tokenize:yve,partial:!0},WS={tokenize:mve,partial:!0},ZS={tokenize:gve,partial:!0},cve={tokenize:kve,partial:!0},QS={name:"wwwAutolink",tokenize:hve,previous:JS},XS={name:"protocolAutolink",tokenize:fve,previous:e_},xo={name:"emailAutolink",tokenize:dve,previous:t_},Lr={};function uve(){return{text:Lr}}let ls=48;for(;ls<123;)Lr[ls]=xo,ls++,ls===58?ls=65:ls===91&&(ls=97);Lr[43]=xo;Lr[45]=xo;Lr[46]=xo;Lr[95]=xo;Lr[72]=[xo,XS];Lr[104]=[xo,XS];Lr[87]=[xo,QS];Lr[119]=[xo,QS];function dve(e,t,n){const a=this;let o,s;return l;function l(y){return!Vm(y)||!t_.call(a,a.previous)||zk(a.events)?n(y):(e.enter("literalAutolink"),e.enter("literalAutolinkEmail"),c(y))}function c(y){return Vm(y)?(e.consume(y),c):y===64?(e.consume(y),d):n(y)}function d(y){return y===46?e.check(cve,p,f)(y):y===45||y===95||Dn(y)?(s=!0,e.consume(y),d):p(y)}function f(y){return e.consume(y),o=!0,d}function p(y){return s&&o&&$n(a.previous)?(e.exit("literalAutolinkEmail"),e.exit("literalAutolink"),t(y)):n(y)}}function hve(e,t,n){const a=this;return o;function o(l){return l!==87&&l!==119||!JS.call(a,a.previous)||zk(a.events)?n(l):(e.enter("literalAutolink"),e.enter("literalAutolinkWww"),e.check(lve,e.attempt(YS,e.attempt(WS,s),n),n)(l))}function s(l){return e.exit("literalAutolinkWww"),e.exit("literalAutolink"),t(l)}}function fve(e,t,n){const a=this;let o="",s=!1;return l;function l(y){return(y===72||y===104)&&e_.call(a,a.previous)&&!zk(a.events)?(e.enter("literalAutolink"),e.enter("literalAutolinkHttp"),o+=String.fromCodePoint(y),e.consume(y),c):n(y)}function c(y){if($n(y)&&o.length<5)return o+=String.fromCodePoint(y),e.consume(y),c;if(y===58){const k=o.toLowerCase();if(k==="http"||k==="https")return e.consume(y),d}return n(y)}function d(y){return y===47?(e.consume(y),s?f:(s=!0,d)):n(y)}function f(y){return y===null||Gh(y)||Mt(y)||Ss(y)||B2(y)?n(y):e.attempt(YS,e.attempt(WS,p),n)(y)}function p(y){return e.exit("literalAutolinkHttp"),e.exit("literalAutolink"),t(y)}}function pve(e,t,n){let a=0;return o;function o(l){return(l===87||l===119)&&a<3?(a++,e.consume(l),o):l===46&&a===3?(e.consume(l),s):n(l)}function s(l){return l===null?n(l):t(l)}}function yve(e,t,n){let a,o,s;return l;function l(f){return f===46||f===95?e.check(ZS,d,c)(f):f===null||Mt(f)||Ss(f)||f!==45&&B2(f)?d(f):(s=!0,e.consume(f),l)}function c(f){return f===95?a=!0:(o=a,a=void 0),e.consume(f),l}function d(f){return o||a||!s?n(f):t(f)}}function mve(e,t){let n=0,a=0;return o;function o(l){return l===40?(n++,e.consume(l),o):l===41&&a<n?s(l):l===33||l===34||l===38||l===39||l===41||l===42||l===44||l===46||l===58||l===59||l===60||l===63||l===93||l===95||l===126?e.check(ZS,t,s)(l):l===null||Mt(l)||Ss(l)?t(l):(e.consume(l),o)}function s(l){return l===41&&a++,e.consume(l),o}}function gve(e,t,n){return a;function a(c){return c===33||c===34||c===39||c===41||c===42||c===44||c===46||c===58||c===59||c===63||c===95||c===126?(e.consume(c),a):c===38?(e.consume(c),s):c===93?(e.consume(c),o):c===60||c===null||Mt(c)||Ss(c)?t(c):n(c)}function o(c){return c===null||c===40||c===91||Mt(c)||Ss(c)?t(c):a(c)}function s(c){return $n(c)?l(c):n(c)}function l(c){return c===59?(e.consume(c),a):$n(c)?(e.consume(c),l):n(c)}}function kve(e,t,n){return a;function a(s){return e.consume(s),o}function o(s){return Dn(s)?n(s):t(s)}}function JS(e){return e===null||e===40||e===42||e===95||e===91||e===93||e===126||Mt(e)}function e_(e){return!$n(e)}function t_(e){return!(e===47||Vm(e))}function Vm(e){return e===43||e===45||e===46||e===95||Dn(e)}function zk(e){let t=e.length,n=!1;for(;t--;){const a=e[t][1];if((a.type==="labelLink"||a.type==="labelImage")&&!a._balanced){n=!0;break}if(a._gfmAutolinkLiteralWalkedInto){n=!1;break}}return e.length>0&&!n&&(e[e.length-1][1]._gfmAutolinkLiteralWalkedInto=!0),n}const vve={tokenize:Ave,partial:!0};function xve(){return{document:{91:{name:"gfmFootnoteDefinition",tokenize:Sve,continuation:{tokenize:_ve},exit:Cve}},text:{91:{name:"gfmFootnoteCall",tokenize:Mve},93:{name:"gfmPotentialFootnoteCall",add:"after",tokenize:bve,resolveTo:wve}}}}function bve(e,t,n){const a=this;let o=a.events.length;const s=a.parser.gfmFootnotes||(a.parser.gfmFootnotes=[]);let l;for(;o--;){const d=a.events[o][1];if(d.type==="labelImage"){l=d;break}if(d.type==="gfmFootnoteCall"||d.type==="labelLink"||d.type==="label"||d.type==="image"||d.type==="link")break}return c;function c(d){if(!l||!l._balanced)return n(d);const f=lr(a.sliceSerialize({start:l.end,end:a.now()}));return f.codePointAt(0)!==94||!s.includes(f.slice(1))?n(d):(e.enter("gfmFootnoteCallLabelMarker"),e.consume(d),e.exit("gfmFootnoteCallLabelMarker"),t(d))}}function wve(e,t){let n=e.length;for(;n--;)if(e[n][1].type==="labelImage"&&e[n][0]==="enter"){e[n][1];break}e[n+1][1].type="data",e[n+3][1].type="gfmFootnoteCallLabelMarker";const a={type:"gfmFootnoteCall",start:Object.assign({},e[n+3][1].start),end:Object.assign({},e[e.length-1][1].end)},o={type:"gfmFootnoteCallMarker",start:Object.assign({},e[n+3][1].end),end:Object.assign({},e[n+3][1].end)};o.end.column++,o.end.offset++,o.end._bufferIndex++;const s={type:"gfmFootnoteCallString",start:Object.assign({},o.end),end:Object.assign({},e[e.length-1][1].start)},l={type:"chunkString",contentType:"string",start:Object.assign({},s.start),end:Object.assign({},s.end)},c=[e[n+1],e[n+2],["enter",a,t],e[n+3],e[n+4],["enter",o,t],["exit",o,t],["enter",s,t],["enter",l,t],["exit",l,t],["exit",s,t],e[e.length-2],e[e.length-1],["exit",a,t]];return e.splice(n,e.length-n+1,...c),e}function Mve(e,t,n){const a=this,o=a.parser.gfmFootnotes||(a.parser.gfmFootnotes=[]);let s=0,l;return c;function c(y){return e.enter("gfmFootnoteCall"),e.enter("gfmFootnoteCallLabelMarker"),e.consume(y),e.exit("gfmFootnoteCallLabelMarker"),d}function d(y){return y!==94?n(y):(e.enter("gfmFootnoteCallMarker"),e.consume(y),e.exit("gfmFootnoteCallMarker"),e.enter("gfmFootnoteCallString"),e.enter("chunkString").contentType="string",f)}function f(y){if(s>999||y===93&&!l||y===null||y===91||Mt(y))return n(y);if(y===93){e.exit("chunkString");const k=e.exit("gfmFootnoteCallString");return o.includes(lr(a.sliceSerialize(k)))?(e.enter("gfmFootnoteCallLabelMarker"),e.consume(y),e.exit("gfmFootnoteCallLabelMarker"),e.exit("gfmFootnoteCall"),t):n(y)}return Mt(y)||(l=!0),s++,e.consume(y),y===92?p:f}function p(y){return y===91||y===92||y===93?(e.consume(y),s++,f):f(y)}}function Sve(e,t,n){const a=this,o=a.parser.gfmFootnotes||(a.parser.gfmFootnotes=[]);let s,l=0,c;return d;function d(w){return e.enter("gfmFootnoteDefinition")._container=!0,e.enter("gfmFootnoteDefinitionLabel"),e.enter("gfmFootnoteDefinitionLabelMarker"),e.consume(w),e.exit("gfmFootnoteDefinitionLabelMarker"),f}function f(w){return w===94?(e.enter("gfmFootnoteDefinitionMarker"),e.consume(w),e.exit("gfmFootnoteDefinitionMarker"),e.enter("gfmFootnoteDefinitionLabelString"),e.enter("chunkString").contentType="string",p):n(w)}function p(w){if(l>999||w===93&&!c||w===null||w===91||Mt(w))return n(w);if(w===93){e.exit("chunkString");const S=e.exit("gfmFootnoteDefinitionLabelString");return s=lr(a.sliceSerialize(S)),e.enter("gfmFootnoteDefinitionLabelMarker"),e.consume(w),e.exit("gfmFootnoteDefinitionLabelMarker"),e.exit("gfmFootnoteDefinitionLabel"),k}return Mt(w)||(c=!0),l++,e.consume(w),w===92?y:p}function y(w){return w===91||w===92||w===93?(e.consume(w),l++,p):p(w)}function k(w){return w===58?(e.enter("definitionMarker"),e.consume(w),e.exit("definitionMarker"),o.includes(s)||o.push(s),ot(e,v,"gfmFootnoteDefinitionWhitespace")):n(w)}function v(w){return t(w)}}function _ve(e,t,n){return e.check(y1,t,e.attempt(vve,t,n))}function Cve(e){e.exit("gfmFootnoteDefinition")}function Ave(e,t,n){const a=this;return ot(e,o,"gfmFootnoteDefinitionIndent",5);function o(s){const l=a.events[a.events.length-1];return l&&l[1].type==="gfmFootnoteDefinitionIndent"&&l[2].sliceSerialize(l[1],!0).length===4?t(s):n(s)}}function Eve(e){let n=(e||{}).singleTilde;const a={name:"strikethrough",tokenize:s,resolveAll:o};return n==null&&(n=!0),{text:{126:a},insideSpan:{null:[a]},attentionMarkers:{null:[126]}};function o(l,c){let d=-1;for(;++d<l.length;)if(l[d][0]==="enter"&&l[d][1].type==="strikethroughSequenceTemporary"&&l[d][1]._close){let f=d;for(;f--;)if(l[f][0]==="exit"&&l[f][1].type==="strikethroughSequenceTemporary"&&l[f][1]._open&&l[d][1].end.offset-l[d][1].start.offset===l[f][1].end.offset-l[f][1].start.offset){l[d][1].type="strikethroughSequence",l[f][1].type="strikethroughSequence";const p={type:"strikethrough",start:Object.assign({},l[f][1].start),end:Object.assign({},l[d][1].end)},y={type:"strikethroughText",start:Object.assign({},l[f][1].end),end:Object.assign({},l[d][1].start)},k=[["enter",p,c],["enter",l[f][1],c],["exit",l[f][1],c],["enter",y,c]],v=c.parser.constructs.insideSpan.null;v&&Pa(k,k.length,0,$2(v,l.slice(f+1,d),c)),Pa(k,k.length,0,[["exit",y,c],["enter",l[d][1],c],["exit",l[d][1],c],["exit",p,c]]),Pa(l,f-1,d-f+3,k),d=f+k.length-2;break}}for(d=-1;++d<l.length;)l[d][1].type==="strikethroughSequenceTemporary"&&(l[d][1].type="data");return l}function s(l,c,d){const f=this.previous,p=this.events;let y=0;return k;function k(w){return f===126&&p[p.length-1][1].type!=="characterEscape"?d(w):(l.enter("strikethroughSequenceTemporary"),v(w))}function v(w){const S=Zl(f);if(w===126)return y>1?d(w):(l.consume(w),y++,v);if(y<2&&!n)return d(w);const _=l.exit("strikethroughSequenceTemporary"),C=Zl(w);return _._open=!C||C===2&&!!S,_._close=!S||S===2&&!!C,c(w)}}}class Rve{constructor(){this.map=[]}add(t,n,a){jve(this,t,n,a)}consume(t){if(this.map.sort(function(s,l){return s[0]-l[0]}),this.map.length===0)return;let n=this.map.length;const a=[];for(;n>0;)n-=1,a.push(t.slice(this.map[n][0]+this.map[n][1]),this.map[n][2]),t.length=this.map[n][0];a.push(t.slice()),t.length=0;let o=a.pop();for(;o;){for(const s of o)t.push(s);o=a.pop()}this.map.length=0}}function jve(e,t,n,a){let o=0;if(!(n===0&&a.length===0)){for(;o<e.map.length;){if(e.map[o][0]===t){e.map[o][1]+=n,e.map[o][2].push(...a);return}o+=1}e.map.push([t,n,a])}}function Ove(e,t){let n=!1;const a=[];for(;t<e.length;){const o=e[t];if(n){if(o[0]==="enter")o[1].type==="tableContent"&&a.push(e[t+1][1].type==="tableDelimiterMarker"?"left":"none");else if(o[1].type==="tableContent"){if(e[t-1][1].type==="tableDelimiterMarker"){const s=a.length-1;a[s]=a[s]==="left"?"center":"right"}}else if(o[1].type==="tableDelimiterRow")break}else o[0]==="enter"&&o[1].type==="tableDelimiterRow"&&(n=!0);t+=1}return a}function Nve(){return{flow:{null:{name:"table",tokenize:Tve,resolveAll:Pve}}}}function Tve(e,t,n){const a=this;let o=0,s=0,l;return c;function c(D){let G=a.events.length-1;for(;G>-1;){const F=a.events[G][1].type;if(F==="lineEnding"||F==="linePrefix")G--;else break}const $=G>-1?a.events[G][1].type:null,X=$==="tableHead"||$==="tableRow"?T:d;return X===T&&a.parser.lazy[a.now().line]?n(D):X(D)}function d(D){return e.enter("tableHead"),e.enter("tableRow"),f(D)}function f(D){return D===124||(l=!0,s+=1),p(D)}function p(D){return D===null?n(D):Le(D)?s>1?(s=0,a.interrupt=!0,e.exit("tableRow"),e.enter("lineEnding"),e.consume(D),e.exit("lineEnding"),v):n(D):Je(D)?ot(e,p,"whitespace")(D):(s+=1,l&&(l=!1,o+=1),D===124?(e.enter("tableCellDivider"),e.consume(D),e.exit("tableCellDivider"),l=!0,p):(e.enter("data"),y(D)))}function y(D){return D===null||D===124||Mt(D)?(e.exit("data"),p(D)):(e.consume(D),D===92?k:y)}function k(D){return D===92||D===124?(e.consume(D),y):y(D)}function v(D){return a.interrupt=!1,a.parser.lazy[a.now().line]?n(D):(e.enter("tableDelimiterRow"),l=!1,Je(D)?ot(e,w,"linePrefix",a.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(D):w(D))}function w(D){return D===45||D===58?_(D):D===124?(l=!0,e.enter("tableCellDivider"),e.consume(D),e.exit("tableCellDivider"),S):I(D)}function S(D){return Je(D)?ot(e,_,"whitespace")(D):_(D)}function _(D){return D===58?(s+=1,l=!0,e.enter("tableDelimiterMarker"),e.consume(D),e.exit("tableDelimiterMarker"),C):D===45?(s+=1,C(D)):D===null||Le(D)?N(D):I(D)}function C(D){return D===45?(e.enter("tableDelimiterFiller"),A(D)):I(D)}function A(D){return D===45?(e.consume(D),A):D===58?(l=!0,e.exit("tableDelimiterFiller"),e.enter("tableDelimiterMarker"),e.consume(D),e.exit("tableDelimiterMarker"),j):(e.exit("tableDelimiterFiller"),j(D))}function j(D){return Je(D)?ot(e,N,"whitespace")(D):N(D)}function N(D){return D===124?w(D):D===null||Le(D)?!l||o!==s?I(D):(e.exit("tableDelimiterRow"),e.exit("tableHead"),t(D)):I(D)}function I(D){return n(D)}function T(D){return e.enter("tableRow"),q(D)}function q(D){return D===124?(e.enter("tableCellDivider"),e.consume(D),e.exit("tableCellDivider"),q):D===null||Le(D)?(e.exit("tableRow"),t(D)):Je(D)?ot(e,q,"whitespace")(D):(e.enter("data"),R(D))}function R(D){return D===null||D===124||Mt(D)?(e.exit("data"),q(D)):(e.consume(D),D===92?H:R)}function H(D){return D===92||D===124?(e.consume(D),R):R(D)}}function Pve(e,t){let n=-1,a=!0,o=0,s=[0,0,0,0],l=[0,0,0,0],c=!1,d=0,f,p,y;const k=new Rve;for(;++n<e.length;){const v=e[n],w=v[1];v[0]==="enter"?w.type==="tableHead"?(c=!1,d!==0&&(J6(k,t,d,f,p),p=void 0,d=0),f={type:"table",start:Object.assign({},w.start),end:Object.assign({},w.end)},k.add(n,0,[["enter",f,t]])):w.type==="tableRow"||w.type==="tableDelimiterRow"?(a=!0,y=void 0,s=[0,0,0,0],l=[0,n+1,0,0],c&&(c=!1,p={type:"tableBody",start:Object.assign({},w.start),end:Object.assign({},w.end)},k.add(n,0,[["enter",p,t]])),o=w.type==="tableDelimiterRow"?2:p?3:1):o&&(w.type==="data"||w.type==="tableDelimiterMarker"||w.type==="tableDelimiterFiller")?(a=!1,l[2]===0&&(s[1]!==0&&(l[0]=l[1],y=dh(k,t,s,o,void 0,y),s=[0,0,0,0]),l[2]=n)):w.type==="tableCellDivider"&&(a?a=!1:(s[1]!==0&&(l[0]=l[1],y=dh(k,t,s,o,void 0,y)),s=l,l=[s[1],n,0,0])):w.type==="tableHead"?(c=!0,d=n):w.type==="tableRow"||w.type==="tableDelimiterRow"?(d=n,s[1]!==0?(l[0]=l[1],y=dh(k,t,s,o,n,y)):l[1]!==0&&(y=dh(k,t,l,o,n,y)),o=0):o&&(w.type==="data"||w.type==="tableDelimiterMarker"||w.type==="tableDelimiterFiller")&&(l[3]=n)}for(d!==0&&J6(k,t,d,f,p),k.consume(t.events),n=-1;++n<t.events.length;){const v=t.events[n];v[0]==="enter"&&v[1].type==="table"&&(v[1]._align=Ove(t.events,n))}return e}function dh(e,t,n,a,o,s){const l=a===1?"tableHeader":a===2?"tableDelimiter":"tableData",c="tableContent";n[0]!==0&&(s.end=Object.assign({},Tl(t.events,n[0])),e.add(n[0],0,[["exit",s,t]]));const d=Tl(t.events,n[1]);if(s={type:l,start:Object.assign({},d),end:Object.assign({},d)},e.add(n[1],0,[["enter",s,t]]),n[2]!==0){const f=Tl(t.events,n[2]),p=Tl(t.events,n[3]),y={type:c,start:Object.assign({},f),end:Object.assign({},p)};if(e.add(n[2],0,[["enter",y,t]]),a!==2){const k=t.events[n[2]],v=t.events[n[3]];if(k[1].end=Object.assign({},v[1].end),k[1].type="chunkText",k[1].contentType="text",n[3]>n[2]+1){const w=n[2]+1,S=n[3]-n[2]-1;e.add(w,S,[])}}e.add(n[3]+1,0,[["exit",y,t]])}return o!==void 0&&(s.end=Object.assign({},Tl(t.events,o)),e.add(o,0,[["exit",s,t]]),s=void 0),s}function J6(e,t,n,a,o){const s=[],l=Tl(t.events,n);o&&(o.end=Object.assign({},l),s.push(["exit",o,t])),a.end=Object.assign({},l),s.push(["exit",a,t]),e.add(n+1,0,s)}function Tl(e,t){const n=e[t],a=n[0]==="enter"?"start":"end";return n[1][a]}const Lve={name:"tasklistCheck",tokenize:Dve};function zve(){return{text:{91:Lve}}}function Dve(e,t,n){const a=this;return o;function o(d){return a.previous!==null||!a._gfmTasklistFirstContentOfListItem?n(d):(e.enter("taskListCheck"),e.enter("taskListCheckMarker"),e.consume(d),e.exit("taskListCheckMarker"),s)}function s(d){return Mt(d)?(e.enter("taskListCheckValueUnchecked"),e.consume(d),e.exit("taskListCheckValueUnchecked"),l):d===88||d===120?(e.enter("taskListCheckValueChecked"),e.consume(d),e.exit("taskListCheckValueChecked"),l):n(d)}function l(d){return d===93?(e.enter("taskListCheckMarker"),e.consume(d),e.exit("taskListCheckMarker"),e.exit("taskListCheck"),c):n(d)}function c(d){return Le(d)?t(d):Je(d)?e.check({tokenize:Ive},t,n)(d):n(d)}}function Ive(e,t,n){return ot(e,a,"whitespace");function a(o){return o===null?n(o):t(o)}}function qve(e){return dS([uve(),xve(),Eve(e),Nve(),zve()])}const Hve={};function n_(e){const t=this,n=e||Hve,a=t.data(),o=a.micromarkExtensions||(a.micromarkExtensions=[]),s=a.fromMarkdownExtensions||(a.fromMarkdownExtensions=[]),l=a.toMarkdownExtensions||(a.toMarkdownExtensions=[]);o.push(qve(n)),s.push(ive()),l.push(sve(n))}function Vve(e){if(!e)return!1;try{const t=typeof window>"u"?"https://localhost":window.location.href,n=new URL(e,t);return n.protocol!=="https:"&&n.protocol!=="http:"?!1:typeof window>"u"||n.host===window.location.host}catch{return!1}}const a_={h1:({children:e})=>h.jsx("h1",{className:"mt-3 mb-1 font-semibold text-base",children:e}),h2:({children:e})=>h.jsx("h2",{className:"mt-3 mb-1 font-semibold text-base",children:e}),h3:({children:e})=>h.jsx("h3",{className:"mt-2 mb-1 font-semibold text-sm",children:e}),h4:({children:e})=>h.jsx("h4",{className:"mt-2 mb-1 font-semibold text-sm",children:e}),p:({children:e})=>h.jsx("p",{className:"leading-relaxed",children:e}),ul:({children:e})=>h.jsx("ul",{className:"my-1 list-disc space-y-0.5 pl-5",children:e}),ol:({children:e})=>h.jsx("ol",{className:"my-1 list-decimal space-y-0.5 pl-5",children:e}),li:({children:e})=>h.jsx("li",{className:"leading-relaxed",children:e}),strong:({children:e})=>h.jsx("strong",{className:"font-semibold",children:e}),em:({children:e})=>h.jsx("em",{className:"italic",children:e}),a:({href:e,children:t})=>Vve(e)?h.jsx("a",{href:e,target:"_blank",rel:"noopener noreferrer",className:"font-medium text-primary underline underline-offset-2",children:t}):h.jsx(h.Fragment,{children:t}),img:({alt:e})=>h.jsx(h.Fragment,{children:e}),code:({className:e,children:t})=>/^language-/.test(e??"")?h.jsx("code",{className:e,children:t}):h.jsx("code",{className:"rounded bg-foreground/10 px-1 py-0.5 text-[0.85em]",children:t}),pre:({children:e})=>h.jsx("pre",{className:"my-2 overflow-x-auto rounded-lg border bg-foreground/5 p-3 text-xs",children:e}),blockquote:({children:e})=>h.jsx("blockquote",{className:"border-border border-l-2 pl-3 text-muted-foreground italic",children:e}),hr:()=>h.jsx("hr",{className:"my-3 border-border"}),table:({children:e})=>h.jsx("div",{className:"my-2 overflow-x-auto",children:h.jsx("table",{className:"w-full border-collapse text-xs",children:e})}),th:({children:e})=>h.jsx("th",{className:"border border-border px-2 py-1 text-left font-semibold",children:e}),td:({children:e})=>h.jsx("td",{className:"border border-border px-2 py-1",children:e})},zAe=({text:e,className:t})=>h.jsx("div",{className:ye("space-y-2 break-words text-sm",t),children:h.jsx(NS,{remarkPlugins:[n_],components:a_,children:e})}),r_={...a_,p:({children:e})=>h.jsx(h.Fragment,{children:e}),h1:({children:e})=>h.jsx(h.Fragment,{children:e}),h2:({children:e})=>h.jsx(h.Fragment,{children:e}),h3:({children:e})=>h.jsx(h.Fragment,{children:e}),h4:({children:e})=>h.jsx(h.Fragment,{children:e}),h5:({children:e})=>h.jsx(h.Fragment,{children:e}),h6:({children:e})=>h.jsx(h.Fragment,{children:e}),ul:({children:e})=>h.jsx(h.Fragment,{children:e}),ol:({children:e})=>h.jsx(h.Fragment,{children:e}),li:({children:e})=>h.jsx(h.Fragment,{children:e}),blockquote:({children:e})=>h.jsx(h.Fragment,{children:e}),pre:({children:e})=>h.jsx(h.Fragment,{children:e}),hr:()=>null},Fve={...r_,a:({children:e})=>h.jsx(h.Fragment,{children:e})},Bve=({text:e,className:t,linkPolicy:n="strip"})=>h.jsx("span",{className:ye("break-words",t),children:h.jsx(NS,{remarkPlugins:[n_],components:n==="app-links"?r_:Fve,children:e})}),Y2=["peek","peek_run_id","peek_content_ids","peek_automation","peek_view","peek_entity"];function o_(e){return e==="1"||e==="true"||e===!0||e===1}function uc(e){if(!e)return{};const t={};for(const n of Y2){const a=e[n];if(!(a==null||a==="")){if(n==="peek"){o_(a)&&(t.peek="1");continue}typeof a=="string"&&a.trim()?t[n]=a.trim():typeof a=="number"&&Number.isFinite(a)&&(t[n]=String(a))}}return t}function e8(e){const t={...e};for(const n of Y2)delete t[n];return t}function $ve(e){return o_(e?.peek)}function qy(e){const t=e.split("/").filter(Boolean);if(t.length<3||t.length%2===0||Ri(t[1]))return null;const n=t.slice(1).join("/");return Ql(n)?n:null}function Uve(e,t){if(t.peek_automation){const n=new URLSearchParams;(t.peek_view==="activity"||t.peek_view==="definition")&&n.set("view",t.peek_view),t.peek_run_id&&/^\d+$/.test(t.peek_run_id)&&n.set("run_id",t.peek_run_id);const a=n.size>0?`?${n.toString()}`:"";return`/${e}/automations/${t.peek_automation}${a}`}if(t.peek_run_id&&Qh(t.peek_run_id)){const n=new URLSearchParams({run_ids:t.peek_run_id});return`/${e}/events?${n.toString()}`}if(t.peek_content_ids&&Qh(t.peek_content_ids)){const n=new URLSearchParams({content_ids:t.peek_content_ids});return`/${e}/events?${n.toString()}`}return t.peek_entity&&Ql(t.peek_entity)?`/${e}/events/${t.peek_entity}`:null}function t8(e){const{pathname:t,search:n}=sc(e),a=t.split("/").filter(Boolean);if(a.length===2&&(a[1]==="events"||a[1]==="memory")){const o=n?.run_ids;if(o&&Qh(o))return{peek:"1",peek_run_id:o};const s=n?.content_ids;return s&&Qh(s)?{peek:"1",peek_content_ids:s}:null}if(a.length>=4&&a[1]==="events"){const o=a.slice(2).join("/");return Ql(o)?{peek:"1",peek_entity:o}:null}if(a.length>=3&&!Ri(a[1])){const o=a.slice(1).join("/");return Ql(o)?{peek:"1",peek_entity:o}:null}if(a.length===3&&a[1]==="automations"){const o={peek:"1",peek_automation:a[2]};return(n?.view==="activity"||n?.view==="definition")&&(o.peek_view=n.view),n?.run_id&&/^\d+$/.test(n.run_id)&&(o.peek_run_id=n.run_id),o}return null}function Ql(e){const t=e.split("/");return t.length>=2&&t.length%2===0&&t.every(n=>n.length>0&&!n.includes("?"))&&!Ri(t[0])&&!["chat","entity-types","recent"].includes(t[0])}function Qh(e){const t=e.split(",");return t.length>0&&t.length<=50&&t.every(n=>/^\d+$/.test(n.trim())&&Number(n)>0)}function n8(e,t){const n={...e};for(const a of Y2)delete n[a];for(const[a,o]of Object.entries(t))o&&(n[a]=o);return n}const Fm="[^/]+",Kve=new RegExp(`^/(${Fm})/automations/(${Fm})/?$`),Gve=new RegExp(`^/(${Fm})/(?:events|memory)/?$`);function W2(e){const{pathname:t,search:n}=sc(e),a=t.match(Kve);if(a){const[,l,c]=a,d=n?.view==="activity"||n?.view==="definition"?n.view:void 0,f=i_(n?.run_id);return{kind:"automation",owner:l,automationId:c,view:d,runId:f}}const o=t.match(Gve);if(o){const[,l]=o,c=a8(n?.run_ids);if(c?.length===1)return{kind:"memory",owner:l,runId:c[0]};if(c&&c.length>1)return{kind:"memory",owner:l,runIds:c};const d=a8(n?.content_ids);return d?{kind:"memory",owner:l,contentIds:d}:null}const s=t.split("/").filter(Boolean);if(s.length>=4&&s[1]==="events")return Ql(s.slice(2).join("/"))?{kind:"entity",owner:s[0],path:s.slice(2).join("/")}:null;if(s.length>=3&&Ql(s.slice(1).join("/"))){const l=s.slice(1).join("/");return{kind:"entity",owner:s[0],path:l}}return null}function a8(e){if(!e)return null;const t=e.split(",");if(t.length===0||t.length>50)return null;const n=t.map(a=>i_(a.trim()));return n.every(a=>a!=null)?n:null}function i_(e){if(e==null||e==="")return;const t=Number(e);return Number.isFinite(t)&&t>0?t:void 0}const s_=b.createContext(null);function Yve(e,t){if(t?.trim())return t.trim();const n=W2(e);return n?n.kind==="memory"&&"runId"in n?`Run #${n.runId}`:n.kind==="memory"||n.kind==="entity"?"Activity":n.kind==="automation"?n.runId!=null?`Automation run #${n.runId}`:"Automation":"Details":"Details"}function DAe({children:e}){const t=qn(),n=t1(),o=e1({strict:!1}).owner??"",[s,l]=b.useState(null),[c,d]=b.useState([]);b.useEffect(()=>{const v=()=>{l(null),d(j=>j.length>0?[]:j)};if(!o){v();return}const w=n.search;if(!$ve(w)){v();return}const S=uc(w);if(!S.peek_entity&&!S.peek_run_id&&!S.peek_content_ids&&!S.peek_automation){const j=qy(n.pathname);j&&(S.peek_entity=j)}const _=Uve(o,S),C=_?W2(_):null;if(!_||!C){v();return}const A=C.kind==="memory"&&"runId"in C||C.kind==="automation"?C.runId:void 0;l(j=>j?.href===_&&j.runId===A?j:{href:_,title:Yve(_,j?.href===_?j.title:void 0),runId:A})},[n.search,n.pathname,o]);const f=b.useCallback(v=>{d(S=>s&&s.href!==v.href?[...S,s]:S);const w=t8(v.href);if(!w){l(v);return}if(typeof v.browserUrl=="string"&&v.browserUrl.length>0){l(v);return}v.runId!=null&&w.peek_automation&&!w.peek_run_id&&(w.peek_run_id=String(v.runId)),w.peek_entity&&w.peek_entity===qy(n.pathname)&&(w.peek_entity=void 0),l(v),t({search:(S=>n8(S,w)),replace:!0})},[t,n.pathname,s]),p=b.useCallback(()=>{const v=c[c.length-1];if(!v)return;d(S=>S.slice(0,-1)),l(v);const w=t8(v.href);!w||v.browserUrl||(w?.peek_entity&&w.peek_entity===qy(n.pathname)&&(w.peek_entity=void 0),t({search:(S=>w?n8(S,w):e8(S)),replace:!0}))},[t,c,n.pathname]),y=b.useCallback(()=>{d([]),l(null),t({search:(v=>e8(v)),replace:!0})},[t]),k=b.useMemo(()=>({item:s,open:f,close:y,back:c.length>0?p:null}),[s,f,y,p,c.length]);return h.jsx(s_.Provider,{value:k,children:e})}function Dk(){return b.useContext(s_)}function Xh({className:e}){return h.jsxs("svg",{viewBox:"-8 -7.3 116 116",className:e,fill:"currentColor","aria-hidden":"true","data-lobu-mark":"",children:[h.jsx("rect",{x:"0",y:"0.5",width:"45",height:"100"}),h.jsx("circle",{cx:"77",cy:"23",r:"23"}),h.jsx("path",{d:"M55,55.96h45v22.5c0,12.42-10.08,22.5-22.5,22.5h0c-12.42,0-22.5-10.08-22.5-22.5v-22.5h0Z"})]})}function Z2(e,t,n="0 0 24 24"){return h.jsx("svg",{"aria-hidden":"true",className:"h-4 w-4 shrink-0","data-app-icon":e,viewBox:n,fill:"currentColor",children:h.jsx("path",{d:t})})}const Wve=Z2("openai","M22.282 9.821a5.985 5.985 0 0 0-.516-4.91 6.046 6.046 0 0 0-6.51-2.9A6.065 6.065 0 0 0 4.981 4.18a5.985 5.985 0 0 0-3.998 2.9 6.046 6.046 0 0 0 .743 7.097 5.98 5.98 0 0 0 .51 4.911 6.051 6.051 0 0 0 6.515 2.9A5.985 5.985 0 0 0 13.26 24a6.056 6.056 0 0 0 5.772-4.206 5.99 5.99 0 0 0 3.997-2.9 6.056 6.056 0 0 0-.747-7.073zM13.26 22.43a4.476 4.476 0 0 1-2.876-1.04l.141-.081 4.779-2.758a.795.795 0 0 0 .392-.681v-6.737l2.02 1.168a.071.071 0 0 1 .038.052v5.583a4.504 4.504 0 0 1-4.494 4.494zM3.6 18.304a4.47 4.47 0 0 1-.535-3.014l.142.085 4.783 2.759a.771.771 0 0 0 .78 0l5.843-3.369v2.332a.08.08 0 0 1-.033.062L9.74 19.95a4.5 4.5 0 0 1-6.14-1.646zM2.34 7.896a4.485 4.485 0 0 1 2.366-1.973V11.6a.766.766 0 0 0 .388.676l5.815 3.355-2.02 1.168a.076.076 0 0 1-.071 0l-4.83-2.786A4.504 4.504 0 0 1 2.34 7.872zm16.597 3.855l-5.833-3.387L15.119 7.2a.076.076 0 0 1 .071 0l4.83 2.791a4.494 4.494 0 0 1-.676 8.105v-5.678a.79.79 0 0 0-.407-.667zm2.01-3.023l-.141-.085-4.774-2.782a.776.776 0 0 0-.785 0L9.409 9.23V6.897a.066.066 0 0 1 .028-.061l4.83-2.787a4.5 4.5 0 0 1 6.68 4.66zm-12.64 4.135l-2.02-1.164a.08.08 0 0 1-.038-.057V6.075a4.5 4.5 0 0 1 7.375-3.453l-.142.08L8.704 5.46a.795.795 0 0 0-.393.681zm1.097-2.365l2.602-1.5 2.607 1.5v2.999l-2.597 1.5-2.607-1.5z"),Zve=Z2("anthropic","M17.3041 3.541h-3.6233l6.6005 16.918H24Zm-10.6082 0L0 20.459h3.7235l1.3508-3.5042h6.9089l1.3505 3.5042h3.7234L10.4313 3.541Zm-.1538 10.353 2.2625-5.8253 2.2623 5.8253Z"),Qve=Z2("gemini","M12 0C5.375 0 0 5.375 0 12s5.375 12 12 12 12-5.375 12-12S18.625 0 12 0zm0 2.182a9.818 9.818 0 0 1 6.943 2.875A13.765 13.765 0 0 1 12 8.727a13.765 13.765 0 0 1-6.943-3.67A9.818 9.818 0 0 1 12 2.182zM3.67 6.41A13.765 13.765 0 0 1 8.727 12a13.765 13.765 0 0 1-5.057 5.59 9.818 9.818 0 0 1 0-11.18zM12 21.818a9.818 9.818 0 0 1-6.943-2.875A13.765 13.765 0 0 1 12 15.273a13.765 13.765 0 0 1 6.943 3.67A9.818 9.818 0 0 1 12 21.818zm8.33-4.228A13.765 13.765 0 0 1 15.273 12a13.765 13.765 0 0 1 5.057-5.59 9.818 9.818 0 0 1 0 11.18z"),Xve=Z2("cursor","M2.5 2L12.5 22L14.5 14.5L22 12.5L2.5 2Z");function Jve(e){const t=e?.trim().toLowerCase();if(t){if(t.includes("claude")||t.includes("anthropic"))return Zve;if(t.includes("codex")||t.includes("chatgpt")||t.includes("openai"))return Wve;if(t.includes("gemini"))return Qve;if(t.includes("cursor"))return Xve;if(t.includes("lobu"))return h.jsx(Xh,{className:"h-4 w-4 shrink-0"})}}function l_({name:e}){return Jve(e)??h.jsx(LM,{className:"h-4 w-4 shrink-0"})}function e4e(e){return new Map(e.map(t=>[t.key,t]))}const t4e={ios:"iOS",android:"Android",macos:"macOS",windows:"Windows",linux:"Linux"};function c_(e){return e?.length?e.map(t=>t4e[t]??t).join(", "):null}const n4e={oauth:"OAuth",browser:"Browser",apiKey:"API key",api_key:"API key",env:"API key",env_keys:"API key",interactive:"Interactive"};function u_(e){if(!e)return[];const t=e.methods;if(!Array.isArray(t))return[];const n=new Set,a=[];for(const o of t){const s=o.type;if(typeof s!="string"||s==="none")continue;const l=n4e[s]??s;n.has(l)||(n.add(l),a.push(l))}return a}function d_(e){if(!e)return null;const t=e.methods;if(!Array.isArray(t))return null;for(const n of t){if(n.type!=="oauth")continue;const a=n.authorization_url??n.authorizationUrl;if(typeof a=="string")try{return new URL(a).hostname}catch{}if(typeof n.provider=="string"&&n.provider.length>0)return`${n.provider}.com`}return null}function a4e(e,t,n){const o=(Array.isArray(t)?e4e(t):t).get(e);return{key:e,name:o?.name||n?.name||e,description:o?.description??n?.description??null,icon:o?.icon??n?.icon??null,iconUrl:n?.iconUrl??null,faviconDomain:o?.favicon_domain??d_(o?.auth_schema)??n?.faviconDomain??null}}function r8(e){const t=e.trim();if(!t)return"?";const n=t.replace(/[^a-zA-Z0-9\s.-]/g,"").trim(),a=n.split(/[\s.-]+/).filter(Boolean);return a.length>=2?`${a[0][0]??""}${a[1][0]??""}`.toUpperCase():(n||t).slice(0,2).toUpperCase()}function h_({icon:e,iconUrl:t,name:n,faviconDomain:a,plain:o=!1,className:s}){const[l,c]=b.useState(!1),[d,f]=b.useState(!1),p=o?"text-muted-foreground":"rounded-lg border bg-muted/40 text-muted-foreground";return e?h.jsx("span",{className:ye("flex h-8 w-8 shrink-0 items-center justify-center",p,s),children:h.jsx(tk,{icon:e,className:"h-4 w-4",fallback:r8(n)})}):t&&!d?h.jsx("span",{className:ye("flex h-8 w-8 shrink-0 items-center justify-center",p,s),children:h.jsx("img",{src:t,alt:n,width:16,height:16,className:"h-4 w-4",onError:()=>f(!0)})}):a&&!l?h.jsx("span",{className:ye("flex h-8 w-8 shrink-0 items-center justify-center",p,s),children:h.jsx("img",{src:`https://www.google.com/s2/favicons?domain=${encodeURIComponent(a)}&sz=32`,alt:n,width:16,height:16,className:"h-4 w-4",onError:()=>c(!0)})}):h.jsx("span",{className:ye("flex h-8 w-8 shrink-0 items-center justify-center text-[11px] font-semibold uppercase tracking-wide",p,s),children:r8(n)})}function Ll({connector:e,className:t,nameClassName:n,descriptionClassName:a,showDescription:o=!0}){const s=e.faviconDomain??e.favicon_domain??d_(e.auth_schema);return h.jsxs("div",{className:ye("flex min-w-0 items-center gap-3",t),children:[h.jsx(h_,{icon:e.icon,iconUrl:e.iconUrl,name:e.name,faviconDomain:s}),h.jsxs("div",{className:"min-w-0",children:[h.jsx("div",{className:ye("truncate text-sm font-medium",n),children:e.name}),o&&e.description&&h.jsx("p",{className:ye("truncate text-xs text-muted-foreground",a),children:e.description})]})]})}const f_={screentime:"Screen Time",local_directory:"Local Folder",healthkit:"Apple Health",photos:"Photos",calendar:"Calendar",reminders:"Reminders",system_audio:"Meeting audio",computer_use:"Computer use"},r4e={ios:"iPhone",macos:"Mac","chrome-extension":"Chrome",headless:"Worker"};function Ik(e){return e.platform?e.platform:/^ios-bridge-/i.test(e.worker_id)?"ios":/^mac-bridge-/i.test(e.worker_id)?"macos":null}function o4e(e){return r4e[e??""]??e??"Device"}function i4e(e){const t=e.label?.trim();return t&&!/^(device|(ios|mac|lobu)?\s*bridge)$/i.test(t)?t:o4e(Ik(e))}function s4e(e){const t=e?.trim();return t?/^\d/.test(t)?`v${t}`:t:null}function l4e(e,t){const n=/^(ios|mac)-bridge-/i.test(e.worker_id)?null:e.worker_id;return[t,n].filter(Boolean).join(" · ")}function IAe(e,t){return e.find(n=>n.id===t||n.worker_id===t)}function p_({platform:e,className:t}){return e==="ios"?h.jsx(l7,{className:ye("h-4 w-4 text-muted-foreground",t)}):e==="headless"?h.jsx($g,{className:ye("h-4 w-4 text-muted-foreground",t)}):e==="chrome-extension"?h.jsx(zg,{className:ye("h-4 w-4 text-muted-foreground",t)}):h.jsx(Hg,{className:ye("h-4 w-4 text-muted-foreground",t)})}function c4e({online:e,className:t}){return h.jsx("span",{"aria-hidden":!0,className:ye("inline-block h-2 w-2 shrink-0 rounded-full",e?"bg-green-500":"bg-muted-foreground/40",t)})}function u4e({owner:e,source:t}){const n=t.agent_name||t.agent_id||null,a=t.client_name||t.client_id||null,o=t.device_label||t.device_worker_id||null,s=n?{kind:"agent",label:n}:a?{kind:"client",label:a}:o?{kind:"device",label:o}:null;if(!s)return null;const c=[s.kind==="agent"&&a?`${s.label} via ${a}`:s.label,s.kind!=="device"&&o?`executed on ${o}`:null].filter(Boolean).join(" · "),d=h.jsxs(h.Fragment,{children:[s.kind==="agent"?h.jsx(Xh,{className:"h-3.5 w-3.5 shrink-0"}):s.kind==="client"?h.jsx(l_,{name:s.label}):h.jsx(p_,{platform:t.device_platform??null,className:"h-3.5 w-3.5"}),h.jsx("span",{className:"truncate",children:s.label})]}),f="inline-flex min-w-0 items-center gap-1";return e&&s.kind==="agent"&&t.agent_id?h.jsx(Ct,{to:"/$owner/agents/$agentId",params:{owner:e,agentId:t.agent_id},className:`${f} hover:underline`,title:c,children:d}):e&&s.kind==="client"&&t.client_id?h.jsx(Ct,{to:"/$owner/agents/connected/$clientId",params:{owner:e,clientId:t.client_id},className:`${f} hover:underline`,title:c,children:d}):e&&s.kind==="device"&&t.device_worker_id?h.jsx(Ct,{to:"/$owner/connectors/device/$deviceId",params:{owner:e,deviceId:t.device_worker_id},className:`${f} hover:underline`,title:c,children:d}):h.jsx("span",{className:f,title:c,children:d})}function d4e({owner:e,source:t,connectorDefinitions:n=[],className:a}){const o=e==="me"?void 0:e,s=t.platform?.trim()||null,l=s?a4e(s,n??[]):null,c=t.connection_name||l?.name||s,d=t.feed_name||t.feed_key||null,f=[];if(s&&c){const y=h.jsxs(h.Fragment,{children:[h.jsx(h_,{plain:!0,name:l?.name??s,icon:l?.icon,faviconDomain:l?.faviconDomain,className:"h-3.5 w-3.5 rounded-sm text-[9px]"}),h.jsx("span",{className:"truncate",children:c})]});f.push({key:"connection",node:o&&t.connection_id!=null?h.jsx(Ct,{to:"/$owner/connectors/$connectorKey/$connectionId",params:{owner:o,connectorKey:s,connectionId:String(t.connection_id)},search:{feedId:void 0},className:"inline-flex min-w-0 items-center gap-1 hover:underline",children:y}):h.jsx("span",{className:"inline-flex min-w-0 items-center gap-1",children:y})})}return d&&f.push({key:"feed",node:o&&s&&t.connection_id!=null&&t.feed_id!=null?h.jsx(Ct,{to:"/$owner/connectors/$connectorKey/$connectionId",params:{owner:o,connectorKey:s,connectionId:String(t.connection_id)},search:{feedId:t.feed_id},className:"truncate hover:underline",children:d}):h.jsx("span",{className:"truncate",children:d})}),t.automation_name&&f.push({key:"automation",node:o&&t.automation_id!=null?h.jsx(Ct,{to:"/$owner/automations/$automationId",params:{owner:o,automationId:String(t.automation_id)},search:{view:"activity",run_id:void 0},className:"truncate hover:underline",children:t.automation_name}):h.jsx("span",{className:"truncate",children:t.automation_name})}),!!(t.agent_name||t.agent_id||t.client_name||t.client_id||t.device_label||t.device_worker_id)&&f.push({key:"originator",node:h.jsx(u4e,{owner:o,source:t})}),f.length===0?null:h.jsx("div",{className:ye("flex min-w-0 flex-wrap items-center gap-1 text-muted-foreground",a),children:f.map(({key:y,node:k},v)=>h.jsxs(b.Fragment,{children:[v>0?h.jsx("span",{className:"shrink-0 text-muted-foreground/50",children:"·"}):null,k]},y))})}const h4e={xs:"h-2.5 w-2.5",sm:"h-3 w-3",md:"h-3.5 w-3.5",lg:"h-4 w-4",xl:"h-5 w-5"};function dt({size:e="md",className:t,...n}){return h.jsx(ZM,{"aria-hidden":"true",className:ye(h4e[e],"animate-spin",t),...n})}function f4e(e,t){const n=t?.limit,a=t?.aggregate!==!1,o=t?.includeNotifications!==!1,s=t?.includeRuns!==!1,l=t?.kinds,c=t?.agentId;return st({queryKey:["activity-feed",e??null,n,a,o,s,l?.join(",")??null,c??null],queryFn:async()=>(await Kn("manage_operations",{action:"list_activity",limit:n,aggregate:a,include_notifications:o,include_runs:s,...l?.length?{kinds:l}:{},...c?{agent_id:c}:{}},e?{slug:e}:void 0)).items??[],enabled:!!e,staleTime:15e3,refetchInterval:3e4})}const o8="owletto:lobu-lens-context",p4e="owletto:lobu-lens-context-request",y4e="owletto:lobu-lens-open-target",Hy="owletto:lobu-lens-open-target-response";function Jh(e){if(!e?.trim())return null;try{const t=new URL(e);if(t.protocol!=="http:"&&t.protocol!=="https:")return null;const n=t.pathname.replace(/\/+$/,"")||"/";return`${t.origin}${n}${t.search}`}catch{return null}}function m4e(e,t){if(t?.kind!=="browser")return!1;const n=Jh(e.browserUrl),a=Jh(t.url);return n==null||a==null?!1:t.urlScope==="origin"?new URL(n).origin===new URL(a).origin:n===a}function g4e(e){return e?e.kind==="browser"?`browser:${e.urlScope??"page"}:${Jh(e.url)??""}`:`application:${e.applicationId??e.applicationName}`:""}function y_(e){if(!(e instanceof CustomEvent)||typeof e.detail!="string")return null;try{return JSON.parse(e.detail)}catch{return null}}function k4e(e,t){document.dispatchEvent(new CustomEvent(e,{detail:JSON.stringify(t)}))}function v4e(e,t,n){if(t===n||e.source!==t||!/^chrome-extension:\/\/[a-p]{32}$/.test(e.origin)||e.data?.owletto!=="ambient-context")return;const a=e.data.context;if(!(a?.kind!=="browser"||a.url!==null&&typeof a.url!="string"))return{kind:"browser",url:Jh(a.url),title:null,applicationName:"Chrome"}}function m_(e){const t=`open-browser-target:${crypto.randomUUID()}`;return new Promise(n=>{const a=window.setTimeout(()=>{document.removeEventListener(Hy,o),n(!1)},1500),o=s=>{const l=y_(s);l?.id===t&&(window.clearTimeout(a),document.removeEventListener(Hy,o),n(l.ok===!0))};document.addEventListener(Hy,o),k4e(y4e,{id:t,...e})})}async function i8(e,t){let n;try{n=new URL(e)}catch{return!1}if(n.protocol!=="http:"&&n.protocol!=="https:")return!1;if(document.documentElement.hasAttribute("data-owletto-lens-bridge"))return t&&await t(),m_({url:n.toString()});if(window.parent===window){const o=window.open("","_blank");if(!o)return!1;o.opener=null;try{t&&await t(),o.location.replace(n.toString())}catch(s){throw o.close(),s}return!0}t&&await t();const a=`open-tab:${crypto.randomUUID()}`;return new Promise(o=>{const s=window.setTimeout(()=>{window.removeEventListener("message",l),o(!1)},1500),l=c=>{c.data?.id===a&&(window.clearTimeout(s),window.removeEventListener("message",l),o(c.data?.ok===!0))};window.addEventListener("message",l),window.parent.postMessage({id:a,op:"openTab",params:{url:n.toString()}},"*")})}async function x4e(){return document.documentElement.hasAttribute("data-owletto-lens-bridge")?m_({focusHost:!0}):(window.focus(),!0)}const g_=6048e5,b4e=864e5,hh=43200,s8=1440,l8=Symbol.for("constructDateFrom");function po(e,t){return typeof e=="function"?e(t):e&&typeof e=="object"&&l8 in e?e[l8](t):e instanceof Date?new e.constructor(t):new Date(t)}function Sn(e,t){return po(t||e,e)}let w4e={};function g1(){return w4e}function $u(e,t){const n=g1(),a=t?.weekStartsOn??t?.locale?.options?.weekStartsOn??n.weekStartsOn??n.locale?.options?.weekStartsOn??0,o=Sn(e,t?.in),s=o.getDay(),l=(s<a?7:0)+s-a;return o.setDate(o.getDate()-l),o.setHours(0,0,0,0),o}function e2(e,t){return $u(e,{...t,weekStartsOn:1})}function k_(e,t){const n=Sn(e,t?.in),a=n.getFullYear(),o=po(n,0);o.setFullYear(a+1,0,4),o.setHours(0,0,0,0);const s=e2(o),l=po(n,0);l.setFullYear(a,0,4),l.setHours(0,0,0,0);const c=e2(l);return n.getTime()>=s.getTime()?a+1:n.getTime()>=c.getTime()?a:a-1}function t2(e){const t=Sn(e),n=new Date(Date.UTC(t.getFullYear(),t.getMonth(),t.getDate(),t.getHours(),t.getMinutes(),t.getSeconds(),t.getMilliseconds()));return n.setUTCFullYear(t.getFullYear()),+e-+n}function Q2(e,...t){const n=po.bind(null,e||t.find(a=>typeof a=="object"));return t.map(n)}function c8(e,t){const n=Sn(e,t?.in);return n.setHours(0,0,0,0),n}function M4e(e,t,n){const[a,o]=Q2(n?.in,e,t),s=c8(a),l=c8(o),c=+s-t2(s),d=+l-t2(l);return Math.round((c-d)/b4e)}function S4e(e,t){const n=k_(e,t),a=po(e,0);return a.setFullYear(n,0,4),a.setHours(0,0,0,0),e2(a)}function Eh(e,t){const n=+Sn(e)-+Sn(t);return n<0?-1:n>0?1:n}function _4e(e){return po(e,Date.now())}function C4e(e){return e instanceof Date||typeof e=="object"&&Object.prototype.toString.call(e)==="[object Date]"}function A4e(e){return!(!C4e(e)&&typeof e!="number"||isNaN(+Sn(e)))}function E4e(e,t,n){const[a,o]=Q2(n?.in,e,t),s=a.getFullYear()-o.getFullYear(),l=a.getMonth()-o.getMonth();return s*12+l}function R4e(e){return t=>{const a=(e?Math[e]:Math.trunc)(t);return a===0?0:a}}function j4e(e,t){return+Sn(e)-+Sn(t)}function O4e(e,t){const n=Sn(e,t?.in);return n.setHours(23,59,59,999),n}function N4e(e,t){const n=Sn(e,t?.in),a=n.getMonth();return n.setFullYear(n.getFullYear(),a+1,0),n.setHours(23,59,59,999),n}function T4e(e,t){const n=Sn(e,t?.in);return+O4e(n,t)==+N4e(n,t)}function P4e(e,t,n){const[a,o,s]=Q2(n?.in,e,e,t),l=Eh(o,s),c=Math.abs(E4e(o,s));if(c<1)return 0;o.getMonth()===1&&o.getDate()>27&&o.setDate(30),o.setMonth(o.getMonth()-l*c);let d=Eh(o,s)===-l;T4e(a)&&c===1&&Eh(a,s)===1&&(d=!1);const f=l*(c-+d);return f===0?0:f}function L4e(e,t,n){const a=j4e(e,t)/1e3;return R4e(n?.roundingMethod)(a)}function z4e(e,t){const n=Sn(e,t?.in);return n.setFullYear(n.getFullYear(),0,1),n.setHours(0,0,0,0),n}const D4e={lessThanXSeconds:{one:"less than a second",other:"less than {{count}} seconds"},xSeconds:{one:"1 second",other:"{{count}} seconds"},halfAMinute:"half a minute",lessThanXMinutes:{one:"less than a minute",other:"less than {{count}} minutes"},xMinutes:{one:"1 minute",other:"{{count}} minutes"},aboutXHours:{one:"about 1 hour",other:"about {{count}} hours"},xHours:{one:"1 hour",other:"{{count}} hours"},xDays:{one:"1 day",other:"{{count}} days"},aboutXWeeks:{one:"about 1 week",other:"about {{count}} weeks"},xWeeks:{one:"1 week",other:"{{count}} weeks"},aboutXMonths:{one:"about 1 month",other:"about {{count}} months"},xMonths:{one:"1 month",other:"{{count}} months"},aboutXYears:{one:"about 1 year",other:"about {{count}} years"},xYears:{one:"1 year",other:"{{count}} years"},overXYears:{one:"over 1 year",other:"over {{count}} years"},almostXYears:{one:"almost 1 year",other:"almost {{count}} years"}},I4e=(e,t,n)=>{let a;const o=D4e[e];return typeof o=="string"?a=o:t===1?a=o.one:a=o.other.replace("{{count}}",t.toString()),n?.addSuffix?n.comparison&&n.comparison>0?"in "+a:a+" ago":a};function Vy(e){return(t={})=>{const n=t.width?String(t.width):e.defaultWidth;return e.formats[n]||e.formats[e.defaultWidth]}}const q4e={full:"EEEE, MMMM do, y",long:"MMMM do, y",medium:"MMM d, y",short:"MM/dd/yyyy"},H4e={full:"h:mm:ss a zzzz",long:"h:mm:ss a z",medium:"h:mm:ss a",short:"h:mm a"},V4e={full:"{{date}} 'at' {{time}}",long:"{{date}} 'at' {{time}}",medium:"{{date}}, {{time}}",short:"{{date}}, {{time}}"},F4e={date:Vy({formats:q4e,defaultWidth:"full"}),time:Vy({formats:H4e,defaultWidth:"full"}),dateTime:Vy({formats:V4e,defaultWidth:"full"})},B4e={lastWeek:"'last' eeee 'at' p",yesterday:"'yesterday at' p",today:"'today at' p",tomorrow:"'tomorrow at' p",nextWeek:"eeee 'at' p",other:"P"},$4e=(e,t,n,a)=>B4e[e];function ku(e){return(t,n)=>{const a=n?.context?String(n.context):"standalone";let o;if(a==="formatting"&&e.formattingValues){const l=e.defaultFormattingWidth||e.defaultWidth,c=n?.width?String(n.width):l;o=e.formattingValues[c]||e.formattingValues[l]}else{const l=e.defaultWidth,c=n?.width?String(n.width):e.defaultWidth;o=e.values[c]||e.values[l]}const s=e.argumentCallback?e.argumentCallback(t):t;return o[s]}}const U4e={narrow:["B","A"],abbreviated:["BC","AD"],wide:["Before Christ","Anno Domini"]},K4e={narrow:["1","2","3","4"],abbreviated:["Q1","Q2","Q3","Q4"],wide:["1st quarter","2nd quarter","3rd quarter","4th quarter"]},G4e={narrow:["J","F","M","A","M","J","J","A","S","O","N","D"],abbreviated:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],wide:["January","February","March","April","May","June","July","August","September","October","November","December"]},Y4e={narrow:["S","M","T","W","T","F","S"],short:["Su","Mo","Tu","We","Th","Fr","Sa"],abbreviated:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],wide:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"]},W4e={narrow:{am:"a",pm:"p",midnight:"mi",noon:"n",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},abbreviated:{am:"AM",pm:"PM",midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},wide:{am:"a.m.",pm:"p.m.",midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"}},Z4e={narrow:{am:"a",pm:"p",midnight:"mi",noon:"n",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"},abbreviated:{am:"AM",pm:"PM",midnight:"midnight",noon:"noon",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"},wide:{am:"a.m.",pm:"p.m.",midnight:"midnight",noon:"noon",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"}},Q4e=(e,t)=>{const n=Number(e),a=n%100;if(a>20||a<10)switch(a%10){case 1:return n+"st";case 2:return n+"nd";case 3:return n+"rd"}return n+"th"},X4e={ordinalNumber:Q4e,era:ku({values:U4e,defaultWidth:"wide"}),quarter:ku({values:K4e,defaultWidth:"wide",argumentCallback:e=>e-1}),month:ku({values:G4e,defaultWidth:"wide"}),day:ku({values:Y4e,defaultWidth:"wide"}),dayPeriod:ku({values:W4e,defaultWidth:"wide",formattingValues:Z4e,defaultFormattingWidth:"wide"})};function vu(e){return(t,n={})=>{const a=n.width,o=a&&e.matchPatterns[a]||e.matchPatterns[e.defaultMatchWidth],s=t.match(o);if(!s)return null;const l=s[0],c=a&&e.parsePatterns[a]||e.parsePatterns[e.defaultParseWidth],d=Array.isArray(c)?e5e(c,y=>y.test(l)):J4e(c,y=>y.test(l));let f;f=e.valueCallback?e.valueCallback(d):d,f=n.valueCallback?n.valueCallback(f):f;const p=t.slice(l.length);return{value:f,rest:p}}}function J4e(e,t){for(const n in e)if(Object.prototype.hasOwnProperty.call(e,n)&&t(e[n]))return n}function e5e(e,t){for(let n=0;n<e.length;n++)if(t(e[n]))return n}function t5e(e){return(t,n={})=>{const a=t.match(e.matchPattern);if(!a)return null;const o=a[0],s=t.match(e.parsePattern);if(!s)return null;let l=e.valueCallback?e.valueCallback(s[0]):s[0];l=n.valueCallback?n.valueCallback(l):l;const c=t.slice(o.length);return{value:l,rest:c}}}const n5e=/^(\d+)(th|st|nd|rd)?/i,a5e=/\d+/i,r5e={narrow:/^(b|a)/i,abbreviated:/^(b\.?\s?c\.?|b\.?\s?c\.?\s?e\.?|a\.?\s?d\.?|c\.?\s?e\.?)/i,wide:/^(before christ|before common era|anno domini|common era)/i},o5e={any:[/^b/i,/^(a|c)/i]},i5e={narrow:/^[1234]/i,abbreviated:/^q[1234]/i,wide:/^[1234](th|st|nd|rd)? quarter/i},s5e={any:[/1/i,/2/i,/3/i,/4/i]},l5e={narrow:/^[jfmasond]/i,abbreviated:/^(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)/i,wide:/^(january|february|march|april|may|june|july|august|september|october|november|december)/i},c5e={narrow:[/^j/i,/^f/i,/^m/i,/^a/i,/^m/i,/^j/i,/^j/i,/^a/i,/^s/i,/^o/i,/^n/i,/^d/i],any:[/^ja/i,/^f/i,/^mar/i,/^ap/i,/^may/i,/^jun/i,/^jul/i,/^au/i,/^s/i,/^o/i,/^n/i,/^d/i]},u5e={narrow:/^[smtwf]/i,short:/^(su|mo|tu|we|th|fr|sa)/i,abbreviated:/^(sun|mon|tue|wed|thu|fri|sat)/i,wide:/^(sunday|monday|tuesday|wednesday|thursday|friday|saturday)/i},d5e={narrow:[/^s/i,/^m/i,/^t/i,/^w/i,/^t/i,/^f/i,/^s/i],any:[/^su/i,/^m/i,/^tu/i,/^w/i,/^th/i,/^f/i,/^sa/i]},h5e={narrow:/^(a|p|mi|n|(in the|at) (morning|afternoon|evening|night))/i,any:/^([ap]\.?\s?m\.?|midnight|noon|(in the|at) (morning|afternoon|evening|night))/i},f5e={any:{am:/^a/i,pm:/^p/i,midnight:/^mi/i,noon:/^no/i,morning:/morning/i,afternoon:/afternoon/i,evening:/evening/i,night:/night/i}},p5e={ordinalNumber:t5e({matchPattern:n5e,parsePattern:a5e,valueCallback:e=>parseInt(e,10)}),era:vu({matchPatterns:r5e,defaultMatchWidth:"wide",parsePatterns:o5e,defaultParseWidth:"any"}),quarter:vu({matchPatterns:i5e,defaultMatchWidth:"wide",parsePatterns:s5e,defaultParseWidth:"any",valueCallback:e=>e+1}),month:vu({matchPatterns:l5e,defaultMatchWidth:"wide",parsePatterns:c5e,defaultParseWidth:"any"}),day:vu({matchPatterns:u5e,defaultMatchWidth:"wide",parsePatterns:d5e,defaultParseWidth:"any"}),dayPeriod:vu({matchPatterns:h5e,defaultMatchWidth:"any",parsePatterns:f5e,defaultParseWidth:"any"})},v_={code:"en-US",formatDistance:I4e,formatLong:F4e,formatRelative:$4e,localize:X4e,match:p5e,options:{weekStartsOn:0,firstWeekContainsDate:1}};function y5e(e,t){const n=Sn(e,t?.in);return M4e(n,z4e(n))+1}function m5e(e,t){const n=Sn(e,t?.in),a=+e2(n)-+S4e(n);return Math.round(a/g_)+1}function x_(e,t){const n=Sn(e,t?.in),a=n.getFullYear(),o=g1(),s=t?.firstWeekContainsDate??t?.locale?.options?.firstWeekContainsDate??o.firstWeekContainsDate??o.locale?.options?.firstWeekContainsDate??1,l=po(t?.in||e,0);l.setFullYear(a+1,0,s),l.setHours(0,0,0,0);const c=$u(l,t),d=po(t?.in||e,0);d.setFullYear(a,0,s),d.setHours(0,0,0,0);const f=$u(d,t);return+n>=+c?a+1:+n>=+f?a:a-1}function g5e(e,t){const n=g1(),a=t?.firstWeekContainsDate??t?.locale?.options?.firstWeekContainsDate??n.firstWeekContainsDate??n.locale?.options?.firstWeekContainsDate??1,o=x_(e,t),s=po(t?.in||e,0);return s.setFullYear(o,0,a),s.setHours(0,0,0,0),$u(s,t)}function k5e(e,t){const n=Sn(e,t?.in),a=+$u(n,t)-+g5e(n,t);return Math.round(a/g_)+1}function gt(e,t){const n=e<0?"-":"",a=Math.abs(e).toString().padStart(t,"0");return n+a}const ni={y(e,t){const n=e.getFullYear(),a=n>0?n:1-n;return gt(t==="yy"?a%100:a,t.length)},M(e,t){const n=e.getMonth();return t==="M"?String(n+1):gt(n+1,2)},d(e,t){return gt(e.getDate(),t.length)},a(e,t){const n=e.getHours()/12>=1?"pm":"am";switch(t){case"a":case"aa":return n.toUpperCase();case"aaa":return n;case"aaaaa":return n[0];case"aaaa":default:return n==="am"?"a.m.":"p.m."}},h(e,t){return gt(e.getHours()%12||12,t.length)},H(e,t){return gt(e.getHours(),t.length)},m(e,t){return gt(e.getMinutes(),t.length)},s(e,t){return gt(e.getSeconds(),t.length)},S(e,t){const n=t.length,a=e.getMilliseconds(),o=Math.trunc(a*Math.pow(10,n-3));return gt(o,t.length)}},El={midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},u8={G:function(e,t,n){const a=e.getFullYear()>0?1:0;switch(t){case"G":case"GG":case"GGG":return n.era(a,{width:"abbreviated"});case"GGGGG":return n.era(a,{width:"narrow"});case"GGGG":default:return n.era(a,{width:"wide"})}},y:function(e,t,n){if(t==="yo"){const a=e.getFullYear(),o=a>0?a:1-a;return n.ordinalNumber(o,{unit:"year"})}return ni.y(e,t)},Y:function(e,t,n,a){const o=x_(e,a),s=o>0?o:1-o;if(t==="YY"){const l=s%100;return gt(l,2)}return t==="Yo"?n.ordinalNumber(s,{unit:"year"}):gt(s,t.length)},R:function(e,t){const n=k_(e);return gt(n,t.length)},u:function(e,t){const n=e.getFullYear();return gt(n,t.length)},Q:function(e,t,n){const a=Math.ceil((e.getMonth()+1)/3);switch(t){case"Q":return String(a);case"QQ":return gt(a,2);case"Qo":return n.ordinalNumber(a,{unit:"quarter"});case"QQQ":return n.quarter(a,{width:"abbreviated",context:"formatting"});case"QQQQQ":return n.quarter(a,{width:"narrow",context:"formatting"});case"QQQQ":default:return n.quarter(a,{width:"wide",context:"formatting"})}},q:function(e,t,n){const a=Math.ceil((e.getMonth()+1)/3);switch(t){case"q":return String(a);case"qq":return gt(a,2);case"qo":return n.ordinalNumber(a,{unit:"quarter"});case"qqq":return n.quarter(a,{width:"abbreviated",context:"standalone"});case"qqqqq":return n.quarter(a,{width:"narrow",context:"standalone"});case"qqqq":default:return n.quarter(a,{width:"wide",context:"standalone"})}},M:function(e,t,n){const a=e.getMonth();switch(t){case"M":case"MM":return ni.M(e,t);case"Mo":return n.ordinalNumber(a+1,{unit:"month"});case"MMM":return n.month(a,{width:"abbreviated",context:"formatting"});case"MMMMM":return n.month(a,{width:"narrow",context:"formatting"});case"MMMM":default:return n.month(a,{width:"wide",context:"formatting"})}},L:function(e,t,n){const a=e.getMonth();switch(t){case"L":return String(a+1);case"LL":return gt(a+1,2);case"Lo":return n.ordinalNumber(a+1,{unit:"month"});case"LLL":return n.month(a,{width:"abbreviated",context:"standalone"});case"LLLLL":return n.month(a,{width:"narrow",context:"standalone"});case"LLLL":default:return n.month(a,{width:"wide",context:"standalone"})}},w:function(e,t,n,a){const o=k5e(e,a);return t==="wo"?n.ordinalNumber(o,{unit:"week"}):gt(o,t.length)},I:function(e,t,n){const a=m5e(e);return t==="Io"?n.ordinalNumber(a,{unit:"week"}):gt(a,t.length)},d:function(e,t,n){return t==="do"?n.ordinalNumber(e.getDate(),{unit:"date"}):ni.d(e,t)},D:function(e,t,n){const a=y5e(e);return t==="Do"?n.ordinalNumber(a,{unit:"dayOfYear"}):gt(a,t.length)},E:function(e,t,n){const a=e.getDay();switch(t){case"E":case"EE":case"EEE":return n.day(a,{width:"abbreviated",context:"formatting"});case"EEEEE":return n.day(a,{width:"narrow",context:"formatting"});case"EEEEEE":return n.day(a,{width:"short",context:"formatting"});case"EEEE":default:return n.day(a,{width:"wide",context:"formatting"})}},e:function(e,t,n,a){const o=e.getDay(),s=(o-a.weekStartsOn+8)%7||7;switch(t){case"e":return String(s);case"ee":return gt(s,2);case"eo":return n.ordinalNumber(s,{unit:"day"});case"eee":return n.day(o,{width:"abbreviated",context:"formatting"});case"eeeee":return n.day(o,{width:"narrow",context:"formatting"});case"eeeeee":return n.day(o,{width:"short",context:"formatting"});case"eeee":default:return n.day(o,{width:"wide",context:"formatting"})}},c:function(e,t,n,a){const o=e.getDay(),s=(o-a.weekStartsOn+8)%7||7;switch(t){case"c":return String(s);case"cc":return gt(s,t.length);case"co":return n.ordinalNumber(s,{unit:"day"});case"ccc":return n.day(o,{width:"abbreviated",context:"standalone"});case"ccccc":return n.day(o,{width:"narrow",context:"standalone"});case"cccccc":return n.day(o,{width:"short",context:"standalone"});case"cccc":default:return n.day(o,{width:"wide",context:"standalone"})}},i:function(e,t,n){const a=e.getDay(),o=a===0?7:a;switch(t){case"i":return String(o);case"ii":return gt(o,t.length);case"io":return n.ordinalNumber(o,{unit:"day"});case"iii":return n.day(a,{width:"abbreviated",context:"formatting"});case"iiiii":return n.day(a,{width:"narrow",context:"formatting"});case"iiiiii":return n.day(a,{width:"short",context:"formatting"});case"iiii":default:return n.day(a,{width:"wide",context:"formatting"})}},a:function(e,t,n){const o=e.getHours()/12>=1?"pm":"am";switch(t){case"a":case"aa":return n.dayPeriod(o,{width:"abbreviated",context:"formatting"});case"aaa":return n.dayPeriod(o,{width:"abbreviated",context:"formatting"}).toLowerCase();case"aaaaa":return n.dayPeriod(o,{width:"narrow",context:"formatting"});case"aaaa":default:return n.dayPeriod(o,{width:"wide",context:"formatting"})}},b:function(e,t,n){const a=e.getHours();let o;switch(a===12?o=El.noon:a===0?o=El.midnight:o=a/12>=1?"pm":"am",t){case"b":case"bb":return n.dayPeriod(o,{width:"abbreviated",context:"formatting"});case"bbb":return n.dayPeriod(o,{width:"abbreviated",context:"formatting"}).toLowerCase();case"bbbbb":return n.dayPeriod(o,{width:"narrow",context:"formatting"});case"bbbb":default:return n.dayPeriod(o,{width:"wide",context:"formatting"})}},B:function(e,t,n){const a=e.getHours();let o;switch(a>=17?o=El.evening:a>=12?o=El.afternoon:a>=4?o=El.morning:o=El.night,t){case"B":case"BB":case"BBB":return n.dayPeriod(o,{width:"abbreviated",context:"formatting"});case"BBBBB":return n.dayPeriod(o,{width:"narrow",context:"formatting"});case"BBBB":default:return n.dayPeriod(o,{width:"wide",context:"formatting"})}},h:function(e,t,n){if(t==="ho"){let a=e.getHours()%12;return a===0&&(a=12),n.ordinalNumber(a,{unit:"hour"})}return ni.h(e,t)},H:function(e,t,n){return t==="Ho"?n.ordinalNumber(e.getHours(),{unit:"hour"}):ni.H(e,t)},K:function(e,t,n){const a=e.getHours()%12;return t==="Ko"?n.ordinalNumber(a,{unit:"hour"}):gt(a,t.length)},k:function(e,t,n){let a=e.getHours();return a===0&&(a=24),t==="ko"?n.ordinalNumber(a,{unit:"hour"}):gt(a,t.length)},m:function(e,t,n){return t==="mo"?n.ordinalNumber(e.getMinutes(),{unit:"minute"}):ni.m(e,t)},s:function(e,t,n){return t==="so"?n.ordinalNumber(e.getSeconds(),{unit:"second"}):ni.s(e,t)},S:function(e,t){return ni.S(e,t)},X:function(e,t,n){const a=e.getTimezoneOffset();if(a===0)return"Z";switch(t){case"X":return h8(a);case"XXXX":case"XX":return ds(a);case"XXXXX":case"XXX":default:return ds(a,":")}},x:function(e,t,n){const a=e.getTimezoneOffset();switch(t){case"x":return h8(a);case"xxxx":case"xx":return ds(a);case"xxxxx":case"xxx":default:return ds(a,":")}},O:function(e,t,n){const a=e.getTimezoneOffset();switch(t){case"O":case"OO":case"OOO":return"GMT"+d8(a,":");case"OOOO":default:return"GMT"+ds(a,":")}},z:function(e,t,n){const a=e.getTimezoneOffset();switch(t){case"z":case"zz":case"zzz":return"GMT"+d8(a,":");case"zzzz":default:return"GMT"+ds(a,":")}},t:function(e,t,n){const a=Math.trunc(+e/1e3);return gt(a,t.length)},T:function(e,t,n){return gt(+e,t.length)}};function d8(e,t=""){const n=e>0?"-":"+",a=Math.abs(e),o=Math.trunc(a/60),s=a%60;return s===0?n+String(o):n+String(o)+t+gt(s,2)}function h8(e,t){return e%60===0?(e>0?"-":"+")+gt(Math.abs(e)/60,2):ds(e,t)}function ds(e,t=""){const n=e>0?"-":"+",a=Math.abs(e),o=gt(Math.trunc(a/60),2),s=gt(a%60,2);return n+o+t+s}const f8=(e,t)=>{switch(e){case"P":return t.date({width:"short"});case"PP":return t.date({width:"medium"});case"PPP":return t.date({width:"long"});case"PPPP":default:return t.date({width:"full"})}},b_=(e,t)=>{switch(e){case"p":return t.time({width:"short"});case"pp":return t.time({width:"medium"});case"ppp":return t.time({width:"long"});case"pppp":default:return t.time({width:"full"})}},v5e=(e,t)=>{const n=e.match(/(P+)(p+)?/)||[],a=n[1],o=n[2];if(!o)return f8(e,t);let s;switch(a){case"P":s=t.dateTime({width:"short"});break;case"PP":s=t.dateTime({width:"medium"});break;case"PPP":s=t.dateTime({width:"long"});break;case"PPPP":default:s=t.dateTime({width:"full"});break}return s.replace("{{date}}",f8(a,t)).replace("{{time}}",b_(o,t))},x5e={p:b_,P:v5e},b5e=/^D+$/,w5e=/^Y+$/,M5e=["D","DD","YY","YYYY"];function S5e(e){return b5e.test(e)}function _5e(e){return w5e.test(e)}function C5e(e,t,n){const a=A5e(e,t,n);if(console.warn(a),M5e.includes(e))throw new RangeError(a)}function A5e(e,t,n){const a=e[0]==="Y"?"years":"days of the month";return`Use \`${e.toLowerCase()}\` instead of \`${e}\` (in \`${t}\`) for formatting ${a} to the input \`${n}\`; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md`}const E5e=/[yYQqMLwIdDecihHKkms]o|(\w)\1*|''|'(''|[^'])+('|$)|./g,R5e=/P+p+|P+|p+|''|'(''|[^'])+('|$)|./g,j5e=/^'([^]*?)'?$/,O5e=/''/g,N5e=/[a-zA-Z]/;function T5e(e,t,n){const a=g1(),o=n?.locale??a.locale??v_,s=n?.firstWeekContainsDate??n?.locale?.options?.firstWeekContainsDate??a.firstWeekContainsDate??a.locale?.options?.firstWeekContainsDate??1,l=n?.weekStartsOn??n?.locale?.options?.weekStartsOn??a.weekStartsOn??a.locale?.options?.weekStartsOn??0,c=Sn(e,n?.in);if(!A4e(c))throw new RangeError("Invalid time value");let d=t.match(R5e).map(p=>{const y=p[0];if(y==="p"||y==="P"){const k=x5e[y];return k(p,o.formatLong)}return p}).join("").match(E5e).map(p=>{if(p==="''")return{isToken:!1,value:"'"};const y=p[0];if(y==="'")return{isToken:!1,value:P5e(p)};if(u8[y])return{isToken:!0,value:p};if(y.match(N5e))throw new RangeError("Format string contains an unescaped latin alphabet character `"+y+"`");return{isToken:!1,value:p}});o.localize.preprocessor&&(d=o.localize.preprocessor(c,d));const f={firstWeekContainsDate:s,weekStartsOn:l,locale:o};return d.map(p=>{if(!p.isToken)return p.value;const y=p.value;(!n?.useAdditionalWeekYearTokens&&_5e(y)||!n?.useAdditionalDayOfYearTokens&&S5e(y))&&C5e(y,t,String(e));const k=u8[y[0]];return k(c,y,o.localize,f)}).join("")}function P5e(e){const t=e.match(j5e);return t?t[1].replace(O5e,"'"):e}function L5e(e,t,n){const a=g1(),o=n?.locale??a.locale??v_,s=2520,l=Eh(e,t);if(isNaN(l))throw new RangeError("Invalid time value");const c=Object.assign({},n,{addSuffix:n?.addSuffix,comparison:l}),[d,f]=Q2(n?.in,...l>0?[t,e]:[e,t]),p=L4e(f,d),y=(t2(f)-t2(d))/1e3,k=Math.round((p-y)/60);let v;if(k<2)return n?.includeSeconds?p<5?o.formatDistance("lessThanXSeconds",5,c):p<10?o.formatDistance("lessThanXSeconds",10,c):p<20?o.formatDistance("lessThanXSeconds",20,c):p<40?o.formatDistance("halfAMinute",0,c):p<60?o.formatDistance("lessThanXMinutes",1,c):o.formatDistance("xMinutes",1,c):k===0?o.formatDistance("lessThanXMinutes",1,c):o.formatDistance("xMinutes",k,c);if(k<45)return o.formatDistance("xMinutes",k,c);if(k<90)return o.formatDistance("aboutXHours",1,c);if(k<s8){const w=Math.round(k/60);return o.formatDistance("aboutXHours",w,c)}else{if(k<s)return o.formatDistance("xDays",1,c);if(k<hh){const w=Math.round(k/s8);return o.formatDistance("xDays",w,c)}else if(k<hh*2)return v=Math.round(k/hh),o.formatDistance("aboutXMonths",v,c)}if(v=P4e(f,d),v<12){const w=Math.round(k/hh);return o.formatDistance("xMonths",w,c)}else{const w=v%12,S=Math.trunc(v/12);return w<3?o.formatDistance("aboutXYears",S,c):w<9?o.formatDistance("overXYears",S,c):o.formatDistance("almostXYears",S+1,c)}}function z5e(e,t){return L5e(e,_4e(e),t)}function k1(e){const t=e instanceof Date?e:new Date(e);return z5e(t,{addSuffix:!0})}function qAe(e){const t=e instanceof Date?e:new Date(e);return T5e(t,"MMM d, HH:mm")}function HAe(e){if(e<60)return`${e}s`;const t=Math.floor(e/60),n=e%60;if(t<60)return n>0?`${t}m ${n}s`:`${t}m`;const a=Math.floor(t/60),o=t%60;return o>0?`${a}h ${o}m`:`${a}h`}const p8=/^\[Review in Lobu\]\(.*\)$/,D5e=/^[-*]\s/;function I5e(e){if(!e)return null;const t=[];for(const o of e.split(`
|
|
7885
7885
|
`)){const s=o.trim();if(s===""){if(t.length>0)break;continue}if(D5e.test(s)||p8.test(s))break;t.push(s)}const n=t.join(" ").trim();if(n!=="")return n;const a=e.split(`
|
|
7886
|
-
`).map(o=>o.trim()).filter(o=>o!==""&&!p8.test(o)).join(" ").trim();return a===""?null:a}function q5e(e){switch(e){case"action_approval_needed":return"Needs approval";case"connection_permission_request":return"Authorization needed";case"browser_auth_expired":return"Sign-in required";case"invitation_received":return"Invitation";case"agent_message":return"Agent";default:return"Notification"}}function H5e(e,t){if(t==null||t==="")return null;switch(e){case"action_approval_needed":return"Review & approve";case"connection_permission_request":return"Authorize connection";case"browser_auth_expired":return"Open connection";case"invitation_received":return"Accept invitation";default:return null}}function V5e(){const e=qn();return t=>{const{pathname:n,search:a}=sc(t);e({to:n,search:a??{}})}}function w_({href:e,className:t,onClick:n,children:a}){const{pathname:o,search:s}=sc(e);return h.jsx(Ct,{to:o,search:s??{},className:t,onClick:n,children:a})}function y8(e,t,n){if(!t)return h.jsx("span",{className:ye("mt-1 h-2 w-2 shrink-0 rounded-full",n==="relevant"?"bg-primary":"bg-blue-500")});const a="mt-0.5 h-4 w-4 shrink-0 text-muted-foreground";switch(e){case"action_approval_needed":return h.jsx(KM,{className:a});case"connection_permission_request":case"browser_auth_expired":return h.jsx(WM,{className:a});case"invitation_received":return h.jsx(QM,{className:a});case"agent_message":return h.jsx(Lg,{className:a});default:return h.jsx(zM,{className:a})}}function F5e(e){return e?q5e(e):"Notification"}function B5e({runId:e,notificationId:t,reviewHref:n,reviewTitle:a,choiceField:o,choices:s}){const{orgContext:l}=er(),c=E0e(),d=R0e(),f=Y9(l),p=Dk(),[y,k]=b.useState(null),[v,w]=b.useState(!1),[S,_]=b.useState(""),C=c.isPending||d.isPending;return y==="approved"?h.jsx("p",{className:"mt-2 text-xs font-medium text-emerald-600 dark:text-emerald-400",children:"Approved — executing…"}):y==="rejected"?h.jsx("p",{className:"mt-2 text-xs font-medium text-muted-foreground",children:"Rejected"}):v?h.jsxs("div",{className:"mt-2 flex flex-wrap items-center gap-2",children:[h.jsx("input",{type:"text",placeholder:"Reason (optional)",value:S,onChange:A=>_(A.target.value),className:"h-7 min-w-[10rem] flex-1 rounded-md border bg-background px-2 text-xs",onClick:A=>A.stopPropagation()}),h.jsxs(ge,{size:"sm",variant:"outline",className:"h-7 text-xs",disabled:C,onClick:A=>{A.stopPropagation(),d.mutate({run_id:e,reason:S.trim()||void 0},{onSuccess:()=>{k("rejected"),f.mutate(t)}})},children:[d.isPending?h.jsx(dt,{size:"sm",className:"mr-1"}):h.jsx(vs,{className:"mr-1 h-3 w-3"}),"Reject"]}),h.jsx("button",{type:"button",className:"text-xs text-muted-foreground hover:text-foreground",onClick:A=>{A.stopPropagation(),w(!1)},children:"Cancel"})]}):o&&s&&s.length>0?h.jsxs("div",{className:"mt-2 flex flex-wrap items-center gap-2",children:[s.map(A=>h.jsxs(ge,{size:"sm",variant:"outline",className:"h-7 text-xs",disabled:C,onClick:j=>{j.stopPropagation(),c.mutate({run_id:e,input:{[o]:A.value}},{onSuccess:()=>{k("approved"),f.mutate(t)}})},children:[c.isPending?h.jsx(dt,{size:"sm",className:"mr-1"}):null,A.label]},A.value)),h.jsxs(ge,{size:"sm",variant:"ghost",className:"h-7 text-xs text-muted-foreground",disabled:C,onClick:A=>{A.stopPropagation(),w(!0)},children:[h.jsx(vs,{className:"mr-1 h-3 w-3"}),"Dismiss"]})]}):h.jsxs("div",{className:"mt-2 flex flex-wrap items-center gap-2",children:[n?p&&W2(n)?h.jsx(ge,{type:"button",size:"sm",variant:"outline",className:"h-7 text-xs",onClick:A=>{A.stopPropagation(),f.mutate(t),p.open({href:n,title:a??"Approval",runId:e})},children:"Review"}):h.jsx(w_,{href:n,className:ye("inline-flex h-7 items-center justify-center rounded-md border border-input bg-background px-3 text-xs font-medium transition-colors hover:bg-accent hover:text-accent-foreground"),onClick:A=>{A.stopPropagation(),f.mutate(t)},children:"Review"}):null,h.jsxs(ge,{size:"sm",className:"h-7 text-xs",disabled:C,onClick:A=>{A.stopPropagation(),c.mutate({run_id:e},{onSuccess:()=>{k("approved"),f.mutate(t)}})},children:[c.isPending?h.jsx(dt,{size:"sm",className:"mr-1"}):h.jsx(Za,{className:"mr-1 h-3 w-3"}),"Approve"]}),h.jsxs(ge,{size:"sm",variant:"outline",className:"h-7 text-xs",disabled:C,onClick:A=>{A.stopPropagation(),w(!0)},children:[h.jsx(vs,{className:"mr-1 h-3 w-3"}),"Reject"]})]})}function $5e(e){return e.interaction_type==="authorization"?e.interaction_status==="pending":!!e.unread||e.interaction_status==="pending"||e.browser_handoff?.state==="ready"}function v1(e){const{session:t}=Xa(),{orgContext:n}=er(),a=J0e(n),o=j0e(),{data:s=[],isLoading:l,isError:c}=f4e(t&&e?e:null,{limit:50,aggregate:!0,includeNotifications:!0,includeRuns:!1,kinds:["notification"]}),d=b.useMemo(()=>s.filter($5e),[s]),f=b.useMemo(()=>d.map(_=>{const C=_.status==="action_approval_needed";return{id:_.id,at:new Date(_.at).getTime(),title:_.title,body:_.body,unread:_.unread,href:_.href,runId:_.run_id??null,approvalRunId:C?_.run_id??null:null,interactionType:_.interaction_type??null,interactionStatus:_.interaction_status??null,interactionInline:C?_.interaction_inline??!1:!1,interactionChoiceField:C?_.interaction_choice_field??null:null,interactionChoices:C?_.interaction_choices??null:null,notificationId:_.notification_id??null,browserUrl:_.browser_url??null,browserHandoff:_.browser_handoff??null,notification:_.notification_id!=null?{id:_.notification_id,type:_.status??"generic",title:_.title,body:_.body,resource_url:_.href,browser_url:_.browser_url??null,browser_handoff:_.browser_handoff??null,resource_type:_.run_id!=null?"run":null,resource_id:_.run_id!=null?String(_.run_id):null,is_read:!_.unread,created_at:_.at,organization_id:"",user_id:"",platform:_.platform??null,connection_id:_.connection_id??null,connection_name:_.connection_name??null,feed_id:_.feed_id??null,feed_key:_.feed_key??null,feed_name:_.feed_name??null,automation_id:_.automation_id??null,automation_name:_.automation_name??null,agent_id:_.agent_id??null,agent_name:_.agent_name??null,client_id:_.client_id??null,client_name:_.client_name??null,device_worker_id:_.device_worker_id??null,device_label:_.device_label??null,device_platform:_.device_platform??null}:void 0}}).reverse(),[d]),p=[...new Set(f.flatMap(_=>_.unread&&_.notificationId!=null?[_.notificationId]:[]))],y=f.filter(_=>_.interactionType==="approval"&&_.interactionStatus==="pending"&&_.interactionInline===!0&&_.approvalRunId!=null),k=[...new Set(y.flatMap(_=>_.approvalRunId!=null?[_.approvalRunId]:[]))],v=async()=>{const _=await a.mutateAsync(p);_.failed>0?mn.error(`Marked ${_.succeeded} read; ${_.failed} could not be updated.`):mn.success(`Marked ${_.succeeded} notification${_.succeeded===1?"":"s"} as read.`)},w=async(_,C)=>{const A=await o.mutateAsync({decision:_,runIds:k,...C?{reason:C}:{}}),j=new Set(A.failedRunIds),N=y.flatMap(I=>I.approvalRunId!=null&&!j.has(I.approvalRunId)&&I.notificationId!=null?[I.notificationId]:[]);N.length>0&&await a.mutateAsync(N),A.failed>0?mn.error(`${A.succeeded} ${_==="approve"?"approved":"rejected"}; ${A.failed} failed.`):mn.success(`${A.succeeded} approval${A.succeeded===1?"":"s"} ${_==="approve"?"approved":"rejected"}.`)},S=o.isPending||a.isPending;return{session:t,isLoading:l,isError:c,attentionCards:d,attentionItems:f,visibleUnreadIds:p,visibleApprovalRunIds:k,markVisibleRead:v,decideVisibleApprovals:w,markManyRead:a,bulkPending:S}}function U5e({owner:e}){const{session:t,isLoading:n,attentionItems:a,visibleUnreadIds:o,visibleApprovalRunIds:s,markVisibleRead:l,decideVisibleApprovals:c,bulkPending:d}=v1(e),[f,p]=b.useState(!1),[y,k]=b.useState("");return!t||n||a.length===0||o.length===0&&s.length===0?null:h.jsxs("div",{className:"flex flex-wrap items-center justify-end gap-2",children:[o.length>0?h.jsxs(ge,{type:"button",variant:"outline",size:"sm",className:"h-7 rounded-md bg-muted text-xs",disabled:d,onClick:()=>void l(),children:[h.jsx(qM,{className:"h-3.5 w-3.5"}),"Mark ",o.length," as read"]}):null,s.length>0?h.jsxs(h.Fragment,{children:[h.jsxs(ge,{type:"button",size:"sm",className:"h-7 rounded-md text-xs",disabled:d,onClick:()=>void c("approve"),children:[h.jsx(Za,{className:"h-3.5 w-3.5"}),"Approve ",s.length]}),h.jsxs(ge,{type:"button",variant:"outline",size:"sm",className:"h-7 rounded-md bg-muted text-xs",disabled:d,onClick:()=>p(!0),children:[h.jsx(vs,{className:"h-3.5 w-3.5"}),"Reject ",s.length]})]}):null,f?h.jsxs("div",{className:"flex w-full flex-wrap items-center gap-2 rounded-md bg-muted/40 p-2",children:[h.jsx("input",{type:"text","aria-label":"Reject reason",placeholder:"Reason (optional)",value:y,onChange:v=>k(v.target.value),className:"h-7 min-w-48 flex-1 rounded-md border bg-background px-2 text-xs"}),h.jsxs(ge,{type:"button",variant:"destructive",size:"sm",className:"h-7 rounded-md text-xs",disabled:d,onClick:()=>{c("reject",y.trim()||void 0),p(!1),k("")},children:["Confirm reject ",s.length]}),h.jsx(ge,{type:"button",variant:"ghost",size:"sm",className:"h-7 text-xs",onClick:()=>p(!1),children:"Cancel"})]}):null]})}function K5e({owner:e,emptyState:t=null,itemFilter:n,onOpenItem:a,ariaLabel:o="Needs attention",tone:s="default",rowAction:l="open"}){const c=V5e(),d=Dk(),{orgContext:f}=er(),{data:p=[]}=O9(f.organizationId??null),y=Y9(f),k=Q0e(f),v=X0e(f),w=v.isPending&&typeof v.variables=="number"?v.variables:null,{session:S,isLoading:_,isError:C,attentionItems:A,markManyRead:j}=v1(e),N=b.useMemo(()=>n?A.filter(n):A,[A,n]),[I,T]=b.useState(0),q=b.useRef(null),R=l==="open",H=F=>{if(F.notificationId!=null&&F.unread&&y.mutate(F.notificationId),F.interactionType==="authorization"&&F.href){c(F.href);return}if(a){a(F);return}if(d){d.open({href:F.href??"",title:F.title,runId:F.runId??void 0,body:F.body,notificationType:F.notification?.type,createdAt:F.notification?.created_at,browserUrl:F.browserUrl??null,browserHandoff:F.browserHandoff??null,owner:e,sourceAttribution:F.notification??null});return}F.href&&c(F.href)},D=async F=>{if(!F.browserUrl)return;const W=F.browserHandoff?.state==="expired"&&F.browserHandoff.run_id!=null;if(F.notificationId!=null&&F.unread&&y.mutate(F.notificationId),F.browserHandoff?.state==="completed"){mn.info("This draft was already activated. Continue in the Chrome tab you opened, or mark it Done.");return}if(W&&F.notificationId==null){mn.error("This expired draft cannot be recreated from this card.");return}try{const P=F.notificationId,U=W&&P!=null?()=>v.mutateAsync(P):void 0;(U?await i8(F.browserUrl,U):await i8(F.browserUrl))||mn.error("Chrome blocked the handoff tab. Allow pop-ups for Lobu and try again.")}catch(P){mn.error(P instanceof Error?P.message:"Could not recreate this browser draft.")}},G=F=>{if(F.browserUrl){D(F);return}H(F)},$=F=>{const W=Math.min(Math.max(F,0),N.length-1);T(W),q.current?.querySelector(`[data-attention-index="${W}"]`)?.focus()};if(!S)return h.jsx("p",{className:"py-6 text-center text-sm text-muted-foreground",children:"Sign in to see workspace activity."});if(_&&N.length===0)return h.jsx("div",{className:"space-y-2",children:Array.from({length:4}).map((F,W)=>h.jsx("div",{className:ye(Yl,"h-14 animate-pulse")},W))});if(C)return h.jsx("p",{className:"py-6 text-center text-sm text-destructive",children:"Could not load recent activity."});if(N.length===0)return t;const X=h.jsx("ul",{className:"space-y-1",children:N.map((F,W)=>{const P=F.approvalRunId??null,U=F.interactionType==="approval",J=U?F.interactionStatus==="approved"?"Approved":F.interactionStatus==="rejected"?"Rejected":F.interactionStatus==="expired"?"Expired":F.interactionStatus&&F.interactionStatus!=="pending"?F.interactionStatus.charAt(0).toUpperCase()+F.interactionStatus.slice(1):null:null,se=U&&F.interactionStatus==="pending"&&F.interactionInline===!0&&P!=null,L=!se&&!J&&F.notification?H5e(F.notification.type,F.href):null,B=U&&J?"Approval":F5e(F.notification?.type),V=I5e(F.body),O=ye(Yl,"flex w-full items-start gap-3 p-3 text-left transition-colors",R&&"hover:bg-accent/50"),ee=F.notification?y8(F.notification.type,!F.unread,s):y8("generic",!F.unread,s),Q=h.jsxs(h.Fragment,{children:[ee,h.jsxs("div",{className:"min-w-0 flex-1",children:[h.jsxs("div",{className:"flex items-baseline gap-2",children:[h.jsx("p",{className:ye("min-w-0 flex-1 truncate text-sm",F.unread?"font-medium text-foreground":"text-foreground/90"),children:F.title}),h.jsx("span",{className:"shrink-0 text-[11px] text-muted-foreground",children:k1(F.at)})]}),V?h.jsx("div",{className:"mt-0.5 line-clamp-2 text-xs text-muted-foreground",onClick:ae=>{ae.target.closest("a")&&ae.stopPropagation()},children:h.jsx(Bve,{text:V,linkPolicy:F.notification?.type==="action_approval_needed"?"app-links":"strip"})}):F.body?h.jsx("p",{className:"mt-0.5 line-clamp-2 text-xs text-muted-foreground",children:F.body}):null,F.notification?h.jsx(d4e,{owner:e,source:F.notification,connectorDefinitions:p,className:"mt-1 text-[11px]"}):null,h.jsx("p",{className:"mt-1 text-[10px] font-medium uppercase tracking-wide text-muted-foreground/80",children:B}),se&&F.notification&&P!=null?h.jsx(B5e,{runId:P,notificationId:F.notification.id,reviewHref:F.href,reviewTitle:F.title,choiceField:F.interactionChoiceField,choices:F.interactionChoices}):J?h.jsx("p",{className:ye("mt-2 text-xs font-medium",F.interactionStatus==="approved"?"text-emerald-600 dark:text-emerald-400":"text-muted-foreground"),children:J}):null,L&&F.href?h.jsx("div",{className:"mt-2",children:h.jsx(w_,{href:F.href,className:"inline-flex h-7 items-center justify-center rounded-md border border-input bg-background px-3 text-xs font-medium transition-colors hover:bg-accent hover:text-accent-foreground",onClick:ae=>{ae.stopPropagation(),F.notification&&!F.notification.is_read&&y.mutate(F.notification.id),F.notification?.type==="action_approval_needed"&&d&&W2(F.href??"")&&(ae.preventDefault(),G(F))},children:L})}):null,F.browserUrl?h.jsxs("div",{className:"mt-2 space-y-1.5",children:[F.browserHandoff?.state==="expired"?h.jsxs("p",{className:"text-xs text-amber-700 dark:text-amber-300",children:["Draft expired",F.browserHandoff.error_message?` — ${F.browserHandoff.error_message}`:"."]}):null,h.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[F.browserHandoff?.state!=="completed"?h.jsxs(ge,{type:"button",size:"sm",variant:"outline",className:"h-7 text-xs",disabled:w!=null&&w===F.notificationId,onClick:ae=>{ae.stopPropagation(),D(F)},children:[w!=null&&w===F.notificationId?h.jsx(dt,{size:"sm",className:"mr-1"}):null,F.browserHandoff?.state==="expired"&&F.browserHandoff.run_id!=null?"Recreate draft":F.browserHandoff?.state==="expired"?"Open page without draft":"Open page"]}):h.jsx("span",{className:"self-center text-xs text-muted-foreground",children:"Opened"}),d?h.jsx(ge,{type:"button",size:"sm",variant:"ghost",className:"h-7 text-xs text-muted-foreground",onClick:ae=>{ae.stopPropagation(),H(F)},children:"Why/how"}):null,F.interactionStatus!=="pending"?h.jsxs(ge,{type:"button",size:"sm",variant:"ghost",className:"h-7 text-xs text-muted-foreground",disabled:k.isPending,onClick:ae=>{ae.stopPropagation(),F.notificationId!=null&&k.mutate(F.notificationId)},children:[h.jsx(vs,{className:"mr-1 h-3 w-3"}),"Done"]}):null]})]}):null]})]});return h.jsx("li",{children:h.jsx("div",{"data-attention-index":W,role:R?"link":void 0,tabIndex:R?0:void 0,onFocus:R?()=>T(W):void 0,onClick:R?()=>G(F):void 0,onKeyDown:R?ae=>{ae.target===ae.currentTarget&&(ae.key==="Enter"||ae.key===" ")&&(ae.preventDefault(),G(F))}:void 0,className:ye(O,R&&"cursor-pointer"),children:Q})},F.id)})});return h.jsxs("section",{ref:q,"data-attention-list":!0,"aria-label":o,"aria-keyshortcuts":R?"ArrowDown ArrowUp Enter R":void 0,className:"space-y-2.5",onKeyDown:R?F=>{const W=F.target;if(!(W.matches("input, textarea, select")||W.isContentEditable)){if(F.key==="ArrowDown"||F.key==="ArrowUp"){const P=W.closest("[data-attention-index]");if(!P)return;F.preventDefault();const U=Number(P?.dataset.attentionIndex),J=Number.isInteger(U)?U:F.key==="ArrowDown"?-1:0;$(J+(F.key==="ArrowDown"?1:-1))}if(F.key.toLowerCase()==="r"){const P=N[I];P?.unread&&P.notificationId!=null&&(F.preventDefault(),j.mutateAsync([P.notificationId]))}}}:void 0,children:[X,R?h.jsxs("div",{"data-testid":"attention-shortcut-hint",role:"note","aria-label":"Attention keyboard shortcuts",className:"attention-shortcut-hint pointer-events-none mx-auto mt-3 w-fit items-center gap-4 rounded-full border bg-background/95 px-5 py-2 text-xs text-muted-foreground backdrop-blur",children:[h.jsxs("span",{children:[h.jsx("kbd",{className:"rounded bg-muted px-1.5 py-0.5",children:"↑↓"})," Navigate"]}),h.jsxs("span",{children:[h.jsx("kbd",{className:"rounded bg-muted px-1.5 py-0.5",children:"Enter"})," Open"]}),h.jsxs("span",{children:[h.jsx("kbd",{className:"rounded bg-muted px-1.5 py-0.5",children:"R"})," Mark read"]}),h.jsxs("span",{children:[h.jsx("kbd",{className:"rounded bg-muted px-1.5 py-0.5",children:"Tab"})," Actions"]})]}):null]})}var X2="Collapsible",[G5e]=dr(X2),[Y5e,qk]=G5e(X2),M_=b.forwardRef((e,t)=>{const{__scopeCollapsible:n,open:a,defaultOpen:o,disabled:s,onOpenChange:l,...c}=e,[d,f]=fo({prop:a,defaultProp:o??!1,onChange:l,caller:X2});return h.jsx(Y5e,{scope:n,disabled:s,contentId:Ya(),open:d,onOpenToggle:b.useCallback(()=>f(p=>!p),[f]),children:h.jsx(He.div,{"data-state":Vk(d),"data-disabled":s?"":void 0,...c,ref:t})})});M_.displayName=X2;var S_="CollapsibleTrigger",__=b.forwardRef((e,t)=>{const{__scopeCollapsible:n,...a}=e,o=qk(S_,n);return h.jsx(He.button,{type:"button","aria-controls":o.open?o.contentId:void 0,"aria-expanded":o.open||!1,"data-state":Vk(o.open),"data-disabled":o.disabled?"":void 0,disabled:o.disabled,...a,ref:t,onClick:xe(e.onClick,o.onOpenToggle)})});__.displayName=S_;var Hk="CollapsibleContent",C_=b.forwardRef((e,t)=>{const{forceMount:n,...a}=e,o=qk(Hk,e.__scopeCollapsible);return h.jsx(Gn,{present:n||o.open,children:({present:s})=>h.jsx(W5e,{...a,ref:t,present:s})})});C_.displayName=Hk;var W5e=b.forwardRef((e,t)=>{const{__scopeCollapsible:n,present:a,children:o,...s}=e,l=qk(Hk,n),[c,d]=b.useState(a),f=b.useRef(null),p=it(t,f),y=b.useRef(0),k=y.current,v=b.useRef(0),w=v.current,S=l.open||c,_=b.useRef(S),C=b.useRef(void 0);return b.useEffect(()=>{const A=requestAnimationFrame(()=>_.current=!1);return()=>cancelAnimationFrame(A)},[]),Mn(()=>{const A=f.current;if(A){C.current=C.current||{transitionDuration:A.style.transitionDuration,animationName:A.style.animationName},A.style.transitionDuration="0s",A.style.animationName="none";const j=A.getBoundingClientRect();y.current=j.height,v.current=j.width,_.current||(A.style.transitionDuration=C.current.transitionDuration,A.style.animationName=C.current.animationName),d(a)}},[l.open,a]),h.jsx(He.div,{"data-state":Vk(l.open),"data-disabled":l.disabled?"":void 0,id:l.contentId,hidden:!S,...s,ref:p,style:{"--radix-collapsible-content-height":k?`${k}px`:void 0,"--radix-collapsible-content-width":w?`${w}px`:void 0,...e.style},children:S&&o})});function Vk(e){return e?"open":"closed"}var Z5e=M_;const J2=Z5e,e0=__,t0=C_;function Fk(e){const t=e+"CollectionProvider",[n,a]=dr(t),[o,s]=n(t,{collectionRef:{current:null},itemMap:new Map}),l=S=>{const{scope:_,children:C}=S,A=b.useRef(null),j=b.useRef(new Map).current;return h.jsx(o,{scope:_,itemMap:j,collectionRef:A,children:C})};l.displayName=t;const c=e+"CollectionSlot",d=Mi(c),f=b.forwardRef((S,_)=>{const{scope:C,children:A}=S,j=s(c,C),N=it(_,j.collectionRef);return h.jsx(d,{ref:N,children:A})});f.displayName=c;const p=e+"CollectionItemSlot",y="data-radix-collection-item",k=Mi(p),v=b.forwardRef((S,_)=>{const{scope:C,children:A,...j}=S,N=b.useRef(null),I=it(_,N),T=s(p,C);return b.useEffect(()=>(T.itemMap.set(N,{ref:N,...j}),()=>void T.itemMap.delete(N))),h.jsx(k,{[y]:"",ref:I,children:A})});v.displayName=p;function w(S){const _=s(e+"CollectionConsumer",S);return b.useCallback(()=>{const A=_.collectionRef.current;if(!A)return[];const j=Array.from(A.querySelectorAll(`[${y}]`));return Array.from(_.itemMap.values()).sort((T,q)=>j.indexOf(T.ref.current)-j.indexOf(q.ref.current))},[_.collectionRef,_.itemMap])}return[{Provider:l,Slot:f,ItemSlot:v},w,a]}var Q5e=b.createContext(void 0);function Bk(e){const t=b.useContext(Q5e);return e||t||"ltr"}const X5e=["top","right","bottom","left"],Ci=Math.min,Ta=Math.max,n2=Math.round,fh=Math.floor,Or=e=>({x:e,y:e}),J5e={left:"right",right:"left",bottom:"top",top:"bottom"};function Bm(e,t,n){return Ta(e,Ci(t,n))}function yo(e,t){return typeof e=="function"?e(t):e}function mo(e){return e.split("-")[0]}function dc(e){return e.split("-")[1]}function $k(e){return e==="x"?"y":"x"}function Uk(e){return e==="y"?"height":"width"}function jr(e){const t=e[0];return t==="t"||t==="b"?"y":"x"}function Kk(e){return $k(jr(e))}function exe(e,t,n){n===void 0&&(n=!1);const a=dc(e),o=Kk(e),s=Uk(o);let l=o==="x"?a===(n?"end":"start")?"right":"left":a==="start"?"bottom":"top";return t.reference[s]>t.floating[s]&&(l=a2(l)),[l,a2(l)]}function txe(e){const t=a2(e);return[$m(e),t,$m(t)]}function $m(e){return e.includes("start")?e.replace("start","end"):e.replace("end","start")}const m8=["left","right"],g8=["right","left"],nxe=["top","bottom"],axe=["bottom","top"];function rxe(e,t,n){switch(e){case"top":case"bottom":return n?t?g8:m8:t?m8:g8;case"left":case"right":return t?nxe:axe;default:return[]}}function oxe(e,t,n,a){const o=dc(e);let s=rxe(mo(e),n==="start",a);return o&&(s=s.map(l=>l+"-"+o),t&&(s=s.concat(s.map($m)))),s}function a2(e){const t=mo(e);return J5e[t]+e.slice(t.length)}function ixe(e){return{top:0,right:0,bottom:0,left:0,...e}}function A_(e){return typeof e!="number"?ixe(e):{top:e,right:e,bottom:e,left:e}}function r2(e){const{x:t,y:n,width:a,height:o}=e;return{width:a,height:o,top:n,left:t,right:t+a,bottom:n+o,x:t,y:n}}function k8(e,t,n){let{reference:a,floating:o}=e;const s=jr(t),l=Kk(t),c=Uk(l),d=mo(t),f=s==="y",p=a.x+a.width/2-o.width/2,y=a.y+a.height/2-o.height/2,k=a[c]/2-o[c]/2;let v;switch(d){case"top":v={x:p,y:a.y-o.height};break;case"bottom":v={x:p,y:a.y+a.height};break;case"right":v={x:a.x+a.width,y};break;case"left":v={x:a.x-o.width,y};break;default:v={x:a.x,y:a.y}}switch(dc(t)){case"start":v[l]-=k*(n&&f?-1:1);break;case"end":v[l]+=k*(n&&f?-1:1);break}return v}async function sxe(e,t){var n;t===void 0&&(t={});const{x:a,y:o,platform:s,rects:l,elements:c,strategy:d}=e,{boundary:f="clippingAncestors",rootBoundary:p="viewport",elementContext:y="floating",altBoundary:k=!1,padding:v=0}=yo(t,e),w=A_(v),_=c[k?y==="floating"?"reference":"floating":y],C=r2(await s.getClippingRect({element:(n=await(s.isElement==null?void 0:s.isElement(_)))==null||n?_:_.contextElement||await(s.getDocumentElement==null?void 0:s.getDocumentElement(c.floating)),boundary:f,rootBoundary:p,strategy:d})),A=y==="floating"?{x:a,y:o,width:l.floating.width,height:l.floating.height}:l.reference,j=await(s.getOffsetParent==null?void 0:s.getOffsetParent(c.floating)),N=await(s.isElement==null?void 0:s.isElement(j))?await(s.getScale==null?void 0:s.getScale(j))||{x:1,y:1}:{x:1,y:1},I=r2(s.convertOffsetParentRelativeRectToViewportRelativeRect?await s.convertOffsetParentRelativeRectToViewportRelativeRect({elements:c,rect:A,offsetParent:j,strategy:d}):A);return{top:(C.top-I.top+w.top)/N.y,bottom:(I.bottom-C.bottom+w.bottom)/N.y,left:(C.left-I.left+w.left)/N.x,right:(I.right-C.right+w.right)/N.x}}const lxe=50,cxe=async(e,t,n)=>{const{placement:a="bottom",strategy:o="absolute",middleware:s=[],platform:l}=n,c=l.detectOverflow?l:{...l,detectOverflow:sxe},d=await(l.isRTL==null?void 0:l.isRTL(t));let f=await l.getElementRects({reference:e,floating:t,strategy:o}),{x:p,y}=k8(f,a,d),k=a,v=0;const w={};for(let S=0;S<s.length;S++){const _=s[S];if(!_)continue;const{name:C,fn:A}=_,{x:j,y:N,data:I,reset:T}=await A({x:p,y,initialPlacement:a,placement:k,strategy:o,middlewareData:w,rects:f,platform:c,elements:{reference:e,floating:t}});p=j??p,y=N??y,w[C]={...w[C],...I},T&&v<lxe&&(v++,typeof T=="object"&&(T.placement&&(k=T.placement),T.rects&&(f=T.rects===!0?await l.getElementRects({reference:e,floating:t,strategy:o}):T.rects),{x:p,y}=k8(f,k,d)),S=-1)}return{x:p,y,placement:k,strategy:o,middlewareData:w}},uxe=e=>({name:"arrow",options:e,async fn(t){const{x:n,y:a,placement:o,rects:s,platform:l,elements:c,middlewareData:d}=t,{element:f,padding:p=0}=yo(e,t)||{};if(f==null)return{};const y=A_(p),k={x:n,y:a},v=Kk(o),w=Uk(v),S=await l.getDimensions(f),_=v==="y",C=_?"top":"left",A=_?"bottom":"right",j=_?"clientHeight":"clientWidth",N=s.reference[w]+s.reference[v]-k[v]-s.floating[w],I=k[v]-s.reference[v],T=await(l.getOffsetParent==null?void 0:l.getOffsetParent(f));let q=T?T[j]:0;(!q||!await(l.isElement==null?void 0:l.isElement(T)))&&(q=c.floating[j]||s.floating[w]);const R=N/2-I/2,H=q/2-S[w]/2-1,D=Ci(y[C],H),G=Ci(y[A],H),$=D,X=q-S[w]-G,F=q/2-S[w]/2+R,W=Bm($,F,X),P=!d.arrow&&dc(o)!=null&&F!==W&&s.reference[w]/2-(F<$?D:G)-S[w]/2<0,U=P?F<$?F-$:F-X:0;return{[v]:k[v]+U,data:{[v]:W,centerOffset:F-W-U,...P&&{alignmentOffset:U}},reset:P}}}),dxe=function(e){return e===void 0&&(e={}),{name:"flip",options:e,async fn(t){var n,a;const{placement:o,middlewareData:s,rects:l,initialPlacement:c,platform:d,elements:f}=t,{mainAxis:p=!0,crossAxis:y=!0,fallbackPlacements:k,fallbackStrategy:v="bestFit",fallbackAxisSideDirection:w="none",flipAlignment:S=!0,..._}=yo(e,t);if((n=s.arrow)!=null&&n.alignmentOffset)return{};const C=mo(o),A=jr(c),j=mo(c)===c,N=await(d.isRTL==null?void 0:d.isRTL(f.floating)),I=k||(j||!S?[a2(c)]:txe(c)),T=w!=="none";!k&&T&&I.push(...oxe(c,S,w,N));const q=[c,...I],R=await d.detectOverflow(t,_),H=[];let D=((a=s.flip)==null?void 0:a.overflows)||[];if(p&&H.push(R[C]),y){const F=exe(o,l,N);H.push(R[F[0]],R[F[1]])}if(D=[...D,{placement:o,overflows:H}],!H.every(F=>F<=0)){var G,$;const F=(((G=s.flip)==null?void 0:G.index)||0)+1,W=q[F];if(W&&(!(y==="alignment"?A!==jr(W):!1)||D.every(J=>jr(J.placement)===A?J.overflows[0]>0:!0)))return{data:{index:F,overflows:D},reset:{placement:W}};let P=($=D.filter(U=>U.overflows[0]<=0).sort((U,J)=>U.overflows[1]-J.overflows[1])[0])==null?void 0:$.placement;if(!P)switch(v){case"bestFit":{var X;const U=(X=D.filter(J=>{if(T){const se=jr(J.placement);return se===A||se==="y"}return!0}).map(J=>[J.placement,J.overflows.filter(se=>se>0).reduce((se,L)=>se+L,0)]).sort((J,se)=>J[1]-se[1])[0])==null?void 0:X[0];U&&(P=U);break}case"initialPlacement":P=c;break}if(o!==P)return{reset:{placement:P}}}return{}}}};function v8(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function x8(e){return X5e.some(t=>e[t]>=0)}const hxe=function(e){return e===void 0&&(e={}),{name:"hide",options:e,async fn(t){const{rects:n,platform:a}=t,{strategy:o="referenceHidden",...s}=yo(e,t);switch(o){case"referenceHidden":{const l=await a.detectOverflow(t,{...s,elementContext:"reference"}),c=v8(l,n.reference);return{data:{referenceHiddenOffsets:c,referenceHidden:x8(c)}}}case"escaped":{const l=await a.detectOverflow(t,{...s,altBoundary:!0}),c=v8(l,n.floating);return{data:{escapedOffsets:c,escaped:x8(c)}}}default:return{}}}}},E_=new Set(["left","top"]);async function fxe(e,t){const{placement:n,platform:a,elements:o}=e,s=await(a.isRTL==null?void 0:a.isRTL(o.floating)),l=mo(n),c=dc(n),d=jr(n)==="y",f=E_.has(l)?-1:1,p=s&&d?-1:1,y=yo(t,e);let{mainAxis:k,crossAxis:v,alignmentAxis:w}=typeof y=="number"?{mainAxis:y,crossAxis:0,alignmentAxis:null}:{mainAxis:y.mainAxis||0,crossAxis:y.crossAxis||0,alignmentAxis:y.alignmentAxis};return c&&typeof w=="number"&&(v=c==="end"?w*-1:w),d?{x:v*p,y:k*f}:{x:k*f,y:v*p}}const pxe=function(e){return e===void 0&&(e=0),{name:"offset",options:e,async fn(t){var n,a;const{x:o,y:s,placement:l,middlewareData:c}=t,d=await fxe(t,e);return l===((n=c.offset)==null?void 0:n.placement)&&(a=c.arrow)!=null&&a.alignmentOffset?{}:{x:o+d.x,y:s+d.y,data:{...d,placement:l}}}}},yxe=function(e){return e===void 0&&(e={}),{name:"shift",options:e,async fn(t){const{x:n,y:a,placement:o,platform:s}=t,{mainAxis:l=!0,crossAxis:c=!1,limiter:d={fn:C=>{let{x:A,y:j}=C;return{x:A,y:j}}},...f}=yo(e,t),p={x:n,y:a},y=await s.detectOverflow(t,f),k=jr(mo(o)),v=$k(k);let w=p[v],S=p[k];if(l){const C=v==="y"?"top":"left",A=v==="y"?"bottom":"right",j=w+y[C],N=w-y[A];w=Bm(j,w,N)}if(c){const C=k==="y"?"top":"left",A=k==="y"?"bottom":"right",j=S+y[C],N=S-y[A];S=Bm(j,S,N)}const _=d.fn({...t,[v]:w,[k]:S});return{..._,data:{x:_.x-n,y:_.y-a,enabled:{[v]:l,[k]:c}}}}}},mxe=function(e){return e===void 0&&(e={}),{options:e,fn(t){const{x:n,y:a,placement:o,rects:s,middlewareData:l}=t,{offset:c=0,mainAxis:d=!0,crossAxis:f=!0}=yo(e,t),p={x:n,y:a},y=jr(o),k=$k(y);let v=p[k],w=p[y];const S=yo(c,t),_=typeof S=="number"?{mainAxis:S,crossAxis:0}:{mainAxis:0,crossAxis:0,...S};if(d){const j=k==="y"?"height":"width",N=s.reference[k]-s.floating[j]+_.mainAxis,I=s.reference[k]+s.reference[j]-_.mainAxis;v<N?v=N:v>I&&(v=I)}if(f){var C,A;const j=k==="y"?"width":"height",N=E_.has(mo(o)),I=s.reference[y]-s.floating[j]+(N&&((C=l.offset)==null?void 0:C[y])||0)+(N?0:_.crossAxis),T=s.reference[y]+s.reference[j]+(N?0:((A=l.offset)==null?void 0:A[y])||0)-(N?_.crossAxis:0);w<I?w=I:w>T&&(w=T)}return{[k]:v,[y]:w}}}},gxe=function(e){return e===void 0&&(e={}),{name:"size",options:e,async fn(t){var n,a;const{placement:o,rects:s,platform:l,elements:c}=t,{apply:d=()=>{},...f}=yo(e,t),p=await l.detectOverflow(t,f),y=mo(o),k=dc(o),v=jr(o)==="y",{width:w,height:S}=s.floating;let _,C;y==="top"||y==="bottom"?(_=y,C=k===(await(l.isRTL==null?void 0:l.isRTL(c.floating))?"start":"end")?"left":"right"):(C=y,_=k==="end"?"top":"bottom");const A=S-p.top-p.bottom,j=w-p.left-p.right,N=Ci(S-p[_],A),I=Ci(w-p[C],j),T=!t.middlewareData.shift;let q=N,R=I;if((n=t.middlewareData.shift)!=null&&n.enabled.x&&(R=j),(a=t.middlewareData.shift)!=null&&a.enabled.y&&(q=A),T&&!k){const D=Ta(p.left,0),G=Ta(p.right,0),$=Ta(p.top,0),X=Ta(p.bottom,0);v?R=w-2*(D!==0||G!==0?D+G:Ta(p.left,p.right)):q=S-2*($!==0||X!==0?$+X:Ta(p.top,p.bottom))}await d({...t,availableWidth:R,availableHeight:q});const H=await l.getDimensions(c.floating);return w!==H.width||S!==H.height?{reset:{rects:!0}}:{}}}};function n0(){return typeof window<"u"}function hc(e){return R_(e)?(e.nodeName||"").toLowerCase():"#document"}function La(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function zr(e){var t;return(t=(R_(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}function R_(e){return n0()?e instanceof Node||e instanceof La(e).Node:!1}function cr(e){return n0()?e instanceof Element||e instanceof La(e).Element:!1}function bo(e){return n0()?e instanceof HTMLElement||e instanceof La(e).HTMLElement:!1}function b8(e){return!n0()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof La(e).ShadowRoot}function x1(e){const{overflow:t,overflowX:n,overflowY:a,display:o}=ur(e);return/auto|scroll|overlay|hidden|clip/.test(t+a+n)&&o!=="inline"&&o!=="contents"}function kxe(e){return/^(table|td|th)$/.test(hc(e))}function a0(e){try{if(e.matches(":popover-open"))return!0}catch{}try{return e.matches(":modal")}catch{return!1}}const vxe=/transform|translate|scale|rotate|perspective|filter/,xxe=/paint|layout|strict|content/,cs=e=>!!e&&e!=="none";let Fy;function Gk(e){const t=cr(e)?ur(e):e;return cs(t.transform)||cs(t.translate)||cs(t.scale)||cs(t.rotate)||cs(t.perspective)||!Yk()&&(cs(t.backdropFilter)||cs(t.filter))||vxe.test(t.willChange||"")||xxe.test(t.contain||"")}function bxe(e){let t=Ai(e);for(;bo(t)&&!Xl(t);){if(Gk(t))return t;if(a0(t))return null;t=Ai(t)}return null}function Yk(){return Fy==null&&(Fy=typeof CSS<"u"&&CSS.supports&&CSS.supports("-webkit-backdrop-filter","none")),Fy}function Xl(e){return/^(html|body|#document)$/.test(hc(e))}function ur(e){return La(e).getComputedStyle(e)}function r0(e){return cr(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function Ai(e){if(hc(e)==="html")return e;const t=e.assignedSlot||e.parentNode||b8(e)&&e.host||zr(e);return b8(t)?t.host:t}function j_(e){const t=Ai(e);return Xl(t)?e.ownerDocument?e.ownerDocument.body:e.body:bo(t)&&x1(t)?t:j_(t)}function Uu(e,t,n){var a;t===void 0&&(t=[]),n===void 0&&(n=!0);const o=j_(e),s=o===((a=e.ownerDocument)==null?void 0:a.body),l=La(o);if(s){const c=Um(l);return t.concat(l,l.visualViewport||[],x1(o)?o:[],c&&n?Uu(c):[])}else return t.concat(o,Uu(o,[],n))}function Um(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function O_(e){const t=ur(e);let n=parseFloat(t.width)||0,a=parseFloat(t.height)||0;const o=bo(e),s=o?e.offsetWidth:n,l=o?e.offsetHeight:a,c=n2(n)!==s||n2(a)!==l;return c&&(n=s,a=l),{width:n,height:a,$:c}}function Wk(e){return cr(e)?e:e.contextElement}function Vl(e){const t=Wk(e);if(!bo(t))return Or(1);const n=t.getBoundingClientRect(),{width:a,height:o,$:s}=O_(t);let l=(s?n2(n.width):n.width)/a,c=(s?n2(n.height):n.height)/o;return(!l||!Number.isFinite(l))&&(l=1),(!c||!Number.isFinite(c))&&(c=1),{x:l,y:c}}const wxe=Or(0);function N_(e){const t=La(e);return!Yk()||!t.visualViewport?wxe:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function Mxe(e,t,n){return t===void 0&&(t=!1),!n||t&&n!==La(e)?!1:t}function _s(e,t,n,a){t===void 0&&(t=!1),n===void 0&&(n=!1);const o=e.getBoundingClientRect(),s=Wk(e);let l=Or(1);t&&(a?cr(a)&&(l=Vl(a)):l=Vl(e));const c=Mxe(s,n,a)?N_(s):Or(0);let d=(o.left+c.x)/l.x,f=(o.top+c.y)/l.y,p=o.width/l.x,y=o.height/l.y;if(s){const k=La(s),v=a&&cr(a)?La(a):a;let w=k,S=Um(w);for(;S&&a&&v!==w;){const _=Vl(S),C=S.getBoundingClientRect(),A=ur(S),j=C.left+(S.clientLeft+parseFloat(A.paddingLeft))*_.x,N=C.top+(S.clientTop+parseFloat(A.paddingTop))*_.y;d*=_.x,f*=_.y,p*=_.x,y*=_.y,d+=j,f+=N,w=La(S),S=Um(w)}}return r2({width:p,height:y,x:d,y:f})}function o0(e,t){const n=r0(e).scrollLeft;return t?t.left+n:_s(zr(e)).left+n}function T_(e,t){const n=e.getBoundingClientRect(),a=n.left+t.scrollLeft-o0(e,n),o=n.top+t.scrollTop;return{x:a,y:o}}function Sxe(e){let{elements:t,rect:n,offsetParent:a,strategy:o}=e;const s=o==="fixed",l=zr(a),c=t?a0(t.floating):!1;if(a===l||c&&s)return n;let d={scrollLeft:0,scrollTop:0},f=Or(1);const p=Or(0),y=bo(a);if((y||!y&&!s)&&((hc(a)!=="body"||x1(l))&&(d=r0(a)),y)){const v=_s(a);f=Vl(a),p.x=v.x+a.clientLeft,p.y=v.y+a.clientTop}const k=l&&!y&&!s?T_(l,d):Or(0);return{width:n.width*f.x,height:n.height*f.y,x:n.x*f.x-d.scrollLeft*f.x+p.x+k.x,y:n.y*f.y-d.scrollTop*f.y+p.y+k.y}}function _xe(e){return Array.from(e.getClientRects())}function Cxe(e){const t=zr(e),n=r0(e),a=e.ownerDocument.body,o=Ta(t.scrollWidth,t.clientWidth,a.scrollWidth,a.clientWidth),s=Ta(t.scrollHeight,t.clientHeight,a.scrollHeight,a.clientHeight);let l=-n.scrollLeft+o0(e);const c=-n.scrollTop;return ur(a).direction==="rtl"&&(l+=Ta(t.clientWidth,a.clientWidth)-o),{width:o,height:s,x:l,y:c}}const w8=25;function Axe(e,t){const n=La(e),a=zr(e),o=n.visualViewport;let s=a.clientWidth,l=a.clientHeight,c=0,d=0;if(o){s=o.width,l=o.height;const p=Yk();(!p||p&&t==="fixed")&&(c=o.offsetLeft,d=o.offsetTop)}const f=o0(a);if(f<=0){const p=a.ownerDocument,y=p.body,k=getComputedStyle(y),v=p.compatMode==="CSS1Compat"&&parseFloat(k.marginLeft)+parseFloat(k.marginRight)||0,w=Math.abs(a.clientWidth-y.clientWidth-v);w<=w8&&(s-=w)}else f<=w8&&(s+=f);return{width:s,height:l,x:c,y:d}}function Exe(e,t){const n=_s(e,!0,t==="fixed"),a=n.top+e.clientTop,o=n.left+e.clientLeft,s=bo(e)?Vl(e):Or(1),l=e.clientWidth*s.x,c=e.clientHeight*s.y,d=o*s.x,f=a*s.y;return{width:l,height:c,x:d,y:f}}function M8(e,t,n){let a;if(t==="viewport")a=Axe(e,n);else if(t==="document")a=Cxe(zr(e));else if(cr(t))a=Exe(t,n);else{const o=N_(e);a={x:t.x-o.x,y:t.y-o.y,width:t.width,height:t.height}}return r2(a)}function P_(e,t){const n=Ai(e);return n===t||!cr(n)||Xl(n)?!1:ur(n).position==="fixed"||P_(n,t)}function Rxe(e,t){const n=t.get(e);if(n)return n;let a=Uu(e,[],!1).filter(c=>cr(c)&&hc(c)!=="body"),o=null;const s=ur(e).position==="fixed";let l=s?Ai(e):e;for(;cr(l)&&!Xl(l);){const c=ur(l),d=Gk(l);!d&&c.position==="fixed"&&(o=null),(s?!d&&!o:!d&&c.position==="static"&&!!o&&(o.position==="absolute"||o.position==="fixed")||x1(l)&&!d&&P_(e,l))?a=a.filter(p=>p!==l):o=c,l=Ai(l)}return t.set(e,a),a}function jxe(e){let{element:t,boundary:n,rootBoundary:a,strategy:o}=e;const l=[...n==="clippingAncestors"?a0(t)?[]:Rxe(t,this._c):[].concat(n),a],c=M8(t,l[0],o);let d=c.top,f=c.right,p=c.bottom,y=c.left;for(let k=1;k<l.length;k++){const v=M8(t,l[k],o);d=Ta(v.top,d),f=Ci(v.right,f),p=Ci(v.bottom,p),y=Ta(v.left,y)}return{width:f-y,height:p-d,x:y,y:d}}function Oxe(e){const{width:t,height:n}=O_(e);return{width:t,height:n}}function Nxe(e,t,n){const a=bo(t),o=zr(t),s=n==="fixed",l=_s(e,!0,s,t);let c={scrollLeft:0,scrollTop:0};const d=Or(0);function f(){d.x=o0(o)}if(a||!a&&!s)if((hc(t)!=="body"||x1(o))&&(c=r0(t)),a){const v=_s(t,!0,s,t);d.x=v.x+t.clientLeft,d.y=v.y+t.clientTop}else o&&f();s&&!a&&o&&f();const p=o&&!a&&!s?T_(o,c):Or(0),y=l.left+c.scrollLeft-d.x-p.x,k=l.top+c.scrollTop-d.y-p.y;return{x:y,y:k,width:l.width,height:l.height}}function By(e){return ur(e).position==="static"}function S8(e,t){if(!bo(e)||ur(e).position==="fixed")return null;if(t)return t(e);let n=e.offsetParent;return zr(e)===n&&(n=n.ownerDocument.body),n}function L_(e,t){const n=La(e);if(a0(e))return n;if(!bo(e)){let o=Ai(e);for(;o&&!Xl(o);){if(cr(o)&&!By(o))return o;o=Ai(o)}return n}let a=S8(e,t);for(;a&&kxe(a)&&By(a);)a=S8(a,t);return a&&Xl(a)&&By(a)&&!Gk(a)?n:a||bxe(e)||n}const Txe=async function(e){const t=this.getOffsetParent||L_,n=this.getDimensions,a=await n(e.floating);return{reference:Nxe(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:a.width,height:a.height}}};function Pxe(e){return ur(e).direction==="rtl"}const Lxe={convertOffsetParentRelativeRectToViewportRelativeRect:Sxe,getDocumentElement:zr,getClippingRect:jxe,getOffsetParent:L_,getElementRects:Txe,getClientRects:_xe,getDimensions:Oxe,getScale:Vl,isElement:cr,isRTL:Pxe};function z_(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function zxe(e,t){let n=null,a;const o=zr(e);function s(){var c;clearTimeout(a),(c=n)==null||c.disconnect(),n=null}function l(c,d){c===void 0&&(c=!1),d===void 0&&(d=1),s();const f=e.getBoundingClientRect(),{left:p,top:y,width:k,height:v}=f;if(c||t(),!k||!v)return;const w=fh(y),S=fh(o.clientWidth-(p+k)),_=fh(o.clientHeight-(y+v)),C=fh(p),j={rootMargin:-w+"px "+-S+"px "+-_+"px "+-C+"px",threshold:Ta(0,Ci(1,d))||1};let N=!0;function I(T){const q=T[0].intersectionRatio;if(q!==d){if(!N)return l();q?l(!1,q):a=setTimeout(()=>{l(!1,1e-7)},1e3)}q===1&&!z_(f,e.getBoundingClientRect())&&l(),N=!1}try{n=new IntersectionObserver(I,{...j,root:o.ownerDocument})}catch{n=new IntersectionObserver(I,j)}n.observe(e)}return l(!0),s}function Dxe(e,t,n,a){a===void 0&&(a={});const{ancestorScroll:o=!0,ancestorResize:s=!0,elementResize:l=typeof ResizeObserver=="function",layoutShift:c=typeof IntersectionObserver=="function",animationFrame:d=!1}=a,f=Wk(e),p=o||s?[...f?Uu(f):[],...t?Uu(t):[]]:[];p.forEach(C=>{o&&C.addEventListener("scroll",n,{passive:!0}),s&&C.addEventListener("resize",n)});const y=f&&c?zxe(f,n):null;let k=-1,v=null;l&&(v=new ResizeObserver(C=>{let[A]=C;A&&A.target===f&&v&&t&&(v.unobserve(t),cancelAnimationFrame(k),k=requestAnimationFrame(()=>{var j;(j=v)==null||j.observe(t)})),n()}),f&&!d&&v.observe(f),t&&v.observe(t));let w,S=d?_s(e):null;d&&_();function _(){const C=_s(e);S&&!z_(S,C)&&n(),S=C,w=requestAnimationFrame(_)}return n(),()=>{var C;p.forEach(A=>{o&&A.removeEventListener("scroll",n),s&&A.removeEventListener("resize",n)}),y?.(),(C=v)==null||C.disconnect(),v=null,d&&cancelAnimationFrame(w)}}const Ixe=pxe,qxe=yxe,Hxe=dxe,Vxe=gxe,Fxe=hxe,_8=uxe,Bxe=mxe,$xe=(e,t,n)=>{const a=new Map,o={platform:Lxe,...n},s={...o.platform,_c:a};return cxe(e,t,{...o,platform:s})};var Uxe=typeof document<"u",Kxe=function(){},Rh=Uxe?b.useLayoutEffect:Kxe;function o2(e,t){if(e===t)return!0;if(typeof e!=typeof t)return!1;if(typeof e=="function"&&e.toString()===t.toString())return!0;let n,a,o;if(e&&t&&typeof e=="object"){if(Array.isArray(e)){if(n=e.length,n!==t.length)return!1;for(a=n;a--!==0;)if(!o2(e[a],t[a]))return!1;return!0}if(o=Object.keys(e),n=o.length,n!==Object.keys(t).length)return!1;for(a=n;a--!==0;)if(!{}.hasOwnProperty.call(t,o[a]))return!1;for(a=n;a--!==0;){const s=o[a];if(!(s==="_owner"&&e.$$typeof)&&!o2(e[s],t[s]))return!1}return!0}return e!==e&&t!==t}function D_(e){return typeof window>"u"?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function C8(e,t){const n=D_(e);return Math.round(t*n)/n}function $y(e){const t=b.useRef(e);return Rh(()=>{t.current=e}),t}function Gxe(e){e===void 0&&(e={});const{placement:t="bottom",strategy:n="absolute",middleware:a=[],platform:o,elements:{reference:s,floating:l}={},transform:c=!0,whileElementsMounted:d,open:f}=e,[p,y]=b.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[k,v]=b.useState(a);o2(k,a)||v(a);const[w,S]=b.useState(null),[_,C]=b.useState(null),A=b.useCallback(J=>{J!==T.current&&(T.current=J,S(J))},[]),j=b.useCallback(J=>{J!==q.current&&(q.current=J,C(J))},[]),N=s||w,I=l||_,T=b.useRef(null),q=b.useRef(null),R=b.useRef(p),H=d!=null,D=$y(d),G=$y(o),$=$y(f),X=b.useCallback(()=>{if(!T.current||!q.current)return;const J={placement:t,strategy:n,middleware:k};G.current&&(J.platform=G.current),$xe(T.current,q.current,J).then(se=>{const L={...se,isPositioned:$.current!==!1};F.current&&!o2(R.current,L)&&(R.current=L,go.flushSync(()=>{y(L)}))})},[k,t,n,G,$]);Rh(()=>{f===!1&&R.current.isPositioned&&(R.current.isPositioned=!1,y(J=>({...J,isPositioned:!1})))},[f]);const F=b.useRef(!1);Rh(()=>(F.current=!0,()=>{F.current=!1}),[]),Rh(()=>{if(N&&(T.current=N),I&&(q.current=I),N&&I){if(D.current)return D.current(N,I,X);X()}},[N,I,X,D,H]);const W=b.useMemo(()=>({reference:T,floating:q,setReference:A,setFloating:j}),[A,j]),P=b.useMemo(()=>({reference:N,floating:I}),[N,I]),U=b.useMemo(()=>{const J={position:n,left:0,top:0};if(!P.floating)return J;const se=C8(P.floating,p.x),L=C8(P.floating,p.y);return c?{...J,transform:"translate("+se+"px, "+L+"px)",...D_(P.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:se,top:L}},[n,c,P.floating,p.x,p.y]);return b.useMemo(()=>({...p,update:X,refs:W,elements:P,floatingStyles:U}),[p,X,W,P,U])}const Yxe=e=>{function t(n){return{}.hasOwnProperty.call(n,"current")}return{name:"arrow",options:e,fn(n){const{element:a,padding:o}=typeof e=="function"?e(n):e;return a&&t(a)?a.current!=null?_8({element:a.current,padding:o}).fn(n):{}:a?_8({element:a,padding:o}).fn(n):{}}}},Wxe=(e,t)=>{const n=Ixe(e);return{name:n.name,fn:n.fn,options:[e,t]}},Zxe=(e,t)=>{const n=qxe(e);return{name:n.name,fn:n.fn,options:[e,t]}},Qxe=(e,t)=>({fn:Bxe(e).fn,options:[e,t]}),Xxe=(e,t)=>{const n=Hxe(e);return{name:n.name,fn:n.fn,options:[e,t]}},Jxe=(e,t)=>{const n=Vxe(e);return{name:n.name,fn:n.fn,options:[e,t]}},e3e=(e,t)=>{const n=Fxe(e);return{name:n.name,fn:n.fn,options:[e,t]}},t3e=(e,t)=>{const n=Yxe(e);return{name:n.name,fn:n.fn,options:[e,t]}};var n3e="Arrow",I_=b.forwardRef((e,t)=>{const{children:n,width:a=10,height:o=5,...s}=e;return h.jsx(He.svg,{...s,ref:t,width:a,height:o,viewBox:"0 0 30 10",preserveAspectRatio:"none",children:e.asChild?n:h.jsx("polygon",{points:"0,0 30,0 15,10"})})});I_.displayName=n3e;var a3e=I_;function q_(e){const[t,n]=b.useState(void 0);return Mn(()=>{if(e){n({width:e.offsetWidth,height:e.offsetHeight});const a=new ResizeObserver(o=>{if(!Array.isArray(o)||!o.length)return;const s=o[0];let l,c;if("borderBoxSize"in s){const d=s.borderBoxSize,f=Array.isArray(d)?d[0]:d;l=f.inlineSize,c=f.blockSize}else l=e.offsetWidth,c=e.offsetHeight;n({width:l,height:c})});return a.observe(e,{box:"border-box"}),()=>a.unobserve(e)}else n(void 0)},[e]),t}var Zk="Popper",[H_,Ti]=dr(Zk),[r3e,V_]=H_(Zk),F_=e=>{const{__scopePopper:t,children:n}=e,[a,o]=b.useState(null),[s,l]=b.useState(void 0);return h.jsx(r3e,{scope:t,anchor:a,onAnchorChange:o,placementState:s,setPlacementState:l,children:n})};F_.displayName=Zk;var B_="PopperAnchor",$_=b.forwardRef((e,t)=>{const{__scopePopper:n,virtualRef:a,...o}=e,s=V_(B_,n),l=b.useRef(null),c=s.onAnchorChange,d=b.useCallback(w=>{l.current=w,w&&c(w)},[c]),f=it(t,d),p=b.useRef(null);b.useEffect(()=>{if(!a)return;const w=p.current;p.current=a.current,w!==p.current&&c(p.current)});const y=s.placementState&&Xk(s.placementState),k=y?.[0],v=y?.[1];return a?null:h.jsx(He.div,{"data-radix-popper-side":k,"data-radix-popper-align":v,...o,ref:f})});$_.displayName=B_;var Qk="PopperContent",[o3e,i3e]=H_(Qk),U_=b.forwardRef((e,t)=>{const{__scopePopper:n,side:a="bottom",sideOffset:o=0,align:s="center",alignOffset:l=0,arrowPadding:c=0,avoidCollisions:d=!0,collisionBoundary:f=[],collisionPadding:p=0,sticky:y="partial",hideWhenDetached:k=!1,updatePositionStrategy:v="optimized",onPlaced:w,...S}=e,_=V_(Qk,n),[C,A]=b.useState(null),j=it(t,de=>A(de)),[N,I]=b.useState(null),T=q_(N),q=T?.width??0,R=T?.height??0,H=a+(s!=="center"?"-"+s:""),D=typeof p=="number"?p:{top:0,right:0,bottom:0,left:0,...p},G=Array.isArray(f)?f:[f],$=G.length>0,X={padding:D,boundary:G.filter(l3e),altBoundary:$},{refs:F,floatingStyles:W,placement:P,isPositioned:U,middlewareData:J}=Gxe({strategy:"fixed",placement:H,whileElementsMounted:(...de)=>Dxe(...de,{animationFrame:v==="always"}),elements:{reference:_.anchor},middleware:[Wxe({mainAxis:o+R,alignmentAxis:l}),d&&Zxe({mainAxis:!0,crossAxis:!1,limiter:y==="partial"?Qxe():void 0,...X}),d&&Xxe({...X}),Jxe({...X,apply:({elements:de,rects:pe,availableWidth:Re,availableHeight:Pe})=>{const{width:De,height:bt}=pe.reference,Ye=de.floating.style;Ye.setProperty("--radix-popper-available-width",`${Re}px`),Ye.setProperty("--radix-popper-available-height",`${Pe}px`),Ye.setProperty("--radix-popper-anchor-width",`${De}px`),Ye.setProperty("--radix-popper-anchor-height",`${bt}px`)}}),N&&t3e({element:N,padding:c}),c3e({arrowWidth:q,arrowHeight:R}),k&&e3e({strategy:"referenceHidden",...X,boundary:$?X.boundary:void 0})]}),se=_.setPlacementState;Mn(()=>(se(P),()=>{se(void 0)}),[P,se]);const[L,B]=Xk(P),V=Nr(w);Mn(()=>{U&&V?.()},[U,V]);const O=J.arrow?.x,ee=J.arrow?.y,Q=J.arrow?.centerOffset!==0,[ae,oe]=b.useState();return Mn(()=>{C&&oe(window.getComputedStyle(C).zIndex)},[C]),h.jsx("div",{ref:F.setFloating,"data-radix-popper-content-wrapper":"",style:{...W,transform:U?W.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:ae,"--radix-popper-transform-origin":[J.transformOrigin?.x,J.transformOrigin?.y].join(" "),...J.hide?.referenceHidden&&{visibility:"hidden",pointerEvents:"none"}},dir:e.dir,children:h.jsx(o3e,{scope:n,placedSide:L,placedAlign:B,onArrowChange:I,arrowX:O,arrowY:ee,shouldHideArrow:Q,children:h.jsx(He.div,{"data-side":L,"data-align":B,...S,ref:j,style:{...S.style,animation:U?void 0:"none"}})})})});U_.displayName=Qk;var K_="PopperArrow",s3e={top:"bottom",right:"left",bottom:"top",left:"right"},G_=b.forwardRef(function(t,n){const{__scopePopper:a,...o}=t,s=i3e(K_,a),l=s3e[s.placedSide];return h.jsx("span",{ref:s.onArrowChange,style:{position:"absolute",left:s.arrowX,top:s.arrowY,[l]:0,transformOrigin:{top:"",right:"0 0",bottom:"center 0",left:"100% 0"}[s.placedSide],transform:{top:"translateY(100%)",right:"translateY(50%) rotate(90deg) translateX(-50%)",bottom:"rotate(180deg)",left:"translateY(50%) rotate(-90deg) translateX(50%)"}[s.placedSide],visibility:s.shouldHideArrow?"hidden":void 0},children:h.jsx(a3e,{...o,ref:n,style:{...o.style,display:"block"}})})});G_.displayName=K_;function l3e(e){return e!==null}var c3e=e=>({name:"transformOrigin",options:e,fn(t){const{placement:n,rects:a,middlewareData:o}=t,l=o.arrow?.centerOffset!==0,c=l?0:e.arrowWidth,d=l?0:e.arrowHeight,[f,p]=Xk(n),y={start:"0%",center:"50%",end:"100%"}[p],k=(o.arrow?.x??0)+c/2,v=(o.arrow?.y??0)+d/2;let w="",S="";return f==="bottom"?(w=l?y:`${k}px`,S=`${-d}px`):f==="top"?(w=l?y:`${k}px`,S=`${a.floating.height+d}px`):f==="right"?(w=`${-d}px`,S=l?y:`${v}px`):f==="left"&&(w=`${a.floating.width+d}px`,S=l?y:`${v}px`),{data:{x:w,y:S}}}});function Xk(e){const[t,n="center"]=e.split("-");return[t,n]}var i0=F_,b1=$_,s0=U_,l0=G_,Uy="rovingFocusGroup.onEntryFocus",u3e={bubbles:!1,cancelable:!0},w1="RovingFocusGroup",[Km,Y_,d3e]=Fk(w1),[h3e,W_]=dr(w1,[d3e]),[f3e,p3e]=h3e(w1),Z_=b.forwardRef((e,t)=>h.jsx(Km.Provider,{scope:e.__scopeRovingFocusGroup,children:h.jsx(Km.Slot,{scope:e.__scopeRovingFocusGroup,children:h.jsx(y3e,{...e,ref:t})})}));Z_.displayName=w1;var y3e=b.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,orientation:a,loop:o=!1,dir:s,currentTabStopId:l,defaultCurrentTabStopId:c,onCurrentTabStopIdChange:d,onEntryFocus:f,preventScrollOnEntryFocus:p=!1,...y}=e,k=b.useRef(null),v=it(t,k),w=Bk(s),[S,_]=fo({prop:l,defaultProp:c??null,onChange:d,caller:w1}),[C,A]=b.useState(!1),j=Nr(f),N=Y_(n),I=b.useRef(!1),[T,q]=b.useState(0);return b.useEffect(()=>{const R=k.current;if(R)return R.addEventListener(Uy,j),()=>R.removeEventListener(Uy,j)},[j]),h.jsx(f3e,{scope:n,orientation:a,dir:w,loop:o,currentTabStopId:S,onItemFocus:b.useCallback(R=>_(R),[_]),onItemShiftTab:b.useCallback(()=>A(!0),[]),onFocusableItemAdd:b.useCallback(()=>q(R=>R+1),[]),onFocusableItemRemove:b.useCallback(()=>q(R=>R-1),[]),children:h.jsx(He.div,{tabIndex:C||T===0?-1:0,"data-orientation":a,...y,ref:v,style:{outline:"none",...e.style},onMouseDown:xe(e.onMouseDown,()=>{I.current=!0}),onFocus:xe(e.onFocus,R=>{const H=!I.current;if(R.target===R.currentTarget&&H&&!C){const D=new CustomEvent(Uy,u3e);if(R.currentTarget.dispatchEvent(D),!D.defaultPrevented){const G=N().filter(P=>P.focusable),$=G.find(P=>P.active),X=G.find(P=>P.id===S),W=[$,X,...G].filter(Boolean).map(P=>P.ref.current);J_(W,p)}}I.current=!1}),onBlur:xe(e.onBlur,()=>A(!1))})})}),Q_="RovingFocusGroupItem",X_=b.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,focusable:a=!0,active:o=!1,tabStopId:s,children:l,...c}=e,d=Ya(),f=s||d,p=p3e(Q_,n),y=p.currentTabStopId===f,k=Y_(n),{onFocusableItemAdd:v,onFocusableItemRemove:w,currentTabStopId:S}=p;return b.useEffect(()=>{if(a)return v(),()=>w()},[a,v,w]),h.jsx(Km.ItemSlot,{scope:n,id:f,focusable:a,active:o,children:h.jsx(He.span,{tabIndex:y?0:-1,"data-orientation":p.orientation,...c,ref:t,onMouseDown:xe(e.onMouseDown,_=>{a?p.onItemFocus(f):_.preventDefault()}),onFocus:xe(e.onFocus,()=>p.onItemFocus(f)),onKeyDown:xe(e.onKeyDown,_=>{if(_.key==="Tab"&&_.shiftKey){p.onItemShiftTab();return}if(_.target!==_.currentTarget)return;const C=k3e(_,p.orientation,p.dir);if(C!==void 0){if(_.metaKey||_.ctrlKey||_.altKey||_.shiftKey)return;_.preventDefault();let j=k().filter(N=>N.focusable).map(N=>N.ref.current);if(C==="last")j.reverse();else if(C==="prev"||C==="next"){C==="prev"&&j.reverse();const N=j.indexOf(_.currentTarget);j=p.loop?v3e(j,N+1):j.slice(N+1)}setTimeout(()=>J_(j))}}),children:typeof l=="function"?l({isCurrentTabStop:y,hasTabStop:S!=null}):l})})});X_.displayName=Q_;var m3e={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function g3e(e,t){return t!=="rtl"?e:e==="ArrowLeft"?"ArrowRight":e==="ArrowRight"?"ArrowLeft":e}function k3e(e,t,n){const a=g3e(e.key,n);if(!(t==="vertical"&&["ArrowLeft","ArrowRight"].includes(a))&&!(t==="horizontal"&&["ArrowUp","ArrowDown"].includes(a)))return m3e[a]}function J_(e,t=!1){const n=document.activeElement;for(const a of e)if(a===n||(a.focus({preventScroll:t}),document.activeElement!==n))return}function v3e(e,t){return e.map((n,a)=>e[(t+a)%e.length])}var x3e=Z_,b3e=X_,Gm=["Enter"," "],w3e=["ArrowDown","PageUp","Home"],eC=["ArrowUp","PageDown","End"],M3e=[...w3e,...eC],S3e={ltr:[...Gm,"ArrowRight"],rtl:[...Gm,"ArrowLeft"]},_3e={ltr:["ArrowLeft"],rtl:["ArrowRight"]},M1="Menu",[Ku,C3e,A3e]=Fk(M1),[Ps,tC]=dr(M1,[A3e,Ti,W_]),c0=Ti(),nC=W_(),[E3e,Ls]=Ps(M1),[R3e,S1]=Ps(M1),aC=e=>{const{__scopeMenu:t,open:n=!1,children:a,dir:o,onOpenChange:s,modal:l=!0}=e,c=c0(t),[d,f]=b.useState(null),p=b.useRef(!1),y=Nr(s),k=Bk(o);return b.useEffect(()=>{const v=()=>{p.current=!0,document.addEventListener("pointerdown",w,{capture:!0,once:!0}),document.addEventListener("pointermove",w,{capture:!0,once:!0})},w=()=>p.current=!1;return document.addEventListener("keydown",v,{capture:!0}),()=>{document.removeEventListener("keydown",v,{capture:!0}),document.removeEventListener("pointerdown",w,{capture:!0}),document.removeEventListener("pointermove",w,{capture:!0})}},[]),b.useEffect(()=>{if(!n)return;const v=()=>y(!1);return window.addEventListener("blur",v),()=>window.removeEventListener("blur",v)},[n,y]),h.jsx(i0,{...c,children:h.jsx(E3e,{scope:t,open:n,onOpenChange:y,content:d,onContentChange:f,children:h.jsx(R3e,{scope:t,onClose:b.useCallback(()=>y(!1),[y]),isUsingKeyboardRef:p,dir:k,modal:l,children:a})})})};aC.displayName=M1;var j3e="MenuAnchor",Jk=b.forwardRef((e,t)=>{const{__scopeMenu:n,...a}=e,o=c0(n);return h.jsx(b1,{...o,...a,ref:t})});Jk.displayName=j3e;var ev="MenuPortal",[O3e,rC]=Ps(ev,{forceMount:void 0}),oC=e=>{const{__scopeMenu:t,forceMount:n,children:a,container:o}=e,s=Ls(ev,t);return h.jsx(O3e,{scope:t,forceMount:n,children:h.jsx(Gn,{present:n||s.open,children:h.jsx(rc,{asChild:!0,container:o,children:a})})})};oC.displayName=ev;var Wa="MenuContent",[N3e,tv]=Ps(Wa),iC=b.forwardRef((e,t)=>{const n=rC(Wa,e.__scopeMenu),{forceMount:a=n.forceMount,...o}=e,s=Ls(Wa,e.__scopeMenu),l=S1(Wa,e.__scopeMenu);return h.jsx(Ku.Provider,{scope:e.__scopeMenu,children:h.jsx(Gn,{present:a||s.open,children:h.jsx(Ku.Slot,{scope:e.__scopeMenu,children:l.modal?h.jsx(T3e,{...o,ref:t}):h.jsx(P3e,{...o,ref:t})})})})}),T3e=b.forwardRef((e,t)=>{const n=Ls(Wa,e.__scopeMenu),a=b.useRef(null),o=it(t,a);return b.useEffect(()=>{const s=a.current;if(s)return i1(s)},[]),h.jsx(nv,{...e,ref:o,trapFocus:n.open,disableOutsidePointerEvents:n.open,disableOutsideScroll:!0,onFocusOutside:xe(e.onFocusOutside,s=>s.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>n.onOpenChange(!1)})}),P3e=b.forwardRef((e,t)=>{const n=Ls(Wa,e.__scopeMenu);return h.jsx(nv,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>n.onOpenChange(!1)})}),L3e=Mi("MenuContent.ScrollLock"),nv=b.forwardRef((e,t)=>{const{__scopeMenu:n,loop:a=!1,trapFocus:o,onOpenAutoFocus:s,onCloseAutoFocus:l,disableOutsidePointerEvents:c,onEntryFocus:d,onEscapeKeyDown:f,onPointerDownOutside:p,onFocusOutside:y,onInteractOutside:k,onDismiss:v,disableOutsideScroll:w,...S}=e,_=Ls(Wa,n),C=S1(Wa,n),A=c0(n),j=nC(n),N=C3e(n),[I,T]=b.useState(null),q=b.useRef(null),R=it(t,q,_.onContentChange),H=b.useRef(0),D=b.useRef(""),G=b.useRef(0),$=b.useRef(null),X=b.useRef("right"),F=b.useRef(0),W=w?oc:b.Fragment,P=w?{as:L3e,allowPinchZoom:!0}:void 0,U=se=>{const L=D.current+se,B=N().filter(oe=>!oe.disabled),V=document.activeElement,O=B.find(oe=>oe.ref.current===V)?.textValue,ee=B.map(oe=>oe.textValue),Q=G3e(ee,L,O),ae=B.find(oe=>oe.textValue===Q)?.ref.current;(function oe(de){D.current=de,window.clearTimeout(H.current),de!==""&&(H.current=window.setTimeout(()=>oe(""),1e3))})(L),ae&&setTimeout(()=>ae.focus())};b.useEffect(()=>()=>window.clearTimeout(H.current),[]),_2();const J=b.useCallback(se=>X.current===$.current?.side&&W3e(se,$.current?.area),[]);return h.jsx(N3e,{scope:n,searchRef:D,onItemEnter:b.useCallback(se=>{J(se)&&se.preventDefault()},[J]),onItemLeave:b.useCallback(se=>{J(se)||(q.current?.focus(),T(null))},[J]),onTriggerLeave:b.useCallback(se=>{J(se)&&se.preventDefault()},[J]),pointerGraceTimerRef:G,onPointerGraceIntentChange:b.useCallback(se=>{$.current=se},[]),children:h.jsx(W,{...P,children:h.jsx(o1,{asChild:!0,trapped:o,onMountAutoFocus:xe(s,se=>{se.preventDefault(),q.current?.focus({preventScroll:!0})}),onUnmountAutoFocus:l,children:h.jsx(ac,{asChild:!0,disableOutsidePointerEvents:c,onEscapeKeyDown:f,onPointerDownOutside:p,onFocusOutside:y,onInteractOutside:k,onDismiss:v,children:h.jsx(x3e,{asChild:!0,...j,dir:C.dir,orientation:"vertical",loop:a,currentTabStopId:I,onCurrentTabStopIdChange:T,onEntryFocus:xe(d,se=>{C.isUsingKeyboardRef.current||se.preventDefault()}),preventScrollOnEntryFocus:!0,children:h.jsx(s0,{role:"menu","aria-orientation":"vertical","data-state":wC(_.open),"data-radix-menu-content":"",dir:C.dir,...A,...S,ref:R,style:{outline:"none",...S.style},onKeyDown:xe(S.onKeyDown,se=>{const B=se.target.closest("[data-radix-menu-content]")===se.currentTarget,V=se.ctrlKey||se.altKey||se.metaKey,O=se.key.length===1;B&&(se.key==="Tab"&&se.preventDefault(),!V&&O&&U(se.key));const ee=q.current;if(se.target!==ee||!M3e.includes(se.key))return;se.preventDefault();const ae=N().filter(oe=>!oe.disabled).map(oe=>oe.ref.current);eC.includes(se.key)&&ae.reverse(),U3e(ae)}),onBlur:xe(e.onBlur,se=>{se.currentTarget.contains(se.target)||(window.clearTimeout(H.current),D.current="")}),onPointerMove:xe(e.onPointerMove,Gu(se=>{const L=se.target,B=F.current!==se.clientX;if(se.currentTarget.contains(L)&&B){const V=se.clientX>F.current?"right":"left";X.current=V,F.current=se.clientX}}))})})})})})})});iC.displayName=Wa;var z3e="MenuGroup",av=b.forwardRef((e,t)=>{const{__scopeMenu:n,...a}=e;return h.jsx(He.div,{role:"group",...a,ref:t})});av.displayName=z3e;var D3e="MenuLabel",sC=b.forwardRef((e,t)=>{const{__scopeMenu:n,...a}=e;return h.jsx(He.div,{...a,ref:t})});sC.displayName=D3e;var i2="MenuItem",A8="menu.itemSelect",u0=b.forwardRef((e,t)=>{const{disabled:n=!1,onSelect:a,...o}=e,s=b.useRef(null),l=S1(i2,e.__scopeMenu),c=tv(i2,e.__scopeMenu),d=it(t,s),f=b.useRef(!1),p=()=>{const y=s.current;if(!n&&y){const k=new CustomEvent(A8,{bubbles:!0,cancelable:!0});y.addEventListener(A8,v=>a?.(v),{once:!0}),N7(y,k),k.defaultPrevented?f.current=!1:l.onClose()}};return h.jsx(lC,{...o,ref:d,disabled:n,onClick:xe(e.onClick,p),onPointerDown:y=>{e.onPointerDown?.(y),f.current=!0},onPointerUp:xe(e.onPointerUp,y=>{f.current||y.currentTarget?.click()}),onKeyDown:xe(e.onKeyDown,y=>{const k=c.searchRef.current!=="";n||k&&y.key===" "||Gm.includes(y.key)&&(y.currentTarget.click(),y.preventDefault())})})});u0.displayName=i2;var lC=b.forwardRef((e,t)=>{const{__scopeMenu:n,disabled:a=!1,textValue:o,...s}=e,l=tv(i2,n),c=nC(n),d=b.useRef(null),f=it(t,d),[p,y]=b.useState(!1),[k,v]=b.useState("");return b.useEffect(()=>{const w=d.current;w&&v((w.textContent??"").trim())},[s.children]),h.jsx(Ku.ItemSlot,{scope:n,disabled:a,textValue:o??k,children:h.jsx(b3e,{asChild:!0,...c,focusable:!a,children:h.jsx(He.div,{role:"menuitem","data-highlighted":p?"":void 0,"aria-disabled":a||void 0,"data-disabled":a?"":void 0,...s,ref:f,onPointerMove:xe(e.onPointerMove,Gu(w=>{a?l.onItemLeave(w):(l.onItemEnter(w),w.defaultPrevented||w.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:xe(e.onPointerLeave,Gu(w=>l.onItemLeave(w))),onFocus:xe(e.onFocus,()=>y(!0)),onBlur:xe(e.onBlur,()=>y(!1))})})})}),I3e="MenuCheckboxItem",cC=b.forwardRef((e,t)=>{const{checked:n=!1,onCheckedChange:a,...o}=e;return h.jsx(pC,{scope:e.__scopeMenu,checked:n,children:h.jsx(u0,{role:"menuitemcheckbox","aria-checked":s2(n)?"mixed":n,...o,ref:t,"data-state":ov(n),onSelect:xe(o.onSelect,()=>a?.(s2(n)?!0:!n),{checkForDefaultPrevented:!1})})})});cC.displayName=I3e;var uC="MenuRadioGroup",[q3e,H3e]=Ps(uC,{value:void 0,onValueChange:()=>{}}),dC=b.forwardRef((e,t)=>{const{value:n,onValueChange:a,...o}=e,s=Nr(a);return h.jsx(q3e,{scope:e.__scopeMenu,value:n,onValueChange:s,children:h.jsx(av,{...o,ref:t})})});dC.displayName=uC;var hC="MenuRadioItem",fC=b.forwardRef((e,t)=>{const{value:n,...a}=e,o=H3e(hC,e.__scopeMenu),s=n===o.value;return h.jsx(pC,{scope:e.__scopeMenu,checked:s,children:h.jsx(u0,{role:"menuitemradio","aria-checked":s,...a,ref:t,"data-state":ov(s),onSelect:xe(a.onSelect,()=>o.onValueChange?.(n),{checkForDefaultPrevented:!1})})})});fC.displayName=hC;var rv="MenuItemIndicator",[pC,V3e]=Ps(rv,{checked:!1}),yC=b.forwardRef((e,t)=>{const{__scopeMenu:n,forceMount:a,...o}=e,s=V3e(rv,n);return h.jsx(Gn,{present:a||s2(s.checked)||s.checked===!0,children:h.jsx(He.span,{...o,ref:t,"data-state":ov(s.checked)})})});yC.displayName=rv;var F3e="MenuSeparator",mC=b.forwardRef((e,t)=>{const{__scopeMenu:n,...a}=e;return h.jsx(He.div,{role:"separator","aria-orientation":"horizontal",...a,ref:t})});mC.displayName=F3e;var B3e="MenuArrow",gC=b.forwardRef((e,t)=>{const{__scopeMenu:n,...a}=e,o=c0(n);return h.jsx(l0,{...o,...a,ref:t})});gC.displayName=B3e;var $3e="MenuSub",[VAe,kC]=Ps($3e),Mu="MenuSubTrigger",vC=b.forwardRef((e,t)=>{const n=Ls(Mu,e.__scopeMenu),a=S1(Mu,e.__scopeMenu),o=kC(Mu,e.__scopeMenu),s=tv(Mu,e.__scopeMenu),l=b.useRef(null),{pointerGraceTimerRef:c,onPointerGraceIntentChange:d}=s,f={__scopeMenu:e.__scopeMenu},p=b.useCallback(()=>{l.current&&window.clearTimeout(l.current),l.current=null},[]);return b.useEffect(()=>p,[p]),b.useEffect(()=>{const y=c.current;return()=>{window.clearTimeout(y),d(null)}},[c,d]),h.jsx(Jk,{asChild:!0,...f,children:h.jsx(lC,{id:o.triggerId,"aria-haspopup":"menu","aria-expanded":n.open,"aria-controls":n.open?o.contentId:void 0,"data-state":wC(n.open),...e,ref:Kg(t,o.onTriggerChange),onClick:y=>{e.onClick?.(y),!(e.disabled||y.defaultPrevented)&&(y.currentTarget.focus(),n.open||n.onOpenChange(!0))},onPointerMove:xe(e.onPointerMove,Gu(y=>{s.onItemEnter(y),!y.defaultPrevented&&!e.disabled&&!n.open&&!l.current&&(s.onPointerGraceIntentChange(null),l.current=window.setTimeout(()=>{n.onOpenChange(!0),p()},100))})),onPointerLeave:xe(e.onPointerLeave,Gu(y=>{p();const k=n.content?.getBoundingClientRect();if(k){const v=n.content?.dataset.side,w=v==="right",S=w?-5:5,_=k[w?"left":"right"],C=k[w?"right":"left"];s.onPointerGraceIntentChange({area:[{x:y.clientX+S,y:y.clientY},{x:_,y:k.top},{x:C,y:k.top},{x:C,y:k.bottom},{x:_,y:k.bottom}],side:v}),window.clearTimeout(c.current),c.current=window.setTimeout(()=>s.onPointerGraceIntentChange(null),300)}else{if(s.onTriggerLeave(y),y.defaultPrevented)return;s.onPointerGraceIntentChange(null)}})),onKeyDown:xe(e.onKeyDown,y=>{const k=s.searchRef.current!=="";e.disabled||k&&y.key===" "||S3e[a.dir].includes(y.key)&&(n.onOpenChange(!0),n.content?.focus(),y.preventDefault())})})})});vC.displayName=Mu;var xC="MenuSubContent",bC=b.forwardRef((e,t)=>{const n=rC(Wa,e.__scopeMenu),{forceMount:a=n.forceMount,align:o="start",...s}=e,l=Ls(Wa,e.__scopeMenu),c=S1(Wa,e.__scopeMenu),d=kC(xC,e.__scopeMenu),f=b.useRef(null),p=it(t,f);return h.jsx(Ku.Provider,{scope:e.__scopeMenu,children:h.jsx(Gn,{present:a||l.open,children:h.jsx(Ku.Slot,{scope:e.__scopeMenu,children:h.jsx(nv,{id:d.contentId,"aria-labelledby":d.triggerId,...s,ref:p,align:o,side:c.dir==="rtl"?"left":"right",disableOutsidePointerEvents:!1,disableOutsideScroll:!1,trapFocus:!1,onOpenAutoFocus:y=>{c.isUsingKeyboardRef.current&&f.current?.focus(),y.preventDefault()},onCloseAutoFocus:y=>y.preventDefault(),onFocusOutside:xe(e.onFocusOutside,y=>{y.target!==d.trigger&&l.onOpenChange(!1)}),onEscapeKeyDown:xe(e.onEscapeKeyDown,y=>{c.onClose(),y.preventDefault()}),onKeyDown:xe(e.onKeyDown,y=>{const k=y.currentTarget.contains(y.target),v=_3e[c.dir].includes(y.key);k&&v&&(l.onOpenChange(!1),d.trigger?.focus(),y.preventDefault())})})})})})});bC.displayName=xC;function wC(e){return e?"open":"closed"}function s2(e){return e==="indeterminate"}function ov(e){return s2(e)?"indeterminate":e?"checked":"unchecked"}function U3e(e){const t=document.activeElement;for(const n of e)if(n===t||(n.focus(),document.activeElement!==t))return}function K3e(e,t){return e.map((n,a)=>e[(t+a)%e.length])}function G3e(e,t,n){const o=t.length>1&&Array.from(t).every(f=>f===t[0])?t[0]:t,s=n?e.indexOf(n):-1;let l=K3e(e,Math.max(s,0));o.length===1&&(l=l.filter(f=>f!==n));const d=l.find(f=>f.toLowerCase().startsWith(o.toLowerCase()));return d!==n?d:void 0}function Y3e(e,t){const{x:n,y:a}=e;let o=!1;for(let s=0,l=t.length-1;s<t.length;l=s++){const c=t[s],d=t[l],f=c.x,p=c.y,y=d.x,k=d.y;p>a!=k>a&&n<(y-f)*(a-p)/(k-p)+f&&(o=!o)}return o}function W3e(e,t){if(!t)return!1;const n={x:e.clientX,y:e.clientY};return Y3e(n,t)}function Gu(e){return t=>t.pointerType==="mouse"?e(t):void 0}var Z3e=aC,Q3e=Jk,X3e=oC,J3e=iC,ebe=av,tbe=sC,nbe=u0,abe=cC,rbe=dC,obe=fC,ibe=yC,sbe=mC,lbe=gC,cbe=vC,ube=bC,d0="DropdownMenu",[dbe]=dr(d0,[tC]),Yn=tC(),[hbe,MC]=dbe(d0),SC=e=>{const{__scopeDropdownMenu:t,children:n,dir:a,open:o,defaultOpen:s,onOpenChange:l,modal:c=!0}=e,d=Yn(t),f=b.useRef(null),[p,y]=fo({prop:o,defaultProp:s??!1,onChange:l,caller:d0});return h.jsx(hbe,{scope:t,triggerId:Ya(),triggerRef:f,contentId:Ya(),open:p,onOpenChange:y,onOpenToggle:b.useCallback(()=>y(k=>!k),[y]),modal:c,children:h.jsx(Z3e,{...d,open:p,onOpenChange:y,dir:a,modal:c,children:n})})};SC.displayName=d0;var _C="DropdownMenuTrigger",CC=b.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,disabled:a=!1,...o}=e,s=MC(_C,n),l=Yn(n);return h.jsx(Q3e,{asChild:!0,...l,children:h.jsx(He.button,{type:"button",id:s.triggerId,"aria-haspopup":"menu","aria-expanded":s.open,"aria-controls":s.open?s.contentId:void 0,"data-state":s.open?"open":"closed","data-disabled":a?"":void 0,disabled:a,...o,ref:Kg(t,s.triggerRef),onPointerDown:xe(e.onPointerDown,c=>{!a&&c.button===0&&c.ctrlKey===!1&&(s.onOpenToggle(),s.open||c.preventDefault())}),onKeyDown:xe(e.onKeyDown,c=>{a||(["Enter"," "].includes(c.key)&&s.onOpenToggle(),c.key==="ArrowDown"&&s.onOpenChange(!0),["Enter"," ","ArrowDown"].includes(c.key)&&c.preventDefault())})})})});CC.displayName=_C;var fbe="DropdownMenuPortal",AC=e=>{const{__scopeDropdownMenu:t,...n}=e,a=Yn(t);return h.jsx(X3e,{...a,...n})};AC.displayName=fbe;var EC="DropdownMenuContent",RC=b.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...a}=e,o=MC(EC,n),s=Yn(n),l=b.useRef(!1);return h.jsx(J3e,{id:o.contentId,"aria-labelledby":o.triggerId,...s,...a,ref:t,onCloseAutoFocus:xe(e.onCloseAutoFocus,c=>{l.current||o.triggerRef.current?.focus(),l.current=!1,c.preventDefault()}),onInteractOutside:xe(e.onInteractOutside,c=>{const d=c.detail.originalEvent,f=d.button===0&&d.ctrlKey===!0,p=d.button===2||f;(!o.modal||p)&&(l.current=!0)}),style:{...e.style,"--radix-dropdown-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-dropdown-menu-content-available-width":"var(--radix-popper-available-width)","--radix-dropdown-menu-content-available-height":"var(--radix-popper-available-height)","--radix-dropdown-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-dropdown-menu-trigger-height":"var(--radix-popper-anchor-height)"}})});RC.displayName=EC;var pbe="DropdownMenuGroup",ybe=b.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...a}=e,o=Yn(n);return h.jsx(ebe,{...o,...a,ref:t})});ybe.displayName=pbe;var mbe="DropdownMenuLabel",gbe=b.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...a}=e,o=Yn(n);return h.jsx(tbe,{...o,...a,ref:t})});gbe.displayName=mbe;var kbe="DropdownMenuItem",jC=b.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...a}=e,o=Yn(n);return h.jsx(nbe,{...o,...a,ref:t})});jC.displayName=kbe;var vbe="DropdownMenuCheckboxItem",xbe=b.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...a}=e,o=Yn(n);return h.jsx(abe,{...o,...a,ref:t})});xbe.displayName=vbe;var bbe="DropdownMenuRadioGroup",wbe=b.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...a}=e,o=Yn(n);return h.jsx(rbe,{...o,...a,ref:t})});wbe.displayName=bbe;var Mbe="DropdownMenuRadioItem",Sbe=b.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...a}=e,o=Yn(n);return h.jsx(obe,{...o,...a,ref:t})});Sbe.displayName=Mbe;var _be="DropdownMenuItemIndicator",Cbe=b.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...a}=e,o=Yn(n);return h.jsx(ibe,{...o,...a,ref:t})});Cbe.displayName=_be;var Abe="DropdownMenuSeparator",OC=b.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...a}=e,o=Yn(n);return h.jsx(sbe,{...o,...a,ref:t})});OC.displayName=Abe;var Ebe="DropdownMenuArrow",Rbe=b.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...a}=e,o=Yn(n);return h.jsx(lbe,{...o,...a,ref:t})});Rbe.displayName=Ebe;var jbe="DropdownMenuSubTrigger",Obe=b.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...a}=e,o=Yn(n);return h.jsx(cbe,{...o,...a,ref:t})});Obe.displayName=jbe;var Nbe="DropdownMenuSubContent",Tbe=b.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...a}=e,o=Yn(n);return h.jsx(ube,{...o,...a,ref:t,style:{...e.style,"--radix-dropdown-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-dropdown-menu-content-available-width":"var(--radix-popper-available-width)","--radix-dropdown-menu-content-available-height":"var(--radix-popper-available-height)","--radix-dropdown-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-dropdown-menu-trigger-height":"var(--radix-popper-anchor-height)"}})});Tbe.displayName=Nbe;var Pbe=SC,Lbe=CC,zbe=AC,NC=RC,TC=jC,PC=OC;const Dbe=Pbe,Ibe=Lbe,LC=b.forwardRef(({className:e,sideOffset:t=4,...n},a)=>h.jsx(zbe,{children:h.jsx(NC,{ref:a,sideOffset:t,className:ye("z-50 min-w-[8rem] overflow-hidden rounded-md border border-border bg-popover p-1 text-popover-foreground ","data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",e),...n})}));LC.displayName=NC.displayName;const Ym=b.forwardRef(({className:e,inset:t,...n},a)=>h.jsx(TC,{ref:a,className:ye("relative flex cursor-default select-none items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&>svg]:size-4 [&>svg]:shrink-0",t&&"pl-8",e),...n}));Ym.displayName=TC.displayName;const zC=b.forwardRef(({className:e,...t},n)=>h.jsx(PC,{ref:n,className:ye("-mx-1 my-1 h-px bg-border",e),...t}));zC.displayName=PC.displayName;function FAe(){return st({queryKey:["automation-catalog"],queryFn:async()=>(await Kn("manage_catalog",{action:"list_catalog",kinds:["automations"]})).catalogs?.automations?.entries??[],staleTime:6e4})}function DC(e,t,n){return st({queryKey:["automations-list",e,t,!0],queryFn:async()=>(await Kn("manage_automations",{action:"list",entity_id:t,status:"active",include_details:!0})).automations||[],enabled:!!e,staleTime:3e4})}function BAe(e,t){return st({queryKey:["automations-list","agent",e,t?.includeDetails??!0],queryFn:async()=>(await Kn("manage_automations",{action:"list",managed_agent_id:e,status:"active",include_details:t?.includeDetails??!0})).automations||[],enabled:!!e,staleTime:3e4})}function $Ae(e,t,n,a={}){return st({queryKey:["automation-detail",e,t,a.since,a.until,a.templateVersion,a.includeVersions??!1],queryFn:async()=>await Kn("get_automation",{automation_id:e,entity_id:t,content_since:a.since,content_until:a.until,template_version:a.templateVersion,page_size:100,include_classification:"summary",include_versions:a.includeVersions??!1},void 0,{timeoutMs:3e4}),enabled:!!e&&!!n,staleTime:3e4})}const UAe=We({tool:"manage_automations",body:e=>({action:"update",...e}),invalidateKeys:["automations-list","automation-detail","automations"],checkError:!1,successMessage:"Automation updated",errorMessage:"Failed to update Automation"}),KAe=We({tool:"manage_automations",body:e=>({action:"delete",automation_ids:[e]}),invalidateKeys:["automations-list","automation-detail","automations","agent-threads"],checkError:!1,successMessage:"Automation deleted",errorMessage:"Failed to delete Automation"}),GAe=We({tool:"manage_automations",body:e=>({action:"create",...e}),invalidateKeys:["automations-list","automations"],successMessage:"Automation created",errorMessage:"Failed to create Automation"});function YAe(){const e=sn();return Qa({mutationFn:async t=>Kn("manage_automations",{action:"create_version",...t}),onSuccess:()=>{e.invalidateQueries({queryKey:["automations-list"]}),e.invalidateQueries({queryKey:["automation-detail"]}),e.invalidateQueries({queryKey:["automations"]})}})}function WAe(){const e=sn();return Qa({mutationFn:async t=>Kn("manage_automations",{action:"set_reaction_script",...t}),onSuccess:()=>{e.invalidateQueries({queryKey:["automations-list"]}),e.invalidateQueries({queryKey:["automation-detail"]}),e.invalidateQueries({queryKey:["automations"]})}})}const qbe=200;function ZAe(e,t){return st({queryKey:["automation-promoted",t,e],enabled:!!e&&!!t,queryFn:async()=>(await Kn("manage_automations",{action:"list_promoted",automation_id:e,limit:qbe+1})).entities??[],staleTime:3e4})}function IC(e){const t=(e??"").replace(/^\/+|\/+$/g,"");if(!t)return{isEntityDetail:!1};const n=t.split("/");return{typeSegment:n[0],path:t,isEntityDetail:n.length>1}}function QAe(e,t,n){return{to:"/$owner/events",params:{owner:e},search:Dt({...t,...n})}}function qC(e,t){return{to:"/$owner/$entityType",params:{owner:e,entityType:t},search:{create:void 0}}}function XAe(e,t){return SM(e,t)}function HC(e){const t=typeof e.entity=="string"&&e.entity.trim()?e.entity.trim():void 0;return t?uz(t):void 0}function Hbe(e){return e.create===!0||e.create==="true"?"true":void 0}function JAe(e){const t=e.connection_ids;return typeof t=="number"?String(t):typeof t=="string"&&t.trim()?t.trim():void 0}function Vbe(e){const t=e.agent??e.agent_id;return typeof t=="string"&&t.trim()?t.trim():void 0}function eEe(e){return Vbe(e)}function Fbe(e){const t=e.automation;return typeof t=="number"?String(t):typeof t=="string"&&t.trim()?t.trim():void 0}function tEe(e){return Fbe(e)}function Bbe(e){const t=e.schedule;return typeof t=="string"&&t.trim()?t.trim():void 0}function nEe(e){return Bbe(e)}function aEe(e,t,n){return{to:"/$owner/events",params:{owner:e},search:Dt({feed_ids:String(t),connection_ids:n?.connectionScope,agent:void 0,automation:void 0,schedule:void 0,platforms:void 0,run_ids:void 0,at:void 0})}}function rEe(e,t){return{to:"/$owner/events",params:{owner:e},search:Dt({connection_ids:String(t),feed_ids:void 0,agent:void 0,automation:void 0,at:void 0})}}function $be(e){const t=HC(e),n=typeof e.type=="string"&&e.type.trim()?ks(e.type.trim()):void 0,a=Hbe(e),o=uc(e);return t?{...Dt({entity:t,create:a}),...o}:n?{...Dt({type:n,create:a}),...o}:{...Dt({create:a}),...o}}function Ube(e){const t=$be(e),n=typeof e.type=="string"&&e.type.trim()?e.type.trim():void 0,a=typeof e.entity=="string"&&e.entity.trim()?e.entity.trim():void 0;return a&&t.entity&&a!==t.entity||n&&t.type&&n!==t.type||a&&n?t:null}function oEe(e,t){if(t.size===0)return;let n;const a=new Set;for(const o of e)for(const s of o.connections){const l=String(s.id);if(t.has(l)){if(n&&n!==o.connector_key)return;n=o.connector_key,a.add(l)}}return a.size===t.size?n:void 0}function Kbe(e){return qC(e,"$member")}function iEe(e){return{to:"/$owner/memory",params:{owner:e},search:Dt({create_type:"true"})}}const Lt=b.forwardRef(({className:e,type:t,...n},a)=>h.jsx("input",{type:t,className:ye("flex h-9 w-full rounded-md border border-input bg-muted px-3 py-1 text-base transition-colors file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",e),ref:a,...n}));Lt.displayName="Input";var Gbe="Label",VC=b.forwardRef((e,t)=>h.jsx(He.label,{...e,ref:t,onMouseDown:n=>{n.target.closest("button, input, select, textarea")||(e.onMouseDown?.(n),!n.defaultPrevented&&n.detail>1&&n.preventDefault())}}));VC.displayName=Gbe;var FC=VC;const ha=b.forwardRef(({className:e,...t},n)=>h.jsx(FC,{ref:n,className:ye("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70",e),...t}));ha.displayName=FC.displayName;function Ybe(e,t){b.useEffect(()=>{function n(a){e.current&&!e.current.contains(a.target)&&t()}return document.addEventListener("mousedown",n),()=>document.removeEventListener("mousedown",n)},[e,t])}function Wbe(e){const t=e.urlOrgSlug?e.organizations.find(o=>o.slug===e.urlOrgSlug):null;if(e.isAuthenticated){if(e.urlOrgSlug){const s=t?.name||e.urlOrgSlug;return{displayName:s,displayLogo:t?.logo||void 0,displayInitial:s[0]||"W",activeSlug:e.urlOrgSlug}}return{displayName:e.activeOrg?.name||e.sessionUser?.name||"Personal",displayLogo:e.activeOrg?.logo||e.sessionUser?.image||void 0,displayInitial:e.activeOrg?.name?.[0]||e.sessionUser?.name?.[0]||e.sessionUser?.email?.[0]||"P",activeSlug:e.activeOrg?.slug||null}}const n=e.urlOrgSlug?t:e.organizations[0],a=n?.name||e.urlOrgSlug||"Select Organization";return{displayName:a,displayLogo:n?.logo||void 0,displayInitial:a[0]||"W",activeSlug:e.urlOrgSlug||n?.slug||null}}function Zbe(e){return e.urlOrgSlug?e.organization.slug===e.urlOrgSlug:e.organization.id===e.activeOrg?.id||e.organization.slug===e.activeOrg?.slug}function E8(e){return e.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")}function Qbe({organization:e,isActive:t,onSelect:n,manageable:a,onManageNavigate:o,isPublic:s}){const l=e.name[0]?.toUpperCase()||"W";return h.jsxs(On,{onSelect:n,value:e.name,className:"group flex w-full cursor-pointer items-center gap-2 px-3 py-2 pr-1 text-sm",children:[h.jsx("div",{className:"h-6 w-6 shrink-0 overflow-hidden rounded bg-muted flex items-center justify-center",children:e.logo?h.jsx("img",{src:e.logo,alt:"",className:"h-full w-full object-cover",referrerPolicy:"no-referrer"}):h.jsx("span",{className:"text-xs font-medium",children:l})}),h.jsx("span",{className:"flex-1 truncate text-left",children:e.name}),s?h.jsx(GM,{className:"h-3.5 w-3.5 shrink-0 text-muted-foreground","aria-label":"Public organization"}):null,a?h.jsx(ge,{asChild:!0,variant:"ghost",size:"icon",className:"h-7 w-7 shrink-0 opacity-0 transition-opacity group-hover:opacity-100 focus-visible:opacity-100","aria-label":`Settings for ${e.name}`,children:h.jsx(Ct,{to:"/$owner/settings/organization",params:{owner:e.slug},onMouseDown:c=>{c.stopPropagation()},onClick:c=>{c.stopPropagation(),o?.()},children:h.jsx(S2,{className:"h-4 w-4"})})}):null,t&&h.jsx(Za,{className:"h-4 w-4 shrink-0 text-primary"})]})}function BC({iconOnly:e=!1}){const[t,n]=b.useState(!1),[a,o]=b.useState(!1),[s,l]=b.useState(""),[c,d]=b.useState(""),[f,p]=b.useState(!1),[y,k]=b.useState(null),[v,w]=b.useState(!1),S=b.useRef(null),_=qn(),{data:C}=mk(),A=U9(),j=C??(A?[A]:[]),{session:N,urlOrgSlug:I,activeOrg:T}=er(),q=!!N,R=b.useMemo(()=>{const P=j.filter(J=>J.is_member),U=j.filter(J=>!J.is_member);return[...P,...U]},[j]),H=b.useCallback(()=>n(!1),[]);Ybe(S,H);const D=P=>{const U=EM(P);if(U.kind==="cross-host"){window.location.assign(U.href);return}_({to:U.to})},G=async(P,U,J=!0)=>{N&&J&&P?(await Au.setActive({organizationId:P}),U?D(U):_({to:"/"})):U&&D(U),n(!1)},$=async()=>{if(k(null),!s.trim()){k("Name is required");return}w(!0);try{const P=c.trim()||E8(s),U=await Au.create({name:s.trim(),slug:P});U.error?k(U.error.message||"Failed to create organization"):(o(!1),l(""),d(""),p(!1),U.data&&(await Au.setActive({organizationId:U.data.id}),D(U.data.slug)))}catch(P){k(P instanceof Error?P.message:"An error occurred")}finally{w(!1)}},{displayName:X,displayLogo:F,displayInitial:W}=Wbe({isAuthenticated:q,urlOrgSlug:I,activeOrg:T,sessionUser:N?.user,organizations:j});return h.jsxs("div",{className:ye("relative min-w-0",e?"shrink-0":"flex-1"),ref:S,children:[h.jsxs("button",{type:"button",onClick:()=>n(!t),"aria-label":X?`Switch workspace (${X})`:"Switch workspace",title:e?X??"Switch workspace":void 0,className:ye("flex cursor-pointer items-center gap-2 rounded-lg px-2 py-1 transition-colors hover:bg-sidebar-accent/60",e?"h-9 w-9 justify-center p-0":"w-full"),children:[h.jsx("div",{className:"h-7 w-7 shrink-0 overflow-hidden rounded-lg bg-sidebar-foreground/10 flex items-center justify-center",children:F?h.jsx("img",{src:F,alt:"",className:"h-full w-full object-cover",referrerPolicy:"no-referrer"}):h.jsx("span",{className:"text-sidebar-foreground text-sm font-semibold",children:W.toUpperCase()})}),e?null:h.jsx("span",{className:"flex-1 truncate text-left font-semibold",children:X}),e?null:h.jsx(n1,{className:`h-4 w-4 shrink-0 transition-transform ${t?"rotate-180":""}`})]}),t&&h.jsx("div",{className:"absolute left-0 right-0 top-full z-50 mt-1 min-w-[240px] overflow-hidden rounded-lg border border-border bg-popover ",children:h.jsxs(l1,{className:"bg-transparent",children:[h.jsx(L2,{placeholder:"Search organizations...",className:"h-9"}),h.jsxs(z2,{className:"max-h-[300px]",children:[h.jsx(D2,{children:"No organizations found."}),q?h.jsx(Ka,{heading:"Organizations",children:R.map(P=>h.jsx(Qbe,{organization:P,isActive:Zbe({organization:P,urlOrgSlug:I,activeOrg:T}),onSelect:()=>G(P.id,P.slug,P.is_member),manageable:P.is_member,isPublic:!P.is_member,onManageNavigate:()=>n(!1)},P.id))}):null]}),h.jsx("div",{className:"border-t border-border",children:q?h.jsx(Ka,{children:h.jsxs(On,{onSelect:()=>{n(!1),o(!0)},className:"cursor-pointer text-muted-foreground",children:[h.jsx(la,{className:"mr-2 h-4 w-4"}),h.jsx("span",{children:"Create Organization"})]})}):h.jsx(Ka,{children:h.jsxs(On,{onSelect:()=>{n(!1),_({to:"/auth/login",search:kk()})},className:"cursor-pointer text-muted-foreground",children:[h.jsx(la,{className:"mr-2 h-4 w-4"}),h.jsx("span",{children:"Sign in to create organization"})]})})})]})}),h.jsx(sk,{open:a,onOpenChange:P=>{P||(o(!1),k(null))},children:h.jsxs(P2,{className:"sm:max-w-md",children:[h.jsxs(lk,{children:[h.jsx(ck,{children:"Create Organization"}),h.jsx(uk,{children:"Create a new organization to collaborate with others."})]}),h.jsxs("div",{className:"space-y-4 py-2",children:[h.jsxs("div",{className:"space-y-1.5",children:[h.jsx(ha,{htmlFor:"org-name",children:"Name"}),h.jsx(Lt,{id:"org-name",value:s,onChange:P=>{l(P.target.value),f||d(E8(P.target.value))},placeholder:"e.g. My Team"})]}),h.jsxs("div",{className:"space-y-1.5",children:[h.jsx(ha,{htmlFor:"org-slug",children:"Slug"}),h.jsx(Lt,{id:"org-slug",value:c,onChange:P=>{p(!0),d(P.target.value)},placeholder:"e.g. my-team"})]}),y&&h.jsx("div",{className:"rounded-md bg-destructive/10 px-3 py-2 text-sm text-destructive",children:y})]}),h.jsxs("div",{className:"flex justify-end gap-2",children:[h.jsx(ge,{variant:"outline",onClick:()=>o(!1),disabled:v,children:"Cancel"}),h.jsx(ge,{onClick:$,disabled:v,children:v?"Creating...":"Create"})]})]})})]})}const Xbe="/$owner/chat/$agentId/c/$threadId";function Jbe(e,t,n){return{to:Xbe,params:{owner:e,agentId:t,threadId:n}}}function e6e(e,t){throw ca({to:"/$owner/agents/$agentId/settings",params:{owner:e,agentId:t},search:{run_id:void 0},replace:!0})}function t6e(e){const{session:t,isReady:n}=Xa(),a=n?t?.user.id:void 0,o=e?.limit??20,l=(e?.clientIds??[]).join(","),c=e?.activityKind??null,d=e?.excludeCommandClients??!1,f=e?.refetchInterval;return st({queryKey:["client-activity-scopes",a,o,l,c,d],queryFn:async()=>{const p=new URLSearchParams({limit:String(o)});l&&p.set("client_ids",l),c&&p.set("activity_kind",c),d&&p.set("exclude_command_clients","true");const y=await Ge(`${pt}/api/me/clients/activity-scopes?${p}`,{credentials:"include"});return await Un(y,"Failed to load client activity"),(await y.json()).scopes??[]},enabled:!!a&&(e?.enabled??!0),staleTime:15e3,refetchInterval:typeof f=="function"?p=>f((p.state.data?.length??0)>0):f})}const R8=12,n6e=5e3;function a6e(e){const t=e.title?.trim();if(t)return t;if(e.activityKind==="session")return"MCP session";const n=e.clientName?.trim();return n||e.clientId}function r6e(e){const t=e.title?.trim(),n=e.lastAction?.trim();return[`${e.callCount} ${e.callCount===1?"call":"calls"}`,n&&n!==t?n:null].filter(Boolean).join(" · ")}function j8(e){const t=typeof e.callCount=="number"?`${e.callCount} ${e.callCount===1?"call":"calls"}`:null,n=e.lastAction?.trim();return[e.isRunning?"Running":null,t,n?W9(n).replace(/\b(Sql|Api|Mcp|Url|Id)\b/g,o=>o.toUpperCase()):null,e.locationLabel?.trim()].filter(Boolean).join(" · ")||void 0}function o6e(e){switch(e){case"slack":return s7;case"telegram":return o7;case"whatsapp":case"discord":return XM;default:return Bg}}function Ky(e,t){let n=0;for(const a of e){if(t.kind==="automation"){a.automation_id===t.automationId&&(n+=1);continue}if(a.href){if(t.kind==="mcp"){try{const o=new URL(a.href,"http://localhost");(o.searchParams.get("client_ids")??"").split(",").filter(Boolean).includes(t.clientId)&&o.searchParams.get("mcp_activity_id")===t.activityId&&(n+=1)}catch{}continue}try{const{pathname:o}=new URL(a.href,"http://localhost"),s=`/${t.owner}/chat/${t.agentId}`;(o===s||o.startsWith(`${s}/`))&&(n+=1)}catch{}}}return n}function Gy({count:e}){return e===0?null:h.jsx("span",{role:"img",title:"Needs attention","aria-label":`${e} item${e===1?"":"s"} need attention`,className:"shrink-0 rounded-full bg-blue-500/15 px-1.5 py-0.5 text-[10px] font-semibold text-blue-600 dark:text-blue-400",children:e})}function ph({to:e,params:t,search:n,active:a,icon:o,leading:s,label:l,detail:c,lastActivityAt:d,trailing:f,tone:p}){const y=[c?.trim(),k1(d)].filter(Boolean).join(" · "),k=p==="page"?"text-muted-foreground":"text-sidebar-foreground/50";return h.jsxs(Ct,{to:e,params:t,search:n,"aria-label":l,"data-recent-row":"",className:ye("block rounded-md px-3 py-2 text-sm transition-colors",p==="sidebar"&&"mx-2",a?p==="page"?"bg-accent text-accent-foreground":"bg-sidebar-accent text-sidebar-accent-foreground":p==="page"?"text-foreground hover:bg-accent/60":"text-sidebar-foreground/80 hover:bg-sidebar-accent/60 hover:text-sidebar-foreground"),children:[h.jsxs("span",{className:"flex items-center gap-1.5",children:[h.jsx("span",{className:"min-w-0 flex-1 truncate",children:l}),f]}),h.jsxs("span",{className:ye("mt-0.5 flex min-w-0 items-center gap-1.5 text-xs",k),children:[h.jsx("span",{className:"flex h-3.5 w-3.5 shrink-0 items-center justify-center",children:s??(o?h.jsx(o,{className:"h-3.5 w-3.5"}):null)}),h.jsx("span",{className:"truncate",children:y})]})]})}function i6e(e){const{data:t}=vo(),n=t??[],a=b.useMemo(()=>n.map(f=>f.agentId),[n]),{threads:o}=x0e(e,a,{enabled:!!e&&a.length>0,limit:R8}),{data:s=[]}=t6e({limit:R8,excludeCommandClients:!0,refetchInterval:f=>f?n6e:!1}),{orgContext:l}=er(),{data:c}=DC(l?.organizationId,void 0),d=b.useMemo(()=>new Set((c??[]).map(f=>String(f.automation_id))),[c]);return b.useMemo(()=>[...(c===void 0?o:o.filter(p=>p.platform!=="automation"||p.automationId==null?!0:d.has(String(p.automationId)))).map(p=>({kind:"conversation",at:p.updatedAt,thread:p})),...s.map(p=>({kind:"mcp",at:p.lastCallAt,conversation:p}))].sort((p,y)=>y.at-p.at),[d,c,s,o])}function s6e({owner:e,tone:t="sidebar",empty:n="hide"}){const{agentId:a=null,threadId:o=null,conversationId:s=null,automationId:l=null}=e1({strict:!1}),{attentionCards:c}=v1(e),d=i6e(e);return d.length===0?n==="hide"?null:h.jsx(v1e,{icon:Vu,title:"Nothing recent",description:"Chats, connected apps, and Automations you use will show up here."}):h.jsxs("div",{className:ye(t==="page"&&"flex flex-col gap-0.5"),children:[t==="sidebar"?h.jsx("div",{className:"px-3 pb-1 pt-3 text-[11px] font-semibold uppercase tracking-wider text-sidebar-foreground/40",children:"Recent"}):null,d.map(f=>{if(f.kind==="mcp")return h.jsx(ph,{to:"/$owner/events",params:{owner:"me"},search:{client_ids:f.conversation.clientId,mcp_activity_id:f.conversation.activityId},active:!1,leading:h.jsx(l_,{name:f.conversation.clientName}),label:a6e(f.conversation),detail:r6e(f.conversation),lastActivityAt:f.at,tone:t,trailing:h.jsx(Gy,{count:Ky(c,{kind:"mcp",clientId:f.conversation.clientId,activityId:f.conversation.activityId})})},`mcp:${f.conversation.clientId}:${f.conversation.activityId}`);const p=f.thread,y=p.title,k=(p.platform??"web")==="web";if(p.platform==="automation"&&p.automationId!=null)return h.jsx(ph,{to:"/$owner/automations/$automationId",params:{owner:e,automationId:String(p.automationId)},active:l===String(p.automationId),leading:h.jsx(Vg,{className:"h-3.5 w-3.5"}),label:y,detail:"Automation",lastActivityAt:p.updatedAt,tone:t,trailing:h.jsx(Gy,{count:Ky(c,{kind:"automation",automationId:p.automationId})})},`automation:workspace:${p.automationId}`);if(!k)return h.jsx(ph,{to:"/$owner/agents/$agentId/conversations/$conversationId",params:{owner:e,agentId:p.agentId,conversationId:p.conversationId??p.id},active:a===p.agentId&&s===(p.conversationId??p.id),icon:o6e(p.platform),label:y,detail:j8(p),lastActivityAt:p.updatedAt,tone:t},`conversation:${p.agentId}:${p.id}`);const v=Jbe(e,p.agentId,p.id);return h.jsx(ph,{to:v.to,params:v.params,active:a===p.agentId&&o===p.id,icon:Bg,label:y,detail:j8(p),lastActivityAt:p.updatedAt,tone:t,trailing:h.jsx(Gy,{count:Ky(c,{kind:"agent",owner:e,agentId:p.agentId})})},`chat:${p.agentId}:${p.id}`)})]})}function Wm(){document.dispatchEvent(new KeyboardEvent("keydown",{key:"k",metaKey:!0,bubbles:!0}))}function Yu({to:e,params:t,search:n,active:a,icon:o,leading:s,label:l,trailing:c}){const d=h.jsxs(h.Fragment,{children:[h.jsx("span",{className:"flex h-3.5 w-3.5 shrink-0 items-center justify-center text-sidebar-foreground/60",children:s??(o?h.jsx(o,{className:"h-3.5 w-3.5"}):null)}),h.jsx("span",{className:"min-w-0 flex-1 truncate",children:l}),c]}),f=ye("mx-2 flex items-center gap-2 rounded-md py-1.5 pl-3 pr-3 text-sm transition-colors",a?"bg-sidebar-accent text-sidebar-accent-foreground":e?"text-sidebar-foreground/80 hover:bg-sidebar-accent/60 hover:text-sidebar-foreground":"text-sidebar-foreground/80");return e?h.jsx(Ct,{to:e,params:t,search:n,title:l,className:f,children:d}):h.jsx("div",{className:f,children:d})}function l6e(e){const[t,n]=b.useState(null),[a,o]=b.useState(e);return e!==a&&(o(e),n(null)),{open:t??e,setOpen:n}}function c6e({open:e}){return h.jsx("span",{className:"flex h-5 w-5 shrink-0 items-center justify-center rounded-md text-sidebar-foreground/40 transition-colors hover:bg-sidebar-accent/60 hover:text-sidebar-foreground",children:h.jsx(da,{className:ye("h-3.5 w-3.5 transition-transform",e?"rotate-90":"rotate-0")})})}function u6e({count:e}){return h.jsx("span",{className:"shrink-0 text-[11px] tabular-nums text-sidebar-foreground/40",children:e})}function h0({count:e,title:t}){return h.jsx("span",{"aria-hidden":"true",title:t,className:"shrink-0 text-[11px] tabular-nums text-sidebar-foreground/40",children:e.toLocaleString()})}function d6e(){return h.jsx("span",{title:"Derived view",className:"shrink-0 text-[11px] lowercase text-sidebar-foreground/40",children:"derived"})}function h6e({ownerSlug:e,active:t,searchRecord:n,entityTypeParam:a}){const o=zn.context,{open:s,setOpen:l}=l6e(t),{orgContext:c}=er(),{data:d}=G9(c),f=b.useMemo(()=>(d??[]).filter(v=>!v.organization_slug||v.organization_slug===e),[d,e]),p=d?f.reduce((v,w)=>v+(w.backing_sql?0:w.entity_count??0),0):void 0,y=a?ks(a):typeof n.type=="string"?n.type:typeof n.entity=="string"?n.entity.split("/")[0]:void 0,k=t&&!(s&&y);return h.jsxs(J2,{open:s,onOpenChange:l,children:[h.jsxs("div",{className:ye("mx-2 flex items-center gap-2 rounded-md py-1.5 pl-3 pr-2 text-sm transition-colors",k?"bg-sidebar-accent text-sidebar-accent-foreground":"text-sidebar-foreground/80 hover:bg-sidebar-accent/60 hover:text-sidebar-foreground"),children:[h.jsxs(Ct,{to:o.to,params:{owner:e},search:o.search,className:"flex min-w-0 flex-1 items-center gap-2",children:[h.jsx("span",{className:"flex h-3.5 w-3.5 shrink-0 items-center justify-center text-sidebar-foreground/60",children:h.jsx(o.icon,{className:"h-3.5 w-3.5"})}),h.jsx("span",{className:ye("min-w-0 flex-1 truncate",s&&!k&&"text-sidebar-foreground/50"),children:o.label})]}),p!=null?h.jsx(h0,{count:p,title:`${p} records`}):null,f.length>0?h.jsx(e0,{asChild:!0,children:h.jsx("button",{type:"button","aria-label":s?"Collapse entity types":"Expand entity types",title:s?"Collapse entity types":"Expand entity types",className:"shrink-0",children:h.jsx(c6e,{open:s})})}):null]}),h.jsx(t0,{children:f.map(v=>{const w=qC(e,v.slug);return h.jsx(Yu,{to:w.to,params:w.params,search:w.search,active:y===v.slug,leading:h.jsx(tk,{icon:v.icon,className:"h-3.5 w-3.5"}),label:v.name||v.slug,trailing:v.backing_sql?h.jsx(d6e,{}):h.jsx(u6e,{count:v.entity_count??0})},v.slug)})})]})}function f6e(e){return e.trim().charAt(0).toUpperCase()||"?"}function p6e({name:e,status:t}){return h.jsxs("span",{"aria-hidden":"true","data-agent-avatar":e,className:"relative flex h-[18px] w-[18px] shrink-0 items-center justify-center rounded-full bg-sidebar-accent text-[9px] font-semibold text-sidebar-accent-foreground",children:[f6e(e),t?h.jsx("span",{className:ye("absolute -bottom-0.5 -right-0.5 h-[7px] w-[7px] rounded-full border-[1.5px] border-sidebar-background",t==="active"?"bg-emerald-500":"bg-sidebar-foreground/30")}):null]})}function y6e({ownerSlug:e,active:t,currentAgent:n,count:a}){const o=zn.agents,s=t&&!n;return h.jsxs("div",{children:[h.jsx(Yu,{to:o.to,params:{owner:e},search:o.search,active:s,icon:o.icon,label:o.label,trailing:a!=null?h.jsx(h0,{count:a,title:`${a} agents`}):void 0}),n?h.jsxs(Ct,{to:"/$owner/agents/$agentId/settings",params:{owner:e,agentId:n.agentId},search:{run_id:void 0},className:"mx-2 flex items-center gap-2 rounded-md py-1.5 pl-3 pr-3 text-sm transition-colors bg-sidebar-accent text-sidebar-accent-foreground",children:[h.jsx(p6e,{name:n.name,status:n.status}),h.jsx("span",{className:"min-w-0 flex-1 truncate",children:n.name}),n.status==="active"?h.jsx("span",{className:"shrink-0 text-[10px] text-sidebar-foreground/40",children:"working"}):null]}):null]})}function m6e({ownerSlug:e,active:t,currentAutomation:n,count:a}){const o=zn.automations,s=t&&!n;return h.jsxs("div",{children:[h.jsx(Yu,{to:o.to,params:{owner:e},search:o.search,active:s,icon:o.icon,label:o.label,trailing:a!=null?h.jsx(h0,{count:a,title:`${a} Automations`}):void 0}),n?h.jsxs(Ct,{to:"/$owner/automations/$automationId",params:{owner:e,automationId:n.automationId},search:{view:"activity",run_id:void 0},className:"mx-2 flex items-center gap-2 rounded-md py-1.5 pl-3 pr-3 text-sm transition-colors bg-sidebar-accent text-sidebar-accent-foreground",children:[h.jsx("span",{className:"flex h-3.5 w-3.5 shrink-0 items-center justify-center text-sidebar-foreground/60",children:h.jsx(Vg,{className:"h-3.5 w-3.5"})}),h.jsx("span",{className:"min-w-0 flex-1 truncate",children:n.name})]}):null]})}function g6e(){const e=qn(),{session:t}=Xa(),n=t?.user?.name?.trim()||"You";return h.jsx("div",{className:"border-t border-sidebar-border p-2",children:h.jsxs(Dbe,{children:[h.jsx(Ibe,{asChild:!0,children:h.jsxs("button",{type:"button",className:"flex w-full items-center gap-2 rounded-md px-3 py-1.5 text-sm text-sidebar-foreground/80 transition-colors hover:bg-sidebar-accent/60 hover:text-sidebar-foreground",children:[h.jsx(Ig,{className:"h-4 w-4 shrink-0 text-sidebar-foreground/60"}),h.jsx("span",{className:"min-w-0 flex-1 truncate text-left",children:n}),h.jsx(n1,{className:"h-4 w-4 shrink-0 text-sidebar-foreground/40"})]})}),h.jsxs(LC,{align:"start",side:"top",className:"min-w-[12rem]",children:[h.jsxs(Ym,{onSelect:()=>void e({to:"/account/settings"}),children:[h.jsx(S2,{className:"h-4 w-4"}),h.jsx("span",{children:"Account settings"})]}),h.jsx(zC,{}),h.jsxs(Ym,{className:"text-destructive",onSelect:()=>{(async()=>(await cM(),window.location.href="/"))()},children:[h.jsx(Fg,{className:"h-4 w-4"}),h.jsx("span",{children:"Sign out"})]})]})]})})}function yh({label:e,active:t=!1,icon:n,onClick:a,to:o,params:s,search:l}){const c=ye("mx-auto flex h-9 w-9 items-center justify-center rounded-md transition-colors",t?"bg-sidebar-accent text-sidebar-accent-foreground":"text-sidebar-foreground/70 hover:bg-sidebar-accent/60 hover:text-sidebar-foreground");return o?h.jsx(Ct,{to:o,params:s,search:l,"aria-label":e,title:e,className:c,children:h.jsx(n,{className:"h-5 w-5"})}):h.jsx("button",{type:"button",onClick:a,"aria-label":e,title:e,className:c,children:h.jsx(n,{className:"h-5 w-5"})})}function k6e({to:e,params:t,search:n,active:a,label:o,icon:s}){return h.jsxs(Ct,{to:e,params:t,search:n,"aria-label":o,title:o,className:ye("flex h-9 items-center justify-center gap-1.5 rounded-md text-sm transition-colors",a?"bg-sidebar-accent px-2.5 text-sidebar-accent-foreground":"w-9 shrink-0 text-sidebar-foreground/70 hover:bg-sidebar-accent/60 hover:text-sidebar-foreground"),children:[h.jsx(s,{className:"h-5 w-5 shrink-0"}),a?h.jsx("span",{className:"whitespace-nowrap font-medium",children:o}):null]})}function v6e(){const{currentOwner:e}=er(),{pathname:t}=t1(),n=e&&!e.startsWith("@")?e:null;return h.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-1",children:[h.jsx(BC,{iconOnly:!0}),n?h.jsx("div",{className:"flex min-w-0 flex-1 items-center overflow-x-auto",children:h.jsx("div",{className:"mx-auto flex shrink-0 items-center gap-0.5",children:Object.keys(zn).map(a=>{const o=zn[a];return h.jsx(k6e,{to:o.to,params:{owner:n},search:o.search,active:jm(a,n,t),label:o.label,icon:o.icon},a)})})}):h.jsx("div",{className:"flex-1"}),n?h.jsx("button",{type:"button",onClick:Wm,"aria-label":"Search",title:"Search (⌘K)",className:"flex h-9 w-9 shrink-0 items-center justify-center rounded-md text-sidebar-foreground/70 transition-colors hover:bg-sidebar-accent/60 hover:text-sidebar-foreground",children:h.jsx(_m,{className:"h-5 w-5"})}):null]})}function x6e({embedded:e=!1,collapsed:t=!1,onToggleCollapsed:n}){const{agentId:a=null,automationId:o=null,entityType:s=null}=e1({strict:!1}),{pathname:l,search:c}=t1(),{available:d,isOpen:f,open:p}=O6e(),y=c??{},{currentOwner:k,orgContext:v,allOrgs:w}=er(),S=k&&!k.startsWith("@")?k:null,_=!!S&&w.some(U=>U.slug===S),{data:C}=vo(),A=C??[],{data:j}=f1(_?`/${S}`:"",v),N=j?.counts,I=N?N.agents+N.clients:void 0,T=N?.connections,q=b.useMemo(()=>a&&l.startsWith(`/${S}/agents/`)?A.find(U=>U.agentId===a):void 0,[a,S,l,A]),{attentionCards:R,isLoading:H,isError:D}=v1(S),G=H||D?void 0:R.length,{data:$}=DC(v?.organizationId,void 0),X=b.useMemo(()=>{if(!o)return;const U=($??[]).find(J=>String(J.automation_id)===String(o));return U?{automationId:String(U.automation_id),name:U.name}:void 0},[o,$]),F=N?.automations,W=S?l===`/${S}/recent`||l.startsWith(`/${S}/recent/`):!1;return t&&!e?h.jsxs("aside",{className:"fixed inset-y-0 left-0 z-40 flex w-14 flex-col items-center border-r border-border bg-sidebar-background text-sidebar-foreground",children:[h.jsx("div",{className:"flex h-14 w-full items-center justify-center border-b border-sidebar-border",children:h.jsx("button",{type:"button",onClick:n,"aria-label":"Expand sidebar",title:"Expand sidebar",className:"flex h-9 w-9 items-center justify-center rounded-md text-sidebar-foreground/70 transition-colors hover:bg-sidebar-accent/60 hover:text-sidebar-foreground",children:h.jsx(n7,{className:"h-[18px] w-[18px]"})})}),S?h.jsxs("div",{className:"flex flex-1 flex-col gap-1 overflow-y-auto py-2",children:[h.jsx(yh,{label:"Search",icon:_m,onClick:Wm}),d?h.jsx(yh,{label:f?"Lobu Lens is open":"Open Lobu Lens",icon:Xh,onClick:()=>void p()}):null,Object.keys(zn).map(U=>{const J=zn[U];return h.jsx(yh,{label:J.label,active:jm(U,S,l),icon:J.icon,to:J.to,params:{owner:S},search:J.search},U)}),h.jsx(yh,{label:"Recent",active:W,icon:Vu,to:"/$owner/recent",params:{owner:S}})]}):h.jsx("div",{className:"flex-1"})]}):h.jsxs("aside",{className:ye("flex flex-col bg-sidebar-background text-sidebar-foreground",e?"h-full w-full":"fixed inset-y-0 left-0 z-40 w-[17.25rem] border-r border-border"),children:[h.jsxs("div",{className:ye("flex h-14 items-center gap-1 px-2",!e&&"border-b border-sidebar-border"),children:[h.jsx("div",{className:"min-w-0 flex-1",children:h.jsx(BC,{})}),d?h.jsx("button",{type:"button","data-lobu-lens-open":"",onClick:()=>void p(),"aria-label":f?"Lobu Lens is open":"Open Lobu Lens",title:f?"Lobu Lens is open":"Open Lobu Lens",className:"flex h-8 w-8 shrink-0 items-center justify-center rounded-md text-primary transition-colors hover:bg-sidebar-accent/60",children:h.jsx(Xh,{className:"h-5 w-5"})}):null,h.jsx("button",{type:"button",onClick:Wm,"aria-label":"Search",title:"Search (⌘K)",className:"flex h-8 w-8 shrink-0 items-center justify-center rounded-md text-sidebar-foreground/60 transition-colors hover:bg-sidebar-accent/60 hover:text-sidebar-foreground",children:h.jsx(_m,{className:"h-5 w-5"})}),!e&&n?h.jsx("button",{type:"button",onClick:n,"aria-label":"Collapse sidebar",title:"Collapse sidebar",className:"flex h-8 w-8 shrink-0 items-center justify-center rounded-md text-sidebar-foreground/60 transition-colors hover:bg-sidebar-accent/60 hover:text-sidebar-foreground",children:h.jsx(t7,{className:"h-[18px] w-[18px]"})}):null]}),S?h.jsxs(h.Fragment,{children:[h.jsxs("div",{className:"flex flex-1 flex-col overflow-y-auto py-2",children:[Object.keys(zn).map(U=>{const J=zn[U],se=jm(U,S,l),L=U==="activity"?G:U==="connectors"?T:void 0,B=L==null?"":U==="activity"?`${L} item${L===1?"":"s"} need attention`:`${L} configured connection${L===1?"":"s"}`;return U==="context"?h.jsx(h6e,{ownerSlug:S,active:se,searchRecord:y,entityTypeParam:s},U):U==="agents"?h.jsx(y6e,{ownerSlug:S,active:se,currentAgent:q,count:I},U):U==="automations"?h.jsx(m6e,{ownerSlug:S,active:se,currentAutomation:X,count:F},U):h.jsx(Yu,{to:J.to,params:{owner:S},search:J.search,active:se,icon:J.icon,label:J.label,trailing:L!=null?h.jsx(h0,{count:L,title:B}):void 0},U)}),e?h.jsx(Yu,{to:"/$owner/recent",params:{owner:S},active:W,icon:Vu,label:"Recent"}):h.jsx(s6e,{owner:S})]}),h.jsx(g6e,{})]}):h.jsx("div",{className:"flex flex-1 flex-col items-center justify-center px-4 text-center text-xs text-sidebar-foreground/50",children:"Pick an organization to continue."})]})}function b6e(e,t){const[n,a]=b.useState(!1);return b.useEffect(()=>{const o=e.current;if(!o||(a(o.clientWidth<=t),typeof ResizeObserver>"u"))return;const s=new ResizeObserver(l=>{const c=l[0];c&&a(c.contentRect.width<=t)});return s.observe(o),()=>s.disconnect()},[e,t]),n}const w6e=640,$C=b.createContext(!1);function UC(){return b.useContext($C)}const O8=new Set(["auth","oauth"]);function M6e(e){const t=e.split("/").filter(Boolean);return O8.has(t[0]??"")||O8.has(t[1]??"")}const N8="lobu.sidebar.collapsed";function S6e({children:e}){const t=b.useRef(null),n=b6e(t,w6e),a=t1(),[o,s]=b.useState(()=>{try{return localStorage.getItem(N8)==="1"}catch{return!1}}),l=()=>{s(d=>{const f=!d;try{localStorage.setItem(N8,f?"1":"0")}catch{}return f})},c=M6e(a.pathname);return h.jsxs($C.Provider,{value:n,children:[h.jsx(yfe,{}),h.jsx("div",{ref:t,className:"h-dvh overflow-hidden bg-background text-foreground",children:c?h.jsxs("div",{className:"flex h-full flex-col overflow-x-hidden overflow-y-auto",children:[h.jsx(by,{}),e]}):n?h.jsxs("div",{className:"flex h-dvh flex-col overflow-hidden",children:[h.jsx("header",{className:"z-30 flex h-14 shrink-0 items-center gap-2 bg-background px-3",children:h.jsx(v6e,{})}),h.jsx(by,{}),h.jsx("main",{className:"flex min-h-0 flex-1 flex-col overflow-x-hidden overflow-y-auto",children:e})]}):h.jsxs(h.Fragment,{children:[h.jsx(x6e,{collapsed:o,onToggleCollapsed:l}),h.jsxs("main",{className:ye("flex h-dvh flex-col overflow-hidden transition-[padding] duration-200",o?"pl-14":"pl-[17.25rem]"),children:[h.jsx(by,{}),h.jsx("div",{className:"flex min-h-0 flex-1 flex-col overflow-x-hidden overflow-y-auto",children:e})]})]})})]})}function T8(){if(window.__lobuAmbientContext)return window.__lobuAmbientContext;if(window.parent!==window&&/^chrome-extension:\/\/[a-p]{32}$/.test(window.location.ancestorOrigins?.[0]??""))return{kind:"browser",url:null,title:null,applicationName:"Chrome"}}function sEe(){const[e,t]=b.useState(T8);return b.useEffect(()=>{const n=()=>t(T8());window.addEventListener("owletto:ambient-context",n),n();const a=o=>{const s=v4e(o,window.parent,window);s&&t(s)};return window.addEventListener("message",a),window.parent!==window&&window.parent.postMessage({owletto:"ambient-context-request"},"*"),()=>{window.removeEventListener("owletto:ambient-context",n),window.removeEventListener("message",a)}},[]),e}function _6e({owner:e,context:t,emptyState:n,tabs:a,onOpenItem:o,compact:s=!1,relevant:l}){const[c,d]=b.useState(!1),f=UC(),{attentionItems:p}=v1(e),y=t!==void 0&&(l??!c),k=y?w=>m4e(w,t):void 0,v=k?p.filter(k).length:p.length;return h.jsxs(h.Fragment,{children:[h.jsxs("div",{className:ye("sticky top-0 z-20 flex min-w-0 flex-wrap items-center gap-x-4 gap-y-2 bg-background pt-1",f?"justify-center":"justify-between"),children:[a??(t?h.jsxs("fieldset",{className:"flex items-center gap-2","aria-label":"Notification scope",children:[h.jsxs("button",{type:"button","aria-pressed":!c,onClick:()=>d(!1),className:"rounded-md px-2.5 py-1 text-xs aria-pressed:bg-muted",children:["Relevant here",y?` (${v})`:""]}),h.jsx("button",{type:"button","aria-pressed":c,onClick:()=>d(!0),className:"rounded-md px-2.5 py-1 text-xs aria-pressed:bg-muted",children:"All notifications"})]}):null),!y&&!s&&h.jsx(U5e,{owner:e})]}),h.jsx(K5e,{owner:e,itemFilter:k,onOpenItem:o,rowAction:s?"none":"open",ariaLabel:y?"Relevant here":"Needs attention",tone:y?"relevant":"default",emptyState:y?h.jsx("p",{className:"px-3 py-6 text-center text-xs text-muted-foreground",children:"No notifications linked to this context."}):n})]})}const C6e={width:340,height:360},A6e={width:340,height:436},KC=b.createContext(null);function P8(){return window.documentPictureInPicture??null}function E6e(e){const t=e.createElement("base");t.href=document.baseURI,e.head.append(t);for(const n of document.querySelectorAll('link[rel="stylesheet"], style')){const a=n.cloneNode(!0);n instanceof HTMLLinkElement&&a instanceof HTMLLinkElement&&(a.href=n.href),e.head.append(a)}e.documentElement.className=document.documentElement.className,e.documentElement.style.colorScheme=getComputedStyle(document.documentElement).colorScheme,e.body.style.margin="0",e.body.style.width="100vw",e.body.style.height="100vh",e.body.style.overflow="hidden"}function R6e({owner:e,activeContext:t}){const n=qn(),a=b.useCallback(s=>{(async()=>{if(!s.href)return;const{pathname:l,search:c}=sc(s.href);await n({to:l,search:c??{}}),await x4e()})()},[n]),o=t??{kind:"browser",url:null,title:null,applicationName:"Chrome"};return h.jsx("main",{className:"lobu-lens-surface bg-background text-foreground","aria-label":"Context notifications",children:h.jsx("div",{className:"lobu-lens-content",children:h.jsx(_6e,{owner:e,context:o,compact:!0,onOpenItem:a,emptyState:h.jsx("div",{className:"lobu-lens-empty text-muted-foreground",children:"All caught up"})},`${e}:${g4e(o)}`)})})}function j6e({children:e}){const{currentOwner:t}=er(),n=t??null,[a,o]=b.useState(()=>({kind:"browser",url:window.location.href,title:document.title||null,applicationName:"Browser"})),[s,l]=b.useState(null),c=b.useRef(null),d=b.useCallback(async()=>{if(c.current&&!c.current.closed){c.current.focus();return}if(!n)throw new Error("Open a Lobu workspace before starting Lens.");const p=P8();if(!p)throw new Error("This browser does not support Document Picture-in-Picture.");const y=document.documentElement.dataset.owlettoDebuggerAttached==="true",k=await p.requestWindow(y?A6e:C6e);c.current=k,E6e(k.document);const v=k.document.createElement("div");v.id="lobu-lens-root",v.style.width="100%",v.style.height="100%",k.document.body.append(v),l(v),k.addEventListener("pagehide",()=>{c.current===k&&(c.current=null,l(null))},{once:!0})},[n]);b.useEffect(()=>{const p=y=>{const k=y_(y);(k?.kind==="browser"||k?.kind==="application")&&o(k)};return document.addEventListener(o8,p),document.dispatchEvent(new Event(p4e)),()=>{document.removeEventListener(o8,p),c.current?.close()}},[]);const f=b.useMemo(()=>({available:n!=null&&P8()!=null,isOpen:s!=null,open:d}),[d,n,s]);return h.jsxs(KC.Provider,{value:f,children:[e,s&&n?go.createPortal(h.jsx(R6e,{owner:n,activeContext:a}),s):null]})}function O6e(){const e=b.useContext(KC);return e||{available:!1,isOpen:!1,open:async()=>{}}}var GC=Object.freeze({position:"absolute",border:0,width:1,height:1,padding:0,margin:-1,overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",wordWrap:"normal"}),N6e="VisuallyHidden",YC=b.forwardRef((e,t)=>h.jsx(He.span,{...e,ref:t,style:{...GC,...e.style}}));YC.displayName=N6e;var T6e=YC,[f0]=dr("Tooltip",[Ti]),p0=Ti(),WC="TooltipProvider",P6e=700,Zm="tooltip.open",[L6e,iv]=f0(WC),ZC=e=>{const{__scopeTooltip:t,delayDuration:n=P6e,skipDelayDuration:a=300,disableHoverableContent:o=!1,children:s}=e,l=b.useRef(!0),c=b.useRef(!1),d=b.useRef(0);return b.useEffect(()=>{const f=d.current;return()=>window.clearTimeout(f)},[]),h.jsx(L6e,{scope:t,isOpenDelayedRef:l,delayDuration:n,onOpen:b.useCallback(()=>{a<=0||(window.clearTimeout(d.current),l.current=!1)},[a]),onClose:b.useCallback(()=>{a<=0||(window.clearTimeout(d.current),d.current=window.setTimeout(()=>l.current=!0,a))},[a]),isPointerInTransitRef:c,onPointerInTransitChange:b.useCallback(f=>{c.current=f},[]),disableHoverableContent:o,children:s})};ZC.displayName=WC;var Wu="Tooltip",[z6e,_1]=f0(Wu),QC=e=>{const{__scopeTooltip:t,children:n,open:a,defaultOpen:o,onOpenChange:s,disableHoverableContent:l,delayDuration:c}=e,d=iv(Wu,e.__scopeTooltip),f=p0(t),[p,y]=b.useState(null),k=Ya(),v=b.useRef(0),w=l??d.disableHoverableContent,S=c??d.delayDuration,_=b.useRef(!1),[C,A]=fo({prop:a,defaultProp:o??!1,onChange:q=>{q?(d.onOpen(),document.dispatchEvent(new CustomEvent(Zm))):d.onClose(),s?.(q)},caller:Wu}),j=b.useMemo(()=>C?_.current?"delayed-open":"instant-open":"closed",[C]),N=b.useCallback(()=>{window.clearTimeout(v.current),v.current=0,_.current=!1,A(!0)},[A]),I=b.useCallback(()=>{window.clearTimeout(v.current),v.current=0,A(!1)},[A]),T=b.useCallback(()=>{window.clearTimeout(v.current),v.current=window.setTimeout(()=>{_.current=!0,A(!0),v.current=0},S)},[S,A]);return b.useEffect(()=>()=>{v.current&&(window.clearTimeout(v.current),v.current=0)},[]),h.jsx(i0,{...f,children:h.jsx(z6e,{scope:t,contentId:k,open:C,stateAttribute:j,trigger:p,onTriggerChange:y,onTriggerEnter:b.useCallback(()=>{d.isOpenDelayedRef.current?T():N()},[d.isOpenDelayedRef,T,N]),onTriggerLeave:b.useCallback(()=>{w?I():(window.clearTimeout(v.current),v.current=0)},[I,w]),onOpen:N,onClose:I,disableHoverableContent:w,children:n})})};QC.displayName=Wu;var Qm="TooltipTrigger",XC=b.forwardRef((e,t)=>{const{__scopeTooltip:n,...a}=e,o=_1(Qm,n),s=iv(Qm,n),l=p0(n),c=b.useRef(null),d=it(t,c,o.onTriggerChange),f=b.useRef(!1),p=b.useRef(!1),y=b.useCallback(()=>f.current=!1,[]);return b.useEffect(()=>()=>document.removeEventListener("pointerup",y),[y]),h.jsx(b1,{asChild:!0,...l,children:h.jsx(He.button,{"aria-describedby":o.open?o.contentId:void 0,"data-state":o.stateAttribute,...a,ref:d,onPointerMove:xe(e.onPointerMove,k=>{k.pointerType!=="touch"&&!p.current&&!s.isPointerInTransitRef.current&&(o.onTriggerEnter(),p.current=!0)}),onPointerLeave:xe(e.onPointerLeave,()=>{o.onTriggerLeave(),p.current=!1}),onPointerDown:xe(e.onPointerDown,()=>{o.open&&o.onClose(),f.current=!0,document.addEventListener("pointerup",y,{once:!0})}),onFocus:xe(e.onFocus,()=>{f.current||o.onOpen()}),onBlur:xe(e.onBlur,o.onClose),onClick:xe(e.onClick,o.onClose)})})});XC.displayName=Qm;var sv="TooltipPortal",[D6e,I6e]=f0(sv,{forceMount:void 0}),JC=e=>{const{__scopeTooltip:t,forceMount:n,children:a,container:o}=e,s=_1(sv,t);return h.jsx(D6e,{scope:t,forceMount:n,children:h.jsx(Gn,{present:n||s.open,children:h.jsx(rc,{asChild:!0,container:o,children:a})})})};JC.displayName=sv;var Jl="TooltipContent",eA=b.forwardRef((e,t)=>{const n=I6e(Jl,e.__scopeTooltip),{forceMount:a=n.forceMount,side:o="top",...s}=e,l=_1(Jl,e.__scopeTooltip);return h.jsx(Gn,{present:a||l.open,children:l.disableHoverableContent?h.jsx(tA,{side:o,...s,ref:t}):h.jsx(q6e,{side:o,...s,ref:t})})}),q6e=b.forwardRef((e,t)=>{const n=_1(Jl,e.__scopeTooltip),a=iv(Jl,e.__scopeTooltip),o=b.useRef(null),s=it(t,o),[l,c]=b.useState(null),{trigger:d,onClose:f}=n,p=o.current,{onPointerInTransitChange:y}=a,k=b.useCallback(()=>{c(null),y(!1)},[y]),v=b.useCallback((w,S)=>{const _=w.currentTarget,C={x:w.clientX,y:w.clientY},A=$6e(C,_.getBoundingClientRect()),j=U6e(C,A),N=K6e(S.getBoundingClientRect()),I=Y6e([...j,...N]);c(I),y(!0)},[y]);return b.useEffect(()=>()=>k(),[k]),b.useEffect(()=>{if(d&&p){const w=_=>v(_,p),S=_=>v(_,d);return d.addEventListener("pointerleave",w),p.addEventListener("pointerleave",S),()=>{d.removeEventListener("pointerleave",w),p.removeEventListener("pointerleave",S)}}},[d,p,v,k]),b.useEffect(()=>{if(l){const w=S=>{const _=S.target,C={x:S.clientX,y:S.clientY},A=d?.contains(_)||p?.contains(_),j=!G6e(C,l);A?k():j&&(k(),f())};return document.addEventListener("pointermove",w),()=>document.removeEventListener("pointermove",w)}},[d,p,l,f,k]),h.jsx(tA,{...e,ref:s})}),[H6e,V6e]=f0(Wu,{isInside:!1}),F6e=mue("TooltipContent"),tA=b.forwardRef((e,t)=>{const{__scopeTooltip:n,children:a,"aria-label":o,onEscapeKeyDown:s,onPointerDownOutside:l,...c}=e,d=_1(Jl,n),f=p0(n),{onClose:p}=d;return b.useEffect(()=>(document.addEventListener(Zm,p),()=>document.removeEventListener(Zm,p)),[p]),b.useEffect(()=>{if(d.trigger){const y=k=>{k.target instanceof Node&&k.target.contains(d.trigger)&&p()};return window.addEventListener("scroll",y,{capture:!0}),()=>window.removeEventListener("scroll",y,{capture:!0})}},[d.trigger,p]),h.jsx(ac,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:s,onPointerDownOutside:l,onFocusOutside:y=>y.preventDefault(),onDismiss:p,children:h.jsxs(s0,{"data-state":d.stateAttribute,...f,...c,ref:t,style:{...c.style,"--radix-tooltip-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-tooltip-content-available-width":"var(--radix-popper-available-width)","--radix-tooltip-content-available-height":"var(--radix-popper-available-height)","--radix-tooltip-trigger-width":"var(--radix-popper-anchor-width)","--radix-tooltip-trigger-height":"var(--radix-popper-anchor-height)"},children:[h.jsx(F6e,{children:a}),h.jsx(H6e,{scope:n,isInside:!0,children:h.jsx(T6e,{id:d.contentId,role:"tooltip",children:o||a})})]})})});eA.displayName=Jl;var nA="TooltipArrow",B6e=b.forwardRef((e,t)=>{const{__scopeTooltip:n,...a}=e,o=p0(n);return V6e(nA,n).isInside?null:h.jsx(l0,{...o,...a,ref:t})});B6e.displayName=nA;function $6e(e,t){const n=Math.abs(t.top-e.y),a=Math.abs(t.bottom-e.y),o=Math.abs(t.right-e.x),s=Math.abs(t.left-e.x);switch(Math.min(n,a,o,s)){case s:return"left";case o:return"right";case n:return"top";case a:return"bottom";default:throw new Error("unreachable")}}function U6e(e,t,n=5){const a=[];switch(t){case"top":a.push({x:e.x-n,y:e.y+n},{x:e.x+n,y:e.y+n});break;case"bottom":a.push({x:e.x-n,y:e.y-n},{x:e.x+n,y:e.y-n});break;case"left":a.push({x:e.x+n,y:e.y-n},{x:e.x+n,y:e.y+n});break;case"right":a.push({x:e.x-n,y:e.y-n},{x:e.x-n,y:e.y+n});break}return a}function K6e(e){const{top:t,right:n,bottom:a,left:o}=e;return[{x:o,y:t},{x:n,y:t},{x:n,y:a},{x:o,y:a}]}function G6e(e,t){const{x:n,y:a}=e;let o=!1;for(let s=0,l=t.length-1;s<t.length;l=s++){const c=t[s],d=t[l],f=c.x,p=c.y,y=d.x,k=d.y;p>a!=k>a&&n<(y-f)*(a-p)/(k-p)+f&&(o=!o)}return o}function Y6e(e){const t=e.slice();return t.sort((n,a)=>n.x<a.x?-1:n.x>a.x?1:n.y<a.y?-1:n.y>a.y?1:0),W6e(t)}function W6e(e){if(e.length<=1)return e.slice();const t=[];for(let a=0;a<e.length;a++){const o=e[a];for(;t.length>=2;){const s=t[t.length-1],l=t[t.length-2];if((s.x-l.x)*(o.y-l.y)>=(s.y-l.y)*(o.x-l.x))t.pop();else break}t.push(o)}t.pop();const n=[];for(let a=e.length-1;a>=0;a--){const o=e[a];for(;n.length>=2;){const s=n[n.length-1],l=n[n.length-2];if((s.x-l.x)*(o.y-l.y)>=(s.y-l.y)*(o.x-l.x))n.pop();else break}n.push(o)}return n.pop(),t.length===1&&n.length===1&&t[0].x===n[0].x&&t[0].y===n[0].y?t:t.concat(n)}var Z6e=ZC,Q6e=QC,X6e=XC,J6e=JC,aA=eA;const e8e=Z6e,lEe=Q6e,cEe=X6e,t8e=b.forwardRef(({className:e,sideOffset:t=4,...n},a)=>h.jsx(J6e,{children:h.jsx(aA,{ref:a,sideOffset:t,className:ye("z-50 overflow-hidden rounded-md bg-primary px-3 py-1.5 text-xs text-primary-foreground animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",e),...n})}));t8e.displayName=aA.displayName;const Yy=3e3,n8e=6e4;function a8e(e){const t=sn(),n=b.useRef(null),a=b.useRef(null),o=b.useRef(Yy);b.useEffect(()=>{if(!e)return;let s=!1;async function l(){const c=await Cz(`${pt}/api/${e}/events`);if(s){c.close();return}n.current=c,c.onopen=()=>{o.current=Yy},c.addEventListener("invalidate",d=>{try{const f=JSON.parse(d.data);if(f.keys)for(const p of f.keys)t.invalidateQueries({queryKey:[p]})}catch{}}),c.onerror=()=>{c.close(),n.current=null,!s&&(a.current=setTimeout(()=>{a.current=null,s||l()},o.current),o.current=Math.min(o.current*2,n8e))}}return l(),()=>{s=!0,n.current?.close(),n.current=null,a.current!=null&&(clearTimeout(a.current),a.current=null),o.current=Yy}},[e,t])}function r8e(){const{session:e,sessionResult:t,isReady:n}=Xa(),a=typeof window<"u"&&!window.location.pathname.startsWith("/auth/"),{data:o}=K0e({enabled:a}),s=sn(),l=b.useRef(!1);b.useEffect(()=>{!n||e||l.current||o?.singleUserMode&&(l.current=!0,(async()=>{try{(await Sz()).ok&&(await t.refetch(),await s.invalidateQueries())}catch{}})())},[n,e,o,t,s])}const ka=eT()({component:o8e});function o8e(){const{session:e,isReady:t}=Xa();r8e();const n=typeof window<"u"?location.pathname:"/",a=n.startsWith("/oauth/")||n.startsWith("/slack/")||n.startsWith("/connector/"),o=AM();return a8e(t&&e?o:null),a?h.jsx("div",{className:"min-h-screen bg-background text-foreground",children:h.jsx(fm,{})}):h.jsx(j6e,{children:h.jsxs(e8e,{delayDuration:200,children:[h.jsx(sde,{richColors:!0,position:"bottom-right"}),h.jsx(S6e,{children:h.jsx(fm,{})}),null]})})}const i8e=()=>Ee(()=>import("./_owner-DglbbDEx.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])),s8e=_e("/$owner")({loader:({context:{queryClient:e},params:t})=>{t.owner!=="me"&&e.prefetchQuery(gn.queryOptions(t.owner,{slug:t.owner}))},pendingComponent:()=>null,component:Ae(i8e,"component")}),l8e=()=>Ee(()=>import("./index-DkKALC2l.js"),__vite__mapDeps([26,27])),c8e=_e("/")({component:Ae(l8e,"component")}),u8e=()=>Ee(()=>import("./index-DZadnZpq.js"),__vite__mapDeps([28,29,7,30,18,20,31,5,19,21,22,32,16,33])),d8e=_e("/$owner/")({loader:({context:{queryClient:e},params:t})=>{e.prefetchQuery(gn.queryOptions(t.owner,{slug:t.owner}))},validateSearch:e=>uc(e),component:Ae(u8e,"component")}),h8e=()=>Ee(()=>import("./claim-DLHRN0bA.js"),[]),f8e=_e("/slack/claim")({component:Ae(h8e,"component"),validateSearch:e=>({team:typeof e.team=="string"?e.team:void 0,t:typeof e.t=="string"?e.t:void 0})}),p8e=()=>Ee(()=>import("./new-DIjOVXrQ.js"),__vite__mapDeps([34,22,27])),y8e=_e("/orgs/new")({component:Ae(p8e,"component"),validateSearch:e=>Dt({slug:e.slug||void 0,name:e.name||void 0})}),m8e=()=>Ee(()=>import("./device-DToHXxDM.js"),__vite__mapDeps([35,36,22]));function g8e(e){if(typeof e!="string")return;const t=e.trim();if(t)try{const n=new URL(t);return n.protocol==="owletto:"||n.protocol==="lobu-ios-bridge:"?t:void 0}catch{return}}const k8e=_e("/oauth/device")({component:Ae(m8e,"component"),validateSearch:e=>Dt({user_code:typeof e.user_code=="string"&&e.user_code.trim().length>0?e.user_code.trim():void 0,return_to:g8e(e.return_to)})}),v8e=()=>Ee(()=>import("./consent-Bi6KCVtT.js"),__vite__mapDeps([37,36,22]));function oo(e){return typeof e=="string"?e:void 0}const x8e=_e("/oauth/consent")({component:Ae(v8e,"component"),validateSearch:e=>Dt({client_id:oo(e.client_id),redirect_uri:oo(e.redirect_uri),scope:oo(e.scope),state:oo(e.state),code_challenge:oo(e.code_challenge),code_challenge_method:oo(e.code_challenge_method),client_name:oo(e.client_name),resource:oo(e.resource),authorization_intent:oo(e.authorization_intent),workspace_grants:e.workspace_grants==="1"||e.workspace_grants===1?"1":void 0})}),b8e=()=>Ee(()=>import("./reset-password-Dsz5-Xeo.js"),__vite__mapDeps([38,22])),w8e=_e("/auth/reset-password")({component:Ae(b8e,"component"),validateSearch:e=>Dt({token:typeof e.token=="string"?e.token:void 0,error:typeof e.error=="string"?e.error:void 0})}),M8e=()=>Ee(()=>import("./logout-DKQS25qd.js"),[]),S8e=_e("/auth/logout")({component:Ae(M8e,"component")}),_8e=()=>Ee(()=>import("./login-D53geSP7.js"),__vite__mapDeps([39,40,22])),C8e=_e("/auth/login")({component:Ae(_8e,"component"),validateSearch:e=>Dt({callbackUrl:e.callbackUrl||void 0,mode:e.mode||void 0,error:e.error||void 0,errorDescription:e.error_description||void 0,loginHint:e.loginHint||e.login_hint||void 0,invitationOrg:e.invitationOrg||void 0,provider:typeof e.provider=="string"&&e.provider.trim()?e.provider.trim().toLowerCase():void 0,intent:e.intent==="sign-up"||e.intent==="sign-in"?e.intent:void 0})}),A8e=()=>Ee(()=>import("./callback-CJxC8u_x.js"),[]),E8e=_e("/auth/callback")({component:Ae(A8e,"component")}),R8e=()=>Ee(()=>import("./accept-invitation-Dgoyublh.js"),__vite__mapDeps([41,40,27])),j8e=_e("/auth/accept-invitation")({component:Ae(R8e,"component"),validateSearch:e=>Dt({invitationId:e.invitationId||void 0})}),O8e=()=>Ee(()=>import("./settings-Bu239SXe.js"),__vite__mapDeps([42,27])),N8e=_e("/account/settings")({component:Ae(O8e,"component")}),T8e=()=>Ee(()=>import("./recent-By19_Buq.js"),[]),P8e=_e("/$owner/recent")({loader:({context:{queryClient:e},params:t})=>{e.prefetchQuery(gn.queryOptions(t.owner,{slug:t.owner}))},component:Ae(T8e,"component")}),L8e=()=>Ee(()=>import("./connectors-Ckn_aoNE.js"),[]),z8e=_e("/$owner/connectors")({component:Ae(L8e,"component")}),D8e=()=>Ee(()=>import("./automations-OLmcj-qM.js"),[]),I8e=_e("/$owner/automations")({component:Ae(D8e,"component")}),q8e=()=>Ee(()=>import("./agents-OLmcj-qM.js"),[]),H8e=_e("/$owner/agents")({component:Ae(q8e,"component")});function V8e(e,t){const n=t;return{path:n?`/${[e,n].filter(Boolean).join("/")}`:e,effectiveSplat:n}}const F8e=()=>Ee(()=>import("./_-DdvHIadV.js"),[]);function B8e(){return h.jsx("div",{"data-public-loading":"true",children:h.jsx(R7,{})})}const $8e=_e("/$owner/$")({pendingComponent:B8e,beforeLoad:({params:e})=>{const n=(e._splat||"").split("/")[0];if(n&&Ri(n))throw y2()},component:Ae(F8e,"component"),validateSearch:e=>{const t={},n=[...L0e,...Y2,"page","merged_from"];for(const a of n){const o=e[a];o!=null&&(t[a]=typeof o=="number"?o:String(o))}for(const a of Object.keys(e))a.startsWith("clf_")&&e[a]!=null&&(t[a]=String(e[a]));return t},loader:({context:{queryClient:e},params:t})=>{const{path:n}=V8e(t.owner,t._splat||"");e.prefetchQuery(f1.queryOptions(n,{slug:t.owner},{includeBootstrap:!0}))}}),U8e=()=>Ee(()=>import("./index-D0lZrXrY.js"),__vite__mapDeps([43,44,6,45,23,11,12,10,46,32,47,21,22,33,48])),K8e=["agent","agent_id","automation","produced_by","schedule","connection_ids","feed_ids","run_ids","content_ids","entity_id","run_id","platforms","at"];function G8e(e){return e.view==="events"||e.view==="feeds"||e.browse_view==="events"?!0:K8e.some(t=>e[t]!=null&&String(e[t]).trim()!=="")}const Y8e=_e("/$owner/memory/")({loader:({context:{queryClient:e},params:t})=>{e.prefetchQuery(gn.queryOptions(t.owner,{slug:t.owner}))},beforeLoad:({params:e,search:t})=>{const n=t,a=typeof n.browse_path=="string"&&n.browse_path.trim()?n.browse_path.trim():void 0;if(a)throw ca({to:"/$owner/memory/$",params:{owner:e.owner,_splat:a},search:{},replace:!0});if(G8e(n))throw ca({to:"/$owner/events",params:{owner:e.owner},search:Dt({...n,type:typeof n.browse_type=="string"&&n.browse_type.trim()?ks(n.browse_type.trim()):n.type,view:void 0,create:void 0,create_type:void 0,browse_type:void 0,browse_view:void 0}),replace:!0});if(typeof n.view=="string")throw ca({to:"/$owner/memory",params:{owner:e.owner},search:Dt({...n,view:void 0}),replace:!0});const o=typeof n.browse_type=="string"&&n.browse_type.trim()?n.browse_type.trim():void 0;if(o)throw ca({to:"/$owner/memory",params:{owner:e.owner},search:Dt({type:ks(o),create:n.create===!0||n.create==="true"?!0:void 0}),replace:!0});const s=Ube(n);if(s)throw ca({to:"/$owner/memory",params:{owner:e.owner},search:s,replace:!0});const l=HC(n);if(l)throw ca({to:"/$owner/$",params:{owner:e.owner,_splat:l},search:{},replace:!0});const c=typeof n.type=="string"&&n.type.trim()?ks(n.type.trim()):void 0;if(c)throw ca({to:"/$owner/$entityType",params:{owner:e.owner,entityType:c},search:{create:n.create===!0||n.create==="true"?!0:void 0},replace:!0})},component:Ae(U8e,"component"),validateSearch:e=>{const t=Dt(e);return(e.create===!0||e.create==="true")&&(t.create="true"),(e.create_type===!0||e.create_type==="true")&&(t.create_type="true"),t}}),W8e=()=>Ee(()=>import("./index-DtqBFgK5.js"),[]),Z8e=_e("/$owner/members/")({beforeLoad:({params:e})=>{throw ca({...Kbe(e.owner),replace:!0})},component:Ae(W8e,"component")}),Q8e=()=>Ee(()=>import("./index-CK2-iHcz.js"),__vite__mapDeps([49,29,7,30,18,20,31,5,19,21,22,32,16,33])),X8e=_e("/$owner/events/")({loader:({context:{queryClient:e},params:t})=>{t.owner!=="me"&&e.prefetchQuery(gn.queryOptions(t.owner,{slug:t.owner}))},component:Ae(Q8e,"component"),validateSearch:e=>Dt(e)}),J8e={all:"All",data:"Data",chat:"Chat",actions:"Actions",inference:"Inference",runtime:"Runtime",device:"On device"},ewe=["all","data","chat","actions","inference","runtime","device"];function twe(e){return typeof e=="string"&&ewe.includes(e)?e:void 0}function nwe(e){return e.options_schema?.["x-lobu-chat-platform"]!=null}function awe(e){return!!e.runtime||!!e.required_capability}function rwe(e,t){const n=e.feeds_schema?Object.keys(e.feeds_schema).length>0:!1,a=e.has_operations||(e.actions_schema?Object.keys(e.actions_schema).length>0:!1);return{data:t?.facets.data??n,chat:t?.facets.chat??nwe(e),actions:t?.facets.actions??a,audience:t?.facets.audience??!1,inference:!1,runtime:!1}}function Wy(e,t){const{connector:n,facets:a}=e;return t==="all"?!0:t==="data"?a.data:t==="chat"?a.chat:t==="actions"?a.actions:t==="inference"?a.inference:t==="runtime"?a.runtime===!0:e.isDevice===!0||awe(n)}const owe=()=>Ee(()=>import("./index-Bq4m-sK0.js"),__vite__mapDeps([50,51])),iwe=_e("/$owner/connectors/")({validateSearch:e=>{const t=twe(e.filter);return t?{filter:t}:{}},loader:({context:{queryClient:e},params:t})=>{e.prefetchQuery(gn.queryOptions(t.owner,{slug:t.owner}))},component:Ae(owe,"component")}),swe=()=>Ee(()=>import("./index-jGZeANLE.js"),__vite__mapDeps([52,16])),lwe=_e("/$owner/chat/")({validateSearch:e=>{const t={};return(e.new===!0||e.new==="1"||e.new==="true")&&(t.new=!0),typeof e.prompt=="string"&&e.prompt.length>0&&(t.prompt=e.prompt),Object.assign(t,uc(e)),t},component:Ae(swe,"component")}),cwe=()=>Ee(()=>import("./index-COgBJ_ab.js"),__vite__mapDeps([53,54,3])),uwe=_e("/$owner/automations/")({loader:({context:{queryClient:e},params:t})=>{e.prefetchQuery(gn.queryOptions(t.owner,{slug:t.owner}))},component:Ae(cwe,"component")}),dwe=()=>Ee(()=>import("./index-DcWyuLQS.js"),__vite__mapDeps([55,56,54,20,31])),hwe=_e("/$owner/agents/")({loader:({context:{queryClient:e},params:t})=>{e.prefetchQuery(gn.queryOptions(t.owner,{slug:t.owner}))},component:Ae(dwe,"component")}),fwe=()=>Ee(()=>import("./index-DxIDxgPJ.js"),__vite__mapDeps([57,44,6,45,23,11,12,10,46,32,47,21,22,33,48])),pwe=_e("/$owner/$entityType/")({validateSearch:e=>({create:e.create===!0||e.create==="true"?!0:void 0}),beforeLoad:({params:e})=>{if(Ri(e.entityType))throw y2()},component:Ae(fwe,"component")}),ywe=()=>Ee(()=>import("./connection-DdBkXNbX.js"),__vite__mapDeps([58,22])),mwe=_e("/connector/$name/connection")({component:Ae(ywe,"component"),validateSearch:e=>({ref:typeof e.ref=="string"?e.ref:void 0})}),gwe=()=>Ee(()=>import("./organization-DHEC7kDq.js"),__vite__mapDeps([59,60,22])),kwe=_e("/$owner/settings/organization")({component:Ae(gwe,"component")}),vwe=()=>Ee(()=>import("./_-DtqBFgK5.js"),[]),xwe=_e("/$owner/memory/$")({beforeLoad:({params:e})=>{const t=IC(e._splat||"");throw t.typeSegment?Ri(t.typeSegment)?y2():t.isEntityDetail?ca({to:"/$owner/$",params:{owner:e.owner,_splat:t.path},search:{},replace:!0}):ca({to:"/$owner/$entityType",params:{owner:e.owner,entityType:t.typeSegment},search:{create:void 0},replace:!0}):ca({to:"/$owner/memory",params:{owner:e.owner},search:{},replace:!0})},component:Ae(vwe,"component")}),bwe=()=>Ee(()=>import("./_-CfcfHJO8.js"),__vite__mapDeps([61,29,7,30,18,20,31,5,19,21,22,32,16,33])),wwe=_e("/$owner/events/$")({beforeLoad:({params:e})=>{const t=IC(e._splat||"");if(!t.typeSegment||!t.isEntityDetail||Ri(t.typeSegment))throw y2()},component:Ae(bwe,"component"),validateSearch:e=>Dt(e)}),Mwe=_e("/$owner/entity-types/new")({beforeLoad:({params:e})=>{throw ca({to:"/$owner/memory",params:{owner:e.owner},search:{create_type:"true"},replace:!0})}}),Swe=()=>Ee(()=>import("./_slug-CnQDfsCE.js"),__vite__mapDeps([62,45,23,11,12,10])),_we=_e("/$owner/entity-types/$slug")({component:Ae(Swe,"component")}),Cwe=()=>Ee(()=>import("./deployments-C5kSeowq.js"),[]),Awe=_e("/$owner/connectors/deployments")({component:Ae(Cwe,"component")});function rA({className:e,children:t}){return h.jsx("div",{className:ye("mx-auto w-full max-w-3xl",e),children:t})}function uEe({header:e,children:t}){return h.jsxs(rA,{className:"flex min-h-0 min-w-0 flex-1 flex-col",children:[h.jsx("div",{className:"sticky top-0 z-10 space-y-4 bg-background pb-1",children:e}),h.jsx("div",{className:"mt-4 min-w-0 flex-1 space-y-7",children:t})]})}const Ewe="min-w-0 truncate text-sm text-muted-foreground transition-colors hover:text-foreground hover:underline";function Rwe({crumbs:e}){return e.length===0?null:h.jsx("nav",{"aria-label":"Breadcrumb",className:"flex min-w-0 flex-wrap items-center gap-1.5",children:e.map((t,n)=>h.jsxs("span",{className:"flex min-w-0 items-center gap-1.5",children:[n>0?h.jsx(da,{className:"h-3.5 w-3.5 shrink-0 text-muted-foreground/50"}):null,t]},n))})}function jwe({breadcrumb:e,icon:t,title:n,badge:a,status:o,meta:s,caption:l,captionTone:c="muted"}){const d=h.jsxs("div",{className:"flex min-w-0 flex-1 flex-wrap items-center justify-between gap-x-3 gap-y-1",children:[h.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-x-2.5 gap-y-1",children:[typeof n=="string"?h.jsx("h1",{className:"text-2xl font-semibold leading-none tracking-tight",children:n}):n,a,o]}),s?h.jsx("div",{className:"flex flex-wrap items-center gap-x-4 gap-y-1 text-xs text-muted-foreground",children:s}):null]}),f=l?h.jsx("p",{className:ye("max-w-2xl text-base leading-relaxed",c==="error"?"text-destructive":"text-muted-foreground"),children:l}):null;return h.jsxs("div",{className:"flex flex-col gap-2",children:[e,t?h.jsxs("div",{className:"flex min-w-0 items-center gap-3",children:[h.jsx("div",{className:"shrink-0",children:t}),d]}):d,f]})}function on({className:e,variant:t="default",...n}){const a={default:"bg-primary text-primary-foreground",secondary:"bg-secondary text-secondary-foreground",destructive:"bg-destructive text-destructive-foreground",outline:"border border-current bg-transparent"};return h.jsx("span",{"data-slot":"badge",className:`inline-flex items-center gap-1 rounded-md px-2 py-0.5 text-xs font-medium ${a[t]} ${e||""}`,...n})}function Owe({badges:e}){return e.length===0?null:h.jsx("div",{className:"mt-auto flex flex-wrap items-center gap-1.5",children:e.map(t=>h.jsx(on,{variant:"secondary",className:"h-4 shrink-0 px-1.5 py-0 text-[10px]",children:t},t))})}function Nwe({count:e=4}){return h.jsx("div",{className:"grid grid-cols-1 gap-2",role:"status","aria-label":"Loading catalog",children:Array.from({length:e}).map((t,n)=>h.jsx(ft,{className:"h-16 w-full rounded-lg"},n))})}function Twe({count:e=8}){return h.jsx("div",{className:"overflow-hidden rounded-lg border",role:"status","aria-label":"Loading connector catalog",children:Array.from({length:e}).map((t,n)=>h.jsxs("div",{className:`flex items-center gap-3 bg-card px-3 py-2.5 ${n===e-1?"":"border-b"}`,children:[h.jsx(ft,{className:"h-8 w-8 shrink-0 rounded-lg"}),h.jsxs("div",{className:"min-w-0 flex-1 space-y-1.5",children:[h.jsx(ft,{className:"h-3.5 w-24 rounded"}),h.jsx(ft,{className:"h-3 w-48 max-w-full rounded"})]}),h.jsx(ft,{className:"h-4 w-14 shrink-0 rounded-full"}),h.jsx(ft,{className:"h-4 w-4 shrink-0 rounded"})]},n))})}function dEe({count:e=4,withSearch:t=!0}){return h.jsxs("div",{className:"space-y-3",role:"status","aria-label":"Loading catalog",children:[t?h.jsx(ft,{className:"h-9 w-full rounded-md"}):null,h.jsx(Nwe,{count:e})]})}function hEe({items:e,searchQuery:t,onSearchChange:n,onSelect:a,emptyMessage:o,searchPlaceholder:s="Search...",searchAriaLabel:l="Search catalog",renderTitle:c}){return h.jsxs("div",{className:"space-y-3",children:[h.jsxs("div",{className:"relative",children:[h.jsx(r1,{className:"absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground"}),h.jsx(Lt,{"aria-label":l,placeholder:s,value:t,onChange:d=>n(d.target.value),className:"pl-9"})]}),e.length===0?h.jsx("p",{className:"py-4 text-center text-sm text-muted-foreground",children:o??`No items match "${t}"`}):h.jsx("div",{className:"overflow-hidden rounded-lg border",children:e.map((d,f)=>h.jsxs("button",{type:"button",className:"flex w-full items-center gap-3 bg-card px-4 py-3 text-left text-muted-foreground transition-colors hover:bg-accent/50 hover:text-foreground"+(f===e.length-1?"":" border-b"),onClick:()=>a(d),children:[h.jsxs("div",{className:"min-w-0 flex-1",children:[h.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[c?c(d):h.jsx("span",{className:"text-sm font-medium text-foreground",children:d.name}),h.jsx(Owe,{badges:d.badges})]}),d.description?h.jsx("p",{className:"line-clamp-1 text-xs text-muted-foreground",children:d.description}):null]}),h.jsx(da,{className:"h-4 w-4 shrink-0 text-muted-foreground"})]},d.key))})]})}function Pwe(e){return e?e.charAt(0).toUpperCase()+e.slice(1):"App"}function Lwe(e,{recovery:t=!1,installShape:n}={}){if(!t||n==="oauth-code-exchange")return e;const a=new URL(e);return a.searchParams.set("recovery","1"),a.toString()}function Xm({organizationId:e,connectorKey:t,provider:n,providerLabel:a,recovery:o=!1,installShape:s,size:l="sm",variant:c,className:d,label:f,icon:p}){const y=q9(e,t),k=y.data?.options.find(S=>S.kind==="local");if(!e||y.isPending)return h.jsx("span",{className:"text-sm text-muted-foreground",children:"Checking app setup…"});if(y.isError)return h.jsxs("div",{className:"space-y-1",children:[h.jsx("p",{className:"text-sm text-muted-foreground",children:"App setup could not be checked."}),h.jsx(ge,{variant:"link",className:"px-0",onClick:()=>void y.refetch(),children:"Retry app setup"})]});if(!k?.configured||!k.url)return h.jsx("p",{className:"text-sm text-muted-foreground",children:"This server has no app configured. Choose an available connection option or configure your own app."});const v=a??Pwe(n),w=f??`${o?"Reconnect":"Connect"} ${v}`;return h.jsx(ge,{asChild:!0,size:l,variant:c,className:d,children:h.jsxs("a",{href:Lwe(k.url,{recovery:o,installShape:s}),children:[p,w]})})}const zwe=[{key:"data",label:"Data",icon:UM},{key:"chat",label:"Chat",icon:JM},{key:"actions",label:"Actions",icon:d7},{key:"audience",label:"Audience",icon:Ug},{key:"inference",label:"Inference",icon:$M},{key:"runtime",label:"Runtime",icon:DM}];function Jm({facets:e,className:t}){if(!e)return null;const n=zwe.filter(a=>e[a.key]);return n.length===0?null:h.jsx("div",{className:ye("flex flex-wrap items-center gap-1",t),children:n.map(({key:a,label:o,icon:s})=>h.jsxs(on,{variant:"secondary",className:"bg-muted text-muted-foreground",children:[h.jsx(s,{className:"h-3 w-3"}),o]},a))})}function Dwe({data:e,error:t,retry:n}){const a=e?.options.filter(s=>s.kind!=="local"&&s.configured&&!!s.url)??[],o=t||e?.cloud_status==="unavailable";return!a.length&&!o?null:h.jsxs("section",{"aria-label":"Available connection options",className:"space-y-3",children:[o&&h.jsxs("div",{role:"status",className:"text-sm text-muted-foreground",children:[h.jsx("p",{children:"Cloud connection options could not be checked. You can retry or continue with your own app."}),n&&h.jsx(ge,{variant:"link",className:"px-0",onClick:n,children:"Retry cloud discovery"})]}),a.map(s=>h.jsxs("div",{className:"space-y-1.5",children:[h.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[s.url&&h.jsx(ge,{asChild:!0,variant:"outline",children:h.jsx("a",{href:s.url,target:"_blank",rel:"noopener noreferrer",children:s.label})}),h.jsx("span",{className:"text-xs text-muted-foreground",children:s.execution==="cloud"?"Runs in Lobu Cloud":"Available for local execution"})]}),h.jsx("p",{className:"text-sm text-muted-foreground",children:s.description}),h.jsxs("details",{className:"text-xs text-muted-foreground",children:[h.jsx("summary",{className:"cursor-pointer",children:"Setup steps"}),h.jsx("p",{className:"pt-1",children:s.instructions})]})]},`${s.kind}:${s.managed_by_org??s.url}`))]})}function eg({organizationId:e,connectorKey:t}){const n=q9(e,t);return!e||n.isPending?h.jsx("p",{role:"status",className:"text-sm text-muted-foreground",children:"Checking connection options…"}):h.jsx(Dwe,{data:n.data,error:n.isError,retry:()=>void n.refetch()})}function L8(e,[t,n]){return Math.min(n,Math.max(t,e))}function oA(e){const t=b.useRef({value:e,previous:e});return b.useMemo(()=>(t.current.value!==e&&(t.current.previous=t.current.value,t.current.value=e),t.current.previous),[e])}var Iwe=[" ","Enter","ArrowUp","ArrowDown"],qwe=[" ","Enter"],Cs="Select",[y0,m0,Hwe]=Fk(Cs),[zs]=dr(Cs,[Hwe,Ti]),g0=Ti(),[Vwe,Pi]=zs(Cs),[Fwe,Bwe]=zs(Cs),$we="SelectProvider";function iA(e){const{__scopeSelect:t,children:n,open:a,defaultOpen:o,onOpenChange:s,value:l,defaultValue:c,onValueChange:d,dir:f,name:p,autoComplete:y,disabled:k,required:v,form:w,internal_do_not_use_render:S}=e,_=g0(t),[C,A]=b.useState(null),[j,N]=b.useState(null),[I,T]=b.useState(!1),q=Bk(f),[R,H]=fo({prop:a,defaultProp:o??!1,onChange:s,caller:Cs}),[D,G]=fo({prop:l,defaultProp:c,onChange:d,caller:Cs}),$=b.useRef(null),X=C?!!w||!!C.closest("form"):!0,[F,W]=b.useState(new Set),P=Ya(),U=Array.from(F).map(B=>B.props.value).join(";"),J=b.useCallback(B=>{W(V=>new Set(V).add(B))},[]),se=b.useCallback(B=>{W(V=>{const O=new Set(V);return O.delete(B),O})},[]),L={required:v,trigger:C,onTriggerChange:A,valueNode:j,onValueNodeChange:N,valueNodeHasChildren:I,onValueNodeHasChildrenChange:T,contentId:P,value:D,onValueChange:G,open:R,onOpenChange:H,dir:q,triggerPointerDownPosRef:$,disabled:k,name:p,autoComplete:y,form:w,nativeOptions:F,nativeSelectKey:U,isFormControl:X};return h.jsx(i0,{..._,children:h.jsx(Vwe,{scope:t,...L,children:h.jsx(y0.Provider,{scope:t,children:h.jsx(Fwe,{scope:t,onNativeOptionAdd:J,onNativeOptionRemove:se,children:iMe(S)?S(L):n})})})})}iA.displayName=$we;var sA=e=>{const{__scopeSelect:t,children:n,...a}=e;return h.jsx(iA,{__scopeSelect:t,...a,internal_do_not_use_render:({isFormControl:o})=>h.jsxs(h.Fragment,{children:[n,o?h.jsx(EA,{__scopeSelect:t}):null]})})};sA.displayName=Cs;var lA="SelectTrigger",lv=b.forwardRef((e,t)=>{const{__scopeSelect:n,disabled:a=!1,...o}=e,s=g0(n),l=Pi(lA,n),c=l.disabled||a,d=it(t,l.onTriggerChange),f=m0(n),p=b.useRef("touch"),[y,k,v]=RA(S=>{const _=f().filter(j=>!j.disabled),C=_.find(j=>j.value===l.value),A=jA(_,S,C);A!==void 0&&l.onValueChange(A.value)}),w=S=>{c||(l.onOpenChange(!0),v()),S&&(l.triggerPointerDownPosRef.current={x:Math.round(S.pageX),y:Math.round(S.pageY)})};return h.jsx(b1,{asChild:!0,...s,children:h.jsx(He.button,{type:"button",role:"combobox","aria-controls":l.open?l.contentId:void 0,"aria-expanded":l.open,"aria-required":l.required,"aria-autocomplete":"none",dir:l.dir,"data-state":l.open?"open":"closed",disabled:c,"data-disabled":c?"":void 0,"data-placeholder":k0(l.value)?"":void 0,...o,ref:d,onClick:xe(o.onClick,S=>{S.currentTarget.focus(),p.current!=="mouse"&&w(S)}),onPointerDown:xe(o.onPointerDown,S=>{p.current=S.pointerType;const _=S.target;_.hasPointerCapture(S.pointerId)&&_.releasePointerCapture(S.pointerId),S.button===0&&S.ctrlKey===!1&&S.pointerType==="mouse"&&(w(S),S.preventDefault())}),onKeyDown:xe(o.onKeyDown,S=>{const _=y.current!=="";!(S.ctrlKey||S.altKey||S.metaKey)&&S.key.length===1&&k(S.key),!(_&&S.key===" ")&&Iwe.includes(S.key)&&(w(),S.preventDefault())})})})});lv.displayName=lA;var cA="SelectValue",uA=b.forwardRef((e,t)=>{const{__scopeSelect:n,className:a,style:o,children:s,placeholder:l="",...c}=e,d=Pi(cA,n),{onValueNodeHasChildrenChange:f}=d,p=s!==void 0,y=it(t,d.onValueNodeChange);Mn(()=>{f(p)},[f,p]);const k=k0(d.value);return h.jsx(He.span,{...c,asChild:k?!1:c.asChild,ref:y,style:{pointerEvents:"none"},children:h.jsx(b.Fragment,{children:k?l:s},k?"placeholder":"value")})});uA.displayName=cA;var Uwe="SelectIcon",dA=b.forwardRef((e,t)=>{const{__scopeSelect:n,children:a,...o}=e;return h.jsx(He.span,{"aria-hidden":!0,...o,ref:t,children:a||"▼"})});dA.displayName=Uwe;var hA="SelectPortal",[Kwe,Gwe]=zs(hA,{forceMount:void 0}),fA=e=>{const{__scopeSelect:t,forceMount:n,...a}=e;return h.jsx(Kwe,{scope:e.__scopeSelect,forceMount:n,children:h.jsx(rc,{asChild:!0,...a})})};fA.displayName=hA;var Ei="SelectContent",cv=b.forwardRef((e,t)=>{const n=Gwe(Ei,e.__scopeSelect),{forceMount:a=n.forceMount,...o}=e,s=Pi(Ei,e.__scopeSelect),[l,c]=b.useState();return Mn(()=>{c(new DocumentFragment)},[]),h.jsx(Gn,{present:a||s.open,children:({present:d})=>d?h.jsx(mA,{...o,ref:t}):h.jsx(pA,{...o,fragment:l})})});cv.displayName=Ei;var pA=b.forwardRef((e,t)=>{const{__scopeSelect:n,children:a,fragment:o}=e;return o?go.createPortal(h.jsx(yA,{scope:n,children:h.jsx(y0.Slot,{scope:n,children:h.jsx("div",{ref:t,children:a})})}),o):null});pA.displayName="SelectContentFragment";var ir=10,[yA,Li]=zs(Ei),Ywe="SelectContentImpl",Wwe=Mi("SelectContent.RemoveScroll"),mA=b.forwardRef((e,t)=>{const{__scopeSelect:n}=e,{position:a="item-aligned",onCloseAutoFocus:o,onEscapeKeyDown:s,onPointerDownOutside:l,side:c,sideOffset:d,align:f,alignOffset:p,arrowPadding:y,collisionBoundary:k,collisionPadding:v,sticky:w,hideWhenDetached:S,avoidCollisions:_,...C}=e,A=Pi(Ei,n),[j,N]=b.useState(null),[I,T]=b.useState(null),q=it(t,oe=>N(oe)),[R,H]=b.useState(null),[D,G]=b.useState(null),$=m0(n),[X,F]=b.useState(!1),W=b.useRef(!1);b.useEffect(()=>{if(j)return i1(j)},[j]),_2();const P=b.useCallback(oe=>{const[de,...pe]=$().map(De=>De.ref.current),[Re]=pe.slice(-1),Pe=document.activeElement;for(const De of oe)if(De===Pe||(De?.scrollIntoView({block:"nearest"}),De===de&&I&&(I.scrollTop=0),De===Re&&I&&(I.scrollTop=I.scrollHeight),De?.focus(),document.activeElement!==Pe))return},[$,I]),U=b.useCallback(()=>P([R,j]),[P,R,j]);b.useEffect(()=>{X&&U()},[X,U]);const{onOpenChange:J,triggerPointerDownPosRef:se}=A;b.useEffect(()=>{if(j){let oe={x:0,y:0};const de=Re=>{oe={x:Math.abs(Math.round(Re.pageX)-(se.current?.x??0)),y:Math.abs(Math.round(Re.pageY)-(se.current?.y??0))}},pe=Re=>{oe.x<=10&&oe.y<=10?Re.preventDefault():Re.composedPath().includes(j)||J(!1),document.removeEventListener("pointermove",de),se.current=null};return se.current!==null&&(document.addEventListener("pointermove",de),document.addEventListener("pointerup",pe,{capture:!0,once:!0})),()=>{document.removeEventListener("pointermove",de),document.removeEventListener("pointerup",pe,{capture:!0})}}},[j,J,se]),b.useEffect(()=>{const oe=()=>J(!1);return window.addEventListener("blur",oe),window.addEventListener("resize",oe),()=>{window.removeEventListener("blur",oe),window.removeEventListener("resize",oe)}},[J]);const[L,B]=RA(oe=>{const de=$().filter(Pe=>!Pe.disabled),pe=de.find(Pe=>Pe.ref.current===document.activeElement),Re=jA(de,oe,pe);Re&&setTimeout(()=>Re.ref.current?.focus())}),V=b.useCallback((oe,de,pe)=>{const Re=!W.current&&!pe;(A.value!==void 0&&A.value===de||Re)&&(H(oe),Re&&(W.current=!0))},[A.value]),O=b.useCallback(()=>j?.focus(),[j]),ee=b.useCallback((oe,de,pe)=>{const Re=!W.current&&!pe;(A.value!==void 0&&A.value===de||Re)&&G(oe)},[A.value]),Q=a==="popper"?tg:gA,ae=Q===tg?{side:c,sideOffset:d,align:f,alignOffset:p,arrowPadding:y,collisionBoundary:k,collisionPadding:v,sticky:w,hideWhenDetached:S,avoidCollisions:_}:{};return h.jsx(yA,{scope:n,content:j,viewport:I,onViewportChange:T,itemRefCallback:V,selectedItem:R,onItemLeave:O,itemTextRefCallback:ee,focusSelectedItem:U,selectedItemText:D,position:a,isPositioned:X,searchRef:L,children:h.jsx(oc,{as:Wwe,allowPinchZoom:!0,children:h.jsx(o1,{asChild:!0,trapped:A.open,onMountAutoFocus:oe=>{oe.preventDefault()},onUnmountAutoFocus:xe(o,oe=>{A.trigger?.focus({preventScroll:!0}),oe.preventDefault()}),children:h.jsx(ac,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:s,onPointerDownOutside:l,onFocusOutside:oe=>oe.preventDefault(),onDismiss:()=>A.onOpenChange(!1),children:h.jsx(Q,{role:"listbox",id:A.contentId,"data-state":A.open?"open":"closed",dir:A.dir,onContextMenu:oe=>oe.preventDefault(),...C,...ae,onPlaced:()=>F(!0),ref:q,style:{display:"flex",flexDirection:"column",outline:"none",...C.style},onKeyDown:xe(C.onKeyDown,oe=>{const de=oe.ctrlKey||oe.altKey||oe.metaKey;if(oe.key==="Tab"&&oe.preventDefault(),!de&&oe.key.length===1&&B(oe.key),["ArrowUp","ArrowDown","Home","End"].includes(oe.key)){let Re=$().filter(Pe=>!Pe.disabled).map(Pe=>Pe.ref.current);if(["ArrowUp","End"].includes(oe.key)&&(Re=Re.slice().reverse()),["ArrowUp","ArrowDown"].includes(oe.key)){const Pe=oe.target,De=Re.indexOf(Pe);Re=Re.slice(De+1)}setTimeout(()=>P(Re)),oe.preventDefault()}})})})})})})});mA.displayName=Ywe;var Zwe="SelectItemAlignedPosition",gA=b.forwardRef((e,t)=>{const{__scopeSelect:n,onPlaced:a,...o}=e,s=Pi(Ei,n),l=Li(Ei,n),[c,d]=b.useState(null),[f,p]=b.useState(null),y=it(t,q=>p(q)),k=m0(n),v=b.useRef(!1),w=b.useRef(!0),{viewport:S,selectedItem:_,selectedItemText:C,focusSelectedItem:A}=l,j=b.useCallback(()=>{if(s.trigger&&s.valueNode&&c&&f&&S&&_&&C){const q=s.trigger.getBoundingClientRect(),R=f.getBoundingClientRect(),H=s.valueNode.getBoundingClientRect(),D=C.getBoundingClientRect();if(s.dir!=="rtl"){const Pe=D.left-R.left,De=H.left-Pe,bt=q.left-De,Ye=q.width+bt,kn=Math.max(Ye,R.width),Qt=window.innerWidth-ir,Xt=L8(De,[ir,Math.max(ir,Qt-kn)]);c.style.minWidth=Ye+"px",c.style.left=Xt+"px"}else{const Pe=R.right-D.right,De=window.innerWidth-H.right-Pe,bt=window.innerWidth-q.right-De,Ye=q.width+bt,kn=Math.max(Ye,R.width),Qt=window.innerWidth-ir,Xt=L8(De,[ir,Math.max(ir,Qt-kn)]);c.style.minWidth=Ye+"px",c.style.right=Xt+"px"}const G=k(),$=window.innerHeight-ir*2,X=S.scrollHeight,F=window.getComputedStyle(f),W=parseInt(F.borderTopWidth,10),P=parseInt(F.paddingTop,10),U=parseInt(F.borderBottomWidth,10),J=parseInt(F.paddingBottom,10),se=W+P+X+J+U,L=Math.min(_.offsetHeight*5,se),B=window.getComputedStyle(S),V=parseInt(B.paddingTop,10),O=parseInt(B.paddingBottom,10),ee=q.top+q.height/2-ir,Q=$-ee,ae=_.offsetHeight/2,oe=_.offsetTop+ae,de=W+P+oe,pe=se-de;if(de<=ee){const Pe=G.length>0&&_===G[G.length-1].ref.current;c.style.bottom="0px";const De=f.clientHeight-S.offsetTop-S.offsetHeight,bt=Math.max(Q,ae+(Pe?O:0)+De+U),Ye=de+bt;c.style.height=Ye+"px"}else{const Pe=G.length>0&&_===G[0].ref.current;c.style.top="0px";const bt=Math.max(ee,W+S.offsetTop+(Pe?V:0)+ae)+pe;c.style.height=bt+"px",S.scrollTop=de-ee+S.offsetTop}c.style.margin=`${ir}px 0`,c.style.minHeight=L+"px",c.style.maxHeight=$+"px",a?.(),requestAnimationFrame(()=>v.current=!0)}},[k,s.trigger,s.valueNode,c,f,S,_,C,s.dir,a]);Mn(()=>j(),[j]);const[N,I]=b.useState();Mn(()=>{f&&I(window.getComputedStyle(f).zIndex)},[f]);const T=b.useCallback(q=>{q&&w.current===!0&&(j(),A?.(),w.current=!1)},[j,A]);return h.jsx(Xwe,{scope:n,contentWrapper:c,shouldExpandOnScrollRef:v,onScrollButtonChange:T,children:h.jsx("div",{ref:d,style:{display:"flex",flexDirection:"column",position:"fixed",zIndex:N},children:h.jsx(He.div,{...o,ref:y,style:{boxSizing:"border-box",maxHeight:"100%",...o.style}})})})});gA.displayName=Zwe;var Qwe="SelectPopperPosition",tg=b.forwardRef((e,t)=>{const{__scopeSelect:n,align:a="start",collisionPadding:o=ir,...s}=e,l=g0(n);return h.jsx(s0,{...l,...s,ref:t,align:a,collisionPadding:o,style:{boxSizing:"border-box",...s.style,"--radix-select-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-select-content-available-width":"var(--radix-popper-available-width)","--radix-select-content-available-height":"var(--radix-popper-available-height)","--radix-select-trigger-width":"var(--radix-popper-anchor-width)","--radix-select-trigger-height":"var(--radix-popper-anchor-height)"}})});tg.displayName=Qwe;var[Xwe,uv]=zs(Ei,{}),ng="SelectViewport",kA=b.forwardRef((e,t)=>{const{__scopeSelect:n,nonce:a,...o}=e,s=Li(ng,n),l=uv(ng,n),c=it(t,s.onViewportChange),d=b.useRef(0);return h.jsxs(h.Fragment,{children:[h.jsx("style",{dangerouslySetInnerHTML:{__html:"[data-radix-select-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-select-viewport]::-webkit-scrollbar{display:none}"},nonce:a}),h.jsx(y0.Slot,{scope:n,children:h.jsx(He.div,{"data-radix-select-viewport":"",role:"presentation",...o,ref:c,style:{position:"relative",flex:1,overflow:"hidden auto",...o.style},onScroll:xe(o.onScroll,f=>{const p=f.currentTarget,{contentWrapper:y,shouldExpandOnScrollRef:k}=l;if(k?.current&&y){const v=Math.abs(d.current-p.scrollTop);if(v>0){const w=window.innerHeight-ir*2,S=parseFloat(y.style.minHeight),_=parseFloat(y.style.height),C=Math.max(S,_);if(C<w){const A=C+v,j=Math.min(w,A),N=A-j;y.style.height=j+"px",y.style.bottom==="0px"&&(p.scrollTop=N>0?N:0,y.style.justifyContent="flex-end")}}}d.current=p.scrollTop})})})]})});kA.displayName=ng;var vA="SelectGroup",[Jwe,eMe]=zs(vA),tMe=b.forwardRef((e,t)=>{const{__scopeSelect:n,...a}=e,o=Ya();return h.jsx(Jwe,{scope:n,id:o,children:h.jsx(He.div,{role:"group","aria-labelledby":o,...a,ref:t})})});tMe.displayName=vA;var xA="SelectLabel",nMe=b.forwardRef((e,t)=>{const{__scopeSelect:n,...a}=e,o=eMe(xA,n);return h.jsx(He.div,{id:o.id,...a,ref:t})});nMe.displayName=xA;var l2="SelectItem",[aMe,bA]=zs(l2),dv=b.forwardRef((e,t)=>{const{__scopeSelect:n,value:a,disabled:o=!1,textValue:s,...l}=e,c=Pi(l2,n),d=Li(l2,n),f=c.value===a,[p,y]=b.useState(s??""),[k,v]=b.useState(!1),w=it(t,A=>d.itemRefCallback?.(A,a,o)),S=Ya(),_=b.useRef("touch"),C=()=>{o||(c.onValueChange(a),c.onOpenChange(!1))};return h.jsx(aMe,{scope:n,value:a,disabled:o,textId:S,isSelected:f,onItemTextChange:b.useCallback(A=>{y(j=>j||(A?.textContent??"").trim())},[]),children:h.jsx(y0.ItemSlot,{scope:n,value:a,disabled:o,textValue:p,children:h.jsx(He.div,{role:"option","aria-labelledby":S,"data-highlighted":k?"":void 0,"aria-selected":f&&k,"data-state":f?"checked":"unchecked","aria-disabled":o||void 0,"data-disabled":o?"":void 0,tabIndex:o?void 0:-1,...l,ref:w,onFocus:xe(l.onFocus,()=>v(!0)),onBlur:xe(l.onBlur,()=>v(!1)),onClick:xe(l.onClick,()=>{_.current!=="mouse"&&C()}),onPointerUp:xe(l.onPointerUp,()=>{_.current==="mouse"&&C()}),onPointerDown:xe(l.onPointerDown,A=>{_.current=A.pointerType}),onPointerMove:xe(l.onPointerMove,A=>{_.current=A.pointerType,o?d.onItemLeave?.():_.current==="mouse"&&A.currentTarget.focus({preventScroll:!0})}),onPointerLeave:xe(l.onPointerLeave,A=>{A.currentTarget===document.activeElement&&d.onItemLeave?.()}),onKeyDown:xe(l.onKeyDown,A=>{d.searchRef?.current!==""&&A.key===" "||(qwe.includes(A.key)&&C(),A.key===" "&&A.preventDefault())})})})})});dv.displayName=l2;var Su="SelectItemText",wA=b.forwardRef((e,t)=>{const{__scopeSelect:n,className:a,style:o,...s}=e,l=Pi(Su,n),c=Li(Su,n),d=bA(Su,n),f=Bwe(Su,n),[p,y]=b.useState(null),k=it(t,C=>y(C),d.onItemTextChange,C=>c.itemTextRefCallback?.(C,d.value,d.disabled)),v=p?.textContent,w=b.useMemo(()=>h.jsx("option",{value:d.value,disabled:d.disabled,children:v},d.value),[d.disabled,d.value,v]),{onNativeOptionAdd:S,onNativeOptionRemove:_}=f;return Mn(()=>(S(w),()=>_(w)),[S,_,w]),h.jsxs(h.Fragment,{children:[h.jsx(He.span,{id:d.textId,...s,ref:k}),d.isSelected&&l.valueNode&&!l.valueNodeHasChildren&&!k0(l.value)?go.createPortal(s.children,l.valueNode):null]})});wA.displayName=Su;var MA="SelectItemIndicator",SA=b.forwardRef((e,t)=>{const{__scopeSelect:n,...a}=e;return bA(MA,n).isSelected?h.jsx(He.span,{"aria-hidden":!0,...a,ref:t}):null});SA.displayName=MA;var ag="SelectScrollUpButton",hv=b.forwardRef((e,t)=>{const n=Li(ag,e.__scopeSelect),a=uv(ag,e.__scopeSelect),[o,s]=b.useState(!1),l=it(t,a.onScrollButtonChange);return Mn(()=>{if(n.viewport&&n.isPositioned){let c=function(){const f=d.scrollTop>0;s(f)};const d=n.viewport;return c(),d.addEventListener("scroll",c),()=>d.removeEventListener("scroll",c)}},[n.viewport,n.isPositioned]),o?h.jsx(_A,{...e,ref:l,onAutoScroll:()=>{const{viewport:c,selectedItem:d}=n;c&&d&&(c.scrollTop=c.scrollTop-d.offsetHeight)}}):null});hv.displayName=ag;var rg="SelectScrollDownButton",fv=b.forwardRef((e,t)=>{const n=Li(rg,e.__scopeSelect),a=uv(rg,e.__scopeSelect),[o,s]=b.useState(!1),l=it(t,a.onScrollButtonChange);return Mn(()=>{if(n.viewport&&n.isPositioned){let c=function(){const f=d.scrollHeight-d.clientHeight,p=Math.ceil(d.scrollTop)<f;s(p)};const d=n.viewport;return c(),d.addEventListener("scroll",c),()=>d.removeEventListener("scroll",c)}},[n.viewport,n.isPositioned]),o?h.jsx(_A,{...e,ref:l,onAutoScroll:()=>{const{viewport:c,selectedItem:d}=n;c&&d&&(c.scrollTop=c.scrollTop+d.offsetHeight)}}):null});fv.displayName=rg;var _A=b.forwardRef((e,t)=>{const{__scopeSelect:n,onAutoScroll:a,...o}=e,s=Li("SelectScrollButton",n),l=b.useRef(null),c=m0(n),d=b.useCallback(()=>{l.current!==null&&(window.clearInterval(l.current),l.current=null)},[]);return b.useEffect(()=>()=>d(),[d]),Mn(()=>{c().find(p=>p.ref.current===document.activeElement)?.ref.current?.scrollIntoView({block:"nearest"})},[c]),h.jsx(He.div,{"aria-hidden":!0,...o,ref:t,style:{flexShrink:0,...o.style},onPointerDown:xe(o.onPointerDown,()=>{l.current===null&&(l.current=window.setInterval(a,50))}),onPointerMove:xe(o.onPointerMove,()=>{s.onItemLeave?.(),l.current===null&&(l.current=window.setInterval(a,50))}),onPointerLeave:xe(o.onPointerLeave,()=>{d()})})}),rMe="SelectSeparator",pv=b.forwardRef((e,t)=>{const{__scopeSelect:n,...a}=e;return h.jsx(He.div,{"aria-hidden":!0,...a,ref:t})});pv.displayName=rMe;var CA="SelectArrow",oMe=b.forwardRef((e,t)=>{const{__scopeSelect:n,...a}=e,o=g0(n);return Li(CA,n).position==="popper"?h.jsx(l0,{...o,...a,ref:t}):null});oMe.displayName=CA;var AA="SelectBubbleInput",EA=b.forwardRef(({__scopeSelect:e,...t},n)=>{const a=Pi(AA,e),{value:o,onValueChange:s,required:l,disabled:c,name:d,autoComplete:f,form:p}=a,{nativeOptions:y,nativeSelectKey:k}=a,v=b.useRef(null),w=it(n,v),S=o??"",_=oA(S),C=Array.from(y).some(A=>(A.props.value??"")==="");return b.useEffect(()=>{const A=v.current;if(!A)return;const j=window.HTMLSelectElement.prototype,I=Object.getOwnPropertyDescriptor(j,"value").set;if(_!==S&&I){const T=new Event("change",{bubbles:!0});I.call(A,S),A.dispatchEvent(T)}},[_,S]),h.jsxs(He.select,{"aria-hidden":!0,required:l,tabIndex:-1,name:d,autoComplete:f,disabled:c,form:p,onChange:A=>s(A.target.value),...t,style:{...GC,...t.style},ref:w,defaultValue:S,children:[k0(o)&&!C?h.jsx("option",{value:""}):null,Array.from(y)]},k)});EA.displayName=AA;function iMe(e){return typeof e=="function"}function k0(e){return e===""||e===void 0}function RA(e){const t=Nr(e),n=b.useRef(""),a=b.useRef(0),o=b.useCallback(l=>{const c=n.current+l;t(c),(function d(f){n.current=f,window.clearTimeout(a.current),f!==""&&(a.current=window.setTimeout(()=>d(""),1e3))})(c)},[t]),s=b.useCallback(()=>{n.current="",window.clearTimeout(a.current)},[]);return b.useEffect(()=>()=>window.clearTimeout(a.current),[]),[n,o,s]}function jA(e,t,n){const o=t.length>1&&Array.from(t).every(f=>f===t[0])?t[0]:t,s=n?e.indexOf(n):-1;let l=sMe(e,Math.max(s,0));o.length===1&&(l=l.filter(f=>f!==n));const d=l.find(f=>f.textValue.toLowerCase().startsWith(o.toLowerCase()));return d!==n?d:void 0}function sMe(e,t){return e.map((n,a)=>e[(t+a)%e.length])}const si=sA,li=uA,io=b.forwardRef(({className:e,children:t,...n},a)=>h.jsxs(lv,{ref:a,className:ye("flex h-9 w-full items-center justify-between whitespace-nowrap rounded-md border border-input bg-muted px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus:outline-none focus:ring-1 focus:ring-ring disabled:cursor-not-allowed disabled:opacity-50 [&>span]:line-clamp-1",e),...n,children:[t,h.jsx(dA,{asChild:!0,children:h.jsx(n1,{className:"h-4 w-4 opacity-50"})})]}));io.displayName=lv.displayName;const OA=b.forwardRef(({className:e,...t},n)=>h.jsx(hv,{ref:n,className:ye("flex cursor-default items-center justify-center py-1",e),...t,children:h.jsx(HM,{className:"h-4 w-4"})}));OA.displayName=hv.displayName;const NA=b.forwardRef(({className:e,...t},n)=>h.jsx(fv,{ref:n,className:ye("flex cursor-default items-center justify-center py-1",e),...t,children:h.jsx(n1,{className:"h-4 w-4"})}));NA.displayName=fv.displayName;const so=b.forwardRef(({className:e,children:t,position:n="popper",...a},o)=>h.jsx(fA,{children:h.jsxs(cv,{ref:o,className:ye("relative z-50 max-h-96 min-w-[8rem] overflow-hidden rounded-md border border-border bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",n==="popper"&&"data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1",e),position:n,...a,children:[h.jsx(OA,{}),h.jsx(kA,{className:ye("p-1",n==="popper"&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"),children:t}),h.jsx(NA,{})]})}));so.displayName=cv.displayName;const Bn=b.forwardRef(({className:e,children:t,...n},a)=>h.jsxs(dv,{ref:a,className:ye("relative flex w-full cursor-default select-none items-center rounded-sm py-1.5 pl-2 pr-8 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",e),...n,children:[h.jsx("span",{className:"absolute right-2 flex h-3.5 w-3.5 items-center justify-center",children:h.jsx(SA,{children:h.jsx(Za,{className:"h-4 w-4"})})}),h.jsx(wA,{children:t})]}));Bn.displayName=dv.displayName;const lMe=b.forwardRef(({className:e,...t},n)=>h.jsx(pv,{ref:n,className:ye("-mx-1 my-1 h-px bg-muted",e),...t}));lMe.displayName=pv.displayName;function TA({device:e}){const t=s4e(e.app_version),n=l4e(e,t);return h.jsx(Bn,{value:e.id,children:h.jsxs("span",{className:"flex items-center gap-2",children:[h.jsx(c4e,{online:e.online}),h.jsx(p_,{platform:Ik(e)}),h.jsx("span",{children:i4e(e)}),n?h.jsxs("span",{className:"text-xs text-muted-foreground",children:["· ",n]}):null,e.online?null:h.jsx("span",{className:"text-xs text-muted-foreground",children:"· offline"})]})})}var v0="Popover",[PA]=dr(v0,[Ti]),C1=Ti(),[cMe,zi]=PA(v0),LA=e=>{const{__scopePopover:t,children:n,open:a,defaultOpen:o,onOpenChange:s,modal:l=!1}=e,c=C1(t),d=b.useRef(null),[f,p]=b.useState(!1),[y,k]=fo({prop:a,defaultProp:o??!1,onChange:s,caller:v0});return h.jsx(i0,{...c,children:h.jsx(cMe,{scope:t,contentId:Ya(),triggerRef:d,open:y,onOpenChange:k,onOpenToggle:b.useCallback(()=>k(v=>!v),[k]),hasCustomAnchor:f,onCustomAnchorAdd:b.useCallback(()=>p(!0),[]),onCustomAnchorRemove:b.useCallback(()=>p(!1),[]),modal:l,children:n})})};LA.displayName=v0;var zA="PopoverAnchor",uMe=b.forwardRef((e,t)=>{const{__scopePopover:n,...a}=e,o=zi(zA,n),s=C1(n),{onCustomAnchorAdd:l,onCustomAnchorRemove:c}=o;return b.useEffect(()=>(l(),()=>c()),[l,c]),h.jsx(b1,{...s,...a,ref:t})});uMe.displayName=zA;var DA="PopoverTrigger",IA=b.forwardRef((e,t)=>{const{__scopePopover:n,...a}=e,o=zi(DA,n),s=C1(n),l=it(t,o.triggerRef),c=h.jsx(He.button,{type:"button","aria-haspopup":"dialog","aria-expanded":o.open,"aria-controls":o.open?o.contentId:void 0,"data-state":BA(o.open),...a,ref:l,onClick:xe(e.onClick,o.onOpenToggle)});return o.hasCustomAnchor?c:h.jsx(b1,{asChild:!0,...s,children:c})});IA.displayName=DA;var yv="PopoverPortal",[dMe,hMe]=PA(yv,{forceMount:void 0}),qA=e=>{const{__scopePopover:t,forceMount:n,children:a,container:o}=e,s=zi(yv,t);return h.jsx(dMe,{scope:t,forceMount:n,children:h.jsx(Gn,{present:n||s.open,children:h.jsx(rc,{asChild:!0,container:o,children:a})})})};qA.displayName=yv;var ec="PopoverContent",HA=b.forwardRef((e,t)=>{const n=hMe(ec,e.__scopePopover),{forceMount:a=n.forceMount,...o}=e,s=zi(ec,e.__scopePopover);return h.jsx(Gn,{present:a||s.open,children:s.modal?h.jsx(pMe,{...o,ref:t}):h.jsx(yMe,{...o,ref:t})})});HA.displayName=ec;var fMe=Mi("PopoverContent.RemoveScroll"),pMe=b.forwardRef((e,t)=>{const n=zi(ec,e.__scopePopover),a=b.useRef(null),o=it(t,a),s=b.useRef(!1);return b.useEffect(()=>{const l=a.current;if(l)return i1(l)},[]),h.jsx(oc,{as:fMe,allowPinchZoom:!0,children:h.jsx(VA,{...e,ref:o,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:xe(e.onCloseAutoFocus,l=>{l.preventDefault(),s.current||n.triggerRef.current?.focus()}),onPointerDownOutside:xe(e.onPointerDownOutside,l=>{const c=l.detail.originalEvent,d=c.button===0&&c.ctrlKey===!0,f=c.button===2||d;s.current=f},{checkForDefaultPrevented:!1}),onFocusOutside:xe(e.onFocusOutside,l=>l.preventDefault(),{checkForDefaultPrevented:!1})})})}),yMe=b.forwardRef((e,t)=>{const n=zi(ec,e.__scopePopover),a=b.useRef(!1),o=b.useRef(!1);return h.jsx(VA,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:s=>{e.onCloseAutoFocus?.(s),s.defaultPrevented||(a.current||n.triggerRef.current?.focus(),s.preventDefault()),a.current=!1,o.current=!1},onInteractOutside:s=>{e.onInteractOutside?.(s),s.defaultPrevented||(a.current=!0,s.detail.originalEvent.type==="pointerdown"&&(o.current=!0));const l=s.target;n.triggerRef.current?.contains(l)&&s.preventDefault(),s.detail.originalEvent.type==="focusin"&&o.current&&s.preventDefault()}})}),VA=b.forwardRef((e,t)=>{const{__scopePopover:n,trapFocus:a,onOpenAutoFocus:o,onCloseAutoFocus:s,disableOutsidePointerEvents:l,onEscapeKeyDown:c,onPointerDownOutside:d,onFocusOutside:f,onInteractOutside:p,...y}=e,k=zi(ec,n),v=C1(n);return _2(),h.jsx(o1,{asChild:!0,loop:!0,trapped:a,onMountAutoFocus:o,onUnmountAutoFocus:s,children:h.jsx(ac,{asChild:!0,disableOutsidePointerEvents:l,onInteractOutside:p,onEscapeKeyDown:c,onPointerDownOutside:d,onFocusOutside:f,onDismiss:()=>k.onOpenChange(!1),deferPointerDownOutside:!0,children:h.jsx(s0,{"data-state":BA(k.open),role:"dialog",id:k.contentId,...v,...y,ref:t,style:{...y.style,"--radix-popover-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-popover-content-available-width":"var(--radix-popper-available-width)","--radix-popover-content-available-height":"var(--radix-popper-available-height)","--radix-popover-trigger-width":"var(--radix-popper-anchor-width)","--radix-popover-trigger-height":"var(--radix-popper-anchor-height)"}})})})}),FA="PopoverClose",mMe=b.forwardRef((e,t)=>{const{__scopePopover:n,...a}=e,o=zi(FA,n);return h.jsx(He.button,{type:"button",...a,ref:t,onClick:xe(e.onClick,()=>o.onOpenChange(!1))})});mMe.displayName=FA;var gMe="PopoverArrow",kMe=b.forwardRef((e,t)=>{const{__scopePopover:n,...a}=e,o=C1(n);return h.jsx(l0,{...o,...a,ref:t})});kMe.displayName=gMe;function BA(e){return e?"open":"closed"}var vMe=LA,xMe=IA,bMe=qA,$A=HA;const wMe=vMe,MMe=xMe,UA=b.forwardRef(({className:e,align:t="center",sideOffset:n=4,...a},o)=>h.jsx(bMe,{children:h.jsx($A,{ref:o,align:t,sideOffset:n,className:ye("z-50 w-72 rounded-md border border-border bg-popover p-4 text-popover-foreground outline-none data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",e),...a})}));UA.displayName=$A.displayName;function SMe({trigger:e,searchPlaceholder:t,emptyText:n,contentClassName:a,align:o="start",onQueryChange:s,children:l}){const[c,d]=b.useState(!1),[f,p]=b.useState(""),y=k=>{p(k),s?.(k)};return h.jsxs(wMe,{open:c,onOpenChange:k=>{d(k),k||y("")},children:[h.jsx(MMe,{asChild:!0,children:e(c)}),h.jsx(UA,{className:ye("p-0",a),align:o,children:h.jsxs(l1,{shouldFilter:!s,children:[h.jsx(L2,{placeholder:t,value:f,onValueChange:y}),h.jsxs(z2,{children:[h.jsx(D2,{children:n}),h.jsx(Ka,{children:l(()=>{d(!1),y("")},f)})]})]})})]})}function mv(e){const{session:t}=Xa(),{data:n=[],isLoading:a}=st({queryKey:["org-members",e],queryFn:async()=>e?(await Au.listMembers({query:{organizationId:e}})).data?.members??[]:[],enabled:!!e,staleTime:6e4}),o=t?.user?.id,l=(o?n.find(c=>c.userId===o):void 0)?.role??null;return{members:n,isLoading:a,currentUserRole:l,isAdmin:l==="admin"||l==="owner"}}function z8({member:e,size:t="sm"}){const n=t==="sm"?"h-5 w-5 text-[10px]":"h-6 w-6 text-xs";return e.user.image?h.jsx("img",{src:e.user.image,alt:e.user.name,referrerPolicy:"no-referrer",className:ye("rounded-full object-cover shrink-0",n)}):h.jsx("div",{className:ye("rounded-full bg-muted flex items-center justify-center font-medium shrink-0",n),children:(e.user.name||e.user.email).charAt(0).toUpperCase()})}function _Me({organizationId:e,value:t,onValueChange:n,disabled:a,placeholder:o="Select member...",className:s}){const{members:l,isLoading:c}=mv(e),d=t?l.find(f=>f.userId===t):void 0;return h.jsx(SMe,{contentClassName:"w-[--radix-popover-trigger-width]",searchPlaceholder:"Search members...",emptyText:"No members found.",trigger:f=>h.jsxs(ge,{variant:"outline",role:"combobox","aria-expanded":f,disabled:a||c,className:ye("w-full justify-between font-normal",s),children:[d?h.jsxs("span",{className:"flex items-center gap-2 truncate",children:[h.jsx(z8,{member:d}),h.jsx("span",{className:"truncate",children:d.user.name||d.user.email})]}):h.jsx("span",{className:"text-muted-foreground",children:c?"Loading...":o}),h.jsx(VM,{className:"ml-2 h-4 w-4 shrink-0 opacity-50"})]}),children:f=>h.jsxs(h.Fragment,{children:[t&&h.jsx(On,{value:"__clear__",onSelect:()=>{n(void 0),f()},children:h.jsx("span",{className:"text-muted-foreground",children:"Clear selection"})}),l.map(p=>h.jsxs(On,{value:`${p.user.name} ${p.user.email}`,onSelect:()=>{n(p.userId===t?void 0:p.userId),f()},children:[h.jsx(z8,{member:p}),h.jsxs("div",{className:"min-w-0 flex-1",children:[h.jsx("p",{className:"truncate text-sm",children:p.user.name||p.user.email}),p.user.name&&h.jsx("p",{className:"truncate text-xs text-muted-foreground",children:p.user.email})]}),h.jsx(Za,{className:ye("ml-auto h-4 w-4 shrink-0",t===p.userId?"opacity-100":"opacity-0")})]},p.userId))]})})}function CMe({onCancel:e,cancelLabel:t="Cancel",cancelDisabled:n,children:a,className:o}){return!e&&!a?null:h.jsxs("div",{className:ye("flex items-center justify-end gap-2",o),children:[e?h.jsx(ge,{type:"button",variant:"outline",onClick:e,disabled:n,children:t}):null,a]})}const KA={data:!1,chat:!1,actions:!1,audience:!1,inference:!1,runtime:!0};function Zu(e){return e==="vercel"?"Vercel":e.charAt(0).toUpperCase()+e.slice(1)}function GA(e){return e==="vercel"?"vercel.com":null}function AMe(e){if(!e.startsWith(km))return null;const t=e.slice(km.length);return t.length>0?t:null}function jh(e){if(!e.startsWith(Vh))return null;const t=e.slice(Vh.length);return t.length>0?t:null}function fEe(e){return e.map(t=>({sandbox:t,facets:KA,connector:{key:`${km}${t.id}`,name:t.name||Zu(t.providerKind),description:null,version:"",auth_schema:null,feeds_schema:null,actions_schema:null,options_schema:null,status:t.connected?"active":"error",login_enabled:!1,installed:!0}}))}function EMe(e){return e.map(t=>({key:`${Vh}${t}`,name:Zu(t),description:`Run agents in a ${Zu(t)} sandbox instead of the built-in local runtime.`,version:"",auth_schema:null,feeds_schema:null,actions_schema:null,options_schema:null,status:"active",login_enabled:!1,favicon_domain:GA(t),installed:!1,installable:!1}))}function og(){return KA}function RMe({providerKind:e,credentialFields:t,pending:n,onCancel:a,onCreate:o}){const[s,l]=b.useState(""),[c,d]=b.useState({}),f=Zu(e),p=y=>{y.preventDefault();const k=Object.fromEntries(Object.entries(c).filter(([,v])=>v.trim()));o({name:s.trim(),provider_kind:e,credential:Object.keys(k).length>0?k:void 0})};return h.jsxs("div",{className:"space-y-3",children:[h.jsxs("div",{className:"space-y-0.5",children:[h.jsxs("h3",{className:"text-sm font-medium",children:["Connect ",f]}),h.jsxs("p",{className:"text-xs text-muted-foreground",children:["Add a credential so agents can execute in a ",f," sandbox."]})]}),h.jsxs("form",{onSubmit:p,className:"grid max-w-md gap-3",children:[h.jsxs("div",{className:"grid gap-2",children:[h.jsxs(ha,{htmlFor:"sandbox-name",children:["Name ",h.jsx("span",{className:"ml-1 text-destructive",children:"*"})]}),h.jsx(Lt,{id:"sandbox-name",placeholder:`${f} production`,value:s,onChange:y=>l(y.target.value),required:!0})]}),t.map(y=>h.jsxs("div",{className:"grid gap-2",children:[h.jsxs(ha,{htmlFor:`sandbox-cred-${y.key}`,children:[y.label,y.required?h.jsx("span",{className:"ml-1 text-destructive",children:"*"}):null]}),h.jsx(Lt,{id:`sandbox-cred-${y.key}`,type:y.secret===!1?"text":"password",value:c[y.key]??"",onChange:k=>d(v=>({...v,[y.key]:k.target.value})),autoComplete:"off",required:y.required})]},y.key)),h.jsx(CMe,{onCancel:a,children:h.jsx(ge,{type:"submit",disabled:n||!s.trim(),children:n?h.jsxs(h.Fragment,{children:[h.jsx(dt,{size:"lg",className:"mr-2"}),"Connecting..."]}):`Connect ${f}`})})]})]})}function xs({visible:e,onReload:t}){return e?h.jsxs("div",{role:"alert",className:"rounded-md border border-amber-500/40 bg-amber-500/10 p-3 text-sm",children:[h.jsx("p",{children:"This form changed while you were editing. Your edits are preserved. Reload the latest values before saving."}),h.jsx(ge,{type:"button",variant:"outline",size:"sm",className:"mt-2",onClick:t,children:"Discard edits and reload"})]}):null}function YA({rows:e=4,className:t}){return h.jsxs("div",{role:"status","aria-label":"Loading form",className:ye("space-y-5",t),children:[Array.from({length:e}).map((n,a)=>h.jsxs("div",{className:"space-y-2",children:[h.jsx(ft,{className:"h-3.5 w-24"}),h.jsx(ft,{className:"h-9 w-full rounded-md"})]},a)),h.jsxs("div",{className:"flex items-center gap-2 pt-2",children:[h.jsx(ft,{className:"h-9 w-24 rounded-md"}),h.jsx(ft,{className:"h-9 w-20 rounded-md"})]})]})}function jMe(e){const t=[];e.configSchema&&t.push({title:"Configuration",schema:e.configSchema});for(const[n,a]of Object.entries(e.eventKinds??{}))a.metadataSchema&&t.push({title:n,description:a.description,schema:a.metadataSchema});return{description:e.description,sections:t}}function OMe(e){const t=[];return e.inputSchema&&t.push({title:"Input",schema:e.inputSchema}),e.outputSchema&&t.push({title:"Output",schema:e.outputSchema}),{description:e.description,sections:t}}function WA(){const e=Dk(),t=b.useCallback((a,o,s="")=>{e&&e.open({href:s,title:o.name??a,schemaSections:jMe(o)})},[e]),n=b.useCallback((a,o)=>{e&&e.open({href:"",title:o.name??a,schemaSections:OMe(o)})},[e]);return{inspectFeed:t,inspectAction:n}}const NMe={image:"Image",stt:"Speech-to-text",tts:"Text-to-speech"};function pEe(e){return e.filter(t=>t!=="text").map(t=>NMe[t])}function yEe(e){return e.supportedAuthTypes.some(t=>t==="oauth"||t==="device-code")}function TMe(e){return e.sdkCompat!=null&&e.supportedAuthTypes.includes("api-key")}function Di(e,t=""){return`${pt}/api/${e}/agents/inference-providers${t}`}function mEe(e){const{slug:t}=Hn();return st({queryKey:["inference-providers",t],queryFn:async()=>{const n=await Ge(Di(t??""),{credentials:"include"});return await Un(n,"Failed to load inference providers"),(await n.json()).providers??[]},enabled:!!t&&!0,staleTime:3e4})}function PMe(e){const{slug:t}=Hn();return st({queryKey:["inference-providers-catalog",t],queryFn:async()=>{const n=await Ge(Di(t??"","/catalog"),{credentials:"include"});return await Un(n,"Failed to load inference provider catalog"),(await n.json()).catalog??[]},enabled:!!t&&!0,staleTime:6e4})}const gEe=Ja({method:"POST",url:({slug:e})=>Di(e),body:e=>e,invalidate:()=>[["inference-providers"]],successMessage:"Provider created",errorMessage:"Failed to create provider"}),kEe=Ja({method:"PUT",url:({slug:e,params:t})=>Di(e,`/${t.providerSlug}/capabilities/${t.modality}`),body:e=>({block:e.block}),invalidate:()=>[["inference-providers"]],successMessage:"Capability updated",errorMessage:"Failed to update capability"}),vEe=Ja({method:"PUT",url:({slug:e,params:t})=>Di(e,`/${t.providerSlug}`),body:e=>({displayName:e.displayName}),invalidate:()=>[["inference-providers"]],successMessage:"Provider updated",errorMessage:"Failed to update provider"}),xEe=Ja({method:"PUT",url:({slug:e,params:t})=>Di(e,`/${t.providerSlug}/default`),invalidate:()=>[["inference-providers"]],successMessage:"Default provider set",errorMessage:"Failed to set default provider"}),bEe=Ja({method:"PUT",url:({slug:e,params:t})=>Di(e,`/${t.providerSlug}/key`),body:e=>({value:e.value}),invalidate:()=>[["inference-providers"]],successMessage:"Key rotated",errorMessage:"Failed to rotate key"}),wEe=Ja({method:"DELETE",url:({slug:e,params:t})=>Di(e,`/${t.providerSlug}`),invalidate:()=>[["inference-providers"]],successMessage:"Provider deleted",errorMessage:"Failed to delete provider"});function MEe(e,t){const n=t.find(a=>a.slug===e);return n?TMe(n):!0}function LMe(e){const t=e.trim();if(!t)return null;let n;try{n=new URL(t)}catch{return"Enter a valid URL"}return n.protocol!=="https:"?"Must start with https://":n.username||n.password?"Credentials in the URL aren't allowed":n.search||n.hash?"Query or fragment isn't allowed":null}const zMe=/^\/[A-Za-z0-9/_.-]*$/;function DMe(e){const t=e.trim();return t?t.startsWith("//")?"Can't start with //":zMe.test(t)?null:"Must be a path like /v1/models":null}function IMe(e){return e.length>0&&!e.trim()?"Model can't be blank":null}function SEe(e){const t={},n=LMe(e.base_url??"");n&&(t.base_url=n);const a=IMe(e.model??"");a&&(t.model=a);const o=DMe(e.models_endpoint??"");return o&&(t.models_endpoint=o),t}function _Ee(e){return!!(e.base_url||e.model||e.models_endpoint)}const qMe="https://github.com/lobu-ai/lobu/releases/latest/download/Lobu.dmg",HMe="https://chromewebstore.google.com/detail/jhgcecbdpnoehfnhpdfihlchjddapepi";function VMe(e){const t=new URL(e);return["127.0.0.1","localhost","[::1]"].includes(t.hostname)&&(t.hostname="host.docker.internal"),`docker run --rm --name lobu-worker --interactive --tty \\
|
|
7886
|
+
`).map(o=>o.trim()).filter(o=>o!==""&&!p8.test(o)).join(" ").trim();return a===""?null:a}function q5e(e){switch(e){case"action_approval_needed":return"Needs approval";case"connection_permission_request":return"Authorization needed";case"browser_auth_expired":return"Sign-in required";case"invitation_received":return"Invitation";case"agent_message":return"Agent";default:return"Notification"}}function H5e(e,t){if(t==null||t==="")return null;switch(e){case"action_approval_needed":return"Review & approve";case"connection_permission_request":return"Authorize connection";case"browser_auth_expired":return"Open connection";case"invitation_received":return"Accept invitation";default:return null}}function V5e(){const e=qn();return t=>{const{pathname:n,search:a}=sc(t);e({to:n,search:a??{}})}}function w_({href:e,className:t,onClick:n,children:a}){const{pathname:o,search:s}=sc(e);return h.jsx(Ct,{to:o,search:s??{},className:t,onClick:n,children:a})}function y8(e,t,n){if(!t)return h.jsx("span",{className:ye("mt-1 h-2 w-2 shrink-0 rounded-full",n==="relevant"?"bg-primary":"bg-blue-500")});const a="mt-0.5 h-4 w-4 shrink-0 text-muted-foreground";switch(e){case"action_approval_needed":return h.jsx(KM,{className:a});case"connection_permission_request":case"browser_auth_expired":return h.jsx(WM,{className:a});case"invitation_received":return h.jsx(QM,{className:a});case"agent_message":return h.jsx(Lg,{className:a});default:return h.jsx(zM,{className:a})}}function F5e(e){return e?q5e(e):"Notification"}function B5e({runId:e,notificationId:t,reviewHref:n,reviewTitle:a,choiceField:o,choices:s}){const{orgContext:l}=er(),c=E0e(),d=R0e(),f=Y9(l),p=Dk(),[y,k]=b.useState(null),[v,w]=b.useState(!1),[S,_]=b.useState(""),C=c.isPending||d.isPending;return y==="approved"?h.jsx("p",{className:"mt-2 text-xs font-medium text-emerald-600 dark:text-emerald-400",children:"Approved — executing…"}):y==="rejected"?h.jsx("p",{className:"mt-2 text-xs font-medium text-muted-foreground",children:"Rejected"}):v?h.jsxs("div",{className:"mt-2 flex flex-wrap items-center gap-2",children:[h.jsx("input",{type:"text",placeholder:"Reason (optional)",value:S,onChange:A=>_(A.target.value),className:"h-7 min-w-[10rem] flex-1 rounded-md border bg-background px-2 text-xs",onClick:A=>A.stopPropagation()}),h.jsxs(ge,{size:"sm",variant:"outline",className:"h-7 text-xs",disabled:C,onClick:A=>{A.stopPropagation(),d.mutate({run_id:e,reason:S.trim()||void 0},{onSuccess:()=>{k("rejected"),f.mutate(t)}})},children:[d.isPending?h.jsx(dt,{size:"sm",className:"mr-1"}):h.jsx(vs,{className:"mr-1 h-3 w-3"}),"Reject"]}),h.jsx("button",{type:"button",className:"text-xs text-muted-foreground hover:text-foreground",onClick:A=>{A.stopPropagation(),w(!1)},children:"Cancel"})]}):o&&s&&s.length>0?h.jsxs("div",{className:"mt-2 flex flex-wrap items-center gap-2",children:[s.map(A=>h.jsxs(ge,{size:"sm",variant:"outline",className:"h-7 text-xs",disabled:C,onClick:j=>{j.stopPropagation(),c.mutate({run_id:e,input:{[o]:A.value}},{onSuccess:()=>{k("approved"),f.mutate(t)}})},children:[c.isPending?h.jsx(dt,{size:"sm",className:"mr-1"}):null,A.label]},A.value)),h.jsxs(ge,{size:"sm",variant:"ghost",className:"h-7 text-xs text-muted-foreground",disabled:C,onClick:A=>{A.stopPropagation(),w(!0)},children:[h.jsx(vs,{className:"mr-1 h-3 w-3"}),"Dismiss"]})]}):h.jsxs("div",{className:"mt-2 flex flex-wrap items-center gap-2",children:[n?p&&W2(n)?h.jsx(ge,{type:"button",size:"sm",variant:"outline",className:"h-7 text-xs",onClick:A=>{A.stopPropagation(),f.mutate(t),p.open({href:n,title:a??"Approval",runId:e})},children:"Review"}):h.jsx(w_,{href:n,className:ye("inline-flex h-7 items-center justify-center rounded-md border border-input bg-background px-3 text-xs font-medium transition-colors hover:bg-accent hover:text-accent-foreground"),onClick:A=>{A.stopPropagation(),f.mutate(t)},children:"Review"}):null,h.jsxs(ge,{size:"sm",className:"h-7 text-xs",disabled:C,onClick:A=>{A.stopPropagation(),c.mutate({run_id:e},{onSuccess:()=>{k("approved"),f.mutate(t)}})},children:[c.isPending?h.jsx(dt,{size:"sm",className:"mr-1"}):h.jsx(Za,{className:"mr-1 h-3 w-3"}),"Approve"]}),h.jsxs(ge,{size:"sm",variant:"outline",className:"h-7 text-xs",disabled:C,onClick:A=>{A.stopPropagation(),w(!0)},children:[h.jsx(vs,{className:"mr-1 h-3 w-3"}),"Reject"]})]})}function $5e(e){return e.interaction_type==="authorization"?e.interaction_status==="pending":!!e.unread||e.interaction_status==="pending"||e.browser_handoff?.state==="ready"}function v1(e){const{session:t}=Xa(),{orgContext:n}=er(),a=J0e(n),o=j0e(),{data:s=[],isLoading:l,isError:c}=f4e(t&&e?e:null,{limit:50,aggregate:!0,includeNotifications:!0,includeRuns:!1,kinds:["notification"]}),d=b.useMemo(()=>s.filter($5e),[s]),f=b.useMemo(()=>d.map(_=>{const C=_.status==="action_approval_needed";return{id:_.id,at:new Date(_.at).getTime(),title:_.title,body:_.body,unread:_.unread,href:_.href,runId:_.run_id??null,approvalRunId:C?_.run_id??null:null,interactionType:_.interaction_type??null,interactionStatus:_.interaction_status??null,interactionInline:C?_.interaction_inline??!1:!1,interactionChoiceField:C?_.interaction_choice_field??null:null,interactionChoices:C?_.interaction_choices??null:null,notificationId:_.notification_id??null,browserUrl:_.browser_url??null,browserHandoff:_.browser_handoff??null,notification:_.notification_id!=null?{id:_.notification_id,type:_.status??"generic",title:_.title,body:_.body,resource_url:_.href,browser_url:_.browser_url??null,browser_handoff:_.browser_handoff??null,resource_type:_.run_id!=null?"run":null,resource_id:_.run_id!=null?String(_.run_id):null,is_read:!_.unread,created_at:_.at,organization_id:"",user_id:"",platform:_.platform??null,connection_id:_.connection_id??null,connection_name:_.connection_name??null,feed_id:_.feed_id??null,feed_key:_.feed_key??null,feed_name:_.feed_name??null,automation_id:_.automation_id??null,automation_name:_.automation_name??null,agent_id:_.agent_id??null,agent_name:_.agent_name??null,client_id:_.client_id??null,client_name:_.client_name??null,device_worker_id:_.device_worker_id??null,device_label:_.device_label??null,device_platform:_.device_platform??null}:void 0}}).reverse(),[d]),p=[...new Set(f.flatMap(_=>_.unread&&_.notificationId!=null?[_.notificationId]:[]))],y=f.filter(_=>_.interactionType==="approval"&&_.interactionStatus==="pending"&&_.interactionInline===!0&&_.approvalRunId!=null),k=[...new Set(y.flatMap(_=>_.approvalRunId!=null?[_.approvalRunId]:[]))],v=async()=>{const _=await a.mutateAsync(p);_.failed>0?mn.error(`Marked ${_.succeeded} read; ${_.failed} could not be updated.`):mn.success(`Marked ${_.succeeded} notification${_.succeeded===1?"":"s"} as read.`)},w=async(_,C)=>{const A=await o.mutateAsync({decision:_,runIds:k,...C?{reason:C}:{}}),j=new Set(A.failedRunIds),N=y.flatMap(I=>I.approvalRunId!=null&&!j.has(I.approvalRunId)&&I.notificationId!=null?[I.notificationId]:[]);N.length>0&&await a.mutateAsync(N),A.failed>0?mn.error(`${A.succeeded} ${_==="approve"?"approved":"rejected"}; ${A.failed} failed.`):mn.success(`${A.succeeded} approval${A.succeeded===1?"":"s"} ${_==="approve"?"approved":"rejected"}.`)},S=o.isPending||a.isPending;return{session:t,isLoading:l,isError:c,attentionCards:d,attentionItems:f,visibleUnreadIds:p,visibleApprovalRunIds:k,markVisibleRead:v,decideVisibleApprovals:w,markManyRead:a,bulkPending:S}}function U5e({owner:e}){const{session:t,isLoading:n,attentionItems:a,visibleUnreadIds:o,visibleApprovalRunIds:s,markVisibleRead:l,decideVisibleApprovals:c,bulkPending:d}=v1(e),[f,p]=b.useState(!1),[y,k]=b.useState("");return!t||n||a.length===0||o.length===0&&s.length===0?null:h.jsxs("div",{className:"flex flex-wrap items-center justify-end gap-2",children:[o.length>0?h.jsxs(ge,{type:"button",variant:"outline",size:"sm",className:"h-7 rounded-md bg-muted text-xs",disabled:d,onClick:()=>void l(),children:[h.jsx(qM,{className:"h-3.5 w-3.5"}),"Mark ",o.length," as read"]}):null,s.length>0?h.jsxs(h.Fragment,{children:[h.jsxs(ge,{type:"button",size:"sm",className:"h-7 rounded-md text-xs",disabled:d,onClick:()=>void c("approve"),children:[h.jsx(Za,{className:"h-3.5 w-3.5"}),"Approve ",s.length]}),h.jsxs(ge,{type:"button",variant:"outline",size:"sm",className:"h-7 rounded-md bg-muted text-xs",disabled:d,onClick:()=>p(!0),children:[h.jsx(vs,{className:"h-3.5 w-3.5"}),"Reject ",s.length]})]}):null,f?h.jsxs("div",{className:"flex w-full flex-wrap items-center gap-2 rounded-md bg-muted/40 p-2",children:[h.jsx("input",{type:"text","aria-label":"Reject reason",placeholder:"Reason (optional)",value:y,onChange:v=>k(v.target.value),className:"h-7 min-w-48 flex-1 rounded-md border bg-background px-2 text-xs"}),h.jsxs(ge,{type:"button",variant:"destructive",size:"sm",className:"h-7 rounded-md text-xs",disabled:d,onClick:()=>{c("reject",y.trim()||void 0),p(!1),k("")},children:["Confirm reject ",s.length]}),h.jsx(ge,{type:"button",variant:"ghost",size:"sm",className:"h-7 text-xs",onClick:()=>p(!1),children:"Cancel"})]}):null]})}function K5e({owner:e,emptyState:t=null,itemFilter:n,onOpenItem:a,ariaLabel:o="Needs attention",tone:s="default",rowAction:l="open"}){const c=V5e(),d=Dk(),{orgContext:f}=er(),{data:p=[]}=O9(f.organizationId??null),y=Y9(f),k=Q0e(f),v=X0e(f),w=v.isPending&&typeof v.variables=="number"?v.variables:null,{session:S,isLoading:_,isError:C,attentionItems:A,markManyRead:j}=v1(e),N=b.useMemo(()=>n?A.filter(n):A,[A,n]),[I,T]=b.useState(0),q=b.useRef(null),R=l==="open",H=F=>{if(F.notificationId!=null&&F.unread&&y.mutate(F.notificationId),F.interactionType==="authorization"&&F.href){c(F.href);return}if(a){a(F);return}if(d){d.open({href:F.href??"",title:F.title,runId:F.runId??void 0,body:F.body,notificationType:F.notification?.type,createdAt:F.notification?.created_at,browserUrl:F.browserUrl??null,browserHandoff:F.browserHandoff??null,owner:e,sourceAttribution:F.notification??null});return}F.href&&c(F.href)},D=async F=>{if(!F.browserUrl)return;const W=F.browserHandoff?.state==="expired"&&F.browserHandoff.run_id!=null;if(F.notificationId!=null&&F.unread&&y.mutate(F.notificationId),F.browserHandoff?.state==="completed"){mn.info("This draft was already activated. Continue in the Chrome tab you opened, or mark it Done.");return}if(W&&F.notificationId==null){mn.error("This expired draft cannot be recreated from this card.");return}try{const P=F.notificationId,U=W&&P!=null?()=>v.mutateAsync(P):void 0;(U?await i8(F.browserUrl,U):await i8(F.browserUrl))||mn.error("Chrome blocked the handoff tab. Allow pop-ups for Lobu and try again.")}catch(P){mn.error(P instanceof Error?P.message:"Could not recreate this browser draft.")}},G=F=>{if(F.browserUrl){D(F);return}H(F)},$=F=>{const W=Math.min(Math.max(F,0),N.length-1);T(W),q.current?.querySelector(`[data-attention-index="${W}"]`)?.focus()};if(!S)return h.jsx("p",{className:"py-6 text-center text-sm text-muted-foreground",children:"Sign in to see workspace activity."});if(_&&N.length===0)return h.jsx("div",{className:"space-y-2",children:Array.from({length:4}).map((F,W)=>h.jsx("div",{className:ye(Yl,"h-14 animate-pulse")},W))});if(C)return h.jsx("p",{className:"py-6 text-center text-sm text-destructive",children:"Could not load recent activity."});if(N.length===0)return t;const X=h.jsx("ul",{className:"space-y-1",children:N.map((F,W)=>{const P=F.approvalRunId??null,U=F.interactionType==="approval",J=U?F.interactionStatus==="approved"?"Approved":F.interactionStatus==="rejected"?"Rejected":F.interactionStatus==="expired"?"Expired":F.interactionStatus&&F.interactionStatus!=="pending"?F.interactionStatus.charAt(0).toUpperCase()+F.interactionStatus.slice(1):null:null,se=U&&F.interactionStatus==="pending"&&F.interactionInline===!0&&P!=null,L=!se&&!J&&F.notification?H5e(F.notification.type,F.href):null,B=U&&J?"Approval":F5e(F.notification?.type),V=I5e(F.body),O=ye(Yl,"flex w-full items-start gap-3 p-3 text-left transition-colors",R&&"hover:bg-accent/50"),ee=F.notification?y8(F.notification.type,!F.unread,s):y8("generic",!F.unread,s),Q=h.jsxs(h.Fragment,{children:[ee,h.jsxs("div",{className:"min-w-0 flex-1",children:[h.jsxs("div",{className:"flex items-baseline gap-2",children:[h.jsx("p",{className:ye("min-w-0 flex-1 truncate text-sm",F.unread?"font-medium text-foreground":"text-foreground/90"),children:F.title}),h.jsx("span",{className:"shrink-0 text-[11px] text-muted-foreground",children:k1(F.at)})]}),V?h.jsx("div",{className:"mt-0.5 line-clamp-2 text-xs text-muted-foreground",onClick:ae=>{ae.target.closest("a")&&ae.stopPropagation()},children:h.jsx(Bve,{text:V,linkPolicy:F.notification?.type==="action_approval_needed"?"app-links":"strip"})}):F.body?h.jsx("p",{className:"mt-0.5 line-clamp-2 text-xs text-muted-foreground",children:F.body}):null,F.notification?h.jsx(d4e,{owner:e,source:F.notification,connectorDefinitions:p,className:"mt-1 text-[11px]"}):null,h.jsx("p",{className:"mt-1 text-[10px] font-medium uppercase tracking-wide text-muted-foreground/80",children:B}),se&&F.notification&&P!=null?h.jsx(B5e,{runId:P,notificationId:F.notification.id,reviewHref:F.href,reviewTitle:F.title,choiceField:F.interactionChoiceField,choices:F.interactionChoices}):J?h.jsx("p",{className:ye("mt-2 text-xs font-medium",F.interactionStatus==="approved"?"text-emerald-600 dark:text-emerald-400":"text-muted-foreground"),children:J}):null,L&&F.href?h.jsx("div",{className:"mt-2",children:h.jsx(w_,{href:F.href,className:"inline-flex h-7 items-center justify-center rounded-md border border-input bg-background px-3 text-xs font-medium transition-colors hover:bg-accent hover:text-accent-foreground",onClick:ae=>{ae.stopPropagation(),F.notification&&!F.notification.is_read&&y.mutate(F.notification.id),F.notification?.type==="action_approval_needed"&&d&&W2(F.href??"")&&(ae.preventDefault(),G(F))},children:L})}):null,F.browserUrl?h.jsxs("div",{className:"mt-2 space-y-1.5",children:[F.browserHandoff?.state==="expired"?h.jsxs("p",{className:"text-xs text-amber-700 dark:text-amber-300",children:["Draft expired",F.browserHandoff.error_message?` — ${F.browserHandoff.error_message}`:"."]}):null,h.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[F.browserHandoff?.state!=="completed"?h.jsxs(ge,{type:"button",size:"sm",variant:"outline",className:"h-7 text-xs",disabled:w!=null&&w===F.notificationId,onClick:ae=>{ae.stopPropagation(),D(F)},children:[w!=null&&w===F.notificationId?h.jsx(dt,{size:"sm",className:"mr-1"}):null,F.browserHandoff?.state==="expired"&&F.browserHandoff.run_id!=null?"Recreate draft":F.browserHandoff?.state==="expired"?"Open page without draft":"Open page"]}):h.jsx("span",{className:"self-center text-xs text-muted-foreground",children:"Opened"}),d?h.jsx(ge,{type:"button",size:"sm",variant:"ghost",className:"h-7 text-xs text-muted-foreground",onClick:ae=>{ae.stopPropagation(),H(F)},children:"Why/how"}):null,F.interactionStatus!=="pending"?h.jsxs(ge,{type:"button",size:"sm",variant:"ghost",className:"h-7 text-xs text-muted-foreground",disabled:k.isPending,onClick:ae=>{ae.stopPropagation(),F.notificationId!=null&&k.mutate(F.notificationId)},children:[h.jsx(vs,{className:"mr-1 h-3 w-3"}),"Done"]}):null]})]}):null]})]});return h.jsx("li",{children:h.jsx("div",{"data-attention-index":W,role:R?"link":void 0,tabIndex:R?0:void 0,onFocus:R?()=>T(W):void 0,onClick:R?()=>G(F):void 0,onKeyDown:R?ae=>{ae.target===ae.currentTarget&&(ae.key==="Enter"||ae.key===" ")&&(ae.preventDefault(),G(F))}:void 0,className:ye(O,R&&"cursor-pointer"),children:Q})},F.id)})});return h.jsxs("section",{ref:q,"data-attention-list":!0,"aria-label":o,"aria-keyshortcuts":R?"ArrowDown ArrowUp Enter R":void 0,className:"space-y-2.5",onKeyDown:R?F=>{const W=F.target;if(!(W.matches("input, textarea, select")||W.isContentEditable)){if(F.key==="ArrowDown"||F.key==="ArrowUp"){const P=W.closest("[data-attention-index]");if(!P)return;F.preventDefault();const U=Number(P?.dataset.attentionIndex),J=Number.isInteger(U)?U:F.key==="ArrowDown"?-1:0;$(J+(F.key==="ArrowDown"?1:-1))}if(F.key.toLowerCase()==="r"){const P=N[I];P?.unread&&P.notificationId!=null&&(F.preventDefault(),j.mutateAsync([P.notificationId]))}}}:void 0,children:[X,R?h.jsxs("div",{"data-testid":"attention-shortcut-hint",role:"note","aria-label":"Attention keyboard shortcuts",className:"attention-shortcut-hint pointer-events-none mx-auto mt-3 w-fit items-center gap-4 rounded-full border bg-background/95 px-5 py-2 text-xs text-muted-foreground backdrop-blur",children:[h.jsxs("span",{children:[h.jsx("kbd",{className:"rounded bg-muted px-1.5 py-0.5",children:"↑↓"})," Navigate"]}),h.jsxs("span",{children:[h.jsx("kbd",{className:"rounded bg-muted px-1.5 py-0.5",children:"Enter"})," Open"]}),h.jsxs("span",{children:[h.jsx("kbd",{className:"rounded bg-muted px-1.5 py-0.5",children:"R"})," Mark read"]}),h.jsxs("span",{children:[h.jsx("kbd",{className:"rounded bg-muted px-1.5 py-0.5",children:"Tab"})," Actions"]})]}):null]})}var X2="Collapsible",[G5e]=dr(X2),[Y5e,qk]=G5e(X2),M_=b.forwardRef((e,t)=>{const{__scopeCollapsible:n,open:a,defaultOpen:o,disabled:s,onOpenChange:l,...c}=e,[d,f]=fo({prop:a,defaultProp:o??!1,onChange:l,caller:X2});return h.jsx(Y5e,{scope:n,disabled:s,contentId:Ya(),open:d,onOpenToggle:b.useCallback(()=>f(p=>!p),[f]),children:h.jsx(He.div,{"data-state":Vk(d),"data-disabled":s?"":void 0,...c,ref:t})})});M_.displayName=X2;var S_="CollapsibleTrigger",__=b.forwardRef((e,t)=>{const{__scopeCollapsible:n,...a}=e,o=qk(S_,n);return h.jsx(He.button,{type:"button","aria-controls":o.open?o.contentId:void 0,"aria-expanded":o.open||!1,"data-state":Vk(o.open),"data-disabled":o.disabled?"":void 0,disabled:o.disabled,...a,ref:t,onClick:xe(e.onClick,o.onOpenToggle)})});__.displayName=S_;var Hk="CollapsibleContent",C_=b.forwardRef((e,t)=>{const{forceMount:n,...a}=e,o=qk(Hk,e.__scopeCollapsible);return h.jsx(Gn,{present:n||o.open,children:({present:s})=>h.jsx(W5e,{...a,ref:t,present:s})})});C_.displayName=Hk;var W5e=b.forwardRef((e,t)=>{const{__scopeCollapsible:n,present:a,children:o,...s}=e,l=qk(Hk,n),[c,d]=b.useState(a),f=b.useRef(null),p=it(t,f),y=b.useRef(0),k=y.current,v=b.useRef(0),w=v.current,S=l.open||c,_=b.useRef(S),C=b.useRef(void 0);return b.useEffect(()=>{const A=requestAnimationFrame(()=>_.current=!1);return()=>cancelAnimationFrame(A)},[]),Mn(()=>{const A=f.current;if(A){C.current=C.current||{transitionDuration:A.style.transitionDuration,animationName:A.style.animationName},A.style.transitionDuration="0s",A.style.animationName="none";const j=A.getBoundingClientRect();y.current=j.height,v.current=j.width,_.current||(A.style.transitionDuration=C.current.transitionDuration,A.style.animationName=C.current.animationName),d(a)}},[l.open,a]),h.jsx(He.div,{"data-state":Vk(l.open),"data-disabled":l.disabled?"":void 0,id:l.contentId,hidden:!S,...s,ref:p,style:{"--radix-collapsible-content-height":k?`${k}px`:void 0,"--radix-collapsible-content-width":w?`${w}px`:void 0,...e.style},children:S&&o})});function Vk(e){return e?"open":"closed"}var Z5e=M_;const J2=Z5e,e0=__,t0=C_;function Fk(e){const t=e+"CollectionProvider",[n,a]=dr(t),[o,s]=n(t,{collectionRef:{current:null},itemMap:new Map}),l=S=>{const{scope:_,children:C}=S,A=b.useRef(null),j=b.useRef(new Map).current;return h.jsx(o,{scope:_,itemMap:j,collectionRef:A,children:C})};l.displayName=t;const c=e+"CollectionSlot",d=Mi(c),f=b.forwardRef((S,_)=>{const{scope:C,children:A}=S,j=s(c,C),N=it(_,j.collectionRef);return h.jsx(d,{ref:N,children:A})});f.displayName=c;const p=e+"CollectionItemSlot",y="data-radix-collection-item",k=Mi(p),v=b.forwardRef((S,_)=>{const{scope:C,children:A,...j}=S,N=b.useRef(null),I=it(_,N),T=s(p,C);return b.useEffect(()=>(T.itemMap.set(N,{ref:N,...j}),()=>void T.itemMap.delete(N))),h.jsx(k,{[y]:"",ref:I,children:A})});v.displayName=p;function w(S){const _=s(e+"CollectionConsumer",S);return b.useCallback(()=>{const A=_.collectionRef.current;if(!A)return[];const j=Array.from(A.querySelectorAll(`[${y}]`));return Array.from(_.itemMap.values()).sort((T,q)=>j.indexOf(T.ref.current)-j.indexOf(q.ref.current))},[_.collectionRef,_.itemMap])}return[{Provider:l,Slot:f,ItemSlot:v},w,a]}var Q5e=b.createContext(void 0);function Bk(e){const t=b.useContext(Q5e);return e||t||"ltr"}const X5e=["top","right","bottom","left"],Ci=Math.min,Ta=Math.max,n2=Math.round,fh=Math.floor,Or=e=>({x:e,y:e}),J5e={left:"right",right:"left",bottom:"top",top:"bottom"};function Bm(e,t,n){return Ta(e,Ci(t,n))}function yo(e,t){return typeof e=="function"?e(t):e}function mo(e){return e.split("-")[0]}function dc(e){return e.split("-")[1]}function $k(e){return e==="x"?"y":"x"}function Uk(e){return e==="y"?"height":"width"}function jr(e){const t=e[0];return t==="t"||t==="b"?"y":"x"}function Kk(e){return $k(jr(e))}function exe(e,t,n){n===void 0&&(n=!1);const a=dc(e),o=Kk(e),s=Uk(o);let l=o==="x"?a===(n?"end":"start")?"right":"left":a==="start"?"bottom":"top";return t.reference[s]>t.floating[s]&&(l=a2(l)),[l,a2(l)]}function txe(e){const t=a2(e);return[$m(e),t,$m(t)]}function $m(e){return e.includes("start")?e.replace("start","end"):e.replace("end","start")}const m8=["left","right"],g8=["right","left"],nxe=["top","bottom"],axe=["bottom","top"];function rxe(e,t,n){switch(e){case"top":case"bottom":return n?t?g8:m8:t?m8:g8;case"left":case"right":return t?nxe:axe;default:return[]}}function oxe(e,t,n,a){const o=dc(e);let s=rxe(mo(e),n==="start",a);return o&&(s=s.map(l=>l+"-"+o),t&&(s=s.concat(s.map($m)))),s}function a2(e){const t=mo(e);return J5e[t]+e.slice(t.length)}function ixe(e){return{top:0,right:0,bottom:0,left:0,...e}}function A_(e){return typeof e!="number"?ixe(e):{top:e,right:e,bottom:e,left:e}}function r2(e){const{x:t,y:n,width:a,height:o}=e;return{width:a,height:o,top:n,left:t,right:t+a,bottom:n+o,x:t,y:n}}function k8(e,t,n){let{reference:a,floating:o}=e;const s=jr(t),l=Kk(t),c=Uk(l),d=mo(t),f=s==="y",p=a.x+a.width/2-o.width/2,y=a.y+a.height/2-o.height/2,k=a[c]/2-o[c]/2;let v;switch(d){case"top":v={x:p,y:a.y-o.height};break;case"bottom":v={x:p,y:a.y+a.height};break;case"right":v={x:a.x+a.width,y};break;case"left":v={x:a.x-o.width,y};break;default:v={x:a.x,y:a.y}}switch(dc(t)){case"start":v[l]-=k*(n&&f?-1:1);break;case"end":v[l]+=k*(n&&f?-1:1);break}return v}async function sxe(e,t){var n;t===void 0&&(t={});const{x:a,y:o,platform:s,rects:l,elements:c,strategy:d}=e,{boundary:f="clippingAncestors",rootBoundary:p="viewport",elementContext:y="floating",altBoundary:k=!1,padding:v=0}=yo(t,e),w=A_(v),_=c[k?y==="floating"?"reference":"floating":y],C=r2(await s.getClippingRect({element:(n=await(s.isElement==null?void 0:s.isElement(_)))==null||n?_:_.contextElement||await(s.getDocumentElement==null?void 0:s.getDocumentElement(c.floating)),boundary:f,rootBoundary:p,strategy:d})),A=y==="floating"?{x:a,y:o,width:l.floating.width,height:l.floating.height}:l.reference,j=await(s.getOffsetParent==null?void 0:s.getOffsetParent(c.floating)),N=await(s.isElement==null?void 0:s.isElement(j))?await(s.getScale==null?void 0:s.getScale(j))||{x:1,y:1}:{x:1,y:1},I=r2(s.convertOffsetParentRelativeRectToViewportRelativeRect?await s.convertOffsetParentRelativeRectToViewportRelativeRect({elements:c,rect:A,offsetParent:j,strategy:d}):A);return{top:(C.top-I.top+w.top)/N.y,bottom:(I.bottom-C.bottom+w.bottom)/N.y,left:(C.left-I.left+w.left)/N.x,right:(I.right-C.right+w.right)/N.x}}const lxe=50,cxe=async(e,t,n)=>{const{placement:a="bottom",strategy:o="absolute",middleware:s=[],platform:l}=n,c=l.detectOverflow?l:{...l,detectOverflow:sxe},d=await(l.isRTL==null?void 0:l.isRTL(t));let f=await l.getElementRects({reference:e,floating:t,strategy:o}),{x:p,y}=k8(f,a,d),k=a,v=0;const w={};for(let S=0;S<s.length;S++){const _=s[S];if(!_)continue;const{name:C,fn:A}=_,{x:j,y:N,data:I,reset:T}=await A({x:p,y,initialPlacement:a,placement:k,strategy:o,middlewareData:w,rects:f,platform:c,elements:{reference:e,floating:t}});p=j??p,y=N??y,w[C]={...w[C],...I},T&&v<lxe&&(v++,typeof T=="object"&&(T.placement&&(k=T.placement),T.rects&&(f=T.rects===!0?await l.getElementRects({reference:e,floating:t,strategy:o}):T.rects),{x:p,y}=k8(f,k,d)),S=-1)}return{x:p,y,placement:k,strategy:o,middlewareData:w}},uxe=e=>({name:"arrow",options:e,async fn(t){const{x:n,y:a,placement:o,rects:s,platform:l,elements:c,middlewareData:d}=t,{element:f,padding:p=0}=yo(e,t)||{};if(f==null)return{};const y=A_(p),k={x:n,y:a},v=Kk(o),w=Uk(v),S=await l.getDimensions(f),_=v==="y",C=_?"top":"left",A=_?"bottom":"right",j=_?"clientHeight":"clientWidth",N=s.reference[w]+s.reference[v]-k[v]-s.floating[w],I=k[v]-s.reference[v],T=await(l.getOffsetParent==null?void 0:l.getOffsetParent(f));let q=T?T[j]:0;(!q||!await(l.isElement==null?void 0:l.isElement(T)))&&(q=c.floating[j]||s.floating[w]);const R=N/2-I/2,H=q/2-S[w]/2-1,D=Ci(y[C],H),G=Ci(y[A],H),$=D,X=q-S[w]-G,F=q/2-S[w]/2+R,W=Bm($,F,X),P=!d.arrow&&dc(o)!=null&&F!==W&&s.reference[w]/2-(F<$?D:G)-S[w]/2<0,U=P?F<$?F-$:F-X:0;return{[v]:k[v]+U,data:{[v]:W,centerOffset:F-W-U,...P&&{alignmentOffset:U}},reset:P}}}),dxe=function(e){return e===void 0&&(e={}),{name:"flip",options:e,async fn(t){var n,a;const{placement:o,middlewareData:s,rects:l,initialPlacement:c,platform:d,elements:f}=t,{mainAxis:p=!0,crossAxis:y=!0,fallbackPlacements:k,fallbackStrategy:v="bestFit",fallbackAxisSideDirection:w="none",flipAlignment:S=!0,..._}=yo(e,t);if((n=s.arrow)!=null&&n.alignmentOffset)return{};const C=mo(o),A=jr(c),j=mo(c)===c,N=await(d.isRTL==null?void 0:d.isRTL(f.floating)),I=k||(j||!S?[a2(c)]:txe(c)),T=w!=="none";!k&&T&&I.push(...oxe(c,S,w,N));const q=[c,...I],R=await d.detectOverflow(t,_),H=[];let D=((a=s.flip)==null?void 0:a.overflows)||[];if(p&&H.push(R[C]),y){const F=exe(o,l,N);H.push(R[F[0]],R[F[1]])}if(D=[...D,{placement:o,overflows:H}],!H.every(F=>F<=0)){var G,$;const F=(((G=s.flip)==null?void 0:G.index)||0)+1,W=q[F];if(W&&(!(y==="alignment"?A!==jr(W):!1)||D.every(J=>jr(J.placement)===A?J.overflows[0]>0:!0)))return{data:{index:F,overflows:D},reset:{placement:W}};let P=($=D.filter(U=>U.overflows[0]<=0).sort((U,J)=>U.overflows[1]-J.overflows[1])[0])==null?void 0:$.placement;if(!P)switch(v){case"bestFit":{var X;const U=(X=D.filter(J=>{if(T){const se=jr(J.placement);return se===A||se==="y"}return!0}).map(J=>[J.placement,J.overflows.filter(se=>se>0).reduce((se,L)=>se+L,0)]).sort((J,se)=>J[1]-se[1])[0])==null?void 0:X[0];U&&(P=U);break}case"initialPlacement":P=c;break}if(o!==P)return{reset:{placement:P}}}return{}}}};function v8(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function x8(e){return X5e.some(t=>e[t]>=0)}const hxe=function(e){return e===void 0&&(e={}),{name:"hide",options:e,async fn(t){const{rects:n,platform:a}=t,{strategy:o="referenceHidden",...s}=yo(e,t);switch(o){case"referenceHidden":{const l=await a.detectOverflow(t,{...s,elementContext:"reference"}),c=v8(l,n.reference);return{data:{referenceHiddenOffsets:c,referenceHidden:x8(c)}}}case"escaped":{const l=await a.detectOverflow(t,{...s,altBoundary:!0}),c=v8(l,n.floating);return{data:{escapedOffsets:c,escaped:x8(c)}}}default:return{}}}}},E_=new Set(["left","top"]);async function fxe(e,t){const{placement:n,platform:a,elements:o}=e,s=await(a.isRTL==null?void 0:a.isRTL(o.floating)),l=mo(n),c=dc(n),d=jr(n)==="y",f=E_.has(l)?-1:1,p=s&&d?-1:1,y=yo(t,e);let{mainAxis:k,crossAxis:v,alignmentAxis:w}=typeof y=="number"?{mainAxis:y,crossAxis:0,alignmentAxis:null}:{mainAxis:y.mainAxis||0,crossAxis:y.crossAxis||0,alignmentAxis:y.alignmentAxis};return c&&typeof w=="number"&&(v=c==="end"?w*-1:w),d?{x:v*p,y:k*f}:{x:k*f,y:v*p}}const pxe=function(e){return e===void 0&&(e=0),{name:"offset",options:e,async fn(t){var n,a;const{x:o,y:s,placement:l,middlewareData:c}=t,d=await fxe(t,e);return l===((n=c.offset)==null?void 0:n.placement)&&(a=c.arrow)!=null&&a.alignmentOffset?{}:{x:o+d.x,y:s+d.y,data:{...d,placement:l}}}}},yxe=function(e){return e===void 0&&(e={}),{name:"shift",options:e,async fn(t){const{x:n,y:a,placement:o,platform:s}=t,{mainAxis:l=!0,crossAxis:c=!1,limiter:d={fn:C=>{let{x:A,y:j}=C;return{x:A,y:j}}},...f}=yo(e,t),p={x:n,y:a},y=await s.detectOverflow(t,f),k=jr(mo(o)),v=$k(k);let w=p[v],S=p[k];if(l){const C=v==="y"?"top":"left",A=v==="y"?"bottom":"right",j=w+y[C],N=w-y[A];w=Bm(j,w,N)}if(c){const C=k==="y"?"top":"left",A=k==="y"?"bottom":"right",j=S+y[C],N=S-y[A];S=Bm(j,S,N)}const _=d.fn({...t,[v]:w,[k]:S});return{..._,data:{x:_.x-n,y:_.y-a,enabled:{[v]:l,[k]:c}}}}}},mxe=function(e){return e===void 0&&(e={}),{options:e,fn(t){const{x:n,y:a,placement:o,rects:s,middlewareData:l}=t,{offset:c=0,mainAxis:d=!0,crossAxis:f=!0}=yo(e,t),p={x:n,y:a},y=jr(o),k=$k(y);let v=p[k],w=p[y];const S=yo(c,t),_=typeof S=="number"?{mainAxis:S,crossAxis:0}:{mainAxis:0,crossAxis:0,...S};if(d){const j=k==="y"?"height":"width",N=s.reference[k]-s.floating[j]+_.mainAxis,I=s.reference[k]+s.reference[j]-_.mainAxis;v<N?v=N:v>I&&(v=I)}if(f){var C,A;const j=k==="y"?"width":"height",N=E_.has(mo(o)),I=s.reference[y]-s.floating[j]+(N&&((C=l.offset)==null?void 0:C[y])||0)+(N?0:_.crossAxis),T=s.reference[y]+s.reference[j]+(N?0:((A=l.offset)==null?void 0:A[y])||0)-(N?_.crossAxis:0);w<I?w=I:w>T&&(w=T)}return{[k]:v,[y]:w}}}},gxe=function(e){return e===void 0&&(e={}),{name:"size",options:e,async fn(t){var n,a;const{placement:o,rects:s,platform:l,elements:c}=t,{apply:d=()=>{},...f}=yo(e,t),p=await l.detectOverflow(t,f),y=mo(o),k=dc(o),v=jr(o)==="y",{width:w,height:S}=s.floating;let _,C;y==="top"||y==="bottom"?(_=y,C=k===(await(l.isRTL==null?void 0:l.isRTL(c.floating))?"start":"end")?"left":"right"):(C=y,_=k==="end"?"top":"bottom");const A=S-p.top-p.bottom,j=w-p.left-p.right,N=Ci(S-p[_],A),I=Ci(w-p[C],j),T=!t.middlewareData.shift;let q=N,R=I;if((n=t.middlewareData.shift)!=null&&n.enabled.x&&(R=j),(a=t.middlewareData.shift)!=null&&a.enabled.y&&(q=A),T&&!k){const D=Ta(p.left,0),G=Ta(p.right,0),$=Ta(p.top,0),X=Ta(p.bottom,0);v?R=w-2*(D!==0||G!==0?D+G:Ta(p.left,p.right)):q=S-2*($!==0||X!==0?$+X:Ta(p.top,p.bottom))}await d({...t,availableWidth:R,availableHeight:q});const H=await l.getDimensions(c.floating);return w!==H.width||S!==H.height?{reset:{rects:!0}}:{}}}};function n0(){return typeof window<"u"}function hc(e){return R_(e)?(e.nodeName||"").toLowerCase():"#document"}function La(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function zr(e){var t;return(t=(R_(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}function R_(e){return n0()?e instanceof Node||e instanceof La(e).Node:!1}function cr(e){return n0()?e instanceof Element||e instanceof La(e).Element:!1}function bo(e){return n0()?e instanceof HTMLElement||e instanceof La(e).HTMLElement:!1}function b8(e){return!n0()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof La(e).ShadowRoot}function x1(e){const{overflow:t,overflowX:n,overflowY:a,display:o}=ur(e);return/auto|scroll|overlay|hidden|clip/.test(t+a+n)&&o!=="inline"&&o!=="contents"}function kxe(e){return/^(table|td|th)$/.test(hc(e))}function a0(e){try{if(e.matches(":popover-open"))return!0}catch{}try{return e.matches(":modal")}catch{return!1}}const vxe=/transform|translate|scale|rotate|perspective|filter/,xxe=/paint|layout|strict|content/,cs=e=>!!e&&e!=="none";let Fy;function Gk(e){const t=cr(e)?ur(e):e;return cs(t.transform)||cs(t.translate)||cs(t.scale)||cs(t.rotate)||cs(t.perspective)||!Yk()&&(cs(t.backdropFilter)||cs(t.filter))||vxe.test(t.willChange||"")||xxe.test(t.contain||"")}function bxe(e){let t=Ai(e);for(;bo(t)&&!Xl(t);){if(Gk(t))return t;if(a0(t))return null;t=Ai(t)}return null}function Yk(){return Fy==null&&(Fy=typeof CSS<"u"&&CSS.supports&&CSS.supports("-webkit-backdrop-filter","none")),Fy}function Xl(e){return/^(html|body|#document)$/.test(hc(e))}function ur(e){return La(e).getComputedStyle(e)}function r0(e){return cr(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function Ai(e){if(hc(e)==="html")return e;const t=e.assignedSlot||e.parentNode||b8(e)&&e.host||zr(e);return b8(t)?t.host:t}function j_(e){const t=Ai(e);return Xl(t)?e.ownerDocument?e.ownerDocument.body:e.body:bo(t)&&x1(t)?t:j_(t)}function Uu(e,t,n){var a;t===void 0&&(t=[]),n===void 0&&(n=!0);const o=j_(e),s=o===((a=e.ownerDocument)==null?void 0:a.body),l=La(o);if(s){const c=Um(l);return t.concat(l,l.visualViewport||[],x1(o)?o:[],c&&n?Uu(c):[])}else return t.concat(o,Uu(o,[],n))}function Um(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function O_(e){const t=ur(e);let n=parseFloat(t.width)||0,a=parseFloat(t.height)||0;const o=bo(e),s=o?e.offsetWidth:n,l=o?e.offsetHeight:a,c=n2(n)!==s||n2(a)!==l;return c&&(n=s,a=l),{width:n,height:a,$:c}}function Wk(e){return cr(e)?e:e.contextElement}function Vl(e){const t=Wk(e);if(!bo(t))return Or(1);const n=t.getBoundingClientRect(),{width:a,height:o,$:s}=O_(t);let l=(s?n2(n.width):n.width)/a,c=(s?n2(n.height):n.height)/o;return(!l||!Number.isFinite(l))&&(l=1),(!c||!Number.isFinite(c))&&(c=1),{x:l,y:c}}const wxe=Or(0);function N_(e){const t=La(e);return!Yk()||!t.visualViewport?wxe:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function Mxe(e,t,n){return t===void 0&&(t=!1),!n||t&&n!==La(e)?!1:t}function _s(e,t,n,a){t===void 0&&(t=!1),n===void 0&&(n=!1);const o=e.getBoundingClientRect(),s=Wk(e);let l=Or(1);t&&(a?cr(a)&&(l=Vl(a)):l=Vl(e));const c=Mxe(s,n,a)?N_(s):Or(0);let d=(o.left+c.x)/l.x,f=(o.top+c.y)/l.y,p=o.width/l.x,y=o.height/l.y;if(s){const k=La(s),v=a&&cr(a)?La(a):a;let w=k,S=Um(w);for(;S&&a&&v!==w;){const _=Vl(S),C=S.getBoundingClientRect(),A=ur(S),j=C.left+(S.clientLeft+parseFloat(A.paddingLeft))*_.x,N=C.top+(S.clientTop+parseFloat(A.paddingTop))*_.y;d*=_.x,f*=_.y,p*=_.x,y*=_.y,d+=j,f+=N,w=La(S),S=Um(w)}}return r2({width:p,height:y,x:d,y:f})}function o0(e,t){const n=r0(e).scrollLeft;return t?t.left+n:_s(zr(e)).left+n}function T_(e,t){const n=e.getBoundingClientRect(),a=n.left+t.scrollLeft-o0(e,n),o=n.top+t.scrollTop;return{x:a,y:o}}function Sxe(e){let{elements:t,rect:n,offsetParent:a,strategy:o}=e;const s=o==="fixed",l=zr(a),c=t?a0(t.floating):!1;if(a===l||c&&s)return n;let d={scrollLeft:0,scrollTop:0},f=Or(1);const p=Or(0),y=bo(a);if((y||!y&&!s)&&((hc(a)!=="body"||x1(l))&&(d=r0(a)),y)){const v=_s(a);f=Vl(a),p.x=v.x+a.clientLeft,p.y=v.y+a.clientTop}const k=l&&!y&&!s?T_(l,d):Or(0);return{width:n.width*f.x,height:n.height*f.y,x:n.x*f.x-d.scrollLeft*f.x+p.x+k.x,y:n.y*f.y-d.scrollTop*f.y+p.y+k.y}}function _xe(e){return Array.from(e.getClientRects())}function Cxe(e){const t=zr(e),n=r0(e),a=e.ownerDocument.body,o=Ta(t.scrollWidth,t.clientWidth,a.scrollWidth,a.clientWidth),s=Ta(t.scrollHeight,t.clientHeight,a.scrollHeight,a.clientHeight);let l=-n.scrollLeft+o0(e);const c=-n.scrollTop;return ur(a).direction==="rtl"&&(l+=Ta(t.clientWidth,a.clientWidth)-o),{width:o,height:s,x:l,y:c}}const w8=25;function Axe(e,t){const n=La(e),a=zr(e),o=n.visualViewport;let s=a.clientWidth,l=a.clientHeight,c=0,d=0;if(o){s=o.width,l=o.height;const p=Yk();(!p||p&&t==="fixed")&&(c=o.offsetLeft,d=o.offsetTop)}const f=o0(a);if(f<=0){const p=a.ownerDocument,y=p.body,k=getComputedStyle(y),v=p.compatMode==="CSS1Compat"&&parseFloat(k.marginLeft)+parseFloat(k.marginRight)||0,w=Math.abs(a.clientWidth-y.clientWidth-v);w<=w8&&(s-=w)}else f<=w8&&(s+=f);return{width:s,height:l,x:c,y:d}}function Exe(e,t){const n=_s(e,!0,t==="fixed"),a=n.top+e.clientTop,o=n.left+e.clientLeft,s=bo(e)?Vl(e):Or(1),l=e.clientWidth*s.x,c=e.clientHeight*s.y,d=o*s.x,f=a*s.y;return{width:l,height:c,x:d,y:f}}function M8(e,t,n){let a;if(t==="viewport")a=Axe(e,n);else if(t==="document")a=Cxe(zr(e));else if(cr(t))a=Exe(t,n);else{const o=N_(e);a={x:t.x-o.x,y:t.y-o.y,width:t.width,height:t.height}}return r2(a)}function P_(e,t){const n=Ai(e);return n===t||!cr(n)||Xl(n)?!1:ur(n).position==="fixed"||P_(n,t)}function Rxe(e,t){const n=t.get(e);if(n)return n;let a=Uu(e,[],!1).filter(c=>cr(c)&&hc(c)!=="body"),o=null;const s=ur(e).position==="fixed";let l=s?Ai(e):e;for(;cr(l)&&!Xl(l);){const c=ur(l),d=Gk(l);!d&&c.position==="fixed"&&(o=null),(s?!d&&!o:!d&&c.position==="static"&&!!o&&(o.position==="absolute"||o.position==="fixed")||x1(l)&&!d&&P_(e,l))?a=a.filter(p=>p!==l):o=c,l=Ai(l)}return t.set(e,a),a}function jxe(e){let{element:t,boundary:n,rootBoundary:a,strategy:o}=e;const l=[...n==="clippingAncestors"?a0(t)?[]:Rxe(t,this._c):[].concat(n),a],c=M8(t,l[0],o);let d=c.top,f=c.right,p=c.bottom,y=c.left;for(let k=1;k<l.length;k++){const v=M8(t,l[k],o);d=Ta(v.top,d),f=Ci(v.right,f),p=Ci(v.bottom,p),y=Ta(v.left,y)}return{width:f-y,height:p-d,x:y,y:d}}function Oxe(e){const{width:t,height:n}=O_(e);return{width:t,height:n}}function Nxe(e,t,n){const a=bo(t),o=zr(t),s=n==="fixed",l=_s(e,!0,s,t);let c={scrollLeft:0,scrollTop:0};const d=Or(0);function f(){d.x=o0(o)}if(a||!a&&!s)if((hc(t)!=="body"||x1(o))&&(c=r0(t)),a){const v=_s(t,!0,s,t);d.x=v.x+t.clientLeft,d.y=v.y+t.clientTop}else o&&f();s&&!a&&o&&f();const p=o&&!a&&!s?T_(o,c):Or(0),y=l.left+c.scrollLeft-d.x-p.x,k=l.top+c.scrollTop-d.y-p.y;return{x:y,y:k,width:l.width,height:l.height}}function By(e){return ur(e).position==="static"}function S8(e,t){if(!bo(e)||ur(e).position==="fixed")return null;if(t)return t(e);let n=e.offsetParent;return zr(e)===n&&(n=n.ownerDocument.body),n}function L_(e,t){const n=La(e);if(a0(e))return n;if(!bo(e)){let o=Ai(e);for(;o&&!Xl(o);){if(cr(o)&&!By(o))return o;o=Ai(o)}return n}let a=S8(e,t);for(;a&&kxe(a)&&By(a);)a=S8(a,t);return a&&Xl(a)&&By(a)&&!Gk(a)?n:a||bxe(e)||n}const Txe=async function(e){const t=this.getOffsetParent||L_,n=this.getDimensions,a=await n(e.floating);return{reference:Nxe(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:a.width,height:a.height}}};function Pxe(e){return ur(e).direction==="rtl"}const Lxe={convertOffsetParentRelativeRectToViewportRelativeRect:Sxe,getDocumentElement:zr,getClippingRect:jxe,getOffsetParent:L_,getElementRects:Txe,getClientRects:_xe,getDimensions:Oxe,getScale:Vl,isElement:cr,isRTL:Pxe};function z_(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function zxe(e,t){let n=null,a;const o=zr(e);function s(){var c;clearTimeout(a),(c=n)==null||c.disconnect(),n=null}function l(c,d){c===void 0&&(c=!1),d===void 0&&(d=1),s();const f=e.getBoundingClientRect(),{left:p,top:y,width:k,height:v}=f;if(c||t(),!k||!v)return;const w=fh(y),S=fh(o.clientWidth-(p+k)),_=fh(o.clientHeight-(y+v)),C=fh(p),j={rootMargin:-w+"px "+-S+"px "+-_+"px "+-C+"px",threshold:Ta(0,Ci(1,d))||1};let N=!0;function I(T){const q=T[0].intersectionRatio;if(q!==d){if(!N)return l();q?l(!1,q):a=setTimeout(()=>{l(!1,1e-7)},1e3)}q===1&&!z_(f,e.getBoundingClientRect())&&l(),N=!1}try{n=new IntersectionObserver(I,{...j,root:o.ownerDocument})}catch{n=new IntersectionObserver(I,j)}n.observe(e)}return l(!0),s}function Dxe(e,t,n,a){a===void 0&&(a={});const{ancestorScroll:o=!0,ancestorResize:s=!0,elementResize:l=typeof ResizeObserver=="function",layoutShift:c=typeof IntersectionObserver=="function",animationFrame:d=!1}=a,f=Wk(e),p=o||s?[...f?Uu(f):[],...t?Uu(t):[]]:[];p.forEach(C=>{o&&C.addEventListener("scroll",n,{passive:!0}),s&&C.addEventListener("resize",n)});const y=f&&c?zxe(f,n):null;let k=-1,v=null;l&&(v=new ResizeObserver(C=>{let[A]=C;A&&A.target===f&&v&&t&&(v.unobserve(t),cancelAnimationFrame(k),k=requestAnimationFrame(()=>{var j;(j=v)==null||j.observe(t)})),n()}),f&&!d&&v.observe(f),t&&v.observe(t));let w,S=d?_s(e):null;d&&_();function _(){const C=_s(e);S&&!z_(S,C)&&n(),S=C,w=requestAnimationFrame(_)}return n(),()=>{var C;p.forEach(A=>{o&&A.removeEventListener("scroll",n),s&&A.removeEventListener("resize",n)}),y?.(),(C=v)==null||C.disconnect(),v=null,d&&cancelAnimationFrame(w)}}const Ixe=pxe,qxe=yxe,Hxe=dxe,Vxe=gxe,Fxe=hxe,_8=uxe,Bxe=mxe,$xe=(e,t,n)=>{const a=new Map,o={platform:Lxe,...n},s={...o.platform,_c:a};return cxe(e,t,{...o,platform:s})};var Uxe=typeof document<"u",Kxe=function(){},Rh=Uxe?b.useLayoutEffect:Kxe;function o2(e,t){if(e===t)return!0;if(typeof e!=typeof t)return!1;if(typeof e=="function"&&e.toString()===t.toString())return!0;let n,a,o;if(e&&t&&typeof e=="object"){if(Array.isArray(e)){if(n=e.length,n!==t.length)return!1;for(a=n;a--!==0;)if(!o2(e[a],t[a]))return!1;return!0}if(o=Object.keys(e),n=o.length,n!==Object.keys(t).length)return!1;for(a=n;a--!==0;)if(!{}.hasOwnProperty.call(t,o[a]))return!1;for(a=n;a--!==0;){const s=o[a];if(!(s==="_owner"&&e.$$typeof)&&!o2(e[s],t[s]))return!1}return!0}return e!==e&&t!==t}function D_(e){return typeof window>"u"?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function C8(e,t){const n=D_(e);return Math.round(t*n)/n}function $y(e){const t=b.useRef(e);return Rh(()=>{t.current=e}),t}function Gxe(e){e===void 0&&(e={});const{placement:t="bottom",strategy:n="absolute",middleware:a=[],platform:o,elements:{reference:s,floating:l}={},transform:c=!0,whileElementsMounted:d,open:f}=e,[p,y]=b.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[k,v]=b.useState(a);o2(k,a)||v(a);const[w,S]=b.useState(null),[_,C]=b.useState(null),A=b.useCallback(J=>{J!==T.current&&(T.current=J,S(J))},[]),j=b.useCallback(J=>{J!==q.current&&(q.current=J,C(J))},[]),N=s||w,I=l||_,T=b.useRef(null),q=b.useRef(null),R=b.useRef(p),H=d!=null,D=$y(d),G=$y(o),$=$y(f),X=b.useCallback(()=>{if(!T.current||!q.current)return;const J={placement:t,strategy:n,middleware:k};G.current&&(J.platform=G.current),$xe(T.current,q.current,J).then(se=>{const L={...se,isPositioned:$.current!==!1};F.current&&!o2(R.current,L)&&(R.current=L,go.flushSync(()=>{y(L)}))})},[k,t,n,G,$]);Rh(()=>{f===!1&&R.current.isPositioned&&(R.current.isPositioned=!1,y(J=>({...J,isPositioned:!1})))},[f]);const F=b.useRef(!1);Rh(()=>(F.current=!0,()=>{F.current=!1}),[]),Rh(()=>{if(N&&(T.current=N),I&&(q.current=I),N&&I){if(D.current)return D.current(N,I,X);X()}},[N,I,X,D,H]);const W=b.useMemo(()=>({reference:T,floating:q,setReference:A,setFloating:j}),[A,j]),P=b.useMemo(()=>({reference:N,floating:I}),[N,I]),U=b.useMemo(()=>{const J={position:n,left:0,top:0};if(!P.floating)return J;const se=C8(P.floating,p.x),L=C8(P.floating,p.y);return c?{...J,transform:"translate("+se+"px, "+L+"px)",...D_(P.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:se,top:L}},[n,c,P.floating,p.x,p.y]);return b.useMemo(()=>({...p,update:X,refs:W,elements:P,floatingStyles:U}),[p,X,W,P,U])}const Yxe=e=>{function t(n){return{}.hasOwnProperty.call(n,"current")}return{name:"arrow",options:e,fn(n){const{element:a,padding:o}=typeof e=="function"?e(n):e;return a&&t(a)?a.current!=null?_8({element:a.current,padding:o}).fn(n):{}:a?_8({element:a,padding:o}).fn(n):{}}}},Wxe=(e,t)=>{const n=Ixe(e);return{name:n.name,fn:n.fn,options:[e,t]}},Zxe=(e,t)=>{const n=qxe(e);return{name:n.name,fn:n.fn,options:[e,t]}},Qxe=(e,t)=>({fn:Bxe(e).fn,options:[e,t]}),Xxe=(e,t)=>{const n=Hxe(e);return{name:n.name,fn:n.fn,options:[e,t]}},Jxe=(e,t)=>{const n=Vxe(e);return{name:n.name,fn:n.fn,options:[e,t]}},e3e=(e,t)=>{const n=Fxe(e);return{name:n.name,fn:n.fn,options:[e,t]}},t3e=(e,t)=>{const n=Yxe(e);return{name:n.name,fn:n.fn,options:[e,t]}};var n3e="Arrow",I_=b.forwardRef((e,t)=>{const{children:n,width:a=10,height:o=5,...s}=e;return h.jsx(He.svg,{...s,ref:t,width:a,height:o,viewBox:"0 0 30 10",preserveAspectRatio:"none",children:e.asChild?n:h.jsx("polygon",{points:"0,0 30,0 15,10"})})});I_.displayName=n3e;var a3e=I_;function q_(e){const[t,n]=b.useState(void 0);return Mn(()=>{if(e){n({width:e.offsetWidth,height:e.offsetHeight});const a=new ResizeObserver(o=>{if(!Array.isArray(o)||!o.length)return;const s=o[0];let l,c;if("borderBoxSize"in s){const d=s.borderBoxSize,f=Array.isArray(d)?d[0]:d;l=f.inlineSize,c=f.blockSize}else l=e.offsetWidth,c=e.offsetHeight;n({width:l,height:c})});return a.observe(e,{box:"border-box"}),()=>a.unobserve(e)}else n(void 0)},[e]),t}var Zk="Popper",[H_,Ti]=dr(Zk),[r3e,V_]=H_(Zk),F_=e=>{const{__scopePopper:t,children:n}=e,[a,o]=b.useState(null),[s,l]=b.useState(void 0);return h.jsx(r3e,{scope:t,anchor:a,onAnchorChange:o,placementState:s,setPlacementState:l,children:n})};F_.displayName=Zk;var B_="PopperAnchor",$_=b.forwardRef((e,t)=>{const{__scopePopper:n,virtualRef:a,...o}=e,s=V_(B_,n),l=b.useRef(null),c=s.onAnchorChange,d=b.useCallback(w=>{l.current=w,w&&c(w)},[c]),f=it(t,d),p=b.useRef(null);b.useEffect(()=>{if(!a)return;const w=p.current;p.current=a.current,w!==p.current&&c(p.current)});const y=s.placementState&&Xk(s.placementState),k=y?.[0],v=y?.[1];return a?null:h.jsx(He.div,{"data-radix-popper-side":k,"data-radix-popper-align":v,...o,ref:f})});$_.displayName=B_;var Qk="PopperContent",[o3e,i3e]=H_(Qk),U_=b.forwardRef((e,t)=>{const{__scopePopper:n,side:a="bottom",sideOffset:o=0,align:s="center",alignOffset:l=0,arrowPadding:c=0,avoidCollisions:d=!0,collisionBoundary:f=[],collisionPadding:p=0,sticky:y="partial",hideWhenDetached:k=!1,updatePositionStrategy:v="optimized",onPlaced:w,...S}=e,_=V_(Qk,n),[C,A]=b.useState(null),j=it(t,de=>A(de)),[N,I]=b.useState(null),T=q_(N),q=T?.width??0,R=T?.height??0,H=a+(s!=="center"?"-"+s:""),D=typeof p=="number"?p:{top:0,right:0,bottom:0,left:0,...p},G=Array.isArray(f)?f:[f],$=G.length>0,X={padding:D,boundary:G.filter(l3e),altBoundary:$},{refs:F,floatingStyles:W,placement:P,isPositioned:U,middlewareData:J}=Gxe({strategy:"fixed",placement:H,whileElementsMounted:(...de)=>Dxe(...de,{animationFrame:v==="always"}),elements:{reference:_.anchor},middleware:[Wxe({mainAxis:o+R,alignmentAxis:l}),d&&Zxe({mainAxis:!0,crossAxis:!1,limiter:y==="partial"?Qxe():void 0,...X}),d&&Xxe({...X}),Jxe({...X,apply:({elements:de,rects:pe,availableWidth:Re,availableHeight:Pe})=>{const{width:De,height:bt}=pe.reference,Ye=de.floating.style;Ye.setProperty("--radix-popper-available-width",`${Re}px`),Ye.setProperty("--radix-popper-available-height",`${Pe}px`),Ye.setProperty("--radix-popper-anchor-width",`${De}px`),Ye.setProperty("--radix-popper-anchor-height",`${bt}px`)}}),N&&t3e({element:N,padding:c}),c3e({arrowWidth:q,arrowHeight:R}),k&&e3e({strategy:"referenceHidden",...X,boundary:$?X.boundary:void 0})]}),se=_.setPlacementState;Mn(()=>(se(P),()=>{se(void 0)}),[P,se]);const[L,B]=Xk(P),V=Nr(w);Mn(()=>{U&&V?.()},[U,V]);const O=J.arrow?.x,ee=J.arrow?.y,Q=J.arrow?.centerOffset!==0,[ae,oe]=b.useState();return Mn(()=>{C&&oe(window.getComputedStyle(C).zIndex)},[C]),h.jsx("div",{ref:F.setFloating,"data-radix-popper-content-wrapper":"",style:{...W,transform:U?W.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:ae,"--radix-popper-transform-origin":[J.transformOrigin?.x,J.transformOrigin?.y].join(" "),...J.hide?.referenceHidden&&{visibility:"hidden",pointerEvents:"none"}},dir:e.dir,children:h.jsx(o3e,{scope:n,placedSide:L,placedAlign:B,onArrowChange:I,arrowX:O,arrowY:ee,shouldHideArrow:Q,children:h.jsx(He.div,{"data-side":L,"data-align":B,...S,ref:j,style:{...S.style,animation:U?void 0:"none"}})})})});U_.displayName=Qk;var K_="PopperArrow",s3e={top:"bottom",right:"left",bottom:"top",left:"right"},G_=b.forwardRef(function(t,n){const{__scopePopper:a,...o}=t,s=i3e(K_,a),l=s3e[s.placedSide];return h.jsx("span",{ref:s.onArrowChange,style:{position:"absolute",left:s.arrowX,top:s.arrowY,[l]:0,transformOrigin:{top:"",right:"0 0",bottom:"center 0",left:"100% 0"}[s.placedSide],transform:{top:"translateY(100%)",right:"translateY(50%) rotate(90deg) translateX(-50%)",bottom:"rotate(180deg)",left:"translateY(50%) rotate(-90deg) translateX(50%)"}[s.placedSide],visibility:s.shouldHideArrow?"hidden":void 0},children:h.jsx(a3e,{...o,ref:n,style:{...o.style,display:"block"}})})});G_.displayName=K_;function l3e(e){return e!==null}var c3e=e=>({name:"transformOrigin",options:e,fn(t){const{placement:n,rects:a,middlewareData:o}=t,l=o.arrow?.centerOffset!==0,c=l?0:e.arrowWidth,d=l?0:e.arrowHeight,[f,p]=Xk(n),y={start:"0%",center:"50%",end:"100%"}[p],k=(o.arrow?.x??0)+c/2,v=(o.arrow?.y??0)+d/2;let w="",S="";return f==="bottom"?(w=l?y:`${k}px`,S=`${-d}px`):f==="top"?(w=l?y:`${k}px`,S=`${a.floating.height+d}px`):f==="right"?(w=`${-d}px`,S=l?y:`${v}px`):f==="left"&&(w=`${a.floating.width+d}px`,S=l?y:`${v}px`),{data:{x:w,y:S}}}});function Xk(e){const[t,n="center"]=e.split("-");return[t,n]}var i0=F_,b1=$_,s0=U_,l0=G_,Uy="rovingFocusGroup.onEntryFocus",u3e={bubbles:!1,cancelable:!0},w1="RovingFocusGroup",[Km,Y_,d3e]=Fk(w1),[h3e,W_]=dr(w1,[d3e]),[f3e,p3e]=h3e(w1),Z_=b.forwardRef((e,t)=>h.jsx(Km.Provider,{scope:e.__scopeRovingFocusGroup,children:h.jsx(Km.Slot,{scope:e.__scopeRovingFocusGroup,children:h.jsx(y3e,{...e,ref:t})})}));Z_.displayName=w1;var y3e=b.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,orientation:a,loop:o=!1,dir:s,currentTabStopId:l,defaultCurrentTabStopId:c,onCurrentTabStopIdChange:d,onEntryFocus:f,preventScrollOnEntryFocus:p=!1,...y}=e,k=b.useRef(null),v=it(t,k),w=Bk(s),[S,_]=fo({prop:l,defaultProp:c??null,onChange:d,caller:w1}),[C,A]=b.useState(!1),j=Nr(f),N=Y_(n),I=b.useRef(!1),[T,q]=b.useState(0);return b.useEffect(()=>{const R=k.current;if(R)return R.addEventListener(Uy,j),()=>R.removeEventListener(Uy,j)},[j]),h.jsx(f3e,{scope:n,orientation:a,dir:w,loop:o,currentTabStopId:S,onItemFocus:b.useCallback(R=>_(R),[_]),onItemShiftTab:b.useCallback(()=>A(!0),[]),onFocusableItemAdd:b.useCallback(()=>q(R=>R+1),[]),onFocusableItemRemove:b.useCallback(()=>q(R=>R-1),[]),children:h.jsx(He.div,{tabIndex:C||T===0?-1:0,"data-orientation":a,...y,ref:v,style:{outline:"none",...e.style},onMouseDown:xe(e.onMouseDown,()=>{I.current=!0}),onFocus:xe(e.onFocus,R=>{const H=!I.current;if(R.target===R.currentTarget&&H&&!C){const D=new CustomEvent(Uy,u3e);if(R.currentTarget.dispatchEvent(D),!D.defaultPrevented){const G=N().filter(P=>P.focusable),$=G.find(P=>P.active),X=G.find(P=>P.id===S),W=[$,X,...G].filter(Boolean).map(P=>P.ref.current);J_(W,p)}}I.current=!1}),onBlur:xe(e.onBlur,()=>A(!1))})})}),Q_="RovingFocusGroupItem",X_=b.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,focusable:a=!0,active:o=!1,tabStopId:s,children:l,...c}=e,d=Ya(),f=s||d,p=p3e(Q_,n),y=p.currentTabStopId===f,k=Y_(n),{onFocusableItemAdd:v,onFocusableItemRemove:w,currentTabStopId:S}=p;return b.useEffect(()=>{if(a)return v(),()=>w()},[a,v,w]),h.jsx(Km.ItemSlot,{scope:n,id:f,focusable:a,active:o,children:h.jsx(He.span,{tabIndex:y?0:-1,"data-orientation":p.orientation,...c,ref:t,onMouseDown:xe(e.onMouseDown,_=>{a?p.onItemFocus(f):_.preventDefault()}),onFocus:xe(e.onFocus,()=>p.onItemFocus(f)),onKeyDown:xe(e.onKeyDown,_=>{if(_.key==="Tab"&&_.shiftKey){p.onItemShiftTab();return}if(_.target!==_.currentTarget)return;const C=k3e(_,p.orientation,p.dir);if(C!==void 0){if(_.metaKey||_.ctrlKey||_.altKey||_.shiftKey)return;_.preventDefault();let j=k().filter(N=>N.focusable).map(N=>N.ref.current);if(C==="last")j.reverse();else if(C==="prev"||C==="next"){C==="prev"&&j.reverse();const N=j.indexOf(_.currentTarget);j=p.loop?v3e(j,N+1):j.slice(N+1)}setTimeout(()=>J_(j))}}),children:typeof l=="function"?l({isCurrentTabStop:y,hasTabStop:S!=null}):l})})});X_.displayName=Q_;var m3e={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function g3e(e,t){return t!=="rtl"?e:e==="ArrowLeft"?"ArrowRight":e==="ArrowRight"?"ArrowLeft":e}function k3e(e,t,n){const a=g3e(e.key,n);if(!(t==="vertical"&&["ArrowLeft","ArrowRight"].includes(a))&&!(t==="horizontal"&&["ArrowUp","ArrowDown"].includes(a)))return m3e[a]}function J_(e,t=!1){const n=document.activeElement;for(const a of e)if(a===n||(a.focus({preventScroll:t}),document.activeElement!==n))return}function v3e(e,t){return e.map((n,a)=>e[(t+a)%e.length])}var x3e=Z_,b3e=X_,Gm=["Enter"," "],w3e=["ArrowDown","PageUp","Home"],eC=["ArrowUp","PageDown","End"],M3e=[...w3e,...eC],S3e={ltr:[...Gm,"ArrowRight"],rtl:[...Gm,"ArrowLeft"]},_3e={ltr:["ArrowLeft"],rtl:["ArrowRight"]},M1="Menu",[Ku,C3e,A3e]=Fk(M1),[Ps,tC]=dr(M1,[A3e,Ti,W_]),c0=Ti(),nC=W_(),[E3e,Ls]=Ps(M1),[R3e,S1]=Ps(M1),aC=e=>{const{__scopeMenu:t,open:n=!1,children:a,dir:o,onOpenChange:s,modal:l=!0}=e,c=c0(t),[d,f]=b.useState(null),p=b.useRef(!1),y=Nr(s),k=Bk(o);return b.useEffect(()=>{const v=()=>{p.current=!0,document.addEventListener("pointerdown",w,{capture:!0,once:!0}),document.addEventListener("pointermove",w,{capture:!0,once:!0})},w=()=>p.current=!1;return document.addEventListener("keydown",v,{capture:!0}),()=>{document.removeEventListener("keydown",v,{capture:!0}),document.removeEventListener("pointerdown",w,{capture:!0}),document.removeEventListener("pointermove",w,{capture:!0})}},[]),b.useEffect(()=>{if(!n)return;const v=()=>y(!1);return window.addEventListener("blur",v),()=>window.removeEventListener("blur",v)},[n,y]),h.jsx(i0,{...c,children:h.jsx(E3e,{scope:t,open:n,onOpenChange:y,content:d,onContentChange:f,children:h.jsx(R3e,{scope:t,onClose:b.useCallback(()=>y(!1),[y]),isUsingKeyboardRef:p,dir:k,modal:l,children:a})})})};aC.displayName=M1;var j3e="MenuAnchor",Jk=b.forwardRef((e,t)=>{const{__scopeMenu:n,...a}=e,o=c0(n);return h.jsx(b1,{...o,...a,ref:t})});Jk.displayName=j3e;var ev="MenuPortal",[O3e,rC]=Ps(ev,{forceMount:void 0}),oC=e=>{const{__scopeMenu:t,forceMount:n,children:a,container:o}=e,s=Ls(ev,t);return h.jsx(O3e,{scope:t,forceMount:n,children:h.jsx(Gn,{present:n||s.open,children:h.jsx(rc,{asChild:!0,container:o,children:a})})})};oC.displayName=ev;var Wa="MenuContent",[N3e,tv]=Ps(Wa),iC=b.forwardRef((e,t)=>{const n=rC(Wa,e.__scopeMenu),{forceMount:a=n.forceMount,...o}=e,s=Ls(Wa,e.__scopeMenu),l=S1(Wa,e.__scopeMenu);return h.jsx(Ku.Provider,{scope:e.__scopeMenu,children:h.jsx(Gn,{present:a||s.open,children:h.jsx(Ku.Slot,{scope:e.__scopeMenu,children:l.modal?h.jsx(T3e,{...o,ref:t}):h.jsx(P3e,{...o,ref:t})})})})}),T3e=b.forwardRef((e,t)=>{const n=Ls(Wa,e.__scopeMenu),a=b.useRef(null),o=it(t,a);return b.useEffect(()=>{const s=a.current;if(s)return i1(s)},[]),h.jsx(nv,{...e,ref:o,trapFocus:n.open,disableOutsidePointerEvents:n.open,disableOutsideScroll:!0,onFocusOutside:xe(e.onFocusOutside,s=>s.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>n.onOpenChange(!1)})}),P3e=b.forwardRef((e,t)=>{const n=Ls(Wa,e.__scopeMenu);return h.jsx(nv,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>n.onOpenChange(!1)})}),L3e=Mi("MenuContent.ScrollLock"),nv=b.forwardRef((e,t)=>{const{__scopeMenu:n,loop:a=!1,trapFocus:o,onOpenAutoFocus:s,onCloseAutoFocus:l,disableOutsidePointerEvents:c,onEntryFocus:d,onEscapeKeyDown:f,onPointerDownOutside:p,onFocusOutside:y,onInteractOutside:k,onDismiss:v,disableOutsideScroll:w,...S}=e,_=Ls(Wa,n),C=S1(Wa,n),A=c0(n),j=nC(n),N=C3e(n),[I,T]=b.useState(null),q=b.useRef(null),R=it(t,q,_.onContentChange),H=b.useRef(0),D=b.useRef(""),G=b.useRef(0),$=b.useRef(null),X=b.useRef("right"),F=b.useRef(0),W=w?oc:b.Fragment,P=w?{as:L3e,allowPinchZoom:!0}:void 0,U=se=>{const L=D.current+se,B=N().filter(oe=>!oe.disabled),V=document.activeElement,O=B.find(oe=>oe.ref.current===V)?.textValue,ee=B.map(oe=>oe.textValue),Q=G3e(ee,L,O),ae=B.find(oe=>oe.textValue===Q)?.ref.current;(function oe(de){D.current=de,window.clearTimeout(H.current),de!==""&&(H.current=window.setTimeout(()=>oe(""),1e3))})(L),ae&&setTimeout(()=>ae.focus())};b.useEffect(()=>()=>window.clearTimeout(H.current),[]),_2();const J=b.useCallback(se=>X.current===$.current?.side&&W3e(se,$.current?.area),[]);return h.jsx(N3e,{scope:n,searchRef:D,onItemEnter:b.useCallback(se=>{J(se)&&se.preventDefault()},[J]),onItemLeave:b.useCallback(se=>{J(se)||(q.current?.focus(),T(null))},[J]),onTriggerLeave:b.useCallback(se=>{J(se)&&se.preventDefault()},[J]),pointerGraceTimerRef:G,onPointerGraceIntentChange:b.useCallback(se=>{$.current=se},[]),children:h.jsx(W,{...P,children:h.jsx(o1,{asChild:!0,trapped:o,onMountAutoFocus:xe(s,se=>{se.preventDefault(),q.current?.focus({preventScroll:!0})}),onUnmountAutoFocus:l,children:h.jsx(ac,{asChild:!0,disableOutsidePointerEvents:c,onEscapeKeyDown:f,onPointerDownOutside:p,onFocusOutside:y,onInteractOutside:k,onDismiss:v,children:h.jsx(x3e,{asChild:!0,...j,dir:C.dir,orientation:"vertical",loop:a,currentTabStopId:I,onCurrentTabStopIdChange:T,onEntryFocus:xe(d,se=>{C.isUsingKeyboardRef.current||se.preventDefault()}),preventScrollOnEntryFocus:!0,children:h.jsx(s0,{role:"menu","aria-orientation":"vertical","data-state":wC(_.open),"data-radix-menu-content":"",dir:C.dir,...A,...S,ref:R,style:{outline:"none",...S.style},onKeyDown:xe(S.onKeyDown,se=>{const B=se.target.closest("[data-radix-menu-content]")===se.currentTarget,V=se.ctrlKey||se.altKey||se.metaKey,O=se.key.length===1;B&&(se.key==="Tab"&&se.preventDefault(),!V&&O&&U(se.key));const ee=q.current;if(se.target!==ee||!M3e.includes(se.key))return;se.preventDefault();const ae=N().filter(oe=>!oe.disabled).map(oe=>oe.ref.current);eC.includes(se.key)&&ae.reverse(),U3e(ae)}),onBlur:xe(e.onBlur,se=>{se.currentTarget.contains(se.target)||(window.clearTimeout(H.current),D.current="")}),onPointerMove:xe(e.onPointerMove,Gu(se=>{const L=se.target,B=F.current!==se.clientX;if(se.currentTarget.contains(L)&&B){const V=se.clientX>F.current?"right":"left";X.current=V,F.current=se.clientX}}))})})})})})})});iC.displayName=Wa;var z3e="MenuGroup",av=b.forwardRef((e,t)=>{const{__scopeMenu:n,...a}=e;return h.jsx(He.div,{role:"group",...a,ref:t})});av.displayName=z3e;var D3e="MenuLabel",sC=b.forwardRef((e,t)=>{const{__scopeMenu:n,...a}=e;return h.jsx(He.div,{...a,ref:t})});sC.displayName=D3e;var i2="MenuItem",A8="menu.itemSelect",u0=b.forwardRef((e,t)=>{const{disabled:n=!1,onSelect:a,...o}=e,s=b.useRef(null),l=S1(i2,e.__scopeMenu),c=tv(i2,e.__scopeMenu),d=it(t,s),f=b.useRef(!1),p=()=>{const y=s.current;if(!n&&y){const k=new CustomEvent(A8,{bubbles:!0,cancelable:!0});y.addEventListener(A8,v=>a?.(v),{once:!0}),N7(y,k),k.defaultPrevented?f.current=!1:l.onClose()}};return h.jsx(lC,{...o,ref:d,disabled:n,onClick:xe(e.onClick,p),onPointerDown:y=>{e.onPointerDown?.(y),f.current=!0},onPointerUp:xe(e.onPointerUp,y=>{f.current||y.currentTarget?.click()}),onKeyDown:xe(e.onKeyDown,y=>{const k=c.searchRef.current!=="";n||k&&y.key===" "||Gm.includes(y.key)&&(y.currentTarget.click(),y.preventDefault())})})});u0.displayName=i2;var lC=b.forwardRef((e,t)=>{const{__scopeMenu:n,disabled:a=!1,textValue:o,...s}=e,l=tv(i2,n),c=nC(n),d=b.useRef(null),f=it(t,d),[p,y]=b.useState(!1),[k,v]=b.useState("");return b.useEffect(()=>{const w=d.current;w&&v((w.textContent??"").trim())},[s.children]),h.jsx(Ku.ItemSlot,{scope:n,disabled:a,textValue:o??k,children:h.jsx(b3e,{asChild:!0,...c,focusable:!a,children:h.jsx(He.div,{role:"menuitem","data-highlighted":p?"":void 0,"aria-disabled":a||void 0,"data-disabled":a?"":void 0,...s,ref:f,onPointerMove:xe(e.onPointerMove,Gu(w=>{a?l.onItemLeave(w):(l.onItemEnter(w),w.defaultPrevented||w.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:xe(e.onPointerLeave,Gu(w=>l.onItemLeave(w))),onFocus:xe(e.onFocus,()=>y(!0)),onBlur:xe(e.onBlur,()=>y(!1))})})})}),I3e="MenuCheckboxItem",cC=b.forwardRef((e,t)=>{const{checked:n=!1,onCheckedChange:a,...o}=e;return h.jsx(pC,{scope:e.__scopeMenu,checked:n,children:h.jsx(u0,{role:"menuitemcheckbox","aria-checked":s2(n)?"mixed":n,...o,ref:t,"data-state":ov(n),onSelect:xe(o.onSelect,()=>a?.(s2(n)?!0:!n),{checkForDefaultPrevented:!1})})})});cC.displayName=I3e;var uC="MenuRadioGroup",[q3e,H3e]=Ps(uC,{value:void 0,onValueChange:()=>{}}),dC=b.forwardRef((e,t)=>{const{value:n,onValueChange:a,...o}=e,s=Nr(a);return h.jsx(q3e,{scope:e.__scopeMenu,value:n,onValueChange:s,children:h.jsx(av,{...o,ref:t})})});dC.displayName=uC;var hC="MenuRadioItem",fC=b.forwardRef((e,t)=>{const{value:n,...a}=e,o=H3e(hC,e.__scopeMenu),s=n===o.value;return h.jsx(pC,{scope:e.__scopeMenu,checked:s,children:h.jsx(u0,{role:"menuitemradio","aria-checked":s,...a,ref:t,"data-state":ov(s),onSelect:xe(a.onSelect,()=>o.onValueChange?.(n),{checkForDefaultPrevented:!1})})})});fC.displayName=hC;var rv="MenuItemIndicator",[pC,V3e]=Ps(rv,{checked:!1}),yC=b.forwardRef((e,t)=>{const{__scopeMenu:n,forceMount:a,...o}=e,s=V3e(rv,n);return h.jsx(Gn,{present:a||s2(s.checked)||s.checked===!0,children:h.jsx(He.span,{...o,ref:t,"data-state":ov(s.checked)})})});yC.displayName=rv;var F3e="MenuSeparator",mC=b.forwardRef((e,t)=>{const{__scopeMenu:n,...a}=e;return h.jsx(He.div,{role:"separator","aria-orientation":"horizontal",...a,ref:t})});mC.displayName=F3e;var B3e="MenuArrow",gC=b.forwardRef((e,t)=>{const{__scopeMenu:n,...a}=e,o=c0(n);return h.jsx(l0,{...o,...a,ref:t})});gC.displayName=B3e;var $3e="MenuSub",[VAe,kC]=Ps($3e),Mu="MenuSubTrigger",vC=b.forwardRef((e,t)=>{const n=Ls(Mu,e.__scopeMenu),a=S1(Mu,e.__scopeMenu),o=kC(Mu,e.__scopeMenu),s=tv(Mu,e.__scopeMenu),l=b.useRef(null),{pointerGraceTimerRef:c,onPointerGraceIntentChange:d}=s,f={__scopeMenu:e.__scopeMenu},p=b.useCallback(()=>{l.current&&window.clearTimeout(l.current),l.current=null},[]);return b.useEffect(()=>p,[p]),b.useEffect(()=>{const y=c.current;return()=>{window.clearTimeout(y),d(null)}},[c,d]),h.jsx(Jk,{asChild:!0,...f,children:h.jsx(lC,{id:o.triggerId,"aria-haspopup":"menu","aria-expanded":n.open,"aria-controls":n.open?o.contentId:void 0,"data-state":wC(n.open),...e,ref:Kg(t,o.onTriggerChange),onClick:y=>{e.onClick?.(y),!(e.disabled||y.defaultPrevented)&&(y.currentTarget.focus(),n.open||n.onOpenChange(!0))},onPointerMove:xe(e.onPointerMove,Gu(y=>{s.onItemEnter(y),!y.defaultPrevented&&!e.disabled&&!n.open&&!l.current&&(s.onPointerGraceIntentChange(null),l.current=window.setTimeout(()=>{n.onOpenChange(!0),p()},100))})),onPointerLeave:xe(e.onPointerLeave,Gu(y=>{p();const k=n.content?.getBoundingClientRect();if(k){const v=n.content?.dataset.side,w=v==="right",S=w?-5:5,_=k[w?"left":"right"],C=k[w?"right":"left"];s.onPointerGraceIntentChange({area:[{x:y.clientX+S,y:y.clientY},{x:_,y:k.top},{x:C,y:k.top},{x:C,y:k.bottom},{x:_,y:k.bottom}],side:v}),window.clearTimeout(c.current),c.current=window.setTimeout(()=>s.onPointerGraceIntentChange(null),300)}else{if(s.onTriggerLeave(y),y.defaultPrevented)return;s.onPointerGraceIntentChange(null)}})),onKeyDown:xe(e.onKeyDown,y=>{const k=s.searchRef.current!=="";e.disabled||k&&y.key===" "||S3e[a.dir].includes(y.key)&&(n.onOpenChange(!0),n.content?.focus(),y.preventDefault())})})})});vC.displayName=Mu;var xC="MenuSubContent",bC=b.forwardRef((e,t)=>{const n=rC(Wa,e.__scopeMenu),{forceMount:a=n.forceMount,align:o="start",...s}=e,l=Ls(Wa,e.__scopeMenu),c=S1(Wa,e.__scopeMenu),d=kC(xC,e.__scopeMenu),f=b.useRef(null),p=it(t,f);return h.jsx(Ku.Provider,{scope:e.__scopeMenu,children:h.jsx(Gn,{present:a||l.open,children:h.jsx(Ku.Slot,{scope:e.__scopeMenu,children:h.jsx(nv,{id:d.contentId,"aria-labelledby":d.triggerId,...s,ref:p,align:o,side:c.dir==="rtl"?"left":"right",disableOutsidePointerEvents:!1,disableOutsideScroll:!1,trapFocus:!1,onOpenAutoFocus:y=>{c.isUsingKeyboardRef.current&&f.current?.focus(),y.preventDefault()},onCloseAutoFocus:y=>y.preventDefault(),onFocusOutside:xe(e.onFocusOutside,y=>{y.target!==d.trigger&&l.onOpenChange(!1)}),onEscapeKeyDown:xe(e.onEscapeKeyDown,y=>{c.onClose(),y.preventDefault()}),onKeyDown:xe(e.onKeyDown,y=>{const k=y.currentTarget.contains(y.target),v=_3e[c.dir].includes(y.key);k&&v&&(l.onOpenChange(!1),d.trigger?.focus(),y.preventDefault())})})})})})});bC.displayName=xC;function wC(e){return e?"open":"closed"}function s2(e){return e==="indeterminate"}function ov(e){return s2(e)?"indeterminate":e?"checked":"unchecked"}function U3e(e){const t=document.activeElement;for(const n of e)if(n===t||(n.focus(),document.activeElement!==t))return}function K3e(e,t){return e.map((n,a)=>e[(t+a)%e.length])}function G3e(e,t,n){const o=t.length>1&&Array.from(t).every(f=>f===t[0])?t[0]:t,s=n?e.indexOf(n):-1;let l=K3e(e,Math.max(s,0));o.length===1&&(l=l.filter(f=>f!==n));const d=l.find(f=>f.toLowerCase().startsWith(o.toLowerCase()));return d!==n?d:void 0}function Y3e(e,t){const{x:n,y:a}=e;let o=!1;for(let s=0,l=t.length-1;s<t.length;l=s++){const c=t[s],d=t[l],f=c.x,p=c.y,y=d.x,k=d.y;p>a!=k>a&&n<(y-f)*(a-p)/(k-p)+f&&(o=!o)}return o}function W3e(e,t){if(!t)return!1;const n={x:e.clientX,y:e.clientY};return Y3e(n,t)}function Gu(e){return t=>t.pointerType==="mouse"?e(t):void 0}var Z3e=aC,Q3e=Jk,X3e=oC,J3e=iC,ebe=av,tbe=sC,nbe=u0,abe=cC,rbe=dC,obe=fC,ibe=yC,sbe=mC,lbe=gC,cbe=vC,ube=bC,d0="DropdownMenu",[dbe]=dr(d0,[tC]),Yn=tC(),[hbe,MC]=dbe(d0),SC=e=>{const{__scopeDropdownMenu:t,children:n,dir:a,open:o,defaultOpen:s,onOpenChange:l,modal:c=!0}=e,d=Yn(t),f=b.useRef(null),[p,y]=fo({prop:o,defaultProp:s??!1,onChange:l,caller:d0});return h.jsx(hbe,{scope:t,triggerId:Ya(),triggerRef:f,contentId:Ya(),open:p,onOpenChange:y,onOpenToggle:b.useCallback(()=>y(k=>!k),[y]),modal:c,children:h.jsx(Z3e,{...d,open:p,onOpenChange:y,dir:a,modal:c,children:n})})};SC.displayName=d0;var _C="DropdownMenuTrigger",CC=b.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,disabled:a=!1,...o}=e,s=MC(_C,n),l=Yn(n);return h.jsx(Q3e,{asChild:!0,...l,children:h.jsx(He.button,{type:"button",id:s.triggerId,"aria-haspopup":"menu","aria-expanded":s.open,"aria-controls":s.open?s.contentId:void 0,"data-state":s.open?"open":"closed","data-disabled":a?"":void 0,disabled:a,...o,ref:Kg(t,s.triggerRef),onPointerDown:xe(e.onPointerDown,c=>{!a&&c.button===0&&c.ctrlKey===!1&&(s.onOpenToggle(),s.open||c.preventDefault())}),onKeyDown:xe(e.onKeyDown,c=>{a||(["Enter"," "].includes(c.key)&&s.onOpenToggle(),c.key==="ArrowDown"&&s.onOpenChange(!0),["Enter"," ","ArrowDown"].includes(c.key)&&c.preventDefault())})})})});CC.displayName=_C;var fbe="DropdownMenuPortal",AC=e=>{const{__scopeDropdownMenu:t,...n}=e,a=Yn(t);return h.jsx(X3e,{...a,...n})};AC.displayName=fbe;var EC="DropdownMenuContent",RC=b.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...a}=e,o=MC(EC,n),s=Yn(n),l=b.useRef(!1);return h.jsx(J3e,{id:o.contentId,"aria-labelledby":o.triggerId,...s,...a,ref:t,onCloseAutoFocus:xe(e.onCloseAutoFocus,c=>{l.current||o.triggerRef.current?.focus(),l.current=!1,c.preventDefault()}),onInteractOutside:xe(e.onInteractOutside,c=>{const d=c.detail.originalEvent,f=d.button===0&&d.ctrlKey===!0,p=d.button===2||f;(!o.modal||p)&&(l.current=!0)}),style:{...e.style,"--radix-dropdown-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-dropdown-menu-content-available-width":"var(--radix-popper-available-width)","--radix-dropdown-menu-content-available-height":"var(--radix-popper-available-height)","--radix-dropdown-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-dropdown-menu-trigger-height":"var(--radix-popper-anchor-height)"}})});RC.displayName=EC;var pbe="DropdownMenuGroup",ybe=b.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...a}=e,o=Yn(n);return h.jsx(ebe,{...o,...a,ref:t})});ybe.displayName=pbe;var mbe="DropdownMenuLabel",gbe=b.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...a}=e,o=Yn(n);return h.jsx(tbe,{...o,...a,ref:t})});gbe.displayName=mbe;var kbe="DropdownMenuItem",jC=b.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...a}=e,o=Yn(n);return h.jsx(nbe,{...o,...a,ref:t})});jC.displayName=kbe;var vbe="DropdownMenuCheckboxItem",xbe=b.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...a}=e,o=Yn(n);return h.jsx(abe,{...o,...a,ref:t})});xbe.displayName=vbe;var bbe="DropdownMenuRadioGroup",wbe=b.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...a}=e,o=Yn(n);return h.jsx(rbe,{...o,...a,ref:t})});wbe.displayName=bbe;var Mbe="DropdownMenuRadioItem",Sbe=b.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...a}=e,o=Yn(n);return h.jsx(obe,{...o,...a,ref:t})});Sbe.displayName=Mbe;var _be="DropdownMenuItemIndicator",Cbe=b.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...a}=e,o=Yn(n);return h.jsx(ibe,{...o,...a,ref:t})});Cbe.displayName=_be;var Abe="DropdownMenuSeparator",OC=b.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...a}=e,o=Yn(n);return h.jsx(sbe,{...o,...a,ref:t})});OC.displayName=Abe;var Ebe="DropdownMenuArrow",Rbe=b.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...a}=e,o=Yn(n);return h.jsx(lbe,{...o,...a,ref:t})});Rbe.displayName=Ebe;var jbe="DropdownMenuSubTrigger",Obe=b.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...a}=e,o=Yn(n);return h.jsx(cbe,{...o,...a,ref:t})});Obe.displayName=jbe;var Nbe="DropdownMenuSubContent",Tbe=b.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...a}=e,o=Yn(n);return h.jsx(ube,{...o,...a,ref:t,style:{...e.style,"--radix-dropdown-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-dropdown-menu-content-available-width":"var(--radix-popper-available-width)","--radix-dropdown-menu-content-available-height":"var(--radix-popper-available-height)","--radix-dropdown-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-dropdown-menu-trigger-height":"var(--radix-popper-anchor-height)"}})});Tbe.displayName=Nbe;var Pbe=SC,Lbe=CC,zbe=AC,NC=RC,TC=jC,PC=OC;const Dbe=Pbe,Ibe=Lbe,LC=b.forwardRef(({className:e,sideOffset:t=4,...n},a)=>h.jsx(zbe,{children:h.jsx(NC,{ref:a,sideOffset:t,className:ye("z-50 min-w-[8rem] overflow-hidden rounded-md border border-border bg-popover p-1 text-popover-foreground ","data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",e),...n})}));LC.displayName=NC.displayName;const Ym=b.forwardRef(({className:e,inset:t,...n},a)=>h.jsx(TC,{ref:a,className:ye("relative flex cursor-default select-none items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&>svg]:size-4 [&>svg]:shrink-0",t&&"pl-8",e),...n}));Ym.displayName=TC.displayName;const zC=b.forwardRef(({className:e,...t},n)=>h.jsx(PC,{ref:n,className:ye("-mx-1 my-1 h-px bg-border",e),...t}));zC.displayName=PC.displayName;function FAe(){return st({queryKey:["automation-catalog"],queryFn:async()=>(await Kn("manage_catalog",{action:"list_catalog",kinds:["automations"]})).catalogs?.automations?.entries??[],staleTime:6e4})}function DC(e,t,n){return st({queryKey:["automations-list",e,t,!0],queryFn:async()=>(await Kn("manage_automations",{action:"list",entity_id:t,status:"active",include_details:!0})).automations||[],enabled:!!e,staleTime:3e4})}function BAe(e,t){return st({queryKey:["automations-list","agent",e,t?.includeDetails??!0],queryFn:async()=>(await Kn("manage_automations",{action:"list",managed_agent_id:e,status:"active",include_details:t?.includeDetails??!0})).automations||[],enabled:!!e,staleTime:3e4})}function $Ae(e,t,n,a={}){return st({queryKey:["automation-detail",e,t,a.since,a.until,a.templateVersion,a.includeVersions??!1],queryFn:async()=>await Kn("get_automation",{automation_id:e,entity_id:t,content_since:a.since,content_until:a.until,template_version:a.templateVersion,page_size:100,include_classification:"summary",include_versions:a.includeVersions??!1},void 0,{timeoutMs:3e4}),enabled:!!e&&!!n,staleTime:3e4})}const UAe=We({tool:"manage_automations",body:e=>({action:"update",...e}),invalidateKeys:["automations-list","automation-detail","automations"],checkError:!1,successMessage:"Automation updated",errorMessage:"Failed to update Automation"}),KAe=We({tool:"manage_automations",body:e=>({action:"delete",automation_ids:[e]}),invalidateKeys:["automations-list","automation-detail","automations","agent-threads"],checkError:!1,successMessage:"Automation deleted",errorMessage:"Failed to delete Automation"}),GAe=We({tool:"manage_automations",body:e=>({action:"create",...e}),invalidateKeys:["automations-list","automations"],successMessage:"Automation created",errorMessage:"Failed to create Automation"});function YAe(){const e=sn();return Qa({mutationFn:async t=>Kn("manage_automations",{action:"create_version",...t}),onSuccess:()=>{e.invalidateQueries({queryKey:["automations-list"]}),e.invalidateQueries({queryKey:["automation-detail"]}),e.invalidateQueries({queryKey:["automations"]})}})}function WAe(){const e=sn();return Qa({mutationFn:async t=>Kn("manage_automations",{action:"set_reaction_script",...t}),onSuccess:()=>{e.invalidateQueries({queryKey:["automations-list"]}),e.invalidateQueries({queryKey:["automation-detail"]}),e.invalidateQueries({queryKey:["automations"]})}})}const qbe=200;function ZAe(e,t){return st({queryKey:["automation-promoted",t,e],enabled:!!e&&!!t,queryFn:async()=>(await Kn("manage_automations",{action:"list_promoted",automation_id:e,limit:qbe+1})).entities??[],staleTime:3e4})}function IC(e){const t=(e??"").replace(/^\/+|\/+$/g,"");if(!t)return{isEntityDetail:!1};const n=t.split("/");return{typeSegment:n[0],path:t,isEntityDetail:n.length>1}}function QAe(e,t,n){return{to:"/$owner/events",params:{owner:e},search:Dt({...t,...n})}}function qC(e,t){return{to:"/$owner/$entityType",params:{owner:e,entityType:t},search:{create:void 0}}}function XAe(e,t){return SM(e,t)}function HC(e){const t=typeof e.entity=="string"&&e.entity.trim()?e.entity.trim():void 0;return t?uz(t):void 0}function Hbe(e){return e.create===!0||e.create==="true"?"true":void 0}function JAe(e){const t=e.connection_ids;return typeof t=="number"?String(t):typeof t=="string"&&t.trim()?t.trim():void 0}function Vbe(e){const t=e.agent??e.agent_id;return typeof t=="string"&&t.trim()?t.trim():void 0}function eEe(e){return Vbe(e)}function Fbe(e){const t=e.automation;return typeof t=="number"?String(t):typeof t=="string"&&t.trim()?t.trim():void 0}function tEe(e){return Fbe(e)}function Bbe(e){const t=e.schedule;return typeof t=="string"&&t.trim()?t.trim():void 0}function nEe(e){return Bbe(e)}function aEe(e,t,n){return{to:"/$owner/events",params:{owner:e},search:Dt({feed_ids:String(t),connection_ids:n?.connectionScope,agent:void 0,automation:void 0,schedule:void 0,platforms:void 0,run_ids:void 0,at:void 0})}}function rEe(e,t){return{to:"/$owner/events",params:{owner:e},search:Dt({connection_ids:String(t),feed_ids:void 0,agent:void 0,automation:void 0,at:void 0})}}function $be(e){const t=HC(e),n=typeof e.type=="string"&&e.type.trim()?ks(e.type.trim()):void 0,a=Hbe(e),o=uc(e);return t?{...Dt({entity:t,create:a}),...o}:n?{...Dt({type:n,create:a}),...o}:{...Dt({create:a}),...o}}function Ube(e){const t=$be(e),n=typeof e.type=="string"&&e.type.trim()?e.type.trim():void 0,a=typeof e.entity=="string"&&e.entity.trim()?e.entity.trim():void 0;return a&&t.entity&&a!==t.entity||n&&t.type&&n!==t.type||a&&n?t:null}function oEe(e,t){if(t.size===0)return;let n;const a=new Set;for(const o of e)for(const s of o.connections){const l=String(s.id);if(t.has(l)){if(n&&n!==o.connector_key)return;n=o.connector_key,a.add(l)}}return a.size===t.size?n:void 0}function Kbe(e){return qC(e,"$member")}function iEe(e){return{to:"/$owner/memory",params:{owner:e},search:Dt({create_type:"true"})}}const Lt=b.forwardRef(({className:e,type:t,...n},a)=>h.jsx("input",{type:t,className:ye("flex h-9 w-full rounded-md border border-input bg-muted px-3 py-1 text-base transition-colors file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",e),ref:a,...n}));Lt.displayName="Input";var Gbe="Label",VC=b.forwardRef((e,t)=>h.jsx(He.label,{...e,ref:t,onMouseDown:n=>{n.target.closest("button, input, select, textarea")||(e.onMouseDown?.(n),!n.defaultPrevented&&n.detail>1&&n.preventDefault())}}));VC.displayName=Gbe;var FC=VC;const ha=b.forwardRef(({className:e,...t},n)=>h.jsx(FC,{ref:n,className:ye("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70",e),...t}));ha.displayName=FC.displayName;function Ybe(e,t){b.useEffect(()=>{function n(a){e.current&&!e.current.contains(a.target)&&t()}return document.addEventListener("mousedown",n),()=>document.removeEventListener("mousedown",n)},[e,t])}function Wbe(e){const t=e.urlOrgSlug?e.organizations.find(o=>o.slug===e.urlOrgSlug):null;if(e.isAuthenticated){if(e.urlOrgSlug){const s=t?.name||e.urlOrgSlug;return{displayName:s,displayLogo:t?.logo||void 0,displayInitial:s[0]||"W",activeSlug:e.urlOrgSlug}}return{displayName:e.activeOrg?.name||e.sessionUser?.name||"Personal",displayLogo:e.activeOrg?.logo||e.sessionUser?.image||void 0,displayInitial:e.activeOrg?.name?.[0]||e.sessionUser?.name?.[0]||e.sessionUser?.email?.[0]||"P",activeSlug:e.activeOrg?.slug||null}}const n=e.urlOrgSlug?t:e.organizations[0],a=n?.name||e.urlOrgSlug||"Select Organization";return{displayName:a,displayLogo:n?.logo||void 0,displayInitial:a[0]||"W",activeSlug:e.urlOrgSlug||n?.slug||null}}function Zbe(e){return e.urlOrgSlug?e.organization.slug===e.urlOrgSlug:e.organization.id===e.activeOrg?.id||e.organization.slug===e.activeOrg?.slug}function E8(e){return e.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")}function Qbe({organization:e,isActive:t,onSelect:n,manageable:a,onManageNavigate:o,isPublic:s}){const l=e.name[0]?.toUpperCase()||"W";return h.jsxs(On,{onSelect:n,value:e.name,className:"group flex w-full cursor-pointer items-center gap-2 px-3 py-2 pr-1 text-sm",children:[h.jsx("div",{className:"h-6 w-6 shrink-0 overflow-hidden rounded bg-muted flex items-center justify-center",children:e.logo?h.jsx("img",{src:e.logo,alt:"",className:"h-full w-full object-cover",referrerPolicy:"no-referrer"}):h.jsx("span",{className:"text-xs font-medium",children:l})}),h.jsx("span",{className:"flex-1 truncate text-left",children:e.name}),s?h.jsx(GM,{className:"h-3.5 w-3.5 shrink-0 text-muted-foreground","aria-label":"Public organization"}):null,a?h.jsx(ge,{asChild:!0,variant:"ghost",size:"icon",className:"h-7 w-7 shrink-0 opacity-0 transition-opacity group-hover:opacity-100 focus-visible:opacity-100","aria-label":`Settings for ${e.name}`,children:h.jsx(Ct,{to:"/$owner/settings/organization",params:{owner:e.slug},onMouseDown:c=>{c.stopPropagation()},onClick:c=>{c.stopPropagation(),o?.()},children:h.jsx(S2,{className:"h-4 w-4"})})}):null,t&&h.jsx(Za,{className:"h-4 w-4 shrink-0 text-primary"})]})}function BC({iconOnly:e=!1}){const[t,n]=b.useState(!1),[a,o]=b.useState(!1),[s,l]=b.useState(""),[c,d]=b.useState(""),[f,p]=b.useState(!1),[y,k]=b.useState(null),[v,w]=b.useState(!1),S=b.useRef(null),_=qn(),{data:C}=mk(),A=U9(),j=C??(A?[A]:[]),{session:N,urlOrgSlug:I,activeOrg:T}=er(),q=!!N,R=b.useMemo(()=>{const P=j.filter(J=>J.is_member),U=j.filter(J=>!J.is_member);return[...P,...U]},[j]),H=b.useCallback(()=>n(!1),[]);Ybe(S,H);const D=P=>{const U=EM(P);if(U.kind==="cross-host"){window.location.assign(U.href);return}_({to:U.to})},G=async(P,U,J=!0)=>{N&&J&&P?(await Au.setActive({organizationId:P}),U?D(U):_({to:"/"})):U&&D(U),n(!1)},$=async()=>{if(k(null),!s.trim()){k("Name is required");return}w(!0);try{const P=c.trim()||E8(s),U=await Au.create({name:s.trim(),slug:P});U.error?k(U.error.message||"Failed to create organization"):(o(!1),l(""),d(""),p(!1),U.data&&(await Au.setActive({organizationId:U.data.id}),D(U.data.slug)))}catch(P){k(P instanceof Error?P.message:"An error occurred")}finally{w(!1)}},{displayName:X,displayLogo:F,displayInitial:W}=Wbe({isAuthenticated:q,urlOrgSlug:I,activeOrg:T,sessionUser:N?.user,organizations:j});return h.jsxs("div",{className:ye("relative min-w-0",e?"shrink-0":"flex-1"),ref:S,children:[h.jsxs("button",{type:"button",onClick:()=>n(!t),"aria-label":X?`Switch workspace (${X})`:"Switch workspace",title:e?X??"Switch workspace":void 0,className:ye("flex cursor-pointer items-center gap-2 rounded-lg px-2 py-1 transition-colors hover:bg-sidebar-accent/60",e?"h-9 w-9 justify-center p-0":"w-full"),children:[h.jsx("div",{className:"h-7 w-7 shrink-0 overflow-hidden rounded-lg bg-sidebar-foreground/10 flex items-center justify-center",children:F?h.jsx("img",{src:F,alt:"",className:"h-full w-full object-cover",referrerPolicy:"no-referrer"}):h.jsx("span",{className:"text-sidebar-foreground text-sm font-semibold",children:W.toUpperCase()})}),e?null:h.jsx("span",{className:"flex-1 truncate text-left font-semibold",children:X}),e?null:h.jsx(n1,{className:`h-4 w-4 shrink-0 transition-transform ${t?"rotate-180":""}`})]}),t&&h.jsx("div",{className:"absolute left-0 right-0 top-full z-50 mt-1 min-w-[240px] overflow-hidden rounded-lg border border-border bg-popover ",children:h.jsxs(l1,{className:"bg-transparent",children:[h.jsx(L2,{placeholder:"Search organizations...",className:"h-9"}),h.jsxs(z2,{className:"max-h-[300px]",children:[h.jsx(D2,{children:"No organizations found."}),q?h.jsx(Ka,{heading:"Organizations",children:R.map(P=>h.jsx(Qbe,{organization:P,isActive:Zbe({organization:P,urlOrgSlug:I,activeOrg:T}),onSelect:()=>G(P.id,P.slug,P.is_member),manageable:P.is_member,isPublic:!P.is_member,onManageNavigate:()=>n(!1)},P.id))}):null]}),h.jsx("div",{className:"border-t border-border",children:q?h.jsx(Ka,{children:h.jsxs(On,{onSelect:()=>{n(!1),o(!0)},className:"cursor-pointer text-muted-foreground",children:[h.jsx(la,{className:"mr-2 h-4 w-4"}),h.jsx("span",{children:"Create Organization"})]})}):h.jsx(Ka,{children:h.jsxs(On,{onSelect:()=>{n(!1),_({to:"/auth/login",search:kk()})},className:"cursor-pointer text-muted-foreground",children:[h.jsx(la,{className:"mr-2 h-4 w-4"}),h.jsx("span",{children:"Sign in to create organization"})]})})})]})}),h.jsx(sk,{open:a,onOpenChange:P=>{P||(o(!1),k(null))},children:h.jsxs(P2,{className:"sm:max-w-md",children:[h.jsxs(lk,{children:[h.jsx(ck,{children:"Create Organization"}),h.jsx(uk,{children:"Create a new organization to collaborate with others."})]}),h.jsxs("div",{className:"space-y-4 py-2",children:[h.jsxs("div",{className:"space-y-1.5",children:[h.jsx(ha,{htmlFor:"org-name",children:"Name"}),h.jsx(Lt,{id:"org-name",value:s,onChange:P=>{l(P.target.value),f||d(E8(P.target.value))},placeholder:"e.g. My Team"})]}),h.jsxs("div",{className:"space-y-1.5",children:[h.jsx(ha,{htmlFor:"org-slug",children:"Slug"}),h.jsx(Lt,{id:"org-slug",value:c,onChange:P=>{p(!0),d(P.target.value)},placeholder:"e.g. my-team"})]}),y&&h.jsx("div",{className:"rounded-md bg-destructive/10 px-3 py-2 text-sm text-destructive",children:y})]}),h.jsxs("div",{className:"flex justify-end gap-2",children:[h.jsx(ge,{variant:"outline",onClick:()=>o(!1),disabled:v,children:"Cancel"}),h.jsx(ge,{onClick:$,disabled:v,children:v?"Creating...":"Create"})]})]})})]})}const Xbe="/$owner/chat/$agentId/c/$threadId";function Jbe(e,t,n){return{to:Xbe,params:{owner:e,agentId:t,threadId:n}}}function e6e(e,t){throw ca({to:"/$owner/agents/$agentId/settings",params:{owner:e,agentId:t},search:{run_id:void 0},replace:!0})}function t6e(e){const{session:t,isReady:n}=Xa(),a=n?t?.user.id:void 0,o=e?.limit??20,l=(e?.clientIds??[]).join(","),c=e?.activityKind??null,d=e?.excludeCommandClients??!1,f=e?.refetchInterval;return st({queryKey:["client-activity-scopes",a,o,l,c,d],queryFn:async()=>{const p=new URLSearchParams({limit:String(o)});l&&p.set("client_ids",l),c&&p.set("activity_kind",c),d&&p.set("exclude_command_clients","true");const y=await Ge(`${pt}/api/me/clients/activity-scopes?${p}`,{credentials:"include"});return await Un(y,"Failed to load client activity"),(await y.json()).scopes??[]},enabled:!!a&&(e?.enabled??!0),staleTime:15e3,refetchInterval:typeof f=="function"?p=>f((p.state.data?.length??0)>0):f})}const R8=12,n6e=5e3;function a6e(e){const t=e.title?.trim();if(t)return t;if(e.activityKind==="session")return"MCP session";const n=e.clientName?.trim();return n||e.clientId}function r6e(e){const t=e.title?.trim(),n=e.lastAction?.trim();return[`${e.callCount} ${e.callCount===1?"call":"calls"}`,n&&n!==t?n:null].filter(Boolean).join(" · ")}function j8(e){const t=typeof e.callCount=="number"?`${e.callCount} ${e.callCount===1?"call":"calls"}`:null,n=e.lastAction?.trim();return[e.isRunning?"Running":null,t,n?W9(n).replace(/\b(Sql|Api|Mcp|Url|Id)\b/g,o=>o.toUpperCase()):null,e.locationLabel?.trim()].filter(Boolean).join(" · ")||void 0}function o6e(e){switch(e){case"slack":return s7;case"telegram":return o7;case"whatsapp":case"discord":return XM;default:return Bg}}function Ky(e,t){let n=0;for(const a of e){if(t.kind==="automation"){a.automation_id===t.automationId&&(n+=1);continue}if(a.href){if(t.kind==="mcp"){try{const o=new URL(a.href,"http://localhost");(o.searchParams.get("client_ids")??"").split(",").filter(Boolean).includes(t.clientId)&&o.searchParams.get("mcp_activity_id")===t.activityId&&(n+=1)}catch{}continue}try{const{pathname:o}=new URL(a.href,"http://localhost"),s=`/${t.owner}/chat/${t.agentId}`;(o===s||o.startsWith(`${s}/`))&&(n+=1)}catch{}}}return n}function Gy({count:e}){return e===0?null:h.jsx("span",{role:"img",title:"Needs attention","aria-label":`${e} item${e===1?"":"s"} need attention`,className:"shrink-0 rounded-full bg-blue-500/15 px-1.5 py-0.5 text-[10px] font-semibold text-blue-600 dark:text-blue-400",children:e})}function ph({to:e,params:t,search:n,active:a,icon:o,leading:s,label:l,detail:c,lastActivityAt:d,trailing:f,tone:p}){const y=[c?.trim(),k1(d)].filter(Boolean).join(" · "),k=p==="page"?"text-muted-foreground":"text-sidebar-foreground/50";return h.jsxs(Ct,{to:e,params:t,search:n,"aria-label":l,"data-recent-row":"",className:ye("block rounded-md px-3 py-2 text-sm transition-colors",p==="sidebar"&&"mx-2",a?p==="page"?"bg-accent text-accent-foreground":"bg-sidebar-accent text-sidebar-accent-foreground":p==="page"?"text-foreground hover:bg-accent/60":"text-sidebar-foreground/80 hover:bg-sidebar-accent/60 hover:text-sidebar-foreground"),children:[h.jsxs("span",{className:"flex items-center gap-1.5",children:[h.jsx("span",{className:"min-w-0 flex-1 truncate",children:l}),f]}),h.jsxs("span",{className:ye("mt-0.5 flex min-w-0 items-center gap-1.5 text-xs",k),children:[h.jsx("span",{className:"flex h-3.5 w-3.5 shrink-0 items-center justify-center",children:s??(o?h.jsx(o,{className:"h-3.5 w-3.5"}):null)}),h.jsx("span",{className:"truncate",children:y})]})]})}function i6e(e){const{data:t}=vo(),n=t??[],a=b.useMemo(()=>n.map(f=>f.agentId),[n]),{threads:o}=x0e(e,a,{enabled:!!e&&a.length>0,limit:R8}),{data:s=[]}=t6e({limit:R8,excludeCommandClients:!0,refetchInterval:f=>f?n6e:!1}),{orgContext:l}=er(),{data:c}=DC(l?.organizationId,void 0),d=b.useMemo(()=>new Set((c??[]).map(f=>String(f.automation_id))),[c]);return b.useMemo(()=>[...(c===void 0?o:o.filter(p=>p.platform!=="automation"||p.automationId==null?!0:d.has(String(p.automationId)))).map(p=>({kind:"conversation",at:p.updatedAt,thread:p})),...s.map(p=>({kind:"mcp",at:p.lastCallAt,conversation:p}))].sort((p,y)=>y.at-p.at),[d,c,s,o])}function s6e({owner:e,tone:t="sidebar",empty:n="hide"}){const{agentId:a=null,threadId:o=null,conversationId:s=null,automationId:l=null}=e1({strict:!1}),{attentionCards:c}=v1(e),d=i6e(e);return d.length===0?n==="hide"?null:h.jsx(v1e,{icon:Vu,title:"Nothing recent",description:"Chats, connected apps, and Automations you use will show up here."}):h.jsxs("div",{className:ye(t==="page"&&"flex flex-col gap-0.5"),children:[t==="sidebar"?h.jsx("div",{className:"px-3 pb-1 pt-3 text-[11px] font-semibold uppercase tracking-wider text-sidebar-foreground/40",children:"Recent"}):null,d.map(f=>{if(f.kind==="mcp")return h.jsx(ph,{to:"/$owner/events",params:{owner:"me"},search:{client_ids:f.conversation.clientId,mcp_activity_id:f.conversation.activityId},active:!1,leading:h.jsx(l_,{name:f.conversation.clientName}),label:a6e(f.conversation),detail:r6e(f.conversation),lastActivityAt:f.at,tone:t,trailing:h.jsx(Gy,{count:Ky(c,{kind:"mcp",clientId:f.conversation.clientId,activityId:f.conversation.activityId})})},`mcp:${f.conversation.clientId}:${f.conversation.activityId}`);const p=f.thread,y=p.title,k=(p.platform??"web")==="web";if(p.platform==="automation"&&p.automationId!=null)return h.jsx(ph,{to:"/$owner/automations/$automationId",params:{owner:e,automationId:String(p.automationId)},active:l===String(p.automationId),leading:h.jsx(Vg,{className:"h-3.5 w-3.5"}),label:y,detail:"Automation",lastActivityAt:p.updatedAt,tone:t,trailing:h.jsx(Gy,{count:Ky(c,{kind:"automation",automationId:p.automationId})})},`automation:workspace:${p.automationId}`);if(!k)return h.jsx(ph,{to:"/$owner/agents/$agentId/conversations/$conversationId",params:{owner:e,agentId:p.agentId,conversationId:p.conversationId??p.id},active:a===p.agentId&&s===(p.conversationId??p.id),icon:o6e(p.platform),label:y,detail:j8(p),lastActivityAt:p.updatedAt,tone:t},`conversation:${p.agentId}:${p.id}`);const v=Jbe(e,p.agentId,p.id);return h.jsx(ph,{to:v.to,params:v.params,active:a===p.agentId&&o===p.id,icon:Bg,label:y,detail:j8(p),lastActivityAt:p.updatedAt,tone:t,trailing:h.jsx(Gy,{count:Ky(c,{kind:"agent",owner:e,agentId:p.agentId})})},`chat:${p.agentId}:${p.id}`)})]})}function Wm(){document.dispatchEvent(new KeyboardEvent("keydown",{key:"k",metaKey:!0,bubbles:!0}))}function Yu({to:e,params:t,search:n,active:a,icon:o,leading:s,label:l,trailing:c}){const d=h.jsxs(h.Fragment,{children:[h.jsx("span",{className:"flex h-3.5 w-3.5 shrink-0 items-center justify-center text-sidebar-foreground/60",children:s??(o?h.jsx(o,{className:"h-3.5 w-3.5"}):null)}),h.jsx("span",{className:"min-w-0 flex-1 truncate",children:l}),c]}),f=ye("mx-2 flex items-center gap-2 rounded-md py-1.5 pl-3 pr-3 text-sm transition-colors",a?"bg-sidebar-accent text-sidebar-accent-foreground":e?"text-sidebar-foreground/80 hover:bg-sidebar-accent/60 hover:text-sidebar-foreground":"text-sidebar-foreground/80");return e?h.jsx(Ct,{to:e,params:t,search:n,title:l,className:f,children:d}):h.jsx("div",{className:f,children:d})}function l6e(e){const[t,n]=b.useState(null),[a,o]=b.useState(e);return e!==a&&(o(e),n(null)),{open:t??e,setOpen:n}}function c6e({open:e}){return h.jsx("span",{className:"flex h-5 w-5 shrink-0 items-center justify-center rounded-md text-sidebar-foreground/40 transition-colors hover:bg-sidebar-accent/60 hover:text-sidebar-foreground",children:h.jsx(da,{className:ye("h-3.5 w-3.5 transition-transform",e?"rotate-90":"rotate-0")})})}function u6e({count:e}){return h.jsx("span",{className:"shrink-0 text-[11px] tabular-nums text-sidebar-foreground/40",children:e})}function h0({count:e,title:t}){return h.jsx("span",{"aria-hidden":"true",title:t,className:"shrink-0 text-[11px] tabular-nums text-sidebar-foreground/40",children:e.toLocaleString()})}function d6e(){return h.jsx("span",{title:"Derived view",className:"shrink-0 text-[11px] lowercase text-sidebar-foreground/40",children:"derived"})}function h6e({ownerSlug:e,active:t,searchRecord:n,entityTypeParam:a}){const o=zn.context,{open:s,setOpen:l}=l6e(t),{orgContext:c}=er(),{data:d}=G9(c),f=b.useMemo(()=>(d??[]).filter(v=>!v.organization_slug||v.organization_slug===e),[d,e]),p=d?f.reduce((v,w)=>v+(w.backing_sql?0:w.entity_count??0),0):void 0,y=a?ks(a):typeof n.type=="string"?n.type:typeof n.entity=="string"?n.entity.split("/")[0]:void 0,k=t&&!(s&&y);return h.jsxs(J2,{open:s,onOpenChange:l,children:[h.jsxs("div",{className:ye("mx-2 flex items-center gap-2 rounded-md py-1.5 pl-3 pr-2 text-sm transition-colors",k?"bg-sidebar-accent text-sidebar-accent-foreground":"text-sidebar-foreground/80 hover:bg-sidebar-accent/60 hover:text-sidebar-foreground"),children:[h.jsxs(Ct,{to:o.to,params:{owner:e},search:o.search,className:"flex min-w-0 flex-1 items-center gap-2",children:[h.jsx("span",{className:"flex h-3.5 w-3.5 shrink-0 items-center justify-center text-sidebar-foreground/60",children:h.jsx(o.icon,{className:"h-3.5 w-3.5"})}),h.jsx("span",{className:ye("min-w-0 flex-1 truncate",s&&!k&&"text-sidebar-foreground/50"),children:o.label})]}),p!=null?h.jsx(h0,{count:p,title:`${p} records`}):null,f.length>0?h.jsx(e0,{asChild:!0,children:h.jsx("button",{type:"button","aria-label":s?"Collapse entity types":"Expand entity types",title:s?"Collapse entity types":"Expand entity types",className:"shrink-0",children:h.jsx(c6e,{open:s})})}):null]}),h.jsx(t0,{children:f.map(v=>{const w=qC(e,v.slug);return h.jsx(Yu,{to:w.to,params:w.params,search:w.search,active:y===v.slug,leading:h.jsx(tk,{icon:v.icon,className:"h-3.5 w-3.5"}),label:v.name||v.slug,trailing:v.backing_sql?h.jsx(d6e,{}):h.jsx(u6e,{count:v.entity_count??0})},v.slug)})})]})}function f6e(e){return e.trim().charAt(0).toUpperCase()||"?"}function p6e({name:e,status:t}){return h.jsxs("span",{"aria-hidden":"true","data-agent-avatar":e,className:"relative flex h-[18px] w-[18px] shrink-0 items-center justify-center rounded-full bg-sidebar-accent text-[9px] font-semibold text-sidebar-accent-foreground",children:[f6e(e),t?h.jsx("span",{className:ye("absolute -bottom-0.5 -right-0.5 h-[7px] w-[7px] rounded-full border-[1.5px] border-sidebar-background",t==="active"?"bg-emerald-500":"bg-sidebar-foreground/30")}):null]})}function y6e({ownerSlug:e,active:t,currentAgent:n,count:a}){const o=zn.agents,s=t&&!n;return h.jsxs("div",{children:[h.jsx(Yu,{to:o.to,params:{owner:e},search:o.search,active:s,icon:o.icon,label:o.label,trailing:a!=null?h.jsx(h0,{count:a,title:`${a} agents`}):void 0}),n?h.jsxs(Ct,{to:"/$owner/agents/$agentId/settings",params:{owner:e,agentId:n.agentId},search:{run_id:void 0},className:"mx-2 flex items-center gap-2 rounded-md py-1.5 pl-3 pr-3 text-sm transition-colors bg-sidebar-accent text-sidebar-accent-foreground",children:[h.jsx(p6e,{name:n.name,status:n.status}),h.jsx("span",{className:"min-w-0 flex-1 truncate",children:n.name}),n.status==="active"?h.jsx("span",{className:"shrink-0 text-[10px] text-sidebar-foreground/40",children:"working"}):null]}):null]})}function m6e({ownerSlug:e,active:t,currentAutomation:n,count:a}){const o=zn.automations,s=t&&!n;return h.jsxs("div",{children:[h.jsx(Yu,{to:o.to,params:{owner:e},search:o.search,active:s,icon:o.icon,label:o.label,trailing:a!=null?h.jsx(h0,{count:a,title:`${a} Automations`}):void 0}),n?h.jsxs(Ct,{to:"/$owner/automations/$automationId",params:{owner:e,automationId:n.automationId},search:{view:"activity",run_id:void 0},className:"mx-2 flex items-center gap-2 rounded-md py-1.5 pl-3 pr-3 text-sm transition-colors bg-sidebar-accent text-sidebar-accent-foreground",children:[h.jsx("span",{className:"flex h-3.5 w-3.5 shrink-0 items-center justify-center text-sidebar-foreground/60",children:h.jsx(Vg,{className:"h-3.5 w-3.5"})}),h.jsx("span",{className:"min-w-0 flex-1 truncate",children:n.name})]}):null]})}function g6e(){const e=qn(),{session:t}=Xa(),n=t?.user?.name?.trim()||"You";return h.jsx("div",{className:"border-t border-sidebar-border p-2",children:h.jsxs(Dbe,{children:[h.jsx(Ibe,{asChild:!0,children:h.jsxs("button",{type:"button",className:"flex w-full items-center gap-2 rounded-md px-3 py-1.5 text-sm text-sidebar-foreground/80 transition-colors hover:bg-sidebar-accent/60 hover:text-sidebar-foreground",children:[h.jsx(Ig,{className:"h-4 w-4 shrink-0 text-sidebar-foreground/60"}),h.jsx("span",{className:"min-w-0 flex-1 truncate text-left",children:n}),h.jsx(n1,{className:"h-4 w-4 shrink-0 text-sidebar-foreground/40"})]})}),h.jsxs(LC,{align:"start",side:"top",className:"min-w-[12rem]",children:[h.jsxs(Ym,{onSelect:()=>void e({to:"/account/settings"}),children:[h.jsx(S2,{className:"h-4 w-4"}),h.jsx("span",{children:"Account settings"})]}),h.jsx(zC,{}),h.jsxs(Ym,{className:"text-destructive",onSelect:()=>{(async()=>(await cM(),window.location.href="/"))()},children:[h.jsx(Fg,{className:"h-4 w-4"}),h.jsx("span",{children:"Sign out"})]})]})]})})}function yh({label:e,active:t=!1,icon:n,onClick:a,to:o,params:s,search:l}){const c=ye("mx-auto flex h-9 w-9 items-center justify-center rounded-md transition-colors",t?"bg-sidebar-accent text-sidebar-accent-foreground":"text-sidebar-foreground/70 hover:bg-sidebar-accent/60 hover:text-sidebar-foreground");return o?h.jsx(Ct,{to:o,params:s,search:l,"aria-label":e,title:e,className:c,children:h.jsx(n,{className:"h-5 w-5"})}):h.jsx("button",{type:"button",onClick:a,"aria-label":e,title:e,className:c,children:h.jsx(n,{className:"h-5 w-5"})})}function k6e({to:e,params:t,search:n,active:a,label:o,icon:s}){return h.jsxs(Ct,{to:e,params:t,search:n,"aria-label":o,title:o,className:ye("flex h-9 items-center justify-center gap-1.5 rounded-md text-sm transition-colors",a?"bg-sidebar-accent px-2.5 text-sidebar-accent-foreground":"w-9 shrink-0 text-sidebar-foreground/70 hover:bg-sidebar-accent/60 hover:text-sidebar-foreground"),children:[h.jsx(s,{className:"h-5 w-5 shrink-0"}),a?h.jsx("span",{className:"whitespace-nowrap font-medium",children:o}):null]})}function v6e(){const{currentOwner:e}=er(),{pathname:t}=t1(),n=e&&!e.startsWith("@")?e:null;return h.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-1",children:[h.jsx(BC,{iconOnly:!0}),n?h.jsx("div",{className:"flex min-w-0 flex-1 items-center overflow-x-auto",children:h.jsx("div",{className:"mx-auto flex shrink-0 items-center gap-0.5",children:Object.keys(zn).map(a=>{const o=zn[a];return h.jsx(k6e,{to:o.to,params:{owner:n},search:o.search,active:jm(a,n,t),label:o.label,icon:o.icon},a)})})}):h.jsx("div",{className:"flex-1"}),n?h.jsx("button",{type:"button",onClick:Wm,"aria-label":"Search",title:"Search (⌘K)",className:"flex h-9 w-9 shrink-0 items-center justify-center rounded-md text-sidebar-foreground/70 transition-colors hover:bg-sidebar-accent/60 hover:text-sidebar-foreground",children:h.jsx(_m,{className:"h-5 w-5"})}):null]})}function x6e({embedded:e=!1,collapsed:t=!1,onToggleCollapsed:n}){const{agentId:a=null,automationId:o=null,entityType:s=null}=e1({strict:!1}),{pathname:l,search:c}=t1(),{available:d,isOpen:f,open:p}=O6e(),y=c??{},{currentOwner:k,orgContext:v,allOrgs:w}=er(),S=k&&!k.startsWith("@")?k:null,_=!!S&&w.some(U=>U.slug===S),{data:C}=vo(),A=C??[],{data:j}=f1(_?`/${S}`:"",v),N=j?.counts,I=N?N.agents+N.clients:void 0,T=N?.connections,q=b.useMemo(()=>a&&l.startsWith(`/${S}/agents/`)?A.find(U=>U.agentId===a):void 0,[a,S,l,A]),{attentionCards:R,isLoading:H,isError:D}=v1(S),G=H||D?void 0:R.length,{data:$}=DC(v?.organizationId,void 0),X=b.useMemo(()=>{if(!o)return;const U=($??[]).find(J=>String(J.automation_id)===String(o));return U?{automationId:String(U.automation_id),name:U.name}:void 0},[o,$]),F=N?.automations,W=S?l===`/${S}/recent`||l.startsWith(`/${S}/recent/`):!1;return t&&!e?h.jsxs("aside",{className:"fixed inset-y-0 left-0 z-40 flex w-14 flex-col items-center border-r border-border bg-sidebar-background text-sidebar-foreground",children:[h.jsx("div",{className:"flex h-14 w-full items-center justify-center border-b border-sidebar-border",children:h.jsx("button",{type:"button",onClick:n,"aria-label":"Expand sidebar",title:"Expand sidebar",className:"flex h-9 w-9 items-center justify-center rounded-md text-sidebar-foreground/70 transition-colors hover:bg-sidebar-accent/60 hover:text-sidebar-foreground",children:h.jsx(n7,{className:"h-[18px] w-[18px]"})})}),S?h.jsxs("div",{className:"flex flex-1 flex-col gap-1 overflow-y-auto py-2",children:[h.jsx(yh,{label:"Search",icon:_m,onClick:Wm}),d?h.jsx(yh,{label:f?"Lobu Lens is open":"Open Lobu Lens",icon:Xh,onClick:()=>void p()}):null,Object.keys(zn).map(U=>{const J=zn[U];return h.jsx(yh,{label:J.label,active:jm(U,S,l),icon:J.icon,to:J.to,params:{owner:S},search:J.search},U)}),h.jsx(yh,{label:"Recent",active:W,icon:Vu,to:"/$owner/recent",params:{owner:S}})]}):h.jsx("div",{className:"flex-1"})]}):h.jsxs("aside",{className:ye("flex flex-col bg-sidebar-background text-sidebar-foreground",e?"h-full w-full":"fixed inset-y-0 left-0 z-40 w-[17.25rem] border-r border-border"),children:[h.jsxs("div",{className:ye("flex h-14 items-center gap-1 px-2",!e&&"border-b border-sidebar-border"),children:[h.jsx("div",{className:"min-w-0 flex-1",children:h.jsx(BC,{})}),d?h.jsx("button",{type:"button","data-lobu-lens-open":"",onClick:()=>void p(),"aria-label":f?"Lobu Lens is open":"Open Lobu Lens",title:f?"Lobu Lens is open":"Open Lobu Lens",className:"flex h-8 w-8 shrink-0 items-center justify-center rounded-md text-primary transition-colors hover:bg-sidebar-accent/60",children:h.jsx(Xh,{className:"h-5 w-5"})}):null,h.jsx("button",{type:"button",onClick:Wm,"aria-label":"Search",title:"Search (⌘K)",className:"flex h-8 w-8 shrink-0 items-center justify-center rounded-md text-sidebar-foreground/60 transition-colors hover:bg-sidebar-accent/60 hover:text-sidebar-foreground",children:h.jsx(_m,{className:"h-5 w-5"})}),!e&&n?h.jsx("button",{type:"button",onClick:n,"aria-label":"Collapse sidebar",title:"Collapse sidebar",className:"flex h-8 w-8 shrink-0 items-center justify-center rounded-md text-sidebar-foreground/60 transition-colors hover:bg-sidebar-accent/60 hover:text-sidebar-foreground",children:h.jsx(t7,{className:"h-[18px] w-[18px]"})}):null]}),S?h.jsxs(h.Fragment,{children:[h.jsxs("div",{className:"flex flex-1 flex-col overflow-y-auto py-2",children:[Object.keys(zn).map(U=>{const J=zn[U],se=jm(U,S,l),L=U==="activity"?G:U==="connectors"?T:void 0,B=L==null?"":U==="activity"?`${L} item${L===1?"":"s"} need attention`:`${L} configured connection${L===1?"":"s"}`;return U==="context"?h.jsx(h6e,{ownerSlug:S,active:se,searchRecord:y,entityTypeParam:s},U):U==="agents"?h.jsx(y6e,{ownerSlug:S,active:se,currentAgent:q,count:I},U):U==="automations"?h.jsx(m6e,{ownerSlug:S,active:se,currentAutomation:X,count:F},U):h.jsx(Yu,{to:J.to,params:{owner:S},search:J.search,active:se,icon:J.icon,label:J.label,trailing:L!=null?h.jsx(h0,{count:L,title:B}):void 0},U)}),e?h.jsx(Yu,{to:"/$owner/recent",params:{owner:S},active:W,icon:Vu,label:"Recent"}):h.jsx(s6e,{owner:S})]}),h.jsx(g6e,{})]}):h.jsx("div",{className:"flex flex-1 flex-col items-center justify-center px-4 text-center text-xs text-sidebar-foreground/50",children:"Pick an organization to continue."})]})}function b6e(e,t){const[n,a]=b.useState(!1);return b.useEffect(()=>{const o=e.current;if(!o||(a(o.clientWidth<=t),typeof ResizeObserver>"u"))return;const s=new ResizeObserver(l=>{const c=l[0];c&&a(c.contentRect.width<=t)});return s.observe(o),()=>s.disconnect()},[e,t]),n}const w6e=640,$C=b.createContext(!1);function UC(){return b.useContext($C)}const O8=new Set(["auth","oauth"]);function M6e(e){const t=e.split("/").filter(Boolean);return O8.has(t[0]??"")||O8.has(t[1]??"")}const N8="lobu.sidebar.collapsed";function S6e({children:e}){const t=b.useRef(null),n=b6e(t,w6e),a=t1(),[o,s]=b.useState(()=>{try{return localStorage.getItem(N8)==="1"}catch{return!1}}),l=()=>{s(d=>{const f=!d;try{localStorage.setItem(N8,f?"1":"0")}catch{}return f})},c=M6e(a.pathname);return h.jsxs($C.Provider,{value:n,children:[h.jsx(yfe,{}),h.jsx("div",{ref:t,className:"h-dvh overflow-hidden bg-background text-foreground",children:c?h.jsxs("div",{className:"flex h-full flex-col overflow-x-hidden overflow-y-auto",children:[h.jsx(by,{}),e]}):n?h.jsxs("div",{className:"flex h-dvh flex-col overflow-hidden",children:[h.jsx("header",{className:"z-30 flex h-14 shrink-0 items-center gap-2 bg-background px-3",children:h.jsx(v6e,{})}),h.jsx(by,{}),h.jsx("main",{className:"flex min-h-0 flex-1 flex-col overflow-x-hidden overflow-y-auto",children:e})]}):h.jsxs(h.Fragment,{children:[h.jsx(x6e,{collapsed:o,onToggleCollapsed:l}),h.jsxs("main",{className:ye("flex h-dvh flex-col overflow-hidden transition-[padding] duration-200",o?"pl-14":"pl-[17.25rem]"),children:[h.jsx(by,{}),h.jsx("div",{className:"flex min-h-0 flex-1 flex-col overflow-x-hidden overflow-y-auto",children:e})]})]})})]})}function T8(){if(window.__lobuAmbientContext)return window.__lobuAmbientContext;if(window.parent!==window&&/^chrome-extension:\/\/[a-p]{32}$/.test(window.location.ancestorOrigins?.[0]??""))return{kind:"browser",url:null,title:null,applicationName:"Chrome"}}function sEe(){const[e,t]=b.useState(T8);return b.useEffect(()=>{const n=()=>t(T8());window.addEventListener("owletto:ambient-context",n),n();const a=o=>{const s=v4e(o,window.parent,window);s&&t(s)};return window.addEventListener("message",a),window.parent!==window&&window.parent.postMessage({owletto:"ambient-context-request"},"*"),()=>{window.removeEventListener("owletto:ambient-context",n),window.removeEventListener("message",a)}},[]),e}function _6e({owner:e,context:t,emptyState:n,tabs:a,onOpenItem:o,compact:s=!1,relevant:l}){const[c,d]=b.useState(!1),f=UC(),{attentionItems:p}=v1(e),y=t!==void 0&&(l??!c),k=y?w=>m4e(w,t):void 0,v=k?p.filter(k).length:p.length;return h.jsxs(h.Fragment,{children:[h.jsxs("div",{className:ye("sticky top-0 z-20 flex min-w-0 flex-wrap items-center gap-x-4 gap-y-2 bg-background pt-1",f?"justify-center":"justify-between"),children:[a??(t?h.jsxs("fieldset",{className:"flex items-center gap-2","aria-label":"Notification scope",children:[h.jsxs("button",{type:"button","aria-pressed":!c,onClick:()=>d(!1),className:"rounded-md px-2.5 py-1 text-xs aria-pressed:bg-muted",children:["Relevant here",y?` (${v})`:""]}),h.jsx("button",{type:"button","aria-pressed":c,onClick:()=>d(!0),className:"rounded-md px-2.5 py-1 text-xs aria-pressed:bg-muted",children:"All notifications"})]}):null),!y&&!s&&h.jsx(U5e,{owner:e})]}),h.jsx(K5e,{owner:e,itemFilter:k,onOpenItem:o,rowAction:s?"none":"open",ariaLabel:y?"Relevant here":"Needs attention",tone:y?"relevant":"default",emptyState:y?h.jsx("p",{className:"px-3 py-6 text-center text-xs text-muted-foreground",children:"No notifications linked to this context."}):n})]})}const C6e={width:340,height:360},A6e={width:340,height:436},KC=b.createContext(null);function P8(){return window.documentPictureInPicture??null}function E6e(e){const t=e.createElement("base");t.href=document.baseURI,e.head.append(t);for(const n of document.querySelectorAll('link[rel="stylesheet"], style')){const a=n.cloneNode(!0);n instanceof HTMLLinkElement&&a instanceof HTMLLinkElement&&(a.href=n.href),e.head.append(a)}e.documentElement.className=document.documentElement.className,e.documentElement.style.colorScheme=getComputedStyle(document.documentElement).colorScheme,e.body.style.margin="0",e.body.style.width="100vw",e.body.style.height="100vh",e.body.style.overflow="hidden"}function R6e({owner:e,activeContext:t}){const n=qn(),a=b.useCallback(s=>{(async()=>{if(!s.href)return;const{pathname:l,search:c}=sc(s.href);await n({to:l,search:c??{}}),await x4e()})()},[n]),o=t??{kind:"browser",url:null,title:null,applicationName:"Chrome"};return h.jsx("main",{className:"lobu-lens-surface bg-background text-foreground","aria-label":"Context notifications",children:h.jsx("div",{className:"lobu-lens-content",children:h.jsx(_6e,{owner:e,context:o,compact:!0,onOpenItem:a,emptyState:h.jsx("div",{className:"lobu-lens-empty text-muted-foreground",children:"All caught up"})},`${e}:${g4e(o)}`)})})}function j6e({children:e}){const{currentOwner:t}=er(),n=t??null,[a,o]=b.useState(()=>({kind:"browser",url:window.location.href,title:document.title||null,applicationName:"Browser"})),[s,l]=b.useState(null),c=b.useRef(null),d=b.useCallback(async()=>{if(c.current&&!c.current.closed){c.current.focus();return}if(!n)throw new Error("Open a Lobu workspace before starting Lens.");const p=P8();if(!p)throw new Error("This browser does not support Document Picture-in-Picture.");const y=document.documentElement.dataset.owlettoDebuggerAttached==="true",k=await p.requestWindow(y?A6e:C6e);c.current=k,E6e(k.document);const v=k.document.createElement("div");v.id="lobu-lens-root",v.style.width="100%",v.style.height="100%",k.document.body.append(v),l(v),k.addEventListener("pagehide",()=>{c.current===k&&(c.current=null,l(null))},{once:!0})},[n]);b.useEffect(()=>{const p=y=>{const k=y_(y);(k?.kind==="browser"||k?.kind==="application")&&o(k)};return document.addEventListener(o8,p),document.dispatchEvent(new Event(p4e)),()=>{document.removeEventListener(o8,p),c.current?.close()}},[]);const f=b.useMemo(()=>({available:n!=null&&P8()!=null,isOpen:s!=null,open:d}),[d,n,s]);return h.jsxs(KC.Provider,{value:f,children:[e,s&&n?go.createPortal(h.jsx(R6e,{owner:n,activeContext:a}),s):null]})}function O6e(){const e=b.useContext(KC);return e||{available:!1,isOpen:!1,open:async()=>{}}}var GC=Object.freeze({position:"absolute",border:0,width:1,height:1,padding:0,margin:-1,overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",wordWrap:"normal"}),N6e="VisuallyHidden",YC=b.forwardRef((e,t)=>h.jsx(He.span,{...e,ref:t,style:{...GC,...e.style}}));YC.displayName=N6e;var T6e=YC,[f0]=dr("Tooltip",[Ti]),p0=Ti(),WC="TooltipProvider",P6e=700,Zm="tooltip.open",[L6e,iv]=f0(WC),ZC=e=>{const{__scopeTooltip:t,delayDuration:n=P6e,skipDelayDuration:a=300,disableHoverableContent:o=!1,children:s}=e,l=b.useRef(!0),c=b.useRef(!1),d=b.useRef(0);return b.useEffect(()=>{const f=d.current;return()=>window.clearTimeout(f)},[]),h.jsx(L6e,{scope:t,isOpenDelayedRef:l,delayDuration:n,onOpen:b.useCallback(()=>{a<=0||(window.clearTimeout(d.current),l.current=!1)},[a]),onClose:b.useCallback(()=>{a<=0||(window.clearTimeout(d.current),d.current=window.setTimeout(()=>l.current=!0,a))},[a]),isPointerInTransitRef:c,onPointerInTransitChange:b.useCallback(f=>{c.current=f},[]),disableHoverableContent:o,children:s})};ZC.displayName=WC;var Wu="Tooltip",[z6e,_1]=f0(Wu),QC=e=>{const{__scopeTooltip:t,children:n,open:a,defaultOpen:o,onOpenChange:s,disableHoverableContent:l,delayDuration:c}=e,d=iv(Wu,e.__scopeTooltip),f=p0(t),[p,y]=b.useState(null),k=Ya(),v=b.useRef(0),w=l??d.disableHoverableContent,S=c??d.delayDuration,_=b.useRef(!1),[C,A]=fo({prop:a,defaultProp:o??!1,onChange:q=>{q?(d.onOpen(),document.dispatchEvent(new CustomEvent(Zm))):d.onClose(),s?.(q)},caller:Wu}),j=b.useMemo(()=>C?_.current?"delayed-open":"instant-open":"closed",[C]),N=b.useCallback(()=>{window.clearTimeout(v.current),v.current=0,_.current=!1,A(!0)},[A]),I=b.useCallback(()=>{window.clearTimeout(v.current),v.current=0,A(!1)},[A]),T=b.useCallback(()=>{window.clearTimeout(v.current),v.current=window.setTimeout(()=>{_.current=!0,A(!0),v.current=0},S)},[S,A]);return b.useEffect(()=>()=>{v.current&&(window.clearTimeout(v.current),v.current=0)},[]),h.jsx(i0,{...f,children:h.jsx(z6e,{scope:t,contentId:k,open:C,stateAttribute:j,trigger:p,onTriggerChange:y,onTriggerEnter:b.useCallback(()=>{d.isOpenDelayedRef.current?T():N()},[d.isOpenDelayedRef,T,N]),onTriggerLeave:b.useCallback(()=>{w?I():(window.clearTimeout(v.current),v.current=0)},[I,w]),onOpen:N,onClose:I,disableHoverableContent:w,children:n})})};QC.displayName=Wu;var Qm="TooltipTrigger",XC=b.forwardRef((e,t)=>{const{__scopeTooltip:n,...a}=e,o=_1(Qm,n),s=iv(Qm,n),l=p0(n),c=b.useRef(null),d=it(t,c,o.onTriggerChange),f=b.useRef(!1),p=b.useRef(!1),y=b.useCallback(()=>f.current=!1,[]);return b.useEffect(()=>()=>document.removeEventListener("pointerup",y),[y]),h.jsx(b1,{asChild:!0,...l,children:h.jsx(He.button,{"aria-describedby":o.open?o.contentId:void 0,"data-state":o.stateAttribute,...a,ref:d,onPointerMove:xe(e.onPointerMove,k=>{k.pointerType!=="touch"&&!p.current&&!s.isPointerInTransitRef.current&&(o.onTriggerEnter(),p.current=!0)}),onPointerLeave:xe(e.onPointerLeave,()=>{o.onTriggerLeave(),p.current=!1}),onPointerDown:xe(e.onPointerDown,()=>{o.open&&o.onClose(),f.current=!0,document.addEventListener("pointerup",y,{once:!0})}),onFocus:xe(e.onFocus,()=>{f.current||o.onOpen()}),onBlur:xe(e.onBlur,o.onClose),onClick:xe(e.onClick,o.onClose)})})});XC.displayName=Qm;var sv="TooltipPortal",[D6e,I6e]=f0(sv,{forceMount:void 0}),JC=e=>{const{__scopeTooltip:t,forceMount:n,children:a,container:o}=e,s=_1(sv,t);return h.jsx(D6e,{scope:t,forceMount:n,children:h.jsx(Gn,{present:n||s.open,children:h.jsx(rc,{asChild:!0,container:o,children:a})})})};JC.displayName=sv;var Jl="TooltipContent",eA=b.forwardRef((e,t)=>{const n=I6e(Jl,e.__scopeTooltip),{forceMount:a=n.forceMount,side:o="top",...s}=e,l=_1(Jl,e.__scopeTooltip);return h.jsx(Gn,{present:a||l.open,children:l.disableHoverableContent?h.jsx(tA,{side:o,...s,ref:t}):h.jsx(q6e,{side:o,...s,ref:t})})}),q6e=b.forwardRef((e,t)=>{const n=_1(Jl,e.__scopeTooltip),a=iv(Jl,e.__scopeTooltip),o=b.useRef(null),s=it(t,o),[l,c]=b.useState(null),{trigger:d,onClose:f}=n,p=o.current,{onPointerInTransitChange:y}=a,k=b.useCallback(()=>{c(null),y(!1)},[y]),v=b.useCallback((w,S)=>{const _=w.currentTarget,C={x:w.clientX,y:w.clientY},A=$6e(C,_.getBoundingClientRect()),j=U6e(C,A),N=K6e(S.getBoundingClientRect()),I=Y6e([...j,...N]);c(I),y(!0)},[y]);return b.useEffect(()=>()=>k(),[k]),b.useEffect(()=>{if(d&&p){const w=_=>v(_,p),S=_=>v(_,d);return d.addEventListener("pointerleave",w),p.addEventListener("pointerleave",S),()=>{d.removeEventListener("pointerleave",w),p.removeEventListener("pointerleave",S)}}},[d,p,v,k]),b.useEffect(()=>{if(l){const w=S=>{const _=S.target,C={x:S.clientX,y:S.clientY},A=d?.contains(_)||p?.contains(_),j=!G6e(C,l);A?k():j&&(k(),f())};return document.addEventListener("pointermove",w),()=>document.removeEventListener("pointermove",w)}},[d,p,l,f,k]),h.jsx(tA,{...e,ref:s})}),[H6e,V6e]=f0(Wu,{isInside:!1}),F6e=mue("TooltipContent"),tA=b.forwardRef((e,t)=>{const{__scopeTooltip:n,children:a,"aria-label":o,onEscapeKeyDown:s,onPointerDownOutside:l,...c}=e,d=_1(Jl,n),f=p0(n),{onClose:p}=d;return b.useEffect(()=>(document.addEventListener(Zm,p),()=>document.removeEventListener(Zm,p)),[p]),b.useEffect(()=>{if(d.trigger){const y=k=>{k.target instanceof Node&&k.target.contains(d.trigger)&&p()};return window.addEventListener("scroll",y,{capture:!0}),()=>window.removeEventListener("scroll",y,{capture:!0})}},[d.trigger,p]),h.jsx(ac,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:s,onPointerDownOutside:l,onFocusOutside:y=>y.preventDefault(),onDismiss:p,children:h.jsxs(s0,{"data-state":d.stateAttribute,...f,...c,ref:t,style:{...c.style,"--radix-tooltip-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-tooltip-content-available-width":"var(--radix-popper-available-width)","--radix-tooltip-content-available-height":"var(--radix-popper-available-height)","--radix-tooltip-trigger-width":"var(--radix-popper-anchor-width)","--radix-tooltip-trigger-height":"var(--radix-popper-anchor-height)"},children:[h.jsx(F6e,{children:a}),h.jsx(H6e,{scope:n,isInside:!0,children:h.jsx(T6e,{id:d.contentId,role:"tooltip",children:o||a})})]})})});eA.displayName=Jl;var nA="TooltipArrow",B6e=b.forwardRef((e,t)=>{const{__scopeTooltip:n,...a}=e,o=p0(n);return V6e(nA,n).isInside?null:h.jsx(l0,{...o,...a,ref:t})});B6e.displayName=nA;function $6e(e,t){const n=Math.abs(t.top-e.y),a=Math.abs(t.bottom-e.y),o=Math.abs(t.right-e.x),s=Math.abs(t.left-e.x);switch(Math.min(n,a,o,s)){case s:return"left";case o:return"right";case n:return"top";case a:return"bottom";default:throw new Error("unreachable")}}function U6e(e,t,n=5){const a=[];switch(t){case"top":a.push({x:e.x-n,y:e.y+n},{x:e.x+n,y:e.y+n});break;case"bottom":a.push({x:e.x-n,y:e.y-n},{x:e.x+n,y:e.y-n});break;case"left":a.push({x:e.x+n,y:e.y-n},{x:e.x+n,y:e.y+n});break;case"right":a.push({x:e.x-n,y:e.y-n},{x:e.x-n,y:e.y+n});break}return a}function K6e(e){const{top:t,right:n,bottom:a,left:o}=e;return[{x:o,y:t},{x:n,y:t},{x:n,y:a},{x:o,y:a}]}function G6e(e,t){const{x:n,y:a}=e;let o=!1;for(let s=0,l=t.length-1;s<t.length;l=s++){const c=t[s],d=t[l],f=c.x,p=c.y,y=d.x,k=d.y;p>a!=k>a&&n<(y-f)*(a-p)/(k-p)+f&&(o=!o)}return o}function Y6e(e){const t=e.slice();return t.sort((n,a)=>n.x<a.x?-1:n.x>a.x?1:n.y<a.y?-1:n.y>a.y?1:0),W6e(t)}function W6e(e){if(e.length<=1)return e.slice();const t=[];for(let a=0;a<e.length;a++){const o=e[a];for(;t.length>=2;){const s=t[t.length-1],l=t[t.length-2];if((s.x-l.x)*(o.y-l.y)>=(s.y-l.y)*(o.x-l.x))t.pop();else break}t.push(o)}t.pop();const n=[];for(let a=e.length-1;a>=0;a--){const o=e[a];for(;n.length>=2;){const s=n[n.length-1],l=n[n.length-2];if((s.x-l.x)*(o.y-l.y)>=(s.y-l.y)*(o.x-l.x))n.pop();else break}n.push(o)}return n.pop(),t.length===1&&n.length===1&&t[0].x===n[0].x&&t[0].y===n[0].y?t:t.concat(n)}var Z6e=ZC,Q6e=QC,X6e=XC,J6e=JC,aA=eA;const e8e=Z6e,lEe=Q6e,cEe=X6e,t8e=b.forwardRef(({className:e,sideOffset:t=4,...n},a)=>h.jsx(J6e,{children:h.jsx(aA,{ref:a,sideOffset:t,className:ye("z-50 overflow-hidden rounded-md bg-primary px-3 py-1.5 text-xs text-primary-foreground animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",e),...n})}));t8e.displayName=aA.displayName;const Yy=3e3,n8e=6e4;function a8e(e){const t=sn(),n=b.useRef(null),a=b.useRef(null),o=b.useRef(Yy);b.useEffect(()=>{if(!e)return;let s=!1;async function l(){const c=await Cz(`${pt}/api/${e}/events`);if(s){c.close();return}n.current=c,c.onopen=()=>{o.current=Yy},c.addEventListener("invalidate",d=>{try{const f=JSON.parse(d.data);if(f.keys)for(const p of f.keys)t.invalidateQueries({queryKey:[p]})}catch{}}),c.onerror=()=>{c.close(),n.current=null,!s&&(a.current=setTimeout(()=>{a.current=null,s||l()},o.current),o.current=Math.min(o.current*2,n8e))}}return l(),()=>{s=!0,n.current?.close(),n.current=null,a.current!=null&&(clearTimeout(a.current),a.current=null),o.current=Yy}},[e,t])}function r8e(){const{session:e,sessionResult:t,isReady:n}=Xa(),a=typeof window<"u"&&!window.location.pathname.startsWith("/auth/"),{data:o}=K0e({enabled:a}),s=sn(),l=b.useRef(!1);b.useEffect(()=>{!n||e||l.current||o?.singleUserMode&&(l.current=!0,(async()=>{try{(await Sz()).ok&&(await t.refetch(),await s.invalidateQueries())}catch{}})())},[n,e,o,t,s])}const ka=eT()({component:o8e});function o8e(){const{session:e,isReady:t}=Xa();r8e();const n=typeof window<"u"?location.pathname:"/",a=n.startsWith("/oauth/")||n.startsWith("/slack/")||n.startsWith("/connector/"),o=AM();return a8e(t&&e?o:null),a?h.jsx("div",{className:"min-h-screen bg-background text-foreground",children:h.jsx(fm,{})}):h.jsx(j6e,{children:h.jsxs(e8e,{delayDuration:200,children:[h.jsx(sde,{richColors:!0,position:"bottom-right"}),h.jsx(S6e,{children:h.jsx(fm,{})}),null]})})}const i8e=()=>Ee(()=>import("./_owner-CFR1G8OX.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])),s8e=_e("/$owner")({loader:({context:{queryClient:e},params:t})=>{t.owner!=="me"&&e.prefetchQuery(gn.queryOptions(t.owner,{slug:t.owner}))},pendingComponent:()=>null,component:Ae(i8e,"component")}),l8e=()=>Ee(()=>import("./index-C2oCgDX7.js"),__vite__mapDeps([26,27])),c8e=_e("/")({component:Ae(l8e,"component")}),u8e=()=>Ee(()=>import("./index-Clw9ZBj-.js"),__vite__mapDeps([28,29,7,30,18,20,31,5,19,21,22,32,16,33])),d8e=_e("/$owner/")({loader:({context:{queryClient:e},params:t})=>{e.prefetchQuery(gn.queryOptions(t.owner,{slug:t.owner}))},validateSearch:e=>uc(e),component:Ae(u8e,"component")}),h8e=()=>Ee(()=>import("./claim-CUpWOSie.js"),[]),f8e=_e("/slack/claim")({component:Ae(h8e,"component"),validateSearch:e=>({team:typeof e.team=="string"?e.team:void 0,t:typeof e.t=="string"?e.t:void 0})}),p8e=()=>Ee(()=>import("./new-Df_dY6Z5.js"),__vite__mapDeps([34,22,27])),y8e=_e("/orgs/new")({component:Ae(p8e,"component"),validateSearch:e=>Dt({slug:e.slug||void 0,name:e.name||void 0})}),m8e=()=>Ee(()=>import("./device-DpY67Jaj.js"),__vite__mapDeps([35,36,22]));function g8e(e){if(typeof e!="string")return;const t=e.trim();if(t)try{const n=new URL(t);return n.protocol==="owletto:"||n.protocol==="lobu-ios-bridge:"?t:void 0}catch{return}}const k8e=_e("/oauth/device")({component:Ae(m8e,"component"),validateSearch:e=>Dt({user_code:typeof e.user_code=="string"&&e.user_code.trim().length>0?e.user_code.trim():void 0,return_to:g8e(e.return_to)})}),v8e=()=>Ee(()=>import("./consent-bswcIzsf.js"),__vite__mapDeps([37,36,22]));function oo(e){return typeof e=="string"?e:void 0}const x8e=_e("/oauth/consent")({component:Ae(v8e,"component"),validateSearch:e=>Dt({client_id:oo(e.client_id),redirect_uri:oo(e.redirect_uri),scope:oo(e.scope),state:oo(e.state),code_challenge:oo(e.code_challenge),code_challenge_method:oo(e.code_challenge_method),client_name:oo(e.client_name),resource:oo(e.resource),authorization_intent:oo(e.authorization_intent),workspace_grants:e.workspace_grants==="1"||e.workspace_grants===1?"1":void 0})}),b8e=()=>Ee(()=>import("./reset-password-CuISnlG_.js"),__vite__mapDeps([38,22])),w8e=_e("/auth/reset-password")({component:Ae(b8e,"component"),validateSearch:e=>Dt({token:typeof e.token=="string"?e.token:void 0,error:typeof e.error=="string"?e.error:void 0})}),M8e=()=>Ee(()=>import("./logout-B-N2aodZ.js"),[]),S8e=_e("/auth/logout")({component:Ae(M8e,"component")}),_8e=()=>Ee(()=>import("./login-CCKNM0gV.js"),__vite__mapDeps([39,40,22])),C8e=_e("/auth/login")({component:Ae(_8e,"component"),validateSearch:e=>Dt({callbackUrl:e.callbackUrl||void 0,mode:e.mode||void 0,error:e.error||void 0,errorDescription:e.error_description||void 0,loginHint:e.loginHint||e.login_hint||void 0,invitationOrg:e.invitationOrg||void 0,provider:typeof e.provider=="string"&&e.provider.trim()?e.provider.trim().toLowerCase():void 0,intent:e.intent==="sign-up"||e.intent==="sign-in"?e.intent:void 0})}),A8e=()=>Ee(()=>import("./callback-CO_K9eR-.js"),[]),E8e=_e("/auth/callback")({component:Ae(A8e,"component")}),R8e=()=>Ee(()=>import("./accept-invitation-Db5jklHT.js"),__vite__mapDeps([41,40,27])),j8e=_e("/auth/accept-invitation")({component:Ae(R8e,"component"),validateSearch:e=>Dt({invitationId:e.invitationId||void 0})}),O8e=()=>Ee(()=>import("./settings-wGNHtsDP.js"),__vite__mapDeps([42,27])),N8e=_e("/account/settings")({component:Ae(O8e,"component")}),T8e=()=>Ee(()=>import("./recent-C03LhMD7.js"),[]),P8e=_e("/$owner/recent")({loader:({context:{queryClient:e},params:t})=>{e.prefetchQuery(gn.queryOptions(t.owner,{slug:t.owner}))},component:Ae(T8e,"component")}),L8e=()=>Ee(()=>import("./connectors-CqPQPo9U.js"),[]),z8e=_e("/$owner/connectors")({component:Ae(L8e,"component")}),D8e=()=>Ee(()=>import("./automations-DFs57C3c.js"),[]),I8e=_e("/$owner/automations")({component:Ae(D8e,"component")}),q8e=()=>Ee(()=>import("./agents-DFs57C3c.js"),[]),H8e=_e("/$owner/agents")({component:Ae(q8e,"component")});function V8e(e,t){const n=t;return{path:n?`/${[e,n].filter(Boolean).join("/")}`:e,effectiveSplat:n}}const F8e=()=>Ee(()=>import("./_-Ds4DyQjj.js"),[]);function B8e(){return h.jsx("div",{"data-public-loading":"true",children:h.jsx(R7,{})})}const $8e=_e("/$owner/$")({pendingComponent:B8e,beforeLoad:({params:e})=>{const n=(e._splat||"").split("/")[0];if(n&&Ri(n))throw y2()},component:Ae(F8e,"component"),validateSearch:e=>{const t={},n=[...L0e,...Y2,"page","merged_from"];for(const a of n){const o=e[a];o!=null&&(t[a]=typeof o=="number"?o:String(o))}for(const a of Object.keys(e))a.startsWith("clf_")&&e[a]!=null&&(t[a]=String(e[a]));return t},loader:({context:{queryClient:e},params:t})=>{const{path:n}=V8e(t.owner,t._splat||"");e.prefetchQuery(f1.queryOptions(n,{slug:t.owner},{includeBootstrap:!0}))}}),U8e=()=>Ee(()=>import("./index-D2oL4Ydo.js"),__vite__mapDeps([43,44,6,45,23,11,12,10,46,32,47,21,22,33,48])),K8e=["agent","agent_id","automation","produced_by","schedule","connection_ids","feed_ids","run_ids","content_ids","entity_id","run_id","platforms","at"];function G8e(e){return e.view==="events"||e.view==="feeds"||e.browse_view==="events"?!0:K8e.some(t=>e[t]!=null&&String(e[t]).trim()!=="")}const Y8e=_e("/$owner/memory/")({loader:({context:{queryClient:e},params:t})=>{e.prefetchQuery(gn.queryOptions(t.owner,{slug:t.owner}))},beforeLoad:({params:e,search:t})=>{const n=t,a=typeof n.browse_path=="string"&&n.browse_path.trim()?n.browse_path.trim():void 0;if(a)throw ca({to:"/$owner/memory/$",params:{owner:e.owner,_splat:a},search:{},replace:!0});if(G8e(n))throw ca({to:"/$owner/events",params:{owner:e.owner},search:Dt({...n,type:typeof n.browse_type=="string"&&n.browse_type.trim()?ks(n.browse_type.trim()):n.type,view:void 0,create:void 0,create_type:void 0,browse_type:void 0,browse_view:void 0}),replace:!0});if(typeof n.view=="string")throw ca({to:"/$owner/memory",params:{owner:e.owner},search:Dt({...n,view:void 0}),replace:!0});const o=typeof n.browse_type=="string"&&n.browse_type.trim()?n.browse_type.trim():void 0;if(o)throw ca({to:"/$owner/memory",params:{owner:e.owner},search:Dt({type:ks(o),create:n.create===!0||n.create==="true"?!0:void 0}),replace:!0});const s=Ube(n);if(s)throw ca({to:"/$owner/memory",params:{owner:e.owner},search:s,replace:!0});const l=HC(n);if(l)throw ca({to:"/$owner/$",params:{owner:e.owner,_splat:l},search:{},replace:!0});const c=typeof n.type=="string"&&n.type.trim()?ks(n.type.trim()):void 0;if(c)throw ca({to:"/$owner/$entityType",params:{owner:e.owner,entityType:c},search:{create:n.create===!0||n.create==="true"?!0:void 0},replace:!0})},component:Ae(U8e,"component"),validateSearch:e=>{const t=Dt(e);return(e.create===!0||e.create==="true")&&(t.create="true"),(e.create_type===!0||e.create_type==="true")&&(t.create_type="true"),t}}),W8e=()=>Ee(()=>import("./index-DtqBFgK5.js"),[]),Z8e=_e("/$owner/members/")({beforeLoad:({params:e})=>{throw ca({...Kbe(e.owner),replace:!0})},component:Ae(W8e,"component")}),Q8e=()=>Ee(()=>import("./index-Bulu5ldM.js"),__vite__mapDeps([49,29,7,30,18,20,31,5,19,21,22,32,16,33])),X8e=_e("/$owner/events/")({loader:({context:{queryClient:e},params:t})=>{t.owner!=="me"&&e.prefetchQuery(gn.queryOptions(t.owner,{slug:t.owner}))},component:Ae(Q8e,"component"),validateSearch:e=>Dt(e)}),J8e={all:"All",data:"Data",chat:"Chat",actions:"Actions",inference:"Inference",runtime:"Runtime",device:"On device"},ewe=["all","data","chat","actions","inference","runtime","device"];function twe(e){return typeof e=="string"&&ewe.includes(e)?e:void 0}function nwe(e){return e.options_schema?.["x-lobu-chat-platform"]!=null}function awe(e){return!!e.runtime||!!e.required_capability}function rwe(e,t){const n=e.feeds_schema?Object.keys(e.feeds_schema).length>0:!1,a=e.has_operations||(e.actions_schema?Object.keys(e.actions_schema).length>0:!1);return{data:t?.facets.data??n,chat:t?.facets.chat??nwe(e),actions:t?.facets.actions??a,audience:t?.facets.audience??!1,inference:!1,runtime:!1}}function Wy(e,t){const{connector:n,facets:a}=e;return t==="all"?!0:t==="data"?a.data:t==="chat"?a.chat:t==="actions"?a.actions:t==="inference"?a.inference:t==="runtime"?a.runtime===!0:e.isDevice===!0||awe(n)}const owe=()=>Ee(()=>import("./index-C-u4yR8Z.js"),__vite__mapDeps([50,51])),iwe=_e("/$owner/connectors/")({validateSearch:e=>{const t=twe(e.filter);return t?{filter:t}:{}},loader:({context:{queryClient:e},params:t})=>{e.prefetchQuery(gn.queryOptions(t.owner,{slug:t.owner}))},component:Ae(owe,"component")}),swe=()=>Ee(()=>import("./index-C6VAJ8Ku.js"),__vite__mapDeps([52,16])),lwe=_e("/$owner/chat/")({validateSearch:e=>{const t={};return(e.new===!0||e.new==="1"||e.new==="true")&&(t.new=!0),typeof e.prompt=="string"&&e.prompt.length>0&&(t.prompt=e.prompt),Object.assign(t,uc(e)),t},component:Ae(swe,"component")}),cwe=()=>Ee(()=>import("./index-DOLFe19K.js"),__vite__mapDeps([53,54,3])),uwe=_e("/$owner/automations/")({loader:({context:{queryClient:e},params:t})=>{e.prefetchQuery(gn.queryOptions(t.owner,{slug:t.owner}))},component:Ae(cwe,"component")}),dwe=()=>Ee(()=>import("./index-BvbfITqH.js"),__vite__mapDeps([55,56,54,20,31])),hwe=_e("/$owner/agents/")({loader:({context:{queryClient:e},params:t})=>{e.prefetchQuery(gn.queryOptions(t.owner,{slug:t.owner}))},component:Ae(dwe,"component")}),fwe=()=>Ee(()=>import("./index-nzvsA3hT.js"),__vite__mapDeps([57,44,6,45,23,11,12,10,46,32,47,21,22,33,48])),pwe=_e("/$owner/$entityType/")({validateSearch:e=>({create:e.create===!0||e.create==="true"?!0:void 0}),beforeLoad:({params:e})=>{if(Ri(e.entityType))throw y2()},component:Ae(fwe,"component")}),ywe=()=>Ee(()=>import("./connection-BgAlYjeV.js"),__vite__mapDeps([58,22])),mwe=_e("/connector/$name/connection")({component:Ae(ywe,"component"),validateSearch:e=>({ref:typeof e.ref=="string"?e.ref:void 0})}),gwe=()=>Ee(()=>import("./organization-uSDYkJpX.js"),__vite__mapDeps([59,60,22])),kwe=_e("/$owner/settings/organization")({component:Ae(gwe,"component")}),vwe=()=>Ee(()=>import("./_-DtqBFgK5.js"),[]),xwe=_e("/$owner/memory/$")({beforeLoad:({params:e})=>{const t=IC(e._splat||"");throw t.typeSegment?Ri(t.typeSegment)?y2():t.isEntityDetail?ca({to:"/$owner/$",params:{owner:e.owner,_splat:t.path},search:{},replace:!0}):ca({to:"/$owner/$entityType",params:{owner:e.owner,entityType:t.typeSegment},search:{create:void 0},replace:!0}):ca({to:"/$owner/memory",params:{owner:e.owner},search:{},replace:!0})},component:Ae(vwe,"component")}),bwe=()=>Ee(()=>import("./_-VmyR6aN_.js"),__vite__mapDeps([61,29,7,30,18,20,31,5,19,21,22,32,16,33])),wwe=_e("/$owner/events/$")({beforeLoad:({params:e})=>{const t=IC(e._splat||"");if(!t.typeSegment||!t.isEntityDetail||Ri(t.typeSegment))throw y2()},component:Ae(bwe,"component"),validateSearch:e=>Dt(e)}),Mwe=_e("/$owner/entity-types/new")({beforeLoad:({params:e})=>{throw ca({to:"/$owner/memory",params:{owner:e.owner},search:{create_type:"true"},replace:!0})}}),Swe=()=>Ee(()=>import("./_slug-CDSO20ac.js"),__vite__mapDeps([62,45,23,11,12,10])),_we=_e("/$owner/entity-types/$slug")({component:Ae(Swe,"component")}),Cwe=()=>Ee(()=>import("./deployments-CjfFxyDA.js"),[]),Awe=_e("/$owner/connectors/deployments")({component:Ae(Cwe,"component")});function rA({className:e,children:t}){return h.jsx("div",{className:ye("mx-auto w-full max-w-3xl",e),children:t})}function uEe({header:e,children:t}){return h.jsxs(rA,{className:"flex min-h-0 min-w-0 flex-1 flex-col",children:[h.jsx("div",{className:"sticky top-0 z-10 space-y-4 bg-background pb-1",children:e}),h.jsx("div",{className:"mt-4 min-w-0 flex-1 space-y-7",children:t})]})}const Ewe="min-w-0 truncate text-sm text-muted-foreground transition-colors hover:text-foreground hover:underline";function Rwe({crumbs:e}){return e.length===0?null:h.jsx("nav",{"aria-label":"Breadcrumb",className:"flex min-w-0 flex-wrap items-center gap-1.5",children:e.map((t,n)=>h.jsxs("span",{className:"flex min-w-0 items-center gap-1.5",children:[n>0?h.jsx(da,{className:"h-3.5 w-3.5 shrink-0 text-muted-foreground/50"}):null,t]},n))})}function jwe({breadcrumb:e,icon:t,title:n,badge:a,status:o,meta:s,caption:l,captionTone:c="muted"}){const d=h.jsxs("div",{className:"flex min-w-0 flex-1 flex-wrap items-center justify-between gap-x-3 gap-y-1",children:[h.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-x-2.5 gap-y-1",children:[typeof n=="string"?h.jsx("h1",{className:"text-2xl font-semibold leading-none tracking-tight",children:n}):n,a,o]}),s?h.jsx("div",{className:"flex flex-wrap items-center gap-x-4 gap-y-1 text-xs text-muted-foreground",children:s}):null]}),f=l?h.jsx("p",{className:ye("max-w-2xl text-base leading-relaxed",c==="error"?"text-destructive":"text-muted-foreground"),children:l}):null;return h.jsxs("div",{className:"flex flex-col gap-2",children:[e,t?h.jsxs("div",{className:"flex min-w-0 items-center gap-3",children:[h.jsx("div",{className:"shrink-0",children:t}),d]}):d,f]})}function on({className:e,variant:t="default",...n}){const a={default:"bg-primary text-primary-foreground",secondary:"bg-secondary text-secondary-foreground",destructive:"bg-destructive text-destructive-foreground",outline:"border border-current bg-transparent"};return h.jsx("span",{"data-slot":"badge",className:`inline-flex items-center gap-1 rounded-md px-2 py-0.5 text-xs font-medium ${a[t]} ${e||""}`,...n})}function Owe({badges:e}){return e.length===0?null:h.jsx("div",{className:"mt-auto flex flex-wrap items-center gap-1.5",children:e.map(t=>h.jsx(on,{variant:"secondary",className:"h-4 shrink-0 px-1.5 py-0 text-[10px]",children:t},t))})}function Nwe({count:e=4}){return h.jsx("div",{className:"grid grid-cols-1 gap-2",role:"status","aria-label":"Loading catalog",children:Array.from({length:e}).map((t,n)=>h.jsx(ft,{className:"h-16 w-full rounded-lg"},n))})}function Twe({count:e=8}){return h.jsx("div",{className:"overflow-hidden rounded-lg border",role:"status","aria-label":"Loading connector catalog",children:Array.from({length:e}).map((t,n)=>h.jsxs("div",{className:`flex items-center gap-3 bg-card px-3 py-2.5 ${n===e-1?"":"border-b"}`,children:[h.jsx(ft,{className:"h-8 w-8 shrink-0 rounded-lg"}),h.jsxs("div",{className:"min-w-0 flex-1 space-y-1.5",children:[h.jsx(ft,{className:"h-3.5 w-24 rounded"}),h.jsx(ft,{className:"h-3 w-48 max-w-full rounded"})]}),h.jsx(ft,{className:"h-4 w-14 shrink-0 rounded-full"}),h.jsx(ft,{className:"h-4 w-4 shrink-0 rounded"})]},n))})}function dEe({count:e=4,withSearch:t=!0}){return h.jsxs("div",{className:"space-y-3",role:"status","aria-label":"Loading catalog",children:[t?h.jsx(ft,{className:"h-9 w-full rounded-md"}):null,h.jsx(Nwe,{count:e})]})}function hEe({items:e,searchQuery:t,onSearchChange:n,onSelect:a,emptyMessage:o,searchPlaceholder:s="Search...",searchAriaLabel:l="Search catalog",renderTitle:c}){return h.jsxs("div",{className:"space-y-3",children:[h.jsxs("div",{className:"relative",children:[h.jsx(r1,{className:"absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground"}),h.jsx(Lt,{"aria-label":l,placeholder:s,value:t,onChange:d=>n(d.target.value),className:"pl-9"})]}),e.length===0?h.jsx("p",{className:"py-4 text-center text-sm text-muted-foreground",children:o??`No items match "${t}"`}):h.jsx("div",{className:"overflow-hidden rounded-lg border",children:e.map((d,f)=>h.jsxs("button",{type:"button",className:"flex w-full items-center gap-3 bg-card px-4 py-3 text-left text-muted-foreground transition-colors hover:bg-accent/50 hover:text-foreground"+(f===e.length-1?"":" border-b"),onClick:()=>a(d),children:[h.jsxs("div",{className:"min-w-0 flex-1",children:[h.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[c?c(d):h.jsx("span",{className:"text-sm font-medium text-foreground",children:d.name}),h.jsx(Owe,{badges:d.badges})]}),d.description?h.jsx("p",{className:"line-clamp-1 text-xs text-muted-foreground",children:d.description}):null]}),h.jsx(da,{className:"h-4 w-4 shrink-0 text-muted-foreground"})]},d.key))})]})}function Pwe(e){return e?e.charAt(0).toUpperCase()+e.slice(1):"App"}function Lwe(e,{recovery:t=!1,installShape:n}={}){if(!t||n==="oauth-code-exchange")return e;const a=new URL(e);return a.searchParams.set("recovery","1"),a.toString()}function Xm({organizationId:e,connectorKey:t,provider:n,providerLabel:a,recovery:o=!1,installShape:s,size:l="sm",variant:c,className:d,label:f,icon:p}){const y=q9(e,t),k=y.data?.options.find(S=>S.kind==="local");if(!e||y.isPending)return h.jsx("span",{className:"text-sm text-muted-foreground",children:"Checking app setup…"});if(y.isError)return h.jsxs("div",{className:"space-y-1",children:[h.jsx("p",{className:"text-sm text-muted-foreground",children:"App setup could not be checked."}),h.jsx(ge,{variant:"link",className:"px-0",onClick:()=>void y.refetch(),children:"Retry app setup"})]});if(!k?.configured||!k.url)return h.jsx("p",{className:"text-sm text-muted-foreground",children:"This server has no app configured. Choose an available connection option or configure your own app."});const v=a??Pwe(n),w=f??`${o?"Reconnect":"Connect"} ${v}`;return h.jsx(ge,{asChild:!0,size:l,variant:c,className:d,children:h.jsxs("a",{href:Lwe(k.url,{recovery:o,installShape:s}),children:[p,w]})})}const zwe=[{key:"data",label:"Data",icon:UM},{key:"chat",label:"Chat",icon:JM},{key:"actions",label:"Actions",icon:d7},{key:"audience",label:"Audience",icon:Ug},{key:"inference",label:"Inference",icon:$M},{key:"runtime",label:"Runtime",icon:DM}];function Jm({facets:e,className:t}){if(!e)return null;const n=zwe.filter(a=>e[a.key]);return n.length===0?null:h.jsx("div",{className:ye("flex flex-wrap items-center gap-1",t),children:n.map(({key:a,label:o,icon:s})=>h.jsxs(on,{variant:"secondary",className:"bg-muted text-muted-foreground",children:[h.jsx(s,{className:"h-3 w-3"}),o]},a))})}function Dwe({data:e,error:t,retry:n}){const a=e?.options.filter(s=>s.kind!=="local"&&s.configured&&!!s.url)??[],o=t||e?.cloud_status==="unavailable";return!a.length&&!o?null:h.jsxs("section",{"aria-label":"Available connection options",className:"space-y-3",children:[o&&h.jsxs("div",{role:"status",className:"text-sm text-muted-foreground",children:[h.jsx("p",{children:"Cloud connection options could not be checked. You can retry or continue with your own app."}),n&&h.jsx(ge,{variant:"link",className:"px-0",onClick:n,children:"Retry cloud discovery"})]}),a.map(s=>h.jsxs("div",{className:"space-y-1.5",children:[h.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[s.url&&h.jsx(ge,{asChild:!0,variant:"outline",children:h.jsx("a",{href:s.url,target:"_blank",rel:"noopener noreferrer",children:s.label})}),h.jsx("span",{className:"text-xs text-muted-foreground",children:s.execution==="cloud"?"Runs in Lobu Cloud":"Available for local execution"})]}),h.jsx("p",{className:"text-sm text-muted-foreground",children:s.description}),h.jsxs("details",{className:"text-xs text-muted-foreground",children:[h.jsx("summary",{className:"cursor-pointer",children:"Setup steps"}),h.jsx("p",{className:"pt-1",children:s.instructions})]})]},`${s.kind}:${s.managed_by_org??s.url}`))]})}function eg({organizationId:e,connectorKey:t}){const n=q9(e,t);return!e||n.isPending?h.jsx("p",{role:"status",className:"text-sm text-muted-foreground",children:"Checking connection options…"}):h.jsx(Dwe,{data:n.data,error:n.isError,retry:()=>void n.refetch()})}function L8(e,[t,n]){return Math.min(n,Math.max(t,e))}function oA(e){const t=b.useRef({value:e,previous:e});return b.useMemo(()=>(t.current.value!==e&&(t.current.previous=t.current.value,t.current.value=e),t.current.previous),[e])}var Iwe=[" ","Enter","ArrowUp","ArrowDown"],qwe=[" ","Enter"],Cs="Select",[y0,m0,Hwe]=Fk(Cs),[zs]=dr(Cs,[Hwe,Ti]),g0=Ti(),[Vwe,Pi]=zs(Cs),[Fwe,Bwe]=zs(Cs),$we="SelectProvider";function iA(e){const{__scopeSelect:t,children:n,open:a,defaultOpen:o,onOpenChange:s,value:l,defaultValue:c,onValueChange:d,dir:f,name:p,autoComplete:y,disabled:k,required:v,form:w,internal_do_not_use_render:S}=e,_=g0(t),[C,A]=b.useState(null),[j,N]=b.useState(null),[I,T]=b.useState(!1),q=Bk(f),[R,H]=fo({prop:a,defaultProp:o??!1,onChange:s,caller:Cs}),[D,G]=fo({prop:l,defaultProp:c,onChange:d,caller:Cs}),$=b.useRef(null),X=C?!!w||!!C.closest("form"):!0,[F,W]=b.useState(new Set),P=Ya(),U=Array.from(F).map(B=>B.props.value).join(";"),J=b.useCallback(B=>{W(V=>new Set(V).add(B))},[]),se=b.useCallback(B=>{W(V=>{const O=new Set(V);return O.delete(B),O})},[]),L={required:v,trigger:C,onTriggerChange:A,valueNode:j,onValueNodeChange:N,valueNodeHasChildren:I,onValueNodeHasChildrenChange:T,contentId:P,value:D,onValueChange:G,open:R,onOpenChange:H,dir:q,triggerPointerDownPosRef:$,disabled:k,name:p,autoComplete:y,form:w,nativeOptions:F,nativeSelectKey:U,isFormControl:X};return h.jsx(i0,{..._,children:h.jsx(Vwe,{scope:t,...L,children:h.jsx(y0.Provider,{scope:t,children:h.jsx(Fwe,{scope:t,onNativeOptionAdd:J,onNativeOptionRemove:se,children:iMe(S)?S(L):n})})})})}iA.displayName=$we;var sA=e=>{const{__scopeSelect:t,children:n,...a}=e;return h.jsx(iA,{__scopeSelect:t,...a,internal_do_not_use_render:({isFormControl:o})=>h.jsxs(h.Fragment,{children:[n,o?h.jsx(EA,{__scopeSelect:t}):null]})})};sA.displayName=Cs;var lA="SelectTrigger",lv=b.forwardRef((e,t)=>{const{__scopeSelect:n,disabled:a=!1,...o}=e,s=g0(n),l=Pi(lA,n),c=l.disabled||a,d=it(t,l.onTriggerChange),f=m0(n),p=b.useRef("touch"),[y,k,v]=RA(S=>{const _=f().filter(j=>!j.disabled),C=_.find(j=>j.value===l.value),A=jA(_,S,C);A!==void 0&&l.onValueChange(A.value)}),w=S=>{c||(l.onOpenChange(!0),v()),S&&(l.triggerPointerDownPosRef.current={x:Math.round(S.pageX),y:Math.round(S.pageY)})};return h.jsx(b1,{asChild:!0,...s,children:h.jsx(He.button,{type:"button",role:"combobox","aria-controls":l.open?l.contentId:void 0,"aria-expanded":l.open,"aria-required":l.required,"aria-autocomplete":"none",dir:l.dir,"data-state":l.open?"open":"closed",disabled:c,"data-disabled":c?"":void 0,"data-placeholder":k0(l.value)?"":void 0,...o,ref:d,onClick:xe(o.onClick,S=>{S.currentTarget.focus(),p.current!=="mouse"&&w(S)}),onPointerDown:xe(o.onPointerDown,S=>{p.current=S.pointerType;const _=S.target;_.hasPointerCapture(S.pointerId)&&_.releasePointerCapture(S.pointerId),S.button===0&&S.ctrlKey===!1&&S.pointerType==="mouse"&&(w(S),S.preventDefault())}),onKeyDown:xe(o.onKeyDown,S=>{const _=y.current!=="";!(S.ctrlKey||S.altKey||S.metaKey)&&S.key.length===1&&k(S.key),!(_&&S.key===" ")&&Iwe.includes(S.key)&&(w(),S.preventDefault())})})})});lv.displayName=lA;var cA="SelectValue",uA=b.forwardRef((e,t)=>{const{__scopeSelect:n,className:a,style:o,children:s,placeholder:l="",...c}=e,d=Pi(cA,n),{onValueNodeHasChildrenChange:f}=d,p=s!==void 0,y=it(t,d.onValueNodeChange);Mn(()=>{f(p)},[f,p]);const k=k0(d.value);return h.jsx(He.span,{...c,asChild:k?!1:c.asChild,ref:y,style:{pointerEvents:"none"},children:h.jsx(b.Fragment,{children:k?l:s},k?"placeholder":"value")})});uA.displayName=cA;var Uwe="SelectIcon",dA=b.forwardRef((e,t)=>{const{__scopeSelect:n,children:a,...o}=e;return h.jsx(He.span,{"aria-hidden":!0,...o,ref:t,children:a||"▼"})});dA.displayName=Uwe;var hA="SelectPortal",[Kwe,Gwe]=zs(hA,{forceMount:void 0}),fA=e=>{const{__scopeSelect:t,forceMount:n,...a}=e;return h.jsx(Kwe,{scope:e.__scopeSelect,forceMount:n,children:h.jsx(rc,{asChild:!0,...a})})};fA.displayName=hA;var Ei="SelectContent",cv=b.forwardRef((e,t)=>{const n=Gwe(Ei,e.__scopeSelect),{forceMount:a=n.forceMount,...o}=e,s=Pi(Ei,e.__scopeSelect),[l,c]=b.useState();return Mn(()=>{c(new DocumentFragment)},[]),h.jsx(Gn,{present:a||s.open,children:({present:d})=>d?h.jsx(mA,{...o,ref:t}):h.jsx(pA,{...o,fragment:l})})});cv.displayName=Ei;var pA=b.forwardRef((e,t)=>{const{__scopeSelect:n,children:a,fragment:o}=e;return o?go.createPortal(h.jsx(yA,{scope:n,children:h.jsx(y0.Slot,{scope:n,children:h.jsx("div",{ref:t,children:a})})}),o):null});pA.displayName="SelectContentFragment";var ir=10,[yA,Li]=zs(Ei),Ywe="SelectContentImpl",Wwe=Mi("SelectContent.RemoveScroll"),mA=b.forwardRef((e,t)=>{const{__scopeSelect:n}=e,{position:a="item-aligned",onCloseAutoFocus:o,onEscapeKeyDown:s,onPointerDownOutside:l,side:c,sideOffset:d,align:f,alignOffset:p,arrowPadding:y,collisionBoundary:k,collisionPadding:v,sticky:w,hideWhenDetached:S,avoidCollisions:_,...C}=e,A=Pi(Ei,n),[j,N]=b.useState(null),[I,T]=b.useState(null),q=it(t,oe=>N(oe)),[R,H]=b.useState(null),[D,G]=b.useState(null),$=m0(n),[X,F]=b.useState(!1),W=b.useRef(!1);b.useEffect(()=>{if(j)return i1(j)},[j]),_2();const P=b.useCallback(oe=>{const[de,...pe]=$().map(De=>De.ref.current),[Re]=pe.slice(-1),Pe=document.activeElement;for(const De of oe)if(De===Pe||(De?.scrollIntoView({block:"nearest"}),De===de&&I&&(I.scrollTop=0),De===Re&&I&&(I.scrollTop=I.scrollHeight),De?.focus(),document.activeElement!==Pe))return},[$,I]),U=b.useCallback(()=>P([R,j]),[P,R,j]);b.useEffect(()=>{X&&U()},[X,U]);const{onOpenChange:J,triggerPointerDownPosRef:se}=A;b.useEffect(()=>{if(j){let oe={x:0,y:0};const de=Re=>{oe={x:Math.abs(Math.round(Re.pageX)-(se.current?.x??0)),y:Math.abs(Math.round(Re.pageY)-(se.current?.y??0))}},pe=Re=>{oe.x<=10&&oe.y<=10?Re.preventDefault():Re.composedPath().includes(j)||J(!1),document.removeEventListener("pointermove",de),se.current=null};return se.current!==null&&(document.addEventListener("pointermove",de),document.addEventListener("pointerup",pe,{capture:!0,once:!0})),()=>{document.removeEventListener("pointermove",de),document.removeEventListener("pointerup",pe,{capture:!0})}}},[j,J,se]),b.useEffect(()=>{const oe=()=>J(!1);return window.addEventListener("blur",oe),window.addEventListener("resize",oe),()=>{window.removeEventListener("blur",oe),window.removeEventListener("resize",oe)}},[J]);const[L,B]=RA(oe=>{const de=$().filter(Pe=>!Pe.disabled),pe=de.find(Pe=>Pe.ref.current===document.activeElement),Re=jA(de,oe,pe);Re&&setTimeout(()=>Re.ref.current?.focus())}),V=b.useCallback((oe,de,pe)=>{const Re=!W.current&&!pe;(A.value!==void 0&&A.value===de||Re)&&(H(oe),Re&&(W.current=!0))},[A.value]),O=b.useCallback(()=>j?.focus(),[j]),ee=b.useCallback((oe,de,pe)=>{const Re=!W.current&&!pe;(A.value!==void 0&&A.value===de||Re)&&G(oe)},[A.value]),Q=a==="popper"?tg:gA,ae=Q===tg?{side:c,sideOffset:d,align:f,alignOffset:p,arrowPadding:y,collisionBoundary:k,collisionPadding:v,sticky:w,hideWhenDetached:S,avoidCollisions:_}:{};return h.jsx(yA,{scope:n,content:j,viewport:I,onViewportChange:T,itemRefCallback:V,selectedItem:R,onItemLeave:O,itemTextRefCallback:ee,focusSelectedItem:U,selectedItemText:D,position:a,isPositioned:X,searchRef:L,children:h.jsx(oc,{as:Wwe,allowPinchZoom:!0,children:h.jsx(o1,{asChild:!0,trapped:A.open,onMountAutoFocus:oe=>{oe.preventDefault()},onUnmountAutoFocus:xe(o,oe=>{A.trigger?.focus({preventScroll:!0}),oe.preventDefault()}),children:h.jsx(ac,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:s,onPointerDownOutside:l,onFocusOutside:oe=>oe.preventDefault(),onDismiss:()=>A.onOpenChange(!1),children:h.jsx(Q,{role:"listbox",id:A.contentId,"data-state":A.open?"open":"closed",dir:A.dir,onContextMenu:oe=>oe.preventDefault(),...C,...ae,onPlaced:()=>F(!0),ref:q,style:{display:"flex",flexDirection:"column",outline:"none",...C.style},onKeyDown:xe(C.onKeyDown,oe=>{const de=oe.ctrlKey||oe.altKey||oe.metaKey;if(oe.key==="Tab"&&oe.preventDefault(),!de&&oe.key.length===1&&B(oe.key),["ArrowUp","ArrowDown","Home","End"].includes(oe.key)){let Re=$().filter(Pe=>!Pe.disabled).map(Pe=>Pe.ref.current);if(["ArrowUp","End"].includes(oe.key)&&(Re=Re.slice().reverse()),["ArrowUp","ArrowDown"].includes(oe.key)){const Pe=oe.target,De=Re.indexOf(Pe);Re=Re.slice(De+1)}setTimeout(()=>P(Re)),oe.preventDefault()}})})})})})})});mA.displayName=Ywe;var Zwe="SelectItemAlignedPosition",gA=b.forwardRef((e,t)=>{const{__scopeSelect:n,onPlaced:a,...o}=e,s=Pi(Ei,n),l=Li(Ei,n),[c,d]=b.useState(null),[f,p]=b.useState(null),y=it(t,q=>p(q)),k=m0(n),v=b.useRef(!1),w=b.useRef(!0),{viewport:S,selectedItem:_,selectedItemText:C,focusSelectedItem:A}=l,j=b.useCallback(()=>{if(s.trigger&&s.valueNode&&c&&f&&S&&_&&C){const q=s.trigger.getBoundingClientRect(),R=f.getBoundingClientRect(),H=s.valueNode.getBoundingClientRect(),D=C.getBoundingClientRect();if(s.dir!=="rtl"){const Pe=D.left-R.left,De=H.left-Pe,bt=q.left-De,Ye=q.width+bt,kn=Math.max(Ye,R.width),Qt=window.innerWidth-ir,Xt=L8(De,[ir,Math.max(ir,Qt-kn)]);c.style.minWidth=Ye+"px",c.style.left=Xt+"px"}else{const Pe=R.right-D.right,De=window.innerWidth-H.right-Pe,bt=window.innerWidth-q.right-De,Ye=q.width+bt,kn=Math.max(Ye,R.width),Qt=window.innerWidth-ir,Xt=L8(De,[ir,Math.max(ir,Qt-kn)]);c.style.minWidth=Ye+"px",c.style.right=Xt+"px"}const G=k(),$=window.innerHeight-ir*2,X=S.scrollHeight,F=window.getComputedStyle(f),W=parseInt(F.borderTopWidth,10),P=parseInt(F.paddingTop,10),U=parseInt(F.borderBottomWidth,10),J=parseInt(F.paddingBottom,10),se=W+P+X+J+U,L=Math.min(_.offsetHeight*5,se),B=window.getComputedStyle(S),V=parseInt(B.paddingTop,10),O=parseInt(B.paddingBottom,10),ee=q.top+q.height/2-ir,Q=$-ee,ae=_.offsetHeight/2,oe=_.offsetTop+ae,de=W+P+oe,pe=se-de;if(de<=ee){const Pe=G.length>0&&_===G[G.length-1].ref.current;c.style.bottom="0px";const De=f.clientHeight-S.offsetTop-S.offsetHeight,bt=Math.max(Q,ae+(Pe?O:0)+De+U),Ye=de+bt;c.style.height=Ye+"px"}else{const Pe=G.length>0&&_===G[0].ref.current;c.style.top="0px";const bt=Math.max(ee,W+S.offsetTop+(Pe?V:0)+ae)+pe;c.style.height=bt+"px",S.scrollTop=de-ee+S.offsetTop}c.style.margin=`${ir}px 0`,c.style.minHeight=L+"px",c.style.maxHeight=$+"px",a?.(),requestAnimationFrame(()=>v.current=!0)}},[k,s.trigger,s.valueNode,c,f,S,_,C,s.dir,a]);Mn(()=>j(),[j]);const[N,I]=b.useState();Mn(()=>{f&&I(window.getComputedStyle(f).zIndex)},[f]);const T=b.useCallback(q=>{q&&w.current===!0&&(j(),A?.(),w.current=!1)},[j,A]);return h.jsx(Xwe,{scope:n,contentWrapper:c,shouldExpandOnScrollRef:v,onScrollButtonChange:T,children:h.jsx("div",{ref:d,style:{display:"flex",flexDirection:"column",position:"fixed",zIndex:N},children:h.jsx(He.div,{...o,ref:y,style:{boxSizing:"border-box",maxHeight:"100%",...o.style}})})})});gA.displayName=Zwe;var Qwe="SelectPopperPosition",tg=b.forwardRef((e,t)=>{const{__scopeSelect:n,align:a="start",collisionPadding:o=ir,...s}=e,l=g0(n);return h.jsx(s0,{...l,...s,ref:t,align:a,collisionPadding:o,style:{boxSizing:"border-box",...s.style,"--radix-select-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-select-content-available-width":"var(--radix-popper-available-width)","--radix-select-content-available-height":"var(--radix-popper-available-height)","--radix-select-trigger-width":"var(--radix-popper-anchor-width)","--radix-select-trigger-height":"var(--radix-popper-anchor-height)"}})});tg.displayName=Qwe;var[Xwe,uv]=zs(Ei,{}),ng="SelectViewport",kA=b.forwardRef((e,t)=>{const{__scopeSelect:n,nonce:a,...o}=e,s=Li(ng,n),l=uv(ng,n),c=it(t,s.onViewportChange),d=b.useRef(0);return h.jsxs(h.Fragment,{children:[h.jsx("style",{dangerouslySetInnerHTML:{__html:"[data-radix-select-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-select-viewport]::-webkit-scrollbar{display:none}"},nonce:a}),h.jsx(y0.Slot,{scope:n,children:h.jsx(He.div,{"data-radix-select-viewport":"",role:"presentation",...o,ref:c,style:{position:"relative",flex:1,overflow:"hidden auto",...o.style},onScroll:xe(o.onScroll,f=>{const p=f.currentTarget,{contentWrapper:y,shouldExpandOnScrollRef:k}=l;if(k?.current&&y){const v=Math.abs(d.current-p.scrollTop);if(v>0){const w=window.innerHeight-ir*2,S=parseFloat(y.style.minHeight),_=parseFloat(y.style.height),C=Math.max(S,_);if(C<w){const A=C+v,j=Math.min(w,A),N=A-j;y.style.height=j+"px",y.style.bottom==="0px"&&(p.scrollTop=N>0?N:0,y.style.justifyContent="flex-end")}}}d.current=p.scrollTop})})})]})});kA.displayName=ng;var vA="SelectGroup",[Jwe,eMe]=zs(vA),tMe=b.forwardRef((e,t)=>{const{__scopeSelect:n,...a}=e,o=Ya();return h.jsx(Jwe,{scope:n,id:o,children:h.jsx(He.div,{role:"group","aria-labelledby":o,...a,ref:t})})});tMe.displayName=vA;var xA="SelectLabel",nMe=b.forwardRef((e,t)=>{const{__scopeSelect:n,...a}=e,o=eMe(xA,n);return h.jsx(He.div,{id:o.id,...a,ref:t})});nMe.displayName=xA;var l2="SelectItem",[aMe,bA]=zs(l2),dv=b.forwardRef((e,t)=>{const{__scopeSelect:n,value:a,disabled:o=!1,textValue:s,...l}=e,c=Pi(l2,n),d=Li(l2,n),f=c.value===a,[p,y]=b.useState(s??""),[k,v]=b.useState(!1),w=it(t,A=>d.itemRefCallback?.(A,a,o)),S=Ya(),_=b.useRef("touch"),C=()=>{o||(c.onValueChange(a),c.onOpenChange(!1))};return h.jsx(aMe,{scope:n,value:a,disabled:o,textId:S,isSelected:f,onItemTextChange:b.useCallback(A=>{y(j=>j||(A?.textContent??"").trim())},[]),children:h.jsx(y0.ItemSlot,{scope:n,value:a,disabled:o,textValue:p,children:h.jsx(He.div,{role:"option","aria-labelledby":S,"data-highlighted":k?"":void 0,"aria-selected":f&&k,"data-state":f?"checked":"unchecked","aria-disabled":o||void 0,"data-disabled":o?"":void 0,tabIndex:o?void 0:-1,...l,ref:w,onFocus:xe(l.onFocus,()=>v(!0)),onBlur:xe(l.onBlur,()=>v(!1)),onClick:xe(l.onClick,()=>{_.current!=="mouse"&&C()}),onPointerUp:xe(l.onPointerUp,()=>{_.current==="mouse"&&C()}),onPointerDown:xe(l.onPointerDown,A=>{_.current=A.pointerType}),onPointerMove:xe(l.onPointerMove,A=>{_.current=A.pointerType,o?d.onItemLeave?.():_.current==="mouse"&&A.currentTarget.focus({preventScroll:!0})}),onPointerLeave:xe(l.onPointerLeave,A=>{A.currentTarget===document.activeElement&&d.onItemLeave?.()}),onKeyDown:xe(l.onKeyDown,A=>{d.searchRef?.current!==""&&A.key===" "||(qwe.includes(A.key)&&C(),A.key===" "&&A.preventDefault())})})})})});dv.displayName=l2;var Su="SelectItemText",wA=b.forwardRef((e,t)=>{const{__scopeSelect:n,className:a,style:o,...s}=e,l=Pi(Su,n),c=Li(Su,n),d=bA(Su,n),f=Bwe(Su,n),[p,y]=b.useState(null),k=it(t,C=>y(C),d.onItemTextChange,C=>c.itemTextRefCallback?.(C,d.value,d.disabled)),v=p?.textContent,w=b.useMemo(()=>h.jsx("option",{value:d.value,disabled:d.disabled,children:v},d.value),[d.disabled,d.value,v]),{onNativeOptionAdd:S,onNativeOptionRemove:_}=f;return Mn(()=>(S(w),()=>_(w)),[S,_,w]),h.jsxs(h.Fragment,{children:[h.jsx(He.span,{id:d.textId,...s,ref:k}),d.isSelected&&l.valueNode&&!l.valueNodeHasChildren&&!k0(l.value)?go.createPortal(s.children,l.valueNode):null]})});wA.displayName=Su;var MA="SelectItemIndicator",SA=b.forwardRef((e,t)=>{const{__scopeSelect:n,...a}=e;return bA(MA,n).isSelected?h.jsx(He.span,{"aria-hidden":!0,...a,ref:t}):null});SA.displayName=MA;var ag="SelectScrollUpButton",hv=b.forwardRef((e,t)=>{const n=Li(ag,e.__scopeSelect),a=uv(ag,e.__scopeSelect),[o,s]=b.useState(!1),l=it(t,a.onScrollButtonChange);return Mn(()=>{if(n.viewport&&n.isPositioned){let c=function(){const f=d.scrollTop>0;s(f)};const d=n.viewport;return c(),d.addEventListener("scroll",c),()=>d.removeEventListener("scroll",c)}},[n.viewport,n.isPositioned]),o?h.jsx(_A,{...e,ref:l,onAutoScroll:()=>{const{viewport:c,selectedItem:d}=n;c&&d&&(c.scrollTop=c.scrollTop-d.offsetHeight)}}):null});hv.displayName=ag;var rg="SelectScrollDownButton",fv=b.forwardRef((e,t)=>{const n=Li(rg,e.__scopeSelect),a=uv(rg,e.__scopeSelect),[o,s]=b.useState(!1),l=it(t,a.onScrollButtonChange);return Mn(()=>{if(n.viewport&&n.isPositioned){let c=function(){const f=d.scrollHeight-d.clientHeight,p=Math.ceil(d.scrollTop)<f;s(p)};const d=n.viewport;return c(),d.addEventListener("scroll",c),()=>d.removeEventListener("scroll",c)}},[n.viewport,n.isPositioned]),o?h.jsx(_A,{...e,ref:l,onAutoScroll:()=>{const{viewport:c,selectedItem:d}=n;c&&d&&(c.scrollTop=c.scrollTop+d.offsetHeight)}}):null});fv.displayName=rg;var _A=b.forwardRef((e,t)=>{const{__scopeSelect:n,onAutoScroll:a,...o}=e,s=Li("SelectScrollButton",n),l=b.useRef(null),c=m0(n),d=b.useCallback(()=>{l.current!==null&&(window.clearInterval(l.current),l.current=null)},[]);return b.useEffect(()=>()=>d(),[d]),Mn(()=>{c().find(p=>p.ref.current===document.activeElement)?.ref.current?.scrollIntoView({block:"nearest"})},[c]),h.jsx(He.div,{"aria-hidden":!0,...o,ref:t,style:{flexShrink:0,...o.style},onPointerDown:xe(o.onPointerDown,()=>{l.current===null&&(l.current=window.setInterval(a,50))}),onPointerMove:xe(o.onPointerMove,()=>{s.onItemLeave?.(),l.current===null&&(l.current=window.setInterval(a,50))}),onPointerLeave:xe(o.onPointerLeave,()=>{d()})})}),rMe="SelectSeparator",pv=b.forwardRef((e,t)=>{const{__scopeSelect:n,...a}=e;return h.jsx(He.div,{"aria-hidden":!0,...a,ref:t})});pv.displayName=rMe;var CA="SelectArrow",oMe=b.forwardRef((e,t)=>{const{__scopeSelect:n,...a}=e,o=g0(n);return Li(CA,n).position==="popper"?h.jsx(l0,{...o,...a,ref:t}):null});oMe.displayName=CA;var AA="SelectBubbleInput",EA=b.forwardRef(({__scopeSelect:e,...t},n)=>{const a=Pi(AA,e),{value:o,onValueChange:s,required:l,disabled:c,name:d,autoComplete:f,form:p}=a,{nativeOptions:y,nativeSelectKey:k}=a,v=b.useRef(null),w=it(n,v),S=o??"",_=oA(S),C=Array.from(y).some(A=>(A.props.value??"")==="");return b.useEffect(()=>{const A=v.current;if(!A)return;const j=window.HTMLSelectElement.prototype,I=Object.getOwnPropertyDescriptor(j,"value").set;if(_!==S&&I){const T=new Event("change",{bubbles:!0});I.call(A,S),A.dispatchEvent(T)}},[_,S]),h.jsxs(He.select,{"aria-hidden":!0,required:l,tabIndex:-1,name:d,autoComplete:f,disabled:c,form:p,onChange:A=>s(A.target.value),...t,style:{...GC,...t.style},ref:w,defaultValue:S,children:[k0(o)&&!C?h.jsx("option",{value:""}):null,Array.from(y)]},k)});EA.displayName=AA;function iMe(e){return typeof e=="function"}function k0(e){return e===""||e===void 0}function RA(e){const t=Nr(e),n=b.useRef(""),a=b.useRef(0),o=b.useCallback(l=>{const c=n.current+l;t(c),(function d(f){n.current=f,window.clearTimeout(a.current),f!==""&&(a.current=window.setTimeout(()=>d(""),1e3))})(c)},[t]),s=b.useCallback(()=>{n.current="",window.clearTimeout(a.current)},[]);return b.useEffect(()=>()=>window.clearTimeout(a.current),[]),[n,o,s]}function jA(e,t,n){const o=t.length>1&&Array.from(t).every(f=>f===t[0])?t[0]:t,s=n?e.indexOf(n):-1;let l=sMe(e,Math.max(s,0));o.length===1&&(l=l.filter(f=>f!==n));const d=l.find(f=>f.textValue.toLowerCase().startsWith(o.toLowerCase()));return d!==n?d:void 0}function sMe(e,t){return e.map((n,a)=>e[(t+a)%e.length])}const si=sA,li=uA,io=b.forwardRef(({className:e,children:t,...n},a)=>h.jsxs(lv,{ref:a,className:ye("flex h-9 w-full items-center justify-between whitespace-nowrap rounded-md border border-input bg-muted px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus:outline-none focus:ring-1 focus:ring-ring disabled:cursor-not-allowed disabled:opacity-50 [&>span]:line-clamp-1",e),...n,children:[t,h.jsx(dA,{asChild:!0,children:h.jsx(n1,{className:"h-4 w-4 opacity-50"})})]}));io.displayName=lv.displayName;const OA=b.forwardRef(({className:e,...t},n)=>h.jsx(hv,{ref:n,className:ye("flex cursor-default items-center justify-center py-1",e),...t,children:h.jsx(HM,{className:"h-4 w-4"})}));OA.displayName=hv.displayName;const NA=b.forwardRef(({className:e,...t},n)=>h.jsx(fv,{ref:n,className:ye("flex cursor-default items-center justify-center py-1",e),...t,children:h.jsx(n1,{className:"h-4 w-4"})}));NA.displayName=fv.displayName;const so=b.forwardRef(({className:e,children:t,position:n="popper",...a},o)=>h.jsx(fA,{children:h.jsxs(cv,{ref:o,className:ye("relative z-50 max-h-96 min-w-[8rem] overflow-hidden rounded-md border border-border bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",n==="popper"&&"data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1",e),position:n,...a,children:[h.jsx(OA,{}),h.jsx(kA,{className:ye("p-1",n==="popper"&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"),children:t}),h.jsx(NA,{})]})}));so.displayName=cv.displayName;const Bn=b.forwardRef(({className:e,children:t,...n},a)=>h.jsxs(dv,{ref:a,className:ye("relative flex w-full cursor-default select-none items-center rounded-sm py-1.5 pl-2 pr-8 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",e),...n,children:[h.jsx("span",{className:"absolute right-2 flex h-3.5 w-3.5 items-center justify-center",children:h.jsx(SA,{children:h.jsx(Za,{className:"h-4 w-4"})})}),h.jsx(wA,{children:t})]}));Bn.displayName=dv.displayName;const lMe=b.forwardRef(({className:e,...t},n)=>h.jsx(pv,{ref:n,className:ye("-mx-1 my-1 h-px bg-muted",e),...t}));lMe.displayName=pv.displayName;function TA({device:e}){const t=s4e(e.app_version),n=l4e(e,t);return h.jsx(Bn,{value:e.id,children:h.jsxs("span",{className:"flex items-center gap-2",children:[h.jsx(c4e,{online:e.online}),h.jsx(p_,{platform:Ik(e)}),h.jsx("span",{children:i4e(e)}),n?h.jsxs("span",{className:"text-xs text-muted-foreground",children:["· ",n]}):null,e.online?null:h.jsx("span",{className:"text-xs text-muted-foreground",children:"· offline"})]})})}var v0="Popover",[PA]=dr(v0,[Ti]),C1=Ti(),[cMe,zi]=PA(v0),LA=e=>{const{__scopePopover:t,children:n,open:a,defaultOpen:o,onOpenChange:s,modal:l=!1}=e,c=C1(t),d=b.useRef(null),[f,p]=b.useState(!1),[y,k]=fo({prop:a,defaultProp:o??!1,onChange:s,caller:v0});return h.jsx(i0,{...c,children:h.jsx(cMe,{scope:t,contentId:Ya(),triggerRef:d,open:y,onOpenChange:k,onOpenToggle:b.useCallback(()=>k(v=>!v),[k]),hasCustomAnchor:f,onCustomAnchorAdd:b.useCallback(()=>p(!0),[]),onCustomAnchorRemove:b.useCallback(()=>p(!1),[]),modal:l,children:n})})};LA.displayName=v0;var zA="PopoverAnchor",uMe=b.forwardRef((e,t)=>{const{__scopePopover:n,...a}=e,o=zi(zA,n),s=C1(n),{onCustomAnchorAdd:l,onCustomAnchorRemove:c}=o;return b.useEffect(()=>(l(),()=>c()),[l,c]),h.jsx(b1,{...s,...a,ref:t})});uMe.displayName=zA;var DA="PopoverTrigger",IA=b.forwardRef((e,t)=>{const{__scopePopover:n,...a}=e,o=zi(DA,n),s=C1(n),l=it(t,o.triggerRef),c=h.jsx(He.button,{type:"button","aria-haspopup":"dialog","aria-expanded":o.open,"aria-controls":o.open?o.contentId:void 0,"data-state":BA(o.open),...a,ref:l,onClick:xe(e.onClick,o.onOpenToggle)});return o.hasCustomAnchor?c:h.jsx(b1,{asChild:!0,...s,children:c})});IA.displayName=DA;var yv="PopoverPortal",[dMe,hMe]=PA(yv,{forceMount:void 0}),qA=e=>{const{__scopePopover:t,forceMount:n,children:a,container:o}=e,s=zi(yv,t);return h.jsx(dMe,{scope:t,forceMount:n,children:h.jsx(Gn,{present:n||s.open,children:h.jsx(rc,{asChild:!0,container:o,children:a})})})};qA.displayName=yv;var ec="PopoverContent",HA=b.forwardRef((e,t)=>{const n=hMe(ec,e.__scopePopover),{forceMount:a=n.forceMount,...o}=e,s=zi(ec,e.__scopePopover);return h.jsx(Gn,{present:a||s.open,children:s.modal?h.jsx(pMe,{...o,ref:t}):h.jsx(yMe,{...o,ref:t})})});HA.displayName=ec;var fMe=Mi("PopoverContent.RemoveScroll"),pMe=b.forwardRef((e,t)=>{const n=zi(ec,e.__scopePopover),a=b.useRef(null),o=it(t,a),s=b.useRef(!1);return b.useEffect(()=>{const l=a.current;if(l)return i1(l)},[]),h.jsx(oc,{as:fMe,allowPinchZoom:!0,children:h.jsx(VA,{...e,ref:o,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:xe(e.onCloseAutoFocus,l=>{l.preventDefault(),s.current||n.triggerRef.current?.focus()}),onPointerDownOutside:xe(e.onPointerDownOutside,l=>{const c=l.detail.originalEvent,d=c.button===0&&c.ctrlKey===!0,f=c.button===2||d;s.current=f},{checkForDefaultPrevented:!1}),onFocusOutside:xe(e.onFocusOutside,l=>l.preventDefault(),{checkForDefaultPrevented:!1})})})}),yMe=b.forwardRef((e,t)=>{const n=zi(ec,e.__scopePopover),a=b.useRef(!1),o=b.useRef(!1);return h.jsx(VA,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:s=>{e.onCloseAutoFocus?.(s),s.defaultPrevented||(a.current||n.triggerRef.current?.focus(),s.preventDefault()),a.current=!1,o.current=!1},onInteractOutside:s=>{e.onInteractOutside?.(s),s.defaultPrevented||(a.current=!0,s.detail.originalEvent.type==="pointerdown"&&(o.current=!0));const l=s.target;n.triggerRef.current?.contains(l)&&s.preventDefault(),s.detail.originalEvent.type==="focusin"&&o.current&&s.preventDefault()}})}),VA=b.forwardRef((e,t)=>{const{__scopePopover:n,trapFocus:a,onOpenAutoFocus:o,onCloseAutoFocus:s,disableOutsidePointerEvents:l,onEscapeKeyDown:c,onPointerDownOutside:d,onFocusOutside:f,onInteractOutside:p,...y}=e,k=zi(ec,n),v=C1(n);return _2(),h.jsx(o1,{asChild:!0,loop:!0,trapped:a,onMountAutoFocus:o,onUnmountAutoFocus:s,children:h.jsx(ac,{asChild:!0,disableOutsidePointerEvents:l,onInteractOutside:p,onEscapeKeyDown:c,onPointerDownOutside:d,onFocusOutside:f,onDismiss:()=>k.onOpenChange(!1),deferPointerDownOutside:!0,children:h.jsx(s0,{"data-state":BA(k.open),role:"dialog",id:k.contentId,...v,...y,ref:t,style:{...y.style,"--radix-popover-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-popover-content-available-width":"var(--radix-popper-available-width)","--radix-popover-content-available-height":"var(--radix-popper-available-height)","--radix-popover-trigger-width":"var(--radix-popper-anchor-width)","--radix-popover-trigger-height":"var(--radix-popper-anchor-height)"}})})})}),FA="PopoverClose",mMe=b.forwardRef((e,t)=>{const{__scopePopover:n,...a}=e,o=zi(FA,n);return h.jsx(He.button,{type:"button",...a,ref:t,onClick:xe(e.onClick,()=>o.onOpenChange(!1))})});mMe.displayName=FA;var gMe="PopoverArrow",kMe=b.forwardRef((e,t)=>{const{__scopePopover:n,...a}=e,o=C1(n);return h.jsx(l0,{...o,...a,ref:t})});kMe.displayName=gMe;function BA(e){return e?"open":"closed"}var vMe=LA,xMe=IA,bMe=qA,$A=HA;const wMe=vMe,MMe=xMe,UA=b.forwardRef(({className:e,align:t="center",sideOffset:n=4,...a},o)=>h.jsx(bMe,{children:h.jsx($A,{ref:o,align:t,sideOffset:n,className:ye("z-50 w-72 rounded-md border border-border bg-popover p-4 text-popover-foreground outline-none data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",e),...a})}));UA.displayName=$A.displayName;function SMe({trigger:e,searchPlaceholder:t,emptyText:n,contentClassName:a,align:o="start",onQueryChange:s,children:l}){const[c,d]=b.useState(!1),[f,p]=b.useState(""),y=k=>{p(k),s?.(k)};return h.jsxs(wMe,{open:c,onOpenChange:k=>{d(k),k||y("")},children:[h.jsx(MMe,{asChild:!0,children:e(c)}),h.jsx(UA,{className:ye("p-0",a),align:o,children:h.jsxs(l1,{shouldFilter:!s,children:[h.jsx(L2,{placeholder:t,value:f,onValueChange:y}),h.jsxs(z2,{children:[h.jsx(D2,{children:n}),h.jsx(Ka,{children:l(()=>{d(!1),y("")},f)})]})]})})]})}function mv(e){const{session:t}=Xa(),{data:n=[],isLoading:a}=st({queryKey:["org-members",e],queryFn:async()=>e?(await Au.listMembers({query:{organizationId:e}})).data?.members??[]:[],enabled:!!e,staleTime:6e4}),o=t?.user?.id,l=(o?n.find(c=>c.userId===o):void 0)?.role??null;return{members:n,isLoading:a,currentUserRole:l,isAdmin:l==="admin"||l==="owner"}}function z8({member:e,size:t="sm"}){const n=t==="sm"?"h-5 w-5 text-[10px]":"h-6 w-6 text-xs";return e.user.image?h.jsx("img",{src:e.user.image,alt:e.user.name,referrerPolicy:"no-referrer",className:ye("rounded-full object-cover shrink-0",n)}):h.jsx("div",{className:ye("rounded-full bg-muted flex items-center justify-center font-medium shrink-0",n),children:(e.user.name||e.user.email).charAt(0).toUpperCase()})}function _Me({organizationId:e,value:t,onValueChange:n,disabled:a,placeholder:o="Select member...",className:s}){const{members:l,isLoading:c}=mv(e),d=t?l.find(f=>f.userId===t):void 0;return h.jsx(SMe,{contentClassName:"w-[--radix-popover-trigger-width]",searchPlaceholder:"Search members...",emptyText:"No members found.",trigger:f=>h.jsxs(ge,{variant:"outline",role:"combobox","aria-expanded":f,disabled:a||c,className:ye("w-full justify-between font-normal",s),children:[d?h.jsxs("span",{className:"flex items-center gap-2 truncate",children:[h.jsx(z8,{member:d}),h.jsx("span",{className:"truncate",children:d.user.name||d.user.email})]}):h.jsx("span",{className:"text-muted-foreground",children:c?"Loading...":o}),h.jsx(VM,{className:"ml-2 h-4 w-4 shrink-0 opacity-50"})]}),children:f=>h.jsxs(h.Fragment,{children:[t&&h.jsx(On,{value:"__clear__",onSelect:()=>{n(void 0),f()},children:h.jsx("span",{className:"text-muted-foreground",children:"Clear selection"})}),l.map(p=>h.jsxs(On,{value:`${p.user.name} ${p.user.email}`,onSelect:()=>{n(p.userId===t?void 0:p.userId),f()},children:[h.jsx(z8,{member:p}),h.jsxs("div",{className:"min-w-0 flex-1",children:[h.jsx("p",{className:"truncate text-sm",children:p.user.name||p.user.email}),p.user.name&&h.jsx("p",{className:"truncate text-xs text-muted-foreground",children:p.user.email})]}),h.jsx(Za,{className:ye("ml-auto h-4 w-4 shrink-0",t===p.userId?"opacity-100":"opacity-0")})]},p.userId))]})})}function CMe({onCancel:e,cancelLabel:t="Cancel",cancelDisabled:n,children:a,className:o}){return!e&&!a?null:h.jsxs("div",{className:ye("flex items-center justify-end gap-2",o),children:[e?h.jsx(ge,{type:"button",variant:"outline",onClick:e,disabled:n,children:t}):null,a]})}const KA={data:!1,chat:!1,actions:!1,audience:!1,inference:!1,runtime:!0};function Zu(e){return e==="vercel"?"Vercel":e.charAt(0).toUpperCase()+e.slice(1)}function GA(e){return e==="vercel"?"vercel.com":null}function AMe(e){if(!e.startsWith(km))return null;const t=e.slice(km.length);return t.length>0?t:null}function jh(e){if(!e.startsWith(Vh))return null;const t=e.slice(Vh.length);return t.length>0?t:null}function fEe(e){return e.map(t=>({sandbox:t,facets:KA,connector:{key:`${km}${t.id}`,name:t.name||Zu(t.providerKind),description:null,version:"",auth_schema:null,feeds_schema:null,actions_schema:null,options_schema:null,status:t.connected?"active":"error",login_enabled:!1,installed:!0}}))}function EMe(e){return e.map(t=>({key:`${Vh}${t}`,name:Zu(t),description:`Run agents in a ${Zu(t)} sandbox instead of the built-in local runtime.`,version:"",auth_schema:null,feeds_schema:null,actions_schema:null,options_schema:null,status:"active",login_enabled:!1,favicon_domain:GA(t),installed:!1,installable:!1}))}function og(){return KA}function RMe({providerKind:e,credentialFields:t,pending:n,onCancel:a,onCreate:o}){const[s,l]=b.useState(""),[c,d]=b.useState({}),f=Zu(e),p=y=>{y.preventDefault();const k=Object.fromEntries(Object.entries(c).filter(([,v])=>v.trim()));o({name:s.trim(),provider_kind:e,credential:Object.keys(k).length>0?k:void 0})};return h.jsxs("div",{className:"space-y-3",children:[h.jsxs("div",{className:"space-y-0.5",children:[h.jsxs("h3",{className:"text-sm font-medium",children:["Connect ",f]}),h.jsxs("p",{className:"text-xs text-muted-foreground",children:["Add a credential so agents can execute in a ",f," sandbox."]})]}),h.jsxs("form",{onSubmit:p,className:"grid max-w-md gap-3",children:[h.jsxs("div",{className:"grid gap-2",children:[h.jsxs(ha,{htmlFor:"sandbox-name",children:["Name ",h.jsx("span",{className:"ml-1 text-destructive",children:"*"})]}),h.jsx(Lt,{id:"sandbox-name",placeholder:`${f} production`,value:s,onChange:y=>l(y.target.value),required:!0})]}),t.map(y=>h.jsxs("div",{className:"grid gap-2",children:[h.jsxs(ha,{htmlFor:`sandbox-cred-${y.key}`,children:[y.label,y.required?h.jsx("span",{className:"ml-1 text-destructive",children:"*"}):null]}),h.jsx(Lt,{id:`sandbox-cred-${y.key}`,type:y.secret===!1?"text":"password",value:c[y.key]??"",onChange:k=>d(v=>({...v,[y.key]:k.target.value})),autoComplete:"off",required:y.required})]},y.key)),h.jsx(CMe,{onCancel:a,children:h.jsx(ge,{type:"submit",disabled:n||!s.trim(),children:n?h.jsxs(h.Fragment,{children:[h.jsx(dt,{size:"lg",className:"mr-2"}),"Connecting..."]}):`Connect ${f}`})})]})]})}function xs({visible:e,onReload:t}){return e?h.jsxs("div",{role:"alert",className:"rounded-md border border-amber-500/40 bg-amber-500/10 p-3 text-sm",children:[h.jsx("p",{children:"This form changed while you were editing. Your edits are preserved. Reload the latest values before saving."}),h.jsx(ge,{type:"button",variant:"outline",size:"sm",className:"mt-2",onClick:t,children:"Discard edits and reload"})]}):null}function YA({rows:e=4,className:t}){return h.jsxs("div",{role:"status","aria-label":"Loading form",className:ye("space-y-5",t),children:[Array.from({length:e}).map((n,a)=>h.jsxs("div",{className:"space-y-2",children:[h.jsx(ft,{className:"h-3.5 w-24"}),h.jsx(ft,{className:"h-9 w-full rounded-md"})]},a)),h.jsxs("div",{className:"flex items-center gap-2 pt-2",children:[h.jsx(ft,{className:"h-9 w-24 rounded-md"}),h.jsx(ft,{className:"h-9 w-20 rounded-md"})]})]})}function jMe(e){const t=[];e.configSchema&&t.push({title:"Configuration",schema:e.configSchema});for(const[n,a]of Object.entries(e.eventKinds??{}))a.metadataSchema&&t.push({title:n,description:a.description,schema:a.metadataSchema});return{description:e.description,sections:t}}function OMe(e){const t=[];return e.inputSchema&&t.push({title:"Input",schema:e.inputSchema}),e.outputSchema&&t.push({title:"Output",schema:e.outputSchema}),{description:e.description,sections:t}}function WA(){const e=Dk(),t=b.useCallback((a,o,s="")=>{e&&e.open({href:s,title:o.name??a,schemaSections:jMe(o)})},[e]),n=b.useCallback((a,o)=>{e&&e.open({href:"",title:o.name??a,schemaSections:OMe(o)})},[e]);return{inspectFeed:t,inspectAction:n}}const NMe={image:"Image",stt:"Speech-to-text",tts:"Text-to-speech"};function pEe(e){return e.filter(t=>t!=="text").map(t=>NMe[t])}function yEe(e){return e.supportedAuthTypes.some(t=>t==="oauth"||t==="device-code")}function TMe(e){return e.sdkCompat!=null&&e.supportedAuthTypes.includes("api-key")}function Di(e,t=""){return`${pt}/api/${e}/agents/inference-providers${t}`}function mEe(e){const{slug:t}=Hn();return st({queryKey:["inference-providers",t],queryFn:async()=>{const n=await Ge(Di(t??""),{credentials:"include"});return await Un(n,"Failed to load inference providers"),(await n.json()).providers??[]},enabled:!!t&&!0,staleTime:3e4})}function PMe(e){const{slug:t}=Hn();return st({queryKey:["inference-providers-catalog",t],queryFn:async()=>{const n=await Ge(Di(t??"","/catalog"),{credentials:"include"});return await Un(n,"Failed to load inference provider catalog"),(await n.json()).catalog??[]},enabled:!!t&&!0,staleTime:6e4})}const gEe=Ja({method:"POST",url:({slug:e})=>Di(e),body:e=>e,invalidate:()=>[["inference-providers"]],successMessage:"Provider created",errorMessage:"Failed to create provider"}),kEe=Ja({method:"PUT",url:({slug:e,params:t})=>Di(e,`/${t.providerSlug}/capabilities/${t.modality}`),body:e=>({block:e.block}),invalidate:()=>[["inference-providers"]],successMessage:"Capability updated",errorMessage:"Failed to update capability"}),vEe=Ja({method:"PUT",url:({slug:e,params:t})=>Di(e,`/${t.providerSlug}`),body:e=>({displayName:e.displayName}),invalidate:()=>[["inference-providers"]],successMessage:"Provider updated",errorMessage:"Failed to update provider"}),xEe=Ja({method:"PUT",url:({slug:e,params:t})=>Di(e,`/${t.providerSlug}/default`),invalidate:()=>[["inference-providers"]],successMessage:"Default provider set",errorMessage:"Failed to set default provider"}),bEe=Ja({method:"PUT",url:({slug:e,params:t})=>Di(e,`/${t.providerSlug}/key`),body:e=>({value:e.value}),invalidate:()=>[["inference-providers"]],successMessage:"Key rotated",errorMessage:"Failed to rotate key"}),wEe=Ja({method:"DELETE",url:({slug:e,params:t})=>Di(e,`/${t.providerSlug}`),invalidate:()=>[["inference-providers"]],successMessage:"Provider deleted",errorMessage:"Failed to delete provider"});function MEe(e,t){const n=t.find(a=>a.slug===e);return n?TMe(n):!0}function LMe(e){const t=e.trim();if(!t)return null;let n;try{n=new URL(t)}catch{return"Enter a valid URL"}return n.protocol!=="https:"?"Must start with https://":n.username||n.password?"Credentials in the URL aren't allowed":n.search||n.hash?"Query or fragment isn't allowed":null}const zMe=/^\/[A-Za-z0-9/_.-]*$/;function DMe(e){const t=e.trim();return t?t.startsWith("//")?"Can't start with //":zMe.test(t)?null:"Must be a path like /v1/models":null}function IMe(e){return e.length>0&&!e.trim()?"Model can't be blank":null}function SEe(e){const t={},n=LMe(e.base_url??"");n&&(t.base_url=n);const a=IMe(e.model??"");a&&(t.model=a);const o=DMe(e.models_endpoint??"");return o&&(t.models_endpoint=o),t}function _Ee(e){return!!(e.base_url||e.model||e.models_endpoint)}const qMe="https://github.com/lobu-ai/lobu/releases/latest/download/Lobu.dmg",HMe="https://chromewebstore.google.com/detail/jhgcecbdpnoehfnhpdfihlchjddapepi";function VMe(e){const t=new URL(e);return["127.0.0.1","localhost","[::1]"].includes(t.hostname)&&(t.hostname="host.docker.internal"),`docker run --rm --name lobu-worker --interactive --tty \\
|
|
7887
7887
|
--add-host host.docker.internal:host-gateway \\
|
|
7888
7888
|
--volume lobu-worker-state:/home/worker \\
|
|
7889
7889
|
ghcr.io/lobu-ai/lobu-worker:latest \\
|
|
@@ -7895,4 +7895,4 @@ For more information, see https://radix-ui.com/primitives/docs/components/${t.do
|
|
|
7895
7895
|
* @license qrcode.react
|
|
7896
7896
|
* Copyright (c) Paul O'Shannessy
|
|
7897
7897
|
* SPDX-License-Identifier: ISC
|
|
7898
|
-
*/var GMe={L:zl.QrCode.Ecc.LOW,M:zl.QrCode.Ecc.MEDIUM,Q:zl.QrCode.Ecc.QUARTILE,H:zl.QrCode.Ecc.HIGH},JA=128,eE="L",tE="#FFFFFF",nE="#000000",aE=!1,rE=1,YMe=4,WMe=0,ZMe=.1;function oE(e,t=0){const n=[];return e.forEach(function(a,o){let s=null;a.forEach(function(l,c){if(!l&&s!==null){n.push(`M${s+t} ${o+t}h${c-s}v1H${s+t}z`),s=null;return}if(c===a.length-1){if(!l)return;s===null?n.push(`M${c+t},${o+t} h1v1H${c+t}z`):n.push(`M${s+t},${o+t} h${c+1-s}v1H${s+t}z`);return}l&&s===null&&(s=c)})}),n.join("")}function iE(e,t){return e.slice().map((n,a)=>a<t.y||a>=t.y+t.h?n:n.map((o,s)=>s<t.x||s>=t.x+t.w?o:!1))}function QMe(e,t,n,a){if(a==null)return null;const o=e.length+n*2,s=Math.floor(t*ZMe),l=o/t,c=(a.width||s)*l,d=(a.height||s)*l,f=a.x==null?e.length/2-c/2:a.x*l,p=a.y==null?e.length/2-d/2:a.y*l,y=a.opacity==null?1:a.opacity;let k=null;if(a.excavate){let w=Math.floor(f),S=Math.floor(p),_=Math.ceil(c+f-w),C=Math.ceil(d+p-S);k={x:w,y:S,w:_,h:C}}const v=a.crossOrigin;return{x:f,y:p,h:d,w:c,excavation:k,opacity:y,crossOrigin:v}}function XMe(e,t){return t!=null?Math.max(Math.floor(t),0):e?YMe:WMe}function sE({value:e,level:t,minVersion:n,includeMargin:a,marginSize:o,imageSettings:s,size:l,boostLevel:c}){let d=fe.useMemo(()=>{const w=(Array.isArray(e)?e:[e]).reduce((S,_)=>(S.push(...zl.QrSegment.makeSegments(_)),S),[]);return zl.QrCode.encodeSegments(w,GMe[t],n,void 0,void 0,c)},[e,t,n,c]);const{cells:f,margin:p,numCells:y,calculatedImageSettings:k}=fe.useMemo(()=>{let v=d.getModules();const w=XMe(a,o),S=v.length+w*2,_=QMe(v,l,w,s);return{cells:v,margin:w,numCells:S,calculatedImageSettings:_}},[d,l,s,a,o]);return{qrcode:d,margin:p,cells:f,numCells:y,calculatedImageSettings:k}}var JMe=(function(){try{new Path2D().addPath(new Path2D)}catch{return!1}return!0})(),e7e=fe.forwardRef(function(t,n){const a=t,{value:o,size:s=JA,level:l=eE,bgColor:c=tE,fgColor:d=nE,includeMargin:f=aE,minVersion:p=rE,boostLevel:y,marginSize:k,imageSettings:v}=a,S=sg(a,["value","size","level","bgColor","fgColor","includeMargin","minVersion","boostLevel","marginSize","imageSettings"]),{style:_}=S,C=sg(S,["style"]),A=v?.src,j=fe.useRef(null),N=fe.useRef(null),I=fe.useCallback(F=>{j.current=F,typeof n=="function"?n(F):n&&(n.current=F)},[n]),[T,q]=fe.useState(!1),{margin:R,cells:H,numCells:D,calculatedImageSettings:G}=sE({value:o,level:l,minVersion:p,boostLevel:y,includeMargin:f,marginSize:k,imageSettings:v,size:s});fe.useEffect(()=>{if(j.current!=null){const F=j.current,W=F.getContext("2d");if(!W)return;let P=H;const U=N.current,J=G!=null&&U!==null&&U.complete&&U.naturalHeight!==0&&U.naturalWidth!==0;J&&G.excavation!=null&&(P=iE(H,G.excavation));const se=window.devicePixelRatio||1;F.height=F.width=s*se;const L=s/D*se;W.scale(L,L),W.fillStyle=c,W.fillRect(0,0,D,D),W.fillStyle=d,JMe?W.fill(new Path2D(oE(P,R))):H.forEach(function(B,V){B.forEach(function(O,ee){O&&W.fillRect(ee+R,V+R,1,1)})}),G&&(W.globalAlpha=G.opacity),J&&W.drawImage(U,G.x+R,G.y+R,G.w,G.h)}}),fe.useEffect(()=>{q(!1)},[A]);const $=ig({height:s,width:s},_);let X=null;return A!=null&&(X=fe.createElement("img",{src:A,key:A,style:{display:"none"},onLoad:()=>{q(!0)},ref:N,crossOrigin:G?.crossOrigin})),fe.createElement(fe.Fragment,null,fe.createElement("canvas",ig({style:$,height:s,width:s,ref:I,role:"img"},C)),X)});e7e.displayName="QRCodeCanvas";var lE=fe.forwardRef(function(t,n){const a=t,{value:o,size:s=JA,level:l=eE,bgColor:c=tE,fgColor:d=nE,includeMargin:f=aE,minVersion:p=rE,boostLevel:y,title:k,marginSize:v,imageSettings:w}=a,S=sg(a,["value","size","level","bgColor","fgColor","includeMargin","minVersion","boostLevel","title","marginSize","imageSettings"]),{margin:_,cells:C,numCells:A,calculatedImageSettings:j}=sE({value:o,level:l,minVersion:p,boostLevel:y,includeMargin:f,marginSize:v,imageSettings:w,size:s});let N=C,I=null;w!=null&&j!=null&&(j.excavation!=null&&(N=iE(C,j.excavation)),I=fe.createElement("image",{href:w.src,height:j.h,width:j.w,x:j.x+_,y:j.y+_,preserveAspectRatio:"none",opacity:j.opacity,crossOrigin:j.crossOrigin}));const T=oE(N,_);return fe.createElement("svg",ig({height:s,width:s,viewBox:`0 0 ${A} ${A}`,ref:n,role:"img"},S),!!k&&fe.createElement("title",null,k),fe.createElement("path",{fill:c,d:`M0,0 h${A}v${A}H0z`,shapeRendering:"crispEdges"}),fe.createElement("path",{fill:d,d:T,shapeRendering:"crispEdges"}),I)});lE.displayName="QRCodeSVG";function t7e(e){const t=Math.max(0,Math.floor(e/1e3)),n=Math.floor(t/60),a=t%60;return n>0?`${n}m ${a}s`:`${a}s`}function cE({expiresAt:e}){const[t,n]=b.useState(()=>Date.now());b.useEffect(()=>{const l=setInterval(()=>n(Date.now()),1e3);return()=>clearInterval(l)},[]);const o=new Date(e).getTime()-t,s=o<=0;return h.jsx("span",{className:`text-xs font-mono ${s?"text-destructive":"text-muted-foreground"}`,children:s?"Expired — waiting for refresh…":`Expires in ${t7e(o)}`})}function n7e({artifact:e}){return h.jsxs("div",{className:"space-y-3",children:[h.jsx("div",{className:"flex justify-center",children:h.jsx("div",{className:"rounded-md bg-white p-3 border",children:h.jsx(lE,{value:e.value,size:220,level:"M"})})}),e.expiresAt&&h.jsx("div",{className:"flex justify-center",children:h.jsx(cE,{expiresAt:e.expiresAt})}),e.instructions&&h.jsx("p",{className:"text-sm text-muted-foreground text-center",children:e.instructions})]})}function a7e({artifact:e}){const[t,n]=b.useState(!1),a=b.useCallback(async()=>{try{await navigator.clipboard.writeText(e.value.replace(/[^A-Za-z0-9]/g,"")),n(!0),setTimeout(()=>n(!1),1500)}catch{}},[e.value]);return h.jsxs("div",{className:"space-y-3",children:[h.jsxs("div",{className:"flex items-center justify-center gap-2",children:[h.jsx("code",{className:"font-mono text-2xl tracking-widest px-4 py-2 rounded bg-muted border",children:e.value}),h.jsx(ge,{variant:"outline",size:"sm",onClick:()=>void a(),children:t?h.jsxs(h.Fragment,{children:[h.jsx(Za,{className:"h-3.5 w-3.5 mr-1.5"})," Copied"]}):h.jsxs(h.Fragment,{children:[h.jsx(Hu,{className:"h-3.5 w-3.5 mr-1.5"})," Copy"]})})]}),e.expiresAt&&h.jsx("div",{className:"flex justify-center",children:h.jsx(cE,{expiresAt:e.expiresAt})}),e.instructions&&h.jsx("p",{className:"text-sm text-muted-foreground text-center",children:e.instructions})]})}function r7e({artifact:e,runId:t}){const n=D9(),[a,o]=b.useState(!1),s=b.useCallback(()=>{e.mode==="popup"?window.open(e.url,"_blank","noopener,noreferrer,width=600,height=700"):window.location.href=e.url,o(!0)},[e.mode,e.url]),l=b.useCallback(()=>{n.mutateAsync({run_id:t,name:e.awaitSignal,payload:{}})},[n,t,e.awaitSignal]);return h.jsxs("div",{className:"space-y-3",children:[e.instructions&&h.jsx("p",{className:"text-sm text-muted-foreground",children:e.instructions}),h.jsxs("div",{className:"flex flex-col items-stretch gap-2",children:[h.jsxs(ge,{onClick:s,children:[h.jsx(a1,{className:"h-4 w-4 mr-2"}),a?"Re-open authorization page":"Open authorization page"]}),a&&h.jsx(ge,{variant:"outline",onClick:l,disabled:n.isPending,children:n.isPending?h.jsxs(h.Fragment,{children:[h.jsx(dt,{size:"lg",className:"mr-2"})," Notifying…"]}):"I have completed authorization"})]})]})}function o7e({artifact:e,runId:t}){const n=D9(),[a,o]=b.useState({}),s=b.useCallback(c=>{c.preventDefault(),n.mutateAsync({run_id:t,name:e.submitSignal,payload:a})},[n,t,e.submitSignal,a]),l=e.fields.every(c=>!c.required||(a[c.key]??"").trim().length>0);return h.jsxs("form",{onSubmit:s,className:"space-y-3",children:[e.instructions&&h.jsx("p",{className:"text-sm text-muted-foreground",children:e.instructions}),e.fields.map(c=>h.jsxs("div",{className:"space-y-1",children:[h.jsxs("label",{htmlFor:`auth-field-${c.key}`,className:"text-xs font-medium",children:[c.label,c.required&&h.jsx("span",{className:"text-destructive ml-0.5",children:"*"})]}),h.jsx(Lt,{id:`auth-field-${c.key}`,type:c.kind==="password"?"password":"text",inputMode:c.kind==="otp"?"numeric":void 0,autoComplete:c.kind==="otp"?"one-time-code":void 0,value:a[c.key]??"",onChange:d=>o(f=>({...f,[c.key]:d.target.value}))})]},c.key)),h.jsx(ge,{type:"submit",disabled:!l||n.isPending,className:"w-full",children:n.isPending?h.jsxs(h.Fragment,{children:[h.jsx(dt,{size:"lg",className:"mr-2"})," Submitting…"]}):"Submit"})]})}function i7e({artifact:e}){return h.jsxs("div",{className:"flex items-center gap-3 py-2",children:[h.jsx(dt,{size:"xl",className:"text-muted-foreground"}),h.jsx("span",{className:"text-sm text-muted-foreground",children:e.message})]})}function uE({artifact:e,runId:t}){switch(e.type){case"qr":return h.jsx(n7e,{artifact:e});case"code":return h.jsx(a7e,{artifact:e});case"redirect":return h.jsx(r7e,{artifact:e,runId:t});case"prompt":return h.jsx(o7e,{artifact:e,runId:t});case"status":return h.jsx(i7e,{artifact:e})}}function s7e({runId:e,onClose:t}){const{data:n,isLoading:a}=z9(e),o=b.useMemo(()=>n?.status==="completed"||n?.status==="failed"||n?.status==="cancelled",[n?.status]);b.useEffect(()=>{if(n?.status==="completed"){const l=setTimeout(t,1500);return()=>clearTimeout(l)}},[n?.status,t]);const s=e!=null;return h.jsx(sk,{open:s,onOpenChange:l=>{l||t()},children:h.jsxs(P2,{className:"sm:max-w-md",children:[h.jsxs(lk,{children:[h.jsx(ck,{children:n?.status==="completed"?"Connection authorized":n?.status==="failed"?"Authorization failed":n?.status==="cancelled"?"Authorization cancelled":"Connect your account"}),h.jsx(uk,{children:n?.connector_key?`Complete sign-in for ${n.connector_key} to finish setup. You can add feeds later if you want scheduled syncs.`:"Complete sign-in to finish setup. You can add feeds later if you want scheduled syncs."})]}),h.jsxs("div",{className:"py-2 space-y-4",children:[a&&!n&&h.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[h.jsx(dt,{size:"lg"})," Preparing…"]}),n?.status==="completed"&&h.jsxs("div",{className:"flex items-center gap-2 text-sm text-emerald-600",children:[h.jsx(Dg,{className:"h-5 w-5"})," Success — closing…"]}),n?.status==="failed"&&h.jsxs("div",{className:"rounded-md border border-destructive/30 bg-destructive/5 p-3 text-sm text-destructive flex items-start gap-2",children:[h.jsx(FM,{className:"h-4 w-4 mt-0.5 shrink-0"}),h.jsx("span",{children:n.error_message||"Authentication failed."})]}),n?.status==="cancelled"&&h.jsxs("div",{className:"rounded-md border p-3 text-sm text-muted-foreground flex items-start gap-2",children:[h.jsx(w2,{className:"h-4 w-4 mt-0.5 shrink-0"}),h.jsx("span",{children:"Authorization was cancelled."})]}),!o&&n&&!n.artifact&&h.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[h.jsx(dt,{size:"lg"})," Waiting for connector…"]}),!o&&n?.artifact&&e!=null&&h.jsx(uE,{artifact:n.artifact,runId:e})]}),h.jsx("div",{className:"flex justify-end gap-2",children:h.jsx(ge,{variant:"outline",onClick:t,children:o?"Close":"Cancel"})})]})})}function l7e(e){return vv(e).find(t=>t.type==="app_installation")}function c7e(e){const t=e.provider.toUpperCase();return{clientIdKey:e.clientIdKey||`${t}_CLIENT_ID`,clientSecretKey:e.clientSecretKey||`${t}_CLIENT_SECRET`}}function u7e(e){if(e)return e}function vv(e){return u7e(e)?.methods??[]}function dE(e,t){if(!(e.auth_profile_slug||e.auth_profile_kind||e.app_auth_profile_slug||e.config?.managedBy||e.config?.installation_ref||e.config?.consent_only))return vv(t).find(n=>n.type==="none")}function _u(e,t){const n=vv(e),a=n.some(o=>o.type!=="none");return n.filter(o=>o.type!=="none"||a).filter(o=>{if(o.type==="oauth"){const s=o,l=Qu(s),c=x0(s);return!(l.length===0&&c.length===0)}return o.type==="env_keys",!0})}function Qu(e){return Array.isArray(e?.requiredScopes)?e.requiredScopes.filter(t=>typeof t=="string"):[]}function x0(e){return Array.isArray(e?.optionalScopes)?e.optionalScopes.filter(t=>typeof t=="string"):[]}function I8(e,t){const n=Qu(e),a=new Set(x0(e)),o=(t??[]).filter(s=>a.has(s));return Array.from(new Set([...n,...o]))}function Oh(e){return e.type==="app_installation"?`${e.provider.charAt(0).toUpperCase()+e.provider.slice(1)} App`:e.type==="oauth"?`OAuth (${e.provider.charAt(0).toUpperCase()+e.provider.slice(1)})`:e.type==="env_keys"?"API Key / Token":e.type==="browser"?"Browser":e.type==="none"?e.label??"No Authentication":e.type==="interactive"?"Interactive pairing":e.type}function d7e(e,t){const n=e.fields;if(n.length===0)return;const a=Object.fromEntries(n.map(s=>[s.key,{type:"string",title:s.label||s.key,description:s.description,example:s.example,...s.secret?{format:"password"}:{}}])),o=n.filter(s=>s.required!==!1).map(s=>s.key);return{type:"object",properties:a,...o.length>0?{required:o}:{}}}function h7e(e){if(e.type==="env_keys"){const t=e.required!==!1;return e.fields.map(n=>({key:n.key,label:n.label,description:n.description,example:n.example,secret:n.secret,required:t&&n.required!==!1}))}if(e.type==="oauth"){const t=e.required!==!1,n=e.provider?e.provider.charAt(0).toUpperCase()+e.provider.slice(1):"OAuth",{clientIdKey:a,clientSecretKey:o}=c7e(e);return[{key:a,label:`${n} Client ID`,description:`${n} OAuth client ID`,secret:!1,required:t},{key:o,label:`${n} Client Secret`,description:`${n} OAuth client secret`,secret:!0,required:t}]}return[]}function f7e(e){if(!e||e.type==="none")return;const t=h7e(e);if(t.length===0)return;const n=Object.fromEntries(t.map(o=>[o.key,{type:"string",title:o.required?o.label||o.key:`${o.label||o.key} (Optional)`,description:o.description,example:o.example,...o.secret?{format:"password"}:{}}])),a=t.filter(o=>o.required).map(o=>o.key);return{type:"object",properties:n,...a.length>0?{required:a}:{}}}function p7e(){return kv()}function y7e({id:e,title:t,count:n,action:a,muted:o,children:s}){return h.jsxs("section",{id:e,className:"min-w-0 scroll-mt-24",children:[h.jsxs("div",{className:"mb-2.5 flex items-center justify-between gap-3 border-b pb-2",children:[h.jsxs("h2",{className:ye("text-[13px] font-semibold tracking-[-0.005em]",o&&"text-muted-foreground"),children:[t,n?h.jsx("span",{className:"ml-1.5 text-[11.5px] font-normal text-muted-foreground",children:n}):null]}),a]}),s]})}function OEe({title:e,summary:t,open:n,onOpenChange:a,children:o}){return h.jsxs(J2,{open:n,onOpenChange:a,className:"min-w-0",children:[h.jsxs(e0,{className:"group flex w-full items-center gap-2 border-b pb-2 text-left transition-colors hover:border-muted-foreground",children:[h.jsx(da,{className:ye("size-3 shrink-0 text-muted-foreground transition-transform",n&&"rotate-90")}),h.jsx("span",{className:"text-[13px] font-semibold tracking-[-0.005em]",children:e}),h.jsx("span",{className:"ml-auto truncate text-[11.5px] text-muted-foreground transition-colors group-hover:text-foreground",children:n?"Hide":t})]}),h.jsx(t0,{className:"pt-3",children:o})]})}class wn{constructor(t,n,a,o=null){this.kind=t,this.text=n,this.value=a,this.error=o}toJSON(){if(this.error)throw new Error(this.error);return this.value}}function Xu(e){return e instanceof wn?e.error!==null:Array.isArray(e)?e.some(Xu):e!==null&&typeof e=="object"?Object.values(e).some(Xu):!1}function Fl(e){return e instanceof wn?Fl(e.toJSON()):Array.isArray(e)?e.map(Fl):e!==null&&typeof e=="object"?Object.fromEntries(Object.entries(e).map(([t,n])=>[t,Fl(n)])):e}function Nh(e){return e instanceof wn?{kind:e.kind,text:e.text,value:Nh(e.value),error:e.error}:Array.isArray(e)?e.map(Nh):e!==null&&typeof e=="object"?Object.fromEntries(Object.keys(e).sort().map(t=>[t,Nh(e[t])])):e}function hs(e){return JSON.stringify(Nh(e))??""}function u2(e,t){return{source:e,token:t,baseline:e.initial,values:e.initial,acceptedKey:void 0}}function hE(e,t){return e.source.initialKey!==t.initialKey||e.source.revisionKey!==t.revisionKey}function m7e(e,t){if(t.sessionKey!==e.source.sessionKey)return u2(t,{});if(!hE(e,t))return e;const n=hs(e.values);return n===hs(e.baseline)||n===t.initialKey?u2(t,e.token):e.acceptedKey===t.initialKey&&e.source.revisionKey===t.revisionKey?{...e,source:t,baseline:t.initial,acceptedKey:void 0}:e}function Bl(e,t,n){const a=b.useMemo(()=>hs(n),[n]),o={sessionKey:e,initial:t,initialKey:hs(t),revision:n,revisionKey:a},[s,l]=b.useState(()=>u2(o,{})),c=m7e(s,o);c!==s&&l(c);const d=c.token,f=b.useCallback(A=>{l(j=>j.token===d?A(j):j)},[d]),p=b.useCallback(A=>f(j=>({...j,values:typeof A=="function"?A(j.values):A})),[f]),y=()=>f(A=>u2(o,A.token)),k=b.useCallback((A,j)=>f(N=>({...N,baseline:A,acceptedKey:hs(j)})),[f]),v=b.useMemo(()=>hs(c.values),[c.values]),w=b.useMemo(()=>hs(c.baseline),[c.baseline]),S=v!==w,_=S&&hE(c,o),C=b.useMemo(()=>Xu(c.values),[c.values]);return{values:c.values,revision:c.source.revision,baseline:c.baseline,setValues:p,reset:y,accept:k,field(A){return[c.values[A],j=>p(N=>({...N,[A]:typeof j=="function"?j(N[A]):j}))]},canSubmit:!_&&!C,hasInvalidInput:C,dirty:S,hasConflict:_}}function NEe(e,t){const[n,a]=b.useState(()=>({sessionKey:e,token:{},value:t}));let o=n;e!==n.sessionKey&&(o={sessionKey:e,token:{},value:t},a(o));const s=o.token,l=b.useCallback(c=>{a(d=>d.token!==s?d:{...d,value:typeof c=="function"?c(d.value):c})},[s]);return[o.value,l]}const g7e={BASE_URL:"/",DEV:!1,MODE:"production",PROD:!0,SSR:!1,TSS_INLINE_CSS_ENABLED:"false",VITE_GATEWAY_URL:""};function k7e(e,t=g7e,n=typeof window<"u"?window.location.origin:void 0){const a=e.startsWith("agentconn-")?e.slice(10):e;return`${kv(t,n)}/lobu/api/v1/webhooks/${encodeURIComponent(a)}`}function TEe({title:e,summary:t,onOpen:n}){return h.jsxs("button",{type:"button",onClick:n,className:"group flex w-full items-center justify-between gap-4 rounded-lg border border-border px-4 py-3 text-left transition-colors hover:bg-accent/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",children:[h.jsxs("span",{className:"min-w-0",children:[h.jsx("span",{className:"block text-sm font-medium",children:e}),h.jsx("span",{className:"mt-0.5 block text-xs text-muted-foreground",children:t})]}),h.jsx(da,{"aria-hidden":"true",className:"h-4 w-4 shrink-0 text-muted-foreground"})]})}function v7e({label:e,query:t,onQueryChange:n,count:a,action:o}){return h.jsxs(h.Fragment,{children:[h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsxs("div",{className:"relative min-w-0 flex-1",children:[h.jsx(r1,{"aria-hidden":"true",className:"pointer-events-none absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground"}),h.jsx(Lt,{type:"search","aria-label":`Search ${e}`,placeholder:`Search ${e}…`,value:t,onChange:s=>n(s.target.value),className:"pl-9"})]}),o]}),h.jsxs("p",{className:"text-xs text-muted-foreground",role:"status",children:[a," ",a===1?e.replace(/s$/,""):e,t.trim()?" found":""]})]})}function x7e({entries:e,label:t,action:n,renderControl:a,renderDetail:o}){const[s,l]=b.useState(""),c=new Set(e.filter(d=>`${d.name} ${d.description??""}`.toLowerCase().includes(s.trim().toLowerCase())).map(d=>d.id));return h.jsxs("div",{className:"space-y-4",children:[h.jsx(v7e,{label:t,query:s,onQueryChange:l,count:c.size,action:n}),h.jsx("ul",{children:e.map(d=>h.jsx(b7e,{entry:d,hidden:!c.has(d.id),control:a?.(d),renderDetail:()=>o(d)},d.id))}),c.size===0&&h.jsx("p",{className:"py-5 text-sm text-muted-foreground",children:s?"No matches. Try another search.":`No ${t} yet.`})]})}function b7e({entry:e,hidden:t,control:n,renderDetail:a}){const[o,s]=b.useState(!1),[l,c]=b.useState(!1);return h.jsx("li",{hidden:t,className:"border-b border-border last:border-b-0",children:h.jsxs(J2,{open:o,onOpenChange:d=>{s(d),d&&c(!0)},children:[h.jsxs("div",{className:"flex items-center gap-3 py-3",children:[h.jsxs(e0,{className:"group flex min-w-0 flex-1 items-start gap-2 rounded-sm text-left hover:text-foreground/80 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",children:[h.jsx(da,{"aria-hidden":"true",className:"mt-0.5 h-4 w-4 shrink-0 text-muted-foreground transition-transform group-data-[state=open]:rotate-90 motion-reduce:transition-none"}),h.jsxs("span",{className:"min-w-0",children:[h.jsx("span",{className:"block text-sm font-medium",children:e.name}),e.status&&h.jsx("span",{className:"mt-0.5 block text-xs text-muted-foreground",children:e.status})]})]}),n&&h.jsx("div",{className:"shrink-0",children:n})]}),l&&h.jsxs(t0,{forceMount:!0,hidden:!o,className:"space-y-4 pb-4 pl-6",children:[e.description&&h.jsx("p",{className:"text-sm text-muted-foreground",children:e.description}),a()]})]})})}const fE={disabled:"Disabled",approval:"Requires approval",auto:"Auto-approve"},w7e=["disabled","approval","auto"];function pE(e){return e==="disabled"||e==="approval"||e==="auto"}function yE(e){if(!e||typeof e!="object")return{};const t=e.action_modes;if(!t||typeof t!="object"||Array.isArray(t))return{};const n={};for(const[a,o]of Object.entries(t))pE(o)&&(n[a]=o);return n}function mE(e){return e.requires_approval?"approval":e.kind==="read"?"auto":e.annotations?.destructiveHint===!0?"approval":"auto"}function lg(e,t){return t[e.operation_key]??mE(e)}function xv({name:e,description:t,onInspect:n,leading:a,trailing:o,badge:s}){return h.jsxs("div",{className:ye(Yl,"flex items-start gap-3 p-3"),children:[a,h.jsxs("div",{className:"min-w-0 flex-1",children:[h.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[n?h.jsx("button",{type:"button",onClick:n,className:"text-sm font-medium text-left hover:underline",children:e}):h.jsx("span",{className:"text-sm font-medium",children:e}),s]}),t&&h.jsx("p",{className:"mt-0.5 text-xs text-muted-foreground",children:t})]}),o]})}function gE({feedsSchema:e,enabledFeeds:t,onToggleFeed:n,onInspect:a}){if(!e)return null;const o=Object.entries(e);if(o.length===0)return null;const s=!!t&&!!n;return h.jsxs("div",{className:"space-y-2",children:[h.jsx("p",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wider",children:"Feeds"}),h.jsx("div",{className:"space-y-1.5",children:o.map(([l,c])=>h.jsx(xv,{name:c.name??l,description:c.description,onInspect:a?()=>a(l,c):void 0,leading:s?h.jsx("input",{type:"checkbox",checked:t.has(l),onChange:d=>n(l,d.target.checked),className:"rounded border-input mt-0.5","aria-label":`Enable ${c.name??l}`}):void 0},l))})]})}function M7e({operations:e,modes:t,onChange:n,onInspect:a}){if(e.length===0)return null;const o=!!n,s=(l,c)=>{if(!n)return;const d=mE(l),f={...t};c===d?delete f[l.operation_key]:f[l.operation_key]=c,n(f)};return h.jsxs("div",{className:"space-y-2",children:[h.jsx("p",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wider",children:"Actions"}),h.jsx("div",{className:"space-y-1.5",children:e.map(l=>{const c=lg(l,t),d=l.name??l.operation_key;return h.jsx(xv,{name:d,description:l.description,onInspect:a?()=>a(l):void 0,trailing:o?h.jsx(cg,{value:c,onChange:f=>s(l,f),"aria-label":`Mode for ${d}`}):h.jsx("span",{className:"text-xs text-muted-foreground",children:fE[c]})},l.operation_key)})})]})}function cg({value:e,onChange:t,"aria-label":n}){return h.jsx("select",{value:e,"aria-label":n,onChange:a=>{pE(a.target.value)&&t(a.target.value)},className:"h-8 max-w-full rounded-md border border-input bg-background px-2 text-xs focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",children:w7e.map(a=>h.jsx("option",{value:a,children:fE[a]},a))})}function kE({actionsSchema:e,onInspect:t}){if(!e)return null;const n=Object.entries(e);return n.length===0?null:h.jsxs("div",{className:"space-y-2",children:[h.jsx("p",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wider",children:"Actions"}),h.jsx("div",{className:"space-y-1.5",children:n.map(([a,o])=>h.jsx(xv,{name:o.name??a,description:o.description,onInspect:t?()=>t(a,o):void 0,badge:o.requiresApproval?h.jsx(on,{variant:"outline",className:"text-[10px] px-1.5 py-0 h-4 text-amber-600 border-amber-300",children:"Requires approval"}):void 0},a))})]})}var b0="Checkbox",[S7e]=dr(b0),[_7e,bv]=S7e(b0);function C7e(e){const{__scopeCheckbox:t,checked:n,children:a,defaultChecked:o,disabled:s,form:l,name:c,onCheckedChange:d,required:f,value:p="on",internal_do_not_use_render:y}=e,[k,v]=fo({prop:n,defaultProp:o??!1,onChange:d,caller:b0}),[w,S]=b.useState(null),[_,C]=b.useState(null),A=b.useRef(!1),j=w?!!l||!!w.closest("form"):!0,N={checked:k,disabled:s,setChecked:v,control:w,setControl:S,name:c,form:l,value:p,hasConsumerStoppedPropagationRef:A,required:f,defaultChecked:vi(o)?!1:o,isFormControl:j,bubbleInput:_,setBubbleInput:C};return h.jsx(_7e,{scope:t,...N,children:A7e(y)?y(N):a})}var vE="CheckboxTrigger",xE=b.forwardRef(({__scopeCheckbox:e,onKeyDown:t,onClick:n,...a},o)=>{const{control:s,value:l,disabled:c,checked:d,required:f,setControl:p,setChecked:y,hasConsumerStoppedPropagationRef:k,isFormControl:v,bubbleInput:w}=bv(vE,e),S=it(o,p),_=b.useRef(d);return b.useEffect(()=>{const C=s?.form;if(C){const A=()=>y(_.current);return C.addEventListener("reset",A),()=>C.removeEventListener("reset",A)}},[s,y]),h.jsx(He.button,{type:"button",role:"checkbox","aria-checked":vi(d)?"mixed":d,"aria-required":f,"data-state":_E(d),"data-disabled":c?"":void 0,disabled:c,value:l,...a,ref:S,onKeyDown:xe(t,C=>{C.key==="Enter"&&C.preventDefault()}),onClick:xe(n,C=>{y(A=>vi(A)?!0:!A),w&&v&&(k.current=C.isPropagationStopped(),k.current||C.stopPropagation())})})});xE.displayName=vE;var wv=b.forwardRef((e,t)=>{const{__scopeCheckbox:n,name:a,checked:o,defaultChecked:s,required:l,disabled:c,value:d,onCheckedChange:f,form:p,...y}=e;return h.jsx(C7e,{__scopeCheckbox:n,checked:o,defaultChecked:s,disabled:c,required:l,onCheckedChange:f,name:a,form:p,value:d,internal_do_not_use_render:({isFormControl:k})=>h.jsxs(h.Fragment,{children:[h.jsx(xE,{...y,ref:t,__scopeCheckbox:n}),k&&h.jsx(SE,{__scopeCheckbox:n})]})})});wv.displayName=b0;var bE="CheckboxIndicator",wE=b.forwardRef((e,t)=>{const{__scopeCheckbox:n,forceMount:a,...o}=e,s=bv(bE,n);return h.jsx(Gn,{present:a||vi(s.checked)||s.checked===!0,children:h.jsx(He.span,{"data-state":_E(s.checked),"data-disabled":s.disabled?"":void 0,...o,ref:t,style:{pointerEvents:"none",...e.style}})})});wE.displayName=bE;var ME="CheckboxBubbleInput",SE=b.forwardRef(({__scopeCheckbox:e,...t},n)=>{const{control:a,hasConsumerStoppedPropagationRef:o,checked:s,defaultChecked:l,required:c,disabled:d,name:f,value:p,form:y,bubbleInput:k,setBubbleInput:v}=bv(ME,e),w=it(n,v),S=oA(s),_=q_(a);b.useEffect(()=>{const A=k;if(!A)return;const j=window.HTMLInputElement.prototype,I=Object.getOwnPropertyDescriptor(j,"checked").set,T=!o.current;if(S!==s&&I){const q=new Event("click",{bubbles:T});A.indeterminate=vi(s),I.call(A,vi(s)?!1:s),A.dispatchEvent(q)}},[k,S,s,o]);const C=b.useRef(vi(s)?!1:s);return h.jsx(He.input,{type:"checkbox","aria-hidden":!0,defaultChecked:l??C.current,required:c,disabled:d,name:f,value:p,form:y,...t,tabIndex:-1,ref:w,style:{...t.style,..._,position:"absolute",pointerEvents:"none",opacity:0,margin:0,transform:"translateX(-100%)"}})});SE.displayName=ME;function A7e(e){return typeof e=="function"}function vi(e){return e==="indeterminate"}function _E(e){return vi(e)?"indeterminate":e?"checked":"unchecked"}const Mv=b.forwardRef(({className:e,...t},n)=>h.jsx(wv,{ref:n,className:ye("peer h-4 w-4 shrink-0 rounded-sm border border-primary focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground",e),...t,children:h.jsx(wE,{className:ye("flex items-center justify-center text-current"),children:h.jsx(Za,{className:"h-4 w-4"})})}));Mv.displayName=wv.displayName;const CE=b.forwardRef(({className:e,...t},n)=>h.jsx("textarea",{className:ye("flex min-h-[60px] w-full rounded-md border border-input bg-muted px-3 py-2 text-base placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",e),ref:n,...t}));CE.displayName="Textarea";function fa(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)&&!(e instanceof wn)}function E7e(e){return Array.isArray(e)?e.map(t=>String(t)).join(", "):""}function R7e(e,t,n,a,o){const s=e.split(",").map(c=>c.trim()).filter(Boolean);let l;if(t==="number"||t==="integer"){const c=s.map(Number);if(!c.every(f=>t==="integer"?Number.isInteger(f):Number.isFinite(f)))return{error:`Enter comma-separated ${t==="integer"?"integers":"numbers"}`};l=c}else if(t==="boolean"){if(s.some(c=>c!=="true"&&c!=="false"))return{error:"Enter comma-separated true or false values"};l=s.map(c=>c==="true")}else l=s;return n&&l.some(c=>!n.some(d=>Object.is(c,d)))?{error:"Enter only the allowed values"}:a!==void 0&&l.length<a?{error:`Enter at least ${a} ${a===1?"item":"items"}`}:o!==void 0&&l.length>o?{error:`Enter at most ${o} ${o===1?"item":"items"}`}:{values:l}}function j7e({id:e,value:t,itemType:n,itemEnum:a,minItems:o,maxItems:s,ariaLabel:l,placeholder:c,readOnly:d=!1,showHelp:f=!0,onChange:p}){const y=t instanceof wn?t.text:E7e(t),k=t instanceof wn?t.error:null;return h.jsxs(h.Fragment,{children:[h.jsx(Lt,{id:e,"aria-label":l,type:"text",value:y,onChange:v=>{const w=v.target.value,S=R7e(w,n,a,o,s);p(new wn("primitive-array",w,S.values,S.error??null))},placeholder:c||"Enter comma-separated values",readOnly:d,disabled:d,"aria-invalid":k?!0:void 0,"aria-describedby":k?`${e}-error`:f?`${e}-help`:void 0}),k?h.jsx("p",{id:`${e}-error`,role:"alert",className:"text-xs text-destructive",children:k}):f?h.jsx("p",{id:`${e}-help`,className:"text-xs text-muted-foreground",children:"Enter values separated by commas"}):null]})}function O7e(e,t){switch(t){case"array":return Array.isArray(e);case"object":return fa(e);case"integer":return typeof e=="number"&&Number.isInteger(e);case"number":return typeof e=="number"&&Number.isFinite(e);case"boolean":return typeof e=="boolean";case"string":return typeof e=="string";default:return!0}}function N7e(e){return e instanceof wn?e.kind==="primitive-array":Array.isArray(e)&&e.every(t=>typeof t=="string"||typeof t=="number"||typeof t=="boolean")}function AE({id:e,value:t,expectedType:n,itemType:a,itemEnum:o,minItems:s,maxItems:l,ariaLabel:c,readOnly:d=!1,onChange:f}){const p=b.useMemo(()=>{if(t instanceof wn)return t.text;try{return JSON.stringify(t,null,2)??""}catch{return""}},[t]),y=t instanceof wn?t.error:null;return h.jsxs(h.Fragment,{children:[h.jsx(CE,{id:e,"aria-label":c,value:p,onChange:k=>{const v=k.target.value;try{const w=JSON.parse(v);if(!(n==="array"?Array.isArray(w):fa(w)))throw new Error(`Value must be a JSON ${n}`);if(n==="array"&&w.some(_=>!O7e(_,a)))throw new Error(`Every item must be a JSON ${String(a)}`);if(n==="array"&&o&&w.some(_=>!o.some(C=>Object.is(_,C))))throw new Error("Enter only the allowed values");if(n==="array"&&s!==void 0&&w.length<s)throw new Error(`Enter at least ${s} ${s===1?"item":"items"}`);if(n==="array"&&l!==void 0&&w.length>l)throw new Error(`Enter at most ${l} ${l===1?"item":"items"}`);f(new wn(`json-${n}`,v,w))}catch(w){f(new wn(`json-${n}`,v,void 0,w instanceof SyntaxError?`Enter a valid JSON ${n}`:w instanceof Error?w.message:`Enter a valid JSON ${n}`))}},readOnly:d,disabled:d,"aria-invalid":y?!0:void 0,"aria-describedby":y?`${e}-error`:void 0,className:"min-h-24 font-mono text-xs"}),y?h.jsx("p",{id:`${e}-error`,role:"alert",className:"text-xs text-destructive",children:y}):null]})}function EE({id:e,value:t,ariaLabel:n="JSON object",readOnly:a=!1,onChange:o}){return h.jsx(AE,{id:e,value:t,expectedType:"object",ariaLabel:n,readOnly:a,onChange:o})}function ug({id:e,value:t,ariaLabel:n="JSON array",readOnly:a=!1,itemType:o,itemEnum:s,minItems:l,maxItems:c,onChange:d}){return h.jsx(AE,{id:e,value:t,expectedType:"array",itemType:o,itemEnum:s,minItems:l,maxItems:c,ariaLabel:n,readOnly:a,onChange:d})}function T7e({id:e,value:t,onChange:n,readOnly:a=!1,integer:o=!1,ariaLabel:s,placeholder:l}){const c=t instanceof wn?t.text:String(t??""),d=t instanceof wn?t.error:null;return h.jsxs(h.Fragment,{children:[h.jsx(Lt,{id:e,type:"text",inputMode:"decimal","aria-label":s,value:c,readOnly:a,disabled:a,placeholder:l,"aria-invalid":d?!0:void 0,"aria-describedby":d?`${e}-error`:void 0,onChange:f=>{const p=f.target.value,y=Number(p),k=/^[-+]?(?:\d+(?:\.\d*)?|\.\d+)(?:[eE][-+]?\d+)?$/.test(p.trim())&&Number.isFinite(y)&&(!o||Number.isInteger(y));n(new wn("number",p,p.trim()!==""&&k?y:void 0,p.trim()===""||k?null:`Enter a valid ${o?"integer":"number"}`))}}),d&&h.jsx("p",{id:`${e}-error`,role:"alert",className:"text-xs text-destructive",children:d})]})}function P7e(e){const t=[],n=/<a\b[^>]*href=['"]([^'"]+)['"][^>]*>(.*?)<\/a>/gi;let a=0,o=n.exec(e);for(;o!==null;){const[s,l,c]=o,d=o.index;d>a&&t.push({id:`text-${a}-${d}`,type:"text",value:e.slice(a,d)}),t.push({id:`link-${d}-${d+s.length}`,type:"link",href:l.trim(),label:c.replace(/<[^>]*>/g,"").trim()||l.trim()}),a=d+s.length,o=n.exec(e)}return a<e.length&&t.push({id:`text-${a}-${e.length}`,type:"text",value:e.slice(a)}),t.length>0?t:[{id:`text-0-${e.length}`,type:"text",value:e}]}function L7e({text:e,onOpenLink:t}){const n=P7e(e);return h.jsx("p",{className:"text-xs text-muted-foreground",children:n.map(a=>a.type==="text"?h.jsx("span",{children:a.value},a.id):t?h.jsx("button",{type:"button",className:"text-blue-600 hover:underline",onClick:()=>t(a.href),children:a.label},a.id):h.jsx("a",{href:a.href,target:"_blank",rel:"noopener noreferrer",className:"text-blue-600 hover:underline",children:a.label},a.id))})}function d2(e){return e.split("_").map(t=>t.charAt(0).toUpperCase()+t.slice(1)).join(" ")}function z7e(e,t){if(!e)return d2(t);const n=e.replace(/\s*\(e\.g\.,?\s.*?\)/gis,"").trim();return n.split(/(?<![A-Za-z0-9])\.(?=\s|$)|\.(?=\s+[A-Z])/)[0].trim().replace(/\.$/,"")||n||d2(t)}function D7e(e){if(e!=null){if(typeof e=="string"||typeof e=="number"||typeof e=="boolean")return String(e);if(Array.isArray(e)){const t=e.map(n=>typeof n=="string"||typeof n=="number"||typeof n=="boolean"?String(n):null).filter(n=>n!==null);if(t.length>0)return t.join(", ")}try{return JSON.stringify(e)}catch{return}}}function mh(e){const t=e.map(a=>d2(String(a))),n=new Map;return t.forEach((a,o)=>{const s=n.get(a)??new Set;s.add(typeof e[o]),n.set(a,s)}),e.map((a,o)=>{const s=t[o],l=(n.get(s)?.size??0)>1;return{id:`option-${o}`,value:a,label:l?`${s} (${typeof a=="string"?"text":typeof a})`:s}})}function RE(e,t,n){const a=t.anyOf;if(a&&a.length>0&&a.find(c=>c.type==="null")){const c=a.filter(d=>d.type!=="null");if(c.length===1){const d=Object.fromEntries(Object.entries(t).filter(([f])=>f!=="anyOf"));return RE(e,{...c[0],...d},n)}}const o={name:e,label:t.title||z7e(t.description,e),type:"text",required:n,description:t.description,defaultValue:t.default,example:t.example,schema:t},s=D7e(t.example);if(t.type==="object"||fa(t.properties))o.type="object";else if(t.type==="string")o.type=t.format==="password"?"password":"text",o.placeholder=s||`Enter ${d2(e).toLowerCase()}`,o.validation={minLength:t.minLength,maxLength:t.maxLength};else if(t.type==="number"||t.type==="integer")o.type="number",o.placeholder=s,o.validation={min:t.minimum,max:t.maximum};else if(t.type==="boolean")o.type="boolean";else if(t.type==="array"){const l=t.items;if(o.itemSchema=l,l?.type==="object"||l?.properties)o.type="object-array";else if(l?.enum&&Array.isArray(l.enum))o.type="multi-select",o.options=mh(l.enum);else if(l?.anyOf||l?.oneOf){const c=l.anyOf||l.oneOf,d=c.filter(f=>f.const!==void 0).map(f=>f.const);d.length>0&&d.length===c.length?(o.type="multi-select",o.options=mh(d)):l?.type==="string"||l?.type==="number"||l?.type==="integer"||l?.type==="boolean"?(o.type="array",o.placeholder=s??"Add items..."):o.type="json-array"}else l?.type==="string"||l?.type==="number"||l?.type==="integer"||l?.type==="boolean"?(o.type="array",o.placeholder=s??"Add items..."):o.type="json-array";o.validation={minItems:t.minItems,maxItems:t.maxItems}}else if(a){const l=a.filter(c=>c.const!==void 0).map(c=>c.const);l.length>0&&(o.type="select",o.options=mh(l),o.placeholder=s)}return t.enum&&Array.isArray(t.enum)&&(o.type="select",o.options=mh(t.enum),o.placeholder=s),o}function jE(e){if(!e?.properties)return[];const t=[],n=e.properties,a=e.required||[];for(const[o,s]of Object.entries(n)){const l=RE(o,s,a.includes(o));l&&t.push(l)}return t}function I7e({id:e,label:t,value:n,schema:a,readOnly:o,onOpenLink:s,onChange:l}){const c=fa(a.properties)?a.properties:null,d=fa(n)?n:{};if(!c||Object.keys(c).length===0||!fa(n)&&n!==void 0&&n!==null)return h.jsx(EE,{id:e,value:n,ariaLabel:`${t} JSON object`,readOnly:o,onChange:l});const f=new Set(Object.keys(c));return h.jsx("fieldset",{"aria-label":t,className:"rounded-md border p-3",children:h.jsx(bi,{schema:{type:"object",properties:c,required:a.required},values:d,onValuesChange:p=>{const y=Object.fromEntries(Object.entries(d).filter(([k])=>!f.has(k)));l({...y,...p})},onOpenLink:s,fieldIdPrefix:`${e}-`,readOnly:o})})}function q7e({id:e,label:t,value:n,itemSchema:a,validation:o,readOnly:s,onOpenLink:l,onChange:c}){if(!Array.isArray(n)&&n!==void 0&&n!==null)return h.jsx(ug,{id:e,value:n,ariaLabel:`${t} JSON array`,readOnly:s,itemType:"object",minItems:o?.minItems,maxItems:o?.maxItems,onChange:c});const d=Array.isArray(n)?n:[],f=fa(a?.properties)?a.properties:null,p=new Set(Object.keys(f??{})),y=o?.maxItems===void 0||d.length<o.maxItems,k=o?.minItems===void 0||d.length>o.minItems;return h.jsxs("div",{className:"space-y-3",children:[d.length===0?h.jsx("p",{className:"rounded-md border border-dashed p-3 text-sm text-muted-foreground",children:"No rows"}):d.map((v,w)=>{const S=`${e}-${w}`;return h.jsxs("fieldset",{className:"rounded-md border p-3",children:[h.jsxs("legend",{className:"px-1 text-xs font-medium text-muted-foreground",children:[t," row ",w+1]}),f&&Object.keys(f).length>0&&fa(v)?h.jsx(bi,{schema:{type:"object",properties:f,required:a?.required},values:v,onValuesChange:_=>{const C=Object.fromEntries(Object.entries(v).filter(([j])=>!p.has(j))),A=[...d];A[w]={...C,..._},c(A)},onOpenLink:l,fieldIdPrefix:`${S}-`,readOnly:s}):h.jsx(EE,{id:`${S}-json`,value:v,ariaLabel:`${t} row ${w+1} JSON object`,readOnly:s,onChange:_=>{const C=[...d];C[w]=_,c(C)}}),s?null:h.jsx("div",{className:"mt-2 flex justify-end",children:h.jsxs(ge,{type:"button",variant:"ghost",size:"sm","aria-label":`Remove ${t} row ${w+1}`,disabled:!k,onClick:()=>c(d.filter((_,C)=>C!==w)),children:[h.jsx(ui,{className:"mr-1.5 h-4 w-4"}),"Remove"]})})]},w)}),s?null:h.jsxs(ge,{type:"button",variant:"outline",size:"sm","aria-label":`Add ${t} row`,disabled:!y,onClick:()=>c([...d,xi(a)]),children:[h.jsx(la,{className:"mr-1.5 h-4 w-4"}),"Add row"]})]})}function xi(e,t={},n=!1){const a={...t};for(const o of jE(e??void 0)){o.name in a||(n&&o.example!==void 0?a[o.name]=o.example:o.defaultValue!==void 0?a[o.name]=o.defaultValue:o.type==="boolean"?a[o.name]=!1:o.type==="object"&&fa(o.schema.properties)&&(a[o.name]={}));const s=a[o.name];o.type==="object"&&fa(s)?a[o.name]=fa(o.schema.properties)&&Object.keys(o.schema.properties).length>0?xi(o.schema,s,n):new wn("json-object",JSON.stringify(s,null,2),s):o.type==="object-array"&&Array.isArray(s)&&(a[o.name]=s.map(l=>fa(l)?xi(o.itemSchema,l,n):l))}return a}function h2(e){const t={};for(const[n,a]of Object.entries(e))if(a instanceof wn){const o=Fl(a);o!==""&&o!==void 0&&o!==null&&(t[n]=o)}else Array.isArray(a)?t[n]=a.map(o=>o instanceof wn?Fl(o):fa(o)?h2(o):o):fa(a)?t[n]=h2(a):a!==""&&a!==void 0&&a!==null&&(t[n]=a);return t}function bi({connectorType:e,schema:t,values:n,onValuesChange:a,onOpenLink:o,fieldIdPrefix:s="",readOnly:l=!1,nativeSelects:c=!1}){const d=b.useMemo(()=>jE(t??e?.options_schema),[t,e]),f=(p,y)=>{a?.({...n,[p]:y})};return d.length===0?h.jsx("p",{className:"text-sm text-muted-foreground",children:"No configuration required."}):h.jsx("div",{className:"space-y-4",children:d.map(p=>{const y=`${s}${p.name}`;return h.jsxs("div",{className:"space-y-1.5",children:[p.type==="object"||p.type==="object-array"?h.jsxs("p",{className:"text-sm font-medium",children:[p.label,p.required&&!l&&h.jsx("span",{className:"text-red-500 ml-1",children:"*"})]}):h.jsxs("label",{htmlFor:y,className:"text-sm font-medium",children:[p.label,p.required&&!l&&h.jsx("span",{className:"text-red-500 ml-1",children:"*"})]}),p.description&&h.jsx(L7e,{text:p.description,onOpenLink:o}),(p.type==="text"||p.type==="password")&&h.jsx(Lt,{id:y,type:p.type,value:n[p.name]??"",onChange:k=>f(p.name,k.target.value),placeholder:p.placeholder,readOnly:l,disabled:l}),p.type==="number"&&h.jsx(T7e,{id:y,value:n[p.name],integer:p.schema.type==="integer",onChange:k=>f(p.name,k),placeholder:p.placeholder,readOnly:l}),p.type==="boolean"&&h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsx(Mv,{id:y,checked:n[p.name]??!1,onCheckedChange:k=>f(p.name,k),disabled:l}),h.jsx("label",{htmlFor:y,className:"text-sm",children:"Enable"})]}),p.type==="select"&&p.options&&c&&h.jsxs("select",{id:y,className:"h-9 w-full rounded-md border border-input bg-background px-3 py-1 text-sm outline-none focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:opacity-50",value:p.options.find(k=>Object.is(k.value,n[p.name]))?.id??"",onChange:k=>{const v=p.options?.find(w=>w.id===k.target.value);v&&f(p.name,v.value)},required:p.required,disabled:l,children:[h.jsx("option",{value:"",disabled:!0,children:p.placeholder||`Select ${p.label.toLowerCase()}...`}),p.options.map(k=>h.jsx("option",{value:k.id,children:k.label},k.id))]}),p.type==="select"&&p.options&&!c&&h.jsxs(si,{value:p.options.find(k=>Object.is(k.value,n[p.name]))?.id??"",onValueChange:k=>{const v=p.options?.find(w=>w.id===k);v&&f(p.name,v.value)},disabled:l,children:[h.jsx(io,{id:y,"aria-required":p.required||void 0,children:h.jsx(li,{placeholder:p.placeholder||`Select ${p.label.toLowerCase()}...`})}),h.jsx(so,{children:p.options.map(k=>h.jsx(Bn,{value:k.id,children:k.label},k.id))})]}),p.type==="multi-select"&&p.options&&h.jsx("div",{className:"flex flex-wrap gap-2 p-2 border rounded-md",children:p.options.map(k=>{const v=Array.isArray(n[p.name])?n[p.name].some(w=>Object.is(w,k.value)):!1;return h.jsx("button",{type:"button",disabled:l,onClick:()=>{const w=n[p.name]||[];v?f(p.name,w.filter(S=>!Object.is(S,k.value))):f(p.name,[...w,k.value])},className:`px-2.5 py-1 text-xs rounded-md border transition-colors ${v?"bg-primary text-primary-foreground border-primary":"bg-background hover:bg-muted border-border"}`,children:k.label},k.id)})}),p.type==="array"&&(n[p.name]!==void 0&&n[p.name]!==null&&!N7e(n[p.name])?h.jsx(ug,{id:y,value:n[p.name],ariaLabel:`${p.label} JSON array`,readOnly:l,itemType:p.itemSchema?.type,itemEnum:p.itemSchema?.enum,minItems:p.validation?.minItems,maxItems:p.validation?.maxItems,onChange:k=>f(p.name,k)}):h.jsx(j7e,{id:y,value:n[p.name],itemType:p.itemSchema?.type,itemEnum:p.itemSchema?.enum,minItems:p.validation?.minItems,maxItems:p.validation?.maxItems,placeholder:p.placeholder,readOnly:l,onChange:k=>f(p.name,k)})),p.type==="json-array"&&h.jsx(ug,{id:y,value:n[p.name],ariaLabel:`${p.label} JSON array`,readOnly:l,itemType:p.itemSchema?.type,itemEnum:p.itemSchema?.enum,minItems:p.validation?.minItems,maxItems:p.validation?.maxItems,onChange:k=>f(p.name,k)}),p.type==="object"&&h.jsx(I7e,{id:y,label:p.label,value:n[p.name],schema:p.schema,readOnly:l,onOpenLink:o,onChange:k=>f(p.name,k)}),p.type==="object-array"&&h.jsx(q7e,{id:y,label:p.label,value:n[p.name],itemSchema:p.itemSchema,validation:p.validation,readOnly:l,onOpenLink:o,onChange:k=>f(p.name,k)})]},p.name)})})}function H7e({connectionId:e,modes:t,onModeChange:n,policyOperations:a,browse:o=!1,onReviewPermissions:s}){const{data:l}=pk(e),c=b.useMemo(()=>(l??[]).filter(R=>R.kind==="write"),[l]),d=b.useMemo(()=>new Map(c.map(R=>[R.operation_key,R])),[c]),f=b.useMemo(()=>a?a.map(R=>d.get(R.operation_key)??R):c,[a,c,d]),p=b.useMemo(()=>Object.fromEntries(f.map(R=>[R.operation_key,xi(R.output_schema,{},!0)])),[f]),{initialInputs:y,inputSchemas:k}=b.useMemo(()=>({initialInputs:Object.fromEntries(f.map(R=>[R.operation_key,xi(R.input_schema)])),inputSchemas:Object.fromEntries(f.map(R=>[R.operation_key,R.input_schema]))}),[f]),v=Bl(e,y,k),{values:w,setValues:S}=v,[_,C]=b.useState({}),[A,j]=b.useState(null),N=w0e(),I=(R,H)=>{S(D=>({...D,[R]:H}))},T=async R=>{if(!(v.hasConflict||Xu(w[R]))){j(R),C(H=>{const D={...H};return delete D[R],D});try{const H=await N.mutateAsync({connection_id:e,operation_key:R,input:Fl(w[R]??{})});C(D=>({...D,[R]:H}))}catch(H){C(D=>({...D,[R]:{run_id:0,status:"failed",error_message:H instanceof Error?H.message:String(H)}}))}finally{j(null)}}};if(f.length===0)return null;const q=(R,H=!1)=>{const D=R.operation_key,G=A===D,$=_[D],X=l?.find(W=>W.operation_key===D),F=X?.readiness==="scope_upgrade_required"||X?.readiness==="auth_required";return h.jsxs(J2,{open:H?!0:void 0,children:[H&&h.jsxs("div",{className:"mb-5 space-y-2",children:[h.jsx("h3",{className:"text-sm font-medium",children:"Provider permissions"}),h.jsx("p",{className:"text-sm text-muted-foreground",children:F?"Additional access is needed before this action can run.":X?.readiness&&X.readiness!=="ready"&&X.readiness!=="disabled"?`Availability: ${X.readiness.replaceAll("_"," ")}`:X?.readiness==="ready"?"Provider access is ready.":"Provider access is checked when the action runs."}),F&&s&&h.jsx(ge,{variant:"outline",size:"sm",onClick:s,children:"Review permissions"})]}),h.jsxs("div",{className:"flex flex-wrap items-start gap-2 sm:flex-nowrap",children:[!H&&h.jsxs(e0,{className:"flex min-w-0 flex-[1_1_12rem] items-start gap-1.5 text-sm text-left group",children:[h.jsx(da,{className:"h-3 w-3 mt-1 text-muted-foreground shrink-0 transition-transform group-data-[state=open]:rotate-90"}),h.jsxs("span",{className:"min-w-0 flex-1",children:[h.jsx("span",{className:"block font-medium",children:R.name??D}),R.description&&h.jsx("span",{className:"line-clamp-2 text-xs text-muted-foreground group-data-[state=open]:line-clamp-none",children:R.description})]})]}),!H&&n?h.jsx(cg,{value:lg(R,t??{}),onChange:W=>n(D,W),"aria-label":`Mode for ${R.name??D}`}):null]}),h.jsx(t0,{children:h.jsxs("div",{className:H?"mt-5 space-y-3":"ml-4 mt-1.5 space-y-3",children:[v.revision?.[D]&&h.jsxs("div",{children:[h.jsx("p",{className:"text-xs text-muted-foreground mb-1",children:"Input"}),h.jsx(bi,{schema:v.revision[D],values:w[D],onValuesChange:W=>I(D,W),fieldIdPrefix:`action-${e}-${D}-`})]}),R.output_schema&&h.jsxs("div",{children:[h.jsx("p",{className:"text-xs text-muted-foreground mb-1",children:"Output Schema"}),h.jsx(bi,{schema:R.output_schema,values:p[D],fieldIdPrefix:`action-${e}-${D}-output-`,readOnly:!0})]}),d.has(D)?h.jsx(ge,{size:"sm",variant:"outline",onClick:()=>T(D),disabled:F||v.hasConflict||Xu(w[D])||G||A!==null,children:G?h.jsxs(h.Fragment,{children:[h.jsx(dt,{size:"md",className:"mr-1.5"}),"Running..."]}):h.jsxs(h.Fragment,{children:[h.jsx(a7,{className:"mr-1.5 h-3.5 w-3.5"}),"Run"]})}):null,$&&h.jsx(V7e,{result:$})]})})]},D)};return o?h.jsxs("div",{className:"space-y-3",children:[h.jsx(xs,{visible:v.hasConflict,onReload:v.reset}),h.jsx(x7e,{entries:f.map(R=>({id:R.operation_key,name:R.name??R.operation_key,description:R.description,operation:R,status:l?.find(H=>H.operation_key===R.operation_key)?.readiness==="scope_upgrade_required"?"Additional provider access needed":void 0})),label:"actions",renderControl:({operation:R})=>n?h.jsx(cg,{value:lg(R,t??{}),onChange:H=>n(R.operation_key,H),"aria-label":`Mode for ${R.name??R.operation_key}`}):null,renderDetail:({operation:R})=>q(R,!0)})]}):h.jsxs("div",{className:"space-y-1.5",children:[h.jsx(xs,{visible:v.hasConflict,onReload:v.reset}),h.jsx("div",{className:"space-y-2",children:f.map(R=>q(R))})]})}function V7e({result:e}){return e.status==="completed"?h.jsxs("div",{className:"rounded-md bg-green-50 dark:bg-green-950/30 p-3 text-sm space-y-1",children:[h.jsxs("div",{className:"flex items-center gap-1.5 text-green-700 dark:text-green-400 font-medium",children:[h.jsx(Dg,{className:"h-3.5 w-3.5"}),"Completed",h.jsxs("span",{className:"text-xs font-normal text-muted-foreground ml-auto",children:["Run #",e.run_id]})]}),e.output&&Object.keys(e.output).length>0&&h.jsx("pre",{className:"text-xs text-green-800 dark:text-green-300 font-mono whitespace-pre-wrap mt-1",children:JSON.stringify(e.output,null,2)})]}):e.status==="pending_approval"?h.jsxs("div",{className:"rounded-md bg-yellow-50 dark:bg-yellow-950/30 p-3 text-sm",children:[h.jsxs("div",{className:"flex items-center gap-1.5 text-yellow-700 dark:text-yellow-400 font-medium",children:[h.jsx(BM,{className:"h-3.5 w-3.5"}),"Pending Approval",h.jsxs("span",{className:"text-xs font-normal text-muted-foreground ml-auto",children:["Run #",e.run_id]})]}),e.message&&h.jsx("p",{className:"text-xs text-yellow-800 dark:text-yellow-300 mt-1",children:e.message})]}):h.jsxs("div",{className:"rounded-md bg-red-50 dark:bg-red-950/30 p-3 text-sm",children:[h.jsxs("div",{className:"flex items-center gap-1.5 text-red-700 dark:text-red-400 font-medium",children:[h.jsx(w2,{className:"h-3.5 w-3.5"}),"Failed",e.run_id>0&&h.jsxs("span",{className:"text-xs font-normal text-muted-foreground ml-auto",children:["Run #",e.run_id]})]}),e.error_message&&h.jsx("p",{className:"text-xs text-red-800 dark:text-red-300 font-mono mt-1",children:e.error_message})]})}function F7e(e){if(e)return e}function B7e(e){return F7e(e)?.methods??[]}function dg({requiredScopes:e,optionalScopes:t,selectedOptionalScopes:n,grantedScopes:a=[],onToggleOptionalScope:o}){const s=b.useId();return!e.length&&!t.length&&!a.length?null:h.jsxs("div",{className:"space-y-3 text-sm",children:[a.length>0&&h.jsxs("div",{children:[h.jsx("p",{className:"font-medium",children:"Already granted"}),h.jsx("p",{className:"text-muted-foreground",children:"These permissions are included when you authorize again."}),h.jsx("ul",{className:"mt-1 space-y-1",children:a.map(l=>h.jsx("li",{className:"break-all",children:l},l))})]}),e.some(l=>!a.includes(l))&&h.jsxs("div",{children:[h.jsx("p",{className:"font-medium",children:"Required permissions"}),h.jsx("ul",{className:"mt-1 space-y-1",children:e.filter(l=>!a.includes(l)).map(l=>h.jsx("li",{className:"break-all",children:l},l))})]}),t.some(l=>!a.includes(l))&&h.jsxs("fieldset",{className:"space-y-2",children:[h.jsx("legend",{className:"font-medium",children:"Additional permissions"}),t.filter(l=>!a.includes(l)).map(l=>h.jsxs("div",{className:"flex items-start gap-2",children:[h.jsx(Mv,{id:`${s}-${l}`,className:"mt-0.5",checked:n.includes(l),onCheckedChange:c=>o(l,c===!0)}),h.jsx("label",{htmlFor:`${s}-${l}`,className:"min-w-0 cursor-pointer break-all",children:l})]},l))]})]})}function hg(e){return e.invalidateQueries({predicate:t=>t.queryKey.some(n=>["auth-profiles","connections","feeds","available-operations","connector-operations",...pr].includes(String(n)))})}function PEe({result:e}){const t=sn();return b.useEffect(()=>{e&&hg(t)},[e,t]),e?h.jsx("p",{role:e==="failed"?"alert":"status",className:"rounded-md border p-3 text-sm",children:e==="connected"?"Account authorization updated. Review your permissions below.":e==="cancelled"?"Authorization cancelled. No permissions were added.":"Authorization did not finish. Review your account below to try again."}):null}function OE(e,t){const{data:n=[]}=fk(e.organization_id,{connectorKey:e.connector_key}),{data:a=[],isLoading:o,isError:s}=pk(e.id),{data:l=[]}=T9(e.id),c=n.find(p=>p.slug===e.auth_profile_slug),d=_u(t?.auth_schema).find(p=>p.type==="oauth"),f=a.filter(p=>p.readiness==="scope_upgrade_required").map(p=>({key:p.operation_key,name:p.name,scopes:p.next_action?.requested_scopes??[]}));if(c?.granted_scopes){const p=Object.entries(t?.feeds_schema??{});for(const y of l){const v=(p.find(([w,S])=>w===y.feed_key||S?.key===y.feed_key)?.[1]?.requiredScopes??[]).filter(w=>!c.granted_scopes?.includes(w));v.length&&f.push({key:`feed:${y.id}`,name:y.display_name??y.feed_key,scopes:v})}}return{profile:c,method:d,affected:f,missing:[...new Set(f.flatMap(p=>p.scopes))],isLoading:o,isError:s}}function LEe({connection:e,connectorDef:t,onReview:n}){const{affected:a}=OE(e,t),o=a.filter(s=>s.key.startsWith("feed:"));return!o.length||e.status!=="active"?null:h.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3 rounded-md border p-3",children:[h.jsxs("div",{className:"min-w-0 text-sm",children:[h.jsx("p",{className:"font-medium",children:"Some sources need additional permissions"}),h.jsxs("p",{className:"text-muted-foreground",children:[o.slice(0,3).map(s=>s.name).join(", "),o.length>3?` and ${o.length-3} more`:""]})]}),h.jsx(ge,{variant:"outline",size:"sm",onClick:n,children:"Review permissions"})]})}function NE(){const e=sn(),t=b.useRef(void 0),[n,a]=b.useState(!1),[o,s]=b.useState(null),[l,c]=b.useState(null);return b.useEffect(()=>()=>t.current?.(),[]),{begin:async f=>{t.current?.();const p=window.open("about:blank","_blank");p&&(p.opener=null);let y=!0;t.current=()=>{y=!1},a(!0),s(null),c(null);try{const k=await f();if(!y){p?.close();return}const v=k.connect_url;if(!v){if(p?.close(),k.status==="active"){hg(e);return}s(k.instructions??"Authorization could not start. Review the app configuration and try again."),c(k.setup_url??null);return}c(v);const w=()=>{hg(e),(!p||p.closed)&&(t.current?.(),c(null))},S=p?window.setInterval(()=>{p.closed&&w()},500):void 0;window.addEventListener("focus",w),t.current=()=>{y=!1,window.removeEventListener("focus",w),S&&window.clearInterval(S)},p&&(p.location.href=v)}catch(k){if(p?.close(),!y)return;s(k instanceof Error?k.message:"Authorization could not start. Try again.")}finally{y&&a(!1)}},pending:n,error:o,continueUrl:l}}function q8({connection:e,connectorDef:t}){const{profile:n,method:a,affected:o,missing:s,isLoading:l,isError:c}=OE(e,t),{session:d}=Xa(),f=P9(),p=A0e(),y=NE(),[k,v]=b.useState(!1),[w,S]=b.useState([]),_=!!d?.user?.id&&d.user.id===e.created_by&&(!e.auth_profile_slug||n?.created_by===d?.user?.id);if(!a)return null;const C=o.filter(I=>I.key.startsWith("feed:")).length,A=o.length-C,j=[C?`${C} configured ${C===1?"feed":"feeds"}`:null,A?`${A} ${A===1?"action":"actions"}`:null].filter(Boolean).join(" and "),N=I=>e.auth_profile_slug?f.mutateAsync({connection_id:e.id,requested_scopes:I}):p.mutateAsync({connector_key:e.connector_key,slug:e.slug,app_auth_profile_slug:e.app_auth_profile_slug??void 0,requested_scopes:I});return h.jsxs("div",{className:"space-y-3",children:[o.length>0&&h.jsxs("p",{role:"status",className:"text-sm text-muted-foreground",children:[j," ",o.length===1?"requires":"require"," ","additional permissions from ",t.name||a.provider,"."]}),l&&h.jsx("p",{className:"text-sm text-muted-foreground",children:"Checking permissions…"}),c&&h.jsx("p",{role:"alert",className:"text-sm text-destructive",children:"Could not check capability permissions. Refresh and try again."}),_?h.jsxs("div",{className:"flex flex-wrap gap-2",children:[h.jsx(ge,{variant:"outline",size:"sm",disabled:y.pending,onClick:()=>void y.begin(()=>N()),children:e.auth_profile_slug?"Reconnect":"Connect account"}),h.jsx(ge,{variant:"outline",size:"sm",onClick:()=>{v(!k),S(s)},children:"Review permissions"})]}):h.jsx("p",{className:"text-sm text-muted-foreground",children:"Only the account owner can reconnect this account."}),k&&_&&h.jsxs("div",{className:"space-y-3",children:[o.length>0&&h.jsxs("div",{children:[h.jsx("p",{className:"text-sm font-medium",children:C?"Feeds and actions needing access":"Actions needing access"}),h.jsx("ul",{className:"mt-1 list-disc pl-5 text-sm text-muted-foreground",children:o.map(I=>h.jsx("li",{children:I.name},I.key))})]}),h.jsx(dg,{requiredScopes:Qu(a),optionalScopes:x0(a),selectedOptionalScopes:w,grantedScopes:n?.granted_scopes,onToggleOptionalScope:(I,T)=>S(q=>T?[...new Set([...q,I])]:q.filter(R=>R!==I))}),h.jsxs(ge,{size:"sm",disabled:y.pending,onClick:()=>void y.begin(()=>N(w)),children:["Continue to ",a.provider]})]}),y.error&&h.jsx("p",{role:"alert",className:"text-sm text-destructive",children:y.error}),y.continueUrl&&h.jsx("a",{className:"text-sm underline",href:y.continueUrl,target:"_blank",rel:"noreferrer",children:"Continue authorization in your browser"})]})}const Zy="__serverless__",H8="__add_device__";function TE(e){const{session:t}=Xa();return e.auth_profile_kind!=="oauth_account"||!!(t?.user?.id&&t.user.id===e.created_by)}function zEe({connection:e,connectorDef:t,ownerSlug:n}){const a=qn(),o=b.useId(),s=u1(),l=L9(),[c,d]=b.useState(e.display_name??""),[f,p]=b.useState(!1),y=c!==(e.display_name??""),k=e.facets?.chat??!1,v=()=>{s.mutate({connection_id:e.id,display_name:c.trim()||void 0})},w=()=>{t?.required_capability&&(window.location.href=Fh(`revoke/${t.required_capability}`)),l.mutate(e.id,{onSuccess:()=>{a({to:"/$owner/connectors/$connectorKey",params:{owner:n,connectorKey:e.connector_key}})}})};return h.jsxs("div",{className:"space-y-6",children:[h.jsxs("dl",{className:"flex flex-wrap gap-x-6 gap-y-2 text-sm",children:[h.jsxs("div",{children:[h.jsx("dt",{className:"text-muted-foreground",children:"Owner"}),h.jsx("dd",{children:e.created_by_username??"Unknown owner"})]}),h.jsxs("div",{children:[h.jsx("dt",{className:"text-muted-foreground",children:"Access"}),h.jsx("dd",{children:e.visibility==="org"?"Shared with workspace":"Private"})]})]}),h.jsxs("div",{className:"space-y-2",children:[h.jsx(ha,{htmlFor:o,children:"Display name"}),h.jsxs("div",{className:"flex gap-2",children:[h.jsx(Lt,{id:o,value:c,onChange:S=>d(S.target.value),placeholder:t?.name??e.connector_key,className:"max-w-md"}),h.jsx(ge,{onClick:v,disabled:!y||s.isPending,children:s.isPending?h.jsxs(h.Fragment,{children:[h.jsx(dt,{size:"lg",className:"mr-2"}),"Saving..."]}):"Save"})]})]}),!k&&h.jsx(U7e,{connection:e,connectorDef:t,ownerSlug:n}),k&&h.jsx($7e,{connection:e,connectorDef:t}),!k&&h.jsx(Y7e,{connection:e,connectorDef:t,ownerSlug:n}),h.jsxs("div",{className:"rounded-lg border border-destructive/30 bg-destructive/5 p-4",children:[h.jsx("p",{className:"text-sm font-medium",children:"Delete this connection"}),h.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:k?"Disconnects this connection. Past messages stay in your workspace.":"Removes the connection and stops its feeds. Past events stay in your workspace."}),h.jsx("div",{className:"mt-3",children:f?h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsxs(ge,{variant:"destructive",size:"sm",disabled:l.isPending,onClick:w,children:[l.isPending?h.jsx(dt,{size:"md",className:"mr-1.5"}):null,"Confirm delete"]}),h.jsx(ge,{variant:"ghost",size:"sm",onClick:()=>p(!1),disabled:l.isPending,children:"Cancel"})]}):h.jsxs(ge,{variant:"outline",size:"sm",className:"text-destructive hover:text-destructive",onClick:()=>p(!0),children:[h.jsx(ui,{className:"mr-1.5 h-3.5 w-3.5"}),"Delete connection"]})})]})]})}function $7e({connection:e,connectorDef:t}){const n=u1(),[a,o]=b.useState(null),s=k7e(e.slug),l=t?.options_schema,c=l&&typeof l=="object"&&Object.keys(l.properties??l).length>0?l:null,d=Bl(e.id,{},c),{values:f,setValues:p}=d,y=d.hasInvalidInput?{}:h2(f),k=e.effective_credential_mode==="managed",v=(t?.auth_schema?.methods??[]).find(A=>A.type==="app_installation"),w=v?.permissions??[],S=v?.events??[],_=e.connector_key==="slack"&&w.length>0?JSON.stringify({display_information:{name:e.display_name??"Lobu bot"},features:{bot_user:{display_name:e.display_name??"Lobu bot",always_online:!0},slash_commands:[{command:"/lobu",url:s,description:"Talk to Lobu"}]},oauth_config:{scopes:{bot:w}},settings:{event_subscriptions:{request_url:s,bot_events:S},interactivity:{is_enabled:!0,request_url:s},socket_mode_enabled:!1}},null,2):null,C=async(A,j)=>{await navigator.clipboard.writeText(j),o(A),window.setTimeout(()=>o(null),1500)};return h.jsxs("div",{className:"space-y-4",children:[h.jsxs("div",{className:"space-y-2",children:[h.jsx(ha,{children:"Webhook URL"}),h.jsxs("div",{className:"flex max-w-2xl gap-2",children:[h.jsx(Lt,{value:s,readOnly:!0,className:"font-mono text-xs"}),h.jsx(ge,{variant:"outline",size:"icon",onClick:()=>void C("webhook",s),children:a==="webhook"?h.jsx(Za,{className:"h-4 w-4"}):h.jsx(Hu,{className:"h-4 w-4"})})]}),h.jsx("p",{className:"text-xs text-muted-foreground",children:"Configure this as the provider's events, commands, and interactivity endpoint."})]}),_?h.jsxs("div",{className:"space-y-2",children:[h.jsx(ha,{children:"Slack app manifest"}),h.jsx("p",{className:"text-xs text-muted-foreground",children:"Create a Slack app from this manifest, or copy it into Slack's app manifest editor to configure events, scopes, commands, and interactivity together. Then install the app and paste its bot token + signing secret back into the connection credentials."}),h.jsxs("div",{className:"flex gap-2",children:[h.jsx(ge,{asChild:!0,variant:"outline",size:"sm",children:h.jsxs("a",{href:`https://api.slack.com/apps?new_app=1&manifest_json=${encodeURIComponent(_)}`,target:"_blank",rel:"noreferrer",children:[h.jsx(a1,{className:"mr-1.5 h-3.5 w-3.5"}),"Create app in Slack"]})}),h.jsxs(ge,{variant:"outline",size:"sm",onClick:()=>void C("manifest",_),children:[a==="manifest"?h.jsx(Za,{className:"mr-1.5 h-3.5 w-3.5"}):h.jsx(Hu,{className:"mr-1.5 h-3.5 w-3.5"}),"Copy manifest"]})]})]}):null,!k&&d.revision?h.jsxs("div",{className:"space-y-3",children:[h.jsxs("div",{children:[h.jsx(ha,{children:"Rotate credentials"}),h.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:"Enter only values you want to replace. Stored secrets are never shown here."})]}),h.jsx(bi,{schema:d.revision??void 0,values:f,onValuesChange:p}),h.jsx(xs,{visible:d.hasConflict,onReload:d.reset}),h.jsxs(ge,{disabled:!d.canSubmit||Object.keys(y).length===0||n.isPending,onClick:()=>n.mutate({connection_id:e.id,config:y}),children:[n.isPending?h.jsx(dt,{size:"md",className:"mr-2"}):null,"Update credentials"]})]}):null]})}function U7e({connection:e,connectorDef:t,ownerSlug:n}){const a=qn(),o=TE(e),s=u1(),{data:l=[],refetch:c,isFetching:d}=d1(),f=t?.required_capability??null,p=e.device_worker_id,y=b.useMemo(()=>{const w=l.filter(S=>S.organization_id===e.organization_id&&(!f||S.capabilities.includes(f)));return p&&!w.some(S=>S.id===p)?[{id:p,worker_id:e.device_worker_handle??p,platform:e.device_platform??null,app_version:null,capabilities:[],label:e.device_label??null,last_seen_at:"",online:e.device_online??!1,organization_id:e.organization_id,organization_name:null,organization_slug:null,connector_count:0,connector_error_count:0,last_sync_at:null,connectors:[]},...w]:w},[l,f,e,p]),k=w=>{if(w===H8){a({to:"/$owner/connectors/create",params:{owner:n}});return}const S=w===Zy?null:w;S!==(p??null)&&s.mutate({connection_id:e.id,device_worker_id:S})},v=p??(f?"":Zy);return h.jsxs("div",{className:"space-y-2",children:[h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsxs(ha,{children:["Run on",f?h.jsx("span",{className:"text-destructive ml-1",children:"*"}):null]}),s.isPending?h.jsxs("span",{className:"inline-flex items-center gap-1 text-xs text-muted-foreground",children:[h.jsx(dt,{size:"sm"}),"Saving…"]}):null]}),h.jsxs("div",{className:"flex items-center gap-2 max-w-md",children:[h.jsxs(si,{value:v,onValueChange:k,disabled:!o||s.isPending,children:[h.jsx(io,{className:"h-8 flex-1",children:h.jsx(li,{placeholder:"Select a device"})}),h.jsxs(so,{children:[!f&&h.jsx(Bn,{value:Zy,children:"Serverless (default)"}),y.map(w=>h.jsx(TA,{device:w},w.id)),h.jsx(Bn,{value:H8,children:h.jsxs("span",{className:"flex items-center gap-2 text-muted-foreground",children:[h.jsx(la,{className:"h-3.5 w-3.5"}),"Add device"]})})]})]}),h.jsxs("button",{type:"button",onClick:()=>void c(),disabled:d,className:"inline-flex shrink-0 items-center gap-1 text-xs text-muted-foreground hover:text-foreground disabled:opacity-50",children:[h.jsx(M2,{className:`h-3 w-3 ${d?"animate-spin":""}`}),"Refresh"]})]}),f&&y.length===0?h.jsxs("p",{className:"text-xs text-muted-foreground",children:["No device has granted the “",f_[f]??f,"” permission. Open the Lobu app on a device and grant it, then"," ",h.jsx("button",{type:"button",onClick:()=>void c(),className:"underline hover:text-foreground",children:"refresh"}),"."]}):p&&e.device_online===!1?h.jsxs("p",{className:"text-xs text-muted-foreground",children:["Device offline — sync runs wait for it to check in",e.device_last_seen_at?` (last seen ${k1(e.device_last_seen_at)})`:"","."]}):null]})}const K7e={env:"Environment variable",oauth_app:"OAuth app (workspace-wide)",oauth_account:"OAuth account",browser_session:"Browser session (local)",interactive:"Interactive credential"},G7e={env:"A secret pulled from the worker process env. Update by changing the env var on whichever device runs this connector.",oauth_app:"Shared client configuration managed by workspace administrators. Account owners grant consent separately.",oauth_account:"The account owner can reconnect to renew access or grant additional permissions.",browser_session:"Reuses your local browser cookies on a device. Sign in again using the browser pairing flow on that device.",interactive:"A credential the agent fills in at run-time (e.g. a one-time code). Nothing stored long-term."};function PE({heading:e,name:t,kind:n,status:a,isDefault:o,headerRight:s,footer:l}){const c=n?K7e[n]:null,d=n?G7e[n]:null;return h.jsxs("div",{className:ye(Yl,"space-y-1.5 p-4"),children:[h.jsxs("div",{className:"flex items-center justify-between gap-2",children:[h.jsx("p",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wider",children:e}),s]}),h.jsxs("div",{className:"flex flex-wrap items-baseline gap-x-2 gap-y-0.5",children:[h.jsx("span",{className:"text-sm font-medium",children:t}),c?h.jsxs("span",{className:"text-xs text-muted-foreground",children:["· ",c]}):null,a?h.jsxs("span",{className:a==="active"?"text-xs text-green-500":"text-xs text-amber-500",children:["· ",a]}):null,o?h.jsx("span",{className:"rounded-md bg-muted px-1.5 py-0.5 text-[10px] font-medium uppercase tracking-wide text-muted-foreground",children:"Org default"}):null]}),d?h.jsx("p",{className:"text-xs text-muted-foreground",children:d}):null,l]})}function Y7e({connection:e,connectorDef:t,ownerSlug:n}){const a=l7e(t?.auth_schema),o=B7e(t?.auth_schema).some(p=>p.type==="oauth"),s=a?a.provider.charAt(0).toUpperCase()+a.provider.slice(1):null,l=e.config?.managedBy;if(l&&typeof l=="object"&&"org"in l&&typeof l.org=="string")return h.jsxs("div",{className:"space-y-2",children:[h.jsx(ha,{children:"Auth"}),h.jsxs("p",{className:"text-sm text-muted-foreground",children:["Managed authorization from ",l.org,". This runtime uses its cloud login to access your grant."]})]});const c=dE(e,t?.auth_schema);if(c)return h.jsxs("div",{id:"connection-auth",className:"space-y-2 scroll-mt-6",children:[h.jsx(ha,{children:"Auth"}),h.jsx("p",{className:"text-sm text-muted-foreground",children:Oh(c)})]});if(!e.auth_profile_name)return h.jsxs("div",{id:"connection-auth",className:"space-y-2 scroll-mt-6",children:[h.jsx(eg,{organizationId:e.organization_id,connectorKey:e.connector_key}),h.jsx(ha,{children:"Auth"}),a?h.jsxs("div",{className:"space-y-2",children:[h.jsxs("p",{className:"text-sm text-muted-foreground",children:["No ",s," App installation linked yet."]}),h.jsx(Xm,{organizationId:e.organization_id,connectorKey:e.connector_key,provider:a.provider,providerLabel:t?.name,installShape:a.installShape,recovery:!0,variant:"outline"})]}):h.jsxs("div",{className:"space-y-2",children:[h.jsx("p",{className:"text-sm text-muted-foreground",children:o?"No account is connected yet.":"No auth profile attached."}),o&&t&&h.jsx(q8,{connection:e,connectorDef:t})]})]});const d=e.auth_profile_kind==="oauth_account"&&!!e.app_auth_profile_name,f=d?"Account":"Profile";return h.jsxs("div",{id:"connection-auth",className:"space-y-2 scroll-mt-6",children:[h.jsx(ha,{children:"Auth"}),h.jsxs("div",{className:"space-y-2",children:[d&&e.app_auth_profile_name?h.jsx(W7e,{connection:e,ownerSlug:n}):null,h.jsx(PE,{heading:f,name:e.auth_profile_name,kind:e.auth_profile_kind,status:e.auth_profile_status,footer:e.auth_profile_kind==="oauth_account"&&t?h.jsx(q8,{connection:e,connectorDef:t}):void 0}),t?.key?h.jsxs("p",{className:"text-xs text-muted-foreground",children:["Connector slug:"," ",h.jsx("code",{className:"font-mono",children:t.key})]}):null,a?h.jsxs("div",{className:"space-y-1.5 pt-1",children:[h.jsx(eg,{organizationId:e.organization_id,connectorKey:e.connector_key}),h.jsx(Xm,{organizationId:e.organization_id,connectorKey:e.connector_key,provider:a.provider,providerLabel:t?.name,installShape:a.installShape,recovery:!0,variant:"outline"})]}):null]})]})}function W7e({connection:e,ownerSlug:t}){const{isAdmin:n}=mv(e.organization_id),{data:a=[]}=fk(e.organization_id,{connectorKey:e.connector_key,profileKind:"oauth_app"}),o=e.app_auth_profile_slug??void 0,s=a.find(c=>c.slug===o)??null,l=!!s?.is_default_for_connector&&s.connector_key===e.connector_key;return h.jsx(PE,{heading:"Workspace app",name:e.app_auth_profile_name??"—",kind:e.app_auth_profile_kind??"oauth_app",status:e.app_auth_profile_status,isDefault:l,headerRight:n?h.jsx(Ct,{to:"/$owner/connectors/$connectorKey",params:{owner:t,connectorKey:e.connector_key},search:{setup:"oauth_app"},hash:"connector-oauth-apps",className:"text-xs text-muted-foreground hover:text-foreground",children:"Manage app"}):null,footer:n?h.jsx("p",{className:"text-xs text-muted-foreground",children:"This account stays linked to the app used to authorize it. To use another app, connect a new account."}):void 0})}function Z7e({connection:e,inPeek:t=!1,onReviewPermissions:n}){const{data:a=[],isLoading:o,isError:s}=pk(e.id),l=u1(),c=TE(e),d=Bl(e.id,yE(e.config)),{values:f,setValues:p}=d;if(o)return h.jsx("p",{className:"text-sm text-muted-foreground",children:"Loading actions…"});if(s)return h.jsx("p",{role:"alert",className:"text-sm",children:"Could not load actions. Close the pane and try again."});if(a.length===0)return h.jsx("p",{className:"text-sm text-muted-foreground",children:"No actions available."});const y=(w,S)=>{p(_=>({..._,[w]:S}))},k=()=>{if(!d.canSubmit)return;const w={...e.config??{},action_modes:f};l.mutate({connection_id:e.id,config:w},{onSuccess:()=>d.accept(f,f)})},v=h.jsxs("div",{className:"space-y-3",children:[h.jsx(H7e,{connectionId:e.id,browse:t,onReviewPermissions:n,modes:f,onModeChange:c?y:void 0,policyOperations:a}),l.isError&&h.jsx("p",{role:"alert",className:"text-sm text-destructive",children:"Could not save the policy. Your changes are still here; try again."}),h.jsx(xs,{visible:d.hasConflict,onReload:d.reset}),c&&d.dirty?h.jsxs("div",{className:t?"sticky bottom-0 z-10 flex justify-end gap-2 border-t bg-background py-3":"flex justify-end gap-2",children:[h.jsx(ge,{variant:"outline",size:"sm",onClick:d.reset,children:"Cancel"}),h.jsx(ge,{size:"sm",onClick:k,disabled:l.isPending||!d.canSubmit,children:l.isPending?"Saving...":"Save"})]}):null]});return t?v:h.jsx(y7e,{title:"Actions",count:`${a.length} ${a.length===1?"action":"actions"}`,children:v})}function Q7e({isInstalling:e,installConnectorFromSourceUri:t,reloadConnectorCatalog:n,resetConnectorConfiguration:a,selectConnector:o,clearSaveError:s,setInstallError:l}){const[c,d]=b.useState(null),[f,p]=b.useState(null),y=b.useCallback(async w=>{if(!e){if(l(null),s(),w.installed===!1&&w.installable){p(w);return}o(w),a()}},[s,e,a,o,l]),k=b.useCallback(async()=>{if(!f||e)return null;if(!f.source_uri)return l(`Connector '${f.name}' is missing a source URI.`),null;d(f.key);try{await t(f.source_uri);const S=(await n()).find(_=>_.key===f.key&&_.installed!==!1)??null;if(!S)throw new Error(`Installed connector '${f.name}' could not be reloaded.`);return p(null),S}catch(w){return l(w instanceof Error?w.message:"Failed to install connector"),null}finally{d(null)}},[t,e,f,n,l]),v=b.useCallback(()=>{p(null),l(null)},[l]);return{installingConnectorKey:c,setInstallingConnectorKey:d,previewConnector:f,handleConnectorSelect:y,handleInstallPreviewedConnector:k,clearPreview:v}}function X7e({open:e,onOpenChange:t,organizationId:n,editingConnection:a,connections:o=[],initialConnectorKey:s,onDeepLinkBack:l}){const c=b0e(),d=NE(),{session:f}=Xa(),p=u1(),y=S0e(),k=C0e(),v=_0e(),{data:w=[],isLoading:S,refetch:_}=hk(n),C=!!a,A=L9(),j=O0e(),[N,I]=b.useState(!1),[T,q]=b.useState(null),[R,H]=b.useState(!1),[D,G]=b.useState(""),[$,X]=b.useState(null),[F,W]=b.useState(""),[P,U]=b.useState(null),[J,se]=b.useState(""),L=Bl(`${a?.id??"new"}:${P?.key??""}:${e}`,xi(P?.options_schema,a?.config??{}),P?.options_schema),{values:B,setValues:V}=L,[O,ee]=b.useState({}),[Q,ae]=b.useState(0),[oe,de]=b.useState(void 0),[pe,Re]=b.useState(void 0),[Pe,De]=b.useState(!1),[bt,Ye]=b.useState(""),[kn,Qt]=b.useState(""),[Xt,ln]=b.useState(!1),[Ot,Jt]=b.useState(""),[va,Nt]=b.useState(""),[Wn,At]=b.useState(!1),[lt,ie]=b.useState(""),[me,Ne]=b.useState(""),[Ie,Ve]=b.useState([]),[vn,Ut]=b.useState(!1),[Kt,Et]=b.useState(""),[Gt,rt]=b.useState(""),[Nn,cn]=b.useState(void 0),[zt,xa]=b.useState(a?.device_worker_id??void 0),[wo,gr]=b.useState(!1),[za,Oe]=b.useState(null),[St,It]=b.useState(null),{isAdmin:qt}=mv(n),kr=b.useMemo(()=>_u(P?.auth_schema).find(Be=>Be.type==="oauth")?.provider??void 0,[P?.auth_schema]),{data:et=[]}=fk(n,{connectorKey:P?.key,provider:kr});b.useEffect(()=>{if(!a||!e||P||S)return;const Me=w.find(Jn=>Jn.key===a.connector_key)??{key:a.connector_key,name:a.connector_name||a.connector_key,description:null,version:"",auth_schema:null,feeds_schema:null,actions_schema:null,options_schema:null,status:"active",login_enabled:!1};U(Me),se(a.display_name??""),de(a.auth_profile_slug??void 0),Re(a.app_auth_profile_slug??void 0),xa(a.device_worker_id??void 0);const hn=_u(Me.auth_schema).findIndex(Jn=>a.auth_profile_kind==="browser_session"?Jn.type==="browser":a.auth_profile_kind==="oauth_account"||a.app_auth_profile_slug?Jn.type==="oauth":a.auth_profile_kind==="env"?Jn.type==="env_keys":dE(a,Me.auth_schema)?Jn.type==="none":!1);ae(hn>=0?hn:0)},[a,e,w,P,S]);const Cn=b.useMemo(()=>_u(P?.auth_schema),[P]),we=Cn[Q]??null,un=b.useMemo(()=>et.filter(ve=>ve.profile_kind==="env"),[et]),Yt=b.useMemo(()=>{if(!we||we.type!=="oauth")return[];const ve=we.provider.toLowerCase();return et.filter(Me=>Me.profile_kind==="oauth_account"&&Me.provider?.toLowerCase()===ve&&(qt||Me.created_by===f?.user?.id))},[we,et,qt,f?.user?.id]),ba=b.useMemo(()=>{if(!we||we.type!=="oauth")return[];const ve=we.provider.toLowerCase();return et.filter(Me=>Me.profile_kind==="oauth_app"&&Me.status==="active"&&Me.provider?.toLowerCase()===ve)},[we,et]),Tn=b.useMemo(()=>et.filter(ve=>ve.profile_kind==="browser_session"),[et]),Hi=b.useMemo(()=>{if(!(!we||we.type!=="env_keys"))return d7e(we)},[we]),Ds=b.useMemo(()=>f7e(we),[we]),wa=Bl(`${P?.key}:${Q}:${Pe}`,xi(Hi),Hi),Ht=Bl(`${P?.key}:${Q}:${Xt}`,xi(Ds),Ds),{values:xn,setValues:Mo}=wa,{values:Vi,setValues:_0}=Ht,Is=b.useMemo(()=>we?.type==="oauth"?x0(we):[],[we]);b.useEffect(()=>{if(!(C||!P||!we))if(we.type==="oauth"){if(!pe&&ba.length>0){const Me=ba.find(Be=>Be.is_default_for_connector&&Be.connector_key===P.key)??(qt&&ba.length===1?ba[0]:void 0);Me&&Re(Me.slug)}!oe&&Yt.length>0&&de(Yt[0].slug)}else we.type==="env_keys"?!oe&&un.length>0&&de(un[0].slug):we.type==="browser"&&!oe&&Tn.length>0&&de(Tn[0].slug)},[qt,C,P,we,pe,oe,ba,Yt,un,Tn]),b.useEffect(()=>{if(we?.type!=="oauth"||Is.length===0){Ve(Be=>Be.length===0?Be:[]);return}const Me=(Yt.find(Be=>Be.slug===oe)?.requested_scopes??[]).filter(Be=>Is.includes(Be));Ve(Be=>Be.length===Me.length&&Be.every((hn,Jn)=>hn===Me[Jn])?Be:Me)},[we,Is,Yt,oe]);const pc=b.useCallback(()=>{De(!1),Ye(""),Qt(""),ln(!1),Jt(""),Nt(""),At(!1),ie(""),Ne(""),Ve([]),Ut(!1),Et(""),rt("")},[]),Dr=b.useCallback(()=>{ee({}),ae(0),de(void 0),Re(void 0),pc()},[pc]);b.useEffect(()=>{if(C||!P)return;const ve=P.default_connection_config;ve&&typeof ve=="object"&&ee(ve)},[C,P]);const{data:Fi=[],refetch:So,isFetching:_o}=d1(),Zn=P?.required_capability??null,Ma=b.useMemo(()=>{const ve=Fi.filter(Be=>Be.organization_id===n&&(!Zn||Be.capabilities.includes(Zn))),Me=a?.device_worker_id;return Me&&!ve.some(Be=>Be.id===Me)?[{id:Me,worker_id:a?.device_worker_handle??Me,platform:a?.device_platform??null,app_version:null,capabilities:[],label:a?.device_label??null,last_seen_at:"",online:a?.device_online??!1,organization_id:n,organization_name:null,organization_slug:null,connector_count:0,connector_error_count:0,last_sync_at:null,connectors:[]},...ve]:ve},[Fi,Zn,a,n]);b.useEffect(()=>{C||xa(void 0)},[P?.key,C]),b.useEffect(()=>{if(zt&&!Ma.some(ve=>ve.id===zt)&&zt!==a?.device_worker_id){xa(void 0);return}C||!Zn||zt||Ma.length===1&&xa(Ma[0].id)},[C,Zn,zt,Ma,a]);const Co=b.useMemo(()=>oe?et.find(ve=>ve.slug===oe&&ve.profile_kind==="browser_session"):void 0,[et,oe])?.device_worker_id??null;b.useEffect(()=>{Co&&zt!==Co&&xa(Co)},[Co,zt]);const A1=b.useCallback(async()=>(await _()).data??[],[_]),{installingConnectorKey:Ir,setInstallingConnectorKey:Ao,previewConnector:E1,handleConnectorSelect:qs,handleInstallPreviewedConnector:R1,clearPreview:yc}=Q7e({isInstalling:j.isPending,installConnectorFromSourceUri:async ve=>{await j.mutateAsync({source_uri:ve})},reloadConnectorCatalog:A1,resetConnectorConfiguration:Dr,selectConnector:U,clearSaveError:()=>Oe(null),setInstallError:X}),Eo=ve=>{ve||(U(null),se(""),Dr(),cn(void 0),Oe(null),I(!1),q(null),H(!1),G(""),X(null),Ao(null),W(""),It(null),yc()),t(ve)},Hs=()=>{if(P&&s&&l){l();return}P?(U(null),Dr(),cn(void 0),Oe(null),X(null)):E1&&yc()},Da=b.useRef(!1);b.useEffect(()=>{if(Da.current||C||!s||P)return;const ve=w.find(Me=>Me.key===s);ve&&(Da.current=!0,qs(ve))},[e,C,s,w,P,qs]);const Qn=b.useMemo(()=>{if(!P||!L.revision||we&&we.type!=="none")return!1;const ve=L.revision.properties;if(!ve)return!1;const Me=new Set,Be=P.feeds_schema;if(Be){for(const hn of Object.values(Be))if(hn.configSchema?.properties)for(const Jn of Object.keys(hn.configSchema.properties))Me.add(Jn)}return Object.keys(ve).some(hn=>!Me.has(hn))},[P,we,L.revision]),Vs=b.useMemo(()=>{const ve=_u(P?.auth_schema),Me=P?.auth_schema?.methods??[];return ve.length===0&&Me.length>0&&Me.every(Be=>Be.type==="none")},[P]),C0=b.useMemo(()=>!Vs||!P||!Nn?null:o.find(ve=>ve.connector_key===P.key&&ve.created_by===Nn)??null,[Vs,P,Nn,o]),qr=b.useCallback(ve=>Object.fromEntries(Object.entries(ve).filter(([,Me])=>typeof Me=="string"&&Me.trim().length>0).map(([Me,Be])=>[Me,String(Be).trim()])),[]),j1=ve=>{d.begin(async()=>({connect_url:ve}))},tr=b.useCallback(async ve=>{if(!(!P||!we))try{const Me=await y.mutateAsync({connector_key:P.key,profile_kind:ve.profileKind,display_name:ve.displayName,slug:ve.slug||void 0,...ve.credentials?{credentials:ve.credentials}:{},...ve.authData?{auth_data:ve.authData}:{},...ve.requestedScopes?{requested_scopes:ve.requestedScopes}:{}});await ve.onSuccess(Me)}catch(Me){Oe(Me instanceof Error?Me.message:"Failed to create auth profile")}},[we,y,P]),A0=b.useCallback(async()=>{if(!wa.canSubmit||!we||we.type!=="env_keys")return;const ve=qr(xn);await tr({profileKind:"env",displayName:bt.trim()||`${P?.name} Auth`,slug:kn.trim(),credentials:ve,onSuccess:Me=>{de(Me.auth_profile.slug),De(!1),Ye(""),Qt("")}})},[we,tr,bt,kn,xn,wa.canSubmit,qr,P?.name]),Xn=b.useCallback(async()=>{if(!Ht.canSubmit||!we||we.type!=="oauth")return;const ve=qr(Vi);await tr({profileKind:"oauth_app",displayName:Ot.trim()||`${P?.name} ${we.provider} App`,slug:va.trim(),credentials:ve,onSuccess:Me=>{Re(Me.auth_profile.slug),ln(!1),Jt(""),Nt("")}})},[we,tr,Ot,va,Vi,Ht.canSubmit,qr,P?.name]),mc=async()=>{if(!(!P||we?.type!=="oauth")){if(!pe){Oe("Choose an OAuth app before connecting your account.");return}Oe(null),await d.begin(async()=>{const ve=await y.mutateAsync({connector_key:P.key,profile_kind:"oauth_account",display_name:lt.trim()||`${P.name} ${we.provider} Account`,slug:me.trim()||void 0,app_auth_profile_slug:pe,requested_scopes:I8(we,Ie)}),Me=ve.auth_profile?.slug??ve.pending_slug;return Me&&de(Me),At(!1),ie(""),Ne(""),{...ve,status:ve.auth_profile?.status}})}},O1=b.useCallback(async()=>{!we||we.type!=="browser"||await tr({profileKind:"browser_session",displayName:Kt.trim()||`${P?.name||"Connector"} Browser Session`,slug:Gt.trim(),onSuccess:ve=>{ve.auth_profile?.slug&&de(ve.auth_profile.slug),Ut(!1),Et(""),rt("")}})},[we,tr,Kt,Gt,P?.name]),gc=async()=>{if(P){if(!L.canSubmit){Oe("Reload the latest connection values before saving.");return}gr(!0),Oe(null);try{const ve={...h2(B),...O};let Me,Be;if(we?.type==="env_keys"&&(Me=oe?.trim()||void 0,!Me))throw new Error("Select or create an auth profile before creating the connection.");if(we?.type==="oauth"){if(Me=oe?.trim()||void 0,Be=pe?.trim()||void 0,!Be)throw new Error(`Select or create an ${we.provider} app profile first.`);if(!Me)throw new Error(`Select or create an ${we.provider} account profile first.`)}if(we?.type==="browser"&&(Me=oe?.trim()||void 0,!Me))throw new Error("Select or create a browser auth profile before creating the connection.");if(Zn&&!zt)throw new Error(Ma.length===0?`No device with the "${Zn}" permission. Open the Lobu app on a device and grant it, then refresh.`:"Choose a device to run this connector on.");if(C){const hn=a.device_worker_id??void 0;await p.mutateAsync({connection_id:a.id,display_name:J||void 0,auth_profile_slug:we?.type==="oauth"||we?.type==="env_keys"||we?.type==="browser"?Me??void 0:we?.type==="none"?null:void 0,app_auth_profile_slug:we?.type==="oauth"?Be??void 0:we?.type==="none"?null:void 0,config:Object.keys(ve).length>0?ve:void 0,device_worker_id:zt===hn?void 0:zt??null}),Eo(!1)}else{const hn=await c.mutateAsync({connector_key:P.key,display_name:J||void 0,auth_profile_slug:we?.type==="none"?null:Me,app_auth_profile_slug:we?.type==="none"?null:Be,config:Object.keys(ve).length>0?ve:void 0,created_by:Nn,device_worker_id:zt??null});hn.auth_run_id?It(hn.auth_run_id):Eo(!1)}}catch(ve){Oe(ve instanceof Error?ve.message:C?"Failed to update connection":"Failed to create connection")}finally{gr(!1)}}},Ro=ve=>{ae(ve),de(void 0),Re(void 0),De(!1),ln(!1),At(!1),Ut(!1),Ve([])},N1=async(ve,Me)=>{try{await k.mutateAsync(ve),q(null),Me==="app"?Re(""):de("")}catch(Be){Oe(Be instanceof Error?Be.message:`Failed to delete ${Me==="app"?"app":"auth"} profile`)}},T1=async ve=>{Oe(null);const Me=et.find(hn=>hn.slug===ve),Be=Me?.status==="pending_auth"&&!Me.granted_scopes?.length;await d.begin(()=>v.mutateAsync({auth_profile_slug:ve,app_auth_profile_slug:Be?pe:void 0,requested_scopes:I8(we?.type==="oauth"?we:null,Ie)}))};return{configDraft:L,runtimeDraft:wa,appDraft:Ht,createAuthProfile:y,deleteAuthProfileMutation:k,reconnectAuthProfile:v,deleteConnection:A,installConnectorMutation:j,connectorDefs:w,isLoadingDefs:S,isEditMode:C,showDeleteConfirm:N,setShowDeleteConfirm:I,confirmingDeleteProfileSlug:T,setConfirmingDeleteProfileSlug:q,showInstallForm:R,setShowInstallForm:H,installSourceUrl:D,setInstallSourceUrl:G,installError:$,setInstallError:X,installingConnectorKey:Ir,searchQuery:F,setSearchQuery:W,previewConnector:E1,handleInstallPreviewedConnector:R1,clearPreview:yc,selectedConnector:P,displayName:J,setDisplayName:se,configValues:B,createActionConfig:O,setCreateActionConfig:ee,selectedAuthMethodIndex:Q,selectedAuthProfileSlug:oe,setSelectedAuthProfileSlug:de,selectedAppAuthProfileSlug:pe,setSelectedAppAuthProfileSlug:Re,showNewRuntimeProfileForm:Pe,setShowNewRuntimeProfileForm:De,newRuntimeProfileName:bt,setNewRuntimeProfileName:Ye,newRuntimeProfileSlug:kn,setNewRuntimeProfileSlug:Qt,newRuntimeProfileValues:xn,setNewRuntimeProfileValues:Mo,showNewAppProfileForm:Xt,setShowNewAppProfileForm:ln,newAppProfileName:Ot,setNewAppProfileName:Jt,newAppProfileSlug:va,setNewAppProfileSlug:Nt,newAppProfileValues:Vi,setNewAppProfileValues:_0,showNewOAuthAccountForm:Wn,setShowNewOAuthAccountForm:At,newOAuthAccountName:lt,setNewOAuthAccountName:ie,newOAuthAccountSlug:me,setNewOAuthAccountSlug:Ne,showNewBrowserProfileForm:vn,setShowNewBrowserProfileForm:Ut,newBrowserProfileName:Kt,setNewBrowserProfileName:Et,newBrowserProfileSlug:Gt,setNewBrowserProfileSlug:rt,isSaving:wo,saveError:za??d.error,authorizationUrl:d.continueUrl,setSaveError:Oe,pendingAuthRunId:St,setPendingAuthRunId:It,authProfiles:et,selectableMethods:Cn,activeMethod:we,runtimeEnvProfiles:un,runtimeOAuthProfiles:Yt,appOAuthProfiles:ba,browserProfiles:Tn,runtimeProfileSchema:Hi,appProfileSchema:Ds,availableOAuthOptionalScopes:Is,selectedOAuthOptionalScopes:Ie,setSelectedOAuthOptionalScopes:Ve,hasUniqueOptionsFields:Qn,connections:o,isNoAuthConnector:Vs,existingNoAuthConnection:C0,selectedMemberUserId:Nn,setSelectedMemberUserId:cn,isAdmin:qt,devices:Fi,deviceOptions:Ma,lockedDeviceWorkerIdFromProfile:Co,requiredCapability:Zn,selectedDeviceWorkerId:zt,setSelectedDeviceWorkerId:xa,refreshDevices:So,devicesRefreshing:_o,handleOpenChange:Eo,handleConnectorSelect:qs,handleBack:Hs,handleValuesChange:V,normalizeStringValues:qr,navigateOAuthPopup:j1,handleCreateRuntimeProfile:A0,handleCreateAppProfile:Xn,handleCreateOAuthAccountProfile:mc,handleCreateBrowserProfile:O1,handleSave:gc,handleMethodChange:Ro,handleDeleteAuthProfile:N1,handleReconnect:T1}}const J7e=["all","data","chat","actions","inference","runtime","device"],V8={data:!1,chat:!1,actions:!1,audience:!1,inference:!0,runtime:!1},F8="__create_oauth_app_profile__",B8="__create_oauth_account_profile__",$8="__create_browser_profile__",Qy="__serverless__",U8="__add_device__",LE=p7e(),Xy=`${LE}/connect/oauth/callback`;function e9e({method:e}){const[t,n]=b.useState(!1),a=e.setupInstructions||e.description,o=a?a.replace(/\{\{redirect_uri\}\}/g,Xy):null;return h.jsxs("div",{className:"space-y-2 rounded-md border bg-muted/30 p-3",children:[o&&h.jsx("p",{className:"text-xs text-muted-foreground",children:o}),h.jsxs("div",{className:"space-y-1",children:[h.jsx("p",{className:"text-xs font-medium text-muted-foreground",children:"Redirect URI"}),h.jsxs("div",{className:"flex items-center gap-1.5",children:[h.jsx("code",{className:"flex-1 rounded bg-muted px-2 py-1 text-xs font-mono break-all",children:Xy}),h.jsx(ge,{type:"button",variant:"ghost",size:"sm",className:"h-7 w-7 shrink-0 p-0",onClick:()=>{navigator.clipboard.writeText(Xy),n(!0),setTimeout(()=>n(!1),2e3)},children:t?h.jsx(Za,{className:"h-3.5 w-3.5"}):h.jsx(Hu,{className:"h-3.5 w-3.5"})})]})]})]})}function t9e({connector:e,existingConnectionCount:t=0,onInstall:n,onBack:a,isInstalling:o,installError:s}){const l=u_(e.auth_schema),c=c_(e.runtime?.platforms),d=e.runtime?.scopes??[],{data:f=[]}=d1(),p=e.required_capability??null,y=p?f.find(_=>_.online&&_.capabilities.includes(p)):void 0,{inspectFeed:k,inspectAction:v}=WA(),w=e.feeds_schema??{},S=e.actions_schema??{};return h.jsxs("div",{className:"space-y-4",children:[h.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[h.jsx(ge,{variant:"ghost",size:"sm",onClick:a,className:"h-7 px-2 text-xs",children:"← Back"}),h.jsx(Ll,{connector:e,showDescription:!1,className:"gap-2"}),e.version&&h.jsxs(on,{variant:"secondary",className:"h-4 px-1.5 py-0 text-[10px] font-mono",children:["v",e.version]}),e.catalog_origin==="org"&&h.jsx(on,{variant:"secondary",className:"h-4 px-1.5 py-0 text-[10px]",children:"Org-installed"})]}),(c||e.required_capability||l.length>0||t>0)&&h.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[t>0&&h.jsxs(on,{variant:"secondary",className:"h-4 px-1.5 py-0 text-[10px]",children:[t," existing connection",t===1?"":"s"]}),c&&h.jsxs(on,{variant:"secondary",className:"h-4 gap-1 px-1.5 py-0 text-[10px]",children:[h.jsx(qg,{className:"h-2.5 w-2.5"}),"Requires ",c]}),e.required_capability&&h.jsxs(on,{variant:"secondary",className:"h-4 px-1.5 py-0 text-[10px]",children:["Needs ",e.required_capability]}),l.map(_=>h.jsx(on,{variant:"secondary",className:"h-4 px-1.5 py-0 text-[10px]",children:_},_))]}),e.description&&h.jsx("div",{className:ye(Yl,"p-3"),children:h.jsx("p",{className:"text-sm text-muted-foreground",children:e.description})}),(e.source_uri||d.length>0)&&h.jsxs("div",{className:"space-y-1 rounded-lg border bg-muted/30 p-3 text-xs",children:[e.source_uri&&h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsx("span",{className:"font-medium text-muted-foreground uppercase tracking-wider text-[10px]",children:"Source"}),h.jsxs("a",{href:e.source_uri,target:"_blank",rel:"noreferrer",className:"inline-flex items-center gap-1 break-all font-mono text-primary hover:underline",children:[e.source_uri,h.jsx(a1,{className:"h-3 w-3 shrink-0"})]})]}),d.length>0&&h.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[h.jsx("span",{className:"font-medium text-muted-foreground uppercase tracking-wider text-[10px]",children:"Scopes"}),d.map(_=>h.jsx(on,{variant:"secondary",className:"h-4 px-1.5 py-0 text-[10px] font-mono",children:_},_))]})]}),h.jsx(gE,{feedsSchema:w,onInspect:k}),h.jsx(kE,{actionsSchema:S,onInspect:v}),s&&h.jsx("div",{className:"rounded-md bg-red-50 dark:bg-red-950/30 p-3 text-sm text-red-600 dark:text-red-400",children:s}),e.required_capability?y?h.jsxs("div",{className:"space-y-2",children:[h.jsxs("div",{className:"rounded-lg border bg-muted/30 px-3 py-2 text-sm text-muted-foreground",children:["Connected on this Mac",y.last_seen_at?` · last seen ${k1(y.last_seen_at)}`:""]}),h.jsxs(ge,{variant:"secondary",onClick:()=>{window.location.href=Fh("sync")},className:"w-full",children:[h.jsx(M2,{className:"mr-2 h-4 w-4"}),"Sync now"]})]}):h.jsxs(ge,{onClick:()=>{window.location.href=Fh(`grant/${e.required_capability}`)},className:"w-full",children:[h.jsx(Hg,{className:"mr-2 h-4 w-4"}),"Connect on this Mac"]}):h.jsx(ge,{onClick:n,disabled:o,className:"w-full",children:o?h.jsxs(h.Fragment,{children:[h.jsx(dt,{size:"lg",className:"mr-2"}),"Installing..."]}):"Install & Configure"})]})}function n9e({connector:e,actionConfig:t,onActionConfigChange:n}){const{data:a=[]}=M0e(e.installed?e.key:null),o=yE(t),{inspectFeed:s,inspectAction:l}=WA(),c=p=>{n({...t,action_modes:p})},d=e.feeds_schema??{},f=e.actions_schema??{};return h.jsxs(h.Fragment,{children:[h.jsx(gE,{feedsSchema:d,onInspect:s}),a.length>0?h.jsx(M7e,{operations:a,modes:o,onChange:c,onInspect:p=>{const y=f[p.operation_key];y&&l(p.operation_key,y)}}):h.jsx(kE,{actionsSchema:f,onInspect:l})]})}function a9e({connection:e,activeAuthRunId:t,onStart:n,onClear:a,onRecover:o,isStarting:s}){const{data:l}=N0e(t==null?e.id:null);b.useEffect(()=>{const k=l?.run_id;t==null&&k&&o(k)},[t,l?.run_id,o]);const{data:c,isLoading:d}=z9(t),f=c?.status==="completed"||c?.status==="failed"||c?.status==="cancelled",p=e.status==="pending_auth"||e.status==="error"||e.auth_profile_status!=null&&e.auth_profile_status!=="active",y=t!=null&&!f;return h.jsxs("div",{className:"space-y-3 rounded-md border bg-background p-3",children:[h.jsx("p",{className:"text-xs text-muted-foreground",children:"This connector pairs interactively (e.g. QR code or device link). Artifacts are only shown to the person who initiates the pairing."}),!y&&h.jsx(ge,{type:"button",variant:p?"default":"outline",size:"sm",className:"h-8",disabled:s,onClick:n,children:s?h.jsxs(h.Fragment,{children:[h.jsx(dt,{size:"md",className:"mr-1.5"}),"Starting…"]}):p?"Pair device":"Reset pairing"}),y&&h.jsxs("div",{className:"space-y-3",children:[d&&!c&&h.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[h.jsx(dt,{size:"lg"})," Preparing…"]}),c&&!c.artifact&&!f&&h.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[h.jsx(dt,{size:"lg"})," Waiting for connector…"]}),c?.artifact&&!f&&t!=null&&h.jsx(uE,{artifact:c.artifact,runId:t}),h.jsxs("div",{className:"flex items-center justify-between gap-2",children:[h.jsx("span",{className:"text-xs text-muted-foreground",children:c?.status==="pending"?"Starting…":c?.status==="running"?"Waiting for you…":""}),h.jsx(ge,{type:"button",variant:"outline",size:"sm",className:"h-8",onClick:a,children:"Cancel"})]})]}),f&&c?.status==="completed"&&h.jsx("div",{className:"text-sm text-emerald-600",children:"Paired successfully."}),f&&c?.status==="failed"&&h.jsx("div",{className:"rounded-md border border-destructive/30 bg-destructive/5 p-2 text-sm text-destructive",children:c.error_message||"Authentication failed."})]})}function r9e({onClose:e,organizationId:t,editingConnection:n,connections:a=[],initialConnectorKey:o,ownerSlug:s,onDeepLinkBack:l}){const c=X7e({open:!0,onOpenChange:R=>{R||e()},organizationId:t,editingConnection:n,connections:a,initialConnectorKey:o,onDeepLinkBack:l}),d=P9(),f=qn(),{data:p=[]}=PMe(),{data:y,isLoading:k}=nfe({enabled:!!s}),[v,w]=b.useState("all"),[S,_]=b.useState(()=>jh(o??"")),C=!c.isEditMode&&c.activeMethod?.type==="app_installation",j=n?.device_worker_id?h.jsxs("p",{className:"text-xs text-muted-foreground",children:["Connected through"," ",n.device_worker_id&&s?h.jsx(Ct,{to:"/$owner/connectors/device/$deviceId",params:{owner:s,deviceId:n.device_worker_id},className:"text-foreground hover:underline",children:n.device_label||n.device_platform||"this device"}):h.jsx("span",{className:"text-foreground",children:n.device_label||n.device_platform||"this device"}),n.device_online===!1?" · offline":n.device_last_seen_at?` · last seen ${k1(n.device_last_seen_at)}`:""]}):null,N=h.jsxs("div",{className:"space-y-6 pb-6",children:[!c.selectedConnector&&c.previewConnector&&h.jsx(t9e,{connector:c.previewConnector,existingConnectionCount:a.filter(R=>R.connector_key===c.previewConnector?.key).length,onInstall:()=>{c.handleInstallPreviewedConnector().then(R=>{!R||!s||f({to:"/$owner/connectors/create/$connectorKey",params:{owner:s,connectorKey:R.key}})})},onBack:c.handleBack,isInstalling:c.installConnectorMutation.isPending,installError:c.installError}),S&&h.jsx(o9e,{providerKind:S,credentialFields:y?.providerCatalog.find(R=>R.id===S)?.credentialFields,isProviderCatalogLoading:k,ownerSlug:s??"",onBack:()=>_(null)}),!S&&!c.selectedConnector&&!c.previewConnector&&h.jsxs("div",{className:"space-y-3",children:[h.jsx("div",{className:ye(Yl,"w-full"),children:c.showInstallForm?h.jsxs("div",{className:"p-3 space-y-3",children:[h.jsx("p",{className:"text-sm font-medium",children:"Install from URL"}),h.jsx(Lt,{placeholder:"https://… (TypeScript source or MCP server URL)",value:c.installSourceUrl,onChange:R=>{c.setInstallSourceUrl(R.target.value),c.setInstallError(null)},className:"text-xs font-mono"}),h.jsx("p",{className:"text-xs text-muted-foreground",children:"URLs ending in .ts/.js are installed as source connectors. Other URLs are probed as MCP servers."}),c.installError&&h.jsx("p",{className:"text-xs text-destructive",children:c.installError}),h.jsxs("div",{className:"flex justify-end gap-2",children:[h.jsx(ge,{variant:"outline",size:"sm",className:"h-7 text-xs",onClick:()=>{c.setShowInstallForm(!1),c.setInstallSourceUrl(""),c.setInstallError(null)},children:"Cancel"}),h.jsxs(ge,{size:"sm",className:"h-7 text-xs",disabled:c.installConnectorMutation.isPending||!c.installSourceUrl.trim(),onClick:()=>{c.setInstallError(null);const R=c.installSourceUrl.trim(),H=/\.(ts|js|mjs)(\?|$)/i.test(R);c.installConnectorMutation.mutate(H?{source_url:R}:{mcp_url:R},{onSuccess:()=>{c.setShowInstallForm(!1),c.setInstallSourceUrl("")},onError:D=>{c.setInstallError(D instanceof Error?D.message:"Failed to install connector")}})},children:[c.installConnectorMutation.isPending?h.jsx(dt,{size:"sm",className:"mr-1"}):null,"Install"]})]})]}):h.jsxs("button",{type:"button",className:"flex items-center gap-3 p-3 w-full text-left text-muted-foreground hover:text-foreground transition-colors",onClick:()=>c.setShowInstallForm(!0),children:[h.jsx("div",{className:"h-8 w-8 rounded-full bg-muted flex items-center justify-center shrink-0",children:h.jsx(u7,{className:"h-4 w-4"})}),h.jsxs("div",{children:[h.jsx("p",{className:"text-sm font-medium",children:"Install Custom Connector"}),h.jsx("p",{className:"text-xs text-muted-foreground",children:"Install from a source file URL or MCP server URL"})]})]})}),h.jsxs("div",{className:"relative",children:[h.jsx(r1,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),h.jsx(Lt,{placeholder:"Search connectors...",value:c.searchQuery,onChange:R=>c.setSearchQuery(R.target.value),className:"pl-9"})]}),h.jsx("div",{className:"flex flex-wrap items-center gap-1.5",children:J7e.map(R=>h.jsx(ge,{type:"button",variant:v===R?"secondary":"ghost",size:"sm",className:"h-7 px-2 text-xs",onClick:()=>w(R),children:J8e[R]},R))}),!c.showInstallForm&&c.installError&&h.jsx("p",{className:"text-xs text-destructive",children:c.installError}),c.isLoadingDefs?h.jsx(Twe,{}):(()=>{const R=c.searchQuery.toLowerCase().trim(),H=new Map;for(const V of a)H.set(V.connector_key,(H.get(V.connector_key)??0)+1);const D=c.connectorDefs.filter(V=>!R||V.name.toLowerCase().includes(R)||V.key.toLowerCase().includes(R)||V.description?.toLowerCase().includes(R)?Wy({connector:V,facets:rwe(V)},v):!1).sort((V,O)=>V.name.localeCompare(O.name)),G=V=>V.installed||(H.get(V.key)??0)>0,$=D.filter(G),X=D.filter(V=>!G(V)),F=s?p.filter(V=>!R||V.displayName.toLowerCase().includes(R)||V.slug.toLowerCase().includes(R)?Wy({connector:{key:`${ci}${V.slug}`,name:V.displayName,auth_schema:null},facets:V8},v):!1).sort((V,O)=>V.displayName.localeCompare(O.displayName)):[],W=s?EMe(y?.availableProviders??[]).filter(V=>!R||V.name.toLowerCase().includes(R)||V.key.toLowerCase().includes(R)||V.description?.toLowerCase().includes(R)?Wy({connector:V,facets:og()},v):!1).sort((V,O)=>V.name.localeCompare(O.name)):[],P=s&&v==="all"?gv(s,kv()).filter(V=>!R||V.name.toLowerCase().includes(R)||V.tagline.toLowerCase().includes(R)):[],U=F.length+W.length+P.length,J=V=>(O,ee)=>{const Q=c.installConnectorMutation.isPending&&c.installingConnectorKey===O.key,ae=c_(O.runtime?.platforms),oe=u_(O.auth_schema);return h.jsxs("button",{type:"button",className:`flex w-full items-center gap-3 bg-card px-3 py-2.5 text-left text-muted-foreground transition-colors hover:bg-accent/50 hover:text-foreground disabled:cursor-not-allowed disabled:opacity-60 ${ee===V-1?"":"border-b"}`,onClick:()=>{if(s&&O.installed!==!1&&!jh(O.key)&&!O.key.startsWith(ci)){f({to:"/$owner/connectors/create/$connectorKey",params:{owner:s,connectorKey:O.key}});return}c.handleConnectorSelect(O)},disabled:c.installConnectorMutation.isPending&&c.installingConnectorKey!==O.key,children:[h.jsx(Ll,{connector:O,className:"min-w-0 flex-1"}),h.jsxs("div",{className:"flex shrink-0 flex-wrap items-center justify-end gap-1.5",children:[Q?h.jsxs(on,{variant:"secondary",className:"h-4 shrink-0 gap-1 px-1.5 py-0 text-[10px]",children:[h.jsx(dt,{size:"xs"}),"Installing"]}):null,ae&&h.jsxs(on,{variant:"secondary",className:"h-4 shrink-0 gap-1 px-1.5 py-0 text-[10px]",children:[h.jsx(qg,{className:"h-2.5 w-2.5"}),"Requires ",ae]}),oe.map(de=>h.jsx(on,{variant:"secondary",className:"h-4 shrink-0 px-1.5 py-0 text-[10px]",children:de},de)),O.login_enabled&&h.jsxs(on,{variant:"secondary",className:"h-4 shrink-0 gap-1 px-1.5 py-0 text-[10px]",children:[h.jsx(xm,{className:"h-2.5 w-2.5"}),"Login"]})]}),h.jsx(da,{className:"h-4 w-4 shrink-0 text-muted-foreground"})]},O.key)},se=(V,O)=>h.jsxs(Ct,{to:"/$owner/connectors/$connectorKey",params:{owner:s??"",connectorKey:`${ci}${V.slug}`},className:`flex w-full items-center gap-3 bg-card px-3 py-2.5 text-left text-muted-foreground transition-colors hover:bg-accent/50 hover:text-foreground ${O===F.length-1&&W.length+P.length===0?"":"border-b"}`,children:[h.jsx(Ll,{connector:{key:`${ci}${V.slug}`,name:V.displayName,iconUrl:V.iconUrl},className:"min-w-0 flex-1"}),h.jsx("div",{className:"flex shrink-0 flex-wrap items-center justify-end gap-1.5",children:h.jsx(Jm,{facets:V8})}),h.jsx(da,{className:"h-4 w-4 shrink-0 text-muted-foreground"})]},`${ci}${V.slug}`),L=(V,O)=>h.jsxs("button",{type:"button",onClick:()=>_(jh(V.key)??null),className:`flex w-full items-center gap-3 bg-card px-3 py-2.5 text-left text-muted-foreground transition-colors hover:bg-accent/50 hover:text-foreground ${O===W.length-1&&P.length===0?"":"border-b"}`,children:[h.jsx(Ll,{connector:V,className:"min-w-0 flex-1"}),h.jsxs("div",{className:"flex shrink-0 flex-wrap items-center justify-end gap-1.5",children:[h.jsx(Jm,{facets:og()}),h.jsx(on,{variant:"secondary",className:"h-4 shrink-0 px-1.5 py-0 text-[10px] text-muted-foreground",children:"Available"})]}),h.jsx(da,{className:"h-4 w-4 shrink-0 text-muted-foreground"})]},V.key),B=(V,O)=>h.jsxs(Ct,{to:"/$owner/connectors/app/$appId",params:{owner:s??"",appId:V.id},className:`flex w-full items-center gap-3 bg-card px-3 py-2.5 text-left text-muted-foreground transition-colors hover:bg-accent/50 hover:text-foreground ${O===P.length-1?"":"border-b"}`,children:[h.jsx("span",{className:"flex h-7 w-7 shrink-0 items-center justify-center rounded-md border border-dashed",children:V.icon}),h.jsxs("div",{className:"min-w-0 flex-1",children:[h.jsx("p",{className:"truncate text-sm font-medium",children:V.name}),h.jsx("p",{className:"truncate text-xs text-muted-foreground",children:V.tagline})]}),h.jsx(da,{className:"h-4 w-4 shrink-0 text-muted-foreground"})]},V.id);return D.length===0&&F.length===0&&W.length===0&&P.length===0?h.jsxs("div",{className:"space-y-3 py-4 text-center",children:[h.jsxs("div",{className:"space-y-1",children:[h.jsx("p",{className:"text-sm font-medium",children:R?`No connectors match "${c.searchQuery}"`:v!=="all"?"No connectors match this filter":"No connectors found"}),h.jsx("p",{className:"mx-auto max-w-sm text-xs text-muted-foreground",children:"Install a custom connector from URL, or create an agent that links the connector your workflow needs."})]}),s?h.jsx(ge,{asChild:!0,variant:"outline",size:"sm",children:h.jsxs(Ct,{to:`/${s}/agents`,search:{create:!0},children:[h.jsx(la,{className:"mr-2 h-4 w-4"}),"Create with an agent"]})}):null]}):h.jsxs("div",{className:"space-y-4",children:[$.length>0?h.jsxs("div",{className:"space-y-1.5",children:[h.jsx("h3",{className:"text-[11.5px] font-medium text-muted-foreground",children:"Already in this workspace"}),h.jsx("div",{className:"overflow-hidden rounded-lg border",children:$.map(J($.length))})]}):null,X.length+U>0?h.jsxs("div",{className:"space-y-1.5",children:[$.length>0?h.jsx("h3",{className:"text-[11.5px] font-medium text-muted-foreground",children:"From the catalog"}):null,h.jsxs("div",{className:"overflow-hidden rounded-lg border",children:[X.map(J(X.length+U)),F.map(se),W.map(L),P.map(B)]})]}):null]})})()]}),c.selectedConnector&&h.jsxs("div",{className:"space-y-4",children:[!c.isEditMode&&h.jsx(eg,{organizationId:t,connectorKey:c.selectedConnector.key}),h.jsxs("div",{className:"flex items-center gap-2",children:[!c.isEditMode&&h.jsx(ge,{variant:"ghost",size:"sm",onClick:c.handleBack,className:"h-7 px-2 text-xs",children:"← Back"}),h.jsx(Ll,{connector:c.selectedConnector,showDescription:!1,className:"gap-2"}),c.selectedConnector.version&&h.jsxs(on,{variant:"secondary",className:"text-[10px] px-1.5 py-0 h-4 font-mono",children:["v",c.selectedConnector.version]})]}),c.isEditMode&&n?.status==="pending_auth"&&n.connect_token&&h.jsxs("div",{className:"rounded-lg border border-amber-200 bg-amber-50 dark:border-amber-800 dark:bg-amber-950/30 p-4 space-y-3",children:[h.jsx("p",{className:"text-sm font-medium text-amber-900 dark:text-amber-200",children:"Authorization required"}),h.jsx("p",{className:"text-xs text-amber-700 dark:text-amber-300",children:"This connection is waiting for OAuth authorization to complete."}),h.jsxs(ge,{size:"sm",onClick:()=>{const R=`${LE}/connect/${n.connect_token}/oauth/start`;c.navigateOAuthPopup(R)},children:[h.jsx(a1,{className:"mr-1.5 h-3.5 w-3.5"}),"Authorize"]})]}),c.isEditMode&&n?.status==="pending_auth"&&n.auth_profile_kind==="browser_session"&&n.auth_profile_slug&&h.jsxs("div",{className:"rounded-lg border border-amber-200 bg-amber-50 dark:border-amber-800 dark:bg-amber-950/30 p-4 space-y-3",children:[h.jsx("p",{className:"text-sm font-medium text-amber-900 dark:text-amber-200",children:"Browser auth required"}),h.jsx("p",{className:"text-xs text-amber-700 dark:text-amber-300",children:"Capture or refresh the browser session for this auth profile, then the connection will resume automatically."}),h.jsx("p",{className:"text-xs text-muted-foreground",children:"Follow the connector’s authorization instructions to refresh this session."})]}),!C&&(c.requiredCapability||c.deviceOptions.length>0)&&h.jsxs("div",{className:"space-y-2",children:[h.jsxs("div",{className:"flex items-center justify-between gap-2",children:[h.jsxs("label",{className:"text-sm font-medium",children:["Run on",c.requiredCapability?h.jsx("span",{className:"text-destructive ml-1",children:"*"}):h.jsx("span",{className:"text-xs font-normal text-muted-foreground ml-1",children:"(optional)"})]}),h.jsx("div",{className:"flex items-center gap-3",children:h.jsxs("button",{type:"button",onClick:()=>void c.refreshDevices(),disabled:c.devicesRefreshing,className:"inline-flex items-center gap-1 text-xs text-muted-foreground hover:text-foreground disabled:opacity-50",children:[h.jsx(M2,{className:`h-3 w-3 ${c.devicesRefreshing?"animate-spin":""}`}),"Refresh"]})})]}),h.jsxs(si,{value:c.selectedDeviceWorkerId??(c.requiredCapability?"":Qy),onValueChange:R=>{if(R===U8){s&&f({to:"/$owner/connectors/create",params:{owner:s}});return}c.setSelectedDeviceWorkerId(R===Qy?void 0:R)},disabled:!!c.lockedDeviceWorkerIdFromProfile,children:[h.jsx(io,{className:"h-8",children:h.jsx(li,{placeholder:"Select a device"})}),h.jsxs(so,{children:[!c.requiredCapability&&h.jsx(Bn,{value:Qy,children:"Serverless (default)"}),c.deviceOptions.map(R=>h.jsx(TA,{device:R},R.id)),s?h.jsx(Bn,{value:U8,children:h.jsxs("span",{className:"flex items-center gap-2 text-muted-foreground",children:[h.jsx(la,{className:"h-3.5 w-3.5"}),"Add device"]})}):null]})]}),c.requiredCapability&&c.deviceOptions.length===0?h.jsxs("p",{className:"text-xs text-muted-foreground",children:["No device has granted the “",f_[c.requiredCapability]??c.requiredCapability,"” permission. Open the Lobu app on a device and grant it, then"," ",h.jsx("button",{type:"button",onClick:()=>void c.refreshDevices(),className:"underline hover:text-foreground",children:"refresh"}),"."]}):c.selectedDeviceWorkerId?h.jsx("p",{className:"text-xs text-muted-foreground",children:"Syncs and actions run on this device — with its credentials and network, not the Lobu server."}):h.jsx("p",{className:"text-xs text-muted-foreground",children:"Runs serverless, in the Lobu server."})]}),c.isEditMode&&n?.has_operations&&h.jsx("div",{className:"rounded-lg border bg-muted/30 p-4 space-y-4",children:h.jsx(Z7e,{connection:n})}),!C&&!c.isEditMode&&h.jsx(n9e,{connector:c.selectedConnector,actionConfig:c.createActionConfig,onActionConfigChange:c.setCreateActionConfig}),c.selectableMethods.length>0&&h.jsxs("section",{className:"space-y-3",children:[h.jsx("p",{className:"text-xs font-medium uppercase tracking-wide text-muted-foreground",children:"Authentication"}),c.selectableMethods.length>1?h.jsx("div",{className:"flex gap-2",children:c.selectableMethods.map((R,H)=>h.jsx("button",{type:"button",onClick:()=>c.handleMethodChange(H),className:`rounded-md border px-3 py-1.5 text-sm transition-colors ${c.selectedAuthMethodIndex===H?"border-primary bg-primary/10 text-foreground":"border-border bg-background text-muted-foreground hover:text-foreground"}`,children:Oh(R)},`${R.type}-${Oh(R)}`))}):h.jsx("p",{className:"text-xs text-muted-foreground",children:Oh(c.selectableMethods[0])}),c.activeMethod?.type!=="none"&&c.activeMethod?.description&&h.jsx("p",{className:"text-xs text-muted-foreground",children:c.activeMethod.description}),c.activeMethod?.type==="app_installation"&&h.jsxs("div",{className:"space-y-3",children:[c.activeMethod.permissions&&c.activeMethod.permissions.length>0&&h.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[h.jsx("span",{className:"text-[10px] font-medium uppercase tracking-wider text-muted-foreground",children:"Grants"}),c.activeMethod.permissions.map(R=>h.jsx(on,{variant:"secondary",className:"h-4 px-1.5 py-0 text-[10px]",children:R},R))]}),h.jsx(Xm,{organizationId:t,connectorKey:c.selectedConnector.key,provider:c.activeMethod.provider,providerLabel:c.selectedConnector?.name,installShape:c.activeMethod.installShape,variant:"default",size:"default",className:"w-full",label:`Install ${c.selectedConnector?.name??"App"}`}),h.jsxs("p",{className:"text-xs text-muted-foreground",children:["You'll be sent to"," ",c.activeMethod.provider.charAt(0).toUpperCase()+c.activeMethod.provider.slice(1)," ","to choose what to grant. The connection and its feeds are created automatically when you return."]})]}),c.activeMethod?.type==="env_keys"&&h.jsxs("div",{className:"space-y-3",children:[h.jsxs("div",{className:"space-y-2",children:[h.jsx("p",{className:"text-xs font-medium text-muted-foreground",children:"Auth Profile"}),h.jsxs("div",{className:"flex gap-1.5",children:[h.jsxs(si,{value:c.selectedAuthProfileSlug,onValueChange:c.setSelectedAuthProfileSlug,children:[h.jsx(io,{className:"h-8 flex-1 min-w-0",children:h.jsx(li,{placeholder:"Select auth profile"})}),h.jsx(so,{children:c.runtimeEnvProfiles.map(R=>h.jsxs(Bn,{value:R.slug,children:[R.display_name," (",R.slug,")"]},R.slug))})]}),c.selectedAuthProfileSlug&&(c.confirmingDeleteProfileSlug===c.selectedAuthProfileSlug?h.jsxs("div",{className:"flex items-center gap-1 shrink-0",children:[h.jsx(ge,{type:"button",variant:"destructive",size:"sm",className:"h-8 text-xs px-2",disabled:c.deleteAuthProfileMutation.isPending,onClick:()=>void c.handleDeleteAuthProfile(c.selectedAuthProfileSlug,"env"),children:c.deleteAuthProfileMutation.isPending?h.jsx(dt,{size:"sm"}):"Delete"}),h.jsx(ge,{type:"button",variant:"ghost",size:"sm",className:"h-8 text-xs px-2",onClick:()=>c.setConfirmingDeleteProfileSlug(null),children:"Cancel"})]}):h.jsx(ge,{type:"button",variant:"ghost",size:"sm",className:"h-8 w-8 p-0 shrink-0 text-muted-foreground hover:text-destructive",onClick:()=>c.setConfirmingDeleteProfileSlug(c.selectedAuthProfileSlug),children:h.jsx(ui,{className:"h-3.5 w-3.5"})}))]}),c.runtimeEnvProfiles.length===0&&h.jsx("p",{className:"text-xs text-muted-foreground",children:"No auth profiles yet for this connector."})]}),h.jsxs(ge,{type:"button",variant:"outline",size:"sm",className:"h-8",onClick:()=>c.setShowNewRuntimeProfileForm(R=>!R),children:[h.jsx(la,{className:"mr-1.5 h-3.5 w-3.5"}),c.showNewRuntimeProfileForm?"Hide New Profile":"Create Auth Profile"]}),c.showNewRuntimeProfileForm&&h.jsxs("div",{className:"space-y-3 rounded-md border bg-background p-3",children:[h.jsx(Lt,{placeholder:"Profile name",value:c.newRuntimeProfileName,onChange:R=>c.setNewRuntimeProfileName(R.target.value)}),h.jsx(Lt,{placeholder:"profile-slug (optional)",value:c.newRuntimeProfileSlug,onChange:R=>c.setNewRuntimeProfileSlug(R.target.value)}),c.runtimeDraft.revision&&h.jsxs(h.Fragment,{children:[h.jsx(xs,{visible:c.runtimeDraft.hasConflict,onReload:c.runtimeDraft.reset}),h.jsx(bi,{schema:c.runtimeDraft.revision,values:c.newRuntimeProfileValues,onValuesChange:c.setNewRuntimeProfileValues,fieldIdPrefix:"new-runtime-profile-"})]}),h.jsxs("div",{className:"flex justify-end gap-2",children:[h.jsx(ge,{type:"button",variant:"ghost",size:"sm",onClick:()=>{c.setShowNewRuntimeProfileForm(!1),c.setNewRuntimeProfileName(""),c.setNewRuntimeProfileSlug(""),c.setNewRuntimeProfileValues({})},children:"Cancel"}),h.jsxs(ge,{type:"button",size:"sm",disabled:!c.runtimeDraft.canSubmit||c.createAuthProfile.isPending||Object.keys(c.normalizeStringValues(c.newRuntimeProfileValues)).length===0,onClick:()=>void c.handleCreateRuntimeProfile(),children:[c.createAuthProfile.isPending?h.jsx(dt,{size:"md",className:"mr-1.5"}):null,"Create"]})]})]})]}),c.activeMethod?.type==="browser"&&h.jsxs("div",{className:"space-y-3",children:[h.jsxs("div",{className:"space-y-2",children:[h.jsx("p",{className:"text-xs font-medium text-muted-foreground",children:"Browser Auth Profile"}),h.jsxs("div",{className:"flex gap-1.5",children:[h.jsxs(si,{value:c.selectedAuthProfileSlug,onValueChange:R=>{if(R===$8){c.setShowNewBrowserProfileForm(!0);return}c.setSelectedAuthProfileSlug(R),c.setShowNewBrowserProfileForm(!1)},children:[h.jsx(io,{className:"h-8 flex-1 min-w-0",children:h.jsx(li,{placeholder:"Select browser auth profile"})}),h.jsxs(so,{children:[h.jsxs(Bn,{value:$8,children:[h.jsx(la,{className:"mr-1.5 inline h-3.5 w-3.5"}),"Create new browser profile"]}),c.browserProfiles.map(R=>{const H=R.device_worker_id?c.devices.find(D=>D.id===R.device_worker_id)?.label:null;return h.jsxs(Bn,{value:R.slug,children:[R.display_name," (",R.slug,")",H?` — on ${H}`:""]},R.slug)})]})]}),c.selectedAuthProfileSlug&&(c.confirmingDeleteProfileSlug===c.selectedAuthProfileSlug?h.jsxs("div",{className:"flex items-center gap-1 shrink-0",children:[h.jsx(ge,{type:"button",variant:"destructive",size:"sm",className:"h-8 text-xs px-2",disabled:c.deleteAuthProfileMutation.isPending,onClick:()=>void c.handleDeleteAuthProfile(c.selectedAuthProfileSlug,"browser"),children:c.deleteAuthProfileMutation.isPending?h.jsx(dt,{size:"sm"}):"Delete"}),h.jsx(ge,{type:"button",variant:"ghost",size:"sm",className:"h-8 text-xs px-2",onClick:()=>c.setConfirmingDeleteProfileSlug(null),children:"Cancel"})]}):h.jsx(ge,{type:"button",variant:"ghost",size:"sm",className:"h-8 w-8 p-0 shrink-0 text-muted-foreground hover:text-destructive",onClick:()=>c.setConfirmingDeleteProfileSlug(c.selectedAuthProfileSlug),children:h.jsx(ui,{className:"h-3.5 w-3.5"})}))]}),c.browserProfiles.length===0&&h.jsx("p",{className:"text-xs text-muted-foreground",children:"No browser auth profiles yet for this connector."})]}),c.selectedAuthProfileSlug&&(()=>{const R=c.browserProfiles.find(H=>H.slug===c.selectedAuthProfileSlug);return R?h.jsxs("div",{className:"space-y-2 rounded-md border bg-background p-3",children:[h.jsxs("div",{className:"flex flex-wrap gap-2",children:[h.jsx(on,{variant:R.status==="active"?"default":"secondary",children:R.status}),typeof R.cookie_count=="number"&&h.jsxs(on,{variant:"outline",children:[R.cookie_count," cookies"]}),R.auth_cookie_name&&h.jsx(on,{variant:"outline",children:R.auth_cookie_name})]}),h.jsx("p",{className:"text-xs text-muted-foreground",children:"Follow the connector’s authorization instructions to refresh this session."})]}):null})(),h.jsxs(ge,{type:"button",variant:"outline",size:"sm",className:"h-8",onClick:()=>c.setShowNewBrowserProfileForm(R=>!R),children:[h.jsx(la,{className:"mr-1.5 h-3.5 w-3.5"}),c.showNewBrowserProfileForm?"Hide New Profile":"Create Browser Profile"]}),c.showNewBrowserProfileForm&&h.jsxs("div",{className:"space-y-3 rounded-md border bg-background p-3",children:[h.jsx(Lt,{placeholder:"Profile name",value:c.newBrowserProfileName,onChange:R=>c.setNewBrowserProfileName(R.target.value)}),h.jsx(Lt,{placeholder:"profile-slug (optional)",value:c.newBrowserProfileSlug,onChange:R=>c.setNewBrowserProfileSlug(R.target.value)}),h.jsx("p",{className:"text-xs text-muted-foreground",children:"Create the session profile, then follow the connector’s authorization instructions."}),h.jsxs("div",{className:"flex justify-end gap-2",children:[h.jsx(ge,{type:"button",variant:"ghost",size:"sm",onClick:()=>{c.setShowNewBrowserProfileForm(!1),c.setNewBrowserProfileName(""),c.setNewBrowserProfileSlug("")},children:"Cancel"}),h.jsxs(ge,{type:"button",size:"sm",disabled:c.createAuthProfile.isPending,onClick:()=>void c.handleCreateBrowserProfile(),children:[c.createAuthProfile.isPending?h.jsx(dt,{size:"md",className:"mr-1.5"}):null,"Create"]})]})]})]}),c.activeMethod?.type==="interactive"&&c.isEditMode&&n&&n.auth_profile_kind==="interactive"&&h.jsx(a9e,{connection:n,activeAuthRunId:c.pendingAuthRunId,onStart:()=>{d.mutate({connection_id:n.id},{onSuccess:R=>{c.setPendingAuthRunId(R.auth_run_id??null)}})},onClear:()=>c.setPendingAuthRunId(null),onRecover:R=>c.setPendingAuthRunId(R),isStarting:d.isPending}),c.activeMethod?.type==="oauth"&&h.jsxs("div",{className:"space-y-4",children:[!c.isEditMode&&c.appOAuthProfiles.length>0&&c.selectedAppAuthProfileSlug?h.jsxs("div",{className:"space-y-1",children:[h.jsxs("div",{className:"flex items-center justify-between gap-2",children:[h.jsx("p",{className:"text-xs font-medium text-muted-foreground",children:"Workspace app"}),c.isAdmin&&s&&c.selectedConnector&&h.jsx(Ct,{to:"/$owner/connectors/$connectorKey",params:{owner:s,connectorKey:c.selectedConnector.key},search:{setup:"oauth_app"},hash:"connector-oauth-apps",className:"text-xs text-muted-foreground hover:text-foreground",children:"Manage app"})]}),c.appOAuthProfiles.length===1||!c.isAdmin?(()=>{const R=c.appOAuthProfiles.find(H=>H.slug===c.selectedAppAuthProfileSlug);return h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsx("p",{className:"text-sm",children:R?.display_name??"Ask an administrator to set the workspace-default app."}),R?.is_default_for_connector&&R.connector_key===c.selectedConnector?.key&&h.jsx("span",{className:"rounded-md bg-muted px-1.5 py-0.5 text-[10px] font-medium uppercase tracking-wide text-muted-foreground",children:"Org default"})]})})():h.jsxs(si,{value:c.selectedAppAuthProfileSlug,onValueChange:c.setSelectedAppAuthProfileSlug,children:[h.jsx(io,{className:"h-8",children:h.jsx(li,{placeholder:"Choose an app"})}),h.jsx(so,{children:c.appOAuthProfiles.map(R=>h.jsxs(Bn,{value:R.slug,children:[R.display_name,R.is_default_for_connector&&R.connector_key===c.selectedConnector?.key?" (default)":""]},R.slug))})]})]}):h.jsxs("div",{className:"space-y-2",children:[h.jsxs("div",{className:"flex items-center justify-between gap-2",children:[h.jsx("p",{className:"text-xs font-medium text-muted-foreground",children:"Workspace app"}),c.isAdmin&&s&&c.selectedConnector&&c.appOAuthProfiles.length>0&&h.jsx(Ct,{to:"/$owner/connectors/$connectorKey",params:{owner:s,connectorKey:c.selectedConnector.key},className:"text-xs text-muted-foreground hover:text-foreground",children:"Manage"})]}),h.jsxs("div",{className:"flex gap-1.5",children:[h.jsxs(si,{value:c.selectedAppAuthProfileSlug,onValueChange:R=>{if(R===F8){c.setShowNewAppProfileForm(!0);return}c.setSelectedAppAuthProfileSlug(R),c.setShowNewAppProfileForm(!1)},children:[h.jsx(io,{className:"h-8 flex-1 min-w-0",children:h.jsx(li,{placeholder:`Select ${c.activeMethod.provider} app profile`})}),h.jsxs(so,{children:[c.isAdmin&&h.jsxs(Bn,{value:F8,children:[h.jsx(la,{className:"mr-1.5 inline h-3.5 w-3.5"}),"Create new app profile"]}),c.appOAuthProfiles.map(R=>h.jsxs(Bn,{value:R.slug,children:[R.display_name," (",R.slug,")",R.is_default_for_connector&&R.connector_key===c.selectedConnector?.key?" — default":""]},R.slug))]})]}),c.selectedAppAuthProfileSlug&&(c.confirmingDeleteProfileSlug===c.selectedAppAuthProfileSlug?h.jsxs("div",{className:"flex items-center gap-1 shrink-0",children:[h.jsx(ge,{type:"button",variant:"destructive",size:"sm",className:"h-8 text-xs px-2",disabled:c.deleteAuthProfileMutation.isPending,onClick:()=>void c.handleDeleteAuthProfile(c.selectedAppAuthProfileSlug,"app"),children:c.deleteAuthProfileMutation.isPending?h.jsx(dt,{size:"sm"}):"Delete"}),h.jsx(ge,{type:"button",variant:"ghost",size:"sm",className:"h-8 text-xs px-2",onClick:()=>c.setConfirmingDeleteProfileSlug(null),children:"Cancel"})]}):h.jsx(ge,{type:"button",variant:"ghost",size:"sm",className:"h-8 w-8 p-0 shrink-0 text-muted-foreground hover:text-destructive",onClick:()=>c.setConfirmingDeleteProfileSlug(c.selectedAppAuthProfileSlug),children:h.jsx(ui,{className:"h-3.5 w-3.5"})}))]}),c.appOAuthProfiles.length===0&&h.jsx("p",{className:"text-xs text-muted-foreground",children:c.isAdmin?"To use your own app, configure its client credentials here. You can also use a managed app when available.":`Choose a managed option if available, or ask an admin to configure your own ${c.activeMethod.provider} app.`}),c.showNewAppProfileForm&&h.jsxs("div",{className:"space-y-3 rounded-md border bg-background p-3",children:[h.jsx(e9e,{method:c.activeMethod}),h.jsx(Lt,{placeholder:"App profile name",value:c.newAppProfileName,onChange:R=>c.setNewAppProfileName(R.target.value)}),h.jsx(Lt,{placeholder:"app-profile-slug (optional)",value:c.newAppProfileSlug,onChange:R=>c.setNewAppProfileSlug(R.target.value)}),c.appDraft.revision&&h.jsxs(h.Fragment,{children:[h.jsx(xs,{visible:c.appDraft.hasConflict,onReload:c.appDraft.reset}),h.jsx(bi,{schema:c.appDraft.revision,values:c.newAppProfileValues,onValuesChange:c.setNewAppProfileValues,fieldIdPrefix:"new-app-profile-"})]}),h.jsxs("div",{className:"flex justify-end gap-2",children:[h.jsx(ge,{type:"button",variant:"ghost",size:"sm",onClick:()=>{c.setShowNewAppProfileForm(!1),c.setNewAppProfileName(""),c.setNewAppProfileSlug(""),c.setNewAppProfileValues({})},children:"Cancel"}),h.jsxs(ge,{type:"button",size:"sm",disabled:!c.appDraft.canSubmit||c.createAuthProfile.isPending||Object.keys(c.normalizeStringValues(c.newAppProfileValues)).length===0,onClick:()=>void c.handleCreateAppProfile(),children:[c.createAuthProfile.isPending?h.jsx(dt,{size:"md",className:"mr-1.5"}):null,"Create"]})]})]})]}),h.jsxs("div",{className:"space-y-2",children:[h.jsx("p",{className:"text-xs font-medium text-muted-foreground",children:"Your account"}),h.jsxs("div",{className:"flex gap-1.5",children:[h.jsxs(si,{value:c.selectedAuthProfileSlug,onValueChange:R=>{if(R===B8){c.setShowNewOAuthAccountForm(!0);return}c.setSelectedAuthProfileSlug(R),c.setShowNewOAuthAccountForm(!1)},children:[h.jsx(io,{className:"h-8 flex-1 min-w-0",children:h.jsx(li,{placeholder:`Select ${c.activeMethod.provider} account profile`})}),h.jsxs(so,{children:[h.jsxs(Bn,{value:B8,children:[h.jsx(la,{className:"mr-1.5 inline h-3.5 w-3.5"}),"Add new account"]}),c.runtimeOAuthProfiles.map(R=>h.jsxs(Bn,{value:R.slug,children:[R.display_name," (",R.slug,") [",R.status,"]"]},R.slug))]})]}),c.selectedAuthProfileSlug&&(c.confirmingDeleteProfileSlug===c.selectedAuthProfileSlug?h.jsxs("div",{className:"flex items-center gap-1 shrink-0",children:[h.jsx(ge,{type:"button",variant:"destructive",size:"sm",className:"h-8 text-xs px-2",disabled:c.deleteAuthProfileMutation.isPending,onClick:()=>void c.handleDeleteAuthProfile(c.selectedAuthProfileSlug,"account"),children:c.deleteAuthProfileMutation.isPending?h.jsx(dt,{size:"sm"}):"Delete"}),h.jsx(ge,{type:"button",variant:"ghost",size:"sm",className:"h-8 text-xs px-2",onClick:()=>c.setConfirmingDeleteProfileSlug(null),children:"Cancel"})]}):h.jsx(ge,{type:"button",variant:"ghost",size:"sm",className:"h-8 w-8 p-0 shrink-0 text-muted-foreground hover:text-destructive",onClick:()=>c.setConfirmingDeleteProfileSlug(c.selectedAuthProfileSlug),children:h.jsx(ui,{className:"h-3.5 w-3.5"})}))]}),(()=>{const R=c.runtimeOAuthProfiles.find(H=>H.slug===c.selectedAuthProfileSlug);return h.jsxs("div",{className:"space-y-2",children:[h.jsx(dg,{requiredScopes:Qu(c.activeMethod),optionalScopes:c.availableOAuthOptionalScopes,selectedOptionalScopes:c.selectedOAuthOptionalScopes,grantedScopes:R?.granted_scopes,onToggleOptionalScope:(H,D)=>{c.setSelectedOAuthOptionalScopes(G=>D?[...new Set([...G,H])]:G.filter($=>$!==H))}}),R?h.jsxs(ge,{type:"button",variant:"outline",size:"sm",className:"h-8",disabled:c.reconnectAuthProfile.isPending,onClick:()=>void c.handleReconnect(R.slug),children:[c.reconnectAuthProfile.isPending?h.jsx(dt,{size:"md",className:"mr-1.5"}):h.jsx(xm,{className:"mr-1.5 h-3.5 w-3.5"}),"Review permissions"]}):null]})})(),c.runtimeOAuthProfiles.length===0&&h.jsx("p",{className:"text-xs text-muted-foreground",children:"No OAuth account profiles yet for this connector."}),c.showNewOAuthAccountForm&&h.jsxs("div",{className:"space-y-3 rounded-md border bg-background p-3",children:[h.jsx(Lt,{placeholder:"Account profile name",value:c.newOAuthAccountName,onChange:R=>c.setNewOAuthAccountName(R.target.value)}),h.jsx(Lt,{placeholder:"account-profile-slug (optional)",value:c.newOAuthAccountSlug,onChange:R=>c.setNewOAuthAccountSlug(R.target.value)}),h.jsx("p",{className:"text-xs text-muted-foreground",children:"Creating the profile will open the OAuth authorization page in a new tab. When it finishes, the profile becomes reusable for future connections."}),h.jsx(dg,{requiredScopes:Qu(c.activeMethod),optionalScopes:c.availableOAuthOptionalScopes,selectedOptionalScopes:c.selectedOAuthOptionalScopes,onToggleOptionalScope:(R,H)=>{c.setSelectedOAuthOptionalScopes(D=>H?[...new Set([...D,R])]:D.filter(G=>G!==R))}}),h.jsxs("div",{className:"flex justify-end gap-2",children:[h.jsx(ge,{type:"button",variant:"ghost",size:"sm",onClick:()=>{c.setShowNewOAuthAccountForm(!1),c.setNewOAuthAccountName(""),c.setNewOAuthAccountSlug("")},children:"Cancel"}),h.jsxs(ge,{type:"button",size:"sm",disabled:c.createAuthProfile.isPending,onClick:()=>void c.handleCreateOAuthAccountProfile(),children:[c.createAuthProfile.isPending?h.jsx(dt,{size:"md",className:"mr-1.5"}):null,"Continue"]})]})]})]})]})]}),!C&&h.jsxs("div",{className:"space-y-2",children:[h.jsx("label",{className:"text-sm font-medium",htmlFor:"conn-display-name",children:"Display Name"}),h.jsx(Lt,{id:"conn-display-name",placeholder:`e.g. Work ${c.selectedConnector.name}`,value:c.displayName,onChange:R=>c.setDisplayName(R.target.value)})]}),!C&&!c.isEditMode&&c.isAdmin&&h.jsxs("div",{className:"space-y-2",children:[h.jsxs("label",{className:"text-sm font-medium",children:["Assign to Member"," ",h.jsx("span",{className:"text-xs font-normal text-muted-foreground",children:"(optional)"})]}),h.jsx(_Me,{organizationId:t,value:c.selectedMemberUserId,onValueChange:c.setSelectedMemberUserId}),h.jsx("p",{className:"text-xs text-muted-foreground",children:c.selectedMemberUserId?"Only the selected member will use this connection.":"Leave empty to make this connection available to everyone in the organization."}),c.existingNoAuthConnection&&h.jsx("div",{className:"rounded-md bg-amber-50 dark:bg-amber-950/30 border border-amber-200 dark:border-amber-800 p-3",children:h.jsxs("p",{className:"text-xs text-amber-700 dark:text-amber-300",children:["This user already has a ",c.selectedConnector.name," ","connection. No-auth connectors are limited to one per user."]})})]}),c.hasUniqueOptionsFields&&h.jsxs("div",{className:"rounded-lg border bg-muted/30 p-4 space-y-3",children:[h.jsx("p",{className:"text-sm font-medium",children:"Connection Options"}),h.jsx(xs,{visible:c.configDraft.hasConflict,onReload:c.configDraft.reset}),h.jsx(bi,{schema:c.configDraft.revision??void 0,values:c.configValues,onValuesChange:c.handleValuesChange})]})]})]}),I=c.selectedConnector&&!c.previewConnector?h.jsxs(h.Fragment,{children:[c.authorizationUrl&&h.jsx("a",{className:"text-sm underline",href:c.authorizationUrl,target:"_blank",rel:"noreferrer",children:"Continue authorization in your browser"}),c.saveError&&h.jsx("div",{className:"w-full mb-3 rounded-md bg-red-50 dark:bg-red-950/30 p-3 text-sm text-red-600 dark:text-red-400",children:c.saveError}),h.jsxs("div",{className:"flex items-center w-full",children:[c.isEditMode&&h.jsx("div",{className:"mr-auto",children:c.showDeleteConfirm?h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsx(ge,{variant:"destructive",size:"sm",disabled:c.deleteConnection.isPending,onClick:()=>{const R=c.connectorDefs.find(H=>H.key===n.connector_key)?.required_capability;R&&(window.location.href=Fh(`revoke/${R}`)),c.deleteConnection.mutate(n.id,{onSuccess:()=>c.handleOpenChange(!1)})},children:c.deleteConnection.isPending?h.jsxs(h.Fragment,{children:[h.jsx(dt,{size:"md",className:"mr-1.5"}),"Deleting..."]}):"Confirm"}),h.jsx(ge,{variant:"outline",size:"sm",onClick:()=>c.setShowDeleteConfirm(!1),disabled:c.deleteConnection.isPending,children:"Cancel"})]}):h.jsxs(ge,{variant:"ghost",size:"sm",className:"text-destructive hover:text-destructive",onClick:()=>c.setShowDeleteConfirm(!0),children:[h.jsx(ui,{className:"mr-1.5 h-3.5 w-3.5"}),"Delete"]})}),!(!c.isEditMode&&c.activeMethod?.type==="app_installation")&&h.jsx(ge,{onClick:c.handleSave,disabled:!c.configDraft.canSubmit||c.isSaving||!!c.existingNoAuthConnection,children:c.isSaving?h.jsxs(h.Fragment,{children:[h.jsx(dt,{size:"lg",className:"mr-2"}),c.isEditMode?"Saving...":"Creating..."]}):c.isEditMode?h.jsx(h.Fragment,{children:"Save Changes"}):h.jsxs(h.Fragment,{children:[h.jsx(la,{className:"mr-2 h-4 w-4"}),"Add connection"]})})]})]}):null,T=I?h.jsx("div",{className:"mt-6",children:I}):null,q=h.jsx(s7e,{runId:c.activeMethod?.type==="interactive"?null:c.pendingAuthRunId,onClose:()=>{c.setPendingAuthRunId(null),c.isEditMode||c.handleOpenChange(!1)}});return h.jsxs(h.Fragment,{children:[j,N,T,q]})}function o9e({providerKind:e,credentialFields:t,isProviderCatalogLoading:n,ownerSlug:a,onBack:o}){const s=qn(),l=afe(),c=Zu(e);return h.jsxs("div",{className:"space-y-4",children:[h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsx(ge,{variant:"ghost",size:"sm",onClick:o,className:"h-7 px-2 text-xs",children:"← Back"}),h.jsx(Ll,{connector:{key:`${Vh}${e}`,name:c,favicon_domain:GA(e)},showDescription:!1,className:"gap-2"}),h.jsx(Jm,{facets:og()})]}),n?h.jsx(YA,{rows:4,className:"max-w-md"}):t?h.jsx(RMe,{providerKind:e,credentialFields:t,pending:l.isPending,onCancel:o,onCreate:d=>l.mutate(d,{onSuccess:f=>{const p=f?.sandbox?.id;s({to:p?"/$owner/connectors/$connectorKey":"/$owner/connectors",params:p?{owner:a,connectorKey:`sandbox:${p}`}:{owner:a}})}})}):h.jsx("p",{className:"rounded-md bg-destructive/10 px-3 py-2 text-sm text-destructive",children:"This runtime provider is not available from the gateway."})]})}function i9e({ownerSlug:e,organizationId:t,connections:n,initialConnectorKey:a}){const o=qn();return h.jsx(r9e,{onClose:()=>{o({to:"/$owner/connectors",params:{owner:e}})},organizationId:t,connections:n,initialConnectorKey:a,ownerSlug:e,onDeepLinkBack:a?()=>{o({to:"/$owner/connectors/$connectorKey",params:{owner:e,connectorKey:a}})}:void 0})}function s9e({owner:e,children:t}){const{data:n,isLoading:a,error:o}=gn(e,{slug:e}),{session:s,isReady:l}=Xa(),c=vz(o),d=xz(o)&&!c&&!n?.workspace;gfe({active:!a&&!d&&l&&!s&&!n?.workspace,owner:e});const f=n?.workspace;return a?h.jsx(h.Fragment,{children:t({organizationId:null,ownerSlug:e,isWorkspaceLoading:!0})}):d?h.jsxs("div",{role:"alert",className:"flex flex-col items-center justify-center gap-1 py-12 text-center",children:[h.jsx("p",{className:"text-muted-foreground",children:"This workspace could not be loaded."}),h.jsx("p",{className:"text-xs text-muted-foreground/70",children:"Please try again in a moment."})]}):c||!f?h.jsx("div",{className:"flex items-center justify-center py-12 text-muted-foreground",children:"Organization not found"}):f.type!=="organization"?h.jsx("div",{className:"flex flex-1 flex-col items-center justify-center gap-2 py-16 text-center",children:h.jsx("p",{className:"text-muted-foreground max-w-md",children:"Select an organization to view this page."})}):h.jsx(h.Fragment,{children:t({organizationId:f.id,ownerSlug:f.slug,isWorkspaceLoading:!1})})}const l9e=()=>Ee(()=>import("./create-BiHpu2f4.js"),[]),c9e=_e("/$owner/connectors/create")({component:Ae(l9e,"component")});function DEe({owner:e,initialConnectorKey:t}){return h.jsx(s9e,{owner:e,children:n=>h.jsx(u9e,{ownerSlug:n.ownerSlug,organizationId:n.organizationId,initialConnectorKey:t})})}function u9e({ownerSlug:e,organizationId:t,initialConnectorKey:n}){const{data:a=[]}=H2(t??"");return h.jsxs(rA,{className:"flex flex-1 flex-col gap-6",children:[h.jsx(jwe,{breadcrumb:h.jsx(Rwe,{crumbs:[h.jsx(Ct,{to:"/$owner/connectors",params:{owner:e},search:{},className:Ewe,children:"Connectors"},"connectors")]}),icon:h.jsx(zn.connectors.icon,{className:"h-6 w-6"}),title:"Add a connection",caption:"Pick a connector from the catalog or drop in an MCP URL — Lobu handles auth and brings the data into memory."}),t?h.jsx(i9e,{ownerSlug:e,organizationId:t,connections:a,initialConnectorKey:n}):h.jsx("div",{className:"max-w-3xl",children:h.jsx(YA,{rows:4})})]})}const d9e=()=>Ee(()=>import("./_agentId-DbTBU4KZ.js"),__vite__mapDeps([63,17,16,18,13,12,30])),h9e=_e("/$owner/chat/$agentId")({validateSearch:e=>{const t={};(e.new===!0||e.new==="1"||e.new==="true")&&(t.new=!0),typeof e.prompt=="string"&&e.prompt.length>0&&(t.prompt=e.prompt);const n=typeof e.message_id=="string"&&e.message_id.trim()||typeof e.message=="string"&&e.message.trim()||"";return n&&(t.message_id=n),Object.assign(t,uc(e)),t},loader:({context:{queryClient:e},params:t})=>{e.prefetchQuery(gn.queryOptions(t.owner,{slug:t.owner})),e.prefetchQuery(vo.queryOptions(t.owner))},component:Ae(d9e,"component")});function f9e(e){const t=n=>typeof e[n]=="string"?e[n]:void 0;return Dt({listen:t("listen"),platform:t("platform"),team:t("team"),label:t("label"),connection:t("connection"),resource_type:t("resource_type"),resource:t("resource"),events:t("events"),agent:t("agent")})}const p9e=()=>Ee(()=>import("./new-B8_sRMYD.js"),__vite__mapDeps([64,2,3,4,5,6,7,8,9,10,11,12,13])),y9e=_e("/$owner/automations/new")({loader:({context:{queryClient:e},params:t})=>{e.prefetchQuery(gn.queryOptions(t.owner,{slug:t.owner}))},validateSearch:e=>f9e(e),component:Ae(p9e,"component")});function zE(e){const t=typeof e=="string"?Number(e):e;if(!(typeof t!="number"||!Number.isInteger(t)||t<=0))return t}function IEe(e){return e.isReview?e.status==="pending"?"active":e.status==="gone"?"gone":e.isError?"error":"loading":"none"}function qEe(e){const t={};return e&&(typeof e.name=="string"&&(t.name=e.name),typeof e.description=="string"&&(t.description=e.description),typeof e.identity_md=="string"&&(t.identityMd=e.identity_md)),t}const m9e=()=>Ee(()=>import("./_automationId-C7dZzg6X.js"),__vite__mapDeps([65,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23]));function g9e(e){return e==="definition"?"definition":"activity"}const k9e=_e("/$owner/automations/$automationId")({loader:({context:{queryClient:e},params:t})=>{e.prefetchQuery(gn.queryOptions(t.owner,{slug:t.owner}))},validateSearch:e=>({run_id:zE(e.run_id),view:g9e(e.view)}),component:Ae(m9e,"component")}),v9e=()=>Ee(()=>import("./new-Df1q7GEj.js"),__vite__mapDeps([66,67,8])),x9e=_e("/$owner/agents/new")({component:Ae(v9e,"component")}),b9e=()=>Ee(()=>import("./connect-1ysEq9l0.js"),[]),w9e=_e("/$owner/agents/connect")({component:Ae(b9e,"component")}),M9e=()=>Ee(()=>import("./_agentId-BTmFhpb6.js"),__vite__mapDeps([68,69,67,8,14,15])),S9e=_e("/$owner/agents/$agentId")({beforeLoad:({params:e,location:t})=>{const n=`/${e.owner}/agents/${e.agentId}`;(t.pathname===n||t.pathname===`${n}/`)&&e6e(e.owner,e.agentId)},loader:({context:{queryClient:e},params:t})=>{e.prefetchQuery(gn.queryOptions(t.owner,{slug:t.owner})),e.prefetchQuery(vo.queryOptions(t.owner))},component:Ae(M9e,"component")}),_9e=()=>Ee(()=>import("./index-DlqjyZKQ.js"),__vite__mapDeps([70,71])),C9e=_e("/$owner/connectors/deployments/")({component:Ae(_9e,"component")}),A9e=()=>Ee(()=>import("./index-DYe_DVHa.js"),[]),E9e=_e("/$owner/connectors/create/")({validateSearch:e=>Dt({connector:typeof e.connector=="string"&&e.connector.length>0?e.connector:void 0,install:typeof e.install=="string"&&e.install.length>0?e.install:void 0}),component:Ae(A9e,"component")}),R9e=b.forwardRef(({className:e,...t},n)=>h.jsx("div",{className:"relative w-full overflow-auto",children:h.jsx("table",{ref:n,className:ye("w-full caption-bottom text-sm",e),...t})}));R9e.displayName="Table";const j9e=b.forwardRef(({className:e,...t},n)=>h.jsx("thead",{ref:n,className:ye("[&_tr]:border-b",e),...t}));j9e.displayName="TableHeader";const O9e=b.forwardRef(({className:e,...t},n)=>h.jsx("tbody",{ref:n,className:ye("[&_tr:last-child]:border-0",e),...t}));O9e.displayName="TableBody";const N9e=b.forwardRef(({className:e,...t},n)=>h.jsx("tr",{ref:n,className:ye("border-b transition-colors hover:bg-muted/50 data-[state=selected]:bg-muted",e),...t}));N9e.displayName="TableRow";const T9e=b.forwardRef(({className:e,...t},n)=>h.jsx("th",{ref:n,className:ye("h-10 px-4 text-left align-middle font-medium text-muted-foreground [&:has([role=checkbox])]:pr-0 [&>[role=checkbox]]:translate-y-[2px]",e),...t}));T9e.displayName="TableHead";const P9e=b.forwardRef(({className:e,...t},n)=>h.jsx("td",{ref:n,className:ye("p-4 align-middle [&:has([role=checkbox])]:pr-0 [&>[role=checkbox]]:translate-y-[2px]",e),...t}));P9e.displayName="TableCell";function L9e(e){const t=$Me(e);if(t!==null)return{kind:"inference",id:t};const n=AMe(e);if(n!==null)return{kind:"sandbox",id:n};const a=jh(e);return a!==null?{kind:"sandbox-provider",id:a}:{kind:"connector",id:null}}function z9e(e){return L9e(e).kind==="connector"}const D9e=()=>Ee(()=>import("./_connectorKey.index-D-0ZNsgM.js"),__vite__mapDeps([72,73,25,5,74,15])),I9e=_e("/$owner/connectors/$connectorKey/")({validateSearch:e=>Dt({setup:e.setup==="oauth_app"?"oauth_app":void 0,model:typeof e.model=="string"?e.model:void 0,reason:typeof e.reason=="string"?e.reason:void 0,agentId:typeof e.agentId=="string"?e.agentId:void 0}),loader:({context:{queryClient:e},params:t})=>{e.fetchQuery(gn.queryOptions(t.owner,{slug:t.owner})).then(n=>{const a=n?.workspace?.id;a&&z9e(t.connectorKey)&&(e.prefetchQuery(hk.queryOptions(a)),e.prefetchQuery(H2.queryOptions(a,{connectorKey:t.connectorKey})))}).catch(()=>{})},component:Ae(D9e,"component")}),q9e=()=>Ee(()=>import("./index-rrnUF981.js"),[]),H9e=_e("/$owner/chat/$agentId/")({component:Ae(q9e,"component")}),V9e=()=>Ee(()=>import("./index-Dv0huHrO.js"),__vite__mapDeps([75,76,56,20,31])),F9e=_e("/$owner/agents/connect/")({component:Ae(V9e,"component")}),B9e=()=>Ee(()=>import("./device._deviceId-CIe7taim.js"),__vite__mapDeps([77,78,74,15,25,5,51])),$9e=_e("/$owner/connectors/device/$deviceId")({validateSearch:e=>({connection:typeof e.connection=="number"?e.connection:typeof e.connection=="string"&&/^\d+$/.test(e.connection)?Number(e.connection):void 0,settings:e.settings===!0||e.settings==="true"?!0:void 0}),loader:({context:{queryClient:e}})=>e.prefetchQuery(d1.queryOptions()),component:Ae(B9e,"component")}),U9e=()=>Ee(()=>import("./_deploymentId-3LTMi0ZT.js"),__vite__mapDeps([79,71,23,11,12])),K9e=_e("/$owner/connectors/deployments/$deploymentId")({component:Ae(U9e,"component")}),G9e=()=>Ee(()=>import("./create._connectorKey-Qynix_hA.js"),[]),Y9e=_e("/$owner/connectors/create/$connectorKey")({component:Ae(G9e,"component")}),W9e=()=>Ee(()=>import("./app._appId-BXmITXO7.js"),__vite__mapDeps([80,51])),Z9e=_e("/$owner/connectors/app/$appId")({component:Ae(W9e,"component")}),Q9e=()=>Ee(()=>import("./_connectorKey._connectionId-NQf43Ew3.js"),__vite__mapDeps([81,78,74,15,25,5,73,24,4,51])),X9e=_e("/$owner/connectors/$connectorKey/$connectionId")({validateSearch:e=>Dt({settings:e.settings===!0||e.settings==="true"?!0:void 0,auth_result:e.auth_result==="connected"||e.auth_result==="cancelled"||e.auth_result==="failed"?e.auth_result:void 0,addFeed:e.addFeed===!0||e.addFeed==="true"?!0:void 0,feedId:typeof e.feedId=="number"?e.feedId:typeof e.feedId=="string"&&/^\d+$/.test(e.feedId)?Number(e.feedId):void 0}),loaderDeps:({search:{feedId:e}})=>({feedId:e}),loader:({context:{queryClient:e},params:t,deps:n})=>{e.fetchQuery(gn.queryOptions(t.owner,{slug:t.owner})).then(a=>{const o=a?.workspace?.id;o&&(e.prefetchQuery(H2.queryOptions(o,{connectorKey:t.connectorKey})),e.prefetchQuery(O9.queryOptions(o)),n.feedId!==void 0&&e.prefetchQuery(T9.queryOptions(Number(t.connectionId))))}).catch(()=>{})},component:Ae(Q9e,"component")}),J9e=()=>Ee(()=>import("./connected._clientId-ByH4etku.js"),__vite__mapDeps([82,20,31])),eSe=_e("/$owner/agents/connected/$clientId")({component:Ae(J9e,"component")}),tSe=()=>Ee(()=>import("./connect._clientId-BbMPs6l3.js"),__vite__mapDeps([83,76,56,20,31])),nSe=_e("/$owner/agents/connect/$clientId")({component:Ae(tSe,"component")}),aSe=()=>Ee(()=>import("./skills-MBZ5ilDK.js"),__vite__mapDeps([84,85,47,9])),rSe=_e("/$owner/agents/$agentId/skills")({component:Ae(aSe,"component")}),DE={validateSearch:e=>({run_id:zE(e.run_id)}),loader:({context:{queryClient:e},params:t})=>{e.prefetchQuery(gn.queryOptions(t.owner,{slug:t.owner})),e.prefetchQuery(vo.queryOptions(t.owner))}},oSe=()=>Ee(()=>import("./settings-FxbIvOhH.js"),__vite__mapDeps([86,69,67,8,14,15])),iSe=_e("/$owner/agents/$agentId/settings")({...DE,component:Ae(oSe,"component")}),sSe=()=>Ee(()=>import("./permissions-i7iwnE1a.js"),__vite__mapDeps([87,60,88])),lSe=_e("/$owner/agents/$agentId/permissions")({loader:({context:{queryClient:e},params:t})=>{e.prefetchQuery(gn.queryOptions(t.owner,{slug:t.owner})),e.prefetchQuery(vo.queryOptions(t.owner))},component:Ae(sSe,"component")}),cSe=()=>Ee(()=>import("./models-ooBIWFuB.js"),__vite__mapDeps([89,69,67,8,14,15])),uSe=_e("/$owner/agents/$agentId/models")({loader:({context:{queryClient:e},params:t})=>{e.prefetchQuery(gn.queryOptions(t.owner,{slug:t.owner})),e.prefetchQuery(vo.queryOptions(t.owner))},component:Ae(cSe,"component")}),dSe=()=>Ee(()=>import("./identity-DMfCjdBz.js"),__vite__mapDeps([90,69,67,8,14,15])),hSe=_e("/$owner/agents/$agentId/identity")({...DE,component:Ae(dSe,"component")}),fSe=()=>Ee(()=>import("./guardrails-9Mr6avxk.js"),[]),pSe=_e("/$owner/agents/$agentId/guardrails")({component:Ae(fSe,"component")}),ySe=()=>Ee(()=>import("./index-CkwwaMrx.js"),__vite__mapDeps([91,92,88,85,47,9,16,93,6])),mSe=_e("/$owner/agents/$agentId/skills/")({component:Ae(ySe,"component")}),gSe=()=>Ee(()=>import("./index-bKUccXCc.js"),__vite__mapDeps([94,95,8,88,16,93,6])),kSe=_e("/$owner/agents/$agentId/guardrails/")({component:Ae(gSe,"component")}),vSe=()=>Ee(()=>import("./_threadId-DtqBFgK5.js"),[]),xSe=_e("/$owner/chat/$agentId/c/$threadId")({validateSearch:e=>{const t={...uc(e)},n=typeof e.message_id=="string"&&e.message_id.trim()||typeof e.message=="string"&&e.message.trim()||"";return n&&(t.message_id=n),t},component:Ae(vSe,"component")}),bSe=()=>Ee(()=>import("./create-kAQa5_Q7.js"),__vite__mapDeps([96,92,88,85,47,9,16,93,6])),wSe=_e("/$owner/agents/$agentId/skills/create")({component:Ae(bSe,"component")}),MSe=()=>Ee(()=>import("./_skillKey-DhiGYYFq.js"),__vite__mapDeps([97,92,88,85,47,9,16,93,6])),SSe=_e("/$owner/agents/$agentId/skills/$skillKey")({component:Ae(MSe,"component")}),_Se=()=>Ee(()=>import("./create-C37QtjbJ.js"),__vite__mapDeps([98,95,8,88,16,93,6])),CSe=_e("/$owner/agents/$agentId/guardrails/create")({component:Ae(_Se,"component")}),ASe=()=>Ee(()=>import("./_name-BKeZbc-h.js"),__vite__mapDeps([99,95,8,88,16,93,6])),ESe=_e("/$owner/agents/$agentId/guardrails/$name")({component:Ae(ASe,"component")}),RSe=()=>Ee(()=>import("./_conversationId-F5YmyLV9.js"),__vite__mapDeps([100,16,17,18,13,12])),jSe=_e("/$owner/agents/$agentId/conversations/$conversationId")({component:Ae(RSe,"component")}),_n=s8e.update({id:"/$owner",path:"/$owner",getParentRoute:()=>ka}),OSe=c8e.update({id:"/",path:"/",getParentRoute:()=>ka}),NSe=d8e.update({id:"/",path:"/",getParentRoute:()=>_n}),TSe=f8e.update({id:"/slack/claim",path:"/slack/claim",getParentRoute:()=>ka}),PSe=y8e.update({id:"/orgs/new",path:"/orgs/new",getParentRoute:()=>ka}),LSe=k8e.update({id:"/oauth/device",path:"/oauth/device",getParentRoute:()=>ka}),zSe=x8e.update({id:"/oauth/consent",path:"/oauth/consent",getParentRoute:()=>ka}),DSe=w8e.update({id:"/auth/reset-password",path:"/auth/reset-password",getParentRoute:()=>ka}),ISe=S8e.update({id:"/auth/logout",path:"/auth/logout",getParentRoute:()=>ka}),qSe=C8e.update({id:"/auth/login",path:"/auth/login",getParentRoute:()=>ka}),HSe=E8e.update({id:"/auth/callback",path:"/auth/callback",getParentRoute:()=>ka}),VSe=j8e.update({id:"/auth/accept-invitation",path:"/auth/accept-invitation",getParentRoute:()=>ka}),FSe=N8e.update({id:"/account/settings",path:"/account/settings",getParentRoute:()=>ka}),BSe=P8e.update({id:"/recent",path:"/recent",getParentRoute:()=>_n}),Ii=z8e.update({id:"/connectors",path:"/connectors",getParentRoute:()=>_n}),w0=I8e.update({id:"/automations",path:"/automations",getParentRoute:()=>_n}),fc=H8e.update({id:"/agents",path:"/agents",getParentRoute:()=>_n}),$Se=$8e.update({id:"/$",path:"/$",getParentRoute:()=>_n}),USe=Y8e.update({id:"/memory/",path:"/memory/",getParentRoute:()=>_n}),KSe=Z8e.update({id:"/members/",path:"/members/",getParentRoute:()=>_n}),GSe=X8e.update({id:"/events/",path:"/events/",getParentRoute:()=>_n}),YSe=iwe.update({id:"/",path:"/",getParentRoute:()=>Ii}),WSe=lwe.update({id:"/chat/",path:"/chat/",getParentRoute:()=>_n}),ZSe=uwe.update({id:"/",path:"/",getParentRoute:()=>w0}),QSe=hwe.update({id:"/",path:"/",getParentRoute:()=>fc}),XSe=pwe.update({id:"/$entityType/",path:"/$entityType/",getParentRoute:()=>_n}),JSe=mwe.update({id:"/connector/$name/connection",path:"/connector/$name/connection",getParentRoute:()=>ka}),e_e=kwe.update({id:"/settings/organization",path:"/settings/organization",getParentRoute:()=>_n}),t_e=xwe.update({id:"/memory/$",path:"/memory/$",getParentRoute:()=>_n}),n_e=wwe.update({id:"/events/$",path:"/events/$",getParentRoute:()=>_n}),a_e=Mwe.update({id:"/entity-types/new",path:"/entity-types/new",getParentRoute:()=>_n}),r_e=_we.update({id:"/entity-types/$slug",path:"/entity-types/$slug",getParentRoute:()=>_n}),Sv=Awe.update({id:"/deployments",path:"/deployments",getParentRoute:()=>Ii}),_v=c9e.update({id:"/create",path:"/create",getParentRoute:()=>Ii}),Cv=h9e.update({id:"/chat/$agentId",path:"/chat/$agentId",getParentRoute:()=>_n}),o_e=y9e.update({id:"/new",path:"/new",getParentRoute:()=>w0}),i_e=k9e.update({id:"/$automationId",path:"/$automationId",getParentRoute:()=>w0}),s_e=x9e.update({id:"/new",path:"/new",getParentRoute:()=>fc}),Av=w9e.update({id:"/connect",path:"/connect",getParentRoute:()=>fc}),qi=S9e.update({id:"/$agentId",path:"/$agentId",getParentRoute:()=>fc}),l_e=C9e.update({id:"/",path:"/",getParentRoute:()=>Sv}),c_e=E9e.update({id:"/",path:"/",getParentRoute:()=>_v}),u_e=I9e.update({id:"/$connectorKey/",path:"/$connectorKey/",getParentRoute:()=>Ii}),d_e=H9e.update({id:"/",path:"/",getParentRoute:()=>Cv}),h_e=F9e.update({id:"/",path:"/",getParentRoute:()=>Av}),f_e=$9e.update({id:"/device/$deviceId",path:"/device/$deviceId",getParentRoute:()=>Ii}),p_e=K9e.update({id:"/$deploymentId",path:"/$deploymentId",getParentRoute:()=>Sv}),y_e=Y9e.update({id:"/$connectorKey",path:"/$connectorKey",getParentRoute:()=>_v}),m_e=Z9e.update({id:"/app/$appId",path:"/app/$appId",getParentRoute:()=>Ii}),g_e=X9e.update({id:"/$connectorKey/$connectionId",path:"/$connectorKey/$connectionId",getParentRoute:()=>Ii}),k_e=eSe.update({id:"/connected/$clientId",path:"/connected/$clientId",getParentRoute:()=>fc}),v_e=nSe.update({id:"/$clientId",path:"/$clientId",getParentRoute:()=>Av}),M0=rSe.update({id:"/skills",path:"/skills",getParentRoute:()=>qi}),x_e=iSe.update({id:"/settings",path:"/settings",getParentRoute:()=>qi}),b_e=lSe.update({id:"/permissions",path:"/permissions",getParentRoute:()=>qi}),w_e=uSe.update({id:"/models",path:"/models",getParentRoute:()=>qi}),M_e=hSe.update({id:"/identity",path:"/identity",getParentRoute:()=>qi}),S0=pSe.update({id:"/guardrails",path:"/guardrails",getParentRoute:()=>qi}),S_e=mSe.update({id:"/",path:"/",getParentRoute:()=>M0}),__e=kSe.update({id:"/",path:"/",getParentRoute:()=>S0}),C_e=xSe.update({id:"/c/$threadId",path:"/c/$threadId",getParentRoute:()=>Cv}),A_e=wSe.update({id:"/create",path:"/create",getParentRoute:()=>M0}),E_e=SSe.update({id:"/$skillKey",path:"/$skillKey",getParentRoute:()=>M0}),R_e=CSe.update({id:"/create",path:"/create",getParentRoute:()=>S0}),j_e=ESe.update({id:"/$name",path:"/$name",getParentRoute:()=>S0}),O_e=jSe.update({id:"/conversations/$conversationId",path:"/conversations/$conversationId",getParentRoute:()=>qi}),N_e={OwnerAgentsAgentIdGuardrailsNameRoute:j_e,OwnerAgentsAgentIdGuardrailsCreateRoute:R_e,OwnerAgentsAgentIdGuardrailsIndexRoute:__e},T_e=S0._addFileChildren(N_e),P_e={OwnerAgentsAgentIdSkillsSkillKeyRoute:E_e,OwnerAgentsAgentIdSkillsCreateRoute:A_e,OwnerAgentsAgentIdSkillsIndexRoute:S_e},L_e=M0._addFileChildren(P_e),z_e={OwnerAgentsAgentIdGuardrailsRoute:T_e,OwnerAgentsAgentIdIdentityRoute:M_e,OwnerAgentsAgentIdModelsRoute:w_e,OwnerAgentsAgentIdPermissionsRoute:b_e,OwnerAgentsAgentIdSettingsRoute:x_e,OwnerAgentsAgentIdSkillsRoute:L_e,OwnerAgentsAgentIdConversationsConversationIdRoute:O_e},D_e=qi._addFileChildren(z_e),I_e={OwnerAgentsConnectClientIdRoute:v_e,OwnerAgentsConnectIndexRoute:h_e},q_e=Av._addFileChildren(I_e),H_e={OwnerAgentsAgentIdRoute:D_e,OwnerAgentsConnectRoute:q_e,OwnerAgentsNewRoute:s_e,OwnerAgentsIndexRoute:QSe,OwnerAgentsConnectedClientIdRoute:k_e},V_e=fc._addFileChildren(H_e),F_e={OwnerAutomationsAutomationIdRoute:i_e,OwnerAutomationsNewRoute:o_e,OwnerAutomationsIndexRoute:ZSe},B_e=w0._addFileChildren(F_e),$_e={OwnerConnectorsCreateConnectorKeyRoute:y_e,OwnerConnectorsCreateIndexRoute:c_e},U_e=_v._addFileChildren($_e),K_e={OwnerConnectorsDeploymentsDeploymentIdRoute:p_e,OwnerConnectorsDeploymentsIndexRoute:l_e},G_e=Sv._addFileChildren(K_e),Y_e={OwnerConnectorsCreateRoute:U_e,OwnerConnectorsDeploymentsRoute:G_e,OwnerConnectorsIndexRoute:YSe,OwnerConnectorsConnectorKeyConnectionIdRoute:g_e,OwnerConnectorsAppAppIdRoute:m_e,OwnerConnectorsDeviceDeviceIdRoute:f_e,OwnerConnectorsConnectorKeyIndexRoute:u_e},W_e=Ii._addFileChildren(Y_e),Z_e={OwnerChatAgentIdIndexRoute:d_e,OwnerChatAgentIdCThreadIdRoute:C_e},Q_e=Cv._addFileChildren(Z_e),X_e={OwnerSplatRoute:$Se,OwnerAgentsRoute:V_e,OwnerAutomationsRoute:B_e,OwnerConnectorsRoute:W_e,OwnerRecentRoute:BSe,OwnerIndexRoute:NSe,OwnerChatAgentIdRoute:Q_e,OwnerEntityTypesSlugRoute:r_e,OwnerEntityTypesNewRoute:a_e,OwnerEventsSplatRoute:n_e,OwnerMemorySplatRoute:t_e,OwnerSettingsOrganizationRoute:e_e,OwnerEntityTypeIndexRoute:XSe,OwnerChatIndexRoute:WSe,OwnerEventsIndexRoute:GSe,OwnerMembersIndexRoute:KSe,OwnerMemoryIndexRoute:USe},J_e=_n._addFileChildren(X_e),eCe={IndexRoute:OSe,OwnerRoute:J_e,AccountSettingsRoute:FSe,AuthAcceptInvitationRoute:VSe,AuthCallbackRoute:HSe,AuthLoginRoute:qSe,AuthLogoutRoute:ISe,AuthResetPasswordRoute:DSe,OauthConsentRoute:zSe,OauthDeviceRoute:LSe,OrgsNewRoute:PSe,SlackClaimRoute:TSe,ConnectorNameConnectionRoute:JSe},tCe=ka._addFileChildren(eCe)._addFileTypes(),IE=new bO({defaultOptions:{queries:{staleTime:1e3*60*5,retry:1}}}),K8=b2(),nCe=pT({routeTree:tCe,context:{queryClient:IE},history:K8?N1e(K8):void 0,parseSearch:S1e,stringifySearch:_1e,defaultPreload:"intent",defaultPreloadStaleTime:0,defaultErrorComponent:M1e,defaultNotFoundComponent:x1e,defaultPendingComponent:()=>b.createElement(R7),defaultPendingMs:150,defaultPendingMinMs:300});TM();const G8=Tz(window.location.search);G8!==window.location.search&&window.history.replaceState(window.history.state,"",`${window.location.pathname}${G8}${window.location.hash}`);{const e=dz(window.location.pathname);e!==window.location.pathname&&window.history.replaceState(window.history.state,"",`${e}${window.location.search}${window.location.hash}`)}const Y8=new URLSearchParams(window.location.search).get("lobu_token");if(Y8){const e=new URL(window.location.href);e.searchParams.delete("lobu_token");const t=e.pathname+e.search+e.hash;window.location.replace(`/api/exchange-token?token=${encodeURIComponent(Y8)}&next=${encodeURIComponent(t)}`),await new Promise(()=>{})}const qE=document.getElementById("root");if(!qE)throw new Error("Root element not found");const Th=qE;MT.createRoot(Th).render(h.jsx(fe.StrictMode,{children:h.jsx(MO,{client:IE,children:h.jsx(jz,{children:h.jsx(gT,{router:nCe})})})}));const gh=document.getElementById("ssr-hydrate-shell");if(gh){let e=function(){a||(a=new MutationObserver(()=>{kb(Th)&&l()}),a.observe(Th,{attributes:!0,childList:!0,characterData:!0,subtree:!0}))},t=function(){if(kb(Th)){l();return}e()},n=!1,a=null;const o=()=>{window.removeEventListener(vm,t),a?.disconnect()},s=()=>{gh.remove(),o()},l=()=>{n||(n=!0,requestAnimationFrame(()=>{requestAnimationFrame(()=>{gh.classList.add("is-hidden"),gh.addEventListener("transitionend",s,{once:!0}),window.setTimeout(s,400)})}))};window.addEventListener(vm,t),window.setTimeout(t,5e3)}export{DAe as $,cg as A,ge as B,v7e as C,i8 as D,a1 as E,xs as F,$Ae as G,wte as H,jZ as I,Dk as J,UC as K,Ct as L,sc as M,Zg as N,Xg as O,la as P,E2 as Q,R2 as R,ft as S,j2 as T,gF as U,SI as V,s8e as W,vs as X,Xa as Y,xz as Z,gfe as _,H2 as a,R7 as a$,fm as a0,er as a1,qn as a2,t1 as a3,N9 as a4,kk as a5,d8e as a6,qw as a7,iCe as a8,y8e as a9,m1e as aA,p7 as aB,tc as aC,mn as aD,He as aE,Nr as aF,Mn as aG,dr as aH,go as aI,oc as aJ,i1 as aK,fe as aL,Ju as aM,ZM as aN,Za as aO,yue as aP,YH as aQ,_ue as aR,Yl as aS,zn as aT,P8e as aU,s9e as aV,Vu as aW,s6e as aX,mCe as aY,$8e as aZ,V8e as a_,ha as aa,Lt as ab,Au as ac,EM as ad,k8e as ae,on as af,pt as ag,x8e as ah,pCe as ai,ye as aj,Mv as ak,mk as al,w8e as am,Ge as an,Tr as ao,cM as ap,K0e as aq,fCe as ar,GM as as,cCe as at,Sz as au,uCe as av,lM as aw,dCe as ax,j8e as ay,FM as az,Z7e as b,so as b$,kCe as b0,Ee as b1,Y8e as b2,X8e as b3,eAe as b4,iwe as b5,HCe as b6,fk as b7,mEe as b8,PMe as b9,_ne as bA,The as bB,IW as bC,sV as bD,d7 as bE,wle as bF,RJ as bG,Lg as bH,$g as bI,BM as bJ,r7 as bK,uwe as bL,mfe as bM,Nhe as bN,Xh as bO,l_ as bP,hwe as bQ,pwe as bR,ks as bS,oCe as bT,xAe as bU,RAe as bV,jAe as bW,vAe as bX,si as bY,io as bZ,li as b_,nfe as ba,d1 as bb,rA as bc,EEe as bd,fEe as be,B7e as bf,rwe as bg,ewe as bh,Wy as bi,AEe as bj,kv as bk,J8e as bl,v1e as bm,a4e as bn,GA as bo,p_ as bp,Ik as bq,h_ as br,Jm as bs,X7 as bt,lwe as bu,vo as bv,ui as bw,c6 as bx,DC as by,KAe as bz,q8 as c,kre as c$,Bn as c0,lMe as c1,CMe as c2,ufe as c3,dfe as c4,LAe as c5,gAe as c6,k1e as c7,gCe as c8,hCe as c9,N9e as cA,T9e as cB,O9e as cC,P9e as cD,st as cE,Kn as cF,CAe as cG,fAe as cH,pAe as cI,fQ as cJ,m$ as cK,cse as cL,r1 as cM,Dbe as cN,Ibe as cO,n1 as cP,LC as cQ,Ym as cR,DM as cS,e1 as cT,sn as cU,Qa as cV,i7 as cW,fae as cX,JY as cY,tX as cZ,ZU as c_,aCe as ca,G9 as cb,AO as cc,bAe as cd,qC as ce,NH as cf,iEe as cg,Phe as ch,wMe as ci,MMe as cj,UA as ck,tk as cl,goe as cm,yAe as cn,NEe as co,_Ae as cp,yCe as cq,YA as cr,Dg as cs,XAe as ct,AW as cu,W9 as cv,PAe as cw,SM as cx,R9e as cy,j9e as cz,x7e as d,_6e as d$,dAe as d0,b2 as d1,CM as d2,j1e as d3,kwe as d4,S2 as d5,wwe as d6,IC as d7,i4e as d8,Hg as d9,EI as dA,e0 as dB,t0 as dC,lAe as dD,nEe as dE,k0e as dF,H9 as dG,nAe as dH,O9 as dI,qCe as dJ,FCe as dK,t6e as dL,BAe as dM,cAe as dN,uAe as dO,d_ as dP,iAe as dQ,sAe as dR,V9 as dS,e8e as dT,da as dU,L0e as dV,tAe as dW,aAe as dX,sEe as dY,g4e as dZ,v1 as d_,o7 as da,Jbe as db,Hn as dc,RG as dd,SMe as de,On as df,Ll as dg,eEe as dh,JAe as di,oEe as dj,QAe as dk,lEe as dl,cEe as dm,t8e as dn,wV as dp,T5e as dq,fo as dr,xe as ds,it as dt,Fk as du,Bk as dv,L8 as dw,q_ as dx,oA as dy,J2 as dz,OMe as e,UM as e$,Rq as e0,tEe as e1,Ug as e2,_we as e3,OAe as e4,yI as e5,hK as e6,c$ as e7,wAe as e8,MAe as e9,YAe as eA,WAe as eB,UAe as eC,FAe as eD,gQ as eE,Hu as eF,dEe as eG,hEe as eH,IEe as eI,Un as eJ,Nie as eK,HM as eL,zAe as eM,WCe as eN,ZCe as eO,E0e as eP,R0e as eQ,xi as eR,w2 as eS,Fl as eT,rAe as eU,oAe as eV,qAe as eW,Bg as eX,ci as eY,bCe as eZ,Cz as e_,CE as ea,SAe as eb,kAe as ec,DCe as ed,ICe as ee,LCe as ef,zCe as eg,EAe as eh,MCe as ei,ZAe as ej,qbe as ek,mAe as el,Xu as em,bi as en,Jre as eo,h2 as ep,VM as eq,sk as er,P2 as es,lk as et,ck as eu,uk as ev,hAe as ew,SCe as ex,ECe as ey,GAe as ez,jMe as f,E9 as f$,DH as f0,LU as f1,sI as f2,CCe as f3,lte as f4,mre as f5,hD as f6,uue as f7,jq as f8,UCe as f9,GY as fA,uce as fB,WM as fC,MQ as fD,vI as fE,Sn as fF,po as fG,Q2 as fH,c8 as fI,g1 as fJ,v_ as fK,M4e as fL,E4e as fM,N4e as fN,m5e as fO,k5e as fP,C4e as fQ,e2 as fR,$u as fS,z4e as fT,g1e as fU,T7e as fV,fa as fW,EE as fX,N7e as fY,ug as fZ,j7e as f_,dI as fa,BW as fb,VCe as fc,KCe as fd,YCe as fe,hte as ff,a7 as fg,M2 as fh,y7e as fi,awe as fj,TEe as fk,WA as fl,wae as fm,aEe as fn,rEe as fo,HAe as fp,hw as fq,Pr as fr,Ixe as fs,Hxe as ft,Dxe as fu,$xe as fv,DN as fw,zw as fx,Fw as fy,vW as fz,mv as g,QCe as g$,q$ as g0,js as g1,jwe as g2,Rwe as g3,Ewe as g4,i9e as g5,xCe as g6,R9 as g7,h9e as g8,y9e as g9,vEe as gA,bEe as gB,kEe as gC,SEe as gD,_Ee as gE,TAe as gF,ure as gG,uEe as gH,eg as gI,A0e as gJ,_0e as gK,NE as gL,dg as gM,x0 as gN,Qu as gO,S0e as gP,BCe as gQ,p7e as gR,f7e as gS,I9e as gT,L9e as gU,_u as gV,l7e as gW,Xm as gX,I8 as gY,Vh as gZ,Zu as g_,k9e as ga,x9e as gb,OCe as gc,NCe as gd,TCe as ge,PCe as gf,qEe as gg,S9e as gh,hoe as gi,Cre as gj,$M as gk,dre as gl,C9e as gm,lae as gn,IK as go,E9e as gp,DEe as gq,gEe as gr,yEe as gs,pEe as gt,TMe as gu,RCe as gv,jCe as gw,xEe as gx,MEe as gy,wEe as gz,M0e as h,F9e as h0,f_ as h1,JCe as h2,XCe as h3,IAe as h4,s4e as h5,l4e as h6,z5e as h7,$9e as h8,GCe as h9,SSe as hA,CSe as hB,ESe as hC,wCe as hD,jSe as hE,NAe as hF,hee as hG,Tg as hH,Ya as hI,x3e as hJ,b3e as hK,Gn as hL,W_ as hM,AAe as hN,hz as hO,Bz as hP,jY as ha,bY as hb,Fh as hc,PEe as hd,LEe as he,OEe as hf,zEe as hg,pk as hh,K9e as hi,Y9e as hj,CEe as hk,Z9e as hl,X9e as hm,eSe as hn,nSe as ho,rSe as hp,iSe as hq,lSe as hr,uSe as hs,hSe as ht,mSe as hu,Owe as hv,kSe as hw,_Ce as hx,ACe as hy,wSe as hz,$Ce as i,h as j,Bl as k,yE as l,lg as m,T9 as n,gn as o,f1 as p,uz as q,b as r,dt as s,W2 as t,hk as u,zM as v,q5e as w,k1 as x,Bve as y,d4e as z};
|
|
7898
|
+
*/var GMe={L:zl.QrCode.Ecc.LOW,M:zl.QrCode.Ecc.MEDIUM,Q:zl.QrCode.Ecc.QUARTILE,H:zl.QrCode.Ecc.HIGH},JA=128,eE="L",tE="#FFFFFF",nE="#000000",aE=!1,rE=1,YMe=4,WMe=0,ZMe=.1;function oE(e,t=0){const n=[];return e.forEach(function(a,o){let s=null;a.forEach(function(l,c){if(!l&&s!==null){n.push(`M${s+t} ${o+t}h${c-s}v1H${s+t}z`),s=null;return}if(c===a.length-1){if(!l)return;s===null?n.push(`M${c+t},${o+t} h1v1H${c+t}z`):n.push(`M${s+t},${o+t} h${c+1-s}v1H${s+t}z`);return}l&&s===null&&(s=c)})}),n.join("")}function iE(e,t){return e.slice().map((n,a)=>a<t.y||a>=t.y+t.h?n:n.map((o,s)=>s<t.x||s>=t.x+t.w?o:!1))}function QMe(e,t,n,a){if(a==null)return null;const o=e.length+n*2,s=Math.floor(t*ZMe),l=o/t,c=(a.width||s)*l,d=(a.height||s)*l,f=a.x==null?e.length/2-c/2:a.x*l,p=a.y==null?e.length/2-d/2:a.y*l,y=a.opacity==null?1:a.opacity;let k=null;if(a.excavate){let w=Math.floor(f),S=Math.floor(p),_=Math.ceil(c+f-w),C=Math.ceil(d+p-S);k={x:w,y:S,w:_,h:C}}const v=a.crossOrigin;return{x:f,y:p,h:d,w:c,excavation:k,opacity:y,crossOrigin:v}}function XMe(e,t){return t!=null?Math.max(Math.floor(t),0):e?YMe:WMe}function sE({value:e,level:t,minVersion:n,includeMargin:a,marginSize:o,imageSettings:s,size:l,boostLevel:c}){let d=fe.useMemo(()=>{const w=(Array.isArray(e)?e:[e]).reduce((S,_)=>(S.push(...zl.QrSegment.makeSegments(_)),S),[]);return zl.QrCode.encodeSegments(w,GMe[t],n,void 0,void 0,c)},[e,t,n,c]);const{cells:f,margin:p,numCells:y,calculatedImageSettings:k}=fe.useMemo(()=>{let v=d.getModules();const w=XMe(a,o),S=v.length+w*2,_=QMe(v,l,w,s);return{cells:v,margin:w,numCells:S,calculatedImageSettings:_}},[d,l,s,a,o]);return{qrcode:d,margin:p,cells:f,numCells:y,calculatedImageSettings:k}}var JMe=(function(){try{new Path2D().addPath(new Path2D)}catch{return!1}return!0})(),e7e=fe.forwardRef(function(t,n){const a=t,{value:o,size:s=JA,level:l=eE,bgColor:c=tE,fgColor:d=nE,includeMargin:f=aE,minVersion:p=rE,boostLevel:y,marginSize:k,imageSettings:v}=a,S=sg(a,["value","size","level","bgColor","fgColor","includeMargin","minVersion","boostLevel","marginSize","imageSettings"]),{style:_}=S,C=sg(S,["style"]),A=v?.src,j=fe.useRef(null),N=fe.useRef(null),I=fe.useCallback(F=>{j.current=F,typeof n=="function"?n(F):n&&(n.current=F)},[n]),[T,q]=fe.useState(!1),{margin:R,cells:H,numCells:D,calculatedImageSettings:G}=sE({value:o,level:l,minVersion:p,boostLevel:y,includeMargin:f,marginSize:k,imageSettings:v,size:s});fe.useEffect(()=>{if(j.current!=null){const F=j.current,W=F.getContext("2d");if(!W)return;let P=H;const U=N.current,J=G!=null&&U!==null&&U.complete&&U.naturalHeight!==0&&U.naturalWidth!==0;J&&G.excavation!=null&&(P=iE(H,G.excavation));const se=window.devicePixelRatio||1;F.height=F.width=s*se;const L=s/D*se;W.scale(L,L),W.fillStyle=c,W.fillRect(0,0,D,D),W.fillStyle=d,JMe?W.fill(new Path2D(oE(P,R))):H.forEach(function(B,V){B.forEach(function(O,ee){O&&W.fillRect(ee+R,V+R,1,1)})}),G&&(W.globalAlpha=G.opacity),J&&W.drawImage(U,G.x+R,G.y+R,G.w,G.h)}}),fe.useEffect(()=>{q(!1)},[A]);const $=ig({height:s,width:s},_);let X=null;return A!=null&&(X=fe.createElement("img",{src:A,key:A,style:{display:"none"},onLoad:()=>{q(!0)},ref:N,crossOrigin:G?.crossOrigin})),fe.createElement(fe.Fragment,null,fe.createElement("canvas",ig({style:$,height:s,width:s,ref:I,role:"img"},C)),X)});e7e.displayName="QRCodeCanvas";var lE=fe.forwardRef(function(t,n){const a=t,{value:o,size:s=JA,level:l=eE,bgColor:c=tE,fgColor:d=nE,includeMargin:f=aE,minVersion:p=rE,boostLevel:y,title:k,marginSize:v,imageSettings:w}=a,S=sg(a,["value","size","level","bgColor","fgColor","includeMargin","minVersion","boostLevel","title","marginSize","imageSettings"]),{margin:_,cells:C,numCells:A,calculatedImageSettings:j}=sE({value:o,level:l,minVersion:p,boostLevel:y,includeMargin:f,marginSize:v,imageSettings:w,size:s});let N=C,I=null;w!=null&&j!=null&&(j.excavation!=null&&(N=iE(C,j.excavation)),I=fe.createElement("image",{href:w.src,height:j.h,width:j.w,x:j.x+_,y:j.y+_,preserveAspectRatio:"none",opacity:j.opacity,crossOrigin:j.crossOrigin}));const T=oE(N,_);return fe.createElement("svg",ig({height:s,width:s,viewBox:`0 0 ${A} ${A}`,ref:n,role:"img"},S),!!k&&fe.createElement("title",null,k),fe.createElement("path",{fill:c,d:`M0,0 h${A}v${A}H0z`,shapeRendering:"crispEdges"}),fe.createElement("path",{fill:d,d:T,shapeRendering:"crispEdges"}),I)});lE.displayName="QRCodeSVG";function t7e(e){const t=Math.max(0,Math.floor(e/1e3)),n=Math.floor(t/60),a=t%60;return n>0?`${n}m ${a}s`:`${a}s`}function cE({expiresAt:e}){const[t,n]=b.useState(()=>Date.now());b.useEffect(()=>{const l=setInterval(()=>n(Date.now()),1e3);return()=>clearInterval(l)},[]);const o=new Date(e).getTime()-t,s=o<=0;return h.jsx("span",{className:`text-xs font-mono ${s?"text-destructive":"text-muted-foreground"}`,children:s?"Expired — waiting for refresh…":`Expires in ${t7e(o)}`})}function n7e({artifact:e}){return h.jsxs("div",{className:"space-y-3",children:[h.jsx("div",{className:"flex justify-center",children:h.jsx("div",{className:"rounded-md bg-white p-3 border",children:h.jsx(lE,{value:e.value,size:220,level:"M"})})}),e.expiresAt&&h.jsx("div",{className:"flex justify-center",children:h.jsx(cE,{expiresAt:e.expiresAt})}),e.instructions&&h.jsx("p",{className:"text-sm text-muted-foreground text-center",children:e.instructions})]})}function a7e({artifact:e}){const[t,n]=b.useState(!1),a=b.useCallback(async()=>{try{await navigator.clipboard.writeText(e.value.replace(/[^A-Za-z0-9]/g,"")),n(!0),setTimeout(()=>n(!1),1500)}catch{}},[e.value]);return h.jsxs("div",{className:"space-y-3",children:[h.jsxs("div",{className:"flex items-center justify-center gap-2",children:[h.jsx("code",{className:"font-mono text-2xl tracking-widest px-4 py-2 rounded bg-muted border",children:e.value}),h.jsx(ge,{variant:"outline",size:"sm",onClick:()=>void a(),children:t?h.jsxs(h.Fragment,{children:[h.jsx(Za,{className:"h-3.5 w-3.5 mr-1.5"})," Copied"]}):h.jsxs(h.Fragment,{children:[h.jsx(Hu,{className:"h-3.5 w-3.5 mr-1.5"})," Copy"]})})]}),e.expiresAt&&h.jsx("div",{className:"flex justify-center",children:h.jsx(cE,{expiresAt:e.expiresAt})}),e.instructions&&h.jsx("p",{className:"text-sm text-muted-foreground text-center",children:e.instructions})]})}function r7e({artifact:e,runId:t}){const n=D9(),[a,o]=b.useState(!1),s=b.useCallback(()=>{e.mode==="popup"?window.open(e.url,"_blank","noopener,noreferrer,width=600,height=700"):window.location.href=e.url,o(!0)},[e.mode,e.url]),l=b.useCallback(()=>{n.mutateAsync({run_id:t,name:e.awaitSignal,payload:{}})},[n,t,e.awaitSignal]);return h.jsxs("div",{className:"space-y-3",children:[e.instructions&&h.jsx("p",{className:"text-sm text-muted-foreground",children:e.instructions}),h.jsxs("div",{className:"flex flex-col items-stretch gap-2",children:[h.jsxs(ge,{onClick:s,children:[h.jsx(a1,{className:"h-4 w-4 mr-2"}),a?"Re-open authorization page":"Open authorization page"]}),a&&h.jsx(ge,{variant:"outline",onClick:l,disabled:n.isPending,children:n.isPending?h.jsxs(h.Fragment,{children:[h.jsx(dt,{size:"lg",className:"mr-2"})," Notifying…"]}):"I have completed authorization"})]})]})}function o7e({artifact:e,runId:t}){const n=D9(),[a,o]=b.useState({}),s=b.useCallback(c=>{c.preventDefault(),n.mutateAsync({run_id:t,name:e.submitSignal,payload:a})},[n,t,e.submitSignal,a]),l=e.fields.every(c=>!c.required||(a[c.key]??"").trim().length>0);return h.jsxs("form",{onSubmit:s,className:"space-y-3",children:[e.instructions&&h.jsx("p",{className:"text-sm text-muted-foreground",children:e.instructions}),e.fields.map(c=>h.jsxs("div",{className:"space-y-1",children:[h.jsxs("label",{htmlFor:`auth-field-${c.key}`,className:"text-xs font-medium",children:[c.label,c.required&&h.jsx("span",{className:"text-destructive ml-0.5",children:"*"})]}),h.jsx(Lt,{id:`auth-field-${c.key}`,type:c.kind==="password"?"password":"text",inputMode:c.kind==="otp"?"numeric":void 0,autoComplete:c.kind==="otp"?"one-time-code":void 0,value:a[c.key]??"",onChange:d=>o(f=>({...f,[c.key]:d.target.value}))})]},c.key)),h.jsx(ge,{type:"submit",disabled:!l||n.isPending,className:"w-full",children:n.isPending?h.jsxs(h.Fragment,{children:[h.jsx(dt,{size:"lg",className:"mr-2"})," Submitting…"]}):"Submit"})]})}function i7e({artifact:e}){return h.jsxs("div",{className:"flex items-center gap-3 py-2",children:[h.jsx(dt,{size:"xl",className:"text-muted-foreground"}),h.jsx("span",{className:"text-sm text-muted-foreground",children:e.message})]})}function uE({artifact:e,runId:t}){switch(e.type){case"qr":return h.jsx(n7e,{artifact:e});case"code":return h.jsx(a7e,{artifact:e});case"redirect":return h.jsx(r7e,{artifact:e,runId:t});case"prompt":return h.jsx(o7e,{artifact:e,runId:t});case"status":return h.jsx(i7e,{artifact:e})}}function s7e({runId:e,onClose:t}){const{data:n,isLoading:a}=z9(e),o=b.useMemo(()=>n?.status==="completed"||n?.status==="failed"||n?.status==="cancelled",[n?.status]);b.useEffect(()=>{if(n?.status==="completed"){const l=setTimeout(t,1500);return()=>clearTimeout(l)}},[n?.status,t]);const s=e!=null;return h.jsx(sk,{open:s,onOpenChange:l=>{l||t()},children:h.jsxs(P2,{className:"sm:max-w-md",children:[h.jsxs(lk,{children:[h.jsx(ck,{children:n?.status==="completed"?"Connection authorized":n?.status==="failed"?"Authorization failed":n?.status==="cancelled"?"Authorization cancelled":"Connect your account"}),h.jsx(uk,{children:n?.connector_key?`Complete sign-in for ${n.connector_key} to finish setup. You can add feeds later if you want scheduled syncs.`:"Complete sign-in to finish setup. You can add feeds later if you want scheduled syncs."})]}),h.jsxs("div",{className:"py-2 space-y-4",children:[a&&!n&&h.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[h.jsx(dt,{size:"lg"})," Preparing…"]}),n?.status==="completed"&&h.jsxs("div",{className:"flex items-center gap-2 text-sm text-emerald-600",children:[h.jsx(Dg,{className:"h-5 w-5"})," Success — closing…"]}),n?.status==="failed"&&h.jsxs("div",{className:"rounded-md border border-destructive/30 bg-destructive/5 p-3 text-sm text-destructive flex items-start gap-2",children:[h.jsx(FM,{className:"h-4 w-4 mt-0.5 shrink-0"}),h.jsx("span",{children:n.error_message||"Authentication failed."})]}),n?.status==="cancelled"&&h.jsxs("div",{className:"rounded-md border p-3 text-sm text-muted-foreground flex items-start gap-2",children:[h.jsx(w2,{className:"h-4 w-4 mt-0.5 shrink-0"}),h.jsx("span",{children:"Authorization was cancelled."})]}),!o&&n&&!n.artifact&&h.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[h.jsx(dt,{size:"lg"})," Waiting for connector…"]}),!o&&n?.artifact&&e!=null&&h.jsx(uE,{artifact:n.artifact,runId:e})]}),h.jsx("div",{className:"flex justify-end gap-2",children:h.jsx(ge,{variant:"outline",onClick:t,children:o?"Close":"Cancel"})})]})})}function l7e(e){return vv(e).find(t=>t.type==="app_installation")}function c7e(e){const t=e.provider.toUpperCase();return{clientIdKey:e.clientIdKey||`${t}_CLIENT_ID`,clientSecretKey:e.clientSecretKey||`${t}_CLIENT_SECRET`}}function u7e(e){if(e)return e}function vv(e){return u7e(e)?.methods??[]}function dE(e,t){if(!(e.auth_profile_slug||e.auth_profile_kind||e.app_auth_profile_slug||e.config?.managedBy||e.config?.installation_ref||e.config?.consent_only))return vv(t).find(n=>n.type==="none")}function _u(e,t){const n=vv(e),a=n.some(o=>o.type!=="none");return n.filter(o=>o.type!=="none"||a).filter(o=>{if(o.type==="oauth"){const s=o,l=Qu(s),c=x0(s);return!(l.length===0&&c.length===0)}return o.type==="env_keys",!0})}function Qu(e){return Array.isArray(e?.requiredScopes)?e.requiredScopes.filter(t=>typeof t=="string"):[]}function x0(e){return Array.isArray(e?.optionalScopes)?e.optionalScopes.filter(t=>typeof t=="string"):[]}function I8(e,t){const n=Qu(e),a=new Set(x0(e)),o=(t??[]).filter(s=>a.has(s));return Array.from(new Set([...n,...o]))}function Oh(e){return e.type==="app_installation"?`${e.provider.charAt(0).toUpperCase()+e.provider.slice(1)} App`:e.type==="oauth"?`OAuth (${e.provider.charAt(0).toUpperCase()+e.provider.slice(1)})`:e.type==="env_keys"?"API Key / Token":e.type==="browser"?"Browser":e.type==="none"?e.label??"No Authentication":e.type==="interactive"?"Interactive pairing":e.type}function d7e(e,t){const n=e.fields;if(n.length===0)return;const a=Object.fromEntries(n.map(s=>[s.key,{type:"string",title:s.label||s.key,description:s.description,example:s.example,...s.secret?{format:"password"}:{}}])),o=n.filter(s=>s.required!==!1).map(s=>s.key);return{type:"object",properties:a,...o.length>0?{required:o}:{}}}function h7e(e){if(e.type==="env_keys"){const t=e.required!==!1;return e.fields.map(n=>({key:n.key,label:n.label,description:n.description,example:n.example,secret:n.secret,required:t&&n.required!==!1}))}if(e.type==="oauth"){const t=e.required!==!1,n=e.provider?e.provider.charAt(0).toUpperCase()+e.provider.slice(1):"OAuth",{clientIdKey:a,clientSecretKey:o}=c7e(e);return[{key:a,label:`${n} Client ID`,description:`${n} OAuth client ID`,secret:!1,required:t},{key:o,label:`${n} Client Secret`,description:`${n} OAuth client secret`,secret:!0,required:t}]}return[]}function f7e(e){if(!e||e.type==="none")return;const t=h7e(e);if(t.length===0)return;const n=Object.fromEntries(t.map(o=>[o.key,{type:"string",title:o.required?o.label||o.key:`${o.label||o.key} (Optional)`,description:o.description,example:o.example,...o.secret?{format:"password"}:{}}])),a=t.filter(o=>o.required).map(o=>o.key);return{type:"object",properties:n,...a.length>0?{required:a}:{}}}function p7e(){return kv()}function y7e({id:e,title:t,count:n,action:a,muted:o,children:s}){return h.jsxs("section",{id:e,className:"min-w-0 scroll-mt-24",children:[h.jsxs("div",{className:"mb-2.5 flex items-center justify-between gap-3 border-b pb-2",children:[h.jsxs("h2",{className:ye("text-[13px] font-semibold tracking-[-0.005em]",o&&"text-muted-foreground"),children:[t,n?h.jsx("span",{className:"ml-1.5 text-[11.5px] font-normal text-muted-foreground",children:n}):null]}),a]}),s]})}function OEe({title:e,summary:t,open:n,onOpenChange:a,children:o}){return h.jsxs(J2,{open:n,onOpenChange:a,className:"min-w-0",children:[h.jsxs(e0,{className:"group flex w-full items-center gap-2 border-b pb-2 text-left transition-colors hover:border-muted-foreground",children:[h.jsx(da,{className:ye("size-3 shrink-0 text-muted-foreground transition-transform",n&&"rotate-90")}),h.jsx("span",{className:"text-[13px] font-semibold tracking-[-0.005em]",children:e}),h.jsx("span",{className:"ml-auto truncate text-[11.5px] text-muted-foreground transition-colors group-hover:text-foreground",children:n?"Hide":t})]}),h.jsx(t0,{className:"pt-3",children:o})]})}class wn{constructor(t,n,a,o=null){this.kind=t,this.text=n,this.value=a,this.error=o}toJSON(){if(this.error)throw new Error(this.error);return this.value}}function Xu(e){return e instanceof wn?e.error!==null:Array.isArray(e)?e.some(Xu):e!==null&&typeof e=="object"?Object.values(e).some(Xu):!1}function Fl(e){return e instanceof wn?Fl(e.toJSON()):Array.isArray(e)?e.map(Fl):e!==null&&typeof e=="object"?Object.fromEntries(Object.entries(e).map(([t,n])=>[t,Fl(n)])):e}function Nh(e){return e instanceof wn?{kind:e.kind,text:e.text,value:Nh(e.value),error:e.error}:Array.isArray(e)?e.map(Nh):e!==null&&typeof e=="object"?Object.fromEntries(Object.keys(e).sort().map(t=>[t,Nh(e[t])])):e}function hs(e){return JSON.stringify(Nh(e))??""}function u2(e,t){return{source:e,token:t,baseline:e.initial,values:e.initial,acceptedKey:void 0}}function hE(e,t){return e.source.initialKey!==t.initialKey||e.source.revisionKey!==t.revisionKey}function m7e(e,t){if(t.sessionKey!==e.source.sessionKey)return u2(t,{});if(!hE(e,t))return e;const n=hs(e.values);return n===hs(e.baseline)||n===t.initialKey?u2(t,e.token):e.acceptedKey===t.initialKey&&e.source.revisionKey===t.revisionKey?{...e,source:t,baseline:t.initial,acceptedKey:void 0}:e}function Bl(e,t,n){const a=b.useMemo(()=>hs(n),[n]),o={sessionKey:e,initial:t,initialKey:hs(t),revision:n,revisionKey:a},[s,l]=b.useState(()=>u2(o,{})),c=m7e(s,o);c!==s&&l(c);const d=c.token,f=b.useCallback(A=>{l(j=>j.token===d?A(j):j)},[d]),p=b.useCallback(A=>f(j=>({...j,values:typeof A=="function"?A(j.values):A})),[f]),y=()=>f(A=>u2(o,A.token)),k=b.useCallback((A,j)=>f(N=>({...N,baseline:A,acceptedKey:hs(j)})),[f]),v=b.useMemo(()=>hs(c.values),[c.values]),w=b.useMemo(()=>hs(c.baseline),[c.baseline]),S=v!==w,_=S&&hE(c,o),C=b.useMemo(()=>Xu(c.values),[c.values]);return{values:c.values,revision:c.source.revision,baseline:c.baseline,setValues:p,reset:y,accept:k,field(A){return[c.values[A],j=>p(N=>({...N,[A]:typeof j=="function"?j(N[A]):j}))]},canSubmit:!_&&!C,hasInvalidInput:C,dirty:S,hasConflict:_}}function NEe(e,t){const[n,a]=b.useState(()=>({sessionKey:e,token:{},value:t}));let o=n;e!==n.sessionKey&&(o={sessionKey:e,token:{},value:t},a(o));const s=o.token,l=b.useCallback(c=>{a(d=>d.token!==s?d:{...d,value:typeof c=="function"?c(d.value):c})},[s]);return[o.value,l]}const g7e={BASE_URL:"/",DEV:!1,MODE:"production",PROD:!0,SSR:!1,TSS_INLINE_CSS_ENABLED:"false",VITE_GATEWAY_URL:""};function k7e(e,t=g7e,n=typeof window<"u"?window.location.origin:void 0){const a=e.startsWith("agentconn-")?e.slice(10):e;return`${kv(t,n)}/lobu/api/v1/webhooks/${encodeURIComponent(a)}`}function TEe({title:e,summary:t,onOpen:n}){return h.jsxs("button",{type:"button",onClick:n,className:"group flex w-full items-center justify-between gap-4 rounded-lg border border-border px-4 py-3 text-left transition-colors hover:bg-accent/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",children:[h.jsxs("span",{className:"min-w-0",children:[h.jsx("span",{className:"block text-sm font-medium",children:e}),h.jsx("span",{className:"mt-0.5 block text-xs text-muted-foreground",children:t})]}),h.jsx(da,{"aria-hidden":"true",className:"h-4 w-4 shrink-0 text-muted-foreground"})]})}function v7e({label:e,query:t,onQueryChange:n,count:a,action:o}){return h.jsxs(h.Fragment,{children:[h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsxs("div",{className:"relative min-w-0 flex-1",children:[h.jsx(r1,{"aria-hidden":"true",className:"pointer-events-none absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground"}),h.jsx(Lt,{type:"search","aria-label":`Search ${e}`,placeholder:`Search ${e}…`,value:t,onChange:s=>n(s.target.value),className:"pl-9"})]}),o]}),h.jsxs("p",{className:"text-xs text-muted-foreground",role:"status",children:[a," ",a===1?e.replace(/s$/,""):e,t.trim()?" found":""]})]})}function x7e({entries:e,label:t,action:n,renderControl:a,renderDetail:o}){const[s,l]=b.useState(""),c=new Set(e.filter(d=>`${d.name} ${d.description??""}`.toLowerCase().includes(s.trim().toLowerCase())).map(d=>d.id));return h.jsxs("div",{className:"space-y-4",children:[h.jsx(v7e,{label:t,query:s,onQueryChange:l,count:c.size,action:n}),h.jsx("ul",{children:e.map(d=>h.jsx(b7e,{entry:d,hidden:!c.has(d.id),control:a?.(d),renderDetail:()=>o(d)},d.id))}),c.size===0&&h.jsx("p",{className:"py-5 text-sm text-muted-foreground",children:s?"No matches. Try another search.":`No ${t} yet.`})]})}function b7e({entry:e,hidden:t,control:n,renderDetail:a}){const[o,s]=b.useState(!1),[l,c]=b.useState(!1);return h.jsx("li",{hidden:t,className:"border-b border-border last:border-b-0",children:h.jsxs(J2,{open:o,onOpenChange:d=>{s(d),d&&c(!0)},children:[h.jsxs("div",{className:"flex items-center gap-3 py-3",children:[h.jsxs(e0,{className:"group flex min-w-0 flex-1 items-start gap-2 rounded-sm text-left hover:text-foreground/80 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",children:[h.jsx(da,{"aria-hidden":"true",className:"mt-0.5 h-4 w-4 shrink-0 text-muted-foreground transition-transform group-data-[state=open]:rotate-90 motion-reduce:transition-none"}),h.jsxs("span",{className:"min-w-0",children:[h.jsx("span",{className:"block text-sm font-medium",children:e.name}),e.status&&h.jsx("span",{className:"mt-0.5 block text-xs text-muted-foreground",children:e.status})]})]}),n&&h.jsx("div",{className:"shrink-0",children:n})]}),l&&h.jsxs(t0,{forceMount:!0,hidden:!o,className:"space-y-4 pb-4 pl-6",children:[e.description&&h.jsx("p",{className:"text-sm text-muted-foreground",children:e.description}),a()]})]})})}const fE={disabled:"Disabled",approval:"Requires approval",auto:"Auto-approve"},w7e=["disabled","approval","auto"];function pE(e){return e==="disabled"||e==="approval"||e==="auto"}function yE(e){if(!e||typeof e!="object")return{};const t=e.action_modes;if(!t||typeof t!="object"||Array.isArray(t))return{};const n={};for(const[a,o]of Object.entries(t))pE(o)&&(n[a]=o);return n}function mE(e){return e.requires_approval?"approval":e.kind==="read"?"auto":e.annotations?.destructiveHint===!0?"approval":"auto"}function lg(e,t){return t[e.operation_key]??mE(e)}function xv({name:e,description:t,onInspect:n,leading:a,trailing:o,badge:s}){return h.jsxs("div",{className:ye(Yl,"flex items-start gap-3 p-3"),children:[a,h.jsxs("div",{className:"min-w-0 flex-1",children:[h.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[n?h.jsx("button",{type:"button",onClick:n,className:"text-sm font-medium text-left hover:underline",children:e}):h.jsx("span",{className:"text-sm font-medium",children:e}),s]}),t&&h.jsx("p",{className:"mt-0.5 text-xs text-muted-foreground",children:t})]}),o]})}function gE({feedsSchema:e,enabledFeeds:t,onToggleFeed:n,onInspect:a}){if(!e)return null;const o=Object.entries(e);if(o.length===0)return null;const s=!!t&&!!n;return h.jsxs("div",{className:"space-y-2",children:[h.jsx("p",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wider",children:"Feeds"}),h.jsx("div",{className:"space-y-1.5",children:o.map(([l,c])=>h.jsx(xv,{name:c.name??l,description:c.description,onInspect:a?()=>a(l,c):void 0,leading:s?h.jsx("input",{type:"checkbox",checked:t.has(l),onChange:d=>n(l,d.target.checked),className:"rounded border-input mt-0.5","aria-label":`Enable ${c.name??l}`}):void 0},l))})]})}function M7e({operations:e,modes:t,onChange:n,onInspect:a}){if(e.length===0)return null;const o=!!n,s=(l,c)=>{if(!n)return;const d=mE(l),f={...t};c===d?delete f[l.operation_key]:f[l.operation_key]=c,n(f)};return h.jsxs("div",{className:"space-y-2",children:[h.jsx("p",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wider",children:"Actions"}),h.jsx("div",{className:"space-y-1.5",children:e.map(l=>{const c=lg(l,t),d=l.name??l.operation_key;return h.jsx(xv,{name:d,description:l.description,onInspect:a?()=>a(l):void 0,trailing:o?h.jsx(cg,{value:c,onChange:f=>s(l,f),"aria-label":`Mode for ${d}`}):h.jsx("span",{className:"text-xs text-muted-foreground",children:fE[c]})},l.operation_key)})})]})}function cg({value:e,onChange:t,"aria-label":n}){return h.jsx("select",{value:e,"aria-label":n,onChange:a=>{pE(a.target.value)&&t(a.target.value)},className:"h-8 max-w-full rounded-md border border-input bg-background px-2 text-xs focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",children:w7e.map(a=>h.jsx("option",{value:a,children:fE[a]},a))})}function kE({actionsSchema:e,onInspect:t}){if(!e)return null;const n=Object.entries(e);return n.length===0?null:h.jsxs("div",{className:"space-y-2",children:[h.jsx("p",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wider",children:"Actions"}),h.jsx("div",{className:"space-y-1.5",children:n.map(([a,o])=>h.jsx(xv,{name:o.name??a,description:o.description,onInspect:t?()=>t(a,o):void 0,badge:o.requiresApproval?h.jsx(on,{variant:"outline",className:"text-[10px] px-1.5 py-0 h-4 text-amber-600 border-amber-300",children:"Requires approval"}):void 0},a))})]})}var b0="Checkbox",[S7e]=dr(b0),[_7e,bv]=S7e(b0);function C7e(e){const{__scopeCheckbox:t,checked:n,children:a,defaultChecked:o,disabled:s,form:l,name:c,onCheckedChange:d,required:f,value:p="on",internal_do_not_use_render:y}=e,[k,v]=fo({prop:n,defaultProp:o??!1,onChange:d,caller:b0}),[w,S]=b.useState(null),[_,C]=b.useState(null),A=b.useRef(!1),j=w?!!l||!!w.closest("form"):!0,N={checked:k,disabled:s,setChecked:v,control:w,setControl:S,name:c,form:l,value:p,hasConsumerStoppedPropagationRef:A,required:f,defaultChecked:vi(o)?!1:o,isFormControl:j,bubbleInput:_,setBubbleInput:C};return h.jsx(_7e,{scope:t,...N,children:A7e(y)?y(N):a})}var vE="CheckboxTrigger",xE=b.forwardRef(({__scopeCheckbox:e,onKeyDown:t,onClick:n,...a},o)=>{const{control:s,value:l,disabled:c,checked:d,required:f,setControl:p,setChecked:y,hasConsumerStoppedPropagationRef:k,isFormControl:v,bubbleInput:w}=bv(vE,e),S=it(o,p),_=b.useRef(d);return b.useEffect(()=>{const C=s?.form;if(C){const A=()=>y(_.current);return C.addEventListener("reset",A),()=>C.removeEventListener("reset",A)}},[s,y]),h.jsx(He.button,{type:"button",role:"checkbox","aria-checked":vi(d)?"mixed":d,"aria-required":f,"data-state":_E(d),"data-disabled":c?"":void 0,disabled:c,value:l,...a,ref:S,onKeyDown:xe(t,C=>{C.key==="Enter"&&C.preventDefault()}),onClick:xe(n,C=>{y(A=>vi(A)?!0:!A),w&&v&&(k.current=C.isPropagationStopped(),k.current||C.stopPropagation())})})});xE.displayName=vE;var wv=b.forwardRef((e,t)=>{const{__scopeCheckbox:n,name:a,checked:o,defaultChecked:s,required:l,disabled:c,value:d,onCheckedChange:f,form:p,...y}=e;return h.jsx(C7e,{__scopeCheckbox:n,checked:o,defaultChecked:s,disabled:c,required:l,onCheckedChange:f,name:a,form:p,value:d,internal_do_not_use_render:({isFormControl:k})=>h.jsxs(h.Fragment,{children:[h.jsx(xE,{...y,ref:t,__scopeCheckbox:n}),k&&h.jsx(SE,{__scopeCheckbox:n})]})})});wv.displayName=b0;var bE="CheckboxIndicator",wE=b.forwardRef((e,t)=>{const{__scopeCheckbox:n,forceMount:a,...o}=e,s=bv(bE,n);return h.jsx(Gn,{present:a||vi(s.checked)||s.checked===!0,children:h.jsx(He.span,{"data-state":_E(s.checked),"data-disabled":s.disabled?"":void 0,...o,ref:t,style:{pointerEvents:"none",...e.style}})})});wE.displayName=bE;var ME="CheckboxBubbleInput",SE=b.forwardRef(({__scopeCheckbox:e,...t},n)=>{const{control:a,hasConsumerStoppedPropagationRef:o,checked:s,defaultChecked:l,required:c,disabled:d,name:f,value:p,form:y,bubbleInput:k,setBubbleInput:v}=bv(ME,e),w=it(n,v),S=oA(s),_=q_(a);b.useEffect(()=>{const A=k;if(!A)return;const j=window.HTMLInputElement.prototype,I=Object.getOwnPropertyDescriptor(j,"checked").set,T=!o.current;if(S!==s&&I){const q=new Event("click",{bubbles:T});A.indeterminate=vi(s),I.call(A,vi(s)?!1:s),A.dispatchEvent(q)}},[k,S,s,o]);const C=b.useRef(vi(s)?!1:s);return h.jsx(He.input,{type:"checkbox","aria-hidden":!0,defaultChecked:l??C.current,required:c,disabled:d,name:f,value:p,form:y,...t,tabIndex:-1,ref:w,style:{...t.style,..._,position:"absolute",pointerEvents:"none",opacity:0,margin:0,transform:"translateX(-100%)"}})});SE.displayName=ME;function A7e(e){return typeof e=="function"}function vi(e){return e==="indeterminate"}function _E(e){return vi(e)?"indeterminate":e?"checked":"unchecked"}const Mv=b.forwardRef(({className:e,...t},n)=>h.jsx(wv,{ref:n,className:ye("peer h-4 w-4 shrink-0 rounded-sm border border-primary focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground",e),...t,children:h.jsx(wE,{className:ye("flex items-center justify-center text-current"),children:h.jsx(Za,{className:"h-4 w-4"})})}));Mv.displayName=wv.displayName;const CE=b.forwardRef(({className:e,...t},n)=>h.jsx("textarea",{className:ye("flex min-h-[60px] w-full rounded-md border border-input bg-muted px-3 py-2 text-base placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",e),ref:n,...t}));CE.displayName="Textarea";function fa(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)&&!(e instanceof wn)}function E7e(e){return Array.isArray(e)?e.map(t=>String(t)).join(", "):""}function R7e(e,t,n,a,o){const s=e.split(",").map(c=>c.trim()).filter(Boolean);let l;if(t==="number"||t==="integer"){const c=s.map(Number);if(!c.every(f=>t==="integer"?Number.isInteger(f):Number.isFinite(f)))return{error:`Enter comma-separated ${t==="integer"?"integers":"numbers"}`};l=c}else if(t==="boolean"){if(s.some(c=>c!=="true"&&c!=="false"))return{error:"Enter comma-separated true or false values"};l=s.map(c=>c==="true")}else l=s;return n&&l.some(c=>!n.some(d=>Object.is(c,d)))?{error:"Enter only the allowed values"}:a!==void 0&&l.length<a?{error:`Enter at least ${a} ${a===1?"item":"items"}`}:o!==void 0&&l.length>o?{error:`Enter at most ${o} ${o===1?"item":"items"}`}:{values:l}}function j7e({id:e,value:t,itemType:n,itemEnum:a,minItems:o,maxItems:s,ariaLabel:l,placeholder:c,readOnly:d=!1,showHelp:f=!0,onChange:p}){const y=t instanceof wn?t.text:E7e(t),k=t instanceof wn?t.error:null;return h.jsxs(h.Fragment,{children:[h.jsx(Lt,{id:e,"aria-label":l,type:"text",value:y,onChange:v=>{const w=v.target.value,S=R7e(w,n,a,o,s);p(new wn("primitive-array",w,S.values,S.error??null))},placeholder:c||"Enter comma-separated values",readOnly:d,disabled:d,"aria-invalid":k?!0:void 0,"aria-describedby":k?`${e}-error`:f?`${e}-help`:void 0}),k?h.jsx("p",{id:`${e}-error`,role:"alert",className:"text-xs text-destructive",children:k}):f?h.jsx("p",{id:`${e}-help`,className:"text-xs text-muted-foreground",children:"Enter values separated by commas"}):null]})}function O7e(e,t){switch(t){case"array":return Array.isArray(e);case"object":return fa(e);case"integer":return typeof e=="number"&&Number.isInteger(e);case"number":return typeof e=="number"&&Number.isFinite(e);case"boolean":return typeof e=="boolean";case"string":return typeof e=="string";default:return!0}}function N7e(e){return e instanceof wn?e.kind==="primitive-array":Array.isArray(e)&&e.every(t=>typeof t=="string"||typeof t=="number"||typeof t=="boolean")}function AE({id:e,value:t,expectedType:n,itemType:a,itemEnum:o,minItems:s,maxItems:l,ariaLabel:c,readOnly:d=!1,onChange:f}){const p=b.useMemo(()=>{if(t instanceof wn)return t.text;try{return JSON.stringify(t,null,2)??""}catch{return""}},[t]),y=t instanceof wn?t.error:null;return h.jsxs(h.Fragment,{children:[h.jsx(CE,{id:e,"aria-label":c,value:p,onChange:k=>{const v=k.target.value;try{const w=JSON.parse(v);if(!(n==="array"?Array.isArray(w):fa(w)))throw new Error(`Value must be a JSON ${n}`);if(n==="array"&&w.some(_=>!O7e(_,a)))throw new Error(`Every item must be a JSON ${String(a)}`);if(n==="array"&&o&&w.some(_=>!o.some(C=>Object.is(_,C))))throw new Error("Enter only the allowed values");if(n==="array"&&s!==void 0&&w.length<s)throw new Error(`Enter at least ${s} ${s===1?"item":"items"}`);if(n==="array"&&l!==void 0&&w.length>l)throw new Error(`Enter at most ${l} ${l===1?"item":"items"}`);f(new wn(`json-${n}`,v,w))}catch(w){f(new wn(`json-${n}`,v,void 0,w instanceof SyntaxError?`Enter a valid JSON ${n}`:w instanceof Error?w.message:`Enter a valid JSON ${n}`))}},readOnly:d,disabled:d,"aria-invalid":y?!0:void 0,"aria-describedby":y?`${e}-error`:void 0,className:"min-h-24 font-mono text-xs"}),y?h.jsx("p",{id:`${e}-error`,role:"alert",className:"text-xs text-destructive",children:y}):null]})}function EE({id:e,value:t,ariaLabel:n="JSON object",readOnly:a=!1,onChange:o}){return h.jsx(AE,{id:e,value:t,expectedType:"object",ariaLabel:n,readOnly:a,onChange:o})}function ug({id:e,value:t,ariaLabel:n="JSON array",readOnly:a=!1,itemType:o,itemEnum:s,minItems:l,maxItems:c,onChange:d}){return h.jsx(AE,{id:e,value:t,expectedType:"array",itemType:o,itemEnum:s,minItems:l,maxItems:c,ariaLabel:n,readOnly:a,onChange:d})}function T7e({id:e,value:t,onChange:n,readOnly:a=!1,integer:o=!1,ariaLabel:s,placeholder:l}){const c=t instanceof wn?t.text:String(t??""),d=t instanceof wn?t.error:null;return h.jsxs(h.Fragment,{children:[h.jsx(Lt,{id:e,type:"text",inputMode:"decimal","aria-label":s,value:c,readOnly:a,disabled:a,placeholder:l,"aria-invalid":d?!0:void 0,"aria-describedby":d?`${e}-error`:void 0,onChange:f=>{const p=f.target.value,y=Number(p),k=/^[-+]?(?:\d+(?:\.\d*)?|\.\d+)(?:[eE][-+]?\d+)?$/.test(p.trim())&&Number.isFinite(y)&&(!o||Number.isInteger(y));n(new wn("number",p,p.trim()!==""&&k?y:void 0,p.trim()===""||k?null:`Enter a valid ${o?"integer":"number"}`))}}),d&&h.jsx("p",{id:`${e}-error`,role:"alert",className:"text-xs text-destructive",children:d})]})}function P7e(e){const t=[],n=/<a\b[^>]*href=['"]([^'"]+)['"][^>]*>(.*?)<\/a>/gi;let a=0,o=n.exec(e);for(;o!==null;){const[s,l,c]=o,d=o.index;d>a&&t.push({id:`text-${a}-${d}`,type:"text",value:e.slice(a,d)}),t.push({id:`link-${d}-${d+s.length}`,type:"link",href:l.trim(),label:c.replace(/<[^>]*>/g,"").trim()||l.trim()}),a=d+s.length,o=n.exec(e)}return a<e.length&&t.push({id:`text-${a}-${e.length}`,type:"text",value:e.slice(a)}),t.length>0?t:[{id:`text-0-${e.length}`,type:"text",value:e}]}function L7e({text:e,onOpenLink:t}){const n=P7e(e);return h.jsx("p",{className:"text-xs text-muted-foreground",children:n.map(a=>a.type==="text"?h.jsx("span",{children:a.value},a.id):t?h.jsx("button",{type:"button",className:"text-blue-600 hover:underline",onClick:()=>t(a.href),children:a.label},a.id):h.jsx("a",{href:a.href,target:"_blank",rel:"noopener noreferrer",className:"text-blue-600 hover:underline",children:a.label},a.id))})}function d2(e){return e.split("_").map(t=>t.charAt(0).toUpperCase()+t.slice(1)).join(" ")}function z7e(e,t){if(!e)return d2(t);const n=e.replace(/\s*\(e\.g\.,?\s.*?\)/gis,"").trim();return n.split(/(?<![A-Za-z0-9])\.(?=\s|$)|\.(?=\s+[A-Z])/)[0].trim().replace(/\.$/,"")||n||d2(t)}function D7e(e){if(e!=null){if(typeof e=="string"||typeof e=="number"||typeof e=="boolean")return String(e);if(Array.isArray(e)){const t=e.map(n=>typeof n=="string"||typeof n=="number"||typeof n=="boolean"?String(n):null).filter(n=>n!==null);if(t.length>0)return t.join(", ")}try{return JSON.stringify(e)}catch{return}}}function mh(e){const t=e.map(a=>d2(String(a))),n=new Map;return t.forEach((a,o)=>{const s=n.get(a)??new Set;s.add(typeof e[o]),n.set(a,s)}),e.map((a,o)=>{const s=t[o],l=(n.get(s)?.size??0)>1;return{id:`option-${o}`,value:a,label:l?`${s} (${typeof a=="string"?"text":typeof a})`:s}})}function RE(e,t,n){const a=t.anyOf;if(a&&a.length>0&&a.find(c=>c.type==="null")){const c=a.filter(d=>d.type!=="null");if(c.length===1){const d=Object.fromEntries(Object.entries(t).filter(([f])=>f!=="anyOf"));return RE(e,{...c[0],...d},n)}}const o={name:e,label:t.title||z7e(t.description,e),type:"text",required:n,description:t.description,defaultValue:t.default,example:t.example,schema:t},s=D7e(t.example);if(t.type==="object"||fa(t.properties))o.type="object";else if(t.type==="string")o.type=t.format==="password"?"password":"text",o.placeholder=s||`Enter ${d2(e).toLowerCase()}`,o.validation={minLength:t.minLength,maxLength:t.maxLength};else if(t.type==="number"||t.type==="integer")o.type="number",o.placeholder=s,o.validation={min:t.minimum,max:t.maximum};else if(t.type==="boolean")o.type="boolean";else if(t.type==="array"){const l=t.items;if(o.itemSchema=l,l?.type==="object"||l?.properties)o.type="object-array";else if(l?.enum&&Array.isArray(l.enum))o.type="multi-select",o.options=mh(l.enum);else if(l?.anyOf||l?.oneOf){const c=l.anyOf||l.oneOf,d=c.filter(f=>f.const!==void 0).map(f=>f.const);d.length>0&&d.length===c.length?(o.type="multi-select",o.options=mh(d)):l?.type==="string"||l?.type==="number"||l?.type==="integer"||l?.type==="boolean"?(o.type="array",o.placeholder=s??"Add items..."):o.type="json-array"}else l?.type==="string"||l?.type==="number"||l?.type==="integer"||l?.type==="boolean"?(o.type="array",o.placeholder=s??"Add items..."):o.type="json-array";o.validation={minItems:t.minItems,maxItems:t.maxItems}}else if(a){const l=a.filter(c=>c.const!==void 0).map(c=>c.const);l.length>0&&(o.type="select",o.options=mh(l),o.placeholder=s)}return t.enum&&Array.isArray(t.enum)&&(o.type="select",o.options=mh(t.enum),o.placeholder=s),o}function jE(e){if(!e?.properties)return[];const t=[],n=e.properties,a=e.required||[];for(const[o,s]of Object.entries(n)){const l=RE(o,s,a.includes(o));l&&t.push(l)}return t}function I7e({id:e,label:t,value:n,schema:a,readOnly:o,onOpenLink:s,onChange:l}){const c=fa(a.properties)?a.properties:null,d=fa(n)?n:{};if(!c||Object.keys(c).length===0||!fa(n)&&n!==void 0&&n!==null)return h.jsx(EE,{id:e,value:n,ariaLabel:`${t} JSON object`,readOnly:o,onChange:l});const f=new Set(Object.keys(c));return h.jsx("fieldset",{"aria-label":t,className:"rounded-md border p-3",children:h.jsx(bi,{schema:{type:"object",properties:c,required:a.required},values:d,onValuesChange:p=>{const y=Object.fromEntries(Object.entries(d).filter(([k])=>!f.has(k)));l({...y,...p})},onOpenLink:s,fieldIdPrefix:`${e}-`,readOnly:o})})}function q7e({id:e,label:t,value:n,itemSchema:a,validation:o,readOnly:s,onOpenLink:l,onChange:c}){if(!Array.isArray(n)&&n!==void 0&&n!==null)return h.jsx(ug,{id:e,value:n,ariaLabel:`${t} JSON array`,readOnly:s,itemType:"object",minItems:o?.minItems,maxItems:o?.maxItems,onChange:c});const d=Array.isArray(n)?n:[],f=fa(a?.properties)?a.properties:null,p=new Set(Object.keys(f??{})),y=o?.maxItems===void 0||d.length<o.maxItems,k=o?.minItems===void 0||d.length>o.minItems;return h.jsxs("div",{className:"space-y-3",children:[d.length===0?h.jsx("p",{className:"rounded-md border border-dashed p-3 text-sm text-muted-foreground",children:"No rows"}):d.map((v,w)=>{const S=`${e}-${w}`;return h.jsxs("fieldset",{className:"rounded-md border p-3",children:[h.jsxs("legend",{className:"px-1 text-xs font-medium text-muted-foreground",children:[t," row ",w+1]}),f&&Object.keys(f).length>0&&fa(v)?h.jsx(bi,{schema:{type:"object",properties:f,required:a?.required},values:v,onValuesChange:_=>{const C=Object.fromEntries(Object.entries(v).filter(([j])=>!p.has(j))),A=[...d];A[w]={...C,..._},c(A)},onOpenLink:l,fieldIdPrefix:`${S}-`,readOnly:s}):h.jsx(EE,{id:`${S}-json`,value:v,ariaLabel:`${t} row ${w+1} JSON object`,readOnly:s,onChange:_=>{const C=[...d];C[w]=_,c(C)}}),s?null:h.jsx("div",{className:"mt-2 flex justify-end",children:h.jsxs(ge,{type:"button",variant:"ghost",size:"sm","aria-label":`Remove ${t} row ${w+1}`,disabled:!k,onClick:()=>c(d.filter((_,C)=>C!==w)),children:[h.jsx(ui,{className:"mr-1.5 h-4 w-4"}),"Remove"]})})]},w)}),s?null:h.jsxs(ge,{type:"button",variant:"outline",size:"sm","aria-label":`Add ${t} row`,disabled:!y,onClick:()=>c([...d,xi(a)]),children:[h.jsx(la,{className:"mr-1.5 h-4 w-4"}),"Add row"]})]})}function xi(e,t={},n=!1){const a={...t};for(const o of jE(e??void 0)){o.name in a||(n&&o.example!==void 0?a[o.name]=o.example:o.defaultValue!==void 0?a[o.name]=o.defaultValue:o.type==="boolean"?a[o.name]=!1:o.type==="object"&&fa(o.schema.properties)&&(a[o.name]={}));const s=a[o.name];o.type==="object"&&fa(s)?a[o.name]=fa(o.schema.properties)&&Object.keys(o.schema.properties).length>0?xi(o.schema,s,n):new wn("json-object",JSON.stringify(s,null,2),s):o.type==="object-array"&&Array.isArray(s)&&(a[o.name]=s.map(l=>fa(l)?xi(o.itemSchema,l,n):l))}return a}function h2(e){const t={};for(const[n,a]of Object.entries(e))if(a instanceof wn){const o=Fl(a);o!==""&&o!==void 0&&o!==null&&(t[n]=o)}else Array.isArray(a)?t[n]=a.map(o=>o instanceof wn?Fl(o):fa(o)?h2(o):o):fa(a)?t[n]=h2(a):a!==""&&a!==void 0&&a!==null&&(t[n]=a);return t}function bi({connectorType:e,schema:t,values:n,onValuesChange:a,onOpenLink:o,fieldIdPrefix:s="",readOnly:l=!1,nativeSelects:c=!1}){const d=b.useMemo(()=>jE(t??e?.options_schema),[t,e]),f=(p,y)=>{a?.({...n,[p]:y})};return d.length===0?h.jsx("p",{className:"text-sm text-muted-foreground",children:"No configuration required."}):h.jsx("div",{className:"space-y-4",children:d.map(p=>{const y=`${s}${p.name}`;return h.jsxs("div",{className:"space-y-1.5",children:[p.type==="object"||p.type==="object-array"?h.jsxs("p",{className:"text-sm font-medium",children:[p.label,p.required&&!l&&h.jsx("span",{className:"text-red-500 ml-1",children:"*"})]}):h.jsxs("label",{htmlFor:y,className:"text-sm font-medium",children:[p.label,p.required&&!l&&h.jsx("span",{className:"text-red-500 ml-1",children:"*"})]}),p.description&&h.jsx(L7e,{text:p.description,onOpenLink:o}),(p.type==="text"||p.type==="password")&&h.jsx(Lt,{id:y,type:p.type,value:n[p.name]??"",onChange:k=>f(p.name,k.target.value),placeholder:p.placeholder,readOnly:l,disabled:l}),p.type==="number"&&h.jsx(T7e,{id:y,value:n[p.name],integer:p.schema.type==="integer",onChange:k=>f(p.name,k),placeholder:p.placeholder,readOnly:l}),p.type==="boolean"&&h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsx(Mv,{id:y,checked:n[p.name]??!1,onCheckedChange:k=>f(p.name,k),disabled:l}),h.jsx("label",{htmlFor:y,className:"text-sm",children:"Enable"})]}),p.type==="select"&&p.options&&c&&h.jsxs("select",{id:y,className:"h-9 w-full rounded-md border border-input bg-background px-3 py-1 text-sm outline-none focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:opacity-50",value:p.options.find(k=>Object.is(k.value,n[p.name]))?.id??"",onChange:k=>{const v=p.options?.find(w=>w.id===k.target.value);v&&f(p.name,v.value)},required:p.required,disabled:l,children:[h.jsx("option",{value:"",disabled:!0,children:p.placeholder||`Select ${p.label.toLowerCase()}...`}),p.options.map(k=>h.jsx("option",{value:k.id,children:k.label},k.id))]}),p.type==="select"&&p.options&&!c&&h.jsxs(si,{value:p.options.find(k=>Object.is(k.value,n[p.name]))?.id??"",onValueChange:k=>{const v=p.options?.find(w=>w.id===k);v&&f(p.name,v.value)},disabled:l,children:[h.jsx(io,{id:y,"aria-required":p.required||void 0,children:h.jsx(li,{placeholder:p.placeholder||`Select ${p.label.toLowerCase()}...`})}),h.jsx(so,{children:p.options.map(k=>h.jsx(Bn,{value:k.id,children:k.label},k.id))})]}),p.type==="multi-select"&&p.options&&h.jsx("div",{className:"flex flex-wrap gap-2 p-2 border rounded-md",children:p.options.map(k=>{const v=Array.isArray(n[p.name])?n[p.name].some(w=>Object.is(w,k.value)):!1;return h.jsx("button",{type:"button",disabled:l,onClick:()=>{const w=n[p.name]||[];v?f(p.name,w.filter(S=>!Object.is(S,k.value))):f(p.name,[...w,k.value])},className:`px-2.5 py-1 text-xs rounded-md border transition-colors ${v?"bg-primary text-primary-foreground border-primary":"bg-background hover:bg-muted border-border"}`,children:k.label},k.id)})}),p.type==="array"&&(n[p.name]!==void 0&&n[p.name]!==null&&!N7e(n[p.name])?h.jsx(ug,{id:y,value:n[p.name],ariaLabel:`${p.label} JSON array`,readOnly:l,itemType:p.itemSchema?.type,itemEnum:p.itemSchema?.enum,minItems:p.validation?.minItems,maxItems:p.validation?.maxItems,onChange:k=>f(p.name,k)}):h.jsx(j7e,{id:y,value:n[p.name],itemType:p.itemSchema?.type,itemEnum:p.itemSchema?.enum,minItems:p.validation?.minItems,maxItems:p.validation?.maxItems,placeholder:p.placeholder,readOnly:l,onChange:k=>f(p.name,k)})),p.type==="json-array"&&h.jsx(ug,{id:y,value:n[p.name],ariaLabel:`${p.label} JSON array`,readOnly:l,itemType:p.itemSchema?.type,itemEnum:p.itemSchema?.enum,minItems:p.validation?.minItems,maxItems:p.validation?.maxItems,onChange:k=>f(p.name,k)}),p.type==="object"&&h.jsx(I7e,{id:y,label:p.label,value:n[p.name],schema:p.schema,readOnly:l,onOpenLink:o,onChange:k=>f(p.name,k)}),p.type==="object-array"&&h.jsx(q7e,{id:y,label:p.label,value:n[p.name],itemSchema:p.itemSchema,validation:p.validation,readOnly:l,onOpenLink:o,onChange:k=>f(p.name,k)})]},p.name)})})}function H7e({connectionId:e,modes:t,onModeChange:n,policyOperations:a,browse:o=!1,onReviewPermissions:s}){const{data:l}=pk(e),c=b.useMemo(()=>(l??[]).filter(R=>R.kind==="write"),[l]),d=b.useMemo(()=>new Map(c.map(R=>[R.operation_key,R])),[c]),f=b.useMemo(()=>a?a.map(R=>d.get(R.operation_key)??R):c,[a,c,d]),p=b.useMemo(()=>Object.fromEntries(f.map(R=>[R.operation_key,xi(R.output_schema,{},!0)])),[f]),{initialInputs:y,inputSchemas:k}=b.useMemo(()=>({initialInputs:Object.fromEntries(f.map(R=>[R.operation_key,xi(R.input_schema)])),inputSchemas:Object.fromEntries(f.map(R=>[R.operation_key,R.input_schema]))}),[f]),v=Bl(e,y,k),{values:w,setValues:S}=v,[_,C]=b.useState({}),[A,j]=b.useState(null),N=w0e(),I=(R,H)=>{S(D=>({...D,[R]:H}))},T=async R=>{if(!(v.hasConflict||Xu(w[R]))){j(R),C(H=>{const D={...H};return delete D[R],D});try{const H=await N.mutateAsync({connection_id:e,operation_key:R,input:Fl(w[R]??{})});C(D=>({...D,[R]:H}))}catch(H){C(D=>({...D,[R]:{run_id:0,status:"failed",error_message:H instanceof Error?H.message:String(H)}}))}finally{j(null)}}};if(f.length===0)return null;const q=(R,H=!1)=>{const D=R.operation_key,G=A===D,$=_[D],X=l?.find(W=>W.operation_key===D),F=X?.readiness==="scope_upgrade_required"||X?.readiness==="auth_required";return h.jsxs(J2,{open:H?!0:void 0,children:[H&&h.jsxs("div",{className:"mb-5 space-y-2",children:[h.jsx("h3",{className:"text-sm font-medium",children:"Provider permissions"}),h.jsx("p",{className:"text-sm text-muted-foreground",children:F?"Additional access is needed before this action can run.":X?.readiness&&X.readiness!=="ready"&&X.readiness!=="disabled"?`Availability: ${X.readiness.replaceAll("_"," ")}`:X?.readiness==="ready"?"Provider access is ready.":"Provider access is checked when the action runs."}),F&&s&&h.jsx(ge,{variant:"outline",size:"sm",onClick:s,children:"Review permissions"})]}),h.jsxs("div",{className:"flex flex-wrap items-start gap-2 sm:flex-nowrap",children:[!H&&h.jsxs(e0,{className:"flex min-w-0 flex-[1_1_12rem] items-start gap-1.5 text-sm text-left group",children:[h.jsx(da,{className:"h-3 w-3 mt-1 text-muted-foreground shrink-0 transition-transform group-data-[state=open]:rotate-90"}),h.jsxs("span",{className:"min-w-0 flex-1",children:[h.jsx("span",{className:"block font-medium",children:R.name??D}),R.description&&h.jsx("span",{className:"line-clamp-2 text-xs text-muted-foreground group-data-[state=open]:line-clamp-none",children:R.description})]})]}),!H&&n?h.jsx(cg,{value:lg(R,t??{}),onChange:W=>n(D,W),"aria-label":`Mode for ${R.name??D}`}):null]}),h.jsx(t0,{children:h.jsxs("div",{className:H?"mt-5 space-y-3":"ml-4 mt-1.5 space-y-3",children:[v.revision?.[D]&&h.jsxs("div",{children:[h.jsx("p",{className:"text-xs text-muted-foreground mb-1",children:"Input"}),h.jsx(bi,{schema:v.revision[D],values:w[D],onValuesChange:W=>I(D,W),fieldIdPrefix:`action-${e}-${D}-`})]}),R.output_schema&&h.jsxs("div",{children:[h.jsx("p",{className:"text-xs text-muted-foreground mb-1",children:"Output Schema"}),h.jsx(bi,{schema:R.output_schema,values:p[D],fieldIdPrefix:`action-${e}-${D}-output-`,readOnly:!0})]}),d.has(D)?h.jsx(ge,{size:"sm",variant:"outline",onClick:()=>T(D),disabled:F||v.hasConflict||Xu(w[D])||G||A!==null,children:G?h.jsxs(h.Fragment,{children:[h.jsx(dt,{size:"md",className:"mr-1.5"}),"Running..."]}):h.jsxs(h.Fragment,{children:[h.jsx(a7,{className:"mr-1.5 h-3.5 w-3.5"}),"Run"]})}):null,$&&h.jsx(V7e,{result:$})]})})]},D)};return o?h.jsxs("div",{className:"space-y-3",children:[h.jsx(xs,{visible:v.hasConflict,onReload:v.reset}),h.jsx(x7e,{entries:f.map(R=>({id:R.operation_key,name:R.name??R.operation_key,description:R.description,operation:R,status:l?.find(H=>H.operation_key===R.operation_key)?.readiness==="scope_upgrade_required"?"Additional provider access needed":void 0})),label:"actions",renderControl:({operation:R})=>n?h.jsx(cg,{value:lg(R,t??{}),onChange:H=>n(R.operation_key,H),"aria-label":`Mode for ${R.name??R.operation_key}`}):null,renderDetail:({operation:R})=>q(R,!0)})]}):h.jsxs("div",{className:"space-y-1.5",children:[h.jsx(xs,{visible:v.hasConflict,onReload:v.reset}),h.jsx("div",{className:"space-y-2",children:f.map(R=>q(R))})]})}function V7e({result:e}){return e.status==="completed"?h.jsxs("div",{className:"rounded-md bg-green-50 dark:bg-green-950/30 p-3 text-sm space-y-1",children:[h.jsxs("div",{className:"flex items-center gap-1.5 text-green-700 dark:text-green-400 font-medium",children:[h.jsx(Dg,{className:"h-3.5 w-3.5"}),"Completed",h.jsxs("span",{className:"text-xs font-normal text-muted-foreground ml-auto",children:["Run #",e.run_id]})]}),e.output&&Object.keys(e.output).length>0&&h.jsx("pre",{className:"text-xs text-green-800 dark:text-green-300 font-mono whitespace-pre-wrap mt-1",children:JSON.stringify(e.output,null,2)})]}):e.status==="pending_approval"?h.jsxs("div",{className:"rounded-md bg-yellow-50 dark:bg-yellow-950/30 p-3 text-sm",children:[h.jsxs("div",{className:"flex items-center gap-1.5 text-yellow-700 dark:text-yellow-400 font-medium",children:[h.jsx(BM,{className:"h-3.5 w-3.5"}),"Pending Approval",h.jsxs("span",{className:"text-xs font-normal text-muted-foreground ml-auto",children:["Run #",e.run_id]})]}),e.message&&h.jsx("p",{className:"text-xs text-yellow-800 dark:text-yellow-300 mt-1",children:e.message})]}):h.jsxs("div",{className:"rounded-md bg-red-50 dark:bg-red-950/30 p-3 text-sm",children:[h.jsxs("div",{className:"flex items-center gap-1.5 text-red-700 dark:text-red-400 font-medium",children:[h.jsx(w2,{className:"h-3.5 w-3.5"}),"Failed",e.run_id>0&&h.jsxs("span",{className:"text-xs font-normal text-muted-foreground ml-auto",children:["Run #",e.run_id]})]}),e.error_message&&h.jsx("p",{className:"text-xs text-red-800 dark:text-red-300 font-mono mt-1",children:e.error_message})]})}function F7e(e){if(e)return e}function B7e(e){return F7e(e)?.methods??[]}function dg({requiredScopes:e,optionalScopes:t,selectedOptionalScopes:n,grantedScopes:a=[],onToggleOptionalScope:o}){const s=b.useId();return!e.length&&!t.length&&!a.length?null:h.jsxs("div",{className:"space-y-3 text-sm",children:[a.length>0&&h.jsxs("div",{children:[h.jsx("p",{className:"font-medium",children:"Already granted"}),h.jsx("p",{className:"text-muted-foreground",children:"These permissions are included when you authorize again."}),h.jsx("ul",{className:"mt-1 space-y-1",children:a.map(l=>h.jsx("li",{className:"break-all",children:l},l))})]}),e.some(l=>!a.includes(l))&&h.jsxs("div",{children:[h.jsx("p",{className:"font-medium",children:"Required permissions"}),h.jsx("ul",{className:"mt-1 space-y-1",children:e.filter(l=>!a.includes(l)).map(l=>h.jsx("li",{className:"break-all",children:l},l))})]}),t.some(l=>!a.includes(l))&&h.jsxs("fieldset",{className:"space-y-2",children:[h.jsx("legend",{className:"font-medium",children:"Additional permissions"}),t.filter(l=>!a.includes(l)).map(l=>h.jsxs("div",{className:"flex items-start gap-2",children:[h.jsx(Mv,{id:`${s}-${l}`,className:"mt-0.5",checked:n.includes(l),onCheckedChange:c=>o(l,c===!0)}),h.jsx("label",{htmlFor:`${s}-${l}`,className:"min-w-0 cursor-pointer break-all",children:l})]},l))]})]})}function hg(e){return e.invalidateQueries({predicate:t=>t.queryKey.some(n=>["auth-profiles","connections","feeds","available-operations","connector-operations",...pr].includes(String(n)))})}function PEe({result:e}){const t=sn();return b.useEffect(()=>{e&&hg(t)},[e,t]),e?h.jsx("p",{role:e==="failed"?"alert":"status",className:"rounded-md border p-3 text-sm",children:e==="connected"?"Account authorization updated. Review your permissions below.":e==="cancelled"?"Authorization cancelled. No permissions were added.":"Authorization did not finish. Review your account below to try again."}):null}function OE(e,t){const{data:n=[]}=fk(e.organization_id,{connectorKey:e.connector_key}),{data:a=[],isLoading:o,isError:s}=pk(e.id),{data:l=[]}=T9(e.id),c=n.find(p=>p.slug===e.auth_profile_slug),d=_u(t?.auth_schema).find(p=>p.type==="oauth"),f=a.filter(p=>p.readiness==="scope_upgrade_required").map(p=>({key:p.operation_key,name:p.name,scopes:p.next_action?.requested_scopes??[]}));if(c?.granted_scopes){const p=Object.entries(t?.feeds_schema??{});for(const y of l){const v=(p.find(([w,S])=>w===y.feed_key||S?.key===y.feed_key)?.[1]?.requiredScopes??[]).filter(w=>!c.granted_scopes?.includes(w));v.length&&f.push({key:`feed:${y.id}`,name:y.display_name??y.feed_key,scopes:v})}}return{profile:c,method:d,affected:f,missing:[...new Set(f.flatMap(p=>p.scopes))],isLoading:o,isError:s}}function LEe({connection:e,connectorDef:t,onReview:n}){const{affected:a}=OE(e,t),o=a.filter(s=>s.key.startsWith("feed:"));return!o.length||e.status!=="active"?null:h.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3 rounded-md border p-3",children:[h.jsxs("div",{className:"min-w-0 text-sm",children:[h.jsx("p",{className:"font-medium",children:"Some sources need additional permissions"}),h.jsxs("p",{className:"text-muted-foreground",children:[o.slice(0,3).map(s=>s.name).join(", "),o.length>3?` and ${o.length-3} more`:""]})]}),h.jsx(ge,{variant:"outline",size:"sm",onClick:n,children:"Review permissions"})]})}function NE(){const e=sn(),t=b.useRef(void 0),[n,a]=b.useState(!1),[o,s]=b.useState(null),[l,c]=b.useState(null);return b.useEffect(()=>()=>t.current?.(),[]),{begin:async f=>{t.current?.();const p=window.open("about:blank","_blank");p&&(p.opener=null);let y=!0;t.current=()=>{y=!1},a(!0),s(null),c(null);try{const k=await f();if(!y){p?.close();return}const v=k.connect_url;if(!v){if(p?.close(),k.status==="active"){hg(e);return}s(k.instructions??"Authorization could not start. Review the app configuration and try again."),c(k.setup_url??null);return}c(v);const w=()=>{hg(e),(!p||p.closed)&&(t.current?.(),c(null))},S=p?window.setInterval(()=>{p.closed&&w()},500):void 0;window.addEventListener("focus",w),t.current=()=>{y=!1,window.removeEventListener("focus",w),S&&window.clearInterval(S)},p&&(p.location.href=v)}catch(k){if(p?.close(),!y)return;s(k instanceof Error?k.message:"Authorization could not start. Try again.")}finally{y&&a(!1)}},pending:n,error:o,continueUrl:l}}function q8({connection:e,connectorDef:t}){const{profile:n,method:a,affected:o,missing:s,isLoading:l,isError:c}=OE(e,t),{session:d}=Xa(),f=P9(),p=A0e(),y=NE(),[k,v]=b.useState(!1),[w,S]=b.useState([]),_=!!d?.user?.id&&d.user.id===e.created_by&&(!e.auth_profile_slug||n?.created_by===d?.user?.id);if(!a)return null;const C=o.filter(I=>I.key.startsWith("feed:")).length,A=o.length-C,j=[C?`${C} configured ${C===1?"feed":"feeds"}`:null,A?`${A} ${A===1?"action":"actions"}`:null].filter(Boolean).join(" and "),N=I=>e.auth_profile_slug?f.mutateAsync({connection_id:e.id,requested_scopes:I}):p.mutateAsync({connector_key:e.connector_key,slug:e.slug,app_auth_profile_slug:e.app_auth_profile_slug??void 0,requested_scopes:I});return h.jsxs("div",{className:"space-y-3",children:[o.length>0&&h.jsxs("p",{role:"status",className:"text-sm text-muted-foreground",children:[j," ",o.length===1?"requires":"require"," ","additional permissions from ",t.name||a.provider,"."]}),l&&h.jsx("p",{className:"text-sm text-muted-foreground",children:"Checking permissions…"}),c&&h.jsx("p",{role:"alert",className:"text-sm text-destructive",children:"Could not check capability permissions. Refresh and try again."}),_?h.jsxs("div",{className:"flex flex-wrap gap-2",children:[h.jsx(ge,{variant:"outline",size:"sm",disabled:y.pending,onClick:()=>void y.begin(()=>N()),children:e.auth_profile_slug?"Reconnect":"Connect account"}),h.jsx(ge,{variant:"outline",size:"sm",onClick:()=>{v(!k),S(s)},children:"Review permissions"})]}):h.jsx("p",{className:"text-sm text-muted-foreground",children:"Only the account owner can reconnect this account."}),k&&_&&h.jsxs("div",{className:"space-y-3",children:[o.length>0&&h.jsxs("div",{children:[h.jsx("p",{className:"text-sm font-medium",children:C?"Feeds and actions needing access":"Actions needing access"}),h.jsx("ul",{className:"mt-1 list-disc pl-5 text-sm text-muted-foreground",children:o.map(I=>h.jsx("li",{children:I.name},I.key))})]}),h.jsx(dg,{requiredScopes:Qu(a),optionalScopes:x0(a),selectedOptionalScopes:w,grantedScopes:n?.granted_scopes,onToggleOptionalScope:(I,T)=>S(q=>T?[...new Set([...q,I])]:q.filter(R=>R!==I))}),h.jsxs(ge,{size:"sm",disabled:y.pending,onClick:()=>void y.begin(()=>N(w)),children:["Continue to ",a.provider]})]}),y.error&&h.jsx("p",{role:"alert",className:"text-sm text-destructive",children:y.error}),y.continueUrl&&h.jsx("a",{className:"text-sm underline",href:y.continueUrl,target:"_blank",rel:"noreferrer",children:"Continue authorization in your browser"})]})}const Zy="__serverless__",H8="__add_device__";function TE(e){const{session:t}=Xa();return e.auth_profile_kind!=="oauth_account"||!!(t?.user?.id&&t.user.id===e.created_by)}function zEe({connection:e,connectorDef:t,ownerSlug:n}){const a=qn(),o=b.useId(),s=u1(),l=L9(),[c,d]=b.useState(e.display_name??""),[f,p]=b.useState(!1),y=c!==(e.display_name??""),k=e.facets?.chat??!1,v=()=>{s.mutate({connection_id:e.id,display_name:c.trim()||void 0})},w=()=>{t?.required_capability&&(window.location.href=Fh(`revoke/${t.required_capability}`)),l.mutate(e.id,{onSuccess:()=>{a({to:"/$owner/connectors/$connectorKey",params:{owner:n,connectorKey:e.connector_key}})}})};return h.jsxs("div",{className:"space-y-6",children:[h.jsxs("dl",{className:"flex flex-wrap gap-x-6 gap-y-2 text-sm",children:[h.jsxs("div",{children:[h.jsx("dt",{className:"text-muted-foreground",children:"Owner"}),h.jsx("dd",{children:e.created_by_username??"Unknown owner"})]}),h.jsxs("div",{children:[h.jsx("dt",{className:"text-muted-foreground",children:"Access"}),h.jsx("dd",{children:e.visibility==="org"?"Shared with workspace":"Private"})]})]}),h.jsxs("div",{className:"space-y-2",children:[h.jsx(ha,{htmlFor:o,children:"Display name"}),h.jsxs("div",{className:"flex gap-2",children:[h.jsx(Lt,{id:o,value:c,onChange:S=>d(S.target.value),placeholder:t?.name??e.connector_key,className:"max-w-md"}),h.jsx(ge,{onClick:v,disabled:!y||s.isPending,children:s.isPending?h.jsxs(h.Fragment,{children:[h.jsx(dt,{size:"lg",className:"mr-2"}),"Saving..."]}):"Save"})]})]}),!k&&h.jsx(U7e,{connection:e,connectorDef:t,ownerSlug:n}),k&&h.jsx($7e,{connection:e,connectorDef:t}),!k&&h.jsx(Y7e,{connection:e,connectorDef:t,ownerSlug:n}),h.jsxs("div",{className:"rounded-lg border border-destructive/30 bg-destructive/5 p-4",children:[h.jsx("p",{className:"text-sm font-medium",children:"Delete this connection"}),h.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:k?"Disconnects this connection. Past messages stay in your workspace.":"Removes the connection and stops its feeds. Past events stay in your workspace."}),h.jsx("div",{className:"mt-3",children:f?h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsxs(ge,{variant:"destructive",size:"sm",disabled:l.isPending,onClick:w,children:[l.isPending?h.jsx(dt,{size:"md",className:"mr-1.5"}):null,"Confirm delete"]}),h.jsx(ge,{variant:"ghost",size:"sm",onClick:()=>p(!1),disabled:l.isPending,children:"Cancel"})]}):h.jsxs(ge,{variant:"outline",size:"sm",className:"text-destructive hover:text-destructive",onClick:()=>p(!0),children:[h.jsx(ui,{className:"mr-1.5 h-3.5 w-3.5"}),"Delete connection"]})})]})]})}function $7e({connection:e,connectorDef:t}){const n=u1(),[a,o]=b.useState(null),s=k7e(e.slug),l=t?.options_schema,c=l&&typeof l=="object"&&Object.keys(l.properties??l).length>0?l:null,d=Bl(e.id,{},c),{values:f,setValues:p}=d,y=d.hasInvalidInput?{}:h2(f),k=e.effective_credential_mode==="managed",v=(t?.auth_schema?.methods??[]).find(A=>A.type==="app_installation"),w=v?.permissions??[],S=v?.events??[],_=e.connector_key==="slack"&&w.length>0?JSON.stringify({display_information:{name:e.display_name??"Lobu bot"},features:{bot_user:{display_name:e.display_name??"Lobu bot",always_online:!0},slash_commands:[{command:"/lobu",url:s,description:"Talk to Lobu"}]},oauth_config:{scopes:{bot:w}},settings:{event_subscriptions:{request_url:s,bot_events:S},interactivity:{is_enabled:!0,request_url:s},socket_mode_enabled:!1}},null,2):null,C=async(A,j)=>{await navigator.clipboard.writeText(j),o(A),window.setTimeout(()=>o(null),1500)};return h.jsxs("div",{className:"space-y-4",children:[h.jsxs("div",{className:"space-y-2",children:[h.jsx(ha,{children:"Webhook URL"}),h.jsxs("div",{className:"flex max-w-2xl gap-2",children:[h.jsx(Lt,{value:s,readOnly:!0,className:"font-mono text-xs"}),h.jsx(ge,{variant:"outline",size:"icon",onClick:()=>void C("webhook",s),children:a==="webhook"?h.jsx(Za,{className:"h-4 w-4"}):h.jsx(Hu,{className:"h-4 w-4"})})]}),h.jsx("p",{className:"text-xs text-muted-foreground",children:"Configure this as the provider's events, commands, and interactivity endpoint."})]}),_?h.jsxs("div",{className:"space-y-2",children:[h.jsx(ha,{children:"Slack app manifest"}),h.jsx("p",{className:"text-xs text-muted-foreground",children:"Create a Slack app from this manifest, or copy it into Slack's app manifest editor to configure events, scopes, commands, and interactivity together. Then install the app and paste its bot token + signing secret back into the connection credentials."}),h.jsxs("div",{className:"flex gap-2",children:[h.jsx(ge,{asChild:!0,variant:"outline",size:"sm",children:h.jsxs("a",{href:`https://api.slack.com/apps?new_app=1&manifest_json=${encodeURIComponent(_)}`,target:"_blank",rel:"noreferrer",children:[h.jsx(a1,{className:"mr-1.5 h-3.5 w-3.5"}),"Create app in Slack"]})}),h.jsxs(ge,{variant:"outline",size:"sm",onClick:()=>void C("manifest",_),children:[a==="manifest"?h.jsx(Za,{className:"mr-1.5 h-3.5 w-3.5"}):h.jsx(Hu,{className:"mr-1.5 h-3.5 w-3.5"}),"Copy manifest"]})]})]}):null,!k&&d.revision?h.jsxs("div",{className:"space-y-3",children:[h.jsxs("div",{children:[h.jsx(ha,{children:"Rotate credentials"}),h.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:"Enter only values you want to replace. Stored secrets are never shown here."})]}),h.jsx(bi,{schema:d.revision??void 0,values:f,onValuesChange:p}),h.jsx(xs,{visible:d.hasConflict,onReload:d.reset}),h.jsxs(ge,{disabled:!d.canSubmit||Object.keys(y).length===0||n.isPending,onClick:()=>n.mutate({connection_id:e.id,config:y}),children:[n.isPending?h.jsx(dt,{size:"md",className:"mr-2"}):null,"Update credentials"]})]}):null]})}function U7e({connection:e,connectorDef:t,ownerSlug:n}){const a=qn(),o=TE(e),s=u1(),{data:l=[],refetch:c,isFetching:d}=d1(),f=t?.required_capability??null,p=e.device_worker_id,y=b.useMemo(()=>{const w=l.filter(S=>S.organization_id===e.organization_id&&(!f||S.capabilities.includes(f)));return p&&!w.some(S=>S.id===p)?[{id:p,worker_id:e.device_worker_handle??p,platform:e.device_platform??null,app_version:null,capabilities:[],label:e.device_label??null,last_seen_at:"",online:e.device_online??!1,organization_id:e.organization_id,organization_name:null,organization_slug:null,connector_count:0,connector_error_count:0,last_sync_at:null,connectors:[]},...w]:w},[l,f,e,p]),k=w=>{if(w===H8){a({to:"/$owner/connectors/create",params:{owner:n}});return}const S=w===Zy?null:w;S!==(p??null)&&s.mutate({connection_id:e.id,device_worker_id:S})},v=p??(f?"":Zy);return h.jsxs("div",{className:"space-y-2",children:[h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsxs(ha,{children:["Run on",f?h.jsx("span",{className:"text-destructive ml-1",children:"*"}):null]}),s.isPending?h.jsxs("span",{className:"inline-flex items-center gap-1 text-xs text-muted-foreground",children:[h.jsx(dt,{size:"sm"}),"Saving…"]}):null]}),h.jsxs("div",{className:"flex items-center gap-2 max-w-md",children:[h.jsxs(si,{value:v,onValueChange:k,disabled:!o||s.isPending,children:[h.jsx(io,{className:"h-8 flex-1",children:h.jsx(li,{placeholder:"Select a device"})}),h.jsxs(so,{children:[!f&&h.jsx(Bn,{value:Zy,children:"Serverless (default)"}),y.map(w=>h.jsx(TA,{device:w},w.id)),h.jsx(Bn,{value:H8,children:h.jsxs("span",{className:"flex items-center gap-2 text-muted-foreground",children:[h.jsx(la,{className:"h-3.5 w-3.5"}),"Add device"]})})]})]}),h.jsxs("button",{type:"button",onClick:()=>void c(),disabled:d,className:"inline-flex shrink-0 items-center gap-1 text-xs text-muted-foreground hover:text-foreground disabled:opacity-50",children:[h.jsx(M2,{className:`h-3 w-3 ${d?"animate-spin":""}`}),"Refresh"]})]}),f&&y.length===0?h.jsxs("p",{className:"text-xs text-muted-foreground",children:["No device has granted the “",f_[f]??f,"” permission. Open the Lobu app on a device and grant it, then"," ",h.jsx("button",{type:"button",onClick:()=>void c(),className:"underline hover:text-foreground",children:"refresh"}),"."]}):p&&e.device_online===!1?h.jsxs("p",{className:"text-xs text-muted-foreground",children:["Device offline — sync runs wait for it to check in",e.device_last_seen_at?` (last seen ${k1(e.device_last_seen_at)})`:"","."]}):null]})}const K7e={env:"Environment variable",oauth_app:"OAuth app (workspace-wide)",oauth_account:"OAuth account",browser_session:"Browser session (local)",interactive:"Interactive credential"},G7e={env:"A secret pulled from the worker process env. Update by changing the env var on whichever device runs this connector.",oauth_app:"Shared client configuration managed by workspace administrators. Account owners grant consent separately.",oauth_account:"The account owner can reconnect to renew access or grant additional permissions.",browser_session:"Reuses your local browser cookies on a device. Sign in again using the browser pairing flow on that device.",interactive:"A credential the agent fills in at run-time (e.g. a one-time code). Nothing stored long-term."};function PE({heading:e,name:t,kind:n,status:a,isDefault:o,headerRight:s,footer:l}){const c=n?K7e[n]:null,d=n?G7e[n]:null;return h.jsxs("div",{className:ye(Yl,"space-y-1.5 p-4"),children:[h.jsxs("div",{className:"flex items-center justify-between gap-2",children:[h.jsx("p",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wider",children:e}),s]}),h.jsxs("div",{className:"flex flex-wrap items-baseline gap-x-2 gap-y-0.5",children:[h.jsx("span",{className:"text-sm font-medium",children:t}),c?h.jsxs("span",{className:"text-xs text-muted-foreground",children:["· ",c]}):null,a?h.jsxs("span",{className:a==="active"?"text-xs text-green-500":"text-xs text-amber-500",children:["· ",a]}):null,o?h.jsx("span",{className:"rounded-md bg-muted px-1.5 py-0.5 text-[10px] font-medium uppercase tracking-wide text-muted-foreground",children:"Org default"}):null]}),d?h.jsx("p",{className:"text-xs text-muted-foreground",children:d}):null,l]})}function Y7e({connection:e,connectorDef:t,ownerSlug:n}){const a=l7e(t?.auth_schema),o=B7e(t?.auth_schema).some(p=>p.type==="oauth"),s=a?a.provider.charAt(0).toUpperCase()+a.provider.slice(1):null,l=e.config?.managedBy;if(l&&typeof l=="object"&&"org"in l&&typeof l.org=="string")return h.jsxs("div",{className:"space-y-2",children:[h.jsx(ha,{children:"Auth"}),h.jsxs("p",{className:"text-sm text-muted-foreground",children:["Managed authorization from ",l.org,". This runtime uses its cloud login to access your grant."]})]});const c=dE(e,t?.auth_schema);if(c)return h.jsxs("div",{id:"connection-auth",className:"space-y-2 scroll-mt-6",children:[h.jsx(ha,{children:"Auth"}),h.jsx("p",{className:"text-sm text-muted-foreground",children:Oh(c)})]});if(!e.auth_profile_name)return h.jsxs("div",{id:"connection-auth",className:"space-y-2 scroll-mt-6",children:[h.jsx(eg,{organizationId:e.organization_id,connectorKey:e.connector_key}),h.jsx(ha,{children:"Auth"}),a?h.jsxs("div",{className:"space-y-2",children:[h.jsxs("p",{className:"text-sm text-muted-foreground",children:["No ",s," App installation linked yet."]}),h.jsx(Xm,{organizationId:e.organization_id,connectorKey:e.connector_key,provider:a.provider,providerLabel:t?.name,installShape:a.installShape,recovery:!0,variant:"outline"})]}):h.jsxs("div",{className:"space-y-2",children:[h.jsx("p",{className:"text-sm text-muted-foreground",children:o?"No account is connected yet.":"No auth profile attached."}),o&&t&&h.jsx(q8,{connection:e,connectorDef:t})]})]});const d=e.auth_profile_kind==="oauth_account"&&!!e.app_auth_profile_name,f=d?"Account":"Profile";return h.jsxs("div",{id:"connection-auth",className:"space-y-2 scroll-mt-6",children:[h.jsx(ha,{children:"Auth"}),h.jsxs("div",{className:"space-y-2",children:[d&&e.app_auth_profile_name?h.jsx(W7e,{connection:e,ownerSlug:n}):null,h.jsx(PE,{heading:f,name:e.auth_profile_name,kind:e.auth_profile_kind,status:e.auth_profile_status,footer:e.auth_profile_kind==="oauth_account"&&t?h.jsx(q8,{connection:e,connectorDef:t}):void 0}),t?.key?h.jsxs("p",{className:"text-xs text-muted-foreground",children:["Connector slug:"," ",h.jsx("code",{className:"font-mono",children:t.key})]}):null,a?h.jsxs("div",{className:"space-y-1.5 pt-1",children:[h.jsx(eg,{organizationId:e.organization_id,connectorKey:e.connector_key}),h.jsx(Xm,{organizationId:e.organization_id,connectorKey:e.connector_key,provider:a.provider,providerLabel:t?.name,installShape:a.installShape,recovery:!0,variant:"outline"})]}):null]})]})}function W7e({connection:e,ownerSlug:t}){const{isAdmin:n}=mv(e.organization_id),{data:a=[]}=fk(e.organization_id,{connectorKey:e.connector_key,profileKind:"oauth_app"}),o=e.app_auth_profile_slug??void 0,s=a.find(c=>c.slug===o)??null,l=!!s?.is_default_for_connector&&s.connector_key===e.connector_key;return h.jsx(PE,{heading:"Workspace app",name:e.app_auth_profile_name??"—",kind:e.app_auth_profile_kind??"oauth_app",status:e.app_auth_profile_status,isDefault:l,headerRight:n?h.jsx(Ct,{to:"/$owner/connectors/$connectorKey",params:{owner:t,connectorKey:e.connector_key},search:{setup:"oauth_app"},hash:"connector-oauth-apps",className:"text-xs text-muted-foreground hover:text-foreground",children:"Manage app"}):null,footer:n?h.jsx("p",{className:"text-xs text-muted-foreground",children:"This account stays linked to the app used to authorize it. To use another app, connect a new account."}):void 0})}function Z7e({connection:e,inPeek:t=!1,onReviewPermissions:n}){const{data:a=[],isLoading:o,isError:s}=pk(e.id),l=u1(),c=TE(e),d=Bl(e.id,yE(e.config)),{values:f,setValues:p}=d;if(o)return h.jsx("p",{className:"text-sm text-muted-foreground",children:"Loading actions…"});if(s)return h.jsx("p",{role:"alert",className:"text-sm",children:"Could not load actions. Close the pane and try again."});if(a.length===0)return h.jsx("p",{className:"text-sm text-muted-foreground",children:"No actions available."});const y=(w,S)=>{p(_=>({..._,[w]:S}))},k=()=>{if(!d.canSubmit)return;const w={...e.config??{},action_modes:f};l.mutate({connection_id:e.id,config:w},{onSuccess:()=>d.accept(f,f)})},v=h.jsxs("div",{className:"space-y-3",children:[h.jsx(H7e,{connectionId:e.id,browse:t,onReviewPermissions:n,modes:f,onModeChange:c?y:void 0,policyOperations:a}),l.isError&&h.jsx("p",{role:"alert",className:"text-sm text-destructive",children:"Could not save the policy. Your changes are still here; try again."}),h.jsx(xs,{visible:d.hasConflict,onReload:d.reset}),c&&d.dirty?h.jsxs("div",{className:t?"sticky bottom-0 z-10 flex justify-end gap-2 border-t bg-background py-3":"flex justify-end gap-2",children:[h.jsx(ge,{variant:"outline",size:"sm",onClick:d.reset,children:"Cancel"}),h.jsx(ge,{size:"sm",onClick:k,disabled:l.isPending||!d.canSubmit,children:l.isPending?"Saving...":"Save"})]}):null]});return t?v:h.jsx(y7e,{title:"Actions",count:`${a.length} ${a.length===1?"action":"actions"}`,children:v})}function Q7e({isInstalling:e,installConnectorFromSourceUri:t,reloadConnectorCatalog:n,resetConnectorConfiguration:a,selectConnector:o,clearSaveError:s,setInstallError:l}){const[c,d]=b.useState(null),[f,p]=b.useState(null),y=b.useCallback(async w=>{if(!e){if(l(null),s(),w.installed===!1&&w.installable){p(w);return}o(w),a()}},[s,e,a,o,l]),k=b.useCallback(async()=>{if(!f||e)return null;if(!f.source_uri)return l(`Connector '${f.name}' is missing a source URI.`),null;d(f.key);try{await t(f.source_uri);const S=(await n()).find(_=>_.key===f.key&&_.installed!==!1)??null;if(!S)throw new Error(`Installed connector '${f.name}' could not be reloaded.`);return p(null),S}catch(w){return l(w instanceof Error?w.message:"Failed to install connector"),null}finally{d(null)}},[t,e,f,n,l]),v=b.useCallback(()=>{p(null),l(null)},[l]);return{installingConnectorKey:c,setInstallingConnectorKey:d,previewConnector:f,handleConnectorSelect:y,handleInstallPreviewedConnector:k,clearPreview:v}}function X7e({open:e,onOpenChange:t,organizationId:n,editingConnection:a,connections:o=[],initialConnectorKey:s,onDeepLinkBack:l}){const c=b0e(),d=NE(),{session:f}=Xa(),p=u1(),y=S0e(),k=C0e(),v=_0e(),{data:w=[],isLoading:S,refetch:_}=hk(n),C=!!a,A=L9(),j=O0e(),[N,I]=b.useState(!1),[T,q]=b.useState(null),[R,H]=b.useState(!1),[D,G]=b.useState(""),[$,X]=b.useState(null),[F,W]=b.useState(""),[P,U]=b.useState(null),[J,se]=b.useState(""),L=Bl(`${a?.id??"new"}:${P?.key??""}:${e}`,xi(P?.options_schema,a?.config??{}),P?.options_schema),{values:B,setValues:V}=L,[O,ee]=b.useState({}),[Q,ae]=b.useState(0),[oe,de]=b.useState(void 0),[pe,Re]=b.useState(void 0),[Pe,De]=b.useState(!1),[bt,Ye]=b.useState(""),[kn,Qt]=b.useState(""),[Xt,ln]=b.useState(!1),[Ot,Jt]=b.useState(""),[va,Nt]=b.useState(""),[Wn,At]=b.useState(!1),[lt,ie]=b.useState(""),[me,Ne]=b.useState(""),[Ie,Ve]=b.useState([]),[vn,Ut]=b.useState(!1),[Kt,Et]=b.useState(""),[Gt,rt]=b.useState(""),[Nn,cn]=b.useState(void 0),[zt,xa]=b.useState(a?.device_worker_id??void 0),[wo,gr]=b.useState(!1),[za,Oe]=b.useState(null),[St,It]=b.useState(null),{isAdmin:qt}=mv(n),kr=b.useMemo(()=>_u(P?.auth_schema).find(Be=>Be.type==="oauth")?.provider??void 0,[P?.auth_schema]),{data:et=[]}=fk(n,{connectorKey:P?.key,provider:kr});b.useEffect(()=>{if(!a||!e||P||S)return;const Me=w.find(Jn=>Jn.key===a.connector_key)??{key:a.connector_key,name:a.connector_name||a.connector_key,description:null,version:"",auth_schema:null,feeds_schema:null,actions_schema:null,options_schema:null,status:"active",login_enabled:!1};U(Me),se(a.display_name??""),de(a.auth_profile_slug??void 0),Re(a.app_auth_profile_slug??void 0),xa(a.device_worker_id??void 0);const hn=_u(Me.auth_schema).findIndex(Jn=>a.auth_profile_kind==="browser_session"?Jn.type==="browser":a.auth_profile_kind==="oauth_account"||a.app_auth_profile_slug?Jn.type==="oauth":a.auth_profile_kind==="env"?Jn.type==="env_keys":dE(a,Me.auth_schema)?Jn.type==="none":!1);ae(hn>=0?hn:0)},[a,e,w,P,S]);const Cn=b.useMemo(()=>_u(P?.auth_schema),[P]),we=Cn[Q]??null,un=b.useMemo(()=>et.filter(ve=>ve.profile_kind==="env"),[et]),Yt=b.useMemo(()=>{if(!we||we.type!=="oauth")return[];const ve=we.provider.toLowerCase();return et.filter(Me=>Me.profile_kind==="oauth_account"&&Me.provider?.toLowerCase()===ve&&(qt||Me.created_by===f?.user?.id))},[we,et,qt,f?.user?.id]),ba=b.useMemo(()=>{if(!we||we.type!=="oauth")return[];const ve=we.provider.toLowerCase();return et.filter(Me=>Me.profile_kind==="oauth_app"&&Me.status==="active"&&Me.provider?.toLowerCase()===ve)},[we,et]),Tn=b.useMemo(()=>et.filter(ve=>ve.profile_kind==="browser_session"),[et]),Hi=b.useMemo(()=>{if(!(!we||we.type!=="env_keys"))return d7e(we)},[we]),Ds=b.useMemo(()=>f7e(we),[we]),wa=Bl(`${P?.key}:${Q}:${Pe}`,xi(Hi),Hi),Ht=Bl(`${P?.key}:${Q}:${Xt}`,xi(Ds),Ds),{values:xn,setValues:Mo}=wa,{values:Vi,setValues:_0}=Ht,Is=b.useMemo(()=>we?.type==="oauth"?x0(we):[],[we]);b.useEffect(()=>{if(!(C||!P||!we))if(we.type==="oauth"){if(!pe&&ba.length>0){const Me=ba.find(Be=>Be.is_default_for_connector&&Be.connector_key===P.key)??(qt&&ba.length===1?ba[0]:void 0);Me&&Re(Me.slug)}!oe&&Yt.length>0&&de(Yt[0].slug)}else we.type==="env_keys"?!oe&&un.length>0&&de(un[0].slug):we.type==="browser"&&!oe&&Tn.length>0&&de(Tn[0].slug)},[qt,C,P,we,pe,oe,ba,Yt,un,Tn]),b.useEffect(()=>{if(we?.type!=="oauth"||Is.length===0){Ve(Be=>Be.length===0?Be:[]);return}const Me=(Yt.find(Be=>Be.slug===oe)?.requested_scopes??[]).filter(Be=>Is.includes(Be));Ve(Be=>Be.length===Me.length&&Be.every((hn,Jn)=>hn===Me[Jn])?Be:Me)},[we,Is,Yt,oe]);const pc=b.useCallback(()=>{De(!1),Ye(""),Qt(""),ln(!1),Jt(""),Nt(""),At(!1),ie(""),Ne(""),Ve([]),Ut(!1),Et(""),rt("")},[]),Dr=b.useCallback(()=>{ee({}),ae(0),de(void 0),Re(void 0),pc()},[pc]);b.useEffect(()=>{if(C||!P)return;const ve=P.default_connection_config;ve&&typeof ve=="object"&&ee(ve)},[C,P]);const{data:Fi=[],refetch:So,isFetching:_o}=d1(),Zn=P?.required_capability??null,Ma=b.useMemo(()=>{const ve=Fi.filter(Be=>Be.organization_id===n&&(!Zn||Be.capabilities.includes(Zn))),Me=a?.device_worker_id;return Me&&!ve.some(Be=>Be.id===Me)?[{id:Me,worker_id:a?.device_worker_handle??Me,platform:a?.device_platform??null,app_version:null,capabilities:[],label:a?.device_label??null,last_seen_at:"",online:a?.device_online??!1,organization_id:n,organization_name:null,organization_slug:null,connector_count:0,connector_error_count:0,last_sync_at:null,connectors:[]},...ve]:ve},[Fi,Zn,a,n]);b.useEffect(()=>{C||xa(void 0)},[P?.key,C]),b.useEffect(()=>{if(zt&&!Ma.some(ve=>ve.id===zt)&&zt!==a?.device_worker_id){xa(void 0);return}C||!Zn||zt||Ma.length===1&&xa(Ma[0].id)},[C,Zn,zt,Ma,a]);const Co=b.useMemo(()=>oe?et.find(ve=>ve.slug===oe&&ve.profile_kind==="browser_session"):void 0,[et,oe])?.device_worker_id??null;b.useEffect(()=>{Co&&zt!==Co&&xa(Co)},[Co,zt]);const A1=b.useCallback(async()=>(await _()).data??[],[_]),{installingConnectorKey:Ir,setInstallingConnectorKey:Ao,previewConnector:E1,handleConnectorSelect:qs,handleInstallPreviewedConnector:R1,clearPreview:yc}=Q7e({isInstalling:j.isPending,installConnectorFromSourceUri:async ve=>{await j.mutateAsync({source_uri:ve})},reloadConnectorCatalog:A1,resetConnectorConfiguration:Dr,selectConnector:U,clearSaveError:()=>Oe(null),setInstallError:X}),Eo=ve=>{ve||(U(null),se(""),Dr(),cn(void 0),Oe(null),I(!1),q(null),H(!1),G(""),X(null),Ao(null),W(""),It(null),yc()),t(ve)},Hs=()=>{if(P&&s&&l){l();return}P?(U(null),Dr(),cn(void 0),Oe(null),X(null)):E1&&yc()},Da=b.useRef(!1);b.useEffect(()=>{if(Da.current||C||!s||P)return;const ve=w.find(Me=>Me.key===s);ve&&(Da.current=!0,qs(ve))},[e,C,s,w,P,qs]);const Qn=b.useMemo(()=>{if(!P||!L.revision||we&&we.type!=="none")return!1;const ve=L.revision.properties;if(!ve)return!1;const Me=new Set,Be=P.feeds_schema;if(Be){for(const hn of Object.values(Be))if(hn.configSchema?.properties)for(const Jn of Object.keys(hn.configSchema.properties))Me.add(Jn)}return Object.keys(ve).some(hn=>!Me.has(hn))},[P,we,L.revision]),Vs=b.useMemo(()=>{const ve=_u(P?.auth_schema),Me=P?.auth_schema?.methods??[];return ve.length===0&&Me.length>0&&Me.every(Be=>Be.type==="none")},[P]),C0=b.useMemo(()=>!Vs||!P||!Nn?null:o.find(ve=>ve.connector_key===P.key&&ve.created_by===Nn)??null,[Vs,P,Nn,o]),qr=b.useCallback(ve=>Object.fromEntries(Object.entries(ve).filter(([,Me])=>typeof Me=="string"&&Me.trim().length>0).map(([Me,Be])=>[Me,String(Be).trim()])),[]),j1=ve=>{d.begin(async()=>({connect_url:ve}))},tr=b.useCallback(async ve=>{if(!(!P||!we))try{const Me=await y.mutateAsync({connector_key:P.key,profile_kind:ve.profileKind,display_name:ve.displayName,slug:ve.slug||void 0,...ve.credentials?{credentials:ve.credentials}:{},...ve.authData?{auth_data:ve.authData}:{},...ve.requestedScopes?{requested_scopes:ve.requestedScopes}:{}});await ve.onSuccess(Me)}catch(Me){Oe(Me instanceof Error?Me.message:"Failed to create auth profile")}},[we,y,P]),A0=b.useCallback(async()=>{if(!wa.canSubmit||!we||we.type!=="env_keys")return;const ve=qr(xn);await tr({profileKind:"env",displayName:bt.trim()||`${P?.name} Auth`,slug:kn.trim(),credentials:ve,onSuccess:Me=>{de(Me.auth_profile.slug),De(!1),Ye(""),Qt("")}})},[we,tr,bt,kn,xn,wa.canSubmit,qr,P?.name]),Xn=b.useCallback(async()=>{if(!Ht.canSubmit||!we||we.type!=="oauth")return;const ve=qr(Vi);await tr({profileKind:"oauth_app",displayName:Ot.trim()||`${P?.name} ${we.provider} App`,slug:va.trim(),credentials:ve,onSuccess:Me=>{Re(Me.auth_profile.slug),ln(!1),Jt(""),Nt("")}})},[we,tr,Ot,va,Vi,Ht.canSubmit,qr,P?.name]),mc=async()=>{if(!(!P||we?.type!=="oauth")){if(!pe){Oe("Choose an OAuth app before connecting your account.");return}Oe(null),await d.begin(async()=>{const ve=await y.mutateAsync({connector_key:P.key,profile_kind:"oauth_account",display_name:lt.trim()||`${P.name} ${we.provider} Account`,slug:me.trim()||void 0,app_auth_profile_slug:pe,requested_scopes:I8(we,Ie)}),Me=ve.auth_profile?.slug??ve.pending_slug;return Me&&de(Me),At(!1),ie(""),Ne(""),{...ve,status:ve.auth_profile?.status}})}},O1=b.useCallback(async()=>{!we||we.type!=="browser"||await tr({profileKind:"browser_session",displayName:Kt.trim()||`${P?.name||"Connector"} Browser Session`,slug:Gt.trim(),onSuccess:ve=>{ve.auth_profile?.slug&&de(ve.auth_profile.slug),Ut(!1),Et(""),rt("")}})},[we,tr,Kt,Gt,P?.name]),gc=async()=>{if(P){if(!L.canSubmit){Oe("Reload the latest connection values before saving.");return}gr(!0),Oe(null);try{const ve={...h2(B),...O};let Me,Be;if(we?.type==="env_keys"&&(Me=oe?.trim()||void 0,!Me))throw new Error("Select or create an auth profile before creating the connection.");if(we?.type==="oauth"){if(Me=oe?.trim()||void 0,Be=pe?.trim()||void 0,!Be)throw new Error(`Select or create an ${we.provider} app profile first.`);if(!Me)throw new Error(`Select or create an ${we.provider} account profile first.`)}if(we?.type==="browser"&&(Me=oe?.trim()||void 0,!Me))throw new Error("Select or create a browser auth profile before creating the connection.");if(Zn&&!zt)throw new Error(Ma.length===0?`No device with the "${Zn}" permission. Open the Lobu app on a device and grant it, then refresh.`:"Choose a device to run this connector on.");if(C){const hn=a.device_worker_id??void 0;await p.mutateAsync({connection_id:a.id,display_name:J||void 0,auth_profile_slug:we?.type==="oauth"||we?.type==="env_keys"||we?.type==="browser"?Me??void 0:we?.type==="none"?null:void 0,app_auth_profile_slug:we?.type==="oauth"?Be??void 0:we?.type==="none"?null:void 0,config:Object.keys(ve).length>0?ve:void 0,device_worker_id:zt===hn?void 0:zt??null}),Eo(!1)}else{const hn=await c.mutateAsync({connector_key:P.key,display_name:J||void 0,auth_profile_slug:we?.type==="none"?null:Me,app_auth_profile_slug:we?.type==="none"?null:Be,config:Object.keys(ve).length>0?ve:void 0,created_by:Nn,device_worker_id:zt??null});hn.auth_run_id?It(hn.auth_run_id):Eo(!1)}}catch(ve){Oe(ve instanceof Error?ve.message:C?"Failed to update connection":"Failed to create connection")}finally{gr(!1)}}},Ro=ve=>{ae(ve),de(void 0),Re(void 0),De(!1),ln(!1),At(!1),Ut(!1),Ve([])},N1=async(ve,Me)=>{try{await k.mutateAsync(ve),q(null),Me==="app"?Re(""):de("")}catch(Be){Oe(Be instanceof Error?Be.message:`Failed to delete ${Me==="app"?"app":"auth"} profile`)}},T1=async ve=>{Oe(null);const Me=et.find(hn=>hn.slug===ve),Be=Me?.status==="pending_auth"&&!Me.granted_scopes?.length;await d.begin(()=>v.mutateAsync({auth_profile_slug:ve,app_auth_profile_slug:Be?pe:void 0,requested_scopes:I8(we?.type==="oauth"?we:null,Ie)}))};return{configDraft:L,runtimeDraft:wa,appDraft:Ht,createAuthProfile:y,deleteAuthProfileMutation:k,reconnectAuthProfile:v,deleteConnection:A,installConnectorMutation:j,connectorDefs:w,isLoadingDefs:S,isEditMode:C,showDeleteConfirm:N,setShowDeleteConfirm:I,confirmingDeleteProfileSlug:T,setConfirmingDeleteProfileSlug:q,showInstallForm:R,setShowInstallForm:H,installSourceUrl:D,setInstallSourceUrl:G,installError:$,setInstallError:X,installingConnectorKey:Ir,searchQuery:F,setSearchQuery:W,previewConnector:E1,handleInstallPreviewedConnector:R1,clearPreview:yc,selectedConnector:P,displayName:J,setDisplayName:se,configValues:B,createActionConfig:O,setCreateActionConfig:ee,selectedAuthMethodIndex:Q,selectedAuthProfileSlug:oe,setSelectedAuthProfileSlug:de,selectedAppAuthProfileSlug:pe,setSelectedAppAuthProfileSlug:Re,showNewRuntimeProfileForm:Pe,setShowNewRuntimeProfileForm:De,newRuntimeProfileName:bt,setNewRuntimeProfileName:Ye,newRuntimeProfileSlug:kn,setNewRuntimeProfileSlug:Qt,newRuntimeProfileValues:xn,setNewRuntimeProfileValues:Mo,showNewAppProfileForm:Xt,setShowNewAppProfileForm:ln,newAppProfileName:Ot,setNewAppProfileName:Jt,newAppProfileSlug:va,setNewAppProfileSlug:Nt,newAppProfileValues:Vi,setNewAppProfileValues:_0,showNewOAuthAccountForm:Wn,setShowNewOAuthAccountForm:At,newOAuthAccountName:lt,setNewOAuthAccountName:ie,newOAuthAccountSlug:me,setNewOAuthAccountSlug:Ne,showNewBrowserProfileForm:vn,setShowNewBrowserProfileForm:Ut,newBrowserProfileName:Kt,setNewBrowserProfileName:Et,newBrowserProfileSlug:Gt,setNewBrowserProfileSlug:rt,isSaving:wo,saveError:za??d.error,authorizationUrl:d.continueUrl,setSaveError:Oe,pendingAuthRunId:St,setPendingAuthRunId:It,authProfiles:et,selectableMethods:Cn,activeMethod:we,runtimeEnvProfiles:un,runtimeOAuthProfiles:Yt,appOAuthProfiles:ba,browserProfiles:Tn,runtimeProfileSchema:Hi,appProfileSchema:Ds,availableOAuthOptionalScopes:Is,selectedOAuthOptionalScopes:Ie,setSelectedOAuthOptionalScopes:Ve,hasUniqueOptionsFields:Qn,connections:o,isNoAuthConnector:Vs,existingNoAuthConnection:C0,selectedMemberUserId:Nn,setSelectedMemberUserId:cn,isAdmin:qt,devices:Fi,deviceOptions:Ma,lockedDeviceWorkerIdFromProfile:Co,requiredCapability:Zn,selectedDeviceWorkerId:zt,setSelectedDeviceWorkerId:xa,refreshDevices:So,devicesRefreshing:_o,handleOpenChange:Eo,handleConnectorSelect:qs,handleBack:Hs,handleValuesChange:V,normalizeStringValues:qr,navigateOAuthPopup:j1,handleCreateRuntimeProfile:A0,handleCreateAppProfile:Xn,handleCreateOAuthAccountProfile:mc,handleCreateBrowserProfile:O1,handleSave:gc,handleMethodChange:Ro,handleDeleteAuthProfile:N1,handleReconnect:T1}}const J7e=["all","data","chat","actions","inference","runtime","device"],V8={data:!1,chat:!1,actions:!1,audience:!1,inference:!0,runtime:!1},F8="__create_oauth_app_profile__",B8="__create_oauth_account_profile__",$8="__create_browser_profile__",Qy="__serverless__",U8="__add_device__",LE=p7e(),Xy=`${LE}/connect/oauth/callback`;function e9e({method:e}){const[t,n]=b.useState(!1),a=e.setupInstructions||e.description,o=a?a.replace(/\{\{redirect_uri\}\}/g,Xy):null;return h.jsxs("div",{className:"space-y-2 rounded-md border bg-muted/30 p-3",children:[o&&h.jsx("p",{className:"text-xs text-muted-foreground",children:o}),h.jsxs("div",{className:"space-y-1",children:[h.jsx("p",{className:"text-xs font-medium text-muted-foreground",children:"Redirect URI"}),h.jsxs("div",{className:"flex items-center gap-1.5",children:[h.jsx("code",{className:"flex-1 rounded bg-muted px-2 py-1 text-xs font-mono break-all",children:Xy}),h.jsx(ge,{type:"button",variant:"ghost",size:"sm",className:"h-7 w-7 shrink-0 p-0",onClick:()=>{navigator.clipboard.writeText(Xy),n(!0),setTimeout(()=>n(!1),2e3)},children:t?h.jsx(Za,{className:"h-3.5 w-3.5"}):h.jsx(Hu,{className:"h-3.5 w-3.5"})})]})]})]})}function t9e({connector:e,existingConnectionCount:t=0,onInstall:n,onBack:a,isInstalling:o,installError:s}){const l=u_(e.auth_schema),c=c_(e.runtime?.platforms),d=e.runtime?.scopes??[],{data:f=[]}=d1(),p=e.required_capability??null,y=p?f.find(_=>_.online&&_.capabilities.includes(p)):void 0,{inspectFeed:k,inspectAction:v}=WA(),w=e.feeds_schema??{},S=e.actions_schema??{};return h.jsxs("div",{className:"space-y-4",children:[h.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[h.jsx(ge,{variant:"ghost",size:"sm",onClick:a,className:"h-7 px-2 text-xs",children:"← Back"}),h.jsx(Ll,{connector:e,showDescription:!1,className:"gap-2"}),e.version&&h.jsxs(on,{variant:"secondary",className:"h-4 px-1.5 py-0 text-[10px] font-mono",children:["v",e.version]}),e.catalog_origin==="org"&&h.jsx(on,{variant:"secondary",className:"h-4 px-1.5 py-0 text-[10px]",children:"Org-installed"})]}),(c||e.required_capability||l.length>0||t>0)&&h.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[t>0&&h.jsxs(on,{variant:"secondary",className:"h-4 px-1.5 py-0 text-[10px]",children:[t," existing connection",t===1?"":"s"]}),c&&h.jsxs(on,{variant:"secondary",className:"h-4 gap-1 px-1.5 py-0 text-[10px]",children:[h.jsx(qg,{className:"h-2.5 w-2.5"}),"Requires ",c]}),e.required_capability&&h.jsxs(on,{variant:"secondary",className:"h-4 px-1.5 py-0 text-[10px]",children:["Needs ",e.required_capability]}),l.map(_=>h.jsx(on,{variant:"secondary",className:"h-4 px-1.5 py-0 text-[10px]",children:_},_))]}),e.description&&h.jsx("div",{className:ye(Yl,"p-3"),children:h.jsx("p",{className:"text-sm text-muted-foreground",children:e.description})}),(e.source_uri||d.length>0)&&h.jsxs("div",{className:"space-y-1 rounded-lg border bg-muted/30 p-3 text-xs",children:[e.source_uri&&h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsx("span",{className:"font-medium text-muted-foreground uppercase tracking-wider text-[10px]",children:"Source"}),h.jsxs("a",{href:e.source_uri,target:"_blank",rel:"noreferrer",className:"inline-flex items-center gap-1 break-all font-mono text-primary hover:underline",children:[e.source_uri,h.jsx(a1,{className:"h-3 w-3 shrink-0"})]})]}),d.length>0&&h.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[h.jsx("span",{className:"font-medium text-muted-foreground uppercase tracking-wider text-[10px]",children:"Scopes"}),d.map(_=>h.jsx(on,{variant:"secondary",className:"h-4 px-1.5 py-0 text-[10px] font-mono",children:_},_))]})]}),h.jsx(gE,{feedsSchema:w,onInspect:k}),h.jsx(kE,{actionsSchema:S,onInspect:v}),s&&h.jsx("div",{className:"rounded-md bg-red-50 dark:bg-red-950/30 p-3 text-sm text-red-600 dark:text-red-400",children:s}),e.required_capability?y?h.jsxs("div",{className:"space-y-2",children:[h.jsxs("div",{className:"rounded-lg border bg-muted/30 px-3 py-2 text-sm text-muted-foreground",children:["Connected on this Mac",y.last_seen_at?` · last seen ${k1(y.last_seen_at)}`:""]}),h.jsxs(ge,{variant:"secondary",onClick:()=>{window.location.href=Fh("sync")},className:"w-full",children:[h.jsx(M2,{className:"mr-2 h-4 w-4"}),"Sync now"]})]}):h.jsxs(ge,{onClick:()=>{window.location.href=Fh(`grant/${e.required_capability}`)},className:"w-full",children:[h.jsx(Hg,{className:"mr-2 h-4 w-4"}),"Connect on this Mac"]}):h.jsx(ge,{onClick:n,disabled:o,className:"w-full",children:o?h.jsxs(h.Fragment,{children:[h.jsx(dt,{size:"lg",className:"mr-2"}),"Installing..."]}):"Install & Configure"})]})}function n9e({connector:e,actionConfig:t,onActionConfigChange:n}){const{data:a=[]}=M0e(e.installed?e.key:null),o=yE(t),{inspectFeed:s,inspectAction:l}=WA(),c=p=>{n({...t,action_modes:p})},d=e.feeds_schema??{},f=e.actions_schema??{};return h.jsxs(h.Fragment,{children:[h.jsx(gE,{feedsSchema:d,onInspect:s}),a.length>0?h.jsx(M7e,{operations:a,modes:o,onChange:c,onInspect:p=>{const y=f[p.operation_key];y&&l(p.operation_key,y)}}):h.jsx(kE,{actionsSchema:f,onInspect:l})]})}function a9e({connection:e,activeAuthRunId:t,onStart:n,onClear:a,onRecover:o,isStarting:s}){const{data:l}=N0e(t==null?e.id:null);b.useEffect(()=>{const k=l?.run_id;t==null&&k&&o(k)},[t,l?.run_id,o]);const{data:c,isLoading:d}=z9(t),f=c?.status==="completed"||c?.status==="failed"||c?.status==="cancelled",p=e.status==="pending_auth"||e.status==="error"||e.auth_profile_status!=null&&e.auth_profile_status!=="active",y=t!=null&&!f;return h.jsxs("div",{className:"space-y-3 rounded-md border bg-background p-3",children:[h.jsx("p",{className:"text-xs text-muted-foreground",children:"This connector pairs interactively (e.g. QR code or device link). Artifacts are only shown to the person who initiates the pairing."}),!y&&h.jsx(ge,{type:"button",variant:p?"default":"outline",size:"sm",className:"h-8",disabled:s,onClick:n,children:s?h.jsxs(h.Fragment,{children:[h.jsx(dt,{size:"md",className:"mr-1.5"}),"Starting…"]}):p?"Pair device":"Reset pairing"}),y&&h.jsxs("div",{className:"space-y-3",children:[d&&!c&&h.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[h.jsx(dt,{size:"lg"})," Preparing…"]}),c&&!c.artifact&&!f&&h.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[h.jsx(dt,{size:"lg"})," Waiting for connector…"]}),c?.artifact&&!f&&t!=null&&h.jsx(uE,{artifact:c.artifact,runId:t}),h.jsxs("div",{className:"flex items-center justify-between gap-2",children:[h.jsx("span",{className:"text-xs text-muted-foreground",children:c?.status==="pending"?"Starting…":c?.status==="running"?"Waiting for you…":""}),h.jsx(ge,{type:"button",variant:"outline",size:"sm",className:"h-8",onClick:a,children:"Cancel"})]})]}),f&&c?.status==="completed"&&h.jsx("div",{className:"text-sm text-emerald-600",children:"Paired successfully."}),f&&c?.status==="failed"&&h.jsx("div",{className:"rounded-md border border-destructive/30 bg-destructive/5 p-2 text-sm text-destructive",children:c.error_message||"Authentication failed."})]})}function r9e({onClose:e,organizationId:t,editingConnection:n,connections:a=[],initialConnectorKey:o,ownerSlug:s,onDeepLinkBack:l}){const c=X7e({open:!0,onOpenChange:R=>{R||e()},organizationId:t,editingConnection:n,connections:a,initialConnectorKey:o,onDeepLinkBack:l}),d=P9(),f=qn(),{data:p=[]}=PMe(),{data:y,isLoading:k}=nfe({enabled:!!s}),[v,w]=b.useState("all"),[S,_]=b.useState(()=>jh(o??"")),C=!c.isEditMode&&c.activeMethod?.type==="app_installation",j=n?.device_worker_id?h.jsxs("p",{className:"text-xs text-muted-foreground",children:["Connected through"," ",n.device_worker_id&&s?h.jsx(Ct,{to:"/$owner/connectors/device/$deviceId",params:{owner:s,deviceId:n.device_worker_id},className:"text-foreground hover:underline",children:n.device_label||n.device_platform||"this device"}):h.jsx("span",{className:"text-foreground",children:n.device_label||n.device_platform||"this device"}),n.device_online===!1?" · offline":n.device_last_seen_at?` · last seen ${k1(n.device_last_seen_at)}`:""]}):null,N=h.jsxs("div",{className:"space-y-6 pb-6",children:[!c.selectedConnector&&c.previewConnector&&h.jsx(t9e,{connector:c.previewConnector,existingConnectionCount:a.filter(R=>R.connector_key===c.previewConnector?.key).length,onInstall:()=>{c.handleInstallPreviewedConnector().then(R=>{!R||!s||f({to:"/$owner/connectors/create/$connectorKey",params:{owner:s,connectorKey:R.key}})})},onBack:c.handleBack,isInstalling:c.installConnectorMutation.isPending,installError:c.installError}),S&&h.jsx(o9e,{providerKind:S,credentialFields:y?.providerCatalog.find(R=>R.id===S)?.credentialFields,isProviderCatalogLoading:k,ownerSlug:s??"",onBack:()=>_(null)}),!S&&!c.selectedConnector&&!c.previewConnector&&h.jsxs("div",{className:"space-y-3",children:[h.jsx("div",{className:ye(Yl,"w-full"),children:c.showInstallForm?h.jsxs("div",{className:"p-3 space-y-3",children:[h.jsx("p",{className:"text-sm font-medium",children:"Install from URL"}),h.jsx(Lt,{placeholder:"https://… (TypeScript source or MCP server URL)",value:c.installSourceUrl,onChange:R=>{c.setInstallSourceUrl(R.target.value),c.setInstallError(null)},className:"text-xs font-mono"}),h.jsx("p",{className:"text-xs text-muted-foreground",children:"URLs ending in .ts/.js are installed as source connectors. Other URLs are probed as MCP servers."}),c.installError&&h.jsx("p",{className:"text-xs text-destructive",children:c.installError}),h.jsxs("div",{className:"flex justify-end gap-2",children:[h.jsx(ge,{variant:"outline",size:"sm",className:"h-7 text-xs",onClick:()=>{c.setShowInstallForm(!1),c.setInstallSourceUrl(""),c.setInstallError(null)},children:"Cancel"}),h.jsxs(ge,{size:"sm",className:"h-7 text-xs",disabled:c.installConnectorMutation.isPending||!c.installSourceUrl.trim(),onClick:()=>{c.setInstallError(null);const R=c.installSourceUrl.trim(),H=/\.(ts|js|mjs)(\?|$)/i.test(R);c.installConnectorMutation.mutate(H?{source_url:R}:{mcp_url:R},{onSuccess:()=>{c.setShowInstallForm(!1),c.setInstallSourceUrl("")},onError:D=>{c.setInstallError(D instanceof Error?D.message:"Failed to install connector")}})},children:[c.installConnectorMutation.isPending?h.jsx(dt,{size:"sm",className:"mr-1"}):null,"Install"]})]})]}):h.jsxs("button",{type:"button",className:"flex items-center gap-3 p-3 w-full text-left text-muted-foreground hover:text-foreground transition-colors",onClick:()=>c.setShowInstallForm(!0),children:[h.jsx("div",{className:"h-8 w-8 rounded-full bg-muted flex items-center justify-center shrink-0",children:h.jsx(u7,{className:"h-4 w-4"})}),h.jsxs("div",{children:[h.jsx("p",{className:"text-sm font-medium",children:"Install Custom Connector"}),h.jsx("p",{className:"text-xs text-muted-foreground",children:"Install from a source file URL or MCP server URL"})]})]})}),h.jsxs("div",{className:"relative",children:[h.jsx(r1,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),h.jsx(Lt,{placeholder:"Search connectors...",value:c.searchQuery,onChange:R=>c.setSearchQuery(R.target.value),className:"pl-9"})]}),h.jsx("div",{className:"flex flex-wrap items-center gap-1.5",children:J7e.map(R=>h.jsx(ge,{type:"button",variant:v===R?"secondary":"ghost",size:"sm",className:"h-7 px-2 text-xs",onClick:()=>w(R),children:J8e[R]},R))}),!c.showInstallForm&&c.installError&&h.jsx("p",{className:"text-xs text-destructive",children:c.installError}),c.isLoadingDefs?h.jsx(Twe,{}):(()=>{const R=c.searchQuery.toLowerCase().trim(),H=new Map;for(const V of a)H.set(V.connector_key,(H.get(V.connector_key)??0)+1);const D=c.connectorDefs.filter(V=>!R||V.name.toLowerCase().includes(R)||V.key.toLowerCase().includes(R)||V.description?.toLowerCase().includes(R)?Wy({connector:V,facets:rwe(V)},v):!1).sort((V,O)=>V.name.localeCompare(O.name)),G=V=>V.installed||(H.get(V.key)??0)>0,$=D.filter(G),X=D.filter(V=>!G(V)),F=s?p.filter(V=>!R||V.displayName.toLowerCase().includes(R)||V.slug.toLowerCase().includes(R)?Wy({connector:{key:`${ci}${V.slug}`,name:V.displayName,auth_schema:null},facets:V8},v):!1).sort((V,O)=>V.displayName.localeCompare(O.displayName)):[],W=s?EMe(y?.availableProviders??[]).filter(V=>!R||V.name.toLowerCase().includes(R)||V.key.toLowerCase().includes(R)||V.description?.toLowerCase().includes(R)?Wy({connector:V,facets:og()},v):!1).sort((V,O)=>V.name.localeCompare(O.name)):[],P=s&&v==="all"?gv(s,kv()).filter(V=>!R||V.name.toLowerCase().includes(R)||V.tagline.toLowerCase().includes(R)):[],U=F.length+W.length+P.length,J=V=>(O,ee)=>{const Q=c.installConnectorMutation.isPending&&c.installingConnectorKey===O.key,ae=c_(O.runtime?.platforms),oe=u_(O.auth_schema);return h.jsxs("button",{type:"button",className:`flex w-full items-center gap-3 bg-card px-3 py-2.5 text-left text-muted-foreground transition-colors hover:bg-accent/50 hover:text-foreground disabled:cursor-not-allowed disabled:opacity-60 ${ee===V-1?"":"border-b"}`,onClick:()=>{if(s&&O.installed!==!1&&!jh(O.key)&&!O.key.startsWith(ci)){f({to:"/$owner/connectors/create/$connectorKey",params:{owner:s,connectorKey:O.key}});return}c.handleConnectorSelect(O)},disabled:c.installConnectorMutation.isPending&&c.installingConnectorKey!==O.key,children:[h.jsx(Ll,{connector:O,className:"min-w-0 flex-1"}),h.jsxs("div",{className:"flex shrink-0 flex-wrap items-center justify-end gap-1.5",children:[Q?h.jsxs(on,{variant:"secondary",className:"h-4 shrink-0 gap-1 px-1.5 py-0 text-[10px]",children:[h.jsx(dt,{size:"xs"}),"Installing"]}):null,ae&&h.jsxs(on,{variant:"secondary",className:"h-4 shrink-0 gap-1 px-1.5 py-0 text-[10px]",children:[h.jsx(qg,{className:"h-2.5 w-2.5"}),"Requires ",ae]}),oe.map(de=>h.jsx(on,{variant:"secondary",className:"h-4 shrink-0 px-1.5 py-0 text-[10px]",children:de},de)),O.login_enabled&&h.jsxs(on,{variant:"secondary",className:"h-4 shrink-0 gap-1 px-1.5 py-0 text-[10px]",children:[h.jsx(xm,{className:"h-2.5 w-2.5"}),"Login"]})]}),h.jsx(da,{className:"h-4 w-4 shrink-0 text-muted-foreground"})]},O.key)},se=(V,O)=>h.jsxs(Ct,{to:"/$owner/connectors/$connectorKey",params:{owner:s??"",connectorKey:`${ci}${V.slug}`},className:`flex w-full items-center gap-3 bg-card px-3 py-2.5 text-left text-muted-foreground transition-colors hover:bg-accent/50 hover:text-foreground ${O===F.length-1&&W.length+P.length===0?"":"border-b"}`,children:[h.jsx(Ll,{connector:{key:`${ci}${V.slug}`,name:V.displayName,iconUrl:V.iconUrl},className:"min-w-0 flex-1"}),h.jsx("div",{className:"flex shrink-0 flex-wrap items-center justify-end gap-1.5",children:h.jsx(Jm,{facets:V8})}),h.jsx(da,{className:"h-4 w-4 shrink-0 text-muted-foreground"})]},`${ci}${V.slug}`),L=(V,O)=>h.jsxs("button",{type:"button",onClick:()=>_(jh(V.key)??null),className:`flex w-full items-center gap-3 bg-card px-3 py-2.5 text-left text-muted-foreground transition-colors hover:bg-accent/50 hover:text-foreground ${O===W.length-1&&P.length===0?"":"border-b"}`,children:[h.jsx(Ll,{connector:V,className:"min-w-0 flex-1"}),h.jsxs("div",{className:"flex shrink-0 flex-wrap items-center justify-end gap-1.5",children:[h.jsx(Jm,{facets:og()}),h.jsx(on,{variant:"secondary",className:"h-4 shrink-0 px-1.5 py-0 text-[10px] text-muted-foreground",children:"Available"})]}),h.jsx(da,{className:"h-4 w-4 shrink-0 text-muted-foreground"})]},V.key),B=(V,O)=>h.jsxs(Ct,{to:"/$owner/connectors/app/$appId",params:{owner:s??"",appId:V.id},className:`flex w-full items-center gap-3 bg-card px-3 py-2.5 text-left text-muted-foreground transition-colors hover:bg-accent/50 hover:text-foreground ${O===P.length-1?"":"border-b"}`,children:[h.jsx("span",{className:"flex h-7 w-7 shrink-0 items-center justify-center rounded-md border border-dashed",children:V.icon}),h.jsxs("div",{className:"min-w-0 flex-1",children:[h.jsx("p",{className:"truncate text-sm font-medium",children:V.name}),h.jsx("p",{className:"truncate text-xs text-muted-foreground",children:V.tagline})]}),h.jsx(da,{className:"h-4 w-4 shrink-0 text-muted-foreground"})]},V.id);return D.length===0&&F.length===0&&W.length===0&&P.length===0?h.jsxs("div",{className:"space-y-3 py-4 text-center",children:[h.jsxs("div",{className:"space-y-1",children:[h.jsx("p",{className:"text-sm font-medium",children:R?`No connectors match "${c.searchQuery}"`:v!=="all"?"No connectors match this filter":"No connectors found"}),h.jsx("p",{className:"mx-auto max-w-sm text-xs text-muted-foreground",children:"Install a custom connector from URL, or create an agent that links the connector your workflow needs."})]}),s?h.jsx(ge,{asChild:!0,variant:"outline",size:"sm",children:h.jsxs(Ct,{to:`/${s}/agents`,search:{create:!0},children:[h.jsx(la,{className:"mr-2 h-4 w-4"}),"Create with an agent"]})}):null]}):h.jsxs("div",{className:"space-y-4",children:[$.length>0?h.jsxs("div",{className:"space-y-1.5",children:[h.jsx("h3",{className:"text-[11.5px] font-medium text-muted-foreground",children:"Already in this workspace"}),h.jsx("div",{className:"overflow-hidden rounded-lg border",children:$.map(J($.length))})]}):null,X.length+U>0?h.jsxs("div",{className:"space-y-1.5",children:[$.length>0?h.jsx("h3",{className:"text-[11.5px] font-medium text-muted-foreground",children:"From the catalog"}):null,h.jsxs("div",{className:"overflow-hidden rounded-lg border",children:[X.map(J(X.length+U)),F.map(se),W.map(L),P.map(B)]})]}):null]})})()]}),c.selectedConnector&&h.jsxs("div",{className:"space-y-4",children:[!c.isEditMode&&h.jsx(eg,{organizationId:t,connectorKey:c.selectedConnector.key}),h.jsxs("div",{className:"flex items-center gap-2",children:[!c.isEditMode&&h.jsx(ge,{variant:"ghost",size:"sm",onClick:c.handleBack,className:"h-7 px-2 text-xs",children:"← Back"}),h.jsx(Ll,{connector:c.selectedConnector,showDescription:!1,className:"gap-2"}),c.selectedConnector.version&&h.jsxs(on,{variant:"secondary",className:"text-[10px] px-1.5 py-0 h-4 font-mono",children:["v",c.selectedConnector.version]})]}),c.isEditMode&&n?.status==="pending_auth"&&n.connect_token&&h.jsxs("div",{className:"rounded-lg border border-amber-200 bg-amber-50 dark:border-amber-800 dark:bg-amber-950/30 p-4 space-y-3",children:[h.jsx("p",{className:"text-sm font-medium text-amber-900 dark:text-amber-200",children:"Authorization required"}),h.jsx("p",{className:"text-xs text-amber-700 dark:text-amber-300",children:"This connection is waiting for OAuth authorization to complete."}),h.jsxs(ge,{size:"sm",onClick:()=>{const R=`${LE}/connect/${n.connect_token}/oauth/start`;c.navigateOAuthPopup(R)},children:[h.jsx(a1,{className:"mr-1.5 h-3.5 w-3.5"}),"Authorize"]})]}),c.isEditMode&&n?.status==="pending_auth"&&n.auth_profile_kind==="browser_session"&&n.auth_profile_slug&&h.jsxs("div",{className:"rounded-lg border border-amber-200 bg-amber-50 dark:border-amber-800 dark:bg-amber-950/30 p-4 space-y-3",children:[h.jsx("p",{className:"text-sm font-medium text-amber-900 dark:text-amber-200",children:"Browser auth required"}),h.jsx("p",{className:"text-xs text-amber-700 dark:text-amber-300",children:"Capture or refresh the browser session for this auth profile, then the connection will resume automatically."}),h.jsx("p",{className:"text-xs text-muted-foreground",children:"Follow the connector’s authorization instructions to refresh this session."})]}),!C&&(c.requiredCapability||c.deviceOptions.length>0)&&h.jsxs("div",{className:"space-y-2",children:[h.jsxs("div",{className:"flex items-center justify-between gap-2",children:[h.jsxs("label",{className:"text-sm font-medium",children:["Run on",c.requiredCapability?h.jsx("span",{className:"text-destructive ml-1",children:"*"}):h.jsx("span",{className:"text-xs font-normal text-muted-foreground ml-1",children:"(optional)"})]}),h.jsx("div",{className:"flex items-center gap-3",children:h.jsxs("button",{type:"button",onClick:()=>void c.refreshDevices(),disabled:c.devicesRefreshing,className:"inline-flex items-center gap-1 text-xs text-muted-foreground hover:text-foreground disabled:opacity-50",children:[h.jsx(M2,{className:`h-3 w-3 ${c.devicesRefreshing?"animate-spin":""}`}),"Refresh"]})})]}),h.jsxs(si,{value:c.selectedDeviceWorkerId??(c.requiredCapability?"":Qy),onValueChange:R=>{if(R===U8){s&&f({to:"/$owner/connectors/create",params:{owner:s}});return}c.setSelectedDeviceWorkerId(R===Qy?void 0:R)},disabled:!!c.lockedDeviceWorkerIdFromProfile,children:[h.jsx(io,{className:"h-8",children:h.jsx(li,{placeholder:"Select a device"})}),h.jsxs(so,{children:[!c.requiredCapability&&h.jsx(Bn,{value:Qy,children:"Serverless (default)"}),c.deviceOptions.map(R=>h.jsx(TA,{device:R},R.id)),s?h.jsx(Bn,{value:U8,children:h.jsxs("span",{className:"flex items-center gap-2 text-muted-foreground",children:[h.jsx(la,{className:"h-3.5 w-3.5"}),"Add device"]})}):null]})]}),c.requiredCapability&&c.deviceOptions.length===0?h.jsxs("p",{className:"text-xs text-muted-foreground",children:["No device has granted the “",f_[c.requiredCapability]??c.requiredCapability,"” permission. Open the Lobu app on a device and grant it, then"," ",h.jsx("button",{type:"button",onClick:()=>void c.refreshDevices(),className:"underline hover:text-foreground",children:"refresh"}),"."]}):c.selectedDeviceWorkerId?h.jsx("p",{className:"text-xs text-muted-foreground",children:"Syncs and actions run on this device — with its credentials and network, not the Lobu server."}):h.jsx("p",{className:"text-xs text-muted-foreground",children:"Runs serverless, in the Lobu server."})]}),c.isEditMode&&n?.has_operations&&h.jsx("div",{className:"rounded-lg border bg-muted/30 p-4 space-y-4",children:h.jsx(Z7e,{connection:n})}),!C&&!c.isEditMode&&h.jsx(n9e,{connector:c.selectedConnector,actionConfig:c.createActionConfig,onActionConfigChange:c.setCreateActionConfig}),c.selectableMethods.length>0&&h.jsxs("section",{className:"space-y-3",children:[h.jsx("p",{className:"text-xs font-medium uppercase tracking-wide text-muted-foreground",children:"Authentication"}),c.selectableMethods.length>1?h.jsx("div",{className:"flex gap-2",children:c.selectableMethods.map((R,H)=>h.jsx("button",{type:"button",onClick:()=>c.handleMethodChange(H),className:`rounded-md border px-3 py-1.5 text-sm transition-colors ${c.selectedAuthMethodIndex===H?"border-primary bg-primary/10 text-foreground":"border-border bg-background text-muted-foreground hover:text-foreground"}`,children:Oh(R)},`${R.type}-${Oh(R)}`))}):h.jsx("p",{className:"text-xs text-muted-foreground",children:Oh(c.selectableMethods[0])}),c.activeMethod?.type!=="none"&&c.activeMethod?.description&&h.jsx("p",{className:"text-xs text-muted-foreground",children:c.activeMethod.description}),c.activeMethod?.type==="app_installation"&&h.jsxs("div",{className:"space-y-3",children:[c.activeMethod.permissions&&c.activeMethod.permissions.length>0&&h.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[h.jsx("span",{className:"text-[10px] font-medium uppercase tracking-wider text-muted-foreground",children:"Grants"}),c.activeMethod.permissions.map(R=>h.jsx(on,{variant:"secondary",className:"h-4 px-1.5 py-0 text-[10px]",children:R},R))]}),h.jsx(Xm,{organizationId:t,connectorKey:c.selectedConnector.key,provider:c.activeMethod.provider,providerLabel:c.selectedConnector?.name,installShape:c.activeMethod.installShape,variant:"default",size:"default",className:"w-full",label:`Install ${c.selectedConnector?.name??"App"}`}),h.jsxs("p",{className:"text-xs text-muted-foreground",children:["You'll be sent to"," ",c.activeMethod.provider.charAt(0).toUpperCase()+c.activeMethod.provider.slice(1)," ","to choose what to grant. The connection and its feeds are created automatically when you return."]})]}),c.activeMethod?.type==="env_keys"&&h.jsxs("div",{className:"space-y-3",children:[h.jsxs("div",{className:"space-y-2",children:[h.jsx("p",{className:"text-xs font-medium text-muted-foreground",children:"Auth Profile"}),h.jsxs("div",{className:"flex gap-1.5",children:[h.jsxs(si,{value:c.selectedAuthProfileSlug,onValueChange:c.setSelectedAuthProfileSlug,children:[h.jsx(io,{className:"h-8 flex-1 min-w-0",children:h.jsx(li,{placeholder:"Select auth profile"})}),h.jsx(so,{children:c.runtimeEnvProfiles.map(R=>h.jsxs(Bn,{value:R.slug,children:[R.display_name," (",R.slug,")"]},R.slug))})]}),c.selectedAuthProfileSlug&&(c.confirmingDeleteProfileSlug===c.selectedAuthProfileSlug?h.jsxs("div",{className:"flex items-center gap-1 shrink-0",children:[h.jsx(ge,{type:"button",variant:"destructive",size:"sm",className:"h-8 text-xs px-2",disabled:c.deleteAuthProfileMutation.isPending,onClick:()=>void c.handleDeleteAuthProfile(c.selectedAuthProfileSlug,"env"),children:c.deleteAuthProfileMutation.isPending?h.jsx(dt,{size:"sm"}):"Delete"}),h.jsx(ge,{type:"button",variant:"ghost",size:"sm",className:"h-8 text-xs px-2",onClick:()=>c.setConfirmingDeleteProfileSlug(null),children:"Cancel"})]}):h.jsx(ge,{type:"button",variant:"ghost",size:"sm",className:"h-8 w-8 p-0 shrink-0 text-muted-foreground hover:text-destructive",onClick:()=>c.setConfirmingDeleteProfileSlug(c.selectedAuthProfileSlug),children:h.jsx(ui,{className:"h-3.5 w-3.5"})}))]}),c.runtimeEnvProfiles.length===0&&h.jsx("p",{className:"text-xs text-muted-foreground",children:"No auth profiles yet for this connector."})]}),h.jsxs(ge,{type:"button",variant:"outline",size:"sm",className:"h-8",onClick:()=>c.setShowNewRuntimeProfileForm(R=>!R),children:[h.jsx(la,{className:"mr-1.5 h-3.5 w-3.5"}),c.showNewRuntimeProfileForm?"Hide New Profile":"Create Auth Profile"]}),c.showNewRuntimeProfileForm&&h.jsxs("div",{className:"space-y-3 rounded-md border bg-background p-3",children:[h.jsx(Lt,{placeholder:"Profile name",value:c.newRuntimeProfileName,onChange:R=>c.setNewRuntimeProfileName(R.target.value)}),h.jsx(Lt,{placeholder:"profile-slug (optional)",value:c.newRuntimeProfileSlug,onChange:R=>c.setNewRuntimeProfileSlug(R.target.value)}),c.runtimeDraft.revision&&h.jsxs(h.Fragment,{children:[h.jsx(xs,{visible:c.runtimeDraft.hasConflict,onReload:c.runtimeDraft.reset}),h.jsx(bi,{schema:c.runtimeDraft.revision,values:c.newRuntimeProfileValues,onValuesChange:c.setNewRuntimeProfileValues,fieldIdPrefix:"new-runtime-profile-"})]}),h.jsxs("div",{className:"flex justify-end gap-2",children:[h.jsx(ge,{type:"button",variant:"ghost",size:"sm",onClick:()=>{c.setShowNewRuntimeProfileForm(!1),c.setNewRuntimeProfileName(""),c.setNewRuntimeProfileSlug(""),c.setNewRuntimeProfileValues({})},children:"Cancel"}),h.jsxs(ge,{type:"button",size:"sm",disabled:!c.runtimeDraft.canSubmit||c.createAuthProfile.isPending||Object.keys(c.normalizeStringValues(c.newRuntimeProfileValues)).length===0,onClick:()=>void c.handleCreateRuntimeProfile(),children:[c.createAuthProfile.isPending?h.jsx(dt,{size:"md",className:"mr-1.5"}):null,"Create"]})]})]})]}),c.activeMethod?.type==="browser"&&h.jsxs("div",{className:"space-y-3",children:[h.jsxs("div",{className:"space-y-2",children:[h.jsx("p",{className:"text-xs font-medium text-muted-foreground",children:"Browser Auth Profile"}),h.jsxs("div",{className:"flex gap-1.5",children:[h.jsxs(si,{value:c.selectedAuthProfileSlug,onValueChange:R=>{if(R===$8){c.setShowNewBrowserProfileForm(!0);return}c.setSelectedAuthProfileSlug(R),c.setShowNewBrowserProfileForm(!1)},children:[h.jsx(io,{className:"h-8 flex-1 min-w-0",children:h.jsx(li,{placeholder:"Select browser auth profile"})}),h.jsxs(so,{children:[h.jsxs(Bn,{value:$8,children:[h.jsx(la,{className:"mr-1.5 inline h-3.5 w-3.5"}),"Create new browser profile"]}),c.browserProfiles.map(R=>{const H=R.device_worker_id?c.devices.find(D=>D.id===R.device_worker_id)?.label:null;return h.jsxs(Bn,{value:R.slug,children:[R.display_name," (",R.slug,")",H?` — on ${H}`:""]},R.slug)})]})]}),c.selectedAuthProfileSlug&&(c.confirmingDeleteProfileSlug===c.selectedAuthProfileSlug?h.jsxs("div",{className:"flex items-center gap-1 shrink-0",children:[h.jsx(ge,{type:"button",variant:"destructive",size:"sm",className:"h-8 text-xs px-2",disabled:c.deleteAuthProfileMutation.isPending,onClick:()=>void c.handleDeleteAuthProfile(c.selectedAuthProfileSlug,"browser"),children:c.deleteAuthProfileMutation.isPending?h.jsx(dt,{size:"sm"}):"Delete"}),h.jsx(ge,{type:"button",variant:"ghost",size:"sm",className:"h-8 text-xs px-2",onClick:()=>c.setConfirmingDeleteProfileSlug(null),children:"Cancel"})]}):h.jsx(ge,{type:"button",variant:"ghost",size:"sm",className:"h-8 w-8 p-0 shrink-0 text-muted-foreground hover:text-destructive",onClick:()=>c.setConfirmingDeleteProfileSlug(c.selectedAuthProfileSlug),children:h.jsx(ui,{className:"h-3.5 w-3.5"})}))]}),c.browserProfiles.length===0&&h.jsx("p",{className:"text-xs text-muted-foreground",children:"No browser auth profiles yet for this connector."})]}),c.selectedAuthProfileSlug&&(()=>{const R=c.browserProfiles.find(H=>H.slug===c.selectedAuthProfileSlug);return R?h.jsxs("div",{className:"space-y-2 rounded-md border bg-background p-3",children:[h.jsxs("div",{className:"flex flex-wrap gap-2",children:[h.jsx(on,{variant:R.status==="active"?"default":"secondary",children:R.status}),typeof R.cookie_count=="number"&&h.jsxs(on,{variant:"outline",children:[R.cookie_count," cookies"]}),R.auth_cookie_name&&h.jsx(on,{variant:"outline",children:R.auth_cookie_name})]}),h.jsx("p",{className:"text-xs text-muted-foreground",children:"Follow the connector’s authorization instructions to refresh this session."})]}):null})(),h.jsxs(ge,{type:"button",variant:"outline",size:"sm",className:"h-8",onClick:()=>c.setShowNewBrowserProfileForm(R=>!R),children:[h.jsx(la,{className:"mr-1.5 h-3.5 w-3.5"}),c.showNewBrowserProfileForm?"Hide New Profile":"Create Browser Profile"]}),c.showNewBrowserProfileForm&&h.jsxs("div",{className:"space-y-3 rounded-md border bg-background p-3",children:[h.jsx(Lt,{placeholder:"Profile name",value:c.newBrowserProfileName,onChange:R=>c.setNewBrowserProfileName(R.target.value)}),h.jsx(Lt,{placeholder:"profile-slug (optional)",value:c.newBrowserProfileSlug,onChange:R=>c.setNewBrowserProfileSlug(R.target.value)}),h.jsx("p",{className:"text-xs text-muted-foreground",children:"Create the session profile, then follow the connector’s authorization instructions."}),h.jsxs("div",{className:"flex justify-end gap-2",children:[h.jsx(ge,{type:"button",variant:"ghost",size:"sm",onClick:()=>{c.setShowNewBrowserProfileForm(!1),c.setNewBrowserProfileName(""),c.setNewBrowserProfileSlug("")},children:"Cancel"}),h.jsxs(ge,{type:"button",size:"sm",disabled:c.createAuthProfile.isPending,onClick:()=>void c.handleCreateBrowserProfile(),children:[c.createAuthProfile.isPending?h.jsx(dt,{size:"md",className:"mr-1.5"}):null,"Create"]})]})]})]}),c.activeMethod?.type==="interactive"&&c.isEditMode&&n&&n.auth_profile_kind==="interactive"&&h.jsx(a9e,{connection:n,activeAuthRunId:c.pendingAuthRunId,onStart:()=>{d.mutate({connection_id:n.id},{onSuccess:R=>{c.setPendingAuthRunId(R.auth_run_id??null)}})},onClear:()=>c.setPendingAuthRunId(null),onRecover:R=>c.setPendingAuthRunId(R),isStarting:d.isPending}),c.activeMethod?.type==="oauth"&&h.jsxs("div",{className:"space-y-4",children:[!c.isEditMode&&c.appOAuthProfiles.length>0&&c.selectedAppAuthProfileSlug?h.jsxs("div",{className:"space-y-1",children:[h.jsxs("div",{className:"flex items-center justify-between gap-2",children:[h.jsx("p",{className:"text-xs font-medium text-muted-foreground",children:"Workspace app"}),c.isAdmin&&s&&c.selectedConnector&&h.jsx(Ct,{to:"/$owner/connectors/$connectorKey",params:{owner:s,connectorKey:c.selectedConnector.key},search:{setup:"oauth_app"},hash:"connector-oauth-apps",className:"text-xs text-muted-foreground hover:text-foreground",children:"Manage app"})]}),c.appOAuthProfiles.length===1||!c.isAdmin?(()=>{const R=c.appOAuthProfiles.find(H=>H.slug===c.selectedAppAuthProfileSlug);return h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsx("p",{className:"text-sm",children:R?.display_name??"Ask an administrator to set the workspace-default app."}),R?.is_default_for_connector&&R.connector_key===c.selectedConnector?.key&&h.jsx("span",{className:"rounded-md bg-muted px-1.5 py-0.5 text-[10px] font-medium uppercase tracking-wide text-muted-foreground",children:"Org default"})]})})():h.jsxs(si,{value:c.selectedAppAuthProfileSlug,onValueChange:c.setSelectedAppAuthProfileSlug,children:[h.jsx(io,{className:"h-8",children:h.jsx(li,{placeholder:"Choose an app"})}),h.jsx(so,{children:c.appOAuthProfiles.map(R=>h.jsxs(Bn,{value:R.slug,children:[R.display_name,R.is_default_for_connector&&R.connector_key===c.selectedConnector?.key?" (default)":""]},R.slug))})]})]}):h.jsxs("div",{className:"space-y-2",children:[h.jsxs("div",{className:"flex items-center justify-between gap-2",children:[h.jsx("p",{className:"text-xs font-medium text-muted-foreground",children:"Workspace app"}),c.isAdmin&&s&&c.selectedConnector&&c.appOAuthProfiles.length>0&&h.jsx(Ct,{to:"/$owner/connectors/$connectorKey",params:{owner:s,connectorKey:c.selectedConnector.key},className:"text-xs text-muted-foreground hover:text-foreground",children:"Manage"})]}),h.jsxs("div",{className:"flex gap-1.5",children:[h.jsxs(si,{value:c.selectedAppAuthProfileSlug,onValueChange:R=>{if(R===F8){c.setShowNewAppProfileForm(!0);return}c.setSelectedAppAuthProfileSlug(R),c.setShowNewAppProfileForm(!1)},children:[h.jsx(io,{className:"h-8 flex-1 min-w-0",children:h.jsx(li,{placeholder:`Select ${c.activeMethod.provider} app profile`})}),h.jsxs(so,{children:[c.isAdmin&&h.jsxs(Bn,{value:F8,children:[h.jsx(la,{className:"mr-1.5 inline h-3.5 w-3.5"}),"Create new app profile"]}),c.appOAuthProfiles.map(R=>h.jsxs(Bn,{value:R.slug,children:[R.display_name," (",R.slug,")",R.is_default_for_connector&&R.connector_key===c.selectedConnector?.key?" — default":""]},R.slug))]})]}),c.selectedAppAuthProfileSlug&&(c.confirmingDeleteProfileSlug===c.selectedAppAuthProfileSlug?h.jsxs("div",{className:"flex items-center gap-1 shrink-0",children:[h.jsx(ge,{type:"button",variant:"destructive",size:"sm",className:"h-8 text-xs px-2",disabled:c.deleteAuthProfileMutation.isPending,onClick:()=>void c.handleDeleteAuthProfile(c.selectedAppAuthProfileSlug,"app"),children:c.deleteAuthProfileMutation.isPending?h.jsx(dt,{size:"sm"}):"Delete"}),h.jsx(ge,{type:"button",variant:"ghost",size:"sm",className:"h-8 text-xs px-2",onClick:()=>c.setConfirmingDeleteProfileSlug(null),children:"Cancel"})]}):h.jsx(ge,{type:"button",variant:"ghost",size:"sm",className:"h-8 w-8 p-0 shrink-0 text-muted-foreground hover:text-destructive",onClick:()=>c.setConfirmingDeleteProfileSlug(c.selectedAppAuthProfileSlug),children:h.jsx(ui,{className:"h-3.5 w-3.5"})}))]}),c.appOAuthProfiles.length===0&&h.jsx("p",{className:"text-xs text-muted-foreground",children:c.isAdmin?"To use your own app, configure its client credentials here. You can also use a managed app when available.":`Choose a managed option if available, or ask an admin to configure your own ${c.activeMethod.provider} app.`}),c.showNewAppProfileForm&&h.jsxs("div",{className:"space-y-3 rounded-md border bg-background p-3",children:[h.jsx(e9e,{method:c.activeMethod}),h.jsx(Lt,{placeholder:"App profile name",value:c.newAppProfileName,onChange:R=>c.setNewAppProfileName(R.target.value)}),h.jsx(Lt,{placeholder:"app-profile-slug (optional)",value:c.newAppProfileSlug,onChange:R=>c.setNewAppProfileSlug(R.target.value)}),c.appDraft.revision&&h.jsxs(h.Fragment,{children:[h.jsx(xs,{visible:c.appDraft.hasConflict,onReload:c.appDraft.reset}),h.jsx(bi,{schema:c.appDraft.revision,values:c.newAppProfileValues,onValuesChange:c.setNewAppProfileValues,fieldIdPrefix:"new-app-profile-"})]}),h.jsxs("div",{className:"flex justify-end gap-2",children:[h.jsx(ge,{type:"button",variant:"ghost",size:"sm",onClick:()=>{c.setShowNewAppProfileForm(!1),c.setNewAppProfileName(""),c.setNewAppProfileSlug(""),c.setNewAppProfileValues({})},children:"Cancel"}),h.jsxs(ge,{type:"button",size:"sm",disabled:!c.appDraft.canSubmit||c.createAuthProfile.isPending||Object.keys(c.normalizeStringValues(c.newAppProfileValues)).length===0,onClick:()=>void c.handleCreateAppProfile(),children:[c.createAuthProfile.isPending?h.jsx(dt,{size:"md",className:"mr-1.5"}):null,"Create"]})]})]})]}),h.jsxs("div",{className:"space-y-2",children:[h.jsx("p",{className:"text-xs font-medium text-muted-foreground",children:"Your account"}),h.jsxs("div",{className:"flex gap-1.5",children:[h.jsxs(si,{value:c.selectedAuthProfileSlug,onValueChange:R=>{if(R===B8){c.setShowNewOAuthAccountForm(!0);return}c.setSelectedAuthProfileSlug(R),c.setShowNewOAuthAccountForm(!1)},children:[h.jsx(io,{className:"h-8 flex-1 min-w-0",children:h.jsx(li,{placeholder:`Select ${c.activeMethod.provider} account profile`})}),h.jsxs(so,{children:[h.jsxs(Bn,{value:B8,children:[h.jsx(la,{className:"mr-1.5 inline h-3.5 w-3.5"}),"Add new account"]}),c.runtimeOAuthProfiles.map(R=>h.jsxs(Bn,{value:R.slug,children:[R.display_name," (",R.slug,") [",R.status,"]"]},R.slug))]})]}),c.selectedAuthProfileSlug&&(c.confirmingDeleteProfileSlug===c.selectedAuthProfileSlug?h.jsxs("div",{className:"flex items-center gap-1 shrink-0",children:[h.jsx(ge,{type:"button",variant:"destructive",size:"sm",className:"h-8 text-xs px-2",disabled:c.deleteAuthProfileMutation.isPending,onClick:()=>void c.handleDeleteAuthProfile(c.selectedAuthProfileSlug,"account"),children:c.deleteAuthProfileMutation.isPending?h.jsx(dt,{size:"sm"}):"Delete"}),h.jsx(ge,{type:"button",variant:"ghost",size:"sm",className:"h-8 text-xs px-2",onClick:()=>c.setConfirmingDeleteProfileSlug(null),children:"Cancel"})]}):h.jsx(ge,{type:"button",variant:"ghost",size:"sm",className:"h-8 w-8 p-0 shrink-0 text-muted-foreground hover:text-destructive",onClick:()=>c.setConfirmingDeleteProfileSlug(c.selectedAuthProfileSlug),children:h.jsx(ui,{className:"h-3.5 w-3.5"})}))]}),(()=>{const R=c.runtimeOAuthProfiles.find(H=>H.slug===c.selectedAuthProfileSlug);return h.jsxs("div",{className:"space-y-2",children:[h.jsx(dg,{requiredScopes:Qu(c.activeMethod),optionalScopes:c.availableOAuthOptionalScopes,selectedOptionalScopes:c.selectedOAuthOptionalScopes,grantedScopes:R?.granted_scopes,onToggleOptionalScope:(H,D)=>{c.setSelectedOAuthOptionalScopes(G=>D?[...new Set([...G,H])]:G.filter($=>$!==H))}}),R?h.jsxs(ge,{type:"button",variant:"outline",size:"sm",className:"h-8",disabled:c.reconnectAuthProfile.isPending,onClick:()=>void c.handleReconnect(R.slug),children:[c.reconnectAuthProfile.isPending?h.jsx(dt,{size:"md",className:"mr-1.5"}):h.jsx(xm,{className:"mr-1.5 h-3.5 w-3.5"}),"Review permissions"]}):null]})})(),c.runtimeOAuthProfiles.length===0&&h.jsx("p",{className:"text-xs text-muted-foreground",children:"No OAuth account profiles yet for this connector."}),c.showNewOAuthAccountForm&&h.jsxs("div",{className:"space-y-3 rounded-md border bg-background p-3",children:[h.jsx(Lt,{placeholder:"Account profile name",value:c.newOAuthAccountName,onChange:R=>c.setNewOAuthAccountName(R.target.value)}),h.jsx(Lt,{placeholder:"account-profile-slug (optional)",value:c.newOAuthAccountSlug,onChange:R=>c.setNewOAuthAccountSlug(R.target.value)}),h.jsx("p",{className:"text-xs text-muted-foreground",children:"Creating the profile will open the OAuth authorization page in a new tab. When it finishes, the profile becomes reusable for future connections."}),h.jsx(dg,{requiredScopes:Qu(c.activeMethod),optionalScopes:c.availableOAuthOptionalScopes,selectedOptionalScopes:c.selectedOAuthOptionalScopes,onToggleOptionalScope:(R,H)=>{c.setSelectedOAuthOptionalScopes(D=>H?[...new Set([...D,R])]:D.filter(G=>G!==R))}}),h.jsxs("div",{className:"flex justify-end gap-2",children:[h.jsx(ge,{type:"button",variant:"ghost",size:"sm",onClick:()=>{c.setShowNewOAuthAccountForm(!1),c.setNewOAuthAccountName(""),c.setNewOAuthAccountSlug("")},children:"Cancel"}),h.jsxs(ge,{type:"button",size:"sm",disabled:c.createAuthProfile.isPending,onClick:()=>void c.handleCreateOAuthAccountProfile(),children:[c.createAuthProfile.isPending?h.jsx(dt,{size:"md",className:"mr-1.5"}):null,"Continue"]})]})]})]})]})]}),!C&&h.jsxs("div",{className:"space-y-2",children:[h.jsx("label",{className:"text-sm font-medium",htmlFor:"conn-display-name",children:"Display Name"}),h.jsx(Lt,{id:"conn-display-name",placeholder:`e.g. Work ${c.selectedConnector.name}`,value:c.displayName,onChange:R=>c.setDisplayName(R.target.value)})]}),!C&&!c.isEditMode&&c.isAdmin&&h.jsxs("div",{className:"space-y-2",children:[h.jsxs("label",{className:"text-sm font-medium",children:["Assign to Member"," ",h.jsx("span",{className:"text-xs font-normal text-muted-foreground",children:"(optional)"})]}),h.jsx(_Me,{organizationId:t,value:c.selectedMemberUserId,onValueChange:c.setSelectedMemberUserId}),h.jsx("p",{className:"text-xs text-muted-foreground",children:c.selectedMemberUserId?"Only the selected member will use this connection.":"Leave empty to make this connection available to everyone in the organization."}),c.existingNoAuthConnection&&h.jsx("div",{className:"rounded-md bg-amber-50 dark:bg-amber-950/30 border border-amber-200 dark:border-amber-800 p-3",children:h.jsxs("p",{className:"text-xs text-amber-700 dark:text-amber-300",children:["This user already has a ",c.selectedConnector.name," ","connection. No-auth connectors are limited to one per user."]})})]}),c.hasUniqueOptionsFields&&h.jsxs("div",{className:"rounded-lg border bg-muted/30 p-4 space-y-3",children:[h.jsx("p",{className:"text-sm font-medium",children:"Connection Options"}),h.jsx(xs,{visible:c.configDraft.hasConflict,onReload:c.configDraft.reset}),h.jsx(bi,{schema:c.configDraft.revision??void 0,values:c.configValues,onValuesChange:c.handleValuesChange})]})]})]}),I=c.selectedConnector&&!c.previewConnector?h.jsxs(h.Fragment,{children:[c.authorizationUrl&&h.jsx("a",{className:"text-sm underline",href:c.authorizationUrl,target:"_blank",rel:"noreferrer",children:"Continue authorization in your browser"}),c.saveError&&h.jsx("div",{className:"w-full mb-3 rounded-md bg-red-50 dark:bg-red-950/30 p-3 text-sm text-red-600 dark:text-red-400",children:c.saveError}),h.jsxs("div",{className:"flex items-center w-full",children:[c.isEditMode&&h.jsx("div",{className:"mr-auto",children:c.showDeleteConfirm?h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsx(ge,{variant:"destructive",size:"sm",disabled:c.deleteConnection.isPending,onClick:()=>{const R=c.connectorDefs.find(H=>H.key===n.connector_key)?.required_capability;R&&(window.location.href=Fh(`revoke/${R}`)),c.deleteConnection.mutate(n.id,{onSuccess:()=>c.handleOpenChange(!1)})},children:c.deleteConnection.isPending?h.jsxs(h.Fragment,{children:[h.jsx(dt,{size:"md",className:"mr-1.5"}),"Deleting..."]}):"Confirm"}),h.jsx(ge,{variant:"outline",size:"sm",onClick:()=>c.setShowDeleteConfirm(!1),disabled:c.deleteConnection.isPending,children:"Cancel"})]}):h.jsxs(ge,{variant:"ghost",size:"sm",className:"text-destructive hover:text-destructive",onClick:()=>c.setShowDeleteConfirm(!0),children:[h.jsx(ui,{className:"mr-1.5 h-3.5 w-3.5"}),"Delete"]})}),!(!c.isEditMode&&c.activeMethod?.type==="app_installation")&&h.jsx(ge,{onClick:c.handleSave,disabled:!c.configDraft.canSubmit||c.isSaving||!!c.existingNoAuthConnection,children:c.isSaving?h.jsxs(h.Fragment,{children:[h.jsx(dt,{size:"lg",className:"mr-2"}),c.isEditMode?"Saving...":"Creating..."]}):c.isEditMode?h.jsx(h.Fragment,{children:"Save Changes"}):h.jsxs(h.Fragment,{children:[h.jsx(la,{className:"mr-2 h-4 w-4"}),"Add connection"]})})]})]}):null,T=I?h.jsx("div",{className:"mt-6",children:I}):null,q=h.jsx(s7e,{runId:c.activeMethod?.type==="interactive"?null:c.pendingAuthRunId,onClose:()=>{c.setPendingAuthRunId(null),c.isEditMode||c.handleOpenChange(!1)}});return h.jsxs(h.Fragment,{children:[j,N,T,q]})}function o9e({providerKind:e,credentialFields:t,isProviderCatalogLoading:n,ownerSlug:a,onBack:o}){const s=qn(),l=afe(),c=Zu(e);return h.jsxs("div",{className:"space-y-4",children:[h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsx(ge,{variant:"ghost",size:"sm",onClick:o,className:"h-7 px-2 text-xs",children:"← Back"}),h.jsx(Ll,{connector:{key:`${Vh}${e}`,name:c,favicon_domain:GA(e)},showDescription:!1,className:"gap-2"}),h.jsx(Jm,{facets:og()})]}),n?h.jsx(YA,{rows:4,className:"max-w-md"}):t?h.jsx(RMe,{providerKind:e,credentialFields:t,pending:l.isPending,onCancel:o,onCreate:d=>l.mutate(d,{onSuccess:f=>{const p=f?.sandbox?.id;s({to:p?"/$owner/connectors/$connectorKey":"/$owner/connectors",params:p?{owner:a,connectorKey:`sandbox:${p}`}:{owner:a}})}})}):h.jsx("p",{className:"rounded-md bg-destructive/10 px-3 py-2 text-sm text-destructive",children:"This runtime provider is not available from the gateway."})]})}function i9e({ownerSlug:e,organizationId:t,connections:n,initialConnectorKey:a}){const o=qn();return h.jsx(r9e,{onClose:()=>{o({to:"/$owner/connectors",params:{owner:e}})},organizationId:t,connections:n,initialConnectorKey:a,ownerSlug:e,onDeepLinkBack:a?()=>{o({to:"/$owner/connectors/$connectorKey",params:{owner:e,connectorKey:a}})}:void 0})}function s9e({owner:e,children:t}){const{data:n,isLoading:a,error:o}=gn(e,{slug:e}),{session:s,isReady:l}=Xa(),c=vz(o),d=xz(o)&&!c&&!n?.workspace;gfe({active:!a&&!d&&l&&!s&&!n?.workspace,owner:e});const f=n?.workspace;return a?h.jsx(h.Fragment,{children:t({organizationId:null,ownerSlug:e,isWorkspaceLoading:!0})}):d?h.jsxs("div",{role:"alert",className:"flex flex-col items-center justify-center gap-1 py-12 text-center",children:[h.jsx("p",{className:"text-muted-foreground",children:"This workspace could not be loaded."}),h.jsx("p",{className:"text-xs text-muted-foreground/70",children:"Please try again in a moment."})]}):c||!f?h.jsx("div",{className:"flex items-center justify-center py-12 text-muted-foreground",children:"Organization not found"}):f.type!=="organization"?h.jsx("div",{className:"flex flex-1 flex-col items-center justify-center gap-2 py-16 text-center",children:h.jsx("p",{className:"text-muted-foreground max-w-md",children:"Select an organization to view this page."})}):h.jsx(h.Fragment,{children:t({organizationId:f.id,ownerSlug:f.slug,isWorkspaceLoading:!1})})}const l9e=()=>Ee(()=>import("./create-Dwo04oWV.js"),[]),c9e=_e("/$owner/connectors/create")({component:Ae(l9e,"component")});function DEe({owner:e,initialConnectorKey:t}){return h.jsx(s9e,{owner:e,children:n=>h.jsx(u9e,{ownerSlug:n.ownerSlug,organizationId:n.organizationId,initialConnectorKey:t})})}function u9e({ownerSlug:e,organizationId:t,initialConnectorKey:n}){const{data:a=[]}=H2(t??"");return h.jsxs(rA,{className:"flex flex-1 flex-col gap-6",children:[h.jsx(jwe,{breadcrumb:h.jsx(Rwe,{crumbs:[h.jsx(Ct,{to:"/$owner/connectors",params:{owner:e},search:{},className:Ewe,children:"Connectors"},"connectors")]}),icon:h.jsx(zn.connectors.icon,{className:"h-6 w-6"}),title:"Add a connection",caption:"Pick a connector from the catalog or drop in an MCP URL — Lobu handles auth and brings the data into memory."}),t?h.jsx(i9e,{ownerSlug:e,organizationId:t,connections:a,initialConnectorKey:n}):h.jsx("div",{className:"max-w-3xl",children:h.jsx(YA,{rows:4})})]})}const d9e=()=>Ee(()=>import("./_agentId-BAVnp0c7.js"),__vite__mapDeps([63,17,16,18,13,12,30])),h9e=_e("/$owner/chat/$agentId")({validateSearch:e=>{const t={};(e.new===!0||e.new==="1"||e.new==="true")&&(t.new=!0),typeof e.prompt=="string"&&e.prompt.length>0&&(t.prompt=e.prompt);const n=typeof e.message_id=="string"&&e.message_id.trim()||typeof e.message=="string"&&e.message.trim()||"";return n&&(t.message_id=n),Object.assign(t,uc(e)),t},loader:({context:{queryClient:e},params:t})=>{e.prefetchQuery(gn.queryOptions(t.owner,{slug:t.owner})),e.prefetchQuery(vo.queryOptions(t.owner))},component:Ae(d9e,"component")});function f9e(e){const t=n=>typeof e[n]=="string"?e[n]:void 0;return Dt({listen:t("listen"),platform:t("platform"),team:t("team"),label:t("label"),connection:t("connection"),resource_type:t("resource_type"),resource:t("resource"),events:t("events"),agent:t("agent")})}const p9e=()=>Ee(()=>import("./new-BVQS9H-Y.js"),__vite__mapDeps([64,2,3,4,5,6,7,8,9,10,11,12,13])),y9e=_e("/$owner/automations/new")({loader:({context:{queryClient:e},params:t})=>{e.prefetchQuery(gn.queryOptions(t.owner,{slug:t.owner}))},validateSearch:e=>f9e(e),component:Ae(p9e,"component")});function zE(e){const t=typeof e=="string"?Number(e):e;if(!(typeof t!="number"||!Number.isInteger(t)||t<=0))return t}function IEe(e){return e.isReview?e.status==="pending"?"active":e.status==="gone"?"gone":e.isError?"error":"loading":"none"}function qEe(e){const t={};return e&&(typeof e.name=="string"&&(t.name=e.name),typeof e.description=="string"&&(t.description=e.description),typeof e.identity_md=="string"&&(t.identityMd=e.identity_md)),t}const m9e=()=>Ee(()=>import("./_automationId-D696vOjd.js"),__vite__mapDeps([65,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23]));function g9e(e){return e==="definition"?"definition":"activity"}const k9e=_e("/$owner/automations/$automationId")({loader:({context:{queryClient:e},params:t})=>{e.prefetchQuery(gn.queryOptions(t.owner,{slug:t.owner}))},validateSearch:e=>({run_id:zE(e.run_id),view:g9e(e.view)}),component:Ae(m9e,"component")}),v9e=()=>Ee(()=>import("./new-DxDVE9nL.js"),__vite__mapDeps([66,67,8])),x9e=_e("/$owner/agents/new")({component:Ae(v9e,"component")}),b9e=()=>Ee(()=>import("./connect-Dtb-E5An.js"),[]),w9e=_e("/$owner/agents/connect")({component:Ae(b9e,"component")}),M9e=()=>Ee(()=>import("./_agentId-Df-3rGi5.js"),__vite__mapDeps([68,69,67,8,14,15])),S9e=_e("/$owner/agents/$agentId")({beforeLoad:({params:e,location:t})=>{const n=`/${e.owner}/agents/${e.agentId}`;(t.pathname===n||t.pathname===`${n}/`)&&e6e(e.owner,e.agentId)},loader:({context:{queryClient:e},params:t})=>{e.prefetchQuery(gn.queryOptions(t.owner,{slug:t.owner})),e.prefetchQuery(vo.queryOptions(t.owner))},component:Ae(M9e,"component")}),_9e=()=>Ee(()=>import("./index-3o4Eepb4.js"),__vite__mapDeps([70,71])),C9e=_e("/$owner/connectors/deployments/")({component:Ae(_9e,"component")}),A9e=()=>Ee(()=>import("./index-vdqhlocx.js"),[]),E9e=_e("/$owner/connectors/create/")({validateSearch:e=>Dt({connector:typeof e.connector=="string"&&e.connector.length>0?e.connector:void 0,install:typeof e.install=="string"&&e.install.length>0?e.install:void 0}),component:Ae(A9e,"component")}),R9e=b.forwardRef(({className:e,...t},n)=>h.jsx("div",{className:"relative w-full overflow-auto",children:h.jsx("table",{ref:n,className:ye("w-full caption-bottom text-sm",e),...t})}));R9e.displayName="Table";const j9e=b.forwardRef(({className:e,...t},n)=>h.jsx("thead",{ref:n,className:ye("[&_tr]:border-b",e),...t}));j9e.displayName="TableHeader";const O9e=b.forwardRef(({className:e,...t},n)=>h.jsx("tbody",{ref:n,className:ye("[&_tr:last-child]:border-0",e),...t}));O9e.displayName="TableBody";const N9e=b.forwardRef(({className:e,...t},n)=>h.jsx("tr",{ref:n,className:ye("border-b transition-colors hover:bg-muted/50 data-[state=selected]:bg-muted",e),...t}));N9e.displayName="TableRow";const T9e=b.forwardRef(({className:e,...t},n)=>h.jsx("th",{ref:n,className:ye("h-10 px-4 text-left align-middle font-medium text-muted-foreground [&:has([role=checkbox])]:pr-0 [&>[role=checkbox]]:translate-y-[2px]",e),...t}));T9e.displayName="TableHead";const P9e=b.forwardRef(({className:e,...t},n)=>h.jsx("td",{ref:n,className:ye("p-4 align-middle [&:has([role=checkbox])]:pr-0 [&>[role=checkbox]]:translate-y-[2px]",e),...t}));P9e.displayName="TableCell";function L9e(e){const t=$Me(e);if(t!==null)return{kind:"inference",id:t};const n=AMe(e);if(n!==null)return{kind:"sandbox",id:n};const a=jh(e);return a!==null?{kind:"sandbox-provider",id:a}:{kind:"connector",id:null}}function z9e(e){return L9e(e).kind==="connector"}const D9e=()=>Ee(()=>import("./_connectorKey.index-BBF8vGJS.js"),__vite__mapDeps([72,73,25,5,74,15])),I9e=_e("/$owner/connectors/$connectorKey/")({validateSearch:e=>Dt({setup:e.setup==="oauth_app"?"oauth_app":void 0,model:typeof e.model=="string"?e.model:void 0,reason:typeof e.reason=="string"?e.reason:void 0,agentId:typeof e.agentId=="string"?e.agentId:void 0}),loader:({context:{queryClient:e},params:t})=>{e.fetchQuery(gn.queryOptions(t.owner,{slug:t.owner})).then(n=>{const a=n?.workspace?.id;a&&z9e(t.connectorKey)&&(e.prefetchQuery(hk.queryOptions(a)),e.prefetchQuery(H2.queryOptions(a,{connectorKey:t.connectorKey})))}).catch(()=>{})},component:Ae(D9e,"component")}),q9e=()=>Ee(()=>import("./index-rrnUF981.js"),[]),H9e=_e("/$owner/chat/$agentId/")({component:Ae(q9e,"component")}),V9e=()=>Ee(()=>import("./index-D7wulT4y.js"),__vite__mapDeps([75,76,56,20,31])),F9e=_e("/$owner/agents/connect/")({component:Ae(V9e,"component")}),B9e=()=>Ee(()=>import("./device._deviceId-DTYKGBY8.js"),__vite__mapDeps([77,78,74,15,25,5,51])),$9e=_e("/$owner/connectors/device/$deviceId")({validateSearch:e=>({connection:typeof e.connection=="number"?e.connection:typeof e.connection=="string"&&/^\d+$/.test(e.connection)?Number(e.connection):void 0,settings:e.settings===!0||e.settings==="true"?!0:void 0}),loader:({context:{queryClient:e}})=>e.prefetchQuery(d1.queryOptions()),component:Ae(B9e,"component")}),U9e=()=>Ee(()=>import("./_deploymentId-Iy-D5PDq.js"),__vite__mapDeps([79,71,23,11,12])),K9e=_e("/$owner/connectors/deployments/$deploymentId")({component:Ae(U9e,"component")}),G9e=()=>Ee(()=>import("./create._connectorKey-CCBb2pil.js"),[]),Y9e=_e("/$owner/connectors/create/$connectorKey")({component:Ae(G9e,"component")}),W9e=()=>Ee(()=>import("./app._appId-D0_LQTJU.js"),__vite__mapDeps([80,51])),Z9e=_e("/$owner/connectors/app/$appId")({component:Ae(W9e,"component")}),Q9e=()=>Ee(()=>import("./_connectorKey._connectionId-BAJGfcy7.js"),__vite__mapDeps([81,78,74,15,25,5,73,24,4,51])),X9e=_e("/$owner/connectors/$connectorKey/$connectionId")({validateSearch:e=>Dt({settings:e.settings===!0||e.settings==="true"?!0:void 0,auth_result:e.auth_result==="connected"||e.auth_result==="cancelled"||e.auth_result==="failed"?e.auth_result:void 0,addFeed:e.addFeed===!0||e.addFeed==="true"?!0:void 0,feedId:typeof e.feedId=="number"?e.feedId:typeof e.feedId=="string"&&/^\d+$/.test(e.feedId)?Number(e.feedId):void 0}),loaderDeps:({search:{feedId:e}})=>({feedId:e}),loader:({context:{queryClient:e},params:t,deps:n})=>{e.fetchQuery(gn.queryOptions(t.owner,{slug:t.owner})).then(a=>{const o=a?.workspace?.id;o&&(e.prefetchQuery(H2.queryOptions(o,{connectorKey:t.connectorKey})),e.prefetchQuery(O9.queryOptions(o)),n.feedId!==void 0&&e.prefetchQuery(T9.queryOptions(Number(t.connectionId))))}).catch(()=>{})},component:Ae(Q9e,"component")}),J9e=()=>Ee(()=>import("./connected._clientId-CMe-wTuV.js"),__vite__mapDeps([82,20,31])),eSe=_e("/$owner/agents/connected/$clientId")({component:Ae(J9e,"component")}),tSe=()=>Ee(()=>import("./connect._clientId-DWtceAAw.js"),__vite__mapDeps([83,76,56,20,31])),nSe=_e("/$owner/agents/connect/$clientId")({component:Ae(tSe,"component")}),aSe=()=>Ee(()=>import("./skills-CN5Ube7A.js"),__vite__mapDeps([84,85,47,9])),rSe=_e("/$owner/agents/$agentId/skills")({component:Ae(aSe,"component")}),DE={validateSearch:e=>({run_id:zE(e.run_id)}),loader:({context:{queryClient:e},params:t})=>{e.prefetchQuery(gn.queryOptions(t.owner,{slug:t.owner})),e.prefetchQuery(vo.queryOptions(t.owner))}},oSe=()=>Ee(()=>import("./settings-Bg9yCCoN.js"),__vite__mapDeps([86,69,67,8,14,15])),iSe=_e("/$owner/agents/$agentId/settings")({...DE,component:Ae(oSe,"component")}),sSe=()=>Ee(()=>import("./permissions-Fe0DP6b8.js"),__vite__mapDeps([87,60,88])),lSe=_e("/$owner/agents/$agentId/permissions")({loader:({context:{queryClient:e},params:t})=>{e.prefetchQuery(gn.queryOptions(t.owner,{slug:t.owner})),e.prefetchQuery(vo.queryOptions(t.owner))},component:Ae(sSe,"component")}),cSe=()=>Ee(()=>import("./models-M51OGDRE.js"),__vite__mapDeps([89,69,67,8,14,15])),uSe=_e("/$owner/agents/$agentId/models")({loader:({context:{queryClient:e},params:t})=>{e.prefetchQuery(gn.queryOptions(t.owner,{slug:t.owner})),e.prefetchQuery(vo.queryOptions(t.owner))},component:Ae(cSe,"component")}),dSe=()=>Ee(()=>import("./identity-MSLryUi8.js"),__vite__mapDeps([90,69,67,8,14,15])),hSe=_e("/$owner/agents/$agentId/identity")({...DE,component:Ae(dSe,"component")}),fSe=()=>Ee(()=>import("./guardrails-CLlnRRy9.js"),[]),pSe=_e("/$owner/agents/$agentId/guardrails")({component:Ae(fSe,"component")}),ySe=()=>Ee(()=>import("./index-DTSA0Xh1.js"),__vite__mapDeps([91,92,88,85,47,9,16,93,6])),mSe=_e("/$owner/agents/$agentId/skills/")({component:Ae(ySe,"component")}),gSe=()=>Ee(()=>import("./index-DxXXVPU0.js"),__vite__mapDeps([94,95,8,88,16,93,6])),kSe=_e("/$owner/agents/$agentId/guardrails/")({component:Ae(gSe,"component")}),vSe=()=>Ee(()=>import("./_threadId-DtqBFgK5.js"),[]),xSe=_e("/$owner/chat/$agentId/c/$threadId")({validateSearch:e=>{const t={...uc(e)},n=typeof e.message_id=="string"&&e.message_id.trim()||typeof e.message=="string"&&e.message.trim()||"";return n&&(t.message_id=n),t},component:Ae(vSe,"component")}),bSe=()=>Ee(()=>import("./create-Cp6hMoeU.js"),__vite__mapDeps([96,92,88,85,47,9,16,93,6])),wSe=_e("/$owner/agents/$agentId/skills/create")({component:Ae(bSe,"component")}),MSe=()=>Ee(()=>import("./_skillKey-DuLcQWBu.js"),__vite__mapDeps([97,92,88,85,47,9,16,93,6])),SSe=_e("/$owner/agents/$agentId/skills/$skillKey")({component:Ae(MSe,"component")}),_Se=()=>Ee(()=>import("./create-CcXUdke7.js"),__vite__mapDeps([98,95,8,88,16,93,6])),CSe=_e("/$owner/agents/$agentId/guardrails/create")({component:Ae(_Se,"component")}),ASe=()=>Ee(()=>import("./_name-CeGwb0oK.js"),__vite__mapDeps([99,95,8,88,16,93,6])),ESe=_e("/$owner/agents/$agentId/guardrails/$name")({component:Ae(ASe,"component")}),RSe=()=>Ee(()=>import("./_conversationId-Ci4rgrHm.js"),__vite__mapDeps([100,16,17,18,13,12])),jSe=_e("/$owner/agents/$agentId/conversations/$conversationId")({component:Ae(RSe,"component")}),_n=s8e.update({id:"/$owner",path:"/$owner",getParentRoute:()=>ka}),OSe=c8e.update({id:"/",path:"/",getParentRoute:()=>ka}),NSe=d8e.update({id:"/",path:"/",getParentRoute:()=>_n}),TSe=f8e.update({id:"/slack/claim",path:"/slack/claim",getParentRoute:()=>ka}),PSe=y8e.update({id:"/orgs/new",path:"/orgs/new",getParentRoute:()=>ka}),LSe=k8e.update({id:"/oauth/device",path:"/oauth/device",getParentRoute:()=>ka}),zSe=x8e.update({id:"/oauth/consent",path:"/oauth/consent",getParentRoute:()=>ka}),DSe=w8e.update({id:"/auth/reset-password",path:"/auth/reset-password",getParentRoute:()=>ka}),ISe=S8e.update({id:"/auth/logout",path:"/auth/logout",getParentRoute:()=>ka}),qSe=C8e.update({id:"/auth/login",path:"/auth/login",getParentRoute:()=>ka}),HSe=E8e.update({id:"/auth/callback",path:"/auth/callback",getParentRoute:()=>ka}),VSe=j8e.update({id:"/auth/accept-invitation",path:"/auth/accept-invitation",getParentRoute:()=>ka}),FSe=N8e.update({id:"/account/settings",path:"/account/settings",getParentRoute:()=>ka}),BSe=P8e.update({id:"/recent",path:"/recent",getParentRoute:()=>_n}),Ii=z8e.update({id:"/connectors",path:"/connectors",getParentRoute:()=>_n}),w0=I8e.update({id:"/automations",path:"/automations",getParentRoute:()=>_n}),fc=H8e.update({id:"/agents",path:"/agents",getParentRoute:()=>_n}),$Se=$8e.update({id:"/$",path:"/$",getParentRoute:()=>_n}),USe=Y8e.update({id:"/memory/",path:"/memory/",getParentRoute:()=>_n}),KSe=Z8e.update({id:"/members/",path:"/members/",getParentRoute:()=>_n}),GSe=X8e.update({id:"/events/",path:"/events/",getParentRoute:()=>_n}),YSe=iwe.update({id:"/",path:"/",getParentRoute:()=>Ii}),WSe=lwe.update({id:"/chat/",path:"/chat/",getParentRoute:()=>_n}),ZSe=uwe.update({id:"/",path:"/",getParentRoute:()=>w0}),QSe=hwe.update({id:"/",path:"/",getParentRoute:()=>fc}),XSe=pwe.update({id:"/$entityType/",path:"/$entityType/",getParentRoute:()=>_n}),JSe=mwe.update({id:"/connector/$name/connection",path:"/connector/$name/connection",getParentRoute:()=>ka}),e_e=kwe.update({id:"/settings/organization",path:"/settings/organization",getParentRoute:()=>_n}),t_e=xwe.update({id:"/memory/$",path:"/memory/$",getParentRoute:()=>_n}),n_e=wwe.update({id:"/events/$",path:"/events/$",getParentRoute:()=>_n}),a_e=Mwe.update({id:"/entity-types/new",path:"/entity-types/new",getParentRoute:()=>_n}),r_e=_we.update({id:"/entity-types/$slug",path:"/entity-types/$slug",getParentRoute:()=>_n}),Sv=Awe.update({id:"/deployments",path:"/deployments",getParentRoute:()=>Ii}),_v=c9e.update({id:"/create",path:"/create",getParentRoute:()=>Ii}),Cv=h9e.update({id:"/chat/$agentId",path:"/chat/$agentId",getParentRoute:()=>_n}),o_e=y9e.update({id:"/new",path:"/new",getParentRoute:()=>w0}),i_e=k9e.update({id:"/$automationId",path:"/$automationId",getParentRoute:()=>w0}),s_e=x9e.update({id:"/new",path:"/new",getParentRoute:()=>fc}),Av=w9e.update({id:"/connect",path:"/connect",getParentRoute:()=>fc}),qi=S9e.update({id:"/$agentId",path:"/$agentId",getParentRoute:()=>fc}),l_e=C9e.update({id:"/",path:"/",getParentRoute:()=>Sv}),c_e=E9e.update({id:"/",path:"/",getParentRoute:()=>_v}),u_e=I9e.update({id:"/$connectorKey/",path:"/$connectorKey/",getParentRoute:()=>Ii}),d_e=H9e.update({id:"/",path:"/",getParentRoute:()=>Cv}),h_e=F9e.update({id:"/",path:"/",getParentRoute:()=>Av}),f_e=$9e.update({id:"/device/$deviceId",path:"/device/$deviceId",getParentRoute:()=>Ii}),p_e=K9e.update({id:"/$deploymentId",path:"/$deploymentId",getParentRoute:()=>Sv}),y_e=Y9e.update({id:"/$connectorKey",path:"/$connectorKey",getParentRoute:()=>_v}),m_e=Z9e.update({id:"/app/$appId",path:"/app/$appId",getParentRoute:()=>Ii}),g_e=X9e.update({id:"/$connectorKey/$connectionId",path:"/$connectorKey/$connectionId",getParentRoute:()=>Ii}),k_e=eSe.update({id:"/connected/$clientId",path:"/connected/$clientId",getParentRoute:()=>fc}),v_e=nSe.update({id:"/$clientId",path:"/$clientId",getParentRoute:()=>Av}),M0=rSe.update({id:"/skills",path:"/skills",getParentRoute:()=>qi}),x_e=iSe.update({id:"/settings",path:"/settings",getParentRoute:()=>qi}),b_e=lSe.update({id:"/permissions",path:"/permissions",getParentRoute:()=>qi}),w_e=uSe.update({id:"/models",path:"/models",getParentRoute:()=>qi}),M_e=hSe.update({id:"/identity",path:"/identity",getParentRoute:()=>qi}),S0=pSe.update({id:"/guardrails",path:"/guardrails",getParentRoute:()=>qi}),S_e=mSe.update({id:"/",path:"/",getParentRoute:()=>M0}),__e=kSe.update({id:"/",path:"/",getParentRoute:()=>S0}),C_e=xSe.update({id:"/c/$threadId",path:"/c/$threadId",getParentRoute:()=>Cv}),A_e=wSe.update({id:"/create",path:"/create",getParentRoute:()=>M0}),E_e=SSe.update({id:"/$skillKey",path:"/$skillKey",getParentRoute:()=>M0}),R_e=CSe.update({id:"/create",path:"/create",getParentRoute:()=>S0}),j_e=ESe.update({id:"/$name",path:"/$name",getParentRoute:()=>S0}),O_e=jSe.update({id:"/conversations/$conversationId",path:"/conversations/$conversationId",getParentRoute:()=>qi}),N_e={OwnerAgentsAgentIdGuardrailsNameRoute:j_e,OwnerAgentsAgentIdGuardrailsCreateRoute:R_e,OwnerAgentsAgentIdGuardrailsIndexRoute:__e},T_e=S0._addFileChildren(N_e),P_e={OwnerAgentsAgentIdSkillsSkillKeyRoute:E_e,OwnerAgentsAgentIdSkillsCreateRoute:A_e,OwnerAgentsAgentIdSkillsIndexRoute:S_e},L_e=M0._addFileChildren(P_e),z_e={OwnerAgentsAgentIdGuardrailsRoute:T_e,OwnerAgentsAgentIdIdentityRoute:M_e,OwnerAgentsAgentIdModelsRoute:w_e,OwnerAgentsAgentIdPermissionsRoute:b_e,OwnerAgentsAgentIdSettingsRoute:x_e,OwnerAgentsAgentIdSkillsRoute:L_e,OwnerAgentsAgentIdConversationsConversationIdRoute:O_e},D_e=qi._addFileChildren(z_e),I_e={OwnerAgentsConnectClientIdRoute:v_e,OwnerAgentsConnectIndexRoute:h_e},q_e=Av._addFileChildren(I_e),H_e={OwnerAgentsAgentIdRoute:D_e,OwnerAgentsConnectRoute:q_e,OwnerAgentsNewRoute:s_e,OwnerAgentsIndexRoute:QSe,OwnerAgentsConnectedClientIdRoute:k_e},V_e=fc._addFileChildren(H_e),F_e={OwnerAutomationsAutomationIdRoute:i_e,OwnerAutomationsNewRoute:o_e,OwnerAutomationsIndexRoute:ZSe},B_e=w0._addFileChildren(F_e),$_e={OwnerConnectorsCreateConnectorKeyRoute:y_e,OwnerConnectorsCreateIndexRoute:c_e},U_e=_v._addFileChildren($_e),K_e={OwnerConnectorsDeploymentsDeploymentIdRoute:p_e,OwnerConnectorsDeploymentsIndexRoute:l_e},G_e=Sv._addFileChildren(K_e),Y_e={OwnerConnectorsCreateRoute:U_e,OwnerConnectorsDeploymentsRoute:G_e,OwnerConnectorsIndexRoute:YSe,OwnerConnectorsConnectorKeyConnectionIdRoute:g_e,OwnerConnectorsAppAppIdRoute:m_e,OwnerConnectorsDeviceDeviceIdRoute:f_e,OwnerConnectorsConnectorKeyIndexRoute:u_e},W_e=Ii._addFileChildren(Y_e),Z_e={OwnerChatAgentIdIndexRoute:d_e,OwnerChatAgentIdCThreadIdRoute:C_e},Q_e=Cv._addFileChildren(Z_e),X_e={OwnerSplatRoute:$Se,OwnerAgentsRoute:V_e,OwnerAutomationsRoute:B_e,OwnerConnectorsRoute:W_e,OwnerRecentRoute:BSe,OwnerIndexRoute:NSe,OwnerChatAgentIdRoute:Q_e,OwnerEntityTypesSlugRoute:r_e,OwnerEntityTypesNewRoute:a_e,OwnerEventsSplatRoute:n_e,OwnerMemorySplatRoute:t_e,OwnerSettingsOrganizationRoute:e_e,OwnerEntityTypeIndexRoute:XSe,OwnerChatIndexRoute:WSe,OwnerEventsIndexRoute:GSe,OwnerMembersIndexRoute:KSe,OwnerMemoryIndexRoute:USe},J_e=_n._addFileChildren(X_e),eCe={IndexRoute:OSe,OwnerRoute:J_e,AccountSettingsRoute:FSe,AuthAcceptInvitationRoute:VSe,AuthCallbackRoute:HSe,AuthLoginRoute:qSe,AuthLogoutRoute:ISe,AuthResetPasswordRoute:DSe,OauthConsentRoute:zSe,OauthDeviceRoute:LSe,OrgsNewRoute:PSe,SlackClaimRoute:TSe,ConnectorNameConnectionRoute:JSe},tCe=ka._addFileChildren(eCe)._addFileTypes(),IE=new bO({defaultOptions:{queries:{staleTime:1e3*60*5,retry:1}}}),K8=b2(),nCe=pT({routeTree:tCe,context:{queryClient:IE},history:K8?N1e(K8):void 0,parseSearch:S1e,stringifySearch:_1e,defaultPreload:"intent",defaultPreloadStaleTime:0,defaultErrorComponent:M1e,defaultNotFoundComponent:x1e,defaultPendingComponent:()=>b.createElement(R7),defaultPendingMs:150,defaultPendingMinMs:300});TM();const G8=Tz(window.location.search);G8!==window.location.search&&window.history.replaceState(window.history.state,"",`${window.location.pathname}${G8}${window.location.hash}`);{const e=dz(window.location.pathname);e!==window.location.pathname&&window.history.replaceState(window.history.state,"",`${e}${window.location.search}${window.location.hash}`)}const Y8=new URLSearchParams(window.location.search).get("lobu_token");if(Y8){const e=new URL(window.location.href);e.searchParams.delete("lobu_token");const t=e.pathname+e.search+e.hash;window.location.replace(`/api/exchange-token?token=${encodeURIComponent(Y8)}&next=${encodeURIComponent(t)}`),await new Promise(()=>{})}const qE=document.getElementById("root");if(!qE)throw new Error("Root element not found");const Th=qE;MT.createRoot(Th).render(h.jsx(fe.StrictMode,{children:h.jsx(MO,{client:IE,children:h.jsx(jz,{children:h.jsx(gT,{router:nCe})})})}));const gh=document.getElementById("ssr-hydrate-shell");if(gh){let e=function(){a||(a=new MutationObserver(()=>{kb(Th)&&l()}),a.observe(Th,{attributes:!0,childList:!0,characterData:!0,subtree:!0}))},t=function(){if(kb(Th)){l();return}e()},n=!1,a=null;const o=()=>{window.removeEventListener(vm,t),a?.disconnect()},s=()=>{gh.remove(),o()},l=()=>{n||(n=!0,requestAnimationFrame(()=>{requestAnimationFrame(()=>{gh.classList.add("is-hidden"),gh.addEventListener("transitionend",s,{once:!0}),window.setTimeout(s,400)})}))};window.addEventListener(vm,t),window.setTimeout(t,5e3)}export{DAe as $,cg as A,ge as B,v7e as C,i8 as D,a1 as E,xs as F,$Ae as G,wte as H,jZ as I,Dk as J,UC as K,Ct as L,sc as M,Zg as N,Xg as O,la as P,E2 as Q,R2 as R,ft as S,j2 as T,gF as U,SI as V,s8e as W,vs as X,Xa as Y,xz as Z,gfe as _,H2 as a,R7 as a$,fm as a0,er as a1,qn as a2,t1 as a3,N9 as a4,kk as a5,d8e as a6,qw as a7,iCe as a8,y8e as a9,m1e as aA,p7 as aB,tc as aC,mn as aD,He as aE,Nr as aF,Mn as aG,dr as aH,go as aI,oc as aJ,i1 as aK,fe as aL,Ju as aM,ZM as aN,Za as aO,yue as aP,YH as aQ,_ue as aR,Yl as aS,zn as aT,P8e as aU,s9e as aV,Vu as aW,s6e as aX,mCe as aY,$8e as aZ,V8e as a_,ha as aa,Lt as ab,Au as ac,EM as ad,k8e as ae,on as af,pt as ag,x8e as ah,pCe as ai,ye as aj,Mv as ak,mk as al,w8e as am,Ge as an,Tr as ao,cM as ap,K0e as aq,fCe as ar,GM as as,cCe as at,Sz as au,uCe as av,lM as aw,dCe as ax,j8e as ay,FM as az,Z7e as b,so as b$,kCe as b0,Ee as b1,Y8e as b2,X8e as b3,eAe as b4,iwe as b5,HCe as b6,fk as b7,mEe as b8,PMe as b9,_ne as bA,The as bB,IW as bC,sV as bD,d7 as bE,wle as bF,RJ as bG,Lg as bH,$g as bI,BM as bJ,r7 as bK,uwe as bL,mfe as bM,Nhe as bN,Xh as bO,l_ as bP,hwe as bQ,pwe as bR,ks as bS,oCe as bT,xAe as bU,RAe as bV,jAe as bW,vAe as bX,si as bY,io as bZ,li as b_,nfe as ba,d1 as bb,rA as bc,EEe as bd,fEe as be,B7e as bf,rwe as bg,ewe as bh,Wy as bi,AEe as bj,kv as bk,J8e as bl,v1e as bm,a4e as bn,GA as bo,p_ as bp,Ik as bq,h_ as br,Jm as bs,X7 as bt,lwe as bu,vo as bv,ui as bw,c6 as bx,DC as by,KAe as bz,q8 as c,kre as c$,Bn as c0,lMe as c1,CMe as c2,ufe as c3,dfe as c4,LAe as c5,gAe as c6,k1e as c7,gCe as c8,hCe as c9,N9e as cA,T9e as cB,O9e as cC,P9e as cD,st as cE,Kn as cF,CAe as cG,fAe as cH,pAe as cI,fQ as cJ,m$ as cK,cse as cL,r1 as cM,Dbe as cN,Ibe as cO,n1 as cP,LC as cQ,Ym as cR,DM as cS,e1 as cT,sn as cU,Qa as cV,i7 as cW,fae as cX,JY as cY,tX as cZ,ZU as c_,aCe as ca,G9 as cb,AO as cc,bAe as cd,qC as ce,NH as cf,iEe as cg,Phe as ch,wMe as ci,MMe as cj,UA as ck,tk as cl,goe as cm,yAe as cn,NEe as co,_Ae as cp,yCe as cq,YA as cr,Dg as cs,XAe as ct,AW as cu,W9 as cv,PAe as cw,SM as cx,R9e as cy,j9e as cz,x7e as d,_6e as d$,dAe as d0,b2 as d1,CM as d2,j1e as d3,kwe as d4,S2 as d5,wwe as d6,IC as d7,i4e as d8,Hg as d9,EI as dA,e0 as dB,t0 as dC,lAe as dD,nEe as dE,k0e as dF,H9 as dG,nAe as dH,O9 as dI,qCe as dJ,FCe as dK,t6e as dL,BAe as dM,cAe as dN,uAe as dO,d_ as dP,iAe as dQ,sAe as dR,V9 as dS,e8e as dT,da as dU,L0e as dV,tAe as dW,aAe as dX,sEe as dY,g4e as dZ,v1 as d_,o7 as da,Jbe as db,Hn as dc,RG as dd,SMe as de,On as df,Ll as dg,eEe as dh,JAe as di,oEe as dj,QAe as dk,lEe as dl,cEe as dm,t8e as dn,wV as dp,T5e as dq,fo as dr,xe as ds,it as dt,Fk as du,Bk as dv,L8 as dw,q_ as dx,oA as dy,J2 as dz,OMe as e,UM as e$,Rq as e0,tEe as e1,Ug as e2,_we as e3,OAe as e4,yI as e5,hK as e6,c$ as e7,wAe as e8,MAe as e9,YAe as eA,WAe as eB,UAe as eC,FAe as eD,gQ as eE,Hu as eF,dEe as eG,hEe as eH,IEe as eI,Un as eJ,Nie as eK,HM as eL,zAe as eM,WCe as eN,ZCe as eO,E0e as eP,R0e as eQ,xi as eR,w2 as eS,Fl as eT,rAe as eU,oAe as eV,qAe as eW,Bg as eX,ci as eY,bCe as eZ,Cz as e_,CE as ea,SAe as eb,kAe as ec,DCe as ed,ICe as ee,LCe as ef,zCe as eg,EAe as eh,MCe as ei,ZAe as ej,qbe as ek,mAe as el,Xu as em,bi as en,Jre as eo,h2 as ep,VM as eq,sk as er,P2 as es,lk as et,ck as eu,uk as ev,hAe as ew,SCe as ex,ECe as ey,GAe as ez,jMe as f,E9 as f$,DH as f0,LU as f1,sI as f2,CCe as f3,lte as f4,mre as f5,hD as f6,uue as f7,jq as f8,UCe as f9,GY as fA,uce as fB,WM as fC,MQ as fD,vI as fE,Sn as fF,po as fG,Q2 as fH,c8 as fI,g1 as fJ,v_ as fK,M4e as fL,E4e as fM,N4e as fN,m5e as fO,k5e as fP,C4e as fQ,e2 as fR,$u as fS,z4e as fT,g1e as fU,T7e as fV,fa as fW,EE as fX,N7e as fY,ug as fZ,j7e as f_,dI as fa,BW as fb,VCe as fc,KCe as fd,YCe as fe,hte as ff,a7 as fg,M2 as fh,y7e as fi,awe as fj,TEe as fk,WA as fl,wae as fm,aEe as fn,rEe as fo,HAe as fp,hw as fq,Pr as fr,Ixe as fs,Hxe as ft,Dxe as fu,$xe as fv,DN as fw,zw as fx,Fw as fy,vW as fz,mv as g,QCe as g$,q$ as g0,js as g1,jwe as g2,Rwe as g3,Ewe as g4,i9e as g5,xCe as g6,R9 as g7,h9e as g8,y9e as g9,vEe as gA,bEe as gB,kEe as gC,SEe as gD,_Ee as gE,TAe as gF,ure as gG,uEe as gH,eg as gI,A0e as gJ,_0e as gK,NE as gL,dg as gM,x0 as gN,Qu as gO,S0e as gP,BCe as gQ,p7e as gR,f7e as gS,I9e as gT,L9e as gU,_u as gV,l7e as gW,Xm as gX,I8 as gY,Vh as gZ,Zu as g_,k9e as ga,x9e as gb,OCe as gc,NCe as gd,TCe as ge,PCe as gf,qEe as gg,S9e as gh,hoe as gi,Cre as gj,$M as gk,dre as gl,C9e as gm,lae as gn,IK as go,E9e as gp,DEe as gq,gEe as gr,yEe as gs,pEe as gt,TMe as gu,RCe as gv,jCe as gw,xEe as gx,MEe as gy,wEe as gz,M0e as h,F9e as h0,f_ as h1,JCe as h2,XCe as h3,IAe as h4,s4e as h5,l4e as h6,z5e as h7,$9e as h8,GCe as h9,SSe as hA,CSe as hB,ESe as hC,wCe as hD,jSe as hE,NAe as hF,hee as hG,Tg as hH,Ya as hI,x3e as hJ,b3e as hK,Gn as hL,W_ as hM,AAe as hN,hz as hO,Bz as hP,jY as ha,bY as hb,Fh as hc,PEe as hd,LEe as he,OEe as hf,zEe as hg,pk as hh,K9e as hi,Y9e as hj,CEe as hk,Z9e as hl,X9e as hm,eSe as hn,nSe as ho,rSe as hp,iSe as hq,lSe as hr,uSe as hs,hSe as ht,mSe as hu,Owe as hv,kSe as hw,_Ce as hx,ACe as hy,wSe as hz,$Ce as i,h as j,Bl as k,yE as l,lg as m,T9 as n,gn as o,f1 as p,uz as q,b as r,dt as s,W2 as t,hk as u,zM as v,q5e as w,k1 as x,Bve as y,d4e as z};
|