@objectstack/console 15.0.0 → 15.1.1

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.
Files changed (124) hide show
  1. package/dist/.objectui-sha +1 -1
  2. package/dist/assets/{AdapterProvider-CSP_T07G.js → AdapterProvider-BFaddpzn.js} +1 -1
  3. package/dist/assets/{AiPendingActionsPage-BNh8Cf9P.js → AiPendingActionsPage-CvBOdCmI.js} +1 -1
  4. package/dist/assets/ApiConsolePage-BETRFRmt.js +1 -0
  5. package/dist/assets/{AppDocsIndex-DFB1tmTx.js → AppDocsIndex-BYY7DwDn.js} +1 -1
  6. package/dist/assets/{AppManagementPage-D2jMv3L-.js → AppManagementPage-ct829ZDs.js} +1 -1
  7. package/dist/assets/ApprovalsInboxPage-CLRfOCfN.js +1 -0
  8. package/dist/assets/AuditLogPage-DrVbfMwo.js +1 -0
  9. package/dist/assets/{ComponentNavView-C8ngAwyN.js → ComponentNavView-BdBCf414.js} +1 -1
  10. package/dist/assets/CreateViewDialog-C1plmcyi.js +1 -0
  11. package/dist/assets/DashboardView-YwIvqU1F.js +1 -0
  12. package/dist/assets/{DeveloperHubPage-VBsID8Fk.js → DeveloperHubPage-Cv1WYOxY.js} +1 -1
  13. package/dist/assets/{DocShell-ChTlUxMm.js → DocShell-CLtiW77i.js} +1 -1
  14. package/dist/assets/ExpressionProvider-E8d0a2zy.js +1 -0
  15. package/dist/assets/FlowRunsPage-Kk2pQjuI.js +1 -0
  16. package/dist/assets/{IntegrationsPage-BR2TkAoB.js → IntegrationsPage-3Mmj9WPX.js} +2 -2
  17. package/dist/assets/InterfaceListPage-BEv_Whkh.js +1 -0
  18. package/dist/assets/ManagedByBadge-h6zYSYEw.js +1 -0
  19. package/dist/assets/MarketplaceAccessDenied-BBrk9Zzt.js +1 -0
  20. package/dist/assets/MarketplaceInstalledPage-Baul16n9.js +1 -0
  21. package/dist/assets/MarketplacePackagePage-C4BoxM9O.js +4 -0
  22. package/dist/assets/MarketplacePage-CIiUcu2P.js +1 -0
  23. package/dist/assets/MetadataInspector-Ty_bVFlI.js +1 -0
  24. package/dist/assets/MetadataProvider-Dw6hFBw2.js +1 -0
  25. package/dist/assets/ObjectDataPage-C0VN22jG.js +1 -0
  26. package/dist/assets/PageView-9Qd343Y8.js +1 -0
  27. package/dist/assets/ProfilePage-DotFPbJV.js +1 -0
  28. package/dist/assets/PublicFormsPage-DIXBuC2U.js +1 -0
  29. package/dist/assets/RecordDetailView-WbRO9Qfl.js +2 -0
  30. package/dist/assets/RecordFormPage-CVM9R6n6.js +1 -0
  31. package/dist/assets/ReportDefaultInspector-Dfj5Pq4K.js +3 -0
  32. package/dist/assets/ReportView-BuAo4KRU.js +2 -0
  33. package/dist/assets/SearchResultsPage-BXtahiUa.js +1 -0
  34. package/dist/assets/{SettingsHub-Begm6jy7.js → SettingsHub-Cbb36Ak1.js} +1 -1
  35. package/dist/assets/SettingsView-MqDu9fQ0.js +1 -0
  36. package/dist/assets/{SystemHubPage-C4J7Le-p.js → SystemHubPage-CRlHp6zs.js} +1 -1
  37. package/dist/assets/data-adapter-BaT0fWzy.js +9 -0
  38. package/dist/assets/framework-CavAJOoG.js +6 -0
  39. package/dist/assets/{getIcon-BZsP3YSU.js → getIcon-CJv2JJRu.js} +1 -1
  40. package/dist/assets/{highlighted-body-OFNGDK62-BPN_aS-T.js → highlighted-body-OFNGDK62-CmEyqxRh.js} +1 -1
  41. package/dist/assets/i18n--Ef6MgVx.js +9 -0
  42. package/dist/assets/index-DwHOkKSZ.css +2 -0
  43. package/dist/assets/index-sUYxMYg4.js +2 -0
  44. package/dist/assets/infrastructure-1EBA2wrr.js +3 -0
  45. package/dist/assets/mermaid-GHXKKRXX-B608OHDp.js +1 -0
  46. package/dist/assets/metadata-admin-CaWsYPuu.js +25 -0
  47. package/dist/assets/plugin-calendar-lTyyzuqa.js +1 -0
  48. package/dist/assets/plugin-charts-CXDDqZeY.js +7 -0
  49. package/dist/assets/plugin-chatbot-CGYrsTXi.js +120 -0
  50. package/dist/assets/plugin-dashboard-oozFEUjN.js +6 -0
  51. package/dist/assets/plugin-form-Hw4-ReuX.js +1 -0
  52. package/dist/assets/plugin-gantt-DIrw5DOt.js +102 -0
  53. package/dist/assets/plugin-grid-QB7O_mff.js +8 -0
  54. package/dist/assets/plugin-kanban-C3U_tMs4.js +1 -0
  55. package/dist/assets/plugin-map-Lz3zZGqA.js +1 -0
  56. package/dist/assets/{plugin-markdown-DgBcCCgO.js → plugin-markdown-CeSEfSMe.js} +1 -1
  57. package/dist/assets/plugin-report-CMTOJSLw.js +59 -0
  58. package/dist/assets/plugin-timeline-CKcNCEwi.js +1 -0
  59. package/dist/assets/plugin-tree-BLG1qg4e.js +1 -0
  60. package/dist/assets/plugin-view-CwV64XEY.js +1 -0
  61. package/dist/assets/plugins-views-CoEgR96I.js +4 -0
  62. package/dist/assets/{skeletons-Bf9TL3pG.js → skeletons-DGSWW9zt.js} +1 -1
  63. package/dist/assets/src-1qbKZhoo.js +1 -0
  64. package/dist/assets/{src-C6-lrmoQ.js → src-2Uisncjb.js} +1 -1
  65. package/dist/assets/src-DXuM24AK.js +18 -0
  66. package/dist/assets/{types-033eBMjb.js → types-C7NHW0h6.js} +1 -1
  67. package/dist/assets/ui-components-CHaxvtjc.js +72 -0
  68. package/dist/assets/{ui-layout-FqyUicdD.js → ui-layout-BLgfeXIq.js} +1 -1
  69. package/dist/assets/{use-book-data-BThfYUpK.js → use-book-data-BwZnHc4z.js} +1 -1
  70. package/dist/assets/{useMetadata-D5f_5ULL.js → useMetadata-IV9x2kG3.js} +1 -1
  71. package/dist/assets/vendor-objectstack-BTM1m7k5.js +104 -0
  72. package/dist/index.html +4 -4
  73. package/package.json +1 -1
  74. package/dist/assets/ApiConsolePage-Btr9hRka.js +0 -1
  75. package/dist/assets/ApprovalsInboxPage-CT4IXwpE.js +0 -1
  76. package/dist/assets/AuditLogPage-BdYvwcAH.js +0 -1
  77. package/dist/assets/CreateViewDialog-DcjN_AhY.js +0 -1
  78. package/dist/assets/DashboardView-CLJM8Cfl.js +0 -1
  79. package/dist/assets/ExpressionProvider-CHaGm5wf.js +0 -1
  80. package/dist/assets/FlowRunsPage-DdOav-6T.js +0 -1
  81. package/dist/assets/InterfaceListPage-Ca4VNsGg.js +0 -1
  82. package/dist/assets/ManagedByBadge-Cdy82I7A.js +0 -1
  83. package/dist/assets/MarketplaceAccessDenied-B6Tg5g6l.js +0 -1
  84. package/dist/assets/MarketplaceInstalledPage-DBmVXCVz.js +0 -1
  85. package/dist/assets/MarketplacePackagePage-Mt1pHE8U.js +0 -4
  86. package/dist/assets/MarketplacePage-D9CLlhnk.js +0 -1
  87. package/dist/assets/MetadataInspector-Bqe7rY0S.js +0 -1
  88. package/dist/assets/MetadataProvider-DqPZ6rV2.js +0 -1
  89. package/dist/assets/ObjectDataPage-Cz_pMsIv.js +0 -1
  90. package/dist/assets/PageView-CLvQYEdi.js +0 -1
  91. package/dist/assets/ProfilePage-BDJLPRAf.js +0 -1
  92. package/dist/assets/PublicFormsPage-BRflG64R.js +0 -1
  93. package/dist/assets/RecordDetailView-w6IBQ1cm.js +0 -2
  94. package/dist/assets/RecordFormPage-inJKFR63.js +0 -1
  95. package/dist/assets/ReportDefaultInspector-BZaG6IPJ.js +0 -3
  96. package/dist/assets/ReportView-CSAIx2AR.js +0 -2
  97. package/dist/assets/SearchResultsPage-DsnzRV3B.js +0 -1
  98. package/dist/assets/SettingsView-C4UULiJk.js +0 -1
  99. package/dist/assets/data-adapter-Mo_lVy1U.js +0 -7
  100. package/dist/assets/framework-BL3BtpKU.js +0 -36
  101. package/dist/assets/i18n-BsjEVcp4.js +0 -9
  102. package/dist/assets/index-CRgNx-tU.js +0 -2
  103. package/dist/assets/index-D1n9Ue1P.css +0 -2
  104. package/dist/assets/infrastructure-Bc4DRENl.js +0 -3
  105. package/dist/assets/mermaid-GHXKKRXX-BBQimMyN.js +0 -1
  106. package/dist/assets/metadata-admin-DHwo5kSi.js +0 -23
  107. package/dist/assets/plugin-calendar-BTCkHFNk.js +0 -1
  108. package/dist/assets/plugin-charts-DugftiGR.js +0 -7
  109. package/dist/assets/plugin-chatbot-Cq19aZcF.js +0 -120
  110. package/dist/assets/plugin-dashboard-CaQs1s4M.js +0 -6
  111. package/dist/assets/plugin-form-6ug8Woph.js +0 -1
  112. package/dist/assets/plugin-gantt-SwenNrGL.js +0 -102
  113. package/dist/assets/plugin-grid-a0e-qAUn.js +0 -8
  114. package/dist/assets/plugin-kanban-B9xzSYs9.js +0 -1
  115. package/dist/assets/plugin-map-DnfptTJp.js +0 -1
  116. package/dist/assets/plugin-report-Dny_M7U-.js +0 -59
  117. package/dist/assets/plugin-timeline-8zgO0jxJ.js +0 -1
  118. package/dist/assets/plugin-tree-Bzgro7b4.js +0 -1
  119. package/dist/assets/plugin-view-DfJ5SCdu.js +0 -1
  120. package/dist/assets/plugins-views-CoobEMX4.js +0 -4
  121. package/dist/assets/src-BMWmj9Zz.js +0 -1
  122. package/dist/assets/src-CQwyy7m_.js +0 -18
  123. package/dist/assets/ui-components-Y3D5-fgK.js +0 -42
  124. package/dist/assets/vendor-objectstack-BjCqbVaM.js +0 -96
package/dist/index.html CHANGED
@@ -46,12 +46,12 @@
46
46
  <script>
47
47
  window.process = window.process || { env: { NODE_ENV: 'development' }, version: '', platform: 'browser' };
48
48
  </script>
49
- <script type="module" crossorigin src="./assets/index-CRgNx-tU.js"></script>
49
+ <script type="module" crossorigin src="./assets/index-sUYxMYg4.js"></script>
50
50
  <link rel="stylesheet" crossorigin href="./assets/ui-components-BL3SEdAz.css">
51
51
  <link rel="stylesheet" crossorigin href="./assets/plugin-dashboard-DnNKJB60.css">
52
- <link rel="stylesheet" crossorigin href="./assets/index-D1n9Ue1P.css">
53
- <link rel="modulepreload" href="./assets/framework-BL3BtpKU.js" />
54
- <link rel="modulepreload" href="./assets/ui-components-Y3D5-fgK.js" />
52
+ <link rel="stylesheet" crossorigin href="./assets/index-DwHOkKSZ.css">
53
+ <link rel="modulepreload" href="./assets/framework-CavAJOoG.js" />
54
+ <link rel="modulepreload" href="./assets/ui-components-CHaxvtjc.js" />
55
55
  <link rel="modulepreload" href="./assets/vendor-radix-CWCRv2pn.js" />
56
56
  <link rel="modulepreload" href="./assets/vendor-react-BKSb6vFP.js" />
57
57
  </head>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@objectstack/console",
3
- "version": "15.0.0",
3
+ "version": "15.1.1",
4
4
  "description": "Prebuilt Console SPA pinned to this @objectstack/framework release. Source of truth: @object-ui/console (https://github.com/objectstack-ai/objectui).",
5
5
  "license": "Apache-2.0",
6
6
  "homepage": "https://github.com/objectstack-ai/framework/tree/main/packages/console",
