@objectstack/console 16.0.0-rc.0 → 16.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/.objectui-sha +1 -1
- package/dist/assets/{AdapterProvider-DaQhp5MR.js → AdapterProvider-C6zOh6HD.js} +1 -1
- package/dist/assets/{AiPendingActionsPage-9UZ4_qZW.js → AiPendingActionsPage-CnAw7P3v.js} +1 -1
- package/dist/assets/{ApiConsolePage-DVnQPvbh.js → ApiConsolePage-BI45__VZ.js} +1 -1
- package/dist/assets/{AppDocsIndex-RWbVdvGq.js → AppDocsIndex-f25vfEKO.js} +1 -1
- package/dist/assets/{AppManagementPage-JlGIV3AH.js → AppManagementPage-Bg9uJgOg.js} +1 -1
- package/dist/assets/ApprovalsInboxPage-DNHuqeXG.js +1 -0
- package/dist/assets/{AuditLogPage-C6SMCaHa.js → AuditLogPage-B7miw4yM.js} +1 -1
- package/dist/assets/{ComponentNavView-DpWz8z8w.js → ComponentNavView-hbkzWx99.js} +1 -1
- package/dist/assets/CreateViewDialog-C9MmF1EQ.js +1 -0
- package/dist/assets/{DashboardView-BTS9ygDI.js → DashboardView-B5fvjbK1.js} +1 -1
- package/dist/assets/{DeveloperHubPage-CX3urxAq.js → DeveloperHubPage-CLMxDfF8.js} +1 -1
- package/dist/assets/{DocShell-CXBgEZhg.js → DocShell-Xat5mAFu.js} +1 -1
- package/dist/assets/{ExpressionProvider-C26LCaQj.js → ExpressionProvider-BrbZIz2M.js} +1 -1
- package/dist/assets/{FlowRunsPage-DKnUh_Ec.js → FlowRunsPage-D3geofgO.js} +1 -1
- package/dist/assets/{IntegrationsPage-BvyX5vIh.js → IntegrationsPage-BomrdGvC.js} +1 -1
- package/dist/assets/InterfaceListPage-B-1CV8r_.js +1 -0
- package/dist/assets/ManagedByBadge-B6i8b85J.js +1 -0
- package/dist/assets/MarketplaceAccessDenied-CB0BqpZm.js +1 -0
- package/dist/assets/{MarketplaceInstalledPage-CKmxuBaG.js → MarketplaceInstalledPage-k4tMP5Il.js} +1 -1
- package/dist/assets/{MarketplacePackagePage-BjhnLR61.js → MarketplacePackagePage-DFu-NbiT.js} +1 -1
- package/dist/assets/{MarketplacePage-BWLFbDxW.js → MarketplacePage-hFFqWDhG.js} +1 -1
- package/dist/assets/MetadataInspector-GuDvqIYj.js +1 -0
- package/dist/assets/{MetadataProvider-Dq7I7eh-.js → MetadataProvider-1pC12cNH.js} +1 -1
- package/dist/assets/ObjectDataPage-BXb8qS_O.js +1 -0
- package/dist/assets/PageView-CJffWMXV.js +1 -0
- package/dist/assets/{ProfilePage-DAkDEioN.js → ProfilePage-giyDPnkE.js} +1 -1
- package/dist/assets/PublicFormsPage-CvTGsvEk.js +1 -0
- package/dist/assets/RecordDetailView-BWj_n2Xd.js +9 -0
- package/dist/assets/{RecordFormPage-Cye1lcxq.js → RecordFormPage-DaAXyIFl.js} +1 -1
- package/dist/assets/ReportDefaultInspector-nzEI_7uY.js +3 -0
- package/dist/assets/ReportView-BkvoSROz.js +2 -0
- package/dist/assets/{SearchResultsPage-XP2cdAyq.js → SearchResultsPage-Badp3TZy.js} +1 -1
- package/dist/assets/{SettingsHub-yoHgXGvm.js → SettingsHub-CLEl9yB4.js} +1 -1
- package/dist/assets/{SettingsView-BO0qYMbW.js → SettingsView-D48FlZZ-.js} +1 -1
- package/dist/assets/{SystemHubPage-qOFiW2Jq.js → SystemHubPage-Bcedpt6c.js} +1 -1
- package/dist/assets/{useMetadata-BMHVJNxp.js → createDerive-CoXOsdH9.js} +1 -1
- package/dist/assets/data-adapter-C-CzgrY8.js +9 -0
- package/dist/assets/framework-brxTxzwx.js +8 -0
- package/dist/assets/{getIcon-CBdepA3t.js → getIcon-CHjgso2Q.js} +1 -1
- package/dist/assets/{highlighted-body-OFNGDK62-CYfwZSTb.js → highlighted-body-OFNGDK62-iRcLhe8Y.js} +1 -1
- package/dist/assets/{i18n-grFi0A0v.js → i18n-BBfFXbqS.js} +1 -1
- package/dist/assets/index-DQKFSIRa.js +2 -0
- package/dist/assets/index-De6xiiED.css +2 -0
- package/dist/assets/infrastructure-C6pQBkbt.js +3 -0
- package/dist/assets/mermaid-GHXKKRXX-o9V61CTW.js +1 -0
- package/dist/assets/metadata-admin-DUDb4_-I.js +25 -0
- package/dist/assets/plugin-calendar-BwqRXov_.js +1 -0
- package/dist/assets/plugin-charts-DFywQsyC.js +7 -0
- package/dist/assets/{plugin-chatbot-BRbgUPLw.js → plugin-chatbot-ChDQ0sZw.js} +46 -46
- package/dist/assets/plugin-dashboard-LbTxdFyx.js +6 -0
- package/dist/assets/plugin-form-B69IWc-v.js +1 -0
- package/dist/assets/plugin-gantt-DNfSxpfa.js +63 -0
- package/dist/assets/plugin-grid-D5ooeMq3.js +8 -0
- package/dist/assets/plugin-kanban-CDv0cMku.js +1 -0
- package/dist/assets/{plugin-map-fMpIp7jh.js → plugin-map-CFb9fmBs.js} +1 -1
- package/dist/assets/{plugin-markdown-wZpqyjok.js → plugin-markdown-BxslElNy.js} +1 -1
- package/dist/assets/{plugin-report-kGtO0FOF.js → plugin-report-DEkf0Fe2.js} +3 -3
- package/dist/assets/{plugin-timeline-DZNEy3Y1.js → plugin-timeline-DUw-qsiu.js} +1 -1
- package/dist/assets/{plugin-tree-CZRX9ChE.js → plugin-tree-8wyez9hx.js} +1 -1
- package/dist/assets/plugin-view-baVOQ3XC.js +1 -0
- package/dist/assets/plugins-views-Bi6X55Wz.js +4 -0
- package/dist/assets/runtime-metadata-persistence-Clk8TRxl.js +1 -0
- package/dist/assets/{skeletons-CX6Ch5Lg.js → skeletons-D8fbNHVX.js} +1 -1
- package/dist/assets/src-BEYY1hUL.js +19 -0
- package/dist/assets/{src-DNd8fJOE.js → src-DM9imiv_.js} +1 -1
- package/dist/assets/src-IWc9jIui.js +1 -0
- package/dist/assets/{types-C0F-S2Id.js → types-DwzGXr-7.js} +1 -1
- package/dist/assets/ui-components-BDIRZFoR.js +72 -0
- package/dist/assets/{ui-layout-CmmmekN3.js → ui-layout-ZABgadCW.js} +1 -1
- package/dist/assets/{use-book-data-DyDHAzga.js → use-book-data-C4CaJKQX.js} +1 -1
- package/dist/assets/{vendor-i18n-ByHglwq-.js → vendor-i18n-D2ce6sLS.js} +1 -1
- package/dist/assets/vendor-objectstack-CjHQG7Oa.js +114 -0
- package/dist/assets/vendor-radix-B1fu-dZi.js +46 -0
- package/dist/assets/{vendor-sentry-C3ouQ5cr.js → vendor-sentry-BFtl-K03.js} +25 -25
- package/dist/index.html +5 -5
- package/package.json +1 -1
- package/dist/assets/ApprovalsInboxPage-DMfSM-B7.js +0 -1
- package/dist/assets/CreateViewDialog-DQqqIAwO.js +0 -1
- package/dist/assets/InterfaceListPage-D00ihpcS.js +0 -1
- package/dist/assets/ManagedByBadge-B4O4Jy3c.js +0 -1
- package/dist/assets/MarketplaceAccessDenied-DFaKQ3Ws.js +0 -1
- package/dist/assets/MetadataInspector-B9z7wtJS.js +0 -1
- package/dist/assets/ObjectDataPage-Bm9tSz-w.js +0 -1
- package/dist/assets/PageView-BTHYu8Z9.js +0 -1
- package/dist/assets/PublicFormsPage-CRNSj35t.js +0 -1
- package/dist/assets/RecordDetailView-C6UiMORv.js +0 -9
- package/dist/assets/ReportDefaultInspector-B0nTPIZ8.js +0 -3
- package/dist/assets/ReportView-BeL2GZLl.js +0 -2
- package/dist/assets/data-adapter-CS4onYGf.js +0 -9
- package/dist/assets/framework-Oi7uo_kE.js +0 -8
- package/dist/assets/index-D3TWmLHH.css +0 -2
- package/dist/assets/index-D_-Sh_Rw.js +0 -2
- package/dist/assets/infrastructure-CQFJ5N6p.js +0 -3
- package/dist/assets/mermaid-GHXKKRXX-DtO0m-Vl.js +0 -1
- package/dist/assets/metadata-admin-D3yD8v_g.js +0 -25
- package/dist/assets/plugin-calendar-Bm0-Kkhu.js +0 -1
- package/dist/assets/plugin-charts-BHxVdXp7.js +0 -7
- package/dist/assets/plugin-dashboard-ARn_CaB3.js +0 -6
- package/dist/assets/plugin-form-C969LzWi.js +0 -1
- package/dist/assets/plugin-gantt-DrEbvyAE.js +0 -63
- package/dist/assets/plugin-grid-CnxMz-9O.js +0 -8
- package/dist/assets/plugin-kanban-C-mR5I0H.js +0 -1
- package/dist/assets/plugin-view-BhPeq9o5.js +0 -1
- package/dist/assets/plugins-views-DCG6qMPm.js +0 -4
- package/dist/assets/runtime-metadata-persistence-D1KKivGr.js +0 -1
- package/dist/assets/src-CB6vSDbd.js +0 -19
- package/dist/assets/src-CIr5NcaF.js +0 -1
- package/dist/assets/ui-components-BluZyuZX.js +0 -72
- package/dist/assets/vendor-objectstack-DxPvmbmF.js +0 -114
- package/dist/assets/vendor-radix-CWCRv2pn.js +0 -46
package/dist/index.html
CHANGED
|
@@ -46,13 +46,13 @@
|
|
|
46
46
|
<script>
|
|
47
47
|
window.process = window.process || { env: { NODE_ENV: 'development' }, version: '', platform: 'browser' };
|
|
48
48
|
</script>
|
|
49
|
-
<script type="module" crossorigin src="./assets/index-
|
|
49
|
+
<script type="module" crossorigin src="./assets/index-DQKFSIRa.js"></script>
|
|
50
50
|
<link rel="stylesheet" crossorigin href="./assets/ui-components-BL3SEdAz.css">
|
|
51
51
|
<link rel="stylesheet" crossorigin href="./assets/plugin-dashboard-DnNKJB60.css">
|
|
52
|
-
<link rel="stylesheet" crossorigin href="./assets/index-
|
|
53
|
-
<link rel="modulepreload" href="./assets/framework-
|
|
54
|
-
<link rel="modulepreload" href="./assets/ui-components-
|
|
55
|
-
<link rel="modulepreload" href="./assets/vendor-radix-
|
|
52
|
+
<link rel="stylesheet" crossorigin href="./assets/index-De6xiiED.css">
|
|
53
|
+
<link rel="modulepreload" href="./assets/framework-brxTxzwx.js" />
|
|
54
|
+
<link rel="modulepreload" href="./assets/ui-components-BDIRZFoR.js" />
|
|
55
|
+
<link rel="modulepreload" href="./assets/vendor-radix-B1fu-dZi.js" />
|
|
56
56
|
<link rel="modulepreload" href="./assets/vendor-react-BKSb6vFP.js" />
|
|
57
57
|
</head>
|
|
58
58
|
<body>
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@objectstack/console",
|
|
3
|
-
"version": "16.0.0
|
|
3
|
+
"version": "16.0.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-DAXXjFlN.js";import{a as t,h as n,m as r,r as i,y as a}from"./vendor-react-BKSb6vFP.js";import{f as ee,g as te,h as ne,p as re}from"./infrastructure-CQFJ5N6p.js";import{$t as ie,Cr as ae,Ct as oe,Dr as se,Er as ce,Es as le,Fi as ue,Fr as de,Fs as fe,Gt as o,Ii as pe,Jt as me,Ks as he,Mc as s,Or as c,Q as ge,Qt as _e,Rs as ve,Sr as ye,St as l,T as be,Tr as xe,Uc as Se,Wr as Ce,Ws as we,Xt as Te,Yi as Ee,Yt as De,Z as Oe,Zt as ke,_r as Ae,_t as je,ar as Me,bi as Ne,br as Pe,bs as Fe,bt as Ie,en as Le,fa as Re,fr as u,fs as ze,gr as Be,gt as Ve,ht as He,mn as Ue,mt as We,nn as Ge,or as Ke,qs as qe,qt as Je,rn as Ye,sr as Xe,tn as d,ts as Ze,tt as Qe,vn as $e,vt as et,wr as tt,wt as nt,xr as rt,xt as f,yr as it,yt as at}from"./ui-components-BluZyuZX.js";import{r as p}from"./vendor-ui-utils-D-WJ115h.js";import{p as ot}from"./src-CB6vSDbd.js";import{u as st}from"./plugins-views-DCG6qMPm.js";var m=e(a(),1),ct=`${``.replace(/\/$/,``)}/api/v1`;async function h(e,t){let n=te.get(),r=await fetch(`${ct}${e}`,{credentials:`include`,headers:{"Content-Type":`application/json`,...n?{Authorization:`Bearer ${n}`}:{},...t?.headers||{}},...t}),i=null;try{i=await r.json()}catch{}if(!r.ok){let e=i?.code??`HTTP_${r.status}`,t=i?.message??i?.error??r.statusText,n=Error(`${e}: ${t}`);throw n.code=e,n.status=r.status,n.details=i,n}return i}var g={listProcesses(e={}){let t=new URLSearchParams;e.object&&t.set(`object`,e.object),e.activeOnly&&t.set(`activeOnly`,`true`);let n=t.toString();return h(`/approvals/processes${n?`?${n}`:``}`)},listRequests(e={}){let t=new URLSearchParams;e.status&&t.set(`status`,e.status),e.object&&t.set(`object`,e.object),e.recordId&&t.set(`recordId`,e.recordId);let n=Array.isArray(e.approverId)?e.approverId.filter(Boolean).join(`,`):e.approverId;n&&t.set(`approverId`,n),e.submitterId&&t.set(`submitterId`,e.submitterId),e.q?.trim()&&t.set(`q`,e.q.trim()),e.limit!=null&&t.set(`limit`,String(e.limit)),e.offset!=null&&t.set(`offset`,String(e.offset));let r=t.toString();return h(`/approvals/requests${r?`?${r}`:``}`)},async getRequest(e){return{data:await h(`/approvals/requests/${encodeURIComponent(e)}`)}},listActions(e){return h(`/approvals/requests/${encodeURIComponent(e)}/actions`)},async approve(e,t){let n=await h(`/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 h(`/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 h(`/approvals/requests/${encodeURIComponent(e)}/recall`,{method:`POST`,body:JSON.stringify(t)})).request,finalized:!0}},async reassign(e,t){return{data:(await h(`/approvals/requests/${encodeURIComponent(e)}/reassign`,{method:`POST`,body:JSON.stringify(t)})).request}},async remind(e,t={}){let n=await h(`/approvals/requests/${encodeURIComponent(e)}/remind`,{method:`POST`,body:JSON.stringify(t)});return{data:n.request,notified:n.notified}},async requestInfo(e,t){return{data:(await h(`/approvals/requests/${encodeURIComponent(e)}/request-info`,{method:`POST`,body:JSON.stringify(t)})).request}},async sendBack(e,t){let n=await h(`/approvals/requests/${encodeURIComponent(e)}/revise`,{method:`POST`,body:JSON.stringify(t)});return{data:n.request,autoRejected:n.autoRejected===!0}},async resubmit(e,t={}){let n=await h(`/approvals/requests/${encodeURIComponent(e)}/resubmit`,{method:`POST`,body:JSON.stringify(t)});return{data:n.request,resumed:n.resumed===!0}},async comment(e,t){return{data:(await h(`/approvals/requests/${encodeURIComponent(e)}/comment`,{method:`POST`,body:JSON.stringify(t)})).request}},async submit(e){return h(`/approvals/requests`,{method:`POST`,body:JSON.stringify(e)})}};function lt(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 _=i(),ut=50,dt={pending:`border-amber-200 bg-amber-50 text-amber-700 dark:border-amber-500/30 dark:bg-amber-500/10 dark:text-amber-400`,approved:`border-emerald-200 bg-emerald-50 text-emerald-700 dark:border-emerald-500/30 dark:bg-emerald-500/10 dark:text-emerald-400`,rejected:`border-red-200 bg-red-50 text-red-700 dark:border-red-500/30 dark:bg-red-500/10 dark:text-red-400`,recalled:`border-border bg-muted text-muted-foreground`,returned:`border-violet-200 bg-violet-50 text-violet-700 dark:border-violet-500/30 dark:bg-violet-500/10 dark:text-violet-400`};function ft(e){if(!e)return`—`;try{return new Date(e).toLocaleString()}catch{return e}}function v(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 pt(e){return e&&String(e).replace(/^flow:/,``).trim().split(/[_\-\s]+/).filter(Boolean).map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(` `)||`—`}function y(e){return e.process_label||pt(e.process_name)}function mt(e){return e.step_label?e.step_label:e.current_step?pt(e.current_step):null}function ht(e){return e.submitter_name||v(e.submitter_id)}function gt(e,t){return t.pending_approver_names?.[e]||v(e)}function _t(e){return e.object_label||e.object_name}function b(e){return e.submitted_at||e.created_at||void 0}function x(e){let t=b(e);if(!t)return null;let n=Date.parse(t);return Number.isNaN(n)?null:(Date.now()-n)/36e5}function vt(e){if(e.status!==`pending`)return`text-muted-foreground`;let t=x(e);return t==null?`text-muted-foreground`:t>72?`text-red-600 dark:text-red-400 font-medium`:t>24?`text-amber-600 dark:text-amber-400`:`text-muted-foreground`}function yt(e){let t=Math.max(1,Math.round(Math.abs(e)/36e5));return t<48?`${t}h`:`${Math.round(t/24)}d`}var S=new Set([`id`,`created_at`,`updated_at`,`created_by`,`updated_by`,`organization_id`]);function C(e){return e.split(`_`).filter(Boolean).map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(` `)}function w(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 T=/^[A-Za-z0-9_-]{15,}$/;function bt(e,t,n=6){if(!e||typeof e!=`object`||Array.isArray(e))return[];let r=[];for(let[i,a]of Object.entries(e)){if(S.has(i)||a==null||typeof a==`object`||String(a).trim()===``)continue;let e=t?.[i];if(!(!e&&typeof a==`string`&&T.test(a.trim())&&!/^\d+$/.test(a.trim()))&&(r.push([C(i),e??w(i,a)]),r.length>=n))break}return r}function xt(){let{t:e,language:i}=Se(),{user:a}=re(),te=ee(),{appName:ct}=r(),[h,pt]=n(),x=(0,m.useMemo)(()=>lt(a),[a]),S=(0,m.useCallback)((t,n,r)=>String(e(`approvalsInbox.${t}`,{defaultValue:n,...r})),[e]),C=(0,m.useCallback)(e=>{if(!e)return`—`;let t=Date.parse(e);if(Number.isNaN(t))return e;let n=Math.round((Date.now()-t)/1e3);if(n<45)return S(`justNow`,`just now`);let r=Math.round(n/60);if(r<60)return S(`minutesAgo`,`{{count}}m ago`,{count:r});let a=Math.round(r/60);if(a<24)return S(`hoursAgo`,`{{count}}h ago`,{count:a});let ee=Math.round(a/24);if(ee<30)return S(`daysAgo`,`{{count}}d ago`,{count:ee});try{return new Date(e).toLocaleDateString(i)}catch{return e}},[S,i]),w=(0,m.useCallback)(e=>{switch(e){case`pending`:return S(`statusPending`,`Pending`);case`approved`:return S(`statusApproved`,`Approved`);case`rejected`:return S(`statusRejected`,`Rejected`);case`recalled`:return S(`statusRecalled`,`Recalled`);case`returned`:return S(`statusReturned`,`Returned for revision`);default:return e}},[S]),T=(0,m.useCallback)((e,t)=>{let n=e?.code??``,r=e?.status??0;return n===`NOT_IMPLEMENTED`||r===501?S(`recallUnavailable`,`Recall is not available on this deployment.`):n===`THROTTLED`||r===429?S(`remindThrottled`,`A reminder was sent recently — try again later.`):r===404?S(`requestGone`,`This request no longer exists. Refresh the list.`):n===`FORBIDDEN`||r===403?S(`notAllowed`,`You are not allowed to perform this action.`):n===`INVALID_STATE`||r===409?S(`alreadyDecided`,`This request was already decided. Refresh the list.`):e?.message||t},[S]);function xt({status:e}){return(0,_.jsx)(u,{variant:`outline`,className:s(`font-medium`,dt[e]??``),children:w(e)})}let St=(0,m.useCallback)(e=>`/apps/${ct||`setup`}/${encodeURIComponent(e.object_name)}/record/${encodeURIComponent(e.record_id)}`,[ct]),[E,Ct]=(0,m.useState)(`pending`),[D,wt]=(0,m.useState)([]),[Tt,Et]=(0,m.useState)(!1),[Dt,Ot]=(0,m.useState)(!1),[kt,O]=(0,m.useState)(null),[At,jt]=(0,m.useState)(null),[Mt,Nt]=(0,m.useState)(0),[k,Pt]=(0,m.useState)(null),[A,j]=(0,m.useState)(null),[Ft,M]=(0,m.useState)([]),[It,Lt]=(0,m.useState)(!1),[Rt,N]=(0,m.useState)(``),[P,zt]=(0,m.useState)(``),[Bt,Vt]=(0,m.useState)(null),[Ht,F]=(0,m.useState)([]),[Ut,I]=(0,m.useState)(null),L=(0,m.useMemo)(()=>ne(),[]),Wt=(0,m.useMemo)(()=>be({baseUrl:``.replace(/\/$/,``),scope:`attachments`,fetchImpl:L}),[L]),Gt=(0,m.useCallback)(async e=>{I(null);for(let t of Array.from(e))try{let e=await Wt.upload(t),n=String(e.meta?.fileId??``);if(!n)throw Error(`upload returned no fileId`);F(t=>[...t,{id:n,name:e.name,size:e.size,type:e.mimeType,url:e.url}])}catch(e){I(e?.message??String(e))}},[Wt]),Kt=(0,m.useCallback)(e=>{F(t=>t.filter(t=>t.id!==e))},[]),[qt,Jt]=(0,m.useState)({});(0,m.useEffect)(()=>{let e=new Set;for(let t of Ft)for(let n of t.attachments??[])n&&qt[n]===void 0&&e.add(n);if(!e.size)return;let t=``.replace(/\/$/,``),n=!1;return(async()=>{let r={};await Promise.all(Array.from(e).map(async e=>{try{let n=await L(`${t}/api/v1/data/sys_file/${encodeURIComponent(e)}`);if(!n.ok){r[e]=``;return}let i=await n.json().catch(()=>null);r[e]=String(i?.record?.name??i?.data?.name??i?.name??``)}catch{r[e]=``}})),n||Jt(e=>({...e,...r}))})(),()=>{n=!0}},[Ft,L]);let Yt=(0,m.useCallback)(async e=>{try{let t=``.replace(/\/$/,``),n=await L(`${t}/api/v1/storage/files/${encodeURIComponent(e)}/url`);if(!n.ok)throw Error(`HTTP_${n.status}`);let r=await n.json().catch(()=>null),i=r?.data?.url??r?.url;i&&window.open(i,`_blank`,`noopener`)}catch{}},[L]),[R,Xt]=(0,m.useState)(``),[z,Zt]=(0,m.useState)(``),[B,Qt]=(0,m.useState)(`all`),[V,$t]=(0,m.useState)(`all`),[H,en]=(0,m.useState)(`all`),[U,tn]=(0,m.useState)(new Set),[nn,rn]=(0,m.useState)(!1),[W,an]=(0,m.useState)(null),[on,sn]=(0,m.useState)(null),[G,cn]=(0,m.useState)(``),[ln,un]=(0,m.useState)(!1),[dn,fn]=(0,m.useState)(-1);(0,m.useEffect)(()=>{if(E===`pending`)return;let e=window.setTimeout(()=>Zt(R),350);return()=>window.clearTimeout(e)},[R,E]);let K=(0,m.useCallback)(async()=>{Et(!0),jt(null);try{let e=[];if(E===`pending`)e=x.length?(await g.listRequests({status:`pending`,approverId:x})).data:[],Nt(e.length),O(null);else{let t={q:z||void 0,status:H===`all`?void 0:H,limit:ut,offset:0};if(E===`submitted`){let n=a?.id;if(n){let r=await g.listRequests({submitterId:n,...t});e=r.data,O(r.total??r.data.length)}else e=[],O(0)}else{let n=await g.listRequests(t);e=n.data,O(n.total??n.data.length)}x.length&&g.listRequests({status:`pending`,approverId:x}).then(e=>Nt(e.data.length)).catch(()=>{})}e.sort((e,t)=>(b(t)||``).localeCompare(b(e)||``)),wt(e)}catch(e){jt(e?.message||String(e)),wt([])}finally{Et(!1)}},[E,x,a?.id,z,H]);(0,m.useEffect)(()=>{K()},[K]);let pn=(0,m.useCallback)(async()=>{if(!(E===`pending`||Dt)){Ot(!0);try{let e=await g.listRequests({submitterId:E===`submitted`?a?.id??void 0:void 0,q:z||void 0,status:H===`all`?void 0:H,limit:ut,offset:D.length});wt(t=>{let n=new Set(t.map(e=>e.id));return[...t,...e.data.filter(e=>!n.has(e.id))]}),e.total!=null&&O(e.total)}catch(e){p.error(T(e,S(`loadFailed`,`Failed to load request`)))}finally{Ot(!1)}}},[E,Dt,a?.id,z,H,D.length,T,S]),q=(0,m.useCallback)(async e=>{Pt(e),Lt(!0),N(``),zt(``),F([]),I(null);try{let[t,n]=await Promise.all([g.getRequest(e),g.listActions(e)]);j(t.data),M(n.data)}catch(e){p.error(T(e,S(`loadFailed`,`Failed to load request`))),j(null),M([])}finally{Lt(!1)}},[T,S]),mn=()=>{Pt(null),j(null),M([]),N(``),zt(``),F([]),I(null)};(0,m.useEffect)(()=>{let e=h.get(`request`);e&&(pt(e=>{let t=new URLSearchParams(e);return t.delete(`request`),t},{replace:!0}),q(e))},[h]);let hn=(0,m.useCallback)(e=>{if(P.trim())return P.trim();if(!e)return a?.id||``;let t=new Set(e.pending_approvers||[]);for(let e of x)if(t.has(e))return e;return a?.id||``},[P,x,a?.id]),J=(0,m.useCallback)(()=>{x.length&&g.listRequests({status:`pending`,approverId:x}).then(e=>Nt(e.data.length)).catch(()=>{})},[x]),gn=(0,m.useCallback)(async e=>{if(!A)return;let t=e===`recall`&&a?.id||hn(A);if(!t){p.error(S(`noActor`,`Cannot determine the acting identity`));return}Vt(e);try{let n={actor_id:t,comment:Rt.trim()||void 0,...e!==`recall`&&Ht.length?{attachments:Ht.map(e=>e.id)}:{}},r=await(e===`approve`?g.approve:e===`reject`?g.reject:g.recall)(A.id,n);if(p.success(e===`approve`?r.finalized?S(`approvedFinal`,`Approved`):S(`approvedWaiting`,`Approved — waiting on the remaining approvers`):e===`reject`?S(`rejectedToast`,`Rejected`):S(`recalledToast`,`Request recalled`)),N(``),F([]),I(null),e!==`recall`&&E===`pending`){let e=An.current,t=e.findIndex(e=>e.id===A.id),n=e[t+1]??e[t-1];K(),n&&n.id!==A.id?q(n.id):mn();return}let[i,a]=await Promise.all([g.getRequest(A.id),g.listActions(A.id)]);j(i.data),M(a.data),K()}catch(e){p.error(T(e,S(`actionFailed`,`Action failed`)))}finally{Vt(null)}},[A,hn,Rt,Ht,K,a?.id,T,S,E,q]),_n=(0,m.useCallback)(async e=>{let[t,n]=await Promise.all([g.getRequest(e),g.listActions(e)]);j(t.data),M(n.data),K()},[K]),vn=(0,m.useCallback)(async()=>{if(!(!A||!G.trim())){un(!0);try{await g.comment(A.id,{actor_id:a?.id,comment:G.trim()}),cn(``),await _n(A.id)}catch(e){p.error(T(e,S(`actionFailed`,`Action failed`)))}finally{un(!1)}}},[A,G,a?.id,_n,T,S]),yn=(0,m.useMemo)(()=>{if(!A||A.status!==`pending`)return!1;let e=new Set(A.pending_approvers||[]);return x.some(t=>e.has(t))||P.trim().length>0},[A,x,P]),bn=(0,m.useMemo)(()=>!A||A.status!==`pending`?!1:A.submitter_id===a?.id||P.trim().length>0,[A,a?.id,P]),xn=(0,m.useMemo)(()=>!A||A.status!==`returned`?!1:A.submitter_id===a?.id||P.trim().length>0,[A,a?.id,P]),Sn=(0,m.useMemo)(()=>{let e=new Set;for(let t of D)e.add(y(t));return Array.from(e).sort()},[D]),Cn=(0,m.useMemo)(()=>{let e=new Set;for(let t of D)t.object_name&&e.add(t.object_name);return Array.from(e).sort()},[D]),Y=(0,m.useMemo)(()=>{let e=R.trim().toLowerCase();return D.filter(t=>B!==`all`&&y(t)!==B||V!==`all`&&t.object_name!==V||H!==`all`&&t.status!==H?!1:E!==`pending`||!e||[t.process_name,t.process_label,t.step_label,t.object_name,t.record_id,t.record_title,t.submitter_id,t.submitter_name,...t.pending_approvers||[]].filter(Boolean).join(` `).toLowerCase().includes(e))},[D,R,B,V,H,E]),X=(0,m.useMemo)(()=>k?Y.findIndex(e=>e.id===k):-1,[Y,k]);(0,m.useEffect)(()=>{if(U.size===0)return;let e=new Set(Y.map(e=>e.id)),t=!1,n=new Set;for(let r of U)e.has(r)?n.add(r):t=!0;t&&tn(n)},[Y,U]),(0,m.useEffect)(()=>{dn>=Y.length&&fn(Y.length-1)},[Y.length,dn]);let Z=(0,m.useCallback)(e=>{if(e.status!==`pending`)return!1;let t=new Set(x);return(e.pending_approvers||[]).some(e=>t.has(e))},[x]),Q=(0,m.useMemo)(()=>Y.filter(e=>U.has(e.id)&&Z(e)),[Y,U,Z]),$=Y.filter(e=>e.status===`pending`),wn=$.length>0&&$.every(e=>U.has(e.id)),Tn=(0,m.useCallback)(()=>{tn(e=>{if(wn)return new Set;let t=new Set(e);for(let e of $)t.add(e.id);return t})},[wn,$]),En=(0,m.useCallback)(e=>{tn(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[]),Dn=(0,m.useCallback)(async e=>{let t=Q;if(t.length===0)return;rn(!0);let n=0,r=[];for(let i of t){let t=new Set(i.pending_approvers||[]),ee=x.find(e=>t.has(e))||a?.id||``;try{await(e===`approve`?g.approve:g.reject)(i.id,{actor_id:ee}),n++}catch{r.push(i.record_title||v(i.record_id))}}if(rn(!1),tn(new Set),r.length===0)p.success(e===`approve`?S(`bulkApproved`,`Approved {{count}} requests`,{count:n}):S(`bulkRejected`,`Rejected {{count}} requests`,{count:n}));else{let e=r.slice(0,3).join(`, `);p.error(S(`bulkPartial`,`{{ok}} succeeded, {{fail}} failed: {{which}}`,{ok:n,fail:r.length,which:e+(r.length>3?`…`:``)}))}K(),J()},[Q,x,a?.id,K,J,S]),On=(0,m.useCallback)(async e=>{if(!Z(e)||on)return;let t=new Set(e.pending_approvers||[]),n=x.find(e=>t.has(e))||a?.id||``;sn(e.id);try{let t=await g.approve(e.id,{actor_id:n});p.success(t.finalized?S(`inlineApproved`,`Approved "{{title}}"`,{title:e.record_title||v(e.record_id)}):S(`approvedWaiting`,`Approved — waiting on the remaining approvers`)),K(),J()}catch(e){p.error(T(e,S(`actionFailed`,`Action failed`)))}finally{sn(null)}},[Z,on,x,a?.id,K,J,T,S]),kn=(0,m.useCallback)(async()=>{let e=W;if(!e)return;let t=new Set(e.pending_approvers||[]),n=x.find(e=>t.has(e))||a?.id||``;sn(e.id),an(null);try{await g.reject(e.id,{actor_id:n}),p.success(S(`inlineRejected`,`Rejected "{{title}}"`,{title:e.record_title||v(e.record_id)})),K(),J()}catch(e){p.error(T(e,S(`actionFailed`,`Action failed`)))}finally{sn(null)}},[W,x,a?.id,K,J,T,S]),An=(0,m.useRef)(Y);An.current=Y;let jn=(0,m.useRef)(dn);jn.current=dn,(0,m.useEffect)(()=>{let e=e=>{if(k||W)return;let t=e.target,n=t?.tagName;if(n===`INPUT`||n===`TEXTAREA`||n===`SELECT`||t?.isContentEditable||document.querySelector(`[role="alertdialog"]`))return;let r=An.current;if(!r.length)return;let i=jn.current;e.key===`j`||e.key===`ArrowDown`?(e.preventDefault(),fn(Math.min(i+1,r.length-1))):e.key===`k`||e.key===`ArrowUp`?(e.preventDefault(),fn(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]&&E===`pending`?(e.preventDefault(),En(r[i].id)):e.key===`a`&&i>=0&&r[i]?(e.preventDefault(),On(r[i])):e.key===`r`&&i>=0&&r[i]&&Z(r[i])&&(e.preventDefault(),an(r[i]))};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[k,W,E,q,En,On,Z]),(0,m.useEffect)(()=>{if(!k)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=An.current,i=r.findIndex(e=>e.id===k);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)},[k,q]);let Mn=!!R||B!==`all`||V!==`all`||H!==`all`,Nn=e=>{Ct(e),en(`all`),Qt(`all`),$t(`all`),Xt(``),fn(-1)};function Pn({r:e}){return(0,_.jsxs)(`div`,{className:`min-w-0`,children:[(0,_.jsx)(`div`,{className:`font-medium truncate`,children:y(e)}),(0,_.jsxs)(`div`,{className:`text-xs text-muted-foreground truncate`,children:[mt(e)||`—`,(e.round??1)>1&&(0,_.jsx)(`span`,{className:`ml-1.5 text-violet-600 dark:text-violet-400`,children:S(`roundChip`,`Round {{n}}`,{n:e.round})})]})]})}function Fn({r:e}){return(0,_.jsxs)(`div`,{className:`min-w-0`,children:[(0,_.jsxs)(t,{to:St(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,_.jsx)(`span`,{className:`truncate`,children:e.record_title||v(e.record_id)}),(0,_.jsx)(Ze,{className:`h-3 w-3 shrink-0 text-muted-foreground`})]}),(0,_.jsx)(`div`,{className:`text-xs text-muted-foreground truncate`,children:_t(e)})]})}function In({r:e}){if(!Z(e))return null;let t=on===e.id;return(0,_.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,_.jsx)(c,{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 On(e),"aria-label":S(`approve`,`Approve`),children:(0,_.jsx)(fe,{className:`h-4 w-4`})}),(0,_.jsx)(c,{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:()=>an(e),"aria-label":S(`reject`,`Reject`),children:(0,_.jsx)(le,{className:`h-4 w-4`})})]})}return(0,_.jsxs)(`div`,{className:`flex flex-col gap-4 sm:gap-6 p-4 sm:p-6 max-w-6xl`,children:[(0,_.jsxs)(`header`,{className:`flex flex-col sm:flex-row sm:items-center sm:justify-between gap-2`,children:[(0,_.jsxs)(`div`,{children:[(0,_.jsxs)(`h1`,{className:`text-2xl font-semibold flex items-center gap-2`,children:[(0,_.jsx)(Ne,{className:`h-6 w-6`}),S(`title`,`Approvals Inbox`)]}),(0,_.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:S(`subtitle`,`Review and act on approval requests.`)})]}),(0,_.jsxs)(c,{variant:`outline`,size:`sm`,onClick:K,disabled:Tt,className:`self-start sm:self-auto`,children:[(0,_.jsx)(Ee,{className:`h-4 w-4 mr-2 ${Tt?`animate-spin`:``}`}),S(`refresh`,`Refresh`)]})]}),At&&(0,_.jsxs)(Be,{variant:`destructive`,children:[(0,_.jsx)(ve,{className:`h-4 w-4`}),(0,_.jsx)(Ae,{children:At})]}),(0,_.jsxs)(He,{value:E,onValueChange:Nn,children:[(0,_.jsxs)(je,{children:[(0,_.jsxs)(et,{value:`pending`,children:[S(`tabMyPending`,`My Pending`),Mt>0&&(0,_.jsx)(u,{variant:`secondary`,className:`ml-2`,children:Mt})]}),(0,_.jsx)(et,{value:`submitted`,children:S(`tabSubmitted`,`Submitted by me`)}),(0,_.jsx)(et,{value:`all`,children:S(`tabAll`,`All`)})]}),(0,_.jsxs)(Ve,{value:E,className:`mt-4 space-y-3`,children:[!Tt&&(D.length>0||E!==`pending`&&(z||H!==`all`))&&(0,_.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,_.jsxs)(`div`,{className:`relative flex-1 min-w-[200px] max-w-sm`,children:[(0,_.jsx)(pe,{className:`absolute left-2.5 top-1/2 -translate-y-1/2 h-3.5 w-3.5 text-muted-foreground`}),(0,_.jsx)(Ue,{value:R,onChange:e=>Xt(e.target.value),placeholder:S(`searchPlaceholder`,`Search record, process, requester…`),className:`pl-8 h-8 text-sm`}),R&&(0,_.jsx)(`button`,{type:`button`,onClick:()=>Xt(``),className:`absolute right-2 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground`,"aria-label":S(`clearSearch`,`Clear search`),children:(0,_.jsx)(de,{className:`h-3.5 w-3.5`})})]}),E!==`pending`&&(0,_.jsxs)(ie,{value:H,onValueChange:en,children:[(0,_.jsx)(Ge,{className:`h-8 w-auto min-w-[130px] text-sm`,children:(0,_.jsx)(Ye,{placeholder:S(`statusFilter`,`Status`)})}),(0,_.jsxs)(Le,{children:[(0,_.jsx)(d,{value:`all`,children:S(`allStatuses`,`All statuses`)}),(0,_.jsx)(d,{value:`pending`,children:w(`pending`)}),(0,_.jsx)(d,{value:`approved`,children:w(`approved`)}),(0,_.jsx)(d,{value:`rejected`,children:w(`rejected`)}),(0,_.jsx)(d,{value:`recalled`,children:w(`recalled`)}),(0,_.jsx)(d,{value:`returned`,children:w(`returned`)})]})]}),Sn.length>1&&(0,_.jsxs)(ie,{value:B,onValueChange:Qt,children:[(0,_.jsx)(Ge,{className:`h-8 w-auto min-w-[140px] text-sm`,children:(0,_.jsx)(Ye,{placeholder:S(`processFilter`,`Process`)})}),(0,_.jsxs)(Le,{children:[(0,_.jsx)(d,{value:`all`,children:S(`allProcesses`,`All processes`)}),Sn.map(e=>(0,_.jsx)(d,{value:e,children:e},e))]})]}),Cn.length>1&&(0,_.jsxs)(ie,{value:V,onValueChange:$t,children:[(0,_.jsx)(Ge,{className:`h-8 w-auto min-w-[140px] text-sm`,children:(0,_.jsx)(Ye,{placeholder:S(`objectFilter`,`Object`)})}),(0,_.jsxs)(Le,{children:[(0,_.jsx)(d,{value:`all`,children:S(`allObjects`,`All objects`)}),Cn.map(e=>(0,_.jsx)(d,{value:e,children:e},e))]})]}),Mn&&(0,_.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:S(`filterCount`,`{{shown}} of {{total}}`,{shown:Y.length,total:D.length})})]}),E===`pending`&&U.size>0&&(0,_.jsxs)(`div`,{className:`flex items-center justify-between gap-2 px-3 py-2 rounded-md border bg-accent/30 text-sm`,children:[(0,_.jsxs)(`span`,{children:[(0,_.jsx)(`strong`,{children:U.size}),` `,S(`selected`,`selected`),Q.length!==U.size&&(0,_.jsx)(`span`,{className:`text-muted-foreground ml-1`,children:S(`actionableCount`,`({{count}} actionable)`,{count:Q.length})})]}),(0,_.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,_.jsxs)(it,{children:[(0,_.jsx)(se,{asChild:!0,children:(0,_.jsxs)(c,{size:`sm`,disabled:nn||Q.length===0,children:[(0,_.jsx)(fe,{className:`h-3.5 w-3.5 mr-1`}),S(`approveN`,`Approve {{count}}`,{count:Q.length||``})]})}),(0,_.jsxs)(ye,{children:[(0,_.jsxs)(xe,{children:[(0,_.jsx)(ce,{children:S(`bulkApproveTitle`,`Approve {{count}} requests?`,{count:Q.length})}),(0,_.jsx)(ae,{children:S(`bulkApproveBody`,`Each request is approved with your identity and its flow continues down the approve branch.`)})]}),(0,_.jsxs)(tt,{children:[(0,_.jsx)(rt,{children:S(`cancel`,`Cancel`)}),(0,_.jsx)(Pe,{onClick:()=>Dn(`approve`),children:S(`approveN`,`Approve {{count}}`,{count:Q.length})})]})]})]}),(0,_.jsxs)(it,{children:[(0,_.jsx)(se,{asChild:!0,children:(0,_.jsxs)(c,{size:`sm`,variant:`outline`,disabled:nn||Q.length===0,className:`border-destructive text-destructive hover:bg-destructive hover:text-destructive-foreground`,children:[(0,_.jsx)(le,{className:`h-3.5 w-3.5 mr-1`}),S(`rejectN`,`Reject {{count}}`,{count:Q.length||``})]})}),(0,_.jsxs)(ye,{children:[(0,_.jsxs)(xe,{children:[(0,_.jsx)(ce,{children:S(`bulkRejectTitle`,`Reject {{count}} requests?`,{count:Q.length})}),(0,_.jsx)(ae,{children:S(`bulkRejectBody`,`This rejects the selected requests and notifies their submitters.`)})]}),(0,_.jsxs)(tt,{children:[(0,_.jsx)(rt,{children:S(`cancel`,`Cancel`)}),(0,_.jsx)(Pe,{onClick:()=>Dn(`reject`),className:`bg-destructive text-destructive-foreground hover:bg-destructive/90`,children:S(`rejectN`,`Reject {{count}}`,{count:Q.length})})]})]})]}),(0,_.jsx)(c,{size:`sm`,variant:`ghost`,onClick:()=>tn(new Set),disabled:nn,children:S(`clear`,`Clear`)})]})]}),Tt?(0,_.jsxs)(`div`,{className:`space-y-2`,children:[(0,_.jsx)(o,{className:`h-10 w-full`}),(0,_.jsx)(o,{className:`h-10 w-full`}),(0,_.jsx)(o,{className:`h-10 w-full`})]}):D.length===0?(0,_.jsx)(`div`,{className:`flex items-center justify-center min-h-[240px] rounded-md border border-dashed`,children:(0,_.jsxs)(Oe,{children:[(0,_.jsx)(Qe,{children:S(`emptyTitle`,`No requests`)}),(0,_.jsx)(ge,{children:E===`pending`?S(`emptyPending`,`You're all caught up — nothing is waiting on you.`):S(`emptyOther`,`Nothing here yet.`)}),E===`pending`&&(0,_.jsx)(c,{variant:`link`,size:`sm`,className:`mt-1`,onClick:()=>Nn(`all`),children:S(`emptyViewAll`,`Browse all requests`)})]})}):Y.length===0?(0,_.jsx)(`div`,{className:`flex items-center justify-center min-h-[160px] rounded-md border border-dashed text-sm text-muted-foreground`,children:S(`noMatches`,`No matches for current filters.`)}):(0,_.jsxs)(_.Fragment,{children:[(0,_.jsx)(Ke,{className:`hidden md:block`,children:(0,_.jsx)(Xe,{className:`p-0`,children:(0,_.jsxs)(at,{children:[(0,_.jsx)(oe,{children:(0,_.jsxs)(nt,{children:[E===`pending`&&(0,_.jsx)(l,{className:`w-10`,children:(0,_.jsx)(Me,{checked:wn,onCheckedChange:Tn,"aria-label":S(`selectAll`,`Select all`),disabled:$.length===0})}),(0,_.jsx)(l,{children:S(`colRequest`,`Request`)}),(0,_.jsx)(l,{children:S(`colRecord`,`Record`)}),(0,_.jsx)(l,{children:S(`colRequester`,`Requester`)}),(0,_.jsx)(l,{children:S(`colStatus`,`Status`)}),(0,_.jsx)(l,{children:S(`colWaiting`,`Submitted`)}),(0,_.jsx)(l,{className:`w-20`,"aria-label":S(`colActions`,`Actions`)})]})}),(0,_.jsx)(Ie,{children:Y.map((e,t)=>(0,_.jsxs)(nt,{className:s(`group cursor-pointer hover:bg-accent/50`,dn===t&&`ring-2 ring-inset ring-ring bg-accent/30`),onClick:()=>{fn(t),q(e.id)},children:[E===`pending`&&(0,_.jsx)(f,{className:`w-10`,onClick:e=>e.stopPropagation(),children:(0,_.jsx)(Me,{checked:U.has(e.id),onCheckedChange:()=>En(e.id),disabled:e.status!==`pending`,"aria-label":S(`selectRow`,`Select request`)})}),(0,_.jsx)(f,{children:(0,_.jsx)(Pn,{r:e})}),(0,_.jsx)(f,{children:(0,_.jsx)(Fn,{r:e})}),(0,_.jsx)(f,{children:(0,_.jsxs)(`div`,{className:`flex items-center gap-1.5 text-sm`,children:[(0,_.jsx)(Ce,{className:`h-3.5 w-3.5 text-muted-foreground shrink-0`}),(0,_.jsx)(`span`,{className:`truncate`,title:e.submitter_id||``,children:ht(e)})]})}),(0,_.jsx)(f,{children:(0,_.jsx)(xt,{status:e.status})}),(0,_.jsxs)(f,{className:s(`text-xs whitespace-nowrap`,vt(e)),title:ft(b(e)),children:[(0,_.jsx)(Fe,{className:`h-3 w-3 inline mr-1`}),C(b(e)),e.status===`pending`&&e.sla_due_at&&(0,_.jsx)(`div`,{className:s(`mt-0.5 text-[10px] font-medium`,Date.parse(e.sla_due_at)<Date.now()?`text-red-600 dark:text-red-400`:`text-muted-foreground`),children:Date.parse(e.sla_due_at)<Date.now()?S(`slaOverdue`,`SLA overdue {{dur}}`,{dur:yt(Date.now()-Date.parse(e.sla_due_at))}):S(`slaRemaining`,`SLA {{dur}} left`,{dur:yt(Date.parse(e.sla_due_at)-Date.now())})})]}),(0,_.jsx)(f,{className:`w-20`,children:(0,_.jsx)(In,{r:e})})]},e.id))})]})})}),(0,_.jsx)(`div`,{className:`md:hidden space-y-2`,children:Y.map(e=>(0,_.jsx)(Ke,{className:`cursor-pointer active:bg-accent/50`,onClick:()=>void q(e.id),children:(0,_.jsxs)(Xe,{className:`p-3 space-y-1.5`,children:[(0,_.jsxs)(`div`,{className:`flex items-start justify-between gap-2`,children:[(0,_.jsx)(`div`,{className:`font-medium text-sm truncate`,children:y(e)}),(0,_.jsx)(xt,{status:e.status})]}),(0,_.jsxs)(`div`,{className:`text-sm truncate`,children:[e.record_title||v(e.record_id),(0,_.jsx)(`span`,{className:`text-muted-foreground text-xs ml-1.5`,children:_t(e)})]}),(0,_.jsxs)(`div`,{className:`flex items-center justify-between text-xs text-muted-foreground`,children:[(0,_.jsxs)(`span`,{className:`inline-flex items-center gap-1 truncate`,children:[(0,_.jsx)(Ce,{className:`h-3 w-3`}),ht(e)]}),(0,_.jsxs)(`span`,{className:s(`inline-flex items-center gap-1 whitespace-nowrap`,vt(e)),children:[(0,_.jsx)(Fe,{className:`h-3 w-3`}),C(b(e))]})]}),Z(e)&&(0,_.jsxs)(`div`,{className:`flex gap-2 pt-1`,onClick:e=>e.stopPropagation(),children:[(0,_.jsxs)(c,{size:`sm`,className:`h-7 flex-1`,disabled:on===e.id,onClick:()=>void On(e),children:[(0,_.jsx)(fe,{className:`h-3.5 w-3.5 mr-1`}),S(`approve`,`Approve`)]}),(0,_.jsxs)(c,{size:`sm`,variant:`outline`,className:`h-7 flex-1 border-destructive text-destructive`,disabled:on===e.id,onClick:()=>an(e),children:[(0,_.jsx)(le,{className:`h-3.5 w-3.5 mr-1`}),S(`reject`,`Reject`)]})]})]})},e.id))}),E!==`pending`&&kt!=null&&(0,_.jsxs)(`div`,{className:`flex items-center justify-center gap-3 py-1`,children:[(0,_.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:S(`loadedOf`,`Loaded {{loaded}} of {{total}}`,{loaded:D.length,total:kt})}),D.length<kt&&(0,_.jsx)(c,{size:`sm`,variant:`outline`,disabled:Dt,onClick:()=>void pn(),children:Dt?S(`loadingMore`,`Loading…`):S(`loadMore`,`Load more`)})]}),(0,_.jsx)(`div`,{className:`hidden md:block text-[11px] text-muted-foreground`,children:S(`keyboardHint`,`Keyboard: j/k move · Enter open · x select · a approve · r reject`)})]})]})]}),(0,_.jsx)(it,{open:!!W,onOpenChange:e=>!e&&an(null),children:(0,_.jsxs)(ye,{children:[(0,_.jsxs)(xe,{children:[(0,_.jsx)(ce,{children:S(`rejectOneTitle`,`Reject "{{title}}"?`,{title:W?W.record_title||v(W.record_id):``})}),(0,_.jsx)(ae,{children:S(`rejectOneBody`,`This rejects the request and notifies the submitter.`)})]}),(0,_.jsxs)(tt,{children:[(0,_.jsx)(rt,{children:S(`cancel`,`Cancel`)}),(0,_.jsx)(Pe,{onClick:()=>void kn(),className:`bg-destructive text-destructive-foreground hover:bg-destructive/90`,children:S(`reject`,`Reject`)})]})]})}),(0,_.jsx)(Je,{open:!!k,onOpenChange:e=>!e&&mn(),children:(0,_.jsxs)(me,{className:`w-full sm:max-w-xl overflow-y-auto`,children:[(0,_.jsxs)(Te,{children:[(0,_.jsx)(ke,{children:A?y(A):S(`drawerTitle`,`Approval Request`)}),(0,_.jsx)(De,{children:A?mt(A)||_t(A):``})]}),A&&X>=0&&Y.length>1&&(0,_.jsxs)(`div`,{className:`flex items-center justify-between mt-2 text-xs text-muted-foreground`,children:[(0,_.jsxs)(c,{variant:`ghost`,size:`sm`,className:`h-7 px-2`,disabled:X<=0,onClick:()=>{let e=Y[X-1];e&&q(e.id)},children:[(0,_.jsx)(he,{className:`h-4 w-4 mr-0.5`}),S(`prevRequest`,`Previous`)]}),(0,_.jsx)(`span`,{children:S(`positionOf`,`{{index}} of {{total}}`,{index:X+1,total:Y.length})}),(0,_.jsxs)(c,{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:[S(`nextRequest`,`Next`),(0,_.jsx)(we,{className:`h-4 w-4 ml-0.5`})]})]}),It?(0,_.jsxs)(`div`,{className:`space-y-2 mt-6`,children:[(0,_.jsx)(o,{className:`h-6 w-3/4`}),(0,_.jsx)(o,{className:`h-6 w-1/2`}),(0,_.jsx)(o,{className:`h-20 w-full`})]}):A?(0,_.jsxs)(`div`,{className:`space-y-4 mt-6`,children:[(0,_.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 text-xs text-muted-foreground`,children:[(0,_.jsx)(xt,{status:A.status}),(A.round??1)>1&&(0,_.jsx)(u,{variant:`outline`,className:`text-[10px] border-violet-200 text-violet-700 dark:border-violet-500/30 dark:text-violet-400`,children:S(`roundChip`,`Round {{n}}`,{n:A.round})}),(0,_.jsxs)(`span`,{className:`inline-flex items-center gap-1`,title:ft(b(A)),children:[(0,_.jsx)(Fe,{className:`h-3 w-3`}),S(`submittedAgo`,`Submitted {{when}}`,{when:C(b(A))})]}),A.completed_at&&(0,_.jsxs)(`span`,{children:[`· `,S(`completedAt`,`Completed {{when}}`,{when:C(A.completed_at)})]}),A.status===`pending`&&A.sla_due_at&&(0,_.jsx)(u,{variant:`outline`,className:s(`text-[10px]`,Date.parse(A.sla_due_at)<Date.now()?`border-red-200 bg-red-50 text-red-700 dark:border-red-500/30 dark:bg-red-500/10 dark:text-red-400`:`border-border text-muted-foreground`),children:Date.parse(A.sla_due_at)<Date.now()?S(`slaOverdue`,`SLA overdue {{dur}}`,{dur:yt(Date.now()-Date.parse(A.sla_due_at))}):S(`slaRemaining`,`SLA {{dur}} left`,{dur:yt(Date.parse(A.sla_due_at)-Date.now())})})]}),(0,_.jsx)(Ke,{children:(0,_.jsxs)(Xe,{className:`p-4 space-y-3`,children:[(0,_.jsxs)(`div`,{className:`flex items-start justify-between gap-2`,children:[(0,_.jsxs)(`div`,{className:`min-w-0`,children:[(0,_.jsxs)(t,{to:St(A),className:`text-base font-semibold hover:underline inline-flex items-center gap-1.5`,children:[(0,_.jsx)(`span`,{className:`truncate`,children:A.record_title||v(A.record_id)}),(0,_.jsx)(Ze,{className:`h-3.5 w-3.5 shrink-0 text-muted-foreground`})]}),(0,_.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:_t(A)})]}),(0,_.jsx)(`div`,{className:`text-right text-xs text-muted-foreground shrink-0`,children:(0,_.jsxs)(`div`,{className:`inline-flex items-center gap-1`,children:[(0,_.jsx)(Ce,{className:`h-3 w-3`}),(0,_.jsx)(`span`,{title:A.submitter_id||``,children:ht(A)})]})})]}),bt(A.payload,A.payload_display).length>0&&(0,_.jsx)(`div`,{className:`grid grid-cols-2 gap-x-4 gap-y-2 text-sm border-t pt-3`,children:bt(A.payload,A.payload_display).map(([e,t])=>(0,_.jsxs)(`div`,{className:`min-w-0`,children:[(0,_.jsx)(`div`,{className:`text-[11px] text-muted-foreground`,children:e}),(0,_.jsx)(`div`,{className:`truncate`,title:t,children:t})]},e))}),A.decision_progress&&(0,_.jsxs)(`div`,{className:`border-t pt-3`,children:[(0,_.jsx)(`div`,{className:`text-[11px] text-muted-foreground mb-1`,children:A.decision_progress.behavior===`per_group`?S(`progressGroups`,`Sign-off progress — {{got}} of {{need}} groups`,{got:A.decision_progress.got,need:A.decision_progress.need}):S(`progressApprovals`,`Approvals — {{got}} of {{need}}`,{got:A.decision_progress.got,need:A.decision_progress.need})}),A.decision_progress.groups&&(0,_.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:A.decision_progress.groups.map(e=>(0,_.jsxs)(u,{variant:`outline`,className:s(`text-[11px] gap-1`,e.satisfied?`border-emerald-300 text-emerald-700 dark:border-emerald-700 dark:text-emerald-400`:`text-muted-foreground`),title:`${e.got}/${e.need}`,children:[e.satisfied?(0,_.jsx)(qe,{className:`h-3 w-3`}):null,e.group,` `,e.got,`/`,e.need]},e.group))})]}),A.status===`pending`&&(A.pending_approvers||[]).length>0&&(0,_.jsxs)(`div`,{className:`border-t pt-3`,children:[(0,_.jsx)(`div`,{className:`text-[11px] text-muted-foreground mb-1`,children:S(`waitingOn`,`Waiting on`)}),(0,_.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:(A.pending_approvers||[]).map((e,t)=>(0,_.jsx)(u,{variant:`outline`,className:`text-[11px]`,title:e,children:gt(e,A)},t))})]})]})}),(A.flow_steps?.length??0)>1&&(0,_.jsx)(`div`,{className:`flex items-center px-1`,"aria-label":S(`stepProgress`,`Approval steps`),children:A.flow_steps.map((e,t)=>(0,_.jsxs)(m.Fragment,{children:[t>0&&(0,_.jsx)(`div`,{className:s(`h-px flex-1 mx-2`,e.state===`done`||e.state===`current`?`bg-emerald-300 dark:bg-emerald-700`:`bg-border`)}),(0,_.jsxs)(`div`,{className:`flex items-center gap-1.5 shrink-0`,children:[(0,_.jsx)(`span`,{className:s(`flex items-center justify-center h-5 w-5 rounded-full text-[10px] font-semibold`,e.state===`done`&&`bg-emerald-500 text-white`,e.state===`current`&&`bg-amber-500 text-white ring-2 ring-amber-200 dark:ring-amber-500/30`,e.state===`upcoming`&&`bg-muted text-muted-foreground border`),children:e.state===`done`?(0,_.jsx)(qe,{className:`h-3 w-3`}):t+1}),(0,_.jsx)(`span`,{className:s(`text-xs`,e.state===`current`?`font-medium`:`text-muted-foreground`),children:e.label})]})]},e.id))}),(0,_.jsxs)(`div`,{children:[(0,_.jsx)(`h3`,{className:`text-sm font-semibold mb-3`,children:S(`history`,`Activity`)}),Ft.length===0?(0,_.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:S(`noActions`,`No actions yet.`)}):(0,_.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:Ft.map(e=>{let t=e.action===`approve`?`bg-emerald-500`:e.action===`reject`?`bg-destructive`:e.action===`submit`?`bg-blue-500`:e.action===`reassign`?`bg-indigo-500`:e.action===`remind`||e.action===`request_info`?`bg-amber-500`:e.action===`comment`?`bg-slate-400`:e.action===`escalate`?`bg-red-500`:e.action===`revise`?`bg-violet-500`:e.action===`resubmit`?`bg-blue-500`:`bg-muted-foreground`,n=e.actor_id===`system:sla`?S(`systemSlaActor`,`System (SLA)`):e.actor_name??(e.actor_id&&e.actor_id===A.submitter_id?ht(A):v(e.actor_id)),r=e.action===`submit`?S(`actSubmit`,`Submitted`):e.action===`approve`?S(`actApprove`,`Approved`):e.action===`reject`?S(`actReject`,`Rejected`):e.action===`recall`?S(`actRecall`,`Recalled`):e.action===`reassign`?S(`actReassign`,`Reassigned`):e.action===`remind`?S(`actRemind`,`Reminder sent`):e.action===`request_info`?S(`actRequestInfo`,`Requested more info`):e.action===`comment`?S(`actComment`,`Commented`):e.action===`escalate`?S(`actEscalate`,`SLA escalated`):e.action===`revise`?S(`actRevise`,`Sent back for revision`):e.action===`resubmit`?S(`actResubmit`,`Resubmitted`):e.action;return(0,_.jsxs)(`li`,{className:`relative text-xs`,children:[(0,_.jsx)(`span`,{className:`absolute -left-[18px] top-1 h-3 w-3 rounded-full ring-2 ring-background ${t}`,"aria-hidden":!0}),(0,_.jsxs)(`div`,{className:`flex items-baseline gap-1.5 flex-wrap`,children:[(0,_.jsx)(`span`,{className:`font-medium`,children:r}),(0,_.jsx)(`span`,{className:`text-muted-foreground`,children:`·`}),(0,_.jsx)(`span`,{title:e.actor_id||``,children:n}),(0,_.jsx)(`span`,{className:`ml-auto text-muted-foreground text-[10px]`,title:ft(e.created_at),children:C(e.created_at)})]}),e.comment&&(0,_.jsxs)(`div`,{className:`text-muted-foreground italic mt-0.5`,children:[`"`,e.comment,`"`]}),Array.isArray(e.attachments)&&e.attachments.length>0&&(0,_.jsx)(`div`,{className:`flex flex-wrap gap-1.5 mt-1`,children:e.attachments.map((t,n)=>(0,_.jsxs)(`button`,{type:`button`,onClick:()=>void Yt(t),className:`inline-flex items-center gap-1 text-[11px] px-2 py-0.5 rounded-full border text-muted-foreground hover:text-foreground hover:bg-accent transition-colors`,title:t,children:[(0,_.jsx)(Re,{className:`h-3 w-3`}),qt[t]||`${S(`attachmentChip`,`Attachment`)}${e.attachments.length>1?` ${n+1}`:``}`]},t))})]},e.id)})}),A.status===`pending`&&(yn||bn)&&(0,_.jsxs)(`div`,{className:`flex items-center gap-2 mt-3`,children:[(0,_.jsx)(Ue,{value:G,onChange:e=>cn(e.target.value),onKeyDown:e=>{e.key===`Enter`&&G.trim()&&(e.preventDefault(),vn())},placeholder:S(`replyPlaceholder`,`Reply on this request…`),className:`h-8 text-sm`}),(0,_.jsx)(c,{size:`sm`,variant:`outline`,className:`h-8 px-2 shrink-0`,disabled:!G.trim()||ln,onClick:()=>void vn(),children:(0,_.jsx)(ue,{className:`h-3.5 w-3.5`})})]})]}),A.payload!=null&&(0,_.jsxs)(`details`,{className:`group`,children:[(0,_.jsx)(`summary`,{className:`cursor-pointer text-xs text-muted-foreground hover:text-foreground select-none`,children:S(`rawData`,`Raw data (JSON)`)}),(0,_.jsxs)(`div`,{className:`mt-2`,children:[(0,_.jsx)(`div`,{className:`flex justify-end`,children:(0,_.jsxs)(`button`,{type:`button`,onClick:async()=>{try{await navigator.clipboard.writeText(JSON.stringify(A.payload,null,2)),p.success(S(`copied`,`Copied`))}catch{p.error(S(`copyFailed`,`Copy failed`))}},className:`text-[10px] text-muted-foreground hover:text-foreground inline-flex items-center gap-1`,children:[(0,_.jsx)(ze,{className:`h-3 w-3`}),S(`copy`,`Copy`)]})}),(0,_.jsx)(`pre`,{className:`text-[11px] bg-muted/50 rounded p-2 overflow-auto max-h-48 mt-1`,children:JSON.stringify(A.payload,null,2)})]})]}),A.status===`pending`&&(0,_.jsxs)(_.Fragment,{children:[(0,_.jsx)(_e,{}),(0,_.jsxs)(`div`,{className:`space-y-3`,children:[te&&(0,_.jsxs)(`details`,{className:`group`,children:[(0,_.jsx)(`summary`,{className:`cursor-pointer text-xs text-muted-foreground hover:text-foreground select-none`,children:S(`overrideActor`,`Act as another identity (admin)`)}),(0,_.jsxs)(`div`,{className:`mt-2`,children:[(0,_.jsx)($e,{htmlFor:`actor-override`,className:`text-xs`,children:S(`actor`,`Actor`)}),(0,_.jsx)(`input`,{id:`actor-override`,type:`text`,value:P,onChange:e=>zt(e.target.value),placeholder:`${S(`auto`,`Auto`)}: ${hn(A)||`—`}`,className:`w-full mt-1 px-3 py-2 text-sm border rounded-md bg-background`}),(0,_.jsx)(`div`,{className:`text-[10px] text-muted-foreground mt-1`,children:S(`overrideHint`,`e.g. role:sales_manager. Leave blank to use the auto-detected identity.`)})]})]}),(0,_.jsxs)(`div`,{children:[(0,_.jsx)($e,{htmlFor:`comment`,className:`text-xs`,children:S(`comment`,`Comment (optional)`)}),(0,_.jsx)(`div`,{className:`flex flex-wrap gap-1.5 mt-1.5`,children:[S(`quickPhrase1`,`Approved — meets requirements.`),S(`quickPhrase2`,`Approved with conditions — please monitor execution.`),S(`quickPhrase3`,`Please add supporting material and resubmit.`)].map(e=>(0,_.jsx)(`button`,{type:`button`,onClick:()=>N(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,_.jsx)(We,{id:`comment`,value:Rt,onChange:e=>N(e.target.value),rows:2,className:`mt-1`}),(0,_.jsx)(st,{className:`mt-2`,attachments:Ht,onUpload:Gt,onRemove:Kt}),Ut&&(0,_.jsx)(`div`,{className:`text-xs text-destructive mt-1`,children:Ut})]}),(0,_.jsxs)(`div`,{className:`flex gap-2 flex-wrap`,children:[(0,_.jsxs)(c,{size:`sm`,onClick:()=>gn(`approve`),disabled:!yn||Bt!==null,children:[(0,_.jsx)(fe,{className:`h-4 w-4 mr-1`}),Bt===`approve`?S(`approving`,`Approving…`):S(`approve`,`Approve`)]}),(0,_.jsxs)(it,{children:[(0,_.jsx)(se,{asChild:!0,children:(0,_.jsxs)(c,{size:`sm`,variant:`outline`,disabled:!yn||Bt!==null,className:`border-destructive text-destructive hover:bg-destructive hover:text-destructive-foreground`,children:[(0,_.jsx)(le,{className:`h-4 w-4 mr-1`}),Bt===`reject`?S(`rejecting`,`Rejecting…`):S(`reject`,`Reject`)]})}),(0,_.jsxs)(ye,{children:[(0,_.jsxs)(xe,{children:[(0,_.jsx)(ce,{children:S(`rejectTitle`,`Reject this request?`)}),(0,_.jsx)(ae,{children:S(`rejectBody`,`This marks the request as rejected and notifies the submitter.`)})]}),(0,_.jsxs)(tt,{children:[(0,_.jsx)(rt,{children:S(`cancel`,`Cancel`)}),(0,_.jsx)(Pe,{onClick:()=>gn(`reject`),className:`bg-destructive text-destructive-foreground hover:bg-destructive/90`,children:S(`reject`,`Reject`)})]})]})]})]}),!yn&&(0,_.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:bn?S(`whyDisabledSubmitter`,`You submitted this request, so you can recall it — but only the assigned approvers can approve or reject.`):S(`whyDisabled`,`Only the assigned approvers can act on this request. It is waiting on: {{who}}.`,{who:(A.pending_approvers||[]).map(e=>gt(e,A)).join(`, `)||`—`})}),(0,_.jsx)(ot,{objectName:`sys_approval_request`,record:A,location:`record_section`,exclude:[`approval_approve`,`approval_reject`],label:S(`declaredActions`,`More actions`),onDone:()=>{_n(A.id),K()}})]})]}),xn&&(0,_.jsxs)(_.Fragment,{children:[(0,_.jsx)(_e,{}),(0,_.jsxs)(`div`,{className:`space-y-3`,children:[(0,_.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:S(`returnedHint`,`An approver sent this back to you. The record is unlocked — fix the data, then resubmit to start a new approval round.`)}),(0,_.jsxs)(`div`,{className:`flex gap-2 flex-wrap items-center`,children:[(0,_.jsx)(c,{asChild:!0,size:`sm`,variant:`outline`,children:(0,_.jsxs)(t,{to:St(A),children:[(0,_.jsx)(Ze,{className:`h-4 w-4 mr-1`}),S(`editRecordBtn`,`Edit record`)]})}),(0,_.jsx)(ot,{objectName:`sys_approval_request`,record:A,location:`record_section`,exclude:[`approval_approve`,`approval_reject`],onDone:()=>{_n(A.id),K()}})]})]})]})]}):null]})})]})}export{xt as ApprovalsInboxPage};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{o as e}from"./rolldown-runtime-DAXXjFlN.js";import{r as t,y as n}from"./vendor-react-BKSb6vFP.js";import{$n as r,Mc as i,Or as a,Qn as o,Rs as s,Uc as c,Va as l,Xn as u,Ya as d,Zn as f,bs as p,er as m,ho as h,mn as g,rc as _,ro as v,tc as y,tr as b,xi as x,yi as S}from"./ui-components-BluZyuZX.js";import{a as C,i as w,n as T,o as E,r as D,s as O,t as k}from"./plugin-view-BhPeq9o5.js";var A=e(n(),1),j=t();function M({title:e,description:t,icon:n,actions:r,accentColor:a,sticky:o=!1,className:s,"data-testid":c}){return(0,j.jsxs)(`div`,{style:{"--page-header-accent":a||`hsl(var(--primary))`},className:i(`relative shrink-0 border-b bg-background z-10`,o&&`sticky top-0 bg-background/85 backdrop-blur supports-[backdrop-filter]:bg-background/75`,s),"data-testid":c??`page-header`,children:[(0,j.jsx)(`div`,{"aria-hidden":!0,className:`pointer-events-none absolute inset-x-0 top-0 h-[2px] opacity-80`,style:{background:`linear-gradient(90deg, transparent, var(--page-header-accent), transparent)`}}),(0,j.jsxs)(`div`,{className:`flex justify-between items-center gap-3 py-2.5 sm:py-3 px-4 sm:px-6`,children:[(0,j.jsxs)(`div`,{className:`flex items-center gap-3 min-w-0 flex-1`,children:[n&&(0,j.jsx)(`div`,{className:i(`shrink-0 inline-flex items-center justify-center rounded-lg`,`h-9 w-9 sm:h-10 sm:w-10`,`[&_svg]:h-[18px] [&_svg]:w-[18px] sm:[&_svg]:h-5 sm:[&_svg]:w-5`),style:{color:`var(--page-header-accent)`,background:`linear-gradient(135deg, color-mix(in srgb, var(--page-header-accent) 18%, transparent), color-mix(in srgb, var(--page-header-accent) 6%, transparent))`,boxShadow:`inset 0 0 0 1px color-mix(in srgb, var(--page-header-accent) 22%, transparent)`},children:n}),(0,j.jsxs)(`div`,{className:`min-w-0`,children:[(0,j.jsx)(`h1`,{className:`text-base sm:text-lg lg:text-xl font-semibold tracking-tight text-foreground truncate leading-tight`,children:e}),t&&(0,j.jsx)(`p`,{className:`text-xs sm:text-sm text-muted-foreground truncate hidden sm:block max-w-xl mt-0.5`,children:t})]})]}),r&&(0,j.jsx)(`div`,{className:`flex items-center gap-1.5 sm:gap-2 shrink-0`,children:r})]})]})}function N(e){return[{type:`grid`,icon:v,label:e(`console.objectView.viewTypeGrid`),description:e(`console.objectView.viewTypeGridDesc`)},{type:`kanban`,icon:S,label:e(`console.objectView.viewTypeKanban`),description:e(`console.objectView.viewTypeKanbanDesc`)},{type:`calendar`,icon:_,label:e(`console.objectView.viewTypeCalendar`),description:e(`console.objectView.viewTypeCalendarDesc`)},{type:`gallery`,icon:h,label:e(`console.objectView.viewTypeGallery`),description:e(`console.objectView.viewTypeGalleryDesc`)},{type:`timeline`,icon:p,label:e(`console.objectView.viewTypeTimeline`),description:e(`console.objectView.viewTypeTimelineDesc`)},{type:`gantt`,icon:x,label:e(`console.objectView.viewTypeGantt`),description:e(`console.objectView.viewTypeGanttDesc`)},{type:`map`,icon:l,label:e(`console.objectView.viewTypeMap`),description:e(`console.objectView.viewTypeMapDesc`)},{type:`chart`,icon:y,label:e(`console.objectView.viewTypeChart`),description:e(`console.objectView.viewTypeChartDesc`)},{type:`tree`,icon:d,label:e(`console.objectView.viewTypeTree`),description:e(`console.objectView.viewTypeTreeDesc`)}]}function P(e,t){for(let n=1;n<1e3;n++){let r=`${e} ${n}`;if(!t.has(r))return r}return e}var F={kanban:[{key:`groupByField`,i18nKey:`console.objectView.groupByField`,helpI18nKey:`console.objectView.groupByFieldHelp`,filter:e=>e.type===`select`||e.type===`boolean`,preferred:T}],calendar:[{key:`startDateField`,i18nKey:`console.objectView.startDateField`,helpI18nKey:`console.objectView.startDateFieldHelp`,filter:e=>e.type===`date`,preferred:D},{key:`titleField`,i18nKey:`console.objectView.titleField`,helpI18nKey:`console.objectView.titleFieldHelp`,filter:e=>e.type===`text`}],timeline:[{key:`startDateField`,i18nKey:`console.objectView.startDateField`,helpI18nKey:`console.objectView.timelineDateFieldHelp`,filter:e=>e.type===`date`,preferred:D},{key:`titleField`,i18nKey:`console.objectView.titleField`,helpI18nKey:`console.objectView.titleFieldHelp`,filter:e=>e.type===`text`}],gantt:[{key:`startDateField`,i18nKey:`console.objectView.startDateField`,helpI18nKey:`console.objectView.ganttStartDateFieldHelp`,filter:e=>e.type===`date`,preferred:D},{key:`endDateField`,i18nKey:`console.objectView.endDateField`,helpI18nKey:`console.objectView.ganttEndDateFieldHelp`,filter:e=>e.type===`date`,preferred:k},{key:`titleField`,i18nKey:`console.objectView.titleField`,helpI18nKey:`console.objectView.titleFieldHelp`,filter:e=>e.type===`text`}],gallery:[{key:`coverField`,i18nKey:`console.objectView.imageField`,helpI18nKey:`console.objectView.imageFieldHelp`,filter:e=>E(e)}],map:[{key:`latitudeField`,i18nKey:`console.objectView.latitudeField`,helpI18nKey:`console.objectView.latitudeFieldHelp`,filter:e=>e.type===`number`&&C(e,`latitude`)},{key:`longitudeField`,i18nKey:`console.objectView.longitudeField`,helpI18nKey:`console.objectView.longitudeFieldHelp`,filter:e=>e.type===`number`&&C(e,`longitude`)}],chart:[{key:`chartType`,i18nKey:`console.objectView.chartType`,helpI18nKey:`console.objectView.chartTypeHelp`,kind:`enum`,enumOptions:[{value:`bar`,i18nKey:`console.objectView.chartTypeBar`},{value:`line`,i18nKey:`console.objectView.chartTypeLine`},{value:`pie`,i18nKey:`console.objectView.chartTypePie`},{value:`area`,i18nKey:`console.objectView.chartTypeArea`},{value:`scatter`,i18nKey:`console.objectView.chartTypeScatter`}],defaultValue:`bar`},{key:`xAxisField`,i18nKey:`console.objectView.xAxisField`,helpI18nKey:`console.objectView.xAxisFieldHelp`,filter:e=>e.type===`select`||e.type===`boolean`||e.type===`date`||e.type===`text`,preferred:T},{key:`yAxisFields`,i18nKey:`console.objectView.yAxisField`,helpI18nKey:`console.objectView.yAxisFieldHelp`,filter:e=>e.type===`number`}],tree:[{key:`parentField`,i18nKey:`console.objectView.parentField`,helpI18nKey:`console.objectView.parentFieldHelp`,filter:e=>e.rawType===`tree`||e.rawType===`lookup`||e.rawType===`master_detail`}]};function I({open:e,onOpenChange:t,onCreate:n,existingLabels:l,availableTypes:d,objectDef:p}){let{t:h}=c(),_=(0,A.useMemo)(()=>N(h),[h]),v=(0,A.useMemo)(()=>d&&d.length>0?_.filter(e=>d.includes(e.type)):_,[_,d]),y=(0,A.useMemo)(()=>new Set(l??[]),[(l??[]).join(`\0`)]),x=(0,A.useMemo)(()=>p?w(p):[],[p]),[S,C]=(0,A.useState)(v[0]?.type??`grid`),[T,E]=(0,A.useState)(``),[D,k]=(0,A.useState)(!1),[M,I]=(0,A.useState)({});(0,A.useEffect)(()=>{e&&(C(v[0]?.type??`grid`),k(!1),I({}))},[e,v]),(0,A.useEffect)(()=>{if(!D){let e=v.find(e=>e.type===S);E(P(e?.label??`View`,y))}},[S,D,v,y]);let L=F[S]??[],R=e=>e.kind===`enum`?(e.enumOptions?.length??0)>0:!p||(e.filter?x.filter(e.filter):x).length>0,z=(0,A.useMemo)(()=>{let e={};return v.forEach(t=>{let n=(F[t.type]??[]).find(e=>!R(e));e[t.type]=n??null}),e},[v,x,p]),B=e=>M[`${S}.${e}`]??``,V=(e,t)=>I(n=>({...n,[`${S}.${e}`]:t})),H=T.trim(),U=H.length>0&&y.has(H),W=L.every(e=>B(e.key).length>0),G=H.length>0&&!U&&W;(0,A.useEffect)(()=>{L.length!==0&&L.forEach(e=>{if(B(e.key).length>0)return;if(e.kind===`enum`){e.defaultValue&&V(e.key,e.defaultValue);return}let t=e.filter?x.filter(e.filter):x;if(t.length===0)return;if(t.length===1){V(e.key,t[0].value);return}let n=O(t,e.preferred??[]);n&&V(e.key,n)})},[S,x]);let K=()=>{if(!G)return;let e={};L.forEach(t=>{let n=B(t.key);n&&(e[t.key]=t.key===`yAxisFields`?[n]:n)});let r={type:S,label:H};Object.keys(e).length>0&&(r[S]=e),n(r),t(!1)};return(0,j.jsx)(u,{open:e,onOpenChange:t,children:(0,j.jsxs)(f,{className:`sm:max-w-[560px]`,"data-testid":`create-view-dialog`,children:[(0,j.jsxs)(m,{children:[(0,j.jsx)(b,{children:h(`console.objectView.createView`)}),(0,j.jsx)(o,{children:h(`console.objectView.createViewDesc`)})]}),(0,j.jsx)(`div`,{className:`grid grid-cols-4 gap-2 py-2`,"data-testid":`create-view-type-grid`,children:v.map(({type:e,label:t,description:n,icon:r})=>{let a=e===S,o=z[e],s=!!o,c=s?h(`console.objectView.viewTypeUnavailable`,{field:h(o.i18nKey)}):void 0;return(0,j.jsxs)(`button`,{type:`button`,"data-testid":`create-view-type-${e}`,"aria-pressed":a,"aria-disabled":s,disabled:s,title:c,onClick:()=>{s||C(e)},className:i(`group flex flex-col items-start gap-1 rounded-lg border bg-background p-3 text-left transition-colors`,!s&&`hover:border-primary/60 hover:bg-accent/40`,a&&!s?`border-primary ring-2 ring-primary/30 bg-accent/40`:`border-border`,s&&`opacity-50 cursor-not-allowed`),children:[(0,j.jsx)(r,{className:i(`h-5 w-5`,a&&!s?`text-primary`:`text-muted-foreground group-hover:text-foreground`)}),(0,j.jsx)(`div`,{className:`text-xs font-medium leading-tight`,children:t}),(0,j.jsx)(`div`,{className:`text-[10px] leading-tight text-muted-foreground line-clamp-2`,children:s?h(`console.objectView.viewTypeUnavailableShort`):n})]},e)})}),L.length>0&&(0,j.jsx)(`div`,{className:`space-y-3 rounded-md border border-dashed bg-muted/30 p-3`,"data-testid":`create-view-required-fields`,children:L.map(e=>{let t=B(e.key),n=e.kind===`enum`,r=n?[]:e.filter?x.filter(e.filter):x,a=!n&&x.length>0&&r.length===0;return(0,j.jsxs)(`div`,{className:`space-y-1`,children:[(0,j.jsxs)(`label`,{htmlFor:`create-view-required-${e.key}`,className:`text-xs font-medium`,children:[h(e.i18nKey),(0,j.jsx)(`span`,{className:`ml-1 text-destructive`,children:`*`})]}),(0,j.jsxs)(`select`,{id:`create-view-required-${e.key}`,"data-testid":`create-view-required-${e.key}`,value:t,onChange:t=>V(e.key,t.target.value),disabled:a,className:i(`h-9 w-full rounded-md border bg-background px-2 text-xs`,`border-input`),children:[(0,j.jsx)(`option`,{value:``,children:h(n?`console.objectView.selectOption`:`console.objectView.selectField`)}),n?e.enumOptions.map(e=>(0,j.jsx)(`option`,{value:e.value,children:h(e.i18nKey)},e.value)):r.map(e=>(0,j.jsx)(`option`,{value:e.value,children:e.label},e.value))]}),e.helpI18nKey&&!a&&(0,j.jsx)(`p`,{className:`text-[11px] text-muted-foreground`,children:h(e.helpI18nKey)}),a&&(0,j.jsxs)(`p`,{className:`flex items-center gap-1 text-[11px] text-destructive`,"data-testid":`create-view-error-no-field-${e.key}`,children:[(0,j.jsx)(s,{className:`h-3 w-3`}),h(`console.objectView.noEligibleFieldForType`)]})]},e.key)})}),(0,j.jsxs)(`div`,{className:`space-y-1`,children:[(0,j.jsxs)(`label`,{htmlFor:`create-view-name-input`,className:`text-xs font-medium`,children:[h(`console.objectView.title`),(0,j.jsx)(`span`,{className:`ml-1 text-destructive`,children:`*`})]}),(0,j.jsx)(g,{id:`create-view-name-input`,"data-testid":`create-view-name-input`,autoFocus:!0,value:T,onChange:e=>{E(e.target.value),k(!0)},onKeyDown:e=>{e.key===`Enter`&&G&&K()},placeholder:h(`console.objectView.newView`),className:`h-9`}),U&&(0,j.jsx)(`p`,{className:`text-[11px] text-destructive`,"data-testid":`create-view-error-duplicate`,children:h(`console.objectView.duplicateViewName`)})]}),(0,j.jsxs)(r,{className:`mt-2`,children:[(0,j.jsx)(a,{type:`button`,variant:`outline`,onClick:()=>t(!1),"data-testid":`create-view-cancel`,children:h(`console.objectView.cancel`)}),(0,j.jsx)(a,{type:`button`,disabled:!G,onClick:K,"data-testid":`create-view-submit`,children:h(`console.objectView.create`)})]})]})})}export{M as n,I as t};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{o as e}from"./rolldown-runtime-DAXXjFlN.js";import{f as t,h as n,r,y as i}from"./vendor-react-BKSb6vFP.js";import{A as a,B as o,H as s,k as c,zt as l}from"./framework-Oi7uo_kE.js";import{J as u,Q as d,Uc as f,Z as p,ls as m,tt as h}from"./ui-components-BluZyuZX.js";import"./MetadataProvider-Dq7I7eh-.js";import{t as g}from"./RecordDetailView-C6UiMORv.js";import{d as _}from"./plugins-views-DCG6qMPm.js";var v=e(i(),1),y=`uf_`;function b(e){let t={};return e.forEach((e,n)=>{if(n.startsWith(y)&&e!==``){let r=n.slice(3);t[r]=e.split(`,`).map(e=>{try{return decodeURIComponent(e)}catch{return e}})}}),Object.keys(t).length>0?t:void 0}function x(e,t){let n=new URLSearchParams(e);for(let[e,r]of Object.entries(t)){let t=y+e;r&&r.length>0?n.set(t,r.map(e=>encodeURIComponent(String(e))).join(`,`)):n.delete(t)}return n}var S=r();function C(e){return Array.isArray(e?.columns)&&e.columns.length>0}function w(e,t){let n=e?.listViews||e?.list_views||{},r=(t?[n[`${e?.name}.${t}`],n[t],...t==="default"||t===`list`?[e?.list]:[]]:[e?.list,...Object.values(n)]).filter(Boolean);return r.find(C)??r[0]}function T(e){let t=e?.highlightFields;if(Array.isArray(t)&&t.length>0)return t.filter(t=>e.fields?.[t]);let n=e?.fields;return n&&typeof n==`object`?Object.entries(n).filter(([e,t])=>t&&!t.hidden&&!l(e,t)).map(([e])=>e).slice(0,6):[]}function E(e,t){let n=e?.fields;if(!(!n||typeof n!=`object`))return Object.entries(n).find(([e,n])=>n&&!n.hidden&&!l(e,n)&&t(e,n))?.[0]}var D=new Set([`select`,`multiselect`,`radio`,`enum`,`boolean`]),O=new Set([`date`,`datetime`,`time`]),k=new Set([`image`,`file`,`attachment`,`avatar`,`photo`]);function A(e){let t=E(e,(e,t)=>D.has(t.type))??E(e,e=>/status|stage|state|priority|category|kind/i.test(e));return t?{groupField:t,groupByField:t}:void 0}function j(e){return E(e,(e,t)=>O.has(t.type))??E(e,e=>/date|due|start|end|deadline|schedule/i.test(e))}function M(e){let t=j(e);return t?{startDateField:t}:void 0}function N(e){let t=E(e,(e,t)=>k.has(t.type));return t?{coverField:t}:void 0}var P=new Set([`location`,`geo`,`geolocation`,`geopoint`,`point`]);function F(e){let t=E(e,(e,t)=>O.has(t.type)&&/start|begin|kickoff/i.test(e))??E(e,(e,t)=>O.has(t.type));if(!t)return;let n=E(e,(e,n)=>O.has(n.type)&&e!==t&&/end|due|finish|deadline|close/i.test(e))??E(e,(e,n)=>O.has(n.type)&&e!==t);if(!n)return;let r=E(e,(e,t)=>(t.type===`number`||t.type===`percent`)&&/progress|percent|complete/i.test(e));return{startDateField:t,endDateField:n,...r?{progressField:r}:{}}}function I(e){let t=E(e,(e,t)=>P.has(t.type))??E(e,e=>/location|address|geo|coords?|place|venue/i.test(e));return t?{locationField:t}:void 0}function L({page:e,className:r,onConfigChange:i,reserveEditAffordance:l}){let{t:y}=f(),{objects:E}=a(),D=c(),O=t(),[k,j]=n(),[P]=v.useState(()=>b(new URLSearchParams(window.location.search))),L=v.useCallback(e=>{j(t=>x(t,e),{replace:!0})},[j]),R=e?.interfaceConfig||{},z=v.useMemo(()=>(E||[]).find(e=>e.name===R.source),[E,R.source]),B=v.useMemo(()=>w(z,R.sourceView),[z,R.sourceView]),V=R.recordAction===`page`||R.recordAction===`modal`||R.recordAction===`none`?R.recordAction:`drawer`,H=v.useCallback(e=>`/apps/${window.location.pathname.split(`/`)[2]||``}/${R.source}/record/${encodeURIComponent(String(e))}`,[R.source]),U=o({navigation:{mode:V===`none`?`none`:V},objectName:R.source,onNavigate:e=>O(H(e))}),W=k.get(`recordId`),G=v.useCallback((e,t)=>{if(V===`none`)return;let n=e?.id??e?._id;if(t&&(t.metaKey||t.ctrlKey||t.button===1)&&n!=null){window.open(H(n),`_blank`);return}if((V===`drawer`||V===`modal`)&&n!=null){j(e=>{let t=new URLSearchParams(e);return t.set(`recordId`,String(n)),t});return}U.handleClick(e,t)},[V,H,U,j]),ee=v.useCallback(()=>{j(e=>{let t=new URLSearchParams(e);return t.delete(`recordId`),t})},[j]);v.useEffect(()=>{W&&!U.isOpen?U.open({id:W}):!W&&U.isOpen&&U.close()},[W]);let K=z?.name,q=!!B&&!C(B),J=B?.name??(R.sourceView?`${R.source}.${R.sourceView}`:void 0),[Y,X]=v.useState(null);v.useEffect(()=>{let e=!1;if(X(null),!(!K||!R.source||!q||!J))return(async()=>{try{let t=D,n=null;typeof t?.listViewOverrides==`function`&&(n=(await t.listViewOverrides(R.source))?.[J]??null),!C(n)&&typeof t?.getView==`function`&&(n=await t.getView(R.source,J)),!e&&n&&typeof n==`object`&&X(n)}catch{}})(),()=>{e=!0}},[K,R.source,R.sourceView,q,J,D]);let Z=v.useMemo(()=>Y?{...B,...Y}:B,[B,Y]),te=JSON.stringify(Z??null),Q=v.useMemo(()=>{if(!z)return;let e=Z||{},t=R.appearance??e.appearance,n=t?.allowedVisualizations||[],r=new Set(n),i=R.userActions||{},a=e.kanban??(r.has(`kanban`)?A(z):void 0),o=e.calendar??(r.has(`calendar`)?M(z):void 0),s=e.timeline??(r.has(`timeline`)?M(z):void 0),c=e.gallery??(r.has(`gallery`)?N(z):void 0),l=e.gantt??(r.has(`gantt`)?F(z):void 0),u=e.options?.map??(r.has(`map`)?I(z):void 0),d=[...Array.isArray(e.filter)?e.filter:[],...Array.isArray(R.filterBy)?R.filterBy:[]],f=C(R)?R.columns:C(e)?e.columns:T(z),p=Array.isArray(R.sort)&&R.sort.length?R.sort:e.sort;return{type:`list-view`,objectName:z.name,viewType:n[0]??e.type??`grid`,fields:f,...d.length?{filters:d}:{},...p?.length?{sort:p}:{},grouping:e.grouping,rowColor:e.rowColor,pagination:e.pagination,searchableFields:e.searchableFields,emptyState:e.emptyState,kanban:a,calendar:o,gallery:c,timeline:s,gantt:l,...u||e.options?{options:{...e.options??{},...u?{map:u}:{}}}:{},userFilters:R.userFilters??e.userFilters,appearance:t,showViewSwitcher:n.length>1,showRecordCount:R.showRecordCount,addRecord:R.addRecord,showSearch:i.search!==!1,showSort:i.sort!==!1,showFilters:i.filter===!0,showDensity:i.rowHeight===!0,showHideFields:!1,showGroup:!1,showColor:!1,allowExport:!1,inlineEdit:i.editInline===!0}},[K,te,R]);if(!z||!Q)return(0,S.jsx)(`div`,{className:`h-full flex items-center justify-center p-8`,children:(0,S.jsxs)(p,{children:[(0,S.jsx)(`div`,{className:`mx-auto mb-4 flex h-12 w-12 items-center justify-center rounded-full bg-muted`,children:(0,S.jsx)(m,{className:`h-6 w-6 text-muted-foreground`})}),(0,S.jsx)(h,{children:y(`empty.objectNotFound`,{defaultValue:`Source object not found`})}),(0,S.jsx)(d,{children:y(`empty.interfacePageSourceMissing`,{defaultValue:`This interface page references "{{name}}", which is not available.`,name:R.source||`?`})})]})});let $=Array.isArray(R.buttons)&&R.buttons.length?R.buttons.map(e=>(z.actions||[]).find(t=>t?.name===e)).filter(Boolean).map(e=>({...e,locations:[`list_toolbar`]})):[];return(0,S.jsxs)(`div`,{className:r??`h-full flex flex-col`,"data-testid":`interface-list-page`,children:[(0,S.jsxs)(`div`,{className:`pl-4 pt-4 pb-2 shrink-0 flex items-start justify-between gap-3 ${l?`pr-12`:`pr-4`}`,children:[(0,S.jsxs)(`div`,{className:`min-w-0`,children:[(0,S.jsx)(`h1`,{className:`text-lg font-semibold leading-tight`,children:typeof e.label==`string`?e.label:e.name}),typeof e.description==`string`&&e.description&&(0,S.jsx)(`p`,{className:`text-sm text-muted-foreground mt-0.5`,children:e.description})]}),$.length>0&&(0,S.jsx)(`div`,{className:`shrink-0`,"data-testid":`interface-page-buttons`,children:(0,S.jsx)(s,{schema:{type:`action:bar`,location:`list_toolbar`,actions:$,size:`sm`,variant:`outline`}})})]}),(0,S.jsx)(`div`,{className:`flex-1 min-h-0 overflow-auto`,children:(0,S.jsx)(_,{schema:Q,dataSource:D,userFilterSelections:P,onUserFilterSelectionsChange:L,onSortChange:i?e=>i({sort:e}):void 0,onColumnStateChange:i?e=>{e?.order?.length&&i({columns:e.order})}:void 0,onRowClick:V===`none`?void 0:G})}),U.isOverlay&&(0,S.jsx)(u,{...U,setIsOpen:e=>{e||ee()},title:typeof e.label==`string`?e.label:R.source||`Record`,children:e=>(0,S.jsx)(g,{objectNameOverride:R.source,recordIdOverride:String(e?.id??e?._id??W??``),embedded:!0,dataSource:D,objects:E,onEdit:()=>{}})})]})}export{A as a,N as i,M as n,x as o,T as r,b as s,L as t};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{r as e}from"./vendor-react-BKSb6vFP.js";import{Ht as t,Ka as n,Mc as r,Oc as i,Pi as a,Uc as o,Ut as s,Vt as c,Wt as l,fr as u,ji as d}from"./ui-components-BluZyuZX.js";var f=e();function p(e){return e===!0||typeof e==`object`&&!!e&&e.enabled===!0}var m={config:{icon:a,i18nKey:`config`,short:`Admin config`,title:`Administrator configuration`,body:()=>`These rows define how the platform behaves at runtime. Author them here; the runtime data they produce lives in a separate table.`,tone:`border-sky-300/60 bg-sky-50 text-sky-900 hover:bg-sky-100 dark:border-sky-500/40 dark:bg-sky-950/40 dark:text-sky-100`},system:{icon:n,i18nKey:`system`,short:`System-managed`,title:`Managed by the platform`,body:()=>`Rows here are created automatically when actions run on the source record. The list below is a read-only monitoring surface — row-level actions (Approve, Recall, Resend, …) live on each row.`,tone:`border-slate-300/60 bg-slate-50 text-slate-900 hover:bg-slate-100 dark:border-slate-500/40 dark:bg-slate-950/40 dark:text-slate-100`},"system-writable":{icon:a,i18nKey:`systemWritable`,short:`Platform schema`,title:`Platform-defined, admin-writable`,body:()=>`This object's schema is defined by the platform, but its rows are yours to create and edit here. Who may write is governed by delegated administration and record-level security, not by this badge.`,tone:`border-slate-300/60 bg-slate-50 text-slate-900 hover:bg-slate-100 dark:border-slate-500/40 dark:bg-slate-950/40 dark:text-slate-100`},"append-only":{icon:i,i18nKey:`appendOnly`,short:`Read-only · Audit log`,title:`Read-only historical record`,body:()=>`Immutable audit log. Rows cannot be created, edited, or deleted from the UI — they're written by the platform when events occur. Use Export to download for compliance review.`,tone:`border-zinc-300/60 bg-zinc-50 text-zinc-900 hover:bg-zinc-100 dark:border-zinc-500/40 dark:bg-zinc-950/40 dark:text-zinc-100`},"better-auth":{icon:d,i18nKey:`betterAuth`,short:`Identity`,title:`Managed by the identity provider`,body:e=>`This object's schema is owned by ${e}. Direct edits bypass password hashing, session validation, two-factor checks, and audit hooks. Manage these records through your authentication provider's sign-in, invitation, and security flows instead.`,tone:`border-amber-300/60 bg-amber-50 text-amber-900 hover:bg-amber-100 dark:border-amber-500/40 dark:bg-amber-950/40 dark:text-amber-100`}};function h({managedBy:e,userActions:n,label:i,className:a}){let{t:d}=o();if(!e||e===`platform`)return null;let h=n??void 0,g=m[e===`system`&&(h?.create===!0||p(h?.edit)||p(h?.delete))?`system-writable`:e];if(!g)return null;let _=g.icon,v=i??`better-auth`,y=d(`managedByBadge.${g.i18nKey}.short`,{defaultValue:g.short}),b=d(`managedByBadge.${g.i18nKey}.title`,{defaultValue:g.title}),x=d(`managedByBadge.${g.i18nKey}.body`,{defaultValue:g.body(v),provider:v});return(0,f.jsx)(s,{delayDuration:200,children:(0,f.jsxs)(c,{children:[(0,f.jsx)(l,{asChild:!0,children:(0,f.jsxs)(u,{variant:`outline`,"data-testid":`managed-by-badge`,"data-bucket":e,className:r(`gap-1 font-normal text-[11px] leading-none py-0.5 px-1.5 cursor-help`,g.tone,a),children:[(0,f.jsx)(_,{className:`h-3 w-3`,"aria-hidden":`true`}),(0,f.jsx)(`span`,{children:y})]})}),(0,f.jsxs)(t,{side:`bottom`,align:`start`,className:`max-w-xs text-xs leading-relaxed`,children:[(0,f.jsx)(`p`,{className:`font-semibold mb-1`,children:b}),(0,f.jsx)(`p`,{className:`text-muted-foreground`,children:x})]})]})})}export{h as t};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{f as e,m as t,r as n}from"./vendor-react-BKSb6vFP.js";import{g as r}from"./infrastructure-CQFJ5N6p.js";import{Ka as i,Or as a,Uc as o,or as s,sr as c}from"./ui-components-BluZyuZX.js";var l={cloudUrl:``,singleEnvironment:!1,defaultOrgId:null,defaultEnvironmentId:null,features:{installLocal:!1,marketplace:!0,aiStudio:!0,autoPublishAiBuilds:!0,customDomain:!1,sso:!1},branding:{productName:`ObjectOS`,productShortName:`ObjectOS`,stage:`preview`,brandColor:`#4F46E5`,pwaThemeColor:`#4f46e5`}},u=[`preview`,`beta`,`ga`];function d(e){return typeof e==`string`&&u.includes(e)}var f={...l};function p(e){f={...f,...e,features:{...f.features,...e.features??{}},branding:{...f.branding,...e.branding??{}}}}async function m(e=``){let t=(e||``).replace(/\/+$/,``);try{let e=await fetch(`${t}/api/v1/runtime/config`,{credentials:`include`,headers:{Accept:`application/json`}});if(!e.ok)return;let n=await e.json();if(!n||typeof n!=`object`)return;p({cloudUrl:typeof n.cloudUrl==`string`?n.cloudUrl.replace(/\/+$/,``):f.cloudUrl,singleEnvironment:!!n.singleEnvironment,defaultOrgId:n.defaultOrgId??f.defaultOrgId??null,defaultEnvironmentId:n.defaultEnvironmentId??f.defaultEnvironmentId??null,features:n.features?{installLocal:!!n.features.installLocal,marketplace:n.features.marketplace!==!1,aiStudio:n.features.aiStudio!==!1,autoPublishAiBuilds:n.features.autoPublishAiBuilds!==!1,customDomain:n.features.customDomain===!0,sso:n.features.sso===!0}:f.features,branding:n.branding?{productName:typeof n.branding.productName==`string`&&n.branding.productName.trim()?n.branding.productName.trim():f.branding.productName,productShortName:typeof n.branding.productShortName==`string`&&n.branding.productShortName.trim()?n.branding.productShortName.trim():f.branding.productShortName,stage:d(n.branding.stage)?n.branding.stage:f.branding.stage,logoUrl:typeof n.branding.logoUrl==`string`&&n.branding.logoUrl.trim()?n.branding.logoUrl.trim():f.branding.logoUrl,faviconUrl:typeof n.branding.faviconUrl==`string`&&n.branding.faviconUrl.trim()?n.branding.faviconUrl.trim():f.branding.faviconUrl,brandColor:typeof n.branding.brandColor==`string`&&n.branding.brandColor.trim()?n.branding.brandColor.trim():f.branding.brandColor,pwaDescription:typeof n.branding.pwaDescription==`string`&&n.branding.pwaDescription.trim()?n.branding.pwaDescription.trim():f.branding.pwaDescription,pwaThemeColor:typeof n.branding.pwaThemeColor==`string`&&n.branding.pwaThemeColor.trim()?n.branding.pwaThemeColor.trim():f.branding.pwaThemeColor}:f.branding})}catch{}}function h(){return f}function g(){return f.branding?.productName||`ObjectOS`}function _(){return f.branding?.productShortName||g()}function v(){return f.branding?.stage??`preview`}function y(){return f.branding?.brandColor||`#4F46E5`}function b(){return f.branding?.logoUrl}function x(){return f.branding?.faviconUrl}function S(){return f.branding?.pwaDescription||`${g()} — runtime console`}function C(){return f.branding?.pwaThemeColor||y()}function w(){return f.cloudUrl??``}var T=``.replace(/\/$/,``),E=`${T}/api/v1/marketplace`;function D(e){let t=r.get();return t?{...e,Authorization:`Bearer ${t}`}:e}async function O(e,t){let n=await fetch(`${E}${e}`,{credentials:`omit`,headers:{Accept:`application/json`,...t?.headers||{}},...t}),r=null;try{r=await n.json()}catch{}if(!n.ok){let e=r?.error?.code??r?.code??`HTTP_${n.status}`,t=r?.error?.message??r?.error??n.statusText,i=Error(typeof t==`string`?t:`${e}`);throw i.code=e,i.status=n.status,i}return r?.data??r}async function k(e={}){let t=new URLSearchParams;e.q&&t.set(`q`,e.q),e.category&&t.set(`category`,e.category),e.limit!=null&&t.set(`limit`,String(e.limit)),e.offset!=null&&t.set(`offset`,String(e.offset));let n=t.toString();return O(`/packages${n?`?${n}`:``}`)}async function A(e){return O(`/packages/${encodeURIComponent(e)}`)}async function j(e){if(w()){let t=await fetch(`/api/v1/cloud-connection/install`,{method:`POST`,credentials:`include`,headers:D({Accept:`application/json`,"Content-Type":`application/json`}),body:JSON.stringify({package_id:e.packageId,seed_sample_data:!!e.seedSampleData})}),n=null;try{n=await t.json()}catch{}if(!t.ok||n?.success===!1){let e=n?.error?.code??n?.code??`HTTP_${t.status}`,r=n?.error?.message??n?.error??n?.message??t.statusText,i=Error(typeof r==`string`?r:`${e}`);throw i.code=e,i.status=t.status,i}return n?.data??n}let t=await fetch(`${T}/api/v1/actions/sys_package/install_package`,{method:`POST`,credentials:`include`,headers:{Accept:`application/json`,"Content-Type":`application/json`},body:JSON.stringify({recordId:e.packageId,params:{environment_id:e.environmentId,seed_sample_data:!!e.seedSampleData}})}),n=null;try{n=await t.json()}catch{}if(!t.ok){let e=n?.code??n?.error?.code??`HTTP_${t.status}`,r=n?.error??n?.message??t.statusText,i=Error(typeof r==`string`?r:`${e}`);throw i.code=e,i.status=t.status,i}return n?.data??n}async function M(){let e=w()||T,t=await fetch(`${e}/api/v1/data/sys_environment?limit=200`,{credentials:`include`,headers:{Accept:`application/json`}});if(!t.ok){let e=Error(`HTTP_${t.status}`);throw e.status=t.status,e}let n=await t.json().catch(()=>({})),r=n?.records??n?.data??n?.items??n??[];return Array.isArray(r)?r:[]}async function N(){let e=w()||T,t=null;try{let n=await fetch(`${e}/api/v1/auth/get-session`,{credentials:`include`,headers:{Accept:`application/json`}});n.ok&&(t=(await n.json().catch(()=>({})))?.user?.id??null)}catch{}if(!t)return new Set;let n=`${e}/api/v1/data/sys_member?limit=200`,r=null;try{let e=await fetch(n,{credentials:`include`,headers:{Accept:`application/json`}});if(!e.ok)return new Set;r=await e.json().catch(()=>({}))}catch{return new Set}let i=r?.records??r?.data??r?.items??r??[];if(!Array.isArray(i))return new Set;let a=new Set;for(let e of i){if(String(e?.user_id??e?.userId??``)!==t)continue;let n=String(e?.role??``).toLowerCase(),r=e?.organization_id??e?.organizationId;r&&(n===`owner`||n===`admin`)&&a.add(String(r))}return a}function P(e){return`${w()||`https://cloud.objectos.app`}/apps/cloud-control/sys_package/${encodeURIComponent(e)}`}function F(){return`${w()||`https://cloud.objectos.app`}/apps/cloud-control/sys_environment`}async function I(e,t){if(!e)return null;if(w())try{let t=await fetch(`/api/v1/cloud-connection/installation?package_id=${encodeURIComponent(e)}`,{credentials:`include`,headers:D({Accept:`application/json`})});if(!t.ok)return null;let n=await t.json().catch(()=>({})),r=n?.data??n??{};return r.installed?{installationId:String(r.installationId??``),version:String(r.version??`installed`),withSampleData:r.withSampleData===!0}:null}catch{return null}if(!t)return null;let n=T;try{let r=await fetch(`${n}/api/v1/cloud/environments/${encodeURIComponent(t)}/installations/${encodeURIComponent(e)}`,{credentials:`include`,headers:{Accept:`application/json`}});if(!r.ok)return null;let i=await r.json().catch(()=>({})),a=i?.data??i??{};return a.installed?{installationId:String(a.installationId??``),version:String(a.version??`installed`),withSampleData:a.withSampleData===!0}:null}catch{return null}}async function L(e){if(!e)return{ok:!1,error:`installation id required`};let t=w()||T;try{let n=await fetch(`${t}/api/v1/cloud/installations/${encodeURIComponent(e)}/reseed-sample-data`,{method:`POST`,credentials:`include`,headers:{Accept:`application/json`,"Content-Type":`application/json`},body:`{}`}),r=await n.json().catch(()=>({}));return!n.ok||r?.success===!1?{ok:!1,error:r?.error||`HTTP ${n.status}`}:{ok:!0}}catch(e){return{ok:!1,error:e?.message||`Network error`}}}async function R(e){if(!e)return{ok:!1,error:`installation id required`};let t=w()||T;try{let n=await fetch(`${t}/api/v1/cloud/installations/${encodeURIComponent(e)}/purge-sample-data`,{method:`POST`,credentials:`include`,headers:{Accept:`application/json`,"Content-Type":`application/json`},body:`{}`}),r=await n.json().catch(()=>({}));return!n.ok||r?.success===!1?{ok:!1,error:r?.error||`HTTP ${n.status}`}:{ok:!0,deleted:Number(r?.data?.deleted??0)}}catch(e){return{ok:!1,error:e?.message||`Network error`}}}async function z(){try{let e=await fetch(`${T}/api/v1/cloud-connection/org-packages`,{credentials:`include`,headers:{Accept:`application/json`}});if(!e.ok)return{connected:!1,items:[]};let t=(await e.json().catch(()=>({})))?.data??{},n=Array.isArray(t.items)?t.items:[];return{connected:t.connected===!0,items:n}}catch{return{connected:!1,items:[]}}}async function B(e){let t=await fetch(`${E}/install-local`,{method:`POST`,credentials:`include`,headers:{Accept:`application/json`,"Content-Type":`application/json`},body:JSON.stringify({packageId:e.packageId,...e.versionId?{versionId:e.versionId}:{}})}),n=null;try{n=await t.json()}catch{}if(!t.ok){let e=n?.error?.code??`HTTP_${t.status}`,r=n?.error?.message??t.statusText,i=Error(typeof r==`string`?r:`${e}`);throw i.code=e,i.status=t.status,i}return n?.data??n}async function V(){try{let e=await fetch(`${E}/install-local`,{credentials:`include`,headers:{Accept:`application/json`}});if(!e.ok)return[];let t=await e.json().catch(()=>({})),n=t?.data?.items??t?.items??[];return Array.isArray(n)?n:[]}catch{return[]}}async function H(){try{let e=await fetch(`${T}/api/v1/cloud-connection/installed`,{credentials:`include`,headers:{Accept:`application/json`}});if(!e.ok)return{connected:!1,items:[]};let t=(await e.json().catch(()=>({})))?.data??{},n=(Array.isArray(t.packages)?t.packages:[]).map(e=>{let t=String(e.packageId??e.package_id??``);return{packageId:t,versionId:String(e.package_version_id??``),manifestId:t,version:String(e.version??`installed`),installedAt:String(e.installed_at??e.installedAt??``),installedBy:e.installed_by??e.installedBy??null,withSampleData:e.with_sample_data===!0||e.withSampleData===!0}});return{connected:t.connected===!0,items:n}}catch{return{connected:!1,items:[]}}}async function U(e){let t=await fetch(`${E}/install-local/${encodeURIComponent(e)}`,{method:`DELETE`,credentials:`include`,headers:{Accept:`application/json`}});if(!t.ok){let e=(await t.json().catch(()=>({})))?.error?.message??t.statusText;throw Error(typeof e==`string`?e:`HTTP_${t.status}`)}}async function W(e,t){let n=await fetch(`${E}/install-local/${encodeURIComponent(e)}/${t===`reseed`?`reseed-sample-data`:`purge-sample-data`}`,{method:`POST`,credentials:`include`,headers:{Accept:`application/json`}}),r=await n.json().catch(()=>({}));if(!n.ok){let e=r?.error?.message??n.statusText,t=Error(typeof e==`string`?e:`HTTP_${n.status}`);throw t.code=r?.error?.code??`HTTP_${n.status}`,t}return r?.data??r}function G(e){return W(e,`reseed`)}function K(e){return W(e,`purge`)}var q=n();function J(){let n=e(),{appName:r}=t(),{t:l}=o(),u=r?`/apps/${r}`:`/`;return(0,q.jsx)(`div`,{className:`container mx-auto max-w-2xl px-6 py-16`,children:(0,q.jsx)(s,{children:(0,q.jsxs)(c,{className:`flex flex-col items-center gap-4 py-12 text-center`,children:[(0,q.jsx)(`div`,{className:`rounded-full bg-muted p-3`,children:(0,q.jsx)(i,{className:`h-6 w-6 text-muted-foreground`})}),(0,q.jsxs)(`div`,{children:[(0,q.jsx)(`h2`,{className:`text-lg font-semibold`,children:l(`marketplace.accessDenied.title`)}),(0,q.jsx)(`p`,{className:`mt-1 text-sm text-muted-foreground`,children:l(`marketplace.accessDenied.description`)})]}),(0,q.jsx)(a,{variant:`outline`,onClick:()=>n(u),children:l(`marketplace.action.backHome`)})]})})})}export{g as C,h as D,C as E,m as O,v as S,S as T,L as _,A as a,x as b,M as c,V as d,k as f,G as g,R as h,I as i,N as l,K as m,P as n,B as o,z as p,F as r,j as s,J as t,H as u,U as v,_ as w,b as x,w as y};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{o as e}from"./rolldown-runtime-DAXXjFlN.js";import{r as t,y as n}from"./vendor-react-BKSb6vFP.js";import{At as r}from"./framework-Oi7uo_kE.js";import{Gs as i,Uc as a,Ws as o,fs as s,qs as c}from"./ui-components-BluZyuZX.js";var l=e(n(),1),u=t();function d({sections:e,open:t}){if(!t)return null;let{t:n}=a(),[r,d]=(0,l.useState)([`0`]),[f,p]=(0,l.useState)(null),m=async(e,t)=>{try{await navigator.clipboard.writeText(JSON.stringify(e,null,2)),p(t),setTimeout(()=>p(null),2e3)}catch(e){console.error(`Failed to copy:`,e)}},h=e=>{d(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e])};return(0,u.jsxs)(`div`,{className:`w-80 border-l bg-background p-0 overflow-hidden flex flex-col shrink-0 z-20 transition-all`,children:[(0,u.jsxs)(`div`,{className:`px-4 py-3 border-b bg-muted/5 flex items-center justify-between`,children:[(0,u.jsx)(`span`,{className:`text-xs font-semibold uppercase tracking-wider text-muted-foreground`,children:n(`layout.metadata.panelTitle`)}),(0,u.jsx)(`span`,{className:`text-[10px] text-muted-foreground/60`,children:n(`layout.metadata.jsonBadge`)})]}),(0,u.jsx)(`div`,{className:`flex-1 overflow-auto`,children:e.map((e,t)=>{let a=String(t),l=r.includes(a),d=f===t;return(0,u.jsxs)(`div`,{className:`border-b last:border-b-0`,children:[(0,u.jsxs)(`div`,{className:`flex items-center justify-between px-4 py-3 hover:bg-muted/5 transition-colors`,children:[(0,u.jsxs)(`button`,{onClick:()=>h(a),className:`flex-1 flex items-center justify-between text-left`,children:[(0,u.jsx)(`h4`,{className:`text-xs font-semibold text-foreground`,children:e.title}),l?(0,u.jsx)(i,{className:`h-3 w-3 text-muted-foreground ml-2`}):(0,u.jsx)(o,{className:`h-3 w-3 text-muted-foreground ml-2`})]}),(0,u.jsx)(`button`,{onClick:()=>m(e.data,t),className:`p-1 hover:bg-muted rounded transition-colors ml-2`,title:n(`layout.metadata.copyJson`),children:d?(0,u.jsx)(c,{className:`h-3 w-3 text-green-600`}):(0,u.jsx)(s,{className:`h-3 w-3 text-muted-foreground`})})]}),l&&(0,u.jsx)(`div`,{className:`px-4 pb-4`,children:(0,u.jsx)(`div`,{className:`relative rounded-md border border-border/50 bg-muted/5 overflow-hidden`,children:(0,u.jsx)(`pre`,{className:`text-[11px] leading-relaxed p-3 overflow-auto max-h-96 font-mono text-foreground/90`,children:JSON.stringify(e.data,null,2)})})})]},t)})})]})}function f(){let[e,t]=(0,l.useState)((0,l.useMemo)(()=>{try{return typeof window<`u`&&r(window.location.search).enabled}catch{return!1}},[]));return{showDebug:e,toggleDebug:()=>t(e=>!e)}}export{f as n,d as t};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{o as e}from"./rolldown-runtime-DAXXjFlN.js";import{f as t,h as n,m as r,r as i,y as a}from"./vendor-react-BKSb6vFP.js";import{f as o,n as s,p as c,t as l}from"./infrastructure-CQFJ5N6p.js";import{B as ee}from"./framework-Oi7uo_kE.js";import{Fr as te,J as ne,Ka as re,Or as u,Q as d,Rc as f,Uc as p,Z as m,ls as h,ra as g,tt as _,zi as v}from"./ui-components-BluZyuZX.js";import{t as y}from"./RecordDetailView-C6UiMORv.js";import{t as b}from"./getIcon-CBdepA3t.js";import{r as x}from"./useMetadata-BMHVJNxp.js";import{n as ie,t as ae}from"./CreateViewDialog-DQqqIAwO.js";import{a as oe,i as se,n as ce,o as le,r as ue,s as de}from"./InterfaceListPage-D00ihpcS.js";import{d as fe}from"./plugins-views-DCG6qMPm.js";import{t as pe}from"./runtime-metadata-persistence-D1KKivGr.js";import{n as me,r as he,t as S}from"./drillUrlFilters-BL8PeMrH.js";var C=e(a(),1),w=i(),T=new Set([`select`,`multiselect`,`radio`,`enum`,`boolean`]),E=4;function D({dataSource:e,objects:i}){let{appName:a,objectName:D}=r(),{t:O}=p(),{objectLabel:k,fieldLabel:A}=f(),j=t(),[M,N]=n(),{can:P}=s(),{canRead:F}=l(D??``),{user:I}=c(),L=o(),R=x(),[ge,z]=C.useState(!1),B=C.useMemo(()=>(i||[]).find(e=>e.name===D),[i,D]),[_e]=C.useState(()=>de(new URLSearchParams(window.location.search))),ve=C.useCallback(e=>{N(t=>le(t,e),{replace:!0})},[N]),V=Array.from(M.entries()).filter(([e])=>e.startsWith(`filter[`)).map(([e,t])=>`${e}=${t}`).join(`&`),H=C.useMemo(()=>{let e=he(new URLSearchParams(V)),t=e.filter(([e])=>F(e));if(t.length<e.length){let t=e.filter(([e])=>!F(e)).map(([e])=>e);console.warn(`[ObjectDataPage] Dropped URL filter(s) on unreadable field(s): ${t.join(`, `)}`)}return t.map(([e,t,n])=>n===`{current_user_id}`?[e,t,I?.id??n]:[e,t,n])},[V,F,I?.id]),ye=C.useMemo(()=>me(H),[H]),U=C.useCallback(e=>{N(t=>S(new URLSearchParams(t),e))},[N]),W=C.useMemo(()=>ue(B).filter(e=>F(e)),[B,F]),G=C.useMemo(()=>{let e=B?.fields;if(!e||typeof e!=`object`)return;let t=Object.entries(e).filter(([e,t])=>t&&!t.hidden&&T.has(t.type)&&F(e)).slice(0,E).map(([e])=>({field:e}));return t.length>0?{element:`dropdown`,fields:t}:void 0},[B,F]),K=C.useCallback(e=>`/apps/${a}/${D}/record/${encodeURIComponent(String(e))}`,[a,D]),q=ee({navigation:{mode:`drawer`},objectName:D??``,onNavigate:e=>j(K(e))}),J=M.get(`recordId`),be=C.useCallback((e,t)=>{let n=e?.id??e?._id;if(t&&(t.metaKey||t.ctrlKey||t.button===1)&&n!=null){window.open(K(n),`_blank`);return}n!=null&&N(e=>{let t=new URLSearchParams(e);return t.set(`recordId`,String(n)),t})},[K,N]),xe=C.useCallback(()=>{N(e=>{let t=new URLSearchParams(e);return t.delete(`recordId`),t})},[N]);C.useEffect(()=>{J&&!q.isOpen?q.open({id:J}):!J&&q.isOpen&&q.close()},[J]);let Y=C.useMemo(()=>oe(B),[B]),X=C.useMemo(()=>ce(B),[B]),Z=C.useMemo(()=>se(B),[B]),Q=C.useMemo(()=>{let e=[`grid`];return Y&&e.push(`kanban`),X&&e.push(`calendar`),Z&&e.push(`gallery`),e},[Y,X,Z]),$=C.useMemo(()=>{if(B)return{type:`list-view`,objectName:B.name,viewType:`grid`,fields:W,...H.length?{filters:H}:{},kanban:Y,calendar:X,gallery:Z,userFilters:G,appearance:{allowedVisualizations:Q},showViewSwitcher:Q.length>1,showSearch:!0,showSort:!0,showFilters:!0,showGroup:!0,showHideFields:!0,showDensity:!0,showRecordCount:!0}},[B,W,H,Y,X,Z,G,Q]),Se=C.useCallback(async e=>{try{let t={...e,columns:Array.isArray(e.columns)&&e.columns.length>0?e.columns:W,...H.length?{filter:H}:{}},n=await pe(`view`,String(e?.name??e?.id??``),t,{metadataClient:R});n&&j(`../view/${n}`,{relative:`path`})}catch(e){console.error(`[ObjectDataPage] Failed to save view:`,e)}},[W,H,R,j]);return B?P(B.name,`read`)?(0,w.jsxs)(`div`,{className:`h-full flex flex-col bg-background min-w-0 overflow-hidden`,"data-testid":`object-data-page`,children:[(0,w.jsx)(`div`,{className:`hidden sm:block`,children:(0,w.jsx)(ie,{title:(0,w.jsxs)(`span`,{className:`inline-flex items-center gap-2`,children:[(0,w.jsx)(`span`,{className:`truncate`,children:k(B)}),(0,w.jsx)(`span`,{className:`rounded border px-1.5 py-0.5 text-[10px] font-medium uppercase tracking-wide text-muted-foreground`,children:O(`console.objectData.badge`,{defaultValue:`Data`})})]}),description:O(`console.objectData.description`,{defaultValue:`URL-defined data slice — not bound to any saved view.`}),icon:C.createElement(b(B?.icon),{className:`h-4 w-4`}),actions:(0,w.jsxs)(w.Fragment,{children:[P(B.name,`create`)&&(0,w.jsxs)(u,{size:`sm`,onClick:()=>j(`../new`,{relative:`path`}),className:`shadow-none gap-1.5 h-8 sm:h-9`,"data-testid":`object-data-new-button`,children:[(0,w.jsx)(g,{className:`h-4 w-4`}),(0,w.jsx)(`span`,{className:`hidden sm:inline`,children:O(`console.objectView.new`)})]}),L&&(0,w.jsxs)(u,{size:`sm`,variant:`outline`,onClick:()=>z(!0),className:`shadow-none gap-1.5 h-8 sm:h-9`,"data-testid":`object-data-save-as-view`,children:[(0,w.jsx)(v,{className:`h-4 w-4`}),(0,w.jsx)(`span`,{className:`hidden sm:inline`,children:O(`console.objectData.saveAsView`,{defaultValue:`Save as view`})})]})]})})}),H.length>0&&(0,w.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5 border-b px-3 sm:px-4 py-2 shrink-0`,"data-testid":`object-data-filter-chips`,children:[(0,w.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:O(`console.objectData.filteredBy`,{defaultValue:`Filtered by`})}),ye.map(({field:e,text:t})=>(0,w.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded-full border bg-muted/40 px-2 py-0.5 text-xs`,children:[(0,w.jsx)(`span`,{className:`font-medium`,children:A(B.name,e,e)}),(0,w.jsx)(`span`,{className:`text-muted-foreground`,children:t}),(0,w.jsx)(`button`,{type:`button`,onClick:()=>U(e),className:`ml-0.5 rounded-full hover:bg-muted p-0.5`,"aria-label":O(`console.objectData.removeFilter`,{defaultValue:`Remove filter {{field}}`,field:e}),"data-testid":`object-data-remove-filter-${e}`,children:(0,w.jsx)(te,{className:`h-3 w-3`})})]},e))]}),(0,w.jsx)(`div`,{className:`flex-1 min-h-0 overflow-auto`,children:$&&(0,w.jsx)(fe,{schema:$,dataSource:e,userFilterSelections:_e,onUserFilterSelectionsChange:ve,onRowClick:be})}),q.isOverlay&&(0,w.jsx)(ne,{...q,setIsOpen:e=>{e||xe()},title:k(B),children:t=>(0,w.jsx)(y,{objectNameOverride:B.name,recordIdOverride:String(t?.id??t?._id??J??``),embedded:!0,dataSource:e,objects:i,onEdit:()=>{}})}),L&&(0,w.jsx)(ae,{open:ge,onOpenChange:z,onCreate:Se,objectDef:B})]}):(0,w.jsx)(`div`,{className:`h-full flex items-center justify-center p-8`,"data-testid":`object-data-403`,children:(0,w.jsxs)(m,{children:[(0,w.jsx)(`div`,{className:`mx-auto mb-4 flex h-12 w-12 items-center justify-center rounded-full bg-muted`,children:(0,w.jsx)(re,{className:`h-6 w-6 text-muted-foreground`})}),(0,w.jsx)(_,{children:O(`console.objectData.noAccessTitle`,{defaultValue:`Access denied`})}),(0,w.jsx)(d,{children:O(`console.objectData.noAccess`,{defaultValue:`You do not have permission to view this data.`})})]})}):(0,w.jsx)(`div`,{className:`h-full flex items-center justify-center p-8`,children:(0,w.jsxs)(m,{children:[(0,w.jsx)(`div`,{className:`mx-auto mb-4 flex h-12 w-12 items-center justify-center rounded-full bg-muted`,children:(0,w.jsx)(h,{className:`h-6 w-6 text-muted-foreground`})}),(0,w.jsx)(_,{children:O(`console.objectView.objectNotFound`)}),(0,w.jsx)(d,{children:O(`console.objectView.objectNotFoundDescription`,{objectName:D})})]})})}export{D as ObjectDataPage};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{o as e,r as t}from"./rolldown-runtime-DAXXjFlN.js";import{d as n,f as r,h as i,m as a,r as o,y as s}from"./vendor-react-BKSb6vFP.js";import{f as c,h as l,n as u,p as d}from"./infrastructure-CQFJ5N6p.js";import{A as f,F as p,H as m,k as h,l as g}from"./framework-Oi7uo_kE.js";import{Cr as _,Er as v,Ho as y,Or as b,Q as x,Rc as S,Sr as C,Tr as w,Uc as T,Z as E,q as D,tt as O,ua as k,wr as A,xr as j,yr as M}from"./ui-components-BluZyuZX.js";import{r as N}from"./vendor-ui-utils-D-WJ115h.js";import"./MetadataProvider-Dq7I7eh-.js";import{r as P}from"./ExpressionProvider-C26LCaQj.js";import{c as ee,i as te,l as ne,r as re,u as ie}from"./RecordDetailView-C6UiMORv.js";import{t as F}from"./preferLocal-CKqyhTP9.js";import{t as I}from"./InterfaceListPage-D00ihpcS.js";import{n as L,t as R}from"./MetadataInspector-B9z7wtJS.js";var z=e(s(),1),B=o();function V(e,t){if(/^https?:\/\//i.test(e)||e.startsWith(`mailto:`))return{href:e,external:!e.startsWith(`mailto:`)};let n=(t||``).replace(/\/+$/,``);return{href:`${n}${e}`,external:!!n}}function H({cta:e,apiBase:t,primary:n,onNavigate:r}){let{href:i,external:a}=V(e.url,t);return(0,B.jsx)(b,{asChild:!0,variant:n?`default`:`outline`,size:`sm`,children:(0,B.jsx)(`a`,{href:i,onClick:r,...a?{target:`_blank`,rel:`noopener noreferrer`}:{},"data-testid":`entitlement-cta-${n?`primary`:`secondary`}`,children:e.label})})}function ae({state:e,apiBase:t,onOpenChange:n}){let r=e.spec;return(0,B.jsx)(M,{open:e.open,onOpenChange:e=>{e||n(!1)},children:(0,B.jsxs)(C,{"data-testid":`environment-entitlement-dialog`,children:[(0,B.jsxs)(w,{children:[(0,B.jsx)(v,{children:r?.title}),(0,B.jsx)(_,{children:r?.message})]}),(0,B.jsxs)(A,{children:[(0,B.jsx)(j,{children:`Close`}),r?.secondaryCta&&(0,B.jsx)(H,{cta:r.secondaryCta,apiBase:t,primary:!1,onNavigate:()=>n(!1)}),r?.cta&&(0,B.jsx)(H,{cta:r.cta,apiBase:t,primary:!0,onNavigate:()=>n(!1)})]})]})})}var U=new Set([`DEV_ENV_PLAN_LOCKED`,`DEV_ENV_LIMIT`,`PRODUCTION_ENV_LIMIT`]);function W(e){return typeof e==`string`&&U.has(e)}var G=`/settings/billing`;function oe(e){let t=e?.code;if(!W(t))return null;let n=typeof e?.error==`string`&&e.error?e.error:typeof e?.message==`string`?e.message:``,r=typeof e?.upgrade_url==`string`&&e.upgrade_url?e.upgrade_url:G,i=typeof e?.contact_url==`string`&&e.contact_url?e.contact_url:``;return t===`PRODUCTION_ENV_LIMIT`?{code:t,title:`You already have your production environment`,message:n||`Each organization includes exactly one production environment. Create a separate organization for another, or contact us about an Enterprise arrangement.`,cta:i?{label:`Contact sales`,url:i}:void 0}:{code:t,title:t===`DEV_ENV_PLAN_LOCKED`?`Development environments are a paid feature`:`Development environment limit reached`,message:n||(t===`DEV_ENV_PLAN_LOCKED`?`Your free plan includes one production environment. Upgrade to add development environments — build in dev, then publish to production.`:`Capacity scales with AI seats. Add an AI seat, or archive an unused development environment to free one up.`),cta:{label:`Upgrade plan`,url:r}}}function K(e){return e.hasProductionEnv?e.canCreateDevelopmentEnv===!1?`upgrade_for_development`:`add_development`:`setup_production`}function q(e){return{code:`DEV_ENV_PLAN_LOCKED`,title:`Development environments are a paid feature`,message:`${e.plan&&e.plan!==`free`?`your ${e.plan} plan`:`your free plan`} includes one production environment. Upgrade to add development environments — build in dev, then publish to production.`,cta:{label:`Upgrade plan`,url:e.upgradeUrl||`/settings/billing`}}}var J=/^\s*\{\{\s*page\.([A-Za-z_$][\w$]*(?:\.[A-Za-z_$][\w$]*)*)\s*\}\}\s*$/;function Y(e,t){let n=t;for(let t of e.split(`.`)){if(n==null)return;n=n[t]}return n}function se(e,t){if(!e.includes(`{{`))return e;let n=e.match(J);if(n){let e=Y(n[1],t);return e===void 0?``:e}return e.replace(/\{\{\s*page\.([A-Za-z_$][\w$]*(?:\.[A-Za-z_$][\w$]*)*)\s*\}\}/g,(e,n)=>{let r=Y(n,t);return r==null?``:String(r)})}function X(e,t){if(typeof e==`string`)return se(e,t);if(Array.isArray(e))return e.map(e=>X(e,t));if(e&&typeof e==`object`){let n={};for(let[r,i]of Object.entries(e))n[r]=X(i,t);return n}return e}function Z(e,t){return t?X(e,t):e}var ce={id:`current-user`,name:`Demo User`,isPlatformAdmin:!1};function Q(e){let t=e.locations;return Array.isArray(t)?t.some(e=>e===`list_item`||e===`record_header`||e===`record_more`||e===`record_section`):!1}function $(e,t){let n=e,r=n?.error;if(typeof r==`string`&&r.length>0)return r;let i=r?.message;return typeof i==`string`&&i.length>0?i:typeof n?.message==`string`&&n.message.length>0?n.message:t}function le(e){let{dataSource:t,objects:n,objectName:i,onRefresh:a}=e,o=r(),{user:s,activeOrganization:c}=d(),{systemPermissions:f}=u(),{fieldLabel:p,fieldOptionLabel:m,actionParamText:h,actionParamOptionLabel:_,actionDescription:v}=S(),y=(0,z.useMemo)(()=>i?n?.find(e=>e.name===i):void 0,[n,i]),b=i||y?.name,x=(0,z.useCallback)(()=>{a?.()},[a]),C=g({dataSource:t,onUndo:()=>{x(),N.success(`Change undone`)}}),[w,T]=(0,z.useState)({open:!1,message:``}),[E,D]=(0,z.useState)({open:!1,params:[]}),[O,k]=(0,z.useState)({open:!1}),[A,j]=(0,z.useState)(null),[M,P]=(0,z.useState)({open:!1}),F=(0,z.useRef)(new Set),I=(0,z.useCallback)((e,t)=>new Promise(n=>{k({open:!0,spec:e,data:t,resolve:n})}),[]),L=(0,z.useCallback)((e,t)=>new Promise(n=>{T({open:!0,message:e,options:t,resolve:n})}),[]),R=(0,z.useCallback)((e,t)=>new Promise(r=>{let a=t?.params&&!Array.isArray(t.params)?t.params._rowRecord:void 0,o=typeof t?.objectName==`string`&&t.objectName?t.objectName:void 0,s=re(e,{objectName:o||i||y?.name||``,objects:n||[],fieldLabel:p,fieldOptionLabel:m,row:a}),c=o||i||y?.name,l=s.map(e=>({...e,label:h(c,t?.name,e.name,`label`,e.label)??e.label,placeholder:h(c,t?.name,e.name,`placeholder`,e.placeholder)??e.placeholder,helpText:h(c,t?.name,e.name,`helpText`,e.helpText)??e.helpText,options:Array.isArray(e.options)?e.options.map(n=>({...n,label:_(c,t?.name,e.name,n.value,n.label)})):e.options}));D({open:!0,params:l,title:t?.label||t?.title,description:v(c,t?.name,t?.description),resolve:r})}),[i,y,n,p,m,h,_]),V=s?{id:s.id,name:s.name,avatar:s.image,isPlatformAdmin:s?.isPlatformAdmin??!1,systemPermissions:f??[]}:{...ce,systemPermissions:f??[]},H=(0,z.useCallback)((e,t)=>{if(t?.type===`error`){N.error(e);return}if(t?.undo){N.success(e,{duration:t.duration,action:{label:t.undo.label||`Undo`,onClick:()=>{C.undo()}}});return}N.success(e,{duration:t?.duration})},[C]),U=(0,z.useCallback)((e,t)=>{t?.external||t?.newTab?window.open(e,`_blank`,`noopener,noreferrer`):o(e)},[o]),W=(0,z.useMemo)(()=>l(),[]),G=(0,z.useCallback)(e=>{P({open:!0,spec:e})},[]),K=(0,z.useCallback)(async(e,n)=>{try{let r=e.target||e.name,i=e.params||{},a=typeof r==`string`?r:``;if(a.startsWith(`/`)||/^https?:\/\//i.test(a)){let t={...i},r=t._rowRecord;delete t._rowRecord;let o=n?.pageVariables??void 0,s=Z(t,o),l=a;r&&/\{[a-z_][a-z0-9_]*\}/i.test(l)&&(l=l.replace(/\{([a-z_][a-z0-9_]*)\}/gi,(e,t)=>{let n=r[t];return n==null?``:encodeURIComponent(String(n))}));let u=l.startsWith(`http`)?l:`${l}`,d=e.bodyShape&&typeof e.bodyShape==`object`&&e.bodyShape.wrap?e.bodyShape.wrap:void 0,f=d?{[d]:s}:{...s};if(r&&e.recordIdParam){let t=r[e.recordIdField||`id`];t!=null&&(f[e.recordIdParam]=t)}/\/api\/v1\/auth\//.test(l)&&!f.organizationId&&c?.id&&(f.organizationId=c.id),e.bodyExtra&&typeof e.bodyExtra==`object`&&Object.assign(f,Z(e.bodyExtra,o));let p=(e.method||`POST`).toUpperCase(),m={method:p,headers:{"Content-Type":`application/json`},credentials:`include`};p!==`GET`&&p!==`DELETE`&&(m.body=JSON.stringify(f));let h=await W(u,m);if(!h.ok){let e=null;try{e=await h.json()}catch{}let t=oe(e);return t?(G(t),{success:!1}):{success:!1,error:$(e,`HTTP ${h.status}`)}}let g=await h.json().catch(()=>({}));return e.refreshAfter!==!1&&x(),{success:!0,data:g&&typeof g==`object`&&!Array.isArray(g)&&`data`in g?g.data:g,reload:e.refreshAfter!==!1}}let o=e.objectName||b,s=i._rowRecord,l={...i};delete l._rowRecord;let u=l.recordId??s?.[e.recordIdField||`id`];delete l.recordId,e.bodyExtra&&typeof e.bodyExtra==`object`&&Object.assign(l,e.bodyExtra),o&&typeof t?.execute==`function`?await t.execute(o,r,l):o&&u&&Object.keys(l).length>0&&typeof t?.update==`function`&&await t.update(o,u,l);let d;if(e.undoable&&o&&u&&s&&Object.keys(l).length>0&&typeof t?.update==`function`){let t={};for(let e of Object.keys(l))t[e]=s[e]??null;d={id:`undo-${o}-${u}-${Date.now()}`,type:`update`,objectName:o,recordId:String(u),timestamp:Date.now(),description:e.label||`Undo ${o}`,undoData:t,redoData:{...l}}}let f=e.refreshAfter!==!1;return f&&x(),{success:!0,reload:f,undo:d}}catch(e){return{success:!1,error:e.message}}},[t,b,W,c,x,G]),q=(0,z.useCallback)(async(e,t)=>{let n=e.target||e.name;if(!n)return{success:!1,error:`No flow target provided for flow action`};try{let r={...e.params||{}},i=r._rowRecord;delete r._rowRecord;let a=r.recordId??i?.id;if(a==null){let n=Array.isArray(t?.selectedRecords)?t.selectedRecords:[];if(n.length===1)a=n[0]?.id;else if(n.length>1)return{success:!1,error:`This flow runs on a single record — select exactly one row.`};else if(Q(e))return{success:!1,error:`This flow runs on a single record — select a row first.`}}a!=null&&r.recordId==null&&(r.recordId=a);let o=await W(`/api/v1/automation/${encodeURIComponent(n)}/trigger`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({recordId:a,objectName:e.objectName||b,params:r})}),s=await o.json().catch(()=>null);if(!o.ok||s&&s.success===!1)return{success:!1,error:$(s,`Flow "${n}" failed (HTTP ${o.status})`)};let c=s?.data??{};if(c.status===`paused`&&c.screen)return j({flowName:n,runId:c.runId,screen:c.screen}),{success:!0,silent:!0};let l=e.refreshAfter!==!1;return l&&x(),{success:!0,data:s?.data,reload:l}}catch(e){return{success:!1,error:e.message}}},[W,b,x]),J=(0,z.useCallback)(async(e,t)=>{let n=e.target||e.name;if(!n)return{success:!1,error:`No action target provided`};let r=e.params&&!Array.isArray(e.params)?{...e.params}:{},i=r._rowRecord;delete r._rowRecord;let a=e.recordIdField||`id`,o=r.recordId??i?.[a];if(o==null){let n=Array.isArray(t?.selectedRecords)?t.selectedRecords:[];if(n.length===1)o=n[0]?.[a];else if(n.length>1)return{success:!1,error:`This action runs on a single record — select exactly one row.`};else if(Q(e))return{success:!1,error:`This action runs on a single record — select a row first.`}}let s=`${n}:${o??``}`;if(F.current.has(s))return{success:!1,error:`Action already in progress`};F.current.add(s);let c=null;if(e.opensInNewTab)try{c=window.open(`about:blank`,`_blank`),c&&(c.document.write(`<!doctype html><meta charset="utf-8"><title>正在打开… Opening…</title><body style="margin:0;font-family:system-ui,sans-serif;display:flex;flex-direction:column;align-items:center;justify-content:center;height:100vh;gap:16px;color:#4b5563"><div style="width:28px;height:28px;border:3px solid #e5e7eb;border-top-color:#6366f1;border-radius:50%;animation:s .8s linear infinite"></div><div>正在为你打开环境…</div><style>@keyframes s{to{transform:rotate(360deg)}}</style></body>`),c.document.close())}catch{c=null}try{let t=typeof e.newTabUrl==`string`?e.newTabUrl:``;if(e.opensInNewTab&&t){if(o==null){if(c)try{c.close()}catch{}return{success:!1,error:`This action runs on a single record — no record id available.`}}let n=`${window.location.origin}${t.replace(`{recordId}`,encodeURIComponent(String(o)))}`;if(c)try{c.location.href=n}catch{try{c.close()}catch{}window.location.href=n}else{let e=null;try{e=window.open(n,`_blank`)}catch{e=null}e||N(`浏览器拦截了弹窗 / Popup blocked`,{description:`点击在新标签页打开环境`,action:{label:`打开环境`,onClick:()=>{try{window.open(n,`_blank`)}catch{window.location.href=n}}},duration:1e4})}return e.refreshAfter===!0&&x(),{success:!0}}let i=e.objectName||b||`global`,a=await W(`/api/v1/actions/${encodeURIComponent(i)}/${encodeURIComponent(n)}`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({recordId:o,params:r})}),s=await a.json().catch(()=>null);if(!a.ok||s&&s.success===!1){let e=$(s,`Action "${n}" failed (HTTP ${a.status})`);if(c)try{c.close()}catch{}return{success:!1,error:e}}let l=e.refreshAfter!==!1;l&&x();let u=s?.data,d=u&&typeof u==`object`&&typeof u.redirectUrl==`string`?u.redirectUrl:null;if(d)if(c)try{c.location.href=d}catch{try{c.close()}catch{}window.location.href=d}else{let e=null;try{e=window.open(d,`_blank`)}catch{e=null}e||N(`浏览器拦截了弹窗 / Popup blocked`,{description:`点击在新标签页打开环境`,action:{label:`打开环境`,onClick:()=>{try{window.open(d,`_blank`)}catch{window.location.href=d}}},duration:1e4})}else if(c)try{c.close()}catch{}return{success:!0,data:u,reload:l}}catch(e){if(c)try{c.close()}catch{}return{success:!1,error:e.message}}finally{F.current.delete(s)}},[W,b,x]);return{confirmHandler:L,toastHandler:H,navigateHandler:U,paramCollectionHandler:R,resultDialogHandler:I,apiHandler:K,flowHandler:q,serverActionHandler:J,authFetch:W,openEntitlementDialog:G,actionProviderProps:(0,z.useMemo)(()=>({context:{...i?{objectName:i}:{},user:V,apiBase:``,activeOrganization:c?{id:c.id,slug:c.slug,name:c.name}:null},onConfirm:L,onToast:H,onNavigate:U,onParamCollection:R,onResultDialog:I,handlers:{api:K,flow:q,script:J,modal:J}}),[i,V,c,L,H,U,R,I,K,q,J]),dialogs:(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(ie,{state:w,onOpenChange:e=>{e||T({open:!1,message:``})}}),(0,B.jsx)(ne,{state:E,onOpenChange:e=>{e||D({open:!1,params:[]})}}),(0,B.jsx)(ee,{state:O,onAcknowledge:()=>{O.resolve?.(),k({open:!1})}}),(0,B.jsx)(te,{state:A,authFetch:W,baseUrl:``,dataSource:t,objects:n,onClose:()=>j(null),onComplete:()=>{j(null),x()}}),(0,B.jsx)(ae,{state:M,apiBase:``,onOpenChange:e=>{e||P({open:!1})}})]})}}function ue({children:e,...t}){let n=le(t);return(0,B.jsxs)(p,{...n.actionProviderProps,children:[e,n.dialogs]})}var de=t({PageView:()=>fe});function fe(){let{t:e}=T(),{pageName:t}=a(),[o]=i(),{showDebug:s}=L(),l=r(),u=n(),d=c(),{pages:p,objects:g,getTypeStatus:_}=f(),{app:v}=P(),b=h(),[S,C]=(0,z.useState)(0),w=F(p,t,v?._packageId);if(!w){let n=_?.(`page`);return n===`idle`||n===`loading`?(0,B.jsx)(`div`,{className:`h-full flex items-center justify-center p-8`,"data-testid":`page-loading`,children:(0,B.jsx)(D,{className:`h-5 w-5 text-muted-foreground`})}):(0,B.jsx)(`div`,{className:`h-full flex items-center justify-center p-8`,children:(0,B.jsxs)(E,{children:[(0,B.jsx)(`div`,{className:`mx-auto mb-4 flex h-12 w-12 items-center justify-center rounded-full bg-muted`,children:(0,B.jsx)(y,{className:`h-6 w-6 text-muted-foreground`})}),(0,B.jsx)(O,{children:e(`empty.pageNotFound`)}),(0,B.jsx)(x,{children:e(`empty.pageNotFoundDescription`,{name:t})})]})})}let A=Object.fromEntries(o.entries()),j=u.pathname.match(/\/apps\/([^/]+)/)?.[1],M=d&&!!j&&!!t;return(0,B.jsx)(ue,{dataSource:b,objects:g,onRefresh:()=>C(e=>e+1),children:(0,B.jsxs)(`div`,{className:`flex flex-row h-full w-full overflow-hidden relative`,children:[(0,B.jsxs)(`div`,{className:`flex-1 overflow-auto h-full relative`,children:[M&&(0,B.jsx)(`button`,{type:`button`,onClick:()=>{M&&l(`/apps/${j}/metadata/page/${encodeURIComponent(t)}`)},className:`absolute right-3 top-3 z-30 inline-flex h-7 w-7 items-center justify-center rounded-md border border-input bg-background/90 text-muted-foreground shadow-sm backdrop-blur hover:bg-accent hover:text-accent-foreground`,"data-testid":`page-edit-in-studio-button`,title:e(`common.editInStudio`,{defaultValue:`Edit in studio`}),"aria-label":e(`common.editInStudio`,{defaultValue:`Edit in studio`}),children:(0,B.jsx)(k,{className:`h-3.5 w-3.5`})}),w.interfaceConfig?.source?(0,B.jsx)(I,{page:w,reserveEditAffordance:M},S):(0,B.jsx)(m,{schema:{...w,type:w.type||`page`,context:{...w.context,params:A,refreshKey:S}}},S)]}),(0,B.jsx)(R,{open:s,sections:[{title:`Page Configuration`,data:w}]})]})})}export{q as a,K as i,le as n,G as r,de as t};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{o as e}from"./rolldown-runtime-DAXXjFlN.js";import{r as t,y as n}from"./vendor-react-BKSb6vFP.js";import{k as r}from"./framework-Oi7uo_kE.js";import{$n as i,Ct as a,Or as o,Pi as ee,Qi as te,Qn as s,St as c,Xn as l,Yi as ne,Zn as u,bt as re,cr as ie,eo as ae,er as d,fr as oe,fs as se,gs as ce,lr as le,mn as f,or as p,ra as ue,sr as de,tr as m,ts as fe,ur as pe,vn as h,wt as g,xt as _,yt as me}from"./ui-components-BluZyuZX.js";import{r as v}from"./vendor-ui-utils-D-WJ115h.js";import"./src-CB6vSDbd.js";var y=e(n(),1),b=t();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,n=t?.kind??`thank-you`;B(n),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)(p,{children:[(0,b.jsxs)(le,{className:`flex flex-row items-start justify-between gap-4 space-y-0`,children:[(0,b.jsxs)(`div`,{children:[(0,b.jsxs)(pe,{className:`flex items-center gap-2`,children:[(0,b.jsx)(te,{className:`h-4 w-4`}),`Public Forms`]}),(0,b.jsx)(ie,{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)(o,{variant:`default`,size:`sm`,onClick:()=>D(!0),disabled:S.length===0,title:S.length===0?`No non-public FormViews available`:`Publish a FormView`,children:[(0,b.jsx)(ue,{className:`h-3.5 w-3.5`}),(0,b.jsx)(`span`,{className:`ml-1.5`,children:`Publish form…`})]}),(0,b.jsxs)(o,{variant:`outline`,size:`sm`,onClick:Y,disabled:C,children:[(0,b.jsx)(ne,{className:`h-3.5 w-3.5 ${C?`animate-spin`:``}`}),(0,b.jsx)(`span`,{className:`ml-1.5`,children:`Refresh`})]})]})]}),(0,b.jsxs)(de,{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)(me,{children:[(0,b.jsx)(a,{children:(0,b.jsxs)(g,{children:[(0,b.jsx)(c,{children:`Name`}),(0,b.jsx)(c,{children:`Object`}),(0,b.jsx)(c,{children:`Slug`}),(0,b.jsx)(c,{children:`Public URL`}),(0,b.jsx)(c,{className:`text-right`,children:`Actions`})]})}),(0,b.jsx)(re,{children:t.map(e=>{let t=X(e.slug);return(0,b.jsxs)(g,{children:[(0,b.jsx)(_,{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)(_,{children:e.object?(0,b.jsx)(oe,{variant:`secondary`,children:e.object}):(0,b.jsx)(`span`,{className:`text-muted-foreground`,children:`—`})}),(0,b.jsx)(_,{children:(0,b.jsx)(`code`,{className:`text-xs`,children:e.slug})}),(0,b.jsx)(_,{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)(fe,{className:`h-3 w-3`})]})}),(0,b.jsx)(_,{className:`text-right`,children:(0,b.jsxs)(`div`,{className:`inline-flex gap-1`,children:[(0,b.jsx)(o,{variant:`ghost`,size:`sm`,title:`Copy URL`,onClick:()=>Q(`URL`,t),children:(0,b.jsx)(ae,{className:`h-3.5 w-3.5`})}),(0,b.jsx)(o,{variant:`ghost`,size:`sm`,title:`Copy <iframe> embed`,onClick:()=>Q(`iframe snippet`,Z(e.slug)),children:(0,b.jsx)(ce,{className:`h-3.5 w-3.5`})}),(0,b.jsx)(o,{variant:`ghost`,size:`sm`,title:`Copy React snippet`,onClick:()=>Q(`React snippet`,be(e.slug)),children:(0,b.jsx)(se,{className:`h-3.5 w-3.5`})}),(0,b.jsx)(o,{variant:`ghost`,size:`sm`,title:`Edit sharing & post-submit behavior`,onClick:()=>Se(e),children:(0,b.jsx)(ee,{className:`h-3.5 w-3.5`})})]})})]},e.name)})})]})]})]}),(0,b.jsx)(l,{open:_e,onOpenChange:D,children:(0,b.jsxs)(u,{className:`sm:max-w-md`,children:[(0,b.jsxs)(d,{children:[(0,b.jsx)(m,{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)(h,{htmlFor:`publish-view`,children:`FormView`}),(0,b.jsxs)(`select`,{id:`publish-view`,className:`flex h-9 w-full rounded-md border border-input bg-transparent px-3 py-1 text-sm shadow-sm`,value:O,onChange:e=>k(e.target.value),children:[(0,b.jsx)(`option`,{value:``,children:`— Select a FormView —`}),S.map(e=>(0,b.jsxs)(`option`,{value:e.name,children:[e.label??e.name,` (`,e.name,`) `,e.object?`· ${e.object}`:``]},e.name))]})]}),(0,b.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,b.jsx)(h,{htmlFor:`publish-slug`,children:`URL slug`}),(0,b.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,b.jsx)(`span`,{className:`text-xs text-muted-foreground whitespace-nowrap`,children:`/console/f/`}),(0,b.jsx)(f,{id:`publish-slug`,placeholder:`contact-us`,value:A,onChange:e=>j(e.target.value)})]}),(0,b.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Lowercase letters, digits, dashes and underscores only.`})]})]}),(0,b.jsxs)(i,{children:[(0,b.jsx)(o,{variant:`ghost`,onClick:()=>D(!1),disabled:M,children:`Cancel`}),(0,b.jsx)(o,{onClick:xe,disabled:M||!O||!A,children:M?`Publishing…`:`Publish`})]})]})}),(0,b.jsx)(l,{open:ve,onOpenChange:P,children:(0,b.jsxs)(u,{className:`sm:max-w-lg`,children:[(0,b.jsxs)(d,{children:[(0,b.jsx)(m,{children:F?`Edit ${F.label??F.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)(h,{htmlFor:`edit-slug`,children:`URL slug`}),(0,b.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,b.jsx)(`span`,{className:`text-xs text-muted-foreground whitespace-nowrap`,children:`/console/f/`}),(0,b.jsx)(f,{id:`edit-slug`,value:L,onChange:e=>R(e.target.value)})]})]}),(0,b.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,b.jsx)(h,{htmlFor:`edit-behavior`,children:`After submit`}),(0,b.jsxs)(`select`,{id:`edit-behavior`,className:`flex h-9 w-full rounded-md border border-input bg-transparent px-3 py-1 text-sm shadow-sm`,value:z,onChange:e=>B(e.target.value),children:[(0,b.jsx)(`option`,{value:`thank-you`,children:`Show a thank-you panel`}),(0,b.jsx)(`option`,{value:`redirect`,children:`Redirect to a URL`}),(0,b.jsx)(`option`,{value:`continue`,children:`Reset for another response`}),(0,b.jsx)(`option`,{value:`next-record`,children:`Advance to next record (internal queues)`})]})]}),z===`thank-you`&&(0,b.jsxs)(b.Fragment,{children:[(0,b.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,b.jsx)(h,{htmlFor:`edit-tytitle`,children:`Title`}),(0,b.jsx)(f,{id:`edit-tytitle`,placeholder:`Thanks!`,value:V,onChange:e=>H(e.target.value)})]}),(0,b.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,b.jsx)(h,{htmlFor:`edit-tymsg`,children:`Message`}),(0,b.jsx)(f,{id:`edit-tymsg`,placeholder:`Your submission has been received.`,value:U,onChange:e=>W(e.target.value)})]})]}),z===`redirect`&&(0,b.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,b.jsx)(h,{htmlFor:`edit-url`,children:`Redirect URL`}),(0,b.jsx)(f,{id:`edit-url`,type:`url`,placeholder:`https://example.com/thanks`,value:G,onChange:e=>K(e.target.value)})]})]}),(0,b.jsxs)(i,{children:[(0,b.jsx)(o,{variant:`ghost`,onClick:()=>P(!1),disabled:q,children:`Cancel`}),(0,b.jsx)(o,{onClick:Ce,disabled:q||!L,children:q?`Saving…`:`Save`})]})]})})]})}export{S as PublicFormsPage};
|