@objectstack/console 11.0.0 → 11.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (101) hide show
  1. package/dist/assets/{AdapterProvider-BieqtbDy.js → AdapterProvider-BTAMdG2T.js} +1 -1
  2. package/dist/assets/{AiPendingActionsPage-_rod9OeO.js → AiPendingActionsPage-BtiQFQw8.js} +1 -1
  3. package/dist/assets/ApiConsolePage-CQJbzAsw.js +1 -0
  4. package/dist/assets/{AppDocsIndex-0yBeTLFW.js → AppDocsIndex-CbHC6KGX.js} +1 -1
  5. package/dist/assets/{AppManagementPage-jXBjId07.js → AppManagementPage-DOoQrTPO.js} +1 -1
  6. package/dist/assets/ApprovalsInboxPage-D6eWYxCu.js +1 -0
  7. package/dist/assets/{AuditLogPage-CO0HOjCA.js → AuditLogPage-F85cQBBY.js} +1 -1
  8. package/dist/assets/{ComponentNavView-DmByVW8F.js → ComponentNavView-g9qw3mhW.js} +1 -1
  9. package/dist/assets/ConsoleFloatingChatbot-Cy-Ny_TS.js +1 -0
  10. package/dist/assets/DashboardView-mIWO-jW_.js +1 -0
  11. package/dist/assets/DashboardWidgetInspector-DOnyBhGN.js +1 -0
  12. package/dist/assets/{DeveloperHubPage-DN8UdQMr.js → DeveloperHubPage-Ci0wA8GZ.js} +1 -1
  13. package/dist/assets/{ExpressionProvider-CT3sX7xF.js → ExpressionProvider-NqLS0ljf.js} +1 -1
  14. package/dist/assets/FlowRunsPage-CNz2_VFK.js +1 -0
  15. package/dist/assets/{IntegrationsPage-CqLzZMOK.js → IntegrationsPage-CAZ3nsKJ.js} +2 -2
  16. package/dist/assets/{InterfaceListPage-GcApvEz0.js → InterfaceListPage-D1BbH0Iy.js} +1 -1
  17. package/dist/assets/{ManagedByBadge-5eJy46Si.js → ManagedByBadge-6DwSVsdr.js} +1 -1
  18. package/dist/assets/{MarketplaceAccessDenied-BGBYYv_M.js → MarketplaceAccessDenied-Cyx7lSjy.js} +1 -1
  19. package/dist/assets/{MarketplaceInstalledPage-Fa8EY_5o.js → MarketplaceInstalledPage-C41H1YlB.js} +1 -1
  20. package/dist/assets/{MarketplacePackagePage-DC6zA893.js → MarketplacePackagePage-Bihb2q1b.js} +2 -2
  21. package/dist/assets/{MarketplacePage-nv-oKrlO.js → MarketplacePage-C2B6TMNM.js} +1 -1
  22. package/dist/assets/MetadataInspector-COEBMw6y.js +1 -0
  23. package/dist/assets/{MetadataProvider-fKK6GbWD.js → MetadataProvider-D234gTjV.js} +1 -1
  24. package/dist/assets/PageView-DuiaqvzN.js +1 -0
  25. package/dist/assets/ProfilePage-B1oCou0F.js +1 -0
  26. package/dist/assets/PublicFormsPage-C2prdsH6.js +1 -0
  27. package/dist/assets/RecordDetailView-B-AuOKPI.js +9 -0
  28. package/dist/assets/{RecordFormPage-Bkn_bUyo.js → RecordFormPage-CpKMoOCj.js} +1 -1
  29. package/dist/assets/ReportDefaultInspector-DxP-Ac7I.js +11 -0
  30. package/dist/assets/{ReportView-Gq01PZlc.js → ReportView-Cw9Ompki.js} +1 -1
  31. package/dist/assets/{SearchResultsPage-C3SyFv3R.js → SearchResultsPage-CZ038ncU.js} +1 -1
  32. package/dist/assets/{SettingsHub-BLCpGzj-.js → SettingsHub-BXe-fVlJ.js} +1 -1
  33. package/dist/assets/{SettingsView-Cd6iNy3t.js → SettingsView-DxPgTnlF.js} +1 -1
  34. package/dist/assets/{SystemHubPage-DBdBlyat.js → SystemHubPage-CJq_1ITt.js} +1 -1
  35. package/dist/assets/{data-adapter-C8ELgvKP.js → data-adapter-02g96tfY.js} +1 -1
  36. package/dist/assets/{framework-CQlIjbCT.js → framework-h98DIM1k.js} +7 -7
  37. package/dist/assets/{highlighted-body-OFNGDK62-02fX_5a1.js → highlighted-body-OFNGDK62-DO9p_wSr.js} +1 -1
  38. package/dist/assets/index-BQhiWf8_.js +2 -0
  39. package/dist/assets/index-WhD62Q-7.css +2 -0
  40. package/dist/assets/infrastructure-B1z73d-r.js +3 -0
  41. package/dist/assets/{marketplaceApi-D36MnuCE.js → marketplaceApi-B_Gmytip.js} +1 -1
  42. package/dist/assets/mermaid-GHXKKRXX-DEmtnxCC.js +1 -0
  43. package/dist/assets/metadata-admin-DStYGsRM.js +22 -0
  44. package/dist/assets/plugin-calendar-BYmYEyQk.js +1 -0
  45. package/dist/assets/plugin-charts-BDFf0TCn.js +7 -0
  46. package/dist/assets/plugin-chatbot-CnuZn8AC.js +120 -0
  47. package/dist/assets/plugin-dashboard-CuwYQhsg.js +6 -0
  48. package/dist/assets/plugin-form-CH8ruD9E.js +1 -0
  49. package/dist/assets/plugin-gantt-BB8ZeREv.js +93 -0
  50. package/dist/assets/plugin-grid-D414NLNP.js +6 -0
  51. package/dist/assets/plugin-kanban-BRFJEEAA.js +1 -0
  52. package/dist/assets/{plugin-map-CIN-oBC5.js → plugin-map-rEWoyyKa.js} +1 -1
  53. package/dist/assets/{plugin-markdown-DU8O5B7L.js → plugin-markdown-BgV76qm3.js} +1 -1
  54. package/dist/assets/plugin-report-C-YPOtvZ.js +59 -0
  55. package/dist/assets/{plugin-timeline-BMM7P_hx.js → plugin-timeline-CC91-fmI.js} +1 -1
  56. package/dist/assets/{plugin-tree-CErRKxCG.js → plugin-tree-D2QWz1x1.js} +1 -1
  57. package/dist/assets/plugin-view-C6iEzx93.js +1 -0
  58. package/dist/assets/plugins-views-CcoNygsH.js +4 -0
  59. package/dist/assets/{skeletons-k9g6qZSy.js → skeletons-BQ5aRDUn.js} +1 -1
  60. package/dist/assets/{src-BcFufHSl.js → src-C4OnKiir.js} +1 -1
  61. package/dist/assets/src-CKHT6scJ.js +2 -0
  62. package/dist/assets/{types-DXihP4sI.js → types-BUZu4QOP.js} +1 -1
  63. package/dist/assets/ui-components-C9egdVxV.js +42 -0
  64. package/dist/assets/{ui-layout-C9ykUXmg.js → ui-layout-BwokMuBv.js} +1 -1
  65. package/dist/assets/{useActionModal-DJG5Babl.js → useActionModal-ChUaxcEW.js} +1 -1
  66. package/dist/assets/{useOpenRecordList-D-g511Jw.js → useOpenRecordList-BkSEs2q6.js} +1 -1
  67. package/dist/assets/{useReconcileOnError-QYVPx52o.js → useReconcileOnError-FPUCNTHc.js} +1 -1
  68. package/dist/assets/vendor-objectstack-BTQLr7T3.js +96 -0
  69. package/dist/index.html +4 -4
  70. package/package.json +1 -1
  71. package/dist/assets/ApiConsolePage-WCI3DIIi.js +0 -1
  72. package/dist/assets/ApprovalsInboxPage-BYHBBA9y.js +0 -1
  73. package/dist/assets/ConsoleFloatingChatbot-C_BlXoV1.js +0 -1
  74. package/dist/assets/DashboardView-Cs-MC_5A.js +0 -1
  75. package/dist/assets/DashboardWidgetInspector-ce9fT5XA.js +0 -1
  76. package/dist/assets/FlowRunsPage-DPj0zPLk.js +0 -1
  77. package/dist/assets/MetadataInspector-XbWYccBm.js +0 -1
  78. package/dist/assets/PageView-C9b2DYFF.js +0 -1
  79. package/dist/assets/ProfilePage-D7Ie0WN7.js +0 -1
  80. package/dist/assets/PublicFormsPage-BaKsA3Eo.js +0 -1
  81. package/dist/assets/RecordDetailView-CfCIFeA9.js +0 -9
  82. package/dist/assets/ReportDefaultInspector-CoxrLLKh.js +0 -11
  83. package/dist/assets/index-Vh0-yrfs.js +0 -2
  84. package/dist/assets/index-_u4ypVlX.css +0 -2
  85. package/dist/assets/infrastructure-BtLHjSlJ.js +0 -3
  86. package/dist/assets/mermaid-GHXKKRXX-BeAYGylq.js +0 -1
  87. package/dist/assets/metadata-admin-mBijR3yo.js +0 -22
  88. package/dist/assets/plugin-calendar-BdTHA4Ee.js +0 -1
  89. package/dist/assets/plugin-charts-DoMMZZk8.js +0 -7
  90. package/dist/assets/plugin-chatbot-CumNGrh8.js +0 -120
  91. package/dist/assets/plugin-dashboard-Bl7wuG9f.js +0 -6
  92. package/dist/assets/plugin-form-hyYQoCHc.js +0 -1
  93. package/dist/assets/plugin-gantt-BsnXplf2.js +0 -93
  94. package/dist/assets/plugin-grid-DvI8i3CO.js +0 -6
  95. package/dist/assets/plugin-kanban-DmKa19Zc.js +0 -1
  96. package/dist/assets/plugin-report-JWTVyA2R.js +0 -59
  97. package/dist/assets/plugin-view-BMfFD77p.js +0 -1
  98. package/dist/assets/plugins-views-iYrs182B.js +0 -4
  99. package/dist/assets/src-Dnw5qGGv.js +0 -2
  100. package/dist/assets/ui-components-CgiD1ql5.js +0 -42
  101. package/dist/assets/vendor-objectstack-C1teU2a6.js +0 -96
package/dist/index.html CHANGED
@@ -18,12 +18,12 @@
18
18
  <script>
19
19
  window.process = window.process || { env: { NODE_ENV: 'development' }, version: '', platform: 'browser' };
20
20
  </script>
21
- <script type="module" crossorigin src="./assets/index-Vh0-yrfs.js"></script>
21
+ <script type="module" crossorigin src="./assets/index-BQhiWf8_.js"></script>
22
22
  <link rel="stylesheet" crossorigin href="./assets/ui-components-BL3SEdAz.css">
23
23
  <link rel="stylesheet" crossorigin href="./assets/plugin-dashboard-DnNKJB60.css">
24
- <link rel="stylesheet" crossorigin href="./assets/index-_u4ypVlX.css">
25
- <link rel="modulepreload" href="./assets/framework-CQlIjbCT.js" />
26
- <link rel="modulepreload" href="./assets/ui-components-CgiD1ql5.js" />
24
+ <link rel="stylesheet" crossorigin href="./assets/index-WhD62Q-7.css">
25
+ <link rel="modulepreload" href="./assets/framework-h98DIM1k.js" />
26
+ <link rel="modulepreload" href="./assets/ui-components-C9egdVxV.js" />
27
27
  <link rel="modulepreload" href="./assets/vendor-radix-90T7eS-d.js" />
28
28
  <link rel="modulepreload" href="./assets/vendor-react-ClIa1CJA.js" />
29
29
  </head>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@objectstack/console",
