@objectstack/console 15.0.0 → 15.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (124) hide show
  1. package/dist/.objectui-sha +1 -1
  2. package/dist/assets/{AdapterProvider-CSP_T07G.js → AdapterProvider-BFaddpzn.js} +1 -1
  3. package/dist/assets/{AiPendingActionsPage-BNh8Cf9P.js → AiPendingActionsPage-CvBOdCmI.js} +1 -1
  4. package/dist/assets/ApiConsolePage-BETRFRmt.js +1 -0
  5. package/dist/assets/{AppDocsIndex-DFB1tmTx.js → AppDocsIndex-BYY7DwDn.js} +1 -1
  6. package/dist/assets/{AppManagementPage-D2jMv3L-.js → AppManagementPage-ct829ZDs.js} +1 -1
  7. package/dist/assets/ApprovalsInboxPage-CLRfOCfN.js +1 -0
  8. package/dist/assets/AuditLogPage-DrVbfMwo.js +1 -0
  9. package/dist/assets/{ComponentNavView-C8ngAwyN.js → ComponentNavView-BdBCf414.js} +1 -1
  10. package/dist/assets/CreateViewDialog-C1plmcyi.js +1 -0
  11. package/dist/assets/DashboardView-YwIvqU1F.js +1 -0
  12. package/dist/assets/{DeveloperHubPage-VBsID8Fk.js → DeveloperHubPage-Cv1WYOxY.js} +1 -1
  13. package/dist/assets/{DocShell-ChTlUxMm.js → DocShell-CLtiW77i.js} +1 -1
  14. package/dist/assets/ExpressionProvider-E8d0a2zy.js +1 -0
  15. package/dist/assets/FlowRunsPage-Kk2pQjuI.js +1 -0
  16. package/dist/assets/{IntegrationsPage-BR2TkAoB.js → IntegrationsPage-3Mmj9WPX.js} +2 -2
  17. package/dist/assets/InterfaceListPage-BEv_Whkh.js +1 -0
  18. package/dist/assets/ManagedByBadge-h6zYSYEw.js +1 -0
  19. package/dist/assets/MarketplaceAccessDenied-BBrk9Zzt.js +1 -0
  20. package/dist/assets/MarketplaceInstalledPage-Baul16n9.js +1 -0
  21. package/dist/assets/MarketplacePackagePage-C4BoxM9O.js +4 -0
  22. package/dist/assets/MarketplacePage-CIiUcu2P.js +1 -0
  23. package/dist/assets/MetadataInspector-Ty_bVFlI.js +1 -0
  24. package/dist/assets/MetadataProvider-Dw6hFBw2.js +1 -0
  25. package/dist/assets/ObjectDataPage-C0VN22jG.js +1 -0
  26. package/dist/assets/PageView-9Qd343Y8.js +1 -0
  27. package/dist/assets/ProfilePage-DotFPbJV.js +1 -0
  28. package/dist/assets/PublicFormsPage-DIXBuC2U.js +1 -0
  29. package/dist/assets/RecordDetailView-WbRO9Qfl.js +2 -0
  30. package/dist/assets/RecordFormPage-CVM9R6n6.js +1 -0
  31. package/dist/assets/ReportDefaultInspector-Dfj5Pq4K.js +3 -0
  32. package/dist/assets/ReportView-BuAo4KRU.js +2 -0
  33. package/dist/assets/SearchResultsPage-BXtahiUa.js +1 -0
  34. package/dist/assets/{SettingsHub-Begm6jy7.js → SettingsHub-Cbb36Ak1.js} +1 -1
  35. package/dist/assets/SettingsView-MqDu9fQ0.js +1 -0
  36. package/dist/assets/{SystemHubPage-C4J7Le-p.js → SystemHubPage-CRlHp6zs.js} +1 -1
  37. package/dist/assets/data-adapter-BaT0fWzy.js +9 -0
  38. package/dist/assets/framework-CavAJOoG.js +6 -0
  39. package/dist/assets/{getIcon-BZsP3YSU.js → getIcon-CJv2JJRu.js} +1 -1
  40. package/dist/assets/{highlighted-body-OFNGDK62-BPN_aS-T.js → highlighted-body-OFNGDK62-CmEyqxRh.js} +1 -1
  41. package/dist/assets/i18n--Ef6MgVx.js +9 -0
  42. package/dist/assets/index-DwHOkKSZ.css +2 -0
  43. package/dist/assets/index-sUYxMYg4.js +2 -0
  44. package/dist/assets/infrastructure-1EBA2wrr.js +3 -0
  45. package/dist/assets/mermaid-GHXKKRXX-B608OHDp.js +1 -0
  46. package/dist/assets/metadata-admin-CaWsYPuu.js +25 -0
  47. package/dist/assets/plugin-calendar-lTyyzuqa.js +1 -0
  48. package/dist/assets/plugin-charts-CXDDqZeY.js +7 -0
  49. package/dist/assets/plugin-chatbot-CGYrsTXi.js +120 -0
  50. package/dist/assets/plugin-dashboard-oozFEUjN.js +6 -0
  51. package/dist/assets/plugin-form-Hw4-ReuX.js +1 -0
  52. package/dist/assets/plugin-gantt-DIrw5DOt.js +102 -0
  53. package/dist/assets/plugin-grid-QB7O_mff.js +8 -0
  54. package/dist/assets/plugin-kanban-C3U_tMs4.js +1 -0
  55. package/dist/assets/plugin-map-Lz3zZGqA.js +1 -0
  56. package/dist/assets/{plugin-markdown-DgBcCCgO.js → plugin-markdown-CeSEfSMe.js} +1 -1
  57. package/dist/assets/plugin-report-CMTOJSLw.js +59 -0
  58. package/dist/assets/plugin-timeline-CKcNCEwi.js +1 -0
  59. package/dist/assets/plugin-tree-BLG1qg4e.js +1 -0
  60. package/dist/assets/plugin-view-CwV64XEY.js +1 -0
  61. package/dist/assets/plugins-views-CoEgR96I.js +4 -0
  62. package/dist/assets/{skeletons-Bf9TL3pG.js → skeletons-DGSWW9zt.js} +1 -1
  63. package/dist/assets/src-1qbKZhoo.js +1 -0
  64. package/dist/assets/{src-C6-lrmoQ.js → src-2Uisncjb.js} +1 -1
  65. package/dist/assets/src-DXuM24AK.js +18 -0
  66. package/dist/assets/{types-033eBMjb.js → types-C7NHW0h6.js} +1 -1
  67. package/dist/assets/ui-components-CHaxvtjc.js +72 -0
  68. package/dist/assets/{ui-layout-FqyUicdD.js → ui-layout-BLgfeXIq.js} +1 -1
  69. package/dist/assets/{use-book-data-BThfYUpK.js → use-book-data-BwZnHc4z.js} +1 -1
  70. package/dist/assets/{useMetadata-D5f_5ULL.js → useMetadata-IV9x2kG3.js} +1 -1
  71. package/dist/assets/vendor-objectstack-BTM1m7k5.js +104 -0
  72. package/dist/index.html +4 -4
  73. package/package.json +1 -1
  74. package/dist/assets/ApiConsolePage-Btr9hRka.js +0 -1
  75. package/dist/assets/ApprovalsInboxPage-CT4IXwpE.js +0 -1
  76. package/dist/assets/AuditLogPage-BdYvwcAH.js +0 -1
  77. package/dist/assets/CreateViewDialog-DcjN_AhY.js +0 -1
  78. package/dist/assets/DashboardView-CLJM8Cfl.js +0 -1
  79. package/dist/assets/ExpressionProvider-CHaGm5wf.js +0 -1
  80. package/dist/assets/FlowRunsPage-DdOav-6T.js +0 -1
  81. package/dist/assets/InterfaceListPage-Ca4VNsGg.js +0 -1
  82. package/dist/assets/ManagedByBadge-Cdy82I7A.js +0 -1
  83. package/dist/assets/MarketplaceAccessDenied-B6Tg5g6l.js +0 -1
  84. package/dist/assets/MarketplaceInstalledPage-DBmVXCVz.js +0 -1
  85. package/dist/assets/MarketplacePackagePage-Mt1pHE8U.js +0 -4
  86. package/dist/assets/MarketplacePage-D9CLlhnk.js +0 -1
  87. package/dist/assets/MetadataInspector-Bqe7rY0S.js +0 -1
  88. package/dist/assets/MetadataProvider-DqPZ6rV2.js +0 -1
  89. package/dist/assets/ObjectDataPage-Cz_pMsIv.js +0 -1
  90. package/dist/assets/PageView-CLvQYEdi.js +0 -1
  91. package/dist/assets/ProfilePage-BDJLPRAf.js +0 -1
  92. package/dist/assets/PublicFormsPage-BRflG64R.js +0 -1
  93. package/dist/assets/RecordDetailView-w6IBQ1cm.js +0 -2
  94. package/dist/assets/RecordFormPage-inJKFR63.js +0 -1
  95. package/dist/assets/ReportDefaultInspector-BZaG6IPJ.js +0 -3
  96. package/dist/assets/ReportView-CSAIx2AR.js +0 -2
  97. package/dist/assets/SearchResultsPage-DsnzRV3B.js +0 -1
  98. package/dist/assets/SettingsView-C4UULiJk.js +0 -1
  99. package/dist/assets/data-adapter-Mo_lVy1U.js +0 -7
  100. package/dist/assets/framework-BL3BtpKU.js +0 -36
  101. package/dist/assets/i18n-BsjEVcp4.js +0 -9
  102. package/dist/assets/index-CRgNx-tU.js +0 -2
  103. package/dist/assets/index-D1n9Ue1P.css +0 -2
  104. package/dist/assets/infrastructure-Bc4DRENl.js +0 -3
  105. package/dist/assets/mermaid-GHXKKRXX-BBQimMyN.js +0 -1
  106. package/dist/assets/metadata-admin-DHwo5kSi.js +0 -23
  107. package/dist/assets/plugin-calendar-BTCkHFNk.js +0 -1
  108. package/dist/assets/plugin-charts-DugftiGR.js +0 -7
  109. package/dist/assets/plugin-chatbot-Cq19aZcF.js +0 -120
  110. package/dist/assets/plugin-dashboard-CaQs1s4M.js +0 -6
  111. package/dist/assets/plugin-form-6ug8Woph.js +0 -1
  112. package/dist/assets/plugin-gantt-SwenNrGL.js +0 -102
  113. package/dist/assets/plugin-grid-a0e-qAUn.js +0 -8
  114. package/dist/assets/plugin-kanban-B9xzSYs9.js +0 -1
  115. package/dist/assets/plugin-map-DnfptTJp.js +0 -1
  116. package/dist/assets/plugin-report-Dny_M7U-.js +0 -59
  117. package/dist/assets/plugin-timeline-8zgO0jxJ.js +0 -1
  118. package/dist/assets/plugin-tree-Bzgro7b4.js +0 -1
  119. package/dist/assets/plugin-view-DfJ5SCdu.js +0 -1
  120. package/dist/assets/plugins-views-CoobEMX4.js +0 -4
  121. package/dist/assets/src-BMWmj9Zz.js +0 -1
  122. package/dist/assets/src-CQwyy7m_.js +0 -18
  123. package/dist/assets/ui-components-Y3D5-fgK.js +0 -42
  124. package/dist/assets/vendor-objectstack-BjCqbVaM.js +0 -96
