@objectstack/console 7.0.0 → 7.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (53) hide show
  1. package/dist/assets/{AiPendingActionsPage-DLWrcsds.js → AiPendingActionsPage-DfPQB-bV.js} +1 -1
  2. package/dist/assets/{ApiConsolePage-BIBykAYj.js → ApiConsolePage-CVt86JW9.js} +1 -1
  3. package/dist/assets/{AppManagementPage-BKE0rv8B.js → AppManagementPage-DuIaI8a2.js} +1 -1
  4. package/dist/assets/ApprovalsInboxPage-BRv2RqN4.js +1 -0
  5. package/dist/assets/{AuditLogPage-Bqlhi2ko.js → AuditLogPage-CDXmY4Lg.js} +1 -1
  6. package/dist/assets/{ComponentNavView-DBMxrUvH.js → ComponentNavView-B2VAx_8W.js} +1 -1
  7. package/dist/assets/{ConsoleFloatingChatbot-CBIXkoNS.js → ConsoleFloatingChatbot-c1A9X4w7.js} +1 -1
  8. package/dist/assets/{DeveloperHubPage-C3Ooh2Gg.js → DeveloperHubPage-E4ydudW4.js} +1 -1
  9. package/dist/assets/{FlowRunsPage-NjEPPv_e.js → FlowRunsPage-CF-nkx9E.js} +1 -1
  10. package/dist/assets/ProfilePage-4wnWye8l.js +1 -0
  11. package/dist/assets/PublicFormsPage-B1cdfwoQ.js +1 -0
  12. package/dist/assets/{SettingsHub-BTNCNbjZ.js → SettingsHub-B4d9Pn8t.js} +1 -1
  13. package/dist/assets/{SettingsView-BLXf7B7b.js → SettingsView-cRQBVn6H.js} +1 -1
  14. package/dist/assets/{SystemHubPage-CgN-8VKO.js → SystemHubPage-DIKmhwy1.js} +1 -1
  15. package/dist/assets/{data-adapter-Dn6-L_yI.js → data-adapter-Be-s1kWX.js} +1 -1
  16. package/dist/assets/{highlighted-body-OFNGDK62-Dua_6VJ2.js → highlighted-body-OFNGDK62-Dynkkk0t.js} +1 -1
  17. package/dist/assets/index-D7iz-IIn.js +24 -0
  18. package/dist/assets/index-Db8Nmh4R.css +2 -0
  19. package/dist/assets/mermaid-GHXKKRXX-DJsGdxYj.js +1 -0
  20. package/dist/assets/plugin-calendar-wl24Whh9.js +1 -0
  21. package/dist/assets/{plugin-charts-C11LxM1X.js → plugin-charts-Mt2y8Sdm.js} +1 -1
  22. package/dist/assets/{plugin-chatbot-COnH_NZC.js → plugin-chatbot-DXGXTdLU.js} +29 -29
  23. package/dist/assets/plugin-dashboard-DqF5vvlQ.js +3 -0
  24. package/dist/assets/{plugin-form-f39dp3V2.js → plugin-form-BBc-xwrZ.js} +1 -1
  25. package/dist/assets/plugin-gantt-scBgVq2Q.js +1 -0
  26. package/dist/assets/plugin-grid-u5JmW5Ui.js +6 -0
  27. package/dist/assets/{plugin-kanban-q2UT5MlD.js → plugin-kanban-0qj1Kr3T.js} +1 -1
  28. package/dist/assets/{plugin-map-C6vgk2bJ.js → plugin-map-CjA33cHV.js} +1 -1
  29. package/dist/assets/{plugin-markdown-DPzm2nVd.js → plugin-markdown-BPsaoDf-.js} +1 -1
  30. package/dist/assets/plugin-report-C35V4A8F.js +59 -0
  31. package/dist/assets/{plugin-timeline-lCaTr_4i.js → plugin-timeline-Bmy8v-AN.js} +1 -1
  32. package/dist/assets/plugin-view-tV_8MnpT.js +1 -0
  33. package/dist/assets/plugins-views-DM6-O61C.js +4 -0
  34. package/dist/assets/{src-Con14F4e.js → src-BJJhwsID.js} +1 -1
  35. package/dist/assets/{types-CuyLcCWX.js → types-BsFD2pPK.js} +1 -1
  36. package/dist/assets/{ui-components-ZN8XdmwJ.js → ui-components-DYQ4Pai7.js} +7 -7
  37. package/dist/assets/{ui-layout-HiDSueut.js → ui-layout-Dmw4Ab7P.js} +1 -1
  38. package/dist/index.html +3 -3
  39. package/package.json +1 -1
  40. package/dist/assets/ApprovalsInboxPage-D7gF2CM8.js +0 -1
  41. package/dist/assets/ObjectManagerListPage-DEPokJwV.js +0 -1
  42. package/dist/assets/ProfilePage-zYSeu2-d.js +0 -1
  43. package/dist/assets/PublicFormsPage-BrLPiHf1.js +0 -1
  44. package/dist/assets/index-Ca4KaljM.js +0 -23
  45. package/dist/assets/index-DsQwZDFr.css +0 -2
  46. package/dist/assets/mermaid-GHXKKRXX-BvEKnLTo.js +0 -1
  47. package/dist/assets/plugin-calendar-Dnr7itgk.js +0 -1
  48. package/dist/assets/plugin-dashboard-DvBectcr.js +0 -3
  49. package/dist/assets/plugin-gantt-7ui7uiVc.js +0 -1
  50. package/dist/assets/plugin-grid-DtceFt_J.js +0 -6
  51. package/dist/assets/plugin-report-BJM4LH87.js +0 -59
  52. package/dist/assets/plugin-view-b7gS6gIn.js +0 -1
  53. package/dist/assets/plugins-views-Dvl7pQvR.js +0 -4
