@objectstack/console 9.2.0 → 9.3.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 (62) hide show
  1. package/dist/assets/{AiPendingActionsPage-B-n-gqzM.js → AiPendingActionsPage-Y9r83gqj.js} +1 -1
  2. package/dist/assets/{ApiConsolePage-uPTuvhXX.js → ApiConsolePage-Dwbms0Zh.js} +1 -1
  3. package/dist/assets/{AppManagementPage-CNpBOuFm.js → AppManagementPage-0JEALVYK.js} +1 -1
  4. package/dist/assets/ApprovalsInboxPage-B-drSsxQ.js +1 -0
  5. package/dist/assets/{AuditLogPage-_9ECzJM8.js → AuditLogPage-CXhNSVOU.js} +1 -1
  6. package/dist/assets/{ComponentNavView-CDdExuCL.js → ComponentNavView-BI4O_zkC.js} +1 -1
  7. package/dist/assets/ConsoleFloatingChatbot-CiODZIcp.js +1 -0
  8. package/dist/assets/{DeveloperHubPage-mdknfgGp.js → DeveloperHubPage-D-UigRUA.js} +1 -1
  9. package/dist/assets/FlowRunsPage-_UeeNdBc.js +1 -0
  10. package/dist/assets/{IntegrationsPage-7SUsLOvq.js → IntegrationsPage-DsWyxKR6.js} +2 -2
  11. package/dist/assets/{ProfilePage-D4yjFTMG.js → ProfilePage-T27zVrMO.js} +1 -1
  12. package/dist/assets/PublicFormsPage-Pd453sW6.js +1 -0
  13. package/dist/assets/{SettingsHub-7kLSZWnI.js → SettingsHub-B4oSx4ed.js} +1 -1
  14. package/dist/assets/{SettingsView-DqnY47y1.js → SettingsView-CkQEI5DW.js} +1 -1
  15. package/dist/assets/{SystemHubPage-DeiksJan.js → SystemHubPage-Di6eqozE.js} +1 -1
  16. package/dist/assets/assistantBus-B-xBT6j1.js +1 -0
  17. package/dist/assets/{data-adapter-D1EJuDUI.js → data-adapter-3AJO7A2o.js} +1 -1
  18. package/dist/assets/framework-crD8qZlm.js +34 -0
  19. package/dist/assets/{highlighted-body-OFNGDK62-Du4wVUV7.js → highlighted-body-OFNGDK62-B3OlR_Nx.js} +1 -1
  20. package/dist/assets/index-Cf7NsvAk.css +2 -0
  21. package/dist/assets/index-CiI7zDDo.js +32 -0
  22. package/dist/assets/{mergeServerFields-CNavewPY.js → mergeServerFields-DUkbynPg.js} +3 -3
  23. package/dist/assets/mermaid-GHXKKRXX-CBocchJ2.js +1 -0
  24. package/dist/assets/{plugin-calendar-u9Aa9OAR.js → plugin-calendar-ed7RoEFF.js} +1 -1
  25. package/dist/assets/{plugin-charts-DSBNwB9E.js → plugin-charts-QabQJ_NJ.js} +2 -2
  26. package/dist/assets/plugin-chatbot-Cy3tiXkg.js +120 -0
  27. package/dist/assets/plugin-dashboard-PA0xf59v.js +5 -0
  28. package/dist/assets/plugin-form-BABEMaum.js +1 -0
  29. package/dist/assets/plugin-gantt-BNjfLkTR.js +1 -0
  30. package/dist/assets/plugin-grid-BxyuFeJP.js +6 -0
  31. package/dist/assets/plugin-kanban-D4yCkUn_.js +1 -0
  32. package/dist/assets/plugin-map-C8Jxhxs1.js +1 -0
  33. package/dist/assets/{plugin-markdown-6MvgfANj.js → plugin-markdown-CR5TpghH.js} +1 -1
  34. package/dist/assets/plugin-report-rz8HUIsi.js +59 -0
  35. package/dist/assets/{plugin-timeline-DrUpbBdn.js → plugin-timeline-DQHQwtdw.js} +1 -1
  36. package/dist/assets/plugin-view-BykLknWa.js +1 -0
  37. package/dist/assets/plugins-views-CBO5qxO-.js +4 -0
  38. package/dist/assets/{src-s-NNbVef.js → src-Tw2eleSi.js} +1 -1
  39. package/dist/assets/{types-Decs33Tv.js → types-BkFEpiv3.js} +1 -1
  40. package/dist/assets/{ui-components-BbPoD3rS.js → ui-components-BrY5joKQ.js} +8 -8
  41. package/dist/assets/{ui-layout-CWeej0a8.js → ui-layout-KICrO2Oe.js} +1 -1
  42. package/dist/index.html +4 -4
  43. package/package.json +1 -1
  44. package/dist/assets/ApprovalsInboxPage-BFNNZBXy.js +0 -1
  45. package/dist/assets/ConsoleFloatingChatbot-DThmuzxB.js +0 -1
  46. package/dist/assets/FlowRunsPage-yleJQxJv.js +0 -1
  47. package/dist/assets/PublicFormsPage-DWj4wR8t.js +0 -1
  48. package/dist/assets/assistantBus-Bppk-Y9t.js +0 -1
  49. package/dist/assets/framework-CHiz03zG.js +0 -34
  50. package/dist/assets/index-B_NAVTba.js +0 -32
  51. package/dist/assets/index-DwG7_t-6.css +0 -2
  52. package/dist/assets/mermaid-GHXKKRXX-D0s_nNwO.js +0 -1
  53. package/dist/assets/plugin-chatbot-BzJE6C-F.js +0 -120
  54. package/dist/assets/plugin-dashboard-C5nSNZfG.js +0 -5
  55. package/dist/assets/plugin-form-DrL6xDfP.js +0 -1
  56. package/dist/assets/plugin-gantt-aDdnMW0u.js +0 -1
  57. package/dist/assets/plugin-grid-CSHgWd0O.js +0 -6
  58. package/dist/assets/plugin-kanban-D45w069C.js +0 -1
  59. package/dist/assets/plugin-map-ue6Mjnhb.js +0 -1
  60. package/dist/assets/plugin-report-QmyiWpfC.js +0 -59
  61. package/dist/assets/plugin-view-DS-dSLs-.js +0 -1
  62. package/dist/assets/plugins-views-DH1gGZh6.js +0 -4