@@ -0,0 +1,3 @@
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./ui-components-BL3SEdAz.css"])))=>i.map(i=>d[i]);
2
+ import{o as e}from"./rolldown-runtime-DAXXjFlN.js";import{g as t,r as n,y as r}from"./vendor-react-BKSb6vFP.js";import{T as i,Y as a,x as o}from"./vendor-objectstack-BTM1m7k5.js";import{$n as s,$t as c,Ba as l,Bo as u,Co as d,Ct as f,Dc as p,Er as m,Es as h,Fr as g,Gi as _,Hs as v,Ja as y,Jn as b,Jr as x,Ls as S,Mc as C,Mi as w,Nr as T,Ns as E,Pi as D,Ps as O,Qa as k,Qn as A,Qo as j,Qr as M,Qt as N,Rs as P,Si as ee,Ta as te,Us as F,Wa as ne,Ws as I,Xa as re,Ya as L,Yn as R,Yo as ie,Yr as ae,Zi as oe,Zo as se,Zt as z,_o as ce,as as le,ba as ue,bi as de,dn as fe,dt as pe,ec as me,ei as he,en as B,er as ge,fn as V,ft as _e,gn as H,gt as ve,hs as ye,ht as be,la as xe,lc as Se,ln as Ce,lt as we,ms as Te,mt as Ee,nc as De,nr as Oe,oa as ke,oi as Ae,pi as je,po as Me,pt as Ne,rc as Pe,ri as Fe,rt as Ie,sa as Le,st as Re,ta as U,tn as W,tr as ze,ua as Be,un as Ve,ur as He,vc as Ue,vi as We,wa as Ge,wi as Ke,xc as qe,xo as Je,yc as Ye,ys as Xe,za as Ze,zr as Qe}from"./ui-components-CHaxvtjc.js";import{a as $e,n as G,o as K,t as q}from"./i18n--Ef6MgVx.js";import{r as et}from"./useMetadata-IV9x2kG3.js";var J=e(r(),1),Y=n();function tt(e){return Array.isArray(e)?{shape:`array`,entries:e.map((e,t)=>{let{name:n,...r}=e??{};return{name:typeof n==`string`&&n?n:`field_${t+1}`,def:r}})}:e&&typeof e==`object`?{shape:`record`,entries:Object.entries(e).map(([e,t])=>({name:e,def:{...t??{}}}))}:{shape:`record`,entries:[]}}function nt(e){if(e.shape===`array`)return e.entries.map(e=>({name:e.name,...e.def}));let t={};for(let n of e.entries)t[n.name]=n.def;return t}function rt(e,t){return e.entries.findIndex(e=>e.name===t)}function it(e,t,n){let r={type:t,label:n??at(e)};return(t===`select`||t===`multiselect`||t===`radio`||t===`checkboxes`)&&(r.options=[]),{name:e,def:r}}function at(e){return e?e.split(`_`).filter(Boolean).map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(` `):``}function ot(e){let t=e.trim().toLowerCase().replace(/[^a-z0-9]+/g,`_`).replace(/^_+|_+$/g,``).replace(/_{2,}/g,`_`);return t?/^[a-z_]/.test(t)?t:`f_${t}`:`field`}function st(e){let t=e.trim().toLowerCase().replace(/[^a-z0-9]+/g,`_`).replace(/^_+/g,``).replace(/_{2,}/g,`_`);return t?/^[a-z_]/.test(t)?t:`f_${t}`:``}function ct(e){return Array.isArray(e)?e.filter(e=>!!e&&typeof e==`object`).map(e=>({...e,key:typeof e.key==`string`?e.key:``,label:typeof e.label==`string`?e.label:``})).filter(e=>e.key):[]}function lt(e,t){let n=/[a-z0-9]/i.test(e)?ot(e):`group`;if(!t.includes(n))return n;let r=2;for(;t.includes(`${n}_${r}`);)r+=1;return`${n}_${r}`}function ut(e,t){let n=t.trim()||`New section`,r=lt(n,e.map(e=>e.key));return[...e,{key:r,label:n}]}function dt(e,t,n){let r=n.trim();return r?e.map(e=>e.key===t?{...e,label:r}:e):e}function ft(e,t,n){return e.map(e=>{if(e.key!==t)return e;let r={...e};for(let[e,t]of Object.entries(n))t===void 0?delete r[e]:r[e]=t;return r})}function pt(e,t){return e.filter(e=>e.key!==t)}function mt(e,t,n){let r=e.findIndex(e=>e.key===t);if(r<0)return e;let i=r+n;return i<0||i>=e.length?e:gt(e,r,i)}function ht(e,t){return{shape:e.shape,entries:e.entries.map(e=>e.def.group===t?{name:e.name,def:{...e.def,group:void 0}}:e)}}function gt(e,t,n){let r=e.slice(),[i]=r.splice(t,1);return r.splice(n,0,i),r}function _t(e,t,n){let r=Array.isArray(t)?t.filter(e=>typeof e?.key==`string`):[],i=new Map;for(let e of r)i.set(e.key,{key:e.key,label:String(e.label??e.key),entries:[]});let a=new Set(r.map(e=>e.key));for(let t of e.entries){let e=typeof t.def.group==`string`?t.def.group:null;e&&a.has(e)?i.get(e).entries.push(t):(i.has(null)||i.set(null,{key:null,label:`Ungrouped`,entries:[]}),i.get(null).entries.push(t))}let o=!!n?.includeEmptyDeclared;return Array.from(i.values()).filter(e=>e.entries.length>0||o&&e.key!==null)}function vt(e,t){return e===t||JSON.stringify(e??null)===JSON.stringify(t??null)}function yt(e,t){let n=new Set([...Object.keys(e),...Object.keys(t)]),r=[];for(let i of n)vt(e[i],t[i])||r.push(i);return r.sort()}function bt(e,t){let n=tt(e),r=tt(t),i=new Map(n.entries.map(e=>[e.name,e])),a=new Set(r.entries.map(e=>e.name)),o={},s=0,c=0;for(let e of r.entries){let t=i.get(e.name);if(!t){o[e.name]={name:e.name,status:`added`,changedKeys:[]},s+=1;continue}let n=yt(t.def,e.def);n.length?(o[e.name]={name:e.name,status:`changed`,changedKeys:n},c+=1):o[e.name]={name:e.name,status:`unchanged`,changedKeys:[]}}let l=n.entries.filter(e=>!a.has(e.name));return{byName:o,removed:l,counts:{added:s,changed:c,removed:l.length}}}function xt(e,t){let n=et(),[r,i]=J.useState({fields:[],loading:!t&&!!e,error:null});return J.useEffect(()=>{if(t){i({fields:t,loading:!1,error:null});return}if(!e){i({fields:[],loading:!1,error:null});return}let r=!1;return i(e=>({...e,loading:!0,error:null})),n.get(`object`,e).then(e=>{if(r)return;if(!e){i({fields:[],loading:!1,error:`Object not found`});return}let t=tt(e.fields).entries.map(e=>({name:e.name,label:typeof e.def.label==`string`&&e.def.label?e.def.label:e.name,type:typeof e.def.type==`string`?e.def.type:`text`,hidden:e.def.hidden===!0}));i({fields:t,loading:!1,error:null})}).catch(e=>{r||i({fields:[],loading:!1,error:e?.message??String(e)})}),()=>{r=!0}},[n,e,t]),r}function St({kindLabel:e,title:t,onClose:n,closeLabel:r=`Close`,children:i,footer:a,headerActions:o,hideClose:s}){return(0,Y.jsxs)(`div`,{className:`flex h-full flex-col`,children:[(0,Y.jsxs)(`div`,{className:`flex items-start justify-between gap-2 border-b px-4 py-2.5`,children:[(0,Y.jsxs)(`div`,{className:`min-w-0`,children:[(0,Y.jsx)(He,{variant:`secondary`,className:`text-[10px] uppercase tracking-wider`,children:e}),(0,Y.jsx)(`div`,{className:`mt-1 truncate text-sm font-medium`,title:t,children:t})]}),(0,Y.jsxs)(`div`,{className:`flex items-center gap-1 shrink-0`,children:[o,!s&&(0,Y.jsx)(m,{variant:`ghost`,size:`sm`,onClick:n,"aria-label":r,className:`h-7 w-7 p-0`,children:(0,Y.jsx)(T,{className:`h-4 w-4`})})]})]}),(0,Y.jsx)(`div`,{className:`flex-1 overflow-auto px-4 py-3 space-y-3`,children:i}),a&&(0,Y.jsx)(`div`,{className:`border-t px-4 py-2.5`,children:a})]})}function Ct({index:e,total:t,onMove:n,upLabel:r=`Move up`,downLabel:i=`Move down`,disabled:a}){if(t<=1||e<0)return null;let o=!a&&e>0,s=!a&&e<t-1;return(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(m,{type:`button`,variant:`ghost`,size:`sm`,className:`h-7 w-7 p-0`,onClick:()=>o&&n(e-1),disabled:!o,"aria-label":r,title:r,children:(0,Y.jsx)(qe,{className:`h-4 w-4`})}),(0,Y.jsx)(m,{type:`button`,variant:`ghost`,size:`sm`,className:`h-7 w-7 p-0`,onClick:()=>s&&n(e+1),disabled:!s,"aria-label":i,title:i,children:(0,Y.jsx)(p,{className:`h-4 w-4`})})]})}function wt({label:e,value:t,onCommit:n,onBlur:r,placeholder:i,disabled:a,mono:o,testId:s}){return(0,Y.jsxs)(`div`,{className:`space-y-1`,children:[(0,Y.jsx)(H,{className:`text-xs text-muted-foreground`,children:e}),(0,Y.jsx)(V,{value:t,onChange:e=>n(e.target.value),onBlur:e=>r?.(e.target.value),placeholder:i,disabled:a,"data-testid":s,className:C(`h-8 text-sm`,o&&`font-mono`)})]})}function Tt({label:e,value:t,onCommit:n,placeholder:r,disabled:i}){return(0,Y.jsxs)(`div`,{className:`space-y-1`,children:[(0,Y.jsx)(H,{className:`text-xs text-muted-foreground`,children:e}),(0,Y.jsx)(V,{type:`number`,value:t??``,onChange:e=>{let t=e.target.value;n(t===``?void 0:Number(t))},placeholder:r,disabled:i,className:`h-8 text-sm`})]})}function X({label:e,value:t,options:n,onCommit:r,placeholder:i=`—`,disabled:a}){let o=e=>e===``?Et:e,s=e=>e===Et?``:e;return(0,Y.jsxs)(`div`,{className:`space-y-1`,children:[(0,Y.jsx)(H,{className:`text-xs text-muted-foreground`,children:e}),(0,Y.jsxs)(z,{value:o(t??``),onValueChange:e=>r(s(e)),disabled:a,children:[(0,Y.jsx)(B,{className:`h-8 text-sm`,children:(0,Y.jsx)(W,{placeholder:i})}),(0,Y.jsx)(N,{children:n.map(e=>(0,Y.jsx)(c,{value:o(e.value),children:e.label},e.value))})]})]})}var Et=`__inspector_select_none__`;function Dt({label:e,value:t,onCommit:n,disabled:r}){return(0,Y.jsxs)(`label`,{className:`flex items-center gap-2 text-xs cursor-pointer select-none`,children:[(0,Y.jsx)(`input`,{type:`checkbox`,checked:t,disabled:r,onChange:e=>n(e.target.checked),className:`h-3.5 w-3.5`}),(0,Y.jsx)(`span`,{children:e})]})}function Ot({label:e,onClick:t,disabled:n}){return(0,Y.jsxs)(m,{variant:`outline`,size:`sm`,onClick:t,disabled:n,className:`w-full gap-1.5 text-muted-foreground hover:border-destructive/40 hover:bg-destructive/5 hover:text-destructive`,children:[(0,Y.jsx)(M,{className:`h-3.5 w-3.5`}),e]})}function kt({message:e}){return(0,Y.jsx)(`div`,{className:`text-xs italic text-muted-foreground p-4 text-center`,children:e})}function At(e,t,n){let r=Array.isArray(e)?[...e]:[];return n===null?r.splice(t,1):r[t]=n,r}function jt(e,t){let n=Array.isArray(e)?[...e]:[];return n.push(t),n}function Mt(e,t,n){let r=Array.isArray(e)?[...e]:[];if(t<0||t>=r.length)return r;let i=Math.max(0,Math.min(r.length-1,n));if(i===t)return r;let[a]=r.splice(t,1);return r.splice(i,0,a),r}function Nt(e,t){let n=new Set(t.filter(e=>typeof e==`string`));for(let t=1;t<1e4;t++){let r=`${e}_${t}`;if(!n.has(r))return r}return`${e}_${Date.now()}`}function Pt(e,t){if(e==null)return!0;let n=typeof e==`string`?e:e.source;if(!n)return!0;try{return Ft(n.trim(),t)}catch{return!0}}function Ft(e,t){let n=It(e,`||`);if(n.length>1)return n.some(e=>Ft(e.trim(),t));let r=It(e,`&&`);if(r.length>1)return r.every(e=>Ft(e.trim(),t));if(e.startsWith(`!`))return!Ft(e.slice(1).trim(),t);let i=e.match(/^(.+?)\s+in\s+(\[.*\])$/);if(i){let e=Lt(i[1].trim(),t),n=Rt(i[2]);return Array.isArray(n)&&n.includes(e)}let a=e.match(/^(.+?)\s*(==|!=)\s*(.+)$/);if(a){let e=Lt(a[1].trim(),t),n=Rt(a[3].trim()),r=e=>e==null,i=r(e)&&r(n)?!0:e===n;return a[2]===`==`?i:!i}return!!Lt(e,t)}function It(e,t){let n=[],r=0,i=null,a=``;for(let o=0;o<e.length;o++){let s=e[o];if(i){a+=s,s===i&&e[o-1]!==`\\`&&(i=null);continue}if(s===`'`||s===`"`){i=s,a+=s;continue}if(s===`(`||s===`[`?r++:(s===`)`||s===`]`)&&r--,r===0&&e.slice(o,o+t.length)===t&&e[o+t.length]!==`=`){n.push(a),a=``,o+=t.length-1;continue}a+=s}return a&&n.push(a),n}function Lt(e,t){if(/^['"]/.test(e)||/^-?\d/.test(e)||e===`true`||e===`false`||e===`null`)return Rt(e);let n=e.split(`.`),r=t;for(let e of n){if(r==null)return;r=r[e]}return r}function Rt(e){let t=e.trim();if(t===`true`)return!0;if(t===`false`)return!1;if(t===`null`)return null;if(/^-?\d+(\.\d+)?$/.test(t))return Number(t);if(t.startsWith(`'`)&&t.endsWith(`'`)||t.startsWith(`"`)&&t.endsWith(`"`))return t.slice(1,-1);if(t.startsWith(`[`)&&t.endsWith(`]`))try{let e=t.replace(/'([^']*)'/g,(e,t)=>JSON.stringify(t));return JSON.parse(e)}catch{return[]}return t}var zt=[{value:`default`,label:`Default`,css:`#9ca3af`},{value:`blue`,label:`Blue`,css:`#3b82f6`},{value:`teal`,label:`Teal`,css:`#14b8a6`},{value:`orange`,label:`Orange`,css:`#f97316`},{value:`purple`,label:`Purple`,css:`#a855f7`},{value:`success`,label:`Success`,css:`#22c55e`},{value:`warning`,label:`Warning`,css:`#f59e0b`},{value:`danger`,label:`Danger`,css:`#ef4444`},{value:`green`,label:`Green`,css:`#22c55e`},{value:`red`,label:`Red`,css:`#ef4444`},{value:`amber`,label:`Amber`,css:`#f59e0b`}],Bt=Object.fromEntries(zt.map(e=>[e.value,e.css]));function Vt(e){return e?/^#([0-9a-f]{3}|[0-9a-f]{6})$/i.test(e)?e:Bt[e]??`#9ca3af`:`#9ca3af`}function Ht({value:e,onChange:t,disabled:n,options:r}){let i=r?r.map(e=>({value:e.value,label:e.label??e.value,css:Vt(e.value)})):zt.slice(0,8),a=e??`default`;return(0,Y.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,role:`radiogroup`,children:i.map(e=>{let r=a===e.value;return(0,Y.jsx)(`button`,{type:`button`,role:`radio`,"aria-checked":r,"aria-label":e.label,title:e.label,disabled:n,onClick:()=>t(e.value),className:C(`flex h-7 w-7 items-center justify-center rounded-full border transition-all`,r?`border-transparent ring-2 ring-foreground/60 ring-offset-1 ring-offset-background`:`border-border hover:scale-110`,n&&`cursor-not-allowed opacity-50`),children:(0,Y.jsx)(`span`,{className:`h-4 w-4 rounded-full`,style:{backgroundColor:e.css}})},e.value)})})}var Ut=null;function Wt(){return Ut||=t(()=>import(`./vendor-objectstack-BTM1m7k5.js`).then(e=>e.k).then(e=>e),[],import.meta.url).catch(()=>null),Ut}var Gt=[`record`,``],Kt=[`current_user`,`user`];async function qt(e,t={}){if(!e||!e.trim())return[];try{let n=await Wt();if(!n?.validateExpression)return[];let r=n.validateExpression(t.role??`predicate`,e,{objectName:t.objectName,fields:t.fields,scope:t.scope??`flattened`}),i=[];for(let e of r?.errors??[])e?.message&&i.push({severity:`error`,message:e.message});for(let e of r?.warnings??[])e?.message&&i.push({severity:`warning`,message:e.message});if(i.every(e=>e.severity!==`error`)&&t.clause===`using`&&n.isPushdownableCel)try{let t=n.isPushdownableCel(e,{fieldRoots:Gt,variableRoots:Kt});t&&t.ok===!1&&t.reason!==`parse-error`&&i.push({severity:`warning`,message:`This read filter isn't a simple field comparison (${t.detail}), so the server may be unable to push it down to the query — depending on the evaluation path it can be dropped and WIDEN access. Prefer a pushdown-able predicate (field vs. value or scope variable).`})}catch{}return i}catch{return[]}}var Jt=[`number`,`text`,`boolean`,`date`,`unknown`];async function Yt(e,t={}){if(!e||!e.trim())return null;try{let n=await Wt();if(!n?.inferExpressionType)return null;let r=n.inferExpressionType(e,{objectName:t.objectName,fields:t.fields,scope:t.scope??`record`});return Jt.includes(r)?r:`unknown`}catch{return null}}async function Xt(e={}){let t={fields:e.fields??[],roots:e.roots??[],functions:[]};try{let n=await Wt();if(!n?.introspectScope)return t;let r=n.introspectScope(e.role??`predicate`,{objectName:e.objectName,fields:e.fields,scope:e.scope??`flattened`});return{fields:r?.fields??e.fields??[],roots:e.roots??r?.roots??[],functions:r?.functions??[]}}catch{return t}}var Zt=/[A-Za-z0-9_$]/,Qt=/[A-Za-z_$]/;function $t(e,t){let n=t;for(;n>0&&Zt.test(e[n-1]);)n--;if(n===t)return null;let r=e.slice(n,t);return!Qt.test(r[0])||n>0&&e[n-1]===`.`?null:{start:n,end:t,text:r}}function en(e,t){let n=t;for(;n>0&&Zt.test(e[n-1]);)n--;let r=e.slice(n,t);if(r&&!Qt.test(r[0])||n===0||e[n-1]!==`.`)return null;let i=n-1;for(;i>0&&Zt.test(e[i-1]);)i--;let a=e.slice(i,n-1);return!a||!Qt.test(a[0])||i>0&&e[i-1]===`.`?null:{root:a,start:n,end:t,text:r}}function tn(e){let t=new Set,n=[],r=(e,r)=>{!e||t.has(e)||(t.add(e),n.push({label:e,kind:r}))};return e.fields.forEach(e=>r(e,`field`)),e.roots.forEach(e=>r(e,`root`)),e.functions.forEach(e=>r(e,`function`)),n}function nn(e,t,n=!1){let r=t.toLowerCase();if(!r&&!n)return[];let i=[];for(let t of e){let e=t.label.toLowerCase();if(e.startsWith(r)&&e!==r&&i.push(t),i.length>=8)break}return i}async function rn(e,t){if(!e||!e.trim())return{status:`error`,kind:`parse`,message:`The predicate is empty.`};let n;try{n=await Wt()}catch{return{status:`unavailable`}}if(!n?.ExpressionEngine?.evaluate)return{status:`unavailable`};try{let r=t.record??{},i=t.currentUser??{},a={record:r,extra:{...r,record:r,current_user:i,user:i}},o=n.ExpressionEngine.evaluate({dialect:`cel`,source:e},a);if(!o||o.ok!==!0){let e=o&&o.ok===!1?o.error:void 0;return{status:`error`,kind:e?.kind??`runtime`,message:e?.message??`Evaluation failed.`}}return o.value===!0?{status:`allow`}:o.value===!1?{status:`deny`}:{status:`value`,value:o.value}}catch(e){return{status:`error`,kind:`runtime`,message:e?.message??String(e)}}}var an=250,on={field:`field`,root:`scope`,function:`fn`},sn=new Set([`record`,`previous`]),cn=[];function ln({value:e,onChange:t,disabled:n,placeholder:r,label:i,objectName:a,fieldNames:o=cn,clause:s,scope:c,roots:l,role:u,onLintChange:d,onInferredTypeChange:f,t:p,id:m}){let h=J.useRef(null),[g,_]=J.useState([]),[v,y]=J.useState(!1),[b,x]=J.useState(null),[w,T]=J.useState(null),[E,D]=J.useState(!1),[k,A]=J.useState([]),[j,M]=J.useState(0),N=J.useRef(null),P=J.useRef(null),ee=o.join(`,`),te=l?l.join(`,`):``,F=J.useRef(d),ne=J.useRef(f);J.useEffect(()=>{F.current=d,ne.current=f}),J.useEffect(()=>{let t=!1,n=setTimeout(()=>{let n={objectName:a,fields:o,clause:s,scope:c,role:u};qt(e,n).then(e=>{t||(_(e),y(!0),F.current?.(e))}),u===`value`&&Yt(e,n).then(e=>{t||(x(e),ne.current?.(e))})},an);return()=>{t=!0,clearTimeout(n)}},[e,a,ee,s,c,u]),J.useEffect(()=>{e.trim()||(_([]),y(!1),x(null),F.current?.([]),u===`value`&&ne.current?.(null))},[e]),J.useEffect(()=>{let e=!1;return Xt({objectName:a,fields:o,scope:c,roots:l}).then(t=>{e||T(t)}),()=>{e=!0}},[a,ee,c,te]);let I=J.useMemo(()=>w?tn(c===`record`?{...w,fields:[]}:w):[],[w,c]),re=J.useMemo(()=>w?w.fields.map(e=>({label:e,kind:`field`})):[],[w]);J.useEffect(()=>{if(P.current!=null&&h.current){let e=P.current;P.current=null,h.current.setSelectionRange(e,e)}},[e]);let L=J.useCallback(()=>{D(!1),A([]),N.current=null},[]),R=J.useCallback(()=>{let e=h.current;if(!e||n)return L();let t=e.value,r=e.selectionStart??t.length,i=null,a=[],o=$t(t,r);if(o)i=o,a=nn(I,o.text);else{let e=en(t,r);e&&sn.has(e.root)&&(i=e,a=nn(re,e.text,!0))}if(!i||!a.length)return L();N.current={start:i.start,end:i.end},A(a),M(0),D(!0)},[I,re,n,L]),ie=J.useCallback(e=>{let n=N.current,r=h.current;if(!n||!r)return;let i=r.value,a=e.kind===`function`?`${e.label}(`:e.label,o=i.slice(0,n.start)+a+i.slice(n.end);P.current=n.start+a.length,L(),t(o)},[t,L]),oe=J.useRef(R);J.useEffect(()=>{oe.current=R},[R]),J.useEffect(()=>{h.current&&document.activeElement===h.current&&oe.current()},[I,re]);let se=e=>{!E||k.length===0||(e.key===`ArrowDown`?(e.preventDefault(),M(e=>(e+1)%k.length)):e.key===`ArrowUp`?(e.preventDefault(),M(e=>(e-1+k.length)%k.length)):e.key===`Enter`||e.key===`Tab`?(e.preventDefault(),ie(k[j])):e.key===`Escape`&&(e.preventDefault(),L()))},z=g.filter(e=>e.severity===`error`),ce=g.filter(e=>e.severity===`warning`),le=v&&!!e.trim()&&g.length===0,ue=u===`value`&&v&&!!e.trim()&&z.length===0&&b!==null,de=m?`${m}-ac`:void 0;return(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(H,{className:`text-[10px] uppercase text-muted-foreground`,htmlFor:m,children:i}),(0,Y.jsxs)(`div`,{className:`relative`,children:[(0,Y.jsx)(_e,{ref:h,id:m,value:e,disabled:n,rows:2,placeholder:r,spellCheck:!1,autoComplete:`off`,role:`combobox`,"aria-expanded":E,"aria-autocomplete":`list`,"aria-controls":E?de:void 0,"aria-invalid":z.length>0||void 0,onChange:e=>{t(e.target.value),R()},onKeyDown:se,onClick:R,onBlur:()=>{window.setTimeout(()=>L(),120)},className:C(`font-mono text-xs`,z.length>0&&`border-destructive focus-visible:ring-destructive/40`)}),E&&k.length>0&&(0,Y.jsx)(`ul`,{id:de,role:`listbox`,"aria-label":p(`perm.cel.suggestions`),className:`absolute z-50 mt-1 max-h-48 w-72 overflow-auto rounded-md border bg-popover p-1 text-popover-foreground shadow-md`,children:k.map((e,t)=>(0,Y.jsxs)(`li`,{role:`option`,"aria-selected":t===j,onMouseDown:t=>{t.preventDefault(),ie(e)},onMouseEnter:()=>M(t),className:C(`flex cursor-pointer items-center justify-between gap-2 rounded-sm px-2 py-1 text-xs`,t===j?`bg-accent text-accent-foreground`:`hover:bg-accent/60`),children:[(0,Y.jsx)(`span`,{className:`font-mono`,children:e.label}),(0,Y.jsx)(`span`,{className:`text-[10px] uppercase text-muted-foreground`,children:on[e.kind]})]},`${e.kind}:${e.label}`))})]}),(z.length>0||ce.length>0)&&(0,Y.jsxs)(`ul`,{className:`mt-1 space-y-1`,"aria-live":`polite`,children:[z.map((e,t)=>(0,Y.jsxs)(`li`,{className:`flex items-start gap-1.5 text-[11px] text-destructive`,children:[(0,Y.jsx)(S,{className:`mt-[1px] h-3 w-3 shrink-0`}),(0,Y.jsx)(`span`,{children:e.message})]},`e${t}`)),ce.map((e,t)=>(0,Y.jsxs)(`li`,{className:`flex items-start gap-1.5 text-[11px] text-amber-600 dark:text-amber-500`,children:[(0,Y.jsx)(ae,{className:`mt-[1px] h-3 w-3 shrink-0`}),(0,Y.jsx)(`span`,{children:e.message})]},`w${t}`))]}),le&&(0,Y.jsxs)(`p`,{className:`mt-1 flex items-center gap-1.5 text-[11px] text-muted-foreground`,children:[(0,Y.jsx)(O,{className:`h-3 w-3 shrink-0 text-emerald-600 dark:text-emerald-500`}),p(`perm.cel.valid`)]}),ue&&(0,Y.jsxs)(`p`,{className:`mt-1 flex items-start gap-1.5 text-[11px] text-muted-foreground`,"aria-live":`polite`,children:[(0,Y.jsx)(Ke,{className:`mt-[1px] h-3 w-3 shrink-0`}),(0,Y.jsxs)(`span`,{children:[p(`perm.cel.type`),` `,(0,Y.jsx)(`span`,{className:C(`font-medium`,b!==`unknown`&&`text-foreground`),children:p(`perm.cel.type.${b}`)}),b===`unknown`&&(0,Y.jsxs)(Y.Fragment,{children:[` — `,p(`perm.cel.type.unknownHint`)]})]})]})]})}var un=[{value:`==`,label:`equals`},{value:`!=`,label:`not equals`},{value:`>`,label:`greater than`},{value:`<`,label:`less than`},{value:`>=`,label:`≥`},{value:`<=`,label:`≤`},{value:`truthy`,label:`is set / true`},{value:`falsy`,label:`is empty / false`}],dn=[{value:`record.id`,label:`record.id`},{value:`user.id`,label:`user.id`},{value:`user.email`,label:`user.email`},{value:`user.role`,label:`user.role`},{value:`user.isAdmin`,label:`user.isAdmin`},{value:`org.id`,label:`org.id`}],fn=e=>e.replace(/\s+/g,` `).trim();function pn(e){let t=e.trim();return t===`true`||t===`false`||t===`null`||t!==``&&!Number.isNaN(Number(t))?t:`'${t.replace(/'/g,`\\'`)}'`}function mn(e){let t=e.trim(),n=/^'(.*)'$/.exec(t);return n?n[1].replace(/\\'/g,`'`):t}function hn(e,t){return e.filter(e=>e.subject).map(e=>e.op===`truthy`?e.subject:e.op===`falsy`?`!${e.subject}`:`${e.subject} ${e.op} ${pn(e.value)}`).join(` ${t} `)}function gn(e){let t=fn(e);if(!t)return{rows:[],join:`&&`};let n=t.includes(`&&`),r=t.includes(`||`);if(n&&r)return null;let i=r?`||`:`&&`,a=t.split(r?`||`:`&&`).map(e=>e.trim()),o=[];for(let e of a){let t=/^([a-zA-Z_][\w.]*)\s*(==|!=|>=|<=|>|<)\s*(.+)$/.exec(e);if(t){o.push({subject:t[1],op:t[2],value:mn(t[3])});continue}let n=/^!\s*([a-zA-Z_][\w.]*)$/.exec(e);if(n){o.push({subject:n[1],op:`falsy`,value:``});continue}let r=/^([a-zA-Z_][\w.]*)$/.exec(e);if(r){o.push({subject:r[1],op:`truthy`,value:``});continue}return null}return{rows:o,join:i}}function _n(e){let t=gn(e||``);return t&&fn(hn(t.rows,t.join))===fn(e||``)?{rows:t.rows,join:t.join,raw:!1}:{rows:[],join:`&&`,raw:!!e}}function vn({label:e,value:t,onCommit:n,objectName:r,fields:i,disabled:a}){let{fields:o}=xt(r),s=i??o,l=J.useMemo(()=>[...s.filter(e=>!e.hidden).map(e=>({value:`record.${e.name}`,label:`record.${e.name}`})),...dn],[s]),u=K(),d=J.useCallback(e=>q(e,u),[u]),f=J.useMemo(()=>s.filter(e=>!e.hidden).map(e=>e.name),[s]),p=J.useMemo(()=>_n(t),[]),[h,g]=J.useState(p.rows),[_,v]=J.useState(p.join),[y,b]=J.useState(p.raw),x=J.useRef(t||``);J.useEffect(()=>{let e=t||``;if(e===x.current)return;x.current=e;let n=_n(e);g(n.rows),v(n.join),b(n.raw)},[t]);let S=(e,t)=>{let r=hn(e,t);x.current=r,n(r)},C=(e,t=_)=>{g(e),v(t),S(e,t)},w=hn(h,_);return y?(0,Y.jsxs)(`div`,{className:`space-y-1`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center justify-between`,children:[e?(0,Y.jsx)(H,{className:`text-xs text-muted-foreground`,children:e}):(0,Y.jsx)(`span`,{}),(0,Y.jsxs)(`button`,{type:`button`,disabled:a,onClick:()=>{let e=_n(t);(!t||!e.raw)&&(g(e.rows),v(e.join),b(!1))},className:`inline-flex items-center gap-1 text-[10px] text-muted-foreground hover:text-foreground disabled:opacity-50`,children:[(0,Y.jsx)(L,{className:`h-3 w-3`}),` Builder`]})]}),(0,Y.jsx)(ln,{label:d(`engine.condition.celLabel`),value:t,onChange:e=>{x.current=e,n(e)},disabled:a,placeholder:`record.status != 'done' && user.isAdmin`,objectName:r,fieldNames:f,t:d}),t&&!gn(t)&&(0,Y.jsx)(`div`,{className:`text-[10px] text-muted-foreground/70`,children:d(`engine.condition.advancedHint`)})]}):(0,Y.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center justify-between`,children:[e?(0,Y.jsx)(H,{className:`text-xs text-muted-foreground`,children:e}):(0,Y.jsx)(`span`,{}),(0,Y.jsxs)(`button`,{type:`button`,disabled:a,onClick:()=>b(!0),className:`inline-flex items-center gap-1 text-[10px] text-muted-foreground hover:text-foreground disabled:opacity-50`,children:[(0,Y.jsx)(ye,{className:`h-3 w-3`}),` Expression`]})]}),h.length===0?(0,Y.jsx)(`p`,{className:`rounded-md border border-dashed bg-muted/30 px-3 py-2 text-center text-[11px] text-muted-foreground`,children:`Always — no condition.`}):(0,Y.jsx)(`div`,{className:`space-y-1.5`,children:h.map((e,t)=>(0,Y.jsxs)(`div`,{className:`space-y-1 rounded-md border border-border p-1.5`,children:[t>0&&(0,Y.jsx)(`div`,{className:`flex justify-center`,children:(0,Y.jsxs)(z,{value:_,onValueChange:e=>C(h,e),disabled:a,children:[(0,Y.jsx)(B,{className:`h-6 w-16 text-[10px]`,children:(0,Y.jsx)(W,{})}),(0,Y.jsxs)(N,{children:[(0,Y.jsx)(c,{value:`&&`,children:`AND`}),(0,Y.jsx)(c,{value:`||`,children:`OR`})]})]})}),(0,Y.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,Y.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,Y.jsxs)(z,{value:e.subject,onValueChange:e=>C(h.map((n,r)=>r===t?{...n,subject:e}:n)),disabled:a,children:[(0,Y.jsx)(B,{className:`h-7 text-xs`,children:(0,Y.jsx)(W,{placeholder:`field / context`})}),(0,Y.jsxs)(N,{children:[l.map(e=>(0,Y.jsx)(c,{value:e.value,children:e.label},e.value)),e.subject&&!l.some(t=>t.value===e.subject)&&(0,Y.jsx)(c,{value:e.subject,children:e.subject})]})]})}),(0,Y.jsx)(m,{type:`button`,variant:`ghost`,size:`icon`,className:`h-7 w-7 shrink-0`,disabled:a,"aria-label":`Remove condition`,onClick:()=>C(h.filter((e,n)=>n!==t)),children:(0,Y.jsx)(T,{className:`h-3.5 w-3.5`})})]}),(0,Y.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,Y.jsx)(`div`,{className:`w-28 shrink-0`,children:(0,Y.jsxs)(z,{value:e.op,onValueChange:e=>C(h.map((n,r)=>r===t?{...n,op:e}:n)),disabled:a,children:[(0,Y.jsx)(B,{className:`h-7 text-xs`,children:(0,Y.jsx)(W,{})}),(0,Y.jsx)(N,{children:un.map(e=>(0,Y.jsx)(c,{value:e.value,children:e.label},e.value))})]})}),e.op!==`truthy`&&e.op!==`falsy`&&(0,Y.jsx)(V,{className:`h-7 flex-1 text-xs`,value:e.value,placeholder:`value`,disabled:a,onChange:e=>C(h.map((n,r)=>r===t?{...n,value:e.target.value}:n))})]})]},t))}),!a&&(0,Y.jsxs)(m,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>C([...h,{subject:``,op:`truthy`,value:``}]),children:[(0,Y.jsx)(U,{className:`mr-1 h-3.5 w-3.5`}),` Add condition`]}),w&&(0,Y.jsx)(`div`,{className:`rounded bg-muted/40 px-2 py-1 text-[10px] font-mono text-muted-foreground break-all`,children:w})]})}function yn({id:e,value:t,onChange:n,readOnly:r,context:i}){let a=K(),o=i?.objectNames??[],s=t==null?``:String(t);return i?.objectsLoading?(0,Y.jsx)(V,{id:e,value:s,disabled:!0,placeholder:q(`engine.form.loadingObjects`,a)}):o.length===0?(0,Y.jsx)(V,{id:e,value:s,disabled:r,onChange:e=>n(e.target.value||void 0),placeholder:q(`engine.form.noObjects`,a)}):(0,Y.jsxs)(z,{value:s,onValueChange:e=>n(e||void 0),disabled:r,children:[(0,Y.jsx)(B,{id:e,children:(0,Y.jsx)(W,{placeholder:q(`engine.form.selectObject`,a)})}),(0,Y.jsx)(N,{children:o.map(e=>(0,Y.jsx)(c,{value:e,children:e},e))})]})}function bn(e){let t=[],n=new Set,r=e=>{if(!e||typeof e!=`object`)return;let r=e,a=r.id;typeof a==`string`&&a&&!n.has(a)&&(n.add(a),t.push({id:a,type:typeof r.type==`string`?r.type:void 0,label:typeof r.label==`string`?r.label:void 0})),i(r.components),i(r.children);let o=r.properties;o&&typeof o==`object`&&(i(o.components),i(o.children))},i=e=>{if(Array.isArray(e))for(let t of e)r(t)};if(e&&typeof e==`object`){let t=e.regions;if(Array.isArray(t))for(let e of t)e&&typeof e==`object`&&i(e.components)}return t}function xn({id:e,value:t,onChange:n,readOnly:r,context:i}){let a=K(),o=i?.componentIds??[],s=t==null?``:String(t);if(o.length===0)return(0,Y.jsx)(V,{id:e,value:s,disabled:r,onChange:e=>n(e.target.value||void 0),placeholder:q(`engine.form.noComponents`,a)});let l=!s||o.some(e=>e.id===s);return(0,Y.jsxs)(z,{value:s||Z,onValueChange:e=>n(e===Z?void 0:e),disabled:r,children:[(0,Y.jsx)(B,{id:e,children:(0,Y.jsx)(W,{placeholder:q(`engine.form.selectComponent`,a)})}),(0,Y.jsxs)(N,{children:[(0,Y.jsx)(c,{value:Z,children:(0,Y.jsx)(`span`,{className:`text-muted-foreground`,children:q(`engine.form.none`,a)})}),!l&&s&&(0,Y.jsx)(c,{value:s,children:(0,Y.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,Y.jsx)(`span`,{className:`font-mono`,children:s}),(0,Y.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:q(`engine.form.notInObject`,a)})]})}),o.map(e=>(0,Y.jsx)(c,{value:e.id,children:(0,Y.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,Y.jsx)(`span`,{className:`font-mono`,children:e.id}),(e.label||e.type)&&(0,Y.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:e.label||e.type})]})},e.id))]})]})}function Sn({id:e,value:t,onChange:n,readOnly:r,context:i,fieldSpec:a}){let o=K(),s=i?.objectNames??[],l=a?.multiple??!1,u=J.useMemo(()=>t?Array.isArray(t)?t.map(String):String(t).split(`,`).map(e=>e.trim()).filter(Boolean):[],[t]),d=e=>{if(!r){if(!l){n(e);return}n(u.includes(e)?u.filter(t=>t!==e):[...u,e])}},f=e=>{if(r)return;let t=u.filter(t=>t!==e);n(l?t:``)};return i?.objectsLoading?(0,Y.jsx)(V,{id:e,value:q(`engine.form.loadingObjects`,o),readOnly:!0,disabled:!0}):(0,Y.jsxs)(`div`,{className:`space-y-2`,children:[u.length>0&&(0,Y.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:u.map(e=>(0,Y.jsxs)(`div`,{className:`inline-flex items-center gap-1 rounded bg-secondary px-2 py-1 text-sm`,children:[(0,Y.jsx)(`span`,{children:e}),!r&&(0,Y.jsx)(`button`,{type:`button`,onClick:()=>f(e),className:`text-muted-foreground hover:text-foreground`,children:`×`})]},e))}),(0,Y.jsxs)(z,{value:``,onValueChange:d,disabled:r||s.length===0,children:[(0,Y.jsx)(B,{id:e,children:(0,Y.jsx)(W,{placeholder:q(l?`engine.form.addObjects`:`engine.form.selectObjectDots`,o)})}),(0,Y.jsx)(N,{children:s.map(e=>(0,Y.jsxs)(c,{value:e,disabled:!l&&u.includes(e),children:[e,u.includes(e)&&` ✓`]},e))})]})]})}function Cn({id:e,value:t,onChange:n,readOnly:r,fieldSpec:i,formData:a}){let o=K(),[s,l]=J.useState([]),[u,d]=J.useState(!1),f=i?.dependsOn||i?.reference||`objectName`,p=Array.isArray(f)?f[0]:f,m=a?.[p];J.useEffect(()=>{if(!m){l([]);return}d(!0),fetch(`/api/v1/objects/${m}/fields`).then(e=>e.json()).then(e=>{l(e.fields||[]),d(!1)}).catch(e=>{console.error(`Failed to load fields:`,e),l([]),d(!1)})},[m]);let h=i?.multiple??!1,g=J.useMemo(()=>t?Array.isArray(t)?t.map(String):String(t).split(`,`).map(e=>e.trim()).filter(Boolean):[],[t]),_=e=>{if(!r){if(!h){n(e);return}n(g.includes(e)?g.filter(t=>t!==e):[...g,e])}},v=e=>{if(r)return;let t=g.filter(t=>t!==e);n(h?t:``)};return m?u?(0,Y.jsx)(V,{id:e,value:q(`engine.form.loadingFields`,o),readOnly:!0,disabled:!0}):(0,Y.jsxs)(`div`,{className:`space-y-2`,children:[g.length>0&&(0,Y.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:g.map(e=>{let t=s.find(t=>t.name===e);return(0,Y.jsxs)(`div`,{className:`inline-flex items-center gap-1 rounded bg-secondary px-2 py-1 text-sm`,children:[(0,Y.jsx)(`span`,{children:t?.label||e}),(0,Y.jsx)(`code`,{className:`text-xs text-muted-foreground`,children:t?.type}),!r&&(0,Y.jsx)(`button`,{type:`button`,onClick:()=>v(e),className:`text-muted-foreground hover:text-foreground`,children:`×`})]},e)})}),(0,Y.jsxs)(z,{value:``,onValueChange:_,disabled:r||s.length===0,children:[(0,Y.jsx)(B,{id:e,children:(0,Y.jsx)(W,{placeholder:q(h?`engine.form.addFields`:`engine.form.selectFieldDots`,o)})}),(0,Y.jsx)(N,{children:s.map(e=>(0,Y.jsx)(c,{value:e.name,disabled:!h&&g.includes(e.name),children:(0,Y.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Y.jsx)(`span`,{children:e.label||e.name}),(0,Y.jsx)(`code`,{className:`text-xs text-muted-foreground`,children:e.type}),g.includes(e.name)&&` ✓`]})},e.name))})]})]}):(0,Y.jsx)(V,{id:e,value:q(`engine.form.selectObjectFirst`,o),readOnly:!0,disabled:!0})}function wn({schema:e,value:t,onChange:n,readOnly:r,context:i}){let a=K(),o=e;if(o?.anyOf||o?.oneOf){let e=(o.anyOf??o.oneOf).find(e=>e?.type===`array`&&e?.items?.type===`object`);e&&(o={...o,...e})}let s=o?.items??{},c=s.properties??{},l=new Set(Array.isArray(s.required)?s.required:[]),u=Array.isArray(t)?t:[],d=Object.keys(c);if(d.length===0)return(0,Y.jsx)(`div`,{className:`rounded border border-dashed border-amber-500/40 bg-amber-500/5 p-2 text-xs text-amber-700 dark:text-amber-300`,children:q(`engine.form.masterDetailSchemaError`,a)});function f(e,t){let r=u.slice();r[e]={...r[e]??{},...t},n(r)}function p(){n([...u,{}])}function h(e){let t=u.slice();t.splice(e,1),n(t)}return(0,Y.jsxs)(`div`,{className:`space-y-2`,children:[(0,Y.jsx)(`div`,{className:`overflow-x-auto rounded border border-border/40`,children:(0,Y.jsxs)(`table`,{className:`w-full text-sm`,children:[(0,Y.jsx)(`thead`,{className:`bg-muted/40`,children:(0,Y.jsxs)(`tr`,{children:[d.map(e=>(0,Y.jsxs)(`th`,{className:`px-2 py-1.5 text-left text-xs font-medium text-muted-foreground`,children:[c[e]?.title??e,l.has(e)&&(0,Y.jsx)(`span`,{className:`text-destructive ml-0.5`,children:`*`})]},e)),(0,Y.jsx)(`th`,{className:`w-8`})]})}),(0,Y.jsxs)(`tbody`,{children:[u.length===0&&(0,Y.jsx)(`tr`,{children:(0,Y.jsx)(`td`,{colSpan:d.length+1,className:`px-2 py-3 text-center text-xs text-muted-foreground`,children:q(`engine.form.noRows`,a)})}),u.map((e,t)=>(0,Y.jsxs)(`tr`,{className:`border-t border-border/30`,children:[d.map(n=>(0,Y.jsx)(`td`,{className:`p-1`,children:(0,Y.jsx)(Tn,{schema:c[n],value:(e??{})[n],readOnly:r,context:i,onChange:e=>f(t,{[n]:e})})},n)),(0,Y.jsx)(`td`,{className:`p-1 text-right`,children:(0,Y.jsx)(m,{type:`button`,variant:`ghost`,size:`sm`,onClick:()=>h(t),disabled:r,className:`h-7 w-7 p-0`,"aria-label":q(`engine.form.removeRow`,a),children:(0,Y.jsx)(M,{className:`h-3.5 w-3.5`})})})]},t))]})]})}),(0,Y.jsxs)(m,{type:`button`,variant:`outline`,size:`sm`,onClick:p,disabled:r,children:[(0,Y.jsx)(U,{className:`h-3.5 w-3.5 mr-1`}),` `,q(`engine.form.addRow`,a)]})]})}function Tn({schema:e,value:t,readOnly:n,context:r,onChange:i}){if(e?.widget===`ref:object`)return(0,Y.jsx)(yn,{schema:e,value:t,onChange:i,readOnly:n,context:r});if(e?.widget===`ref:component`)return(0,Y.jsx)(xn,{schema:e,value:t,onChange:i,readOnly:n,context:r});let a=e?.enum;return Array.isArray(a)&&a.length>0?(0,Y.jsxs)(z,{value:t==null?``:String(t),onValueChange:e=>i(e||void 0),disabled:n,children:[(0,Y.jsx)(B,{className:`h-8 text-xs`,children:(0,Y.jsx)(W,{placeholder:`—`})}),(0,Y.jsx)(N,{children:a.map(e=>(0,Y.jsx)(c,{value:String(e),children:String(e)},String(e)))})]}):e?.type===`boolean`?(0,Y.jsx)(`input`,{type:`checkbox`,checked:!!t,disabled:n,onChange:e=>i(e.target.checked),className:`h-4 w-4`}):e?.type===`number`||e?.type===`integer`?(0,Y.jsx)(V,{type:`number`,value:t==null?``:String(t),disabled:n,onChange:e=>{let t=e.target.valueAsNumber;i(Number.isFinite(t)?t:void 0)},className:`h-8 text-xs`}):(0,Y.jsx)(V,{value:t==null?``:String(t),disabled:n,onChange:e=>i(e.target.value||void 0),className:`h-8 text-xs`})}function En({id:e,value:t,onChange:n,readOnly:r}){let i=K(),a=Array.isArray(t)?t:[],[o,s]=J.useState(``);function c(e){let t=e.split(/[,\n]/).map(e=>e.trim()).filter(Boolean);if(t.length===0)return;let r=[...a];for(let e of t)r.includes(e)||r.push(e);n(r),s(``)}function l(e){let t=a.slice();t.splice(e,1),n(t)}return(0,Y.jsx)(`div`,{className:`rounded border border-input bg-background p-1.5`,children:(0,Y.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1`,children:[a.map((e,t)=>(0,Y.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded bg-muted px-1.5 py-0.5 text-xs`,children:[(0,Y.jsx)(`span`,{className:`font-mono`,children:e}),!r&&(0,Y.jsx)(`button`,{type:`button`,"aria-label":`Remove ${e}`,onClick:()=>l(t),className:`text-muted-foreground hover:text-destructive`,children:`×`})]},t)),(0,Y.jsx)(`input`,{id:e,type:`text`,value:o,disabled:r,placeholder:a.length===0?q(`engine.form.tagsPlaceholder`,i):``,onChange:e=>s(e.target.value),onKeyDown:e=>{e.key===`Enter`||e.key===`,`?(e.preventDefault(),c(o)):e.key===`Backspace`&&!o&&a.length>0&&l(a.length-1)},onBlur:()=>o&&c(o),className:`min-w-[8rem] flex-1 bg-transparent text-sm outline-none`})]})})}function Dn(e){return e.replace(/[_-]+/g,` `).replace(/\b\w/g,e=>e.toUpperCase())}function On({value:e,onChange:t,readOnly:n,schema:r,fieldSpec:i}){let a=J.useMemo(()=>{if(Array.isArray(i?.options)&&i.options.length)return i.options.map(e=>({label:e.label,value:e.value}));let e=r?.items?.enum??r?.enum??[];return(Array.isArray(e)?e:[]).filter(e=>typeof e==`string`).map(e=>({label:Dn(e),value:e}))},[i,r]),o=J.useMemo(()=>Array.isArray(e)?e.filter(e=>typeof e==`string`):[],[e]);function s(e){if(n)return;let r=new Set(o);r.has(e)?r.delete(e):r.add(e);let i=a.map(e=>e.value).filter(e=>r.has(e));t(i.length?i:void 0)}return a.length===0?(0,Y.jsx)(En,{value:e,onChange:t,readOnly:n,schema:r,fieldSpec:i}):(0,Y.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,role:`group`,children:a.map(e=>{let t=o.includes(e.value);return(0,Y.jsxs)(`button`,{type:`button`,role:`checkbox`,"aria-checked":t,disabled:n,onClick:()=>s(e.value),className:`inline-flex items-center gap-1.5 rounded-md border px-2.5 py-1 text-xs font-medium transition-colors `+(t?`border-primary bg-primary/10 text-primary`:`border-input bg-background text-muted-foreground hover:text-foreground hover:bg-muted`)+(n?` opacity-60 cursor-not-allowed`:``),children:[(0,Y.jsx)(`span`,{"aria-hidden":!0,className:`flex h-3.5 w-3.5 items-center justify-center rounded-[3px] border text-[9px] leading-none `+(t?`border-primary bg-primary text-primary-foreground`:`border-muted-foreground/40`),children:t?`✓`:``}),e.label]},e.value)})})}var Z=`__none__`;function kn({id:e,value:t,onChange:n,readOnly:r,context:i}){let a=K(),o=i?.objectFields??[],s=t==null?``:String(t),l=!s||o.some(e=>e.name===s);return(0,Y.jsxs)(z,{value:s||Z,onValueChange:e=>n(e===Z?``:e),disabled:r,children:[(0,Y.jsx)(B,{id:e,children:(0,Y.jsx)(W,{placeholder:o.length?q(`engine.form.selectField`,a):q(`engine.form.noObjectBound`,a)})}),(0,Y.jsxs)(N,{children:[(0,Y.jsx)(c,{value:Z,children:(0,Y.jsx)(`span`,{className:`text-muted-foreground`,children:q(`engine.form.none`,a)})}),!l&&s&&(0,Y.jsxs)(c,{value:s,children:[(0,Y.jsx)(`span`,{className:`font-mono`,children:s}),(0,Y.jsx)(`span`,{className:`ml-2 text-xs text-muted-foreground`,children:q(`engine.form.notInObject`,a)})]}),o.map(e=>(0,Y.jsx)(c,{value:e.name,children:(0,Y.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,Y.jsx)(`span`,{children:e.label||e.name}),(0,Y.jsx)(`code`,{className:`text-xs text-muted-foreground`,children:e.name})]})},e.name))]})]})}function An(e,t){let n=t?e.find(e=>e.name===t):void 0,r=t&&!n?e.find(e=>e.name.endsWith(`.${t}`)):void 0,i=t==="default"||t===`list`;return{exact:n,suffixMatch:r,isSpecial:i,resolves:!!n||!!r||i,showStored:!!t&&!n}}function jn({id:e,value:t,onChange:n,readOnly:r,context:i}){let a=K(),o=i?.objectViews??[],s=t==null?``:String(t),{suffixMatch:l,resolves:u,showStored:d}=An(o,s);return(0,Y.jsxs)(z,{value:s||Z,onValueChange:e=>n(e===Z?void 0:e),disabled:r,children:[(0,Y.jsx)(B,{id:e,children:(0,Y.jsx)(W,{placeholder:o.length?q(`engine.form.selectEllipsis`,a):q(`engine.form.noObjectBound`,a)})}),(0,Y.jsxs)(N,{children:[(0,Y.jsx)(c,{value:Z,children:(0,Y.jsx)(`span`,{className:`text-muted-foreground`,children:q(`engine.form.none`,a)})}),d&&(0,Y.jsx)(c,{value:s,children:(0,Y.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,Y.jsx)(`span`,{children:l?.label||s}),(0,Y.jsx)(`code`,{className:`text-xs text-muted-foreground`,children:l?`\u2192 ${l.name}`:s}),!u&&(0,Y.jsx)(`span`,{className:`ml-1 text-xs text-muted-foreground`,children:q(`engine.form.notInObject`,a)})]})}),o.map(e=>(0,Y.jsx)(c,{value:e.name,children:(0,Y.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,Y.jsx)(`span`,{children:e.label||e.name}),(0,Y.jsx)(`code`,{className:`text-xs text-muted-foreground`,children:e.name})]})},e.name))]})]})}function Mn({id:e,value:t,onChange:n,readOnly:r,context:i}){let a=K(),o=i?.objectFields??[],s=Array.isArray(t)?t.map(String):typeof t==`string`&&t?t.split(`,`).map(e=>e.trim()).filter(Boolean):[],l=e=>o.find(t=>t.name===e)?.label||e,u=o.filter(e=>!s.includes(e.name)),d=e=>{s.includes(e)||n([...s,e])},f=e=>{let t=s.slice();t.splice(e,1),n(t)},p=(e,t)=>{let r=e+t;if(r<0||r>=s.length)return;let i=s.slice();[i[e],i[r]]=[i[r],i[e]],n(i)};return(0,Y.jsxs)(`div`,{className:`space-y-2`,children:[s.length>0&&(0,Y.jsx)(`div`,{className:`space-y-1`,children:s.map((e,t)=>(0,Y.jsxs)(`div`,{className:`flex items-center gap-1 rounded border border-input bg-background px-2 py-1 text-sm`,children:[(0,Y.jsxs)(`span`,{className:`flex-1 truncate`,children:[l(e),(0,Y.jsx)(`code`,{className:`ml-2 text-xs text-muted-foreground`,children:e})]}),!r&&(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(`button`,{type:`button`,"aria-label":`Move up`,disabled:t===0,onClick:()=>p(t,-1),className:`px-1 text-muted-foreground hover:text-foreground disabled:opacity-30`,children:`↑`}),(0,Y.jsx)(`button`,{type:`button`,"aria-label":`Move down`,disabled:t===s.length-1,onClick:()=>p(t,1),className:`px-1 text-muted-foreground hover:text-foreground disabled:opacity-30`,children:`↓`}),(0,Y.jsx)(`button`,{type:`button`,"aria-label":`Remove ${e}`,onClick:()=>f(t),className:`px-1 text-muted-foreground hover:text-destructive`,children:`×`})]})]},e))}),!r&&(0,Y.jsxs)(z,{value:``,onValueChange:d,disabled:u.length===0,children:[(0,Y.jsx)(B,{id:e,children:(0,Y.jsx)(W,{placeholder:o.length?u.length?q(`engine.form.addField`,a):q(`engine.form.allFieldsAdded`,a):q(`engine.form.noObjectBound`,a)})}),(0,Y.jsx)(N,{children:u.map(e=>(0,Y.jsx)(c,{value:e.name,children:(0,Y.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,Y.jsx)(`span`,{children:e.label||e.name}),(0,Y.jsx)(`code`,{className:`text-xs text-muted-foreground`,children:e.name})]})},e.name))})]})]})}var Nn=pe,Pn=new Set(Nn),Fn=120;function In({id:e,value:t,onChange:n,readOnly:r}){let i=K(),a=t==null?``:String(t),[o,c]=J.useState(!1),[l,u]=J.useState(``),d=a?we(a):``,f=!a||Pn.has(d),p=we(l.trim()),m=J.useMemo(()=>p?Nn.filter(e=>e.includes(p)):Nn,[p]),h=m.slice(0,Fn),g=m.length>h.length,_=e=>{n(e||void 0),c(!1),u(``)};return(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(`button`,{id:e,type:`button`,role:`combobox`,"aria-haspopup":`dialog`,"aria-expanded":o,disabled:r,onClick:()=>!r&&c(!0),className:`flex w-full items-center gap-2 rounded-md border border-input bg-background px-3 py-2 text-sm text-left disabled:cursor-not-allowed disabled:opacity-60`,children:[(0,Y.jsx)(Re,{name:f?a:void 0,className:`h-4 w-4 shrink-0 text-muted-foreground`}),(0,Y.jsx)(`span`,{className:`flex-1 truncate `+(a?`font-mono`:`text-muted-foreground`),children:a||q(`engine.form.selectEllipsis`,i)}),!f&&a&&(0,Y.jsx)(`span`,{className:`shrink-0 text-xs text-muted-foreground`,children:q(`engine.form.notInObject`,i)}),(0,Y.jsx)(P,{"aria-hidden":!0,className:`h-3.5 w-3.5 shrink-0 opacity-50`})]}),(0,Y.jsx)(b,{open:o,onOpenChange:e=>{c(e),e||u(``)},children:(0,Y.jsxs)(R,{className:`max-w-2xl`,children:[(0,Y.jsx)(A,{children:(0,Y.jsx)(s,{children:q(`engine.form.chooseIcon`,i)})}),(0,Y.jsxs)(`div`,{className:`flex items-center gap-2 rounded-md border border-input bg-background px-3 py-2`,children:[(0,Y.jsx)(D,{"aria-hidden":!0,className:`h-4 w-4 shrink-0 text-muted-foreground`}),(0,Y.jsx)(`input`,{type:`text`,autoFocus:!0,value:l,"aria-label":q(`engine.form.searchIcons`,i),placeholder:q(`engine.form.searchIcons`,i),onChange:e=>u(e.target.value),className:`w-full bg-transparent text-sm outline-none`})]}),(0,Y.jsxs)(`div`,{id:e?`${e}-listbox`:void 0,role:`listbox`,className:`grid max-h-[52vh] grid-cols-6 gap-1.5 overflow-y-auto pr-1 sm:grid-cols-8`,children:[a&&(0,Y.jsxs)(`button`,{type:`button`,role:`option`,"aria-selected":!1,title:q(`engine.form.none`,i),onClick:()=>_(void 0),className:`flex aspect-square flex-col items-center justify-center gap-1 rounded border border-dashed border-border p-1 text-muted-foreground hover:bg-accent hover:text-accent-foreground`,children:[(0,Y.jsx)(M,{className:`h-4 w-4`}),(0,Y.jsx)(`span`,{className:`w-full truncate text-center text-[9px] leading-tight`,children:`none`})]}),!f&&a&&(0,Y.jsxs)(`button`,{type:`button`,role:`option`,"aria-selected":!0,title:a,onClick:()=>_(a),className:`flex aspect-square flex-col items-center justify-center gap-1 rounded bg-accent p-1 text-accent-foreground ring-1 ring-primary`,children:[(0,Y.jsx)(Re,{name:void 0,className:`h-4 w-4`}),(0,Y.jsx)(`span`,{className:`w-full truncate text-center text-[9px] leading-tight`,children:a})]}),h.map(e=>{let t=e===d;return(0,Y.jsxs)(`button`,{type:`button`,role:`option`,"aria-selected":t,title:e,onClick:()=>_(e),className:`flex aspect-square flex-col items-center justify-center gap-1 rounded p-1 text-muted-foreground hover:bg-accent hover:text-accent-foreground `+(t?`bg-accent text-accent-foreground ring-1 ring-primary`:``),children:[(0,Y.jsx)(Re,{name:e,className:`h-5 w-5`}),(0,Y.jsx)(`span`,{className:`w-full truncate text-center text-[9px] leading-tight`,children:e})]},e)}),h.length===0&&(0,Y.jsx)(`p`,{className:`col-span-full px-2 py-6 text-center text-sm text-muted-foreground`,children:q(`engine.form.noMatchingIcons`,i)})]}),g&&(0,Y.jsx)(`p`,{className:`text-center text-xs text-muted-foreground`,children:G(`engine.form.iconsTruncated`,i,{shown:h.length,total:m.length})})]})})]})}var Ln=[{key:`none`,label:`None`},{key:`tabs`,label:`Tabs`},{key:`dropdown`,label:`Dropdown`}],Rn=e=>(e||``).trim().toLowerCase().replace(/[^a-z0-9]+/g,`_`).replace(/^_+|_+$/g,``)||`tab`;function zn({value:e,onChange:t,readOnly:n,context:r}){let i=e&&typeof e==`object`?e:void 0,a=i?.element??(i?`dropdown`:`none`),o=r?.objectFields??[],s=e=>{if(!n){if(e===`none`){t(void 0);return}t({...i??{},element:e})}},l=Array.isArray(i?.fields)?i.fields:[],u=e=>t({...i??{},element:a===`none`?`dropdown`:a,fields:e}),d=new Set(l.map(e=>e.field)),p=o.filter(e=>!d.has(e.name)),m=e=>o.find(t=>t.name===e)?.label||e,h=a===`dropdown`||a===`toggle`,g=(Array.isArray(i?.tabs)?i.tabs:[]).map(e=>({...e,name:e?.name??e?.id??``,label:typeof e?.label==`string`?e.label:e?.name??e?.id??``,filter:Array.isArray(e?.filter)?e.filter:Array.isArray(e?.filters)?e.filters.filter(e=>Array.isArray(e)&&e.length>=2).map(e=>({field:String(e[0]),operator:String(e[1]),value:e[2]})):[],isDefault:e?.isDefault??e?.default})),_=e=>{let t={name:Rn(e.label||e.name),label:e.label||e.name||`Tab`};return e.icon&&(t.icon=e.icon),t.filter=Array.isArray(e.filter)?e.filter:[],e.isDefault&&(t.isDefault=!0),t},y=e=>{let n={},r=e.map(_).map(e=>{let t=e.name;if(n[t]){let r=2;for(;n[`${e.name}_${r}`];)r++;t=`${e.name}_${r}`}return n[t]=!0,{...e,name:t}});t({...i??{},element:`tabs`,tabs:r})},b=()=>y([...g,{name:``,label:`Tab ${g.length+1}`,filter:[]}]),x=e=>y(g.filter((t,n)=>n!==e)),S=(e,t)=>{let n=[...g],r=e+t;r<0||r>=n.length||([n[e],n[r]]=[n[r],n[e]],y(n))},C=(e,t)=>y(g.map((n,r)=>r===e?{...n,...t}:n));return(0,Y.jsxs)(`div`,{className:`space-y-3`,children:[(0,Y.jsx)(`div`,{className:`inline-flex rounded-md border border-input bg-background p-0.5`,role:`radiogroup`,"aria-label":`Filter element`,children:Ln.map(e=>{let t=a===e.key;return(0,Y.jsx)(`button`,{type:`button`,role:`radio`,"aria-checked":t,"data-testid":`filter-mode-${e.key}`,disabled:n,onClick:()=>s(e.key),className:`px-3 py-1 text-xs font-medium rounded transition-colors `+(t?`bg-primary text-primary-foreground shadow-sm`:`text-muted-foreground hover:text-foreground hover:bg-muted`),children:e.label},e.key)})}),h&&(0,Y.jsxs)(`div`,{className:`space-y-2`,"data-testid":`filter-mode-fields`,children:[l.length>0&&(0,Y.jsx)(`div`,{className:`space-y-1`,children:l.map((e,t)=>(0,Y.jsxs)(`div`,{className:`flex items-center gap-2 rounded border border-input bg-background px-2 py-1 text-sm`,children:[(0,Y.jsxs)(`span`,{className:`flex-1 truncate`,children:[m(e.field),(0,Y.jsx)(`code`,{className:`ml-2 text-xs text-muted-foreground`,children:e.field})]}),(0,Y.jsxs)(`label`,{className:`flex items-center gap-1 text-xs text-muted-foreground`,children:[(0,Y.jsx)(f,{checked:!!e.showCount,disabled:n,onCheckedChange:e=>u(l.map((n,r)=>r===t?{...n,showCount:e}:n))}),`count`]}),!n&&(0,Y.jsx)(`button`,{type:`button`,"aria-label":`Remove field`,onClick:()=>u(l.filter((e,n)=>n!==t)),className:`px-1 text-muted-foreground hover:text-destructive`,children:(0,Y.jsx)(M,{className:`h-3.5 w-3.5`})})]},e.field))}),!n&&p.length>0&&(0,Y.jsxs)(z,{onValueChange:e=>u([...l,{field:e}]),children:[(0,Y.jsx)(B,{className:`h-8 text-xs`,"data-testid":`filter-mode-add-field`,children:(0,Y.jsx)(W,{placeholder:`+ Add filter field…`})}),(0,Y.jsx)(N,{children:p.map(e=>(0,Y.jsx)(c,{value:e.name,children:e.label||e.name},e.name))})]}),o.length===0&&(0,Y.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Bind a source object to pick filter fields.`})]}),a===`tabs`&&(0,Y.jsxs)(`div`,{className:`space-y-2`,"data-testid":`filter-mode-tabs-editor`,children:[g.map((e,t)=>(0,Y.jsxs)(`div`,{className:`rounded-md border border-input bg-background p-2 space-y-2`,"data-testid":`tab-preset-${t}`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,Y.jsx)(V,{value:e.label,placeholder:`Tab label`,disabled:n,className:`h-8 text-sm flex-1`,"data-testid":`tab-label-${t}`,onChange:e=>C(t,{label:e.target.value})}),(0,Y.jsx)(`code`,{className:`text-[10px] text-muted-foreground shrink-0 max-w-[6rem] truncate`,title:e.name,children:e.name}),!n&&(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(`button`,{type:`button`,"aria-label":`Move tab up`,disabled:t===0,onClick:()=>S(t,-1),className:`px-1 text-muted-foreground hover:text-foreground disabled:opacity-30`,children:(0,Y.jsx)(v,{className:`h-3.5 w-3.5`})}),(0,Y.jsx)(`button`,{type:`button`,"aria-label":`Move tab down`,disabled:t===g.length-1,onClick:()=>S(t,1),className:`px-1 text-muted-foreground hover:text-foreground disabled:opacity-30`,children:(0,Y.jsx)(I,{className:`h-3.5 w-3.5`})}),(0,Y.jsx)(`button`,{type:`button`,"aria-label":`Remove tab`,onClick:()=>x(t),className:`px-1 text-muted-foreground hover:text-destructive`,children:(0,Y.jsx)(M,{className:`h-3.5 w-3.5`})})]})]}),(0,Y.jsx)(`div`,{className:`pl-1`,"data-testid":`tab-${t}-filter`,children:(0,Y.jsx)(Un,{value:e.filter,onChange:e=>C(t,{filter:e}),fields:o,readOnly:n})})]},t)),!n&&(0,Y.jsxs)(`button`,{type:`button`,"data-testid":`filter-mode-add-tab`,onClick:b,className:`inline-flex items-center text-xs font-medium text-primary hover:underline`,children:[(0,Y.jsx)(U,{className:`h-3.5 w-3.5 mr-1`}),` Add tab`]}),(0,Y.jsxs)(`label`,{className:`flex items-center gap-2 text-xs text-muted-foreground pt-1`,children:[(0,Y.jsx)(f,{checked:i?.showAllRecords!==!1,disabled:n,"data-testid":`filter-mode-show-all`,onCheckedChange:e=>t({...i??{},element:`tabs`,showAllRecords:e})}),`Show “All records” tab`]}),o.length===0&&(0,Y.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Bind a source object to build tab filter rules.`})]})]})}function Bn({id:e,value:t,onChange:n,readOnly:r,context:i}){let a=i?.objectActions??[],o=Array.isArray(t)?t.map(String):typeof t==`string`&&t?t.split(`,`).map(e=>e.trim()).filter(Boolean):[],s=e=>a.find(t=>t.name===e)?.label||e,l=a.filter(e=>!o.includes(e.name)),u=e=>{o.includes(e)||n([...o,e])},d=e=>{let t=o.slice();t.splice(e,1),n(t)},f=(e,t)=>{let r=e+t;if(r<0||r>=o.length)return;let i=o.slice();[i[e],i[r]]=[i[r],i[e]],n(i)};return(0,Y.jsxs)(`div`,{className:`space-y-2`,"data-testid":`action-multi`,children:[o.length>0&&(0,Y.jsx)(`div`,{className:`space-y-1`,children:o.map((e,t)=>(0,Y.jsxs)(`div`,{className:`flex items-center gap-1 rounded border border-input bg-background px-2 py-1 text-sm`,children:[(0,Y.jsxs)(`span`,{className:`flex-1 truncate`,children:[s(e),(0,Y.jsx)(`code`,{className:`ml-2 text-xs text-muted-foreground`,children:e})]}),!r&&(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(`button`,{type:`button`,"aria-label":`Move up`,disabled:t===0,onClick:()=>f(t,-1),className:`px-1 text-muted-foreground hover:text-foreground disabled:opacity-30`,children:`↑`}),(0,Y.jsx)(`button`,{type:`button`,"aria-label":`Move down`,disabled:t===o.length-1,onClick:()=>f(t,1),className:`px-1 text-muted-foreground hover:text-foreground disabled:opacity-30`,children:`↓`}),(0,Y.jsx)(`button`,{type:`button`,"aria-label":`Remove ${e}`,onClick:()=>d(t),className:`px-1 text-muted-foreground hover:text-destructive`,children:`×`})]})]},e))}),!r&&(0,Y.jsxs)(z,{value:``,onValueChange:u,disabled:l.length===0,children:[(0,Y.jsx)(B,{id:e,"data-testid":`action-multi-add`,children:(0,Y.jsx)(W,{placeholder:a.length?l.length?`+ Add action button…`:`All actions added`:`Bind a source object to pick actions`})}),(0,Y.jsx)(N,{children:l.map(e=>(0,Y.jsx)(c,{value:e.name,children:(0,Y.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,Y.jsx)(`span`,{children:e.label||e.name}),(0,Y.jsx)(`code`,{className:`text-xs text-muted-foreground`,children:e.name})]})},e.name))})]})]})}var Vn={equals:`equals`,notEquals:`not_equals`,contains:`contains`,notContains:`not_contains`,isEmpty:`is_empty`,isNotEmpty:`is_not_empty`,greaterThan:`gt`,lessThan:`lt`,greaterOrEqual:`gte`,lessOrEqual:`lte`,before:`lt`,after:`gt`,between:`between`,in:`in`,notIn:`not_in`},Hn={equals:`equals`,eq:`equals`,not_equals:`notEquals`,ne:`notEquals`,neq:`notEquals`,contains:`contains`,not_contains:`notContains`,is_empty:`isEmpty`,is_not_empty:`isNotEmpty`,gt:`greaterThan`,greater_than:`greaterThan`,lt:`lessThan`,less_than:`lessThan`,gte:`greaterOrEqual`,lte:`lessOrEqual`,in:`in`,not_in:`notIn`,nin:`notIn`};function Un({value:e,onChange:t,fields:n,readOnly:r}){let i=Array.isArray(e)?e:[],a={id:`g`,logic:`and`,conditions:i.map((e,t)=>({id:`c${t}`,field:e.field,operator:Hn[e.operator]??e.operator??`equals`,value:e.value??``}))},o=n.map(e=>({value:e.name,label:e.label||e.name,type:e.type})),s=i.length?i.map(e=>`${n.find(t=>t.name===e.field)?.label||e.field}`).filter(Boolean).join(`, `):``;return(0,Y.jsxs)(Ce,{children:[(0,Y.jsx)(fe,{asChild:!0,children:(0,Y.jsxs)(m,{variant:`outline`,size:`sm`,disabled:r,className:`h-8 w-full justify-between text-xs font-normal`,"data-testid":`filter-builder-trigger`,children:[(0,Y.jsx)(`span`,{className:`truncate text-left`,children:s||(0,Y.jsx)(`span`,{className:`text-muted-foreground`,children:`+ Add filter…`})}),(0,Y.jsx)(I,{className:`h-3.5 w-3.5 opacity-60 shrink-0`})]})}),(0,Y.jsx)(Ve,{align:`start`,className:`w-[440px] max-w-[90vw] p-3`,children:n.length===0?(0,Y.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Bind a source object to add filter conditions.`}):(0,Y.jsx)(Ie,{fields:o,value:a,onChange:e=>{t((e?.conditions??[]).filter(e=>e?.field).map(e=>({field:e.field,operator:Vn[e.operator]??e.operator,value:e.value})))}})})]})}function Wn({value:e,onChange:t,readOnly:n,context:r}){return(0,Y.jsx)(Un,{value:e,onChange:e=>t(e.length?e:void 0),fields:r?.objectFields??[],readOnly:n})}function Gn({value:e,onChange:t,readOnly:n,schema:r,fieldSpec:i}){let a=Array.isArray(i?.options)&&i.options.length?i.options.map(e=>({value:e.value,label:e.label})):Array.isArray(r?.enum)?r.enum.filter(e=>typeof e==`string`).map(e=>({value:e})):null;if(a&&a.length)return(0,Y.jsx)(Ht,{value:e==null?void 0:String(e),onChange:e=>t(e),disabled:n,options:a});let o=e==null?``:String(e);return(0,Y.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Y.jsx)(`input`,{type:`color`,value:/^#([0-9a-f]{6})$/i.test(o)?o:`#000000`,disabled:n,onChange:e=>t(e.target.value),className:`h-8 w-10 shrink-0 rounded border border-input bg-background p-0.5 disabled:opacity-60`,"aria-label":`Color`}),(0,Y.jsx)(V,{value:o,placeholder:`#RRGGBB`,disabled:n,onChange:e=>t(e.target.value||void 0),className:`h-8 text-sm font-mono`})]})}function Kn({value:e,onChange:t,readOnly:n,context:r}){return(0,Y.jsx)(vn,{value:e==null?``:String(e),onCommit:e=>t(e||void 0),fields:r?.objectFields,disabled:n})}var qn=`••••••••`;function Jn({value:e,onChange:t,readOnly:n,schema:r,id:i}){let a=e===qn,[o,s]=J.useState(!1),[c,l]=J.useState(a||e==null?``:String(e)),u=e=>{l(e),t(e===``?a?qn:void 0:e)};return(0,Y.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Y.jsx)(V,{id:i,type:o?`text`:`password`,value:c,disabled:n,autoComplete:`off`,placeholder:a?r?.description?`•••••••• set — type to replace`:`•••••••• set — leave blank to keep`:typeof r?.description==`string`?``:`Enter a value`,onChange:e=>u(e.target.value),className:`h-8 text-sm font-mono`,"aria-label":`Secret value`}),(0,Y.jsx)(m,{type:`button`,variant:`ghost`,size:`icon`,className:`h-8 w-8 shrink-0`,disabled:n,"aria-label":o?`Hide value`:`Reveal value`,onClick:()=>s(e=>!e),children:o?(0,Y.jsx)(j,{className:`h-4 w-4`}):(0,Y.jsx)(se,{className:`h-4 w-4`})}),a&&(0,Y.jsx)(m,{type:`button`,variant:`ghost`,size:`sm`,className:`h-8 shrink-0 text-destructive hover:text-destructive`,disabled:n,onClick:()=>{l(``),t(null)},children:`Clear`})]})}function Yn({value:e,onChange:t,readOnly:n,fieldSpec:r,formData:i,context:a}){let o=Array.isArray(r?.dependsOn)?r.dependsOn[0]:r?.dependsOn,s=o?i?.[o]:void 0,l=s==null?void 0:a?.dynamicSchemas?.[String(s)],u=l?.properties??{},d=new Set(l?.required??[]),p=e&&typeof e==`object`?e:{},m=(e,n)=>{let r={...p};n===void 0||n===``?delete r[e]:r[e]=n,t(r)};return s?!l||Object.keys(u).length===0?(0,Y.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[`No configuration needed for "`,String(s),`".`]}):(0,Y.jsx)(`div`,{className:`space-y-2 rounded-md border border-border/60 p-3`,children:Object.entries(u).map(([e,t])=>{let r=t?.title||e,i=p[e],a=d.has(e);if(t?.type===`boolean`)return(0,Y.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,Y.jsx)(H,{className:`text-xs`,children:r}),(0,Y.jsx)(f,{checked:!!i,disabled:n,onCheckedChange:t=>m(e,t)})]},e);if(Array.isArray(t?.enum))return(0,Y.jsxs)(`div`,{className:`space-y-1`,children:[(0,Y.jsxs)(H,{className:`text-xs`,children:[r,a?` *`:``]}),(0,Y.jsxs)(z,{value:i==null?``:String(i),onValueChange:t=>m(e,t),disabled:n,children:[(0,Y.jsx)(B,{className:`h-8`,"aria-label":r,children:(0,Y.jsx)(W,{placeholder:`Select…`})}),(0,Y.jsx)(N,{children:t.enum.map(e=>(0,Y.jsx)(c,{value:String(e),children:String(e)},String(e)))})]})]},e);let o=t?.format===`password`||t?.writeOnly===!0,s=t?.type===`number`||t?.type===`integer`;return(0,Y.jsxs)(`div`,{className:`space-y-1`,children:[(0,Y.jsxs)(H,{className:`text-xs`,children:[r,a?` *`:``]}),o?(0,Y.jsx)(Jn,{value:i,onChange:t=>m(e,t),readOnly:n,schema:t}):(0,Y.jsx)(V,{type:s?`number`:`text`,value:i==null?``:String(i),disabled:n,"aria-label":r,onChange:t=>m(e,s?t.target.value===``?void 0:Number(t.target.value):t.target.value),className:`h-8 text-sm`}),t?.description&&(0,Y.jsx)(`p`,{className:`text-[11px] text-muted-foreground`,children:t.description})]},e)})}):(0,Y.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[`Select `,o??`an option`,` to configure.`]})}var Xn={"ref:object":yn,"ref:component":xn,"filter-mode":zn,"object-selector":Sn,"field-selector":Cn,"field-ref":kn,"field-multi":Mn,"action-multi":Bn,"filter-builder":Wn,"view-ref":jn,icon:In,"color-picker":Gn,condition:Kn,"master-detail":wn,"string-tags":En,multiselect:On,code:$n,secret:Jn,"dynamic-config":Yn};function Zn(e,t){if(e?.language)return e.language;if(typeof t?.format==`string`){let e=t.format.toLowerCase();if(e===`sql`||e===`javascript`||e===`typescript`||e===`json`||e===`yaml`||e===`html`||e===`css`||e===`python`)return e}let n=e?.field?.toLowerCase()??``;return n.includes(`sql`)||n===`query`?`sql`:`javascript`}var Qn=J.lazy(()=>t(()=>import(`./src-2Uisncjb.js`).then(e=>({default:e.CodeEditorRenderer})),__vite__mapDeps([0]),import.meta.url));function $n({schema:e,value:t,onChange:n,readOnly:r,fieldSpec:i}){let a=Zn(i,e),o=typeof t==`string`?t:t==null?``:String(t);return(0,Y.jsxs)(`div`,{className:`rounded-md border border-border/50 overflow-hidden`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center justify-between px-2 py-1 bg-muted/40 border-b border-border/30 text-[10px] font-mono text-muted-foreground`,children:[(0,Y.jsx)(`span`,{children:a}),r&&(0,Y.jsx)(`span`,{children:`read-only`})]}),(0,Y.jsx)(J.Suspense,{fallback:(0,Y.jsx)(`div`,{className:`h-[280px] flex items-center justify-center text-xs text-muted-foreground`,children:`Loading editor…`}),children:(0,Y.jsx)(Qn,{schema:{type:`code`,language:a,theme:`vs-dark`,height:`280px`,readOnly:r},value:o,onChange:e=>n(e??``)})})]})}var er=new Set([`text`,`textarea`,`number`,`switch`,`select`,`json`]);function tr(e,t){if(!e)return e;let n=e.oneOf??e.anyOf;if(!Array.isArray(n)||n.length===0)return e;let r=typeof t==`object`&&!!t&&!Array.isArray(t),i=Array.isArray(t),a=r?new Set(Object.keys(t)):null,o=null,s=i&&t.length?t[0]:void 0,c=typeof s==`object`&&!!s&&!Array.isArray(s);for(let e of n){let n=0;if(e.type===`array`&&i){n+=5;let t=e.items?.type;(t===`object`&&c||t===`string`&&typeof s==`string`||t===`number`&&typeof s==`number`||t===`integer`&&typeof s==`number`)&&(n+=3)}if(e.type===`object`&&r&&(n+=5),e.type===`string`&&typeof t==`string`&&(n+=5),e.type===`number`&&typeof t==`number`&&(n+=5),e.type===`boolean`&&typeof t==`boolean`&&(n+=5),a&&Array.isArray(e.required))for(let t of e.required)a.has(t)&&(n+=1);(!o||n>o.score)&&(o={branch:e,score:n})}let l=o?.branch??n[0];return{...e,...l,oneOf:void 0,anyOf:void 0}}function nr(e,t){if(e?.widget)return e.widget;if(e?.type){let t=e.type;if(t===`text`||t===`email`||t===`url`||t===`phone`||t===`password`)return`text`;if(t===`textarea`||t===`markdown`||t===`html`||t===`richtext`)return`textarea`;if(t===`number`||t===`currency`||t===`percent`)return`number`;if(t===`date`||t===`datetime`||t===`time`)return`date-picker`;if(t===`boolean`||t===`toggle`)return`switch`;if(t===`select`||t===`radio`)return e.multiple?`multiselect`:`select`;if(t===`multiselect`||t===`checkboxes`||t===`tags`)return`string-tags`;if(t===`composite`)return`composite`;if(t===`repeater`)return`repeater`;if(t===`record`)return`record`;if(t===`lookup`||t===`master_detail`||t===`tree`)return`ref-object`;if(t===`image`||t===`file`||t===`avatar`||t===`video`||t===`audio`)return`file-upload`;if(t===`code`)return`code`;if(t===`json`||t===`location`||t===`address`)return`json`;if(t===`color`)return`color-picker`;if(t===`rating`)return`number`;if(t===`slider`)return`slider`;if(t===`signature`)return`signature`;if(t===`qrcode`)return`qrcode`;if(t===`progress`)return`number`;if(t===`formula`||t===`summary`||t===`autonumber`)return`text`;if(t===`vector`)return`json`}if(t){let e=t.type;if(e===`array`&&Array.isArray(t.items?.enum))return`multiselect`;if(e===`array`&&t.items?.type===`string`)return`string-tags`;if(e===`array`&&t.items?.type===`object`)return`master-detail`;if(e===`object`)return`object-fields`;if(e===`boolean`)return`switch`;if(e===`number`||e===`integer`)return`number`;if(Array.isArray(t.enum))return`select`;if(e===`string`){if(t.format===`date`||t.format===`date-time`)return`date-picker`;if(t.format===`email`||t.format===`uri`||t.format===`uri-reference`)return`text`;if(t.format===`multiline`)return`textarea`}}}function rr(e,t,n){if(n?.objectFields&&!Array.isArray(t?.enum)){if(t?.type===`array`&&t.items?.type===`string`&&(/Fields$/.test(e)||e===`columns`||e===`fieldOrder`))return`field-multi`;if((t?.type===`string`||Array.isArray(t?.anyOf)&&t.anyOf.some(e=>e?.type===`string`))&&(/.Field$/.test(e)||e===`field`))return`field-ref`}}function ir(e,t){if(!Array.isArray(t?.enum)&&(t?.type===`string`||Array.isArray(t?.anyOf)&&t.anyOf.some(e=>e?.type===`string`))&&(e===`icon`||/Icon$/.test(e)))return`icon`}function ar(e,t){if((t?.type===`string`||Array.isArray(t?.enum)||Array.isArray(t?.anyOf)&&t.anyOf.some(e=>e?.type===`string`))&&(e===`color`||e===`colorVariant`||/Color$/.test(e)))return`color-picker`}var or=new Set([`visible`,`hidden`,`disabled`,`visibleOn`,`condition`,`predicate`]);function sr(e,t){if(!Array.isArray(t?.enum)&&(t?.type===`string`||Array.isArray(t?.anyOf)&&t.anyOf.some(e=>e?.type===`string`))&&(or.has(e)||/When$/.test(e)))return`condition`}var cr=/(^|_)(secret|token|api[_-]?key|access[_-]?key|client[_-]?secret|credential|private[_-]?key|passphrase)$/i;function lr(e,t){if(t?.format===`password`||t?.writeOnly===!0||!Array.isArray(t?.enum)&&(t?.type===`string`||Array.isArray(t?.anyOf)&&t.anyOf.some(e=>e?.type===`string`))&&cr.test(e))return`secret`}function ur({schema:e,form:t,value:n,onChange:r,issues:i=[],hiddenFields:a=[],fieldOrder:o=[],readOnly:s=!1,createMode:c=!1,widgetContext:l}){let u=K(),d=e;if(!d||typeof d!=`object`)if(n&&typeof n==`object`)d=br(n);else return(0,Y.jsx)(yr,{value:n,onChange:r,readOnly:s});let f=d.properties??{},p=Array.isArray(d.required)?d.required:[],m=n??{},h=Cr(Object.keys(f),o).filter(e=>!a.includes(e)).filter(e=>{let t=f[e]?.visibleOn;return!t||Pt(t,{data:m})}),g=J.useMemo(()=>{let e={};for(let t of i)(e[t.path]??=[]).push($e(t.message,u));return e},[i,u]),_=n??{};function v(e,t){let n={..._,[e]:t};(t===void 0||t===``)&&delete n[e],r(n)}if(t?.sections?.length){let e=[];for(let n of t.sections)for(let t of n.fields)e.push(typeof t==`string`?t:t.field);let n=e.filter(e=>f[e]).length;if(e.length===0||n>0)return(0,Y.jsx)(fr,{form:t,props:f,required:p,hiddenFields:a,issuesByPath:g,value:_,readOnly:s,createMode:c,widgetContext:l,onChange:v});typeof console<`u`&&console.warn(`[SchemaForm] form layout declares no fields that exist in the schema; falling back to flat schema-driven rendering. Declared:`,e,`Available:`,Object.keys(f))}return(0,Y.jsx)(`div`,{className:`space-y-4`,children:h.map(e=>(0,Y.jsx)(Q,{name:e,schema:f[e],value:_[e],required:p.includes(e),issues:g[e],readOnly:s,widgetContext:l,fieldSpec:f[e]?.widget?{field:e,widget:f[e].widget}:void 0,formData:_,onChange:t=>v(e,t)},e))})}function dr(e){return typeof e==`string`?{field:e}:e}function fr({form:e,props:t,required:n,hiddenFields:r,issuesByPath:i,value:a,readOnly:o,createMode:s,widgetContext:c,onChange:l}){let u=K(),d=(e.sections??[]).filter(e=>!e.visibleOn||Pt(e.visibleOn,{data:a})),f=e.type===`tabbed`&&d.length>1,p=(e,d)=>{let f=e.fields.map(dr).filter(e=>!(e.hidden||r.includes(e.field)||e.visibleOn&&!Pt(e.visibleOn,{data:a})));if(f.length===0)return null;let p=(0,Y.jsx)(`div`,{className:`grid gap-4`,style:{gridTemplateColumns:`repeat(${e.columns??1}, minmax(0, 1fr))`},children:f.map(e=>{let r=t[e.field];return r?(0,Y.jsx)(`div`,{style:{gridColumn:`span ${e.colSpan??1}`},children:(0,Y.jsx)(Q,{name:e.field,schema:{...r,...e.label?{title:e.label}:{},...e.helpText?{description:e.helpText}:{},...e.placeholder?{placeholder:e.placeholder}:{}},value:a[e.field],required:e.required??n.includes(e.field),issues:i[e.field],readOnly:o||e.readonly||e.immutable&&!s,fieldSpec:e,widgetContext:c,formData:a,onChange:t=>l(e.field,t)})},e.field):(0,Y.jsx)(`div`,{className:`rounded border border-dashed border-amber-500/40 bg-amber-500/5 p-2 text-xs text-amber-700 dark:text-amber-300`,style:{gridColumn:`span ${e.colSpan??1}`},children:G(`engine.form.missingField`,u,{field:e.field})},e.field)})});return e.collapsible&&e.label?(0,Y.jsxs)(ge,{defaultOpen:!e.collapsed,className:`rounded-md border border-border/40 bg-card/30`,children:[(0,Y.jsxs)(Oe,{className:`group flex w-full items-center justify-between gap-2 p-4 text-left`,children:[(0,Y.jsxs)(`span`,{children:[(0,Y.jsx)(`span`,{className:`block text-sm font-semibold text-foreground/90`,children:e.label}),e.description&&(0,Y.jsx)(`span`,{className:`mt-0.5 block text-xs text-muted-foreground`,children:e.description})]}),(0,Y.jsx)(I,{className:`h-4 w-4 shrink-0 text-muted-foreground transition-transform group-data-[state=closed]:-rotate-90`})]}),(0,Y.jsx)(ze,{className:`space-y-3 px-4 pb-4`,children:p})]},d):(0,Y.jsxs)(`section`,{className:`space-y-3 rounded-md border border-border/40 bg-card/30 p-4`,children:[e.label&&(0,Y.jsxs)(`header`,{children:[(0,Y.jsx)(`h3`,{className:`text-sm font-semibold text-foreground/90`,children:e.label}),e.description&&(0,Y.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:e.description})]}),p]},d)};if(f){let e=d.filter(e=>e.fields.map(dr).some(e=>!e.hidden&&!r.includes(e.field)&&(!e.visibleOn||Pt(e.visibleOn,{data:a}))));return e.length===0?null:(0,Y.jsxs)(Ne,{defaultValue:(e[0].label??`section-0`).toLowerCase(),className:`w-full`,children:[(0,Y.jsx)(be,{className:`flex flex-wrap gap-1`,children:e.map((e,t)=>(0,Y.jsx)(ve,{value:(e.label??`section-${t}`).toLowerCase(),children:e.label??`Section ${t+1}`},t))}),e.map((e,t)=>(0,Y.jsx)(Ee,{value:(e.label??`section-${t}`).toLowerCase(),className:`mt-4`,children:p(e,t)},t))]})}return(0,Y.jsx)(`div`,{className:`space-y-4`,children:d.map(p)})}function Q({name:e,schema:t,value:n,required:r,issues:i,readOnly:a,fieldSpec:o,widgetContext:s,formData:c,onChange:l}){let u=o?.label||t?.title||Sr(e),d=o?.helpText||t?.description,f=`mdf-${e}`,p=nr(o,t);if(!o?.widget){let n=rr(e,t,s);if(n)p=n;else{let n=lr(e,t);if(n)p=n;else{let n=ir(e,t);if(n)p=n;else{let n=ar(e,t);if(n)p=n;else{let n=sr(e,t);n&&(p=n)}}}}}let m=t?.type===`boolean`||p===`switch`,h=t?.default!==void 0,g=r&&!(m&&h),_=Sr(e).toLowerCase()===u.toLowerCase();return m?(0,Y.jsxs)(`div`,{className:`flex items-start justify-between gap-3 py-1.5`,children:[(0,Y.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Y.jsxs)(H,{htmlFor:f,className:`text-sm font-medium cursor-pointer`,children:[u,g&&(0,Y.jsx)(`span`,{className:`text-destructive ml-0.5`,children:`*`})]}),d&&(0,Y.jsx)(`div`,{className:`text-xs text-muted-foreground mt-0.5`,children:d}),i?.map((e,t)=>(0,Y.jsx)(`div`,{className:`text-xs text-destructive mt-0.5`,children:e},t))]}),(0,Y.jsx)(pr,{id:f,schema:t,value:n,onChange:l,readOnly:a,widget:p,fieldSpec:o,widgetContext:s,formData:c})]}):(0,Y.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Y.jsx)(`div`,{className:`flex items-center justify-between gap-2`,children:(0,Y.jsxs)(H,{htmlFor:f,className:`text-sm font-medium`,children:[u,g&&(0,Y.jsx)(`span`,{className:`text-destructive ml-0.5`,children:`*`}),!_&&(0,Y.jsx)(`code`,{className:`ml-2 text-[10px] font-mono text-muted-foreground/70`,title:`Machine name`,children:e})]})}),(0,Y.jsx)(pr,{id:f,schema:t,value:n,onChange:l,readOnly:a,widget:p,fieldSpec:o,widgetContext:s,formData:c}),d&&(0,Y.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:d}),i?.map((e,t)=>(0,Y.jsx)(`div`,{className:`text-xs text-destructive`,children:e},t))]})}function pr({id:e,schema:t,value:n,onChange:r,readOnly:i,widget:a,fieldSpec:o,widgetContext:s,formData:l}){let u=K();if(o?.type===`composite`)return(0,Y.jsx)(gr,{value:n,fields:o.fields?.length?o.fields:wr(t),schema:t,readOnly:i,widgetContext:s,fieldSpec:o,onChange:r});if(o?.type===`repeater`){let e=t?.items??{};return(0,Y.jsx)(_r,{value:n,fields:o.fields?.length?o.fields:wr(e),schema:t,readOnly:i,widgetContext:s,widget:o.widget,onChange:r})}if(o?.type===`record`){let e=t?.additionalProperties??{};return(0,Y.jsx)(vr,{value:n,fields:o.fields?.length?o.fields:wr(e),schema:t,readOnly:i,widgetContext:s,widget:o.widget,keyField:o.keyField,formData:l,onChange:r})}if(a){let c=Xn[a];if(c)return(0,Y.jsx)(c,{id:e,schema:t,value:n,onChange:r,readOnly:i,context:s,fieldSpec:o,formData:l});let d=tr(t,n);if(d?.type===`object`&&d.properties&&typeof d.properties==`object`)return(0,Y.jsx)(`div`,{className:`rounded-md border border-border/40 bg-card/30 p-3`,children:(0,Y.jsx)(ur,{schema:d,value:n??{},onChange:e=>r(e),readOnly:i,widgetContext:s})});if(d?.type===`array`&&d.items&&typeof d.items==`object`){let e=tr(d.items,Array.isArray(n)&&n.length?n[0]:void 0);if(e?.type===`object`&&e.properties&&typeof e.properties==`object`)return(0,Y.jsx)(_r,{value:n,fields:wr(e),schema:{...d,items:e},readOnly:i,widgetContext:s,widget:o?.widget,onChange:r})}if(!er.has(a))return(0,Y.jsxs)(`div`,{className:`space-y-1`,children:[(0,Y.jsx)(yr,{value:n,onChange:e=>r(e),readOnly:i}),(0,Y.jsx)(`div`,{className:`text-[10px] text-muted-foreground`,children:G(`engine.form.fallbackJson`,u,{widget:a})})]})}let d=tr(t,n)??t,p=d?.type,m=o?.options,h=d?.enum??void 0;if(Array.isArray(m)&&m.length>0)return(0,Y.jsxs)(z,{value:n==null?``:String(n),onValueChange:e=>r(e),disabled:i,children:[(0,Y.jsx)(B,{id:e,children:(0,Y.jsx)(W,{placeholder:q(`engine.form.selectEllipsis`,u)})}),(0,Y.jsx)(N,{children:m.map(e=>(0,Y.jsxs)(c,{value:e.value,children:[e.label,e.color&&(0,Y.jsx)(`span`,{className:`ml-2 inline-block h-3 w-3 rounded`,style:{backgroundColor:e.color}})]},e.value))})]});if(Array.isArray(h)&&h.length>0)return(0,Y.jsxs)(z,{value:n==null?``:String(n),onValueChange:e=>r(e),disabled:i,children:[(0,Y.jsx)(B,{id:e,children:(0,Y.jsx)(W,{placeholder:q(`engine.form.selectEllipsis`,u)})}),(0,Y.jsx)(N,{children:h.map(e=>(0,Y.jsx)(c,{value:String(e),children:String(e)},String(e)))})]});if(p===`boolean`||a===`switch`||o?.type===`boolean`||o?.type===`toggle`)return(0,Y.jsx)(f,{id:e,checked:!!n,onCheckedChange:e=>r(e),disabled:i});if(p===`number`||p===`integer`){let t=o?.min,a=o?.max;return(0,Y.jsx)(V,{id:e,type:`number`,value:n==null?``:String(n),min:t,max:a,onChange:e=>{let t=e.target.value;if(t===``)return r(void 0);let n=p===`integer`?parseInt(t,10):Number(t);r(Number.isFinite(n)?n:void 0)},readOnly:i})}if(p===`string`){let t=o?.maxLength;return d?.format===`multiline`||d?.contentMediaType===`text/markdown`||typeof n==`string`&&n.length>80?(0,Y.jsx)(_e,{id:e,rows:4,value:n??``,maxLength:t,onChange:e=>r(e.target.value||void 0),readOnly:i}):(0,Y.jsx)(V,{id:e,value:n??``,maxLength:t,onChange:e=>r(e.target.value||void 0),readOnly:i})}if(p===`array`){let t=d?.items??{};if(t.type===`string`||t.type===`number`||t.type===`integer`)return(0,Y.jsx)(V,{id:e,value:(Array.isArray(n)?n:[]).map(String).join(`, `),placeholder:q(`engine.form.arrayPlaceholder`,u),onChange:e=>{let n=e.target.value.split(`,`).map(e=>e.trim()).filter(Boolean);t.type===`number`||t.type===`integer`?r(n.map(e=>Number(e)).filter(e=>Number.isFinite(e))):r(n)},readOnly:i})}if(d?.type===`object`&&d.properties&&typeof d.properties==`object`)return(0,Y.jsx)(`div`,{className:`rounded-md border border-border/40 bg-card/30 p-3`,children:(0,Y.jsx)(ur,{schema:d,value:n??{},onChange:e=>r(e),readOnly:i,widgetContext:s})});if(d?.type===`array`&&d.items&&typeof d.items==`object`){let e=tr(d.items,Array.isArray(n)&&n.length?n[0]:void 0);if(e?.type===`object`&&e.properties&&typeof e.properties==`object`)return(0,Y.jsx)(_r,{value:n,fields:wr(e),schema:{...d,items:e},readOnly:i,widgetContext:s,widget:o?.widget,onChange:r})}return(0,Y.jsx)(yr,{value:n,onChange:r,readOnly:i,small:!0})}function mr(e,t,n){if(!e)return{};let r;return r=t===`composite`?e.properties:t===`repeater`?e.items?.properties:e.additionalProperties?.properties,r?.[n]??{}}function hr(e,t){let n=[];for(let r of t){let t=e[r.field];if(t==null||t===``||t===!1)continue;let i=r.label||r.field;t===!0?n.push(i):Array.isArray(t)?t.length&&n.push(t.map(e=>typeof e==`object`&&e?e.field??e.name??``:String(e)).filter(Boolean).join(`, `)):typeof t==`object`?n.push(i):n.push(String(t))}return n.join(` · `)}function gr({value:e,fields:t,schema:n,readOnly:r,widgetContext:i,fieldSpec:a,onChange:o}){let s=e&&typeof e==`object`&&!Array.isArray(e)?e:{},c=t.map(dr),l=c.map(e=>{let t=mr(n,`composite`,e.field);return(0,Y.jsx)(Q,{name:e.field,schema:t,value:s[e.field],required:!!e.required,readOnly:r||e.readonly,fieldSpec:e,widgetContext:i,formData:s,onChange:t=>o({...s,[e.field]:t})},e.field)});if(a?.disclosure===`popover`){let e=hr(s,c);return(0,Y.jsxs)(`div`,{className:`flex items-center justify-between gap-2 rounded-md border border-border/50 bg-muted/20 px-3 py-1.5`,children:[(0,Y.jsx)(`span`,{className:`text-sm text-muted-foreground truncate`,title:e,children:e||(0,Y.jsx)(`span`,{className:`italic opacity-70`,children:`Not configured`})}),(0,Y.jsxs)(Ce,{children:[(0,Y.jsx)(fe,{asChild:!0,children:(0,Y.jsx)(m,{variant:`ghost`,size:`sm`,className:`h-7 w-7 p-0 shrink-0`,"aria-label":`Configure`,"data-testid":`composite-popover-${a.field}`,children:(0,Y.jsx)(w,{className:`h-4 w-4`})})}),(0,Y.jsx)(Ve,{align:`end`,className:`w-80 space-y-3`,children:l})]})]})}return(0,Y.jsx)(`div`,{className:`rounded-md border border-border/50 bg-muted/20 p-3 space-y-3`,children:l})}function _r({value:e,fields:t,schema:n,readOnly:r,widgetContext:i,widget:a,onChange:o}){let s=K(),c=Array.isArray(e)?e:[],l=t.map(dr),[u,d]=J.useState(null),f=a===`grid`||a===`table`,p=(e,t)=>{o(c.map((n,r)=>r===e?{...n,...t}:n))},h=e=>o(c.filter((t,n)=>n!==e)),g=()=>{let e={};l.forEach(t=>{e[t.field]=void 0}),o([...c,e]),d(c.length)};return f?(0,Y.jsxs)(`div`,{className:`space-y-2`,children:[(0,Y.jsx)(`div`,{className:`overflow-x-auto rounded-md border border-border/50`,children:(0,Y.jsxs)(`table`,{className:`w-full text-sm`,children:[(0,Y.jsx)(`thead`,{className:`bg-muted/40`,children:(0,Y.jsxs)(`tr`,{children:[l.map(e=>(0,Y.jsxs)(`th`,{className:`px-2 py-1.5 text-left text-xs font-medium`,children:[e.label||Sr(e.field),e.required&&(0,Y.jsx)(`span`,{className:`text-destructive ml-0.5`,children:`*`})]},e.field)),!r&&(0,Y.jsx)(`th`,{className:`w-8`})]})}),(0,Y.jsxs)(`tbody`,{children:[c.length===0&&(0,Y.jsx)(`tr`,{children:(0,Y.jsx)(`td`,{colSpan:l.length+1,className:`px-2 py-3 text-center text-xs text-muted-foreground`,children:q(`engine.repeater.empty`,s)})}),c.map((e,t)=>(0,Y.jsxs)(`tr`,{className:`border-t border-border/30 align-top`,children:[l.map(a=>{let o=mr(n,`repeater`,a.field);return(0,Y.jsx)(`td`,{className:`p-1.5`,children:(0,Y.jsx)(pr,{id:`rep-${t}-${a.field}`,schema:o,value:e?.[a.field],readOnly:r||a.readonly,widget:nr(a,o),fieldSpec:a,widgetContext:i,formData:e,onChange:e=>p(t,{[a.field]:e})})},a.field)}),!r&&(0,Y.jsx)(`td`,{className:`p-1.5 text-right`,children:(0,Y.jsx)(m,{type:`button`,variant:`ghost`,size:`sm`,onClick:()=>h(t),className:`h-7 w-7 p-0`,"aria-label":q(`engine.form.remove`,s),children:(0,Y.jsx)(M,{className:`h-3.5 w-3.5`})})})]},t))]})]})}),!r&&(0,Y.jsxs)(m,{type:`button`,variant:`outline`,size:`sm`,onClick:g,children:[(0,Y.jsx)(U,{className:`h-3.5 w-3.5 mr-1`}),` `,q(`engine.form.add`,s)]})]}):(0,Y.jsxs)(`div`,{className:`space-y-2`,children:[c.length===0&&(0,Y.jsx)(`div`,{className:`rounded-md border border-dashed border-border/50 px-3 py-4 text-center text-xs text-muted-foreground`,children:q(`engine.list.empty`,s)}),c.map((e,t)=>{let a=u===t,o=l.map(t=>e?.[t.field]).find(e=>e!=null&&e!==``);return(0,Y.jsxs)(`div`,{className:`rounded-md border border-border/50 bg-muted/10`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center justify-between gap-2 px-2 py-1.5 border-b border-border/30`,children:[(0,Y.jsxs)(`button`,{type:`button`,onClick:()=>d(a?null:t),className:`flex items-center gap-1.5 text-sm font-medium text-left flex-1 min-w-0`,children:[a?(0,Y.jsx)(I,{className:`h-3.5 w-3.5`}):(0,Y.jsx)(F,{className:`h-3.5 w-3.5`}),(0,Y.jsxs)(`span`,{className:`truncate`,children:[`#`,t+1,o==null?``:` — ${String(o)}`]})]}),!r&&(0,Y.jsx)(m,{type:`button`,variant:`ghost`,size:`sm`,onClick:()=>h(t),className:`h-7 w-7 p-0`,"aria-label":q(`engine.form.remove`,s),children:(0,Y.jsx)(M,{className:`h-3.5 w-3.5`})})]}),a&&(0,Y.jsx)(`div`,{className:`p-3 space-y-3`,children:l.map(a=>{let o=mr(n,`repeater`,a.field);return(0,Y.jsx)(Q,{name:a.field,schema:o,value:e?.[a.field],required:!!a.required,readOnly:r||a.readonly,fieldSpec:a,widgetContext:i,formData:e,onChange:e=>p(t,{[a.field]:e})},a.field)})})]},t)}),!r&&(0,Y.jsxs)(m,{type:`button`,variant:`outline`,size:`sm`,onClick:g,children:[(0,Y.jsx)(U,{className:`h-3.5 w-3.5 mr-1`}),` `,q(`engine.form.addItem`,s)]})]})}function vr({value:e,fields:t,schema:n,readOnly:r,widgetContext:i,widget:a,keyField:o,formData:s,onChange:c}){let l=K();if(a){let o=Xn[a];if(o)return(0,Y.jsx)(o,{schema:n,value:e,onChange:c,readOnly:r,context:i,fieldSpec:{field:``,type:`record`,fields:t,widget:a},formData:s})}let u=o?.field??`name`,d=o?.label??Sr(u),f=o?.regex?new RegExp(o.regex):null,p=o?.immutable!==!1,h=e&&typeof e==`object`&&!Array.isArray(e)?e:{},g=Object.entries(h),_=t.map(dr).filter(e=>e.field!==u),[v,y]=J.useState(null),[b,x]=J.useState(``),[S,C]=J.useState(null),w=e=>c(e),T=(e,t)=>{let n={};for(let[r,i]of g)n[r]=r===e?{...i,...t}:i;w(n)},E=e=>{let t={};for(let[n,r]of g)n!==e&&(t[n]=r);w(t)},D=(e,t)=>{if(t===e)return;if(h[t]){C(G(`engine.form.keyExists`,l,{key:t}));return}if(f&&!f.test(t)){C(G(`engine.form.keyPattern`,l,{pattern:String(f)}));return}let n={};for(let[r,i]of g)r===e?n[t]={...i,[u]:t}:n[r]=i;C(null),w(n)},O=()=>{let e=b.trim();if(!e){C(q(`engine.form.keyRequired`,l));return}if(h[e]){C(G(`engine.form.keyExists`,l,{key:e}));return}if(f&&!f.test(e)){C(G(`engine.form.keyPattern`,l,{pattern:String(f)}));return}let t={[u]:e};_.forEach(e=>{t[e.field]=void 0}),w({...h,[e]:t}),x(``),C(null),y(e)},[k,A]=J.useState(null),[j,N]=J.useState(null),P=(e,t)=>{if(e===t)return;let n=g.map(([e])=>e),r=n.indexOf(e),i=n.indexOf(t);if(r<0||i<0)return;n.splice(r,1),n.splice(i,0,e);let a={};for(let e of n)a[e]=h[e];w(a)};return(0,Y.jsxs)(`div`,{className:`space-y-2`,children:[g.length===0&&(0,Y.jsx)(`div`,{className:`rounded-md border border-dashed border-border/50 px-3 py-4 text-center text-xs text-muted-foreground`,children:q(`engine.list.empty`,l)}),g.map(([e,t])=>{let a=v===e,s=_.map(e=>t?.[e.field]).find(e=>e!=null&&e!==``);return(0,Y.jsxs)(`div`,{className:`rounded-md border bg-muted/10 ${j===e&&k&&k!==e?`border-primary border-2`:`border-border/50`}`,onDragOver:t=>{!k||r||(t.preventDefault(),j!==e&&N(e))},onDragLeave:()=>{j===e&&N(null)},onDrop:t=>{!k||r||(t.preventDefault(),P(k,e),A(null),N(null))},children:[(0,Y.jsxs)(`div`,{className:`flex items-center justify-between gap-2 px-2 py-1.5 border-b border-border/30`,children:[!r&&(0,Y.jsx)(`span`,{draggable:!0,onDragStart:t=>{A(e),t.dataTransfer.effectAllowed=`move`,t.dataTransfer.setData(`text/plain`,e)},onDragEnd:()=>{A(null),N(null)},className:`cursor-grab active:cursor-grabbing text-muted-foreground hover:text-foreground`,"aria-label":q(`engine.form.dragToReorder`,l),title:q(`engine.form.dragToReorder`,l),children:(0,Y.jsx)(Je,{className:`h-3.5 w-3.5`})}),(0,Y.jsxs)(`button`,{type:`button`,onClick:()=>y(a?null:e),className:`flex items-center gap-1.5 text-sm font-medium text-left flex-1 min-w-0`,children:[a?(0,Y.jsx)(I,{className:`h-3.5 w-3.5`}):(0,Y.jsx)(F,{className:`h-3.5 w-3.5`}),(0,Y.jsx)(`span`,{className:`font-mono text-xs px-1.5 py-0.5 rounded bg-muted/60`,children:e}),s!=null&&(0,Y.jsxs)(`span`,{className:`truncate text-muted-foreground`,children:[`— `,String(s)]})]}),!r&&(0,Y.jsx)(m,{type:`button`,variant:`ghost`,size:`sm`,onClick:()=>E(e),className:`h-7 w-7 p-0`,"aria-label":q(`engine.form.remove`,l),children:(0,Y.jsx)(M,{className:`h-3.5 w-3.5`})})]}),a&&(0,Y.jsxs)(`div`,{className:`p-3 space-y-3`,children:[(0,Y.jsx)(Q,{name:u,schema:{type:`string`},value:e,required:!0,readOnly:r||p,fieldSpec:{field:u,type:`text`,label:d,helpText:o?.helpText},widgetContext:i,formData:t,onChange:t=>D(e,String(t??``).trim())}),_.map(a=>{if(a.visibleOn&&!Pt(a.visibleOn,{data:t}))return null;let o=mr(n,`record`,a.field);return(0,Y.jsx)(Q,{name:a.field,schema:o,value:t?.[a.field],required:!!a.required,readOnly:r||a.readonly,fieldSpec:a,widgetContext:i,formData:t,onChange:t=>T(e,{[a.field]:t})},a.field)})]})]},e)}),!r&&(0,Y.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Y.jsx)(V,{value:b,onChange:e=>{x(e.target.value),S&&C(null)},placeholder:o?.placeholder??d,className:`h-8 text-xs font-mono max-w-[220px]`,onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),O())}}),(0,Y.jsxs)(m,{type:`button`,variant:`outline`,size:`sm`,onClick:O,children:[(0,Y.jsx)(U,{className:`h-3.5 w-3.5 mr-1`}),` `,q(`engine.form.add`,l)]}),S&&(0,Y.jsx)(`span`,{className:`text-xs text-destructive`,children:S})]})]})}function yr({value:e,onChange:t,readOnly:n,small:r}){let i=K(),[a,o]=J.useState(()=>xr(e)),[s,c]=J.useState(null);return J.useEffect(()=>{o(xr(e)),c(null)},[JSON.stringify(e)]),(0,Y.jsxs)(`div`,{className:`space-y-1`,children:[(0,Y.jsx)(_e,{rows:r?4:12,className:`font-mono text-xs`,value:a,readOnly:n,onChange:e=>{let n=e.target.value;if(o(n),!n.trim()){c(null),t(void 0);return}try{let e=JSON.parse(n);c(null),t(e)}catch(e){c(e?.message??q(`engine.form.invalidJson`,i))}}}),s&&(0,Y.jsx)(`div`,{className:`text-xs text-destructive`,children:s})]})}function br(e){let t={};for(let[n,r]of Object.entries(e))if(!n.startsWith(`_`))if(r==null)t[n]={type:`string`};else if(typeof r==`string`)t[n]=r.length>80||r.includes(`
3
+ `)?{type:`string`,format:`multiline`}:{type:`string`};else if(typeof r==`number`)t[n]={type:Number.isInteger(r)?`integer`:`number`};else if(typeof r==`boolean`)t[n]={type:`boolean`};else if(Array.isArray(r))if(r.length>0&&typeof r[0]==`string`)t[n]={type:`array`,items:{type:`string`}};else if(r.length>0&&typeof r[0]==`object`&&r[0]!==null){let e=r[0],i={};for(let t of Object.keys(e))i[t]={type:`string`};t[n]={type:`array`,items:{type:`object`,properties:i}}}else t[n]={type:`array`,items:{type:`string`}};else typeof r==`object`?t[n]={type:`object`,additionalProperties:!0}:t[n]={type:`string`};return{type:`object`,properties:t,additionalProperties:!0}}function xr(e){if(e===void 0)return``;try{return JSON.stringify(e,null,2)}catch{return String(e)}}function Sr(e){return e.replace(/[_-]+/g,` `).replace(/([a-z])([A-Z])/g,`$1 $2`).replace(/\b\w/g,e=>e.toUpperCase())}function Cr(e,t){if(!t.length)return e;let n=new Set(e),r=t.filter(e=>n.has(e)),i=e.filter(e=>!t.includes(e));return[...r,...i]}function wr(e){let t=e?.properties??{};return Object.keys(t)}var $=(e,t,n,r,i)=>({id:e,label:t,labelZh:n,category:r,Icon:i}),Tr={text:$(`text`,`Text`,`单行文本`,`text`,x),textarea:$(`textarea`,`Text Area`,`多行文本`,`text`,Fe),email:$(`email`,`Email`,`邮箱`,`text`,Ye),url:$(`url`,`URL`,`网址`,`text`,d),phone:$(`phone`,`Phone`,`电话`,`text`,ke),password:$(`password`,`Password`,`密码`,`text`,ne),markdown:$(`markdown`,`Markdown`,`Markdown`,`text`,u),html:$(`html`,`HTML`,`HTML`,`text`,Te),richtext:$(`richtext`,`Rich Text`,`富文本`,`text`,de),number:$(`number`,`Number`,`数字`,`number`,ce),currency:$(`currency`,`Currency`,`货币`,`number`,le),percent:$(`percent`,`Percent`,`百分比`,`number`,Le),date:$(`date`,`Date`,`日期`,`date`,De),datetime:$(`datetime`,`Date/Time`,`日期时间`,`date`,De),time:$(`time`,`Time`,`时间`,`date`,Xe),boolean:$(`boolean`,`Checkbox`,`复选框`,`logic`,We),toggle:$(`toggle`,`Toggle`,`开关`,`logic`,he),select:$(`select`,`Picklist`,`下拉选择`,`selection`,y),multiselect:$(`multiselect`,`Multi-Select`,`多选`,`selection`,re),radio:$(`radio`,`Radio`,`单选`,`selection`,E),checkboxes:$(`checkboxes`,`Checkboxes`,`复选组`,`selection`,re),lookup:$(`lookup`,`Lookup`,`查找关系`,`relation`,k),master_detail:$(`master_detail`,`Master-Detail`,`主从关系`,`relation`,g),tree:$(`tree`,`Tree`,`树形关系`,`relation`,Ge),image:$(`image`,`Image`,`图片`,`media`,Me),file:$(`file`,`File`,`文件`,`media`,Be),avatar:$(`avatar`,`Avatar`,`头像`,`media`,h),video:$(`video`,`Video`,`视频`,`media`,Qe),audio:$(`audio`,`Audio`,`音频`,`media`,te),formula:$(`formula`,`Formula`,`公式`,`calculated`,Pe),summary:$(`summary`,`Rollup`,`汇总`,`calculated`,Ke),autonumber:$(`autonumber`,`Auto Number`,`自动编号`,`calculated`,ce),composite:$(`composite`,`Composite`,`复合字段`,`advanced`,Se),repeater:$(`repeater`,`Repeater`,`重复字段`,`advanced`,_),location:$(`location`,`Location`,`地理坐标`,`advanced`,l),address:$(`address`,`Address`,`地址`,`advanced`,Ze),code:$(`code`,`Code`,`代码`,`advanced`,Te),json:$(`json`,`JSON`,`JSON`,`advanced`,ie),color:$(`color`,`Color`,`颜色`,`advanced`,ue),rating:$(`rating`,`Rating`,`评分`,`advanced`,je),slider:$(`slider`,`Slider`,`滑块`,`advanced`,ee),signature:$(`signature`,`Signature`,`签名`,`advanced`,xe),qrcode:$(`qrcode`,`QR Code`,`二维码`,`advanced`,oe),progress:$(`progress`,`Progress`,`进度条`,`advanced`,me),tags:$(`tags`,`Tags`,`标签`,`advanced`,Ae),vector:$(`vector`,`Vector`,`向量`,`advanced`,Ue)},Er=[`text`,`number`,`date`,`logic`,`selection`,`relation`,`media`,`calculated`,`advanced`],Dr={text:`Text`,number:`Number`,date:`Date & Time`,logic:`Logic`,selection:`Selection`,relation:`Relation`,media:`Media`,calculated:`Calculated`,advanced:`Advanced`},Or={text:{icon:`text-slate-500 dark:text-slate-400`,badge:`border-slate-200 bg-slate-50 text-slate-600 dark:border-slate-700/50 dark:bg-slate-800/40 dark:text-slate-300`},number:{icon:`text-blue-600 dark:text-blue-400`,badge:`border-blue-200 bg-blue-50 text-blue-700 dark:border-blue-800/50 dark:bg-blue-950/40 dark:text-blue-300`},date:{icon:`text-violet-600 dark:text-violet-400`,badge:`border-violet-200 bg-violet-50 text-violet-700 dark:border-violet-800/50 dark:bg-violet-950/40 dark:text-violet-300`},logic:{icon:`text-amber-600 dark:text-amber-400`,badge:`border-amber-200 bg-amber-50 text-amber-700 dark:border-amber-800/50 dark:bg-amber-950/40 dark:text-amber-300`},selection:{icon:`text-teal-600 dark:text-teal-400`,badge:`border-teal-200 bg-teal-50 text-teal-700 dark:border-teal-800/50 dark:bg-teal-950/40 dark:text-teal-300`},relation:{icon:`text-indigo-600 dark:text-indigo-400`,badge:`border-indigo-200 bg-indigo-50 text-indigo-700 dark:border-indigo-800/50 dark:bg-indigo-950/40 dark:text-indigo-300`},media:{icon:`text-pink-600 dark:text-pink-400`,badge:`border-pink-200 bg-pink-50 text-pink-700 dark:border-pink-800/50 dark:bg-pink-950/40 dark:text-pink-300`},calculated:{icon:`text-emerald-600 dark:text-emerald-400`,badge:`border-emerald-200 bg-emerald-50 text-emerald-700 dark:border-emerald-800/50 dark:bg-emerald-950/40 dark:text-emerald-300`},advanced:{icon:`text-zinc-500 dark:text-zinc-400`,badge:`border-zinc-200 bg-zinc-50 text-zinc-600 dark:border-zinc-700/50 dark:bg-zinc-800/40 dark:text-zinc-300`}};function kr(e){return Or[Mr(e).category]}var Ar={text:`文本`,number:`数值`,date:`日期/时间`,logic:`逻辑`,selection:`选择`,relation:`关系`,media:`媒体`,calculated:`计算`,advanced:`高级`},jr=Er.map(e=>({category:e,types:Object.keys(Tr).filter(t=>Tr[t].category===e)}));function Mr(e){return typeof e==`string`&&e in Tr?Tr[e]:{id:`text`,label:typeof e==`string`?e:`unknown`,labelZh:typeof e==`string`?e:`未知`,category:`advanced`,Icon:x}}var Nr=`text/x-objectui-viewcol`;function Pr({type:e}){let t=Mr(e),n=kr(e),r=t.Icon;return(0,Y.jsx)(r,{className:`h-3.5 w-3.5 shrink-0 ${n.icon}`})}function Fr({index:e,label:t,fieldName:n,fieldType:r,selected:i,canEdit:a,dragging:o,dropBefore:s,onSelect:c,onRemove:l,onDragStart:u,onDragEnd:d,onDragOverRow:f,onDropRow:p}){return(0,Y.jsxs)(`div`,{className:`relative`,children:[s&&(0,Y.jsx)(`span`,{className:`pointer-events-none absolute -top-0.5 left-0 right-0 h-0.5 rounded bg-primary`}),(0,Y.jsxs)(`div`,{role:`button`,tabIndex:0,draggable:a,"aria-pressed":i,onDragStart:t=>{a&&(t.dataTransfer.effectAllowed=`move`,t.dataTransfer.setData(Nr,String(e)),u())},onDragEnd:d,onDragOver:e=>{!a||!o||e.dataTransfer.types.includes(Nr)&&(e.preventDefault(),e.dataTransfer.dropEffect=`move`,f())},onDrop:e=>{a&&e.dataTransfer.types.includes(Nr)&&(e.preventDefault(),e.stopPropagation(),p())},onClick:c,onKeyDown:e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),c())},className:`group flex items-center gap-2 rounded-md border bg-card px-2 py-1.5 text-xs transition-colors hover:border-primary/40 `+(i?`border-primary ring-1 ring-primary `:`border-border `)+(a?`cursor-grab active:cursor-grabbing`:``),children:[a&&(0,Y.jsx)(Je,{className:`h-3.5 w-3.5 shrink-0 text-muted-foreground/40 group-hover:text-muted-foreground`}),(0,Y.jsx)(Pr,{type:r}),(0,Y.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-medium`,children:t}),n&&n!==t&&(0,Y.jsx)(`code`,{className:`max-w-[7rem] shrink-0 truncate text-[10px] text-muted-foreground`,children:n}),a&&(0,Y.jsx)(`span`,{role:`button`,tabIndex:0,"aria-label":`Remove ${t}`,onClick:e=>{e.stopPropagation(),l()},onKeyDown:e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),e.stopPropagation(),l())},className:`inline-flex h-4 w-4 shrink-0 items-center justify-center rounded text-muted-foreground/60 hover:bg-destructive/10 hover:text-destructive`,children:(0,Y.jsx)(T,{className:`h-3 w-3`})})]})]})}function Ir({fields:e,usedNames:t,loading:n,error:r,onAdd:i}){let a=K(),[o,s]=J.useState(!1),[c,l]=J.useState(``),u=J.useMemo(()=>{let t=c.trim().toLowerCase();return t?e.filter(e=>e.name.toLowerCase().includes(t)||e.label.toLowerCase().includes(t)):e},[e,c]);return(0,Y.jsxs)(Ce,{open:o,onOpenChange:s,children:[(0,Y.jsx)(fe,{asChild:!0,children:(0,Y.jsxs)(`button`,{type:`button`,className:`inline-flex items-center gap-1 rounded-md border border-dashed px-2 py-1 text-xs text-muted-foreground hover:border-primary/40 hover:bg-accent/40 hover:text-foreground`,children:[(0,Y.jsx)(U,{className:`h-3.5 w-3.5`}),` `,q(`engine.form.addFieldPlain`,a)]})}),(0,Y.jsxs)(Ve,{align:`start`,className:`w-72 p-0`,children:[(0,Y.jsxs)(`div`,{className:`relative border-b p-2`,children:[(0,Y.jsx)(D,{className:`pointer-events-none absolute left-4 top-1/2 h-3.5 w-3.5 -translate-y-1/2 text-muted-foreground`}),(0,Y.jsx)(`input`,{autoFocus:!0,value:c,onChange:e=>l(e.target.value),placeholder:q(`engine.form.searchFields`,a),className:`h-8 w-full rounded border border-input bg-background pl-7 pr-2 text-xs outline-none focus:border-primary`})]}),(0,Y.jsx)(`div`,{className:`max-h-72 overflow-auto p-1`,children:n?(0,Y.jsx)(Lr,{children:q(`engine.form.loadingFields`,a)}):r?(0,Y.jsx)(Lr,{tone:`warn`,children:G(`engine.form.noObjectFields`,a,{error:r})}):u.length===0?(0,Y.jsx)(Lr,{children:q(c?`engine.form.noMatchingFields`:`engine.form.noFieldsOnObject`,a)}):u.map(e=>{let n=t.has(e.name);return(0,Y.jsxs)(`button`,{type:`button`,onClick:()=>i(e),className:`flex w-full items-center gap-2 rounded px-2 py-1.5 text-left text-xs hover:bg-accent`,children:[(0,Y.jsx)(Pr,{type:e.type}),(0,Y.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-medium`,children:e.label}),e.name!==e.label&&(0,Y.jsx)(`code`,{className:`max-w-[6rem] truncate text-[10px] text-muted-foreground`,children:e.name}),n&&(0,Y.jsx)(He,{variant:`secondary`,className:`px-1 py-0 text-[9px]`,children:q(`engine.form.added`,a)})]},e.name)})})]})]})}function Lr({children:e,tone:t}){return(0,Y.jsx)(`div`,{className:`px-2 py-4 text-center text-[11px] `+(t===`warn`?`text-amber-600 dark:text-amber-300`:`text-muted-foreground`),children:e})}function Rr(e){let t=new Set;for(let n of e?.sections??[])for(let e of n.fields??[])t.add(typeof e==`string`?e:e?.field);return t}function zr({bundledSchema:e,bundledForm:t,serverSchema:n,excludeFields:r,sectionTitle:i}){if(!e)return{schema:e,form:t};let a=n?.properties;if(!a||typeof a!=`object`)return{schema:e,form:t};let o=e.properties??{},s=Rr(t),c=Object.keys(a).filter(e=>!(e in o)&&!r.has(e)&&!s.has(e));if(c.length===0)return{schema:e,form:t};let l={...e,properties:{...o}};for(let e of c)e in l.properties||(l.properties[e]=a[e]);let u=t;if(t&&typeof t==`object`){let e=JSON.parse(JSON.stringify(t));e.sections=[...e.sections??[],{label:i,fields:c.map(e=>({field:e}))}],u=e}return{schema:l,form:u}}function Br(e,t){if(typeof e==`string`&&e)return e;if(e&&typeof e==`object`){let t=e.default;if(typeof t==`string`&&t)return t}return t}function Vr(e){let t=typeof e.name==`string`?e.name:``;if(!t)return null;let n=Array.isArray(e.dimensions)?e.dimensions.filter(e=>e&&typeof e.name==`string`&&e.name).map(e=>({name:e.name,type:typeof e.type==`string`?e.type:void 0})):[],r=Array.isArray(e.measures)?e.measures.filter(e=>e&&typeof e.name==`string`&&e.name).map(e=>({name:e.name,aggregate:typeof e.aggregate==`string`?e.aggregate:void 0,certified:e.certified===!0})):[];return{name:t,label:Br(e.label,t),dimensions:n,measures:r}}function Hr(e){let t=et(),[n,r]=J.useState({datasets:e??[],loading:!e,error:null});return J.useEffect(()=>{if(e){r({datasets:e,loading:!1,error:null});return}let n=!1;return r(e=>({...e,loading:!0,error:null})),t.list(`dataset`).then(e=>{if(n)return;let t=(Array.isArray(e)?e:[]).map(Vr).filter(e=>e!==null);r({datasets:t,loading:!1,error:null})}).catch(e=>{n||r({datasets:[],loading:!1,error:e?.message??String(e)})}),()=>{n=!0}},[t,e]),n}function Ur(e,t){let n=et(),r=e?t.datasets.find(t=>t.name===e):void 0,i=!!e&&!t.loading&&(!r||r.dimensions.length===0&&r.measures.length===0),[a,o]=J.useState(null);J.useEffect(()=>{if(!i||!e||a?.name===e)return;let t=!1;return n.get(`dataset`,e).then(n=>{t||o({name:e,entry:n?Vr(n):null,error:n?null:`Dataset not found`})}).catch(n=>{t||o({name:e,entry:null,error:n?.message??String(n)})}),()=>{t=!0}},[n,e,i,a]);let s=i&&a?.name===e?a.entry:r;return{dimensions:s?.dimensions??[],measures:s?.measures??[],loading:t.loading||i&&a?.name!==e,error:(i&&a?.name===e?a.error:null)??t.error}}var Wr={io:`input`,unrepresentable:`any`},Gr=new Set([`dataset`,`values`,`rows`,`columns`,`name`]),Kr,qr=!1;function Jr(){if(Kr||qr)return Kr;try{Kr=a(o,Wr)}catch(e){qr=!0,typeof console<`u`&&console.warn(`[report-schema] failed to derive Report JSONSchema from spec`,e)}return Kr}var Yr;function Xr(){if(Yr)return Yr;if(!(!i||typeof i!=`object`)){try{let e=JSON.parse(JSON.stringify(i)),t=Jr()?.properties;for(let n of e.sections??[])n.fields=(n.fields??[]).filter(e=>{let n=typeof e==`string`?e:e?.field;return!(Gr.has(n)||t&&!(n in t))});if(t&&`runtimeFilter`in t){let t=new Set;for(let n of e.sections??[])for(let e of n.fields??[])t.add(typeof e==`string`?e:e?.field);t.has(`runtimeFilter`)||(e.sections=[...e.sections??[],{label:`Filter`,description:`Render-time scope filter, ANDed at query time.`,collapsible:!0,collapsed:!0,fields:[{field:`runtimeFilter`,widget:`json`}]}])}e.sections=(e.sections??[]).filter(e=>(e.fields??[]).length>0),Yr=e}catch(e){typeof console<`u`&&console.warn(`[report-schema] failed to prepare reportForm from spec`,e);return}return Yr}}var Zr=new Set([`type`,`label`,`name`,`dataset`,`values`,`rows`,`columns`,`chart`]),Qr=[`bar`,`column`,`line`,`area`,`pie`,`donut`],$r={tabular:`engine.inspector.report.type.tabular`,summary:`engine.inspector.report.type.summary`,matrix:`engine.inspector.report.type.matrix`,joined:`engine.inspector.report.type.joined`};function ei(e,t){return J.useMemo(()=>{let n=Jr()?.properties?.type?.enum,r=(Array.isArray(n)&&n.length?n.filter(e=>typeof e==`string`):[`tabular`,`summary`,`matrix`,`joined`]).map(e=>{let n=$r[e],r=n?q(n,t):e;return{value:e,label:r===n?e:r}});return!r.some(t=>t.value===e)&&e&&r.push({value:e,label:e}),r},[e,t])}function ti(e){return Array.isArray(e)?e.filter(e=>typeof e==`string`):[]}function ni({label:e,emptyText:t,names:n,options:r,loading:i,error:a,readOnly:o,onCommit:s}){let[c,l]=J.useState(null),[u,d]=J.useState(null),f=J.useMemo(()=>new Set(n),[n]),p=J.useMemo(()=>{let e=new Map;for(let t of r)e.set(t.name,t.type);return e},[r]);return(0,Y.jsxs)(`div`,{className:`border-t pt-3 space-y-1.5`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,Y.jsx)(H,{className:`text-xs text-muted-foreground`,children:e}),(0,Y.jsx)(He,{variant:`outline`,className:`text-[10px]`,children:n.length})]}),n.length===0?(0,Y.jsx)(`p`,{className:`rounded-md border border-dashed bg-muted/30 px-3 py-3 text-center text-[11px] text-muted-foreground`,children:t}):(0,Y.jsx)(`div`,{className:`space-y-1`,children:n.map((e,t)=>(0,Y.jsx)(Fr,{index:t,label:e,fieldName:e,fieldType:p.get(e)??`number`,selected:!1,canEdit:!o,dragging:c!==null,dropBefore:u===t&&c!==null&&c!==t,onSelect:()=>{},onRemove:()=>s(At(n,t,null)),onDragStart:()=>l(t),onDragEnd:()=>{l(null),d(null)},onDragOverRow:()=>d(t),onDropRow:()=>{c!=null&&c!==t&&s(Mt(n,c,t)),l(null),d(null)}},`${e}-${t}`))}),!o&&(0,Y.jsx)(Ir,{fields:r,usedNames:f,loading:i,error:a,onAdd:e=>s(jt(n,e.name))})]})}function ri({name:e,draft:t,onPatch:n,readOnly:r,locale:i,datasetCatalogOverride:a,serverSchema:o}){let s=J.useCallback(e=>q(e,i),[i]),c=!e,l=J.useRef(!1),u=typeof t.name==`string`?t.name:``,d=typeof t.type==`string`?t.type:`tabular`,f=ei(d,i),p=typeof t.label==`string`?t.label:``,m=typeof t.dataset==`string`?t.dataset:``,h=J.useMemo(()=>ti(t.values),[t.values]),g=J.useMemo(()=>ti(t.rows),[t.rows]),_=J.useMemo(()=>ti(t.columns),[t.columns]),v=Hr(a),y=Ur(m||void 0,v),b=J.useMemo(()=>{let e=v.datasets.map(e=>({value:e.name,label:e.label&&e.label!==e.name?`${e.label} (${e.name})`:e.name}));return m&&!e.some(e=>e.value===m)&&e.push({value:m,label:m}),e},[v.datasets,m]),x=J.useMemo(()=>y.measures.map(e=>({name:e.name,label:e.aggregate?`${e.name} · ${e.aggregate}`:e.name,type:`number`,hidden:!1})),[y.measures]),S=J.useMemo(()=>y.dimensions.map(e=>({name:e.name,label:e.name,type:e.type??`text`,hidden:!1})),[y.dimensions]),C=t.chart&&typeof t.chart==`object`?t.chart:{},w=typeof C.type==`string`?C.type:``,T=typeof C.xAxis==`string`?C.xAxis:``,E=typeof C.yAxis==`string`?C.yAxis:``,D=typeof C.title==`string`?C.title:``,O=e=>{let t={...C,...e};n({chart:t.type?t:void 0})},k=J.useMemo(()=>{let e=S.map(e=>({value:e.name,label:e.label||e.name}));return T&&!e.some(e=>e.value===T)&&e.push({value:T,label:T}),e},[S,T]),A=J.useMemo(()=>{let e=x.map(e=>({value:e.name,label:e.label||e.name}));return E&&!e.some(e=>e.value===E)&&e.push({value:E,label:E}),e},[x,E]),j=d!==`joined`,{schema:M,form:N}=J.useMemo(()=>zr({bundledSchema:Jr(),bundledForm:Xr(),serverSchema:o,excludeFields:Zr,sectionTitle:q(`engine.inspector.moreFields`,i)}),[o,i]);return(0,Y.jsxs)(St,{kindLabel:s(`engine.inspector.report.kind`),title:String(p||t.name||s(`engine.inspector.report.kind`)),onClose:()=>{},closeLabel:s(`engine.inspector.report.close`),hideClose:!0,children:[c&&(0,Y.jsx)(wt,{label:s(`engine.inspector.report.name`),value:u,onCommit:e=>{l.current=!0,n({name:ot(e)})},placeholder:s(`engine.inspector.report.namePlaceholder`),disabled:r,mono:!0}),(0,Y.jsx)(wt,{label:s(`engine.inspector.report.label`),value:p,onCommit:e=>{let t={label:e};c&&!l.current&&(t.name=ot(e)),n(t)},placeholder:s(`engine.inspector.report.labelPlaceholder`),disabled:r}),(0,Y.jsx)(X,{label:s(`engine.inspector.report.type`),value:d,options:f,onCommit:e=>n({type:e}),disabled:r}),j&&(0,Y.jsxs)(Y.Fragment,{children:[v.datasets.length>0||m?(0,Y.jsx)(X,{label:s(`engine.inspector.report.dataset`),value:m,options:b,onCommit:e=>n({dataset:e}),disabled:r}):(0,Y.jsx)(wt,{label:s(`engine.inspector.report.dataset`),value:m,onCommit:e=>n({dataset:e}),placeholder:s(`engine.inspector.report.datasetPlaceholder`),disabled:r,mono:!0}),(0,Y.jsx)(ni,{label:s(`engine.inspector.report.values`),emptyText:s(`engine.inspector.report.valuesEmpty`),names:h,options:x,loading:y.loading,error:y.error,readOnly:r,onCommit:e=>n({values:e})}),(0,Y.jsx)(ni,{label:s(`engine.inspector.report.rows`),emptyText:s(`engine.inspector.report.rowsEmpty`),names:g,options:S,loading:y.loading,error:y.error,readOnly:r,onCommit:e=>n({rows:e})}),d===`matrix`&&(0,Y.jsx)(ni,{label:s(`engine.inspector.report.columnsAcross`),emptyText:s(`engine.inspector.report.columnsAcrossEmpty`),names:_,options:S,loading:y.loading,error:y.error,readOnly:r,onCommit:e=>n({columns:e})}),(0,Y.jsxs)(`div`,{className:`border-t pt-3 space-y-2`,children:[(0,Y.jsx)(H,{className:`text-xs text-muted-foreground`,children:s(`engine.inspector.report.chart`)}),(0,Y.jsx)(X,{label:s(`engine.inspector.report.chartType`),value:w,options:[{value:``,label:s(`engine.inspector.report.chartNone`)},...Qr.map(e=>({value:e,label:e}))],onCommit:e=>O({type:e||void 0}),disabled:r}),w?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(wt,{label:s(`engine.inspector.report.chartTitle`),value:D,onCommit:e=>O({title:e||void 0}),disabled:r}),(0,Y.jsx)(X,{label:s(`engine.inspector.report.chartX`),value:T,options:k,onCommit:e=>O({xAxis:e}),disabled:r}),(0,Y.jsx)(X,{label:s(`engine.inspector.report.chartY`),value:E,options:A,onCommit:e=>O({yAxis:e}),disabled:r})]}):null]})]}),(0,Y.jsx)(`div`,{className:`border-t pt-3`,children:M?(0,Y.jsx)(ur,{schema:M,form:N,value:t,hiddenFields:[`type`,`label`,`name`,`dataset`,`values`,`rows`,`columns`,`chart`],readOnly:r,onChange:e=>n(e)}):(0,Y.jsx)(`p`,{className:`text-[11px] text-muted-foreground`,children:s(`engine.inspector.report.noSchema`)})})]})}export{Mt as A,it as B,Tt as C,St as D,X as E,ht as F,ot as G,ct as H,bt as I,nt as J,st as K,_t as L,Nt as M,xt as N,wt as O,ut as P,rt as R,kt as S,Ct as T,pt as U,tt as V,dt as W,ln as _,zr as a,Ht as b,Dr as c,Tr as d,jr as f,vn as g,bn as h,Ur as i,At as j,jt as k,Ar as l,In as m,ri as n,Ir as o,ur as p,ft as q,Hr as r,Fr as s,ni as t,Or as u,qt as v,Ot as w,Dt as x,rn as y,mt as z};
@@ -0,0 +1,2 @@
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./ui-components-BL3SEdAz.css"])))=>i.map(i=>d[i]);
2
+ import{o as e,r as t}from"./rolldown-runtime-DAXXjFlN.js";import{g as n,m as r,r as i,y as a}from"./vendor-react-BKSb6vFP.js";import{f as o}from"./infrastructure-1EBA2wrr.js";import{O as s,h as c,k as l}from"./framework-CavAJOoG.js";import{$ as u,Er as d,Ga as f,Ni as p,Nr as m,Uc as h,X as g,Y as _,ca as v,ec as y,qr as b}from"./ui-components-CHaxvtjc.js";import"./AdapterProvider-BFaddpzn.js";import"./MetadataProvider-Dw6hFBw2.js";import{r as x}from"./ExpressionProvider-E8d0a2zy.js";import{t as S}from"./preferLocal-CKqyhTP9.js";import{n as C,o as w,t as T}from"./i18n--Ef6MgVx.js";import{r as ee}from"./useMetadata-IV9x2kG3.js";import{n as E}from"./ReportDefaultInspector-Dfj5Pq4K.js";import{n as D,t as te}from"./MetadataInspector-Ty_bVFlI.js";import{a as O,i as k,n as A,r as j}from"./runtime-metadata-persistence-D1KKivGr.js";import{r as M}from"./plugin-dashboard-oozFEUjN.js";import{t as N}from"./useOpenRecordList-C75NAaDm.js";var P=e(a(),1),F=i();function I({type:e,name:t,metadataClient:n,dirty:r,onResume:i,onAfterChange:a,savedSignal:o}){let s=w(),[c,l]=(0,P.useState)(!1),[u,m]=(0,P.useState)(!1),h=(0,P.useRef)(null),g=(0,P.useCallback)(async()=>{if(!t||!n){l(!1);return}let r;try{r=await O(e,t,{metadataClient:n})}catch{l(!1);return}if(l(!!r),r&&i&&h.current!==t){h.current=t;try{i(r)}catch(e){console.error(`[RuntimeDraftBar] Resume draft failed:`,e)}}},[e,t,n,i]);(0,P.useEffect)(()=>{g()},[g]);let _=(0,P.useRef)(o);(0,P.useEffect)(()=>{o!==_.current&&(_.current=o,o&&l(!0))},[o]);let v=(0,P.useCallback)(async()=>{if(t){m(!0);try{await k(e,t,{metadataClient:n}),l(!1),a?.()}catch(e){console.error(`[RuntimeDraftBar] Publish failed:`,e)}finally{m(!1)}}},[e,t,n,a]),y=(0,P.useCallback)(async()=>{if(t&&!(typeof confirm==`function`&&!confirm(C(`engine.edit.discardDraftConfirm`,s,{type:e,name:t})))){m(!0);try{await A(e,t,{metadataClient:n}),l(!1),a?.()}catch(e){console.error(`[RuntimeDraftBar] Discard draft failed:`,e)}finally{m(!1)}}},[e,t,n,a,s]);return c?(0,F.jsxs)(`div`,{className:`mr-auto flex items-center gap-2`,"data-testid":`runtime-draft-bar`,children:[(0,F.jsxs)(`span`,{className:`text-xs text-amber-700 dark:text-amber-400`,title:T(`engine.edit.draftPending`,s),"data-testid":`runtime-draft-indicator`,children:[`● `,T(`engine.edit.draftPending`,s)]}),(0,F.jsx)(d,{variant:`ghost`,size:`sm`,onClick:y,disabled:u,className:`h-7 w-7 p-0 text-muted-foreground`,title:T(`engine.edit.discardDraft`,s),"aria-label":T(`engine.edit.discardDraft`,s),"data-testid":`runtime-draft-discard`,children:(0,F.jsx)(b,{className:`h-3.5 w-3.5`})}),(0,F.jsx)(d,{size:`sm`,onClick:v,disabled:u||r,className:`h-7 px-2 bg-emerald-600 hover:bg-emerald-700 text-emerald-50`,title:T(r?`engine.edit.publishBlockedDirty`:`engine.edit.publish`,s),"data-testid":`runtime-draft-publish`,children:u?(0,F.jsx)(f,{className:`h-3.5 w-3.5 animate-spin`}):(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(p,{className:`h-3.5 w-3.5 mr-1`}),T(`engine.edit.publish`,s)]})})]}):null}function ne({open:e,onClose:t,config:n,onSave:r,onFieldChange:i,name:a,metadataClient:o,onAfterChange:s}){let{t:c}=h(),l=w(),[u,f]=(0,P.useState)(!1),p=(0,P.useMemo)(()=>({...n??{}}),[n]),[g,_]=(0,P.useState)(p),v=(0,P.useRef)(g),y=(0,P.useRef)(p);y.current!==p&&(y.current=p,v.current=p,_(p),f(!1));let b=(0,P.useCallback)(e=>{let t={...v.current,...e};if(v.current=t,_(t),f(!0),i)for(let[n,r]of Object.entries(e))i(n,r,t)},[i]),x=(0,P.useCallback)(()=>{r(v.current),f(!1),t()},[r,t]),S=(0,P.useCallback)(e=>{let t={...e};v.current=t,_(t),f(!1)},[]),C=(0,P.useCallback)(()=>{t()},[t]);return e?(0,F.jsxs)(`aside`,{className:`hidden sm:flex w-[440px] shrink-0 flex-col border-l bg-background h-full`,"data-testid":`report-config-panel`,role:`complementary`,"aria-label":c(`report.editor.title`,{defaultValue:`Edit report`}),children:[(0,F.jsxs)(`div`,{className:`flex items-center justify-between gap-2 border-b px-4 py-2.5 shrink-0`,children:[(0,F.jsx)(`div`,{className:`text-sm font-medium truncate`,children:c(`report.editor.title`,{defaultValue:`Edit report`})}),(0,F.jsx)(d,{variant:`ghost`,size:`sm`,onClick:t,className:`h-7 w-7 p-0`,"aria-label":c(`common.close`,{defaultValue:`Close`}),"data-testid":`report-config-close`,children:(0,F.jsx)(m,{className:`h-4 w-4`})})]}),(0,F.jsx)(`div`,{className:`min-h-0 flex-1 overflow-auto`,children:(0,F.jsx)(E,{type:`report`,name:typeof g.name==`string`?g.name:``,draft:g,readOnly:!1,locale:l,onPatch:b})}),(0,F.jsxs)(`div`,{"data-testid":`report-config-footer`,className:`flex items-center justify-end gap-2 border-t px-4 py-2.5 shrink-0`,children:[(0,F.jsx)(I,{type:`report`,name:a,metadataClient:o,dirty:u,onResume:S,onAfterChange:s}),(0,F.jsx)(d,{variant:`ghost`,size:`sm`,onClick:C,"data-testid":`report-config-discard`,children:c(`common.cancel`,{defaultValue:`Cancel`})}),(0,F.jsx)(d,{size:`sm`,onClick:x,"data-testid":`report-config-save`,children:c(`common.save`,{defaultValue:`Save`})})]})]}):null}var L=t({ReportView:()=>V}),R=(0,P.lazy)(()=>n(()=>import(`./plugin-report-CMTOJSLw.js`).then(e=>e.t).then(e=>({default:e.ReportViewer})),__vite__mapDeps([0]),import.meta.url)),z=(0,P.lazy)(()=>n(()=>import(`./plugin-report-CMTOJSLw.js`).then(e=>e.t).then(e=>({default:e.ReportRenderer})),__vite__mapDeps([0]),import.meta.url)),B=[{value:`month`,label:`Month`,type:`text`},{value:`revenue`,label:`Revenue`,type:`number`},{value:`count`,label:`Count`,type:`number`},{value:`region`,label:`Region`,type:`text`},{value:`product`,label:`Product`,type:`text`},{value:`source`,label:`Lead Source`,type:`text`},{value:`stage`,label:`Stage`,type:`text`},{value:`amount`,label:`Amount`,type:`number`}];function V({dataSource:e}){let{t}=h(),{reportName:n}=r(),{showDebug:i}=D();s();let a=ee(),d=o(),[p,m]=(0,P.useState)(!1),[b,C]=(0,P.useState)(0),{reports:w,objects:T,loading:E,refresh:O}=l(),{app:k}=x(),A=S(w,n,k?._packageId),[I,L]=(0,P.useState)(A),[V,H]=(0,P.useState)(null),[U,W]=(0,P.useState)([]),[G,K]=(0,P.useState)(!1),q=N(),[J,Y]=(0,P.useState)(null),X=(0,P.useCallback)(e=>{if(!e||!T?.length)return;let t=T.find(t=>t.name===e);if(!t?.fields)return;let n=t.fields;return Array.isArray(n)?n.map(e=>typeof e==`string`?{value:e,label:e,type:`text`}:{value:e.name,label:e.label||e.name,type:e.type||`text`}):Object.entries(n).map(([e,t])=>({value:e,label:t.label||e,type:t.type||`text`}))},[T]),re=(0,P.useCallback)(async({dataset:e,groupKey:t,object:n,objectFilter:r})=>{try{let i=Object.values(t).filter(e=>e!=null).map(e=>String(e)).join(` / `)||String(I?.label??I?.name??`Details`);if(n&&r){Y({object:n,filter:r,title:i});return}let o=await a.get(`dataset`,e),s=typeof o?.object==`string`?o.object:void 0;if(!s)return;let c=Array.isArray(o?.dimensions)?o.dimensions:[],l=new Map(c.filter(e=>e?.name).map(e=>[e.name,e])),u=T?.find(e=>e.name===s)?.fields,d=e=>{if(Array.isArray(u))return u.find(t=>t?.name===e);if(u&&typeof u==`object`)return u[e]},f={};for(let[e,n]of Object.entries(t)){if(n==null)continue;let t=l.get(e);if(t?.dateGranularity)continue;let r=t?.field||e,i=d(r);if(i?.type===`lookup`||i?.type===`master_detail`)continue;let a=n;if(Array.isArray(i?.options)){let e=i.options.find(e=>e?.label===n||e?.value===n);e&&e.value!=null&&(a=e.value)}f[r]=a}Y({object:s,filter:f,title:i})}catch(e){console.warn(`ReportView: drill failed`,e)}},[a,T,I]),ie=(0,P.useMemo)(()=>{let e=V||I,t=e?.objectName||e?.dataSource?.object||e?.dataSource?.resource;return X(t)??B},[V,I,X]),Z=(0,P.useCallback)(async e=>{try{a&&(await j(`report`,n,e,{metadataClient:a}),O().catch(()=>{}))}catch(e){console.warn(`[ReportView] Auto-save failed:`,e)}},[a,n,O]),ae=(0,P.useCallback)(()=>{H(I),m(!0),C(e=>e+1)},[I]),oe=(0,P.useCallback)(()=>{m(!1)},[]),se=(0,P.useMemo)(()=>V||I,[b]),ce=(0,P.useCallback)(e=>{H(e),Z(e),C(e=>e+1)},[Z]),le=(0,P.useCallback)((e,t)=>{H(n=>({...n,[e]:t}))},[]);(0,P.useEffect)(()=>{L(A)},[A]),(0,P.useEffect)(()=>{p||H(null)},[A]);let Q=V||I,ue=(0,P.useMemo)(()=>JSON.stringify(Q?.filters),[Q?.filters]),de=(0,P.useMemo)(()=>JSON.stringify(Q?.dataSource),[Q?.dataSource]),fe=(0,P.useMemo)(()=>JSON.stringify(Q?.data),[Q?.data]);if((0,P.useEffect)(()=>{if(!Q||!e){W([]);return}if(Q.data&&Array.isArray(Q.data)){W(Q.data);return}if(Q.dataSource){(async()=>{K(!0);try{let t=Q.dataSource.object||Q.dataSource.resource;if(!t){console.warn(`ReportView: dataSource missing object/resource property`),W([]);return}let n=await e.find(t,{$filter:Q.dataSource.filter,$orderby:Q.dataSource.sort,$top:Q.dataSource.limit});W(n.data||[])}catch(e){console.error(`ReportView: Failed to load data from dataSource`,e),W([])}finally{K(!1)}})();return}if(Q.objectName){(async()=>{K(!0);try{let t=await e.find(Q.objectName,{$filter:Q.filters,$orderby:Q.sort,$top:Q.limit||100});W(t.data||[])}catch(e){console.error(`ReportView: Failed to load data from objectName`,e),W([])}finally{K(!1)}})();return}W([])},[Q?.objectName,Q?.limit,ue,de,fe,e]),E)return(0,F.jsx)(`div`,{className:`h-full flex items-center justify-center p-8`,children:(0,F.jsx)(f,{className:`h-8 w-8 animate-spin text-muted-foreground`})});if(!A||!I)return!E&&!A?(0,F.jsx)(`div`,{className:`h-full flex items-center justify-center p-8`,children:(0,F.jsxs)(_,{children:[(0,F.jsx)(`div`,{className:`mx-auto mb-4 flex h-12 w-12 items-center justify-center rounded-full bg-muted`,children:(0,F.jsx)(y,{className:`h-6 w-6 text-muted-foreground`})}),(0,F.jsx)(u,{children:t(`empty.reportNotFound`)}),(0,F.jsx)(g,{children:t(`empty.reportNotFoundDescription`,{name:n})})]})}):(0,F.jsx)(`div`,{className:`h-full flex items-center justify-center p-8`,children:(0,F.jsx)(f,{className:`h-8 w-8 animate-spin text-muted-foreground`})});let pe=e=>{let t={...e};!t.title&&t.label&&(t.title=t.label);let n=t.objectName||t.dataSource?.object||t.dataSource?.resource,r=n?T?.find(e=>e.name===n):null,i=Array.isArray(r?.fields)?r.fields:r?.fields?Object.entries(r.fields).map(([e,t])=>({name:e,...t})):[],a={};for(let e of i)e&&e.name&&(a[e.name]=e);let o=e=>{let t=e.name||e.field,n=t?a[t]:void 0;if(!n)return e;let r={...e};if(r.type===void 0&&n.type!==void 0&&(r.type=n.type),r.options===void 0&&Array.isArray(n.options)&&(r.options=n.options),r.referenceTo===void 0){let e=n.reference_to||n.referenceTo||(typeof n.reference==`string`?n.reference:n.reference?.to)||n.target;e&&(r.referenceTo=e)}return r.label===void 0&&n.label&&(r.label=n.label),r};if(!t.fields&&Array.isArray(t.columns)?t.fields=t.columns.map(e=>{let t=o(e);return{name:t.field||t.name,label:t.label,type:t.type,options:t.options,referenceTo:t.referenceTo,format:t.format,renderAs:t.renderAs,colorMap:t.colorMap,...t.aggregate?{aggregation:t.aggregate,showInSummary:!0}:{}}}):Array.isArray(t.fields)&&(t.fields=t.fields.map(o)),t.fields&&Array.isArray(t.fields)&&t.fields.length>0){let n=t.fields.some(e=>e.showInSummary||e.aggregation),r=t.type||t.reportType||`tabular`,i=[];(r===`summary`||n)&&i.push({type:`summary`,title:`Key Metrics`}),i.push({type:`table`,title:`Details`,columns:t.fields.map(e=>({name:e.name,label:e.label,type:e.type,options:e.options,referenceTo:e.referenceTo,format:e.format,renderAs:e.renderAs,colorMap:e.colorMap}))});let a=t.chart||t.chartConfig,o=a?.type||a?.chartType;if(o){let e=a.xAxis||a.xAxisField,t=a.yAxis||a.yAxisFields?.[0];i.push({type:`chart`,title:`Chart`,chart:{type:`chart`,chartType:o,xAxisField:e,yAxisFields:t?[t]:a.yAxisFields}})}if(Array.isArray(e.sections)){let t=e.sections.filter(e=>e.type===`chart`&&!o);i.push(...t)}t.sections=i}else t.sections||=[];return t},$=V||I,me=!!($&&(typeof $.dataset==`string`||$.type===`joined`&&Array.isArray($.blocks)&&$.blocks.some(e=>typeof e?.dataset==`string`)))||!!($&&$.objectName&&($.type===`matrix`||$.type===`joined`||$.type===`summary`||$.type===`tabular`||$.type===void 0||Array.isArray($.groupingsAcross)&&$.groupingsAcross.length>0||Array.isArray($.columns))),he={type:`report-viewer`,report:pe($),data:U,showToolbar:!0,allowExport:!0,loading:G};return(0,F.jsxs)(c,{value:{openRecordList:q},children:[(0,F.jsxs)(`div`,{className:`flex flex-col h-full overflow-hidden bg-background`,children:[(0,F.jsxs)(`div`,{className:`flex flex-col sm:flex-row justify-between sm:items-center gap-3 sm:gap-4 p-4 sm:p-6 border-b shrink-0`,children:[(0,F.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,F.jsx)(`h1`,{className:`text-lg sm:text-xl md:text-2xl font-bold tracking-tight truncate`,children:$.title||$.label||`Report Viewer`}),$.description&&(0,F.jsx)(`p`,{className:`text-sm text-muted-foreground mt-1 line-clamp-2`,children:$.description})]}),(0,F.jsx)(`div`,{className:`shrink-0 flex items-center gap-1.5`,children:d&&(0,F.jsxs)(`button`,{type:`button`,onClick:ae,className:`inline-flex items-center gap-1.5 rounded-md border border-input bg-background px-2.5 py-1.5 text-xs font-medium text-muted-foreground shadow-sm hover:bg-accent hover:text-accent-foreground`,"data-testid":`report-edit-button`,children:[(0,F.jsx)(v,{className:`h-3.5 w-3.5`}),t(`common.edit`)]})})]}),(0,F.jsxs)(`div`,{className:`flex-1 overflow-hidden flex flex-col sm:flex-row relative`,children:[(0,F.jsx)(`div`,{className:`flex-1 min-w-0 overflow-auto p-4 sm:p-6 lg:p-8 bg-muted/5`,children:(0,F.jsx)(`div`,{className:`w-full shadow-sm border rounded-lg sm:rounded-xl bg-background overflow-hidden min-h-150`,children:(0,F.jsx)(P.Suspense,{fallback:(0,F.jsx)(`div`,{className:`p-8 text-sm text-muted-foreground`,children:t(`common.loading`,{defaultValue:`Loading…`})}),children:me?(0,F.jsx)(`div`,{className:`p-4 sm:p-6`,children:(0,F.jsx)(z,{schema:$,dataSource:e,rows:U,onDrill:re})}):(0,F.jsx)(R,{schema:he})})})}),(0,F.jsx)(ne,{open:p&&d,onClose:oe,config:se,onSave:ce,onFieldChange:le,availableFields:ie,getFieldsForObject:X,name:n,metadataClient:a,onAfterChange:()=>O().catch(()=>{})}),(0,F.jsx)(te,{open:i,sections:[{title:`Report Configuration`,data:$}]})]})]}),(0,F.jsx)(M,{open:!!J,onClose:()=>Y(null),title:J?.title??``,objectName:J?.object??``,filter:J?.filter,dataSource:e})]})}export{I as n,L as t};
@@ -0,0 +1 @@
1
+ import{o as e,r as t}from"./rolldown-runtime-DAXXjFlN.js";import{a as n,h as r,m as i,r as a,y as o}from"./vendor-react-BKSb6vFP.js";import{p as s}from"./infrastructure-1EBA2wrr.js";import{k as c}from"./framework-CavAJOoG.js";import{Bo as l,Ec as u,Pi as d,Uc as f,ar as p,ec as m,fn as h,ir as g,no as _,ss as v,ur as y}from"./ui-components-CHaxvtjc.js";import"./MetadataProvider-Dw6hFBw2.js";import{n as b}from"./ui-layout-BLgfeXIq.js";import{r as x}from"./appRoute-C7XNGt8B.js";var S=t({SearchResultsPage:()=>O}),C=e(o(),1),w=a();function T(e){let t=[];for(let n of e)n.type===`group`&&n.children?t.push(...T(n.children)):t.push(n);return t}var E={object:v,dashboard:_,page:l,report:m},D={object:`bg-blue-100 text-blue-800 dark:bg-blue-900 dark:text-blue-200`,dashboard:`bg-purple-100 text-purple-800 dark:bg-purple-900 dark:text-purple-200`,page:`bg-green-100 text-green-800 dark:bg-green-900 dark:text-green-200`,report:`bg-orange-100 text-orange-800 dark:bg-orange-900 dark:text-orange-200`};function O(){let{t:e}=f(),{appName:t}=i(),[a,o]=r(),[l,m]=(0,C.useState)(a.get(`q`)||``),{apps:_}=c(),S=_||[],O=x(S,t)||S[0],k=`/apps/${t}`,{user:A,activeOrganization:j}=s(),M=(0,C.useMemo)(()=>{if(!O)return[];let e=T(O.navigation||[]),t={currentUserId:A?.id??null,currentOrgId:j?.id??null};return e.map(e=>{let{href:n}=b(e,k,t);return{id:e.id,label:e.label||e.objectName||e.dashboardName||e.pageName||e.reportName||``,href:n,type:e.type,description:e.description}}).filter(e=>e.href!==`#`)},[O,k,A?.id]),N=(0,C.useMemo)(()=>{if(!l.trim())return M;let e=l.toLowerCase();return M.filter(t=>t.label.toLowerCase().includes(e)||t.type.toLowerCase().includes(e)||t.description&&t.description.toLowerCase().includes(e))},[M,l]),P=e=>{m(e),o(e?{q:e}:{})},F=(0,C.useMemo)(()=>{let e={};for(let t of N)(e[t.type]||=[]).push(t);return e},[N]);return(0,w.jsxs)(`div`,{className:`flex flex-col gap-6 p-4 sm:p-6 max-w-4xl mx-auto`,children:[(0,w.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,w.jsxs)(n,{to:k,className:`flex items-center gap-1 text-sm text-muted-foreground hover:text-foreground transition-colors`,children:[(0,w.jsx)(u,{className:`h-4 w-4`}),e(`search.back`)]}),(0,w.jsx)(`h1`,{className:`text-xl font-semibold`,children:e(`search.title`)})]}),(0,w.jsxs)(`div`,{className:`relative`,children:[(0,w.jsx)(`label`,{htmlFor:`search-results-input`,className:`sr-only`,children:e(`search.placeholder`)}),(0,w.jsx)(d,{className:`absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground`,"aria-hidden":`true`}),(0,w.jsx)(h,{id:`search-results-input`,value:l,onChange:e=>P(e.target.value),placeholder:e(`search.placeholder`),className:`pl-10 h-11 text-base`,autoFocus:!0})]}),(0,w.jsx)(`div`,{className:`text-sm text-muted-foreground`,children:l.trim()?e(N.length===1?`search.resultsCount`:`search.resultsCountPlural`,{count:N.length,query:l}):e(`search.itemsAvailable`,{count:M.length})}),N.length===0?(0,w.jsxs)(`div`,{className:`flex flex-col items-center justify-center py-12 text-center`,children:[(0,w.jsx)(d,{className:`h-12 w-12 text-muted-foreground/30 mb-4`}),(0,w.jsx)(`p`,{className:`text-lg font-medium text-muted-foreground`,children:e(`search.noResults`)}),(0,w.jsx)(`p`,{className:`text-sm text-muted-foreground/80 mt-1`,children:e(`search.noResultsHint`)})]}):(0,w.jsx)(`div`,{className:`space-y-6`,children:Object.entries(F).map(([t,r])=>{let i=E[t]||v,a=`search.type${t.charAt(0).toUpperCase()}${t.slice(1)}s`;return`${t.charAt(0).toUpperCase()}${t.slice(1)}`,(0,w.jsxs)(`div`,{children:[(0,w.jsxs)(`h2`,{className:`text-sm font-medium text-muted-foreground mb-2 flex items-center gap-1.5`,children:[(0,w.jsx)(i,{className:`h-4 w-4`}),e(a),(0,w.jsx)(y,{variant:`secondary`,className:`ml-1 text-xs`,children:r.length})]}),(0,w.jsx)(`div`,{className:`grid gap-2`,children:r.map(t=>{let r=E[t.type]||v,i=`search.badge${t.type.charAt(0).toUpperCase()}${t.type.slice(1)}`;return(0,w.jsx)(n,{to:t.href,className:`rounded-lg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2`,children:(0,w.jsx)(g,{className:`hover:bg-accent/50 transition-colors cursor-pointer`,children:(0,w.jsxs)(p,{className:`flex items-center gap-3 p-3`,children:[(0,w.jsx)(`div`,{className:`flex h-8 w-8 items-center justify-center rounded ${D[t.type]||``}`,children:(0,w.jsx)(r,{className:`h-4 w-4`})}),(0,w.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,w.jsx)(`p`,{className:`text-sm font-medium truncate`,children:t.label}),t.description&&(0,w.jsx)(`p`,{className:`text-xs text-muted-foreground truncate`,children:t.description})]}),(0,w.jsx)(y,{variant:`outline`,className:`text-xs shrink-0`,children:e(i)})]})})},t.id)})})]},t)})})]})}export{S as t};
@@ -1 +1 @@
1
- import{o as e}from"./rolldown-runtime-DAXXjFlN.js";import{f as t,r as n,y as r}from"./vendor-react-BKSb6vFP.js";import{Bt as i,Oi as a,ar as o,ir as s,nr as c,rr as l,sr as u,tr as d}from"./ui-components-Y3D5-fgK.js";import{o as f,r as p,t as m}from"./types-033eBMjb.js";var h=e(r(),1),g=n();function _(){let e=t(),[n,r]=(0,h.useState)(null),[_,v]=(0,h.useState)(null);(0,h.useEffect)(()=>{p().then(e=>r(e.manifests??[])).catch(e=>v(e?.message??`Failed to load settings`))},[]);let y=(0,h.useMemo)(()=>{if(!n)return null;let e=new Map;for(let t of[...n].sort((e,t)=>(e.order??999)-(t.order??999))){let n=t.category??`Other`,r=e.get(n)??[];r.push(t),e.set(n,r)}return e},[n]);return(0,g.jsxs)(`div`,{className:`p-6 max-w-6xl mx-auto`,children:[(0,g.jsxs)(`div`,{className:`flex items-center gap-3 mb-6`,children:[(0,g.jsx)(a,{className:`h-7 w-7 text-muted-foreground`}),(0,g.jsxs)(`div`,{children:[(0,g.jsx)(`h1`,{className:`text-2xl font-semibold tracking-tight`,children:`Settings`}),(0,g.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Configure your workspace, integrations, and feature flags.`})]})]}),_?(0,g.jsx)(d,{children:(0,g.jsx)(c,{className:`py-8 text-center text-sm text-destructive`,children:_})}):null,n?n.length===0?(0,g.jsx)(d,{children:(0,g.jsx)(c,{className:`py-12 text-center text-sm text-muted-foreground`,children:`No settings registered. Plugins can register settings manifests via the SettingsService.`})}):Array.from(y??[]).map(([t,n])=>(0,g.jsxs)(`section`,{className:`mb-8`,children:[(0,g.jsx)(`h2`,{className:`text-sm font-semibold tracking-wide uppercase text-muted-foreground mb-3`,children:t}),(0,g.jsx)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4`,children:n.map(t=>(0,g.jsxs)(d,{className:`cursor-pointer hover:border-primary/50 hover:shadow-sm transition-all`,onClick:()=>e(`/system/settings/${t.namespace}`),children:[(0,g.jsxs)(s,{className:`pb-3`,children:[(0,g.jsxs)(`div`,{className:`flex items-start justify-between`,children:[(0,g.jsx)(t.icon?f(t.icon):a,{className:`h-6 w-6 text-muted-foreground`}),t.beta?(0,g.jsx)(u,{variant:`secondary`,className:`text-[10px]`,children:`Beta`}):null]}),(0,g.jsx)(o,{className:`text-base mt-2`,children:m(t.label)}),t.description?(0,g.jsx)(l,{className:`text-xs`,children:t.description}):null]}),(0,g.jsx)(c,{className:`pt-0`,children:(0,g.jsxs)(`div`,{className:`text-[11px] text-muted-foreground`,children:[t.specifiers.length,` setting`,t.specifiers.length===1?``:`s`]})})]},t.namespace))})]},t)):(0,g.jsxs)(`div`,{className:`space-y-4`,children:[(0,g.jsx)(i,{className:`h-6 w-32`}),(0,g.jsx)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4`,children:Array.from({length:3}).map((e,t)=>(0,g.jsx)(i,{className:`h-32 w-full`},t))})]})]})}export{_ as SettingsHub};
1
+ import{o as e}from"./rolldown-runtime-DAXXjFlN.js";import{f as t,r as n,y as r}from"./vendor-react-BKSb6vFP.js";import{Ut as i,ar as a,cr as o,ir as s,ji as c,or as l,sr as u,ur as d}from"./ui-components-CHaxvtjc.js";import{o as f,r as p,t as m}from"./types-C7NHW0h6.js";var h=e(r(),1),g=n();function _(){let e=t(),[n,r]=(0,h.useState)(null),[_,v]=(0,h.useState)(null);(0,h.useEffect)(()=>{p().then(e=>r(e.manifests??[])).catch(e=>v(e?.message??`Failed to load settings`))},[]);let y=(0,h.useMemo)(()=>{if(!n)return null;let e=new Map;for(let t of[...n].sort((e,t)=>(e.order??999)-(t.order??999))){let n=t.category??`Other`,r=e.get(n)??[];r.push(t),e.set(n,r)}return e},[n]);return(0,g.jsxs)(`div`,{className:`p-6 max-w-6xl mx-auto`,children:[(0,g.jsxs)(`div`,{className:`flex items-center gap-3 mb-6`,children:[(0,g.jsx)(c,{className:`h-7 w-7 text-muted-foreground`}),(0,g.jsxs)(`div`,{children:[(0,g.jsx)(`h1`,{className:`text-2xl font-semibold tracking-tight`,children:`Settings`}),(0,g.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Configure your workspace, integrations, and feature flags.`})]})]}),_?(0,g.jsx)(s,{children:(0,g.jsx)(a,{className:`py-8 text-center text-sm text-destructive`,children:_})}):null,n?n.length===0?(0,g.jsx)(s,{children:(0,g.jsx)(a,{className:`py-12 text-center text-sm text-muted-foreground`,children:`No settings registered. Plugins can register settings manifests via the SettingsService.`})}):Array.from(y??[]).map(([t,n])=>(0,g.jsxs)(`section`,{className:`mb-8`,children:[(0,g.jsx)(`h2`,{className:`text-sm font-semibold tracking-wide uppercase text-muted-foreground mb-3`,children:t}),(0,g.jsx)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4`,children:n.map(t=>(0,g.jsxs)(s,{className:`cursor-pointer hover:border-primary/50 hover:shadow-sm transition-all`,onClick:()=>e(`/system/settings/${t.namespace}`),children:[(0,g.jsxs)(u,{className:`pb-3`,children:[(0,g.jsxs)(`div`,{className:`flex items-start justify-between`,children:[(0,g.jsx)(t.icon?f(t.icon):c,{className:`h-6 w-6 text-muted-foreground`}),t.beta?(0,g.jsx)(d,{variant:`secondary`,className:`text-[10px]`,children:`Beta`}):null]}),(0,g.jsx)(o,{className:`text-base mt-2`,children:m(t.label)}),t.description?(0,g.jsx)(l,{className:`text-xs`,children:t.description}):null]}),(0,g.jsx)(a,{className:`pt-0`,children:(0,g.jsxs)(`div`,{className:`text-[11px] text-muted-foreground`,children:[t.specifiers.length,` setting`,t.specifiers.length===1?``:`s`]})})]},t.namespace))})]},t)):(0,g.jsxs)(`div`,{className:`space-y-4`,children:[(0,g.jsx)(i,{className:`h-6 w-32`}),(0,g.jsx)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4`,children:Array.from({length:3}).map((e,t)=>(0,g.jsx)(i,{className:`h-32 w-full`},t))})]})]})}export{_ as SettingsHub};
@@ -0,0 +1 @@
1
+ import{o as e}from"./rolldown-runtime-DAXXjFlN.js";import{f as t,m as n,r,y as i}from"./vendor-react-BKSb6vFP.js";import{$t as a,Ct as o,Ec as s,Er as c,Ga as l,Hi as u,Qt as d,Uc as f,Us as p,Ut as m,Wa as h,Xt as g,Zt as _,ar as v,en as y,fn as b,ft as x,gn as S,gr as C,hr as w,ir as T,mr as E,on as D,rr as O,sn as k,tn as A,uo as j,ur as M,wt as N}from"./ui-components-CHaxvtjc.js";import{r as P}from"./vendor-ui-utils-D-WJ115h.js";import{a as F,i as I,n as L,o as R,t as z}from"./types-C7NHW0h6.js";var B=e(i(),1),V=r();function H({reason:e,className:t}){return(0,V.jsxs)(M,{variant:`outline`,className:`gap-1 border-amber-300 bg-amber-50 text-amber-900 ${t??``}`,title:e??`Pinned by environment variable — cannot be edited from the UI.`,children:[(0,V.jsx)(h,{className:`h-3 w-3`}),`Locked by env`]})}function U({resolved:e,labels:t}){let n=e.cascadeChain;if(!n||n.length===0)return null;let r=n.find(e=>e.effective)??n[n.length-1],i=n.find(e=>e!==r&&e.value!==null&&e.value!==void 0),a=e=>t?.sourceLabel?.(e)??e;return r.scope!=="default"&&r.scope!==`user`&&r.scope!==`tenant`?(0,V.jsxs)(M,{variant:`outline`,className:`text-blue-700 border-blue-300 text-[10px]`,children:[`Inherited from `,a(r.scope)]}):i?(0,V.jsxs)(M,{variant:`outline`,className:`text-amber-700 border-amber-300 text-[10px]`,children:[`Overrides `,a(i.scope)]}):null}function W({spec:e,resolved:t,labelText:n,labels:r}){return(0,V.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,V.jsxs)(S,{className:`text-sm font-medium`,children:[n,e.required?(0,V.jsx)(`span`,{className:`ml-0.5 text-destructive`,children:`*`}):null]}),e.deprecated?(0,V.jsxs)(M,{variant:`outline`,className:`text-amber-700 border-amber-300`,children:[`Deprecated`,e.replacedBy?` → ${e.replacedBy}`:``]}):null,t?.locked?(0,V.jsx)(H,{reason:t.lockedReason}):null,t&&!t.locked?(0,V.jsx)(U,{resolved:t,labels:r}):null,t?.source&&t.source!=="default"&&!t.locked?(0,V.jsx)(`span`,{className:`text-[11px] text-muted-foreground`,children:r?.sourceLabel?.(t.source)??t.source}):null]})}function G({description:e}){return e?(0,V.jsx)(`p`,{className:`text-xs text-muted-foreground mt-1`,children:e}):null}function K(e){let{spec:t,resolved:n,value:r,onChange:i,onAction:s,locked:l,saving:u,labels:f}=e,m=(0,B.useId)(),h=!!(l||u),v=z(t.label),T=t.key&&f?f.fieldLabel(t.key,v):v,M=t.key&&f?f.fieldHelp(t.key,t.description):t.description;if(t.type===`group`){let e=t.id&&f?f.groupTitle(t.id,v):v,n=t.id&&f?f.groupDescription(t.id,t.description):t.description;return(0,V.jsxs)(`div`,{className:`pt-6 pb-2`,children:[(0,V.jsx)(`h3`,{className:`text-sm font-semibold tracking-tight text-foreground/90`,children:e}),n?(0,V.jsx)(`p`,{className:`text-xs text-muted-foreground mt-1`,children:n}):null,(0,V.jsx)(g,{className:`mt-3`})]})}if(t.type===`info_banner`)return(0,V.jsxs)(E,{variant:t.bannerSeverity===`error`?`destructive`:`default`,className:`my-2`,children:[(0,V.jsx)(j,{className:`h-4 w-4`}),(0,V.jsx)(C,{children:v}),t.bannerText?(0,V.jsx)(w,{children:t.bannerText}):null]});if(t.type===`child_pane`)return(0,V.jsxs)(`a`,{href:`#/settings/${t.childNamespace}`,className:`flex items-center justify-between rounded-md border border-border bg-card px-4 py-3 hover:bg-accent transition-colors`,children:[(0,V.jsxs)(`div`,{children:[(0,V.jsx)(`div`,{className:`text-sm font-medium`,children:v}),t.description?(0,V.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:t.description}):null]}),(0,V.jsx)(p,{className:`h-4 w-4 text-muted-foreground`})]});if(t.type===`title_value`)return(0,V.jsxs)(`div`,{className:`flex items-center justify-between py-2`,children:[(0,V.jsx)(W,{spec:t,resolved:n,labelText:T,labels:f}),(0,V.jsx)(`span`,{className:`text-sm text-muted-foreground`,children:String(r??`—`)})]});if(t.type===`action_button`){let e=t.icon?R(t.icon):null,n=t.id??t.key??`test`,r=f?f.actionLabel(n,v):v;return(0,V.jsxs)(`div`,{className:`flex items-center justify-between py-3`,children:[(0,V.jsxs)(`div`,{children:[(0,V.jsx)(`div`,{className:`text-sm font-medium`,children:r}),t.description?(0,V.jsx)(`p`,{className:`text-xs text-muted-foreground mt-1`,children:t.description}):null]}),(0,V.jsxs)(c,{size:`sm`,variant:`secondary`,onClick:s,disabled:u,children:[e?(0,V.jsx)(e,{className:`h-4 w-4 mr-1.5`}):null,r]})]})}let P=e=>(0,V.jsxs)(`div`,{className:`space-y-1.5 py-2`,children:[(0,V.jsx)(W,{spec:t,resolved:n,labelText:T,labels:f}),e,(0,V.jsx)(G,{description:M})]}),F=e=>{let n=typeof e.label==`string`?e.label:e.label?.defaultValue??String(e.value);return!t.key||!f?n:f.optionLabel(t.key,String(e.value),n)};switch(t.type){case`text`:case`email`:case`url`:case`phone`:return P((0,V.jsx)(b,{id:m,type:t.type===`email`?`email`:t.type===`url`?`url`:`text`,value:r??``,minLength:t.minLength,maxLength:t.maxLength,pattern:t.pattern,disabled:h,onChange:e=>i(e.target.value)}));case`password`:return P((0,V.jsx)(b,{id:m,type:`password`,autoComplete:`new-password`,placeholder:r?`••••••••`:``,disabled:h,onChange:e=>i(e.target.value)}));case`textarea`:return P((0,V.jsx)(x,{id:m,rows:t.rows??4,value:r??``,minLength:t.minLength,maxLength:t.maxLength,disabled:h,onChange:e=>i(e.target.value)}));case`number`:return P((0,V.jsx)(b,{id:m,type:`number`,value:r,min:t.min,max:t.max,step:t.step,disabled:h,onChange:e=>i(e.target.value===``?null:Number(e.target.value))}));case`toggle`:return(0,V.jsxs)(`div`,{className:`flex items-center justify-between py-3`,children:[(0,V.jsxs)(`div`,{children:[(0,V.jsx)(W,{spec:t,resolved:n,labelText:T,labels:f}),(0,V.jsx)(G,{description:M})]}),(0,V.jsx)(o,{id:m,checked:!!r,disabled:h,onCheckedChange:e=>i(e)})]});case`select`:return P((0,V.jsxs)(_,{value:r==null?void 0:String(r),onValueChange:e=>i(e),disabled:h,children:[(0,V.jsx)(y,{id:m,children:(0,V.jsx)(A,{placeholder:`Select…`})}),(0,V.jsx)(d,{children:t.options?.map(e=>(0,V.jsx)(a,{value:String(e.value),children:F(e)},String(e.value)))})]}));case`radio`:return P((0,V.jsx)(D,{value:r==null?void 0:String(r),onValueChange:e=>i(e),disabled:h,children:t.options?.map(e=>(0,V.jsxs)(`div`,{className:`flex items-center space-x-2`,children:[(0,V.jsx)(k,{value:String(e.value),id:`${m}-${e.value}`}),(0,V.jsx)(S,{htmlFor:`${m}-${e.value}`,className:`text-sm font-normal`,children:F(e)})]},String(e.value)))}));case`multiselect`:{let e=Array.isArray(r)?r:[];return P((0,V.jsx)(`div`,{className:`grid grid-cols-2 gap-2`,children:t.options?.map(t=>{let n=String(t.value);return(0,V.jsxs)(`label`,{className:`flex items-center gap-2 text-sm`,children:[(0,V.jsx)(O,{checked:e.map(String).includes(n),disabled:h,onCheckedChange:t=>{let r=new Set(e.map(String));t?r.add(n):r.delete(n),i(Array.from(r))}}),F(t)]},n)})}))}case`slider`:return P((0,V.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,V.jsx)(N,{value:[Number(r??t.min??0)],min:t.min??0,max:t.max??100,step:t.step??1,disabled:h,onValueChange:e=>i(e[0]),className:`flex-1`}),(0,V.jsx)(`span`,{className:`text-sm tabular-nums w-12 text-right`,children:String(r??t.min??0)})]}));case`color`:return P((0,V.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,V.jsx)(b,{id:m,type:`color`,value:r??`#000000`,disabled:h,onChange:e=>i(e.target.value),className:`w-16 h-9 p-1`}),(0,V.jsx)(b,{value:r??``,disabled:h,onChange:e=>i(e.target.value),className:`flex-1 font-mono text-sm`})]}));case`json`:return P((0,V.jsx)(x,{id:m,rows:t.rows??6,className:`font-mono text-xs`,value:typeof r==`string`?r:JSON.stringify(r??null,null,2),disabled:h,onChange:e=>i(e.target.value)}));default:return P((0,V.jsxs)(`div`,{className:`text-sm text-muted-foreground`,children:[`Unsupported specifier type: `,t.type]}))}}var q=new Set([`common`,`validation`,`errors`,`system`,`auth`]);function J(e){let{t,i18n:n}=f();return(0,B.useMemo)(()=>{let r=()=>{if(!n||typeof n.getResourceBundle!=`function`)return[];let e=n.language||`en`,t=n.getResourceBundle(e,`translation`);return t?Object.keys(t).filter(e=>!q.has(e)&&t[e]&&typeof t[e]==`object`&&t[e].settings):[]},i=(n,i)=>{if(!e)return i;try{let i=r();for(let r of i){let i=`${r}.settings.${e}.${n}`,a=t(i,{defaultValue:``});if(a&&a!==i&&a!==``)return a}}catch{}return i},a=(e,r)=>{try{if(!n||typeof n.getResourceBundle!=`function`)return r;let i=n.language||`en`,a=n.getResourceBundle(i,`translation`);if(!a)return r;for(let n of Object.keys(a)){if(q.has(n))continue;let r=a[n];if(!r||typeof r!=`object`||!(`settingsCommon`in r))continue;let i=`${n}.settingsCommon.${e}`,o=t(i,{defaultValue:``});if(o&&o!==i&&o!==``)return o}}catch{}return r},o={env:`Env`,global:`Global`,tenant:`Tenant`,user:`User`,default:`Default`};return{title:e=>i(`title`,e)??e,description:e=>i(`description`,e),groupTitle:(e,t)=>i(`groups.${e}.title`,t)??t,groupDescription:(e,t)=>i(`groups.${e}.description`,t),fieldLabel:(e,t)=>i(`keys.${e}.label`,t)??t,fieldHelp:(e,t)=>i(`keys.${e}.help`,t),fieldPlaceholder:(e,t)=>i(`keys.${e}.placeholder`,t),optionLabel:(e,t,n)=>i(`keys.${e}.options.${t}`,n)??n,actionLabel:(e,t)=>i(`actions.${e}.label`,t)??t,actionConfirm:(e,t)=>i(`actions.${e}.confirmText`,t),actionSuccess:(e,t)=>i(`actions.${e}.successMessage`,t),sourceLabel:e=>a(`sourceLabels.${e}`,o[e]??e)}},[e,t,n,n?.language])}function Y(e,t){if(!e)return!0;let n=e.trim().match(/^\$\{(.+)\}$/);if(!n)return!0;try{return!!Function(`data`,`with (data) { return (${n[1]}); }`)(t)}catch{return!0}}function X(){let e=n(),r=t(),i=e.namespace??``,[a,o]=(0,B.useState)(null),[d,f]=(0,B.useState)(!0),[p,h]=(0,B.useState)(!1),[g,_]=(0,B.useState)(null),[y,b]=(0,B.useState)({}),x=(0,B.useCallback)(async()=>{f(!0),_(null);try{let e=await L(i);o(e),b({})}catch(e){_(e?.message??`Failed to load settings`)}finally{f(!1)}},[i]);(0,B.useEffect)(()=>{i&&x()},[i,x]);let S=(0,B.useMemo)(()=>{let e={};if(!a)return e;for(let[t,n]of Object.entries(a.values))e[t]=n.value;return{...e,...y}},[a,y]),C=(0,B.useMemo)(()=>Object.keys(y),[y]),w=J(i);if(!i)return(0,V.jsx)(`div`,{className:`p-6 text-muted-foreground`,children:`No namespace selected.`});if(d)return(0,V.jsxs)(`div`,{className:`p-6 space-y-3 max-w-3xl`,children:[(0,V.jsx)(m,{className:`h-8 w-1/3`}),(0,V.jsx)(m,{className:`h-4 w-2/3`}),(0,V.jsx)(m,{className:`h-32 w-full`}),(0,V.jsx)(m,{className:`h-32 w-full`})]});if(g)return(0,V.jsxs)(`div`,{className:`p-6 max-w-3xl`,children:[(0,V.jsxs)(c,{variant:`ghost`,size:`sm`,onClick:()=>r(-1),children:[(0,V.jsx)(s,{className:`h-4 w-4 mr-1`}),` Back`]}),(0,V.jsx)(T,{className:`mt-3`,children:(0,V.jsx)(v,{className:`py-8 text-center text-sm text-destructive`,children:g})})]});if(!a)return null;let{manifest:E,values:D}=a,O=E.icon?R(E.icon):null,k=w.title(z(E.label)),A=w.description(E.description),j=async()=>{if(C.length!==0){h(!0);try{let e=await F(i,y);o({...a,values:{...D,...e.values}}),b({}),P.success(`Settings saved`)}catch(e){e?.payload?.error?.code===`SETTINGS_LOCKED`?P.error(`Locked by environment: ${e.payload.error.key}`):P.error(e?.message??`Save failed`)}finally{h(!1)}}},N=async e=>{h(!0);try{let t=await I(i,e,y);t.ok?P.success(t.message??`Action succeeded`):P.error(t.message??`Action failed`)}catch(e){P.error(e?.message??`Action failed`)}finally{h(!1)}};return(0,V.jsxs)(`div`,{className:`p-6 max-w-3xl mx-auto pb-32`,children:[(0,V.jsxs)(c,{variant:`ghost`,size:`sm`,onClick:()=>r(`/system/settings`),children:[(0,V.jsx)(s,{className:`h-4 w-4 mr-1`}),` All settings`]}),(0,V.jsxs)(`div`,{className:`mt-3 flex items-start gap-3`,children:[O?(0,V.jsx)(O,{className:`h-7 w-7 mt-0.5 text-muted-foreground`}):null,(0,V.jsxs)(`div`,{className:`flex-1`,children:[(0,V.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,V.jsx)(`h1`,{className:`text-2xl font-semibold tracking-tight`,children:k}),E.beta?(0,V.jsx)(M,{variant:`secondary`,children:`Beta`}):null]}),A?(0,V.jsx)(`p`,{className:`text-sm text-muted-foreground mt-1`,children:A}):null]})]}),E.helpText?(0,V.jsx)(`p`,{className:`text-sm text-muted-foreground mt-4 whitespace-pre-wrap`,children:E.helpText}):null,(0,V.jsx)(`div`,{className:`mt-6 divide-y`,children:E.specifiers.filter(e=>Y(e.visible,S)).map((e,t)=>{let n=e.key,r=n?D[n]:void 0;return(0,V.jsx)(K,{spec:e,resolved:r,value:n?n in y?y[n]:r?.value:void 0,onChange:e=>n&&b(t=>({...t,[n]:e})),onAction:e.type===`action_button`?()=>N(e.id??n??`test`):void 0,locked:r?.locked,saving:p,labels:w},(n??`_layout_${t}`)+t)})}),C.length>0?(0,V.jsx)(`div`,{className:`fixed bottom-0 inset-x-0 bg-background/95 backdrop-blur border-t shadow-lg z-40`,children:(0,V.jsxs)(`div`,{className:`max-w-3xl mx-auto px-6 py-3 flex items-center justify-between`,children:[(0,V.jsxs)(`div`,{className:`text-sm text-muted-foreground`,children:[C.length,` unsaved change`,C.length>1?`s`:``]}),(0,V.jsxs)(`div`,{className:`flex gap-2`,children:[(0,V.jsxs)(c,{variant:`ghost`,size:`sm`,onClick:()=>b({}),disabled:p,children:[(0,V.jsx)(u,{className:`h-4 w-4 mr-1`}),` Discard`]}),(0,V.jsxs)(c,{onClick:j,disabled:p,children:[p?(0,V.jsx)(l,{className:`h-4 w-4 mr-1 animate-spin`}):null,`Save changes`]})]})]})}):null]})}export{X as SettingsView};
@@ -1 +1 @@
1
- import{o as e}from"./rolldown-runtime-DAXXjFlN.js";import{f as t,m as n,r,y as i}from"./vendor-react-BKSb6vFP.js";import{f as a}from"./infrastructure-Bc4DRENl.js";import{L as o}from"./framework-BL3BtpKU.js";import{Ha as s,Mi as c,Oi as l,Qa as u,Rr as d,Si as f,ac as p,ar as m,ci as h,ec as g,ir as _,ni as v,nr as y,ro as b,rr as x,rs as S,sc as C,sr as w,tr as T,zr as E}from"./ui-components-Y3D5-fgK.js";import"./src-CQwyy7m_.js";var D=e(i(),1),O=r();function k(){let e=t(),{appName:r}=n(),i=r?`/apps/${r}`:``,k=o(),A=a(),[j,M]=(0,D.useState)({users:null,orgs:null,positions:null,permissions:null,auditLogs:null}),[N,P]=(0,D.useState)(!0),F=(0,D.useCallback)(async()=>{if(k){P(!0);try{let[e,t,n,r,i]=await Promise.all([k.find(`sys_user`).catch(()=>({data:[]})),k.find(`sys_org`).catch(()=>({data:[]})),k.find(`sys_position`).catch(()=>({data:[]})),k.find(`sys_permission`).catch(()=>({data:[]})),k.find(`sys_audit_log`).catch(()=>({data:[]}))]);M({users:e.data?.length??0,orgs:t.data?.length??0,positions:n.data?.length??0,permissions:r.data?.length??0,auditLogs:i.data?.length??0})}catch{}finally{P(!1)}}},[k]);(0,D.useEffect)(()=>{F()},[F]);let I=[{title:`Applications`,description:`Manage all configured applications`,icon:u,href:`${i}/system/apps`,countLabel:``,count:null},{title:`Metadata`,description:`Browse and edit every metadata type the platform exposes`,icon:S,href:`${i}/component/metadata/directory`,countLabel:``,count:null},{title:`Datasources`,description:`Connect external databases and sync their tables in as objects`,icon:p,href:`${i}/component/metadata/resource?type=datasource`,countLabel:``,count:null}],L=[{title:`Users`,description:`Manage system users and accounts`,icon:d,href:`${i}/system/users`,countLabel:`users`,count:j.users},{title:`Organizations`,description:`Manage organizations and teams`,icon:g,href:`${i}/system/organizations`,countLabel:`organizations`,count:j.orgs},{title:`Positions`,description:`Configure positions and access levels`,icon:f,href:`${i}/system/positions`,countLabel:`positions`,count:j.positions},{title:`Permissions`,description:`Manage permission rules and assignments`,icon:b,href:`${i}/system/permissions`,countLabel:`permissions`,count:j.permissions},{title:`Audit Log`,description:`View system activity and changes`,icon:c,href:`${i}/system/audit-log`,countLabel:`entries`,count:j.auditLogs},{title:`AI Approvals`,description:`Review actions AI agents propose before they execute`,icon:C,href:`${i}/system/ai-approvals`,countLabel:``,count:null},{title:`App Marketplace`,description:`Browse and install approved apps from the ObjectStack catalog`,icon:h,href:`${i}/system/marketplace`,countLabel:``,count:null,adminOnly:!0},{title:`Settings`,description:`Configure mail, branding, feature flags, and more`,icon:l,href:`${i}/system/settings`,countLabel:``,count:null},{title:`Developer`,description:`API console, flow runs, and public form management`,icon:v,href:`${i}/developer`,countLabel:``,count:null},{title:`Profile`,description:`View and edit your account settings`,icon:E,href:`${i}/system/profile`,countLabel:``,count:null}],R=[...I,...L].filter(e=>!e.adminOnly||A);return(0,O.jsxs)(`div`,{className:`flex flex-col gap-6 p-4 sm:p-6`,children:[(0,O.jsxs)(`div`,{className:`min-w-0`,children:[(0,O.jsx)(`h1`,{className:`text-xl sm:text-2xl font-bold tracking-tight`,children:`System Settings`}),(0,O.jsx)(`p`,{className:`text-sm text-muted-foreground mt-1`,children:`Manage applications, users, positions, permissions, and system configuration`})]}),N&&(0,O.jsxs)(`div`,{className:`flex items-center gap-2 text-sm text-muted-foreground`,role:`status`,"aria-live":`polite`,children:[(0,O.jsx)(s,{className:`h-4 w-4 animate-spin`,"aria-hidden":`true`}),`Loading statistics...`]}),(0,O.jsx)(`div`,{className:`grid gap-4 sm:grid-cols-2 lg:grid-cols-3`,children:R.map(t=>{let n=t.icon;return(0,O.jsxs)(T,{className:`cursor-pointer transition-colors hover:bg-accent/50`,onClick:()=>e(t.href),"data-testid":`hub-card-${t.title.toLowerCase().replace(/\s+/g,`-`)}`,role:`link`,tabIndex:0,"aria-label":`${t.title}: ${t.description}`,onKeyDown:n=>{(n.key===`Enter`||n.key===` `)&&(n.preventDefault(),e(t.href))},children:[(0,O.jsxs)(_,{className:`flex flex-row items-center gap-3 pb-2`,children:[(0,O.jsx)(`div`,{className:`flex h-10 w-10 shrink-0 items-center justify-center rounded-lg bg-primary/10 text-primary`,children:(0,O.jsx)(n,{className:`h-5 w-5`})}),(0,O.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,O.jsx)(m,{className:`text-base`,children:t.title}),(0,O.jsx)(x,{className:`text-xs`,children:t.description})]})]}),(0,O.jsx)(y,{className:`pt-0`,children:t.count!==null&&(0,O.jsxs)(w,{variant:`secondary`,children:[t.count,` `,t.countLabel]})})]},t.title)})})]})}export{k as SystemHubPage};
1
+ import{o as e}from"./rolldown-runtime-DAXXjFlN.js";import{f as t,m as n,r,y as i}from"./vendor-react-BKSb6vFP.js";import{f as a}from"./infrastructure-1EBA2wrr.js";import{O as o}from"./framework-CavAJOoG.js";import{Fi as s,Ga as c,Hr as l,Ti as u,Vr as d,ai as f,ar as p,cr as m,dc as h,di as g,ic as _,ir as v,ji as y,lc as b,oo as x,or as S,sr as C,ss as w,to as T,ur as E}from"./ui-components-CHaxvtjc.js";import"./src-DXuM24AK.js";var D=e(i(),1),O=r();function k(){let e=t(),{appName:r}=n(),i=r?`/apps/${r}`:``,k=o(),A=a(),[j,M]=(0,D.useState)({users:null,orgs:null,positions:null,permissions:null,auditLogs:null}),[N,P]=(0,D.useState)(!0),F=(0,D.useCallback)(async()=>{if(k){P(!0);try{let[e,t,n,r,i]=await Promise.all([k.find(`sys_user`).catch(()=>({data:[]})),k.find(`sys_org`).catch(()=>({data:[]})),k.find(`sys_position`).catch(()=>({data:[]})),k.find(`sys_permission`).catch(()=>({data:[]})),k.find(`sys_audit_log`).catch(()=>({data:[]}))]);M({users:e.data?.length??0,orgs:t.data?.length??0,positions:n.data?.length??0,permissions:r.data?.length??0,auditLogs:i.data?.length??0})}catch{}finally{P(!1)}}},[k]);(0,D.useEffect)(()=>{F()},[F]);let I=[{title:`Applications`,description:`Manage all configured applications`,icon:T,href:`${i}/system/apps`,countLabel:``,count:null},{title:`Metadata`,description:`Browse and edit every metadata type the platform exposes`,icon:w,href:`${i}/component/metadata/directory`,countLabel:``,count:null},{title:`Datasources`,description:`Connect external databases and sync their tables in as objects`,icon:b,href:`${i}/component/metadata/resource?type=datasource`,countLabel:``,count:null}],L=[{title:`Users`,description:`Manage system users and accounts`,icon:d,href:`${i}/system/users`,countLabel:`users`,count:j.users},{title:`Organizations`,description:`Manage organizations and teams`,icon:_,href:`${i}/system/organizations`,countLabel:`organizations`,count:j.orgs},{title:`Positions`,description:`Configure positions and access levels`,icon:u,href:`${i}/system/positions`,countLabel:`positions`,count:j.positions},{title:`Permissions`,description:`Manage permission rules and assignments`,icon:x,href:`${i}/system/permissions`,countLabel:`permissions`,count:j.permissions},{title:`Audit Log`,description:`View system activity and changes`,icon:s,href:`${i}/system/audit-log`,countLabel:`entries`,count:j.auditLogs},{title:`AI Approvals`,description:`Review actions AI agents propose before they execute`,icon:h,href:`${i}/system/ai-approvals`,countLabel:``,count:null},{title:`App Marketplace`,description:`Browse and install approved apps from the ObjectStack catalog`,icon:g,href:`${i}/system/marketplace`,countLabel:``,count:null,adminOnly:!0},{title:`Settings`,description:`Configure mail, branding, feature flags, and more`,icon:y,href:`${i}/system/settings`,countLabel:``,count:null},{title:`Developer`,description:`API console, flow runs, and public form management`,icon:f,href:`${i}/developer`,countLabel:``,count:null},{title:`Profile`,description:`View and edit your account settings`,icon:l,href:`${i}/system/profile`,countLabel:``,count:null}],R=[...I,...L].filter(e=>!e.adminOnly||A);return(0,O.jsxs)(`div`,{className:`flex flex-col gap-6 p-4 sm:p-6`,children:[(0,O.jsxs)(`div`,{className:`min-w-0`,children:[(0,O.jsx)(`h1`,{className:`text-xl sm:text-2xl font-bold tracking-tight`,children:`System Settings`}),(0,O.jsx)(`p`,{className:`text-sm text-muted-foreground mt-1`,children:`Manage applications, users, positions, permissions, and system configuration`})]}),N&&(0,O.jsxs)(`div`,{className:`flex items-center gap-2 text-sm text-muted-foreground`,role:`status`,"aria-live":`polite`,children:[(0,O.jsx)(c,{className:`h-4 w-4 animate-spin`,"aria-hidden":`true`}),`Loading statistics...`]}),(0,O.jsx)(`div`,{className:`grid gap-4 sm:grid-cols-2 lg:grid-cols-3`,children:R.map(t=>{let n=t.icon;return(0,O.jsxs)(v,{className:`cursor-pointer transition-colors hover:bg-accent/50`,onClick:()=>e(t.href),"data-testid":`hub-card-${t.title.toLowerCase().replace(/\s+/g,`-`)}`,role:`link`,tabIndex:0,"aria-label":`${t.title}: ${t.description}`,onKeyDown:n=>{(n.key===`Enter`||n.key===` `)&&(n.preventDefault(),e(t.href))},children:[(0,O.jsxs)(C,{className:`flex flex-row items-center gap-3 pb-2`,children:[(0,O.jsx)(`div`,{className:`flex h-10 w-10 shrink-0 items-center justify-center rounded-lg bg-primary/10 text-primary`,children:(0,O.jsx)(n,{className:`h-5 w-5`})}),(0,O.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,O.jsx)(m,{className:`text-base`,children:t.title}),(0,O.jsx)(S,{className:`text-xs`,children:t.description})]})]}),(0,O.jsx)(p,{className:`pt-0`,children:t.count!==null&&(0,O.jsxs)(E,{variant:`secondary`,children:[t.count,` `,t.countLabel]})})]},t.title)})})]})}export{k as SystemHubPage};