@@ -1 +0,0 @@
1
- import{o as e}from"./rolldown-runtime-DAXXjFlN.js";import{r as t,y as n}from"./vendor-react-BKSb6vFP.js";import{L as r}from"./framework-BL3BtpKU.js";import{$n as i,Ar as a,Bs as o,Ha as s,Hs as c,Qi as l,Qn as u,Wi as d,Yr as f,Zn as p,bo as m,ea as h,hs as g,ji as _,sr as v,ss as y,zs as b}from"./ui-components-Y3D5-fgK.js";import"./src-CQwyy7m_.js";var x=e(n(),1),S=[`plugin`,`plugins`,`kind`,`package`];function C(e){return[{method:`POST`,path:`${e}/sign-in/email`,desc:`Sign in (email)`,group:`Auth`,bodyTemplate:{email:`user@example.com`,password:``}},{method:`POST`,path:`${e}/sign-up/email`,desc:`Sign up (email)`,group:`Auth`,bodyTemplate:{email:``,password:``,name:``}},{method:`POST`,path:`${e}/sign-out`,desc:`Sign out`,group:`Auth`},{method:`GET`,path:`${e}/get-session`,desc:`Get session`,group:`Auth`}]}var w={ai:{group:`AI`,defaultRoute:`/api/v1/ai`,endpoints:[{method:`POST`,path:`/chat`,desc:`Chat completion`,bodyTemplate:{messages:[{role:`user`,content:``}]}},{method:`POST`,path:`/chat/stream`,desc:`Streaming chat (SSE)`,bodyTemplate:{messages:[{role:`user`,content:``}]}},{method:`POST`,path:`/complete`,desc:`Text completion`,bodyTemplate:{prompt:``}},{method:`GET`,path:`/models`,desc:`List available models`},{method:`POST`,path:`/nlq`,desc:`Natural language query`,bodyTemplate:{query:``}},{method:`POST`,path:`/suggest`,desc:`AI-powered suggestions`,bodyTemplate:{object:``,field:``,context:{}}},{method:`POST`,path:`/insights`,desc:`AI-generated insights`,bodyTemplate:{object:``,recordIds:[]}},{method:`POST`,path:`/conversations`,desc:`Create conversation`,bodyTemplate:{}},{method:`GET`,path:`/conversations`,desc:`List conversations`},{method:`POST`,path:`/conversations/:id/messages`,desc:`Add message to conversation`,bodyTemplate:{role:`user`,content:``}},{method:`DELETE`,path:`/conversations/:id`,desc:`Delete conversation`}]},workflow:{group:`Workflow`,defaultRoute:`/api/v1/workflow`,endpoints:[{method:`GET`,path:`/:object/config`,desc:`Get workflow configuration`},{method:`GET`,path:`/:object/:recordId/state`,desc:`Get workflow state`},{method:`POST`,path:`/:object/:recordId/transition`,desc:`Execute workflow transition`,bodyTemplate:{targetState:``}},{method:`POST`,path:`/:object/:recordId/approve`,desc:`Approve workflow step`,bodyTemplate:{comment:``}},{method:`POST`,path:`/:object/:recordId/reject`,desc:`Reject workflow step`,bodyTemplate:{comment:``}}]},realtime:{group:`Realtime`,defaultRoute:`/api/v1/realtime`,endpoints:[{method:`POST`,path:`/connect`,desc:`Establish realtime connection`,bodyTemplate:{transport:`websocket`}},{method:`POST`,path:`/disconnect`,desc:`Close realtime connection`,bodyTemplate:{connectionId:``}},{method:`POST`,path:`/subscribe`,desc:`Subscribe to channel`,bodyTemplate:{channel:``}},{method:`POST`,path:`/unsubscribe`,desc:`Unsubscribe from channel`,bodyTemplate:{channel:``}},{method:`PUT`,path:`/presence/:channel`,desc:`Set presence state`,bodyTemplate:{status:`online`}},{method:`GET`,path:`/presence/:channel`,desc:`Get channel presence`}]},notification:{group:`Notifications`,defaultRoute:`/api/v1/notifications`,endpoints:[{method:`GET`,path:``,desc:`List notifications`},{method:`POST`,path:`/devices`,desc:`Register device for push`,bodyTemplate:{token:``,platform:`web`}},{method:`DELETE`,path:`/devices/:deviceId`,desc:`Unregister device`},{method:`GET`,path:`/preferences`,desc:`Get notification preferences`},{method:`PATCH`,path:`/preferences`,desc:`Update notification preferences`,bodyTemplate:{email:!0,push:!0}},{method:`POST`,path:`/read`,desc:`Mark notifications as read`,bodyTemplate:{ids:[]}},{method:`POST`,path:`/read/all`,desc:`Mark all as read`}]},analytics:{group:`Analytics`,defaultRoute:`/api/v1/analytics`,endpoints:[{method:`POST`,path:`/query`,desc:`Execute analytics query`,bodyTemplate:{measures:[],dimensions:[]}},{method:`GET`,path:`/meta`,desc:`Get analytics metadata`}]},automation:{group:`Automation`,defaultRoute:`/api/v1/automation`,endpoints:[{method:`POST`,path:`/trigger`,desc:`Trigger automation`,bodyTemplate:{name:``,params:{}}}]},i18n:{group:`i18n`,defaultRoute:`/api/v1/i18n`,endpoints:[{method:`GET`,path:`/locales`,desc:`Get available locales`},{method:`GET`,path:`/translations/:locale`,desc:`Get translations for locale`},{method:`GET`,path:`/labels/:object/:locale`,desc:`Get translated field labels`}]},ui:{group:`UI`,defaultRoute:`/api/v1/ui`,endpoints:[{method:`GET`,path:`/views`,desc:`List views`},{method:`GET`,path:`/views/:id`,desc:`Get view by ID`},{method:`POST`,path:`/views`,desc:`Create view`,bodyTemplate:{name:``,object:``,type:`list`}},{method:`PATCH`,path:`/views/:id`,desc:`Update view`,bodyTemplate:{name:``}},{method:`DELETE`,path:`/views/:id`,desc:`Delete view`}]},feed:{group:`Feed`,defaultRoute:`/api/v1/feed`,endpoints:[{method:`GET`,path:`/:object/:recordId`,desc:`Get feed items`},{method:`POST`,path:`/:object/:recordId`,desc:`Post feed item`,bodyTemplate:{body:``}}]},storage:{group:`Storage`,defaultRoute:`/api/v1/storage`,endpoints:[{method:`POST`,path:`/upload`,desc:`Upload file (multipart/form-data)`},{method:`GET`,path:`/:fileId`,desc:`Download file`},{method:`DELETE`,path:`/:fileId`,desc:`Delete file`}]}};function T(e,t){let n=w[e];return n?n.endpoints.map(e=>({method:e.method,path:`${t}${e.path}`,desc:e.desc,group:n.group,...e.bodyTemplate?{bodyTemplate:e.bodyTemplate}:{}})):[]}function ee(){let e=r(),[t,n]=(0,x.useState)([]),[i,a]=(0,x.useState)([]),[o,s]=(0,x.useState)(!0),[c,l]=(0,x.useState)(null),u=(0,x.useCallback)(async()=>{s(!0),l(null);let t=`/api/v1`,r=`${t}/discovery`,i=[{method:`GET`,path:r,desc:`API Discovery`,group:`System`},{method:`GET`,path:`${t}/meta/types`,desc:`List metadata types`,group:`Metadata`},{method:`GET`,path:`${t}/packages`,desc:`List packages`,group:`System`},{method:`GET`,path:`/api/v1/health`,desc:`Health check`,group:`System`}];try{let o=`/api/v1/auth`,s={},c={};try{let e=await fetch(r);if(e.ok){let t=await e.json(),n=t?.data??t;c=n?.routes??{},s=n?.services??{},c.auth&&(o=c.auth)}}catch{}let l=[];for(let[e,t]of Object.entries(w)){let n=s[e],r=n?.enabled??!1,i=n?.handlerReady??(n?.status===`available`||n?.status===`degraded`),a=n?.route??c[e]??t.defaultRoute;r&&i&&l.push(...T(e,a))}let u=e?.getClient?.(),d=[];try{let e=await u?.meta?.getTypes?.();e&&Array.isArray(e.types)?d=e.types:Array.isArray(e)&&(d=e)}catch{}let f=[];try{let e=d.includes(`object`)?`object`:null;if(e&&u?.meta?.getItems){let t=await u.meta.getItems(e),n=[];Array.isArray(t)?n=t:t&&Array.isArray(t.items)?n=t.items:t&&Array.isArray(t.value)&&(n=t.value),f=n.map(e=>e.name||e.id).filter(Boolean)}}catch{}let p=f.flatMap(e=>{let n=e.startsWith(`sys_`)?`Data: system tables`:`Data: ${e}`;return[{method:`GET`,path:`${t}/data/${e}`,desc:`List ${e}`,group:n},{method:`POST`,path:`${t}/data/${e}`,desc:`Create ${e}`,group:n,bodyTemplate:{name:`example`}},{method:`GET`,path:`${t}/data/${e}/:id`,desc:`Get ${e} by ID`,group:n},{method:`PATCH`,path:`${t}/data/${e}/:id`,desc:`Update ${e}`,group:n,bodyTemplate:{name:`updated`}},{method:`DELETE`,path:`${t}/data/${e}/:id`,desc:`Delete ${e}`,group:n}]}),m=d.filter(e=>!S.includes(e)).map(e=>({method:`GET`,path:`${t}/meta/${e}`,desc:`List ${e} metadata`,group:`Metadata`})),h=f.map(e=>({method:`GET`,path:`${t}/meta/object/${e}`,desc:`${e} schema`,group:`Metadata`})),g=[...i,...C(o),...l,...m,...h,...p],_=new Map;for(let e of g){let t=_.get(e.group)||[];t.push(e),_.set(e.group,t)}let v=[`System`,`Auth`,`AI`,`Workflow`,`Realtime`,`Notifications`,`Analytics`,`Automation`,`i18n`,`UI`,`Feed`,`Storage`,`Metadata`],y=Array.from(_.entries()).sort(([e],[t])=>{let n=v.indexOf(e),r=v.indexOf(t);return n!==-1&&r!==-1?n-r:n===-1?r===-1?e.localeCompare(t):1:-1}).map(([e,t])=>({key:e,label:e,endpoints:t}));n(y),a(g)}catch(e){l(e.message||`Failed to discover APIs`)}finally{s(!1)}},[e]);return(0,x.useEffect)(()=>{u()},[u]),{groups:t,allEndpoints:i,loading:o,error:c,refresh:u}}var E=t(),D={GET:`text-emerald-600 bg-emerald-50 border-emerald-200 dark:text-emerald-400 dark:bg-emerald-950/50`,POST:`text-blue-600 bg-blue-50 border-blue-200 dark:text-blue-400 dark:bg-blue-950/50`,PATCH:`text-amber-600 bg-amber-50 border-amber-200 dark:text-amber-400 dark:bg-amber-950/50`,PUT:`text-amber-600 bg-amber-50 border-amber-200 dark:text-amber-400 dark:bg-amber-950/50`,DELETE:`text-red-600 bg-red-50 border-red-200 dark:text-red-400 dark:bg-red-950/50`},te={2:`text-emerald-600 dark:text-emerald-400`,3:`text-blue-600 dark:text-blue-400`,4:`text-amber-600 dark:text-amber-400`,5:`text-red-600 dark:text-red-400`},ne=[{key:`$top`,placeholder:`10`,hint:`limit`},{key:`$skip`,placeholder:`0`,hint:`offset`},{key:`$sort`,placeholder:`name`,hint:`sort field`},{key:`$select`,placeholder:`name,email`,hint:`fields`},{key:`$count`,placeholder:`true`,hint:`total count`},{key:`$filter`,placeholder:`status eq 'active'`,hint:`OData filter`}],O=1;function k(){let e=r()?.getClient?.(),{groups:t,loading:n,refresh:S}=ee(),[C,w]=(0,x.useState)(``),[T,k]=(0,x.useState)(new Set),[A,j]=(0,x.useState)(null),[re,M]=(0,x.useState)(``),[ie,N]=(0,x.useState)(``),[P,F]=(0,x.useState)(``),[I,L]=(0,x.useState)([]),[R,z]=(0,x.useState)(!1),[B,V]=(0,x.useState)(null),[H,U]=(0,x.useState)([]),[W,ae]=(0,x.useState)(null),[G,K]=(0,x.useState)(!1),q=(0,x.useMemo)(()=>{if(!C)return t;let e=C.toLowerCase();return t.map(t=>({...t,endpoints:t.endpoints.filter(t=>t.desc.toLowerCase().includes(e)||t.path.toLowerCase().includes(e)||t.method.toLowerCase().includes(e))})).filter(e=>e.endpoints.length>0)},[t,C]),oe=(0,x.useCallback)(e=>{k(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[]),se=(0,x.useCallback)(e=>{j(e),M(e.method),N(e.path),F(e.bodyTemplate?JSON.stringify(e.bodyTemplate,null,2):``),L([]),V(null)},[]),J=re||A?.method||`GET`,Y=ie||A?.path||``,X=(0,x.useMemo)(()=>{let e=I.filter(e=>e.enabled&&e.key.trim());if(e.length===0)return Y;let t=e.map(e=>`${encodeURIComponent(e.key)}=${encodeURIComponent(e.value)}`).join(`&`);return`${Y}?${t}`},[Y,I]),Z=(0,x.useCallback)((e=``,t=``)=>{L(n=>[...n,{id:O++,key:e,value:t,enabled:!0}])},[]),ce=(0,x.useCallback)(e=>{L(t=>t.filter(t=>t.id!==e))},[]),Q=(0,x.useCallback)((e,t,n)=>{L(r=>r.map(r=>r.id===e?{...r,[t]:n}:r))},[]),le=(0,x.useCallback)(e=>{L(t=>t.map(t=>t.id===e?{...t,enabled:!t.enabled}:t))},[]),$=(0,x.useCallback)(async()=>{if(R||!X)return;let t=`${e?.baseUrl??``}${X}`;z(!0);let n=performance.now();try{let e={method:J,headers:{"Content-Type":`application/json`}};[`POST`,`PATCH`,`PUT`].includes(J)&&P.trim()&&(e.body=P);let r=await fetch(t,e),i=Math.round(performance.now()-n),a;if((r.headers.get(`content-type`)??``).includes(`json`)){let e=await r.json();a=JSON.stringify(e,null,2)}else a=await r.text();let o={status:r.status,body:a,duration:i};V(o),U(e=>[{id:Date.now(),method:J,url:X,body:P||void 0,status:r.status,duration:i,response:a,timestamp:new Date},...e].slice(0,50))}catch(e){let t=Math.round(performance.now()-n);V({status:0,body:`Network Error: ${e.message}`,duration:t})}finally{z(!1)}},[e,X,J,P,R]),ue=(0,x.useCallback)(e=>{M(e.method);let[t,n]=e.url.split(`?`);if(N(t),F(e.body||``),n){let e=new URLSearchParams(n),t=[];e.forEach((e,n)=>{t.push({id:O++,key:n,value:e,enabled:!0})}),L(t)}else L([]);V(null),j(null)},[]),de=(0,x.useCallback)(()=>{B?.body&&(navigator.clipboard.writeText(B.body),K(!0),setTimeout(()=>K(!1),1500))},[B]),fe=e=>te[String(e)[0]]??`text-muted-foreground`;return(0,E.jsxs)(`div`,{className:`flex flex-1 min-h-0 overflow-hidden`,children:[(0,E.jsxs)(`div`,{className:`w-72 shrink-0 border-r flex flex-col overflow-hidden`,children:[(0,E.jsxs)(`div`,{className:`p-3 border-b space-y-2`,children:[(0,E.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,E.jsx)(`h3`,{className:`text-sm font-semibold text-foreground flex-1`,children:`API Endpoints`}),(0,E.jsx)(`button`,{onClick:S,disabled:n,className:`p-1 rounded hover:bg-muted transition-colors text-muted-foreground hover:text-foreground`,title:`Refresh endpoints`,children:(0,E.jsx)(d,{className:`h-3.5 w-3.5 ${n?`animate-spin`:``}`})})]}),(0,E.jsxs)(`div`,{className:`relative`,children:[(0,E.jsx)(_,{className:`absolute left-2.5 top-1/2 h-3.5 w-3.5 -translate-y-1/2 text-muted-foreground`}),(0,E.jsx)(`input`,{type:`text`,value:C,onChange:e=>w(e.target.value),placeholder:`Search endpoints...`,className:`w-full rounded-md border bg-background pl-8 pr-3 py-1.5 text-sm focus:outline-none focus:ring-1 focus:ring-ring`})]})]}),(0,E.jsx)(`div`,{className:`flex-1 overflow-auto p-2 space-y-1`,children:n?(0,E.jsxs)(`div`,{className:`flex items-center justify-center py-8 text-muted-foreground text-sm`,children:[(0,E.jsx)(s,{className:`h-4 w-4 animate-spin mr-2`}),`Discovering APIs...`]}):q.length===0?(0,E.jsxs)(`div`,{className:`flex flex-col items-center justify-center py-8 text-muted-foreground text-sm`,children:[(0,E.jsx)(m,{className:`h-6 w-6 opacity-30 mb-2`}),(0,E.jsx)(`span`,{children:C?`No matching endpoints`:`No endpoints found`})]}):q.map(e=>{let t=T.has(e.key)||!!C;return(0,E.jsxs)(p,{open:t,onOpenChange:()=>oe(e.key),children:[(0,E.jsx)(i,{asChild:!0,children:(0,E.jsxs)(`button`,{className:`w-full flex items-center gap-1.5 px-2 py-1.5 rounded-md text-xs font-medium text-muted-foreground hover:bg-muted/50 hover:text-foreground transition-colors`,children:[(0,E.jsx)(b,{className:`h-3 w-3 shrink-0 transition-transform duration-200 ${t?`rotate-90`:``}`}),(0,E.jsx)(`span`,{className:`flex-1 text-left truncate`,children:e.label}),(0,E.jsx)(`span`,{className:`shrink-0 text-[10px] tabular-nums opacity-60`,children:e.endpoints.length})]})}),(0,E.jsx)(u,{children:(0,E.jsx)(`div`,{className:`ml-3 space-y-0.5 mt-0.5`,children:e.endpoints.map((e,t)=>(0,E.jsxs)(`button`,{onClick:()=>se(e),className:`w-full text-left flex items-center gap-1.5 px-2 py-1 rounded text-xs transition-colors ${A===e?`bg-accent text-accent-foreground`:`hover:bg-muted/50 text-muted-foreground hover:text-foreground`}`,children:[(0,E.jsx)(v,{variant:`outline`,className:`font-mono text-[9px] shrink-0 px-1 py-0 ${D[e.method]||``}`,children:e.method}),(0,E.jsx)(`span`,{className:`truncate`,children:e.desc})]},`${e.method}-${e.path}-${t}`))})})]},e.key)})}),(0,E.jsxs)(`div`,{className:`p-3 border-t space-y-2`,children:[(0,E.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,E.jsx)(`h4`,{className:`text-[10px] font-medium text-muted-foreground uppercase tracking-wider`,children:`Query Parameters`}),(0,E.jsxs)(`button`,{onClick:()=>Z(),className:`inline-flex items-center gap-0.5 text-[10px] text-muted-foreground hover:text-foreground transition-colors`,children:[(0,E.jsx)(l,{className:`h-3 w-3`}),`Add`]})]}),(0,E.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:ne.map(e=>(0,E.jsx)(`button`,{onClick:()=>Z(e.key,``),className:`text-[10px] px-1.5 py-0.5 rounded border bg-muted/30 text-muted-foreground hover:text-foreground hover:bg-muted/60 transition-colors font-mono`,title:e.hint,children:e.key},e.key))}),I.length>0&&(0,E.jsx)(`div`,{className:`space-y-1`,children:I.map(e=>(0,E.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,E.jsx)(`input`,{type:`checkbox`,checked:e.enabled,onChange:()=>le(e.id),className:`h-3 w-3 shrink-0 rounded border accent-primary`}),(0,E.jsx)(`input`,{type:`text`,value:e.key,onChange:t=>Q(e.id,`key`,t.target.value),placeholder:`key`,className:`flex-1 min-w-0 rounded border bg-background px-1.5 py-0.5 text-[10px] font-mono focus:outline-none focus:ring-1 focus:ring-ring`}),(0,E.jsx)(`input`,{type:`text`,value:e.value,onChange:t=>Q(e.id,`value`,t.target.value),placeholder:`value`,className:`flex-1 min-w-0 rounded border bg-background px-1.5 py-0.5 text-[10px] font-mono focus:outline-none focus:ring-1 focus:ring-ring`}),(0,E.jsx)(`button`,{onClick:()=>ce(e.id),className:`shrink-0 p-0.5 rounded text-muted-foreground hover:text-destructive transition-colors`,children:(0,E.jsx)(a,{className:`h-3 w-3`})})]},e.id))})]})]}),(0,E.jsxs)(`div`,{className:`flex-1 flex flex-col min-w-0 overflow-hidden`,children:[(0,E.jsxs)(`div`,{className:`p-3 border-b space-y-1`,children:[(0,E.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,E.jsx)(`select`,{value:J,onChange:e=>M(e.target.value),className:`rounded-md border bg-background px-2 py-1.5 font-mono text-xs font-semibold focus:outline-none focus:ring-1 focus:ring-ring ${D[J]||``}`,children:[`GET`,`POST`,`PATCH`,`PUT`,`DELETE`].map(e=>(0,E.jsx)(`option`,{value:e,children:e},e))}),(0,E.jsx)(`input`,{type:`text`,value:Y,onChange:e=>N(e.target.value),className:`flex-1 rounded-md border bg-background px-3 py-1.5 font-mono text-sm focus:outline-none focus:ring-1 focus:ring-ring`,placeholder:`/api/v1/...`,onKeyDown:e=>{e.key===`Enter`&&$()}}),(0,E.jsxs)(`button`,{onClick:$,disabled:R||!X,className:`inline-flex items-center gap-1.5 rounded-md bg-primary px-4 py-1.5 text-sm font-medium text-primary-foreground hover:bg-primary/90 disabled:opacity-50 transition-colors`,children:[R?(0,E.jsx)(s,{className:`h-3.5 w-3.5 animate-spin`}):(0,E.jsx)(h,{className:`h-3.5 w-3.5`}),`Send`]})]}),I.some(e=>e.enabled&&e.key.trim())&&(0,E.jsxs)(`div`,{className:`text-[10px] font-mono text-muted-foreground truncate pl-1`,children:[`→ `,X]})]}),(0,E.jsxs)(`div`,{className:`flex-1 flex flex-col min-h-0 overflow-auto`,children:[[`POST`,`PATCH`,`PUT`].includes(J)&&(0,E.jsxs)(`div`,{className:`p-3 border-b space-y-1`,children:[(0,E.jsx)(`label`,{className:`text-xs font-medium text-muted-foreground`,children:`Request Body (JSON)`}),(0,E.jsx)(`textarea`,{value:P,onChange:e=>F(e.target.value),rows:5,className:`w-full rounded-md border bg-background px-3 py-2 font-mono text-xs focus:outline-none focus:ring-1 focus:ring-ring resize-y`,placeholder:`{ "key": "value" }`})]}),R&&(0,E.jsxs)(`div`,{className:`flex items-center justify-center py-8 text-muted-foreground text-sm`,children:[(0,E.jsx)(s,{className:`h-4 w-4 animate-spin mr-2`}),`Sending request...`]}),B&&!R&&(0,E.jsxs)(`div`,{className:`flex-1 min-h-0 flex flex-col overflow-hidden`,children:[(0,E.jsxs)(`div`,{className:`flex items-center justify-between px-3 py-2 bg-muted/30 border-b`,children:[(0,E.jsxs)(`div`,{className:`flex items-center gap-3 text-sm`,children:[(0,E.jsx)(`span`,{className:`font-mono font-semibold ${fe(B.status)}`,children:B.status||`ERR`}),(0,E.jsxs)(`span`,{className:`text-muted-foreground flex items-center gap-1`,children:[(0,E.jsx)(g,{className:`h-3 w-3`}),B.duration,`ms`]})]}),(0,E.jsxs)(`button`,{onClick:de,className:`inline-flex items-center gap-1 text-xs text-muted-foreground hover:text-foreground transition-colors`,children:[G?(0,E.jsx)(c,{className:`h-3 w-3`}):(0,E.jsx)(y,{className:`h-3 w-3`}),G?`Copied`:`Copy`]})]}),(0,E.jsx)(`pre`,{className:`flex-1 overflow-auto p-3 text-xs font-mono bg-muted/10 whitespace-pre-wrap break-all`,children:B.body})]}),!B&&!R&&(0,E.jsx)(`div`,{className:`flex-1 flex items-center justify-center text-muted-foreground text-sm`,children:(0,E.jsxs)(`div`,{className:`text-center space-y-2`,children:[(0,E.jsx)(m,{className:`h-10 w-10 mx-auto opacity-20`}),(0,E.jsxs)(`p`,{children:[`Select an endpoint or type a URL and click `,(0,E.jsx)(`strong`,{children:`Send`})]}),(0,E.jsx)(`p`,{className:`text-xs opacity-60`,children:`All registered APIs are auto-discovered from the platform`})]})}),H.length>0&&(0,E.jsxs)(`div`,{className:`border-t`,children:[(0,E.jsxs)(`div`,{className:`flex items-center justify-between px-3 py-2`,children:[(0,E.jsxs)(`h4`,{className:`text-xs font-medium text-muted-foreground uppercase tracking-wider`,children:[`History (`,H.length,`)`]}),(0,E.jsxs)(`button`,{onClick:()=>U([]),className:`inline-flex items-center gap-1 text-[10px] text-muted-foreground hover:text-foreground transition-colors`,children:[(0,E.jsx)(f,{className:`h-3 w-3`}),`Clear`]})]}),(0,E.jsx)(`div`,{className:`space-y-0.5 px-2 pb-2 max-h-60 overflow-auto`,children:H.map(e=>(0,E.jsxs)(`div`,{className:`rounded border`,children:[(0,E.jsxs)(`button`,{onClick:()=>ae(W===e.id?null:e.id),className:`w-full flex items-center gap-2 px-2 py-1.5 text-xs hover:bg-muted/30 transition-colors`,children:[W===e.id?(0,E.jsx)(o,{className:`h-3 w-3 shrink-0`}):(0,E.jsx)(b,{className:`h-3 w-3 shrink-0`}),(0,E.jsx)(v,{variant:`outline`,className:`font-mono text-[9px] shrink-0 ${D[e.method]||``}`,children:e.method}),(0,E.jsx)(`span`,{className:`font-mono truncate text-left flex-1`,children:e.url}),(0,E.jsx)(`span`,{className:`ml-auto shrink-0 font-mono ${fe(e.status)}`,children:e.status}),(0,E.jsxs)(`span`,{className:`shrink-0 text-muted-foreground`,children:[e.duration,`ms`]}),(0,E.jsx)(`button`,{onClick:t=>{t.stopPropagation(),ue(e)},className:`shrink-0 p-0.5 rounded hover:bg-muted text-muted-foreground hover:text-foreground transition-colors`,title:`Replay request`,children:(0,E.jsx)(h,{className:`h-2.5 w-2.5`})})]}),W===e.id&&(0,E.jsx)(`pre`,{className:`px-3 py-2 text-xs font-mono bg-muted/10 border-t overflow-auto max-h-40 whitespace-pre-wrap break-all`,children:e.response})]},e.id))})]})]})]})]})}export{k as ApiConsolePage};
@@ -1 +0,0 @@
1
- import{o as e}from"./rolldown-runtime-DAXXjFlN.js";import{a as t,m as n,r,y as i}from"./vendor-react-BKSb6vFP.js";import{f as a,p as ee}from"./infrastructure-Bc4DRENl.js";import{l as te}from"./framework-BL3BtpKU.js";import{Ai as ne,Ar as re,As as ie,Bt as o,Cr as s,Gt as ae,Hs as oe,Ht as se,Jt as ce,K as le,Kt as ue,Ns as de,Oc as c,Qt as fe,Sr as pe,Ts as me,Ut as he,Vs as ge,Wi as _e,Wr as ve,Wt as ye,X as be,Xt as l,Yo as xe,Yt as Se,Zt as Ce,_r as u,_t as d,as as we,br as f,dr as Te,dt as Ee,er as De,fc as Oe,fr as ke,ft as Ae,gr as p,gt as m,hi as je,hr as h,hs as Me,ht as Ne,ji as Pe,ln as Fe,lt as Ie,mr as g,mt as Le,nr as Re,pn as ze,pt as Be,q as Ve,qt as He,sr as Ue,ss as We,tr as Ge,ut as Ke,vr as _,vt as qe,xc as Je,xr as v,xs as Ye,yr as y,yt as Xe,zr as Ze,zs as Qe}from"./ui-components-Y3D5-fgK.js";import{r as b}from"./vendor-ui-utils-D-WJ115h.js";var x=e(i(),1),$e=`${``.replace(/\/$/,``)}/api/v1`;async function S(e,t){let n=await fetch(`${$e}${e}`,{credentials:`include`,headers:{"Content-Type":`application/json`,...t?.headers||{}},...t}),r=null;try{r=await n.json()}catch{}if(!n.ok){let e=r?.code??`HTTP_${n.status}`,t=r?.message??r?.error??n.statusText,i=Error(`${e}: ${t}`);throw i.code=e,i.status=n.status,i.details=r,i}return r}var C={listProcesses(e={}){let t=new URLSearchParams;e.object&&t.set(`object`,e.object),e.activeOnly&&t.set(`activeOnly`,`true`);let n=t.toString();return S(`/approvals/processes${n?`?${n}`:``}`)},listRequests(e={}){let t=new URLSearchParams;e.status&&t.set(`status`,e.status),e.object&&t.set(`object`,e.object),e.recordId&&t.set(`recordId`,e.recordId);let n=Array.isArray(e.approverId)?e.approverId.filter(Boolean).join(`,`):e.approverId;n&&t.set(`approverId`,n),e.submitterId&&t.set(`submitterId`,e.submitterId),e.q?.trim()&&t.set(`q`,e.q.trim()),e.limit!=null&&t.set(`limit`,String(e.limit)),e.offset!=null&&t.set(`offset`,String(e.offset));let r=t.toString();return S(`/approvals/requests${r?`?${r}`:``}`)},async getRequest(e){return{data:await S(`/approvals/requests/${encodeURIComponent(e)}`)}},listActions(e){return S(`/approvals/requests/${encodeURIComponent(e)}/actions`)},async approve(e,t){let n=await S(`/approvals/requests/${encodeURIComponent(e)}/approve`,{method:`POST`,body:JSON.stringify(t)});return{data:n.request,finalized:n.finalized}},async reject(e,t){let n=await S(`/approvals/requests/${encodeURIComponent(e)}/reject`,{method:`POST`,body:JSON.stringify(t)});return{data:n.request,finalized:n.finalized}},async recall(e,t){return{data:(await S(`/approvals/requests/${encodeURIComponent(e)}/recall`,{method:`POST`,body:JSON.stringify(t)})).request,finalized:!0}},async reassign(e,t){return{data:(await S(`/approvals/requests/${encodeURIComponent(e)}/reassign`,{method:`POST`,body:JSON.stringify(t)})).request}},async remind(e,t={}){let n=await S(`/approvals/requests/${encodeURIComponent(e)}/remind`,{method:`POST`,body:JSON.stringify(t)});return{data:n.request,notified:n.notified}},async requestInfo(e,t){return{data:(await S(`/approvals/requests/${encodeURIComponent(e)}/request-info`,{method:`POST`,body:JSON.stringify(t)})).request}},async sendBack(e,t){let n=await S(`/approvals/requests/${encodeURIComponent(e)}/revise`,{method:`POST`,body:JSON.stringify(t)});return{data:n.request,autoRejected:n.autoRejected===!0}},async resubmit(e,t={}){let n=await S(`/approvals/requests/${encodeURIComponent(e)}/resubmit`,{method:`POST`,body:JSON.stringify(t)});return{data:n.request,resumed:n.resumed===!0}},async comment(e,t){return{data:(await S(`/approvals/requests/${encodeURIComponent(e)}/comment`,{method:`POST`,body:JSON.stringify(t)})).request}},async submit(e){return S(`/approvals/requests`,{method:`POST`,body:JSON.stringify(e)})}};function et(e){if(!e)return[];let t=new Set;e.id&&t.add(e.id),e.email&&t.add(e.email);let n=[...e.roles||[],...typeof e.role==`string`?e.role.split(`,`):[]];for(let e of n){let n=String(e).trim();n&&t.add(`role:${n}`)}return Array.from(t)}var w=r(),tt=50,nt={pending:`border-amber-200 bg-amber-50 text-amber-700 dark:border-amber-500/30 dark:bg-amber-500/10 dark:text-amber-400`,approved:`border-emerald-200 bg-emerald-50 text-emerald-700 dark:border-emerald-500/30 dark:bg-emerald-500/10 dark:text-emerald-400`,rejected:`border-red-200 bg-red-50 text-red-700 dark:border-red-500/30 dark:bg-red-500/10 dark:text-red-400`,recalled:`border-border bg-muted text-muted-foreground`,returned:`border-violet-200 bg-violet-50 text-violet-700 dark:border-violet-500/30 dark:bg-violet-500/10 dark:text-violet-400`};function rt(e){if(!e)return`—`;try{return new Date(e).toLocaleString()}catch{return e}}function T(e){return e?e.includes(`@`)?e:e.startsWith(`role:`)?`Role: ${e.slice(5)}`:e.length>14?`${e.slice(0,6)}…${e.slice(-4)}`:e:`—`}function E(e){return e&&String(e).replace(/^flow:/,``).trim().split(/[_\-\s]+/).filter(Boolean).map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(` `)||`—`}function it(e){return e.process_label||E(e.process_name)}function at(e){return e.step_label?e.step_label:e.current_step?E(e.current_step):null}function ot(e){return e.submitter_name||T(e.submitter_id)}function st(e,t){return t.pending_approver_names?.[e]||T(e)}function ct(e){return e.object_label||e.object_name}function D(e){return e.submitted_at||e.created_at||void 0}function O(e){let t=D(e);if(!t)return null;let n=Date.parse(t);return Number.isNaN(n)?null:(Date.now()-n)/36e5}function lt(e){if(e.status!==`pending`)return`text-muted-foreground`;let t=O(e);return t==null?`text-muted-foreground`:t>72?`text-red-600 dark:text-red-400 font-medium`:t>24?`text-amber-600 dark:text-amber-400`:`text-muted-foreground`}function ut(e){let t=Math.max(1,Math.round(Math.abs(e)/36e5));return t<48?`${t}h`:`${Math.round(t/24)}d`}var k=new Set([`id`,`created_at`,`updated_at`,`created_by`,`updated_by`,`organization_id`]);function A(e){return e.split(`_`).filter(Boolean).map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(` `)}function j(e,t){if(typeof t==`boolean`)return t?`✓`:`—`;if(typeof t==`number`){if(t>0xe8d4a51000&&/(_at$|_date$|^date_|_time$)/.test(e))try{return new Date(t).toLocaleDateString()}catch{}return t.toLocaleString()}let n=String(t);if(/^\d{4}-\d{2}-\d{2}T\d{2}/.test(n))try{return new Date(n).toLocaleString()}catch{}return n}var dt=/^[A-Za-z0-9_-]{15,}$/;function ft(e,t,n=6){if(!e||typeof e!=`object`||Array.isArray(e))return[];let r=[];for(let[i,a]of Object.entries(e)){if(k.has(i)||a==null||typeof a==`object`||String(a).trim()===``)continue;let e=t?.[i];if(!(!e&&typeof a==`string`&&dt.test(a.trim())&&!/^\d+$/.test(a.trim()))&&(r.push([A(i),e??j(i,a)]),r.length>=n))break}return r}function pt(){let{t:e,language:r}=te(),{user:i}=ee(),$e=a(),{appName:S}=n(),E=(0,x.useMemo)(()=>et(i),[i]),O=(0,x.useCallback)((t,n,r)=>String(e(`approvalsInbox.${t}`,{defaultValue:n,...r})),[e]),k=(0,x.useCallback)(e=>{if(!e)return`—`;let t=Date.parse(e);if(Number.isNaN(t))return e;let n=Math.round((Date.now()-t)/1e3);if(n<45)return O(`justNow`,`just now`);let i=Math.round(n/60);if(i<60)return O(`minutesAgo`,`{{count}}m ago`,{count:i});let a=Math.round(i/60);if(a<24)return O(`hoursAgo`,`{{count}}h ago`,{count:a});let ee=Math.round(a/24);if(ee<30)return O(`daysAgo`,`{{count}}d ago`,{count:ee});try{return new Date(e).toLocaleDateString(r)}catch{return e}},[O,r]),A=(0,x.useCallback)(e=>{switch(e){case`pending`:return O(`statusPending`,`Pending`);case`approved`:return O(`statusApproved`,`Approved`);case`rejected`:return O(`statusRejected`,`Rejected`);case`recalled`:return O(`statusRecalled`,`Recalled`);case`returned`:return O(`statusReturned`,`Returned for revision`);default:return e}},[O]),j=(0,x.useCallback)((e,t)=>{let n=e?.code??``,r=e?.status??0;return n===`NOT_IMPLEMENTED`||r===501?O(`recallUnavailable`,`Recall is not available on this deployment.`):n===`THROTTLED`||r===429?O(`remindThrottled`,`A reminder was sent recently — try again later.`):r===404?O(`requestGone`,`This request no longer exists. Refresh the list.`):n===`FORBIDDEN`||r===403?O(`notAllowed`,`You are not allowed to perform this action.`):n===`INVALID_STATE`||r===409?O(`alreadyDecided`,`This request was already decided. Refresh the list.`):e?.message||t},[O]);function dt({status:e}){return(0,w.jsx)(Ue,{variant:`outline`,className:c(`font-medium`,nt[e]??``),children:A(e)})}let pt=(0,x.useCallback)(e=>`/apps/${S||`setup`}/${encodeURIComponent(e.object_name)}/record/${encodeURIComponent(e.record_id)}`,[S]),[M,mt]=(0,x.useState)(`pending`),[N,ht]=(0,x.useState)([]),[gt,_t]=(0,x.useState)(!1),[vt,yt]=(0,x.useState)(!1),[bt,xt]=(0,x.useState)(null),[St,Ct]=(0,x.useState)(null),[wt,Tt]=(0,x.useState)(0),[P,Et]=(0,x.useState)(null),[F,Dt]=(0,x.useState)(null),[Ot,kt]=(0,x.useState)([]),[At,jt]=(0,x.useState)(!1),[I,L]=(0,x.useState)(``),[R,Mt]=(0,x.useState)(``),[z,Nt]=(0,x.useState)(null),[B,Pt]=(0,x.useState)(``),[Ft,It]=(0,x.useState)(``),[Lt,Rt]=(0,x.useState)(`all`),[zt,Bt]=(0,x.useState)(`all`),[V,Vt]=(0,x.useState)(`all`),[H,Ht]=(0,x.useState)(new Set),[Ut,Wt]=(0,x.useState)(!1),[U,Gt]=(0,x.useState)(null),[Kt,qt]=(0,x.useState)(null),[Jt,Yt]=(0,x.useState)(!1),[Xt,Zt]=(0,x.useState)(``),[Qt,$t]=(0,x.useState)(!1),[en,tn]=(0,x.useState)(``),[nn,rn]=(0,x.useState)(!1),[an,on]=(0,x.useState)(``),[sn,cn]=(0,x.useState)(!1),[ln,un]=(0,x.useState)(``),[W,G]=(0,x.useState)(!1),[dn,fn]=(0,x.useState)([]),[pn,mn]=(0,x.useState)(-1);(0,x.useEffect)(()=>{if(M===`pending`)return;let e=window.setTimeout(()=>It(B),350);return()=>window.clearTimeout(e)},[B,M]);let K=(0,x.useCallback)(async()=>{_t(!0),Ct(null);try{let e=[];if(M===`pending`)e=E.length?(await C.listRequests({status:`pending`,approverId:E})).data:[],Tt(e.length),xt(null);else{let t={q:Ft||void 0,status:V===`all`?void 0:V,limit:tt,offset:0};if(M===`submitted`){let n=i?.id;if(n){let r=await C.listRequests({submitterId:n,...t});e=r.data,xt(r.total??r.data.length)}else e=[],xt(0)}else{let n=await C.listRequests(t);e=n.data,xt(n.total??n.data.length)}E.length&&C.listRequests({status:`pending`,approverId:E}).then(e=>Tt(e.data.length)).catch(()=>{})}e.sort((e,t)=>(D(t)||``).localeCompare(D(e)||``)),ht(e)}catch(e){Ct(e?.message||String(e)),ht([])}finally{_t(!1)}},[M,E,i?.id,Ft,V]);(0,x.useEffect)(()=>{K()},[K]);let hn=(0,x.useCallback)(async()=>{if(!(M===`pending`||vt)){yt(!0);try{let e=await C.listRequests({submitterId:M===`submitted`?i?.id??void 0:void 0,q:Ft||void 0,status:V===`all`?void 0:V,limit:tt,offset:N.length});ht(t=>{let n=new Set(t.map(e=>e.id));return[...t,...e.data.filter(e=>!n.has(e.id))]}),e.total!=null&&xt(e.total)}catch(e){b.error(j(e,O(`loadFailed`,`Failed to load request`)))}finally{yt(!1)}}},[M,vt,i?.id,Ft,V,N.length,j,O]),q=(0,x.useCallback)(async e=>{Et(e),jt(!0),L(``),Mt(``);try{let[t,n]=await Promise.all([C.getRequest(e),C.listActions(e)]);Dt(t.data),kt(n.data)}catch(e){b.error(j(e,O(`loadFailed`,`Failed to load request`))),Dt(null),kt([])}finally{jt(!1)}},[j,O]),gn=()=>{Et(null),Dt(null),kt([]),L(``),Mt(``)},J=(0,x.useCallback)(e=>{if(R.trim())return R.trim();if(!e)return i?.id||``;let t=new Set(e.pending_approvers||[]);for(let e of E)if(t.has(e))return e;return i?.id||``},[R,E,i?.id]),Y=(0,x.useCallback)(()=>{E.length&&C.listRequests({status:`pending`,approverId:E}).then(e=>Tt(e.data.length)).catch(()=>{})},[E]),_n=(0,x.useCallback)(async e=>{if(!F)return;let t=e===`recall`&&i?.id||J(F);if(!t){b.error(O(`noActor`,`Cannot determine the acting identity`));return}Nt(e);try{let n={actor_id:t,comment:I.trim()||void 0},r=await(e===`approve`?C.approve:e===`reject`?C.reject:C.recall)(F.id,n);if(b.success(e===`approve`?r.finalized?O(`approvedFinal`,`Approved`):O(`approvedWaiting`,`Approved — waiting on the remaining approvers`):e===`reject`?O(`rejectedToast`,`Rejected`):O(`recalledToast`,`Request recalled`)),L(``),e!==`recall`&&M===`pending`){let e=Rn.current,t=e.findIndex(e=>e.id===F.id),n=e[t+1]??e[t-1];K(),n&&n.id!==F.id?q(n.id):gn();return}let[i,a]=await Promise.all([C.getRequest(F.id),C.listActions(F.id)]);Dt(i.data),kt(a.data),K()}catch(e){b.error(j(e,O(`actionFailed`,`Action failed`)))}finally{Nt(null)}},[F,J,I,K,i?.id,j,O,M,q]),X=(0,x.useCallback)(async e=>{let[t,n]=await Promise.all([C.getRequest(e),C.listActions(e)]);Dt(t.data),kt(n.data),K()},[K]),vn=(0,x.useCallback)(async()=>{if(!(!F||!Xt.trim())){G(!0);try{await C.reassign(F.id,{actor_id:J(F),to:Xt.trim(),comment:I.trim()||void 0}),b.success(O(`reassignSuccess`,`Handed to {{to}}`,{to:Xt.trim()})),Yt(!1),Zt(``),L(``),await X(F.id),Y()}catch(e){b.error(j(e,O(`actionFailed`,`Action failed`)))}finally{G(!1)}}},[F,Xt,I,J,X,Y,j,O]),yn=(0,x.useCallback)(async()=>{if(F){G(!0);try{let e=await C.remind(F.id,{actor_id:i?.id});b.success(O(`remindSuccess`,`Reminder sent to {{count}} approver(s)`,{count:e.notified})),await X(F.id)}catch(e){b.error(j(e,O(`actionFailed`,`Action failed`)))}finally{G(!1)}}},[F,i?.id,X,j,O]),bn=(0,x.useCallback)(async()=>{if(!(!F||!en.trim())){G(!0);try{await C.requestInfo(F.id,{actor_id:J(F),comment:en.trim()}),b.success(O(`requestInfoSent`,`Sent back to the requester for more information`)),$t(!1),tn(``),await X(F.id)}catch(e){b.error(j(e,O(`actionFailed`,`Action failed`)))}finally{G(!1)}}},[F,en,J,X,j,O]),xn=(0,x.useCallback)(async()=>{if(F){G(!0);try{let e=await C.sendBack(F.id,{actor_id:J(F),comment:an.trim()||void 0});b.success(e.autoRejected?O(`sendBackAutoRejected`,`Revision limit reached — the request was auto-rejected`):O(`sendBackSuccess`,`Sent back for revision — the requester can now edit and resubmit`)),rn(!1),on(``),await X(F.id),Y()}catch(e){b.error(j(e,O(`actionFailed`,`Action failed`)))}finally{G(!1)}}},[F,an,J,X,Y,j,O]),Sn=(0,x.useCallback)(async()=>{if(F){cn(!0);try{await C.resubmit(F.id,{actor_id:i?.id,comment:I.trim()||void 0}),b.success(O(`resubmitSuccess`,`Resubmitted — a new approval round has opened`)),L(``),await X(F.id),Y()}catch(e){b.error(j(e,O(`actionFailed`,`Action failed`)))}finally{cn(!1)}}},[F,I,i?.id,X,Y,j,O]),Cn=(0,x.useCallback)(async()=>{if(!(!F||!ln.trim())){G(!0);try{await C.comment(F.id,{actor_id:i?.id,comment:ln.trim()}),un(``),await X(F.id)}catch(e){b.error(j(e,O(`actionFailed`,`Action failed`)))}finally{G(!1)}}},[F,ln,i?.id,X,j,O]),wn=(0,x.useCallback)(async()=>{if(!dn.length)try{let e=``.replace(/\/$/,``),t=await(await fetch(`${e}/api/v1/data/sys_user?limit=100`,{credentials:`include`})).json();fn((t.records||[]).filter(e=>e.email&&e.name&&e.id!==i?.id).map(e=>({name:String(e.name),email:String(e.email)})))}catch{}},[dn.length,i?.id]),Tn=(0,x.useMemo)(()=>{if(!F||F.status!==`pending`)return!1;let e=new Set(F.pending_approvers||[]);return E.some(t=>e.has(t))||R.trim().length>0},[F,E,R]),En=(0,x.useMemo)(()=>!F||F.status!==`pending`?!1:F.submitter_id===i?.id||R.trim().length>0,[F,i?.id,R]),Dn=(0,x.useMemo)(()=>!F||F.status!==`returned`?!1:F.submitter_id===i?.id||R.trim().length>0,[F,i?.id,R]),On=(0,x.useMemo)(()=>{let e=new Set;for(let t of N)e.add(it(t));return Array.from(e).sort()},[N]),kn=(0,x.useMemo)(()=>{let e=new Set;for(let t of N)t.object_name&&e.add(t.object_name);return Array.from(e).sort()},[N]),Z=(0,x.useMemo)(()=>{let e=B.trim().toLowerCase();return N.filter(t=>Lt!==`all`&&it(t)!==Lt||zt!==`all`&&t.object_name!==zt||V!==`all`&&t.status!==V?!1:M!==`pending`||!e||[t.process_name,t.process_label,t.step_label,t.object_name,t.record_id,t.record_title,t.submitter_id,t.submitter_name,...t.pending_approvers||[]].filter(Boolean).join(` `).toLowerCase().includes(e))},[N,B,Lt,zt,V,M]),An=(0,x.useMemo)(()=>P?Z.findIndex(e=>e.id===P):-1,[Z,P]);(0,x.useEffect)(()=>{if(H.size===0)return;let e=new Set(Z.map(e=>e.id)),t=!1,n=new Set;for(let r of H)e.has(r)?n.add(r):t=!0;t&&Ht(n)},[Z,H]),(0,x.useEffect)(()=>{pn>=Z.length&&mn(Z.length-1)},[Z.length,pn]);let Q=(0,x.useCallback)(e=>{if(e.status!==`pending`)return!1;let t=new Set(E);return(e.pending_approvers||[]).some(e=>t.has(e))},[E]),$=(0,x.useMemo)(()=>Z.filter(e=>H.has(e.id)&&Q(e)),[Z,H,Q]),jn=Z.filter(e=>e.status===`pending`),Mn=jn.length>0&&jn.every(e=>H.has(e.id)),Nn=(0,x.useCallback)(()=>{Ht(e=>{if(Mn)return new Set;let t=new Set(e);for(let e of jn)t.add(e.id);return t})},[Mn,jn]),Pn=(0,x.useCallback)(e=>{Ht(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[]),Fn=(0,x.useCallback)(async e=>{let t=$;if(t.length===0)return;Wt(!0);let n=0,r=[];for(let a of t){let t=new Set(a.pending_approvers||[]),ee=E.find(e=>t.has(e))||i?.id||``;try{await(e===`approve`?C.approve:C.reject)(a.id,{actor_id:ee}),n++}catch{r.push(a.record_title||T(a.record_id))}}if(Wt(!1),Ht(new Set),r.length===0)b.success(e===`approve`?O(`bulkApproved`,`Approved {{count}} requests`,{count:n}):O(`bulkRejected`,`Rejected {{count}} requests`,{count:n}));else{let e=r.slice(0,3).join(`, `);b.error(O(`bulkPartial`,`{{ok}} succeeded, {{fail}} failed: {{which}}`,{ok:n,fail:r.length,which:e+(r.length>3?`…`:``)}))}K(),Y()},[$,E,i?.id,K,Y,O]),In=(0,x.useCallback)(async e=>{if(!Q(e)||Kt)return;let t=new Set(e.pending_approvers||[]),n=E.find(e=>t.has(e))||i?.id||``;qt(e.id);try{let t=await C.approve(e.id,{actor_id:n});b.success(t.finalized?O(`inlineApproved`,`Approved "{{title}}"`,{title:e.record_title||T(e.record_id)}):O(`approvedWaiting`,`Approved — waiting on the remaining approvers`)),K(),Y()}catch(e){b.error(j(e,O(`actionFailed`,`Action failed`)))}finally{qt(null)}},[Q,Kt,E,i?.id,K,Y,j,O]),Ln=(0,x.useCallback)(async()=>{let e=U;if(!e)return;let t=new Set(e.pending_approvers||[]),n=E.find(e=>t.has(e))||i?.id||``;qt(e.id),Gt(null);try{await C.reject(e.id,{actor_id:n}),b.success(O(`inlineRejected`,`Rejected "{{title}}"`,{title:e.record_title||T(e.record_id)})),K(),Y()}catch(e){b.error(j(e,O(`actionFailed`,`Action failed`)))}finally{qt(null)}},[U,E,i?.id,K,Y,j,O]),Rn=(0,x.useRef)(Z);Rn.current=Z;let zn=(0,x.useRef)(pn);zn.current=pn,(0,x.useEffect)(()=>{let e=e=>{if(P||U)return;let t=e.target,n=t?.tagName;if(n===`INPUT`||n===`TEXTAREA`||n===`SELECT`||t?.isContentEditable||document.querySelector(`[role="alertdialog"]`))return;let r=Rn.current;if(!r.length)return;let i=zn.current;e.key===`j`||e.key===`ArrowDown`?(e.preventDefault(),mn(Math.min(i+1,r.length-1))):e.key===`k`||e.key===`ArrowUp`?(e.preventDefault(),mn(Math.max(i-1,0))):e.key===`Enter`&&i>=0&&r[i]?(e.preventDefault(),q(r[i].id)):(e.key===`x`||e.key===` `)&&i>=0&&r[i]&&M===`pending`?(e.preventDefault(),Pn(r[i].id)):e.key===`a`&&i>=0&&r[i]?(e.preventDefault(),In(r[i])):e.key===`r`&&i>=0&&r[i]&&Q(r[i])&&(e.preventDefault(),Gt(r[i]))};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[P,U,M,q,Pn,In,Q]),(0,x.useEffect)(()=>{if(!P)return;let e=e=>{if(e.key!==`ArrowLeft`&&e.key!==`ArrowRight`)return;let t=e.target,n=t?.tagName;if(n===`INPUT`||n===`TEXTAREA`||n===`SELECT`||t?.isContentEditable||document.querySelector(`[role="alertdialog"]`))return;let r=Rn.current,i=r.findIndex(e=>e.id===P);if(i<0)return;let a=e.key===`ArrowLeft`?r[i-1]:r[i+1];a&&(e.preventDefault(),q(a.id))};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[P,q]);let Bn=!!B||Lt!==`all`||zt!==`all`||V!==`all`,Vn=e=>{mt(e),Vt(`all`),Rt(`all`),Bt(`all`),Pt(``),mn(-1)};function Hn({r:e}){return(0,w.jsxs)(`div`,{className:`min-w-0`,children:[(0,w.jsx)(`div`,{className:`font-medium truncate`,children:it(e)}),(0,w.jsxs)(`div`,{className:`text-xs text-muted-foreground truncate`,children:[at(e)||`—`,(e.round??1)>1&&(0,w.jsx)(`span`,{className:`ml-1.5 text-violet-600 dark:text-violet-400`,children:O(`roundChip`,`Round {{n}}`,{n:e.round})})]})]})}function Un({r:e}){return(0,w.jsxs)(`div`,{className:`min-w-0`,children:[(0,w.jsxs)(t,{to:pt(e),onClick:e=>e.stopPropagation(),className:`inline-flex items-center gap-1 text-sm hover:underline truncate max-w-full`,title:e.record_id,children:[(0,w.jsx)(`span`,{className:`truncate`,children:e.record_title||T(e.record_id)}),(0,w.jsx)(xe,{className:`h-3 w-3 shrink-0 text-muted-foreground`})]}),(0,w.jsx)(`div`,{className:`text-xs text-muted-foreground truncate`,children:ct(e)})]})}function Wn({r:e}){if(!Q(e))return null;let t=Kt===e.id;return(0,w.jsxs)(`div`,{className:`flex items-center gap-1 opacity-0 group-hover:opacity-100 focus-within:opacity-100 transition-opacity`,onClick:e=>e.stopPropagation(),children:[(0,w.jsx)(s,{size:`sm`,variant:`ghost`,className:`h-7 px-2 text-emerald-700 hover:text-emerald-800 hover:bg-emerald-50 dark:text-emerald-400`,disabled:t,onClick:()=>void In(e),"aria-label":O(`approve`,`Approve`),children:(0,w.jsx)(ie,{className:`h-4 w-4`})}),(0,w.jsx)(s,{size:`sm`,variant:`ghost`,className:`h-7 px-2 text-red-600 hover:text-red-700 hover:bg-red-50 dark:text-red-400`,disabled:t,onClick:()=>Gt(e),"aria-label":O(`reject`,`Reject`),children:(0,w.jsx)(Ye,{className:`h-4 w-4`})})]})}return(0,w.jsxs)(`div`,{className:`flex flex-col gap-4 sm:gap-6 p-4 sm:p-6 max-w-6xl`,children:[(0,w.jsxs)(`header`,{className:`flex flex-col sm:flex-row sm:items-center sm:justify-between gap-2`,children:[(0,w.jsxs)(`div`,{children:[(0,w.jsxs)(`h1`,{className:`text-2xl font-semibold flex items-center gap-2`,children:[(0,w.jsx)(je,{className:`h-6 w-6`}),O(`title`,`Approvals Inbox`)]}),(0,w.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:O(`subtitle`,`Review and act on approval requests.`)})]}),(0,w.jsxs)(s,{variant:`outline`,size:`sm`,onClick:K,disabled:gt,className:`self-start sm:self-auto`,children:[(0,w.jsx)(_e,{className:`h-4 w-4 mr-2 ${gt?`animate-spin`:``}`}),O(`refresh`,`Refresh`)]})]}),St&&(0,w.jsxs)(Te,{variant:`destructive`,children:[(0,w.jsx)(de,{className:`h-4 w-4`}),(0,w.jsx)(ke,{children:St})]}),(0,w.jsxs)(Ke,{value:M,onValueChange:Vn,children:[(0,w.jsxs)(Ae,{children:[(0,w.jsxs)(Be,{value:`pending`,children:[O(`tabMyPending`,`My Pending`),wt>0&&(0,w.jsx)(Ue,{variant:`secondary`,className:`ml-2`,children:wt})]}),(0,w.jsx)(Be,{value:`submitted`,children:O(`tabSubmitted`,`Submitted by me`)}),(0,w.jsx)(Be,{value:`all`,children:O(`tabAll`,`All`)})]}),(0,w.jsxs)(Ee,{value:M,className:`mt-4 space-y-3`,children:[!gt&&(N.length>0||M!==`pending`&&(Ft||V!==`all`))&&(0,w.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,w.jsxs)(`div`,{className:`relative flex-1 min-w-[200px] max-w-sm`,children:[(0,w.jsx)(Pe,{className:`absolute left-2.5 top-1/2 -translate-y-1/2 h-3.5 w-3.5 text-muted-foreground`}),(0,w.jsx)(Fe,{value:B,onChange:e=>Pt(e.target.value),placeholder:O(`searchPlaceholder`,`Search record, process, requester…`),className:`pl-8 h-8 text-sm`}),B&&(0,w.jsx)(`button`,{type:`button`,onClick:()=>Pt(``),className:`absolute right-2 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground`,"aria-label":O(`clearSearch`,`Clear search`),children:(0,w.jsx)(re,{className:`h-3.5 w-3.5`})})]}),M!==`pending`&&(0,w.jsxs)(ce,{value:V,onValueChange:Vt,children:[(0,w.jsx)(Ce,{className:`h-8 w-auto min-w-[130px] text-sm`,children:(0,w.jsx)(fe,{placeholder:O(`statusFilter`,`Status`)})}),(0,w.jsxs)(Se,{children:[(0,w.jsx)(l,{value:`all`,children:O(`allStatuses`,`All statuses`)}),(0,w.jsx)(l,{value:`pending`,children:A(`pending`)}),(0,w.jsx)(l,{value:`approved`,children:A(`approved`)}),(0,w.jsx)(l,{value:`rejected`,children:A(`rejected`)}),(0,w.jsx)(l,{value:`recalled`,children:A(`recalled`)}),(0,w.jsx)(l,{value:`returned`,children:A(`returned`)})]})]}),On.length>1&&(0,w.jsxs)(ce,{value:Lt,onValueChange:Rt,children:[(0,w.jsx)(Ce,{className:`h-8 w-auto min-w-[140px] text-sm`,children:(0,w.jsx)(fe,{placeholder:O(`processFilter`,`Process`)})}),(0,w.jsxs)(Se,{children:[(0,w.jsx)(l,{value:`all`,children:O(`allProcesses`,`All processes`)}),On.map(e=>(0,w.jsx)(l,{value:e,children:e},e))]})]}),kn.length>1&&(0,w.jsxs)(ce,{value:zt,onValueChange:Bt,children:[(0,w.jsx)(Ce,{className:`h-8 w-auto min-w-[140px] text-sm`,children:(0,w.jsx)(fe,{placeholder:O(`objectFilter`,`Object`)})}),(0,w.jsxs)(Se,{children:[(0,w.jsx)(l,{value:`all`,children:O(`allObjects`,`All objects`)}),kn.map(e=>(0,w.jsx)(l,{value:e,children:e},e))]})]}),Bn&&(0,w.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:O(`filterCount`,`{{shown}} of {{total}}`,{shown:Z.length,total:N.length})})]}),M===`pending`&&H.size>0&&(0,w.jsxs)(`div`,{className:`flex items-center justify-between gap-2 px-3 py-2 rounded-md border bg-accent/30 text-sm`,children:[(0,w.jsxs)(`span`,{children:[(0,w.jsx)(`strong`,{children:H.size}),` `,O(`selected`,`selected`),$.length!==H.size&&(0,w.jsx)(`span`,{className:`text-muted-foreground ml-1`,children:O(`actionableCount`,`({{count}} actionable)`,{count:$.length})})]}),(0,w.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,w.jsxs)(g,{children:[(0,w.jsx)(pe,{asChild:!0,children:(0,w.jsxs)(s,{size:`sm`,disabled:Ut||$.length===0,children:[(0,w.jsx)(ie,{className:`h-3.5 w-3.5 mr-1`}),O(`approveN`,`Approve {{count}}`,{count:$.length||``})]})}),(0,w.jsxs)(u,{children:[(0,w.jsxs)(f,{children:[(0,w.jsx)(v,{children:O(`bulkApproveTitle`,`Approve {{count}} requests?`,{count:$.length})}),(0,w.jsx)(_,{children:O(`bulkApproveBody`,`Each request is approved with your identity and its flow continues down the approve branch.`)})]}),(0,w.jsxs)(y,{children:[(0,w.jsx)(p,{children:O(`cancel`,`Cancel`)}),(0,w.jsx)(h,{onClick:()=>Fn(`approve`),children:O(`approveN`,`Approve {{count}}`,{count:$.length})})]})]})]}),(0,w.jsxs)(g,{children:[(0,w.jsx)(pe,{asChild:!0,children:(0,w.jsxs)(s,{size:`sm`,variant:`outline`,disabled:Ut||$.length===0,className:`border-destructive text-destructive hover:bg-destructive hover:text-destructive-foreground`,children:[(0,w.jsx)(Ye,{className:`h-3.5 w-3.5 mr-1`}),O(`rejectN`,`Reject {{count}}`,{count:$.length||``})]})}),(0,w.jsxs)(u,{children:[(0,w.jsxs)(f,{children:[(0,w.jsx)(v,{children:O(`bulkRejectTitle`,`Reject {{count}} requests?`,{count:$.length})}),(0,w.jsx)(_,{children:O(`bulkRejectBody`,`This rejects the selected requests and notifies their submitters.`)})]}),(0,w.jsxs)(y,{children:[(0,w.jsx)(p,{children:O(`cancel`,`Cancel`)}),(0,w.jsx)(h,{onClick:()=>Fn(`reject`),className:`bg-destructive text-destructive-foreground hover:bg-destructive/90`,children:O(`rejectN`,`Reject {{count}}`,{count:$.length})})]})]})]}),(0,w.jsx)(s,{size:`sm`,variant:`ghost`,onClick:()=>Ht(new Set),disabled:Ut,children:O(`clear`,`Clear`)})]})]}),gt?(0,w.jsxs)(`div`,{className:`space-y-2`,children:[(0,w.jsx)(o,{className:`h-10 w-full`}),(0,w.jsx)(o,{className:`h-10 w-full`}),(0,w.jsx)(o,{className:`h-10 w-full`})]}):N.length===0?(0,w.jsx)(`div`,{className:`flex items-center justify-center min-h-[240px] rounded-md border border-dashed`,children:(0,w.jsxs)(le,{children:[(0,w.jsx)(be,{children:O(`emptyTitle`,`No requests`)}),(0,w.jsx)(Ve,{children:M===`pending`?O(`emptyPending`,`You're all caught up — nothing is waiting on you.`):O(`emptyOther`,`Nothing here yet.`)}),M===`pending`&&(0,w.jsx)(s,{variant:`link`,size:`sm`,className:`mt-1`,onClick:()=>Vn(`all`),children:O(`emptyViewAll`,`Browse all requests`)})]})}):Z.length===0?(0,w.jsx)(`div`,{className:`flex items-center justify-center min-h-[160px] rounded-md border border-dashed text-sm text-muted-foreground`,children:O(`noMatches`,`No matches for current filters.`)}):(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(Ge,{className:`hidden md:block`,children:(0,w.jsx)(Re,{className:`p-0`,children:(0,w.jsxs)(Le,{children:[(0,w.jsx)(qe,{children:(0,w.jsxs)(Xe,{children:[M===`pending`&&(0,w.jsx)(d,{className:`w-10`,children:(0,w.jsx)(De,{checked:Mn,onCheckedChange:Nn,"aria-label":O(`selectAll`,`Select all`),disabled:jn.length===0})}),(0,w.jsx)(d,{children:O(`colRequest`,`Request`)}),(0,w.jsx)(d,{children:O(`colRecord`,`Record`)}),(0,w.jsx)(d,{children:O(`colRequester`,`Requester`)}),(0,w.jsx)(d,{children:O(`colStatus`,`Status`)}),(0,w.jsx)(d,{children:O(`colWaiting`,`Submitted`)}),(0,w.jsx)(d,{className:`w-20`,"aria-label":O(`colActions`,`Actions`)})]})}),(0,w.jsx)(Ne,{children:Z.map((e,t)=>(0,w.jsxs)(Xe,{className:c(`group cursor-pointer hover:bg-accent/50`,pn===t&&`ring-2 ring-inset ring-ring bg-accent/30`),onClick:()=>{mn(t),q(e.id)},children:[M===`pending`&&(0,w.jsx)(m,{className:`w-10`,onClick:e=>e.stopPropagation(),children:(0,w.jsx)(De,{checked:H.has(e.id),onCheckedChange:()=>Pn(e.id),disabled:e.status!==`pending`,"aria-label":O(`selectRow`,`Select request`)})}),(0,w.jsx)(m,{children:(0,w.jsx)(Hn,{r:e})}),(0,w.jsx)(m,{children:(0,w.jsx)(Un,{r:e})}),(0,w.jsx)(m,{children:(0,w.jsxs)(`div`,{className:`flex items-center gap-1.5 text-sm`,children:[(0,w.jsx)(Ze,{className:`h-3.5 w-3.5 text-muted-foreground shrink-0`}),(0,w.jsx)(`span`,{className:`truncate`,title:e.submitter_id||``,children:ot(e)})]})}),(0,w.jsx)(m,{children:(0,w.jsx)(dt,{status:e.status})}),(0,w.jsxs)(m,{className:c(`text-xs whitespace-nowrap`,lt(e)),title:rt(D(e)),children:[(0,w.jsx)(Me,{className:`h-3 w-3 inline mr-1`}),k(D(e)),e.status===`pending`&&e.sla_due_at&&(0,w.jsx)(`div`,{className:c(`mt-0.5 text-[10px] font-medium`,Date.parse(e.sla_due_at)<Date.now()?`text-red-600 dark:text-red-400`:`text-muted-foreground`),children:Date.parse(e.sla_due_at)<Date.now()?O(`slaOverdue`,`SLA overdue {{dur}}`,{dur:ut(Date.now()-Date.parse(e.sla_due_at))}):O(`slaRemaining`,`SLA {{dur}} left`,{dur:ut(Date.parse(e.sla_due_at)-Date.now())})})]}),(0,w.jsx)(m,{className:`w-20`,children:(0,w.jsx)(Wn,{r:e})})]},e.id))})]})})}),(0,w.jsx)(`div`,{className:`md:hidden space-y-2`,children:Z.map(e=>(0,w.jsx)(Ge,{className:`cursor-pointer active:bg-accent/50`,onClick:()=>void q(e.id),children:(0,w.jsxs)(Re,{className:`p-3 space-y-1.5`,children:[(0,w.jsxs)(`div`,{className:`flex items-start justify-between gap-2`,children:[(0,w.jsx)(`div`,{className:`font-medium text-sm truncate`,children:it(e)}),(0,w.jsx)(dt,{status:e.status})]}),(0,w.jsxs)(`div`,{className:`text-sm truncate`,children:[e.record_title||T(e.record_id),(0,w.jsx)(`span`,{className:`text-muted-foreground text-xs ml-1.5`,children:ct(e)})]}),(0,w.jsxs)(`div`,{className:`flex items-center justify-between text-xs text-muted-foreground`,children:[(0,w.jsxs)(`span`,{className:`inline-flex items-center gap-1 truncate`,children:[(0,w.jsx)(Ze,{className:`h-3 w-3`}),ot(e)]}),(0,w.jsxs)(`span`,{className:c(`inline-flex items-center gap-1 whitespace-nowrap`,lt(e)),children:[(0,w.jsx)(Me,{className:`h-3 w-3`}),k(D(e))]})]}),Q(e)&&(0,w.jsxs)(`div`,{className:`flex gap-2 pt-1`,onClick:e=>e.stopPropagation(),children:[(0,w.jsxs)(s,{size:`sm`,className:`h-7 flex-1`,disabled:Kt===e.id,onClick:()=>void In(e),children:[(0,w.jsx)(ie,{className:`h-3.5 w-3.5 mr-1`}),O(`approve`,`Approve`)]}),(0,w.jsxs)(s,{size:`sm`,variant:`outline`,className:`h-7 flex-1 border-destructive text-destructive`,disabled:Kt===e.id,onClick:()=>Gt(e),children:[(0,w.jsx)(Ye,{className:`h-3.5 w-3.5 mr-1`}),O(`reject`,`Reject`)]})]})]})},e.id))}),M!==`pending`&&bt!=null&&(0,w.jsxs)(`div`,{className:`flex items-center justify-center gap-3 py-1`,children:[(0,w.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:O(`loadedOf`,`Loaded {{loaded}} of {{total}}`,{loaded:N.length,total:bt})}),N.length<bt&&(0,w.jsx)(s,{size:`sm`,variant:`outline`,disabled:vt,onClick:()=>void hn(),children:vt?O(`loadingMore`,`Loading…`):O(`loadMore`,`Load more`)})]}),(0,w.jsx)(`div`,{className:`hidden md:block text-[11px] text-muted-foreground`,children:O(`keyboardHint`,`Keyboard: j/k move · Enter open · x select · a approve · r reject`)})]})]})]}),(0,w.jsx)(g,{open:Jt,onOpenChange:e=>{e||(Yt(!1),Zt(``))},children:(0,w.jsxs)(u,{children:[(0,w.jsxs)(f,{children:[(0,w.jsx)(v,{children:O(`reassignTitle`,`Hand this approval to someone else?`)}),(0,w.jsx)(_,{children:O(`reassignBody`,`Your approver slot moves to the person you pick — they are notified and can act immediately.`)})]}),(0,w.jsxs)(`div`,{children:[(0,w.jsx)(ze,{htmlFor:`reassign-to`,className:`text-xs`,children:O(`reassignTo`,`New approver`)}),(0,w.jsx)(Fe,{id:`reassign-to`,list:`reassign-user-options`,value:Xt,onChange:e=>Zt(e.target.value),placeholder:O(`reassignToPlaceholder`,`Pick a user or type an email / role:<name>`),className:`mt-1`}),(0,w.jsx)(`datalist`,{id:`reassign-user-options`,children:dn.map(e=>(0,w.jsx)(`option`,{value:e.email,children:e.name},e.email))})]}),(0,w.jsxs)(y,{children:[(0,w.jsx)(p,{children:O(`cancel`,`Cancel`)}),(0,w.jsx)(h,{disabled:!Xt.trim()||W,onClick:()=>void vn(),children:O(`reassignBtn`,`Reassign`)})]})]})}),(0,w.jsx)(g,{open:Qt,onOpenChange:e=>{e||($t(!1),tn(``))},children:(0,w.jsxs)(u,{children:[(0,w.jsxs)(f,{children:[(0,w.jsx)(v,{children:O(`requestInfoTitle`,`Ask the requester for more information?`)}),(0,w.jsx)(_,{children:O(`requestInfoBody`,`The request stays pending; the requester is notified and can reply on the thread.`)})]}),(0,w.jsx)(Ie,{value:en,onChange:e=>tn(e.target.value),rows:3,placeholder:O(`requestInfoPlaceholder`,`What do you need from the requester?`)}),(0,w.jsxs)(y,{children:[(0,w.jsx)(p,{children:O(`cancel`,`Cancel`)}),(0,w.jsx)(h,{disabled:!en.trim()||W,onClick:()=>void bn(),children:O(`requestInfoBtn`,`Request info`)})]})]})}),(0,w.jsx)(g,{open:nn,onOpenChange:e=>{e||(rn(!1),on(``))},children:(0,w.jsxs)(u,{children:[(0,w.jsxs)(f,{children:[(0,w.jsx)(v,{children:O(`sendBackTitle`,`Send this request back for revision?`)}),(0,w.jsx)(_,{children:O(`sendBackBody`,`This round ends and the record unlocks so the requester can fix the data. When they resubmit, a fresh approval round opens for all approvers.`)})]}),(0,w.jsx)(Ie,{value:an,onChange:e=>on(e.target.value),rows:3,placeholder:O(`sendBackPlaceholder`,`What needs to be fixed before this can be approved?`)}),(0,w.jsxs)(y,{children:[(0,w.jsx)(p,{children:O(`cancel`,`Cancel`)}),(0,w.jsx)(h,{disabled:W,onClick:()=>void xn(),children:O(`sendBackBtn`,`Send back`)})]})]})}),(0,w.jsx)(g,{open:!!U,onOpenChange:e=>!e&&Gt(null),children:(0,w.jsxs)(u,{children:[(0,w.jsxs)(f,{children:[(0,w.jsx)(v,{children:O(`rejectOneTitle`,`Reject "{{title}}"?`,{title:U?U.record_title||T(U.record_id):``})}),(0,w.jsx)(_,{children:O(`rejectOneBody`,`This rejects the request and notifies the submitter.`)})]}),(0,w.jsxs)(y,{children:[(0,w.jsx)(p,{children:O(`cancel`,`Cancel`)}),(0,w.jsx)(h,{onClick:()=>void Ln(),className:`bg-destructive text-destructive-foreground hover:bg-destructive/90`,children:O(`reject`,`Reject`)})]})]})}),(0,w.jsx)(se,{open:!!P,onOpenChange:e=>!e&&gn(),children:(0,w.jsxs)(he,{className:`w-full sm:max-w-xl overflow-y-auto`,children:[(0,w.jsxs)(ae,{children:[(0,w.jsx)(ue,{children:F?it(F):O(`drawerTitle`,`Approval Request`)}),(0,w.jsx)(ye,{children:F?at(F)||ct(F):``})]}),F&&An>=0&&Z.length>1&&(0,w.jsxs)(`div`,{className:`flex items-center justify-between mt-2 text-xs text-muted-foreground`,children:[(0,w.jsxs)(s,{variant:`ghost`,size:`sm`,className:`h-7 px-2`,disabled:An<=0,onClick:()=>{let e=Z[An-1];e&&q(e.id)},children:[(0,w.jsx)(ge,{className:`h-4 w-4 mr-0.5`}),O(`prevRequest`,`Previous`)]}),(0,w.jsx)(`span`,{children:O(`positionOf`,`{{index}} of {{total}}`,{index:An+1,total:Z.length})}),(0,w.jsxs)(s,{variant:`ghost`,size:`sm`,className:`h-7 px-2`,disabled:An>=Z.length-1,onClick:()=>{let e=Z[An+1];e&&q(e.id)},children:[O(`nextRequest`,`Next`),(0,w.jsx)(Qe,{className:`h-4 w-4 ml-0.5`})]})]}),At?(0,w.jsxs)(`div`,{className:`space-y-2 mt-6`,children:[(0,w.jsx)(o,{className:`h-6 w-3/4`}),(0,w.jsx)(o,{className:`h-6 w-1/2`}),(0,w.jsx)(o,{className:`h-20 w-full`})]}):F?(0,w.jsxs)(`div`,{className:`space-y-4 mt-6`,children:[(0,w.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 text-xs text-muted-foreground`,children:[(0,w.jsx)(dt,{status:F.status}),(F.round??1)>1&&(0,w.jsx)(Ue,{variant:`outline`,className:`text-[10px] border-violet-200 text-violet-700 dark:border-violet-500/30 dark:text-violet-400`,children:O(`roundChip`,`Round {{n}}`,{n:F.round})}),(0,w.jsxs)(`span`,{className:`inline-flex items-center gap-1`,title:rt(D(F)),children:[(0,w.jsx)(Me,{className:`h-3 w-3`}),O(`submittedAgo`,`Submitted {{when}}`,{when:k(D(F))})]}),F.completed_at&&(0,w.jsxs)(`span`,{children:[`· `,O(`completedAt`,`Completed {{when}}`,{when:k(F.completed_at)})]}),F.status===`pending`&&F.sla_due_at&&(0,w.jsx)(Ue,{variant:`outline`,className:c(`text-[10px]`,Date.parse(F.sla_due_at)<Date.now()?`border-red-200 bg-red-50 text-red-700 dark:border-red-500/30 dark:bg-red-500/10 dark:text-red-400`:`border-border text-muted-foreground`),children:Date.parse(F.sla_due_at)<Date.now()?O(`slaOverdue`,`SLA overdue {{dur}}`,{dur:ut(Date.now()-Date.parse(F.sla_due_at))}):O(`slaRemaining`,`SLA {{dur}} left`,{dur:ut(Date.parse(F.sla_due_at)-Date.now())})})]}),(0,w.jsx)(Ge,{children:(0,w.jsxs)(Re,{className:`p-4 space-y-3`,children:[(0,w.jsxs)(`div`,{className:`flex items-start justify-between gap-2`,children:[(0,w.jsxs)(`div`,{className:`min-w-0`,children:[(0,w.jsxs)(t,{to:pt(F),className:`text-base font-semibold hover:underline inline-flex items-center gap-1.5`,children:[(0,w.jsx)(`span`,{className:`truncate`,children:F.record_title||T(F.record_id)}),(0,w.jsx)(xe,{className:`h-3.5 w-3.5 shrink-0 text-muted-foreground`})]}),(0,w.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:ct(F)})]}),(0,w.jsx)(`div`,{className:`text-right text-xs text-muted-foreground shrink-0`,children:(0,w.jsxs)(`div`,{className:`inline-flex items-center gap-1`,children:[(0,w.jsx)(Ze,{className:`h-3 w-3`}),(0,w.jsx)(`span`,{title:F.submitter_id||``,children:ot(F)})]})})]}),ft(F.payload,F.payload_display).length>0&&(0,w.jsx)(`div`,{className:`grid grid-cols-2 gap-x-4 gap-y-2 text-sm border-t pt-3`,children:ft(F.payload,F.payload_display).map(([e,t])=>(0,w.jsxs)(`div`,{className:`min-w-0`,children:[(0,w.jsx)(`div`,{className:`text-[11px] text-muted-foreground`,children:e}),(0,w.jsx)(`div`,{className:`truncate`,title:t,children:t})]},e))}),F.status===`pending`&&(F.pending_approvers||[]).length>0&&(0,w.jsxs)(`div`,{className:`border-t pt-3`,children:[(0,w.jsx)(`div`,{className:`text-[11px] text-muted-foreground mb-1`,children:O(`waitingOn`,`Waiting on`)}),(0,w.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:(F.pending_approvers||[]).map((e,t)=>(0,w.jsx)(Ue,{variant:`outline`,className:`text-[11px]`,title:e,children:st(e,F)},t))})]})]})}),(F.flow_steps?.length??0)>1&&(0,w.jsx)(`div`,{className:`flex items-center px-1`,"aria-label":O(`stepProgress`,`Approval steps`),children:F.flow_steps.map((e,t)=>(0,w.jsxs)(x.Fragment,{children:[t>0&&(0,w.jsx)(`div`,{className:c(`h-px flex-1 mx-2`,e.state===`done`||e.state===`current`?`bg-emerald-300 dark:bg-emerald-700`:`bg-border`)}),(0,w.jsxs)(`div`,{className:`flex items-center gap-1.5 shrink-0`,children:[(0,w.jsx)(`span`,{className:c(`flex items-center justify-center h-5 w-5 rounded-full text-[10px] font-semibold`,e.state===`done`&&`bg-emerald-500 text-white`,e.state===`current`&&`bg-amber-500 text-white ring-2 ring-amber-200 dark:ring-amber-500/30`,e.state===`upcoming`&&`bg-muted text-muted-foreground border`),children:e.state===`done`?(0,w.jsx)(oe,{className:`h-3 w-3`}):t+1}),(0,w.jsx)(`span`,{className:c(`text-xs`,e.state===`current`?`font-medium`:`text-muted-foreground`),children:e.label})]})]},e.id))}),(0,w.jsxs)(`div`,{children:[(0,w.jsx)(`h3`,{className:`text-sm font-semibold mb-3`,children:O(`history`,`Activity`)}),Ot.length===0?(0,w.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:O(`noActions`,`No actions yet.`)}):(0,w.jsx)(`ol`,{className:`relative space-y-3 pl-5 before:absolute before:left-[7px] before:top-1 before:bottom-1 before:w-px before:bg-border`,children:Ot.map(e=>{let t=e.action===`approve`?`bg-emerald-500`:e.action===`reject`?`bg-destructive`:e.action===`submit`?`bg-blue-500`:e.action===`reassign`?`bg-indigo-500`:e.action===`remind`||e.action===`request_info`?`bg-amber-500`:e.action===`comment`?`bg-slate-400`:e.action===`escalate`?`bg-red-500`:e.action===`revise`?`bg-violet-500`:e.action===`resubmit`?`bg-blue-500`:`bg-muted-foreground`,n=e.actor_id===`system:sla`?O(`systemSlaActor`,`System (SLA)`):e.actor_name??(e.actor_id&&e.actor_id===F.submitter_id?ot(F):T(e.actor_id)),r=e.action===`submit`?O(`actSubmit`,`Submitted`):e.action===`approve`?O(`actApprove`,`Approved`):e.action===`reject`?O(`actReject`,`Rejected`):e.action===`recall`?O(`actRecall`,`Recalled`):e.action===`reassign`?O(`actReassign`,`Reassigned`):e.action===`remind`?O(`actRemind`,`Reminder sent`):e.action===`request_info`?O(`actRequestInfo`,`Requested more info`):e.action===`comment`?O(`actComment`,`Commented`):e.action===`escalate`?O(`actEscalate`,`SLA escalated`):e.action===`revise`?O(`actRevise`,`Sent back for revision`):e.action===`resubmit`?O(`actResubmit`,`Resubmitted`):e.action;return(0,w.jsxs)(`li`,{className:`relative text-xs`,children:[(0,w.jsx)(`span`,{className:`absolute -left-[18px] top-1 h-3 w-3 rounded-full ring-2 ring-background ${t}`,"aria-hidden":!0}),(0,w.jsxs)(`div`,{className:`flex items-baseline gap-1.5 flex-wrap`,children:[(0,w.jsx)(`span`,{className:`font-medium`,children:r}),(0,w.jsx)(`span`,{className:`text-muted-foreground`,children:`·`}),(0,w.jsx)(`span`,{title:e.actor_id||``,children:n}),(0,w.jsx)(`span`,{className:`ml-auto text-muted-foreground text-[10px]`,title:rt(e.created_at),children:k(e.created_at)})]}),e.comment&&(0,w.jsxs)(`div`,{className:`text-muted-foreground italic mt-0.5`,children:[`"`,e.comment,`"`]})]},e.id)})}),F.status===`pending`&&(Tn||En)&&(0,w.jsxs)(`div`,{className:`flex items-center gap-2 mt-3`,children:[(0,w.jsx)(Fe,{value:ln,onChange:e=>un(e.target.value),onKeyDown:e=>{e.key===`Enter`&&ln.trim()&&(e.preventDefault(),Cn())},placeholder:O(`replyPlaceholder`,`Reply on this request…`),className:`h-8 text-sm`}),(0,w.jsx)(s,{size:`sm`,variant:`outline`,className:`h-8 px-2 shrink-0`,disabled:!ln.trim()||W,onClick:()=>void Cn(),children:(0,w.jsx)(ne,{className:`h-3.5 w-3.5`})})]})]}),F.payload!=null&&(0,w.jsxs)(`details`,{className:`group`,children:[(0,w.jsx)(`summary`,{className:`cursor-pointer text-xs text-muted-foreground hover:text-foreground select-none`,children:O(`rawData`,`Raw data (JSON)`)}),(0,w.jsxs)(`div`,{className:`mt-2`,children:[(0,w.jsx)(`div`,{className:`flex justify-end`,children:(0,w.jsxs)(`button`,{type:`button`,onClick:async()=>{try{await navigator.clipboard.writeText(JSON.stringify(F.payload,null,2)),b.success(O(`copied`,`Copied`))}catch{b.error(O(`copyFailed`,`Copy failed`))}},className:`text-[10px] text-muted-foreground hover:text-foreground inline-flex items-center gap-1`,children:[(0,w.jsx)(We,{className:`h-3 w-3`}),O(`copy`,`Copy`)]})}),(0,w.jsx)(`pre`,{className:`text-[11px] bg-muted/50 rounded p-2 overflow-auto max-h-48 mt-1`,children:JSON.stringify(F.payload,null,2)})]})]}),F.status===`pending`&&(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(He,{}),(0,w.jsxs)(`div`,{className:`space-y-3`,children:[$e&&(0,w.jsxs)(`details`,{className:`group`,children:[(0,w.jsx)(`summary`,{className:`cursor-pointer text-xs text-muted-foreground hover:text-foreground select-none`,children:O(`overrideActor`,`Act as another identity (admin)`)}),(0,w.jsxs)(`div`,{className:`mt-2`,children:[(0,w.jsx)(ze,{htmlFor:`actor-override`,className:`text-xs`,children:O(`actor`,`Actor`)}),(0,w.jsx)(`input`,{id:`actor-override`,type:`text`,value:R,onChange:e=>Mt(e.target.value),placeholder:`${O(`auto`,`Auto`)}: ${J(F)||`—`}`,className:`w-full mt-1 px-3 py-2 text-sm border rounded-md bg-background`}),(0,w.jsx)(`div`,{className:`text-[10px] text-muted-foreground mt-1`,children:O(`overrideHint`,`e.g. role:sales_manager. Leave blank to use the auto-detected identity.`)})]})]}),(0,w.jsxs)(`div`,{children:[(0,w.jsx)(ze,{htmlFor:`comment`,className:`text-xs`,children:O(`comment`,`Comment (optional)`)}),(0,w.jsx)(`div`,{className:`flex flex-wrap gap-1.5 mt-1.5`,children:[O(`quickPhrase1`,`Approved — meets requirements.`),O(`quickPhrase2`,`Approved with conditions — please monitor execution.`),O(`quickPhrase3`,`Please add supporting material and resubmit.`)].map(e=>(0,w.jsx)(`button`,{type:`button`,onClick:()=>L(e),className:`text-[11px] px-2 py-0.5 rounded-full border text-muted-foreground hover:text-foreground hover:bg-accent transition-colors`,children:e},e))}),(0,w.jsx)(Ie,{id:`comment`,value:I,onChange:e=>L(e.target.value),rows:2,className:`mt-1`})]}),(0,w.jsxs)(`div`,{className:`flex gap-2 flex-wrap`,children:[(0,w.jsxs)(s,{size:`sm`,onClick:()=>_n(`approve`),disabled:!Tn||z!==null,children:[(0,w.jsx)(ie,{className:`h-4 w-4 mr-1`}),z===`approve`?O(`approving`,`Approving…`):O(`approve`,`Approve`)]}),(0,w.jsxs)(g,{children:[(0,w.jsx)(pe,{asChild:!0,children:(0,w.jsxs)(s,{size:`sm`,variant:`outline`,disabled:!Tn||z!==null,className:`border-destructive text-destructive hover:bg-destructive hover:text-destructive-foreground`,children:[(0,w.jsx)(Ye,{className:`h-4 w-4 mr-1`}),z===`reject`?O(`rejecting`,`Rejecting…`):O(`reject`,`Reject`)]})}),(0,w.jsxs)(u,{children:[(0,w.jsxs)(f,{children:[(0,w.jsx)(v,{children:O(`rejectTitle`,`Reject this request?`)}),(0,w.jsx)(_,{children:O(`rejectBody`,`This marks the request as rejected and notifies the submitter.`)})]}),(0,w.jsxs)(y,{children:[(0,w.jsx)(p,{children:O(`cancel`,`Cancel`)}),(0,w.jsx)(h,{onClick:()=>_n(`reject`),className:`bg-destructive text-destructive-foreground hover:bg-destructive/90`,children:O(`reject`,`Reject`)})]})]})]}),Tn&&(0,w.jsxs)(w.Fragment,{children:[(0,w.jsxs)(s,{size:`sm`,variant:`outline`,disabled:z!==null||W,className:`border-violet-300 text-violet-700 hover:bg-violet-50 dark:text-violet-400`,onClick:()=>rn(!0),children:[(0,w.jsx)(we,{className:`h-4 w-4 mr-1`}),O(`sendBackBtn`,`Send back`)]}),(0,w.jsxs)(s,{size:`sm`,variant:`outline`,disabled:z!==null||W,className:`border-amber-300 text-amber-700 hover:bg-amber-50 dark:text-amber-400`,onClick:()=>$t(!0),children:[(0,w.jsx)(me,{className:`h-4 w-4 mr-1`}),O(`requestInfoBtn`,`Request info`)]}),(0,w.jsxs)(s,{size:`sm`,variant:`outline`,disabled:z!==null||W,onClick:()=>{wn(),Yt(!0)},children:[(0,w.jsx)(Je,{className:`h-4 w-4 mr-1`}),O(`reassignBtn`,`Reassign`)]})]}),En&&(0,w.jsxs)(s,{size:`sm`,variant:`outline`,disabled:W,onClick:()=>void yn(),children:[(0,w.jsx)(Oe,{className:`h-4 w-4 mr-1`}),O(`remindBtn`,`Send reminder`)]}),En&&(0,w.jsxs)(g,{children:[(0,w.jsx)(pe,{asChild:!0,children:(0,w.jsxs)(s,{size:`sm`,variant:`outline`,disabled:z!==null,children:[(0,w.jsx)(ve,{className:`h-4 w-4 mr-1`}),z===`recall`?O(`recalling`,`Recalling…`):O(`recall`,`Recall`)]})}),(0,w.jsxs)(u,{children:[(0,w.jsxs)(f,{children:[(0,w.jsx)(v,{children:O(`recallTitle`,`Recall this request?`)}),(0,w.jsx)(_,{children:O(`recallBody`,`This withdraws your request. Approvers can no longer act on it, and the record is unlocked.`)})]}),(0,w.jsxs)(y,{children:[(0,w.jsx)(p,{children:O(`cancel`,`Cancel`)}),(0,w.jsx)(h,{onClick:()=>_n(`recall`),children:O(`recall`,`Recall`)})]})]})]})]}),!Tn&&(0,w.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:En?O(`whyDisabledSubmitter`,`You submitted this request, so you can recall it — but only the assigned approvers can approve or reject.`):O(`whyDisabled`,`Only the assigned approvers can act on this request. It is waiting on: {{who}}.`,{who:(F.pending_approvers||[]).map(e=>st(e,F)).join(`, `)||`—`})})]})]}),Dn&&(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(He,{}),(0,w.jsxs)(`div`,{className:`space-y-3`,children:[(0,w.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:O(`returnedHint`,`An approver sent this back to you. The record is unlocked — fix the data, then resubmit to start a new approval round.`)}),(0,w.jsxs)(`div`,{children:[(0,w.jsx)(ze,{htmlFor:`resubmit-comment`,className:`text-xs`,children:O(`comment`,`Comment (optional)`)}),(0,w.jsx)(Ie,{id:`resubmit-comment`,value:I,onChange:e=>L(e.target.value),rows:2,className:`mt-1`,placeholder:O(`resubmitPlaceholder`,`What did you change?`)})]}),(0,w.jsxs)(`div`,{className:`flex gap-2 flex-wrap`,children:[(0,w.jsx)(s,{asChild:!0,size:`sm`,variant:`outline`,children:(0,w.jsxs)(t,{to:pt(F),children:[(0,w.jsx)(xe,{className:`h-4 w-4 mr-1`}),O(`editRecordBtn`,`Edit record`)]})}),(0,w.jsxs)(s,{size:`sm`,disabled:sn,onClick:()=>void Sn(),children:[(0,w.jsx)(_e,{className:c(`h-4 w-4 mr-1`,sn&&`animate-spin`)}),sn?O(`resubmitting`,`Resubmitting…`):O(`resubmitBtn`,`Resubmit`)]}),(0,w.jsxs)(g,{children:[(0,w.jsx)(pe,{asChild:!0,children:(0,w.jsxs)(s,{size:`sm`,variant:`outline`,disabled:sn,children:[(0,w.jsx)(ve,{className:`h-4 w-4 mr-1`}),O(`recall`,`Recall`)]})}),(0,w.jsxs)(u,{children:[(0,w.jsxs)(f,{children:[(0,w.jsx)(v,{children:O(`abandonTitle`,`Abandon this revision?`)}),(0,w.jsx)(_,{children:O(`abandonBody`,`This withdraws the request instead of resubmitting it. The approval ends here.`)})]}),(0,w.jsxs)(y,{children:[(0,w.jsx)(p,{children:O(`cancel`,`Cancel`)}),(0,w.jsx)(h,{onClick:()=>_n(`recall`),children:O(`recall`,`Recall`)})]})]})]})]})]})]})]}):null]})})]})}export{pt as ApprovalsInboxPage};
@@ -1 +0,0 @@
1
- import{o as e}from"./rolldown-runtime-DAXXjFlN.js";import{r as t,y as n}from"./vendor-react-BKSb6vFP.js";import{Ar as r,Bt as i,Cr as a,Gt as ee,Ht as te,Jt as o,K as ne,Kt as re,Mi as s,Ns as ie,Qt as c,Ut as l,Wi as ae,Wt as oe,X as u,Xt as d,Yt as f,Zt as p,_t as m,dr as se,fr as ce,gt as h,ht as le,ji as ue,ln as g,mt as _,nr as v,pn as y,q as de,qt as b,sr as x,tr as S,vt as fe,yt as C}from"./ui-components-Y3D5-fgK.js";var w=e(n(),1),T=t(),E=`${``.replace(/\/$/,``)}/api/v1`,D=[`create`,`update`,`delete`,`restore`,`login`,`logout`,`permission_change`,`config_change`,`export`,`import`],O={create:`default`,update:`secondary`,delete:`destructive`,restore:`outline`,login:`outline`,logout:`outline`,permission_change:`secondary`,config_change:`secondary`,export:`outline`,import:`outline`},k=50;function A(e){if(!e)return`—`;try{return new Date(e).toLocaleString()}catch{return e}}function j(e,t=24){return e?e.length>t?`${e.slice(0,t-1)}…`:e:`—`}function M(e){if(!e)return``;try{return JSON.stringify(JSON.parse(e),null,2)}catch{return e}}function N(){let[e,t]=(0,w.useState)([]),[n,N]=(0,w.useState)(!1),[P,F]=(0,w.useState)(null),[I,L]=(0,w.useState)(`all`),[R,z]=(0,w.useState)(``),[B,V]=(0,w.useState)(``),[H,U]=(0,w.useState)(``),[W,G]=(0,w.useState)(``),[K,q]=(0,w.useState)(0),[J,Y]=(0,w.useState)(!1),[X,Z]=(0,w.useState)(null),Q=(0,w.useCallback)(async()=>{N(!0),F(null);try{let e={};I&&I!==`all`&&(e.action=I),R.trim()&&(e.object_name=R.trim()),B.trim()&&(e.user_id=B.trim()),H&&(e.created_at={...e.created_at||{},$gte:H}),W&&(e.created_at={...e.created_at||{},$lte:`${W}T23:59:59`});let n=new URLSearchParams;Object.keys(e).length>0&&n.set(`$filter`,JSON.stringify(e)),n.set(`$orderby`,`created_at desc`),n.set(`$top`,`51`),n.set(`$skip`,String(K*k));let r=await fetch(`${E}/data/sys_audit_log?${n.toString()}`,{credentials:`include`});if(!r.ok){let e=await r.text().catch(()=>``);throw Error(`HTTP ${r.status}: ${e.slice(0,200)||r.statusText}`)}let i=await r.json(),a=Array.isArray(i)?i:Array.isArray(i?.records)?i.records:Array.isArray(i?.data)?i.data:[];Y(a.length>k),t(a.slice(0,k))}catch(e){console.warn(`[AuditLogPage] load failed:`,e),F(e?.message||`Failed to load audit log`),t([]),Y(!1)}finally{N(!1)}},[I,R,B,H,W,K]);(0,w.useEffect)(()=>{Q()},[Q]);let pe=(0,w.useCallback)(()=>{L(`all`),z(``),V(``),U(``),G(``),q(0)},[]),$=(0,w.useMemo)(()=>{let e=0;return I!==`all`&&(e+=1),R.trim()&&(e+=1),B.trim()&&(e+=1),H&&(e+=1),W&&(e+=1),e},[I,R,B,H,W]);return(0,T.jsxs)(`div`,{className:`p-6 space-y-4 max-w-screen-2xl mx-auto`,children:[(0,T.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,T.jsx)(s,{className:`h-6 w-6 text-muted-foreground`}),(0,T.jsxs)(`div`,{className:`flex-1`,children:[(0,T.jsx)(`h1`,{className:`text-2xl font-semibold tracking-tight`,children:`Audit Log`}),(0,T.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Read-only system activity and record changes. Newest first.`})]}),(0,T.jsxs)(a,{variant:`outline`,size:`sm`,onClick:Q,disabled:n,children:[(0,T.jsx)(ae,{className:`h-4 w-4 mr-1 ${n?`animate-spin`:``}`}),`Refresh`]})]}),(0,T.jsx)(S,{children:(0,T.jsxs)(v,{className:`p-4 grid grid-cols-1 md:grid-cols-5 gap-3`,children:[(0,T.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,T.jsx)(y,{className:`text-xs`,children:`Action`}),(0,T.jsxs)(o,{value:I,onValueChange:e=>{L(e),q(0)},children:[(0,T.jsx)(p,{className:`h-9`,children:(0,T.jsx)(c,{})}),(0,T.jsxs)(f,{children:[(0,T.jsx)(d,{value:`all`,children:`All actions`}),D.map(e=>(0,T.jsx)(d,{value:e,children:e},e))]})]})]}),(0,T.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,T.jsx)(y,{className:`text-xs`,children:`Object`}),(0,T.jsx)(g,{placeholder:`e.g. account`,value:R,onChange:e=>{z(e.target.value),q(0)},className:`h-9`})]}),(0,T.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,T.jsx)(y,{className:`text-xs`,children:`Actor (user id)`}),(0,T.jsx)(g,{placeholder:`user id`,value:B,onChange:e=>{V(e.target.value),q(0)},className:`h-9`})]}),(0,T.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,T.jsx)(y,{className:`text-xs`,children:`From`}),(0,T.jsx)(g,{type:`date`,value:H,onChange:e=>{U(e.target.value),q(0)},className:`h-9`})]}),(0,T.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,T.jsx)(y,{className:`text-xs`,children:`To`}),(0,T.jsx)(g,{type:`date`,value:W,onChange:e=>{G(e.target.value),q(0)},className:`h-9`})]}),$>0&&(0,T.jsx)(`div`,{className:`md:col-span-5 flex justify-end`,children:(0,T.jsxs)(a,{variant:`ghost`,size:`sm`,onClick:pe,children:[(0,T.jsx)(r,{className:`h-4 w-4 mr-1`}),`Clear filters (`,$,`)`]})})]})}),P&&(0,T.jsxs)(se,{variant:`destructive`,children:[(0,T.jsx)(ie,{className:`h-4 w-4`}),(0,T.jsx)(ce,{children:P})]}),(0,T.jsx)(S,{children:(0,T.jsx)(v,{className:`p-0`,children:n&&e.length===0?(0,T.jsx)(`div`,{className:`p-6 space-y-2`,children:Array.from({length:6}).map((e,t)=>(0,T.jsx)(i,{className:`h-9 w-full`},t))}):e.length===0?(0,T.jsx)(`div`,{className:`p-12`,children:(0,T.jsxs)(ne,{children:[(0,T.jsx)(ue,{className:`h-8 w-8 text-muted-foreground mb-3`}),(0,T.jsx)(u,{children:`No audit entries`}),(0,T.jsx)(de,{children:$>0?`Try clearing filters or widening the date range.`:`Events will appear here once tracked objects are modified.`})]})}):(0,T.jsxs)(_,{children:[(0,T.jsx)(fe,{children:(0,T.jsxs)(C,{children:[(0,T.jsx)(m,{className:`w-[180px]`,children:`Timestamp`}),(0,T.jsx)(m,{className:`w-[130px]`,children:`Action`}),(0,T.jsx)(m,{children:`Object`}),(0,T.jsx)(m,{children:`Record`}),(0,T.jsx)(m,{children:`Actor`}),(0,T.jsx)(m,{className:`w-[130px]`,children:`IP`})]})}),(0,T.jsx)(le,{children:e.map(e=>{let t=O[e.action||``]||`outline`;return(0,T.jsxs)(C,{className:`cursor-pointer`,onClick:()=>Z(e),children:[(0,T.jsx)(h,{className:`font-mono text-xs`,children:A(e.created_at)}),(0,T.jsx)(h,{children:(0,T.jsx)(x,{variant:t,children:e.action||`—`})}),(0,T.jsx)(h,{children:e.object_name||`—`}),(0,T.jsx)(h,{className:`font-mono text-xs`,children:j(e.record_id,18)}),(0,T.jsx)(h,{className:`font-mono text-xs`,children:j(e.user_id,18)}),(0,T.jsx)(h,{className:`font-mono text-xs`,children:e.ip_address||`—`})]},e.id)})})]})})}),(e.length>0||K>0)&&(0,T.jsxs)(`div`,{className:`flex items-center justify-between text-sm text-muted-foreground`,children:[(0,T.jsxs)(`span`,{children:[`Page `,K+1,J?``:` · end`]}),(0,T.jsxs)(`div`,{className:`flex gap-2`,children:[(0,T.jsx)(a,{variant:`outline`,size:`sm`,disabled:K===0||n,onClick:()=>q(e=>Math.max(0,e-1)),children:`Previous`}),(0,T.jsx)(a,{variant:`outline`,size:`sm`,disabled:!J||n,onClick:()=>q(e=>e+1),children:`Next`})]})]}),(0,T.jsx)(te,{open:!!X,onOpenChange:e=>!e&&Z(null),children:(0,T.jsxs)(l,{side:`right`,className:`sm:max-w-2xl w-full overflow-y-auto`,children:[(0,T.jsxs)(ee,{children:[(0,T.jsxs)(re,{className:`flex items-center gap-2`,children:[(0,T.jsx)(x,{variant:X&&O[X.action||``]||`outline`,children:X?.action||`—`}),X?.object_name||`Audit Event`]}),(0,T.jsx)(oe,{children:X?.id?(0,T.jsx)(`span`,{className:`font-mono text-xs`,children:X.id}):null})]}),X&&(0,T.jsxs)(`div`,{className:`mt-6 space-y-5`,children:[(0,T.jsxs)(`div`,{className:`grid grid-cols-2 gap-3 text-sm`,children:[(0,T.jsxs)(`div`,{children:[(0,T.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:`Timestamp`}),(0,T.jsx)(`div`,{className:`font-mono`,children:A(X.created_at)})]}),(0,T.jsxs)(`div`,{children:[(0,T.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:`IP Address`}),(0,T.jsx)(`div`,{className:`font-mono`,children:X.ip_address||`—`})]}),(0,T.jsxs)(`div`,{children:[(0,T.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:`Actor (user_id)`}),(0,T.jsx)(`div`,{className:`font-mono break-all`,children:X.user_id||`—`})]}),(0,T.jsxs)(`div`,{children:[(0,T.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:`Tenant`}),(0,T.jsx)(`div`,{className:`font-mono break-all`,children:X.tenant_id||`—`})]}),(0,T.jsxs)(`div`,{className:`col-span-2`,children:[(0,T.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:`Target record`}),(0,T.jsxs)(`div`,{className:`font-mono text-sm break-all`,children:[X.object_name||`—`,` / `,X.record_id||`—`]})]}),X.user_agent&&(0,T.jsxs)(`div`,{className:`col-span-2`,children:[(0,T.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:`User Agent`}),(0,T.jsx)(`div`,{className:`font-mono text-xs break-all`,children:X.user_agent})]})]}),(X.old_value||X.new_value)&&(0,T.jsxs)(T.Fragment,{children:[(0,T.jsx)(b,{}),(0,T.jsxs)(`div`,{className:`space-y-3`,children:[(0,T.jsx)(`div`,{className:`text-sm font-medium`,children:`Change payload`}),X.old_value&&(0,T.jsxs)(`div`,{children:[(0,T.jsx)(`div`,{className:`text-xs text-muted-foreground mb-1`,children:`Before`}),(0,T.jsx)(`pre`,{className:`rounded-md bg-muted p-3 text-xs font-mono whitespace-pre-wrap max-h-64 overflow-auto`,children:M(X.old_value)})]}),X.new_value&&(0,T.jsxs)(`div`,{children:[(0,T.jsx)(`div`,{className:`text-xs text-muted-foreground mb-1`,children:`After`}),(0,T.jsx)(`pre`,{className:`rounded-md bg-muted p-3 text-xs font-mono whitespace-pre-wrap max-h-64 overflow-auto`,children:M(X.new_value)})]})]})]}),X.metadata&&(0,T.jsxs)(T.Fragment,{children:[(0,T.jsx)(b,{}),(0,T.jsxs)(`div`,{children:[(0,T.jsx)(`div`,{className:`text-sm font-medium mb-2`,children:`Metadata`}),(0,T.jsx)(`pre`,{className:`rounded-md bg-muted p-3 text-xs font-mono whitespace-pre-wrap max-h-48 overflow-auto`,children:M(X.metadata)})]})]})]})]})})]})}export{N as AuditLogPage};
@@ -1 +0,0 @@
1
- import{o as e}from"./rolldown-runtime-DAXXjFlN.js";import{r as t,y as n}from"./vendor-react-BKSb6vFP.js";import{l as r}from"./framework-BL3BtpKU.js";import{Cr as i,Gn as a,Ia as o,Jn as s,Kn as c,Ns as l,Oc as u,Qa as d,Qs as f,Wa as p,Xn as m,Xs as h,Yn as g,gi as _,hs as v,ln as y,mi as b,qn as x,uo as S}from"./ui-components-Y3D5-fgK.js";import{a as C,i as w,n as T,o as E,r as D,s as O,t as k}from"./plugin-view-DfJ5SCdu.js";var A=e(n(),1),j=t();function M({title:e,description:t,icon:n,actions:r,accentColor:i,sticky:a=!1,className:o,"data-testid":s}){return(0,j.jsxs)(`div`,{style:{"--page-header-accent":i||`hsl(var(--primary))`},className:u(`relative shrink-0 border-b bg-background z-10`,a&&`sticky top-0 bg-background/85 backdrop-blur supports-[backdrop-filter]:bg-background/75`,o),"data-testid":s??`page-header`,children:[(0,j.jsx)(`div`,{"aria-hidden":!0,className:`pointer-events-none absolute inset-x-0 top-0 h-[2px] opacity-80`,style:{background:`linear-gradient(90deg, transparent, var(--page-header-accent), transparent)`}}),(0,j.jsxs)(`div`,{className:`flex justify-between items-center gap-3 py-2.5 sm:py-3 px-4 sm:px-6`,children:[(0,j.jsxs)(`div`,{className:`flex items-center gap-3 min-w-0 flex-1`,children:[n&&(0,j.jsx)(`div`,{className:u(`shrink-0 inline-flex items-center justify-center rounded-lg`,`h-9 w-9 sm:h-10 sm:w-10`,`[&_svg]:h-[18px] [&_svg]:w-[18px] sm:[&_svg]:h-5 sm:[&_svg]:w-5`),style:{color:`var(--page-header-accent)`,background:`linear-gradient(135deg, color-mix(in srgb, var(--page-header-accent) 18%, transparent), color-mix(in srgb, var(--page-header-accent) 6%, transparent))`,boxShadow:`inset 0 0 0 1px color-mix(in srgb, var(--page-header-accent) 22%, transparent)`},children:n}),(0,j.jsxs)(`div`,{className:`min-w-0`,children:[(0,j.jsx)(`h1`,{className:`text-base sm:text-lg lg:text-xl font-semibold tracking-tight text-foreground truncate leading-tight`,children:e}),t&&(0,j.jsx)(`p`,{className:`text-xs sm:text-sm text-muted-foreground truncate hidden sm:block max-w-xl mt-0.5`,children:t})]})]}),r&&(0,j.jsx)(`div`,{className:`flex items-center gap-1.5 sm:gap-2 shrink-0`,children:r})]})]})}function N(e){return[{type:`grid`,icon:d,label:e(`console.objectView.viewTypeGrid`),description:e(`console.objectView.viewTypeGridDesc`)},{type:`kanban`,icon:b,label:e(`console.objectView.viewTypeKanban`),description:e(`console.objectView.viewTypeKanbanDesc`)},{type:`calendar`,icon:f,label:e(`console.objectView.viewTypeCalendar`),description:e(`console.objectView.viewTypeCalendarDesc`)},{type:`gallery`,icon:S,label:e(`console.objectView.viewTypeGallery`),description:e(`console.objectView.viewTypeGalleryDesc`)},{type:`timeline`,icon:v,label:e(`console.objectView.viewTypeTimeline`),description:e(`console.objectView.viewTypeTimelineDesc`)},{type:`gantt`,icon:_,label:e(`console.objectView.viewTypeGantt`),description:e(`console.objectView.viewTypeGanttDesc`)},{type:`map`,icon:o,label:e(`console.objectView.viewTypeMap`),description:e(`console.objectView.viewTypeMapDesc`)},{type:`chart`,icon:h,label:e(`console.objectView.viewTypeChart`),description:e(`console.objectView.viewTypeChartDesc`)},{type:`tree`,icon:p,label:e(`console.objectView.viewTypeTree`),description:e(`console.objectView.viewTypeTreeDesc`)}]}function P(e,t){for(let n=1;n<1e3;n++){let r=`${e} ${n}`;if(!t.has(r))return r}return e}var F={kanban:[{key:`groupByField`,i18nKey:`console.objectView.groupByField`,helpI18nKey:`console.objectView.groupByFieldHelp`,filter:e=>e.type===`select`||e.type===`boolean`,preferred:T}],calendar:[{key:`startDateField`,i18nKey:`console.objectView.startDateField`,helpI18nKey:`console.objectView.startDateFieldHelp`,filter:e=>e.type===`date`,preferred:D},{key:`titleField`,i18nKey:`console.objectView.titleField`,helpI18nKey:`console.objectView.titleFieldHelp`,filter:e=>e.type===`text`}],timeline:[{key:`startDateField`,i18nKey:`console.objectView.startDateField`,helpI18nKey:`console.objectView.timelineDateFieldHelp`,filter:e=>e.type===`date`,preferred:D},{key:`titleField`,i18nKey:`console.objectView.titleField`,helpI18nKey:`console.objectView.titleFieldHelp`,filter:e=>e.type===`text`}],gantt:[{key:`startDateField`,i18nKey:`console.objectView.startDateField`,helpI18nKey:`console.objectView.ganttStartDateFieldHelp`,filter:e=>e.type===`date`,preferred:D},{key:`endDateField`,i18nKey:`console.objectView.endDateField`,helpI18nKey:`console.objectView.ganttEndDateFieldHelp`,filter:e=>e.type===`date`,preferred:k},{key:`titleField`,i18nKey:`console.objectView.titleField`,helpI18nKey:`console.objectView.titleFieldHelp`,filter:e=>e.type===`text`}],gallery:[{key:`coverField`,i18nKey:`console.objectView.imageField`,helpI18nKey:`console.objectView.imageFieldHelp`,filter:e=>E(e)}],map:[{key:`latitudeField`,i18nKey:`console.objectView.latitudeField`,helpI18nKey:`console.objectView.latitudeFieldHelp`,filter:e=>e.type===`number`&&C(e,`latitude`)},{key:`longitudeField`,i18nKey:`console.objectView.longitudeField`,helpI18nKey:`console.objectView.longitudeFieldHelp`,filter:e=>e.type===`number`&&C(e,`longitude`)}],chart:[{key:`chartType`,i18nKey:`console.objectView.chartType`,helpI18nKey:`console.objectView.chartTypeHelp`,kind:`enum`,enumOptions:[{value:`bar`,i18nKey:`console.objectView.chartTypeBar`},{value:`line`,i18nKey:`console.objectView.chartTypeLine`},{value:`pie`,i18nKey:`console.objectView.chartTypePie`},{value:`area`,i18nKey:`console.objectView.chartTypeArea`},{value:`scatter`,i18nKey:`console.objectView.chartTypeScatter`}],defaultValue:`bar`},{key:`xAxisField`,i18nKey:`console.objectView.xAxisField`,helpI18nKey:`console.objectView.xAxisFieldHelp`,filter:e=>e.type===`select`||e.type===`boolean`||e.type===`date`||e.type===`text`,preferred:T},{key:`yAxisFields`,i18nKey:`console.objectView.yAxisField`,helpI18nKey:`console.objectView.yAxisFieldHelp`,filter:e=>e.type===`number`}],tree:[{key:`parentField`,i18nKey:`console.objectView.parentField`,helpI18nKey:`console.objectView.parentFieldHelp`,filter:e=>e.rawType===`tree`||e.rawType===`lookup`||e.rawType===`master_detail`}]};function I({open:e,onOpenChange:t,onCreate:n,existingLabels:o,availableTypes:d,objectDef:f}){let{t:p}=r(),h=(0,A.useMemo)(()=>N(p),[p]),_=(0,A.useMemo)(()=>d&&d.length>0?h.filter(e=>d.includes(e.type)):h,[h,d]),v=(0,A.useMemo)(()=>new Set(o??[]),[(o??[]).join(`\0`)]),b=(0,A.useMemo)(()=>f?w(f):[],[f]),[S,C]=(0,A.useState)(_[0]?.type??`grid`),[T,E]=(0,A.useState)(``),[D,k]=(0,A.useState)(!1),[M,I]=(0,A.useState)({});(0,A.useEffect)(()=>{e&&(C(_[0]?.type??`grid`),k(!1),I({}))},[e,_]),(0,A.useEffect)(()=>{if(!D){let e=_.find(e=>e.type===S);E(P(e?.label??`View`,v))}},[S,D,_,v]);let L=F[S]??[],R=e=>e.kind===`enum`?(e.enumOptions?.length??0)>0:!f||(e.filter?b.filter(e.filter):b).length>0,z=(0,A.useMemo)(()=>{let e={};return _.forEach(t=>{let n=(F[t.type]??[]).find(e=>!R(e));e[t.type]=n??null}),e},[_,b,f]),B=e=>M[`${S}.${e}`]??``,V=(e,t)=>I(n=>({...n,[`${S}.${e}`]:t})),H=T.trim(),U=H.length>0&&v.has(H),W=L.every(e=>B(e.key).length>0),G=H.length>0&&!U&&W;(0,A.useEffect)(()=>{L.length!==0&&L.forEach(e=>{if(B(e.key).length>0)return;if(e.kind===`enum`){e.defaultValue&&V(e.key,e.defaultValue);return}let t=e.filter?b.filter(e.filter):b;if(t.length===0)return;if(t.length===1){V(e.key,t[0].value);return}let n=O(t,e.preferred??[]);n&&V(e.key,n)})},[S,b]);let K=()=>{if(!G)return;let e={};L.forEach(t=>{let n=B(t.key);n&&(e[t.key]=t.key===`yAxisFields`?[n]:n)});let r={type:S,label:H};Object.keys(e).length>0&&(r[S]=e),n(r),t(!1)};return(0,j.jsx)(a,{open:e,onOpenChange:t,children:(0,j.jsxs)(c,{className:`sm:max-w-[560px]`,"data-testid":`create-view-dialog`,children:[(0,j.jsxs)(g,{children:[(0,j.jsx)(m,{children:p(`console.objectView.createView`)}),(0,j.jsx)(x,{children:p(`console.objectView.createViewDesc`)})]}),(0,j.jsx)(`div`,{className:`grid grid-cols-4 gap-2 py-2`,"data-testid":`create-view-type-grid`,children:_.map(({type:e,label:t,description:n,icon:r})=>{let i=e===S,a=z[e],o=!!a,s=o?p(`console.objectView.viewTypeUnavailable`,{field:p(a.i18nKey)}):void 0;return(0,j.jsxs)(`button`,{type:`button`,"data-testid":`create-view-type-${e}`,"aria-pressed":i,"aria-disabled":o,disabled:o,title:s,onClick:()=>{o||C(e)},className:u(`group flex flex-col items-start gap-1 rounded-lg border bg-background p-3 text-left transition-colors`,!o&&`hover:border-primary/60 hover:bg-accent/40`,i&&!o?`border-primary ring-2 ring-primary/30 bg-accent/40`:`border-border`,o&&`opacity-50 cursor-not-allowed`),children:[(0,j.jsx)(r,{className:u(`h-5 w-5`,i&&!o?`text-primary`:`text-muted-foreground group-hover:text-foreground`)}),(0,j.jsx)(`div`,{className:`text-xs font-medium leading-tight`,children:t}),(0,j.jsx)(`div`,{className:`text-[10px] leading-tight text-muted-foreground line-clamp-2`,children:o?p(`console.objectView.viewTypeUnavailableShort`):n})]},e)})}),L.length>0&&(0,j.jsx)(`div`,{className:`space-y-3 rounded-md border border-dashed bg-muted/30 p-3`,"data-testid":`create-view-required-fields`,children:L.map(e=>{let t=B(e.key),n=e.kind===`enum`,r=n?[]:e.filter?b.filter(e.filter):b,i=!n&&b.length>0&&r.length===0;return(0,j.jsxs)(`div`,{className:`space-y-1`,children:[(0,j.jsxs)(`label`,{htmlFor:`create-view-required-${e.key}`,className:`text-xs font-medium`,children:[p(e.i18nKey),(0,j.jsx)(`span`,{className:`ml-1 text-destructive`,children:`*`})]}),(0,j.jsxs)(`select`,{id:`create-view-required-${e.key}`,"data-testid":`create-view-required-${e.key}`,value:t,onChange:t=>V(e.key,t.target.value),disabled:i,className:u(`h-9 w-full rounded-md border bg-background px-2 text-xs`,`border-input`),children:[(0,j.jsx)(`option`,{value:``,children:p(n?`console.objectView.selectOption`:`console.objectView.selectField`)}),n?e.enumOptions.map(e=>(0,j.jsx)(`option`,{value:e.value,children:p(e.i18nKey)},e.value)):r.map(e=>(0,j.jsx)(`option`,{value:e.value,children:e.label},e.value))]}),e.helpI18nKey&&!i&&(0,j.jsx)(`p`,{className:`text-[11px] text-muted-foreground`,children:p(e.helpI18nKey)}),i&&(0,j.jsxs)(`p`,{className:`flex items-center gap-1 text-[11px] text-destructive`,"data-testid":`create-view-error-no-field-${e.key}`,children:[(0,j.jsx)(l,{className:`h-3 w-3`}),p(`console.objectView.noEligibleFieldForType`)]})]},e.key)})}),(0,j.jsxs)(`div`,{className:`space-y-1`,children:[(0,j.jsxs)(`label`,{htmlFor:`create-view-name-input`,className:`text-xs font-medium`,children:[p(`console.objectView.title`),(0,j.jsx)(`span`,{className:`ml-1 text-destructive`,children:`*`})]}),(0,j.jsx)(y,{id:`create-view-name-input`,"data-testid":`create-view-name-input`,autoFocus:!0,value:T,onChange:e=>{E(e.target.value),k(!0)},onKeyDown:e=>{e.key===`Enter`&&G&&K()},placeholder:p(`console.objectView.newView`),className:`h-9`}),U&&(0,j.jsx)(`p`,{className:`text-[11px] text-destructive`,"data-testid":`create-view-error-duplicate`,children:p(`console.objectView.duplicateViewName`)})]}),(0,j.jsxs)(s,{className:`mt-2`,children:[(0,j.jsx)(i,{type:`button`,variant:`outline`,onClick:()=>t(!1),"data-testid":`create-view-cancel`,children:p(`console.objectView.cancel`)}),(0,j.jsx)(i,{type:`button`,disabled:!G,onClick:K,"data-testid":`create-view-submit`,children:p(`console.objectView.create`)})]})]})})}export{M as n,I as t};
@@ -1 +0,0 @@
1
- import{o as e,r as t}from"./rolldown-runtime-DAXXjFlN.js";import{m as n,r,y as i}from"./vendor-react-BKSb6vFP.js";import{E as a,L as o,R as s,l as c}from"./framework-BL3BtpKU.js";import{$a as l,Cr as u,Gn as d,Jn as f,K as p,Kn as m,Pc as h,X as g,Xn as _,Yn as v,q as y,qn as b}from"./ui-components-Y3D5-fgK.js";import{r as x}from"./vendor-ui-utils-D-WJ115h.js";import"./AdapterProvider-CSP_T07G.js";import{n as S}from"./plugin-form-6ug8Woph.js";import"./MetadataProvider-DqPZ6rV2.js";import{r as C}from"./ExpressionProvider-CHaGm5wf.js";import{t as w}from"./preferLocal-CKqyhTP9.js";import{t as T}from"./utils-Bxty7IIa.js";import{n as E,t as D}from"./MetadataInspector-Bqe7rY0S.js";import{n as O}from"./skeletons-Bf9TL3pG.js";import{n as k}from"./plugin-dashboard-CaQs1s4M.js";import{t as A}from"./useOpenRecordList-C75NAaDm.js";var j=t({DashboardView:()=>P}),M=e(i(),1),N=r();function P({dataSource:e}){let t=A(),{dashboardName:r}=n(),{showDebug:i}=E(),j=o(),{t:P}=c(),{dashboardLabel:F,dashboardDescription:I}=h(),[L,R]=(0,M.useState)(!0),[z,B]=(0,M.useState)(null),V=(0,M.useCallback)(e=>{B(t=>(t&&t.resolve(e),null))},[]),H=(0,M.useCallback)(e=>new Promise(t=>{let n;if(typeof e==`string`){let t=e.match(/^(create|new|add|edit|update)_(.+)$/);if(t){let e=t[1];n={objectName:t[2],mode:e===`edit`||e===`update`?`edit`:`create`}}else n={objectName:e,mode:`create`}}else n=e;B({schema:n,resolve:t})}),[]),U=(0,M.useMemo)(()=>({export_dashboard_pdf:async()=>{x.info(P(`dashboardActions.pdfPreparing`));try{return window.print(),{success:!0}}catch(e){return x.error(P(`dashboardActions.exportFailed`,{message:e?.message||String(e)})),{success:!1,error:e?.message||String(e)}}},forecast_dashboard:async()=>(x.info(P(`dashboardActions.forecastSoon`)),{success:!0})}),[P]);(0,M.useEffect)(()=>{R(!0),queueMicrotask(()=>R(!1))},[r]);let{dashboards:W,objects:G}=s(),{app:K}=C(),q=w(W,r,K?._packageId),J=(0,M.useMemo)(()=>new Set((G||[]).map(e=>e?.name).filter(Boolean)),[G]),Y=(0,M.useMemo)(()=>{if(!q||J.size===0)return q;let e=q.widgets;if(!Array.isArray(e)||e.length===0)return q;let t=e.filter(e=>{let t=e?.requiresObject??e?.object;return!t||J.has(t)});return t.length===e.length?q:{...q,widgets:t}},[q,J]);return L?(0,N.jsx)(O,{}):q?(0,N.jsxs)(`div`,{className:`flex flex-col h-full overflow-hidden bg-background`,children:[(0,N.jsx)(`div`,{className:`flex flex-col sm:flex-row justify-between sm:items-center gap-3 sm:gap-4 p-4 sm:p-6 border-b shrink-0`,children:(0,N.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(()=>{let e=T((Y||q).title,P),t=T(q.label,P),n=F({name:q.name,label:t});return(0,N.jsx)(`h1`,{className:`text-lg sm:text-xl md:text-2xl font-bold tracking-tight truncate`,children:e||n||q.name})})(),(()=>{let e=(Y||q).description??q.description,t=I({name:q.name,description:T(e,P)});return t?(0,N.jsx)(`p`,{className:`text-sm text-muted-foreground mt-1 line-clamp-2`,children:t}):null})()]})}),(0,N.jsxs)(`div`,{className:`flex-1 overflow-hidden flex flex-col sm:flex-row relative`,children:[(0,N.jsx)(`div`,{className:`flex-1 min-w-0 overflow-auto p-2 sm:p-4 md:p-6`,children:(0,N.jsx)(a,{value:{openRecordList:t},children:(0,N.jsx)(k,{schema:Y,dataSource:e,modalHandler:H,scriptHandlers:U,hideHeaderText:!0})})}),(0,N.jsx)(D,{open:i,sections:[{title:`Dashboard Configuration`,data:Y}]})]}),z&&z.schema?.objectName?(0,N.jsx)(S,{schema:{type:`object-form`,formType:`modal`,objectName:z.schema.objectName,mode:z.schema.mode||`create`,recordId:z.schema.recordId,title:z.schema.title,description:z.schema.description,fields:z.schema.fields,open:!0,onOpenChange:e=>{e||V({success:!1})},onSuccess:e=>{V({success:!0,reload:!0,data:e})},onCancel:()=>{V({success:!1})},showSubmit:!0,showCancel:!0},dataSource:j}):z?(0,N.jsx)(d,{open:!0,onOpenChange:e=>{e||V({success:!1})},children:(0,N.jsxs)(m,{children:[(0,N.jsxs)(v,{children:[(0,N.jsx)(_,{children:z.schema?.title||P(`actionDialog.defaultActionTitle`)}),z.schema?.description&&(0,N.jsx)(b,{children:z.schema.description})]}),(0,N.jsxs)(f,{children:[(0,N.jsx)(u,{variant:`outline`,onClick:()=>V({success:!1}),children:P(`actionDialog.cancel`)}),(0,N.jsx)(u,{onClick:()=>V({success:!0}),children:P(`actionDialog.ok`)})]})]})}):null]}):(0,N.jsx)(`div`,{className:`h-full flex items-center justify-center p-8`,children:(0,N.jsxs)(p,{children:[(0,N.jsx)(`div`,{className:`mx-auto mb-4 flex h-12 w-12 items-center justify-center rounded-full bg-muted`,children:(0,N.jsx)(l,{className:`h-6 w-6 text-muted-foreground`})}),(0,N.jsx)(g,{children:P(`empty.dashboardNotFound`)}),(0,N.jsx)(y,{children:P(`empty.dashboardNotFoundDescription`,{name:r})})]})})}export{j as t};
@@ -1 +0,0 @@
1
- import{o as e}from"./rolldown-runtime-DAXXjFlN.js";import{r as t,y as n}from"./vendor-react-BKSb6vFP.js";import{$ as r,Wt as i}from"./framework-BL3BtpKU.js";var a=e(n(),1),o=t(),s=(0,a.createContext)(null);function c({children:e,user:t={},app:n={},data:c={},features:l={}}){let u=(0,a.useMemo)(()=>({user:t,app:n,data:c,features:l,evaluator:new i({current_user:t,user:t,ctx:{user:t},app:n,data:c,features:l})}),[t,n,c,l]),d=(0,a.useMemo)(()=>({current_user:t,user:t,ctx:{user:t},app:n,data:c,features:l}),[t,n,c,l]);return(0,o.jsx)(s.Provider,{value:u,children:(0,o.jsx)(r,{scope:d,children:e})})}function l(){let e=(0,a.useContext)(s);if(!e){let e={user:{},app:{},data:{},features:{}},t={current_user:{},ctx:{user:{}},...e};return{...e,evaluator:new i(t)}}return e}function u(e,t){if(e==null||e===!0||e===`true`)return!0;if(e===!1||e===`false`)return!1;if(typeof e==`string`&&e.includes("${"))try{return t.evaluateCondition(e)}catch{return!0}return!0}export{u as n,l as r,c as t};
@@ -1 +0,0 @@
1
- import{o as e}from"./rolldown-runtime-DAXXjFlN.js";import{r as t,y as n}from"./vendor-react-BKSb6vFP.js";import{L as r}from"./framework-BL3BtpKU.js";import{$t as i,As as a,Bt as o,Cr as s,Gt as c,Ha as l,Ht as u,Kt as d,Mr as f,Ns as p,Ut as m,Wi as h,Wt as g,_t as _,ar as v,bt as y,ea as b,gt as x,hs as S,ht as C,ir as w,ln as T,lt as E,mt as D,nr as O,pn as k,rr as A,sr as j,tr as M,vt as N,xs as P,yt as F}from"./ui-components-Y3D5-fgK.js";import"./src-CQwyy7m_.js";var I=e(n(),1),L=t();function R({status:e}){let t={success:{icon:a,cls:`text-emerald-600 border-emerald-300`},completed:{icon:a,cls:`text-emerald-600 border-emerald-300`},failed:{icon:P,cls:`text-red-600 border-red-300`},error:{icon:P,cls:`text-red-600 border-red-300`},running:{icon:l,cls:`text-blue-600 border-blue-300 animate-pulse`},pending:{icon:S,cls:`text-amber-600 border-amber-300`},skipped:{icon:p,cls:`text-muted-foreground`}}[e]??{icon:p,cls:`text-muted-foreground`},n=t.icon;return(0,L.jsxs)(j,{variant:`outline`,className:`text-[10px] font-mono inline-flex items-center gap-1 ${t.cls}`,children:[(0,L.jsx)(n,{className:`h-3 w-3`}),e]})}function z(e){if(!e)return`—`;try{return new Date(e).toLocaleString()}catch{return e}}function B(e,t){switch(t){case`number`:{if(e===``)return;let t=Number(e);return Number.isNaN(t)?e:t}case`boolean`:return e===`true`;case`object`:case`list`:case`array`:if(e.trim()===``)return;try{return JSON.parse(e)}catch{return e}default:return e}}function V({data:e}){return(0,L.jsx)(`pre`,{className:`rounded border bg-muted/30 p-2 text-xs font-mono overflow-auto whitespace-pre-wrap break-all max-h-96`,children:JSON.stringify(e,null,2)})}function H(){let e=r()?.getClient?.(),[t,n]=(0,I.useState)([]),[i,a]=(0,I.useState)(!0),[c,l]=(0,I.useState)(null),[u,d]=(0,I.useState)(``),[p,m]=(0,I.useState)(0),g=(0,I.useCallback)(async()=>{if(!e?.meta?.getItems){l(`meta.getItems is not available on this client`),a(!1);return}a(!0),l(null);try{let t=await e.meta.getItems(`flow`),r=(Array.isArray(t)?t:Array.isArray(t?.items)?t.items:Array.isArray(t?.value)?t.value:[]).map(e=>({name:e?.spec?.name??e?.name,label:e?.spec?.label,spec:e?.spec??e,updatedAt:e?.updatedAt??e?.updated_at})).filter(e=>e.name);n(r),!u&&r.length>0&&d(r[0].name)}catch(e){l(e?.message??String(e))}finally{a(!1)}},[e,u]);(0,I.useEffect)(()=>{g()},[g]);let _=(0,I.useMemo)(()=>t.find(e=>e.name===u)??null,[t,u]);return(0,L.jsxs)(`div`,{className:`flex flex-col gap-4 p-4 sm:p-6`,children:[(0,L.jsxs)(`div`,{className:`min-w-0`,children:[(0,L.jsxs)(`h1`,{className:`text-xl sm:text-2xl font-bold tracking-tight flex items-center gap-2`,children:[(0,L.jsx)(f,{className:`h-5 w-5`}),`Flow Runs`]}),(0,L.jsx)(`p`,{className:`text-sm text-muted-foreground mt-1`,children:`Pick a flow, trigger a test run with sample inputs, and inspect recent run history`})]}),(0,L.jsxs)(M,{children:[(0,L.jsx)(w,{className:`pb-3`,children:(0,L.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3`,children:[(0,L.jsxs)(`div`,{children:[(0,L.jsx)(v,{className:`text-base`,children:`Flow`}),(0,L.jsx)(A,{children:`Select a flow definition to test`})]}),(0,L.jsxs)(s,{variant:`outline`,size:`sm`,onClick:g,disabled:i,children:[(0,L.jsx)(h,{className:`h-3.5 w-3.5 mr-2 ${i?`animate-spin`:``}`}),`Refresh`]})]})}),(0,L.jsxs)(O,{children:[i&&(0,L.jsx)(o,{className:`h-9 w-72`}),c&&(0,L.jsx)(`p`,{className:`text-sm text-red-500 font-mono break-all`,children:c}),!i&&!c&&t.length===0&&(0,L.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`No flow definitions found.`}),!i&&!c&&t.length>0&&(0,L.jsx)(`select`,{value:u,onChange:e=>d(e.target.value),className:`flex h-9 w-full max-w-md rounded-md border border-input bg-transparent px-3 py-1 text-sm shadow-sm focus:outline-none focus:ring-1 focus:ring-ring`,children:t.map(e=>(0,L.jsx)(`option`,{value:e.name,children:e.label?`${e.label} (${e.name})`:e.name},e.name))})]})]}),_&&(0,L.jsxs)(`div`,{className:`grid gap-4 lg:grid-cols-2`,children:[(0,L.jsx)(U,{client:e,flow:_.spec,onExecuted:()=>m(e=>e+1)}),(0,L.jsx)(W,{client:e,flowName:_.name,refreshKey:p})]})]})}function U({client:e,flow:t,onExecuted:n}){let r=(0,I.useMemo)(()=>(t?.variables??[]).filter(e=>e?.isInput),[t]),[i,o]=(0,I.useState)({}),[c,u]=(0,I.useState)(!1),[d,f]=(0,I.useState)(null),[p,m]=(0,I.useState)(null);(0,I.useEffect)(()=>{o({}),f(null),m(null)},[t?.name]);let h=(e,t)=>o(n=>({...n,[e]:t}));return(0,L.jsxs)(M,{children:[(0,L.jsxs)(w,{className:`pb-3`,children:[(0,L.jsx)(v,{className:`text-base`,children:`Test Run`}),(0,L.jsx)(A,{children:`Provide input values and invoke the flow`})]}),(0,L.jsxs)(O,{className:`space-y-3`,children:[r.length===0&&(0,L.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`This flow declares no input variables. Click Run to invoke with no parameters.`}),r.map(e=>(0,L.jsxs)(`div`,{className:`grid gap-1.5`,children:[(0,L.jsxs)(k,{htmlFor:`var-${e.name}`,className:`flex items-center gap-2`,children:[(0,L.jsx)(`span`,{className:`font-mono text-xs`,children:e.name}),(0,L.jsx)(j,{variant:`outline`,className:`text-[10px] font-mono`,children:e.type})]}),e.type===`boolean`?(0,L.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,L.jsx)(y,{id:`var-${e.name}`,checked:i[e.name]===`true`,onCheckedChange:t=>h(e.name,t?`true`:`false`)}),(0,L.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:i[e.name]===`true`?`true`:`false`})]}):e.type===`object`||e.type===`list`||e.type===`array`?(0,L.jsx)(E,{id:`var-${e.name}`,placeholder:`JSON ${e.type}`,value:i[e.name]??``,onChange:t=>h(e.name,t.target.value),className:`font-mono text-xs min-h-[80px]`}):(0,L.jsx)(T,{id:`var-${e.name}`,type:e.type===`number`?`number`:`text`,value:i[e.name]??``,onChange:t=>h(e.name,t.target.value)})]},e.name)),(0,L.jsx)(`div`,{className:`pt-1`,children:(0,L.jsxs)(s,{onClick:async()=>{if(!e?.automation?.execute){m(`automation.execute is not available on this client`);return}u(!0),m(null),f(null);try{let a={};for(let e of r){let t=i[e.name];t!==void 0&&(a[e.name]=B(t,e.type))}let o=await e.automation.execute(t.name,{params:a});f(o),n?.()}catch(e){m(e?.message??String(e))}finally{u(!1)}},disabled:c,size:`sm`,children:[c?(0,L.jsx)(l,{className:`h-3.5 w-3.5 mr-2 animate-spin`}):(0,L.jsx)(b,{className:`h-3.5 w-3.5 mr-2`}),c?`Running…`:`Run Flow`]})}),(d||p)&&(0,L.jsxs)(`div`,{className:`pt-2 border-t mt-2 space-y-2`,children:[(0,L.jsxs)(`div`,{className:`flex items-center gap-2 text-sm font-medium`,children:[p||d?.success===!1?(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(P,{className:`h-4 w-4 text-red-500`}),` Failed`]}):(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(a,{className:`h-4 w-4 text-emerald-500`}),` Result`]}),typeof d?.durationMs==`number`&&(0,L.jsxs)(j,{variant:`secondary`,className:`text-[10px] font-mono`,children:[d.durationMs,` ms`]})]}),p&&(0,L.jsx)(`p`,{className:`text-sm text-red-500 font-mono break-all`,children:p}),d&&(0,L.jsx)(V,{data:d})]})]})]})}function W({client:e,flowName:t,refreshKey:n}){let[r,a]=(0,I.useState)([]),[f,p]=(0,I.useState)(!0),[y,b]=(0,I.useState)(null),[S,T]=(0,I.useState)(null),[E,k]=(0,I.useState)(null),[P,B]=(0,I.useState)(!1),[H,U]=(0,I.useState)(null),W=(0,I.useCallback)(async()=>{if(!e?.automation?.listRuns){b(`automation.listRuns is not available on this client`),p(!1);return}p(!0),b(null);try{let n=await e.automation.listRuns(t,{limit:20}),r=Array.isArray(n)?n:n?.items??n?.runs??[];a(r)}catch(e){b(e?.message??String(e))}finally{p(!1)}},[e,t]);(0,I.useEffect)(()=>{W()},[W,n]);let G=async n=>{T(n),k(null),U(null),B(!0);try{let r=await e.automation.getRun(t,n);k(r?.run??r)}catch(e){U(e?.message??String(e))}finally{B(!1)}};return(0,L.jsxs)(L.Fragment,{children:[(0,L.jsxs)(M,{children:[(0,L.jsx)(w,{className:`pb-3`,children:(0,L.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,L.jsxs)(`div`,{children:[(0,L.jsx)(v,{className:`text-base`,children:`Recent Runs`}),(0,L.jsx)(A,{className:`font-mono text-xs`,children:t})]}),(0,L.jsxs)(s,{variant:`outline`,size:`sm`,onClick:W,disabled:f,children:[f?(0,L.jsx)(l,{className:`h-3.5 w-3.5 mr-2 animate-spin`}):(0,L.jsx)(h,{className:`h-3.5 w-3.5 mr-2`}),`Refresh`]})]})}),(0,L.jsxs)(O,{children:[f&&(0,L.jsxs)(`div`,{className:`space-y-2`,children:[(0,L.jsx)(o,{className:`h-8 w-full`}),(0,L.jsx)(o,{className:`h-8 w-full`}),(0,L.jsx)(o,{className:`h-8 w-full`})]}),!f&&y&&(0,L.jsx)(`p`,{className:`text-sm text-red-500 font-mono break-all`,children:y}),!f&&!y&&r.length===0&&(0,L.jsx)(`p`,{className:`text-sm text-muted-foreground py-6 text-center`,children:`No runs yet. Use the Test Run panel to invoke this flow.`}),!f&&!y&&r.length>0&&(0,L.jsxs)(D,{children:[(0,L.jsx)(N,{children:(0,L.jsxs)(F,{children:[(0,L.jsx)(_,{children:`Run`}),(0,L.jsx)(_,{children:`Status`}),(0,L.jsx)(_,{children:`Started`}),(0,L.jsx)(_,{className:`text-right`,children:`Duration`})]})}),(0,L.jsx)(C,{children:r.map(e=>(0,L.jsxs)(F,{className:`cursor-pointer`,onClick:()=>G(e.id),children:[(0,L.jsxs)(x,{className:`font-mono text-xs`,children:[e.id.slice(0,12),`…`]}),(0,L.jsx)(x,{children:(0,L.jsx)(R,{status:e.status})}),(0,L.jsx)(x,{className:`text-xs text-muted-foreground`,children:z(e.startedAt)}),(0,L.jsx)(x,{className:`text-right font-mono text-xs`,children:typeof e.durationMs==`number`?`${e.durationMs} ms`:`—`})]},e.id))})]})]})]}),(0,L.jsx)(u,{open:!!S,onOpenChange:e=>{e||(T(null),k(null))},children:(0,L.jsxs)(m,{side:`right`,className:`w-full sm:max-w-2xl p-0 flex flex-col`,children:[(0,L.jsxs)(c,{className:`p-4 border-b`,children:[(0,L.jsxs)(d,{className:`font-mono text-sm break-all`,children:[`Run `,S]}),(0,L.jsx)(g,{children:E&&(0,L.jsxs)(`span`,{className:`inline-flex items-center gap-2`,children:[(0,L.jsx)(R,{status:E.status}),typeof E.durationMs==`number`&&(0,L.jsxs)(j,{variant:`secondary`,className:`text-[10px] font-mono`,children:[E.durationMs,` ms`]}),(0,L.jsx)(`span`,{className:`text-xs`,children:z(E.startedAt)})]})})]}),(0,L.jsxs)(i,{className:`flex-1 p-4`,children:[P&&(0,L.jsxs)(`div`,{className:`space-y-2`,children:[(0,L.jsx)(o,{className:`h-16 w-full`}),(0,L.jsx)(o,{className:`h-16 w-full`}),(0,L.jsx)(o,{className:`h-16 w-full`})]}),H&&(0,L.jsx)(`p`,{className:`text-sm text-red-500 font-mono break-all`,children:H}),!P&&E&&(0,L.jsx)(`div`,{className:`space-y-3`,children:Array.isArray(E.steps)&&E.steps.length>0?E.steps.map((e,t)=>(0,L.jsxs)(`div`,{className:`rounded-md border p-3 space-y-2`,children:[(0,L.jsxs)(`div`,{className:`flex items-center gap-2 flex-wrap`,children:[(0,L.jsxs)(`span`,{className:`text-muted-foreground font-mono text-xs`,children:[`#`,t+1]}),(0,L.jsx)(`span`,{className:`font-mono text-sm font-medium`,children:e.nodeLabel||e.nodeId}),e.nodeType&&(0,L.jsx)(j,{variant:`outline`,className:`text-[10px] font-mono`,children:e.nodeType}),(0,L.jsx)(R,{status:e.status}),typeof e.durationMs==`number`&&(0,L.jsxs)(j,{variant:`secondary`,className:`text-[10px] font-mono ml-auto`,children:[e.durationMs,` ms`]})]}),e.input!==void 0&&(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`div`,{className:`text-[10px] uppercase text-muted-foreground mb-1`,children:`Input`}),(0,L.jsx)(V,{data:e.input})]}),e.output!==void 0&&(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`div`,{className:`text-[10px] uppercase text-muted-foreground mb-1`,children:`Output`}),(0,L.jsx)(V,{data:e.output})]}),e.error&&(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`div`,{className:`text-[10px] uppercase text-red-500 mb-1`,children:`Error`}),(0,L.jsx)(V,{data:e.error})]})]},`${e.nodeId}-${t}`)):(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`div`,{className:`text-[10px] uppercase text-muted-foreground mb-1`,children:`Run`}),(0,L.jsx)(V,{data:E})]})})]})]})})]})}export{H as FlowRunsPage};
@@ -1 +0,0 @@
1
- import{o as e}from"./rolldown-runtime-DAXXjFlN.js";import{f as t,h as n,r,y as i}from"./vendor-react-BKSb6vFP.js";import{L as a,R as o,Y as s,l as c,q as l}from"./framework-BL3BtpKU.js";import{K as u,U as d,X as f,q as p,rs as m}from"./ui-components-Y3D5-fgK.js";import"./MetadataProvider-DqPZ6rV2.js";import{t as h}from"./RecordDetailView-w6IBQ1cm.js";import{l as g}from"./plugins-views-CoobEMX4.js";var _=e(i(),1),v=`uf_`;function y(e){let t={};return e.forEach((e,n)=>{if(n.startsWith(v)&&e!==``){let r=n.slice(3);t[r]=e.split(`,`).map(e=>{try{return decodeURIComponent(e)}catch{return e}})}}),Object.keys(t).length>0?t:void 0}function b(e,t){let n=new URLSearchParams(e);for(let[e,r]of Object.entries(t)){let t=v+e;r&&r.length>0?n.set(t,r.map(e=>encodeURIComponent(String(e))).join(`,`)):n.delete(t)}return n}var x=r();function S(e){return Array.isArray(e?.columns)&&e.columns.length>0}function C(e,t){let n=e?.listViews||e?.list_views||{},r=(t?[n[`${e?.name}.${t}`],n[t],...t==="default"||t===`list`?[e?.list]:[]]:[e?.list,...Object.values(n)]).filter(Boolean);return r.find(S)??r[0]}var w=new Set([`id`,`created_at`,`createdAt`,`updated_at`,`updatedAt`,`deleted_at`,`deletedAt`,`created_by`,`createdBy`,`updated_by`,`updatedBy`,`_version`,`_rev`]);function T(e){let t=e?.highlightFields;if(Array.isArray(t)&&t.length>0)return t.filter(t=>e.fields?.[t]);let n=e?.fields;return n&&typeof n==`object`?Object.entries(n).filter(([e,t])=>t&&!t.hidden&&!w.has(e)).map(([e])=>e).slice(0,6):[]}function E(e,t){let n=e?.fields;if(!(!n||typeof n!=`object`))return Object.entries(n).find(([e,n])=>n&&!n.hidden&&!w.has(e)&&t(e,n))?.[0]}var D=new Set([`select`,`multiselect`,`radio`,`enum`,`boolean`]),O=new Set([`date`,`datetime`,`time`]),k=new Set([`image`,`file`,`attachment`,`avatar`,`photo`]);function A(e){let t=E(e,(e,t)=>D.has(t.type))??E(e,e=>/status|stage|state|priority|category|kind/i.test(e));return t?{groupField:t,groupByField:t}:void 0}function j(e){return E(e,(e,t)=>O.has(t.type))??E(e,e=>/date|due|start|end|deadline|schedule/i.test(e))}function M(e){let t=j(e);return t?{startDateField:t}:void 0}function N(e){let t=E(e,(e,t)=>k.has(t.type));return t?{coverField:t}:void 0}var P=new Set([`location`,`geo`,`geolocation`,`geopoint`,`point`]);function F(e){let t=E(e,(e,t)=>O.has(t.type)&&/start|begin|kickoff/i.test(e))??E(e,(e,t)=>O.has(t.type));if(!t)return;let n=E(e,(e,n)=>O.has(n.type)&&e!==t&&/end|due|finish|deadline|close/i.test(e))??E(e,(e,n)=>O.has(n.type)&&e!==t);if(!n)return;let r=E(e,(e,t)=>(t.type===`number`||t.type===`percent`)&&/progress|percent|complete/i.test(e));return{startDateField:t,endDateField:n,...r?{progressField:r}:{}}}function I(e){let t=E(e,(e,t)=>P.has(t.type))??E(e,e=>/location|address|geo|coords?|place|venue/i.test(e));return t?{locationField:t}:void 0}function L({page:e,className:r,onConfigChange:i,reserveEditAffordance:v}){let{t:w}=c(),{objects:E}=o(),D=a(),O=t(),[k,j]=n(),[P]=_.useState(()=>y(new URLSearchParams(window.location.search))),L=_.useCallback(e=>{j(t=>b(t,e),{replace:!0})},[j]),R=e?.interfaceConfig||{},z=_.useMemo(()=>(E||[]).find(e=>e.name===R.source),[E,R.source]),B=_.useMemo(()=>C(z,R.sourceView),[z,R.sourceView]),V=R.recordAction===`page`||R.recordAction===`modal`||R.recordAction===`none`?R.recordAction:`drawer`,H=_.useCallback(e=>`/apps/${window.location.pathname.split(`/`)[2]||``}/${R.source}/record/${encodeURIComponent(String(e))}`,[R.source]),U=l({navigation:{mode:V===`none`?`none`:V},objectName:R.source,onNavigate:e=>O(H(e))}),W=k.get(`recordId`),G=_.useCallback((e,t)=>{if(V===`none`)return;let n=e?.id??e?._id;if(t&&(t.metaKey||t.ctrlKey||t.button===1)&&n!=null){window.open(H(n),`_blank`);return}if((V===`drawer`||V===`modal`)&&n!=null){j(e=>{let t=new URLSearchParams(e);return t.set(`recordId`,String(n)),t});return}U.handleClick(e,t)},[V,H,U,j]),ee=_.useCallback(()=>{j(e=>{let t=new URLSearchParams(e);return t.delete(`recordId`),t})},[j]);_.useEffect(()=>{W&&!U.isOpen?U.open({id:W}):!W&&U.isOpen&&U.close()},[W]);let K=z?.name,q=!!B&&!S(B),J=B?.name??(R.sourceView?`${R.source}.${R.sourceView}`:void 0),[Y,X]=_.useState(null);_.useEffect(()=>{let e=!1;if(X(null),!(!K||!R.source||!q||!J))return(async()=>{try{let t=D,n=null;typeof t?.listViewOverrides==`function`&&(n=(await t.listViewOverrides(R.source))?.[J]??null),!S(n)&&typeof t?.getView==`function`&&(n=await t.getView(R.source,J)),!e&&n&&typeof n==`object`&&X(n)}catch{}})(),()=>{e=!0}},[K,R.source,R.sourceView,q,J,D]);let Z=_.useMemo(()=>Y?{...B,...Y}:B,[B,Y]),te=JSON.stringify(Z??null),Q=_.useMemo(()=>{if(!z)return;let e=Z||{},t=R.appearance??e.appearance,n=t?.allowedVisualizations||[],r=new Set(n),i=R.userActions||{},a=e.kanban??(r.has(`kanban`)?A(z):void 0),o=e.calendar??(r.has(`calendar`)?M(z):void 0),s=e.timeline??(r.has(`timeline`)?M(z):void 0),c=e.gallery??(r.has(`gallery`)?N(z):void 0),l=e.gantt??(r.has(`gantt`)?F(z):void 0),u=e.options?.map??(r.has(`map`)?I(z):void 0),d=[...Array.isArray(e.filter)?e.filter:[],...Array.isArray(R.filterBy)?R.filterBy:[]],f=S(R)?R.columns:S(e)?e.columns:T(z),p=Array.isArray(R.sort)&&R.sort.length?R.sort:e.sort;return{type:`list-view`,objectName:z.name,viewType:n[0]??e.type??`grid`,fields:f,...d.length?{filters:d}:{},...p?.length?{sort:p}:{},grouping:e.grouping,rowColor:e.rowColor,pagination:e.pagination,searchableFields:e.searchableFields,emptyState:e.emptyState,kanban:a,calendar:o,gallery:c,timeline:s,gantt:l,...u||e.options?{options:{...e.options??{},...u?{map:u}:{}}}:{},userFilters:R.userFilters??e.userFilters,appearance:t,showViewSwitcher:n.length>1,showRecordCount:R.showRecordCount,addRecord:R.addRecord,showSearch:i.search!==!1,showSort:i.sort!==!1,showFilters:i.filter===!0,showDensity:i.rowHeight===!0,showHideFields:!1,showGroup:!1,showColor:!1,allowExport:!1,inlineEdit:i.editInline===!0}},[K,te,R]);if(!z||!Q)return(0,x.jsx)(`div`,{className:`h-full flex items-center justify-center p-8`,children:(0,x.jsxs)(u,{children:[(0,x.jsx)(`div`,{className:`mx-auto mb-4 flex h-12 w-12 items-center justify-center rounded-full bg-muted`,children:(0,x.jsx)(m,{className:`h-6 w-6 text-muted-foreground`})}),(0,x.jsx)(f,{children:w(`empty.objectNotFound`,{defaultValue:`Source object not found`})}),(0,x.jsx)(p,{children:w(`empty.interfacePageSourceMissing`,{defaultValue:`This interface page references "{{name}}", which is not available.`,name:R.source||`?`})})]})});let $=Array.isArray(R.buttons)&&R.buttons.length?R.buttons.map(e=>(z.actions||[]).find(t=>t?.name===e)).filter(Boolean).map(e=>({...e,locations:[`list_toolbar`]})):[];return(0,x.jsxs)(`div`,{className:r??`h-full flex flex-col`,"data-testid":`interface-list-page`,children:[(0,x.jsxs)(`div`,{className:`pl-4 pt-4 pb-2 shrink-0 flex items-start justify-between gap-3 ${v?`pr-12`:`pr-4`}`,children:[(0,x.jsxs)(`div`,{className:`min-w-0`,children:[(0,x.jsx)(`h1`,{className:`text-lg font-semibold leading-tight`,children:typeof e.label==`string`?e.label:e.name}),typeof e.description==`string`&&e.description&&(0,x.jsx)(`p`,{className:`text-sm text-muted-foreground mt-0.5`,children:e.description})]}),$.length>0&&(0,x.jsx)(`div`,{className:`shrink-0`,"data-testid":`interface-page-buttons`,children:(0,x.jsx)(s,{schema:{type:`action:bar`,location:`list_toolbar`,actions:$,size:`sm`,variant:`outline`}})})]}),(0,x.jsx)(`div`,{className:`flex-1 min-h-0 overflow-auto`,children:(0,x.jsx)(g,{schema:Q,dataSource:D,userFilterSelections:P,onUserFilterSelectionsChange:L,onSortChange:i?e=>i({sort:e}):void 0,onColumnStateChange:i?e=>{e?.order?.length&&i({columns:e.order})}:void 0,onRowClick:V===`none`?void 0:G})}),U.isOverlay&&(0,x.jsx)(d,{...U,setIsOpen:e=>{e||ee()},title:typeof e.label==`string`?e.label:R.source||`Record`,children:e=>(0,x.jsx)(h,{objectNameOverride:R.source,recordIdOverride:String(e?.id??e?._id??W??``),embedded:!0,dataSource:D,objects:E,onEdit:()=>{}})})]})}export{A as a,N as i,M as n,b as o,T as r,y as s,L as t};
@@ -1 +0,0 @@
1
- import{r as e}from"./vendor-react-BKSb6vFP.js";import{l as t}from"./framework-BL3BtpKU.js";import{Ei as n,It as r,Lt as i,Oc as a,Rt as o,Va as s,ki as c,sr as l,wc as u,zt as d}from"./ui-components-Y3D5-fgK.js";var f=e(),p={config:{icon:c,i18nKey:`config`,short:`Admin config`,title:`Administrator configuration`,body:()=>`These rows define how the platform behaves at runtime. Author them here; the runtime data they produce lives in a separate table.`,tone:`border-sky-300/60 bg-sky-50 text-sky-900 hover:bg-sky-100 dark:border-sky-500/40 dark:bg-sky-950/40 dark:text-sky-100`},system:{icon:s,i18nKey:`system`,short:`System-managed`,title:`Managed by the platform`,body:()=>`Rows here are created automatically when actions run on the source record. The list below is a read-only monitoring surface — row-level actions (Approve, Recall, Resend, …) live on each row.`,tone:`border-slate-300/60 bg-slate-50 text-slate-900 hover:bg-slate-100 dark:border-slate-500/40 dark:bg-slate-950/40 dark:text-slate-100`},"append-only":{icon:u,i18nKey:`appendOnly`,short:`Read-only · Audit log`,title:`Read-only historical record`,body:()=>`Immutable audit log. Rows cannot be created, edited, or deleted from the UI — they're written by the platform when events occur. Use Export to download for compliance review.`,tone:`border-zinc-300/60 bg-zinc-50 text-zinc-900 hover:bg-zinc-100 dark:border-zinc-500/40 dark:bg-zinc-950/40 dark:text-zinc-100`},"better-auth":{icon:n,i18nKey:`betterAuth`,short:`Identity`,title:`Managed by the identity provider`,body:e=>`This object's schema is owned by ${e}. Direct edits bypass password hashing, session validation, two-factor checks, and audit hooks. Manage these records through your authentication provider's sign-in, invitation, and security flows instead.`,tone:`border-amber-300/60 bg-amber-50 text-amber-900 hover:bg-amber-100 dark:border-amber-500/40 dark:bg-amber-950/40 dark:text-amber-100`}};function m({managedBy:e,label:n,className:s}){let{t:c}=t();if(!e||e===`platform`)return null;let u=p[e];if(!u)return null;let m=u.icon,h=n??`better-auth`,g=c(`managedByBadge.${u.i18nKey}.short`,{defaultValue:u.short}),_=c(`managedByBadge.${u.i18nKey}.title`,{defaultValue:u.title}),v=c(`managedByBadge.${u.i18nKey}.body`,{defaultValue:u.body(h),provider:h});return(0,f.jsx)(o,{delayDuration:200,children:(0,f.jsxs)(r,{children:[(0,f.jsx)(d,{asChild:!0,children:(0,f.jsxs)(l,{variant:`outline`,"data-testid":`managed-by-badge`,"data-bucket":e,className:a(`gap-1 font-normal text-[11px] leading-none py-0.5 px-1.5 cursor-help`,u.tone,s),children:[(0,f.jsx)(m,{className:`h-3 w-3`,"aria-hidden":`true`}),(0,f.jsx)(`span`,{children:g})]})}),(0,f.jsxs)(i,{side:`bottom`,align:`start`,className:`max-w-xs text-xs leading-relaxed`,children:[(0,f.jsx)(`p`,{className:`font-semibold mb-1`,children:_}),(0,f.jsx)(`p`,{className:`text-muted-foreground`,children:v})]})]})})}export{m as t};
@@ -1 +0,0 @@
1
- import{f as e,m as t,r as n}from"./vendor-react-BKSb6vFP.js";import{g as r}from"./infrastructure-Bc4DRENl.js";import{l as i}from"./framework-BL3BtpKU.js";import{Cr as a,Va as o,nr as s,tr as c}from"./ui-components-Y3D5-fgK.js";var l={cloudUrl:``,singleEnvironment:!1,defaultOrgId:null,defaultEnvironmentId:null,features:{installLocal:!1,marketplace:!0,aiStudio:!0,autoPublishAiBuilds:!0,customDomain:!1,sso:!1},branding:{productName:`ObjectOS`,productShortName:`ObjectOS`,stage:`preview`,brandColor:`#4F46E5`,pwaThemeColor:`#4f46e5`}},u=[`preview`,`beta`,`ga`];function d(e){return typeof e==`string`&&u.includes(e)}var f={...l};function p(e){f={...f,...e,features:{...f.features,...e.features??{}},branding:{...f.branding,...e.branding??{}}}}async function m(e=``){let t=(e||``).replace(/\/+$/,``);try{let e=await fetch(`${t}/api/v1/runtime/config`,{credentials:`include`,headers:{Accept:`application/json`}});if(!e.ok)return;let n=await e.json();if(!n||typeof n!=`object`)return;p({cloudUrl:typeof n.cloudUrl==`string`?n.cloudUrl.replace(/\/+$/,``):f.cloudUrl,singleEnvironment:!!n.singleEnvironment,defaultOrgId:n.defaultOrgId??f.defaultOrgId??null,defaultEnvironmentId:n.defaultEnvironmentId??f.defaultEnvironmentId??null,features:n.features?{installLocal:!!n.features.installLocal,marketplace:n.features.marketplace!==!1,aiStudio:n.features.aiStudio!==!1,autoPublishAiBuilds:n.features.autoPublishAiBuilds!==!1,customDomain:n.features.customDomain===!0,sso:n.features.sso===!0}:f.features,branding:n.branding?{productName:typeof n.branding.productName==`string`&&n.branding.productName.trim()?n.branding.productName.trim():f.branding.productName,productShortName:typeof n.branding.productShortName==`string`&&n.branding.productShortName.trim()?n.branding.productShortName.trim():f.branding.productShortName,stage:d(n.branding.stage)?n.branding.stage:f.branding.stage,logoUrl:typeof n.branding.logoUrl==`string`&&n.branding.logoUrl.trim()?n.branding.logoUrl.trim():f.branding.logoUrl,faviconUrl:typeof n.branding.faviconUrl==`string`&&n.branding.faviconUrl.trim()?n.branding.faviconUrl.trim():f.branding.faviconUrl,brandColor:typeof n.branding.brandColor==`string`&&n.branding.brandColor.trim()?n.branding.brandColor.trim():f.branding.brandColor,pwaDescription:typeof n.branding.pwaDescription==`string`&&n.branding.pwaDescription.trim()?n.branding.pwaDescription.trim():f.branding.pwaDescription,pwaThemeColor:typeof n.branding.pwaThemeColor==`string`&&n.branding.pwaThemeColor.trim()?n.branding.pwaThemeColor.trim():f.branding.pwaThemeColor}:f.branding})}catch{}}function h(){return f}function g(){return f.branding?.productName||`ObjectOS`}function _(){return f.branding?.productShortName||g()}function v(){return f.branding?.stage??`preview`}function y(){return f.branding?.brandColor||`#4F46E5`}function b(){return f.branding?.logoUrl}function x(){return f.branding?.faviconUrl}function S(){return f.branding?.pwaDescription||`${g()} — runtime console`}function C(){return f.branding?.pwaThemeColor||y()}function w(){return f.cloudUrl??``}var T=``.replace(/\/$/,``),E=`${T}/api/v1/marketplace`;function D(e){let t=r.get();return t?{...e,Authorization:`Bearer ${t}`}:e}async function O(e,t){let n=await fetch(`${E}${e}`,{credentials:`omit`,headers:{Accept:`application/json`,...t?.headers||{}},...t}),r=null;try{r=await n.json()}catch{}if(!n.ok){let e=r?.error?.code??r?.code??`HTTP_${n.status}`,t=r?.error?.message??r?.error??n.statusText,i=Error(typeof t==`string`?t:`${e}`);throw i.code=e,i.status=n.status,i}return r?.data??r}async function k(e={}){let t=new URLSearchParams;e.q&&t.set(`q`,e.q),e.category&&t.set(`category`,e.category),e.limit!=null&&t.set(`limit`,String(e.limit)),e.offset!=null&&t.set(`offset`,String(e.offset));let n=t.toString();return O(`/packages${n?`?${n}`:``}`)}async function A(e){return O(`/packages/${encodeURIComponent(e)}`)}async function j(e){if(w()){let t=await fetch(`/api/v1/cloud-connection/install`,{method:`POST`,credentials:`include`,headers:D({Accept:`application/json`,"Content-Type":`application/json`}),body:JSON.stringify({package_id:e.packageId,seed_sample_data:!!e.seedSampleData})}),n=null;try{n=await t.json()}catch{}if(!t.ok||n?.success===!1){let e=n?.error?.code??n?.code??`HTTP_${t.status}`,r=n?.error?.message??n?.error??n?.message??t.statusText,i=Error(typeof r==`string`?r:`${e}`);throw i.code=e,i.status=t.status,i}return n?.data??n}let t=await fetch(`${T}/api/v1/actions/sys_package/install_package`,{method:`POST`,credentials:`include`,headers:{Accept:`application/json`,"Content-Type":`application/json`},body:JSON.stringify({recordId:e.packageId,params:{environment_id:e.environmentId,seed_sample_data:!!e.seedSampleData}})}),n=null;try{n=await t.json()}catch{}if(!t.ok){let e=n?.code??n?.error?.code??`HTTP_${t.status}`,r=n?.error??n?.message??t.statusText,i=Error(typeof r==`string`?r:`${e}`);throw i.code=e,i.status=t.status,i}return n?.data??n}async function M(){let e=w()||T,t=await fetch(`${e}/api/v1/data/sys_environment?limit=200`,{credentials:`include`,headers:{Accept:`application/json`}});if(!t.ok){let e=Error(`HTTP_${t.status}`);throw e.status=t.status,e}let n=await t.json().catch(()=>({})),r=n?.records??n?.data??n?.items??n??[];return Array.isArray(r)?r:[]}async function N(){let e=w()||T,t=null;try{let n=await fetch(`${e}/api/v1/auth/get-session`,{credentials:`include`,headers:{Accept:`application/json`}});n.ok&&(t=(await n.json().catch(()=>({})))?.user?.id??null)}catch{}if(!t)return new Set;let n=`${e}/api/v1/data/sys_member?limit=200`,r=null;try{let e=await fetch(n,{credentials:`include`,headers:{Accept:`application/json`}});if(!e.ok)return new Set;r=await e.json().catch(()=>({}))}catch{return new Set}let i=r?.records??r?.data??r?.items??r??[];if(!Array.isArray(i))return new Set;let a=new Set;for(let e of i){if(String(e?.user_id??e?.userId??``)!==t)continue;let n=String(e?.role??``).toLowerCase(),r=e?.organization_id??e?.organizationId;r&&(n===`owner`||n===`admin`)&&a.add(String(r))}return a}function P(e){return`${w()||`https://cloud.objectos.app`}/apps/cloud-control/sys_package/${encodeURIComponent(e)}`}function F(){return`${w()||`https://cloud.objectos.app`}/apps/cloud-control/sys_environment`}async function I(e,t){if(!e)return null;if(w())try{let t=await fetch(`/api/v1/cloud-connection/installation?package_id=${encodeURIComponent(e)}`,{credentials:`include`,headers:D({Accept:`application/json`})});if(!t.ok)return null;let n=await t.json().catch(()=>({})),r=n?.data??n??{};return r.installed?{installationId:String(r.installationId??``),version:String(r.version??`installed`),withSampleData:r.withSampleData===!0}:null}catch{return null}if(!t)return null;let n=T;try{let r=await fetch(`${n}/api/v1/cloud/environments/${encodeURIComponent(t)}/installations/${encodeURIComponent(e)}`,{credentials:`include`,headers:{Accept:`application/json`}});if(!r.ok)return null;let i=await r.json().catch(()=>({})),a=i?.data??i??{};return a.installed?{installationId:String(a.installationId??``),version:String(a.version??`installed`),withSampleData:a.withSampleData===!0}:null}catch{return null}}async function L(e){if(!e)return{ok:!1,error:`installation id required`};let t=w()||T;try{let n=await fetch(`${t}/api/v1/cloud/installations/${encodeURIComponent(e)}/reseed-sample-data`,{method:`POST`,credentials:`include`,headers:{Accept:`application/json`,"Content-Type":`application/json`},body:`{}`}),r=await n.json().catch(()=>({}));return!n.ok||r?.success===!1?{ok:!1,error:r?.error||`HTTP ${n.status}`}:{ok:!0}}catch(e){return{ok:!1,error:e?.message||`Network error`}}}async function R(e){if(!e)return{ok:!1,error:`installation id required`};let t=w()||T;try{let n=await fetch(`${t}/api/v1/cloud/installations/${encodeURIComponent(e)}/purge-sample-data`,{method:`POST`,credentials:`include`,headers:{Accept:`application/json`,"Content-Type":`application/json`},body:`{}`}),r=await n.json().catch(()=>({}));return!n.ok||r?.success===!1?{ok:!1,error:r?.error||`HTTP ${n.status}`}:{ok:!0,deleted:Number(r?.data?.deleted??0)}}catch(e){return{ok:!1,error:e?.message||`Network error`}}}async function z(){try{let e=await fetch(`${T}/api/v1/cloud-connection/org-packages`,{credentials:`include`,headers:{Accept:`application/json`}});if(!e.ok)return{connected:!1,items:[]};let t=(await e.json().catch(()=>({})))?.data??{},n=Array.isArray(t.items)?t.items:[];return{connected:t.connected===!0,items:n}}catch{return{connected:!1,items:[]}}}async function B(e){let t=await fetch(`${E}/install-local`,{method:`POST`,credentials:`include`,headers:{Accept:`application/json`,"Content-Type":`application/json`},body:JSON.stringify({packageId:e.packageId,...e.versionId?{versionId:e.versionId}:{}})}),n=null;try{n=await t.json()}catch{}if(!t.ok){let e=n?.error?.code??`HTTP_${t.status}`,r=n?.error?.message??t.statusText,i=Error(typeof r==`string`?r:`${e}`);throw i.code=e,i.status=t.status,i}return n?.data??n}async function V(){try{let e=await fetch(`${E}/install-local`,{credentials:`include`,headers:{Accept:`application/json`}});if(!e.ok)return[];let t=await e.json().catch(()=>({})),n=t?.data?.items??t?.items??[];return Array.isArray(n)?n:[]}catch{return[]}}async function H(){try{let e=await fetch(`${T}/api/v1/cloud-connection/installed`,{credentials:`include`,headers:{Accept:`application/json`}});if(!e.ok)return{connected:!1,items:[]};let t=(await e.json().catch(()=>({})))?.data??{},n=(Array.isArray(t.packages)?t.packages:[]).map(e=>{let t=String(e.packageId??e.package_id??``);return{packageId:t,versionId:String(e.package_version_id??``),manifestId:t,version:String(e.version??`installed`),installedAt:String(e.installed_at??e.installedAt??``),installedBy:e.installed_by??e.installedBy??null,withSampleData:e.with_sample_data===!0||e.withSampleData===!0}});return{connected:t.connected===!0,items:n}}catch{return{connected:!1,items:[]}}}async function U(e){let t=await fetch(`${E}/install-local/${encodeURIComponent(e)}`,{method:`DELETE`,credentials:`include`,headers:{Accept:`application/json`}});if(!t.ok){let e=(await t.json().catch(()=>({})))?.error?.message??t.statusText;throw Error(typeof e==`string`?e:`HTTP_${t.status}`)}}async function W(e,t){let n=await fetch(`${E}/install-local/${encodeURIComponent(e)}/${t===`reseed`?`reseed-sample-data`:`purge-sample-data`}`,{method:`POST`,credentials:`include`,headers:{Accept:`application/json`}}),r=await n.json().catch(()=>({}));if(!n.ok){let e=r?.error?.message??n.statusText,t=Error(typeof e==`string`?e:`HTTP_${n.status}`);throw t.code=r?.error?.code??`HTTP_${n.status}`,t}return r?.data??r}function G(e){return W(e,`reseed`)}function K(e){return W(e,`purge`)}var q=n();function J(){let n=e(),{appName:r}=t(),{t:l}=i(),u=r?`/apps/${r}`:`/`;return(0,q.jsx)(`div`,{className:`container mx-auto max-w-2xl px-6 py-16`,children:(0,q.jsx)(c,{children:(0,q.jsxs)(s,{className:`flex flex-col items-center gap-4 py-12 text-center`,children:[(0,q.jsx)(`div`,{className:`rounded-full bg-muted p-3`,children:(0,q.jsx)(o,{className:`h-6 w-6 text-muted-foreground`})}),(0,q.jsxs)(`div`,{children:[(0,q.jsx)(`h2`,{className:`text-lg font-semibold`,children:l(`marketplace.accessDenied.title`)}),(0,q.jsx)(`p`,{className:`mt-1 text-sm text-muted-foreground`,children:l(`marketplace.accessDenied.description`)})]}),(0,q.jsx)(a,{variant:`outline`,onClick:()=>n(u),children:l(`marketplace.action.backHome`)})]})})})}export{g as C,h as D,C as E,m as O,v as S,S as T,L as _,A as a,x as b,M as c,V as d,k as f,G as g,R as h,I as i,N as l,K as m,P as n,B as o,z as p,F as r,j as s,J as t,H as u,U as v,_ as w,b as x,w as y};
@@ -1 +0,0 @@
1
- import{o as e,r as t}from"./rolldown-runtime-DAXXjFlN.js";import{f as n,m as r,r as i,y as a}from"./vendor-react-BKSb6vFP.js";import{f as o}from"./infrastructure-Bc4DRENl.js";import{Yt as s,l as c}from"./framework-BL3BtpKU.js";import{Bt as l,Cr as u,Gi as d,Ns as f,Sc as p,Yo as m,Yr as h,ar as g,ci as _,ir as v,nr as y,sr as b,tr as x}from"./ui-components-Y3D5-fgK.js";import{d as S,t as C,u as w,v as T}from"./MarketplaceAccessDenied-B6Tg5g6l.js";var E=e(a(),1),D=i();function O(){let e=n(),{appName:t}=r(),i=o(),{t:a,language:s}=c(),p=t?`/apps/${t}`:``,[_,O]=(0,E.useState)([]),[k,A]=(0,E.useState)(`local`),[j,M]=(0,E.useState)(!0),[N,P]=(0,E.useState)(null),[F,I]=(0,E.useState)(null),L=async()=>{M(!0);try{let e=await w();e.connected?(A(`cloud`),O(e.items)):(A(`local`),O(await S()))}finally{M(!1)}};(0,E.useEffect)(()=>{L()},[]);let R=async e=>{if(confirm(a(`marketplace.uninstall.confirm`,{manifestId:e.manifestId,version:e.version}))){P(e.manifestId),I(null);try{await T(e.manifestId),I({ok:!0,message:a(`marketplace.uninstall.successInList`,{manifestId:e.manifestId})}),await L()}catch(e){I({ok:!1,message:e?.message??String(e)})}finally{P(null)}}};return i?(0,D.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,D.jsx)(`div`,{className:`flex justify-end`,children:(0,D.jsxs)(u,{variant:`outline`,size:`sm`,onClick:()=>void L(),disabled:j,children:[(0,D.jsx)(d,{className:`h-4 w-4 mr-1.5`,"aria-hidden":`true`}),a(`marketplace.refresh`)]})}),F&&(0,D.jsx)(`div`,{className:`rounded-md border p-3 text-sm ${F.ok?`border-green-500/30 bg-green-500/5 text-green-700 dark:text-green-400`:`border-destructive/30 bg-destructive/5 text-destructive`}`,children:(0,D.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,D.jsx)(f,{className:`h-4 w-4 mt-0.5 shrink-0`,"aria-hidden":`true`}),(0,D.jsx)(`div`,{children:F.message})]})}),j&&_.length===0?(0,D.jsx)(`div`,{className:`grid gap-3`,children:Array.from({length:3}).map((e,t)=>(0,D.jsx)(l,{className:`h-20 w-full`},t))}):_.length===0?(0,D.jsxs)(`div`,{className:`text-center py-12 text-sm text-muted-foreground border rounded-md`,children:[(0,D.jsx)(`p`,{children:a(`marketplace.installedEmpty`)}),(0,D.jsx)(u,{variant:`link`,className:`mt-2`,onClick:()=>e(`${p}/system/marketplace`),children:a(`marketplace.browseLink`)})]}):(0,D.jsx)(`div`,{className:`grid gap-3`,children:_.map(t=>(0,D.jsxs)(x,{children:[(0,D.jsxs)(v,{className:`flex flex-row items-start justify-between gap-3 pb-2`,children:[(0,D.jsxs)(`div`,{className:`min-w-0`,children:[(0,D.jsxs)(g,{className:`text-base truncate flex items-center gap-2`,children:[t.manifestId,(0,D.jsx)(b,{variant:`outline`,children:a(`marketplace.versionBadge`,{version:t.version})})]}),(0,D.jsxs)(`div`,{className:`text-xs text-muted-foreground mt-1 flex flex-wrap gap-x-3 gap-y-1`,children:[(0,D.jsx)(`span`,{children:a(`marketplace.installedAt`,{when:new Date(t.installedAt).toLocaleString(s||void 0)})}),t.installedBy&&(0,D.jsx)(`span`,{children:a(`marketplace.installedBy`,{user:t.installedBy})}),(0,D.jsxs)(`span`,{children:[a(`marketplace.installedPackageId`),` `,(0,D.jsx)(`code`,{className:`font-mono`,children:t.packageId})]})]})]}),(0,D.jsxs)(`div`,{className:`flex items-center gap-2 shrink-0`,children:[(0,D.jsxs)(u,{variant:`ghost`,size:`sm`,onClick:()=>e(`${p}/system/marketplace/${t.packageId}`),children:[(0,D.jsx)(m,{className:`h-4 w-4 mr-1.5`,"aria-hidden":`true`}),a(`marketplace.action.details`)]}),k===`local`&&(0,D.jsxs)(u,{variant:`outline`,size:`sm`,onClick:()=>void R(t),disabled:N===t.manifestId,children:[(0,D.jsx)(h,{className:`h-4 w-4 mr-1.5`,"aria-hidden":`true`}),N===t.manifestId?a(`marketplace.action.uninstalling`):a(`marketplace.action.uninstall`)]})]})]}),k===`local`&&(0,D.jsx)(y,{className:`pt-0 text-xs text-muted-foreground`,dangerouslySetInnerHTML:{__html:a(`marketplace.cachedAs`,{path:`.objectstack/installed-packages/${t.manifestId.replace(/[^a-zA-Z0-9._-]/g,`_`)}.json`})}})]},t.manifestId))}),(0,D.jsx)(`p`,{className:`text-xs text-muted-foreground border-t pt-4`,dangerouslySetInnerHTML:{__html:a(`marketplace.installedAdditiveNote`)}})]}):(0,D.jsx)(C,{})}s.register(`marketplace:installed-list`,()=>(0,D.jsx)(O,{}),{namespace:`app-shell`,label:`Installed Marketplace Packages`,category:`plugin`,inputs:[]});var k=t({MarketplaceInstalledPage:()=>A});function A(){let e=n(),{appName:t}=r(),{t:i}=c(),a=t?`/apps/${t}`:``;return(0,D.jsxs)(`div`,{className:`flex flex-col gap-6 p-4 sm:p-6 max-w-5xl`,children:[(0,D.jsxs)(u,{variant:`ghost`,size:`sm`,className:`self-start`,onClick:()=>e(`${a}/system/marketplace`),children:[(0,D.jsx)(p,{className:`h-4 w-4 mr-1.5`,"aria-hidden":`true`}),i(`marketplace.back`)]}),(0,D.jsxs)(`div`,{children:[(0,D.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,D.jsx)(_,{className:`h-6 w-6 text-primary`,"aria-hidden":`true`}),(0,D.jsx)(`h1`,{className:`text-xl sm:text-2xl font-bold tracking-tight`,children:i(`marketplace.installedTitle`)})]}),(0,D.jsx)(`p`,{className:`text-sm text-muted-foreground mt-1`,dangerouslySetInnerHTML:{__html:i(`marketplace.installedSubtitle`)}})]}),(0,D.jsx)(O,{})]})}export{k as t};
@@ -1,4 +0,0 @@
1
- import{o as e,r as t}from"./rolldown-runtime-DAXXjFlN.js";import{f as n,m as r,r as i,y as a}from"./vendor-react-BKSb6vFP.js";import{f as o,g as s}from"./infrastructure-Bc4DRENl.js";import{R as ee,l as c}from"./framework-BL3BtpKU.js";import{$o as te,As as l,Bt as u,Cn as ne,Cr as d,Ei as re,Gn as ie,Ha as f,Jn as ae,Jt as oe,Kn as se,Ms as ce,Ns as p,Oc as m,Oo as h,Pr as g,Qt as le,Sc as ue,Ti as _,Xn as de,Xo as fe,Xt as pe,Yn as me,Yo as he,Yr as ge,Yt as _e,Zt as ve,_n as v,ac as ye,ar as be,ds as xe,er as Se,hn as Ce,ir as we,mn as Te,nr as Ee,pn as y,qn as De,rs as Oe,sr as b,tr as ke,wi as x,xa as Ae,ya as je}from"./ui-components-Y3D5-fgK.js";import{r as S}from"./vendor-ui-utils-D-WJ115h.js";import"./MetadataProvider-DqPZ6rV2.js";import{t as Me}from"./assistantBus-CbDb2Mju.js";import{D as C,_ as Ne,a as Pe,c as Fe,d as Ie,g as Le,h as Re,i as ze,l as Be,m as Ve,n as He,o as Ue,s as We,t as Ge,v as Ke}from"./MarketplaceAccessDenied-B6Tg5g6l.js";import{n as qe,t as Je}from"./usePackageL10n-DfeTyD2w.js";var w=e(a(),1),T=i();function Ye(e){let t=e.replace(/\r\n/g,`
2
- `).split(`
3
- `),n=[],r=0;for(;r<t.length;){let e=t[r];if(e.startsWith("```")){let i=e.slice(3).trim();r++;let a=[];for(;r<t.length&&!t[r].startsWith("```");)a.push(t[r]),r++;r++,n.push({type:`code`,text:a.join(`
4
- `),lang:i});continue}let i=/^(#{1,3})\s+(.*)$/.exec(e);if(i){let e=i[1].length;n.push({type:`h${e}`,text:i[2].trim()}),r++;continue}if(/^[-*]\s+/.test(e)){let e=[];for(;r<t.length&&/^[-*]\s+/.test(t[r]);)e.push(t[r].replace(/^[-*]\s+/,``)),r++;n.push({type:`ul`,items:e});continue}if(/^\d+\.\s+/.test(e)){let e=[];for(;r<t.length&&/^\d+\.\s+/.test(t[r]);)e.push(t[r].replace(/^\d+\.\s+/,``)),r++;n.push({type:`ol`,items:e});continue}if(!e.trim()){r++;continue}let a=[];for(;r<t.length&&t[r].trim()&&!/^#{1,3}\s+/.test(t[r])&&!/^[-*]\s+/.test(t[r])&&!/^\d+\.\s+/.test(t[r])&&!t[r].startsWith("```");)a.push(t[r]),r++;n.push({type:`p`,text:a.join(` `)})}return n}function E(e){let t=[],n=e,r=0,i=[{re:/`([^`]+)`/,render:e=>(0,T.jsx)(`code`,{className:`rounded bg-muted px-1.5 py-0.5 font-mono text-[0.85em]`,children:e[1]},`k${r++}`)},{re:/\*\*([^*]+)\*\*/,render:e=>(0,T.jsx)(`strong`,{className:`font-semibold text-foreground`,children:e[1]},`k${r++}`)},{re:/\*([^*]+)\*/,render:e=>(0,T.jsx)(`em`,{children:e[1]},`k${r++}`)},{re:/\[([^\]]+)\]\(([^)]+)\)/,render:e=>(0,T.jsx)(`a`,{href:e[2],target:`_blank`,rel:`noopener noreferrer`,className:`text-violet-600 underline-offset-2 hover:underline dark:text-violet-400`,children:e[1]},`k${r++}`)}];for(;n;){let e=-1,r=null,a=null;for(let t of i){let i=t.re.exec(n);i&&(e===-1||i.index<e)&&(e=i.index,r=i,a=t)}if(!r||!a){t.push(n);break}e>0&&t.push(n.slice(0,e)),t.push(a.render(r)),n=n.slice(e+r[0].length)}return(0,T.jsx)(T.Fragment,{children:t.map((e,t)=>(0,T.jsx)(w.Fragment,{children:e},t))})}function Xe({source:e,className:t}){let n=Ye(e);return(0,T.jsx)(`div`,{className:`flex flex-col gap-4 text-sm leading-relaxed text-foreground/90 ${t??``}`,children:n.map((e,t)=>{switch(e.type){case`h1`:return(0,T.jsx)(`h2`,{className:`mt-2 text-xl font-bold tracking-tight`,children:E(e.text??``)},t);case`h2`:return(0,T.jsx)(`h3`,{className:`mt-3 text-base font-semibold tracking-tight`,children:E(e.text??``)},t);case`h3`:return(0,T.jsx)(`h4`,{className:`mt-2 text-sm font-semibold tracking-tight text-foreground/80`,children:E(e.text??``)},t);case`p`:return(0,T.jsx)(`p`,{children:E(e.text??``)},t);case`ul`:return(0,T.jsx)(`ul`,{className:`ml-1 flex list-none flex-col gap-1.5`,children:(e.items??[]).map((e,t)=>(0,T.jsxs)(`li`,{className:`flex gap-2`,children:[(0,T.jsx)(`span`,{"aria-hidden":`true`,className:`mt-1.5 inline-block h-1.5 w-1.5 shrink-0 rounded-full bg-violet-500/70`}),(0,T.jsx)(`span`,{children:E(e)})]},t))},t);case`ol`:return(0,T.jsx)(`ol`,{className:`ml-5 flex list-decimal flex-col gap-1.5 marker:text-muted-foreground`,children:(e.items??[]).map((e,t)=>(0,T.jsx)(`li`,{className:`pl-1`,children:E(e)},t))},t);case`code`:return(0,T.jsx)(`pre`,{className:`overflow-x-auto rounded-lg border bg-muted/40 p-3 text-xs leading-relaxed`,children:(0,T.jsx)(`code`,{className:`font-mono`,children:e.text})},t)}return null})})}var Ze={node:`In-process · full trust`,sandbox:`Sandboxed`,worker:`Out-of-process`};function D({icon:e,label:t,items:n}){return!n||n.length===0?null:(0,T.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,T.jsx)(e,{className:`h-3.5 w-3.5 mt-0.5 text-muted-foreground shrink-0`,"aria-hidden":`true`}),(0,T.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,T.jsx)(`div`,{className:`text-xs font-medium`,children:t}),(0,T.jsx)(`div`,{className:`flex flex-wrap gap-1 mt-0.5`,children:n.map(e=>(0,T.jsx)(`code`,{className:`font-mono text-[11px] px-1 py-0.5 rounded bg-muted break-all`,children:e},e))})]})]})}function Qe({version:e}){let{t}=c();if(!e?.contains_code)return null;let n=e.permissions??{},r=(n.services?.length??0)+(n.hooks?.length??0)+(n.network?.length??0)+(n.fs?.length??0)>0;return(0,T.jsxs)(`div`,{className:`rounded-md border border-amber-500/30 bg-amber-500/5 p-3 space-y-3 text-sm`,children:[(0,T.jsxs)(`div`,{className:`flex items-center gap-2 font-medium`,children:[(0,T.jsx)(xe,{className:`h-4 w-4 text-amber-600 shrink-0`,"aria-hidden":`true`}),t(`marketplace.disclosure.containsCode`,{defaultValue:`This package contains code`})]}),(0,T.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:[e.runtime&&(0,T.jsx)(b,{variant:`outline`,children:t(`marketplace.disclosure.runtime.${e.runtime}`,{defaultValue:Ze[e.runtime]??e.runtime})}),e.platform_verified?(0,T.jsxs)(b,{variant:`outline`,className:`gap-1 border-green-500/40 text-green-700 dark:text-green-400`,children:[(0,T.jsx)(_,{className:`h-3 w-3`,"aria-hidden":`true`}),t(`marketplace.disclosure.reviewed`,{defaultValue:`Reviewed & approved`})]}):(0,T.jsxs)(b,{variant:`outline`,className:`gap-1 border-amber-500/40 text-amber-700 dark:text-amber-400`,children:[(0,T.jsx)(re,{className:`h-3 w-3`,"aria-hidden":`true`}),t(`marketplace.disclosure.unreviewed`,{defaultValue:`Not yet reviewed`})]}),e.signed&&(0,T.jsxs)(b,{variant:`outline`,className:`gap-1`,children:[(0,T.jsx)(l,{className:`h-3 w-3`,"aria-hidden":`true`}),t(`marketplace.disclosure.signed`,{defaultValue:`Signed`})]})]}),r?(0,T.jsxs)(`div`,{className:`space-y-2`,children:[(0,T.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:t(`marketplace.disclosure.grantsIntro`,{defaultValue:`On install, this package will be granted:`})}),(0,T.jsx)(D,{icon:ye,label:t(`marketplace.disclosure.services`,{defaultValue:`Platform services`}),items:n.services??void 0}),(0,T.jsx)(D,{icon:g,label:t(`marketplace.disclosure.hooks`,{defaultValue:`Lifecycle hooks`}),items:n.hooks??void 0}),(0,T.jsx)(D,{icon:Ae,label:t(`marketplace.disclosure.network`,{defaultValue:`Network access`}),items:n.network??void 0}),(0,T.jsx)(D,{icon:h,label:t(`marketplace.disclosure.fs`,{defaultValue:`Filesystem access`}),items:n.fs??void 0})]}):(0,T.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:t(`marketplace.disclosure.noPermissions`,{defaultValue:`Requests no special permissions.`})})]})}var O=`${``.replace(/\/$/,``)}/api/v1/security/suggested-bindings`;function k(e={}){let t={Accept:`application/json`,...e},n=s.get();return n?{...t,Authorization:`Bearer ${n}`}:t}async function A(e){let t=null;try{t=await e.json()}catch{}if(!e.ok){let n=t?.error?.code??`HTTP_${e.status}`,r=t?.error?.message??t?.error??e.statusText,i=Error(typeof r==`string`?r:String(n));throw i.code=n,i.status=e.status,i}return t?.data??t}async function j(e={}){let t=new URLSearchParams;e.status&&t.set(`status`,e.status),e.packageId&&t.set(`packageId`,e.packageId);let n=t.toString(),r=await A(await fetch(`${O}${n?`?${n}`:``}`,{credentials:`include`,headers:k()}));return Array.isArray(r?.suggestions)?r.suggestions:[]}async function M(e){return(await A(await fetch(`${O}/${encodeURIComponent(e)}/confirm`,{method:`POST`,credentials:`include`,headers:k({"Content-Type":`application/json`})})))?.suggestion}async function N(e){return(await A(await fetch(`${O}/${encodeURIComponent(e)}/dismiss`,{method:`POST`,credentials:`include`,headers:k({"Content-Type":`application/json`})})))?.suggestion}function P({packageId:e,strings:t,className:n,onResolved:r}){let[i,a]=(0,w.useState)([]),[o,s]=(0,w.useState)(null),ee=(0,w.useCallback)(()=>{let t=!1;return j({status:`pending`,...e?{packageId:e}:{}}).then(e=>{t||a(e)}).catch(()=>{}),()=>{t=!0}},[e]);(0,w.useEffect)(()=>ee(),[ee]);let c=async(e,n)=>{s(e.id);try{let i=n===`confirm`?await M(e.id):await N(e.id);a(t=>t.filter(t=>t.id!==e.id)),S.success(n===`confirm`?t.confirmedToast(e):t.dismissedToast(e)),r?.(i??e)}catch(e){S.error(e?.message??String(e))}finally{s(null)}};return i.length===0?null:(0,T.jsx)(`div`,{"data-testid":`suggested-bindings-panel`,className:m(`rounded-lg border border-amber-300/60 dark:border-amber-700/50 bg-amber-50 dark:bg-amber-950/30 px-3 py-2 space-y-2`,n),children:i.map(e=>(0,T.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,T.jsx)(x,{className:`h-4 w-4 shrink-0 text-amber-600 dark:text-amber-400`}),(0,T.jsx)(`p`,{className:`flex-1 min-w-0 text-sm text-amber-900 dark:text-amber-200`,children:t.describe(e)}),(0,T.jsx)(d,{size:`sm`,disabled:o===e.id,onClick:()=>c(e,`confirm`),"data-testid":`suggested-binding-confirm-${e.permission_set_name}`,children:o===e.id?t.confirming:t.confirm}),(0,T.jsx)(d,{size:`sm`,variant:`ghost`,disabled:o===e.id,onClick:()=>c(e,`dismiss`),"data-testid":`suggested-binding-dismiss-${e.permission_set_name}`,children:t.dismiss})]},e.id))})}var $e=t({MarketplacePackagePage:()=>F});function F(){let e=n(),{packageId:t,appName:i}=r(),a=o(),{t:s,language:re}=c(),m={describe:e=>s(e.anchor===`guest`?`marketplace.suggestedBindings.promptGuest`:`marketplace.suggestedBindings.promptEveryone`,{set:e.permission_set_name}),confirm:s(`marketplace.suggestedBindings.confirm`),confirming:s(`marketplace.suggestedBindings.confirming`),dismiss:s(`marketplace.suggestedBindings.dismiss`),confirmedToast:e=>s(`marketplace.suggestedBindings.confirmedToast`,{set:e.permission_set_name,anchor:e.anchor}),dismissedToast:e=>s(`marketplace.suggestedBindings.dismissedToast`,{set:e.permission_set_name})},h=i?`/apps/${i}`:``,{refresh:g}=ee(),[_,ye]=(0,w.useState)(null),[xe,x]=(0,w.useState)(!0),[Ae,S]=(0,w.useState)(null),[Ye,E]=(0,w.useState)(!1),[Ze,D]=(0,w.useState)([]),[O,k]=(0,w.useState)(!1),[A,j]=(0,w.useState)(null),[M,N]=(0,w.useState)(``),[$e,F]=(0,w.useState)({}),[I,et]=(0,w.useState)(!1),[tt,nt]=(0,w.useState)(!1),[L,rt]=(0,w.useState)(!1),[R,z]=(0,w.useState)(null),[B,it]=(0,w.useState)(null),[V,H]=(0,w.useState)(null),[U,W]=(0,w.useState)(null),[G,K]=(0,w.useState)(null),[at,ot]=(0,w.useState)([]),[st,q]=(0,w.useState)(!1),[J,Y]=(0,w.useState)(null);(0,w.useEffect)(()=>{if(!C().features.installLocal)return;let e=!1;return(async()=>{let t=await Ie();e||ot(t)})(),()=>{e=!0}},[t,J]),(0,w.useEffect)(()=>{if(!t)return;let e=C().defaultEnvironmentId??``,n=!1;return(async()=>{let r=await ze(t,e);n||!r||(H(r),it(r.version))})(),()=>{n=!0}},[t]),(0,w.useEffect)(()=>{let e=!1;return(async()=>{if(t){x(!0),S(null);try{let n=await Pe(t);e||ye(n)}catch(t){e||S(t?.message??String(t))}finally{e||x(!1)}}})(),()=>{e=!0}},[t]);let ct=async()=>{E(!0),z(null),j(null);let e=C().defaultEnvironmentId;if(e){k(!1),N(e),D([]);return}k(!0);try{let[e,n]=await Promise.all([Fe(),Be()]),r=e.filter(e=>{let t=e.organization_id;return t?n.has(String(t)):!1});D(r),F({});let i=t;i&&Promise.all(r.map(async e=>{try{let t=await ze(i,e.id);return t?[e.id,t.version]:null}catch{return null}})).then(e=>{let t={};for(let n of e)n&&(t[n[0]]=n[1]);F(t)}),e.length>0&&r.length===0?j(s(`marketplace.install.noPermission`)):r.length===1&&N(r[0].id)}catch(e){let t=e?.status;j(t===401||t===403?s(`marketplace.install.signInFirst`):e?.message??String(e))}finally{k(!1)}},lt=async()=>{if(!(!t||!M)){rt(!0),z(null);try{let e=(await We({packageId:t,environmentId:M,seedSampleData:I}))?.installation?.version??_?.package?.latest_version?.version??_?.versions?.[0]?.version??``;it(e||`installed`);try{let e=C().defaultEnvironmentId||M;if(e){let n=await ze(t,e);n&&H(n)}}catch{}let n=C().defaultEnvironmentId;if(!n||n===M)try{if(typeof sessionStorage<`u`)for(let e of Object.keys(sessionStorage))e.startsWith(`objectui:metadata:`)&&sessionStorage.removeItem(e);await g()}catch{}z({ok:!0,message:s(`marketplace.install.success`)}),Me()}catch(e){z({ok:!1,message:e?.message??String(e)})}finally{rt(!1)}}},ut=async()=>{if(t){q(!0),Y(null);try{let e=await Ue({packageId:t});try{await g(`app`)}catch{}Y({ok:!0,message:s(`marketplace.install.localSuccess`,{version:e.version,name:_?.package?Je(_.package,re).displayName:e.manifestId})}),Me()}catch(e){let t=e?.code,n=e?.message??String(e);t===`manifest_conflict`?n=s(`marketplace.install.localManifestConflict`,{message:n}):t===`unauthorized`?n=s(`marketplace.install.localUnauthorized`):t===`marketplace_unavailable`&&(n=s(`marketplace.install.localMarketplaceUnavailable`)),Y({ok:!1,message:n})}finally{q(!1)}}},dt=async()=>{if($&&confirm(s(`marketplace.uninstall.confirm`,{manifestId:$.manifestId,version:$.version}))){q(!0),Y(null);try{await Ke($.manifestId);try{await g(`app`)}catch{}Y({ok:!0,message:s(`marketplace.uninstall.successInDetail`,{manifestId:$.manifestId})})}catch(e){Y({ok:!1,message:e?.message??String(e)})}finally{q(!1)}}},ft=async()=>{if(V){W(`reseed`),K(null);try{let e=await Ne(V.installationId);e.ok?(H({...V,withSampleData:!0}),K({ok:!0,text:s(`marketplace.detail.reseedQueued`)||`Sample data will be re-seeded on next environment access.`})):K({ok:!1,text:e.error||`Re-seed failed`})}finally{W(null)}}},pt=async()=>{if(V&&confirm(s(`marketplace.detail.purgeConfirm`)||`Delete all sample records seeded by this package? User-added records will NOT be touched.`)){W(`purge`),K(null);try{let e=await Re(V.installationId);if(e.ok){H({...V,withSampleData:!1});let t=e.deleted??0;K({ok:!0,text:t>0?s(`marketplace.detail.purgeSuccess`,{count:t})||`Removed ${t} sample record(s).`:s(`marketplace.detail.purgeNoData`)||`No sample records found to purge.`})}else K({ok:!1,text:e.error||`Purge failed`})}finally{W(null)}}},mt=async()=>{if($){W(`reseed`),K(null);try{let e=await Le($.manifestId);ot(e=>e.map(e=>e.manifestId===$.manifestId?{...e,withSampleData:!0}:e));let t=e.inserted??0,n=e.updated??0,r=e.errors??0,i=s(`marketplace.detail.reseedLocalSuccess`,{inserted:t,updated:n})||`Sample data re-seeded (inserted=${t}, updated=${n}).`;K(r>0?{ok:!1,text:`${i} ${s(`marketplace.detail.reseedPartialErrors`,{count:r})||`(${r} record(s) failed to write)`}`}:{ok:!0,text:i})}catch(e){K({ok:!1,text:e?.message||`Re-seed failed`})}finally{W(null)}}},ht=async()=>{if($&&confirm(s(`marketplace.detail.purgeConfirm`)||`Delete all sample records seeded by this package? User-added records will NOT be touched.`)){W(`purge`),K(null);try{let e=await Ve($.manifestId);ot(e=>e.map(e=>e.manifestId===$.manifestId?{...e,withSampleData:!1}:e));let t=e.deleted??0;K({ok:!0,text:t>0?s(`marketplace.detail.purgeSuccess`,{count:t})||`Removed ${t} sample record(s).`:s(`marketplace.detail.purgeNoData`)||`No sample records found to purge.`})}catch(e){K({ok:!1,text:e?.message||`Purge failed`})}finally{W(null)}}};if(xe)return(0,T.jsxs)(`div`,{className:`mx-auto w-full max-w-6xl flex flex-col gap-6 p-4 sm:p-6`,children:[(0,T.jsx)(u,{className:`h-8 w-32`}),(0,T.jsx)(u,{className:`h-16 w-full`}),(0,T.jsx)(u,{className:`h-64 w-full`})]});if(Ae||!_)return(0,T.jsxs)(`div`,{className:`mx-auto w-full max-w-6xl flex flex-col gap-6 p-4 sm:p-6`,children:[(0,T.jsxs)(d,{variant:`ghost`,size:`sm`,onClick:()=>e(`${h}/system/marketplace`),children:[(0,T.jsx)(ue,{className:`h-4 w-4 mr-1.5`,"aria-hidden":`true`}),s(`marketplace.back`)]}),(0,T.jsxs)(`div`,{className:`flex items-start gap-3 rounded-md border border-destructive/30 bg-destructive/5 p-4 text-sm`,children:[(0,T.jsx)(p,{className:`h-4 w-4 mt-0.5 text-destructive`,"aria-hidden":`true`}),(0,T.jsxs)(`div`,{children:[(0,T.jsx)(`div`,{className:`font-medium text-destructive`,children:s(`marketplace.load.packageFailed`)}),(0,T.jsx)(`div`,{className:`text-muted-foreground mt-1`,children:Ae??s(`marketplace.load.notFound`)})]})]})]});let X=_.package,Z=Je(X,re),Q=X.latest_version?.version??_.versions[0]?.version??null,$=at.find(e=>e.manifestId===X.manifest_id)??null,gt=!!X.latest_version?.contains_code,_t=!!B&&B!==`installed`&&!!Q&&B!==Q,vt=C().features.installLocal,yt=!Q||st||L||!vt&&!!B&&!_t,bt=vt?{label:s(st?`marketplace.action.working`:$?`marketplace.action.reinstall`:`marketplace.action.install`),onClick:ut}:{label:L?s(`marketplace.action.installing`):B?_t?s(`marketplace.action.updateTo`,{defaultValue:`Update`,version:Q}):s(`marketplace.action.installed`,{defaultValue:`Installed`}):s(`marketplace.action.installToCloud`),onClick:ct},xt=X.category?s(`marketplace.category.${X.category}`,{defaultValue:X.category}):null;return a?(0,T.jsxs)(`div`,{className:`mx-auto w-full max-w-6xl flex flex-col gap-6 p-4 sm:p-6`,children:[(0,T.jsxs)(d,{variant:`ghost`,size:`sm`,className:`self-start -ml-2 text-muted-foreground hover:text-foreground`,onClick:()=>e(`${h}/system/marketplace`),children:[(0,T.jsx)(ue,{className:`h-4 w-4 mr-1.5`,"aria-hidden":`true`}),s(`marketplace.back`)]}),(0,T.jsxs)(`div`,{className:`flex items-start gap-5 flex-wrap sm:flex-nowrap rounded-2xl border bg-gradient-to-br from-primary/5 via-background to-background p-6 sm:p-8`,children:[(0,T.jsx)(qe,{iconUrl:X.icon_url,displayName:Z.displayName,manifestId:X.manifest_id,className:`h-20 w-20 rounded-2xl shadow-sm ring-1 ring-border shrink-0`,initialClassName:`text-3xl font-bold`}),(0,T.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,T.jsxs)(`div`,{className:`flex items-center gap-2 flex-wrap`,children:[(0,T.jsx)(`h1`,{className:`text-2xl sm:text-3xl font-bold tracking-tight truncate`,children:Z.displayName||X.manifest_id}),X.homepage_url&&(0,T.jsxs)(`a`,{href:X.homepage_url,target:`_blank`,rel:`noopener noreferrer`,className:`inline-flex items-center gap-1 text-xs text-muted-foreground hover:text-foreground transition-colors`,title:s(`marketplace.detail.homepage`),children:[(0,T.jsx)(he,{className:`h-3.5 w-3.5`,"aria-hidden":`true`}),(0,T.jsx)(`span`,{className:`hidden sm:inline`,children:s(`marketplace.detail.homepage`)})]})]}),(0,T.jsxs)(`div`,{className:`text-sm text-muted-foreground mt-2 flex flex-wrap items-center gap-1.5`,children:[(0,T.jsx)(`code`,{className:`font-mono text-xs px-1.5 py-0.5 rounded bg-muted`,children:X.manifest_id}),Q&&(0,T.jsx)(b,{variant:`outline`,children:s(`marketplace.versionBadge`,{version:Q})}),X.publisher&&X.publisher!==`private`&&(0,T.jsx)(b,{variant:X.publisher===`objectstack`?`default`:`secondary`,children:X.publisher}),xt&&(0,T.jsx)(b,{variant:`outline`,children:xt}),X.license&&(0,T.jsx)(b,{variant:`outline`,className:`font-normal`,children:X.license}),$&&(0,T.jsxs)(b,{variant:`default`,className:`bg-green-600 hover:bg-green-600 gap-1`,children:[(0,T.jsx)(l,{className:`h-3 w-3`,"aria-hidden":`true`}),s(`marketplace.detail.installedV`,{version:$.version})]}),!$&&B&&(0,T.jsxs)(b,{variant:`default`,className:`bg-green-600 hover:bg-green-600 gap-1`,children:[(0,T.jsx)(l,{className:`h-3 w-3`,"aria-hidden":`true`}),s(`marketplace.detail.installedV`,{version:B})]}),_t&&(0,T.jsxs)(b,{variant:`default`,className:`bg-amber-500 hover:bg-amber-500 gap-1`,children:[(0,T.jsx)(ce,{className:`h-3 w-3`,"aria-hidden":`true`}),s(`marketplace.detail.updateAvailable`,{defaultValue:`Update available`}),` → v`,Q]})]}),Z.description&&(0,T.jsx)(`p`,{className:`text-sm sm:text-base text-foreground/80 mt-3 max-w-2xl leading-relaxed`,children:Z.description})]}),(0,T.jsxs)(`div`,{className:`flex items-center gap-2 shrink-0 self-start`,children:[(0,T.jsxs)(d,{onClick:bt.onClick,disabled:yt,size:`lg`,className:`min-w-[8rem]`,children:[(0,T.jsx)(te,{className:`h-4 w-4 mr-1.5`,"aria-hidden":`true`}),bt.label]}),$&&(0,T.jsxs)(Te,{children:[(0,T.jsx)(ne,{asChild:!0,children:(0,T.jsx)(d,{variant:`outline`,size:`lg`,className:`px-2.5`,"aria-label":s(`marketplace.detail.moreOptions`),children:(0,T.jsx)(fe,{className:`h-4 w-4`,"aria-hidden":`true`})})}),(0,T.jsxs)(Ce,{align:`end`,className:`w-56`,children:[(0,T.jsxs)(v,{onSelect:mt,disabled:U!==null,children:[U===`reseed`?(0,T.jsx)(f,{className:`h-4 w-4 mr-2 animate-spin`,"aria-hidden":`true`}):(0,T.jsx)(Oe,{className:`h-4 w-4 mr-2`,"aria-hidden":`true`}),$.withSampleData?s(`marketplace.detail.reseedAgain`)||`Re-seed sample data`:s(`marketplace.detail.addSampleData`)||`Add sample data`]}),(0,T.jsxs)(v,{onSelect:ht,disabled:U!==null||!$.withSampleData,className:`text-destructive focus:text-destructive`,children:[U===`purge`?(0,T.jsx)(f,{className:`h-4 w-4 mr-2 animate-spin`,"aria-hidden":`true`}):(0,T.jsx)(ge,{className:`h-4 w-4 mr-2`,"aria-hidden":`true`}),s(`marketplace.detail.purgeSampleData`)||`Purge sample data`]}),(0,T.jsxs)(v,{onSelect:dt,disabled:st,className:`text-destructive focus:text-destructive`,children:[(0,T.jsx)(ge,{className:`h-4 w-4 mr-2`,"aria-hidden":`true`}),s(`marketplace.detail.uninstallFromRuntime`)]})]})]}),!$&&V&&!C().cloudUrl&&(0,T.jsxs)(Te,{children:[(0,T.jsx)(ne,{asChild:!0,children:(0,T.jsx)(d,{variant:`outline`,size:`lg`,className:`px-2.5`,"aria-label":s(`marketplace.detail.moreOptions`)||`More options`,children:(0,T.jsx)(fe,{className:`h-4 w-4`,"aria-hidden":`true`})})}),(0,T.jsxs)(Ce,{align:`end`,className:`w-56`,children:[(0,T.jsxs)(v,{onSelect:ft,disabled:U!==null,children:[U===`reseed`?(0,T.jsx)(f,{className:`h-4 w-4 mr-2 animate-spin`,"aria-hidden":`true`}):(0,T.jsx)(Oe,{className:`h-4 w-4 mr-2`,"aria-hidden":`true`}),V.withSampleData?s(`marketplace.detail.reseedAgain`)||`Re-seed sample data`:s(`marketplace.detail.addSampleData`)||`Add sample data`]}),(0,T.jsxs)(v,{onSelect:pt,disabled:U!==null||!V.withSampleData,className:`text-destructive focus:text-destructive`,children:[U===`purge`?(0,T.jsx)(f,{className:`h-4 w-4 mr-2 animate-spin`,"aria-hidden":`true`}):(0,T.jsx)(ge,{className:`h-4 w-4 mr-2`,"aria-hidden":`true`}),s(`marketplace.detail.purgeSampleData`)||`Purge sample data`]})]})]})]})]}),G&&(0,T.jsxs)(`div`,{role:`status`,className:`flex items-start gap-2 rounded-md border p-3 text-sm ${G.ok?`border-green-500/30 bg-green-500/5 text-green-700 dark:text-green-400`:`border-destructive/30 bg-destructive/5 text-destructive`}`,children:[G.ok?(0,T.jsx)(l,{className:`h-4 w-4 mt-0.5 shrink-0`,"aria-hidden":`true`}):(0,T.jsx)(p,{className:`h-4 w-4 mt-0.5 shrink-0`,"aria-hidden":`true`}),(0,T.jsx)(`div`,{className:`flex-1`,children:G.text}),(0,T.jsx)(`button`,{type:`button`,className:`text-xs underline opacity-60 hover:opacity-100`,onClick:()=>K(null),children:s(`marketplace.action.dismiss`)})]}),J&&(0,T.jsxs)(`div`,{role:`status`,className:`flex items-start gap-2 rounded-md border p-3 text-sm whitespace-pre-wrap ${J.ok?`border-green-500/30 bg-green-500/5 text-green-700 dark:text-green-400`:`border-destructive/30 bg-destructive/5 text-destructive`}`,children:[J.ok?(0,T.jsx)(l,{className:`h-4 w-4 mt-0.5 shrink-0`,"aria-hidden":`true`}):(0,T.jsx)(p,{className:`h-4 w-4 mt-0.5 shrink-0`,"aria-hidden":`true`}),(0,T.jsxs)(`div`,{className:`flex-1`,children:[J.message,J.ok&&(0,T.jsx)(P,{packageId:X.manifest_id,strings:m,className:`mt-2`})]}),(0,T.jsx)(`button`,{type:`button`,className:`text-xs underline opacity-60 hover:opacity-100`,onClick:()=>Y(null),children:s(`marketplace.action.dismiss`)})]}),(0,T.jsxs)(`div`,{className:`grid gap-4 lg:grid-cols-3`,children:[(0,T.jsx)(`div`,{className:`lg:col-span-2 space-y-4`,children:(0,T.jsxs)(ke,{children:[(0,T.jsx)(we,{children:(0,T.jsx)(be,{className:`text-base`,children:s(`marketplace.detail.about`)})}),(0,T.jsx)(Ee,{children:Z.readme?(0,T.jsx)(Xe,{source:Z.readme}):(0,T.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:s(`marketplace.detail.noReadme`)})})]})}),(0,T.jsx)(`div`,{className:`space-y-4`,children:(0,T.jsxs)(ke,{children:[(0,T.jsx)(we,{children:(0,T.jsx)(be,{className:`text-base`,children:s(`marketplace.detail.versions`)})}),(0,T.jsx)(Ee,{children:_.versions.length===0?(0,T.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:s(`marketplace.detail.noApprovedVersions`)}):(0,T.jsx)(`ul`,{className:`space-y-3`,children:_.versions.map(e=>(0,T.jsxs)(`li`,{className:`space-y-1 text-sm`,children:[(0,T.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,T.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,T.jsx)(je,{className:`h-3.5 w-3.5 text-muted-foreground`,"aria-hidden":`true`}),(0,T.jsxs)(`code`,{className:`font-mono`,children:[`v`,e.version]}),e.is_prerelease&&(0,T.jsx)(b,{variant:`outline`,className:`text-xs`,children:s(`marketplace.detail.prerelease`)})]}),(0,T.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:e.published_at?new Date(e.published_at).toLocaleDateString():`—`})]}),e.release_notes&&e.release_notes.trim()&&(0,T.jsx)(`p`,{className:`whitespace-pre-line pl-5 text-xs text-muted-foreground`,children:e.release_notes.trim()})]},e.id))})})]})})]}),(0,T.jsx)(ie,{open:Ye,onOpenChange:e=>{E(e),e||(z(null),nt(!1))},children:(0,T.jsxs)(se,{children:[(0,T.jsxs)(me,{children:[(0,T.jsx)(de,{children:s(`marketplace.install.dialogTitle`,{name:Z.displayName||X.manifest_id})}),(0,T.jsx)(De,{children:C().defaultEnvironmentId?s(`marketplace.install.dialogDescCurrent`,{host:typeof window<`u`?window.location.host:``}):s(`marketplace.install.dialogDescPicker`)})]}),O?(0,T.jsx)(u,{className:`h-10 w-full`}):A?(0,T.jsxs)(`div`,{className:`rounded-md border border-amber-500/30 bg-amber-500/5 p-3 text-sm space-y-2`,children:[(0,T.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,T.jsx)(p,{className:`h-4 w-4 mt-0.5 text-amber-600`,"aria-hidden":`true`}),(0,T.jsx)(`div`,{className:`flex-1`,children:A})]}),(0,T.jsx)(`a`,{href:He(X.id),target:`_blank`,rel:`noopener noreferrer`,children:(0,T.jsxs)(d,{variant:`outline`,size:`sm`,className:`w-full`,children:[(0,T.jsx)(he,{className:`h-4 w-4 mr-1.5`,"aria-hidden":`true`}),s(`marketplace.action.openOnCloud`)]})})]}):C().defaultEnvironmentId?(0,T.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,T.jsx)(Se,{id:`seed`,checked:I,onCheckedChange:e=>et(e===!0)}),(0,T.jsx)(y,{htmlFor:`seed`,className:`text-sm font-normal cursor-pointer`,children:s(`marketplace.install.includeSampleData`)})]}):Ze.length===0?(0,T.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:s(`marketplace.install.noEnvs`)}):(0,T.jsxs)(`div`,{className:`space-y-4`,children:[(0,T.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,T.jsx)(y,{htmlFor:`env-select`,children:s(`marketplace.install.environment`)}),(0,T.jsxs)(oe,{value:M,onValueChange:N,children:[(0,T.jsx)(ve,{id:`env-select`,children:(0,T.jsx)(le,{placeholder:s(`marketplace.install.environmentPlaceholder`)})}),(0,T.jsx)(_e,{children:Ze.map(e=>{let t=$e[e.id],n=!!t&&!!Q&&t!==`installed`&&t!==Q;return(0,T.jsxs)(pe,{value:e.id,children:[e.display_name||e.hostname||e.id,e.plan&&(0,T.jsxs)(`span`,{className:`text-muted-foreground`,children:[` · `,e.plan]}),t&&(n?(0,T.jsxs)(`span`,{className:`text-amber-600`,children:[` · `,s(`marketplace.install.updateTo`,{defaultValue:`Update → v{{version}}`,version:Q})]}):(0,T.jsxs)(`span`,{className:`text-muted-foreground`,children:[` · `,s(`marketplace.install.installedVersion`,{defaultValue:`Installed v{{version}}`,version:t})]}))]},e.id)})})]})]}),(0,T.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,T.jsx)(Se,{id:`seed`,checked:I,onCheckedChange:e=>et(e===!0)}),(0,T.jsx)(y,{htmlFor:`seed`,className:`text-sm font-normal cursor-pointer`,children:s(`marketplace.install.includeSampleData`)})]})]}),gt&&!A&&(0,T.jsxs)(`div`,{className:`space-y-3`,children:[(0,T.jsx)(Qe,{version:X.latest_version}),(0,T.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,T.jsx)(Se,{id:`ack-perms`,checked:tt,onCheckedChange:e=>nt(e===!0)}),(0,T.jsx)(y,{htmlFor:`ack-perms`,className:`text-sm font-normal cursor-pointer leading-snug`,children:s(`marketplace.disclosure.acknowledge`,{defaultValue:`I understand this package runs code and grants the permissions above.`})})]})]}),R&&(0,T.jsx)(`div`,{className:`rounded-md border p-3 text-sm ${R.ok?`border-green-500/30 bg-green-500/5 text-green-700`:`border-destructive/30 bg-destructive/5 text-destructive`}`,children:R.message}),R?.ok===!0&&C().defaultEnvironmentId&&C().defaultEnvironmentId===M&&(0,T.jsx)(P,{packageId:X.manifest_id,strings:m}),(0,T.jsxs)(ae,{children:[(0,T.jsx)(d,{variant:`outline`,onClick:()=>E(!1),children:s(`marketplace.action.close`)}),!A&&(0,T.jsx)(d,{onClick:lt,disabled:!M||L||R?.ok===!0||gt&&!tt,children:s(L?`marketplace.action.installing`:`marketplace.action.install`)})]})]})})]}):(0,T.jsx)(Ge,{})}export{P as n,$e as t};
@@ -1 +0,0 @@
1
- import{o as e,r as t}from"./rolldown-runtime-DAXXjFlN.js";import{f as n,m as r,r as i,y as a}from"./vendor-react-BKSb6vFP.js";import{f as o}from"./infrastructure-Bc4DRENl.js";import{l as s}from"./framework-BL3BtpKU.js";import{As as c,Bt as l,Cr as u,Gi as ee,Ns as te,Oi as d,ar as f,ci as p,ir as m,ji as ne,ln as h,nr as g,rr as _,sr as v,tr as y,ya as b}from"./ui-components-Y3D5-fgK.js";import{t as re}from"./assistantBus-CbDb2Mju.js";import{D as ie,d as x,f as ae,o as oe,p as S,s as C,t as se,u as ce}from"./MarketplaceAccessDenied-B6Tg5g6l.js";import{n as w,t as T}from"./usePackageL10n-DfeTyD2w.js";var E=t({MarketplacePage:()=>A}),D=e(a(),1),O=i();function k(){let{language:e,t}=s();return n=>{if(!n)return``;let r=new Date(n);if(Number.isNaN(r.getTime()))return``;let i=Math.floor((Date.now()-r.getTime())/864e5);if(i<1)return t(`marketplace.relativeTime.today`);try{let t=new Intl.RelativeTimeFormat(e||`en`,{numeric:`auto`});return i<30?t.format(-i,`day`):i<365?t.format(-Math.floor(i/30),`month`):t.format(-Math.floor(i/365),`year`)}catch{return i<30?t(`marketplace.relativeTime.daysAgo`,{count:i}):i<365?t(`marketplace.relativeTime.monthsAgo`,{count:Math.floor(i/30)}):t(`marketplace.relativeTime.yearsAgo`,{count:Math.floor(i/365)})}}}function A(){let e=n(),{appName:t}=r(),i=o(),{t:a,language:E}=s(),A=k(),j=t?`/apps/${t}`:``,[M,N]=(0,D.useState)([]),[P,F]=(0,D.useState)(!0),[I,L]=(0,D.useState)(null),[R,z]=(0,D.useState)(``),[B,V]=(0,D.useState)(``),[H,U]=(0,D.useState)([]),[W,le]=(0,D.useState)([]),[G,K]=(0,D.useState)(null),[q,J]=(0,D.useState)(null),[ue,Y]=(0,D.useState)(new Set),de=(0,D.useMemo)(()=>{let e=new Map;for(let t of H)e.set(t.manifestId,t);return e},[H]),X=async()=>{F(!0),L(null);try{let[e,t,n,r]=await Promise.all([ae({limit:100}),x(),S(),ce()]);N(e.items??[]),U(t),le(n.items??[]);let i=new Set;for(let e of t)i.add(e.manifestId);for(let e of r.items)i.add(e.manifestId);Y(i)}catch(e){L(e?.message??String(e)),N([])}finally{F(!1)}};(0,D.useEffect)(()=>{X()},[]);let fe=async e=>{K(e.id),J(null);try{ie().features.installLocal?await oe({packageId:e.manifest_id||e.id,versionId:`latest`}):await C({packageId:e.id,environmentId:``,seedSampleData:!0}),J({ok:!0,text:a(`marketplace.org.installed`,{defaultValue:`Installed ${e.display_name}`,name:e.display_name})}),await X(),re()}catch(e){J({ok:!1,text:e?.message??String(e)})}finally{K(null)}},Z=(0,D.useMemo)(()=>{let e=new Set;for(let t of M)t.category&&e.add(t.category);return Array.from(e).sort()},[M]),Q=e=>{let t=`marketplace.category.${e}`,n=a(t,{defaultValue:e});return n===t?e:n},$=(0,D.useMemo)(()=>{let e=R.trim().toLowerCase();return M.filter(t=>{if(B&&t.category!==B)return!1;if(!e)return!0;let n=T(t,E);return`${n.displayName} ${t.manifest_id} ${n.description??``}`.toLowerCase().includes(e)})},[M,R,B,E]);return i?(0,O.jsxs)(`div`,{className:`flex flex-col gap-6 p-4 sm:p-6`,children:[(0,O.jsxs)(`div`,{className:`flex items-start justify-between gap-4 flex-wrap`,children:[(0,O.jsxs)(`div`,{className:`min-w-0`,children:[(0,O.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,O.jsx)(p,{className:`h-6 w-6 text-primary`,"aria-hidden":`true`}),(0,O.jsx)(`h1`,{className:`text-xl sm:text-2xl font-bold tracking-tight`,children:a(`marketplace.title`)})]}),(0,O.jsx)(`p`,{className:`text-sm text-muted-foreground mt-1`,children:a(`marketplace.subtitle`)})]}),(0,O.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,O.jsxs)(u,{variant:`outline`,size:`sm`,onClick:()=>e(`${j}/system/marketplace/installed`),children:[(0,O.jsx)(d,{className:`h-4 w-4 mr-1.5`,"aria-hidden":`true`}),H.length>0?a(`marketplace.installedCount`,{count:H.length}):a(`marketplace.installed`)]}),(0,O.jsxs)(u,{variant:`outline`,size:`sm`,onClick:()=>void X(),disabled:P,children:[(0,O.jsx)(ee,{className:`h-4 w-4 mr-1.5`,"aria-hidden":`true`}),a(`marketplace.refresh`)]})]})]}),(0,O.jsxs)(`div`,{className:`flex flex-col sm:flex-row gap-3`,children:[(0,O.jsxs)(`div`,{className:`relative flex-1`,children:[(0,O.jsx)(ne,{className:`absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground`,"aria-hidden":`true`}),(0,O.jsx)(h,{value:R,onChange:e=>z(e.target.value),placeholder:a(`marketplace.searchPlaceholder`),className:`pl-9`,"aria-label":a(`marketplace.searchAria`)})]}),Z.length>0&&(0,O.jsxs)(`div`,{className:`flex flex-wrap gap-1.5`,children:[(0,O.jsx)(u,{size:`sm`,variant:B===``?`default`:`outline`,onClick:()=>V(``),children:a(`marketplace.all`)}),Z.map(e=>(0,O.jsx)(u,{size:`sm`,variant:B===e?`default`:`outline`,onClick:()=>V(e),children:Q(e)},e))]})]}),I&&(0,O.jsxs)(`div`,{className:`flex items-start gap-3 rounded-md border border-destructive/30 bg-destructive/5 p-4 text-sm`,children:[(0,O.jsx)(te,{className:`h-4 w-4 mt-0.5 text-destructive`,"aria-hidden":`true`}),(0,O.jsxs)(`div`,{children:[(0,O.jsx)(`div`,{className:`font-medium text-destructive`,children:a(`marketplace.load.failed`)}),(0,O.jsx)(`div`,{className:`text-muted-foreground mt-1`,children:I}),(0,O.jsx)(`div`,{className:`text-xs text-muted-foreground mt-2`,dangerouslySetInnerHTML:{__html:a(`marketplace.load.failedHint`)}})]})]}),W.length>0&&(0,O.jsxs)(`section`,{className:`flex flex-col gap-3`,children:[(0,O.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,O.jsx)(p,{className:`h-5 w-5 text-primary`,"aria-hidden":`true`}),(0,O.jsx)(`h2`,{className:`text-sm font-semibold`,children:a(`marketplace.org.heading`,{defaultValue:`Your organization`})}),(0,O.jsx)(v,{variant:`secondary`,className:`text-xs`,children:W.length})]}),q&&(0,O.jsx)(`div`,{className:`rounded-md border p-3 text-sm ${q.ok?`border-green-500/30 bg-green-500/5 text-green-700 dark:text-green-400`:`border-destructive/30 bg-destructive/5 text-destructive`}`,children:q.text}),(0,O.jsx)(`div`,{className:`grid gap-4 sm:grid-cols-2 lg:grid-cols-3`,children:W.map(e=>{let t=ue.has(e.manifest_id);return(0,O.jsxs)(y,{className:`flex flex-col`,"data-testid":`org-card-${e.manifest_id}`,children:[(0,O.jsxs)(m,{className:`flex flex-row items-start gap-3 pb-2`,children:[(0,O.jsx)(w,{iconUrl:e.icon_url,displayName:e.display_name,manifestId:e.manifest_id}),(0,O.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,O.jsx)(f,{className:`text-base truncate`,children:e.display_name}),(0,O.jsx)(_,{className:`text-xs truncate`,children:(0,O.jsx)(`code`,{className:`font-mono`,children:e.manifest_id})})]}),e.visibility&&(0,O.jsx)(v,{variant:`outline`,className:`shrink-0 text-xs`,children:e.visibility})]}),(0,O.jsxs)(g,{className:`flex-1 flex flex-col gap-2`,children:[(0,O.jsx)(`p`,{className:`text-sm text-muted-foreground line-clamp-2`,children:e.description||a(`marketplace.noDescription`)}),(0,O.jsxs)(`div`,{className:`flex items-center gap-2 mt-auto pt-2 flex-wrap`,children:[e.latest_version&&(0,O.jsxs)(v,{variant:`outline`,className:`text-xs`,children:[(0,O.jsx)(b,{className:`h-3 w-3 mr-1`,"aria-hidden":`true`}),a(`marketplace.versionBadge`,{version:e.latest_version})]}),(0,O.jsx)(`div`,{className:`ml-auto`,children:t?(0,O.jsxs)(v,{variant:`default`,className:`text-xs bg-green-600 hover:bg-green-600`,children:[(0,O.jsx)(c,{className:`h-3 w-3 mr-1`,"aria-hidden":`true`}),a(`marketplace.org.installedBadge`,{defaultValue:`Installed`})]}):(0,O.jsx)(u,{size:`sm`,onClick:()=>void fe(e),disabled:G===e.id,children:G===e.id?a(`marketplace.org.installing`,{defaultValue:`Installing…`}):a(`marketplace.org.install`,{defaultValue:`Install`})})})]})]})]},e.id)})}),(0,O.jsx)(`div`,{className:`border-b pt-2`})]}),P&&M.length===0?(0,O.jsx)(`div`,{className:`grid gap-4 sm:grid-cols-2 lg:grid-cols-3`,children:Array.from({length:6}).map((e,t)=>(0,O.jsxs)(y,{children:[(0,O.jsxs)(m,{className:`pb-2`,children:[(0,O.jsx)(l,{className:`h-10 w-10 rounded-lg mb-2`}),(0,O.jsx)(l,{className:`h-5 w-3/4`}),(0,O.jsx)(l,{className:`h-4 w-1/2 mt-1`})]}),(0,O.jsx)(g,{children:(0,O.jsx)(l,{className:`h-12 w-full`})})]},t))}):$.length===0?(0,O.jsx)(`div`,{className:`text-center py-12 text-sm text-muted-foreground`,children:M.length===0?a(`marketplace.noApprovedYet`):a(`marketplace.noMatchFilters`)}):(0,O.jsx)(`div`,{className:`grid gap-4 sm:grid-cols-2 lg:grid-cols-3`,children:$.map(t=>{let n=de.get(t.manifest_id),r=T(t,E);return(0,O.jsxs)(y,{className:`cursor-pointer transition-colors hover:bg-accent/50 flex flex-col`,onClick:()=>e(`${j}/system/marketplace/${t.id}`),role:`link`,tabIndex:0,onKeyDown:n=>{(n.key===`Enter`||n.key===` `)&&(n.preventDefault(),e(`${j}/system/marketplace/${t.id}`))},"data-testid":`marketplace-card-${t.manifest_id}`,children:[(0,O.jsxs)(m,{className:`flex flex-row items-start gap-3 pb-2`,children:[(0,O.jsx)(w,{iconUrl:t.icon_url,displayName:r.displayName,manifestId:t.manifest_id}),(0,O.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,O.jsx)(f,{className:`text-base truncate`,children:r.displayName}),(0,O.jsx)(_,{className:`text-xs truncate`,children:(0,O.jsx)(`code`,{className:`font-mono`,children:t.manifest_id})})]}),t.publisher&&t.publisher!==`private`&&(0,O.jsx)(v,{variant:t.publisher===`objectstack`?`default`:`secondary`,className:`shrink-0`,children:t.publisher})]}),(0,O.jsxs)(g,{className:`flex-1 flex flex-col gap-2`,children:[(0,O.jsx)(`p`,{className:`text-sm text-muted-foreground line-clamp-2`,children:r.description||a(`marketplace.noDescription`)}),(0,O.jsxs)(`div`,{className:`flex items-center gap-2 mt-auto pt-2 flex-wrap`,children:[n&&(0,O.jsxs)(v,{variant:`default`,className:`text-xs bg-green-600 hover:bg-green-600`,children:[(0,O.jsx)(c,{className:`h-3 w-3 mr-1`,"aria-hidden":`true`}),a(`marketplace.installedBadge`,{version:n.version})]}),t.latest_version?.version&&(0,O.jsxs)(v,{variant:`outline`,className:`text-xs`,children:[(0,O.jsx)(b,{className:`h-3 w-3 mr-1`,"aria-hidden":`true`}),a(`marketplace.versionBadge`,{version:t.latest_version.version})]}),t.category&&(0,O.jsx)(v,{variant:`outline`,className:`text-xs`,children:Q(t.category)}),t.latest_version?.published_at&&(0,O.jsx)(`span`,{className:`text-xs text-muted-foreground ml-auto`,children:A(t.latest_version.published_at)})]})]})]},t.id)})})]}):(0,O.jsx)(se,{})}export{E as t};
@@ -1 +0,0 @@
1
- import{o as e}from"./rolldown-runtime-DAXXjFlN.js";import{r as t,y as n}from"./vendor-react-BKSb6vFP.js";import{kt as r,l as i}from"./framework-BL3BtpKU.js";import{Bs as a,Hs as o,ss as s,zs as c}from"./ui-components-Y3D5-fgK.js";var l=e(n(),1),u=t();function d({sections:e,open:t}){if(!t)return null;let{t:n}=i(),[r,d]=(0,l.useState)([`0`]),[f,p]=(0,l.useState)(null),m=async(e,t)=>{try{await navigator.clipboard.writeText(JSON.stringify(e,null,2)),p(t),setTimeout(()=>p(null),2e3)}catch(e){console.error(`Failed to copy:`,e)}},h=e=>{d(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e])};return(0,u.jsxs)(`div`,{className:`w-80 border-l bg-background p-0 overflow-hidden flex flex-col shrink-0 z-20 transition-all`,children:[(0,u.jsxs)(`div`,{className:`px-4 py-3 border-b bg-muted/5 flex items-center justify-between`,children:[(0,u.jsx)(`span`,{className:`text-xs font-semibold uppercase tracking-wider text-muted-foreground`,children:n(`layout.metadata.panelTitle`)}),(0,u.jsx)(`span`,{className:`text-[10px] text-muted-foreground/60`,children:n(`layout.metadata.jsonBadge`)})]}),(0,u.jsx)(`div`,{className:`flex-1 overflow-auto`,children:e.map((e,t)=>{let i=String(t),l=r.includes(i),d=f===t;return(0,u.jsxs)(`div`,{className:`border-b last:border-b-0`,children:[(0,u.jsxs)(`div`,{className:`flex items-center justify-between px-4 py-3 hover:bg-muted/5 transition-colors`,children:[(0,u.jsxs)(`button`,{onClick:()=>h(i),className:`flex-1 flex items-center justify-between text-left`,children:[(0,u.jsx)(`h4`,{className:`text-xs font-semibold text-foreground`,children:e.title}),l?(0,u.jsx)(a,{className:`h-3 w-3 text-muted-foreground ml-2`}):(0,u.jsx)(c,{className:`h-3 w-3 text-muted-foreground ml-2`})]}),(0,u.jsx)(`button`,{onClick:()=>m(e.data,t),className:`p-1 hover:bg-muted rounded transition-colors ml-2`,title:n(`layout.metadata.copyJson`),children:d?(0,u.jsx)(o,{className:`h-3 w-3 text-green-600`}):(0,u.jsx)(s,{className:`h-3 w-3 text-muted-foreground`})})]}),l&&(0,u.jsx)(`div`,{className:`px-4 pb-4`,children:(0,u.jsx)(`div`,{className:`relative rounded-md border border-border/50 bg-muted/5 overflow-hidden`,children:(0,u.jsx)(`pre`,{className:`text-[11px] leading-relaxed p-3 overflow-auto max-h-96 font-mono text-foreground/90`,children:JSON.stringify(e.data,null,2)})})})]},t)})})]})}function f(){let[e,t]=(0,l.useState)((0,l.useMemo)(()=>{try{return typeof window<`u`&&r(window.location.search).enabled}catch{return!1}},[]));return{showDebug:e,toggleDebug:()=>t(e=>!e)}}export{f as n,d as t};
@@ -1 +0,0 @@
1
- import{o as e}from"./rolldown-runtime-DAXXjFlN.js";import{d as t,f as n,r,y as i}from"./vendor-react-BKSb6vFP.js";import{h as a}from"./infrastructure-Bc4DRENl.js";import{I as o}from"./framework-BL3BtpKU.js";import{n as s}from"./data-adapter-Mo_lVy1U.js";import{i as c}from"./plugin-form-6ug8Woph.js";import{i as l,r as u}from"./assistantBus-CbDb2Mju.js";var d=e(i(),1),f=r(),p=(0,d.createContext)(!1),m=`preview`,h=`draft`;function g(e){return new URLSearchParams(e).get(m)===h}var _=!1;function v(){_=!0}function y({force:e,children:r}){let i=t(),a=n(),o=(0,d.useMemo)(()=>g(i.search),[i.search]),[s,c]=(0,d.useState)(o);return(0,d.useEffect)(()=>{if(o){c(!0),_=!1;return}if(!s)return;if(_){_=!1,c(!1);return}let e=new URLSearchParams(i.search);e.set(m,h),a(`${i.pathname}?${e.toString()}${i.hash}`,{replace:!0})},[o,s,i.pathname,i.search,i.hash,a]),(0,f.jsx)(p.Provider,{value:e??(o||s),children:r})}function b(){return(0,d.useContext)(p)}var x=a();function S(){return``}function C(e={}){let{previewDrafts:t=!1,environmentId:n}=e,r=new s({baseUrl:S(),previewDrafts:t,fetch:x});return n?r.withEnvironment(n):r}var w=300*1e3,T=[`app`,`view`],E={apps:`app`,objects:`object`,dashboards:`dashboard`,reports:`report`,pages:`page`},D=`objectui:metadata:`;function O(){try{let e=import.meta;if(e&&e.env&&typeof e.env.MODE==`string`)return e.env.MODE!==`production`}catch{}return!1}var k=O();function A(...e){k&&console.debug(`[MetadataProvider]`,...e)}function j(e){return Array.isArray(e)?e:e&&typeof e==`object`&&`items`in e&&Array.isArray(e.items)?e.items:[]}function M(e){return e==null?null:typeof e==`object`&&`item`in e?e.item??null:e}function N(e){return!!e&&typeof e==`object`&&`name`in e&&typeof e.name==`string`}function P(e){return!!e&&typeof e==`object`&&!!e.viewKind&&!!e.object}function F(e,t){if(!e.length||!t.length)return e;let n={},r=new Set;for(let e of t)P(e)&&r.add(e.object);for(let e of t){if(P(e)){let t=n[e.object]||={listViews:{},formViews:{}},r=e.name||`${e.object}.${e.viewKind}`,i=e.config&&typeof e.config==`object`?e.config:{},a={...i,name:r,label:e.label??i.label,isDefault:!!e.isDefault};e.viewKind===`form`?(t.formViews[r]=a,(e.isDefault||!t.form)&&(t.form=a)):(t.listViews[r]=a,e.isDefault&&(t.primary=a));continue}let t=e?.name||e?.list?.data?.object||e?.form?.data?.object;if(!t||r.has(t))continue;let i=n[t]||={listViews:{},formViews:{}};if(e.list){i.primary=e.list;let t=e.list.name||`list`;i.listViews[t]=e.list}if(e.form&&(i.form=e.form),e.listViews&&typeof e.listViews==`object`)for(let[t,n]of Object.entries(e.listViews))i.listViews[t]=n;if(e.formViews&&typeof e.formViews==`object`)for(let[t,n]of Object.entries(e.formViews))i.formViews[t]=n}return e.map(e=>{let t=n[e.name];if(!t)return e;let r=e.listViews||e.list_views||{},i=e.formViews||e.form_views||{},a={...e,listViews:{...t.listViews,...r}};return(Object.keys(t.formViews).length||Object.keys(i).length)&&(a.formViews={...t.formViews,...i}),t.primary&&!e.list&&(a.list=t.primary),t.form&&!e.form&&(a.form=t.form),a})}function I(e){if(!e?.length)return e;let t={};for(let n of e){let e=n?.fields;if(!e)continue;let r=Array.isArray(e)?e.map(e=>[e?.name,e]):Object.entries(e);for(let[e,i]of r){let r=i;if(!e||!r?.inlineEdit||r.type!==`master_detail`&&r.type!==`lookup`)continue;let a=r.reference;a&&(t[a]||=[]).push({childObject:n.name,relationshipField:e,inlineMode:c(n,r.inlineEdit,{relationshipField:e}),...r.inlineTitle?{title:r.inlineTitle}:{},...Array.isArray(r.inlineColumns)?{columns:r.inlineColumns}:{},...typeof r.inlineAmountField==`string`?{amountField:r.inlineAmountField}:{}})}}return Object.keys(t).length?e.map(e=>{let n=t[e.name];if(!n?.length)return e;let r={...e.form||{type:`simple`}},i=Array.isArray(r.subforms)?r.subforms:[],a=new Set(i.map(e=>e.childObject));r.subforms=[...n.filter(e=>!a.has(e.childObject)),...i];let o={...e,form:r};return e.formViews?.default&&(o.formViews={...e.formViews,default:{...e.formViews.default,subforms:r.subforms}}),o}):e}function L(){return{status:`idle`,items:[],byName:new Map,error:null,fetchedAt:0,promise:null}}function R(e){if(typeof sessionStorage>`u`)return null;try{let t=sessionStorage.getItem(D+e);if(!t)return null;let n=JSON.parse(t);return Array.isArray(n)?n:null}catch{return null}}function z(e,t){if(!(typeof sessionStorage>`u`))try{sessionStorage.setItem(D+e,JSON.stringify(t))}catch{}}function B({children:e,adapter:t,ttlMs:n=w}){let r=(0,d.useRef)(new Map),i=(0,d.useRef)(new Map),a=(0,d.useRef)(t);a.current=t;let s=b(),c=(0,d.useMemo)(()=>s?C({previewDrafts:!0}):null,[s]),p=(0,d.useRef)(c);p.current=c;let[m,h]=(0,d.useState)(0),g=(0,d.useCallback)(()=>{typeof queueMicrotask==`function`?queueMicrotask(()=>h(e=>e+1)):Promise.resolve().then(()=>h(e=>e+1))},[]);(0,d.useEffect)(()=>{r.current.clear(),i.current.clear(),g()},[s,g]);let _=(0,d.useCallback)(e=>{let t=r.current.get(e);return t||(t=L(),r.current.set(e,t)),t},[]),v=(0,d.useCallback)(e=>{let t=_(e);if(t.promise)return t.promise;if(t.status===`ready`&&Date.now()-t.fetchedAt<n)return A(`cache hit (fresh) type=${e} items=${t.items.length}`),Promise.resolve(t.items);let r=Date.now();t.status=`loading`,t.error=null;let i=p.current,o=(i?i.list(e):a.current.getClient().meta.getItems(e)).then(n=>{let a=j(n);t.items=a,t.status=`ready`,t.error=null,t.fetchedAt=Date.now(),t.promise=null,t.byName.clear();for(let e of a)N(e)&&t.byName.set(e.name,e);return e===`app`&&!i&&z(e,a),A(`fetched type=${e} items=${a.length} in ${Date.now()-r}ms`),g(),a}).catch(n=>{let r=n instanceof Error?n:Error(String(n));return t.status=`error`,t.error=r,t.promise=null,A(`fetch failed type=${e}`,r),g(),[]});return t.promise=o,o},[g,_,n]),y=(0,d.useCallback)((e,t)=>{let n=_(e);if(n.byName.has(t))return A(`item cache hit type=${e} name=${t}`),Promise.resolve(n.byName.get(t)??null);let r=i.current.get(e);r||(r=new Map,i.current.set(e,r));let o=r.get(t);if(o)return o;let s=Date.now(),c=p.current,l=(c?c.get(e,t):a.current.getClient().meta.getItem(e,t)).then(i=>{let a=M(i);return a&&n.byName.set(t,a),A(`fetched item type=${e} name=${t} in ${Date.now()-s}ms`),r.delete(t),a}).catch(n=>(r.delete(t),A(`fetch item failed type=${e} name=${t}`,n),null));return r.set(t,l),l},[_]),x=(0,d.useCallback)(async e=>{if(e){let t=_(e);t.fetchedAt=0,t.byName.clear(),await v(e);return}let t=Array.from(r.current.keys()).filter(e=>r.current.get(e).status!==`idle`);await Promise.all(t.map(e=>{let t=r.current.get(e);return t.fetchedAt=0,t.byName.clear(),v(e)}))},[v,_]),S=(0,d.useCallback)((e,t)=>{let n=r.current.get(e);n&&(t?(n.byName.delete(t),n.items=n.items.filter(e=>e?.name!==t),A(`invalidated type=${e} name=${t}`)):(n.status=`idle`,n.items=[],n.byName.clear(),n.error=null,n.fetchedAt=0,A(`invalidated type=${e}`)),g())},[g]);(0,d.useEffect)(()=>{if(s)return u(({type:e})=>{S(e)})},[s,S]),(0,d.useEffect)(()=>l(()=>{try{a.current?.clearCache?.()}catch{}x()}),[x]);let[D,O]=(0,d.useState)(!0),[k,P]=(0,d.useState)(null);(0,d.useEffect)(()=>{let e=!1,t=s?null:R(`app`);if(t){let e=_(`app`);e.items=t,e.status=`ready`,e.fetchedAt=0;for(let n of t)N(n)&&e.byName.set(n.name,n);g(),O(!1)}return(async()=>{for(let t of T)try{await v(t),e||P(null)}catch(t){e||P(t instanceof Error?t:Error(String(t)))}e||O(!1)})(),()=>{e=!0}},[t,v,_,g,s]);let B=(0,d.useMemo)(()=>{let e=e=>{let t=_(e);return t.status===`idle`&&v(e),t.items};return{apps:_(`app`).items,get objects(){let t=e(E.objects),n=e(`view`);return I(n.length?F(t,n):t)},get dashboards(){return e(E.dashboards)},get reports(){return e(E.reports)},get pages(){return e(E.pages)},loading:D,error:k??_(`app`).error,refresh:x,invalidate:S,ensureType:v,getItem:y,getItemsByType:t=>e(t),getTypeStatus:e=>_(e).status}},[m,D,k,v,y,_,x,S]);return(0,f.jsx)(o.Provider,{value:B,children:e})}export{v as a,y as i,C as n,b as o,m as r,B as t};
@@ -1 +0,0 @@
1
- import{o as e}from"./rolldown-runtime-DAXXjFlN.js";import{f as t,h as n,m as r,r as i,y as a}from"./vendor-react-BKSb6vFP.js";import{f as ee,n as o,p as s,t as c}from"./infrastructure-Bc4DRENl.js";import{l,q as u}from"./framework-BL3BtpKU.js";import{Ar as te,Cr as d,K as f,Pc as p,Pi as ne,Qi as re,U as ie,Va as ae,X as m,q as h,rs as g}from"./ui-components-Y3D5-fgK.js";import{t as oe}from"./RecordDetailView-w6IBQ1cm.js";import{t as _}from"./getIcon-BZsP3YSU.js";import{r as v}from"./useMetadata-D5f_5ULL.js";import{n as y,t as b}from"./CreateViewDialog-DcjN_AhY.js";import{a as x,i as S,n as se,o as ce,r as le,s as ue}from"./InterfaceListPage-Ca4VNsGg.js";import{l as de}from"./plugins-views-CoobEMX4.js";import{t as fe}from"./runtime-metadata-persistence-D1KKivGr.js";var C=e(a(),1),w=i();function pe(e){let t=[];return e.forEach((e,n)=>{let r=/^filter\[(.+)\]$/.exec(n);r&&r[1]&&e!==``&&t.push([r[1],`=`,e])}),t}var T=new Set([`select`,`multiselect`,`radio`,`enum`,`boolean`]),E=4;function D({dataSource:e,objects:i}){let{appName:a,objectName:D}=r(),{t:O}=l(),{objectLabel:k,fieldLabel:A}=p(),j=t(),[M,N]=n(),{can:P}=o(),{canRead:F}=c(D??``),{user:I}=s(),L=ee(),R=v(),[z,B]=C.useState(!1),V=C.useMemo(()=>(i||[]).find(e=>e.name===D),[i,D]),[me]=C.useState(()=>ue(new URLSearchParams(window.location.search))),he=C.useCallback(e=>{N(t=>ce(t,e),{replace:!0})},[N]),H=Array.from(M.entries()).filter(([e])=>e.startsWith(`filter[`)).map(([e,t])=>`${e}=${t}`).join(`&`),U=C.useMemo(()=>{let e=pe(new URLSearchParams(H)),t=e.filter(([e])=>F(e));if(t.length<e.length){let t=e.filter(([e])=>!F(e)).map(([e])=>e);console.warn(`[ObjectDataPage] Dropped URL filter(s) on unreadable field(s): ${t.join(`, `)}`)}return t.map(([e,t,n])=>n===`{current_user_id}`?[e,t,I?.id??n]:[e,t,n])},[H,F,I?.id]),ge=C.useCallback(e=>{N(t=>{let n=new URLSearchParams(t);return n.delete(`filter[${e}]`),n})},[N]),W=C.useMemo(()=>le(V).filter(e=>F(e)),[V,F]),G=C.useMemo(()=>{let e=V?.fields;if(!e||typeof e!=`object`)return;let t=Object.entries(e).filter(([e,t])=>t&&!t.hidden&&T.has(t.type)&&F(e)).slice(0,E).map(([e])=>({field:e}));return t.length>0?{element:`dropdown`,fields:t}:void 0},[V,F]),K=C.useCallback(e=>`/apps/${a}/${D}/record/${encodeURIComponent(String(e))}`,[a,D]),q=u({navigation:{mode:`drawer`},objectName:D??``,onNavigate:e=>j(K(e))}),J=M.get(`recordId`),_e=C.useCallback((e,t)=>{let n=e?.id??e?._id;if(t&&(t.metaKey||t.ctrlKey||t.button===1)&&n!=null){window.open(K(n),`_blank`);return}n!=null&&N(e=>{let t=new URLSearchParams(e);return t.set(`recordId`,String(n)),t})},[K,N]),ve=C.useCallback(()=>{N(e=>{let t=new URLSearchParams(e);return t.delete(`recordId`),t})},[N]);C.useEffect(()=>{J&&!q.isOpen?q.open({id:J}):!J&&q.isOpen&&q.close()},[J]);let Y=C.useMemo(()=>x(V),[V]),X=C.useMemo(()=>se(V),[V]),Z=C.useMemo(()=>S(V),[V]),Q=C.useMemo(()=>{let e=[`grid`];return Y&&e.push(`kanban`),X&&e.push(`calendar`),Z&&e.push(`gallery`),e},[Y,X,Z]),$=C.useMemo(()=>{if(V)return{type:`list-view`,objectName:V.name,viewType:`grid`,fields:W,...U.length?{filters:U}:{},kanban:Y,calendar:X,gallery:Z,userFilters:G,appearance:{allowedVisualizations:Q},showViewSwitcher:Q.length>1,showSearch:!0,showSort:!0,showFilters:!0,showGroup:!0,showHideFields:!0,showDensity:!0,showRecordCount:!0}},[V,W,U,Y,X,Z,G,Q]),ye=C.useCallback(async e=>{try{let t={...e,columns:Array.isArray(e.columns)&&e.columns.length>0?e.columns:W,...U.length?{filter:U}:{}},n=await fe(`view`,String(e?.name??e?.id??``),t,{metadataClient:R});n&&j(`../view/${n}`,{relative:`path`})}catch(e){console.error(`[ObjectDataPage] Failed to save view:`,e)}},[W,U,R,j]);return V?P(V.name,`read`)?(0,w.jsxs)(`div`,{className:`h-full flex flex-col bg-background min-w-0 overflow-hidden`,"data-testid":`object-data-page`,children:[(0,w.jsx)(`div`,{className:`hidden sm:block`,children:(0,w.jsx)(y,{title:(0,w.jsxs)(`span`,{className:`inline-flex items-center gap-2`,children:[(0,w.jsx)(`span`,{className:`truncate`,children:k(V)}),(0,w.jsx)(`span`,{className:`rounded border px-1.5 py-0.5 text-[10px] font-medium uppercase tracking-wide text-muted-foreground`,children:O(`console.objectData.badge`,{defaultValue:`Data`})})]}),description:O(`console.objectData.description`,{defaultValue:`URL-defined data slice — not bound to any saved view.`}),icon:C.createElement(_(V?.icon),{className:`h-4 w-4`}),actions:(0,w.jsxs)(w.Fragment,{children:[P(V.name,`create`)&&(0,w.jsxs)(d,{size:`sm`,onClick:()=>j(`../new`,{relative:`path`}),className:`shadow-none gap-1.5 h-8 sm:h-9`,"data-testid":`object-data-new-button`,children:[(0,w.jsx)(re,{className:`h-4 w-4`}),(0,w.jsx)(`span`,{className:`hidden sm:inline`,children:O(`console.objectView.new`)})]}),L&&(0,w.jsxs)(d,{size:`sm`,variant:`outline`,onClick:()=>B(!0),className:`shadow-none gap-1.5 h-8 sm:h-9`,"data-testid":`object-data-save-as-view`,children:[(0,w.jsx)(ne,{className:`h-4 w-4`}),(0,w.jsx)(`span`,{className:`hidden sm:inline`,children:O(`console.objectData.saveAsView`,{defaultValue:`Save as view`})})]})]})})}),U.length>0&&(0,w.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5 border-b px-3 sm:px-4 py-2 shrink-0`,"data-testid":`object-data-filter-chips`,children:[(0,w.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:O(`console.objectData.filteredBy`,{defaultValue:`Filtered by`})}),U.map(([e,,t])=>(0,w.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded-full border bg-muted/40 px-2 py-0.5 text-xs`,children:[(0,w.jsx)(`span`,{className:`font-medium`,children:A(V.name,e,e)}),(0,w.jsxs)(`span`,{className:`text-muted-foreground`,children:[`= `,String(t)]}),(0,w.jsx)(`button`,{type:`button`,onClick:()=>ge(e),className:`ml-0.5 rounded-full hover:bg-muted p-0.5`,"aria-label":O(`console.objectData.removeFilter`,{defaultValue:`Remove filter {{field}}`,field:e}),"data-testid":`object-data-remove-filter-${e}`,children:(0,w.jsx)(te,{className:`h-3 w-3`})})]},e))]}),(0,w.jsx)(`div`,{className:`flex-1 min-h-0 overflow-auto`,children:$&&(0,w.jsx)(de,{schema:$,dataSource:e,userFilterSelections:me,onUserFilterSelectionsChange:he,onRowClick:_e})}),q.isOverlay&&(0,w.jsx)(ie,{...q,setIsOpen:e=>{e||ve()},title:k(V),children:t=>(0,w.jsx)(oe,{objectNameOverride:V.name,recordIdOverride:String(t?.id??t?._id??J??``),embedded:!0,dataSource:e,objects:i,onEdit:()=>{}})}),L&&(0,w.jsx)(b,{open:z,onOpenChange:B,onCreate:ye,objectDef:V})]}):(0,w.jsx)(`div`,{className:`h-full flex items-center justify-center p-8`,"data-testid":`object-data-403`,children:(0,w.jsxs)(f,{children:[(0,w.jsx)(`div`,{className:`mx-auto mb-4 flex h-12 w-12 items-center justify-center rounded-full bg-muted`,children:(0,w.jsx)(ae,{className:`h-6 w-6 text-muted-foreground`})}),(0,w.jsx)(m,{children:O(`console.objectData.noAccessTitle`,{defaultValue:`Access denied`})}),(0,w.jsx)(h,{children:O(`console.objectData.noAccess`,{defaultValue:`You do not have permission to view this data.`})})]})}):(0,w.jsx)(`div`,{className:`h-full flex items-center justify-center p-8`,children:(0,w.jsxs)(f,{children:[(0,w.jsx)(`div`,{className:`mx-auto mb-4 flex h-12 w-12 items-center justify-center rounded-full bg-muted`,children:(0,w.jsx)(g,{className:`h-6 w-6 text-muted-foreground`})}),(0,w.jsx)(m,{children:O(`console.objectView.objectNotFound`)}),(0,w.jsx)(h,{children:O(`console.objectView.objectNotFoundDescription`,{objectName:D})})]})})}export{D as ObjectDataPage};
@@ -1 +0,0 @@
1
- import{o as e,r as t}from"./rolldown-runtime-DAXXjFlN.js";import{d as n,f as r,h as i,m as a,r as o,y as s}from"./vendor-react-BKSb6vFP.js";import{f as c,h as l,n as u,p as d}from"./infrastructure-Bc4DRENl.js";import{H as f,L as p,R as m,Y as h,b as g,l as _}from"./framework-BL3BtpKU.js";import{Cr as v,H as y,Io as b,K as x,Pc as S,X as C,_r as w,aa as T,br as E,gr as D,mr as O,q as k,vr as A,xr as j,yr as M}from"./ui-components-Y3D5-fgK.js";import{r as N}from"./vendor-ui-utils-D-WJ115h.js";import"./MetadataProvider-DqPZ6rV2.js";import{r as P}from"./ExpressionProvider-CHaGm5wf.js";import{c as ee,i as te,l as ne,r as re,u as ie}from"./RecordDetailView-w6IBQ1cm.js";import{t as F}from"./preferLocal-CKqyhTP9.js";import{t as I}from"./InterfaceListPage-Ca4VNsGg.js";import{n as L,t as R}from"./MetadataInspector-Bqe7rY0S.js";var z=e(s(),1),B=o();function V(e,t){if(/^https?:\/\//i.test(e)||e.startsWith(`mailto:`))return{href:e,external:!e.startsWith(`mailto:`)};let n=(t||``).replace(/\/+$/,``);return{href:`${n}${e}`,external:!!n}}function H({cta:e,apiBase:t,primary:n,onNavigate:r}){let{href:i,external:a}=V(e.url,t);return(0,B.jsx)(v,{asChild:!0,variant:n?`default`:`outline`,size:`sm`,children:(0,B.jsx)(`a`,{href:i,onClick:r,...a?{target:`_blank`,rel:`noopener noreferrer`}:{},"data-testid":`entitlement-cta-${n?`primary`:`secondary`}`,children:e.label})})}function ae({state:e,apiBase:t,onOpenChange:n}){let r=e.spec;return(0,B.jsx)(O,{open:e.open,onOpenChange:e=>{e||n(!1)},children:(0,B.jsxs)(w,{"data-testid":`environment-entitlement-dialog`,children:[(0,B.jsxs)(E,{children:[(0,B.jsx)(j,{children:r?.title}),(0,B.jsx)(A,{children:r?.message})]}),(0,B.jsxs)(M,{children:[(0,B.jsx)(D,{children:`Close`}),r?.secondaryCta&&(0,B.jsx)(H,{cta:r.secondaryCta,apiBase:t,primary:!1,onNavigate:()=>n(!1)}),r?.cta&&(0,B.jsx)(H,{cta:r.cta,apiBase:t,primary:!0,onNavigate:()=>n(!1)})]})]})})}var U=new Set([`DEV_ENV_PLAN_LOCKED`,`DEV_ENV_LIMIT`,`PRODUCTION_ENV_LIMIT`]);function W(e){return typeof e==`string`&&U.has(e)}var G=`/settings/billing`;function oe(e){let t=e?.code;if(!W(t))return null;let n=typeof e?.error==`string`&&e.error?e.error:typeof e?.message==`string`?e.message:``,r=typeof e?.upgrade_url==`string`&&e.upgrade_url?e.upgrade_url:G,i=typeof e?.contact_url==`string`&&e.contact_url?e.contact_url:``;return t===`PRODUCTION_ENV_LIMIT`?{code:t,title:`You already have your production environment`,message:n||`Each organization includes exactly one production environment. Create a separate organization for another, or contact us about an Enterprise arrangement.`,cta:i?{label:`Contact sales`,url:i}:void 0}:{code:t,title:t===`DEV_ENV_PLAN_LOCKED`?`Development environments are a paid feature`:`Development environment limit reached`,message:n||(t===`DEV_ENV_PLAN_LOCKED`?`Your free plan includes one production environment. Upgrade to add development environments — build in dev, then publish to production.`:`Capacity scales with AI seats. Add an AI seat, or archive an unused development environment to free one up.`),cta:{label:`Upgrade plan`,url:r}}}function K(e){return e.hasProductionEnv?e.canCreateDevelopmentEnv===!1?`upgrade_for_development`:`add_development`:`setup_production`}function q(e){return{code:`DEV_ENV_PLAN_LOCKED`,title:`Development environments are a paid feature`,message:`${e.plan&&e.plan!==`free`?`your ${e.plan} plan`:`your free plan`} includes one production environment. Upgrade to add development environments — build in dev, then publish to production.`,cta:{label:`Upgrade plan`,url:e.upgradeUrl||`/settings/billing`}}}var J=/^\s*\{\{\s*page\.([A-Za-z_$][\w$]*(?:\.[A-Za-z_$][\w$]*)*)\s*\}\}\s*$/;function Y(e,t){let n=t;for(let t of e.split(`.`)){if(n==null)return;n=n[t]}return n}function se(e,t){if(!e.includes(`{{`))return e;let n=e.match(J);if(n){let e=Y(n[1],t);return e===void 0?``:e}return e.replace(/\{\{\s*page\.([A-Za-z_$][\w$]*(?:\.[A-Za-z_$][\w$]*)*)\s*\}\}/g,(e,n)=>{let r=Y(n,t);return r==null?``:String(r)})}function X(e,t){if(typeof e==`string`)return se(e,t);if(Array.isArray(e))return e.map(e=>X(e,t));if(e&&typeof e==`object`){let n={};for(let[r,i]of Object.entries(e))n[r]=X(i,t);return n}return e}function Z(e,t){return t?X(e,t):e}var ce={id:`current-user`,name:`Demo User`,isPlatformAdmin:!1};function Q(e){let t=e.locations;return Array.isArray(t)?t.some(e=>e===`list_item`||e===`record_header`||e===`record_more`||e===`record_section`):!1}function $(e){let{dataSource:t,objects:n,objectName:i,onRefresh:a}=e,o=r(),{user:s,activeOrganization:c}=d(),{systemPermissions:f}=u(),{fieldLabel:p,fieldOptionLabel:m,actionParamText:h,actionParamOptionLabel:_,actionDescription:v}=S(),y=(0,z.useMemo)(()=>i?n?.find(e=>e.name===i):void 0,[n,i]),b=i||y?.name,x=(0,z.useCallback)(()=>{a?.()},[a]),C=g({dataSource:t,onUndo:()=>{x(),N.success(`Change undone`)}}),[w,T]=(0,z.useState)({open:!1,message:``}),[E,D]=(0,z.useState)({open:!1,params:[]}),[O,k]=(0,z.useState)({open:!1}),[A,j]=(0,z.useState)(null),[M,P]=(0,z.useState)({open:!1}),F=(0,z.useRef)(new Set),I=(0,z.useCallback)((e,t)=>new Promise(n=>{k({open:!0,spec:e,data:t,resolve:n})}),[]),L=(0,z.useCallback)((e,t)=>new Promise(n=>{T({open:!0,message:e,options:t,resolve:n})}),[]),R=(0,z.useCallback)((e,t)=>new Promise(r=>{let a=t?.params&&!Array.isArray(t.params)?t.params._rowRecord:void 0,o=typeof t?.objectName==`string`&&t.objectName?t.objectName:void 0,s=re(e,{objectName:o||i||y?.name||``,objects:n||[],fieldLabel:p,fieldOptionLabel:m,row:a}),c=o||i||y?.name,l=s.map(e=>({...e,label:h(c,t?.name,e.name,`label`,e.label)??e.label,placeholder:h(c,t?.name,e.name,`placeholder`,e.placeholder)??e.placeholder,helpText:h(c,t?.name,e.name,`helpText`,e.helpText)??e.helpText,options:Array.isArray(e.options)?e.options.map(n=>({...n,label:_(c,t?.name,e.name,n.value,n.label)})):e.options}));D({open:!0,params:l,title:t?.label||t?.title,description:v(c,t?.name,t?.description),resolve:r})}),[i,y,n,p,m,h,_]),V=s?{id:s.id,name:s.name,avatar:s.image,isPlatformAdmin:s?.isPlatformAdmin??!1,systemPermissions:f??[]}:{...ce,systemPermissions:f??[]},H=(0,z.useCallback)((e,t)=>{if(t?.type===`error`){N.error(e);return}if(t?.undo){N.success(e,{duration:t.duration,action:{label:t.undo.label||`Undo`,onClick:()=>{C.undo()}}});return}N.success(e,{duration:t?.duration})},[C]),U=(0,z.useCallback)((e,t)=>{t?.external||t?.newTab?window.open(e,`_blank`,`noopener,noreferrer`):o(e)},[o]),W=(0,z.useMemo)(()=>l(),[]),G=(0,z.useCallback)(e=>{P({open:!0,spec:e})},[]),K=(0,z.useCallback)(async(e,n)=>{try{let r=e.target||e.name,i=e.params||{},a=typeof r==`string`?r:``;if(a.startsWith(`/`)||/^https?:\/\//i.test(a)){let t={...i},r=t._rowRecord;delete t._rowRecord;let o=n?.pageVariables??void 0,s=Z(t,o),l=a;r&&/\{[a-z_][a-z0-9_]*\}/i.test(l)&&(l=l.replace(/\{([a-z_][a-z0-9_]*)\}/gi,(e,t)=>{let n=r[t];return n==null?``:encodeURIComponent(String(n))}));let u=l.startsWith(`http`)?l:`${l}`,d=e.bodyShape&&typeof e.bodyShape==`object`&&e.bodyShape.wrap?e.bodyShape.wrap:void 0,f=d?{[d]:s}:{...s};if(r&&e.recordIdParam){let t=r[e.recordIdField||`id`];t!=null&&(f[e.recordIdParam]=t)}/\/api\/v1\/auth\//.test(l)&&!f.organizationId&&c?.id&&(f.organizationId=c.id),e.bodyExtra&&typeof e.bodyExtra==`object`&&Object.assign(f,Z(e.bodyExtra,o));let p=(e.method||`POST`).toUpperCase(),m={method:p,headers:{"Content-Type":`application/json`},credentials:`include`};p!==`GET`&&p!==`DELETE`&&(m.body=JSON.stringify(f));let h=await W(u,m);if(!h.ok){let e=null;try{e=await h.json()}catch{}let t=oe(e);return t?(G(t),{success:!1}):{success:!1,error:e?.error||e?.message||`HTTP ${h.status}`}}let g=await h.json().catch(()=>({}));return e.refreshAfter!==!1&&x(),{success:!0,data:g&&typeof g==`object`&&!Array.isArray(g)&&`data`in g?g.data:g,reload:e.refreshAfter!==!1}}let o=e.objectName||b,s=i._rowRecord,l={...i};delete l._rowRecord;let u=l.recordId??s?.[e.recordIdField||`id`];delete l.recordId,e.bodyExtra&&typeof e.bodyExtra==`object`&&Object.assign(l,e.bodyExtra),o&&typeof t?.execute==`function`?await t.execute(o,r,l):o&&u&&Object.keys(l).length>0&&typeof t?.update==`function`&&await t.update(o,u,l);let d;if(e.undoable&&o&&u&&s&&Object.keys(l).length>0&&typeof t?.update==`function`){let t={};for(let e of Object.keys(l))t[e]=s[e]??null;d={id:`undo-${o}-${u}-${Date.now()}`,type:`update`,objectName:o,recordId:String(u),timestamp:Date.now(),description:e.label||`Undo ${o}`,undoData:t,redoData:{...l}}}let f=e.refreshAfter!==!1;return f&&x(),{success:!0,reload:f,undo:d}}catch(e){return{success:!1,error:e.message}}},[t,b,W,c,x,G]),q=(0,z.useCallback)(async(e,t)=>{let n=e.target||e.name;if(!n)return{success:!1,error:`No flow target provided for flow action`};try{let r={...e.params||{}},i=r._rowRecord;delete r._rowRecord;let a=r.recordId??i?.id;if(a==null){let n=Array.isArray(t?.selectedRecords)?t.selectedRecords:[];if(n.length===1)a=n[0]?.id;else if(n.length>1)return{success:!1,error:`This flow runs on a single record — select exactly one row.`};else if(Q(e))return{success:!1,error:`This flow runs on a single record — select a row first.`}}a!=null&&r.recordId==null&&(r.recordId=a);let o=await W(`/api/v1/automation/${encodeURIComponent(n)}/trigger`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({recordId:a,objectName:e.objectName||b,params:r})}),s=await o.json().catch(()=>null);if(!o.ok||s&&s.success===!1)return{success:!1,error:s?.error||`Flow "${n}" failed (HTTP ${o.status})`};let c=s?.data??{};if(c.status===`paused`&&c.screen)return j({flowName:n,runId:c.runId,screen:c.screen}),{success:!0,silent:!0};let l=e.refreshAfter!==!1;return l&&x(),{success:!0,data:s?.data,reload:l}}catch(e){return{success:!1,error:e.message}}},[W,b,x]),J=(0,z.useCallback)(async(e,t)=>{let n=e.target||e.name;if(!n)return{success:!1,error:`No action target provided`};let r=e.params&&!Array.isArray(e.params)?{...e.params}:{},i=r._rowRecord;delete r._rowRecord;let a=e.recordIdField||`id`,o=r.recordId??i?.[a];if(o==null){let n=Array.isArray(t?.selectedRecords)?t.selectedRecords:[];if(n.length===1)o=n[0]?.[a];else if(n.length>1)return{success:!1,error:`This action runs on a single record — select exactly one row.`};else if(Q(e))return{success:!1,error:`This action runs on a single record — select a row first.`}}let s=`${n}:${o??``}`;if(F.current.has(s))return{success:!1,error:`Action already in progress`};F.current.add(s);let c=null;if(e.opensInNewTab)try{c=window.open(`about:blank`,`_blank`),c&&(c.document.write(`<!doctype html><meta charset="utf-8"><title>正在打开… Opening…</title><body style="margin:0;font-family:system-ui,sans-serif;display:flex;flex-direction:column;align-items:center;justify-content:center;height:100vh;gap:16px;color:#4b5563"><div style="width:28px;height:28px;border:3px solid #e5e7eb;border-top-color:#6366f1;border-radius:50%;animation:s .8s linear infinite"></div><div>正在为你打开环境…</div><style>@keyframes s{to{transform:rotate(360deg)}}</style></body>`),c.document.close())}catch{c=null}try{let t=typeof e.newTabUrl==`string`?e.newTabUrl:``;if(e.opensInNewTab&&t){if(o==null){if(c)try{c.close()}catch{}return{success:!1,error:`This action runs on a single record — no record id available.`}}let n=`${window.location.origin}${t.replace(`{recordId}`,encodeURIComponent(String(o)))}`;if(c)try{c.location.href=n}catch{try{c.close()}catch{}window.location.href=n}else{let e=null;try{e=window.open(n,`_blank`)}catch{e=null}e||N(`浏览器拦截了弹窗 / Popup blocked`,{description:`点击在新标签页打开环境`,action:{label:`打开环境`,onClick:()=>{try{window.open(n,`_blank`)}catch{window.location.href=n}}},duration:1e4})}return e.refreshAfter===!0&&x(),{success:!0}}let i=e.objectName||b||`global`,a=await W(`/api/v1/actions/${encodeURIComponent(i)}/${encodeURIComponent(n)}`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({recordId:o,params:r})}),s=await a.json().catch(()=>null);if(!a.ok||s&&s.success===!1){let e=s?.error||`Action "${n}" failed (HTTP ${a.status})`;if(c)try{c.close()}catch{}return{success:!1,error:e}}let l=e.refreshAfter!==!1;l&&x();let u=s?.data,d=u&&typeof u==`object`&&typeof u.redirectUrl==`string`?u.redirectUrl:null;if(d)if(c)try{c.location.href=d}catch{try{c.close()}catch{}window.location.href=d}else{let e=null;try{e=window.open(d,`_blank`)}catch{e=null}e||N(`浏览器拦截了弹窗 / Popup blocked`,{description:`点击在新标签页打开环境`,action:{label:`打开环境`,onClick:()=>{try{window.open(d,`_blank`)}catch{window.location.href=d}}},duration:1e4})}else if(c)try{c.close()}catch{}return{success:!0,data:u,reload:l}}catch(e){if(c)try{c.close()}catch{}return{success:!1,error:e.message}}finally{F.current.delete(s)}},[W,b,x]);return{confirmHandler:L,toastHandler:H,navigateHandler:U,paramCollectionHandler:R,resultDialogHandler:I,apiHandler:K,flowHandler:q,serverActionHandler:J,authFetch:W,openEntitlementDialog:G,actionProviderProps:(0,z.useMemo)(()=>({context:{...i?{objectName:i}:{},user:V,apiBase:``,activeOrganization:c?{id:c.id,slug:c.slug,name:c.name}:null},onConfirm:L,onToast:H,onNavigate:U,onParamCollection:R,onResultDialog:I,handlers:{api:K,flow:q,script:J,modal:J}}),[i,V,c,L,H,U,R,I,K,q,J]),dialogs:(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(ie,{state:w,onOpenChange:e=>{e||T({open:!1,message:``})}}),(0,B.jsx)(ne,{state:E,onOpenChange:e=>{e||D({open:!1,params:[]})}}),(0,B.jsx)(ee,{state:O,onAcknowledge:()=>{O.resolve?.(),k({open:!1})}}),(0,B.jsx)(te,{state:A,authFetch:W,baseUrl:``,dataSource:t,objects:n,onClose:()=>j(null),onComplete:()=>{j(null),x()}}),(0,B.jsx)(ae,{state:M,apiBase:``,onOpenChange:e=>{e||P({open:!1})}})]})}}function le({children:e,...t}){let n=$(t);return(0,B.jsxs)(f,{...n.actionProviderProps,children:[e,n.dialogs]})}var ue=t({PageView:()=>de});function de(){let{t:e}=_(),{pageName:t}=a(),[o]=i(),{showDebug:s}=L(),l=r(),u=n(),d=c(),{pages:f,objects:g,getTypeStatus:v}=m(),{app:S}=P(),w=p(),[E,D]=(0,z.useState)(0),O=F(f,t,S?._packageId);if(!O){let n=v?.(`page`);return n===`idle`||n===`loading`?(0,B.jsx)(`div`,{className:`h-full flex items-center justify-center p-8`,"data-testid":`page-loading`,children:(0,B.jsx)(y,{className:`h-5 w-5 text-muted-foreground`})}):(0,B.jsx)(`div`,{className:`h-full flex items-center justify-center p-8`,children:(0,B.jsxs)(x,{children:[(0,B.jsx)(`div`,{className:`mx-auto mb-4 flex h-12 w-12 items-center justify-center rounded-full bg-muted`,children:(0,B.jsx)(b,{className:`h-6 w-6 text-muted-foreground`})}),(0,B.jsx)(C,{children:e(`empty.pageNotFound`)}),(0,B.jsx)(k,{children:e(`empty.pageNotFoundDescription`,{name:t})})]})})}let A=Object.fromEntries(o.entries()),j=u.pathname.match(/\/apps\/([^/]+)/)?.[1],M=d&&!!j&&!!t;return(0,B.jsx)(le,{dataSource:w,objects:g,onRefresh:()=>D(e=>e+1),children:(0,B.jsxs)(`div`,{className:`flex flex-row h-full w-full overflow-hidden relative`,children:[(0,B.jsxs)(`div`,{className:`flex-1 overflow-auto h-full relative`,children:[M&&(0,B.jsx)(`button`,{type:`button`,onClick:()=>{M&&l(`/apps/${j}/metadata/page/${encodeURIComponent(t)}`)},className:`absolute right-3 top-3 z-30 inline-flex h-7 w-7 items-center justify-center rounded-md border border-input bg-background/90 text-muted-foreground shadow-sm backdrop-blur hover:bg-accent hover:text-accent-foreground`,"data-testid":`page-edit-in-studio-button`,title:e(`common.editInStudio`,{defaultValue:`Edit in studio`}),"aria-label":e(`common.editInStudio`,{defaultValue:`Edit in studio`}),children:(0,B.jsx)(T,{className:`h-3.5 w-3.5`})}),O.interfaceConfig?.source?(0,B.jsx)(I,{page:O,reserveEditAffordance:M},E):(0,B.jsx)(h,{schema:{...O,type:O.type||`page`,context:{...O.context,params:A,refreshKey:E}}},E)]}),(0,B.jsx)(R,{open:s,sections:[{title:`Page Configuration`,data:O}]})]})})}export{q as a,K as i,$ as n,G as r,ue as t};