3
- "version": "11.0.0",
3
+ "version": "11.1.0",
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-CMxvf4Kt.js";import{_ as t,t as n}from"./vendor-react-ClIa1CJA.js";import{A as r}from"./framework-CQlIjbCT.js";import{Ei as i,Er as a,Gr as o,Is as s,Jn as c,La as l,Rs as u,Yi as d,Yn as f,fs as p,is as m,mo as h,qi as g,qn as _,rr as v,zi as ee,zs as te}from"./ui-components-CgiD1ql5.js";import"./src-Dnw5qGGv.js";var y=e(t(),1),b=[`plugin`,`plugins`,`kind`,`package`];function x(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 S={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 C(e,t){let n=S[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 ne(){let e=r(),[t,n]=(0,y.useState)([]),[i,a]=(0,y.useState)([]),[o,s]=(0,y.useState)(!0),[c,l]=(0,y.useState)(null),u=(0,y.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(S)){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(...C(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=>!b.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,...x(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`];n(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}))),a(g)}catch(e){l(e.message||`Failed to discover APIs`)}finally{s(!1)}},[e]);return(0,y.useEffect)(()=>{u()},[u]),{groups:t,allEndpoints:i,loading:o,error:c,refresh:u}}var w=n(),T={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`},E={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`},re=[{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`}],D=1;function O(){let e=r()?.getClient?.(),{groups:t,loading:n,refresh:b}=ne(),[x,S]=(0,y.useState)(``),[C,O]=(0,y.useState)(new Set),[k,A]=(0,y.useState)(null),[ie,j]=(0,y.useState)(``),[ae,M]=(0,y.useState)(``),[N,P]=(0,y.useState)(``),[F,I]=(0,y.useState)([]),[L,R]=(0,y.useState)(!1),[z,B]=(0,y.useState)(null),[V,H]=(0,y.useState)([]),[U,oe]=(0,y.useState)(null),[W,G]=(0,y.useState)(!1),K=(0,y.useMemo)(()=>{if(!x)return t;let e=x.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,x]),se=(0,y.useCallback)(e=>{O(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[]),ce=(0,y.useCallback)(e=>{A(e),j(e.method),M(e.path),P(e.bodyTemplate?JSON.stringify(e.bodyTemplate,null,2):``),I([]),B(null)},[]),q=ie||k?.method||`GET`,J=ae||k?.path||``,Y=(0,y.useMemo)(()=>{let e=F.filter(e=>e.enabled&&e.key.trim());return e.length===0?J:`${J}?${e.map(e=>`${encodeURIComponent(e.key)}=${encodeURIComponent(e.value)}`).join(`&`)}`},[J,F]),X=(0,y.useCallback)((e=``,t=``)=>{I(n=>[...n,{id:D++,key:e,value:t,enabled:!0}])},[]),le=(0,y.useCallback)(e=>{I(t=>t.filter(t=>t.id!==e))},[]),Z=(0,y.useCallback)((e,t,n)=>{I(r=>r.map(r=>r.id===e?{...r,[t]:n}:r))},[]),ue=(0,y.useCallback)(e=>{I(t=>t.map(t=>t.id===e?{...t,enabled:!t.enabled}:t))},[]),Q=(0,y.useCallback)(async()=>{if(L||!Y)return;let t=`${e?.baseUrl??``}${Y}`;R(!0);let n=performance.now();try{let e={method:q,headers:{"Content-Type":`application/json`}};[`POST`,`PATCH`,`PUT`].includes(q)&&N.trim()&&(e.body=N);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();B({status:r.status,body:a,duration:i}),H(e=>[{id:Date.now(),method:q,url:Y,body:N||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);B({status:0,body:`Network Error: ${e.message}`,duration:t})}finally{R(!1)}},[e,Y,q,N,L]),de=(0,y.useCallback)(e=>{j(e.method);let[t,n]=e.url.split(`?`);if(M(t),P(e.body||``),n){let e=new URLSearchParams(n),t=[];e.forEach((e,n)=>{t.push({id:D++,key:n,value:e,enabled:!0})}),I(t)}else I([]);B(null),A(null)},[]),fe=(0,y.useCallback)(()=>{z?.body&&(navigator.clipboard.writeText(z.body),G(!0),setTimeout(()=>G(!1),1500))},[z]),$=e=>E[String(e)[0]]??`text-muted-foreground`;return(0,w.jsxs)(`div`,{className:`flex flex-1 min-h-0 overflow-hidden`,children:[(0,w.jsxs)(`div`,{className:`w-72 shrink-0 border-r flex flex-col overflow-hidden`,children:[(0,w.jsxs)(`div`,{className:`p-3 border-b space-y-2`,children:[(0,w.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,w.jsx)(`h3`,{className:`text-sm font-semibold text-foreground flex-1`,children:`API Endpoints`}),(0,w.jsx)(`button`,{onClick:b,disabled:n,className:`p-1 rounded hover:bg-muted transition-colors text-muted-foreground hover:text-foreground`,title:`Refresh endpoints`,children:(0,w.jsx)(ee,{className:`h-3.5 w-3.5 ${n?`animate-spin`:``}`})})]}),(0,w.jsxs)(`div`,{className:`relative`,children:[(0,w.jsx)(i,{className:`absolute left-2.5 top-1/2 h-3.5 w-3.5 -translate-y-1/2 text-muted-foreground`}),(0,w.jsx)(`input`,{type:`text`,value:x,onChange:e=>S(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,w.jsx)(`div`,{className:`flex-1 overflow-auto p-2 space-y-1`,children:n?(0,w.jsxs)(`div`,{className:`flex items-center justify-center py-8 text-muted-foreground text-sm`,children:[(0,w.jsx)(l,{className:`h-4 w-4 animate-spin mr-2`}),`Discovering APIs...`]}):K.length===0?(0,w.jsxs)(`div`,{className:`flex flex-col items-center justify-center py-8 text-muted-foreground text-sm`,children:[(0,w.jsx)(h,{className:`h-6 w-6 opacity-30 mb-2`}),(0,w.jsx)(`span`,{children:x?`No matching endpoints`:`No endpoints found`})]}):K.map(e=>{let t=C.has(e.key)||!!x;return(0,w.jsxs)(_,{open:t,onOpenChange:()=>se(e.key),children:[(0,w.jsx)(f,{asChild:!0,children:(0,w.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,w.jsx)(s,{className:`h-3 w-3 shrink-0 transition-transform duration-200 ${t?`rotate-90`:``}`}),(0,w.jsx)(`span`,{className:`flex-1 text-left truncate`,children:e.label}),(0,w.jsx)(`span`,{className:`shrink-0 text-[10px] tabular-nums opacity-60`,children:e.endpoints.length})]})}),(0,w.jsx)(c,{children:(0,w.jsx)(`div`,{className:`ml-3 space-y-0.5 mt-0.5`,children:e.endpoints.map((e,t)=>(0,w.jsxs)(`button`,{onClick:()=>ce(e),className:`w-full text-left flex items-center gap-1.5 px-2 py-1 rounded text-xs transition-colors ${k===e?`bg-accent text-accent-foreground`:`hover:bg-muted/50 text-muted-foreground hover:text-foreground`}`,children:[(0,w.jsx)(v,{variant:`outline`,className:`font-mono text-[9px] shrink-0 px-1 py-0 ${T[e.method]||``}`,children:e.method}),(0,w.jsx)(`span`,{className:`truncate`,children:e.desc})]},`${e.method}-${e.path}-${t}`))})})]},e.key)})}),(0,w.jsxs)(`div`,{className:`p-3 border-t space-y-2`,children:[(0,w.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,w.jsx)(`h4`,{className:`text-[10px] font-medium text-muted-foreground uppercase tracking-wider`,children:`Query Parameters`}),(0,w.jsxs)(`button`,{onClick:()=>X(),className:`inline-flex items-center gap-0.5 text-[10px] text-muted-foreground hover:text-foreground transition-colors`,children:[(0,w.jsx)(g,{className:`h-3 w-3`}),`Add`]})]}),(0,w.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:re.map(e=>(0,w.jsx)(`button`,{onClick:()=>X(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))}),F.length>0&&(0,w.jsx)(`div`,{className:`space-y-1`,children:F.map(e=>(0,w.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,w.jsx)(`input`,{type:`checkbox`,checked:e.enabled,onChange:()=>ue(e.id),className:`h-3 w-3 shrink-0 rounded border accent-primary`}),(0,w.jsx)(`input`,{type:`text`,value:e.key,onChange:t=>Z(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,w.jsx)(`input`,{type:`text`,value:e.value,onChange:t=>Z(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,w.jsx)(`button`,{onClick:()=>le(e.id),className:`shrink-0 p-0.5 rounded text-muted-foreground hover:text-destructive transition-colors`,children:(0,w.jsx)(a,{className:`h-3 w-3`})})]},e.id))})]})]}),(0,w.jsxs)(`div`,{className:`flex-1 flex flex-col min-w-0 overflow-hidden`,children:[(0,w.jsxs)(`div`,{className:`p-3 border-b space-y-1`,children:[(0,w.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,w.jsx)(`select`,{value:q,onChange:e=>j(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 ${T[q]||``}`,children:[`GET`,`POST`,`PATCH`,`PUT`,`DELETE`].map(e=>(0,w.jsx)(`option`,{value:e,children:e},e))}),(0,w.jsx)(`input`,{type:`text`,value:J,onChange:e=>M(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`&&Q()}}),(0,w.jsxs)(`button`,{onClick:Q,disabled:L||!Y,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:[L?(0,w.jsx)(l,{className:`h-3.5 w-3.5 animate-spin`}):(0,w.jsx)(d,{className:`h-3.5 w-3.5`}),`Send`]})]}),F.some(e=>e.enabled&&e.key.trim())&&(0,w.jsxs)(`div`,{className:`text-[10px] font-mono text-muted-foreground truncate pl-1`,children:[`→ `,Y]})]}),(0,w.jsxs)(`div`,{className:`flex-1 flex flex-col min-h-0 overflow-auto`,children:[[`POST`,`PATCH`,`PUT`].includes(q)&&(0,w.jsxs)(`div`,{className:`p-3 border-b space-y-1`,children:[(0,w.jsx)(`label`,{className:`text-xs font-medium text-muted-foreground`,children:`Request Body (JSON)`}),(0,w.jsx)(`textarea`,{value:N,onChange:e=>P(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" }`})]}),L&&(0,w.jsxs)(`div`,{className:`flex items-center justify-center py-8 text-muted-foreground text-sm`,children:[(0,w.jsx)(l,{className:`h-4 w-4 animate-spin mr-2`}),`Sending request...`]}),z&&!L&&(0,w.jsxs)(`div`,{className:`flex-1 min-h-0 flex flex-col overflow-hidden`,children:[(0,w.jsxs)(`div`,{className:`flex items-center justify-between px-3 py-2 bg-muted/30 border-b`,children:[(0,w.jsxs)(`div`,{className:`flex items-center gap-3 text-sm`,children:[(0,w.jsx)(`span`,{className:`font-mono font-semibold ${$(z.status)}`,children:z.status||`ERR`}),(0,w.jsxs)(`span`,{className:`text-muted-foreground flex items-center gap-1`,children:[(0,w.jsx)(p,{className:`h-3 w-3`}),z.duration,`ms`]})]}),(0,w.jsxs)(`button`,{onClick:fe,className:`inline-flex items-center gap-1 text-xs text-muted-foreground hover:text-foreground transition-colors`,children:[W?(0,w.jsx)(te,{className:`h-3 w-3`}):(0,w.jsx)(m,{className:`h-3 w-3`}),W?`Copied`:`Copy`]})]}),(0,w.jsx)(`pre`,{className:`flex-1 overflow-auto p-3 text-xs font-mono bg-muted/10 whitespace-pre-wrap break-all`,children:z.body})]}),!z&&!L&&(0,w.jsx)(`div`,{className:`flex-1 flex items-center justify-center text-muted-foreground text-sm`,children:(0,w.jsxs)(`div`,{className:`text-center space-y-2`,children:[(0,w.jsx)(h,{className:`h-10 w-10 mx-auto opacity-20`}),(0,w.jsxs)(`p`,{children:[`Select an endpoint or type a URL and click `,(0,w.jsx)(`strong`,{children:`Send`})]}),(0,w.jsx)(`p`,{className:`text-xs opacity-60`,children:`All registered APIs are auto-discovered from the platform`})]})}),V.length>0&&(0,w.jsxs)(`div`,{className:`border-t`,children:[(0,w.jsxs)(`div`,{className:`flex items-center justify-between px-3 py-2`,children:[(0,w.jsxs)(`h4`,{className:`text-xs font-medium text-muted-foreground uppercase tracking-wider`,children:[`History (`,V.length,`)`]}),(0,w.jsxs)(`button`,{onClick:()=>H([]),className:`inline-flex items-center gap-1 text-[10px] text-muted-foreground hover:text-foreground transition-colors`,children:[(0,w.jsx)(o,{className:`h-3 w-3`}),`Clear`]})]}),(0,w.jsx)(`div`,{className:`space-y-0.5 px-2 pb-2 max-h-60 overflow-auto`,children:V.map(e=>(0,w.jsxs)(`div`,{className:`rounded border`,children:[(0,w.jsxs)(`button`,{onClick:()=>oe(U===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:[U===e.id?(0,w.jsx)(u,{className:`h-3 w-3 shrink-0`}):(0,w.jsx)(s,{className:`h-3 w-3 shrink-0`}),(0,w.jsx)(v,{variant:`outline`,className:`font-mono text-[9px] shrink-0 ${T[e.method]||``}`,children:e.method}),(0,w.jsx)(`span`,{className:`font-mono truncate text-left flex-1`,children:e.url}),(0,w.jsx)(`span`,{className:`ml-auto shrink-0 font-mono ${$(e.status)}`,children:e.status}),(0,w.jsxs)(`span`,{className:`shrink-0 text-muted-foreground`,children:[e.duration,`ms`]}),(0,w.jsx)(`button`,{onClick:t=>{t.stopPropagation(),de(e)},className:`shrink-0 p-0.5 rounded hover:bg-muted text-muted-foreground hover:text-foreground transition-colors`,title:`Replay request`,children:(0,w.jsx)(d,{className:`h-2.5 w-2.5`})})]}),U===e.id&&(0,w.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{O as ApiConsolePage};
@@ -1 +0,0 @@
1
- import{o as e}from"./rolldown-runtime-CMxvf4Kt.js";import{_ as t,f as n,r,t as i}from"./vendor-react-ClIa1CJA.js";import{d as a,f as ee}from"./infrastructure-BtLHjSlJ.js";import{i as te}from"./framework-CQlIjbCT.js";import{As as ne,Br as re,Bt as ie,Ds as ae,Ei as oe,Er as se,Fr as ce,Ft as le,G as ue,Gt as o,H as de,Ht as fe,Is as pe,Kt as me,Ls as he,Lt as ge,Qn as _e,Rt as ve,Ss as ye,Tc as s,Ti as be,Ut as xe,V as Se,Vt as Ce,Wo as we,Wt as Te,Xn as Ee,Zn as De,_r as c,an as Oe,at as ke,cr as Ae,ct as je,dr as l,dt as u,fi as Me,fr as d,fs as Ne,ft as f,gr as p,hr as m,is as Pe,it as Fe,lc as Ie,ln as Le,lt as Re,mr as h,mt as ze,ot as Be,pr as g,pt as Ve,qt as He,rr as Ue,sr as We,st as Ge,ts as Ke,ur as _,ut as qe,vc as Je,vr as Ye,vs as Xe,yr as v,zi as Ze,zs as Qe,zt as $e}from"./ui-components-CgiD1ql5.js";import{r as y}from"./vendor-ui-utils-C92Fl7BT.js";var b=e(t(),1),et=`${``.replace(/\/$/,``)}/api/v1`;async function x(e,t){let n=await fetch(`${et}${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 S={listProcesses(e={}){let t=new URLSearchParams;e.object&&t.set(`object`,e.object),e.activeOnly&&t.set(`activeOnly`,`true`);let n=t.toString();return x(`/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 x(`/approvals/requests${r?`?${r}`:``}`)},async getRequest(e){return{data:await x(`/approvals/requests/${encodeURIComponent(e)}`)}},listActions(e){return x(`/approvals/requests/${encodeURIComponent(e)}/actions`)},async approve(e,t){let n=await x(`/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 x(`/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 x(`/approvals/requests/${encodeURIComponent(e)}/recall`,{method:`POST`,body:JSON.stringify(t)})).request,finalized:!0}},async reassign(e,t){return{data:(await x(`/approvals/requests/${encodeURIComponent(e)}/reassign`,{method:`POST`,body:JSON.stringify(t)})).request}},async remind(e,t={}){let n=await x(`/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 x(`/approvals/requests/${encodeURIComponent(e)}/request-info`,{method:`POST`,body:JSON.stringify(t)})).request}},async sendBack(e,t){let n=await x(`/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 x(`/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 x(`/approvals/requests/${encodeURIComponent(e)}/comment`,{method:`POST`,body:JSON.stringify(t)})).request}},async submit(e){return x(`/approvals/requests`,{method:`POST`,body:JSON.stringify(e)})}};function tt(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 C=i(),nt=50,rt={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 it(e){if(!e)return`—`;try{return new Date(e).toLocaleString()}catch{return e}}function w(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 T(e){return e&&String(e).replace(/^flow:/,``).trim().split(/[_\-\s]+/).filter(Boolean).map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(` `)||`—`}function at(e){return e.process_label||T(e.process_name)}function ot(e){return e.step_label?e.step_label:e.current_step?T(e.current_step):null}function st(e){return e.submitter_name||w(e.submitter_id)}function ct(e,t){return t.pending_approver_names?.[e]||w(e)}function lt(e){return e.object_label||e.object_name}function E(e){return e.submitted_at||e.created_at||void 0}function D(e){let t=E(e);if(!t)return null;let n=Date.parse(t);return Number.isNaN(n)?null:(Date.now()-n)/36e5}function ut(e){if(e.status!==`pending`)return`text-muted-foreground`;let t=D(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 dt(e){let t=Math.max(1,Math.round(Math.abs(e)/36e5));return t<48?`${t}h`:`${Math.round(t/24)}d`}var O=new Set([`id`,`created_at`,`updated_at`,`created_by`,`updated_by`,`organization_id`]);function k(e){return e.split(`_`).filter(Boolean).map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(` `)}function A(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 ft=/^[A-Za-z0-9_-]{15,}$/;function pt(e,t,n=6){if(!e||typeof e!=`object`||Array.isArray(e))return[];let r=[];for(let[i,a]of Object.entries(e)){if(O.has(i)||a==null||typeof a==`object`||String(a).trim()===``)continue;let e=t?.[i];if(!(!e&&typeof a==`string`&&ft.test(a.trim())&&!/^\d+$/.test(a.trim()))&&(r.push([k(i),e??A(i,a)]),r.length>=n))break}return r}function mt(){let{t:e,language:t}=te(),{user:i}=ee(),et=a(),{appName:x}=n(),T=(0,b.useMemo)(()=>tt(i),[i]),D=(0,b.useCallback)((t,n,r)=>String(e(`approvalsInbox.${t}`,{defaultValue:n,...r})),[e]),O=(0,b.useCallback)(e=>{if(!e)return`—`;let n=Date.parse(e);if(Number.isNaN(n))return e;let r=Math.round((Date.now()-n)/1e3);if(r<45)return D(`justNow`,`just now`);let i=Math.round(r/60);if(i<60)return D(`minutesAgo`,`{{count}}m ago`,{count:i});let a=Math.round(i/60);if(a<24)return D(`hoursAgo`,`{{count}}h ago`,{count:a});let ee=Math.round(a/24);if(ee<30)return D(`daysAgo`,`{{count}}d ago`,{count:ee});try{return new Date(e).toLocaleDateString(t)}catch{return e}},[D,t]),k=(0,b.useCallback)(e=>{switch(e){case`pending`:return D(`statusPending`,`Pending`);case`approved`:return D(`statusApproved`,`Approved`);case`rejected`:return D(`statusRejected`,`Rejected`);case`recalled`:return D(`statusRecalled`,`Recalled`);case`returned`:return D(`statusReturned`,`Returned for revision`);default:return e}},[D]),A=(0,b.useCallback)((e,t)=>{let n=e?.code??``,r=e?.status??0;return n===`NOT_IMPLEMENTED`||r===501?D(`recallUnavailable`,`Recall is not available on this deployment.`):n===`THROTTLED`||r===429?D(`remindThrottled`,`A reminder was sent recently — try again later.`):r===404?D(`requestGone`,`This request no longer exists. Refresh the list.`):n===`FORBIDDEN`||r===403?D(`notAllowed`,`You are not allowed to perform this action.`):n===`INVALID_STATE`||r===409?D(`alreadyDecided`,`This request was already decided. Refresh the list.`):e?.message||t},[D]);function ft({status:e}){return(0,C.jsx)(Ue,{variant:`outline`,className:s(`font-medium`,rt[e]??``),children:k(e)})}let mt=(0,b.useCallback)(e=>`/apps/${x||`setup`}/${encodeURIComponent(e.object_name)}/record/${encodeURIComponent(e.record_id)}`,[x]),[j,ht]=(0,b.useState)(`pending`),[M,gt]=(0,b.useState)([]),[_t,vt]=(0,b.useState)(!1),[yt,bt]=(0,b.useState)(!1),[xt,St]=(0,b.useState)(null),[Ct,wt]=(0,b.useState)(null),[Tt,Et]=(0,b.useState)(0),[N,Dt]=(0,b.useState)(null),[P,Ot]=(0,b.useState)(null),[kt,At]=(0,b.useState)([]),[jt,Mt]=(0,b.useState)(!1),[F,I]=(0,b.useState)(``),[L,Nt]=(0,b.useState)(``),[R,Pt]=(0,b.useState)(null),[z,Ft]=(0,b.useState)(``),[It,Lt]=(0,b.useState)(``),[Rt,zt]=(0,b.useState)(`all`),[Bt,Vt]=(0,b.useState)(`all`),[B,Ht]=(0,b.useState)(`all`),[V,Ut]=(0,b.useState)(new Set),[Wt,Gt]=(0,b.useState)(!1),[H,Kt]=(0,b.useState)(null),[qt,Jt]=(0,b.useState)(null),[Yt,Xt]=(0,b.useState)(!1),[U,Zt]=(0,b.useState)(``),[Qt,$t]=(0,b.useState)(!1),[en,tn]=(0,b.useState)(``),[nn,rn]=(0,b.useState)(!1),[an,on]=(0,b.useState)(``),[sn,cn]=(0,b.useState)(!1),[ln,un]=(0,b.useState)(``),[W,G]=(0,b.useState)(!1),[dn,fn]=(0,b.useState)([]),[pn,mn]=(0,b.useState)(-1);(0,b.useEffect)(()=>{if(j===`pending`)return;let e=window.setTimeout(()=>Lt(z),350);return()=>window.clearTimeout(e)},[z,j]);let K=(0,b.useCallback)(async()=>{vt(!0),wt(null);try{let e=[];if(j===`pending`)e=T.length?(await S.listRequests({status:`pending`,approverId:T})).data:[],Et(e.length),St(null);else{let t={q:It||void 0,status:B===`all`?void 0:B,limit:nt,offset:0};if(j===`submitted`){let n=i?.id;if(n){let r=await S.listRequests({submitterId:n,...t});e=r.data,St(r.total??r.data.length)}else e=[],St(0)}else{let n=await S.listRequests(t);e=n.data,St(n.total??n.data.length)}T.length&&S.listRequests({status:`pending`,approverId:T}).then(e=>Et(e.data.length)).catch(()=>{})}e.sort((e,t)=>(E(t)||``).localeCompare(E(e)||``)),gt(e)}catch(e){wt(e?.message||String(e)),gt([])}finally{vt(!1)}},[j,T,i?.id,It,B]);(0,b.useEffect)(()=>{K()},[K]);let hn=(0,b.useCallback)(async()=>{if(!(j===`pending`||yt)){bt(!0);try{let e=await S.listRequests({submitterId:j===`submitted`?i?.id??void 0:void 0,q:It||void 0,status:B===`all`?void 0:B,limit:nt,offset:M.length});gt(t=>{let n=new Set(t.map(e=>e.id));return[...t,...e.data.filter(e=>!n.has(e.id))]}),e.total!=null&&St(e.total)}catch(e){y.error(A(e,D(`loadFailed`,`Failed to load request`)))}finally{bt(!1)}}},[j,yt,i?.id,It,B,M.length,A,D]),q=(0,b.useCallback)(async e=>{Dt(e),Mt(!0),I(``),Nt(``);try{let[t,n]=await Promise.all([S.getRequest(e),S.listActions(e)]);Ot(t.data),At(n.data)}catch(e){y.error(A(e,D(`loadFailed`,`Failed to load request`))),Ot(null),At([])}finally{Mt(!1)}},[A,D]),gn=()=>{Dt(null),Ot(null),At([]),I(``),Nt(``)},J=(0,b.useCallback)(e=>{if(L.trim())return L.trim();if(!e)return i?.id||``;let t=new Set(e.pending_approvers||[]);for(let e of T)if(t.has(e))return e;return i?.id||``},[L,T,i?.id]),Y=(0,b.useCallback)(()=>{T.length&&S.listRequests({status:`pending`,approverId:T}).then(e=>Et(e.data.length)).catch(()=>{})},[T]),_n=(0,b.useCallback)(async e=>{if(!P)return;let t=e===`recall`&&i?.id||J(P);if(!t){y.error(D(`noActor`,`Cannot determine the acting identity`));return}Pt(e);try{let n={actor_id:t,comment:F.trim()||void 0},r=await(e===`approve`?S.approve:e===`reject`?S.reject:S.recall)(P.id,n);if(y.success(e===`approve`?r.finalized?D(`approvedFinal`,`Approved`):D(`approvedWaiting`,`Approved — waiting on the remaining approvers`):e===`reject`?D(`rejectedToast`,`Rejected`):D(`recalledToast`,`Request recalled`)),I(``),e!==`recall`&&j===`pending`){let e=Rn.current,t=e.findIndex(e=>e.id===P.id),n=e[t+1]??e[t-1];K(),n&&n.id!==P.id?q(n.id):gn();return}let[i,a]=await Promise.all([S.getRequest(P.id),S.listActions(P.id)]);Ot(i.data),At(a.data),K()}catch(e){y.error(A(e,D(`actionFailed`,`Action failed`)))}finally{Pt(null)}},[P,J,F,K,i?.id,A,D,j,q]),X=(0,b.useCallback)(async e=>{let[t,n]=await Promise.all([S.getRequest(e),S.listActions(e)]);Ot(t.data),At(n.data),K()},[K]),vn=(0,b.useCallback)(async()=>{if(!(!P||!U.trim())){G(!0);try{await S.reassign(P.id,{actor_id:J(P),to:U.trim(),comment:F.trim()||void 0}),y.success(D(`reassignSuccess`,`Handed to {{to}}`,{to:U.trim()})),Xt(!1),Zt(``),I(``),await X(P.id),Y()}catch(e){y.error(A(e,D(`actionFailed`,`Action failed`)))}finally{G(!1)}}},[P,U,F,J,X,Y,A,D]),yn=(0,b.useCallback)(async()=>{if(P){G(!0);try{let e=await S.remind(P.id,{actor_id:i?.id});y.success(D(`remindSuccess`,`Reminder sent to {{count}} approver(s)`,{count:e.notified})),await X(P.id)}catch(e){y.error(A(e,D(`actionFailed`,`Action failed`)))}finally{G(!1)}}},[P,i?.id,X,A,D]),bn=(0,b.useCallback)(async()=>{if(!(!P||!en.trim())){G(!0);try{await S.requestInfo(P.id,{actor_id:J(P),comment:en.trim()}),y.success(D(`requestInfoSent`,`Sent back to the requester for more information`)),$t(!1),tn(``),await X(P.id)}catch(e){y.error(A(e,D(`actionFailed`,`Action failed`)))}finally{G(!1)}}},[P,en,J,X,A,D]),xn=(0,b.useCallback)(async()=>{if(P){G(!0);try{let e=await S.sendBack(P.id,{actor_id:J(P),comment:an.trim()||void 0});y.success(e.autoRejected?D(`sendBackAutoRejected`,`Revision limit reached — the request was auto-rejected`):D(`sendBackSuccess`,`Sent back for revision — the requester can now edit and resubmit`)),rn(!1),on(``),await X(P.id),Y()}catch(e){y.error(A(e,D(`actionFailed`,`Action failed`)))}finally{G(!1)}}},[P,an,J,X,Y,A,D]),Sn=(0,b.useCallback)(async()=>{if(P){cn(!0);try{await S.resubmit(P.id,{actor_id:i?.id,comment:F.trim()||void 0}),y.success(D(`resubmitSuccess`,`Resubmitted — a new approval round has opened`)),I(``),await X(P.id),Y()}catch(e){y.error(A(e,D(`actionFailed`,`Action failed`)))}finally{cn(!1)}}},[P,F,i?.id,X,Y,A,D]),Cn=(0,b.useCallback)(async()=>{if(!(!P||!ln.trim())){G(!0);try{await S.comment(P.id,{actor_id:i?.id,comment:ln.trim()}),un(``),await X(P.id)}catch(e){y.error(A(e,D(`actionFailed`,`Action failed`)))}finally{G(!1)}}},[P,ln,i?.id,X,A,D]),wn=(0,b.useCallback)(async()=>{if(!dn.length)try{let e=``.replace(/\/$/,``);fn(((await(await fetch(`${e}/api/v1/data/sys_user?limit=100`,{credentials:`include`})).json()).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,b.useMemo)(()=>{if(!P||P.status!==`pending`)return!1;let e=new Set(P.pending_approvers||[]);return T.some(t=>e.has(t))||L.trim().length>0},[P,T,L]),En=(0,b.useMemo)(()=>!P||P.status!==`pending`?!1:P.submitter_id===i?.id||L.trim().length>0,[P,i?.id,L]),Dn=(0,b.useMemo)(()=>!P||P.status!==`returned`?!1:P.submitter_id===i?.id||L.trim().length>0,[P,i?.id,L]),On=(0,b.useMemo)(()=>{let e=new Set;for(let t of M)e.add(at(t));return Array.from(e).sort()},[M]),kn=(0,b.useMemo)(()=>{let e=new Set;for(let t of M)t.object_name&&e.add(t.object_name);return Array.from(e).sort()},[M]),Z=(0,b.useMemo)(()=>{let e=z.trim().toLowerCase();return M.filter(t=>Rt!==`all`&&at(t)!==Rt||Bt!==`all`&&t.object_name!==Bt||B!==`all`&&t.status!==B?!1:j!==`pending`||!e?!0:[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))},[M,z,Rt,Bt,B,j]),An=(0,b.useMemo)(()=>N?Z.findIndex(e=>e.id===N):-1,[Z,N]);(0,b.useEffect)(()=>{if(V.size===0)return;let e=new Set(Z.map(e=>e.id)),t=!1,n=new Set;for(let r of V)e.has(r)?n.add(r):t=!0;t&&Ut(n)},[Z,V]),(0,b.useEffect)(()=>{pn>=Z.length&&mn(Z.length-1)},[Z.length,pn]);let Q=(0,b.useCallback)(e=>{if(e.status!==`pending`)return!1;let t=new Set(T);return(e.pending_approvers||[]).some(e=>t.has(e))},[T]),$=(0,b.useMemo)(()=>Z.filter(e=>V.has(e.id)&&Q(e)),[Z,V,Q]),jn=Z.filter(e=>e.status===`pending`),Mn=jn.length>0&&jn.every(e=>V.has(e.id)),Nn=(0,b.useCallback)(()=>{Ut(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,b.useCallback)(e=>{Ut(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[]),Fn=(0,b.useCallback)(async e=>{let t=$;if(t.length===0)return;Gt(!0);let n=0,r=[];for(let a of t){let t=new Set(a.pending_approvers||[]),ee=T.find(e=>t.has(e))||i?.id||``;try{await(e===`approve`?S.approve:S.reject)(a.id,{actor_id:ee}),n++}catch{r.push(a.record_title||w(a.record_id))}}if(Gt(!1),Ut(new Set),r.length===0)y.success(e===`approve`?D(`bulkApproved`,`Approved {{count}} requests`,{count:n}):D(`bulkRejected`,`Rejected {{count}} requests`,{count:n}));else{let e=r.slice(0,3).join(`, `);y.error(D(`bulkPartial`,`{{ok}} succeeded, {{fail}} failed: {{which}}`,{ok:n,fail:r.length,which:e+(r.length>3?`…`:``)}))}K(),Y()},[$,T,i?.id,K,Y,D]),In=(0,b.useCallback)(async e=>{if(!Q(e)||qt)return;let t=new Set(e.pending_approvers||[]),n=T.find(e=>t.has(e))||i?.id||``;Jt(e.id);try{let t=await S.approve(e.id,{actor_id:n});y.success(t.finalized?D(`inlineApproved`,`Approved "{{title}}"`,{title:e.record_title||w(e.record_id)}):D(`approvedWaiting`,`Approved — waiting on the remaining approvers`)),K(),Y()}catch(e){y.error(A(e,D(`actionFailed`,`Action failed`)))}finally{Jt(null)}},[Q,qt,T,i?.id,K,Y,A,D]),Ln=(0,b.useCallback)(async()=>{let e=H;if(!e)return;let t=new Set(e.pending_approvers||[]),n=T.find(e=>t.has(e))||i?.id||``;Jt(e.id),Kt(null);try{await S.reject(e.id,{actor_id:n}),y.success(D(`inlineRejected`,`Rejected "{{title}}"`,{title:e.record_title||w(e.record_id)})),K(),Y()}catch(e){y.error(A(e,D(`actionFailed`,`Action failed`)))}finally{Jt(null)}},[H,T,i?.id,K,Y,A,D]),Rn=(0,b.useRef)(Z);Rn.current=Z;let zn=(0,b.useRef)(pn);zn.current=pn,(0,b.useEffect)(()=>{let e=e=>{if(N||H)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]&&j===`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(),Kt(r[i]))};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[N,H,j,q,Pn,In,Q]),(0,b.useEffect)(()=>{if(!N)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===N);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)},[N,q]);let Bn=!!z||Rt!==`all`||Bt!==`all`||B!==`all`,Vn=e=>{ht(e),Ht(`all`),zt(`all`),Vt(`all`),Ft(``),mn(-1)};function Hn({r:e}){return(0,C.jsxs)(`div`,{className:`min-w-0`,children:[(0,C.jsx)(`div`,{className:`font-medium truncate`,children:at(e)}),(0,C.jsxs)(`div`,{className:`text-xs text-muted-foreground truncate`,children:[ot(e)||`—`,(e.round??1)>1&&(0,C.jsx)(`span`,{className:`ml-1.5 text-violet-600 dark:text-violet-400`,children:D(`roundChip`,`Round {{n}}`,{n:e.round})})]})]})}function Un({r:e}){return(0,C.jsxs)(`div`,{className:`min-w-0`,children:[(0,C.jsxs)(r,{to:mt(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,C.jsx)(`span`,{className:`truncate`,children:e.record_title||w(e.record_id)}),(0,C.jsx)(we,{className:`h-3 w-3 shrink-0 text-muted-foreground`})]}),(0,C.jsx)(`div`,{className:`text-xs text-muted-foreground truncate`,children:lt(e)})]})}function Wn({r:e}){if(!Q(e))return null;let t=qt===e.id;return(0,C.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,C.jsx)(v,{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":D(`approve`,`Approve`),children:(0,C.jsx)(ae,{className:`h-4 w-4`})}),(0,C.jsx)(v,{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:()=>Kt(e),"aria-label":D(`reject`,`Reject`),children:(0,C.jsx)(Xe,{className:`h-4 w-4`})})]})}return(0,C.jsxs)(`div`,{className:`flex flex-col gap-4 sm:gap-6 p-4 sm:p-6 max-w-6xl`,children:[(0,C.jsxs)(`header`,{className:`flex flex-col sm:flex-row sm:items-center sm:justify-between gap-2`,children:[(0,C.jsxs)(`div`,{children:[(0,C.jsxs)(`h1`,{className:`text-2xl font-semibold flex items-center gap-2`,children:[(0,C.jsx)(Me,{className:`h-6 w-6`}),D(`title`,`Approvals Inbox`)]}),(0,C.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:D(`subtitle`,`Review and act on approval requests.`)})]}),(0,C.jsxs)(v,{variant:`outline`,size:`sm`,onClick:K,disabled:_t,className:`self-start sm:self-auto`,children:[(0,C.jsx)(Ze,{className:`h-4 w-4 mr-2 ${_t?`animate-spin`:``}`}),D(`refresh`,`Refresh`)]})]}),Ct&&(0,C.jsxs)(We,{variant:`destructive`,children:[(0,C.jsx)(ne,{className:`h-4 w-4`}),(0,C.jsx)(Ae,{children:Ct})]}),(0,C.jsxs)(ke,{value:j,onValueChange:Vn,children:[(0,C.jsxs)(Ge,{children:[(0,C.jsxs)(je,{value:`pending`,children:[D(`tabMyPending`,`My Pending`),Tt>0&&(0,C.jsx)(Ue,{variant:`secondary`,className:`ml-2`,children:Tt})]}),(0,C.jsx)(je,{value:`submitted`,children:D(`tabSubmitted`,`Submitted by me`)}),(0,C.jsx)(je,{value:`all`,children:D(`tabAll`,`All`)})]}),(0,C.jsxs)(Be,{value:j,className:`mt-4 space-y-3`,children:[!_t&&(M.length>0||j!==`pending`&&(It||B!==`all`))&&(0,C.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,C.jsxs)(`div`,{className:`relative flex-1 min-w-[200px] max-w-sm`,children:[(0,C.jsx)(oe,{className:`absolute left-2.5 top-1/2 -translate-y-1/2 h-3.5 w-3.5 text-muted-foreground`}),(0,C.jsx)(Oe,{value:z,onChange:e=>Ft(e.target.value),placeholder:D(`searchPlaceholder`,`Search record, process, requester…`),className:`pl-8 h-8 text-sm`}),z&&(0,C.jsx)(`button`,{type:`button`,onClick:()=>Ft(``),className:`absolute right-2 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground`,"aria-label":D(`clearSearch`,`Clear search`),children:(0,C.jsx)(se,{className:`h-3.5 w-3.5`})})]}),j!==`pending`&&(0,C.jsxs)(xe,{value:B,onValueChange:Ht,children:[(0,C.jsx)(me,{className:`h-8 w-auto min-w-[130px] text-sm`,children:(0,C.jsx)(He,{placeholder:D(`statusFilter`,`Status`)})}),(0,C.jsxs)(Te,{children:[(0,C.jsx)(o,{value:`all`,children:D(`allStatuses`,`All statuses`)}),(0,C.jsx)(o,{value:`pending`,children:k(`pending`)}),(0,C.jsx)(o,{value:`approved`,children:k(`approved`)}),(0,C.jsx)(o,{value:`rejected`,children:k(`rejected`)}),(0,C.jsx)(o,{value:`recalled`,children:k(`recalled`)}),(0,C.jsx)(o,{value:`returned`,children:k(`returned`)})]})]}),On.length>1&&(0,C.jsxs)(xe,{value:Rt,onValueChange:zt,children:[(0,C.jsx)(me,{className:`h-8 w-auto min-w-[140px] text-sm`,children:(0,C.jsx)(He,{placeholder:D(`processFilter`,`Process`)})}),(0,C.jsxs)(Te,{children:[(0,C.jsx)(o,{value:`all`,children:D(`allProcesses`,`All processes`)}),On.map(e=>(0,C.jsx)(o,{value:e,children:e},e))]})]}),kn.length>1&&(0,C.jsxs)(xe,{value:Bt,onValueChange:Vt,children:[(0,C.jsx)(me,{className:`h-8 w-auto min-w-[140px] text-sm`,children:(0,C.jsx)(He,{placeholder:D(`objectFilter`,`Object`)})}),(0,C.jsxs)(Te,{children:[(0,C.jsx)(o,{value:`all`,children:D(`allObjects`,`All objects`)}),kn.map(e=>(0,C.jsx)(o,{value:e,children:e},e))]})]}),Bn&&(0,C.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:D(`filterCount`,`{{shown}} of {{total}}`,{shown:Z.length,total:M.length})})]}),j===`pending`&&V.size>0&&(0,C.jsxs)(`div`,{className:`flex items-center justify-between gap-2 px-3 py-2 rounded-md border bg-accent/30 text-sm`,children:[(0,C.jsxs)(`span`,{children:[(0,C.jsx)(`strong`,{children:V.size}),` `,D(`selected`,`selected`),$.length!==V.size&&(0,C.jsx)(`span`,{className:`text-muted-foreground ml-1`,children:D(`actionableCount`,`({{count}} actionable)`,{count:$.length})})]}),(0,C.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,C.jsxs)(_,{children:[(0,C.jsx)(Ye,{asChild:!0,children:(0,C.jsxs)(v,{size:`sm`,disabled:Wt||$.length===0,children:[(0,C.jsx)(ae,{className:`h-3.5 w-3.5 mr-1`}),D(`approveN`,`Approve {{count}}`,{count:$.length||``})]})}),(0,C.jsxs)(g,{children:[(0,C.jsxs)(p,{children:[(0,C.jsx)(c,{children:D(`bulkApproveTitle`,`Approve {{count}} requests?`,{count:$.length})}),(0,C.jsx)(h,{children:D(`bulkApproveBody`,`Each request is approved with your identity and its flow continues down the approve branch.`)})]}),(0,C.jsxs)(m,{children:[(0,C.jsx)(d,{children:D(`cancel`,`Cancel`)}),(0,C.jsx)(l,{onClick:()=>Fn(`approve`),children:D(`approveN`,`Approve {{count}}`,{count:$.length})})]})]})]}),(0,C.jsxs)(_,{children:[(0,C.jsx)(Ye,{asChild:!0,children:(0,C.jsxs)(v,{size:`sm`,variant:`outline`,disabled:Wt||$.length===0,className:`border-destructive text-destructive hover:bg-destructive hover:text-destructive-foreground`,children:[(0,C.jsx)(Xe,{className:`h-3.5 w-3.5 mr-1`}),D(`rejectN`,`Reject {{count}}`,{count:$.length||``})]})}),(0,C.jsxs)(g,{children:[(0,C.jsxs)(p,{children:[(0,C.jsx)(c,{children:D(`bulkRejectTitle`,`Reject {{count}} requests?`,{count:$.length})}),(0,C.jsx)(h,{children:D(`bulkRejectBody`,`This rejects the selected requests and notifies their submitters.`)})]}),(0,C.jsxs)(m,{children:[(0,C.jsx)(d,{children:D(`cancel`,`Cancel`)}),(0,C.jsx)(l,{onClick:()=>Fn(`reject`),className:`bg-destructive text-destructive-foreground hover:bg-destructive/90`,children:D(`rejectN`,`Reject {{count}}`,{count:$.length})})]})]})]}),(0,C.jsx)(v,{size:`sm`,variant:`ghost`,onClick:()=>Ut(new Set),disabled:Wt,children:D(`clear`,`Clear`)})]})]}),_t?(0,C.jsxs)(`div`,{className:`space-y-2`,children:[(0,C.jsx)(le,{className:`h-10 w-full`}),(0,C.jsx)(le,{className:`h-10 w-full`}),(0,C.jsx)(le,{className:`h-10 w-full`})]}):M.length===0?(0,C.jsx)(`div`,{className:`flex items-center justify-center min-h-[240px] rounded-md border border-dashed`,children:(0,C.jsxs)(Se,{children:[(0,C.jsx)(ue,{children:D(`emptyTitle`,`No requests`)}),(0,C.jsx)(de,{children:j===`pending`?D(`emptyPending`,`You're all caught up — nothing is waiting on you.`):D(`emptyOther`,`Nothing here yet.`)}),j===`pending`&&(0,C.jsx)(v,{variant:`link`,size:`sm`,className:`mt-1`,onClick:()=>Vn(`all`),children:D(`emptyViewAll`,`Browse all requests`)})]})}):Z.length===0?(0,C.jsx)(`div`,{className:`flex items-center justify-center min-h-[160px] rounded-md border border-dashed text-sm text-muted-foreground`,children:D(`noMatches`,`No matches for current filters.`)}):(0,C.jsxs)(C.Fragment,{children:[(0,C.jsx)(De,{className:`hidden md:block`,children:(0,C.jsx)(_e,{className:`p-0`,children:(0,C.jsxs)(Re,{children:[(0,C.jsx)(Ve,{children:(0,C.jsxs)(ze,{children:[j===`pending`&&(0,C.jsx)(f,{className:`w-10`,children:(0,C.jsx)(Ee,{checked:Mn,onCheckedChange:Nn,"aria-label":D(`selectAll`,`Select all`),disabled:jn.length===0})}),(0,C.jsx)(f,{children:D(`colRequest`,`Request`)}),(0,C.jsx)(f,{children:D(`colRecord`,`Record`)}),(0,C.jsx)(f,{children:D(`colRequester`,`Requester`)}),(0,C.jsx)(f,{children:D(`colStatus`,`Status`)}),(0,C.jsx)(f,{children:D(`colWaiting`,`Submitted`)}),(0,C.jsx)(f,{className:`w-20`,"aria-label":D(`colActions`,`Actions`)})]})}),(0,C.jsx)(qe,{children:Z.map((e,t)=>(0,C.jsxs)(ze,{className:s(`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:[j===`pending`&&(0,C.jsx)(u,{className:`w-10`,onClick:e=>e.stopPropagation(),children:(0,C.jsx)(Ee,{checked:V.has(e.id),onCheckedChange:()=>Pn(e.id),disabled:e.status!==`pending`,"aria-label":D(`selectRow`,`Select request`)})}),(0,C.jsx)(u,{children:(0,C.jsx)(Hn,{r:e})}),(0,C.jsx)(u,{children:(0,C.jsx)(Un,{r:e})}),(0,C.jsx)(u,{children:(0,C.jsxs)(`div`,{className:`flex items-center gap-1.5 text-sm`,children:[(0,C.jsx)(ce,{className:`h-3.5 w-3.5 text-muted-foreground shrink-0`}),(0,C.jsx)(`span`,{className:`truncate`,title:e.submitter_id||``,children:st(e)})]})}),(0,C.jsx)(u,{children:(0,C.jsx)(ft,{status:e.status})}),(0,C.jsxs)(u,{className:s(`text-xs whitespace-nowrap`,ut(e)),title:it(E(e)),children:[(0,C.jsx)(Ne,{className:`h-3 w-3 inline mr-1`}),O(E(e)),e.status===`pending`&&e.sla_due_at&&(0,C.jsx)(`div`,{className:s(`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()?D(`slaOverdue`,`SLA overdue {{dur}}`,{dur:dt(Date.now()-Date.parse(e.sla_due_at))}):D(`slaRemaining`,`SLA {{dur}} left`,{dur:dt(Date.parse(e.sla_due_at)-Date.now())})})]}),(0,C.jsx)(u,{className:`w-20`,children:(0,C.jsx)(Wn,{r:e})})]},e.id))})]})})}),(0,C.jsx)(`div`,{className:`md:hidden space-y-2`,children:Z.map(e=>(0,C.jsx)(De,{className:`cursor-pointer active:bg-accent/50`,onClick:()=>void q(e.id),children:(0,C.jsxs)(_e,{className:`p-3 space-y-1.5`,children:[(0,C.jsxs)(`div`,{className:`flex items-start justify-between gap-2`,children:[(0,C.jsx)(`div`,{className:`font-medium text-sm truncate`,children:at(e)}),(0,C.jsx)(ft,{status:e.status})]}),(0,C.jsxs)(`div`,{className:`text-sm truncate`,children:[e.record_title||w(e.record_id),(0,C.jsx)(`span`,{className:`text-muted-foreground text-xs ml-1.5`,children:lt(e)})]}),(0,C.jsxs)(`div`,{className:`flex items-center justify-between text-xs text-muted-foreground`,children:[(0,C.jsxs)(`span`,{className:`inline-flex items-center gap-1 truncate`,children:[(0,C.jsx)(ce,{className:`h-3 w-3`}),st(e)]}),(0,C.jsxs)(`span`,{className:s(`inline-flex items-center gap-1 whitespace-nowrap`,ut(e)),children:[(0,C.jsx)(Ne,{className:`h-3 w-3`}),O(E(e))]})]}),Q(e)&&(0,C.jsxs)(`div`,{className:`flex gap-2 pt-1`,onClick:e=>e.stopPropagation(),children:[(0,C.jsxs)(v,{size:`sm`,className:`h-7 flex-1`,disabled:qt===e.id,onClick:()=>void In(e),children:[(0,C.jsx)(ae,{className:`h-3.5 w-3.5 mr-1`}),D(`approve`,`Approve`)]}),(0,C.jsxs)(v,{size:`sm`,variant:`outline`,className:`h-7 flex-1 border-destructive text-destructive`,disabled:qt===e.id,onClick:()=>Kt(e),children:[(0,C.jsx)(Xe,{className:`h-3.5 w-3.5 mr-1`}),D(`reject`,`Reject`)]})]})]})},e.id))}),j!==`pending`&&xt!=null&&(0,C.jsxs)(`div`,{className:`flex items-center justify-center gap-3 py-1`,children:[(0,C.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:D(`loadedOf`,`Loaded {{loaded}} of {{total}}`,{loaded:M.length,total:xt})}),M.length<xt&&(0,C.jsx)(v,{size:`sm`,variant:`outline`,disabled:yt,onClick:()=>void hn(),children:yt?D(`loadingMore`,`Loading…`):D(`loadMore`,`Load more`)})]}),(0,C.jsx)(`div`,{className:`hidden md:block text-[11px] text-muted-foreground`,children:D(`keyboardHint`,`Keyboard: j/k move · Enter open · x select · a approve · r reject`)})]})]})]}),(0,C.jsx)(_,{open:Yt,onOpenChange:e=>{e||(Xt(!1),Zt(``))},children:(0,C.jsxs)(g,{children:[(0,C.jsxs)(p,{children:[(0,C.jsx)(c,{children:D(`reassignTitle`,`Hand this approval to someone else?`)}),(0,C.jsx)(h,{children:D(`reassignBody`,`Your approver slot moves to the person you pick — they are notified and can act immediately.`)})]}),(0,C.jsxs)(`div`,{children:[(0,C.jsx)(Le,{htmlFor:`reassign-to`,className:`text-xs`,children:D(`reassignTo`,`New approver`)}),(0,C.jsx)(Oe,{id:`reassign-to`,list:`reassign-user-options`,value:U,onChange:e=>Zt(e.target.value),placeholder:D(`reassignToPlaceholder`,`Pick a user or type an email / role:<name>`),className:`mt-1`}),(0,C.jsx)(`datalist`,{id:`reassign-user-options`,children:dn.map(e=>(0,C.jsx)(`option`,{value:e.email,children:e.name},e.email))})]}),(0,C.jsxs)(m,{children:[(0,C.jsx)(d,{children:D(`cancel`,`Cancel`)}),(0,C.jsx)(l,{disabled:!U.trim()||W,onClick:()=>void vn(),children:D(`reassignBtn`,`Reassign`)})]})]})}),(0,C.jsx)(_,{open:Qt,onOpenChange:e=>{e||($t(!1),tn(``))},children:(0,C.jsxs)(g,{children:[(0,C.jsxs)(p,{children:[(0,C.jsx)(c,{children:D(`requestInfoTitle`,`Ask the requester for more information?`)}),(0,C.jsx)(h,{children:D(`requestInfoBody`,`The request stays pending; the requester is notified and can reply on the thread.`)})]}),(0,C.jsx)(Fe,{value:en,onChange:e=>tn(e.target.value),rows:3,placeholder:D(`requestInfoPlaceholder`,`What do you need from the requester?`)}),(0,C.jsxs)(m,{children:[(0,C.jsx)(d,{children:D(`cancel`,`Cancel`)}),(0,C.jsx)(l,{disabled:!en.trim()||W,onClick:()=>void bn(),children:D(`requestInfoBtn`,`Request info`)})]})]})}),(0,C.jsx)(_,{open:nn,onOpenChange:e=>{e||(rn(!1),on(``))},children:(0,C.jsxs)(g,{children:[(0,C.jsxs)(p,{children:[(0,C.jsx)(c,{children:D(`sendBackTitle`,`Send this request back for revision?`)}),(0,C.jsx)(h,{children:D(`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,C.jsx)(Fe,{value:an,onChange:e=>on(e.target.value),rows:3,placeholder:D(`sendBackPlaceholder`,`What needs to be fixed before this can be approved?`)}),(0,C.jsxs)(m,{children:[(0,C.jsx)(d,{children:D(`cancel`,`Cancel`)}),(0,C.jsx)(l,{disabled:W,onClick:()=>void xn(),children:D(`sendBackBtn`,`Send back`)})]})]})}),(0,C.jsx)(_,{open:!!H,onOpenChange:e=>!e&&Kt(null),children:(0,C.jsxs)(g,{children:[(0,C.jsxs)(p,{children:[(0,C.jsx)(c,{children:D(`rejectOneTitle`,`Reject "{{title}}"?`,{title:H?H.record_title||w(H.record_id):``})}),(0,C.jsx)(h,{children:D(`rejectOneBody`,`This rejects the request and notifies the submitter.`)})]}),(0,C.jsxs)(m,{children:[(0,C.jsx)(d,{children:D(`cancel`,`Cancel`)}),(0,C.jsx)(l,{onClick:()=>void Ln(),className:`bg-destructive text-destructive-foreground hover:bg-destructive/90`,children:D(`reject`,`Reject`)})]})]})}),(0,C.jsx)(ge,{open:!!N,onOpenChange:e=>!e&&gn(),children:(0,C.jsxs)(ve,{className:`w-full sm:max-w-xl overflow-y-auto`,children:[(0,C.jsxs)(ie,{children:[(0,C.jsx)(Ce,{children:P?at(P):D(`drawerTitle`,`Approval Request`)}),(0,C.jsx)($e,{children:P?ot(P)||lt(P):``})]}),P&&An>=0&&Z.length>1&&(0,C.jsxs)(`div`,{className:`flex items-center justify-between mt-2 text-xs text-muted-foreground`,children:[(0,C.jsxs)(v,{variant:`ghost`,size:`sm`,className:`h-7 px-2`,disabled:An<=0,onClick:()=>{let e=Z[An-1];e&&q(e.id)},children:[(0,C.jsx)(he,{className:`h-4 w-4 mr-0.5`}),D(`prevRequest`,`Previous`)]}),(0,C.jsx)(`span`,{children:D(`positionOf`,`{{index}} of {{total}}`,{index:An+1,total:Z.length})}),(0,C.jsxs)(v,{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:[D(`nextRequest`,`Next`),(0,C.jsx)(pe,{className:`h-4 w-4 ml-0.5`})]})]}),jt?(0,C.jsxs)(`div`,{className:`space-y-2 mt-6`,children:[(0,C.jsx)(le,{className:`h-6 w-3/4`}),(0,C.jsx)(le,{className:`h-6 w-1/2`}),(0,C.jsx)(le,{className:`h-20 w-full`})]}):P?(0,C.jsxs)(`div`,{className:`space-y-4 mt-6`,children:[(0,C.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 text-xs text-muted-foreground`,children:[(0,C.jsx)(ft,{status:P.status}),(P.round??1)>1&&(0,C.jsx)(Ue,{variant:`outline`,className:`text-[10px] border-violet-200 text-violet-700 dark:border-violet-500/30 dark:text-violet-400`,children:D(`roundChip`,`Round {{n}}`,{n:P.round})}),(0,C.jsxs)(`span`,{className:`inline-flex items-center gap-1`,title:it(E(P)),children:[(0,C.jsx)(Ne,{className:`h-3 w-3`}),D(`submittedAgo`,`Submitted {{when}}`,{when:O(E(P))})]}),P.completed_at&&(0,C.jsxs)(`span`,{children:[`· `,D(`completedAt`,`Completed {{when}}`,{when:O(P.completed_at)})]}),P.status===`pending`&&P.sla_due_at&&(0,C.jsx)(Ue,{variant:`outline`,className:s(`text-[10px]`,Date.parse(P.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(P.sla_due_at)<Date.now()?D(`slaOverdue`,`SLA overdue {{dur}}`,{dur:dt(Date.now()-Date.parse(P.sla_due_at))}):D(`slaRemaining`,`SLA {{dur}} left`,{dur:dt(Date.parse(P.sla_due_at)-Date.now())})})]}),(0,C.jsx)(De,{children:(0,C.jsxs)(_e,{className:`p-4 space-y-3`,children:[(0,C.jsxs)(`div`,{className:`flex items-start justify-between gap-2`,children:[(0,C.jsxs)(`div`,{className:`min-w-0`,children:[(0,C.jsxs)(r,{to:mt(P),className:`text-base font-semibold hover:underline inline-flex items-center gap-1.5`,children:[(0,C.jsx)(`span`,{className:`truncate`,children:P.record_title||w(P.record_id)}),(0,C.jsx)(we,{className:`h-3.5 w-3.5 shrink-0 text-muted-foreground`})]}),(0,C.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:lt(P)})]}),(0,C.jsx)(`div`,{className:`text-right text-xs text-muted-foreground shrink-0`,children:(0,C.jsxs)(`div`,{className:`inline-flex items-center gap-1`,children:[(0,C.jsx)(ce,{className:`h-3 w-3`}),(0,C.jsx)(`span`,{title:P.submitter_id||``,children:st(P)})]})})]}),pt(P.payload,P.payload_display).length>0&&(0,C.jsx)(`div`,{className:`grid grid-cols-2 gap-x-4 gap-y-2 text-sm border-t pt-3`,children:pt(P.payload,P.payload_display).map(([e,t])=>(0,C.jsxs)(`div`,{className:`min-w-0`,children:[(0,C.jsx)(`div`,{className:`text-[11px] text-muted-foreground`,children:e}),(0,C.jsx)(`div`,{className:`truncate`,title:t,children:t})]},e))}),P.status===`pending`&&(P.pending_approvers||[]).length>0&&(0,C.jsxs)(`div`,{className:`border-t pt-3`,children:[(0,C.jsx)(`div`,{className:`text-[11px] text-muted-foreground mb-1`,children:D(`waitingOn`,`Waiting on`)}),(0,C.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:(P.pending_approvers||[]).map((e,t)=>(0,C.jsx)(Ue,{variant:`outline`,className:`text-[11px]`,title:e,children:ct(e,P)},t))})]})]})}),(P.flow_steps?.length??0)>1&&(0,C.jsx)(`div`,{className:`flex items-center px-1`,"aria-label":D(`stepProgress`,`Approval steps`),children:P.flow_steps.map((e,t)=>(0,C.jsxs)(b.Fragment,{children:[t>0&&(0,C.jsx)(`div`,{className:s(`h-px flex-1 mx-2`,e.state===`done`||e.state===`current`?`bg-emerald-300 dark:bg-emerald-700`:`bg-border`)}),(0,C.jsxs)(`div`,{className:`flex items-center gap-1.5 shrink-0`,children:[(0,C.jsx)(`span`,{className:s(`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,C.jsx)(Qe,{className:`h-3 w-3`}):t+1}),(0,C.jsx)(`span`,{className:s(`text-xs`,e.state===`current`?`font-medium`:`text-muted-foreground`),children:e.label})]})]},e.id))}),(0,C.jsxs)(`div`,{children:[(0,C.jsx)(`h3`,{className:`text-sm font-semibold mb-3`,children:D(`history`,`Activity`)}),kt.length===0?(0,C.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:D(`noActions`,`No actions yet.`)}):(0,C.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:kt.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`?D(`systemSlaActor`,`System (SLA)`):e.actor_name??(e.actor_id&&e.actor_id===P.submitter_id?st(P):w(e.actor_id)),r=e.action===`submit`?D(`actSubmit`,`Submitted`):e.action===`approve`?D(`actApprove`,`Approved`):e.action===`reject`?D(`actReject`,`Rejected`):e.action===`recall`?D(`actRecall`,`Recalled`):e.action===`reassign`?D(`actReassign`,`Reassigned`):e.action===`remind`?D(`actRemind`,`Reminder sent`):e.action===`request_info`?D(`actRequestInfo`,`Requested more info`):e.action===`comment`?D(`actComment`,`Commented`):e.action===`escalate`?D(`actEscalate`,`SLA escalated`):e.action===`revise`?D(`actRevise`,`Sent back for revision`):e.action===`resubmit`?D(`actResubmit`,`Resubmitted`):e.action;return(0,C.jsxs)(`li`,{className:`relative text-xs`,children:[(0,C.jsx)(`span`,{className:`absolute -left-[18px] top-1 h-3 w-3 rounded-full ring-2 ring-background ${t}`,"aria-hidden":!0}),(0,C.jsxs)(`div`,{className:`flex items-baseline gap-1.5 flex-wrap`,children:[(0,C.jsx)(`span`,{className:`font-medium`,children:r}),(0,C.jsx)(`span`,{className:`text-muted-foreground`,children:`·`}),(0,C.jsx)(`span`,{title:e.actor_id||``,children:n}),(0,C.jsx)(`span`,{className:`ml-auto text-muted-foreground text-[10px]`,title:it(e.created_at),children:O(e.created_at)})]}),e.comment&&(0,C.jsxs)(`div`,{className:`text-muted-foreground italic mt-0.5`,children:[`"`,e.comment,`"`]})]},e.id)})}),P.status===`pending`&&(Tn||En)&&(0,C.jsxs)(`div`,{className:`flex items-center gap-2 mt-3`,children:[(0,C.jsx)(Oe,{value:ln,onChange:e=>un(e.target.value),onKeyDown:e=>{e.key===`Enter`&&ln.trim()&&(e.preventDefault(),Cn())},placeholder:D(`replyPlaceholder`,`Reply on this request…`),className:`h-8 text-sm`}),(0,C.jsx)(v,{size:`sm`,variant:`outline`,className:`h-8 px-2 shrink-0`,disabled:!ln.trim()||W,onClick:()=>void Cn(),children:(0,C.jsx)(be,{className:`h-3.5 w-3.5`})})]})]}),P.payload!=null&&(0,C.jsxs)(`details`,{className:`group`,children:[(0,C.jsx)(`summary`,{className:`cursor-pointer text-xs text-muted-foreground hover:text-foreground select-none`,children:D(`rawData`,`Raw data (JSON)`)}),(0,C.jsxs)(`div`,{className:`mt-2`,children:[(0,C.jsx)(`div`,{className:`flex justify-end`,children:(0,C.jsxs)(`button`,{type:`button`,onClick:async()=>{try{await navigator.clipboard.writeText(JSON.stringify(P.payload,null,2)),y.success(D(`copied`,`Copied`))}catch{y.error(D(`copyFailed`,`Copy failed`))}},className:`text-[10px] text-muted-foreground hover:text-foreground inline-flex items-center gap-1`,children:[(0,C.jsx)(Pe,{className:`h-3 w-3`}),D(`copy`,`Copy`)]})}),(0,C.jsx)(`pre`,{className:`text-[11px] bg-muted/50 rounded p-2 overflow-auto max-h-48 mt-1`,children:JSON.stringify(P.payload,null,2)})]})]}),P.status===`pending`&&(0,C.jsxs)(C.Fragment,{children:[(0,C.jsx)(fe,{}),(0,C.jsxs)(`div`,{className:`space-y-3`,children:[et&&(0,C.jsxs)(`details`,{className:`group`,children:[(0,C.jsx)(`summary`,{className:`cursor-pointer text-xs text-muted-foreground hover:text-foreground select-none`,children:D(`overrideActor`,`Act as another identity (admin)`)}),(0,C.jsxs)(`div`,{className:`mt-2`,children:[(0,C.jsx)(Le,{htmlFor:`actor-override`,className:`text-xs`,children:D(`actor`,`Actor`)}),(0,C.jsx)(`input`,{id:`actor-override`,type:`text`,value:L,onChange:e=>Nt(e.target.value),placeholder:`${D(`auto`,`Auto`)}: ${J(P)||`—`}`,className:`w-full mt-1 px-3 py-2 text-sm border rounded-md bg-background`}),(0,C.jsx)(`div`,{className:`text-[10px] text-muted-foreground mt-1`,children:D(`overrideHint`,`e.g. role:sales_manager. Leave blank to use the auto-detected identity.`)})]})]}),(0,C.jsxs)(`div`,{children:[(0,C.jsx)(Le,{htmlFor:`comment`,className:`text-xs`,children:D(`comment`,`Comment (optional)`)}),(0,C.jsx)(`div`,{className:`flex flex-wrap gap-1.5 mt-1.5`,children:[D(`quickPhrase1`,`Approved — meets requirements.`),D(`quickPhrase2`,`Approved with conditions — please monitor execution.`),D(`quickPhrase3`,`Please add supporting material and resubmit.`)].map(e=>(0,C.jsx)(`button`,{type:`button`,onClick:()=>I(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,C.jsx)(Fe,{id:`comment`,value:F,onChange:e=>I(e.target.value),rows:2,className:`mt-1`})]}),(0,C.jsxs)(`div`,{className:`flex gap-2 flex-wrap`,children:[(0,C.jsxs)(v,{size:`sm`,onClick:()=>_n(`approve`),disabled:!Tn||R!==null,children:[(0,C.jsx)(ae,{className:`h-4 w-4 mr-1`}),R===`approve`?D(`approving`,`Approving…`):D(`approve`,`Approve`)]}),(0,C.jsxs)(_,{children:[(0,C.jsx)(Ye,{asChild:!0,children:(0,C.jsxs)(v,{size:`sm`,variant:`outline`,disabled:!Tn||R!==null,className:`border-destructive text-destructive hover:bg-destructive hover:text-destructive-foreground`,children:[(0,C.jsx)(Xe,{className:`h-4 w-4 mr-1`}),R===`reject`?D(`rejecting`,`Rejecting…`):D(`reject`,`Reject`)]})}),(0,C.jsxs)(g,{children:[(0,C.jsxs)(p,{children:[(0,C.jsx)(c,{children:D(`rejectTitle`,`Reject this request?`)}),(0,C.jsx)(h,{children:D(`rejectBody`,`This marks the request as rejected and notifies the submitter.`)})]}),(0,C.jsxs)(m,{children:[(0,C.jsx)(d,{children:D(`cancel`,`Cancel`)}),(0,C.jsx)(l,{onClick:()=>_n(`reject`),className:`bg-destructive text-destructive-foreground hover:bg-destructive/90`,children:D(`reject`,`Reject`)})]})]})]}),Tn&&(0,C.jsxs)(C.Fragment,{children:[(0,C.jsxs)(v,{size:`sm`,variant:`outline`,disabled:R!==null||W,className:`border-violet-300 text-violet-700 hover:bg-violet-50 dark:text-violet-400`,onClick:()=>rn(!0),children:[(0,C.jsx)(Ke,{className:`h-4 w-4 mr-1`}),D(`sendBackBtn`,`Send back`)]}),(0,C.jsxs)(v,{size:`sm`,variant:`outline`,disabled:R!==null||W,className:`border-amber-300 text-amber-700 hover:bg-amber-50 dark:text-amber-400`,onClick:()=>$t(!0),children:[(0,C.jsx)(ye,{className:`h-4 w-4 mr-1`}),D(`requestInfoBtn`,`Request info`)]}),(0,C.jsxs)(v,{size:`sm`,variant:`outline`,disabled:R!==null||W,onClick:()=>{wn(),Xt(!0)},children:[(0,C.jsx)(Je,{className:`h-4 w-4 mr-1`}),D(`reassignBtn`,`Reassign`)]})]}),En&&(0,C.jsxs)(v,{size:`sm`,variant:`outline`,disabled:W,onClick:()=>void yn(),children:[(0,C.jsx)(Ie,{className:`h-4 w-4 mr-1`}),D(`remindBtn`,`Send reminder`)]}),En&&(0,C.jsxs)(_,{children:[(0,C.jsx)(Ye,{asChild:!0,children:(0,C.jsxs)(v,{size:`sm`,variant:`outline`,disabled:R!==null,children:[(0,C.jsx)(re,{className:`h-4 w-4 mr-1`}),R===`recall`?D(`recalling`,`Recalling…`):D(`recall`,`Recall`)]})}),(0,C.jsxs)(g,{children:[(0,C.jsxs)(p,{children:[(0,C.jsx)(c,{children:D(`recallTitle`,`Recall this request?`)}),(0,C.jsx)(h,{children:D(`recallBody`,`This withdraws your request. Approvers can no longer act on it, and the record is unlocked.`)})]}),(0,C.jsxs)(m,{children:[(0,C.jsx)(d,{children:D(`cancel`,`Cancel`)}),(0,C.jsx)(l,{onClick:()=>_n(`recall`),children:D(`recall`,`Recall`)})]})]})]})]}),!Tn&&(0,C.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:En?D(`whyDisabledSubmitter`,`You submitted this request, so you can recall it — but only the assigned approvers can approve or reject.`):D(`whyDisabled`,`Only the assigned approvers can act on this request. It is waiting on: {{who}}.`,{who:(P.pending_approvers||[]).map(e=>ct(e,P)).join(`, `)||`—`})})]})]}),Dn&&(0,C.jsxs)(C.Fragment,{children:[(0,C.jsx)(fe,{}),(0,C.jsxs)(`div`,{className:`space-y-3`,children:[(0,C.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:D(`returnedHint`,`An approver sent this back to you. The record is unlocked — fix the data, then resubmit to start a new approval round.`)}),(0,C.jsxs)(`div`,{children:[(0,C.jsx)(Le,{htmlFor:`resubmit-comment`,className:`text-xs`,children:D(`comment`,`Comment (optional)`)}),(0,C.jsx)(Fe,{id:`resubmit-comment`,value:F,onChange:e=>I(e.target.value),rows:2,className:`mt-1`,placeholder:D(`resubmitPlaceholder`,`What did you change?`)})]}),(0,C.jsxs)(`div`,{className:`flex gap-2 flex-wrap`,children:[(0,C.jsx)(v,{asChild:!0,size:`sm`,variant:`outline`,children:(0,C.jsxs)(r,{to:mt(P),children:[(0,C.jsx)(we,{className:`h-4 w-4 mr-1`}),D(`editRecordBtn`,`Edit record`)]})}),(0,C.jsxs)(v,{size:`sm`,disabled:sn,onClick:()=>void Sn(),children:[(0,C.jsx)(Ze,{className:s(`h-4 w-4 mr-1`,sn&&`animate-spin`)}),sn?D(`resubmitting`,`Resubmitting…`):D(`resubmitBtn`,`Resubmit`)]}),(0,C.jsxs)(_,{children:[(0,C.jsx)(Ye,{asChild:!0,children:(0,C.jsxs)(v,{size:`sm`,variant:`outline`,disabled:sn,children:[(0,C.jsx)(re,{className:`h-4 w-4 mr-1`}),D(`recall`,`Recall`)]})}),(0,C.jsxs)(g,{children:[(0,C.jsxs)(p,{children:[(0,C.jsx)(c,{children:D(`abandonTitle`,`Abandon this revision?`)}),(0,C.jsx)(h,{children:D(`abandonBody`,`This withdraws the request instead of resubmitting it. The approval ends here.`)})]}),(0,C.jsxs)(m,{children:[(0,C.jsx)(d,{children:D(`cancel`,`Cancel`)}),(0,C.jsx)(l,{onClick:()=>_n(`recall`),children:D(`recall`,`Recall`)})]})]})]})]})]})]})]}):null]})})]})}export{mt as ApprovalsInboxPage};
@@ -1 +0,0 @@
1
- import{o as e}from"./rolldown-runtime-CMxvf4Kt.js";import{_ as t,l as n,t as r,u as i}from"./vendor-react-ClIa1CJA.js";import{i as a}from"./framework-CQlIjbCT.js";import{D as o,Gt as s,Kt as c,Si as l,Ut as u,Wt as d,li as f,qt as p,yr as m}from"./ui-components-CgiD1ql5.js";import{r as h}from"./vendor-ui-utils-C92Fl7BT.js";import{i as g,s as _,t as v}from"./assistantBus-BMrg1uLy.js";import{c as y,l as b,n as ee,o as te,t as ne}from"./useReconcileOnError-QYVPx52o.js";import{C as re,a as ie,d as x,f as S,g as C,h as w,m as T,r as ae,t as oe,u as se,y as ce}from"./plugin-chatbot-CumNGrh8.js";import{n as E,x as D}from"./marketplaceApi-D36MnuCE.js";var O=e(t(),1);function k(e){return e.some(e=>w(e.name))&&e.some(e=>C(e.name))}function A({agents:e,showAgentPickerProp:t,envOptIn:n=!1,aiStudioEnabled:r=!0}){return t===void 0?n?!0:r&&k(e):t}var j=r(),M={ask:{zh:`智能助手`,en:`Assistant`},build:{zh:`构建助手`,en:`Build assistant`}};function N(e,t,n){let r=t?M[T(t)]:void 0;return r?e?r.zh:r.en:n}function le(e,t,n,r,i){let a=(e??``).toLowerCase().startsWith(`zh`),o=N(a,n,r),s=i.slice(0,2).map(e=>e.label||e.name);if(a){let e=[s[0]?`查询最近创建的${s[0]}`:`帮我查询最近的数据`,s[0]?`统计${s[0]}的总数量`:`统计各对象的记录数量`,s[1]?`${s[1]}有哪些字段?`:`当前应用里有哪些数据对象?`].filter(Boolean);return{agentLabel:o,labels:{emptyTitle:`你好,我是${o}`,emptyDescription:`随时帮你查询和分析「${t}」中的数据。试试下面的问题,或直接输入你的需求。`,clear:`清空对话`,sendHint:`发送`,agentActivity:`执行过程`,toolCompleted:`已完成`,toolRunning:`运行中`,toolAwaitingApproval:`等待确认`,toolFailed:`失败`,connectionWaiting:`正在等待服务器响应…`,connectionStalledLabel:`仍在处理中…`,connectionOfflineLabel:`网络已断开,正在重连…`,toolDetailsHidden:`已隐藏工具参数和原始结果,仅保留过程摘要。`,copy:`复制`,copied:`已复制`,regenerate:`重新生成`,model:`模型`,submit:`发送`,uploadFiles:`上传文件`,stopResponse:`停止生成`,trace:`调试 trace`,viewTrace:`查看调试 trace`},placeholder:`向${o}提问…`,loadingPlaceholder:`正在加载助手…`,title:`${t} 智能助手`,newChat:`开启新对话`,share:`分享对话`,reviewDraft:e=>`查看 ${e} 项变更`,publishDrafts:`发布`,published:`已发布`,nextSteps:`下一步`,planTitle:`方案预览`,planQuestions:`搭建前请确认`,planAssumptions:`假设`,planApproveHint:`回复以确认或调整该方案。`,planApprove:`开始搭建`,planAdjust:`调整方案`,planBuilt:`已搭建`,planApproveMessage:`确认,开始搭建。`,planApproveDefaultsMessage:`确认搭建,未决问题按你的合理假设和默认处理。`,planAnswer:(e,t)=>`关于「${e}」,我选择「${t}」。`,publishOk:`已发布,对象已生效。`,publishFailed:`发布失败`,seedWarn:`已发布,但部分示例数据未能载入。`,openBuiltApp:`打开应用`,suggestions:e}}let c=[s[0]?`Show the latest ${s[0]}`:`Show my most recent records`,s[0]?`How many ${s[0]} are there?`:`Count records by status`,s[1]?`What fields does ${s[1]} have?`:`What data can I work with here?`].filter(Boolean);return{agentLabel:o,labels:{emptyTitle:`Hi, I'm ${o}`,emptyDescription:`I can help you query and analyze your ${t} data. Try a prompt below, or just type your question.`,clear:`Clear`,sendHint:`to send`,agentActivity:`Agent activity`,toolCompleted:`Completed`,toolRunning:`Running`,toolAwaitingApproval:`Awaiting approval`,toolFailed:`Failed`,connectionWaiting:`Waiting for server…`,connectionStalledLabel:`Still working…`,connectionOfflineLabel:`Connection lost — reconnecting…`,toolDetailsHidden:`Tool inputs and raw results are hidden in this view.`,copy:`Copy`,copied:`Copied`,regenerate:`Regenerate`,model:`Model`,submit:`Submit`,uploadFiles:`Upload files`,stopResponse:`Stop response`,trace:`trace`,viewTrace:`View trace`},placeholder:`Ask ${o}...`,loadingPlaceholder:`Loading assistant...`,title:`${t} Assistant`,newChat:`New chat`,share:`Share conversation`,reviewDraft:e=>`Review ${e} change${e===1?``:`s`}`,publishDrafts:`Publish`,published:`Published`,nextSteps:`What's next`,planTitle:`Proposed plan`,planQuestions:`Confirm before building`,planAssumptions:`Assumptions`,planApproveHint:`Reply to approve or adjust this plan.`,planApprove:`Build it`,planAdjust:`Adjust`,planBuilt:`Built`,planApproveMessage:`Looks good — build it as proposed.`,planApproveDefaultsMessage:`Build it with your best assumptions; use sensible defaults for the open questions.`,planAnswer:(e,t)=>`For "${e}", go with: ${t}.`,publishOk:`Published — objects are now live.`,publishFailed:`Publish failed`,seedWarn:`Published, but some sample data failed to load.`,openBuiltApp:`Open app`,suggestions:c}}var P=`/api/v1/ai`;function F(e){if(e)return e.replace(/\/$/,``);let t={BASE_URL:`./`,DEV:!1,MODE:`production`,PROD:!0,SSR:!1,VITE_SENTRY_DSN:`https://1373a588ceb9da150b11e64bf85f583d@o4510356161757184.ingest.us.sentry.io/4511439670673408`,VITE_SENTRY_ENVIRONMENT:`production`,VITE_SENTRY_SEND_DEFAULT_PII:`true`,VITE_SERVER_URL:``,VITE_USE_MOCK_SERVER:`false`},n=t.VITE_AI_BASE_URL;return n?n.replace(/\/$/,``):`${(t.VITE_SERVER_URL??``).replace(/\/$/,``)}${P}`}function ue(e,t){if(!e||e.type!==`object`)return null;let n=e.label||e.name||`this object`;return(t??``).toLowerCase().startsWith(`zh`)?[`为「${n}」补充字段`,`为「${n}」建议校验规则`,`添加一个状态选项字段`]:[`Add fields to ${n}`,`Suggest validations for ${n}`,`Add a status picklist field`]}var I=new Set([`view`,`record`,`page`,`dashboard`,`design`,`report`,`metadata`]);function L(e){try{return decodeURIComponent(e)}catch{return e}}function de(e,t){let n=e.split(`/`).filter(Boolean),r=n.indexOf(`apps`);if(r===-1||n.length<r+3)return{};let i=L(n[r+2]);if(I.has(i)||!t.some(e=>e.name===i))return{};let a=n[r+3]?L(n[r+3]):void 0,o=a&&a!==`new`?a:void 0;return{objectName:i,...o?{recordId:o}:{}}}function R({appLabel:e,appName:t,objects:r,agents:y,agentsLoading:x,activeAgent:S,onAgentChange:C,showAgentPicker:w,chatApi:T,apiBase:k,defaultOpen:A=!1,conversationId:M,initialMessages:N}){let{language:P}=a(),F=i(),I=n(),L=O.useMemo(()=>de(I.pathname,r),[I.pathname,r]),{editor:R}=_(),{models:z,defaultModelId:B}=se({apiBase:k}),[V,fe]=O.useState(void 0),H=V??B,pe=O.useMemo(()=>!N||N.length===0?[]:re(N),[N]),U=O.useMemo(()=>y.find(e=>e.name===S)?.label??S??e,[y,S,e]),W=O.useMemo(()=>le(P,e,S,U,r),[P,e,S,U,r]),me=O.useMemo(()=>ue(R,P),[R,P]),{errorSuppressed:he,handleChatError:ge,setMessagesRef:_e,resetSuppression:G}=ne({chatApi:T,conversationId:M}),{messages:K,isLoading:q,error:ve,sendMessage:J,stop:Y,reload:ye,clear:X,setMessages:Z}=ce({api:T,conversationId:M,model:H,onError:ge,body:{context:{activeApp:e,appName:t,objects:r.map(e=>({name:e.name,label:e.label})),agentName:S,autoPublishAiBuilds:D().features.autoPublishAiBuilds,...L.objectName?{objectName:L.objectName}:{},...L.recordId?{recordId:L.recordId}:{},...R?{editing:R}:{}}},initialMessages:pe,autoResponse:!T,autoResponseText:r.length>0?`I can help you work with ${r.map(e=>e.label||e.name).join(`, `)}. What would you like to do?`:`Thanks for your message! I'm here to help you navigate and manage your data.`,autoResponseDelay:600});O.useEffect(()=>{_e.current=Z},[Z]),O.useEffect(()=>{b(M,te(K))},[M,K]);let Q=oe({messages:K,apiBase:k,continueConversation:e=>{G(),J(e)}}),be=w&&y.length>1?(0,j.jsxs)(u,{value:S,onValueChange:C,disabled:x,children:[(0,j.jsx)(c,{className:`h-7 w-[180px] text-xs`,"data-testid":`floating-chatbot-agent-picker`,children:(0,j.jsx)(p,{placeholder:`Choose agent...`})}),(0,j.jsx)(d,{align:`end`,children:y.map(e=>(0,j.jsxs)(s,{value:e.name,className:`text-xs`,children:[(0,j.jsx)(`span`,{className:`font-medium`,children:e.label}),e.description?(0,j.jsx)(`span`,{className:`block text-muted-foreground text-[10px] truncate max-w-[220px]`,children:e.description}):null]},e.name))})]}):null,[xe,$]=O.useState(!1),Se=O.useMemo(()=>k.replace(/\/v1\/ai$/,``).replace(/\/ai$/,``)||`/api`,[k]),Ce=(0,j.jsxs)(j.Fragment,{children:[K.length>0?(0,j.jsx)(m,{variant:`ghost`,size:`icon`,className:`h-7 w-7`,"aria-label":W.newChat,title:W.newChat,"data-testid":`floating-chatbot-new`,onClick:X,children:(0,j.jsx)(f,{className:`h-4 w-4`})}):null,M?(0,j.jsx)(m,{variant:`ghost`,size:`icon`,className:`h-7 w-7`,"aria-label":W.share,title:W.share,"data-testid":`floating-chatbot-share`,onClick:()=>$(!0),children:(0,j.jsx)(l,{className:`h-4 w-4`})}):null]});return(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(ae,{onUpgrade:()=>window.open(E(),`_blank`,`noopener,noreferrer`),floatingConfig:{position:`bottom-right`,defaultOpen:A,panelWidth:420,panelHeight:560,title:W.title,triggerSize:56},headerExtra:be,headerActions:Ce,messages:K,labels:W.labels,models:z,selectedModelId:H,onModelChange:fe,showAvatars:!0,hideClearBar:!0,assistantAvatarFallback:W.agentLabel,suggestions:K.length===0?me??W.suggestions:void 0,placeholder:S?W.placeholder:x?W.loadingPlaceholder:W.placeholder,onSendMessage:e=>{G(),J(e)},onClear:X,onStop:q?Y:void 0,onReload:ye,isLoading:q,error:he?void 0:ve,enableMarkdown:!0,onToolApprove:Q.decide,toolDecisions:Q.decisions,toolApproveLabel:`Approve & run`,toolDenyLabel:`Reject`,toolDenyReason:`Operator rejected from chat`,onReviewDraft:e=>{e[0]&&g(e[0])},toolReviewLabel:W.reviewDraft,onOpenBuiltApp:e=>F(`/apps/${encodeURIComponent(e)}`),openBuiltAppLabel:W.openBuiltApp,onPreviewDraftApp:(e,t)=>F(t?.materialized?`/apps/${encodeURIComponent(e)}`:`/apps/${encodeURIComponent(e)}?preview=draft`),onDraftArtifacts:e=>{for(let t of e)v(t)},fetchPendingDraftCount:ee,onPublishDrafts:async e=>{try{let t=await fetch(`/api/v1/packages/${encodeURIComponent(e)}/publish-drafts`,{method:`POST`,credentials:`include`,headers:{"Content-Type":`application/json`,Accept:`application/json`},body:`{}`}),n=await t.json().catch(()=>null);if(!t.ok||n?.success===!1)throw Error(n?.error?.message||`HTTP ${t.status}`);let r=n?.data?.failedCount??n?.failedCount??0;if(r)throw Error(String(r));let i=n?.data?.seedApplied??n?.seedApplied;i&&i.success===!1?h.warning(W.seedWarn,{description:i.error??(Array.isArray(i.errors)&&i.errors.length?String(i.errors[0]):void 0)}):h.success(W.publishOk);let a=(n?.data?.published??n?.published??[]).find(e=>e?.type===`app`&&e?.name);return a?.name&&F(`/apps/${encodeURIComponent(a.name)}`),{ok:!0,health:ie(n)}}catch(e){return h.error(W.publishFailed,{description:e instanceof Error?e.message:void 0}),!1}},publishDraftsLabel:W.publishDrafts,nextStepsLabel:W.nextSteps,planTitleLabel:W.planTitle,planQuestionsLabel:W.planQuestions,planAssumptionsLabel:W.planAssumptions,planApproveHintLabel:W.planApproveHint,planApproveLabel:W.planApprove,planAdjustLabel:W.planAdjust,planBuiltLabel:W.planBuilt,planApproveMessage:W.planApproveMessage,planApproveDefaultsMessage:W.planApproveDefaultsMessage,planAnswerMessage:W.planAnswer,publishedLabel:W.published,autoPublishDrafts:D().features.autoPublishAiBuilds}),M&&(0,j.jsx)(o,{open:xe,onOpenChange:$,objectName:`ai_conversations`,recordId:M,recordLabel:`this conversation`,apiBase:Se})]})}function z({appLabel:e,appName:t,objects:n,apiBase:r,defaultAgent:i,showAgentPicker:a,defaultOpen:o=!1,userId:s}){let c=O.useMemo(()=>F(r),[r]),l={BASE_URL:`./`,DEV:!1,MODE:`production`,PROD:!0,SSR:!1,VITE_SENTRY_DSN:`https://1373a588ceb9da150b11e64bf85f583d@o4510356161757184.ingest.us.sentry.io/4511439670673408`,VITE_SENTRY_ENVIRONMENT:`production`,VITE_SENTRY_SEND_DEFAULT_PII:`true`,VITE_SERVER_URL:``,VITE_USE_MOCK_SERVER:`false`},u=l.VITE_AI_DEFAULT_AGENT,{agents:d,isLoading:f,error:p}=S({apiBase:c}),m=A({agents:d,showAgentPickerProp:a,envOptIn:l.VITE_AI_SHOW_AGENT_PICKER===`true`,aiStudioEnabled:D().features.aiStudio!==!1}),[h,g]=O.useState(void 0);O.useEffect(()=>{if(!h&&d.length>0){let e=x(d,i??u);e&&g(e)}},[d,h,i,u]);let _=h?`${c}/agents/${encodeURIComponent(h)}/chat`:void 0,{conversationId:v,initialMessages:b}=y({userId:h?s:void 0,scope:h,apiBase:c});return(0,j.jsx)(R,{appLabel:e,appName:t,objects:n,agents:d,agentsLoading:f,agentsError:p,activeAgent:h,onAgentChange:g,showAgentPicker:m,chatApi:_,apiBase:c,defaultOpen:o,conversationId:v,initialMessages:b},`${_??`local`}:${v??`pending`}`)}export{z as default};
@@ -1 +0,0 @@
1
- import{o as e,r as t}from"./rolldown-runtime-CMxvf4Kt.js";import{_ as n,f as r,t as i}from"./vendor-react-ClIa1CJA.js";import{f as a}from"./infrastructure-BtLHjSlJ.js";import{A as o,i as s,j as c,y as l}from"./framework-CQlIjbCT.js";import{Er as u,G as d,Gn as f,Gr as p,H as m,Hn as h,Hr as g,Hs as _,Ja as v,Ka as y,Kn as b,Ks as x,Un as S,V as C,Vn as w,Wn as T,ea as E,jc as ee,ni as D,qi as te,qs as O,yc as k,yr as A}from"./ui-components-CgiD1ql5.js";import{r as j}from"./vendor-ui-utils-C92Fl7BT.js";import"./AdapterProvider-BieqtbDy.js";import{n as M}from"./plugin-form-hyYQoCHc.js";import"./MetadataProvider-fKK6GbWD.js";import{r as ne}from"./ExpressionProvider-CT3sX7xF.js";import{Q as re,v as N}from"./ReportDefaultInspector-CoxrLLKh.js";import{n as P}from"./utils-6HhVlFkm.js";import{n as ie,r as ae,t as oe}from"./MetadataInspector-XbWYccBm.js";import{n as F,t as I}from"./DashboardWidgetInspector-ce9fT5XA.js";import{i as se,n as L,t as ce}from"./useOpenRecordList-D-g511Jw.js";import{n as le}from"./skeletons-k9g6qZSy.js";import{n as ue}from"./plugin-dashboard-Bl7wuG9f.js";var R=e(n(),1),z=i();function de({open:e,onClose:t,schema:n,selectedWidgetId:r,onSelectWidget:i,onSave:a,onChange:o,onRemoveWidget:c,name:l,metadataClient:d,onAfterChange:f}){let{t:m}=s(),h=(0,R.useMemo)(()=>N(),[]),[g,_]=(0,R.useState)(!1),[v,y]=(0,R.useState)(0),b=(0,R.useCallback)(e=>{_(!0),o({...n??{},...e})},[n,o]),x=(0,R.useCallback)(e=>{o(e),_(!1)},[o]),S=(0,R.useCallback)(e=>{i(e&&e.kind===`widget`?e.id:null)},[i]),C=Array.isArray(n?.widgets)?n.widgets:[],w=r?C.find(e=>e?.id===r):null;if(!e)return null;let T=typeof n?.name==`string`?n.name:``,E=w?m(`widget.editor.title`,{defaultValue:`Edit widget`}):m(`dashboard.editor.title`,{defaultValue:`Edit dashboard`});return(0,z.jsxs)(`aside`,{className:`hidden sm:flex w-[440px] shrink-0 flex-col border-l bg-background h-full`,"data-testid":`dashboard-config-panel`,role:`complementary`,"aria-label":E,children:[(0,z.jsxs)(`div`,{className:`flex items-center justify-between gap-2 border-b px-4 py-2.5 shrink-0`,children:[(0,z.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1.5`,children:[w&&(0,z.jsx)(A,{variant:`ghost`,size:`sm`,onClick:()=>i(null),className:`h-7 w-7 p-0`,"aria-label":m(`dashboard.editor.backToDashboard`,{defaultValue:`Back to dashboard`}),title:m(`dashboard.editor.backToDashboard`,{defaultValue:`Back to dashboard`}),"data-testid":`dashboard-config-back`,children:(0,z.jsx)(k,{className:`h-4 w-4`})}),(0,z.jsx)(`div`,{className:`text-sm font-medium truncate`,children:E})]}),(0,z.jsxs)(`div`,{className:`flex items-center gap-1 shrink-0`,children:[w&&c&&(0,z.jsx)(A,{variant:`ghost`,size:`sm`,onClick:()=>c(r),className:`h-7 w-7 p-0 text-destructive hover:text-destructive`,"aria-label":m(`widget.editor.delete`,{defaultValue:`Delete widget`}),title:m(`widget.editor.delete`,{defaultValue:`Delete widget`}),"data-testid":`widget-delete-button`,children:(0,z.jsx)(p,{className:`h-3.5 w-3.5`})}),(0,z.jsx)(A,{variant:`ghost`,size:`sm`,onClick:t,className:`h-7 w-7 p-0`,"aria-label":m(`common.close`,{defaultValue:`Close`}),"data-testid":`dashboard-config-close`,children:(0,z.jsx)(u,{className:`h-4 w-4`})})]})]}),(0,z.jsx)(`div`,{className:`min-h-0 flex-1 overflow-auto p-4`,children:w?(0,z.jsx)(I,{type:`dashboard`,name:T,draft:n??{},selection:{kind:`widget`,id:r},onPatch:b,onClearSelection:()=>i(null),onSelectionChange:S,readOnly:!1,locale:h}):(0,z.jsx)(F,{type:`dashboard`,name:T,draft:n??{},onPatch:b,onSelectionChange:S,readOnly:!1,locale:h})}),(0,z.jsxs)(`div`,{"data-testid":`dashboard-config-footer`,className:`flex items-center justify-end gap-2 border-t px-4 py-2.5 shrink-0`,children:[(0,z.jsx)(L,{type:`dashboard`,name:l||T||void 0,metadataClient:d,dirty:g,onResume:x,savedSignal:v,onAfterChange:f}),(0,z.jsx)(A,{size:`sm`,onClick:()=>{a(n??{}),_(!1),y(e=>e+1)},"data-testid":`dashboard-config-save`,children:m(`common.save`,{defaultValue:`Save`})})]})]})}var B=t({DashboardView:()=>W}),V=[{type:`metric`,label:`KPI Metric`,Icon:g},{type:`bar`,label:`Bar Chart`,Icon:O},{type:`line`,label:`Line Chart`,Icon:x},{type:`pie`,label:`Pie Chart`,Icon:_},{type:`table`,label:`Table`,Icon:D},{type:`pivot`,label:`Pivot`,Icon:y}],H=0;function U(){return H+=1,`widget_${Date.now()}_${H}`}function fe(e){return!e.widgets?.length||!e.widgets.some(e=>!e.id)?e:{...e,widgets:e.widgets.map(e=>e.id?e:{...e,id:U()})}}function pe(e){let t=V.find(t=>t.type===e);return t?`New ${t.label}`:`New Widget`}function W({dataSource:e}){let t=ce(),{dashboardName:n}=r(),{showDebug:i}=ie(),u=o(),p=re(),{t:g}=s(),{dashboardLabel:_,dashboardDescription:y}=ee(),{user:x}=a(),D=x?.role===`admin`,[O,k]=(0,R.useState)(!0),[N,F]=(0,R.useState)(!1),[I,L]=(0,R.useState)(null),[B,H]=(0,R.useState)(null),W=(0,R.useCallback)(e=>{H(t=>(t&&t.resolve(e),null))},[]),me=(0,R.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;H({schema:n,resolve:t})}),[]),he=(0,R.useMemo)(()=>({export_dashboard_pdf:async()=>{j.info(g(`dashboardActions.pdfPreparing`));try{return window.print(),{success:!0}}catch(e){return j.error(g(`dashboardActions.exportFailed`,{message:e?.message||String(e)})),{success:!1,error:e?.message||String(e)}}},forecast_dashboard:async()=>(j.info(g(`dashboardActions.forecastSoon`)),{success:!0})}),[g]);(0,R.useEffect)(()=>{k(!0),Y(null),F(!1),L(null),queueMicrotask(()=>k(!1))},[n]);let{dashboards:ge,objects:G,refresh:K}=c(),{app:_e}=ne(),q=ae(ge,n,_e?._packageId),[J,Y]=(0,R.useState)(null);(0,R.useEffect)(()=>{N||Y(null)},[q]);let X=(0,R.useCallback)(async e=>{try{p&&await se(`dashboard`,n,e,{metadataClient:p}),K().catch(()=>{})}catch(e){let t=e instanceof Error?e.message:String(e);console.warn(`[DashboardView] Auto-save failed:`,e),j.error(`Failed to save dashboard: ${t}`)}},[p,n,K]),ve=(0,R.useCallback)(()=>{Y(fe(q)),F(!0)},[q]),ye=(0,R.useCallback)(()=>{F(!1),L(null)},[]),be=(0,R.useCallback)(e=>{if(!J)return;let t=U(),n={id:t,title:pe(e),type:e,layout:{x:0,y:J.widgets?.length??0,w:J.columns??2,h:1}},r={...J,widgets:[...J.widgets||[],n]};Y(r),X(r),L(t)},[J,X]),xe=(0,R.useCallback)(e=>{if(!J)return;let t={...J,widgets:J.widgets.filter(t=>t.id!==e)};Y(t),X(t),I===e&&L(null)},[J,I,X]),Se=(0,R.useCallback)(e=>{let t=J||q;if(!t)return;let n={...t,widgets:e};Y(n),X(n)},[J,q,X]),Ce=(J||q)??null,Z=(0,R.useMemo)(()=>new Set((G||[]).map(e=>e?.name).filter(Boolean)),[G]),Q=J||q,$=(0,R.useMemo)(()=>{if(!Q||Z.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?Z.has(t):!0});return t.length===e.length?Q:{...Q,widgets:t}},[Q,Z]);return O?(0,z.jsx)(le,{}):q?(0,z.jsxs)(`div`,{className:`flex flex-col h-full overflow-hidden bg-background`,children:[(0,z.jsxs)(`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,z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(()=>{let e=P(($||q).title,g),t=P(q.label,g),n=_({name:q.name,label:t});return(0,z.jsx)(`h1`,{className:`text-lg sm:text-xl md:text-2xl font-bold tracking-tight truncate`,children:e||n||q.name})})(),(()=>{let e=($||q).description??q.description,t=y({name:q.name,description:P(e,g)});return t?(0,z.jsx)(`p`,{className:`text-sm text-muted-foreground mt-1 line-clamp-2`,children:t}):null})()]}),(0,z.jsxs)(`div`,{className:`shrink-0 flex items-center gap-1.5`,children:[N&&(0,z.jsx)(`div`,{className:`flex items-center gap-1 mr-2`,role:`toolbar`,"aria-label":`Add widgets`,"data-testid":`dashboard-widget-toolbar`,children:V.map(({type:e,label:t,Icon:n})=>(0,z.jsxs)(`button`,{type:`button`,"data-testid":`dashboard-add-${e}`,onClick:()=>be(e),className:`inline-flex items-center gap-1 rounded-md border border-input bg-background px-2 py-1.5 text-[11px] font-medium text-muted-foreground hover:bg-accent hover:text-accent-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring`,title:`Add ${t}`,"aria-label":`Add ${t} widget`,children:[(0,z.jsx)(te,{className:`h-3 w-3`}),(0,z.jsx)(n,{className:`h-3 w-3`})]},e))}),D&&(0,z.jsxs)(`button`,{type:`button`,onClick:ve,className:`inline-flex items-center gap-1.5 rounded-md border border-input bg-background px-2.5 py-1.5 text-xs font-medium text-muted-foreground shadow-sm hover:bg-accent hover:text-accent-foreground`,"data-testid":`dashboard-edit-button`,children:[(0,z.jsx)(E,{className:`h-3.5 w-3.5`}),g(`common.edit`,{defaultValue:`Edit`})]})]})]}),(0,z.jsxs)(`div`,{className:`flex-1 overflow-hidden flex flex-col sm:flex-row relative`,children:[(0,z.jsx)(`div`,{className:`flex-1 min-w-0 overflow-auto p-2 sm:p-4 md:p-6`,children:(0,z.jsx)(l,{value:{openRecordList:t},children:(0,z.jsx)(ue,{schema:$,dataSource:e,designMode:N,selectedWidgetId:I,onWidgetClick:L,onWidgetsReorder:Se,modalHandler:me,scriptHandlers:he,hideHeaderText:!0})})}),(0,z.jsx)(de,{open:N&&D,onClose:ye,schema:Ce,selectedWidgetId:I,onSelectWidget:L,onSave:X,onChange:Y,onRemoveWidget:xe,name:n,metadataClient:p,onAfterChange:()=>K().catch(()=>{})}),(0,z.jsx)(oe,{open:i,sections:[{title:`Dashboard Configuration`,data:$}]})]}),B&&B.schema?.objectName?(0,z.jsx)(M,{schema:{type:`object-form`,formType:`modal`,objectName:B.schema.objectName,mode:B.schema.mode||`create`,recordId:B.schema.recordId,title:B.schema.title,description:B.schema.description,fields:B.schema.fields,open:!0,onOpenChange:e=>{e||W({success:!1})},onSuccess:e=>{W({success:!0,reload:!0,data:e})},onCancel:()=>{W({success:!1})},showSubmit:!0,showCancel:!0},dataSource:u}):B?(0,z.jsx)(w,{open:!0,onOpenChange:e=>{e||W({success:!1})},children:(0,z.jsxs)(h,{children:[(0,z.jsxs)(f,{children:[(0,z.jsx)(b,{children:B.schema?.title||g(`actionDialog.defaultActionTitle`)}),B.schema?.description&&(0,z.jsx)(S,{children:B.schema.description})]}),(0,z.jsxs)(T,{children:[(0,z.jsx)(A,{variant:`outline`,onClick:()=>W({success:!1}),children:g(`actionDialog.cancel`)}),(0,z.jsx)(A,{onClick:()=>W({success:!0}),children:g(`actionDialog.ok`)})]})]})}):null]}):(0,z.jsx)(`div`,{className:`h-full flex items-center justify-center p-8`,children:(0,z.jsxs)(C,{children:[(0,z.jsx)(`div`,{className:`mx-auto mb-4 flex h-12 w-12 items-center justify-center rounded-full bg-muted`,children:(0,z.jsx)(v,{className:`h-6 w-6 text-muted-foreground`})}),(0,z.jsx)(d,{children:g(`empty.dashboardNotFound`)}),(0,z.jsx)(m,{children:g(`empty.dashboardNotFoundDescription`,{name:n})})]})})}export{B as t};
@@ -1 +0,0 @@
1
- import{o as e}from"./rolldown-runtime-CMxvf4Kt.js";import{_ as t,t as n}from"./vendor-react-ClIa1CJA.js";import{R as r,l as i,m as a}from"./vendor-objectstack-C1teU2a6.js";import{Ei as o,Er as s,Fn as c,Gs as l,Gt as u,Hs as d,In as f,Js as p,Ks as m,Kt as h,Ln as g,Ms as _,Nn as v,Qo as y,Ra as b,Rn as x,Tc as S,Ut as C,Vs as w,Wr as T,Ws as E,Wt as D,Yo as O,an as k,cs as A,fo as j,in as M,ln as N,lo as P,ni as ee,nn as te,qi as ne,qt as F,rn as re,rr as ie,wc as ae,yr as I,zn as oe,zs as se}from"./ui-components-CgiD1ql5.js";import{G as L,H as ce,J as le,K as ue,Q as R,W as de,Y as fe,_ as pe,a as me,g as he,i as ge,j as _e,p as ve,q as z,r as ye,t as B,y as V}from"./ReportDefaultInspector-CoxrLLKh.js";var H=e(t(),1),U=n();function be(e,t){if(!t)return!0;let n=t.toLowerCase();return e.value.toLowerCase().includes(n)||e.label.toLowerCase().includes(n)||(e.group?.toLowerCase().includes(n)??!1)}function W({label:e,value:t,onCommit:n,options:r,placeholder:i=`Select…`,searchPlaceholder:a=`Search or type…`,emptyText:o=`No match — keep typing to use a custom value.`,disabled:s,loading:l,allowCustom:u=!0,mono:d,className:p}){let[m,h]=H.useState(!1),[y,b]=H.useState(``),C=r.find(e=>e.value===t),w=C?C.label:t||(l?`Loading…`:i),T=H.useMemo(()=>r.filter(e=>be(e,y)),[r,y]),E=H.useMemo(()=>{let e=[],t=new Map;for(let n of T){let r=n.group??``;t.has(r)||(t.set(r,[]),e.push(r)),t.get(r).push(n)}return e.map(e=>({heading:e,items:t.get(e)}))},[T]),D=y.trim(),O=u&&!!D&&!r.some(e=>e.value===D),k=e=>{n(e),h(!1),b(``)},A=(0,U.jsxs)(te,{open:m,onOpenChange:e=>{h(e),e||b(``)},children:[(0,U.jsx)(M,{asChild:!0,children:(0,U.jsxs)(I,{type:`button`,variant:`outline`,role:`combobox`,"aria-expanded":m,disabled:s,className:S(`h-8 w-full justify-between px-2 text-sm font-normal`,p),children:[(0,U.jsx)(`span`,{className:S(`truncate`,d&&`font-mono`,!C&&!t&&`text-muted-foreground`),children:w}),(0,U.jsx)(_,{className:`ml-2 h-3.5 w-3.5 shrink-0 opacity-50`})]})}),(0,U.jsx)(re,{align:`start`,className:`w-[var(--radix-popover-trigger-width)] min-w-[14rem] p-0`,children:(0,U.jsxs)(v,{shouldFilter:!1,children:[(0,U.jsx)(g,{value:y,onValueChange:b,placeholder:a}),(0,U.jsxs)(oe,{children:[!O&&T.length===0&&(0,U.jsx)(c,{children:o}),O&&(0,U.jsx)(f,{children:(0,U.jsx)(x,{value:`__custom__${D}`,onSelect:()=>k(D),children:(0,U.jsxs)(`span`,{className:`truncate`,children:[`Use `,(0,U.jsxs)(`span`,{className:`font-mono`,children:[`“`,D,`”`]})]})})}),E.map((e,n)=>(0,U.jsx)(f,{heading:e.heading||void 0,children:e.items.map(e=>(0,U.jsxs)(x,{value:e.value,onSelect:()=>k(e.value),children:[(0,U.jsx)(se,{className:S(`h-3.5 w-3.5`,e.value===t?`opacity-100`:`opacity-0`)}),(0,U.jsx)(`span`,{className:`truncate font-mono`,children:e.value}),e.label&&e.label!==e.value&&(0,U.jsx)(`span`,{className:`ml-1 truncate text-muted-foreground`,children:e.label}),e.hint&&(0,U.jsx)(`span`,{className:`ml-auto pl-2 text-[10px] text-muted-foreground`,children:e.hint})]},e.value))},e.heading||`g${n}`))]})]})})]});return e?(0,U.jsxs)(`div`,{className:`space-y-1`,children:[(0,U.jsx)(N,{className:`text-xs text-muted-foreground`,children:e}),A]}):A}var xe=new Set([`lookup`,`master_detail`,`masterdetail`,`master-detail`]);function G(e,t){if(typeof e==`string`&&e)return e;if(e&&typeof e==`object`){let t=e.default;if(typeof t==`string`&&t)return t}return t}function Se(e){let t=e.reference??e.reference_to??e.referenceTo??e.reference_to_object;if(typeof t==`string`&&t)return t;if(Array.isArray(t)&&typeof t[0]==`string`)return t[0];if(t&&typeof t==`object`){let e=t.object;if(typeof e==`string`&&e)return e}}function Ce(e){switch(e){case`lookup`:case`master_detail`:case`masterDetail`:case`master-detail`:return`lookup`;case`date`:case`datetime`:case`time`:return`date`;case`number`:case`currency`:case`percent`:case`int`:case`integer`:case`float`:case`double`:case`autonumber`:return`number`;case`boolean`:case`toggle`:return`boolean`;default:return`string`}}function K(e,t){if(!e)return{label:t,fields:[],relationships:[]};let n=G(e.label,t),r=_e(e.fields).entries.map(e=>({name:e.name,label:G(e.def.label,e.name),type:typeof e.def.type==`string`?e.def.type:void 0,def:e.def}));return{label:n,fields:r,relationships:r.filter(e=>e.type&&xe.has(e.type.toLowerCase())).map(e=>({name:e.name,label:e.label,referenceTo:Se(e.def)}))}}function q(e,t,n){let r=e,i=[];for(let e of t.split(`.`)){let t=r.relationships.find(t=>t.name===e);if(!t?.referenceTo)return;let a=n[t.referenceTo];if(!a)return;i.push(t.label),r=a}return{target:r,labels:i}}function we(e,t,n){let r=e.fields.map(t=>({value:t.name,label:t.label,type:t.type,group:e.label}));for(let i of t){let t=q(e,i,n);if(!t)continue;let a=[...t.labels,t.target.label].join(` → `);for(let e of t.target.fields)r.push({value:`${i}.${e.name}`,label:e.label,type:e.type,group:a})}return r}function J(e,t){if(!e||typeof e!=`object`)return!1;if(Array.isArray(e))return e.some(e=>J(e,t));let n=e;return typeof n.dataset==`string`&&n.dataset===t?!0:Object.values(n).some(e=>e&&typeof e==`object`&&J(e,t))}function Y(){let e=R(),[t,n]=H.useState({options:[],loading:!0});return H.useEffect(()=>{let t=!1;return n(e=>({...e,loading:!0})),e.list(`object`).then(e=>{t||n({options:(Array.isArray(e)?e:[]).map(e=>({name:typeof e.name==`string`?e.name:``,label:G(e.label,typeof e.name==`string`?e.name:``)})).filter(e=>!!e.name).sort((e,t)=>e.label.localeCompare(t.label)),loading:!1})}).catch(()=>{t||n({options:[],loading:!1})}),()=>{t=!0}},[e]),t}function Te(e,t){let n=R(),r=t.join(`\0`),[i,a]=H.useState({relationships:[],fieldOptions:[],loading:!!e});return H.useEffect(()=>{if(!e){a({relationships:[],fieldOptions:[],loading:!1});return}let t=!1;return a(e=>({...e,loading:!0})),(async()=>{try{let i=await n.get(`object`,e);if(t)return;let o=K(i,e),s=r?r.split(`\0`):[],c={[e]:o},l=async e=>{if(c[e])return c[e];let t;try{t=K(await n.get(`object`,e),e)}catch{t=K(null,e)}return c[e]=t,t};for(let e of s){let t=o;for(let n of e.split(`.`)){let e=t.relationships.find(e=>e.name===n);if(!e?.referenceTo)break;t=await l(e.referenceTo)}}if(t)return;let u=[...o.relationships];for(let e of s){if(e.split(`.`).length>=3)continue;let t=q(o,e,c);if(t)for(let n of t.target.relationships)u.push({name:`${e}.${n.name}`,label:`${e}.${n.name}`,referenceTo:n.referenceTo})}a({relationships:u,fieldOptions:we(o,s,c),loading:!1})}catch{t||a({relationships:[],fieldOptions:[],loading:!1})}})(),()=>{t=!0}},[n,e,r]),i}function Ee(e){let t=R(),[n,r]=H.useState({reports:0,dashboards:0,loading:!!e});return H.useEffect(()=>{if(!e){r({reports:0,dashboards:0,loading:!1});return}let n=!1;return r(e=>({...e,loading:!0})),(async()=>{let[i,a]=await Promise.all([t.list(`report`).catch(()=>[]),t.list(`dashboard`).catch(()=>[])]);n||r({reports:(Array.isArray(i)?i:[]).filter(t=>J(t,e)).length,dashboards:(Array.isArray(a)?a:[]).filter(t=>J(t,e)).length,loading:!1})})(),()=>{n=!0}},[t,e]),n}var X={metric:{id:`metric`,label:`Metric (KPI)`,category:`kpi`,icon:P},bar:{id:`bar`,label:`Bar chart`,category:`chart`,icon:l},"horizontal-bar":{id:`horizontal-bar`,label:`Horizontal bar`,category:`chart`,icon:E},line:{id:`line`,label:`Line chart`,category:`chart`,icon:m},area:{id:`area`,label:`Area chart`,category:`chart`,icon:p},pie:{id:`pie`,label:`Pie chart`,category:`chart`,icon:d},donut:{id:`donut`,label:`Donut chart`,category:`chart`,icon:O},scatter:{id:`scatter`,label:`Scatter plot`,category:`chart`,icon:w},funnel:{id:`funnel`,label:`Funnel`,category:`chart`,icon:T},table:{id:`table`,label:`Data table`,category:`data`,icon:ee},pivot:{id:`pivot`,label:`Pivot table`,category:`data`,icon:y},list:{id:`list`,label:`Record list`,category:`data`,icon:b},custom:{id:`custom`,label:`Custom widget`,category:`custom`,icon:A}},De={kpi:`Single value`,chart:`Charts`,data:`Tabular`,custom:`Custom`},Oe=[`kpi`,`chart`,`data`,`custom`].map(e=>({category:e,types:Object.values(X).filter(t=>t.category===e)})),ke=ae;function Ae({onAdd:e,label:t=`Add widget`}){let[n,r]=H.useState(!1),[i,a]=H.useState(``),s=H.useRef(null),c=H.useRef(null);H.useEffect(()=>{if(!n){a(``);return}let e=e=>{s.current?.contains(e.target)||r(!1)},t=e=>{e.key===`Escape`&&r(!1)};return document.addEventListener(`mousedown`,e),document.addEventListener(`keydown`,t),queueMicrotask(()=>c.current?.focus()),()=>{document.removeEventListener(`mousedown`,e),document.removeEventListener(`keydown`,t)}},[n]);let l=H.useMemo(()=>{let e=i.trim().toLowerCase();return e?Oe.map(t=>({category:t.category,types:t.types.filter(t=>t.id.toLowerCase().includes(e)||t.label.toLowerCase().includes(e))})).filter(e=>e.types.length):Oe},[i]);return(0,U.jsxs)(`div`,{ref:s,className:`relative`,children:[(0,U.jsxs)(`button`,{type:`button`,className:`inline-flex items-center gap-1 rounded border border-dashed px-3 py-1.5 text-xs text-muted-foreground hover:bg-muted/30 hover:text-foreground`,onClick:()=>r(e=>!e),children:[(0,U.jsx)(ne,{className:`h-3 w-3`}),t]}),n&&(0,U.jsxs)(`div`,{className:`absolute right-0 top-full z-40 mt-1 w-72 rounded-md border bg-popover shadow-md`,children:[(0,U.jsxs)(`div`,{className:`flex items-center gap-2 border-b px-2 py-1.5`,children:[(0,U.jsx)(o,{className:`h-3.5 w-3.5 text-muted-foreground`}),(0,U.jsx)(`input`,{ref:c,type:`text`,value:i,onChange:e=>a(e.target.value),placeholder:`Search widgets…`,className:`w-full bg-transparent text-xs outline-none placeholder:text-muted-foreground`})]}),(0,U.jsx)(`div`,{className:`max-h-72 overflow-auto py-1`,children:l.length===0?(0,U.jsx)(`div`,{className:`px-3 py-4 text-center text-xs text-muted-foreground`,children:`No matches.`}):l.map(t=>(0,U.jsxs)(`div`,{children:[(0,U.jsx)(`div`,{className:`px-3 pt-2 pb-1 text-[10px] uppercase tracking-wider text-muted-foreground`,children:De[t.category]}),t.types.map(t=>(0,U.jsxs)(`button`,{type:`button`,className:`flex w-full items-center gap-2 px-3 py-1.5 text-left text-xs hover:bg-accent`,onClick:()=>{e(t.id),r(!1)},children:[(0,U.jsx)(X[t.id]?.icon??ke,{className:`h-3.5 w-3.5 text-muted-foreground shrink-0`}),(0,U.jsx)(`span`,{className:`font-medium truncate`,children:t.label}),(0,U.jsx)(`code`,{className:`ml-auto text-[10px] text-muted-foreground`,children:t.id})]},t.id))]},t.category))})]})]})}var je={io:`input`,unrepresentable:`any`},Me=new Set([`widgets`,`label`,`description`,`name`]),Z,Ne=!1;function Pe(){if(Z||Ne)return Z;try{Z=r(i,je)}catch(e){Ne=!0,typeof console<`u`&&console.warn(`[dashboard-schema] failed to derive Dashboard JSONSchema from spec`,e)}return Z}var Q;function Fe(){if(Q)return Q;if(!(!a||typeof a!=`object`)){try{let e=JSON.parse(JSON.stringify(a));for(let t of e.sections??[])t.fields=(t.fields??[]).filter(e=>{let t=typeof e==`string`?e:e?.field;return!Me.has(t)});e.sections=(e.sections??[]).filter(e=>(e.fields??[]).length>0),Q=e}catch(e){typeof console<`u`&&console.warn(`[dashboard-schema] failed to prepare dashboardForm from spec`,e);return}return Q}}var Ie=new Set([`name`,`label`,`description`,`widgets`]);function Le({draft:e,onPatch:t,readOnly:n,locale:r,onSelectionChange:i,serverSchema:a}){let o=H.useCallback(e=>V(e,r),[r]),c=typeof e.label==`string`?e.label:``,l=typeof e.description==`string`?e.description:``,u=H.useMemo(()=>Array.isArray(e.widgets)?e.widgets:[],[e.widgets]),d=e=>{let n=fe(`widget`,u.map(e=>e?.id).filter(Boolean)),r=X[e],a=r?`New ${r.label.toLowerCase()}`:`New widget`;t({widgets:ue(u,{id:n,type:e,title:a,...r?.defaults??{}})}),i?.({kind:`widget`,id:n,label:a})},f=e=>{t({widgets:le(u,e,null)})},p=(e,n)=>{e!==n&&t({widgets:z(u,e,n)})},m=(e,t)=>{e?.id&&i?.({kind:`widget`,id:e.id,label:e.title||e.id||`Widget ${t+1}`})},[h,g]=H.useState(null),[_,v]=H.useState(null),{schema:y,form:b}=H.useMemo(()=>me({bundledSchema:Pe(),bundledForm:Fe(),serverSchema:a,excludeFields:Ie,sectionTitle:V(`engine.inspector.moreFields`,r)}),[a,r]);return(0,U.jsxs)(de,{kindLabel:o(`engine.inspector.dashboard.kind`),title:String(c||e.name||o(`engine.inspector.dashboard.kind`)),onClose:()=>{},closeLabel:o(`engine.inspector.dashboard.close`),hideClose:!0,children:[(0,U.jsx)(L,{label:o(`engine.inspector.dashboard.label`),value:c,onCommit:e=>t({label:e}),placeholder:o(`engine.inspector.dashboard.labelPlaceholder`),disabled:n}),(0,U.jsx)(L,{label:o(`engine.inspector.dashboard.description`),value:l,onCommit:e=>t({description:e}),placeholder:o(`engine.inspector.dashboard.descriptionPlaceholder`),disabled:n}),(0,U.jsxs)(`div`,{className:`border-t pt-3 space-y-1.5`,children:[(0,U.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,U.jsx)(N,{className:`text-xs text-muted-foreground`,children:o(`engine.inspector.dashboard.widgets`)}),(0,U.jsx)(ie,{variant:`outline`,className:`text-[10px]`,children:u.length})]}),u.length===0?(0,U.jsx)(`p`,{className:`rounded-md border border-dashed bg-muted/30 px-3 py-3 text-center text-[11px] text-muted-foreground`,children:o(`engine.inspector.dashboard.widgetsEmpty`)}):(0,U.jsx)(`div`,{className:`space-y-1`,children:u.map((e,t)=>{let r=X[e?.type]?.icon??ke;return(0,U.jsxs)(`div`,{draggable:!n,onDragStart:()=>g(t),onDragEnd:()=>{g(null),v(null)},onDragOver:e=>{e.preventDefault(),v(t)},onDrop:()=>{h!=null&&h!==t&&p(h,t),g(null),v(null)},className:`group flex items-center gap-2 rounded-md border px-2 py-1.5 text-xs hover:bg-accent`+(_===t&&h!==null&&h!==t?` border-primary`:``),children:[!n&&(0,U.jsx)(j,{className:`h-3.5 w-3.5 shrink-0 cursor-grab text-muted-foreground`}),(0,U.jsx)(r,{className:`h-3.5 w-3.5 shrink-0 text-muted-foreground`}),(0,U.jsx)(`button`,{type:`button`,className:`min-w-0 flex-1 truncate text-left font-medium`,onClick:()=>m(e,t),title:e?.title||e?.id,children:e?.title||e?.id||`Widget ${t+1}`}),(0,U.jsx)(`code`,{className:`text-[10px] text-muted-foreground`,children:e?.type}),!n&&(0,U.jsx)(I,{type:`button`,variant:`ghost`,size:`sm`,className:`h-6 w-6 shrink-0 p-0 opacity-0 group-hover:opacity-100`,onClick:()=>f(t),title:o(`engine.inspector.dashboard.removeWidget`),"aria-label":o(`engine.inspector.dashboard.removeWidget`),children:(0,U.jsx)(s,{className:`h-3.5 w-3.5`})})]},e?.id??t)})}),!n&&(0,U.jsx)(Ae,{onAdd:d,label:o(`engine.inspector.add.widget`)})]}),(0,U.jsx)(`div`,{className:`border-t pt-3`,children:y?(0,U.jsx)(ve,{schema:y,form:b,value:e,hiddenFields:[`name`,`label`,`description`,`widgets`],readOnly:n,onChange:e=>t(e)}):(0,U.jsx)(`p`,{className:`text-[11px] text-muted-foreground`,children:o(`engine.inspector.dashboard.noSchema`)})})]})}var Re=[{value:`metric`,label:`KPI Metric`},{value:`bar`,label:`Bar Chart`},{value:`line`,label:`Line Chart`},{value:`pie`,label:`Pie Chart`},{value:`table`,label:`Table`},{value:`grid`,label:`Grid`}],ze=[`count`,`sum`,`avg`,`min`,`max`],Be=[`default`,`blue`,`teal`,`orange`,`purple`,`success`,`warning`,`danger`];function Ve(e,t){let n=Array.isArray(e.widgets)?e.widgets:[],r=n.findIndex(e=>e?.id===t);return r<0?null:{widget:n[r],index:r}}function He({draft:e,selection:t,onPatch:n,onClearSelection:r,onSelectionChange:i,readOnly:a,locale:o}){let c=Array.isArray(e.widgets)?e.widgets:[],l=t.kind===`widget`?t.id:void 0,d=l?Ve(e,l):null,f=d?.widget??{},p=typeof f.dataset==`string`?f.dataset:``,m=typeof f.object==`string`?f.object:``,g=Array.isArray(f.dimensions)?f.dimensions.filter(e=>typeof e==`string`):[],_=Array.isArray(f.values)?f.values.filter(e=>typeof e==`string`):[],v=ye(),y=ge(p||void 0,v),{options:b,loading:x}=Y(),{fields:S}=he(m||void 0),w=H.useMemo(()=>{let e=v.datasets.map(e=>({value:e.name,label:e.label&&e.label!==e.name?`${e.label} (${e.name})`:e.name}));return p&&!e.some(e=>e.value===p)&&e.push({value:p,label:p}),e},[v.datasets,p]),T=H.useMemo(()=>b.map(e=>({value:e.name,label:e.label})),[b]),E=H.useMemo(()=>S.map(e=>({value:e.name,label:e.label,hint:e.type})),[S]),O=H.useMemo(()=>y.measures.map(e=>({name:e.name,label:e.aggregate?`${e.name} · ${e.aggregate}`:e.name,type:`number`,hidden:!1})),[y.measures]),A=H.useMemo(()=>y.dimensions.map(e=>({name:e.name,label:e.name,type:e.type??`text`,hidden:!1})),[y.dimensions]);if(t.kind!==`widget`)return(0,U.jsx)(Ue,{message:`Unsupported selection kind: ${t.kind}`,onClose:r,locale:o});if(!d)return(0,U.jsx)(Ue,{message:`The selected widget was removed from the draft.`,onClose:r,locale:o});let{widget:j,index:M}=d;function N(e){let t=[...c];t[M]={...t[M],...e},n({widgets:t})}function P(e){n({widgets:z(c,M,e)}),j.id&&i?.({kind:`widget`,id:j.id,label:j.title??void 0})}return(0,U.jsxs)(`div`,{className:`space-y-4`,children:[(0,U.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,U.jsxs)(`div`,{className:`min-w-0`,children:[(0,U.jsx)(`div`,{className:`text-[10px] uppercase tracking-wider text-muted-foreground`,children:V(`engine.inspector.widget.kind`,o)}),(0,U.jsx)(`div`,{className:`truncate text-sm font-semibold`,children:j.title||t.label||`Widget ${M+1}`})]}),(0,U.jsxs)(`div`,{className:`flex items-center gap-1 shrink-0`,children:[(0,U.jsx)(ce,{index:M,total:c.length,onMove:P,upLabel:V(`engine.inspector.reorder.up`,o),downLabel:V(`engine.inspector.reorder.down`,o),disabled:a}),(0,U.jsx)(I,{type:`button`,variant:`ghost`,size:`sm`,className:`h-7 w-7 p-0`,onClick:r,title:V(`engine.inspector.widget.close`,o),"aria-label":V(`engine.inspector.widget.close`,o),children:(0,U.jsx)(s,{className:`h-3.5 w-3.5`})})]})]}),(0,U.jsx)($,{id:`widget-title`,label:V(`engine.inspector.widget.title`,o),children:(0,U.jsx)(k,{id:`widget-title`,value:j.title??``,onChange:e=>N({title:e.target.value}),disabled:a})}),(0,U.jsx)($,{id:`widget-type`,label:V(`engine.inspector.widget.type`,o),children:(0,U.jsxs)(C,{value:j.type??`metric`,onValueChange:e=>N({type:e}),disabled:a,children:[(0,U.jsx)(h,{id:`widget-type`,children:(0,U.jsx)(F,{})}),(0,U.jsx)(D,{children:Re.map(e=>(0,U.jsx)(u,{value:e.value,children:e.label},e.value))})]})}),(0,U.jsxs)(`div`,{className:`space-y-3 rounded-md border border-dashed border-primary/40 bg-primary/5 p-3`,children:[(0,U.jsx)(`div`,{className:`text-[10px] font-semibold uppercase tracking-wider text-primary/80`,children:V(`engine.inspector.widget.datasetSection`,o)}),(0,U.jsxs)($,{id:`widget-dataset`,label:V(`engine.inspector.widget.dataset`,o),children:[(0,U.jsx)(W,{value:p,onCommit:e=>N({dataset:e||void 0}),options:w,loading:v.loading,placeholder:V(`engine.inspector.widget.datasetPlaceholder`,o),searchPlaceholder:V(`engine.inspector.widget.datasetPlaceholder`,o),disabled:a,mono:!0}),(0,U.jsx)(`p`,{className:`text-[10px] leading-snug text-muted-foreground`,children:V(`engine.inspector.widget.datasetHint`,o)})]}),p&&(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(B,{label:V(`engine.inspector.widget.dimensions`,o),emptyText:V(`engine.inspector.widget.dimensionsHint`,o),names:g,options:A,loading:y.loading,error:y.error,readOnly:a,onCommit:e=>N({dimensions:e})}),(0,U.jsx)(B,{label:V(`engine.inspector.widget.values`,o),emptyText:V(`engine.inspector.widget.valuesHint`,o),names:_,options:O,loading:y.loading,error:y.error,readOnly:a,onCommit:e=>N({values:e})})]})]}),(0,U.jsx)($,{id:`widget-object`,label:V(`engine.inspector.widget.object`,o),children:(0,U.jsx)(W,{value:j.object??``,onCommit:e=>N({object:e||void 0}),options:T,loading:x,placeholder:`Select an object…`,searchPlaceholder:`Search objects…`,disabled:a,mono:!0})}),(0,U.jsx)($,{id:`widget-value-field`,label:V(`engine.inspector.widget.valueField`,o),children:(0,U.jsx)(W,{value:j.valueField??``,onCommit:e=>N({valueField:e||void 0}),options:E,placeholder:j.object?`Select a field…`:`e.g. amount`,searchPlaceholder:`Search fields…`,disabled:a,mono:!0})}),(0,U.jsx)($,{id:`widget-category-field`,label:V(`engine.inspector.widget.categoryField`,o),children:(0,U.jsx)(W,{value:j.categoryField??``,onCommit:e=>N({categoryField:e||void 0}),options:E,placeholder:j.object?`Select a field…`:`e.g. status`,searchPlaceholder:`Search fields…`,disabled:a,mono:!0})}),(0,U.jsx)($,{id:`widget-aggregate`,label:V(`engine.inspector.widget.aggregate`,o),children:(0,U.jsxs)(C,{value:j.aggregate??`count`,onValueChange:e=>N({aggregate:e}),disabled:a,children:[(0,U.jsx)(h,{id:`widget-aggregate`,children:(0,U.jsx)(F,{})}),(0,U.jsx)(D,{children:ze.map(e=>(0,U.jsx)(u,{value:e,children:e},e))})]})}),(0,U.jsx)($,{id:`widget-color`,label:V(`engine.inspector.widget.color`,o),children:(0,U.jsx)(pe,{value:j.colorVariant??`default`,onChange:e=>N({colorVariant:e}),disabled:a,options:Be.map(e=>({value:e}))})}),(0,U.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,U.jsx)($,{id:`widget-w`,label:V(`engine.inspector.widget.width`,o),children:(0,U.jsx)(k,{id:`widget-w`,type:`number`,min:1,value:j.layout?.w??1,onChange:e=>N({layout:{...j.layout??{},w:Number(e.target.value)||1}}),disabled:a})}),(0,U.jsx)($,{id:`widget-h`,label:V(`engine.inspector.widget.height`,o),children:(0,U.jsx)(k,{id:`widget-h`,type:`number`,min:1,value:j.layout?.h??1,onChange:e=>N({layout:{...j.layout??{},h:Number(e.target.value)||1}}),disabled:a})})]}),!a&&(0,U.jsx)(`div`,{className:`pt-2 border-t`,children:(0,U.jsx)(I,{type:`button`,variant:`outline`,size:`sm`,className:`w-full text-destructive hover:text-destructive`,onClick:()=>{let t=Array.isArray(e.widgets)?[...e.widgets]:[];t.splice(M,1),n({widgets:t}),r()},children:V(`engine.inspector.widget.remove`,o)})})]})}function $({id:e,label:t,children:n}){return(0,U.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,U.jsx)(N,{htmlFor:e,className:`text-xs font-medium text-muted-foreground`,children:t}),n]})}function Ue({message:e,onClose:t,locale:n}){return(0,U.jsxs)(`div`,{className:`space-y-3 rounded-md border border-dashed p-4 text-sm text-muted-foreground`,children:[(0,U.jsx)(`p`,{children:e}),(0,U.jsx)(I,{type:`button`,variant:`outline`,size:`sm`,onClick:t,children:V(`engine.inspector.widget.close`,n)})]})}export{Ce as a,Y as c,X as i,W as l,Le as n,Te as o,Ae as r,Ee as s,He as t};
@@ -1 +0,0 @@
1
- import{o as e}from"./rolldown-runtime-CMxvf4Kt.js";import{_ as t,t as n}from"./vendor-react-ClIa1CJA.js";import{A as r}from"./framework-CQlIjbCT.js";import{$n as i,As as a,Bt as o,Ds as s,Ft as c,Jt as l,La as u,Lt as d,Or as f,Qn as p,Rt as m,Vt as h,Yi as g,Zn as _,an as v,dt as y,er as b,fs as x,ft as S,ht as C,it as w,ln as T,lt as E,mt as D,pt as O,rr as k,tr as A,ut as j,vs as M,yr as N,zi as P,zt as F}from"./ui-components-CgiD1ql5.js";import"./src-Dnw5qGGv.js";var I=e(t(),1),L=n();function R({status:e}){let t={success:{icon:s,cls:`text-emerald-600 border-emerald-300`},completed:{icon:s,cls:`text-emerald-600 border-emerald-300`},failed:{icon:M,cls:`text-red-600 border-red-300`},error:{icon:M,cls:`text-red-600 border-red-300`},running:{icon:u,cls:`text-blue-600 border-blue-300 animate-pulse`},pending:{icon:x,cls:`text-amber-600 border-amber-300`},skipped:{icon:a,cls:`text-muted-foreground`}}[e]??{icon:a,cls:`text-muted-foreground`},n=t.icon;return(0,L.jsxs)(k,{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)([]),[a,o]=(0,I.useState)(!0),[s,l]=(0,I.useState)(null),[u,d]=(0,I.useState)(``),[m,h]=(0,I.useState)(0),g=(0,I.useCallback)(async()=>{if(!e?.meta?.getItems){l(`meta.getItems is not available on this client`),o(!1);return}o(!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{o(!1)}},[e,u]);(0,I.useEffect)(()=>{g()},[g]);let v=(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)(_,{children:[(0,L.jsx)(b,{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)(A,{className:`text-base`,children:`Flow`}),(0,L.jsx)(i,{children:`Select a flow definition to test`})]}),(0,L.jsxs)(N,{variant:`outline`,size:`sm`,onClick:g,disabled:a,children:[(0,L.jsx)(P,{className:`h-3.5 w-3.5 mr-2 ${a?`animate-spin`:``}`}),`Refresh`]})]})}),(0,L.jsxs)(p,{children:[a&&(0,L.jsx)(c,{className:`h-9 w-72`}),s&&(0,L.jsx)(`p`,{className:`text-sm text-red-500 font-mono break-all`,children:s}),!a&&!s&&t.length===0&&(0,L.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`No flow definitions found.`}),!a&&!s&&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))})]})]}),v&&(0,L.jsxs)(`div`,{className:`grid gap-4 lg:grid-cols-2`,children:[(0,L.jsx)(U,{client:e,flow:v.spec,onExecuted:()=>h(e=>e+1)}),(0,L.jsx)(W,{client:e,flowName:v.name,refreshKey:m})]})]})}function U({client:e,flow:t,onExecuted:n}){let r=(0,I.useMemo)(()=>(t?.variables??[]).filter(e=>e?.isInput),[t]),[a,o]=(0,I.useState)({}),[c,l]=(0,I.useState)(!1),[d,f]=(0,I.useState)(null),[m,h]=(0,I.useState)(null);(0,I.useEffect)(()=>{o({}),f(null),h(null)},[t?.name]);let y=(e,t)=>o(n=>({...n,[e]:t}));return(0,L.jsxs)(_,{children:[(0,L.jsxs)(b,{className:`pb-3`,children:[(0,L.jsx)(A,{className:`text-base`,children:`Test Run`}),(0,L.jsx)(i,{children:`Provide input values and invoke the flow`})]}),(0,L.jsxs)(p,{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)(T,{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)(k,{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)(C,{id:`var-${e.name}`,checked:a[e.name]===`true`,onCheckedChange:t=>y(e.name,t?`true`:`false`)}),(0,L.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:a[e.name]===`true`?`true`:`false`})]}):e.type===`object`||e.type===`list`||e.type===`array`?(0,L.jsx)(w,{id:`var-${e.name}`,placeholder:`JSON ${e.type}`,value:a[e.name]??``,onChange:t=>y(e.name,t.target.value),className:`font-mono text-xs min-h-[80px]`}):(0,L.jsx)(v,{id:`var-${e.name}`,type:e.type===`number`?`number`:`text`,value:a[e.name]??``,onChange:t=>y(e.name,t.target.value)})]},e.name)),(0,L.jsx)(`div`,{className:`pt-1`,children:(0,L.jsxs)(N,{onClick:async()=>{if(!e?.automation?.execute){h(`automation.execute is not available on this client`);return}l(!0),h(null),f(null);try{let i={};for(let e of r){let t=a[e.name];t!==void 0&&(i[e.name]=B(t,e.type))}f(await e.automation.execute(t.name,{params:i})),n?.()}catch(e){h(e?.message??String(e))}finally{l(!1)}},disabled:c,size:`sm`,children:[c?(0,L.jsx)(u,{className:`h-3.5 w-3.5 mr-2 animate-spin`}):(0,L.jsx)(g,{className:`h-3.5 w-3.5 mr-2`}),c?`Running…`:`Run Flow`]})}),(d||m)&&(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:[m||d?.success===!1?(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(M,{className:`h-4 w-4 text-red-500`}),` Failed`]}):(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(s,{className:`h-4 w-4 text-emerald-500`}),` Result`]}),typeof d?.durationMs==`number`&&(0,L.jsxs)(k,{variant:`secondary`,className:`text-[10px] font-mono`,children:[d.durationMs,` ms`]})]}),m&&(0,L.jsx)(`p`,{className:`text-sm text-red-500 font-mono break-all`,children:m}),d&&(0,L.jsx)(V,{data:d})]})]})]})}function W({client:e,flowName:t,refreshKey:n}){let[r,a]=(0,I.useState)([]),[s,f]=(0,I.useState)(!0),[g,v]=(0,I.useState)(null),[x,C]=(0,I.useState)(null),[w,T]=(0,I.useState)(null),[M,B]=(0,I.useState)(!1),[H,U]=(0,I.useState)(null),W=(0,I.useCallback)(async()=>{if(!e?.automation?.listRuns){v(`automation.listRuns is not available on this client`),f(!1);return}f(!0),v(null);try{let n=await e.automation.listRuns(t,{limit:20});a(Array.isArray(n)?n:n?.items??n?.runs??[])}catch(e){v(e?.message??String(e))}finally{f(!1)}},[e,t]);(0,I.useEffect)(()=>{W()},[W,n]);let G=async n=>{C(n),T(null),U(null),B(!0);try{let r=await e.automation.getRun(t,n);T(r?.run??r)}catch(e){U(e?.message??String(e))}finally{B(!1)}};return(0,L.jsxs)(L.Fragment,{children:[(0,L.jsxs)(_,{children:[(0,L.jsx)(b,{className:`pb-3`,children:(0,L.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,L.jsxs)(`div`,{children:[(0,L.jsx)(A,{className:`text-base`,children:`Recent Runs`}),(0,L.jsx)(i,{className:`font-mono text-xs`,children:t})]}),(0,L.jsxs)(N,{variant:`outline`,size:`sm`,onClick:W,disabled:s,children:[s?(0,L.jsx)(u,{className:`h-3.5 w-3.5 mr-2 animate-spin`}):(0,L.jsx)(P,{className:`h-3.5 w-3.5 mr-2`}),`Refresh`]})]})}),(0,L.jsxs)(p,{children:[s&&(0,L.jsxs)(`div`,{className:`space-y-2`,children:[(0,L.jsx)(c,{className:`h-8 w-full`}),(0,L.jsx)(c,{className:`h-8 w-full`}),(0,L.jsx)(c,{className:`h-8 w-full`})]}),!s&&g&&(0,L.jsx)(`p`,{className:`text-sm text-red-500 font-mono break-all`,children:g}),!s&&!g&&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.`}),!s&&!g&&r.length>0&&(0,L.jsxs)(E,{children:[(0,L.jsx)(O,{children:(0,L.jsxs)(D,{children:[(0,L.jsx)(S,{children:`Run`}),(0,L.jsx)(S,{children:`Status`}),(0,L.jsx)(S,{children:`Started`}),(0,L.jsx)(S,{className:`text-right`,children:`Duration`})]})}),(0,L.jsx)(j,{children:r.map(e=>(0,L.jsxs)(D,{className:`cursor-pointer`,onClick:()=>G(e.id),children:[(0,L.jsxs)(y,{className:`font-mono text-xs`,children:[e.id.slice(0,12),`…`]}),(0,L.jsx)(y,{children:(0,L.jsx)(R,{status:e.status})}),(0,L.jsx)(y,{className:`text-xs text-muted-foreground`,children:z(e.startedAt)}),(0,L.jsx)(y,{className:`text-right font-mono text-xs`,children:typeof e.durationMs==`number`?`${e.durationMs} ms`:`—`})]},e.id))})]})]})]}),(0,L.jsx)(d,{open:!!x,onOpenChange:e=>{e||(C(null),T(null))},children:(0,L.jsxs)(m,{side:`right`,className:`w-full sm:max-w-2xl p-0 flex flex-col`,children:[(0,L.jsxs)(o,{className:`p-4 border-b`,children:[(0,L.jsxs)(h,{className:`font-mono text-sm break-all`,children:[`Run `,x]}),(0,L.jsx)(F,{children:w&&(0,L.jsxs)(`span`,{className:`inline-flex items-center gap-2`,children:[(0,L.jsx)(R,{status:w.status}),typeof w.durationMs==`number`&&(0,L.jsxs)(k,{variant:`secondary`,className:`text-[10px] font-mono`,children:[w.durationMs,` ms`]}),(0,L.jsx)(`span`,{className:`text-xs`,children:z(w.startedAt)})]})})]}),(0,L.jsxs)(l,{className:`flex-1 p-4`,children:[M&&(0,L.jsxs)(`div`,{className:`space-y-2`,children:[(0,L.jsx)(c,{className:`h-16 w-full`}),(0,L.jsx)(c,{className:`h-16 w-full`}),(0,L.jsx)(c,{className:`h-16 w-full`})]}),H&&(0,L.jsx)(`p`,{className:`text-sm text-red-500 font-mono break-all`,children:H}),!M&&w&&(0,L.jsx)(`div`,{className:`space-y-3`,children:Array.isArray(w.steps)&&w.steps.length>0?w.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)(k,{variant:`outline`,className:`text-[10px] font-mono`,children:e.nodeType}),(0,L.jsx)(R,{status:e.status}),typeof e.durationMs==`number`&&(0,L.jsxs)(k,{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:w})]})})]})]})})]})}export{H as FlowRunsPage};
@@ -1 +0,0 @@
1
- import{o as e}from"./rolldown-runtime-CMxvf4Kt.js";import{_ as t,t as n}from"./vendor-react-ClIa1CJA.js";import{i as r,pt as i}from"./framework-CQlIjbCT.js";import{Is as a,Rs as o,is as s,zs as c}from"./ui-components-CgiD1ql5.js";function l(e,t,n){if(!(!e||t==null)){if(n){let r=e.find(e=>e.name===t&&e._packageId===n);if(r)return r}return e.find(e=>e.name===t)}}var u=e(t(),1),d=n();function f({sections:e,open:t}){if(!t)return null;let{t:n}=r(),[i,l]=(0,u.useState)([`0`]),[f,p]=(0,u.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=>{l(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e])};return(0,d.jsxs)(`div`,{className:`w-80 border-l bg-background p-0 overflow-hidden flex flex-col shrink-0 z-20 transition-all`,children:[(0,d.jsxs)(`div`,{className:`px-4 py-3 border-b bg-muted/5 flex items-center justify-between`,children:[(0,d.jsx)(`span`,{className:`text-xs font-semibold uppercase tracking-wider text-muted-foreground`,children:n(`layout.metadata.panelTitle`)}),(0,d.jsx)(`span`,{className:`text-[10px] text-muted-foreground/60`,children:n(`layout.metadata.jsonBadge`)})]}),(0,d.jsx)(`div`,{className:`flex-1 overflow-auto`,children:e.map((e,t)=>{let r=String(t),l=i.includes(r),u=f===t;return(0,d.jsxs)(`div`,{className:`border-b last:border-b-0`,children:[(0,d.jsxs)(`div`,{className:`flex items-center justify-between px-4 py-3 hover:bg-muted/5 transition-colors`,children:[(0,d.jsxs)(`button`,{onClick:()=>h(r),className:`flex-1 flex items-center justify-between text-left`,children:[(0,d.jsx)(`h4`,{className:`text-xs font-semibold text-foreground`,children:e.title}),l?(0,d.jsx)(o,{className:`h-3 w-3 text-muted-foreground ml-2`}):(0,d.jsx)(a,{className:`h-3 w-3 text-muted-foreground ml-2`})]}),(0,d.jsx)(`button`,{onClick:()=>m(e.data,t),className:`p-1 hover:bg-muted rounded transition-colors ml-2`,title:n(`layout.metadata.copyJson`),children:u?(0,d.jsx)(c,{className:`h-3 w-3 text-green-600`}):(0,d.jsx)(s,{className:`h-3 w-3 text-muted-foreground`})})]}),l&&(0,d.jsx)(`div`,{className:`px-4 pb-4`,children:(0,d.jsx)(`div`,{className:`relative rounded-md border border-border/50 bg-muted/5 overflow-hidden`,children:(0,d.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 p(){let[e,t]=(0,u.useState)((0,u.useMemo)(()=>{try{return typeof window<`u`?i(window.location.search).enabled:!1}catch{return!1}},[]));return{showDebug:e,toggleDebug:()=>t(e=>!e)}}export{p as n,l as r,f as t};
@@ -1 +0,0 @@
1
- import{o as e,r as t}from"./rolldown-runtime-CMxvf4Kt.js";import{_ as n,f as r,l as i,p as a,t as o,u as s}from"./vendor-react-ClIa1CJA.js";import{f as c,m as l,n as u}from"./infrastructure-BtLHjSlJ.js";import{A as d,F as f,V as p,h as m,i as h,j as g}from"./framework-CQlIjbCT.js";import{G as _,H as v,V as y,_r as b,ea as x,fr as S,gr as C,hr as w,jc as T,jo as E,mr as D,pr as O,ur as k,yr as A}from"./ui-components-CgiD1ql5.js";import{r as j}from"./vendor-ui-utils-C92Fl7BT.js";import"./MetadataProvider-fKK6GbWD.js";import{r as M}from"./ExpressionProvider-CT3sX7xF.js";import{c as N,i as P,l as ee,r as te,u as ne}from"./RecordDetailView-CfCIFeA9.js";import{n as F,r as I,t as L}from"./MetadataInspector-XbWYccBm.js";import{t as R}from"./InterfaceListPage-GcApvEz0.js";var z=e(n(),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)(A,{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 re({state:e,apiBase:t,onOpenChange:n}){let r=e.spec;return(0,B.jsx)(k,{open:e.open,onOpenChange:e=>{e||n(!1)},children:(0,B.jsxs)(O,{"data-testid":`environment-entitlement-dialog`,children:[(0,B.jsxs)(C,{children:[(0,B.jsx)(b,{children:r?.title}),(0,B.jsx)(D,{children:r?.message})]}),(0,B.jsxs)(w,{children:[(0,B.jsx)(S,{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 ie(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 X(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 Z(e,t){if(typeof e==`string`)return X(e,t);if(Array.isArray(e))return e.map(e=>Z(e,t));if(e&&typeof e==`object`){let n={};for(let[r,i]of Object.entries(e))n[r]=Z(i,t);return n}return e}function Q(e,t){return t?Z(e,t):e}var ae={id:`current-user`,name:`Demo User`,isPlatformAdmin:!1};function $(e){let{dataSource:t,objects:n,objectName:r,onRefresh:i}=e,a=s(),{user:o,activeOrganization:d}=c(),{systemPermissions:f}=u(),{fieldLabel:p,fieldOptionLabel:h,actionParamText:g,actionParamOptionLabel:_,actionDescription:v}=T(),y=(0,z.useMemo)(()=>r?n?.find(e=>e.name===r):void 0,[n,r]),b=r||y?.name,x=(0,z.useCallback)(()=>{i?.()},[i]),S=m({dataSource:t,onUndo:()=>{x(),j.success(`Change undone`)}}),[C,w]=(0,z.useState)({open:!1,message:``}),[E,D]=(0,z.useState)({open:!1,params:[]}),[O,k]=(0,z.useState)({open:!1}),[A,M]=(0,z.useState)(null),[F,I]=(0,z.useState)({open:!1}),L=(0,z.useRef)(new Set),R=(0,z.useCallback)((e,t)=>new Promise(n=>{k({open:!0,spec:e,data:t,resolve:n})}),[]),V=(0,z.useCallback)((e,t)=>new Promise(n=>{w({open:!0,message:e,options:t,resolve:n})}),[]),H=(0,z.useCallback)((e,t)=>new Promise(i=>{let a=t?.params&&!Array.isArray(t.params)?t.params._rowRecord:void 0,o=te(e,{objectName:r||y?.name||``,objects:n||[],fieldLabel:p,fieldOptionLabel:h,row:a}),s=r||y?.name;D({open:!0,params:o.map(e=>({...e,label:g(s,t?.name,e.name,`label`,e.label)??e.label,placeholder:g(s,t?.name,e.name,`placeholder`,e.placeholder)??e.placeholder,helpText:g(s,t?.name,e.name,`helpText`,e.helpText)??e.helpText,options:Array.isArray(e.options)?e.options.map(n=>({...n,label:_(s,t?.name,e.name,n.value,n.label)})):e.options})),title:t?.label||t?.title,description:v(s,t?.name,t?.description),resolve:i})}),[r,y,n,p,h,g,_]),U=o?{id:o.id,name:o.name,avatar:o.image,isPlatformAdmin:o?.isPlatformAdmin??!1,systemPermissions:f??[]}:{...ae,systemPermissions:f??[]},W=(0,z.useCallback)((e,t)=>{if(t?.type===`error`){j.error(e);return}if(t?.undo){j.success(e,{duration:t.duration,action:{label:t.undo.label||`Undo`,onClick:()=>{S.undo()}}});return}j.success(e,{duration:t?.duration})},[S]),G=(0,z.useCallback)((e,t)=>{t?.external||t?.newTab?window.open(e,`_blank`,`noopener,noreferrer`):a(e)},[a]),K=(0,z.useMemo)(()=>l(),[]),q=(0,z.useCallback)(e=>{I({open:!0,spec:e})},[]),J=(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=Q(t,o),c=a;r&&/\{[a-z_][a-z0-9_]*\}/i.test(c)&&(c=c.replace(/\{([a-z_][a-z0-9_]*)\}/gi,(e,t)=>{let n=r[t];return n==null?``:encodeURIComponent(String(n))}));let l=c.startsWith(`http`)?c:`${c}`,u=e.bodyShape&&typeof e.bodyShape==`object`&&e.bodyShape.wrap?e.bodyShape.wrap:void 0,f=u?{[u]:s}:{...s};if(r&&e.recordIdParam){let t=r[e.recordIdField||`id`];t!=null&&(f[e.recordIdParam]=t)}/\/api\/v1\/auth\//.test(c)&&!f.organizationId&&d?.id&&(f.organizationId=d.id),e.bodyExtra&&typeof e.bodyExtra==`object`&&Object.assign(f,Q(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 K(l,m);if(!h.ok){let e=null;try{e=await h.json()}catch{}let t=ie(e);return t?(q(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,reload:e.refreshAfter!==!1}}let o=e.objectName||b,s=i._rowRecord,c={...i};delete c._rowRecord;let l=c.recordId??s?.[e.recordIdField||`id`];delete c.recordId,e.bodyExtra&&typeof e.bodyExtra==`object`&&Object.assign(c,e.bodyExtra),o&&typeof t?.execute==`function`?await t.execute(o,r,c):o&&l&&Object.keys(c).length>0&&typeof t?.update==`function`&&await t.update(o,l,c);let u;if(e.undoable&&o&&l&&s&&Object.keys(c).length>0&&typeof t?.update==`function`){let t={};for(let e of Object.keys(c))t[e]=s[e]??null;u={id:`undo-${o}-${l}-${Date.now()}`,type:`update`,objectName:o,recordId:String(l),timestamp:Date.now(),description:e.label||`Undo ${o}`,undoData:t,redoData:{...c}}}let f=e.refreshAfter!==!1;return f&&x(),{success:!0,reload:f,undo:u}}catch(e){return{success:!1,error:e.message}}},[t,b,K,d,x,q]),Y=(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 e=Array.isArray(t?.selectedRecords)?t.selectedRecords:[];if(e.length===1)a=e[0]?.id;else if(e.length>1)return{success:!1,error:`This flow runs on a single record — select exactly one row.`}}a!=null&&r.recordId==null&&(r.recordId=a);let o=await K(`/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 M({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}}},[K,b,x]),X=(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 e=Array.isArray(t?.selectedRecords)?t.selectedRecords:[];if(e.length===1)o=e[0]?.[a];else if(e.length>1)return{success:!1,error:`This action runs on a single record — select exactly one row.`}}let s=`${n}:${o??``}`;if(L.current.has(s))return{success:!1,error:`Action already in progress`};L.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||j(`浏览器拦截了弹窗 / 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 K(`/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 j.error(e),{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||j(`浏览器拦截了弹窗 / 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{}let t=e.message;return j.error(t),{success:!1,error:t}}finally{L.current.delete(s)}},[K,b,x]);return{confirmHandler:V,toastHandler:W,navigateHandler:G,paramCollectionHandler:H,resultDialogHandler:R,apiHandler:J,flowHandler:Y,serverActionHandler:X,authFetch:K,openEntitlementDialog:q,actionProviderProps:(0,z.useMemo)(()=>({context:{...r?{objectName:r}:{},user:U,apiBase:``,activeOrganization:d?{id:d.id,slug:d.slug,name:d.name}:null},onConfirm:V,onToast:W,onNavigate:G,onParamCollection:H,onResultDialog:R,handlers:{api:J,flow:Y,script:X,modal:X}}),[r,U,d,V,W,G,H,R,J,Y,X]),dialogs:(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(ne,{state:C,onOpenChange:e=>{e||w({open:!1,message:``})}}),(0,B.jsx)(ee,{state:E,onOpenChange:e=>{e||D({open:!1,params:[]})}}),(0,B.jsx)(N,{state:O,onAcknowledge:()=>{O.resolve?.(),k({open:!1})}}),(0,B.jsx)(P,{state:A,authFetch:K,baseUrl:``,dataSource:t,objects:n,onClose:()=>M(null),onComplete:()=>{M(null),x()}}),(0,B.jsx)(re,{state:F,apiBase:``,onOpenChange:e=>{e||I({open:!1})}})]})}}function oe({children:e,...t}){let n=$(t);return(0,B.jsxs)(f,{...n.actionProviderProps,children:[e,n.dialogs]})}var se=t({PageView:()=>ce});function ce(){let{t:e}=h(),{pageName:t}=r(),[n]=a(),{showDebug:o}=F(),l=s(),u=i(),{user:f}=c(),m=f?.role===`admin`,{pages:b,objects:S}=g(),{app:C}=M(),w=d(),[T,D]=(0,z.useState)(0),O=I(b,t,C?._packageId);if(!O)return(0,B.jsx)(`div`,{className:`h-full flex items-center justify-center p-8`,children:(0,B.jsxs)(y,{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)(E,{className:`h-6 w-6 text-muted-foreground`})}),(0,B.jsx)(_,{children:e(`empty.pageNotFound`)}),(0,B.jsx)(v,{children:e(`empty.pageNotFoundDescription`,{name:t})})]})});let k=Object.fromEntries(n.entries()),A=u.pathname.match(/\/apps\/([^/]+)/)?.[1],j=m&&!!A&&!!t;return(0,B.jsx)(oe,{dataSource:w,objects:S,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:[j&&(0,B.jsx)(`button`,{type:`button`,onClick:()=>{j&&l(`/apps/${A}/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)(x,{className:`h-3.5 w-3.5`})}),O.interfaceConfig?.source?(0,B.jsx)(R,{page:O,reserveEditAffordance:j},T):(0,B.jsx)(p,{schema:{...O,type:O.type||`page`,context:{...O.context,params:k,refreshKey:T}}},T)]}),(0,B.jsx)(L,{open:o,sections:[{title:`Page Configuration`,data:O}]})]})})}export{q as a,K as i,$ as n,G as r,se as t};
@@ -1 +0,0 @@
1
- import{o as e}from"./rolldown-runtime-CMxvf4Kt.js";import{_ as t,t as n}from"./vendor-react-ClIa1CJA.js";import{f as r,o as i}from"./infrastructure-BtLHjSlJ.js";import{$n as a,As as o,Ds as s,Er as c,Fr as l,Ia as u,La as d,Lr as f,Qn as p,S as m,Zn as h,an as g,ar as _,cr as v,er as y,ir as b,ln as x,or as S,rr as C,sr as w,tr as T,yr as E}from"./ui-components-CgiD1ql5.js";var D=e(t(),1),O=n();function k(){let{user:e,updateUser:t,isLoading:n,changePassword:u,setInitialPassword:k,hasLocalPassword:j}=r(),{upload:M}=m(),[N,P]=(0,D.useState)(e?.name??``),[F,I]=(0,D.useState)(!1),[L,R]=(0,D.useState)(null),z=(0,D.useRef)(null),[B,V]=(0,D.useState)(!1),[H,U]=(0,D.useState)(null);return(0,D.useEffect)(()=>{P(e?.name??``)},[e?.name]),e?(0,O.jsxs)(`div`,{className:`flex flex-col gap-4 sm:gap-6 p-4 sm:p-6 max-w-2xl`,children:[(0,O.jsxs)(`div`,{className:`min-w-0`,children:[(0,O.jsx)(`h1`,{className:`text-xl sm:text-2xl font-bold tracking-tight`,children:`Profile`}),(0,O.jsx)(`p`,{className:`text-sm text-muted-foreground mt-1`,children:`Manage your account settings`})]}),(0,O.jsx)(h,{children:(0,O.jsxs)(p,{className:`pt-6`,children:[(0,O.jsxs)(`div`,{className:`flex items-center gap-4`,children:[(0,O.jsxs)(b,{className:`h-16 w-16`,children:[(0,O.jsx)(S,{src:e.image??void 0,alt:e.name??`User`}),(0,O.jsx)(_,{className:`text-lg bg-primary text-primary-foreground`,children:i(e)})]}),(0,O.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,O.jsx)(`p`,{className:`text-lg font-semibold truncate`,children:e.name??`User`}),(0,O.jsx)(`p`,{className:`text-sm text-muted-foreground truncate`,children:e.email}),(0,O.jsx)(C,{variant:`secondary`,className:`mt-1`,children:e.role??`member`})]}),(0,O.jsxs)(`div`,{className:`flex flex-col gap-2 shrink-0`,children:[(0,O.jsx)(`input`,{ref:z,type:`file`,accept:`image/*`,className:`hidden`,onChange:async e=>{let n=e.target.files?.[0];if(z.current&&(z.current.value=``),n){V(!0),U(null);try{await t({image:(await M(n)).url})}catch(e){U(e instanceof Error?e.message:String(e))}finally{V(!1)}}},"data-testid":`profile-avatar-file`}),(0,O.jsxs)(E,{type:`button`,variant:`outline`,size:`sm`,disabled:B,onClick:()=>z.current?.click(),"data-testid":`profile-avatar-upload-btn`,children:[B?(0,O.jsx)(d,{className:`mr-2 h-4 w-4 animate-spin`}):(0,O.jsx)(f,{className:`mr-2 h-4 w-4`}),e.image?`Replace`:`Upload`]}),e.image&&(0,O.jsxs)(E,{type:`button`,variant:`ghost`,size:`sm`,disabled:B,onClick:async()=>{V(!0),U(null);try{await t({image:null})}catch(e){U(e instanceof Error?e.message:String(e))}finally{V(!1)}},"data-testid":`profile-avatar-remove-btn`,children:[(0,O.jsx)(c,{className:`mr-2 h-4 w-4`}),`Remove`]})]})]}),H&&(0,O.jsxs)(w,{variant:`destructive`,className:`mt-4`,children:[(0,O.jsx)(o,{className:`h-4 w-4`}),(0,O.jsx)(v,{children:H})]})]})}),(0,O.jsxs)(h,{children:[(0,O.jsxs)(y,{children:[(0,O.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,O.jsx)(l,{className:`h-4 w-4 text-muted-foreground`}),(0,O.jsx)(T,{className:`text-base sm:text-lg`,children:`Personal Information`})]}),(0,O.jsx)(a,{children:`Update your name and view account details`})]}),(0,O.jsx)(p,{children:(0,O.jsxs)(`form`,{onSubmit:async e=>{e.preventDefault(),R(null),I(!1);try{await t({name:N}),I(!0)}catch(e){R(e instanceof Error?e.message:String(e))}},className:`space-y-4`,children:[L&&(0,O.jsxs)(w,{variant:`destructive`,children:[(0,O.jsx)(o,{className:`h-4 w-4`}),(0,O.jsx)(v,{children:L})]}),F&&(0,O.jsxs)(w,{children:[(0,O.jsx)(s,{className:`h-4 w-4 text-green-600`}),(0,O.jsx)(v,{className:`text-green-800 dark:text-green-400`,children:`Profile updated successfully.`})]}),(0,O.jsxs)(`div`,{className:`space-y-2`,children:[(0,O.jsx)(x,{htmlFor:`profile-name`,children:`Name`}),(0,O.jsx)(g,{id:`profile-name`,type:`text`,value:N,onChange:e=>P(e.target.value),required:!0,"aria-required":`true`,disabled:n})]}),(0,O.jsxs)(`div`,{className:`space-y-2`,children:[(0,O.jsx)(x,{htmlFor:`profile-email`,children:`Email`}),(0,O.jsx)(g,{id:`profile-email`,type:`email`,value:e.email,disabled:!0,className:`bg-muted text-muted-foreground`}),(0,O.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Email cannot be changed.`})]}),(0,O.jsxs)(`div`,{className:`space-y-2`,children:[(0,O.jsx)(x,{children:`Role`}),(0,O.jsx)(g,{type:`text`,value:e.role??`member`,disabled:!0,className:`bg-muted text-muted-foreground`})]}),(0,O.jsx)(E,{type:`submit`,disabled:n,className:`w-full sm:w-auto`,children:n?`Saving…`:`Save Changes`})]})})]}),(0,O.jsx)(A,{changePassword:u,setInitialPassword:k,hasLocalPassword:j})]}):null}function A({changePassword:e,setInitialPassword:t,hasLocalPassword:n,highlight:r,onPasswordSet:i}){let[c,l]=(0,D.useState)(null),[d,f]=(0,D.useState)(``),[m,_]=(0,D.useState)(``),[b,S]=(0,D.useState)(``),[C,k]=(0,D.useState)(!1),[A,j]=(0,D.useState)(null),[M,N]=(0,D.useState)(null);(0,D.useEffect)(()=>{let e=!1;return n().then(t=>{e||l(t)}).catch(()=>{e||l(!1)}),()=>{e=!0}},[n]);let P=()=>{f(``),_(``),S(``)},F=async n=>{if(n.preventDefault(),j(null),N(null),m.length<8){j(`Password must be at least 8 characters`);return}if(m!==b){j(`Passwords do not match`);return}k(!0);try{if(c){if(!d){j(`Enter your current password`),k(!1);return}await e(d,m),N(`Password changed.`)}else await t(m),N(`Local password set. You can now sign in with email and password on this environment.`),l(!0),i?.();P()}catch(e){j(e instanceof Error?e.message:String(e))}finally{k(!1)}},I=c===null;return(0,O.jsxs)(h,{className:r?`ring-2 ring-amber-300 dark:ring-amber-700`:void 0,children:[(0,O.jsxs)(y,{children:[(0,O.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,O.jsx)(u,{className:`h-4 w-4 text-muted-foreground`}),(0,O.jsx)(T,{className:`text-base sm:text-lg`,children:c?`Change Password`:`Set Local Password`})]}),(0,O.jsx)(a,{children:c?`Update the password you use to sign in to this environment.`:`You signed in via single sign-on. Set a local password to also sign in with email and password on this environment.`})]}),(0,O.jsx)(p,{children:(0,O.jsxs)(`form`,{onSubmit:F,className:`space-y-4 max-w-md`,children:[c&&(0,O.jsxs)(`div`,{className:`space-y-2`,children:[(0,O.jsx)(x,{htmlFor:`current-password`,children:`Current password`}),(0,O.jsx)(g,{id:`current-password`,type:`password`,autoComplete:`current-password`,value:d,onChange:e=>f(e.target.value),disabled:C||I,required:!0})]}),(0,O.jsxs)(`div`,{className:`space-y-2`,children:[(0,O.jsx)(x,{htmlFor:`new-password`,children:c?`New password`:`Password`}),(0,O.jsx)(g,{id:`new-password`,type:`password`,autoComplete:`new-password`,value:m,onChange:e=>_(e.target.value),disabled:C||I,minLength:8,required:!0})]}),(0,O.jsxs)(`div`,{className:`space-y-2`,children:[(0,O.jsx)(x,{htmlFor:`confirm-password`,children:`Confirm password`}),(0,O.jsx)(g,{id:`confirm-password`,type:`password`,autoComplete:`new-password`,value:b,onChange:e=>S(e.target.value),disabled:C||I,minLength:8,required:!0})]}),A&&(0,O.jsxs)(w,{variant:`destructive`,children:[(0,O.jsx)(o,{className:`h-4 w-4`}),(0,O.jsx)(v,{children:A})]}),M&&(0,O.jsxs)(w,{children:[(0,O.jsx)(s,{className:`h-4 w-4`}),(0,O.jsx)(v,{children:M})]}),(0,O.jsx)(E,{type:`submit`,disabled:C||I,className:`w-full sm:w-auto`,children:C?`Saving…`:c?`Change password`:`Set password`})]})})]})}export{k as ProfilePage};
@@ -1 +0,0 @@
1
- import{o as e}from"./rolldown-runtime-CMxvf4Kt.js";import{_ as t,t as n}from"./vendor-react-ClIa1CJA.js";import{A as r}from"./framework-CQlIjbCT.js";import{$n as i,Ci as a,Gn as o,Hi as ee,Hn as s,Kn as c,Qn as te,Un as l,Vn as u,Wa as ne,Wn as d,Wo as re,Zn as ie,an as f,cs as ae,dt as p,er as oe,ft as m,is as se,ln as h,lt as ce,mt as g,pt as le,qi as ue,rr as de,tr as fe,ut as pe,yr as _,zi as me}from"./ui-components-CgiD1ql5.js";import{r as v}from"./vendor-ui-utils-C92Fl7BT.js";import"./src-Dnw5qGGv.js";var y=e(t(),1),b=n();function he(e){return e?e.replace(/^\/+/,``).match(/^forms\/([^/?#]+)/i)?.[1]??null:null}function x(e){return e.trim().toLowerCase().replace(/[^a-z0-9-_]+/g,`-`).replace(/^-+|-+$/g,``)}function S(){let e=r()?.getClient?.(),[t,n]=(0,y.useState)([]),[S,ge]=(0,y.useState)([]),[C,w]=(0,y.useState)(!0),[T,E]=(0,y.useState)(null),[_e,D]=(0,y.useState)(!1),[O,k]=(0,y.useState)(``),[A,j]=(0,y.useState)(``),[M,N]=(0,y.useState)(!1),[ve,P]=(0,y.useState)(!1),[F,I]=(0,y.useState)(null),[L,R]=(0,y.useState)(``),[z,B]=(0,y.useState)(`thank-you`),[V,H]=(0,y.useState)(``),[U,W]=(0,y.useState)(``),[G,K]=(0,y.useState)(``),[q,J]=(0,y.useState)(!1),Y=async()=>{if(!e?.meta?.getItems){E(`meta.getItems is not available on this client`),w(!1);return}w(!0),E(null);try{let t=await e.meta.getItems(`view`),r=Array.isArray(t)?t:Array.isArray(t?.items)?t.items:Array.isArray(t?.value)?t.value:[],i=[],a=[];for(let e of r){let t=e?.spec??e;if(!(t?.sections||t?.groups||t?.form||t?.type===`simple`||t?.type===`tabbed`||t?.type===`wizard`||t?.viewType===`form`))continue;let n=t?.sharing,r=n?.publicLink,o=he(r);n?.allowAnonymous&&o&&r?i.push({name:t?.name??e?.name,label:t?.label,object:t?.object,slug:o,publicLink:r,updatedAt:e?.updatedAt??e?.updated_at,spec:t}):a.push({name:t?.name??e?.name,label:t?.label,object:t?.object,spec:t})}n(i),ge(a)}catch(e){E(e?.message??String(e))}finally{w(!1)}};(0,y.useEffect)(()=>{Y()},[]);let ye=typeof window<`u`?window.location.origin:``,X=e=>`${ye}/console/f/${e}`,Z=e=>`<iframe src="${X(e)}" width="100%" height="640" frameborder="0" style="border:0;"></iframe>`,be=e=>`<iframe\n src={\`${X(e)}\`}\n title="Public form"\n style={{ width: '100%', height: 640, border: 0 }}\n/>`,Q=async(e,t)=>{try{await navigator.clipboard.writeText(t),v.success(`Copied ${e}`)}catch{v.error(`Clipboard unavailable`)}},xe=async()=>{if(!O||!A)return;let t=S.find(e=>e.name===O);if(!t)return;let n=x(A);if(!n){v.error(`Invalid slug`);return}let r={...t.spec,sharing:{...t.spec.sharing??{},enabled:!0,allowAnonymous:!0,publicLink:`/forms/${n}`}};N(!0);try{await e.meta.saveItem(`view`,t.name,r),v.success(`Published ${t.name}`),D(!1),k(``),j(``),await Y()}catch(e){v.error(`Publish failed: ${e?.message??e}`)}finally{N(!1)}},Se=e=>{I(e),R(e.slug);let t=e.spec?.submitBehavior;B(t?.kind??`thank-you`),H(t?.title??``),W(t?.message??``),K(t?.url??``),P(!0)},Ce=async()=>{if(!F)return;let t=x(L);if(!t){v.error(`Invalid slug`);return}let n;switch(z){case`thank-you`:n={kind:`thank-you`},V&&(n.title=V),U&&(n.message=U);break;case`redirect`:if(!G){v.error(`Redirect URL is required`);return}n={kind:`redirect`,url:G};break;case`continue`:case`next-record`:n={kind:z};break}let r={...F.spec,sharing:{...F.spec.sharing??{},enabled:!0,allowAnonymous:!0,publicLink:`/forms/${t}`},submitBehavior:n};J(!0);try{await e.meta.saveItem(`view`,F.name,r),v.success(`Saved ${F.name}`),P(!1),I(null),await Y()}catch(e){v.error(`Save failed: ${e?.message??e}`)}finally{J(!1)}},$=t.length>0;return(0,b.jsxs)(`div`,{className:`flex flex-1 flex-col gap-4 p-4 md:p-6 overflow-auto`,children:[(0,b.jsxs)(ie,{children:[(0,b.jsxs)(oe,{className:`flex flex-row items-start justify-between gap-4 space-y-0`,children:[(0,b.jsxs)(`div`,{children:[(0,b.jsxs)(fe,{className:`flex items-center gap-2`,children:[(0,b.jsx)(ee,{className:`h-4 w-4`}),`Public Forms`]}),(0,b.jsx)(i,{children:`Forms anyone can fill out — no login required. Publish a form to get a shareable link; submissions land directly in the bound object.`})]}),(0,b.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,b.jsxs)(_,{variant:`default`,size:`sm`,onClick:()=>D(!0),disabled:S.length===0,title:S.length===0?`No non-public FormViews available`:`Publish a FormView`,children:[(0,b.jsx)(ue,{className:`h-3.5 w-3.5`}),(0,b.jsx)(`span`,{className:`ml-1.5`,children:`Publish form…`})]}),(0,b.jsxs)(_,{variant:`outline`,size:`sm`,onClick:Y,disabled:C,children:[(0,b.jsx)(me,{className:`h-3.5 w-3.5 ${C?`animate-spin`:``}`}),(0,b.jsx)(`span`,{className:`ml-1.5`,children:`Refresh`})]})]})]}),(0,b.jsxs)(te,{children:[T&&(0,b.jsx)(`div`,{className:`mb-3 rounded-md border border-destructive/40 bg-destructive/10 p-3 text-sm text-destructive`,children:T}),!C&&!$&&(0,b.jsxs)(`div`,{className:`rounded-md border border-dashed p-6 text-center text-sm text-muted-foreground`,children:[(0,b.jsx)(`p`,{className:`font-medium text-foreground`,children:`No public forms yet`}),(0,b.jsxs)(`p`,{className:`mt-1`,children:[`Click `,(0,b.jsx)(`strong`,{children:`Publish form…`}),` above to share an existing form, or build a new one in Views & Apps and mark it public.`]})]}),$&&(0,b.jsxs)(ce,{children:[(0,b.jsx)(le,{children:(0,b.jsxs)(g,{children:[(0,b.jsx)(m,{children:`Name`}),(0,b.jsx)(m,{children:`Object`}),(0,b.jsx)(m,{children:`Slug`}),(0,b.jsx)(m,{children:`Public URL`}),(0,b.jsx)(m,{className:`text-right`,children:`Actions`})]})}),(0,b.jsx)(pe,{children:t.map(e=>{let t=X(e.slug);return(0,b.jsxs)(g,{children:[(0,b.jsx)(p,{children:(0,b.jsxs)(`div`,{className:`flex flex-col`,children:[(0,b.jsx)(`span`,{className:`font-medium`,children:e.label??e.name}),(0,b.jsx)(`code`,{className:`text-xs text-muted-foreground`,children:e.name})]})}),(0,b.jsx)(p,{children:e.object?(0,b.jsx)(de,{variant:`secondary`,children:e.object}):(0,b.jsx)(`span`,{className:`text-muted-foreground`,children:`—`})}),(0,b.jsx)(p,{children:(0,b.jsx)(`code`,{className:`text-xs`,children:e.slug})}),(0,b.jsx)(p,{children:(0,b.jsxs)(`a`,{href:t,target:`_blank`,rel:`noreferrer`,className:`inline-flex items-center gap-1 text-xs text-primary underline-offset-2 hover:underline`,children:[t,(0,b.jsx)(re,{className:`h-3 w-3`})]})}),(0,b.jsx)(p,{className:`text-right`,children:(0,b.jsxs)(`div`,{className:`inline-flex gap-1`,children:[(0,b.jsx)(_,{variant:`ghost`,size:`sm`,title:`Copy URL`,onClick:()=>Q(`URL`,t),children:(0,b.jsx)(ne,{className:`h-3.5 w-3.5`})}),(0,b.jsx)(_,{variant:`ghost`,size:`sm`,title:`Copy <iframe> embed`,onClick:()=>Q(`iframe snippet`,Z(e.slug)),children:(0,b.jsx)(ae,{className:`h-3.5 w-3.5`})}),(0,b.jsx)(_,{variant:`ghost`,size:`sm`,title:`Copy React snippet`,onClick:()=>Q(`React snippet`,be(e.slug)),children:(0,b.jsx)(se,{className:`h-3.5 w-3.5`})}),(0,b.jsx)(_,{variant:`ghost`,size:`sm`,title:`Edit sharing & post-submit behavior`,onClick:()=>Se(e),children:(0,b.jsx)(a,{className:`h-3.5 w-3.5`})})]})})]},e.name)})})]})]})]}),(0,b.jsx)(u,{open:_e,onOpenChange:D,children:(0,b.jsxs)(s,{className:`sm:max-w-md`,children:[(0,b.jsxs)(o,{children:[(0,b.jsx)(c,{children:`Publish a FormView`}),(0,b.jsxs)(l,{children:[`Pick an existing FormView and turn it into a public form by enabling `,(0,b.jsx)(`code`,{className:`text-xs`,children:`sharing.allowAnonymous`}),` `,`and setting `,(0,b.jsx)(`code`,{className:`text-xs`,children:`publicLink`}),`.`]})]}),(0,b.jsxs)(`div`,{className:`space-y-3`,children:[(0,b.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,b.jsx)(h,{htmlFor:`publish-view`,children:`FormView`}),(0,b.jsxs)(`select`,{id:`publish-view`,className:`flex h-9 w-full rounded-md border border-input bg-transparent px-3 py-1 text-sm shadow-sm`,value:O,onChange:e=>k(e.target.value),children:[(0,b.jsx)(`option`,{value:``,children:`— Select a FormView —`}),S.map(e=>(0,b.jsxs)(`option`,{value:e.name,children:[e.label??e.name,` (`,e.name,`) `,e.object?`· ${e.object}`:``]},e.name))]})]}),(0,b.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,b.jsx)(h,{htmlFor:`publish-slug`,children:`URL slug`}),(0,b.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,b.jsx)(`span`,{className:`text-xs text-muted-foreground whitespace-nowrap`,children:`/console/f/`}),(0,b.jsx)(f,{id:`publish-slug`,placeholder:`contact-us`,value:A,onChange:e=>j(e.target.value)})]}),(0,b.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Lowercase letters, digits, dashes and underscores only.`})]})]}),(0,b.jsxs)(d,{children:[(0,b.jsx)(_,{variant:`ghost`,onClick:()=>D(!1),disabled:M,children:`Cancel`}),(0,b.jsx)(_,{onClick:xe,disabled:M||!O||!A,children:M?`Publishing…`:`Publish`})]})]})}),(0,b.jsx)(u,{open:ve,onOpenChange:P,children:(0,b.jsxs)(s,{className:`sm:max-w-lg`,children:[(0,b.jsxs)(o,{children:[(0,b.jsx)(c,{children:F?`Edit ${F.label??F.name}`:`Edit form`}),(0,b.jsx)(l,{children:`Configure the public URL and what happens after submit.`})]}),(0,b.jsxs)(`div`,{className:`space-y-3`,children:[(0,b.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,b.jsx)(h,{htmlFor:`edit-slug`,children:`URL slug`}),(0,b.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,b.jsx)(`span`,{className:`text-xs text-muted-foreground whitespace-nowrap`,children:`/console/f/`}),(0,b.jsx)(f,{id:`edit-slug`,value:L,onChange:e=>R(e.target.value)})]})]}),(0,b.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,b.jsx)(h,{htmlFor:`edit-behavior`,children:`After submit`}),(0,b.jsxs)(`select`,{id:`edit-behavior`,className:`flex h-9 w-full rounded-md border border-input bg-transparent px-3 py-1 text-sm shadow-sm`,value:z,onChange:e=>B(e.target.value),children:[(0,b.jsx)(`option`,{value:`thank-you`,children:`Show a thank-you panel`}),(0,b.jsx)(`option`,{value:`redirect`,children:`Redirect to a URL`}),(0,b.jsx)(`option`,{value:`continue`,children:`Reset for another response`}),(0,b.jsx)(`option`,{value:`next-record`,children:`Advance to next record (internal queues)`})]})]}),z===`thank-you`&&(0,b.jsxs)(b.Fragment,{children:[(0,b.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,b.jsx)(h,{htmlFor:`edit-tytitle`,children:`Title`}),(0,b.jsx)(f,{id:`edit-tytitle`,placeholder:`Thanks!`,value:V,onChange:e=>H(e.target.value)})]}),(0,b.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,b.jsx)(h,{htmlFor:`edit-tymsg`,children:`Message`}),(0,b.jsx)(f,{id:`edit-tymsg`,placeholder:`Your submission has been received.`,value:U,onChange:e=>W(e.target.value)})]})]}),z===`redirect`&&(0,b.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,b.jsx)(h,{htmlFor:`edit-url`,children:`Redirect URL`}),(0,b.jsx)(f,{id:`edit-url`,type:`url`,placeholder:`https://example.com/thanks`,value:G,onChange:e=>K(e.target.value)})]})]}),(0,b.jsxs)(d,{children:[(0,b.jsx)(_,{variant:`ghost`,onClick:()=>P(!1),disabled:q,children:`Cancel`}),(0,b.jsx)(_,{onClick:Ce,disabled:q||!L,children:q?`Saving…`:`Save`})]})]})})]})}export{S as PublicFormsPage};