@@ -1 +1 @@
1
- import{o as e}from"./rolldown-runtime-CMxvf4Kt.js";import{a as t,g as n,l as r,r as i}from"./vendor-react-CIpZOxG3.js";import{Ct as a,Di as o,Gr as s,Hn as c,J as l,La as u,Lt as d,Oa as f,Oi as p,Qn as m,St as h,Un as g,Wn as _,Zo as v,_o as y,bt as b,gt as x,ht as S,mt as C,vt as w,xt as T,yt as E}from"./ui-components-ZN8XdmwJ.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-0jp7h5ty.js";var R=e(n(),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:o}){return W(o,o?.title),(0,z.jsxs)(a,{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)(w,{className:`min-w-0`,children:(0,z.jsx)(`main`,{className:v(`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?l(e):u}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 Y=e=>!(e===!1||e===`false`),X=()=>!0,Z=()=>!0,ee=/\{(current_user_id|current_org_id)\}/g;function te(e,t){if(!e.includes(`{`))return e;let n=!1,r=e.replace(ee,(e,r)=>(r===`current_user_id`?t?.currentUserId:t?.currentOrgId)||(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=te(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=te(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 n=e.componentRef;if(!n)return{href:`#`,external:!1};let r=n.split(`:`).filter(Boolean);if(r.length===0)return{href:`#`,external:!1};let i=e.params;if(r[0]===`metadata`){let e=r[1],n=i&&typeof i.type==`string`?i.type:void 0,a=i&&typeof i.name==`string`?i.name:void 0;return e===`directory`||!e?{href:`${t}/metadata`,external:!1}:e===`resource`&&n?{href:`${t}/metadata${a?`/${encodeURIComponent(n)}/${encodeURIComponent(a)}`:`/${encodeURIComponent(n)}`}`,external:!1}:{href:`${t}/metadata`,external:!1}}let a=`${t}/component/${r.join(`/`)}`;if(i&&typeof i==`object`){let e=new URLSearchParams;for(let[t,n]of Object.entries(i))n!=null&&e.set(t,typeof n==`string`?n:JSON.stringify(n));let t=e.toString();t&&(a+=`?${t}`)}return{href:a,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:n,evalVis:i,checkPerm:a,checkCap:s,onAction:l,enablePinning:u,onPinToggle:v,dragListeners:w,resolveObjectLabel:D,resolveDashboardLabel:O,resolveGroupLabel:k,resolveViewLabel:A,resolveItemLabel:j,t:M,templateContext:N}){let P=r(),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 t=e=>{if(!e)return!1;for(let r of e){if(r.type===`group`){if(t(r.children))return!0;continue}let{href:e}=Q(r,n,N);if(ne(r,e,P.pathname))return!0}return!1};return t(e.children)},[e,n,P.pathname])?!0:F??!(I>=8));if(!i(e.visible)||e.requiredPermissions?.length&&!a(e.requiredPermissions))return null;let V=e.requiresObject,H=e.requiresService;if(V&&!s(`object`,V)||H&&!s(`service`,H))return null;if(e.type===`separator`)return(0,z.jsx)(d,{className:`my-2`});if(e.type===`group`){let t=(e.children??[]).slice().sort((e,t)=>(e.order??0)-(t.order??0));return(0,z.jsx)(c,{open:L,onOpenChange:B,children:(0,z.jsxs)(C,{children:[(0,z.jsx)(x,{asChild:!0,children:(0,z.jsxs)(_,{className:`flex w-full items-center justify-between`,children:[J(e,D,M,O,k,A,j),(0,z.jsx)(y,{className:`ml-auto h-4 w-4 transition-transform ${L?`rotate-90`:``}`})]})}),(0,z.jsx)(g,{children:(0,z.jsx)(S,{children:(0,z.jsx)(E,{children:t.map(e=>(0,z.jsx)($,{item:e,basePath:n,evalVis:i,checkPerm:a,checkCap:s,onAction:l,enablePinning:u,onPinToggle:v,resolveObjectLabel:D,resolveDashboardLabel:O,resolveGroupLabel:k,resolveViewLabel:A,resolveItemLabel:j,t:M,templateContext:N},e.id))})})})]})})}if(e.type===`action`){let t=K(e.icon),r=q(e.label,M);return(0,z.jsxs)(h,{children:[w&&(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`,...w,children:(0,z.jsx)(f,{className:`h-3.5 w-3.5`})}),(0,z.jsxs)(T,{tooltip:r,onClick:()=>l?.(e),children:[(0,z.jsx)(t,{className:`h-4 w-4`}),(0,z.jsx)(`span`,{children:r}),e.badge!=null&&(0,z.jsx)(m,{variant:e.badgeVariant??`default`,className:`ml-auto text-[10px] px-1.5 py-0`,children:e.badge})]}),u&&v&&(0,z.jsx)(b,{showOnHover:!0,onClick:()=>v(e.id,!e.pinned,e,n),"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,n,N),Y=ne(e,W,P.pathname),X=J(e,D,M,O,k,A,j),Z=(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(U,{className:`h-4 w-4`}),(0,z.jsx)(`span`,{children:X}),e.badge!=null&&(0,z.jsx)(m,{variant:e.badgeVariant??`default`,className:`ml-auto text-[10px] px-1.5 py-0`,children:e.badge})]});return(0,z.jsxs)(h,{children:[w&&(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`,...w,children:(0,z.jsx)(f,{className:`h-3.5 w-3.5`})}),(0,z.jsx)(T,{asChild:!0,isActive:Y,tooltip:X,children:G?(0,z.jsx)(`a`,{href:W,target:`_blank`,rel:`noopener noreferrer`,children:Z}):(0,z.jsx)(t,{to:W,children:Z})}),u&&v&&(0,z.jsx)(b,{showOnHover:!0,onClick:()=>v(e.id,!e.pinned,e,n),"aria-label":M?M(e.pinned?`console.nav.unpinItem`:`console.nav.pinItem`,{defaultValue:e.pinned?`Unpin ${X}`:`Pin ${X}`,name:X}):e.pinned?`Unpin ${X}`:`Pin ${X}`,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=Y,checkPermission:r=X,checkCapability:i=Z,onAction:a,searchQuery:o,enablePinning:c,onPinToggle:l,enableReorder:u,onReorder:d,resolveObjectLabel:f,resolveDashboardLabel:p,resolveGroupLabel:m,resolveViewLabel:h,resolveItemLabel:g,t:_,templateContext:v}){let y=(0,R.useMemo)(()=>o?re(e,o):e,[e,o]),b=(0,R.useMemo)(()=>se(y),[y]),w=y.slice().sort((e,t)=>(e.order??0)-(t.order??0)),T=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=w.findIndex(e=>e.id===t.id),i=w.findIndex(e=>e.id===n.id);r===-1||i===-1||d(M(w,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:_,templateContext:v},B=w.some(e=>e.type===`group`),V=b.length>0&&c?(0,z.jsxs)(C,{children:[(0,z.jsxs)(x,{className:`flex items-center gap-1.5`,children:[(0,z.jsx)(s,{className:`h-3.5 w-3.5`}),_?_(`console.nav.favorites`,{defaultValue:`Favorites`}):`Favorites`]}),(0,z.jsx)(S,{children:(0,z.jsx)(E,{children:b.map(e=>(0,z.jsx)($,{item:e,...N},`fav-${e.id}`))})})]}):null;if(!B){let e=w.filter(e=>e.type!==`group`).map(e=>e.id);return(0,z.jsxs)(z.Fragment,{children:[V,(0,z.jsx)(C,{children:(0,z.jsx)(S,{children:u?(0,z.jsx)(O,{sensors:T,collisionDetection:P,onDragEnd:D,children:(0,z.jsx)(I,{items:e,strategy:F,children:(0,z.jsx)(E,{children:w.map(e=>(0,z.jsx)(ae,{item:e,enableReorder:u,...N},e.id))})})}):(0,z.jsx)(E,{children:w.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)(C,{children:(0,z.jsx)(S,{children:(0,z.jsx)(E,{children:t.map(e=>(0,z.jsx)($,{item:e,...N},e.id))})})},e))};return w.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{a as t,g as n,l as r,r as i}from"./vendor-react-CIpZOxG3.js";import{Aa as a,Ct as o,Hn as s,J as c,Kr as l,Lt as u,Oi as d,Qn as f,St as p,Un as m,Wn as h,bo as g,bt as _,es as v,gt as y,ht as b,ki as x,mt as S,vt as C,xt as w,yt as T,za as E}from"./ui-components-DYQ4Pai7.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-0jp7h5ty.js";var R=e(n(),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)(o,{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)(C,{className:`min-w-0`,children:(0,z.jsx)(`main`,{className:v(`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?c(e):E}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 Y=e=>!(e===!1||e===`false`),X=()=>!0,Z=()=>!0,ee=/\{(current_user_id|current_org_id)\}/g;function te(e,t){if(!e.includes(`{`))return e;let n=!1,r=e.replace(ee,(e,r)=>(r===`current_user_id`?t?.currentUserId:t?.currentOrgId)||(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=te(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=te(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 n=e.componentRef;if(!n)return{href:`#`,external:!1};let r=n.split(`:`).filter(Boolean);if(r.length===0)return{href:`#`,external:!1};let i=e.params;if(r[0]===`metadata`){let e=r[1],n=i&&typeof i.type==`string`?i.type:void 0,a=i&&typeof i.name==`string`?i.name:void 0;return e===`directory`||!e?{href:`${t}/metadata`,external:!1}:e===`resource`&&n?{href:`${t}/metadata${a?`/${encodeURIComponent(n)}/${encodeURIComponent(a)}`:`/${encodeURIComponent(n)}`}`,external:!1}:{href:`${t}/metadata`,external:!1}}let a=`${t}/component/${r.join(`/`)}`;if(i&&typeof i==`object`){let e=new URLSearchParams;for(let[t,n]of Object.entries(i))n!=null&&e.set(t,typeof n==`string`?n:JSON.stringify(n));let t=e.toString();t&&(a+=`?${t}`)}return{href:a,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:n,evalVis:i,checkPerm:o,checkCap:c,onAction:l,enablePinning:v,onPinToggle:C,dragListeners:E,resolveObjectLabel:D,resolveDashboardLabel:O,resolveGroupLabel:k,resolveViewLabel:A,resolveItemLabel:j,t:M,templateContext:N}){let P=r(),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 t=e=>{if(!e)return!1;for(let r of e){if(r.type===`group`){if(t(r.children))return!0;continue}let{href:e}=Q(r,n,N);if(ne(r,e,P.pathname))return!0}return!1};return t(e.children)},[e,n,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&&!c(`object`,V)||H&&!c(`service`,H))return null;if(e.type===`separator`)return(0,z.jsx)(u,{className:`my-2`});if(e.type===`group`){let t=(e.children??[]).slice().sort((e,t)=>(e.order??0)-(t.order??0));return(0,z.jsx)(s,{open:L,onOpenChange:B,children:(0,z.jsxs)(S,{children:[(0,z.jsx)(y,{asChild:!0,children:(0,z.jsxs)(h,{className:`flex w-full items-center justify-between`,children:[J(e,D,M,O,k,A,j),(0,z.jsx)(g,{className:`ml-auto h-4 w-4 transition-transform ${L?`rotate-90`:``}`})]})}),(0,z.jsx)(m,{children:(0,z.jsx)(b,{children:(0,z.jsx)(T,{children:t.map(e=>(0,z.jsx)($,{item:e,basePath:n,evalVis:i,checkPerm:o,checkCap:c,onAction:l,enablePinning:v,onPinToggle:C,resolveObjectLabel:D,resolveDashboardLabel:O,resolveGroupLabel:k,resolveViewLabel:A,resolveItemLabel:j,t:M,templateContext:N},e.id))})})})]})})}if(e.type===`action`){let t=K(e.icon),r=q(e.label,M);return(0,z.jsxs)(p,{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)(w,{tooltip:r,onClick:()=>l?.(e),children:[(0,z.jsx)(t,{className:`h-4 w-4`}),(0,z.jsx)(`span`,{children:r}),e.badge!=null&&(0,z.jsx)(f,{variant:e.badgeVariant??`default`,className:`ml-auto text-[10px] px-1.5 py-0`,children:e.badge})]}),v&&C&&(0,z.jsx)(_,{showOnHover:!0,onClick:()=>C(e.id,!e.pinned,e,n),"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)(x,{className:`h-3.5 w-3.5`}):(0,z.jsx)(d,{className:`h-3.5 w-3.5`})})]})}let U=K(e.icon),{href:W,external:G}=Q(e,n,N),Y=ne(e,W,P.pathname),X=J(e,D,M,O,k,A,j),Z=(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(U,{className:`h-4 w-4`}),(0,z.jsx)(`span`,{children:X}),e.badge!=null&&(0,z.jsx)(f,{variant:e.badgeVariant??`default`,className:`ml-auto text-[10px] px-1.5 py-0`,children:e.badge})]});return(0,z.jsxs)(p,{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)(w,{asChild:!0,isActive:Y,tooltip:X,children:G?(0,z.jsx)(`a`,{href:W,target:`_blank`,rel:`noopener noreferrer`,children:Z}):(0,z.jsx)(t,{to:W,children:Z})}),v&&C&&(0,z.jsx)(_,{showOnHover:!0,onClick:()=>C(e.id,!e.pinned,e,n),"aria-label":M?M(e.pinned?`console.nav.unpinItem`:`console.nav.pinItem`,{defaultValue:e.pinned?`Unpin ${X}`:`Pin ${X}`,name:X}):e.pinned?`Unpin ${X}`:`Pin ${X}`,children:e.pinned?(0,z.jsx)(x,{className:`h-3.5 w-3.5`}):(0,z.jsx)(d,{className:`h-3.5 w-3.5`})})]})}function oe({items:e,basePath:t=``,evaluateVisibility:n=Y,checkPermission:r=X,checkCapability:i=Z,onAction:a,searchQuery:o,enablePinning:s,onPinToggle:c,enableReorder:u,onReorder:d,resolveObjectLabel:f,resolveDashboardLabel:p,resolveGroupLabel:m,resolveViewLabel:h,resolveItemLabel:g,t:_,templateContext:v}){let x=(0,R.useMemo)(()=>o?re(e,o):e,[e,o]),C=(0,R.useMemo)(()=>se(x),[x]),w=x.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=w.findIndex(e=>e.id===t.id),i=w.findIndex(e=>e.id===n.id);r===-1||i===-1||d(M(w,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=w.some(e=>e.type===`group`),V=C.length>0&&s?(0,z.jsxs)(S,{children:[(0,z.jsxs)(y,{className:`flex items-center gap-1.5`,children:[(0,z.jsx)(l,{className:`h-3.5 w-3.5`}),_?_(`console.nav.favorites`,{defaultValue:`Favorites`}):`Favorites`]}),(0,z.jsx)(b,{children:(0,z.jsx)(T,{children:C.map(e=>(0,z.jsx)($,{item:e,...N},`fav-${e.id}`))})})]}):null;if(!B){let e=w.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)(b,{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)(T,{children:w.map(e=>(0,z.jsx)(ae,{item:e,enableReorder:u,...N},e.id))})})}):(0,z.jsx)(T,{children:w.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)(b,{children:(0,z.jsx)(T,{children:t.map(e=>(0,z.jsx)($,{item:e,...N},e.id))})})},e))};return w.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-Ca4KaljM.js"></script>
21
+ <script type="module" crossorigin src="./assets/index-D7iz-IIn.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-DsQwZDFr.css">
24
+ <link rel="stylesheet" crossorigin href="./assets/index-Db8Nmh4R.css">
25
25
  <link rel="modulepreload" href="./assets/framework-ClI3DbWX.js" />
26
- <link rel="modulepreload" href="./assets/ui-components-ZN8XdmwJ.js" />
26
+ <link rel="modulepreload" href="./assets/ui-components-DYQ4Pai7.js" />
27
27
  <link rel="modulepreload" href="./assets/vendor-radix-BNWIlSsV.js" />
28
28
  <link rel="modulepreload" href="./assets/vendor-react-CIpZOxG3.js" />
29
29
  </head>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@objectstack/console",
3
- "version": "7.0.0",
3
+ "version": "7.1.0",
4
4
  "description": "Prebuilt Console SPA pinned to this @objectstack/framework release. Source of truth: @object-ui/console (https://github.com/objectstack-ai/objectui).",
5
5
  "license": "Apache-2.0",
6
6
  "homepage": "https://github.com/objectstack-ai/framework/tree/main/packages/console",
@@ -1 +0,0 @@
1
- import{o as e}from"./rolldown-runtime-CMxvf4Kt.js";import{g as t,r as n}from"./vendor-react-CIpZOxG3.js";import{l as r}from"./infrastructure-ezj3FgNE.js";import{$ as i,At as a,Bt as o,F as ee,Ft as te,Gn as ne,Ht as s,I as re,It as ie,Kn as ae,Lt as c,Mt as oe,Nt as se,Pt as ce,Q as le,Qa as ue,Qn as l,Rt as de,Vt as fe,Xr as pe,ar as me,at as u,br as he,cr as ge,ct as _e,dr as ve,en as ye,et as be,fr as xe,ho as Se,in as Ce,it as we,kr as Te,li as Ee,lr as De,mr as d,nr as Oe,nt as f,or as p,ot as m,po as ke,pr as Ae,qn as je,ro as Me,rr as Ne,rt as Pe,so as Fe,sr as Ie,st as Le,tt as Re,ur as ze,vi as Be,z as Ve,zt as He}from"./ui-components-ZN8XdmwJ.js";import{o as h}from"./vendor-ui-utils-D3GsyZyi.js";var g=e(t(),1),_=`${``.replace(/\/$/,``)}/api/v1`;async function v(e,t){let n=await fetch(`${_}${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),e.approverId&&t.set(`approverId`,e.approverId),e.submitterId&&t.set(`submitterId`,e.submitterId);let n=t.toString();return v(`/approvals/requests${n?`?${n}`:``}`)},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){let n=await v(`/approvals/requests/${encodeURIComponent(e)}/recall`,{method:`POST`,body:JSON.stringify(t)});return{data:n.request,finalized:n.finalized}},async submit(e){return v(`/approvals/requests`,{method:`POST`,body:JSON.stringify(e)})}};function Ue(e){if(!e)return[];let t=new Set;e.id&&t.add(e.id),e.email&&t.add(e.email);for(let n of e.roles||[])n&&t.add(`role:${n}`);return Array.from(t)}var b=n(),x={pending:{variant:`secondary`,label:`Pending`},approved:{variant:`default`,label:`Approved`},rejected:{variant:`destructive`,label:`Rejected`},recalled:{variant:`outline`,label:`Recalled`}};function S({status:e}){let t=x[e]??{variant:`outline`,label:e};return(0,b.jsx)(l,{variant:t.variant,children:t.label})}function C(e){if(!e)return`—`;try{return new Date(e).toLocaleString()}catch{return e}}function w(e){if(!e)return`—`;let t=Date.parse(e);if(Number.isNaN(t))return e;let n=Date.now()-t,r=Math.round(n/1e3);if(r<45)return`just now`;let i=Math.round(r/60);if(i<60)return`${i}m ago`;let a=Math.round(i/60);if(a<24)return`${a}h ago`;let o=Math.round(a/24);if(o<30)return`${o}d ago`;try{return new Date(e).toLocaleDateString()}catch{return e}}function T(e){return e?e.includes(`@`)?e:e.startsWith(`role:`)?`Role: ${e.slice(5)}`:e.length>14?`${e.slice(0,6)}…${e.slice(-4)}`:e:`—`}function E(){let{user:e}=r(),t=(0,g.useMemo)(()=>Ue(e),[e]),[n,_]=(0,g.useState)(`pending`),[v,x]=(0,g.useState)([]),[E,D]=(0,g.useState)(!1),[O,k]=(0,g.useState)(null),[We,A]=(0,g.useState)(null),[j,M]=(0,g.useState)(null),[Ge,N]=(0,g.useState)([]),[Ke,qe]=(0,g.useState)(!1),[P,F]=(0,g.useState)(``),[I,L]=(0,g.useState)(``),[R,Je]=(0,g.useState)(null),[z,Ye]=(0,g.useState)(``),[B,Xe]=(0,g.useState)(`all`),[V,Ze]=(0,g.useState)(`all`),[H,U]=(0,g.useState)(new Set),[W,G]=(0,g.useState)(!1),K=(0,g.useCallback)(async()=>{D(!0),k(null);try{let r=[];if(n===`pending`){let e=new Set;if(t.length===0){let e=await y.listRequests({status:`pending`});for(let t of e.data)r.push(t)}else for(let n of t){let t=await y.listRequests({status:`pending`,approverId:n});for(let n of t.data)e.has(n.id)||(e.add(n.id),r.push(n))}}else if(n===`submitted`){let t=e?.id;if(!t){x([]),D(!1);return}let n=await y.listRequests({submitterId:t});r.push(...n.data)}else{let e=await y.listRequests({});r.push(...e.data)}r.sort((e,t)=>(t.submitted_at||``).localeCompare(e.submitted_at||``)),x(r)}catch(e){k(e?.message||String(e)),x([])}finally{D(!1)}},[n,t,e?.id]);(0,g.useEffect)(()=>{K()},[K]);let Qe=(0,g.useCallback)(async e=>{A(e),qe(!0),F(``),L(``);try{let[t,n]=await Promise.all([y.getRequest(e),y.listActions(e)]);M(t.data),N(n.data)}catch(e){h.error(e?.message||`Failed to load request`),M(null),N([])}finally{qe(!1)}},[]),$e=()=>{A(null),M(null),N([]),F(``),L(``)},q=(0,g.useCallback)(n=>{if(I.trim())return I.trim();if(!n)return e?.id||``;let r=new Set(n.pending_approvers||[]);for(let e of t)if(r.has(e))return e;return e?.id||``},[I,t,e?.id]),J=(0,g.useCallback)(async e=>{if(!j)return;let t=q(j);if(!t){h.error(`Cannot determine actor id`);return}Je(e);try{let n={actor_id:t,comment:P.trim()||void 0},r=await(e===`approve`?y.approve:e===`reject`?y.reject:y.recall)(j.id,n);h.success(e===`approve`?r.finalized?`Approved (finalized)`:`Approved — advanced to next step`:e===`reject`?r.finalized?`Rejected`:`Rejected — returned to previous step`:`Recalled`),F(``);let[i,a]=await Promise.all([y.getRequest(j.id),y.listActions(j.id)]);M(i.data),N(a.data),K()}catch(t){h.error(t?.message||`Failed to ${e}`)}finally{Je(null)}},[j,q,P,K]),Y=(0,g.useMemo)(()=>{if(!j||j.status!==`pending`)return!1;let e=new Set(j.pending_approvers||[]);return t.some(t=>e.has(t))||I.trim().length>0},[j,t,I]),et=(0,g.useMemo)(()=>!j||j.status!==`pending`?!1:j.submitter_id===e?.id||I.trim().length>0,[j,e?.id,I]),tt=(0,g.useMemo)(()=>v.filter(e=>e.status===`pending`).length,[v]),nt=(0,g.useMemo)(()=>{let e=new Set;for(let t of v)t.process_name&&e.add(t.process_name);return Array.from(e).sort()},[v]),rt=(0,g.useMemo)(()=>{let e=new Set;for(let t of v)t.object_name&&e.add(t.object_name);return Array.from(e).sort()},[v]),X=(0,g.useMemo)(()=>{let e=z.trim().toLowerCase();return v.filter(t=>B!==`all`&&t.process_name!==B||V!==`all`&&t.object_name!==V?!1:e?[t.process_name,t.object_name,t.record_id,t.submitter_id,...t.pending_approvers||[]].filter(Boolean).join(` `).toLowerCase().includes(e):!0)},[v,z,B,V]);(0,g.useEffect)(()=>{if(H.size===0)return;let e=new Set(X.map(e=>e.id)),t=!1,n=new Set;for(let r of H)e.has(r)?n.add(r):t=!0;t&&U(n)},[X,H]);let Z=(0,g.useMemo)(()=>{let e=new Set(t);return X.filter(t=>H.has(t.id)&&t.status===`pending`&&(t.pending_approvers||[]).some(t=>e.has(t)))},[X,H,t]),Q=X.filter(e=>e.status===`pending`),$=Q.length>0&&Q.every(e=>H.has(e.id)),it=(0,g.useCallback)(()=>{U(e=>{if($)return new Set;let t=new Set(e);for(let e of Q)t.add(e.id);return t})},[$,Q]),at=(0,g.useCallback)(e=>{U(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[]),ot=(0,g.useCallback)(async n=>{let r=Z;if(r.length===0)return;G(!0);let i=0,a=0;for(let o of r){let r=new Set(o.pending_approvers||[]),ee=t.find(e=>r.has(e))||e?.id||``;try{await(n===`approve`?y.approve:y.reject)(o.id,{actor_id:ee}),i++}catch{a++}}G(!1),U(new Set),a===0?h.success(`${n===`approve`?`Approved`:`Rejected`} ${i} request${i===1?``:`s`}`):h.error(`${i} succeeded, ${a} failed`),K()},[Z,t,e?.id,K]);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)(pe,{className:`h-6 w-6`}),`Approvals Inbox`]}),(0,b.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Review and act on multi-step approval requests.`})]}),(0,b.jsxs)(d,{variant:`outline`,size:`sm`,onClick:K,disabled:E,children:[(0,b.jsx)(Be,{className:`h-4 w-4 mr-2 ${E?`animate-spin`:``}`}),`Refresh`]})]}),O&&(0,b.jsxs)(Oe,{variant:`destructive`,children:[(0,b.jsx)(Se,{className:`h-4 w-4`}),(0,b.jsx)(Ne,{children:O})]}),(0,b.jsxs)(i,{value:n,onValueChange:e=>_(e),children:[(0,b.jsxs)(Re,{children:[(0,b.jsxs)(f,{value:`pending`,children:[`My Pending`,tt>0&&(0,b.jsx)(l,{variant:`secondary`,className:`ml-2`,children:tt})]}),(0,b.jsx)(f,{value:`submitted`,children:`Submitted by me`}),(0,b.jsx)(f,{value:`all`,children:`All`})]}),(0,b.jsxs)(be,{value:n,className:`mt-4 space-y-3`,children:[!E&&v.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)(Ee,{className:`absolute left-2.5 top-1/2 -translate-y-1/2 h-3.5 w-3.5 text-muted-foreground`}),(0,b.jsx)(ye,{value:z,onChange:e=>Ye(e.target.value),placeholder:`Search process, record, approver…`,className:`pl-8 h-8 text-sm`}),z&&(0,b.jsx)(`button`,{type:`button`,onClick:()=>Ye(``),className:`absolute right-2 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground`,"aria-label":`Clear search`,children:(0,b.jsx)(he,{className:`h-3.5 w-3.5`})})]}),nt.length>1&&(0,b.jsxs)(de,{value:B,onValueChange:Xe,children:[(0,b.jsx)(fe,{className:`h-8 w-auto min-w-[140px] text-sm`,children:(0,b.jsx)(s,{placeholder:`Process`})}),(0,b.jsxs)(He,{children:[(0,b.jsx)(o,{value:`all`,children:`All processes`}),nt.map(e=>(0,b.jsx)(o,{value:e,children:e},e))]})]}),rt.length>1&&(0,b.jsxs)(de,{value:V,onValueChange:Ze,children:[(0,b.jsx)(fe,{className:`h-8 w-auto min-w-[140px] text-sm`,children:(0,b.jsx)(s,{placeholder:`Object`})}),(0,b.jsxs)(He,{children:[(0,b.jsx)(o,{value:`all`,children:`All objects`}),rt.map(e=>(0,b.jsx)(o,{value:e,children:e},e))]})]}),(z||B!==`all`||V!==`all`)&&(0,b.jsxs)(`span`,{className:`text-xs text-muted-foreground`,children:[X.length,` of `,v.length]})]}),n===`pending`&&H.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:H.size}),` selected`,Z.length!==H.size&&(0,b.jsxs)(`span`,{className:`text-muted-foreground ml-1`,children:[`(`,Z.length,` actionable)`]})]}),(0,b.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,b.jsxs)(d,{size:`sm`,onClick:()=>ot(`approve`),disabled:W||Z.length===0,children:[(0,b.jsx)(ke,{className:`h-3.5 w-3.5 mr-1`}),`Approve `,Z.length||``]}),(0,b.jsxs)(me,{children:[(0,b.jsx)(Ae,{asChild:!0,children:(0,b.jsxs)(d,{size:`sm`,variant:`outline`,disabled:W||Z.length===0,className:`border-destructive text-destructive hover:bg-destructive hover:text-destructive-foreground`,children:[(0,b.jsx)(Fe,{className:`h-3.5 w-3.5 mr-1`}),`Reject `,Z.length||``]})}),(0,b.jsxs)(ge,{children:[(0,b.jsxs)(ve,{children:[(0,b.jsxs)(xe,{children:[`Reject `,Z.length,` requests?`]}),(0,b.jsx)(De,{children:`This will reject the selected requests and notify their submitters.`})]}),(0,b.jsxs)(ze,{children:[(0,b.jsx)(Ie,{children:`Cancel`}),(0,b.jsxs)(p,{onClick:()=>ot(`reject`),className:`bg-destructive text-destructive-foreground hover:bg-destructive/90`,children:[`Reject `,Z.length]})]})]})]}),(0,b.jsx)(d,{size:`sm`,variant:`ghost`,onClick:()=>U(new Set),disabled:W,children:`Clear`})]})]}),E?(0,b.jsxs)(`div`,{className:`space-y-2`,children:[(0,b.jsx)(a,{className:`h-10 w-full`}),(0,b.jsx)(a,{className:`h-10 w-full`}),(0,b.jsx)(a,{className:`h-10 w-full`})]}):v.length===0?(0,b.jsx)(`div`,{className:`flex items-center justify-center min-h-[240px] rounded-md border border-dashed`,children:(0,b.jsxs)(ee,{children:[(0,b.jsx)(Ve,{children:`No requests`}),(0,b.jsx)(re,{children:n===`pending`?`You have no pending approvals.`:`Nothing here yet.`})]})}):X.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:`No matches for current filters.`}):(0,b.jsx)(ae,{children:(0,b.jsx)(je,{className:`p-0`,children:(0,b.jsxs)(Pe,{children:[(0,b.jsx)(Le,{children:(0,b.jsxs)(_e,{children:[n===`pending`&&(0,b.jsx)(m,{className:`w-10`,children:(0,b.jsx)(ne,{checked:$,onCheckedChange:it,"aria-label":`Select all`,disabled:Q.length===0})}),(0,b.jsx)(m,{children:`Process`}),(0,b.jsx)(m,{children:`Object`}),(0,b.jsx)(m,{children:`Record`}),(0,b.jsx)(m,{children:`Step`}),(0,b.jsx)(m,{children:`Status`}),(0,b.jsx)(m,{children:`Approvers`}),(0,b.jsx)(m,{children:`Submitted`})]})}),(0,b.jsx)(we,{children:X.map(e=>(0,b.jsxs)(_e,{className:`cursor-pointer hover:bg-accent/50`,onClick:()=>Qe(e.id),children:[n===`pending`&&(0,b.jsx)(u,{className:`w-10`,onClick:e=>e.stopPropagation(),children:(0,b.jsx)(ne,{checked:H.has(e.id),onCheckedChange:()=>at(e.id),disabled:e.status!==`pending`,"aria-label":`Select request ${e.id}`})}),(0,b.jsx)(u,{className:`font-medium`,children:e.process_name}),(0,b.jsx)(u,{children:e.object_name}),(0,b.jsx)(u,{className:`font-mono text-xs`,title:e.record_id,children:T(e.record_id)}),(0,b.jsx)(u,{children:e.current_step?(0,b.jsxs)(`span`,{className:`text-xs`,children:[e.current_step,typeof e.current_step_index==`number`&&(0,b.jsxs)(`span`,{className:`text-muted-foreground`,children:[` (#`,e.current_step_index,`)`]})]}):`—`}),(0,b.jsx)(u,{children:(0,b.jsx)(S,{status:e.status})}),(0,b.jsx)(u,{className:`max-w-[220px] truncate text-xs text-muted-foreground`,title:(e.pending_approvers||[]).join(`, `),children:(e.pending_approvers||[]).map(T).join(`, `)||`—`}),(0,b.jsxs)(u,{className:`text-xs whitespace-nowrap text-muted-foreground`,title:C(e.submitted_at),children:[(0,b.jsx)(Me,{className:`h-3 w-3 inline mr-1`}),w(e.submitted_at)]})]},e.id))})]})})})]})]}),(0,b.jsx)(oe,{open:!!We,onOpenChange:e=>!e&&$e(),children:(0,b.jsxs)(se,{className:`w-full sm:max-w-xl overflow-y-auto`,children:[(0,b.jsxs)(te,{children:[(0,b.jsx)(ie,{children:`Approval Request`}),(0,b.jsx)(ce,{children:j?`${j.process_name} · ${j.object_name}/${j.record_id}`:``})]}),Ke?(0,b.jsxs)(`div`,{className:`space-y-2 mt-6`,children:[(0,b.jsx)(a,{className:`h-6 w-3/4`}),(0,b.jsx)(a,{className:`h-6 w-1/2`}),(0,b.jsx)(a,{className:`h-20 w-full`})]}):j?(0,b.jsxs)(`div`,{className:`space-y-4 mt-6`,children:[(0,b.jsxs)(`div`,{className:`grid grid-cols-2 gap-3 text-sm`,children:[(0,b.jsxs)(`div`,{children:[(0,b.jsx)(`div`,{className:`text-muted-foreground text-xs`,children:`Status`}),(0,b.jsx)(S,{status:j.status})]}),(0,b.jsxs)(`div`,{children:[(0,b.jsx)(`div`,{className:`text-muted-foreground text-xs`,children:`Current Step`}),j.current_step||`—`]}),(0,b.jsxs)(`div`,{children:[(0,b.jsx)(`div`,{className:`text-muted-foreground text-xs`,children:`Step Index`}),j.current_step_index??`—`]}),(0,b.jsxs)(`div`,{children:[(0,b.jsx)(`div`,{className:`text-muted-foreground text-xs`,children:`Submitter`}),(0,b.jsx)(`span`,{className:`font-mono text-xs`,title:j.submitter_id||``,children:T(j.submitter_id)})]}),(0,b.jsxs)(`div`,{children:[(0,b.jsx)(`div`,{className:`text-muted-foreground text-xs`,children:`Submitted`}),C(j.submitted_at)]}),(0,b.jsxs)(`div`,{children:[(0,b.jsx)(`div`,{className:`text-muted-foreground text-xs`,children:`Completed`}),C(j.completed_at)]}),(0,b.jsxs)(`div`,{className:`col-span-2`,children:[(0,b.jsx)(`div`,{className:`text-muted-foreground text-xs`,children:`Pending Approvers`}),(0,b.jsx)(`div`,{className:`flex flex-wrap gap-1 mt-1`,children:(j.pending_approvers||[]).length===0?`—`:(j.pending_approvers||[]).map((e,t)=>(0,b.jsx)(l,{variant:`outline`,className:`font-mono text-[10px]`,title:e,children:T(e)},t))})]}),j.payload&&(0,b.jsxs)(`div`,{className:`col-span-2`,children:[(0,b.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,b.jsx)(`div`,{className:`text-muted-foreground text-xs`,children:`Payload`}),(0,b.jsxs)(`button`,{type:`button`,onClick:async()=>{try{await navigator.clipboard.writeText(JSON.stringify(j.payload,null,2)),h.success(`Payload copied`)}catch{h.error(`Copy failed`)}},className:`text-[10px] text-muted-foreground hover:text-foreground inline-flex items-center gap-1`,children:[(0,b.jsx)(ue,{className:`h-3 w-3`}),`Copy`]})]}),(0,b.jsx)(`pre`,{className:`text-[11px] bg-muted/50 rounded p-2 overflow-auto max-h-32 mt-1`,children:JSON.stringify(j.payload,null,2)})]})]}),(0,b.jsx)(c,{}),(0,b.jsxs)(`div`,{children:[(0,b.jsx)(`h3`,{className:`text-sm font-semibold mb-3`,children:`Action History`}),Ge.length===0?(0,b.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:`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:Ge.map(e=>(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 ${e.action===`approve`?`bg-emerald-500`:e.action===`reject`?`bg-destructive`:e.action===`submit`?`bg-blue-500`:(e.action,`bg-muted-foreground`)}`,"aria-hidden":!0}),(0,b.jsxs)(`div`,{className:`flex items-baseline gap-1.5 flex-wrap`,children:[(0,b.jsx)(`span`,{className:`font-medium capitalize`,children:e.action}),(0,b.jsx)(`span`,{className:`text-muted-foreground`,children:`by`}),(0,b.jsx)(`span`,{className:`font-mono`,title:e.actor_id||``,children:T(e.actor_id)}),e.step_name&&(0,b.jsxs)(`span`,{className:`text-muted-foreground`,children:[`· `,e.step_name,` (#`,e.step_index,`)`]}),(0,b.jsx)(`span`,{className:`ml-auto text-muted-foreground text-[10px]`,title:C(e.created_at),children:w(e.created_at)})]}),e.comment&&(0,b.jsxs)(`div`,{className:`text-muted-foreground italic mt-0.5`,children:[`"`,e.comment,`"`]})]},e.id))})]}),j.status===`pending`&&(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(c,{}),(0,b.jsxs)(`div`,{className:`space-y-3`,children:[(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:`Override actor (advanced)`}),(0,b.jsxs)(`div`,{className:`mt-2`,children:[(0,b.jsx)(Ce,{htmlFor:`actor-override`,className:`text-xs`,children:`Actor`}),(0,b.jsx)(`input`,{id:`actor-override`,type:`text`,value:I,onChange:e=>L(e.target.value),placeholder:`Auto: ${q(j)||`(none)`}`,className:`w-full mt-1 px-3 py-2 text-sm border rounded-md bg-background`}),(0,b.jsxs)(`div`,{className:`text-[10px] text-muted-foreground mt-1`,children:[`e.g. `,(0,b.jsx)(`code`,{children:`role:sales_manager`}),`. Leave blank to use auto-detected.`]})]})]}),(0,b.jsxs)(`div`,{children:[(0,b.jsx)(Ce,{htmlFor:`comment`,className:`text-xs`,children:`Comment (optional)`}),(0,b.jsx)(le,{id:`comment`,value:P,onChange:e=>F(e.target.value),rows:2,className:`mt-1`})]}),(0,b.jsxs)(`div`,{className:`flex gap-2 flex-wrap`,children:[(0,b.jsxs)(d,{size:`sm`,onClick:()=>J(`approve`),disabled:!Y||R!==null,children:[(0,b.jsx)(ke,{className:`h-4 w-4 mr-1`}),R===`approve`?`Approving…`:`Approve`]}),(0,b.jsxs)(me,{children:[(0,b.jsx)(Ae,{asChild:!0,children:(0,b.jsxs)(d,{size:`sm`,variant:`outline`,disabled:!Y||R!==null,className:`border-destructive text-destructive hover:bg-destructive hover:text-destructive-foreground`,children:[(0,b.jsx)(Fe,{className:`h-4 w-4 mr-1`}),R===`reject`?`Rejecting…`:`Reject`]})}),(0,b.jsxs)(ge,{children:[(0,b.jsxs)(ve,{children:[(0,b.jsx)(xe,{children:`Reject this request?`}),(0,b.jsxs)(De,{children:[`This will mark the request as rejected and notify the submitter.`,j.current_step_index!=null&&j.current_step_index>0?` If the process is multi-step, it returns to the previous step.`:``]})]}),(0,b.jsxs)(ze,{children:[(0,b.jsx)(Ie,{children:`Cancel`}),(0,b.jsx)(p,{onClick:()=>J(`reject`),className:`bg-destructive text-destructive-foreground hover:bg-destructive/90`,children:`Reject`})]})]})]}),(0,b.jsxs)(d,{size:`sm`,variant:`outline`,onClick:()=>J(`recall`),disabled:!et||R!==null,children:[(0,b.jsx)(Te,{className:`h-4 w-4 mr-1`}),R===`recall`?`Recalling…`:`Recall`]})]}),!Y&&!et&&(0,b.jsxs)(`div`,{className:`text-xs text-muted-foreground`,children:[`You are not in the pending approvers list and did not submit this request. Use the override above to act as another identity (e.g. `,(0,b.jsx)(`code`,{children:`role:sales_manager`}),`).`]})]})]})]}):null]})})]})}export{E as ApprovalsInboxPage};
@@ -1 +0,0 @@
1
- import{o as e}from"./rolldown-runtime-CMxvf4Kt.js";import{g as t,l as n,r,u as i}from"./vendor-react-CIpZOxG3.js";import{S as a}from"./framework-ClI3DbWX.js";import{na as o}from"./ui-components-ZN8XdmwJ.js";import{o as s}from"./vendor-ui-utils-D3GsyZyi.js";import{n as c,o as l,r as u,t as d}from"./index-Ca4KaljM.js";var f=e(t(),1),p=r();function m(){let e=n(),t=e.pathname.indexOf(`/component/metadata/resource`);return t>=0?e.pathname.slice(0,t+28):e.pathname}function h({type:e}){let t=i(),n=m(),{objects:r,refresh:h}=a(),g=l(),_=(0,f.useMemo)(()=>(r||[]).map(u),[r]),[v,y]=(0,f.useState)(null),[b,x]=(0,f.useState)(!1),S=v??_,C=(0,f.useRef)(S),w=(0,f.useCallback)(r=>{t(`${n}/${r.name}?type=${e}`)},[t,n,e]),T=(0,f.useCallback)(async e=>{let t=C.current;if(y(e),C.current=e,!g){s.error(`Service unavailable — changes saved locally only`);return}let n=d.diffObjects(t,e);x(!0);try{if(n)n.type===`delete`?await g.deleteObject(n.object.name):await g.saveObject(n.object);else for(let t of e)await g.saveObject(t);await h();let t=n?n.type===`create`?`Object "${n.object.label||n.object.name}" created`:n.type===`update`?`Object "${n.object.label||n.object.name}" updated`:`Object "${n.object.label||n.object.name}" deleted`:`Object definitions updated`;s.success(t)}catch(e){y(t),C.current=t,s.error(e?.message||`Failed to save object changes`)}finally{x(!1)}},[g,h]);return(0,p.jsxs)(`div`,{className:`flex flex-col gap-4 p-4 sm:p-6`,children:[b&&(0,p.jsxs)(`div`,{className:`flex items-center gap-2 text-sm text-muted-foreground`,"data-testid":`object-saving-indicator`,children:[(0,p.jsx)(o,{className:`h-4 w-4 animate-spin`}),`Saving object changes…`]}),(0,p.jsx)(c,{objects:S,onObjectsChange:T,onSelectObject:w,showSystemObjects:!0})]})}export{h as ObjectManagerListPage};
@@ -1 +0,0 @@
1
- import{o as e}from"./rolldown-runtime-CMxvf4Kt.js";import{g as t,r as n}from"./vendor-react-CIpZOxG3.js";import{l as r,o as i}from"./infrastructure-ezj3FgNE.js";import{$n as a,Er as o,Jn as s,Kn as c,Or as l,Qn as u,Xn as d,Yn as f,_ as p,br as m,en as h,er as g,ho as _,ii as v,in as y,ir as b,mr as x,na as S,nr as C,po as w,qn as T,rr as E,ta as D,tr as O}from"./ui-components-ZN8XdmwJ.js";var k=e(t(),1),A=n();function j(){let[e,t]=(0,k.useState)(!1);return(0,k.useEffect)(()=>{typeof window>`u`||t(new URLSearchParams(window.location.search).get(`recovery_needed`)===`true`)},[]),{recoveryNeeded:e,clear:()=>{if(typeof window>`u`)return;let e=new URL(window.location.href);e.searchParams.delete(`recovery_needed`),window.history.replaceState({},``,e.toString()),t(!1)}}}function M(){let{user:e,updateUser:t,isLoading:n,changePassword:D,setInitialPassword:M,hasLocalPassword:P}=r(),{upload:F}=p(),[I,L]=(0,k.useState)(e?.name??``),[R,z]=(0,k.useState)(!1),[B,V]=(0,k.useState)(null),H=(0,k.useRef)(null),[U,W]=(0,k.useState)(!1),[G,K]=(0,k.useState)(null),q=(0,k.useRef)(null),{recoveryNeeded:J,clear:Y}=j();return(0,k.useEffect)(()=>{if(!J)return;let e=setTimeout(()=>{q.current?.scrollIntoView({behavior:`smooth`,block:`start`})},200);return()=>clearTimeout(e)},[J]),e?(0,A.jsxs)(`div`,{className:`flex flex-col gap-4 sm:gap-6 p-4 sm:p-6 max-w-2xl`,children:[(0,A.jsxs)(`div`,{className:`min-w-0`,children:[(0,A.jsx)(`h1`,{className:`text-xl sm:text-2xl font-bold tracking-tight`,children:`Profile`}),(0,A.jsx)(`p`,{className:`text-sm text-muted-foreground mt-1`,children:`Manage your account settings`})]}),J&&(0,A.jsxs)(C,{variant:`default`,className:`border-amber-300 bg-amber-50 text-amber-900 dark:border-amber-700 dark:bg-amber-950/40 dark:text-amber-200`,"data-testid":`profile-recovery-banner`,children:[(0,A.jsx)(v,{className:`h-4 w-4`}),(0,A.jsx)(b,{children:`Set a recovery password`}),(0,A.jsx)(E,{children:`You signed in via single sign-on from the control plane. Set a local password below so you can still sign in to this environment directly if SSO ever becomes unavailable.`})]}),(0,A.jsx)(c,{children:(0,A.jsxs)(T,{className:`pt-6`,children:[(0,A.jsxs)(`div`,{className:`flex items-center gap-4`,children:[(0,A.jsxs)(a,{className:`h-16 w-16`,children:[(0,A.jsx)(O,{src:e.image??void 0,alt:e.name??`User`}),(0,A.jsx)(g,{className:`text-lg bg-primary text-primary-foreground`,children:i(e)})]}),(0,A.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,A.jsx)(`p`,{className:`text-lg font-semibold truncate`,children:e.name??`User`}),(0,A.jsx)(`p`,{className:`text-sm text-muted-foreground truncate`,children:e.email}),(0,A.jsx)(u,{variant:`secondary`,className:`mt-1`,children:e.role??`member`})]}),(0,A.jsxs)(`div`,{className:`flex flex-col gap-2 shrink-0`,children:[(0,A.jsx)(`input`,{ref:H,type:`file`,accept:`image/*`,className:`hidden`,onChange:async e=>{let n=e.target.files?.[0];if(H.current&&(H.current.value=``),n){W(!0),K(null);try{await t({image:(await F(n)).url})}catch(e){K(e instanceof Error?e.message:String(e))}finally{W(!1)}}},"data-testid":`profile-avatar-file`}),(0,A.jsxs)(x,{type:`button`,variant:`outline`,size:`sm`,disabled:U,onClick:()=>H.current?.click(),"data-testid":`profile-avatar-upload-btn`,children:[U?(0,A.jsx)(S,{className:`mr-2 h-4 w-4 animate-spin`}):(0,A.jsx)(l,{className:`mr-2 h-4 w-4`}),e.image?`Replace`:`Upload`]}),e.image&&(0,A.jsxs)(x,{type:`button`,variant:`ghost`,size:`sm`,disabled:U,onClick:async()=>{W(!0),K(null);try{await t({image:null})}catch(e){K(e instanceof Error?e.message:String(e))}finally{W(!1)}},"data-testid":`profile-avatar-remove-btn`,children:[(0,A.jsx)(m,{className:`mr-2 h-4 w-4`}),`Remove`]})]})]}),G&&(0,A.jsxs)(C,{variant:`destructive`,className:`mt-4`,children:[(0,A.jsx)(_,{className:`h-4 w-4`}),(0,A.jsx)(E,{children:G})]})]})}),(0,A.jsxs)(c,{children:[(0,A.jsxs)(f,{children:[(0,A.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,A.jsx)(o,{className:`h-4 w-4 text-muted-foreground`}),(0,A.jsx)(d,{className:`text-base sm:text-lg`,children:`Personal Information`})]}),(0,A.jsx)(s,{children:`Update your name and view account details`})]}),(0,A.jsx)(T,{children:(0,A.jsxs)(`form`,{onSubmit:async e=>{e.preventDefault(),V(null),z(!1);try{await t({name:I}),z(!0)}catch(e){V(e instanceof Error?e.message:String(e))}},className:`space-y-4`,children:[B&&(0,A.jsxs)(C,{variant:`destructive`,children:[(0,A.jsx)(_,{className:`h-4 w-4`}),(0,A.jsx)(E,{children:B})]}),R&&(0,A.jsxs)(C,{children:[(0,A.jsx)(w,{className:`h-4 w-4 text-green-600`}),(0,A.jsx)(E,{className:`text-green-800 dark:text-green-400`,children:`Profile updated successfully.`})]}),(0,A.jsxs)(`div`,{className:`space-y-2`,children:[(0,A.jsx)(y,{htmlFor:`profile-name`,children:`Name`}),(0,A.jsx)(h,{id:`profile-name`,type:`text`,value:I,onChange:e=>L(e.target.value),required:!0,"aria-required":`true`,disabled:n})]}),(0,A.jsxs)(`div`,{className:`space-y-2`,children:[(0,A.jsx)(y,{htmlFor:`profile-email`,children:`Email`}),(0,A.jsx)(h,{id:`profile-email`,type:`email`,value:e.email,disabled:!0,className:`bg-muted text-muted-foreground`}),(0,A.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Email cannot be changed.`})]}),(0,A.jsxs)(`div`,{className:`space-y-2`,children:[(0,A.jsx)(y,{children:`Role`}),(0,A.jsx)(h,{type:`text`,value:e.role??`member`,disabled:!0,className:`bg-muted text-muted-foreground`})]}),(0,A.jsx)(x,{type:`submit`,disabled:n,className:`w-full sm:w-auto`,children:n?`Saving…`:`Save Changes`})]})})]}),(0,A.jsx)(`div`,{ref:q,children:(0,A.jsx)(N,{changePassword:D,setInitialPassword:M,hasLocalPassword:P,highlight:J,onPasswordSet:Y})})]}):null}function N({changePassword:e,setInitialPassword:t,hasLocalPassword:n,highlight:r,onPasswordSet:i}){let[a,o]=(0,k.useState)(null),[l,u]=(0,k.useState)(``),[p,m]=(0,k.useState)(``),[g,v]=(0,k.useState)(``),[b,S]=(0,k.useState)(!1),[O,j]=(0,k.useState)(null),[M,N]=(0,k.useState)(null);(0,k.useEffect)(()=>{let e=!1;return n().then(t=>{e||o(t)}).catch(()=>{e||o(!1)}),()=>{e=!0}},[n]);let P=()=>{u(``),m(``),v(``)},F=async n=>{if(n.preventDefault(),j(null),N(null),p.length<8){j(`Password must be at least 8 characters`);return}if(p!==g){j(`Passwords do not match`);return}S(!0);try{if(a){if(!l){j(`Enter your current password`),S(!1);return}await e(l,p),N(`Password changed.`)}else await t(p),N(`Local password set. You can now sign in with email and password on this environment.`),o(!0),i?.();P()}catch(e){j(e instanceof Error?e.message:String(e))}finally{S(!1)}},I=a===null;return(0,A.jsxs)(c,{className:r?`ring-2 ring-amber-300 dark:ring-amber-700`:void 0,children:[(0,A.jsxs)(f,{children:[(0,A.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,A.jsx)(D,{className:`h-4 w-4 text-muted-foreground`}),(0,A.jsx)(d,{className:`text-base sm:text-lg`,children:a?`Change Password`:`Set Local Password`})]}),(0,A.jsx)(s,{children:a?`Update the password you use to sign in to this environment.`:`You signed in via single sign-on. Set a local password to also sign in with email and password on this environment.`})]}),(0,A.jsx)(T,{children:(0,A.jsxs)(`form`,{onSubmit:F,className:`space-y-4 max-w-md`,children:[a&&(0,A.jsxs)(`div`,{className:`space-y-2`,children:[(0,A.jsx)(y,{htmlFor:`current-password`,children:`Current password`}),(0,A.jsx)(h,{id:`current-password`,type:`password`,autoComplete:`current-password`,value:l,onChange:e=>u(e.target.value),disabled:b||I,required:!0})]}),(0,A.jsxs)(`div`,{className:`space-y-2`,children:[(0,A.jsx)(y,{htmlFor:`new-password`,children:a?`New password`:`Password`}),(0,A.jsx)(h,{id:`new-password`,type:`password`,autoComplete:`new-password`,value:p,onChange:e=>m(e.target.value),disabled:b||I,minLength:8,required:!0})]}),(0,A.jsxs)(`div`,{className:`space-y-2`,children:[(0,A.jsx)(y,{htmlFor:`confirm-password`,children:`Confirm password`}),(0,A.jsx)(h,{id:`confirm-password`,type:`password`,autoComplete:`new-password`,value:g,onChange:e=>v(e.target.value),disabled:b||I,minLength:8,required:!0})]}),O&&(0,A.jsxs)(C,{variant:`destructive`,children:[(0,A.jsx)(_,{className:`h-4 w-4`}),(0,A.jsx)(E,{children:O})]}),M&&(0,A.jsxs)(C,{children:[(0,A.jsx)(w,{className:`h-4 w-4`}),(0,A.jsx)(E,{children:M})]}),(0,A.jsx)(x,{type:`submit`,disabled:b||I,className:`w-full sm:w-auto`,children:b?`Saving…`:a?`Change password`:`Set password`})]})})]})}export{M as ProfilePage};
@@ -1 +0,0 @@
1
- import{o as e}from"./rolldown-runtime-CMxvf4Kt.js";import{g as t,r as n}from"./vendor-react-CIpZOxG3.js";import{x as r}from"./framework-ClI3DbWX.js";import{Bn as i,Fn as a,In as o,Jn as ee,Kn as te,Ln as s,Qa as ne,Qn as re,Rn as c,Ua as l,Xn as ie,Yn as ae,at as u,ct as d,en as f,in as p,it as m,mr as h,no as oe,ot as g,qn as se,rt as ce,sa as le,si as ue,st as de,vi as fe,wi as pe,xi as me,zn as _}from"./ui-components-ZN8XdmwJ.js";import{o as v}from"./vendor-ui-utils-D3GsyZyi.js";import"./index-Ca4KaljM.js";var y=e(t(),1),b=n();function x(e){return e?e.replace(/^\/+/,``).match(/^forms\/([^/?#]+)/i)?.[1]??null:null}function S(e){return e.trim().toLowerCase().replace(/[^a-z0-9-_]+/g,`-`).replace(/^-+|-+$/g,``)}function C(){let e=r()?.getClient?.(),[t,n]=(0,y.useState)([]),[C,he]=(0,y.useState)([]),[w,T]=(0,y.useState)(!0),[E,D]=(0,y.useState)(null),[ge,O]=(0,y.useState)(!1),[k,A]=(0,y.useState)(``),[j,M]=(0,y.useState)(``),[N,P]=(0,y.useState)(!1),[_e,F]=(0,y.useState)(!1),[I,L]=(0,y.useState)(null),[R,z]=(0,y.useState)(``),[B,V]=(0,y.useState)(`thank-you`),[H,U]=(0,y.useState)(``),[W,G]=(0,y.useState)(``),[K,q]=(0,y.useState)(``),[J,Y]=(0,y.useState)(!1),X=async()=>{if(!e?.meta?.getItems){D(`meta.getItems is not available on this client`),T(!1);return}T(!0),D(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=x(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),he(a)}catch(e){D(e?.message??String(e))}finally{T(!1)}};(0,y.useEffect)(()=>{X()},[]);let ve=typeof window<`u`?window.location.origin:``,Z=e=>`${ve}/console/f/${e}`,ye=e=>`<iframe src="${Z(e)}" width="100%" height="640" frameborder="0" style="border:0;"></iframe>`,be=e=>`<iframe\n src={\`${Z(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(!k||!j)return;let t=C.find(e=>e.name===k);if(!t)return;let n=S(j);if(!n){v.error(`Invalid slug`);return}let r={...t.spec,sharing:{...t.spec.sharing??{},enabled:!0,allowAnonymous:!0,publicLink:`/forms/${n}`}};P(!0);try{await e.meta.saveItem(`view`,t.name,r),v.success(`Published ${t.name}`),O(!1),A(``),M(``),await X()}catch(e){v.error(`Publish failed: ${e?.message??e}`)}finally{P(!1)}},Se=e=>{L(e),z(e.slug);let t=e.spec?.submitBehavior;V(t?.kind??`thank-you`),U(t?.title??``),G(t?.message??``),q(t?.url??``),F(!0)},Ce=async()=>{if(!I)return;let t=S(R);if(!t){v.error(`Invalid slug`);return}let n;switch(B){case`thank-you`:n={kind:`thank-you`},H&&(n.title=H),W&&(n.message=W);break;case`redirect`:if(!K){v.error(`Redirect URL is required`);return}n={kind:`redirect`,url:K};break;case`continue`:case`next-record`:n={kind:B};break}let r={...I.spec,sharing:{...I.spec.sharing??{},enabled:!0,allowAnonymous:!0,publicLink:`/forms/${t}`},submitBehavior:n};Y(!0);try{await e.meta.saveItem(`view`,I.name,r),v.success(`Saved ${I.name}`),F(!1),L(null),await X()}catch(e){v.error(`Save failed: ${e?.message??e}`)}finally{Y(!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)(te,{children:[(0,b.jsxs)(ae,{className:`flex flex-row items-start justify-between gap-4 space-y-0`,children:[(0,b.jsxs)(`div`,{children:[(0,b.jsxs)(ie,{className:`flex items-center gap-2`,children:[(0,b.jsx)(me,{className:`h-4 w-4`}),`Public Forms`]}),(0,b.jsx)(ee,{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:()=>O(!0),disabled:C.length===0,title:C.length===0?`No non-public FormViews available`:`Publish a FormView`,children:[(0,b.jsx)(pe,{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:X,disabled:w,children:[(0,b.jsx)(fe,{className:`h-3.5 w-3.5 ${w?`animate-spin`:``}`}),(0,b.jsx)(`span`,{className:`ml-1.5`,children:`Refresh`})]})]})]}),(0,b.jsxs)(se,{children:[E&&(0,b.jsx)(`div`,{className:`mb-3 rounded-md border border-destructive/40 bg-destructive/10 p-3 text-sm text-destructive`,children:E}),!w&&!$&&(0,b.jsxs)(`div`,{className:`rounded-md border border-dashed p-6 text-center text-sm text-muted-foreground`,children:[(0,b.jsx)(`p`,{className:`font-medium text-foreground`,children:`No public forms yet`}),(0,b.jsxs)(`p`,{className:`mt-1`,children:[`Click `,(0,b.jsx)(`strong`,{children:`Publish form…`}),` above to share an existing form, or build a new one in Views & Apps and mark it public.`]})]}),$&&(0,b.jsxs)(ce,{children:[(0,b.jsx)(de,{children:(0,b.jsxs)(d,{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)(m,{children:t.map(e=>{let t=Z(e.slug);return(0,b.jsxs)(d,{children:[(0,b.jsx)(u,{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)(u,{children:e.object?(0,b.jsx)(re,{variant:`secondary`,children:e.object}):(0,b.jsx)(`span`,{className:`text-muted-foreground`,children:`—`})}),(0,b.jsx)(u,{children:(0,b.jsx)(`code`,{className:`text-xs`,children:e.slug})}),(0,b.jsx)(u,{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)(l,{className:`h-3 w-3`})]})}),(0,b.jsx)(u,{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)(le,{className:`h-3.5 w-3.5`})}),(0,b.jsx)(h,{variant:`ghost`,size:`sm`,title:`Copy <iframe> embed`,onClick:()=>Q(`iframe snippet`,ye(e.slug)),children:(0,b.jsx)(oe,{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)(ne,{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)(a,{open:ge,onOpenChange:O,children:(0,b.jsxs)(o,{className:`sm:max-w-md`,children:[(0,b.jsxs)(_,{children:[(0,b.jsx)(i,{children:`Publish a FormView`}),(0,b.jsxs)(s,{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)(p,{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:k,onChange:e=>A(e.target.value),children:[(0,b.jsx)(`option`,{value:``,children:`— Select a FormView —`}),C.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)(p,{htmlFor:`publish-slug`,children:`URL slug`}),(0,b.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,b.jsx)(`span`,{className:`text-xs text-muted-foreground whitespace-nowrap`,children:`/console/f/`}),(0,b.jsx)(f,{id:`publish-slug`,placeholder:`contact-us`,value:j,onChange:e=>M(e.target.value)})]}),(0,b.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Lowercase letters, digits, dashes and underscores only.`})]})]}),(0,b.jsxs)(c,{children:[(0,b.jsx)(h,{variant:`ghost`,onClick:()=>O(!1),disabled:N,children:`Cancel`}),(0,b.jsx)(h,{onClick:xe,disabled:N||!k||!j,children:N?`Publishing…`:`Publish`})]})]})}),(0,b.jsx)(a,{open:_e,onOpenChange:F,children:(0,b.jsxs)(o,{className:`sm:max-w-lg`,children:[(0,b.jsxs)(_,{children:[(0,b.jsx)(i,{children:I?`Edit ${I.label??I.name}`:`Edit form`}),(0,b.jsx)(s,{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)(p,{htmlFor:`edit-slug`,children:`URL slug`}),(0,b.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,b.jsx)(`span`,{className:`text-xs text-muted-foreground whitespace-nowrap`,children:`/console/f/`}),(0,b.jsx)(f,{id:`edit-slug`,value:R,onChange:e=>z(e.target.value)})]})]}),(0,b.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,b.jsx)(p,{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:B,onChange:e=>V(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)`})]})]}),B===`thank-you`&&(0,b.jsxs)(b.Fragment,{children:[(0,b.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,b.jsx)(p,{htmlFor:`edit-tytitle`,children:`Title`}),(0,b.jsx)(f,{id:`edit-tytitle`,placeholder:`Thanks!`,value:H,onChange:e=>U(e.target.value)})]}),(0,b.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,b.jsx)(p,{htmlFor:`edit-tymsg`,children:`Message`}),(0,b.jsx)(f,{id:`edit-tymsg`,placeholder:`Your submission has been received.`,value:W,onChange:e=>G(e.target.value)})]})]}),B===`redirect`&&(0,b.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,b.jsx)(p,{htmlFor:`edit-url`,children:`Redirect URL`}),(0,b.jsx)(f,{id:`edit-url`,type:`url`,placeholder:`https://example.com/thanks`,value:K,onChange:e=>q(e.target.value)})]})]}),(0,b.jsxs)(c,{children:[(0,b.jsx)(h,{variant:`ghost`,onClick:()=>F(!1),disabled:J,children:`Cancel`}),(0,b.jsx)(h,{onClick:Ce,disabled:J||!R,children:J?`Saving…`:`Save`})]})]})})]})}export{C as PublicFormsPage};