@@ -1 +1 @@
1
- import{o as e}from"./rolldown-runtime-CMxvf4Kt.js";import{_ as t,l as n,r,t as i}from"./vendor-react-DR370ovB.js";import{Ct as a,Hi as o,Hn as s,Lt as c,Qa as l,Qr as u,St as d,Un as f,Vi as p,Vn as m,Y as h,Zn as g,Zs as _,_o as v,_t as y,bt as b,gt as x,ht as S,us as C,wt as w,xt as T,yt as E}from"./ui-components-BbPoD3rS.js";import{_ as D,c as O,d as k,g as A,h as j,n as M,o as N,p as P,s as F,t as I,u as L}from"./vendor-dndkit-DMFEUxSy.js";var R=e(t(),1),z=i();function B(e){let t=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(e);if(!t)return null;let n=parseInt(t[1],16)/255,r=parseInt(t[2],16)/255,i=parseInt(t[3],16)/255,a=Math.max(n,r,i),o=Math.min(n,r,i),s=0,c=0,l=(a+o)/2;if(a!==o){let e=a-o;switch(c=l>.5?e/(2-a-o):e/(a+o),a){case n:s=((r-i)/e+(r<i?6:0))/6;break;case r:s=((i-n)/e+2)/6;break;case i:s=((n-r)/e+4)/6;break}}return{h:s*360,s:c*100,l:l*100}}function V(e){let t=B(e);return t?`${Math.round(t.h)} ${Math.round(t.s)}% ${Math.round(t.l)}%`:null}function H(e){let t=B(e);if(!t)return null;let n=Math.max(t.l,65),r=t.s>80?Math.max(t.s-10,70):t.s;return`${Math.round(t.h)} ${Math.round(r)}% ${Math.round(n)}%`}function U(e){let t=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(e);if(!t)return`0 0% 100%`;let n=e=>{let t=e/255;return t<=.03928?t/12.92:((t+.055)/1.055)**2.4},r=n(parseInt(t[1],16)),i=n(parseInt(t[2],16)),a=n(parseInt(t[3],16));return .2126*r+.7152*i+.0722*a>.6?`222 47% 11%`:`0 0% 100%`}function W(e,t){(0,R.useEffect)(()=>{let n=document.documentElement,r=()=>n.classList.contains(`dark`),i=()=>{if(e?.primaryColor){let t=V(e.primaryColor),i=H(e.primaryColor),a=r()&&i||t;a&&(n.style.setProperty(`--brand-primary`,e.primaryColor),n.style.setProperty(`--brand-primary-hsl`,t||a),n.style.setProperty(`--primary`,a),n.style.setProperty(`--primary-foreground`,r()?`222 47% 11%`:U(e.primaryColor)),n.style.setProperty(`--ring`,a),n.style.setProperty(`--sidebar-primary`,a),n.style.setProperty(`--sidebar-ring`,a))}else n.style.removeProperty(`--brand-primary`),n.style.removeProperty(`--brand-primary-hsl`),n.style.removeProperty(`--primary`),n.style.removeProperty(`--primary-foreground`),n.style.removeProperty(`--ring`),n.style.removeProperty(`--sidebar-primary`),n.style.removeProperty(`--sidebar-ring`);if(e?.accentColor){let t=V(e.accentColor),i=H(e.accentColor),a=r()&&i||t;a&&(n.style.setProperty(`--brand-accent`,e.accentColor),n.style.setProperty(`--brand-accent-hsl`,t||a),n.style.setProperty(`--accent`,a),n.style.setProperty(`--accent-foreground`,r()?`222 47% 11%`:U(e.accentColor)))}else n.style.removeProperty(`--brand-accent`),n.style.removeProperty(`--brand-accent-hsl`),n.style.removeProperty(`--accent`),n.style.removeProperty(`--accent-foreground`)};i();let a=new MutationObserver(e=>{for(let t of e)if(t.type===`attributes`&&t.attributeName===`class`){i();break}});if(a.observe(n,{attributes:!0,attributeFilter:[`class`]}),e?.favicon){let t=document.querySelector(`#favicon`)||document.querySelector(`link[rel="icon"]`);t&&(t.href=e.favicon)}return t&&(document.title=t),()=>{a.disconnect(),n.style.removeProperty(`--brand-primary`),n.style.removeProperty(`--brand-primary-hsl`),n.style.removeProperty(`--brand-accent`),n.style.removeProperty(`--brand-accent-hsl`),n.style.removeProperty(`--primary`),n.style.removeProperty(`--primary-foreground`),n.style.removeProperty(`--ring`),n.style.removeProperty(`--sidebar-primary`),n.style.removeProperty(`--sidebar-ring`),n.style.removeProperty(`--accent`),n.style.removeProperty(`--accent-foreground`)}},[e?.primaryColor,e?.accentColor,e?.favicon,t])}function G({sidebar:e,navbar:t,children:n,className:r,defaultOpen:i=!0,branding:a}){return W(a,a?.title),(0,z.jsxs)(w,{defaultOpen:i,className:`!flex-col h-svh overflow-hidden`,children:[(0,z.jsx)(`header`,{className:`sticky top-0 z-30 flex h-14 w-full shrink-0 items-center gap-2 border-b bg-background px-2 sm:px-4`,children:t}),(0,z.jsxs)(`div`,{className:`flex flex-1 min-h-0 w-full`,children:[e,(0,z.jsx)(E,{className:`min-w-0`,children:(0,z.jsx)(`main`,{className:_(`flex-1 min-w-0 overflow-auto p-3 sm:p-4 md:p-6 pb-20 sm:pb-4 md:pb-6`,r),children:n})})]})]})}function K(e){return e?h(e):v}function q(e,t){if(typeof e==`string`)return e;if(t){let n=t(e.key,{defaultValue:e.defaultValue,...e.params});if(n&&n!==e.key)return n}return e.defaultValue||e.key}function J(e,t,n,r,i,a,o){let s=q(e.label,n);if(typeof e.label!=`string`)return s;if(e.type===`object`&&e.objectName){if(e.viewName)return a?a(e.objectName,e.viewName,s):s;if(t)return t(e.objectName,s)}return r&&e.type===`dashboard`&&e.dashboardName?r(e.dashboardName,s):i&&e.type===`group`&&e.id?i(e.id,s):o&&e.id?o(e.id,s):s}var ee=e=>!(e===!1||e===`false`),Y=()=>!0,X=()=>!0,te=/\{(current_user_id|current_org_id|[a-z][a-z0-9_]*)\}/g;function Z(e,t){if(!e.includes(`{`))return e;let n=!1,r=e.replace(te,(e,r)=>{let i;return i=r===`current_user_id`?t?.currentUserId:r===`current_org_id`?t?.currentOrgId:t?.contextValues?.[r],i||(n=!0,``)});return n?null:r}function Q(e,t,n){switch(e.type){case`object`:{let r=`${t}/${e.objectName??``}`,i=e.recordId;if(i){let t=Z(i,n);if(t){let n=`${r}/record/${encodeURIComponent(t)}`;return{href:e.recordMode===`edit`?`${n}/edit`:n,external:!1}}}return{href:e.viewName?`${r}/view/${e.viewName}`:r,external:!1}}case`dashboard`:return{href:e.dashboardName?`${t}/dashboard/${e.dashboardName}`:`#`,external:!1};case`page`:{if(!e.pageName)return{href:`#`,external:!1};let r=e.params,i=`${t}/page/${e.pageName}`;if(r&&typeof r==`object`){let e=new URLSearchParams;for(let[t,i]of Object.entries(r))if(i!=null)if(typeof i==`string`){let r=Z(i,n);r!==null&&e.set(t,r)}else e.set(t,JSON.stringify(i));let t=e.toString();t&&(i+=`?${t}`)}return{href:i,external:!1}}case`report`:return{href:e.reportName?`${t}/report/${e.reportName}`:`#`,external:!1};case`url`:return{href:e.url??`#`,external:e.target===`_blank`};case`component`:{let r=e.componentRef;if(!r)return{href:`#`,external:!1};let i=r.split(`:`).filter(Boolean);if(i.length===0)return{href:`#`,external:!1};let a=e.params;if(i[0]===`metadata`){let e=i[1],r=a&&typeof a.type==`string`?a.type:void 0,o=a&&typeof a.name==`string`?a.name:void 0,s=``;if(a&&typeof a==`object`){let e=new URLSearchParams;for(let[t,r]of Object.entries(a))if(!(t===`type`||t===`name`)&&r!=null)if(typeof r==`string`){let i=Z(r,n);i&&e.set(t,i)}else e.set(t,JSON.stringify(r));let t=e.toString();t&&(s=`?${t}`)}return e===`directory`||!e?{href:`${t}/metadata${s}`,external:!1}:e===`resource`&&r?{href:`${t}/metadata${o?`/${encodeURIComponent(r)}/${encodeURIComponent(o)}`:`/${encodeURIComponent(r)}`}${s}`,external:!1}:{href:`${t}/metadata${s}`,external:!1}}let o=`${t}/component/${i.join(`/`)}`;if(a&&typeof a==`object`){let e=new URLSearchParams;for(let[t,n]of Object.entries(a))n!=null&&e.set(t,typeof n==`string`?n:JSON.stringify(n));let t=e.toString();t&&(o+=`?${t}`)}return{href:o,external:!1}}default:return{href:`#`,external:!1}}}function ne(e,t,n){if(t===`#`)return!1;if(n===t)return!0;let r=e.componentRef;return r&&r.split(`:`)[1]===`directory`?!1:e.type===`object`&&e.objectName?!(e.viewName||!n.startsWith(`${t}/`)||n.slice(t.length+1).startsWith(`view/`)):n.startsWith(`${t}/`)}function re(e,t){if(!t.trim())return e;let n=t.toLowerCase().trim();return e.reduce((e,r)=>{if(r.type===`separator`)return e;if(r.type===`group`&&r.children?.length){let n=re(r.children,t);return n.length>0&&e.push({...r,children:n}),e}return q(r.label).toLowerCase().includes(n)&&e.push(r),e},[])}var ie=5;function ae({item:e,basePath:t,evalVis:n,checkPerm:r,checkCap:i,onAction:a,enablePinning:o,onPinToggle:s,enableReorder:c,resolveObjectLabel:l,resolveDashboardLabel:u,resolveGroupLabel:d,resolveViewLabel:f,resolveItemLabel:p,t:m,templateContext:h}){let{attributes:g,listeners:_,setNodeRef:v,transform:y,transition:b,isDragging:x}=N({id:e.id,disabled:!c});return(0,z.jsx)(`div`,{ref:v,style:{transform:D.Transform.toString(y),transition:b,opacity:x?.5:void 0,zIndex:x?10:void 0},...g,children:(0,z.jsx)($,{item:e,basePath:t,evalVis:n,checkPerm:r,checkCap:i,onAction:a,enablePinning:o,onPinToggle:s,dragListeners:c?_:void 0,resolveObjectLabel:l,resolveDashboardLabel:u,resolveGroupLabel:d,resolveViewLabel:f,resolveItemLabel:p,t:m,templateContext:h})})}function $({item:e,basePath:t,evalVis:i,checkPerm:u,checkCap:h,onAction:_,enablePinning:v,onPinToggle:w,dragListeners:E,resolveObjectLabel:D,resolveDashboardLabel:O,resolveGroupLabel:k,resolveViewLabel:A,resolveItemLabel:j,t:M,templateContext:N}){let P=n(),F=(()=>{let t=e.expanded;if(typeof t==`boolean`)return t;if(typeof e.defaultOpen==`boolean`)return e.defaultOpen})(),I=e.type===`group`?e.children?.length??0:0,[L,B]=(0,R.useState)(R.useMemo(()=>{if(e.type!==`group`)return!1;let n=e=>{if(!e)return!1;for(let r of e){if(r.type===`group`){if(n(r.children))return!0;continue}let{href:e}=Q(r,t,N);if(ne(r,e,P.pathname))return!0}return!1};return n(e.children)},[e,t,P.pathname])?!0:F??!(I>=8));if(!i(e.visible)||e.requiredPermissions?.length&&!u(e.requiredPermissions))return null;let V=e.requiresObject,H=e.requiresService;if(V&&!h(`object`,V)||H&&!h(`service`,H))return null;if(e.type===`separator`)return(0,z.jsx)(c,{className:`my-2`});if(e.type===`group`){let n=(e.children??[]).slice().sort((e,t)=>(e.order??0)-(t.order??0));return(0,z.jsx)(m,{open:L,onOpenChange:B,children:(0,z.jsxs)(S,{children:[(0,z.jsx)(y,{asChild:!0,children:(0,z.jsxs)(f,{className:`flex w-full items-center justify-between`,children:[J(e,D,M,O,k,A,j),(0,z.jsx)(C,{className:`ml-auto h-4 w-4 transition-transform ${L?`rotate-90`:``}`})]})}),(0,z.jsx)(s,{children:(0,z.jsx)(x,{children:(0,z.jsx)(b,{children:n.map(e=>(0,z.jsx)($,{item:e,basePath:t,evalVis:i,checkPerm:u,checkCap:h,onAction:_,enablePinning:v,onPinToggle:w,resolveObjectLabel:D,resolveDashboardLabel:O,resolveGroupLabel:k,resolveViewLabel:A,resolveItemLabel:j,t:M,templateContext:N},e.id))})})})]})})}if(e.type===`action`){let n=K(e.icon),r=q(e.label,M);return(0,z.jsxs)(a,{children:[E&&(0,z.jsx)(`span`,{className:`absolute left-0.5 top-1/2 -translate-y-1/2 cursor-grab text-muted-foreground`,"aria-label":M?M(`console.nav.dragToReorder`,{defaultValue:`Drag to reorder`}):`Drag to reorder`,...E,children:(0,z.jsx)(l,{className:`h-3.5 w-3.5`})}),(0,z.jsxs)(d,{tooltip:r,onClick:()=>_?.(e),children:[(0,z.jsx)(n,{className:`h-4 w-4`}),(0,z.jsx)(`span`,{children:r}),e.badge!=null&&(0,z.jsx)(g,{variant:e.badgeVariant??`default`,className:`ml-auto text-[10px] px-1.5 py-0`,children:e.badge})]}),v&&w&&(0,z.jsx)(T,{showOnHover:!0,onClick:()=>w(e.id,!e.pinned,e,t),"aria-label":M?M(e.pinned?`console.nav.unpinItem`:`console.nav.pinItem`,{defaultValue:e.pinned?`Unpin ${r}`:`Pin ${r}`,name:r}):e.pinned?`Unpin ${r}`:`Pin ${r}`,children:e.pinned?(0,z.jsx)(p,{className:`h-3.5 w-3.5`}):(0,z.jsx)(o,{className:`h-3.5 w-3.5`})})]})}let U=K(e.icon),{href:W,external:G}=Q(e,t,N),ee=ne(e,W,P.pathname),Y=J(e,D,M,O,k,A,j),X=(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(U,{className:`h-4 w-4`}),(0,z.jsx)(`span`,{children:Y}),e.badge!=null&&(0,z.jsx)(g,{variant:e.badgeVariant??`default`,className:`ml-auto text-[10px] px-1.5 py-0`,children:e.badge})]});return(0,z.jsxs)(a,{children:[E&&(0,z.jsx)(`span`,{className:`absolute left-0.5 top-1/2 -translate-y-1/2 cursor-grab text-muted-foreground`,"aria-label":M?M(`console.nav.dragToReorder`,{defaultValue:`Drag to reorder`}):`Drag to reorder`,...E,children:(0,z.jsx)(l,{className:`h-3.5 w-3.5`})}),(0,z.jsx)(d,{asChild:!0,isActive:ee,tooltip:Y,children:G?(0,z.jsx)(`a`,{href:W,target:`_blank`,rel:`noopener noreferrer`,children:X}):(0,z.jsx)(r,{to:W,children:X})}),v&&w&&(0,z.jsx)(T,{showOnHover:!0,onClick:()=>w(e.id,!e.pinned,e,t),"aria-label":M?M(e.pinned?`console.nav.unpinItem`:`console.nav.pinItem`,{defaultValue:e.pinned?`Unpin ${Y}`:`Pin ${Y}`,name:Y}):e.pinned?`Unpin ${Y}`:`Pin ${Y}`,children:e.pinned?(0,z.jsx)(p,{className:`h-3.5 w-3.5`}):(0,z.jsx)(o,{className:`h-3.5 w-3.5`})})]})}function oe({items:e,basePath:t=``,evaluateVisibility:n=ee,checkPermission:r=Y,checkCapability:i=X,onAction:a,searchQuery:o,enablePinning:s,onPinToggle:c,enableReorder:l,onReorder:d,resolveObjectLabel:f,resolveDashboardLabel:p,resolveGroupLabel:m,resolveViewLabel:h,resolveItemLabel:g,t:_,templateContext:v}){let C=(0,R.useMemo)(()=>o?re(e,o):e,[e,o]),w=(0,R.useMemo)(()=>se(C),[C]),T=C.slice().sort((e,t)=>(e.order??0)-(t.order??0)),E=A(j(k,{activationConstraint:{distance:ie}}),j(L)),D=e=>{let{active:t,over:n}=e;if(!n||t.id===n.id||!d)return;let r=T.findIndex(e=>e.id===t.id),i=T.findIndex(e=>e.id===n.id);r===-1||i===-1||d(M(T,r,i).map((e,t)=>({...e,order:t})))},N={basePath:t,evalVis:n,checkPerm:r,checkCap:i,onAction:a,enablePinning:s,onPinToggle:c,resolveObjectLabel:f,resolveDashboardLabel:p,resolveGroupLabel:m,resolveViewLabel:h,resolveItemLabel:g,t:_,templateContext:v},B=T.some(e=>e.type===`group`),V=w.length>0&&s?(0,z.jsxs)(S,{children:[(0,z.jsxs)(y,{className:`flex items-center gap-1.5`,children:[(0,z.jsx)(u,{className:`h-3.5 w-3.5`}),_?_(`console.nav.favorites`,{defaultValue:`Favorites`}):`Favorites`]}),(0,z.jsx)(x,{children:(0,z.jsx)(b,{children:w.map(e=>(0,z.jsx)($,{item:e,...N},`fav-${e.id}`))})})]}):null;if(!B){let e=T.filter(e=>e.type!==`group`).map(e=>e.id);return(0,z.jsxs)(z.Fragment,{children:[V,(0,z.jsx)(S,{children:(0,z.jsx)(x,{children:l?(0,z.jsx)(O,{sensors:E,collisionDetection:P,onDragEnd:D,children:(0,z.jsx)(I,{items:e,strategy:F,children:(0,z.jsx)(b,{children:T.map(e=>(0,z.jsx)(ae,{item:e,enableReorder:l,...N},e.id))})})}):(0,z.jsx)(b,{children:T.map(e=>(0,z.jsx)($,{item:e,...N},e.id))})})})]})}let H=[],U=[],W=e=>{if(U.length===0)return;let t=U;U=[],H.push((0,z.jsx)(S,{children:(0,z.jsx)(x,{children:(0,z.jsx)(b,{children:t.map(e=>(0,z.jsx)($,{item:e,...N},e.id))})})},e))};return T.forEach((e,t)=>{e.type===`group`?(W(`leaf-${t}`),H.push((0,z.jsx)($,{item:e,...N},e.id))):U.push(e)}),W(`leaf-end`),(0,z.jsxs)(z.Fragment,{children:[V,H]})}function se(e){let t=[];for(let n of e)n.pinned&&n.type!==`group`&&n.type!==`separator`&&t.push(n),n.children?.length&&t.push(...se(n.children));return t}export{Q as n,G as r,oe as t};
1
+ import{o as e}from"./rolldown-runtime-CMxvf4Kt.js";import{_ as t,l as n,r,t as i}from"./vendor-react-DR370ovB.js";import{$a as a,$r as o,Ct as s,Hi as c,Hn as l,Lt as u,St as d,Ui as f,Un as p,Vn as m,Y as h,Zn as g,_t as _,bt as v,gt as y,hs as b,ht as x,rc as S,vo as C,wt as w,xt as T,yt as E}from"./ui-components-BrY5joKQ.js";import{_ as D,c as O,d as k,g as A,h as j,n as M,o as N,p as P,s as F,t as I,u as L}from"./vendor-dndkit-DMFEUxSy.js";var R=e(t(),1),z=i();function B(e){let t=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(e);if(!t)return null;let n=parseInt(t[1],16)/255,r=parseInt(t[2],16)/255,i=parseInt(t[3],16)/255,a=Math.max(n,r,i),o=Math.min(n,r,i),s=0,c=0,l=(a+o)/2;if(a!==o){let e=a-o;switch(c=l>.5?e/(2-a-o):e/(a+o),a){case n:s=((r-i)/e+(r<i?6:0))/6;break;case r:s=((i-n)/e+2)/6;break;case i:s=((n-r)/e+4)/6;break}}return{h:s*360,s:c*100,l:l*100}}function V(e){let t=B(e);return t?`${Math.round(t.h)} ${Math.round(t.s)}% ${Math.round(t.l)}%`:null}function H(e){let t=B(e);if(!t)return null;let n=Math.max(t.l,65),r=t.s>80?Math.max(t.s-10,70):t.s;return`${Math.round(t.h)} ${Math.round(r)}% ${Math.round(n)}%`}function U(e){let t=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(e);if(!t)return`0 0% 100%`;let n=e=>{let t=e/255;return t<=.03928?t/12.92:((t+.055)/1.055)**2.4},r=n(parseInt(t[1],16)),i=n(parseInt(t[2],16)),a=n(parseInt(t[3],16));return .2126*r+.7152*i+.0722*a>.6?`222 47% 11%`:`0 0% 100%`}function W(e,t){(0,R.useEffect)(()=>{let n=document.documentElement,r=()=>n.classList.contains(`dark`),i=()=>{if(e?.primaryColor){let t=V(e.primaryColor),i=H(e.primaryColor),a=r()&&i||t;a&&(n.style.setProperty(`--brand-primary`,e.primaryColor),n.style.setProperty(`--brand-primary-hsl`,t||a),n.style.setProperty(`--primary`,a),n.style.setProperty(`--primary-foreground`,r()?`222 47% 11%`:U(e.primaryColor)),n.style.setProperty(`--ring`,a),n.style.setProperty(`--sidebar-primary`,a),n.style.setProperty(`--sidebar-ring`,a))}else n.style.removeProperty(`--brand-primary`),n.style.removeProperty(`--brand-primary-hsl`),n.style.removeProperty(`--primary`),n.style.removeProperty(`--primary-foreground`),n.style.removeProperty(`--ring`),n.style.removeProperty(`--sidebar-primary`),n.style.removeProperty(`--sidebar-ring`);if(e?.accentColor){let t=V(e.accentColor),i=H(e.accentColor),a=r()&&i||t;a&&(n.style.setProperty(`--brand-accent`,e.accentColor),n.style.setProperty(`--brand-accent-hsl`,t||a),n.style.setProperty(`--accent`,a),n.style.setProperty(`--accent-foreground`,r()?`222 47% 11%`:U(e.accentColor)))}else n.style.removeProperty(`--brand-accent`),n.style.removeProperty(`--brand-accent-hsl`),n.style.removeProperty(`--accent`),n.style.removeProperty(`--accent-foreground`)};i();let a=new MutationObserver(e=>{for(let t of e)if(t.type===`attributes`&&t.attributeName===`class`){i();break}});if(a.observe(n,{attributes:!0,attributeFilter:[`class`]}),e?.favicon){let t=document.querySelector(`#favicon`)||document.querySelector(`link[rel="icon"]`);t&&(t.href=e.favicon)}return t&&(document.title=t),()=>{a.disconnect(),n.style.removeProperty(`--brand-primary`),n.style.removeProperty(`--brand-primary-hsl`),n.style.removeProperty(`--brand-accent`),n.style.removeProperty(`--brand-accent-hsl`),n.style.removeProperty(`--primary`),n.style.removeProperty(`--primary-foreground`),n.style.removeProperty(`--ring`),n.style.removeProperty(`--sidebar-primary`),n.style.removeProperty(`--sidebar-ring`),n.style.removeProperty(`--accent`),n.style.removeProperty(`--accent-foreground`)}},[e?.primaryColor,e?.accentColor,e?.favicon,t])}function G({sidebar:e,navbar:t,children:n,className:r,defaultOpen:i=!0,branding:a}){return W(a,a?.title),(0,z.jsxs)(w,{defaultOpen:i,className:`!flex-col h-svh overflow-hidden`,children:[(0,z.jsx)(`header`,{className:`sticky top-0 z-30 flex h-14 w-full shrink-0 items-center gap-2 border-b bg-background px-2 sm:px-4`,children:t}),(0,z.jsxs)(`div`,{className:`flex flex-1 min-h-0 w-full`,children:[e,(0,z.jsx)(E,{className:`min-w-0`,children:(0,z.jsx)(`main`,{className:S(`flex-1 min-w-0 overflow-auto p-3 sm:p-4 md:p-6 pb-20 sm:pb-4 md:pb-6`,r),children:n})})]})]})}function K(e){return e?h(e):C}function q(e,t){if(typeof e==`string`)return e;if(t){let n=t(e.key,{defaultValue:e.defaultValue,...e.params});if(n&&n!==e.key)return n}return e.defaultValue||e.key}function J(e,t,n,r,i,a,o){let s=q(e.label,n);if(typeof e.label!=`string`)return s;if(e.type===`object`&&e.objectName){if(e.viewName)return a?a(e.objectName,e.viewName,s):s;if(t)return t(e.objectName,s)}return r&&e.type===`dashboard`&&e.dashboardName?r(e.dashboardName,s):i&&e.type===`group`&&e.id?i(e.id,s):o&&e.id?o(e.id,s):s}var ee=e=>!(e===!1||e===`false`),Y=()=>!0,X=()=>!0,te=/\{(current_user_id|current_org_id|[a-z][a-z0-9_]*)\}/g;function Z(e,t){if(!e.includes(`{`))return e;let n=!1,r=e.replace(te,(e,r)=>{let i;return i=r===`current_user_id`?t?.currentUserId:r===`current_org_id`?t?.currentOrgId:t?.contextValues?.[r],i||(n=!0,``)});return n?null:r}function Q(e,t,n){switch(e.type){case`object`:{let r=`${t}/${e.objectName??``}`,i=e.recordId;if(i){let t=Z(i,n);if(t){let n=`${r}/record/${encodeURIComponent(t)}`;return{href:e.recordMode===`edit`?`${n}/edit`:n,external:!1}}}return{href:e.viewName?`${r}/view/${e.viewName}`:r,external:!1}}case`dashboard`:return{href:e.dashboardName?`${t}/dashboard/${e.dashboardName}`:`#`,external:!1};case`page`:{if(!e.pageName)return{href:`#`,external:!1};let r=e.params,i=`${t}/page/${e.pageName}`;if(r&&typeof r==`object`){let e=new URLSearchParams;for(let[t,i]of Object.entries(r))if(i!=null)if(typeof i==`string`){let r=Z(i,n);r!==null&&e.set(t,r)}else e.set(t,JSON.stringify(i));let t=e.toString();t&&(i+=`?${t}`)}return{href:i,external:!1}}case`report`:return{href:e.reportName?`${t}/report/${e.reportName}`:`#`,external:!1};case`url`:return{href:e.url??`#`,external:e.target===`_blank`};case`component`:{let r=e.componentRef;if(!r)return{href:`#`,external:!1};let i=r.split(`:`).filter(Boolean);if(i.length===0)return{href:`#`,external:!1};let a=e.params;if(i[0]===`metadata`){let e=i[1],r=a&&typeof a.type==`string`?a.type:void 0,o=a&&typeof a.name==`string`?a.name:void 0,s=``;if(a&&typeof a==`object`){let e=new URLSearchParams;for(let[t,r]of Object.entries(a))if(!(t===`type`||t===`name`)&&r!=null)if(typeof r==`string`){let i=Z(r,n);i&&e.set(t,i)}else e.set(t,JSON.stringify(r));let t=e.toString();t&&(s=`?${t}`)}return e===`directory`||!e?{href:`${t}/metadata${s}`,external:!1}:e===`resource`&&r?{href:`${t}/metadata${o?`/${encodeURIComponent(r)}/${encodeURIComponent(o)}`:`/${encodeURIComponent(r)}`}${s}`,external:!1}:{href:`${t}/metadata${s}`,external:!1}}let o=`${t}/component/${i.join(`/`)}`;if(a&&typeof a==`object`){let e=new URLSearchParams;for(let[t,n]of Object.entries(a))n!=null&&e.set(t,typeof n==`string`?n:JSON.stringify(n));let t=e.toString();t&&(o+=`?${t}`)}return{href:o,external:!1}}default:return{href:`#`,external:!1}}}function ne(e,t,n){if(t===`#`)return!1;if(n===t)return!0;let r=e.componentRef;return r&&r.split(`:`)[1]===`directory`?!1:e.type===`object`&&e.objectName?!(e.viewName||!n.startsWith(`${t}/`)||n.slice(t.length+1).startsWith(`view/`)):n.startsWith(`${t}/`)}function re(e,t){if(!t.trim())return e;let n=t.toLowerCase().trim();return e.reduce((e,r)=>{if(r.type===`separator`)return e;if(r.type===`group`&&r.children?.length){let n=re(r.children,t);return n.length>0&&e.push({...r,children:n}),e}return q(r.label).toLowerCase().includes(n)&&e.push(r),e},[])}var ie=5;function ae({item:e,basePath:t,evalVis:n,checkPerm:r,checkCap:i,onAction:a,enablePinning:o,onPinToggle:s,enableReorder:c,resolveObjectLabel:l,resolveDashboardLabel:u,resolveGroupLabel:d,resolveViewLabel:f,resolveItemLabel:p,t:m,templateContext:h}){let{attributes:g,listeners:_,setNodeRef:v,transform:y,transition:b,isDragging:x}=N({id:e.id,disabled:!c});return(0,z.jsx)(`div`,{ref:v,style:{transform:D.Transform.toString(y),transition:b,opacity:x?.5:void 0,zIndex:x?10:void 0},...g,children:(0,z.jsx)($,{item:e,basePath:t,evalVis:n,checkPerm:r,checkCap:i,onAction:a,enablePinning:o,onPinToggle:s,dragListeners:c?_:void 0,resolveObjectLabel:l,resolveDashboardLabel:u,resolveGroupLabel:d,resolveViewLabel:f,resolveItemLabel:p,t:m,templateContext:h})})}function $({item:e,basePath:t,evalVis:i,checkPerm:o,checkCap:h,onAction:S,enablePinning:C,onPinToggle:w,dragListeners:E,resolveObjectLabel:D,resolveDashboardLabel:O,resolveGroupLabel:k,resolveViewLabel:A,resolveItemLabel:j,t:M,templateContext:N}){let P=n(),F=(()=>{let t=e.expanded;if(typeof t==`boolean`)return t;if(typeof e.defaultOpen==`boolean`)return e.defaultOpen})(),I=e.type===`group`?e.children?.length??0:0,[L,B]=(0,R.useState)(R.useMemo(()=>{if(e.type!==`group`)return!1;let n=e=>{if(!e)return!1;for(let r of e){if(r.type===`group`){if(n(r.children))return!0;continue}let{href:e}=Q(r,t,N);if(ne(r,e,P.pathname))return!0}return!1};return n(e.children)},[e,t,P.pathname])?!0:F??!(I>=8));if(!i(e.visible)||e.requiredPermissions?.length&&!o(e.requiredPermissions))return null;let V=e.requiresObject,H=e.requiresService;if(V&&!h(`object`,V)||H&&!h(`service`,H))return null;if(e.type===`separator`)return(0,z.jsx)(u,{className:`my-2`});if(e.type===`group`){let n=(e.children??[]).slice().sort((e,t)=>(e.order??0)-(t.order??0));return(0,z.jsx)(m,{open:L,onOpenChange:B,children:(0,z.jsxs)(x,{children:[(0,z.jsx)(_,{asChild:!0,children:(0,z.jsxs)(p,{className:`flex w-full items-center justify-between`,children:[J(e,D,M,O,k,A,j),(0,z.jsx)(b,{className:`ml-auto h-4 w-4 transition-transform ${L?`rotate-90`:``}`})]})}),(0,z.jsx)(l,{children:(0,z.jsx)(y,{children:(0,z.jsx)(v,{children:n.map(e=>(0,z.jsx)($,{item:e,basePath:t,evalVis:i,checkPerm:o,checkCap:h,onAction:S,enablePinning:C,onPinToggle:w,resolveObjectLabel:D,resolveDashboardLabel:O,resolveGroupLabel:k,resolveViewLabel:A,resolveItemLabel:j,t:M,templateContext:N},e.id))})})})]})})}if(e.type===`action`){let n=K(e.icon),r=q(e.label,M);return(0,z.jsxs)(s,{children:[E&&(0,z.jsx)(`span`,{className:`absolute left-0.5 top-1/2 -translate-y-1/2 cursor-grab text-muted-foreground`,"aria-label":M?M(`console.nav.dragToReorder`,{defaultValue:`Drag to reorder`}):`Drag to reorder`,...E,children:(0,z.jsx)(a,{className:`h-3.5 w-3.5`})}),(0,z.jsxs)(d,{tooltip:r,onClick:()=>S?.(e),children:[(0,z.jsx)(n,{className:`h-4 w-4`}),(0,z.jsx)(`span`,{children:r}),e.badge!=null&&(0,z.jsx)(g,{variant:e.badgeVariant??`default`,className:`ml-auto text-[10px] px-1.5 py-0`,children:e.badge})]}),C&&w&&(0,z.jsx)(T,{showOnHover:!0,onClick:()=>w(e.id,!e.pinned,e,t),"aria-label":M?M(e.pinned?`console.nav.unpinItem`:`console.nav.pinItem`,{defaultValue:e.pinned?`Unpin ${r}`:`Pin ${r}`,name:r}):e.pinned?`Unpin ${r}`:`Pin ${r}`,children:e.pinned?(0,z.jsx)(c,{className:`h-3.5 w-3.5`}):(0,z.jsx)(f,{className:`h-3.5 w-3.5`})})]})}let U=K(e.icon),{href:W,external:G}=Q(e,t,N),ee=ne(e,W,P.pathname),Y=J(e,D,M,O,k,A,j),X=(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(U,{className:`h-4 w-4`}),(0,z.jsx)(`span`,{children:Y}),e.badge!=null&&(0,z.jsx)(g,{variant:e.badgeVariant??`default`,className:`ml-auto text-[10px] px-1.5 py-0`,children:e.badge})]});return(0,z.jsxs)(s,{children:[E&&(0,z.jsx)(`span`,{className:`absolute left-0.5 top-1/2 -translate-y-1/2 cursor-grab text-muted-foreground`,"aria-label":M?M(`console.nav.dragToReorder`,{defaultValue:`Drag to reorder`}):`Drag to reorder`,...E,children:(0,z.jsx)(a,{className:`h-3.5 w-3.5`})}),(0,z.jsx)(d,{asChild:!0,isActive:ee,tooltip:Y,children:G?(0,z.jsx)(`a`,{href:W,target:`_blank`,rel:`noopener noreferrer`,children:X}):(0,z.jsx)(r,{to:W,children:X})}),C&&w&&(0,z.jsx)(T,{showOnHover:!0,onClick:()=>w(e.id,!e.pinned,e,t),"aria-label":M?M(e.pinned?`console.nav.unpinItem`:`console.nav.pinItem`,{defaultValue:e.pinned?`Unpin ${Y}`:`Pin ${Y}`,name:Y}):e.pinned?`Unpin ${Y}`:`Pin ${Y}`,children:e.pinned?(0,z.jsx)(c,{className:`h-3.5 w-3.5`}):(0,z.jsx)(f,{className:`h-3.5 w-3.5`})})]})}function oe({items:e,basePath:t=``,evaluateVisibility:n=ee,checkPermission:r=Y,checkCapability:i=X,onAction:a,searchQuery:s,enablePinning:c,onPinToggle:l,enableReorder:u,onReorder:d,resolveObjectLabel:f,resolveDashboardLabel:p,resolveGroupLabel:m,resolveViewLabel:h,resolveItemLabel:g,t:b,templateContext:S}){let C=(0,R.useMemo)(()=>s?re(e,s):e,[e,s]),w=(0,R.useMemo)(()=>se(C),[C]),T=C.slice().sort((e,t)=>(e.order??0)-(t.order??0)),E=A(j(k,{activationConstraint:{distance:ie}}),j(L)),D=e=>{let{active:t,over:n}=e;if(!n||t.id===n.id||!d)return;let r=T.findIndex(e=>e.id===t.id),i=T.findIndex(e=>e.id===n.id);r===-1||i===-1||d(M(T,r,i).map((e,t)=>({...e,order:t})))},N={basePath:t,evalVis:n,checkPerm:r,checkCap:i,onAction:a,enablePinning:c,onPinToggle:l,resolveObjectLabel:f,resolveDashboardLabel:p,resolveGroupLabel:m,resolveViewLabel:h,resolveItemLabel:g,t:b,templateContext:S},B=T.some(e=>e.type===`group`),V=w.length>0&&c?(0,z.jsxs)(x,{children:[(0,z.jsxs)(_,{className:`flex items-center gap-1.5`,children:[(0,z.jsx)(o,{className:`h-3.5 w-3.5`}),b?b(`console.nav.favorites`,{defaultValue:`Favorites`}):`Favorites`]}),(0,z.jsx)(y,{children:(0,z.jsx)(v,{children:w.map(e=>(0,z.jsx)($,{item:e,...N},`fav-${e.id}`))})})]}):null;if(!B){let e=T.filter(e=>e.type!==`group`).map(e=>e.id);return(0,z.jsxs)(z.Fragment,{children:[V,(0,z.jsx)(x,{children:(0,z.jsx)(y,{children:u?(0,z.jsx)(O,{sensors:E,collisionDetection:P,onDragEnd:D,children:(0,z.jsx)(I,{items:e,strategy:F,children:(0,z.jsx)(v,{children:T.map(e=>(0,z.jsx)(ae,{item:e,enableReorder:u,...N},e.id))})})}):(0,z.jsx)(v,{children:T.map(e=>(0,z.jsx)($,{item:e,...N},e.id))})})})]})}let H=[],U=[],W=e=>{if(U.length===0)return;let t=U;U=[],H.push((0,z.jsx)(x,{children:(0,z.jsx)(y,{children:(0,z.jsx)(v,{children:t.map(e=>(0,z.jsx)($,{item:e,...N},e.id))})})},e))};return T.forEach((e,t)=>{e.type===`group`?(W(`leaf-${t}`),H.push((0,z.jsx)($,{item:e,...N},e.id))):U.push(e)}),W(`leaf-end`),(0,z.jsxs)(z.Fragment,{children:[V,H]})}function se(e){let t=[];for(let n of e)n.pinned&&n.type!==`group`&&n.type!==`separator`&&t.push(n),n.children?.length&&t.push(...se(n.children));return t}export{Q as n,G as r,oe as t};
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-B_NAVTba.js"></script>
21
+ <script type="module" crossorigin src="./assets/index-CiI7zDDo.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-DwG7_t-6.css">
25
- <link rel="modulepreload" href="./assets/framework-CHiz03zG.js" />
26
- <link rel="modulepreload" href="./assets/ui-components-BbPoD3rS.js" />
24
+ <link rel="stylesheet" crossorigin href="./assets/index-Cf7NsvAk.css">
25
+ <link rel="modulepreload" href="./assets/framework-crD8qZlm.js" />
26
+ <link rel="modulepreload" href="./assets/ui-components-BrY5joKQ.js" />
27
27
  <link rel="modulepreload" href="./assets/vendor-radix-CSVEhP0L.js" />
28
28
  <link rel="modulepreload" href="./assets/vendor-react-DR370ovB.js" />
29
29
  </head>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@objectstack/console",
3
- "version": "9.2.0",
3
+ "version": "9.3.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,f as n,r,t as i}from"./vendor-react-DR370ovB.js";import{d as a,f as ee}from"./infrastructure-CxityHZF.js";import{r as te}from"./framework-CHiz03zG.js";import{$ as ne,Ai as re,At as o,B as ie,Bt as s,Do as ae,Ft as oe,Gn as se,Go as ce,Ht as le,I as ue,It as de,Kn as fe,L as pe,Lt as me,Mr as he,Mt as ge,Nt as _e,Or as ve,Pt as ye,Rt as be,Vt as xe,Wn as Se,Xo as Ce,Zn as we,Zs as Te,ar as c,at as Ee,br as De,cr as l,ct as Oe,dr as ke,ds as Ae,en as je,et as Me,fr as Ne,in as Pe,ir as Fe,is as Ie,it as Le,lr as u,lt as Re,nr as ze,nt as Be,or as d,os as Ve,ot as f,pr as p,ri as He,rt as Ue,sr as m,st as h,tr as We,tt as Ge,ur as Ke,us as qe,vi as Je,zo as Ye,zt as Xe}from"./ui-components-BbPoD3rS.js";import{r as g}from"./vendor-ui-utils-rQOI1gAo.js";var _=e(t(),1),Ze=`${``.replace(/\/$/,``)}/api/v1`;async function v(e,t){let n=await fetch(`${Ze}${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 y={listProcesses(e={}){let t=new URLSearchParams;e.object&&t.set(`object`,e.object),e.activeOnly&&t.set(`activeOnly`,`true`);let n=t.toString();return v(`/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);let r=t.toString();return v(`/approvals/requests${r?`?${r}`:``}`)},async getRequest(e){return{data:await v(`/approvals/requests/${encodeURIComponent(e)}`)}},listActions(e){return v(`/approvals/requests/${encodeURIComponent(e)}/actions`)},async approve(e,t){let n=await v(`/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 v(`/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 v(`/approvals/requests/${encodeURIComponent(e)}/recall`,{method:`POST`,body:JSON.stringify(t)})).request,finalized:!0}},async submit(e){return v(`/approvals/requests`,{method:`POST`,body:JSON.stringify(e)})}};function Qe(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 b=i(),$e={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`};function et(e){if(!e)return`—`;try{return new Date(e).toLocaleString()}catch{return e}}function x(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 S(e){return e&&String(e).replace(/^flow:/,``).trim().split(/[_\-\s]+/).filter(Boolean).map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(` `)||`—`}function tt(e){return e.process_label||S(e.process_name)}function nt(e){return e.step_label?e.step_label:e.current_step?S(e.current_step):null}function rt(e){return e.submitter_name||x(e.submitter_id)}function it(e,t){return t.pending_approver_names?.[e]||x(e)}function at(e){return e.object_label||e.object_name}function C(e){return e.submitted_at||e.created_at||void 0}function w(e){let t=C(e);if(!t)return null;let n=Date.parse(t);return Number.isNaN(n)?null:(Date.now()-n)/36e5}function ot(e){if(e.status!==`pending`)return`text-muted-foreground`;let t=w(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`}var T=new Set([`id`,`created_at`,`updated_at`,`created_by`,`updated_by`,`organization_id`]);function E(e){return e.split(`_`).filter(Boolean).map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(` `)}function D(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 st=/^[A-Za-z0-9_-]{15,}$/;function ct(e,t,n=6){if(!e||typeof e!=`object`||Array.isArray(e))return[];let r=[];for(let[i,a]of Object.entries(e)){if(T.has(i)||a==null||typeof a==`object`||String(a).trim()===``)continue;let e=t?.[i];if(!(!e&&typeof a==`string`&&st.test(a.trim())&&!/^\d+$/.test(a.trim()))&&(r.push([E(i),e??D(i,a)]),r.length>=n))break}return r}function lt(){let{t:e,language:t}=te(),{user:i}=ee(),Ze=a(),{appName:v}=n(),S=(0,_.useMemo)(()=>Qe(i),[i]),w=(0,_.useCallback)((t,n,r)=>String(e(`approvalsInbox.${t}`,{defaultValue:n,...r})),[e]),T=(0,_.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 w(`justNow`,`just now`);let i=Math.round(r/60);if(i<60)return w(`minutesAgo`,`{{count}}m ago`,{count:i});let a=Math.round(i/60);if(a<24)return w(`hoursAgo`,`{{count}}h ago`,{count:a});let ee=Math.round(a/24);if(ee<30)return w(`daysAgo`,`{{count}}d ago`,{count:ee});try{return new Date(e).toLocaleDateString(t)}catch{return e}},[w,t]),E=(0,_.useCallback)(e=>{switch(e){case`pending`:return w(`statusPending`,`Pending`);case`approved`:return w(`statusApproved`,`Approved`);case`rejected`:return w(`statusRejected`,`Rejected`);case`recalled`:return w(`statusRecalled`,`Recalled`);default:return e}},[w]),D=(0,_.useCallback)((e,t)=>{let n=e?.code??``,r=e?.status??0;return n===`NOT_IMPLEMENTED`||r===501?w(`recallUnavailable`,`Recall is not available on this deployment.`):r===404?w(`requestGone`,`This request no longer exists. Refresh the list.`):n===`FORBIDDEN`||r===403?w(`notAllowed`,`You are not allowed to perform this action.`):n===`INVALID_STATE`||r===409?w(`alreadyDecided`,`This request was already decided. Refresh the list.`):e?.message||t},[w]);function st({status:e}){return(0,b.jsx)(we,{variant:`outline`,className:Te(`font-medium`,$e[e]??``),children:E(e)})}let lt=(0,_.useCallback)(e=>`/apps/${v||`setup`}/${encodeURIComponent(e.object_name)}/record/${encodeURIComponent(e.record_id)}`,[v]),[O,ut]=(0,_.useState)(`pending`),[k,dt]=(0,_.useState)([]),[ft,pt]=(0,_.useState)(!1),[mt,ht]=(0,_.useState)(null),[gt,_t]=(0,_.useState)(0),[A,vt]=(0,_.useState)(null),[j,yt]=(0,_.useState)(null),[bt,xt]=(0,_.useState)([]),[St,Ct]=(0,_.useState)(!1),[wt,M]=(0,_.useState)(``),[N,Tt]=(0,_.useState)(``),[P,Et]=(0,_.useState)(null),[F,Dt]=(0,_.useState)(``),[I,Ot]=(0,_.useState)(`all`),[L,kt]=(0,_.useState)(`all`),[R,At]=(0,_.useState)(`all`),[z,B]=(0,_.useState)(new Set),[jt,Mt]=(0,_.useState)(!1),[V,H]=(0,_.useState)(null),[U,Nt]=(0,_.useState)(null),[W,G]=(0,_.useState)(-1),K=(0,_.useCallback)(async()=>{pt(!0),ht(null);try{let e=[];if(O===`pending`)e=S.length?(await y.listRequests({status:`pending`,approverId:S})).data:[],_t(e.length);else{if(O===`submitted`){let t=i?.id;e=t?(await y.listRequests({submitterId:t})).data:[]}else e=(await y.listRequests({})).data;S.length&&y.listRequests({status:`pending`,approverId:S}).then(e=>_t(e.data.length)).catch(()=>{})}e.sort((e,t)=>(C(t)||``).localeCompare(C(e)||``)),dt(e)}catch(e){ht(e?.message||String(e)),dt([])}finally{pt(!1)}},[O,S,i?.id]);(0,_.useEffect)(()=>{K()},[K]);let q=(0,_.useCallback)(async e=>{vt(e),Ct(!0),M(``),Tt(``);try{let[t,n]=await Promise.all([y.getRequest(e),y.listActions(e)]);yt(t.data),xt(n.data)}catch(e){g.error(D(e,w(`loadFailed`,`Failed to load request`))),yt(null),xt([])}finally{Ct(!1)}},[D,w]),Pt=()=>{vt(null),yt(null),xt([]),M(``),Tt(``)},Ft=(0,_.useCallback)(e=>{if(N.trim())return N.trim();if(!e)return i?.id||``;let t=new Set(e.pending_approvers||[]);for(let e of S)if(t.has(e))return e;return i?.id||``},[N,S,i?.id]),J=(0,_.useCallback)(()=>{S.length&&y.listRequests({status:`pending`,approverId:S}).then(e=>_t(e.data.length)).catch(()=>{})},[S]),It=(0,_.useCallback)(async e=>{if(!j)return;let t=e===`recall`&&i?.id||Ft(j);if(!t){g.error(w(`noActor`,`Cannot determine the acting identity`));return}Et(e);try{let n={actor_id:t,comment:wt.trim()||void 0},r=await(e===`approve`?y.approve:e===`reject`?y.reject:y.recall)(j.id,n);if(g.success(e===`approve`?r.finalized?w(`approvedFinal`,`Approved`):w(`approvedWaiting`,`Approved — waiting on the remaining approvers`):e===`reject`?w(`rejectedToast`,`Rejected`):w(`recalledToast`,`Request recalled`)),M(``),e!==`recall`&&O===`pending`){let e=qt.current,t=e.findIndex(e=>e.id===j.id),n=e[t+1]??e[t-1];K(),n&&n.id!==j.id?q(n.id):Pt();return}let[i,a]=await Promise.all([y.getRequest(j.id),y.listActions(j.id)]);yt(i.data),xt(a.data),K()}catch(e){g.error(D(e,w(`actionFailed`,`Action failed`)))}finally{Et(null)}},[j,Ft,wt,K,i?.id,D,w,O,q]),Lt=(0,_.useMemo)(()=>{if(!j||j.status!==`pending`)return!1;let e=new Set(j.pending_approvers||[]);return S.some(t=>e.has(t))||N.trim().length>0},[j,S,N]),Rt=(0,_.useMemo)(()=>!j||j.status!==`pending`?!1:j.submitter_id===i?.id||N.trim().length>0,[j,i?.id,N]),zt=(0,_.useMemo)(()=>{let e=new Set;for(let t of k)e.add(tt(t));return Array.from(e).sort()},[k]),Bt=(0,_.useMemo)(()=>{let e=new Set;for(let t of k)t.object_name&&e.add(t.object_name);return Array.from(e).sort()},[k]),Y=(0,_.useMemo)(()=>{let e=F.trim().toLowerCase();return k.filter(t=>I!==`all`&&tt(t)!==I||L!==`all`&&t.object_name!==L||R!==`all`&&t.status!==R?!1:e?[t.process_name,t.process_label,t.step_label,t.object_name,t.record_id,t.record_title,t.submitter_id,t.submitter_name,...t.pending_approvers||[]].filter(Boolean).join(` `).toLowerCase().includes(e):!0)},[k,F,I,L,R]),X=(0,_.useMemo)(()=>A?Y.findIndex(e=>e.id===A):-1,[Y,A]);(0,_.useEffect)(()=>{if(z.size===0)return;let e=new Set(Y.map(e=>e.id)),t=!1,n=new Set;for(let r of z)e.has(r)?n.add(r):t=!0;t&&B(n)},[Y,z]),(0,_.useEffect)(()=>{W>=Y.length&&G(Y.length-1)},[Y.length,W]);let Z=(0,_.useCallback)(e=>{if(e.status!==`pending`)return!1;let t=new Set(S);return(e.pending_approvers||[]).some(e=>t.has(e))},[S]),Q=(0,_.useMemo)(()=>Y.filter(e=>z.has(e.id)&&Z(e)),[Y,z,Z]),$=Y.filter(e=>e.status===`pending`),Vt=$.length>0&&$.every(e=>z.has(e.id)),Ht=(0,_.useCallback)(()=>{B(e=>{if(Vt)return new Set;let t=new Set(e);for(let e of $)t.add(e.id);return t})},[Vt,$]),Ut=(0,_.useCallback)(e=>{B(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[]),Wt=(0,_.useCallback)(async e=>{let t=Q;if(t.length===0)return;Mt(!0);let n=0,r=[];for(let a of t){let t=new Set(a.pending_approvers||[]),ee=S.find(e=>t.has(e))||i?.id||``;try{await(e===`approve`?y.approve:y.reject)(a.id,{actor_id:ee}),n++}catch{r.push(a.record_title||x(a.record_id))}}if(Mt(!1),B(new Set),r.length===0)g.success(e===`approve`?w(`bulkApproved`,`Approved {{count}} requests`,{count:n}):w(`bulkRejected`,`Rejected {{count}} requests`,{count:n}));else{let e=r.slice(0,3).join(`, `);g.error(w(`bulkPartial`,`{{ok}} succeeded, {{fail}} failed: {{which}}`,{ok:n,fail:r.length,which:e+(r.length>3?`…`:``)}))}K(),J()},[Q,S,i?.id,K,J,w]),Gt=(0,_.useCallback)(async e=>{if(!Z(e)||U)return;let t=new Set(e.pending_approvers||[]),n=S.find(e=>t.has(e))||i?.id||``;Nt(e.id);try{let t=await y.approve(e.id,{actor_id:n});g.success(t.finalized?w(`inlineApproved`,`Approved "{{title}}"`,{title:e.record_title||x(e.record_id)}):w(`approvedWaiting`,`Approved — waiting on the remaining approvers`)),K(),J()}catch(e){g.error(D(e,w(`actionFailed`,`Action failed`)))}finally{Nt(null)}},[Z,U,S,i?.id,K,J,D,w]),Kt=(0,_.useCallback)(async()=>{let e=V;if(!e)return;let t=new Set(e.pending_approvers||[]),n=S.find(e=>t.has(e))||i?.id||``;Nt(e.id),H(null);try{await y.reject(e.id,{actor_id:n}),g.success(w(`inlineRejected`,`Rejected "{{title}}"`,{title:e.record_title||x(e.record_id)})),K(),J()}catch(e){g.error(D(e,w(`actionFailed`,`Action failed`)))}finally{Nt(null)}},[V,S,i?.id,K,J,D,w]),qt=(0,_.useRef)(Y);qt.current=Y;let Jt=(0,_.useRef)(W);Jt.current=W,(0,_.useEffect)(()=>{let e=e=>{if(A||V)return;let t=e.target,n=t?.tagName;if(n===`INPUT`||n===`TEXTAREA`||n===`SELECT`||t?.isContentEditable||document.querySelector(`[role="alertdialog"]`))return;let r=qt.current;if(!r.length)return;let i=Jt.current;e.key===`j`||e.key===`ArrowDown`?(e.preventDefault(),G(Math.min(i+1,r.length-1))):e.key===`k`||e.key===`ArrowUp`?(e.preventDefault(),G(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]&&O===`pending`?(e.preventDefault(),Ut(r[i].id)):e.key===`a`&&i>=0&&r[i]?(e.preventDefault(),Gt(r[i])):e.key===`r`&&i>=0&&r[i]&&Z(r[i])&&(e.preventDefault(),H(r[i]))};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[A,V,O,q,Ut,Gt,Z]),(0,_.useEffect)(()=>{if(!A)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=qt.current,i=r.findIndex(e=>e.id===A);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)},[A,q]);let Yt=!!F||I!==`all`||L!==`all`||R!==`all`,Xt=e=>{ut(e),At(`all`),Ot(`all`),kt(`all`),Dt(``),G(-1)};function Zt({r:e}){return(0,b.jsxs)(`div`,{className:`min-w-0`,children:[(0,b.jsx)(`div`,{className:`font-medium truncate`,children:tt(e)}),(0,b.jsx)(`div`,{className:`text-xs text-muted-foreground truncate`,children:nt(e)||`—`})]})}function Qt({r:e}){return(0,b.jsxs)(`div`,{className:`min-w-0`,children:[(0,b.jsxs)(r,{to:lt(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,b.jsx)(`span`,{className:`truncate`,children:e.record_title||x(e.record_id)}),(0,b.jsx)(ae,{className:`h-3 w-3 shrink-0 text-muted-foreground`})]}),(0,b.jsx)(`div`,{className:`text-xs text-muted-foreground truncate`,children:at(e)})]})}function $t({r:e}){if(!Z(e))return null;let t=U===e.id;return(0,b.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,b.jsx)(p,{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 Gt(e),"aria-label":w(`approve`,`Approve`),children:(0,b.jsx)(Ie,{className:`h-4 w-4`})}),(0,b.jsx)(p,{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:()=>H(e),"aria-label":w(`reject`,`Reject`),children:(0,b.jsx)(Ce,{className:`h-4 w-4`})})]})}return(0,b.jsxs)(`div`,{className:`flex flex-col gap-4 sm:gap-6 p-4 sm:p-6 max-w-6xl`,children:[(0,b.jsxs)(`header`,{className:`flex flex-col sm:flex-row sm:items-center sm:justify-between gap-2`,children:[(0,b.jsxs)(`div`,{children:[(0,b.jsxs)(`h1`,{className:`text-2xl font-semibold flex items-center gap-2`,children:[(0,b.jsx)(He,{className:`h-6 w-6`}),w(`title`,`Approvals Inbox`)]}),(0,b.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:w(`subtitle`,`Review and act on approval requests.`)})]}),(0,b.jsxs)(p,{variant:`outline`,size:`sm`,onClick:K,disabled:ft,className:`self-start sm:self-auto`,children:[(0,b.jsx)(re,{className:`h-4 w-4 mr-2 ${ft?`animate-spin`:``}`}),w(`refresh`,`Refresh`)]})]}),mt&&(0,b.jsxs)(We,{variant:`destructive`,children:[(0,b.jsx)(Ve,{className:`h-4 w-4`}),(0,b.jsx)(ze,{children:mt})]}),(0,b.jsxs)(Me,{value:O,onValueChange:Xt,children:[(0,b.jsxs)(Be,{children:[(0,b.jsxs)(Ue,{value:`pending`,children:[w(`tabMyPending`,`My Pending`),gt>0&&(0,b.jsx)(we,{variant:`secondary`,className:`ml-2`,children:gt})]}),(0,b.jsx)(Ue,{value:`submitted`,children:w(`tabSubmitted`,`Submitted by me`)}),(0,b.jsx)(Ue,{value:`all`,children:w(`tabAll`,`All`)})]}),(0,b.jsxs)(Ge,{value:O,className:`mt-4 space-y-3`,children:[!ft&&k.length>0&&(0,b.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,b.jsxs)(`div`,{className:`relative flex-1 min-w-[200px] max-w-sm`,children:[(0,b.jsx)(Je,{className:`absolute left-2.5 top-1/2 -translate-y-1/2 h-3.5 w-3.5 text-muted-foreground`}),(0,b.jsx)(je,{value:F,onChange:e=>Dt(e.target.value),placeholder:w(`searchPlaceholder`,`Search record, process, requester…`),className:`pl-8 h-8 text-sm`}),F&&(0,b.jsx)(`button`,{type:`button`,onClick:()=>Dt(``),className:`absolute right-2 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground`,"aria-label":w(`clearSearch`,`Clear search`),children:(0,b.jsx)(De,{className:`h-3.5 w-3.5`})})]}),O!==`pending`&&(0,b.jsxs)(be,{value:R,onValueChange:At,children:[(0,b.jsx)(xe,{className:`h-8 w-auto min-w-[130px] text-sm`,children:(0,b.jsx)(le,{placeholder:w(`statusFilter`,`Status`)})}),(0,b.jsxs)(Xe,{children:[(0,b.jsx)(s,{value:`all`,children:w(`allStatuses`,`All statuses`)}),(0,b.jsx)(s,{value:`pending`,children:E(`pending`)}),(0,b.jsx)(s,{value:`approved`,children:E(`approved`)}),(0,b.jsx)(s,{value:`rejected`,children:E(`rejected`)}),(0,b.jsx)(s,{value:`recalled`,children:E(`recalled`)})]})]}),zt.length>1&&(0,b.jsxs)(be,{value:I,onValueChange:Ot,children:[(0,b.jsx)(xe,{className:`h-8 w-auto min-w-[140px] text-sm`,children:(0,b.jsx)(le,{placeholder:w(`processFilter`,`Process`)})}),(0,b.jsxs)(Xe,{children:[(0,b.jsx)(s,{value:`all`,children:w(`allProcesses`,`All processes`)}),zt.map(e=>(0,b.jsx)(s,{value:e,children:e},e))]})]}),Bt.length>1&&(0,b.jsxs)(be,{value:L,onValueChange:kt,children:[(0,b.jsx)(xe,{className:`h-8 w-auto min-w-[140px] text-sm`,children:(0,b.jsx)(le,{placeholder:w(`objectFilter`,`Object`)})}),(0,b.jsxs)(Xe,{children:[(0,b.jsx)(s,{value:`all`,children:w(`allObjects`,`All objects`)}),Bt.map(e=>(0,b.jsx)(s,{value:e,children:e},e))]})]}),Yt&&(0,b.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:w(`filterCount`,`{{shown}} of {{total}}`,{shown:Y.length,total:k.length})})]}),O===`pending`&&z.size>0&&(0,b.jsxs)(`div`,{className:`flex items-center justify-between gap-2 px-3 py-2 rounded-md border bg-accent/30 text-sm`,children:[(0,b.jsxs)(`span`,{children:[(0,b.jsx)(`strong`,{children:z.size}),` `,w(`selected`,`selected`),Q.length!==z.size&&(0,b.jsx)(`span`,{className:`text-muted-foreground ml-1`,children:w(`actionableCount`,`({{count}} actionable)`,{count:Q.length})})]}),(0,b.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,b.jsxs)(Fe,{children:[(0,b.jsx)(Ne,{asChild:!0,children:(0,b.jsxs)(p,{size:`sm`,disabled:jt||Q.length===0,children:[(0,b.jsx)(Ie,{className:`h-3.5 w-3.5 mr-1`}),w(`approveN`,`Approve {{count}}`,{count:Q.length||``})]})}),(0,b.jsxs)(m,{children:[(0,b.jsxs)(Ke,{children:[(0,b.jsx)(ke,{children:w(`bulkApproveTitle`,`Approve {{count}} requests?`,{count:Q.length})}),(0,b.jsx)(l,{children:w(`bulkApproveBody`,`Each request is approved with your identity and its flow continues down the approve branch.`)})]}),(0,b.jsxs)(u,{children:[(0,b.jsx)(d,{children:w(`cancel`,`Cancel`)}),(0,b.jsx)(c,{onClick:()=>Wt(`approve`),children:w(`approveN`,`Approve {{count}}`,{count:Q.length})})]})]})]}),(0,b.jsxs)(Fe,{children:[(0,b.jsx)(Ne,{asChild:!0,children:(0,b.jsxs)(p,{size:`sm`,variant:`outline`,disabled:jt||Q.length===0,className:`border-destructive text-destructive hover:bg-destructive hover:text-destructive-foreground`,children:[(0,b.jsx)(Ce,{className:`h-3.5 w-3.5 mr-1`}),w(`rejectN`,`Reject {{count}}`,{count:Q.length||``})]})}),(0,b.jsxs)(m,{children:[(0,b.jsxs)(Ke,{children:[(0,b.jsx)(ke,{children:w(`bulkRejectTitle`,`Reject {{count}} requests?`,{count:Q.length})}),(0,b.jsx)(l,{children:w(`bulkRejectBody`,`This rejects the selected requests and notifies their submitters.`)})]}),(0,b.jsxs)(u,{children:[(0,b.jsx)(d,{children:w(`cancel`,`Cancel`)}),(0,b.jsx)(c,{onClick:()=>Wt(`reject`),className:`bg-destructive text-destructive-foreground hover:bg-destructive/90`,children:w(`rejectN`,`Reject {{count}}`,{count:Q.length})})]})]})]}),(0,b.jsx)(p,{size:`sm`,variant:`ghost`,onClick:()=>B(new Set),disabled:jt,children:w(`clear`,`Clear`)})]})]}),ft?(0,b.jsxs)(`div`,{className:`space-y-2`,children:[(0,b.jsx)(o,{className:`h-10 w-full`}),(0,b.jsx)(o,{className:`h-10 w-full`}),(0,b.jsx)(o,{className:`h-10 w-full`})]}):k.length===0?(0,b.jsx)(`div`,{className:`flex items-center justify-center min-h-[240px] rounded-md border border-dashed`,children:(0,b.jsxs)(ue,{children:[(0,b.jsx)(ie,{children:w(`emptyTitle`,`No requests`)}),(0,b.jsx)(pe,{children:O===`pending`?w(`emptyPending`,`You're all caught up — nothing is waiting on you.`):w(`emptyOther`,`Nothing here yet.`)}),O===`pending`&&(0,b.jsx)(p,{variant:`link`,size:`sm`,className:`mt-1`,onClick:()=>Xt(`all`),children:w(`emptyViewAll`,`Browse all requests`)})]})}):Y.length===0?(0,b.jsx)(`div`,{className:`flex items-center justify-center min-h-[160px] rounded-md border border-dashed text-sm text-muted-foreground`,children:w(`noMatches`,`No matches for current filters.`)}):(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(se,{className:`hidden md:block`,children:(0,b.jsx)(fe,{className:`p-0`,children:(0,b.jsxs)(Le,{children:[(0,b.jsx)(Oe,{children:(0,b.jsxs)(Re,{children:[O===`pending`&&(0,b.jsx)(h,{className:`w-10`,children:(0,b.jsx)(Se,{checked:Vt,onCheckedChange:Ht,"aria-label":w(`selectAll`,`Select all`),disabled:$.length===0})}),(0,b.jsx)(h,{children:w(`colRequest`,`Request`)}),(0,b.jsx)(h,{children:w(`colRecord`,`Record`)}),(0,b.jsx)(h,{children:w(`colRequester`,`Requester`)}),(0,b.jsx)(h,{children:w(`colStatus`,`Status`)}),(0,b.jsx)(h,{children:w(`colWaiting`,`Submitted`)}),(0,b.jsx)(h,{className:`w-20`,"aria-label":w(`colActions`,`Actions`)})]})}),(0,b.jsx)(Ee,{children:Y.map((e,t)=>(0,b.jsxs)(Re,{className:Te(`group cursor-pointer hover:bg-accent/50`,W===t&&`ring-2 ring-inset ring-ring bg-accent/30`),onClick:()=>{G(t),q(e.id)},children:[O===`pending`&&(0,b.jsx)(f,{className:`w-10`,onClick:e=>e.stopPropagation(),children:(0,b.jsx)(Se,{checked:z.has(e.id),onCheckedChange:()=>Ut(e.id),disabled:e.status!==`pending`,"aria-label":w(`selectRow`,`Select request`)})}),(0,b.jsx)(f,{children:(0,b.jsx)(Zt,{r:e})}),(0,b.jsx)(f,{children:(0,b.jsx)(Qt,{r:e})}),(0,b.jsx)(f,{children:(0,b.jsxs)(`div`,{className:`flex items-center gap-1.5 text-sm`,children:[(0,b.jsx)(ve,{className:`h-3.5 w-3.5 text-muted-foreground shrink-0`}),(0,b.jsx)(`span`,{className:`truncate`,title:e.submitter_id||``,children:rt(e)})]})}),(0,b.jsx)(f,{children:(0,b.jsx)(st,{status:e.status})}),(0,b.jsxs)(f,{className:Te(`text-xs whitespace-nowrap`,ot(e)),title:et(C(e)),children:[(0,b.jsx)(ce,{className:`h-3 w-3 inline mr-1`}),T(C(e))]}),(0,b.jsx)(f,{className:`w-20`,children:(0,b.jsx)($t,{r:e})})]},e.id))})]})})}),(0,b.jsx)(`div`,{className:`md:hidden space-y-2`,children:Y.map(e=>(0,b.jsx)(se,{className:`cursor-pointer active:bg-accent/50`,onClick:()=>void q(e.id),children:(0,b.jsxs)(fe,{className:`p-3 space-y-1.5`,children:[(0,b.jsxs)(`div`,{className:`flex items-start justify-between gap-2`,children:[(0,b.jsx)(`div`,{className:`font-medium text-sm truncate`,children:tt(e)}),(0,b.jsx)(st,{status:e.status})]}),(0,b.jsxs)(`div`,{className:`text-sm truncate`,children:[e.record_title||x(e.record_id),(0,b.jsx)(`span`,{className:`text-muted-foreground text-xs ml-1.5`,children:at(e)})]}),(0,b.jsxs)(`div`,{className:`flex items-center justify-between text-xs text-muted-foreground`,children:[(0,b.jsxs)(`span`,{className:`inline-flex items-center gap-1 truncate`,children:[(0,b.jsx)(ve,{className:`h-3 w-3`}),rt(e)]}),(0,b.jsxs)(`span`,{className:Te(`inline-flex items-center gap-1 whitespace-nowrap`,ot(e)),children:[(0,b.jsx)(ce,{className:`h-3 w-3`}),T(C(e))]})]}),Z(e)&&(0,b.jsxs)(`div`,{className:`flex gap-2 pt-1`,onClick:e=>e.stopPropagation(),children:[(0,b.jsxs)(p,{size:`sm`,className:`h-7 flex-1`,disabled:U===e.id,onClick:()=>void Gt(e),children:[(0,b.jsx)(Ie,{className:`h-3.5 w-3.5 mr-1`}),w(`approve`,`Approve`)]}),(0,b.jsxs)(p,{size:`sm`,variant:`outline`,className:`h-7 flex-1 border-destructive text-destructive`,disabled:U===e.id,onClick:()=>H(e),children:[(0,b.jsx)(Ce,{className:`h-3.5 w-3.5 mr-1`}),w(`reject`,`Reject`)]})]})]})},e.id))}),(0,b.jsx)(`div`,{className:`hidden md:block text-[11px] text-muted-foreground`,children:w(`keyboardHint`,`Keyboard: j/k move · Enter open · x select · a approve · r reject`)})]})]})]}),(0,b.jsx)(Fe,{open:!!V,onOpenChange:e=>!e&&H(null),children:(0,b.jsxs)(m,{children:[(0,b.jsxs)(Ke,{children:[(0,b.jsx)(ke,{children:w(`rejectOneTitle`,`Reject "{{title}}"?`,{title:V?V.record_title||x(V.record_id):``})}),(0,b.jsx)(l,{children:w(`rejectOneBody`,`This rejects the request and notifies the submitter.`)})]}),(0,b.jsxs)(u,{children:[(0,b.jsx)(d,{children:w(`cancel`,`Cancel`)}),(0,b.jsx)(c,{onClick:()=>void Kt(),className:`bg-destructive text-destructive-foreground hover:bg-destructive/90`,children:w(`reject`,`Reject`)})]})]})}),(0,b.jsx)(ge,{open:!!A,onOpenChange:e=>!e&&Pt(),children:(0,b.jsxs)(_e,{className:`w-full sm:max-w-xl overflow-y-auto`,children:[(0,b.jsxs)(oe,{children:[(0,b.jsx)(de,{children:j?tt(j):w(`drawerTitle`,`Approval Request`)}),(0,b.jsx)(ye,{children:j?nt(j)||at(j):``})]}),j&&X>=0&&Y.length>1&&(0,b.jsxs)(`div`,{className:`flex items-center justify-between mt-2 text-xs text-muted-foreground`,children:[(0,b.jsxs)(p,{variant:`ghost`,size:`sm`,className:`h-7 px-2`,disabled:X<=0,onClick:()=>{let e=Y[X-1];e&&q(e.id)},children:[(0,b.jsx)(Ae,{className:`h-4 w-4 mr-0.5`}),w(`prevRequest`,`Previous`)]}),(0,b.jsx)(`span`,{children:w(`positionOf`,`{{index}} of {{total}}`,{index:X+1,total:Y.length})}),(0,b.jsxs)(p,{variant:`ghost`,size:`sm`,className:`h-7 px-2`,disabled:X>=Y.length-1,onClick:()=>{let e=Y[X+1];e&&q(e.id)},children:[w(`nextRequest`,`Next`),(0,b.jsx)(qe,{className:`h-4 w-4 ml-0.5`})]})]}),St?(0,b.jsxs)(`div`,{className:`space-y-2 mt-6`,children:[(0,b.jsx)(o,{className:`h-6 w-3/4`}),(0,b.jsx)(o,{className:`h-6 w-1/2`}),(0,b.jsx)(o,{className:`h-20 w-full`})]}):j?(0,b.jsxs)(`div`,{className:`space-y-4 mt-6`,children:[(0,b.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 text-xs text-muted-foreground`,children:[(0,b.jsx)(st,{status:j.status}),(0,b.jsxs)(`span`,{className:`inline-flex items-center gap-1`,title:et(C(j)),children:[(0,b.jsx)(ce,{className:`h-3 w-3`}),w(`submittedAgo`,`Submitted {{when}}`,{when:T(C(j))})]}),j.completed_at&&(0,b.jsxs)(`span`,{children:[`· `,w(`completedAt`,`Completed {{when}}`,{when:T(j.completed_at)})]})]}),(0,b.jsx)(se,{children:(0,b.jsxs)(fe,{className:`p-4 space-y-3`,children:[(0,b.jsxs)(`div`,{className:`flex items-start justify-between gap-2`,children:[(0,b.jsxs)(`div`,{className:`min-w-0`,children:[(0,b.jsxs)(r,{to:lt(j),className:`text-base font-semibold hover:underline inline-flex items-center gap-1.5`,children:[(0,b.jsx)(`span`,{className:`truncate`,children:j.record_title||x(j.record_id)}),(0,b.jsx)(ae,{className:`h-3.5 w-3.5 shrink-0 text-muted-foreground`})]}),(0,b.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:at(j)})]}),(0,b.jsx)(`div`,{className:`text-right text-xs text-muted-foreground shrink-0`,children:(0,b.jsxs)(`div`,{className:`inline-flex items-center gap-1`,children:[(0,b.jsx)(ve,{className:`h-3 w-3`}),(0,b.jsx)(`span`,{title:j.submitter_id||``,children:rt(j)})]})})]}),ct(j.payload,j.payload_display).length>0&&(0,b.jsx)(`div`,{className:`grid grid-cols-2 gap-x-4 gap-y-2 text-sm border-t pt-3`,children:ct(j.payload,j.payload_display).map(([e,t])=>(0,b.jsxs)(`div`,{className:`min-w-0`,children:[(0,b.jsx)(`div`,{className:`text-[11px] text-muted-foreground`,children:e}),(0,b.jsx)(`div`,{className:`truncate`,title:t,children:t})]},e))}),j.status===`pending`&&(j.pending_approvers||[]).length>0&&(0,b.jsxs)(`div`,{className:`border-t pt-3`,children:[(0,b.jsx)(`div`,{className:`text-[11px] text-muted-foreground mb-1`,children:w(`waitingOn`,`Waiting on`)}),(0,b.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:(j.pending_approvers||[]).map((e,t)=>(0,b.jsx)(we,{variant:`outline`,className:`text-[11px]`,title:e,children:it(e,j)},t))})]})]})}),(0,b.jsxs)(`div`,{children:[(0,b.jsx)(`h3`,{className:`text-sm font-semibold mb-3`,children:w(`history`,`Activity`)}),bt.length===0?(0,b.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:w(`noActions`,`No actions yet.`)}):(0,b.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:bt.map(e=>{let t=e.action===`approve`?`bg-emerald-500`:e.action===`reject`?`bg-destructive`:e.action===`submit`?`bg-blue-500`:`bg-muted-foreground`,n=e.actor_name??(e.actor_id&&e.actor_id===j.submitter_id?rt(j):x(e.actor_id)),r=e.action===`submit`?w(`actSubmit`,`Submitted`):e.action===`approve`?w(`actApprove`,`Approved`):e.action===`reject`?w(`actReject`,`Rejected`):e.action===`recall`?w(`actRecall`,`Recalled`):e.action;return(0,b.jsxs)(`li`,{className:`relative text-xs`,children:[(0,b.jsx)(`span`,{className:`absolute -left-[18px] top-1 h-3 w-3 rounded-full ring-2 ring-background ${t}`,"aria-hidden":!0}),(0,b.jsxs)(`div`,{className:`flex items-baseline gap-1.5 flex-wrap`,children:[(0,b.jsx)(`span`,{className:`font-medium`,children:r}),(0,b.jsx)(`span`,{className:`text-muted-foreground`,children:`·`}),(0,b.jsx)(`span`,{title:e.actor_id||``,children:n}),(0,b.jsx)(`span`,{className:`ml-auto text-muted-foreground text-[10px]`,title:et(e.created_at),children:T(e.created_at)})]}),e.comment&&(0,b.jsxs)(`div`,{className:`text-muted-foreground italic mt-0.5`,children:[`"`,e.comment,`"`]})]},e.id)})})]}),j.payload!=null&&(0,b.jsxs)(`details`,{className:`group`,children:[(0,b.jsx)(`summary`,{className:`cursor-pointer text-xs text-muted-foreground hover:text-foreground select-none`,children:w(`rawData`,`Raw data (JSON)`)}),(0,b.jsxs)(`div`,{className:`mt-2`,children:[(0,b.jsx)(`div`,{className:`flex justify-end`,children:(0,b.jsxs)(`button`,{type:`button`,onClick:async()=>{try{await navigator.clipboard.writeText(JSON.stringify(j.payload,null,2)),g.success(w(`copied`,`Copied`))}catch{g.error(w(`copyFailed`,`Copy failed`))}},className:`text-[10px] text-muted-foreground hover:text-foreground inline-flex items-center gap-1`,children:[(0,b.jsx)(Ye,{className:`h-3 w-3`}),w(`copy`,`Copy`)]})}),(0,b.jsx)(`pre`,{className:`text-[11px] bg-muted/50 rounded p-2 overflow-auto max-h-48 mt-1`,children:JSON.stringify(j.payload,null,2)})]})]}),j.status===`pending`&&(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(me,{}),(0,b.jsxs)(`div`,{className:`space-y-3`,children:[Ze&&(0,b.jsxs)(`details`,{className:`group`,children:[(0,b.jsx)(`summary`,{className:`cursor-pointer text-xs text-muted-foreground hover:text-foreground select-none`,children:w(`overrideActor`,`Act as another identity (admin)`)}),(0,b.jsxs)(`div`,{className:`mt-2`,children:[(0,b.jsx)(Pe,{htmlFor:`actor-override`,className:`text-xs`,children:w(`actor`,`Actor`)}),(0,b.jsx)(`input`,{id:`actor-override`,type:`text`,value:N,onChange:e=>Tt(e.target.value),placeholder:`${w(`auto`,`Auto`)}: ${Ft(j)||`—`}`,className:`w-full mt-1 px-3 py-2 text-sm border rounded-md bg-background`}),(0,b.jsx)(`div`,{className:`text-[10px] text-muted-foreground mt-1`,children:w(`overrideHint`,`e.g. role:sales_manager. Leave blank to use the auto-detected identity.`)})]})]}),(0,b.jsxs)(`div`,{children:[(0,b.jsx)(Pe,{htmlFor:`comment`,className:`text-xs`,children:w(`comment`,`Comment (optional)`)}),(0,b.jsx)(`div`,{className:`flex flex-wrap gap-1.5 mt-1.5`,children:[w(`quickPhrase1`,`Approved — meets requirements.`),w(`quickPhrase2`,`Approved with conditions — please monitor execution.`),w(`quickPhrase3`,`Please add supporting material and resubmit.`)].map(e=>(0,b.jsx)(`button`,{type:`button`,onClick:()=>M(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,b.jsx)(ne,{id:`comment`,value:wt,onChange:e=>M(e.target.value),rows:2,className:`mt-1`})]}),(0,b.jsxs)(`div`,{className:`flex gap-2 flex-wrap`,children:[(0,b.jsxs)(p,{size:`sm`,onClick:()=>It(`approve`),disabled:!Lt||P!==null,children:[(0,b.jsx)(Ie,{className:`h-4 w-4 mr-1`}),P===`approve`?w(`approving`,`Approving…`):w(`approve`,`Approve`)]}),(0,b.jsxs)(Fe,{children:[(0,b.jsx)(Ne,{asChild:!0,children:(0,b.jsxs)(p,{size:`sm`,variant:`outline`,disabled:!Lt||P!==null,className:`border-destructive text-destructive hover:bg-destructive hover:text-destructive-foreground`,children:[(0,b.jsx)(Ce,{className:`h-4 w-4 mr-1`}),P===`reject`?w(`rejecting`,`Rejecting…`):w(`reject`,`Reject`)]})}),(0,b.jsxs)(m,{children:[(0,b.jsxs)(Ke,{children:[(0,b.jsx)(ke,{children:w(`rejectTitle`,`Reject this request?`)}),(0,b.jsx)(l,{children:w(`rejectBody`,`This marks the request as rejected and notifies the submitter.`)})]}),(0,b.jsxs)(u,{children:[(0,b.jsx)(d,{children:w(`cancel`,`Cancel`)}),(0,b.jsx)(c,{onClick:()=>It(`reject`),className:`bg-destructive text-destructive-foreground hover:bg-destructive/90`,children:w(`reject`,`Reject`)})]})]})]}),Rt&&(0,b.jsxs)(Fe,{children:[(0,b.jsx)(Ne,{asChild:!0,children:(0,b.jsxs)(p,{size:`sm`,variant:`outline`,disabled:P!==null,children:[(0,b.jsx)(he,{className:`h-4 w-4 mr-1`}),P===`recall`?w(`recalling`,`Recalling…`):w(`recall`,`Recall`)]})}),(0,b.jsxs)(m,{children:[(0,b.jsxs)(Ke,{children:[(0,b.jsx)(ke,{children:w(`recallTitle`,`Recall this request?`)}),(0,b.jsx)(l,{children:w(`recallBody`,`This withdraws your request. Approvers can no longer act on it, and the record is unlocked.`)})]}),(0,b.jsxs)(u,{children:[(0,b.jsx)(d,{children:w(`cancel`,`Cancel`)}),(0,b.jsx)(c,{onClick:()=>It(`recall`),children:w(`recall`,`Recall`)})]})]})]})]}),!Lt&&(0,b.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:Rt?w(`whyDisabledSubmitter`,`You submitted this request, so you can recall it — but only the assigned approvers can approve or reject.`):w(`whyDisabled`,`Only the assigned approvers can act on this request. It is waiting on: {{who}}.`,{who:(j.pending_approvers||[]).map(e=>it(e,j)).join(`, `)||`—`})})]})]})]}):null]})})]})}export{lt as ApprovalsInboxPage};
@@ -1 +0,0 @@
1
- import{o as e}from"./rolldown-runtime-CMxvf4Kt.js";import{_ as t,t as n,u as r}from"./vendor-react-DR370ovB.js";import{r as i}from"./framework-CHiz03zG.js";import{Bt as a,Ht as o,Rt as s,S as c,Vt as l,mi as u,pr as d,ti as f,zt as p}from"./ui-components-BbPoD3rS.js";import{r as m}from"./vendor-ui-utils-rQOI1gAo.js";import{a as h,r as g,t as _}from"./assistantBus-Bppk-Y9t.js";import{a as v,d as y,f as b,p as x,r as S,t as C,u as w}from"./plugin-chatbot-BzJE6C-F.js";import{i as T}from"./runtime-config-ir5bt3TX.js";import{i as E,n as D,r as O}from"./index-B_NAVTba.js";var k=e(t(),1),A=n(),j={data_chat:{zh:`数据助手`,en:`Data Assistant`},metadata_assistant:{zh:`元数据开发助手`,en:`Metadata Assistant`}};function M(e,t,n){let r=t?j[t]:void 0;return r?e?r.zh:r.en:n}function N(e,t,n,r,i){let a=(e??``).toLowerCase().startsWith(`zh`),o=M(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:`失败`,toolDetailsHidden:`已隐藏工具参数和原始结果,仅保留过程摘要。`,copy:`复制`,copied:`已复制`,regenerate:`重新生成`,model:`模型`,submit:`发送`,uploadFiles:`上传文件`,stopResponse:`停止生成`,trace:`调试 trace`,viewTrace:`查看调试 trace`},placeholder:`向${o}提问…`,loadingPlaceholder:`正在加载助手…`,title:`${t} 智能助手`,newChat:`开启新对话`,share:`分享对话`,reviewDraft:e=>`查看 ${e} 项变更`,publishDrafts:`发布`,published:`已发布`,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`,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`,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 ee(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`]}function I({appLabel:e,appName:t,objects:n,agents:y,agentsLoading:w,activeAgent:O,onAgentChange:j,showAgentPicker:M,chatApi:P,apiBase:F,defaultOpen:I=!1,conversationId:L,initialMessages:R}){let{language:z}=i(),B=r(),{editor:V}=h(),te=k.useMemo(()=>!R||R.length===0?[]:x(R),[R]),H=k.useMemo(()=>y.find(e=>e.name===O)?.label??O??e,[y,O,e]),U=k.useMemo(()=>N(z,e,O,H,n),[z,e,O,H,n]),W=k.useMemo(()=>ee(V,z),[V,z]),{messages:G,isLoading:K,error:q,sendMessage:J,stop:Y,reload:X,clear:Z}=b({api:P,conversationId:L,body:{context:{activeApp:e,appName:t,objects:n.map(e=>({name:e.name,label:e.label})),agentName:O,autoPublishAiBuilds:T().features.autoPublishAiBuilds,...V?{editing:V}:{}}},initialMessages:te,autoResponse:!P,autoResponseText:n.length>0?`I can help you work with ${n.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});k.useEffect(()=>{E(L,D(G))},[L,G]);let Q=C({messages:G,apiBase:F,continueConversation:e=>{J(e)}}),ne=M&&y.length>1?(0,A.jsxs)(s,{value:O,onValueChange:j,disabled:w,children:[(0,A.jsx)(l,{className:`h-7 w-[180px] text-xs`,"data-testid":`floating-chatbot-agent-picker`,children:(0,A.jsx)(o,{placeholder:`Choose agent...`})}),(0,A.jsx)(p,{align:`end`,children:y.map(e=>(0,A.jsxs)(a,{value:e.name,className:`text-xs`,children:[(0,A.jsx)(`span`,{className:`font-medium`,children:e.label}),e.description?(0,A.jsx)(`span`,{className:`block text-muted-foreground text-[10px] truncate max-w-[220px]`,children:e.description}):null]},e.name))})]}):null,[re,$]=k.useState(!1),ie=k.useMemo(()=>F.replace(/\/v1\/ai$/,``).replace(/\/ai$/,``)||`/api`,[F]),ae=(0,A.jsxs)(A.Fragment,{children:[G.length>0?(0,A.jsx)(d,{variant:`ghost`,size:`icon`,className:`h-7 w-7`,"aria-label":U.newChat,title:U.newChat,"data-testid":`floating-chatbot-new`,onClick:Z,children:(0,A.jsx)(f,{className:`h-4 w-4`})}):null,L?(0,A.jsx)(d,{variant:`ghost`,size:`icon`,className:`h-7 w-7`,"aria-label":U.share,title:U.share,"data-testid":`floating-chatbot-share`,onClick:()=>$(!0),children:(0,A.jsx)(u,{className:`h-4 w-4`})}):null]});return(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)(S,{floatingConfig:{position:`bottom-right`,defaultOpen:I,panelWidth:420,panelHeight:560,title:U.title,triggerSize:56},headerExtra:ne,headerActions:ae,messages:G,labels:U.labels,showAvatars:!0,hideClearBar:!0,assistantAvatarFallback:U.agentLabel,suggestions:G.length===0?W??U.suggestions:void 0,placeholder:O?U.placeholder:w?U.loadingPlaceholder:U.placeholder,onSendMessage:e=>J(e),onClear:Z,onStop:K?Y:void 0,onReload:X,isLoading:K,error:q,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:U.reviewDraft,onOpenBuiltApp:e=>B(`/apps/${encodeURIComponent(e)}`),openBuiltAppLabel:U.openBuiltApp,onPreviewDraftApp:e=>B(`/apps/${encodeURIComponent(e)}?preview=draft`),onDraftArtifacts:e=>{for(let t of e)_(t)},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?m.warning(U.seedWarn,{description:i.error??(Array.isArray(i.errors)&&i.errors.length?String(i.errors[0]):void 0)}):m.success(U.publishOk);let a=(n?.data?.published??n?.published??[]).find(e=>e?.type===`app`&&e?.name);return a?.name&&B(`/apps/${encodeURIComponent(a.name)}`),{ok:!0,health:v(n)}}catch(e){return m.error(U.publishFailed,{description:e instanceof Error?e.message:void 0}),!1}},publishDraftsLabel:U.publishDrafts,publishedLabel:U.published,autoPublishDrafts:T().features.autoPublishAiBuilds}),L&&(0,A.jsx)(c,{open:re,onOpenChange:$,objectName:`ai_conversations`,recordId:L,recordLabel:`this conversation`,apiBase:ie})]})}function L({appLabel:e,appName:t,objects:n,apiBase:r,defaultAgent:i,showAgentPicker:a,defaultOpen:o=!1,userId:s}){let c=k.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,d=a??l.VITE_AI_SHOW_AGENT_PICKER===`true`,{agents:f,isLoading:p,error:m}=y({apiBase:c}),[h,g]=k.useState(void 0);k.useEffect(()=>{if(!h&&f.length>0){let e=w(f,i??u);e&&g(e)}},[f,h,i,u]);let _=h?`${c}/agents/${encodeURIComponent(h)}/chat`:void 0,{conversationId:v,initialMessages:b}=O({userId:s,scope:h,apiBase:c});return(0,A.jsx)(I,{appLabel:e,appName:t,objects:n,agents:f,agentsLoading:p,agentsError:m,activeAgent:h,onAgentChange:g,showAgentPicker:d,chatApi:_,apiBase:c,defaultOpen:o,conversationId:v,initialMessages:b},`${_??`local`}:${v??`pending`}`)}export{L as default};
@@ -1 +0,0 @@
1
- import{o as e}from"./rolldown-runtime-CMxvf4Kt.js";import{_ as t,t as n}from"./vendor-react-DR370ovB.js";import{w as r}from"./framework-CHiz03zG.js";import{$ as i,Ai as a,At as o,Bi as s,Ea as c,Ft as l,Gn as u,Go as d,It as f,Jn as p,Kn as m,Mt as h,Nt as g,Pt as _,Sr as v,Ut as y,Xo as b,Yn as x,Zn as S,at as C,ct as w,en as T,in as E,is as D,it as O,lt as k,os as A,ot as j,pr as M,qn as N,st as P,ut as F}from"./ui-components-BbPoD3rS.js";import"./index-B_NAVTba.js";var I=e(t(),1),L=n();function R({status:e}){let t={success:{icon:D,cls:`text-emerald-600 border-emerald-300`},completed:{icon:D,cls:`text-emerald-600 border-emerald-300`},failed:{icon:b,cls:`text-red-600 border-red-300`},error:{icon:b,cls:`text-red-600 border-red-300`},running:{icon:c,cls:`text-blue-600 border-blue-300 animate-pulse`},pending:{icon:d,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)(S,{variant:`outline`,className:`text-[10px] font-mono inline-flex items-center gap-1 ${t.cls}`,children:[(0,L.jsx)(n,{className:`h-3 w-3`}),e]})}function z(e){if(!e)return`—`;try{return new Date(e).toLocaleString()}catch{return e}}function B(e,t){switch(t){case`number`:{if(e===``)return;let t=Number(e);return Number.isNaN(t)?e:t}case`boolean`:return e===`true`;case`object`:case`list`:case`array`:if(e.trim()===``)return;try{return JSON.parse(e)}catch{return e}default:return e}}function V({data:e}){return(0,L.jsx)(`pre`,{className:`rounded border bg-muted/30 p-2 text-xs font-mono overflow-auto whitespace-pre-wrap break-all max-h-96`,children:JSON.stringify(e,null,2)})}function H(){let e=r()?.getClient?.(),[t,n]=(0,I.useState)([]),[i,s]=(0,I.useState)(!0),[c,l]=(0,I.useState)(null),[d,f]=(0,I.useState)(``),[h,g]=(0,I.useState)(0),_=(0,I.useCallback)(async()=>{if(!e?.meta?.getItems){l(`meta.getItems is not available on this client`),s(!1);return}s(!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),!d&&r.length>0&&f(r[0].name)}catch(e){l(e?.message??String(e))}finally{s(!1)}},[e,d]);(0,I.useEffect)(()=>{_()},[_]);let y=(0,I.useMemo)(()=>t.find(e=>e.name===d)??null,[t,d]);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)(v,{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)(u,{children:[(0,L.jsx)(p,{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)(x,{className:`text-base`,children:`Flow`}),(0,L.jsx)(N,{children:`Select a flow definition to test`})]}),(0,L.jsxs)(M,{variant:`outline`,size:`sm`,onClick:_,disabled:i,children:[(0,L.jsx)(a,{className:`h-3.5 w-3.5 mr-2 ${i?`animate-spin`:``}`}),`Refresh`]})]})}),(0,L.jsxs)(m,{children:[i&&(0,L.jsx)(o,{className:`h-9 w-72`}),c&&(0,L.jsx)(`p`,{className:`text-sm text-red-500 font-mono break-all`,children:c}),!i&&!c&&t.length===0&&(0,L.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`No flow definitions found.`}),!i&&!c&&t.length>0&&(0,L.jsx)(`select`,{value:d,onChange:e=>f(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))})]})]}),y&&(0,L.jsxs)(`div`,{className:`grid gap-4 lg:grid-cols-2`,children:[(0,L.jsx)(U,{client:e,flow:y.spec,onExecuted:()=>g(e=>e+1)}),(0,L.jsx)(W,{client:e,flowName:y.name,refreshKey:h})]})]})}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)({}),[l,d]=(0,I.useState)(!1),[f,h]=(0,I.useState)(null),[g,_]=(0,I.useState)(null);(0,I.useEffect)(()=>{o({}),h(null),_(null)},[t?.name]);let v=(e,t)=>o(n=>({...n,[e]:t}));return(0,L.jsxs)(u,{children:[(0,L.jsxs)(p,{className:`pb-3`,children:[(0,L.jsx)(x,{className:`text-base`,children:`Test Run`}),(0,L.jsx)(N,{children:`Provide input values and invoke the flow`})]}),(0,L.jsxs)(m,{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)(E,{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)(S,{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)(F,{id:`var-${e.name}`,checked:a[e.name]===`true`,onCheckedChange:t=>v(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)(i,{id:`var-${e.name}`,placeholder:`JSON ${e.type}`,value:a[e.name]??``,onChange:t=>v(e.name,t.target.value),className:`font-mono text-xs min-h-[80px]`}):(0,L.jsx)(T,{id:`var-${e.name}`,type:e.type===`number`?`number`:`text`,value:a[e.name]??``,onChange:t=>v(e.name,t.target.value)})]},e.name)),(0,L.jsx)(`div`,{className:`pt-1`,children:(0,L.jsxs)(M,{onClick:async()=>{if(!e?.automation?.execute){_(`automation.execute is not available on this client`);return}d(!0),_(null),h(null);try{let i={};for(let e of r){let t=a[e.name];t!==void 0&&(i[e.name]=B(t,e.type))}h(await e.automation.execute(t.name,{params:i})),n?.()}catch(e){_(e?.message??String(e))}finally{d(!1)}},disabled:l,size:`sm`,children:[l?(0,L.jsx)(c,{className:`h-3.5 w-3.5 mr-2 animate-spin`}):(0,L.jsx)(s,{className:`h-3.5 w-3.5 mr-2`}),l?`Running…`:`Run Flow`]})}),(f||g)&&(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:[g||f?.success===!1?(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(b,{className:`h-4 w-4 text-red-500`}),` Failed`]}):(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(D,{className:`h-4 w-4 text-emerald-500`}),` Result`]}),typeof f?.durationMs==`number`&&(0,L.jsxs)(S,{variant:`secondary`,className:`text-[10px] font-mono`,children:[f.durationMs,` ms`]})]}),g&&(0,L.jsx)(`p`,{className:`text-sm text-red-500 font-mono break-all`,children:g}),f&&(0,L.jsx)(V,{data:f})]})]})]})}function W({client:e,flowName:t,refreshKey:n}){let[r,i]=(0,I.useState)([]),[s,d]=(0,I.useState)(!0),[v,b]=(0,I.useState)(null),[T,E]=(0,I.useState)(null),[D,A]=(0,I.useState)(null),[F,B]=(0,I.useState)(!1),[H,U]=(0,I.useState)(null),W=(0,I.useCallback)(async()=>{if(!e?.automation?.listRuns){b(`automation.listRuns is not available on this client`),d(!1);return}d(!0),b(null);try{let n=await e.automation.listRuns(t,{limit:20});i(Array.isArray(n)?n:n?.items??n?.runs??[])}catch(e){b(e?.message??String(e))}finally{d(!1)}},[e,t]);(0,I.useEffect)(()=>{W()},[W,n]);let G=async n=>{E(n),A(null),U(null),B(!0);try{let r=await e.automation.getRun(t,n);A(r?.run??r)}catch(e){U(e?.message??String(e))}finally{B(!1)}};return(0,L.jsxs)(L.Fragment,{children:[(0,L.jsxs)(u,{children:[(0,L.jsx)(p,{className:`pb-3`,children:(0,L.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,L.jsxs)(`div`,{children:[(0,L.jsx)(x,{className:`text-base`,children:`Recent Runs`}),(0,L.jsx)(N,{className:`font-mono text-xs`,children:t})]}),(0,L.jsxs)(M,{variant:`outline`,size:`sm`,onClick:W,disabled:s,children:[s?(0,L.jsx)(c,{className:`h-3.5 w-3.5 mr-2 animate-spin`}):(0,L.jsx)(a,{className:`h-3.5 w-3.5 mr-2`}),`Refresh`]})]})}),(0,L.jsxs)(m,{children:[s&&(0,L.jsxs)(`div`,{className:`space-y-2`,children:[(0,L.jsx)(o,{className:`h-8 w-full`}),(0,L.jsx)(o,{className:`h-8 w-full`}),(0,L.jsx)(o,{className:`h-8 w-full`})]}),!s&&v&&(0,L.jsx)(`p`,{className:`text-sm text-red-500 font-mono break-all`,children:v}),!s&&!v&&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&&!v&&r.length>0&&(0,L.jsxs)(O,{children:[(0,L.jsx)(w,{children:(0,L.jsxs)(k,{children:[(0,L.jsx)(P,{children:`Run`}),(0,L.jsx)(P,{children:`Status`}),(0,L.jsx)(P,{children:`Started`}),(0,L.jsx)(P,{className:`text-right`,children:`Duration`})]})}),(0,L.jsx)(C,{children:r.map(e=>(0,L.jsxs)(k,{className:`cursor-pointer`,onClick:()=>G(e.id),children:[(0,L.jsxs)(j,{className:`font-mono text-xs`,children:[e.id.slice(0,12),`…`]}),(0,L.jsx)(j,{children:(0,L.jsx)(R,{status:e.status})}),(0,L.jsx)(j,{className:`text-xs text-muted-foreground`,children:z(e.startedAt)}),(0,L.jsx)(j,{className:`text-right font-mono text-xs`,children:typeof e.durationMs==`number`?`${e.durationMs} ms`:`—`})]},e.id))})]})]})]}),(0,L.jsx)(h,{open:!!T,onOpenChange:e=>{e||(E(null),A(null))},children:(0,L.jsxs)(g,{side:`right`,className:`w-full sm:max-w-2xl p-0 flex flex-col`,children:[(0,L.jsxs)(l,{className:`p-4 border-b`,children:[(0,L.jsxs)(f,{className:`font-mono text-sm break-all`,children:[`Run `,T]}),(0,L.jsx)(_,{children:D&&(0,L.jsxs)(`span`,{className:`inline-flex items-center gap-2`,children:[(0,L.jsx)(R,{status:D.status}),typeof D.durationMs==`number`&&(0,L.jsxs)(S,{variant:`secondary`,className:`text-[10px] font-mono`,children:[D.durationMs,` ms`]}),(0,L.jsx)(`span`,{className:`text-xs`,children:z(D.startedAt)})]})})]}),(0,L.jsxs)(y,{className:`flex-1 p-4`,children:[F&&(0,L.jsxs)(`div`,{className:`space-y-2`,children:[(0,L.jsx)(o,{className:`h-16 w-full`}),(0,L.jsx)(o,{className:`h-16 w-full`}),(0,L.jsx)(o,{className:`h-16 w-full`})]}),H&&(0,L.jsx)(`p`,{className:`text-sm text-red-500 font-mono break-all`,children:H}),!F&&D&&(0,L.jsx)(`div`,{className:`space-y-3`,children:Array.isArray(D.steps)&&D.steps.length>0?D.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)(S,{variant:`outline`,className:`text-[10px] font-mono`,children:e.nodeType}),(0,L.jsx)(R,{status:e.status}),typeof e.durationMs==`number`&&(0,L.jsxs)(S,{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:D})]})})]})]})})]})}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-DR370ovB.js";import{w as r}from"./framework-CHiz03zG.js";import{Ai as i,Bn as a,Do as o,Fn as s,Gn as ee,In as c,Jn as te,Kn as ne,Ln as l,Ni as re,Ri as ie,Rn as u,Uo as ae,Yn as oe,Zn as se,at as ce,ct as le,en as d,gi as ue,in as f,it as de,ja as fe,lt as p,ot as m,pr as h,qn as pe,st as g,zn as _,zo as me}from"./ui-components-BbPoD3rS.js";import{r as v}from"./vendor-ui-utils-rQOI1gAo.js";import"./index-B_NAVTba.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)(ee,{children:[(0,b.jsxs)(te,{className:`flex flex-row items-start justify-between gap-4 space-y-0`,children:[(0,b.jsxs)(`div`,{children:[(0,b.jsxs)(oe,{className:`flex items-center gap-2`,children:[(0,b.jsx)(re,{className:`h-4 w-4`}),`Public Forms`]}),(0,b.jsx)(pe,{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)(h,{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)(ie,{className:`h-3.5 w-3.5`}),(0,b.jsx)(`span`,{className:`ml-1.5`,children:`Publish form…`})]}),(0,b.jsxs)(h,{variant:`outline`,size:`sm`,onClick:Y,disabled:C,children:[(0,b.jsx)(i,{className:`h-3.5 w-3.5 ${C?`animate-spin`:``}`}),(0,b.jsx)(`span`,{className:`ml-1.5`,children:`Refresh`})]})]})]}),(0,b.jsxs)(ne,{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)(de,{children:[(0,b.jsx)(le,{children:(0,b.jsxs)(p,{children:[(0,b.jsx)(g,{children:`Name`}),(0,b.jsx)(g,{children:`Object`}),(0,b.jsx)(g,{children:`Slug`}),(0,b.jsx)(g,{children:`Public URL`}),(0,b.jsx)(g,{className:`text-right`,children:`Actions`})]})}),(0,b.jsx)(ce,{children:t.map(e=>{let t=X(e.slug);return(0,b.jsxs)(p,{children:[(0,b.jsx)(m,{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)(m,{children:e.object?(0,b.jsx)(se,{variant:`secondary`,children:e.object}):(0,b.jsx)(`span`,{className:`text-muted-foreground`,children:`—`})}),(0,b.jsx)(m,{children:(0,b.jsx)(`code`,{className:`text-xs`,children:e.slug})}),(0,b.jsx)(m,{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)(o,{className:`h-3 w-3`})]})}),(0,b.jsx)(m,{className:`text-right`,children:(0,b.jsxs)(`div`,{className:`inline-flex gap-1`,children:[(0,b.jsx)(h,{variant:`ghost`,size:`sm`,title:`Copy URL`,onClick:()=>Q(`URL`,t),children:(0,b.jsx)(fe,{className:`h-3.5 w-3.5`})}),(0,b.jsx)(h,{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)(h,{variant:`ghost`,size:`sm`,title:`Copy React snippet`,onClick:()=>Q(`React snippet`,be(e.slug)),children:(0,b.jsx)(me,{className:`h-3.5 w-3.5`})}),(0,b.jsx)(h,{variant:`ghost`,size:`sm`,title:`Edit sharing & post-submit behavior`,onClick:()=>Se(e),children:(0,b.jsx)(ue,{className:`h-3.5 w-3.5`})})]})})]},e.name)})})]})]})]}),(0,b.jsx)(s,{open:_e,onOpenChange:D,children:(0,b.jsxs)(c,{className:`sm:max-w-md`,children:[(0,b.jsxs)(_,{children:[(0,b.jsx)(a,{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)(f,{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)(f,{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)(d,{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)(u,{children:[(0,b.jsx)(h,{variant:`ghost`,onClick:()=>D(!1),disabled:M,children:`Cancel`}),(0,b.jsx)(h,{onClick:xe,disabled:M||!O||!A,children:M?`Publishing…`:`Publish`})]})]})}),(0,b.jsx)(s,{open:ve,onOpenChange:P,children:(0,b.jsxs)(c,{className:`sm:max-w-lg`,children:[(0,b.jsxs)(_,{children:[(0,b.jsx)(a,{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)(f,{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)(d,{id:`edit-slug`,value:L,onChange:e=>R(e.target.value)})]})]}),(0,b.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,b.jsx)(f,{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)(f,{htmlFor:`edit-tytitle`,children:`Title`}),(0,b.jsx)(d,{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)(f,{htmlFor:`edit-tymsg`,children:`Message`}),(0,b.jsx)(d,{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)(f,{htmlFor:`edit-url`,children:`Redirect URL`}),(0,b.jsx)(d,{id:`edit-url`,type:`url`,placeholder:`https://example.com/thanks`,value:G,onChange:e=>K(e.target.value)})]})]}),(0,b.jsxs)(u,{children:[(0,b.jsx)(h,{variant:`ghost`,onClick:()=>P(!1),disabled:q,children:`Cancel`}),(0,b.jsx)(h,{onClick:Ce,disabled:q||!L,children:q?`Saving…`:`Save`})]})]})})]})}export{S as PublicFormsPage};
@@ -1 +0,0 @@
1
- import{o as e}from"./rolldown-runtime-CMxvf4Kt.js";import{_ as t,l as n,t as r}from"./vendor-react-DR370ovB.js";var i=e(t(),1),a=r(),o=(0,i.createContext)(!1),s=`preview`,c=`draft`;function l(e){return new URLSearchParams(e).get(s)===c}function u({force:e,children:t}){let r=n(),s=(0,i.useMemo)(()=>l(r.search),[r.search]);return(0,a.jsx)(o.Provider,{value:e??s,children:t})}function d(){return(0,i.useContext)(o)}var f=null,p=0,m=0,h=null,g={editor:f,openSeq:p,reviewSeq:m,reviewTarget:h},_=new Set;function v(){g={editor:f,openSeq:p,reviewSeq:m,reviewTarget:h};for(let e of _)e()}function y(e,t){return e===t?!0:JSON.stringify(e)===JSON.stringify(t)}var b={subscribe(e){return _.add(e),()=>{_.delete(e)}},getSnapshot(){return g},setEditor(e){y(f,e)||(f=e,v())},requestOpen(){p+=1,v()},requestReview(e){m+=1,h=e,v()}},x=new Set;function S(e){for(let t of x)t(e)}function C(e){return x.add(e),()=>{x.delete(e)}}function w(){return(0,i.useSyncExternalStore)(b.subscribe,b.getSnapshot,b.getSnapshot)}function T(e){(0,i.useEffect)(()=>(b.setEditor(e),()=>b.setEditor(null)),[e?JSON.stringify(e):``])}function E(){b.requestOpen()}function D(e){b.requestReview(e)}export{w as a,u as c,C as i,d as l,E as n,T as o,D as r,s,S as t};