@objectstack/console 17.0.0-rc.4 → 17.0.0-rc.5

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 (97) hide show
  1. package/CHANGELOG.md +20 -0
  2. package/dist/.objectui-sha +1 -1
  3. package/dist/assets/AdapterProvider-D5_dIBsl.js +2 -0
  4. package/dist/assets/{AiPendingActionsPage-UIynjb20.js → AiPendingActionsPage-CVC7LIfi.js} +1 -1
  5. package/dist/assets/{ApiConsolePage-B7CzUZnr.js → ApiConsolePage-CpDU7ooT.js} +1 -1
  6. package/dist/assets/{AppDocsIndex-DUsMqAwN.js → AppDocsIndex-DFMKKZm6.js} +1 -1
  7. package/dist/assets/{AppManagementPage-DJ6118-F.js → AppManagementPage-Cot1HC5W.js} +1 -1
  8. package/dist/assets/{ApprovalsInboxPage-CTVm3l-x.js → ApprovalsInboxPage-ruj1cfw8.js} +1 -1
  9. package/dist/assets/{AuditLogPage-Riqi0U7P.js → AuditLogPage-QwYEUDC7.js} +1 -1
  10. package/dist/assets/{ComponentNavView-B2otfGZ7.js → ComponentNavView-BzOXbmFy.js} +1 -1
  11. package/dist/assets/{CreateViewDialog-z6h6V9xj.js → CreateViewDialog-DZQW3zK4.js} +1 -1
  12. package/dist/assets/{DashboardView-6_sxqUcT.js → DashboardView-CWd5f0LK.js} +1 -1
  13. package/dist/assets/{DeveloperHubPage-NbNGfp6j.js → DeveloperHubPage-CdgOf6lM.js} +1 -1
  14. package/dist/assets/{DocShell-DvmmtwpW.js → DocShell-BAMZcj4T.js} +1 -1
  15. package/dist/assets/{ExpressionProvider-_qLpGaJS.js → ExpressionProvider-BKktrnvG.js} +1 -1
  16. package/dist/assets/{FlowRunsPage-ZTpe0n1O.js → FlowRunsPage-Cr-PKPag.js} +1 -1
  17. package/dist/assets/{IntegrationsPage-DMuzWjMr.js → IntegrationsPage-CmkmHyHB.js} +2 -2
  18. package/dist/assets/{InterfaceListPage-BHcPP_6g.js → InterfaceListPage-Bf9_sd45.js} +1 -1
  19. package/dist/assets/{ManagedByBadge-DNLmY8V4.js → ManagedByBadge-BPiPq6-K.js} +1 -1
  20. package/dist/assets/{MarketplaceAccessDenied-Drlrrrd9.js → MarketplaceAccessDenied-DQYD2Yla.js} +1 -1
  21. package/dist/assets/{MarketplaceInstalledPage-CYP2CaJz.js → MarketplaceInstalledPage-BvHt07_e.js} +1 -1
  22. package/dist/assets/{MarketplacePackagePage-DZwFKOQv.js → MarketplacePackagePage-Duz9UzE3.js} +2 -2
  23. package/dist/assets/{MarketplacePage-XU0PQLAW.js → MarketplacePage-BfYSidiA.js} +1 -1
  24. package/dist/assets/{MetadataInspector-CoxLxxKN.js → MetadataInspector-DZP7_4Ng.js} +1 -1
  25. package/dist/assets/{MetadataProvider-DJXxy8nz.js → MetadataProvider-C5EAtW6M.js} +1 -1
  26. package/dist/assets/{ObjectDataPage-CHRZduUP.js → ObjectDataPage-EBvhhSu8.js} +1 -1
  27. package/dist/assets/{PageView-D27Yy4W9.js → PageView-DHw-8JWT.js} +1 -1
  28. package/dist/assets/{ProfilePage-09XXYshY.js → ProfilePage-BFO0o43s.js} +1 -1
  29. package/dist/assets/{PublicFormsPage-O8fm4eBn.js → PublicFormsPage-3RTLTTOX.js} +1 -1
  30. package/dist/assets/RecordDetailView-D6YP24Fu.js +9 -0
  31. package/dist/assets/RecordFormPage-CEuXajud.js +1 -0
  32. package/dist/assets/ReportDefaultInspector-CoVDiePd.js +3 -0
  33. package/dist/assets/{ReportView-CwCw4i27.js → ReportView-DU1WEs9f.js} +1 -1
  34. package/dist/assets/{SearchResultsPage-I8ngrVdn.js → SearchResultsPage-BaK92Vl2.js} +1 -1
  35. package/dist/assets/{SettingsHub-BY_utblN.js → SettingsHub-BkazZzY4.js} +1 -1
  36. package/dist/assets/{SettingsView-DNKEl-i-.js → SettingsView-BxS4_zm8.js} +1 -1
  37. package/dist/assets/{SystemHubPage-WWns1vXN.js → SystemHubPage-CwaVpP2G.js} +1 -1
  38. package/dist/assets/{createDerive-CsNhKPNT.js → createDerive-CeHn9TlT.js} +1 -1
  39. package/dist/assets/data-adapter-BbwX3ocs.js +32 -0
  40. package/dist/assets/framework-Dk4iu8ZK.js +8 -0
  41. package/dist/assets/{getIcon-CQlbi2Hn.js → getIcon-0xu011em.js} +1 -1
  42. package/dist/assets/{highlighted-body-OFNGDK62-0kvj_GdK.js → highlighted-body-OFNGDK62-DaX2t0Np.js} +1 -1
  43. package/dist/assets/{i18n-BFepWCa9.js → i18n-BqOg8Sj-.js} +1 -1
  44. package/dist/assets/index-QGTHTleH.js +2 -0
  45. package/dist/assets/{infrastructure-BKCMsWnH.js → infrastructure-V4ehxh8R.js} +1 -1
  46. package/dist/assets/mermaid-GHXKKRXX-DhkyRE-b.js +1 -0
  47. package/dist/assets/metadata-admin-CngSCs9l.js +25 -0
  48. package/dist/assets/plugin-calendar-BhbFZ1Dz.js +1 -0
  49. package/dist/assets/plugin-charts-DCnTkboW.js +7 -0
  50. package/dist/assets/plugin-chatbot-Cxk2I5E2.js +120 -0
  51. package/dist/assets/plugin-dashboard-Cc5zXaJZ.js +6 -0
  52. package/dist/assets/plugin-form-BPgojUr9.js +1 -0
  53. package/dist/assets/plugin-gantt-D5_Cski-.js +63 -0
  54. package/dist/assets/plugin-grid-DOeo-xLc.js +8 -0
  55. package/dist/assets/plugin-kanban-DO8gBhwP.js +1 -0
  56. package/dist/assets/{plugin-map-zu5SGrw4.js → plugin-map-Ob_kDGyN.js} +1 -1
  57. package/dist/assets/{plugin-markdown-BqKwZink.js → plugin-markdown-mn_FYkeV.js} +1 -1
  58. package/dist/assets/plugin-report-DVVwWMiU.js +59 -0
  59. package/dist/assets/{plugin-timeline-sB_LQnGB.js → plugin-timeline-rzVARN_g.js} +1 -1
  60. package/dist/assets/{plugin-tree-CHZ2Wjl4.js → plugin-tree-BjFac627.js} +1 -1
  61. package/dist/assets/plugin-view-DA6WPNHK.js +1 -0
  62. package/dist/assets/plugins-views-wOHCrjrA.js +4 -0
  63. package/dist/assets/{runtime-metadata-persistence-TwDeIZza.js → runtime-metadata-persistence-DrONSJyN.js} +1 -1
  64. package/dist/assets/{skeletons-BZIrujxl.js → skeletons-D41oCKnf.js} +1 -1
  65. package/dist/assets/src-DGFWwOg3.js +1 -0
  66. package/dist/assets/{src-Boqr2A0h.js → src-aYMNjfWn.js} +1 -1
  67. package/dist/assets/src-rZhRmjZV.js +19 -0
  68. package/dist/assets/ui-components-BioReIdK.js +72 -0
  69. package/dist/assets/ui-layout-CSKVB0dn.js +1 -0
  70. package/dist/assets/{use-book-data-BIflvfeG.js → use-book-data-DoM93RB0.js} +1 -1
  71. package/dist/assets/{useSettingsLabel-CeykvoQ_.js → useSettingsLabel-JZ_zJ7Ow.js} +1 -1
  72. package/dist/index.html +3 -3
  73. package/package.json +1 -1
  74. package/dist/assets/AdapterProvider-BJ47DW1h.js +0 -2
  75. package/dist/assets/RecordDetailView-aOOCQH95.js +0 -9
  76. package/dist/assets/RecordFormPage-oqNb9asS.js +0 -1
  77. package/dist/assets/ReportDefaultInspector-Bo94YiWL.js +0 -3
  78. package/dist/assets/data-adapter-Bh8GerYu.js +0 -32
  79. package/dist/assets/framework-s0wcPYfi.js +0 -8
  80. package/dist/assets/index-CB0grcA9.js +0 -2
  81. package/dist/assets/mermaid-GHXKKRXX-CI_uxHoC.js +0 -1
  82. package/dist/assets/metadata-admin-CApOhXis.js +0 -25
  83. package/dist/assets/plugin-calendar-BOjBc2zc.js +0 -1
  84. package/dist/assets/plugin-charts-Bk48oCaW.js +0 -7
  85. package/dist/assets/plugin-chatbot-CEj8h-9I.js +0 -120
  86. package/dist/assets/plugin-dashboard-B0k1x0iX.js +0 -6
  87. package/dist/assets/plugin-form-B_6Tki5r.js +0 -1
  88. package/dist/assets/plugin-gantt-va3r2kNG.js +0 -63
  89. package/dist/assets/plugin-grid-C0rE_dCh.js +0 -8
  90. package/dist/assets/plugin-kanban-BhzMbWNL.js +0 -1
  91. package/dist/assets/plugin-report-DOylY2iS.js +0 -59
  92. package/dist/assets/plugin-view-DoxfBkwY.js +0 -1
  93. package/dist/assets/plugins-views-DoZ6BQOM.js +0 -4
  94. package/dist/assets/src--uGAhLxY.js +0 -19
  95. package/dist/assets/src-t-RiW1Dw.js +0 -1
  96. package/dist/assets/ui-components-BFOT5Gog.js +0 -72
  97. package/dist/assets/ui-layout-D4KJD2jH.js +0 -1
@@ -1,8 +0,0 @@
1
- import{i as e,o as t,t as n}from"./rolldown-runtime-C0FnF6B9.js";import{r,y as i}from"./vendor-react-DpRf6e0g.js";import{D as a,f as o,m as s,v as c,z as l}from"./vendor-objectstack-Dm5CaPeY.js";var u=`object-grid.list-view.object-form.embeddable-form.object-master-detail-form.object-kanban.object-calendar.object-gantt.object-timeline.object-map.object-metric.object-chart.dashboard.object-pivot.record:details.record:highlights.record:related_list.record:path.record:line_items.record:activity.record:discussion.record:history.record:quick_actions.record:reference_rail.record:alert.page:tabs.page:card.page:accordion.page:section.page:footer.page:sidebar.element:text.element:number.element:button.element:definition-list.element:repeater.action:button.action:group.action:menu.action:icon.flex.grid.stack.card.tabs.accordion.container.page:header.text.image.icon.markdown.element:divider.badge.alert.button.html`.split(`.`);new Set(u);var d=new class{components=new Map;lazyEntries=new Map;listeners=new Set;version=0;register(e,t,n){let r=n?.namespace?`${n.namespace}:${e}`:e;if(n?.namespace||console.warn(`Registering component "${e}" without a namespace is deprecated. Please provide a namespace in the meta parameter.\n\n Migration:\n // Before (deprecated):\n registry.register('${e}', MyComponent);\n\n // After:\n registry.register('${e}', MyComponent, { namespace: 'my-plugin' });\n\n See: https://github.com/objectstack-ai/objectui/blob/main/MIGRATION_GUIDE.md`),this.components.has(r),this.components.set(r,{type:r,component:t,...n}),n?.namespace&&!n?.skipFallback){let i=this.components.get(e);i&&i.component!==t&&i.type!==r&&console.warn(`Component "${e}" bare-name fallback is being overwritten by "${r}". If this is intentional keep going; otherwise register "${r}" with { skipFallback: true } so it doesn't claim the bare "${e}" key.`),this.components.set(e,{type:r,component:t,...n})}this.lazyEntries.delete(r),this.lazyEntries.delete(e),this.notify()}unregister(e,t){let n=t?`${t}:${e}`:e,r=this.components.delete(n);if(t){let t=this.components.get(e);t&&t.type===n&&this.components.delete(e)}return this.lazyEntries.delete(n),this.lazyEntries.delete(e),r&&this.notify(),r}registerLazy(e,t,n){let r=n?.namespace?`${n.namespace}:${e}`:e,i={loader:t,meta:n};this.lazyEntries.set(r,i),n?.namespace&&!n?.skipFallback&&this.lazyEntries.set(e,i),this.version++}hasLazy(e,t){return t?this.lazyEntries.has(`${t}:${e}`):this.lazyEntries.has(e)}loadLazy(e,t){let n=t?`${t}:${e}`:e,r=this.lazyEntries.get(n);if(r)return r.pending||=r.loader().catch(e=>{throw r.pending=void 0,e}),r.pending}subscribe(e){return this.listeners.add(e),()=>{this.listeners.delete(e)}}notify(){this.version++;for(let e of this.listeners)try{e()}catch(e){console.error(`[Registry] listener error`,e)}}getVersion(){return this.version}get(e,t){if(t){let n=`${t}:${e}`;return this.components.get(n)?.component}return this.components.get(e)?.component}getConfig(e,t){if(t){let n=`${t}:${e}`;return this.components.get(n)}return this.components.get(e)}has(e,t){if(t){let n=`${t}:${e}`;return this.components.has(n)}return this.components.has(e)}getAllTypes(){return Array.from(this.components.keys())}getKnownTypes(){return Array.from(new Set([...this.components.keys(),...this.lazyEntries.keys()]))}getMeta(e,t){let n=t?`${t}:${e}`:e;return this.components.get(n)??this.lazyEntries.get(n)?.meta}getAllConfigs(){return Array.from(this.components.values())}getContractConfig(e){let t=this.components.get(e);if(t)return t;let n=this.lazyEntries.get(e);if(!n)return;let r=n.meta?.namespace,i=r&&!e.startsWith(`${r}:`)?`${r}:${e}`:e;return{...n.meta,type:i,lazy:!0}}getPublicConfigs(){let e=new Set,t=[],n=(n,r)=>{!r||e.has(r.type)||(e.add(r.type),t.push({...r,type:n}))};for(let e of u)n(e,this.getContractConfig(e));for(let[e,t]of this.components.entries())t.tier===`public`&&!e.includes(`:`)&&n(e,t);for(let[e,t]of this.lazyEntries.entries())t.meta?.tier===`public`&&!e.includes(`:`)&&n(e,this.getContractConfig(e));return t}getNamespaceComponents(e){return Array.from(this.components.values()).filter(t=>t.namespace===e)}};function f(e){return e==null||typeof e==`string`&&e.trim()===``||Array.isArray(e)&&e.length===0}var p={type:{required:!0,validate:e=>typeof e==`string`&&e.length>0,message:`type must be a non-empty string`},id:{required:!1,validate:e=>typeof e==`string`,message:`id must be a string`},className:{required:!1,validate:e=>typeof e==`string`,message:`className must be a string`},visible:{required:!1,validate:e=>typeof e==`boolean`,message:`visible must be a boolean`},disabled:{required:!1,validate:e=>typeof e==`boolean`,message:`disabled must be a boolean`}};function m(e,t=`schema`){let n=[];return!e||typeof e!=`object`?(n.push({path:t,message:`Schema must be an object`,type:`error`,code:`INVALID_SCHEMA`}),n):(Object.entries(p).forEach(([r,i])=>{let a=e[r];i.required&&a===void 0&&n.push({path:`${t}.${r}`,message:`${r} is required`,type:`error`,code:`MISSING_REQUIRED`}),a!==void 0&&!i.validate(a)&&n.push({path:`${t}.${r}`,message:i.message,type:`error`,code:`INVALID_TYPE`})}),n)}function h(e,t=`schema`){let n=[];return e.type===`crud`&&((!e.columns||!Array.isArray(e.columns))&&n.push({path:`${t}.columns`,message:`CRUD schema requires columns array`,type:`error`,code:`MISSING_COLUMNS`}),!e.api&&!e.dataSource&&n.push({path:`${t}.api`,message:`CRUD schema requires api or dataSource`,type:`warning`,code:`MISSING_DATA_SOURCE`}),e.columns&&Array.isArray(e.columns)&&e.columns.forEach((e,r)=>{e.name||n.push({path:`${t}.columns[${r}]`,message:`Column requires name property`,type:`error`,code:`MISSING_COLUMN_NAME`})}),e.fields&&Array.isArray(e.fields)&&e.fields.forEach((e,r)=>{e.name||n.push({path:`${t}.fields[${r}]`,message:`Field requires name property`,type:`error`,code:`MISSING_FIELD_NAME`})})),n}function g(e,t=`schema`){let n=[];return e.type===`form`&&e.fields&&Array.isArray(e.fields)&&e.fields.forEach((r,i)=>{r.name||n.push({path:`${t}.fields[${i}]`,message:`Form field requires name property`,type:`error`,code:`MISSING_FIELD_NAME`}),e.fields.filter(e=>e.name===r.name).length>1&&n.push({path:`${t}.fields[${i}]`,message:`Duplicate field name: ${r.name}`,type:`warning`,code:`DUPLICATE_FIELD_NAME`})}),n}function _(e,t=`schema`){let n=[],r=e.children||e.body;if(r){if(Array.isArray(r))r.forEach((e,r)=>{if(typeof e==`object`&&e){let i=v(e,`${t}.children[${r}]`);n.push(...i.errors,...i.warnings)}});else if(typeof r==`object`&&r){let e=v(r,`${t}.children`);n.push(...e.errors,...e.warnings)}}return n}function v(e,t=`schema`){let n=[];n.push(...m(e,t)),n.push(...h(e,t)),n.push(...g(e,t)),n.push(..._(e,t));let r=n.filter(e=>e.type===`error`),i=n.filter(e=>e.type===`warning`);return{valid:r.length===0,errors:r,warnings:i}}var y=class extends Error{code=`INVALID_FILTER`;httpStatus=400;constructor(e){super(e),this.name=`FilterOperatorError`}};function b(e){return{$eq:`=`,$ne:`!=`,$gt:`>`,$gte:`>=`,$lt:`<`,$lte:`<=`,$in:`in`,$nin:`nin`,$notin:`nin`,$between:`between`,$contains:`contains`,$notContains:`notcontains`,$notcontains:`notcontains`,$startsWith:`startswith`,$startswith:`startswith`,$endsWith:`endswith`,$endswith:`endswith`}[e]||null}function x(e){let t=[];for(let[n,r]of Object.entries(e))if(r!=null)if(typeof r==`object`&&!Array.isArray(r))for(let[e,i]of Object.entries(r)){if(e===`$regex`)throw new y(`[ObjectUI] The '\$regex' filter operator is not supported. It used to be converted to 'contains', which matches a literal substring rather than a pattern — a different result, not a degraded one. Field: '${n}', Value: ${JSON.stringify(i)}. Use $contains, $startsWith or $endsWith.`);if(e===`$null`){t.push([n,i?`is_null`:`is_not_null`,!0]);continue}if(e===`$exists`){t.push([n,i?`is_not_null`:`is_null`,!0]);continue}let r=b(e);if(r)t.push([n,r,i]);else throw new y(`[ObjectUI] Unknown filter operator '${e}' for field '${n}'. Supported operators: $eq, $ne, $gt, $gte, $lt, $lte, $in, $nin, $between, $contains, $notContains, $startsWith, $endsWith, $null, $exists. If you need exact object matching, use the value directly without an operator.`)}else t.push([n,`=`,r]);return t.length===0?e:t.length===1?t[0]:[`and`,...t]}function S(e){if(typeof e!=`object`||!e||Array.isArray(e))return!1;let t=e.field;return typeof t==`string`&&t!==``}function ee(e){let t=l(e.operator);return e.value===void 0?[e.field,t]:[e.field,t,e.value]}function te(e){if(e==null)return;if(Array.isArray(e))return e.length===0?void 0:e.some(S)?e.map(e=>S(e)?ee(e):e):e;if(typeof e!=`object`)return;let t=e;if(Object.keys(t).length!==0)return x(t)}function ne(...e){let t=e.map(te).filter(e=>e!==void 0);if(t.length!==0)return t.length===1?t[0]:[`and`,...t]}function re(e,t){if(e==null)return{enabled:t};if(typeof e==`boolean`)return{enabled:e};let n=e.enabled??t;if(e.visibleWhen==null&&e.disabledWhen==null)return{enabled:n};let r={};return e.visibleWhen!=null&&(r.visibleWhen=e.visibleWhen),e.disabledWhen!=null&&(r.disabledWhen=e.disabledWhen),{enabled:n,predicates:r}}function ie(e){return re(e,!1).predicates}var ae={create:`create`,import:`import`,edit:`update`,delete:`delete`,exportCsv:`export`};function C(e,t){let n=a({managedBy:e?.managedBy??void 0,userActions:e?.userActions??void 0});if(Array.isArray(t)){let e=new Set(t);for(let[t,r]of Object.entries(ae))n[t]&&!e.has(r)&&(n[t]=!1)}return n}function oe(e,t){return C(e,t).edit}function se(e){if(Array.isArray(e))return e;if(e&&typeof e==`object`){if(Array.isArray(e.records))return e.records;if(Array.isArray(e.data))return e.data;if(Array.isArray(e.value))return e.value}return[]}var w=`field`,T=[`name`,`fieldName`],ce=e=>!!e&&typeof e==`object`&&!Array.isArray(e),le=e=>typeof e==`string`&&e.length>0?e:void 0;function E(e){if(typeof e==`string`)return le(e);if(!ce(e))return;let t=le(e[w]);if(t)return t;for(let t of T){let n=le(e[t]);if(n)return n}}var D=new Set,O=()=>!1;function ue(e,t,n){if(!(!O()||n.length===0))for(let r of n){let n=`${t}:${r}:${String(e[r])}`;D.has(n)||(D.add(n),console.warn(`[ObjectUI] Column carries two identities: \`${w}: '${t}'\` and \`${r}: '${String(e[r])}'\`. \`${w}\` wins — it is the only key \`ListColumnSchema\` declares — and \`${r}\` has been rewritten to match, so the rendered column and the requested field agree. Fix the producer: drop \`${r}\` and author \`${w}\` only. (objectui#3104)`))}}function de(e){if(typeof e==`string`||!ce(e))return e;let t=E(e);if(!t)return e;let n=e[w]!==t,r=T.filter(n=>e[n]!==void 0&&e[n]!==t);if(!n&&r.length===0)return e;ue(e,t,r);let i={...e};i[w]=t;for(let e of r)i[e]=t;return i}function fe(e){if(!Array.isArray(e))return e;let t=!1,n=e.map(e=>{let n=de(e);return n!==e&&(t=!0),n});return t?n:e}var pe=new Set([`lookup`,`master_detail`,`tree`,`user`]);function me(e){return!!e&&typeof e==`object`&&pe.has(e.type)}function he(e,t){if(!e||typeof e!=`object`)return[];let n=[];for(let[t,r]of Object.entries(e))me(r)&&n.push(t);if(n.length===0)return[];if(t&&Array.isArray(t)&&t.length>0){let e=new Set;for(let n of t){let t=E(n);t&&e.add(t)}return n.filter(t=>e.has(t))}return n}var k=`\0`,ge=`[-\\u2013\\u2014|/·,:]`,_e=[`name`,`title`,`subject`,`label`,`full_name`,`display_name`],ve=new Set([`date`,`datetime`,`time`,`number`,`currency`,`percent`,`boolean`,`file`,`image`,`attachment`,`json`,`geolocation`,`select`,`multiselect`,`picklist`,`multipicklist`,`lookup`,`master_detail`,`reference`,`autonumber`,`auto_number`,`phone`]),ye=new Set([`text`,`string`,`textarea`,`html`]);function be(e){let t=e.name??e.full_name??e.display_name??e.label??e.title??e.subject??null;return t==null||typeof t==`string`&&!t.trim()?[e.salutation,e.first_name,e.last_name].filter(e=>typeof e==`string`&&e.trim()).map(e=>e.trim()).join(` `)||(typeof e.email==`string`&&e.email.trim()?e.email.trim():null):typeof t==`string`?t:String(t)}function xe(e,t){let n=typeof e==`string`?e:e&&typeof e==`object`&&typeof e.source==`string`?e.source:void 0;if(!n||!t||typeof t!=`object`)return``;n=n.replace(/\{\{\s*([^{}]+?)\s*\}\}/g,`{$1}`);let r=!1,i=n.replace(/\{([^{}]+)\}/g,(e,n)=>{let i=String(n).trim().split(`.`),a=t;for(let e of i){if(a==null)break;a=a[e]}return a&&typeof a==`object`&&(a=be(a)),a==null||a===``?k:(r=!0,String(a))});if(!r)return``;let a=RegExp(`\\s*${ge}\\s*${k}`,`g`),o=RegExp(`${k}\\s*${ge}\\s*`,`g`);return i=i.replace(a,``).replace(o,``).replace(new RegExp(k,`g`),``).replace(/\s+/g,` `).trim(),i}function Se(e){if(!e||typeof e!=`object`)return!1;let t=typeof e.type==`string`?e.type.toLowerCase():void 0;if(!t)return!0;if(t===`formula`){let t=String(e.data_type??e.dataType??e.returnType??e.result_type??``).toLowerCase();return ye.has(t)}return!ve.has(t)}function Ce(e){return e?Array.isArray(e)?e.filter(e=>e&&typeof e==`object`&&typeof e.name==`string`).map(e=>[e.name,e]):typeof e==`object`?Object.keys(e).map(t=>[t,e[t]]):[]:[]}var we=new WeakMap;function Te(e){let t=Ce(e?.fields).filter(([,e])=>Se(e));if(t.length===0)return;for(let e of _e){let n=t.find(([t])=>t.toLowerCase()===e);if(n)return n[0]}let n=t.find(([e])=>{let t=e.toLowerCase();return t.endsWith(`_name`)||t.endsWith(`_title`)||t.startsWith(`name_`)});return n?n[0]:t[0][0]}function Ee(e){if(typeof e!=`object`||!e)return Te(e);if(we.has(e))return we.get(e);let t=Te(e);return we.set(e,t),t}var De=[`name`,`full_name`,`fullName`,`display_name`,`displayName`,`title`,`subject`,`label`];function A(e,t){if(!t||!e||typeof e!=`object`)return;let n=e[t];if(n&&typeof n==`object`&&(n=be(n)),n==null)return;let r=typeof n==`string`?n.trim():String(n);return r===``?void 0:r}function Oe(e,t,n){let r=A(t,n?.titleField)??A(t,e?.titleField);if(r)return r;let i=A(t,e?.nameField??e?.displayNameField??e?.NAME_FIELD_KEY);if(i)return i;if(e?.titleFormat){let n=xe(e.titleFormat,t);if(n)return n}let a=A(t,Ee(e));if(a)return a;if(n?.deriveFromRecordKeys!==!1&&t&&typeof t==`object`){for(let e of De){let n=A(t,e);if(n)return n}for(let e of Object.keys(t)){let n=e.toLowerCase();if(!(n===`id`||n===`_id`||n.endsWith(`_id`)||n.startsWith(`_`))&&(n.endsWith(`_name`)||n.endsWith(`_title`)||n.startsWith(`name_`))){let n=A(t,e);if(n)return n}}}let o=t?.id??t?._id;return o!=null&&String(o).trim()!==``?`Record #${o}`:n?.fallback??`Untitled`}function ke(e,t){if(e==null||e===``)return null;let n=t?.labels;if(typeof e==`string`)return n?.[e]??e;if(typeof e==`number`)return Number.isFinite(e)?n?.[String(e)]??e:null;if(typeof e==`boolean`)return e;if(e instanceof Date){let t=e.getTime();return Number.isNaN(t)?null:t}if(Array.isArray(e)){let n=e.map(e=>ke(e,t)).filter(e=>e!==null).map(e=>String(e));return n.length>0?n.join(`, `):null}if(typeof e==`object`){let t=e,r=t.id??t._id;if(r!=null){let e=n?.[String(r)];if(e)return e}let i=Oe(void 0,t,{fallback:``});return i===``?null:i}return String(e)}function Ae(e,t){return e===null&&t===null?0:e===null?1:t===null?-1:typeof e==`boolean`&&typeof t==`boolean`?!!e-+!!t:typeof e==`number`&&typeof t==`number`?e-t:String(e).localeCompare(String(t),void 0,{numeric:!0})}var je=class e{scopes=[];constructor(e={}){this.scopes.push(new Map(Object.entries(e)))}pushScope(e){this.scopes.push(new Map(Object.entries(e)))}popScope(){this.scopes.length>1&&this.scopes.pop()}get(e){let t=e.split(`.`),n=t[0];for(let e=this.scopes.length-1;e>=0;e--)if(this.scopes[e].has(n)){let r=this.scopes[e].get(n);for(let e=1;e<t.length;e++)if(r&&typeof r==`object`)r=r[t[e]];else return;return r}}set(e,t){this.scopes.length>0&&this.scopes[this.scopes.length-1].set(e,t)}has(e){let t=e.split(`.`)[0];for(let e=this.scopes.length-1;e>=0;e--)if(this.scopes[e].has(t))return!0;return!1}toObject(){let e={};for(let t of this.scopes)for(let[n,r]of t.entries())e[n]=r;return e}createChild(t={}){let n=new e;return n.scopes=[...this.scopes,new Map(Object.entries(t))],n}},Me={Math,JSON,parseInt,parseFloat,isNaN,isFinite},Ne=new Set([`constructor`,`__proto__`,`prototype`,`__defineGetter__`,`__defineSetter__`,`__lookupGetter__`,`__lookupSetter__`]),Pe=class e{source=``;pos=0;context={};_evaluating=!0;evaluate(e,t){this.source=e.trim(),this.pos=0,this.context={...Me,...t};let n=this.parseTernary();if(this.skipWhitespace(),this.pos<this.source.length)throw SyntaxError(`Unexpected token "${this.source[this.pos]}" at position ${this.pos} in expression "${e}"`);return n}skipWhitespace(){for(;this.pos<this.source.length&&/\s/.test(this.source[this.pos]);)this.pos++}peek(e=0){return this.source[this.pos+e]??``}consume(){return this.source[this.pos++]??``}withEvaluation(e,t){let n=this._evaluating;this._evaluating=e;try{return t()}finally{this._evaluating=n}}assertSafeProp(e){if(typeof e==`string`&&Ne.has(e))throw TypeError(`Access to property "${e}" is not permitted in expressions`)}parseTernary(){let e=this.parseNullish();if(this.skipWhitespace(),this.peek()===`?`&&this.peek(1)!==`?`){if(this.pos++,this.skipWhitespace(),!this._evaluating){if(this.parseTernary(),this.skipWhitespace(),this.peek()!==`:`)throw SyntaxError(`Expected ":" in ternary expression`);this.pos++,this.skipWhitespace(),this.parseTernary();return}if(e){let e=this.parseTernary();if(this.skipWhitespace(),this.peek()!==`:`)throw SyntaxError(`Expected ":" in ternary expression`);return this.pos++,this.skipWhitespace(),this.withEvaluation(!1,()=>this.parseTernary()),e}if(this.withEvaluation(!1,()=>this.parseTernary()),this.skipWhitespace(),this.peek()!==`:`)throw SyntaxError(`Expected ":" in ternary expression`);return this.pos++,this.skipWhitespace(),this.parseTernary()}return e}parseNullish(){let e=this.parseOr();for(this.skipWhitespace();this.peek()===`?`&&this.peek(1)===`?`;){if(this.pos+=2,this.skipWhitespace(),this._evaluating&&e!=null)this.withEvaluation(!1,()=>this.parseOr());else{let t=this.parseOr();this._evaluating&&(e??=t)}this.skipWhitespace()}return e}parseOr(){let e=this.parseAnd();for(this.skipWhitespace();this.peek()===`|`&&this.peek(1)===`|`;){if(this.pos+=2,this.skipWhitespace(),this._evaluating&&e)this.withEvaluation(!1,()=>this.parseAnd());else{let t=this.parseAnd();this._evaluating&&(e||=t)}this.skipWhitespace()}return e}parseAnd(){let e=this.parseEquality();for(this.skipWhitespace();this.peek()===`&`&&this.peek(1)===`&`;){if(this.pos+=2,this.skipWhitespace(),this._evaluating&&!e)this.withEvaluation(!1,()=>this.parseEquality());else{let t=this.parseEquality();this._evaluating&&(e&&=t)}this.skipWhitespace()}return e}parseEquality(){let e=this.parseAddition();for(this.skipWhitespace();;){let t;if(this.peek()===`=`&&this.peek(1)===`=`&&this.peek(2)===`=`)t=`===`,this.pos+=3;else if(this.peek()===`!`&&this.peek(1)===`=`&&this.peek(2)===`=`)t=`!==`,this.pos+=3;else if(this.peek()===`=`&&this.peek(1)===`=`)t=`==`,this.pos+=2;else if(this.peek()===`!`&&this.peek(1)===`=`)t=`!=`,this.pos+=2;else if(this.peek()===`>`&&this.peek(1)===`=`)t=`>=`,this.pos+=2;else if(this.peek()===`<`&&this.peek(1)===`=`)t=`<=`,this.pos+=2;else if(this.peek()===`>`&&this.peek(1)!==`>`)t=`>`,this.pos++;else if(this.peek()===`<`&&this.peek(1)!==`<`)t=`<`,this.pos++;else break;this.skipWhitespace();let n=this.parseAddition();switch(t){case`===`:e=e===n;break;case`!==`:e=e!==n;break;case`==`:e=e==n;break;case`!=`:e=e!=n;break;case`>`:e=e>n;break;case`<`:e=e<n;break;case`>=`:e=e>=n;break;case`<=`:e=e<=n}this.skipWhitespace()}return e}parseAddition(){let e=this.parseMultiplication();for(this.skipWhitespace();(this.peek()===`+`||this.peek()===`-`)&&this.peek(1)!==`=`;){let t=this.consume();this.skipWhitespace();let n=this.parseMultiplication();e=t===`+`?e+n:e-n,this.skipWhitespace()}return e}parseMultiplication(){let e=this.parseUnary();for(this.skipWhitespace();(this.peek()===`*`||this.peek()===`/`||this.peek()===`%`)&&this.peek(1)!==`=`;){let t=this.consume();this.skipWhitespace();let n=this.parseUnary();t===`*`?e*=n:t===`/`?e/=n:e%=n,this.skipWhitespace()}return e}parseUnary(){if(this.skipWhitespace(),this.source.startsWith(`typeof`,this.pos)&&!/[\w$]/.test(this.source[this.pos+6]??``)){this.pos+=6,this.skipWhitespace();try{return typeof this.parseUnary()}catch{return`undefined`}}return this.peek()===`!`?(this.pos++,!this.parseUnary()):this.peek()===`-`?(this.pos++,-this.parseUnary()):this.peek()===`+`?(this.pos++,+this.parseUnary()):this.parseMember()}parseMember(){let e=this.parsePrimary();for(;;){this.skipWhitespace();let t=this.peek()===`?`&&this.peek(1)===`.`;if(this.peek()===`.`&&this.peek(1)!==`.`||t){t&&this.pos++,this.pos++,this.skipWhitespace();let n=this.parseIdentifierName();if(!n)break;if(this.assertSafeProp(n),this.skipWhitespace(),this.peek()===`(`){this.pos++;let t=this.parseArgList();if(this.peek()!==`)`)throw SyntaxError(`Expected ")" after argument list at position ${this.pos}`);if(this.pos++,!this._evaluating){e=void 0;continue}e=e!=null&&typeof e[n]==`function`?e[n](...t):void 0}else{if(!this._evaluating){e=void 0;continue}e=e?.[n]}continue}let n=this.peek()===`?`&&this.peek(1)===`[`;if(this.peek()===`[`||n){n&&this.pos++,this.pos++,this.skipWhitespace();let t=this.parseTernary();if(this.skipWhitespace(),this.peek()!==`]`)throw SyntaxError(`Expected "]" after bracket expression at position ${this.pos}`);if(this.pos++,this.assertSafeProp(t),!this._evaluating){e=void 0;continue}e=e?.[t];continue}if(this.peek()===`(`){this.pos++;let t=this.parseArgList();if(this.peek()!==`)`)throw SyntaxError(`Expected ")" after argument list at position ${this.pos}`);if(this.pos++,!this._evaluating){e=void 0;continue}if(typeof e==`function`)e=e(...t);else throw TypeError(`${String(e)} is not a function`);continue}break}return e}parsePrimary(){this.skipWhitespace();let e=this.peek();if(e===`(`){this.pos++;let e=this.parseTernary();if(this.skipWhitespace(),this.peek()!==`)`)throw SyntaxError(`Expected ")" to close "(" expression at position ${this.pos}`);return this.pos++,e}if(e===`[`)return this.parseArrayLiteral();if(e===`"`||e===`'`)return this.parseString(e);if(/\d/.test(e)||e===`.`&&/\d/.test(this.peek(1)))return this.parseNumber();if(/[a-zA-Z_$]/.test(e))return this.parseIdentifierOrKeyword();throw SyntaxError(`Unexpected character "${e}" at position ${this.pos}`)}parseArrayLiteral(){this.pos++;let e=[];for(this.skipWhitespace();this.peek()!==`]`&&this.pos<this.source.length;)e.push(this.parseTernary()),this.skipWhitespace(),this.peek()===`,`&&(this.pos++,this.skipWhitespace());if(this.peek()!==`]`)throw SyntaxError(`Expected "]" to close array literal at position ${this.pos}`);return this.pos++,e}parseString(e){this.pos++;let t=``;for(;this.pos<this.source.length;){let n=this.source[this.pos];if(n===`\\`){this.pos++;let e=this.source[this.pos++]??``;switch(e){case`n`:t+=`
2
- `;break;case`t`:t+=` `;break;case`r`:t+=`\r`;break;case`\\`:t+=`\\`;break;case`"`:t+=`"`;break;case`'`:t+=`'`;break;case"`":t+="`";break;default:t+=e}}else if(n===e){this.pos++;break}else t+=n,this.pos++}return t}parseNumber(){let e=this.pos,t=!1;for(;this.pos<this.source.length&&/\d/.test(this.source[this.pos]);)t=!0,this.pos++;if(this.source[this.pos]===`.`)for(this.pos++;this.pos<this.source.length&&/\d/.test(this.source[this.pos]);)t=!0,this.pos++;if(/[eE]/.test(this.source[this.pos]??``)){this.pos++,/[+-]/.test(this.source[this.pos]??``)&&this.pos++;let t=0;for(;this.pos<this.source.length&&/\d/.test(this.source[this.pos]);)t++,this.pos++;if(t===0)throw SyntaxError(`Invalid numeric literal exponent at position ${e}`)}if(!t)throw SyntaxError(`Invalid numeric literal at position ${e}`);let n=this.source.slice(e,this.pos),r=Number(n);if(!Number.isFinite(r))throw SyntaxError(`Invalid numeric literal "${n}" at position ${e}`);return r}parseIdentifierName(){let e=this.pos;for(;this.pos<this.source.length&&/[\w$]/.test(this.source[this.pos]);)this.pos++;return this.source.slice(e,this.pos)}parseIdentifierOrKeyword(){let e=this.parseIdentifierName();switch(e){case`true`:return!0;case`false`:return!1;case`null`:return null;case`undefined`:return;case`NaN`:return NaN;case`Infinity`:return 1/0}if(e===`new`)return this.parseNewExpression();if(this.skipWhitespace(),this.peek()===`=`&&this.peek(1)===`>`)return this.parseArrowFunction(e);if(this.peek()===`(`){this.pos++;let t=this.parseArgList();if(this.peek()!==`)`)throw SyntaxError(`Expected ")" after argument list at position ${this.pos}`);if(this.pos++,!this._evaluating)return;let n=this.context[e];if(typeof n==`function`)return n(...t);throw TypeError(`"${e}" is not a function`)}if(this._evaluating){if(!(e in this.context))throw ReferenceError(`${e} is not defined`);return this.context[e]}}parseNewExpression(){this.skipWhitespace();let e=this.parseIdentifierName();this.skipWhitespace();let t=[];if(this.peek()===`(`){if(this.pos++,t=this.parseArgList(),this.peek()!==`)`)throw SyntaxError(`Expected ")" after new ${e}() at position ${this.pos}`);this.pos++}if(this._evaluating)switch(e){case`Date`:return new Date(...t);case`RegExp`:return new RegExp(t[0],t[1]);default:throw TypeError(`new ${e}() is not supported in expressions`)}}parseArrowFunction(t){this.pos+=2,this.skipWhitespace();let n=this.pos,r=this.scanExpressionEnd(),i=this.source.slice(n,r).trim();this.pos=r;let a=this.context;return n=>new e().evaluate(i,{...a,[t]:n})}scanExpressionEnd(){let e=this.pos,t=0,n=!1,r=``;for(;e<this.source.length;){let i=this.source[e];if(n){if(i===`\\`){e+=2;continue}i===r&&(n=!1),e++;continue}if(i===`"`||i===`'`){n=!0,r=i,e++;continue}if(i===`(`||i===`[`)t++;else if(i===`)`||i===`]`){if(t===0)break;t--}else if(i===`,`&&t===0)break;e++}return e}parseArgList(){let e=[];for(this.skipWhitespace();this.peek()!==`)`&&this.pos<this.source.length;)e.push(this.parseTernary()),this.skipWhitespace(),this.peek()===`,`&&(this.pos++,this.skipWhitespace());return e}},Fe=class{cache=new Map;maxSize;constructor(e=1e3){this.maxSize=e}compile(e,t){let n=`${e}::${t.join(`,`)}`;if(this.cache.has(n)){let e=this.cache.get(n);return e.hitCount++,e}this.cache.size>=this.maxSize&&this.evictLFU();let r={fn:this.compileExpression(e,t),varNames:[...t],expression:e,compiledAt:Date.now(),hitCount:1};return this.cache.set(n,r),r}compileExpression(e,t){let n=new Pe;return(...r)=>{let i={};for(let e=0;e<t.length;e++)i[t[e]]=r[e];return n.evaluate(e,i)}}evictLFU(){let e=null,t=1/0,n=1/0;for(let[r,i]of this.cache.entries())(i.hitCount<n||i.hitCount===n&&i.compiledAt<t)&&(e=r,t=i.compiledAt,n=i.hitCount);e&&this.cache.delete(e)}has(e,t){let n=`${e}::${t.join(`,`)}`;return this.cache.has(n)}clear(){this.cache.clear()}getStats(){let e=0,t=[];for(let n of this.cache.values())e+=n.hitCount,t.push({expression:n.expression,hitCount:n.hitCount});return{size:this.cache.size,maxSize:this.maxSize,totalHits:e,entries:t.sort((e,t)=>t.hitCount-e.hitCount)}}},Ie=class{functions=new Map;constructor(){this.registerDefaults()}register(e,t){this.functions.set(e.toUpperCase(),t)}get(e){return this.functions.get(e.toUpperCase())}has(e){return this.functions.has(e.toUpperCase())}getNames(){return Array.from(this.functions.keys())}toObject(){let e={};for(let[t,n]of this.functions)e[t]=n;return e}registerDefaults(){this.registerAggregationFunctions(),this.registerDateFunctions(),this.registerLogicFunctions(),this.registerStringFunctions(),this.registerStringSearchFunctions(),this.registerStatisticalFunctions()}registerAggregationFunctions(){this.register(`SUM`,(...e)=>j(e).reduce((e,t)=>e+t,0)),this.register(`AVG`,(...e)=>{let t=j(e);return t.length===0?0:t.reduce((e,t)=>e+t,0)/t.length}),this.register(`COUNT`,(...e)=>Le(e).filter(e=>e!=null).length),this.register(`MIN`,(...e)=>{let t=j(e);return t.length===0?0:Math.min(...t)}),this.register(`MAX`,(...e)=>{let t=j(e);return t.length===0?0:Math.max(...t)})}registerDateFunctions(){this.register(`TODAY`,()=>new Date().toISOString().split(`T`)[0]),this.register(`NOW`,()=>new Date().toISOString()),this.register(`DATEADD`,(e,t,n)=>{let r=new Date(e);if(isNaN(r.getTime()))throw Error(`DATEADD: Invalid date "${e}"`);switch(String(n).toLowerCase()){case`day`:case`days`:r.setDate(r.getDate()+t);break;case`month`:case`months`:r.setMonth(r.getMonth()+t);break;case`year`:case`years`:r.setFullYear(r.getFullYear()+t);break;case`hour`:case`hours`:r.setHours(r.getHours()+t);break;case`minute`:case`minutes`:r.setMinutes(r.getMinutes()+t);break;default:throw Error(`DATEADD: Unsupported unit "${n}"`)}return r.toISOString()}),this.register(`DATEDIFF`,(e,t,n)=>{let r=new Date(e),i=new Date(t);if(isNaN(r.getTime()))throw Error(`DATEDIFF: Invalid date "${e}"`);if(isNaN(i.getTime()))throw Error(`DATEDIFF: Invalid date "${t}"`);let a=i.getTime()-r.getTime();switch(String(n).toLowerCase()){case`day`:case`days`:return Math.floor(a/864e5);case`month`:case`months`:return(i.getFullYear()-r.getFullYear())*12+(i.getMonth()-r.getMonth());case`year`:case`years`:return i.getFullYear()-r.getFullYear();case`hour`:case`hours`:return Math.floor(a/36e5);case`minute`:case`minutes`:return Math.floor(a/6e4);default:throw Error(`DATEDIFF: Unsupported unit "${n}"`)}}),this.register(`DATEFORMAT`,(e,t)=>{let n=new Date(e);if(isNaN(n.getTime()))throw Error(`DATEFORMAT: Invalid date "${e}"`);let r=(e,t=2)=>String(e).padStart(t,`0`);return t.replace(`YYYY`,String(n.getFullYear())).replace(`YY`,String(n.getFullYear()).slice(-2)).replace(`MM`,r(n.getMonth()+1)).replace(`DD`,r(n.getDate())).replace(`HH`,r(n.getHours())).replace(`mm`,r(n.getMinutes())).replace(`ss`,r(n.getSeconds()))})}registerLogicFunctions(){this.register(`IF`,(e,t,n)=>e?t:n),this.register(`AND`,(...e)=>e.every(Boolean)),this.register(`OR`,(...e)=>e.some(Boolean)),this.register(`NOT`,e=>!e),this.register(`SWITCH`,(e,...t)=>{for(let n=0;n<t.length-1;n+=2)if(e===t[n])return t[n+1];if(t.length%2==1)return t[t.length-1]})}registerStringFunctions(){this.register(`CONCAT`,(...e)=>e.map(e=>String(e??``)).join(``)),this.register(`LEFT`,(e,t)=>String(e??``).substring(0,t)),this.register(`RIGHT`,(e,t)=>{let n=String(e??``);return n.substring(Math.max(0,n.length-t))}),this.register(`TRIM`,e=>String(e??``).trim()),this.register(`UPPER`,e=>String(e??``).toUpperCase()),this.register(`LOWER`,e=>String(e??``).toLowerCase())}registerStringSearchFunctions(){this.register(`FIND`,(e,t,n)=>String(t??``).indexOf(String(e??``),n??0)),this.register(`REPLACE`,(e,t,n)=>String(e??``).split(String(t??``)).join(String(n??``))),this.register(`SUBSTRING`,(e,t,n)=>{let r=String(e??``);return n===void 0?r.substring(t):r.substring(t,t+n)}),this.register(`REGEX`,(e,t,n)=>{let r=String(e??``);return new RegExp(t,n).test(r)}),this.register(`LEN`,e=>String(e??``).length)}registerStatisticalFunctions(){this.register(`MEDIAN`,(...e)=>{let t=j(e).sort((e,t)=>e-t);if(t.length===0)return 0;let n=Math.floor(t.length/2);return t.length%2==0?(t[n-1]+t[n])/2:t[n]}),this.register(`STDEV`,(...e)=>{let t=j(e);if(t.length<2)return 0;let n=t.reduce((e,t)=>e+t,0)/t.length,r=t.map(e=>(e-n)**2).reduce((e,t)=>e+t,0)/(t.length-1);return Math.sqrt(r)}),this.register(`VARIANCE`,(...e)=>{let t=j(e);if(t.length<2)return 0;let n=t.reduce((e,t)=>e+t,0)/t.length;return t.map(e=>(e-n)**2).reduce((e,t)=>e+t,0)/(t.length-1)}),this.register(`PERCENTILE`,(e,...t)=>{let n=j(t).sort((e,t)=>e-t);if(n.length===0)return 0;let r=Math.max(0,Math.min(100,e))/100*(n.length-1),i=Math.floor(r),a=Math.ceil(r);if(i===a)return n[i];let o=r-i;return n[i]+o*(n[a]-n[i])})}};function j(e){let t=[];for(let n of e)if(Array.isArray(n))t.push(...j(n));else{let e=Number(n);isNaN(e)||t.push(e)}return t}function Le(e){let t=[];for(let n of e)Array.isArray(n)?t.push(...Le(n)):t.push(n);return t}function Re(e){return typeof e==`string`?{dialect:`cel`,source:e}:{dialect:e.dialect??`cel`,source:e.source}}function M(e,t,n,r,i){if(e==null||typeof e==`string`&&!e.trim())return n;try{let a=o.evaluate(Re(e),{record:t,previous:r,...i?{extra:i}:{}});return a.ok?a.value===!0:n}catch{return n}}function ze(e,t,n,r,i){return{visible:e.visibleWhen==null||M(e.visibleWhen,t,!0,r,i),readonly:n.readonly===!0||e.readonlyWhen!=null&&M(e.readonlyWhen,t,!1,r,i),required:n.required===!0||e.requiredWhen!=null&&M(e.requiredWhen,t,!1,r,i)}}var N=class e{context;cache;formulas;constructor(e,t,n){this.context=e instanceof je?e:new je(e||{}),this.cache=t||new Fe,this.formulas=n||new Ie}evaluate(e,t={}){if(e&&typeof e==`object`&&typeof e.source==`string`&&(e=e.source),typeof e!=`string`)return e;let{defaultValue:n,throwOnError:r=!1,sanitize:i=!0}=t;try{if(!e.includes("${"))return e;let t=e.match(/^\$\{([^}]+)\}$/);return t?this.evaluateExpression(t[1].trim(),{sanitize:i}):e.replace(/\$\{([^}]+)\}/g,(e,t)=>{try{let e=this.evaluateExpression(t.trim(),{sanitize:i});return String(e??``)}catch(n){if(r)throw n;return console.warn(`Expression evaluation failed for: ${t}`,n),e}})}catch(t){if(r)throw t;return console.warn(`Failed to evaluate expression: ${e}`,t),n??e}}evaluateExpression(e,t={}){let{sanitize:n=!0}=t;if(!(!e||e.trim()===``)){if(n&&this.isDangerous(e))throw Error(`Potentially dangerous expression detected: ${e}`);try{let t=this.context.toObject(),n={...this.formulas.toObject(),...t},r=Object.keys(n),i=Object.values(n);return this.cache.compile(e,r).fn(...i)}catch(t){throw Error(`Failed to evaluate expression "${e}": ${t.message}`)}}}isDangerous(e){return[/eval\s*\(/i,/Function\s*\(/i,/setTimeout\s*\(/i,/setInterval\s*\(/i,/import\s*\(/i,/require\s*\(/i,/process\./i,/global\./i,/window\./i,/document\./i,/__proto__/i,/constructor\s*\(/i,/prototype\./i].some(t=>t.test(e))}evaluateCondition(e,t={}){if(typeof e==`boolean`)return e;if(e&&typeof e==`object`&&e.dialect===`cel`&&typeof e.source==`string`)return this.evaluateCelCondition(e.source,t);if(e&&typeof e==`object`&&typeof e.source==`string`&&(e=e.source),!e)return!0;if(typeof e!=`string`)return!!e;let n=e.trim();if(!n)return!0;if(n.includes("${"))return!!this.evaluate(n,t);try{return!!this.evaluateExpression(n,{sanitize:t.sanitize!==!1})}catch(e){if(t.throwOnError)throw e;return!0}}evaluateCelCondition(e,t){if(!e.trim())return!0;let n=this.context.toObject(),r=n.record,i=r&&typeof r==`object`&&!Array.isArray(r)?r:n;if(!t.throwOnError)return M(e,i,!0,void 0,n);let a=M(e,i,!0,void 0,n);if(a!==M(e,i,!1,void 0,n))throw Error(`CEL predicate failed to evaluate: ${e}`);return a}updateContext(e){Object.entries(e).forEach(([e,t])=>{this.context.set(e,t)})}getContext(){return this.context}withContext(t){return new e(this.context.createChild(t),this.cache,this.formulas)}getCacheStats(){return this.cache.getStats()}clearCache(){this.cache.clear()}getFormulas(){return this.formulas}registerFunction(e,t){this.formulas.register(e,t)}};new Fe,new Ie;function Be(e){if(e!=null&&e!==``){if(typeof e==`boolean`)return e;if(typeof e==`string`)return`\${${e}}`;if(typeof e==`object`&&typeof e.source==`string`){let t=e.source;return t?e.dialect===`cel`?{dialect:`cel`,source:t}:`\${${t}}`:void 0}}}var Ve=/\$\{|===|!==|\?\.|\?\?|\.(?:includes|indexOf|toUpperCase|toLowerCase|startsWith|endsWith|trim|split|map|filter|reduce|find|some|every|join|slice|charAt|padStart|padEnd|replace|match|test)\s*\(/;function He(e){return Ve.test(e)}var Ue=new Set;function We(e){Ue.has(e)||(Ue.add(e),console.warn(`[object-ui] A list conditional predicate uses the legacy expression dialect and is not portable to the server CEL engine: `+JSON.stringify(e)+`. Rewrite it as CEL (use "==" not "===", "x in [..]" for membership, ".contains()" not ".includes()", and drop template interpolation).`))}var Ge=new Set;function Ke(e,t){let n=JSON.stringify([t??``,e]);Ge.has(n)||(Ge.add(n),console.warn(`[object-ui] A list conditional predicate failed to evaluate`+(t?` (${t})`:``)+` and was treated as its safe default: `+JSON.stringify(e)+`. Check the field names and CEL syntax.`))}function qe(e,t,n){let r=M(e,t,!0,void 0,n);return r===M(e,t,!1,void 0,n)?{ok:!0,value:r}:{ok:!1,value:!1}}function Je(e,t,n={}){let r=n.fallback??!1;if(e==null)return r;let i=typeof e==`string`?e:void 0;if(i!==void 0&&!i.trim())return r;let a=t&&typeof t==`object`?t:{},o={...n.scope??{},...a,data:a};if(i!==void 0&&He(i)){We(i);try{return new N({...o,record:a}).evaluateCondition(i,{throwOnError:!0})}catch{return n.warnOnError&&Ke(i,n.label),r}}if(!n.warnOnError)return M(e,a,r,void 0,o);let s=qe(e,a,o);return s.ok?s.value:(Ke(i??`(expression)`,n.label),r)}function P(e){if(e==null)return`null`;let t=typeof e;return t===`string`?JSON.stringify(e):t===`number`||t===`boolean`?String(e):Array.isArray(e)?`[${e.map(P).join(`, `)}]`:JSON.stringify(String(e))}function Ye(e){let{field:t,operator:n,value:r}=e;if(!t||!n)return null;let i=`record[${JSON.stringify(t)}]`;switch(n){case`equals`:return`${i} == ${P(r)}`;case`not_equals`:return`${i} != ${P(r)}`;case`greater_than`:return`${i} > ${P(r)}`;case`less_than`:return`${i} < ${P(r)}`;case`contains`:return`${i}.contains(${P(r)})`;case`in`:return`${i} in ${P(Array.isArray(r)?r:[r])}`;default:return null}}function Xe(e){return e.condition==null?typeof e.expression==`string`&&e.expression.trim()?e.expression:Ye(e):e.condition}function Ze(e){let t={};if(e.style&&typeof e.style==`object`)for(let[n,r]of Object.entries(e.style))r!=null&&(t[n]=String(r));return e.backgroundColor&&(t.backgroundColor=String(e.backgroundColor)),e.textColor&&(t.color=String(e.textColor)),e.borderColor&&(t.borderColor=String(e.borderColor)),t}function Qe(e,t,n){if(!t||t.length===0)return{};let r=e&&typeof e==`object`?e:{};for(let e=0;e<t.length;e++){let i=t[e];if(!i||typeof i!=`object`)continue;let a=Xe(i);if(a!=null&&Je(a,r,{fallback:!1,scope:n,label:`conditionalFormatting[${e}]`}))return Ze(i)}return{}}function $e(e){return e?(Array.isArray(e)?e:[e]).map(e=>typeof e==`string`?e:e&&typeof e==`object`?e.field:null).filter(e=>typeof e==`string`&&e.length>0):[]}function et(e){return e==null||e===``||Array.isArray(e)&&e.length===0}function tt(e,t){return $e(e).some(e=>et(t[e]))}function nt(e,t,n){return!e||e.length===0?[]:e.filter(e=>e?.visibleWhen==null||M(e.visibleWhen,t,!0,void 0,n))}function rt(e,t){return et(e)?!0:Array.isArray(e)?e.every(e=>t.some(t=>t.value===e)):t.some(t=>t.value===e)}function it(e,t,n,r){let i=$e(n),a=i.length>0&&tt(n,t);return{options:a?[]:nt(e,t,r),gated:a,dependsOnFields:i}}function at(e){if(typeof e!=`object`||!e)return!1;let t=e;return typeof t.id==`string`&&typeof t.type==`string`&&typeof t.objectName==`string`&&typeof t.recordId==`string`&&typeof t.timestamp==`number`}var F=new class e{undoStack=[];redoStack=[];maxHistory;listeners=new Set;constructor(e){this.maxHistory=e?.maxHistory??50}push(e){this.undoStack.push(e),this.undoStack.length>this.maxHistory&&this.undoStack.shift(),this.redoStack=[],this.notify()}peekUndo(){return this.undoStack[this.undoStack.length-1]}peekRedo(){return this.redoStack[this.redoStack.length-1]}popUndo(){let e=this.undoStack.pop();return e&&(this.redoStack.push(e),this.notify()),e}popRedo(){let e=this.redoStack.pop();return e&&(this.undoStack.push(e),this.notify()),e}clear(){this.undoStack=[],this.redoStack=[],this.notify()}get canUndo(){return this.undoStack.length>0}get canRedo(){return this.redoStack.length>0}get undoCount(){return this.undoStack.length}get redoCount(){return this.redoStack.length}subscribe(e){return this.listeners.add(e),()=>this.listeners.delete(e)}getHistory(){return[...this.undoStack]}getRedoHistory(){return[...this.redoStack]}pushBatch(e){e.length!==0&&(this.undoStack.push(...e),this.undoStack.length>this.maxHistory&&this.undoStack.splice(0,this.undoStack.length-this.maxHistory),this.redoStack=[],this.notify())}popUndoBatch(e){let t=Math.min(e,this.undoStack.length);if(t===0)return[];let n=this.undoStack.splice(this.undoStack.length-t,t);return this.redoStack.push(...n),this.notify(),n}popRedoBatch(e){let t=Math.min(e,this.redoStack.length);if(t===0)return[];let n=this.redoStack.splice(this.redoStack.length-t,t);return this.undoStack.push(...n),this.notify(),n}static STORAGE_KEY=`objectui:undo-history`;saveToStorage(){try{let t=JSON.stringify({undoStack:this.undoStack,redoStack:this.redoStack});localStorage.setItem(e.STORAGE_KEY,t)}catch{}}loadFromStorage(){try{if(typeof localStorage>`u`)return;let t=localStorage.getItem(e.STORAGE_KEY);if(!t)return;let n=JSON.parse(t);Array.isArray(n.undoStack)&&(this.undoStack=n.undoStack.filter(at)),Array.isArray(n.redoStack)&&(this.redoStack=n.redoStack.filter(at)),this.undoStack.length>this.maxHistory&&this.undoStack.splice(0,this.undoStack.length-this.maxHistory),this.notify()}catch{}}notify(){this.listeners.forEach(e=>e())}},ot=`type.actionType.name.label.confirmText.confirm.condition.disabled.api.endpoint.method.navigate.onClick.reload.close.redirect.toast.successMessage.errorMessage.refreshAfter.undoable.params.actionParams.resultDialog.target.body.openIn.modal.chain.chainMode.onSuccess.onFailure.opensInNewTab.newTabUrl.locations.visible.requiredPermissions.icon.variant.order.component.objectName.ai.aria.bodyExtra.bodyShape.mode.recordIdField.recordIdParam.requiresFeature.shortcut.bulkEnabled`.split(`.`),st=`_lock._lockDocsUrl._lockReason._lockSource._packageId._packageVersion._provenance.ai.aria.body.bodyExtra.bodyShape.bulkEnabled.component.confirmText.disabled.errorMessage.execute.icon.label.locations.method.mode.name.newTabUrl.objectName.openIn.opensInNewTab.order.params.recordIdField.recordIdParam.refreshAfter.requiredPermissions.requiresFeature.resultDialog.shortcut.successMessage.target.type.undoable.variant.visible`.split(`.`),ct=[`to`,`external`,`newTab`,`replace`],lt={execute:"`execute` was removed in @objectstack/spec 17 (#3855) — rename the key to `target`. The value (a script name or expression) is unchanged. Run `os migrate meta --from 16` to rewrite it automatically."},ut=new Set([...ot,...st,...ct].filter(e=>!(e in lt)));function dt(e){let t=[],n=[];if(!e||typeof e!=`object`)return{unknown:t,retired:n};for(let r of Object.keys(e))r in lt?n.push(r):ut.has(r)||t.push(r);return{unknown:t,retired:n}}var ft=new Set,pt=()=>!1;function mt(e,t=`ActionRunner`){if(!pt())return;let{unknown:n,retired:r}=dt(e),i=e?.name??e?.type??`(unnamed)`;for(let e of r){let n=`retired:${String(i)}:${e}`;ft.has(n)||(ft.add(n),console.warn(`[${t}] action "${String(i)}" carries the retired key \`${e}\`. ${lt[e]}`))}if(n.length===0)return;let a=`unknown:${String(i)}:${n.slice().sort().join(`,`)}`;ft.has(a)||(ft.add(a),console.warn(`[${t}] action "${String(i)}" carries ${n.length===1?`a key`:`keys`} no reader recognizes: \`${n.join("`, `")}\`. Nothing will read ${n.length===1?`it`:`them`} — check for a typo, or promote the key to an explicit field on \`ActionDef\` (packages/core/src/actions/actionKeys.ts). Warned rather than rejected because \`ActionDef\` still carries \`[key: string]: any\`, so the compiler cannot see this (objectstack#4075).`))}function ht(e){let t=e.user;if(t===void 0)return e;let n=e.os;return n&&typeof n==`object`&&n.user===t?e:{...e,os:{...n&&typeof n==`object`?n:{},user:t}}}var I=class{handlers=new Map;scripts=new Map;evaluator;context;confirmHandler;toastHandler;modalHandler;navigationHandler;paramCollectionHandler;resultDialogHandler;builtinExecutors={script:e=>this.executeScript(e),url:e=>this.executeUrl(e),modal:e=>this.executeModal(e),flow:e=>this.executeFlow(e),api:e=>this.executeAPI(e),form:e=>this.executeForm(e),navigation:e=>this.executeNavigation(e)};constructor(e={}){this.context=ht(e),this.evaluator=new N(this.context),this.confirmHandler=async e=>window.confirm(e),this.toastHandler=null,this.modalHandler=null,this.navigationHandler=null,this.paramCollectionHandler=null,this.resultDialogHandler=null}setConfirmHandler(e){this.confirmHandler=e}setToastHandler(e){this.toastHandler=e}setModalHandler(e){this.modalHandler=e}setNavigationHandler(e){this.navigationHandler=e}setParamCollectionHandler(e){this.paramCollectionHandler=e}setResultDialogHandler(e){this.resultDialogHandler=e}registerHandler(e,t){this.handlers.set(e,t)}unregisterHandler(e){this.handlers.delete(e)}registerScript(e,t){this.scripts.set(e,t)}unregisterScript(e){this.scripts.delete(e)}async execute(e){try{mt(e);let t=e.type||e.actionType||e.name||``;if(e.condition&&!this.evaluator.evaluateCondition(e.condition))return{success:!1,error:`Action condition not met`};if(e.disabled!=null&&e.disabled!==!1){let t=!1;try{t=this.evaluator.evaluateCondition(e.disabled)}catch{t=!1}if(t)return{success:!1,error:`Action is disabled`}}let n=e.confirm?.message||e.confirmText;if(n&&!await this.confirmHandler(this.evaluator.evaluate(n),e.confirm?{title:e.confirm.title,confirmText:e.confirm.confirmText,cancelText:e.confirm.cancelText}:void 0))return{success:!1,error:`Action cancelled by user`};let r=e.actionParams&&Array.isArray(e.actionParams)?e.actionParams:Array.isArray(e.params)?e.params:void 0;if(r&&r.length>0&&this.paramCollectionHandler){let t=await this.paramCollectionHandler(r,e);if(t===null)return{success:!1,error:`Action cancelled by user (params)`};let n=Array.isArray(e.params)?{}:e.params||{},i=n._rowRecord;e.params={...n,...t},i!==void 0&&(e.params._rowRecord=i)}if(t&&this.handlers.has(t)){let n=await this.handlers.get(t)(e,this.context);return await this.handlePostExecution(e,n),n}let i,a=t?this.builtinExecutors[t]:void 0;return a?i=await a(e):e.navigate?i=await this.executeNavigation(e):e.api||e.endpoint?i=await this.executeAPI(e):e.onClick?(await e.onClick(),i={success:!0}):i=await this.executeActionSchema(e),await this.handlePostExecution(e,i),i}catch(t){let n={success:!1,error:t.message};return await this.handlePostExecution(e,n),n}}async executeChain(e,t=`sequential`){if(e.length===0)return{success:!0};if(t===`parallel`){let t=await Promise.allSettled(e.map(e=>this.execute(e)));if(t.filter(e=>e.status===`rejected`||e.status===`fulfilled`&&!e.value.success).length>0)return{success:!1,error:t.find(e=>e.status===`fulfilled`&&!e.value.success)?.value?.error||`One or more parallel actions failed`};let n=t[t.length-1];return n.status===`fulfilled`?n.value:{success:!1,error:`Action failed`}}let n={success:!0};for(let t of e)if(n=await this.execute(t),!n.success)return n;return n}async handlePostExecution(e,t){let n=!!(e.resultDialog&&t.success);if(this.toastHandler){let r=e.toast??{showOnSuccess:!0,showOnError:!0},i=e.toast?.duration;if(t.success&&!n&&!t.silent&&r.showOnSuccess!==!1){let n=(t.data&&typeof t.data==`object`&&typeof t.data.message==`string`?String(t.data.message).trim():``)||e.successMessage||`Action completed successfully`;if(t.undo)try{F.push(t.undo)}catch{}this.toastHandler(n,{type:`success`,duration:i,undo:t.undo?{}:void 0})}if(!t.success&&r.showOnError!==!1&&t.error){let n=e.errorMessage||t.error,r=typeof n==`string`?n:n&&typeof n.message==`string`?n.message:`Action failed`;this.toastHandler(r,{type:`error`,duration:i})}}if(n)if(this.resultDialogHandler)try{await this.resultDialogHandler(e.resultDialog,t.data,e)}catch(e){console.warn(`[ActionRunner] resultDialog handler rejected; treating as acknowledged`,e)}else console.warn(`[ActionRunner] action.resultDialog set but no resultDialogHandler registered — the response value will not be shown to the user.`,{action:e.name,data:t.data});if(e.refreshAfter&&t.success&&(t.reload=!0),e.chain&&e.chain.length>0&&t.success){let n=await this.executeChain(e.chain,e.chainMode||`sequential`);n.success||(t.success=!1,t.error=n.error),n.data&&(t.data=n.data),n.redirect&&(t.redirect=n.redirect),n.reload&&(t.reload=!0)}if(t.success&&e.onSuccess){let t=Array.isArray(e.onSuccess)?e.onSuccess:[e.onSuccess];await this.executeChain(t,`sequential`)}if(!t.success&&e.onFailure){let t=Array.isArray(e.onFailure)?e.onFailure:[e.onFailure];await this.executeChain(t,`sequential`)}}async executeScript(e){let t=e.target;if(!t)return e.body==null?typeof e.execute==`string`?{success:!1,error:"`execute` was removed in @objectstack/spec 17 — rename the key to `target`. The value (a script name or expression) is unchanged. Run `os migrate meta --from 16` to rewrite it automatically."}:{success:!1,error:`No script provided for script action`}:{success:!1,error:"Action body must be executed server-side — this client runner does not interpret `body` (sandboxed JS needs an isolated VM; expression bodies use the formula engine). Register a `script` handler that POSTs to /api/v1/actions/{object}/{action} — build one with createServerActionHandler from @object-ui/core."};let n=this.scripts.get(t);if(n)try{return await n(e,this.context)}catch(e){return{success:!1,error:`Script execution failed: ${e.message}`}}try{let e=this.evaluator.evaluate(`\${${t}}`);return e!=null&&typeof e.then==`function`&&(e=await e),{success:!0,data:e}}catch(e){return{success:!1,error:`Script execution failed: ${e.message}`}}}async executeUrl(e){let t=e.target||e.redirect;return t?this.navigateTo(e,t,e):{success:!1,error:`No URL provided for url action`}}async navigateTo(e,t,n){let r=this.interpolateTarget(t,e),i=this.evaluator.evaluate(r);if(!this.isValidUrl(i))return{success:!1,error:`Invalid URL scheme. Only http://, https://, and relative URLs are allowed.`};let a=typeof this.context.apiBase==`string`?this.context.apiBase.replace(/\/+$/,``):``;a&&/^\/(api|_auth|_account)\//.test(i)&&(i=`${a}${i}`);let o=!!n.external||i.startsWith(`http://`)||i.startsWith(`https://`);if(/\/(api|_auth|_account)\//.test(i)&&(o||i.startsWith(`/`)))return window.location.href=i,{success:!0};let s=n.openIn??e.openIn,c=s===`new-tab`?!0:s===`self`?!1:n.newTab??e.params?.newTab??o,l=n.replace??e.replace;if(this.navigationHandler)return this.navigationHandler(i,{external:o,newTab:c,...l===void 0?{}:{replace:!!l}}),{success:!0};if(c)window.open(i,`_blank`,`noopener,noreferrer`);else return{success:!0,redirect:i};return{success:!0}}async executeModal(e){let t=e.modal||e.target||e.params?.schema;return t?this.modalHandler?await this.modalHandler(t,this.context):{success:!0,modal:t}:{success:!1,error:`No modal schema or target provided for modal action`}}async executeFlow(e){let t=e.target||e.name;return t?this.handlers.has(`flow`)?await this.handlers.get(`flow`)(e,this.context):{success:!1,error:`Flow handler not registered. Cannot execute flow: ${t}`}:{success:!1,error:`No flow target provided for flow action`}}async executeActionSchema(e){let t=!!(e.api||e.endpoint);if(!(t||e.onClick||e.redirect||e.reload===!0||e.close===!0))return{success:!1,error:`Action "${e.name||e.type||e.actionType||`action`}" is not executable: no handler is registered under that name and it declares no api, endpoint, navigate, redirect or onClick.`};let n={success:!0};if(t){let t=await this.executeAPI(e);if(!t.success)return t;n.data=t.data}return e.onClick&&await e.onClick(),n.reload=e.reload!==!1,n.close=e.close!==!1,e.redirect&&(n.redirect=this.evaluator.evaluate(e.redirect)),n}async executeForm(e){let t=this.evaluator.evaluate(e.target);if(!t||typeof t!=`string`)return{success:!1,error:`No form target (FormView name) provided for form action`};let n=(this.context.record&&this.context.record.id)??(this.context.data&&this.context.data.id),r=`/forms/${t}`,i=n==null?r:`${r}?recordId=${encodeURIComponent(String(n))}`;return this.navigationHandler?(this.navigationHandler(i,{external:!1}),{success:!0}):{success:!0,redirect:i}}async executeNavigation(e){let t=e.navigate||e,n=t.to||t.target||t.redirect;return n?this.navigateTo(e,n,t):{success:!1,error:`No URL provided for navigation action`}}async executeAPI(e){let t=e.api||e.endpoint||e.target;if(!t)return{success:!1,error:`No API endpoint provided`};try{let n,r,i={"Content-Type":`application/json`},a,o=`json`;if(typeof t==`string`)n=this.interpolateTarget(t,e),r=e.method||`POST`,a=JSON.stringify(e.params||this.context.data||{});else{let s=t;if(n=this.interpolateTarget(s.url,e),r=s.method||e.method||`POST`,i={...i,...s.headers},o=s.responseType||`json`,s.queryParams){let e=new URLSearchParams(s.queryParams);n=`${n}${n.includes(`?`)?`&`:`?`}${e.toString()}`}s.body?a=typeof s.body==`string`?s.body:JSON.stringify(s.body):r!==`GET`&&r!==`HEAD`&&(a=JSON.stringify(e.params||this.context.data||{}))}let s={method:r,headers:i};a&&r!==`GET`&&r!==`HEAD`&&(s.body=a);let c=await fetch(n,s);if(!c.ok)throw Error(`HTTP ${c.status}: ${c.statusText}`);let l;switch(o){case`text`:l=await c.text();break;case`blob`:l=await c.blob();break;default:l=await c.json()}return{success:!0,data:l}}catch(e){return{success:!1,error:e.message}}}isValidUrl(e){return typeof e==`string`&&(e.startsWith(`http://`)||e.startsWith(`https://`)||e.startsWith(`/`)||e.startsWith(`./`))}interpolateTarget(e,t){if(typeof e!=`string`||e.indexOf("${")===-1)return e;let n=t.params&&typeof t.params==`object`&&!Array.isArray(t.params)?t.params:{},r=this.buildInterpolationContext();return e.replace(/\$\{(param|ctx)\.([\w.]+)\}/g,(e,t,i)=>{let a=gt(t===`param`?n:r,i);return a==null?``:encodeURIComponent(String(a))})}buildInterpolationContext(){let e={origin:typeof window<`u`?window.location.origin:``,apiBase:typeof this.context.apiBase==`string`?this.context.apiBase.replace(/\/+$/,``):``,user:this.context.user??{},org:this.context.org??this.context.organization??{},recordId:this.context.record?.id??this.context.recordId,selection:{ids:Array.isArray(this.context.selectedRecords)?this.context.selectedRecords.map(e=>e?.id).filter(e=>e!=null).map(String):[],count:Array.isArray(this.context.selectedRecords)?this.context.selectedRecords.length:0}};return this.context.ctx&&typeof this.context.ctx==`object`&&Object.assign(e,this.context.ctx),e}updateContext(e){this.context=ht({...this.context,...e}),this.evaluator.updateContext(this.context)}getContext(){return this.context}getEvaluator(){return this.evaluator}};function gt(e,t){if(e!=null)return t.split(`.`).reduce((e,t)=>{if(e!=null)return e[t]},e)}function _t(e){return/^[a-z][a-z0-9]*(_[a-z0-9]+)*$/.test(e)}function vt(e){return{type:`app`,name:e.name,title:e.title,label:e.title,description:e.description,icon:e.icon,logo:e.branding.logo,favicon:e.branding.favicon,branding:e.branding,layout:e.layout,navigation:e.navigation}}function yt(e){if(!e)return null;let t=e.stageField;if(t===!1)return null;if(typeof t==`string`&&t)return t;let n=e.fields||{};for(let e of[`status`,`stage`,`state`,`phase`])if(e in n)return e;for(let[e,t]of Object.entries(n)){let n=(t?.type||``).toLowerCase();if(n===`status`||n===`stage`)return e}return null}var bt=new Set(`id._id.__v._version._rev.created.created_at.createdAt.created_by.createdBy.modified.modified_by.updated_at.updatedAt.updated_by.updatedBy.deleted.deleted_at.deletedAt.is_deleted.instance_state.locked.owner_id.organization_id.tenant_id.company_id.space`.split(`.`)),xt={createdAt:`created_at`,createdBy:`created_by`,updatedAt:`updated_at`,updatedBy:`updated_by`},St=new Set(Object.values(xt));function Ct(e,t){return t?.system===!0||bt.has(e)}var wt=`text.textarea.number.boolean.date.datetime.time.select.email.phone.url.password.currency.percent.lookup.formula.autonumber.file.image.markdown.html.color.code.location.address.rating.slider`.split(`.`);function Tt(e,t){if(typeof e==`string`)return e;if(e&&typeof e==`object`){let t=e.default;if(typeof t==`string`)return t}return t}function Et(e){let t=e.type??`tabular`,n=t===`joined`||t===`tabular`?`tabular`:t,r=(e.values??[]).map(e=>({name:e,label:Tt(void 0,e)})),i=(e.rows??[]).map(e=>({field:e,sort:`asc`}));return{type:`report`,title:Tt(e.label,e.name),description:e.description?Tt(e.description,``):void 0,reportType:n,fields:r,groupBy:i.length>0?i:void 0}}function Dt(e){if(!e||typeof e!=`object`)return!1;let t=e;return typeof t.name!=`string`||t.type===`report`&&Array.isArray(t.fields)?!1:typeof t.dataset==`string`||Array.isArray(t.blocks)||typeof t.type==`string`&&[`tabular`,`summary`,`matrix`,`joined`].includes(t.type)}function Ot(e,t){if(!t)return!0;let n=e?.locations;return Array.isArray(n)&&n.includes(t)}c.options;function kt(e,t){let n=e?.code;return typeof n!=`string`||n.length===0?!1:n.toUpperCase()===t.toUpperCase()}function At(e,t){return t.some(t=>kt(e,t))}var jt=3e4,Mt=new Set([408,425,429,502,503,504]),Nt=class extends Error{status;retryAfterMs;constructor(e,t,n){super(n??`Endpoint returned ${e}`),this.status=e,this.retryAfterMs=t,this.name=`HttpFetchError`}};function Pt(e){return e instanceof Nt?Mt.has(e.status):!0}function Ft(e,t){if(!e)return;let n=e.trim();if(!n)return;let r;if(/^\d+$/.test(n))r=Number(n)*1e3;else{let e=Date.parse(n);if(Number.isNaN(e))return;r=e-t}if(!(!Number.isFinite(r)||r<0))return Math.min(r,jt)}function It(e,t,n){return n===void 0?Math.min(t*2**e,jt):n}var Lt=e=>new Promise(t=>setTimeout(t,e));function Rt(e){return Ft(e.headers?.get?.(`Retry-After`),Date.now())}function zt(e){return e.toLowerCase().split(`+`).map(e=>e.trim()).sort().join(`+`)}var Bt=new Set;function Vt(e,t,n){let r=typeof t==`string`?t:t&&typeof t==`object`&&typeof t.source==`string`?t.source:String(t),i=`${String(e)}::${r}`;if(Bt.has(i))return;Bt.add(i);let a=n instanceof Error?n.message:String(n);console.warn(`[ActionEngine] action "${String(e)}" hidden: its \`visible\` predicate threw — ${a}. Predicate: ${r}. Action predicates evaluate against { record, recordId, objectName, user, os.user, … }; use \`record.<field>\` (not a bare field).`)}var Ht=class{actions=new Map;mappings=[];shortcuts=[];normalizedShortcutMap=new Map;runner;constructor(e={}){this.runner=e instanceof I?e:new I(e)}getRunner(){return this.runner}registerAction(e,t){let n=e.name||e.type||``;if(!n)throw Error(`Action must have a name or type`);this.actions.set(n,{action:e,locations:t?.locations||[],shortcut:t?.shortcut,bulkEnabled:t?.bulkEnabled??!1,priority:t?.priority??100}),t?.shortcut&&(this.shortcuts.push({keys:t.shortcut,actionName:n}),this.normalizedShortcutMap.set(zt(t.shortcut),n))}registerActions(e){for(let t of e)this.registerAction(t,{locations:t.locations})}unregisterAction(e){let t=this.actions.get(e);t?.shortcut&&this.normalizedShortcutMap.delete(zt(t.shortcut)),this.actions.delete(e),this.shortcuts=this.shortcuts.filter(t=>t.actionName!==e),this.mappings=this.mappings.filter(t=>t.actionName!==e)}addMapping(e){this.mappings.push(e)}getActionsForLocation(e){let t=this.runner.getEvaluator();return Array.from(this.actions.values()).filter(t=>t.locations.includes(e)).filter(e=>{let t=e.action.requiredPermissions;if(!Array.isArray(t)||t.length===0)return!0;let n=this.runner.getContext()?.user?.systemPermissions;return!Array.isArray(n)||t.every(e=>n.includes(e))}).filter(e=>{let n=e.action.visible;if(n==null||n===``||n===!0)return!0;if(n===!1)return!1;let r=Be(n);if(r===void 0)return typeof n==`object`||!!n;try{return t.evaluateCondition(r,{throwOnError:!0})}catch(t){return Vt(e.action.name,n,t),!1}}).sort((e,t)=>(e.priority??100)-(t.priority??100)).map(e=>e.action)}getBulkActions(){return Array.from(this.actions.values()).filter(e=>e.bulkEnabled).sort((e,t)=>(e.priority??100)-(t.priority??100)).map(e=>e.action)}getShortcuts(){return[...this.shortcuts]}getAction(e){return this.actions.get(e)?.action}async executeAction(e,t){let n=this.actions.get(e);return n?(t&&this.runner.updateContext(t),this.runner.execute(n.action)):{success:!1,error:`Action not found: ${e}`}}async dispatch(e,t){let n=this.mappings.filter(t=>t.event===e);if(n.length===0)return[];let r=[];for(let e of n){if(e.condition&&!this.runner.getEvaluator().evaluateCondition(e.condition))continue;let n=await this.executeAction(e.actionName,t);r.push(n)}return r}async handleShortcut(e,t){let n=this.normalizedShortcutMap.get(zt(e));return n?this.executeAction(n,t):null}async executeBulk(e,t,n){let r=this.actions.get(e);if(!r)return{total:0,succeeded:0,failed:0,results:[{success:!1,error:`Action not found: ${e}`}]};if(!r.bulkEnabled)return{total:0,succeeded:0,failed:0,results:[{success:!1,error:`Action ${e} does not support bulk operations`}]};let i=[],a=0,o=0;if(n?.parallel){let e=t.map(e=>(this.runner.updateContext({record:e,selectedRecords:t}),this.runner.execute(r.action))),n=await Promise.allSettled(e);for(let e of n)e.status===`fulfilled`?(i.push(e.value),e.value.success?a++:o++):(i.push({success:!1,error:e.reason?.message||`Unknown error`}),o++)}else for(let e of t){this.runner.updateContext({record:e,selectedRecords:t});let s=await this.runner.execute(r.action);if(i.push(s),s.success)a++;else if(o++,!n?.continueOnError)break}return{total:t.length,succeeded:a,failed:o,results:i}}updateContext(e){this.runner.updateContext(e)}clear(){this.actions.clear(),this.mappings=[],this.shortcuts=[],this.normalizedShortcutMap.clear()}};async function Ut(e,t){let{ids:n,allowBulk:r,offset:i,label:a=`bulk`}=e,o={succeeded:0,failed:0,errors:[]};if(r&&typeof t.bulkCall==`function`)try{let e=await t.bulkCall(n),r=Math.max(0,Math.min(e,n.length));o.succeeded+=r;let s=n.length-r;return s>0&&(o.failed+=s,o.errors.push({id:`batch_${i}`,error:`${s} record${s===1?``:`s`} failed in ${a}`})),o}catch{}return(await Promise.allSettled(n.map(e=>t.perRow(e)))).forEach((e,t)=>{e.status===`fulfilled`?o.succeeded+=1:(o.failed+=1,o.errors.push({id:n[t],error:e.reason instanceof Error?e.reason.message:String(e.reason)}))}),o}function Wt(e,t){let n=e,r=n?.error;if(typeof r==`string`&&r.length>0)return r;let i=r?.message;return typeof i==`string`&&i.length>0?i:typeof n?.message==`string`&&n.message.length>0?n.message:t}function Gt(e){return qt(e)?e.data:e}var Kt=new Set([`success`,`data`,`error`,`code`,`fields`]);function qt(e){return!!e&&typeof e==`object`&&!Array.isArray(e)&&typeof e.success==`boolean`&&Object.keys(e).every(e=>Kt.has(e))}function Jt(e,t,n){let r=t?.data,i=qt(r)&&r.success===!1;return!e.ok||t&&t.success===!1||i?{ok:!1,error:i?Wt(r,`${n} failed`):Wt(t,`${n} failed (HTTP ${e.status})`)}:{ok:!0,envelope:r,payload:Gt(r)}}function Yt(e){let t=e.locations;return Array.isArray(t)?t.some(e=>e===`list_item`||e===`record_header`||e===`record_more`||e===`record_section`):!1}function Xt(e,t){let n=e.params&&!Array.isArray(e.params)?e.params:{},r=n._rowRecord,i=e.recordIdField||`id`,a=n.recordId??r?.[i],o=Array.isArray(n._selectedIds);if(a==null&&!o){let n=Array.isArray(t?.selectedRecords)?t.selectedRecords:[];if(n.length===1)a=n[0]?.[i];else if(n.length>1)return{error:`This action runs on a single record — select exactly one row.`};else if(Yt(e))return{error:`This action runs on a single record — select a row first.`}}return{recordId:a??void 0}}function Zt(e){let{fetch:t,resolveObject:n,onRefresh:r}=e,i=e.resolveRecordId??Xt,a=new Set;return async function(o,s){let c=o.name;if(!c)return{success:!1,error:`Action has no name — a server action must declare one`};let l=o.params&&!Array.isArray(o.params)?{...o.params}:{};delete l._rowRecord;let u=i(o,s);if(u.error)return{success:!1,error:u.error};let d=u.recordId,f=`${c}:${d??``}`;if(a.has(f))return{success:!1,error:`Action already in progress`};a.add(f);try{let i=typeof e.baseUrl==`function`?e.baseUrl():e.baseUrl??``,a=o.objectName||n?.(o,s)||`global`,u=await t(`${i}/api/v1/actions/${encodeURIComponent(a)}/${encodeURIComponent(c)}`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({recordId:d,params:l})}),f=Jt(u,await u.json().catch(()=>null),`Action "${c}"`);if(!f.ok)return{success:!1,error:f.error};let p=o.refreshAfter!==!1;return p&&r?.(),{success:!0,data:f.envelope,reload:p}}catch(e){return{success:!1,error:e.message}}finally{a.delete(f)}}}function Qt(e){if(e!=null)return e.id??e._id??e.recordId}function $t(e,t){let n={};for(let[r,i]of Object.entries(e))if(i&&typeof i==`object`&&!Array.isArray(i)&&typeof i.$ref==`number`){let e=i.$ref,a=Qt(t[e]);if(a===void 0)throw Error(`batchTransaction: field "${r}" references operation ${e}, which has not produced an id (forward or invalid $ref)`);n[r]=a}else n[r]=i;return n}async function L(e,t){let n=[],r=[];try{for(let i of t){let t=i.action??`create`;if(t===`create`){let t=await e.create(i.object,$t(i.data??{},n));n.push(t);let a=Qt(t);a&&r.push({object:i.object,id:a})}else if(t===`update`){if(i.id==null)throw Error(`batchTransaction: update on "${i.object}" requires an id`);n.push(await e.update(i.object,i.id,$t(i.data??{},n)))}else{if(i.id==null)throw Error(`batchTransaction: delete on "${i.object}" requires an id`);n.push(await e.delete(i.object,i.id))}}return{results:n}}catch(t){throw r.length>0&&await Promise.allSettled([...r].reverse().map(t=>e.delete(t.object,t.id))),t}}function en(e,t){return typeof e.batchTransaction==`function`?e.batchTransaction(t):L(e,t)}function tn(e,t,n){let r=e;if(t&&(r=r.replace(/\/+$/,``)+`/`+t.replace(/^\/+/,``)),n&&Object.keys(n).length>0){let e=new URLSearchParams;for(let[t,r]of Object.entries(n))r!=null&&e.set(t,String(r));let t=e.toString();t&&(r+=(r.includes(`?`)?`&`:`?`)+t)}return r}function nn(e){if(!e)return{};let t={};return e.$select?.length&&(t.$select=e.$select.join(`,`)),e.$filter&&Object.keys(e.$filter).length>0&&(t.$filter=JSON.stringify(e.$filter)),e.$orderby&&(t.$orderby=typeof e.$orderby==`string`?e.$orderby:Array.isArray(e.$orderby)?typeof e.$orderby[0]==`string`?e.$orderby.join(`,`):e.$orderby.map(e=>`${e.field} ${e.order||`asc`}`).join(`,`):Object.entries(e.$orderby).map(([e,t])=>`${e} ${t}`).join(`,`)),e.$skip!==void 0&&(t.$skip=e.$skip),e.$top!==void 0&&(t.$top=e.$top),e.$expand?.length&&(t.$expand=e.$expand.join(`,`)),e.$search&&(t.$search=e.$search),e.$count&&(t.$count=`true`),t}function rn(e,t){return{...e,...t}}var an=class{readConfig;writeConfig;fetchFn;defaultHeaders;constructor(e){this.readConfig=e.read,this.writeConfig=e.write,this.fetchFn=e.fetch??globalThis.fetch.bind(globalThis),this.defaultHeaders=e.defaultHeaders??{}}async request(e,t={}){if(!e)throw Error(`ApiDataSource: No HTTP configuration provided for this operation. Ensure the ViewData has read/write configs.`);let n=t.method??e.method??`GET`,r={...e.params,...t.queryParams},i=tn(e.url,t.pathSuffix,r),a=rn(rn(this.defaultHeaders,e.headers),t.headers),o={method:n,headers:a};t.body!==void 0&&n!==`GET`&&(t.body instanceof FormData||t.body instanceof Blob?o.body=t.body:typeof t.body==`string`?(o.body=t.body,a[`Content-Type`]||=`text/plain`):(o.body=JSON.stringify(t.body),a[`Content-Type`]||=`application/json`));let s=await this.fetchFn(i,o);if(!s.ok){let e=await s.text().catch(()=>``);throw Error(`ApiDataSource: HTTP ${s.status} ${s.statusText} — ${e}`)}return(s.headers.get(`content-type`)??``).includes(`application/json`)?s.json():await s.text()}async find(e,t){let n=nn(t),r=await this.request(this.readConfig,{method:`GET`,queryParams:n});return this.normalizeQueryResult(r)}async findOne(e,t,n){try{let e=nn(n);return await this.request(this.readConfig,{pathSuffix:String(t),method:`GET`,queryParams:e})??null}catch{return null}}async create(e,t){let n=this.writeConfig??this.readConfig;return this.request(n,{method:`POST`,body:t})}async update(e,t,n,r){let i=this.writeConfig??this.readConfig;return this.request(i,{pathSuffix:String(t),method:`PATCH`,body:n,...r?.ifMatch?{headers:{"If-Match":String(r.ifMatch)}}:{}})}async delete(e,t,n){let r=this.writeConfig??this.readConfig;try{return await this.request(r,{pathSuffix:String(t),method:`DELETE`,...n?.ifMatch?{headers:{"If-Match":String(n.ifMatch)}}:{}}),!0}catch{return!1}}batchTransaction(e){return L(this,e)}async getObjectSchema(e){return{name:e,fields:{}}}async getView(e,t){return null}async getApp(e){return null}async aggregate(e,t){let n={field:t.field,function:t.function,groupBy:t.groupBy};t.filter&&(n.filter=typeof t.filter==`string`?t.filter:JSON.stringify(t.filter));let r=await this.request(this.readConfig,{pathSuffix:`aggregate`,method:`GET`,queryParams:n});return Array.isArray(r)?r:r?.data&&Array.isArray(r.data)?r.data:r?.results&&Array.isArray(r.results)?r.results:[]}normalizeQueryResult(e){if(Array.isArray(e))return{data:e,total:e.length};if(e&&typeof e==`object`){if(Array.isArray(e.data)&&(`total`in e||`totalCount`in e))return{data:e.data,total:e.total??e.totalCount??e.data.length,hasMore:e.hasMore,cursor:e.cursor};for(let t of[`data`,`items`,`results`,`records`,`value`])if(Array.isArray(e[t]))return{data:e[t],total:e.total??e.totalCount??e.count??e[t].length,hasMore:e.hasMore??e.hasNextPage};return{data:[e],total:1}}return{data:[],total:0}}};function R(e,t){return t?e[t]:e.id??e._id}function on(e,t){if(!t||t.length===0)return!0;let n=t[0];if(n===`and`)return t.slice(1).every(t=>on(e,t));if(n===`or`)return t.slice(1).some(t=>on(e,t));if(t.length===3&&typeof n==`string`){let[n,r,i]=t,a=e[n];switch(r){case`=`:return a===i;case`!=`:return a!==i;case`>`:return a>i;case`>=`:return a>=i;case`<`:return a<i;case`<=`:return a<=i;case`in`:return Array.isArray(i)&&i.includes(a);case`not in`:case`not_in`:case`nin`:case`notin`:return Array.isArray(i)&&!i.includes(a);case`contains`:{let e=typeof a==`string`?a.toLowerCase():``;return typeof a==`string`&&e.includes(String(i).toLowerCase())}case`notcontains`:{let e=typeof a==`string`?a.toLowerCase():``;return typeof a==`string`&&!e.includes(String(i).toLowerCase())}case`startswith`:{let e=typeof a==`string`?a.toLowerCase():``;return typeof a==`string`&&e.startsWith(String(i).toLowerCase())}case`between`:return Array.isArray(i)&&i.length===2&&a>=i[0]&&a<=i[1];default:return!0}}return!0}function sn(e,t){for(let[n,r]of Object.entries(t)){let t=e[n];if(r&&typeof r==`object`&&!Array.isArray(r))for(let[e,n]of Object.entries(r))switch(e){case`$gt`:if(!(t>n))return!1;break;case`$gte`:if(!(t>=n))return!1;break;case`$lt`:if(!(t<n))return!1;break;case`$lte`:if(!(t<=n))return!1;break;case`$ne`:if(t===n)return!1;break;case`$in`:if(!Array.isArray(n)||!n.includes(t))return!1;break;case`$contains`:if(typeof t!=`string`||!t.toLowerCase().includes(String(n).toLowerCase()))return!1}else if(t!==r)return!1}return!0}function cn(e,t){if(!t)return e;let n=[];return Array.isArray(t)?n=t.map(e=>typeof e==`string`?e.startsWith(`-`)?{field:e.slice(1),order:`desc`}:{field:e,order:`asc`}:{field:e.field,order:e.order??`asc`}):typeof t==`object`&&(n=Object.entries(t).map(([e,t])=>({field:e,order:t}))),n.length===0?e:[...e].sort((e,t)=>{for(let{field:r,order:i}of n){let n=e[r],a=t[r];if(n===a)continue;if(n==null)return i===`asc`?-1:1;if(a==null)return i===`asc`?1:-1;let o=n<a?-1:1;return i===`asc`?o:-o}return 0})}function ln(e,t){if(!t||t.length===0)return e;let n={};for(let r of t)r in e&&(n[r]=e[r]);return n}var un=class{items;idField;mutationListeners=new Set;constructor(e){this.items=JSON.parse(JSON.stringify(e.items)),this.idField=e.idField}emitMutation(e){for(let t of this.mutationListeners)try{t(e)}catch(e){console.warn(`ValueDataSource: mutation listener error`,e)}}async find(e,t){let n=[...this.items];if(t?.$filter&&(Array.isArray(t.$filter)&&t.$filter.length>0?n=n.filter(e=>on(e,t.$filter)):!Array.isArray(t.$filter)&&Object.keys(t.$filter).length>0&&(n=n.filter(e=>sn(e,t.$filter)))),t?.$search){let e=t.$search.toLowerCase();n=n.filter(t=>Object.values(t).some(t=>typeof t==`string`&&t.toLowerCase().includes(e)))}let r=n.length;n=cn(n,t?.$orderby);let i=t?.$skip??0,a=t?.$top;return i>0&&(n=n.slice(i)),a!==void 0&&(n=n.slice(0,a)),t?.$select?.length&&(n=n.map(e=>ln(e,t.$select))),{data:n,total:r,hasMore:i+(a??n.length)<r}}async findOne(e,t,n){let r=this.items.find(e=>String(R(e,this.idField))===String(t));return r?n?.$select?.length?ln(r,n.$select):{...r}:null}async create(e,t){let n={...t};if(!R(n,this.idField)){let e=this.idField??`id`;n[e]=`auto_${Date.now()}_${Math.random().toString(36).slice(2,8)}`}return this.items.push(n),this.emitMutation({type:`create`,resource:e,record:{...n}}),{...n}}async update(e,t,n){let r=this.items.findIndex(e=>String(R(e,this.idField))===String(t));if(r===-1)throw Error(`ValueDataSource: Record with id "${t}" not found`);return this.items[r]={...this.items[r],...n},this.emitMutation({type:`update`,resource:e,id:t,record:{...this.items[r]}}),{...this.items[r]}}async delete(e,t){let n=this.items.findIndex(e=>String(R(e,this.idField))===String(t));return n!==-1&&(this.items.splice(n,1),this.emitMutation({type:`delete`,resource:e,id:t}),!0)}async bulk(e,t,n){let r=[];for(let i of n)switch(t){case`create`:r.push(await this.create(e,i));break;case`update`:{let t=R(i,this.idField);t!==void 0&&r.push(await this.update(e,t,i));break}case`delete`:{let t=R(i,this.idField);t!==void 0&&await this.delete(e,t);break}}return r}batchTransaction(e){return L(this,e)}async getObjectSchema(e){if(this.items.length===0)return{name:e,fields:{}};let t=this.items[0],n={};for(let[e,r]of Object.entries(t))n[e]={type:typeof r};return{name:e,fields:n}}async getView(e,t){return null}async getApp(e){return null}async aggregate(e,t){let{field:n,function:r,groupBy:i}=t,a={};for(let e of this.items){let t=String(e[i]??`Unknown`);a[t]||(a[t]=[]),a[t].push(e)}return Object.entries(a).map(([e,t])=>{let a=t.map(e=>Number(e[n])||0),o;switch(r){case`count`:o=t.length;break;case`avg`:o=a.length>0?a.reduce((e,t)=>e+t,0)/a.length:0;break;case`min`:o=a.length>0?Math.min(...a):0;break;case`max`:o=a.length>0?Math.max(...a):0;break;default:o=a.reduce((e,t)=>e+t,0)}return{[i]:e,[n]:o}})}onMutation(e){return this.mutationListeners.add(e),()=>{this.mutationListeners.delete(e)}}get count(){return this.items.length}getAll(){return JSON.parse(JSON.stringify(this.items))}};function dn(e,t,n){if(!e)return t??null;switch(e.provider){case`object`:return t??null;case`api`:return new an({read:e.read,write:e.write,fetch:n?.fetch,defaultHeaders:n?.defaultHeaders});case`value`:return new un({items:e.items??[],idField:n?.idField});default:return t??null}}var z=`https://objectui.dev/docs/errors`,fn={"OBJUI-001":{code:`OBJUI-001`,message:'Unknown component type: "${type}"',suggestion:`Ensure the component is registered via registry.register() before rendering. Check for typos in the component type name.`,docUrl:`${z}/OBJUI-001`},"OBJUI-002":{code:`OBJUI-002`,message:"Schema validation failed: ${reason}",suggestion:`Verify the schema against the ObjectUI JSON spec. Run the built-in schema validator for details.`,docUrl:`${z}/OBJUI-002`},"OBJUI-003":{code:`OBJUI-003`,message:"Expression evaluation failed: ${expression}",suggestion:`Check the expression syntax and ensure all referenced variables exist in the current data scope.`,docUrl:`${z}/OBJUI-003`},"OBJUI-004":{code:`OBJUI-004`,message:'Plugin dependency missing: "${dependency}"',suggestion:`Install the required dependency and register it before loading this plugin.`,docUrl:`${z}/OBJUI-004`},"OBJUI-005":{code:`OBJUI-005`,message:'Plugin already loaded: "${plugin}"',suggestion:`A plugin with the same name is already registered. Remove the duplicate or use a unique plugin name.`,docUrl:`${z}/OBJUI-005`},"OBJUI-006":{code:`OBJUI-006`,message:'Plugin not found: "${plugin}"',suggestion:`Verify the plugin name and ensure it has been registered before access.`,docUrl:`${z}/OBJUI-006`},"OBJUI-007":{code:`OBJUI-007`,message:'Registry namespace deprecated: "${namespace}"',suggestion:`Migrate to the new namespace format. See the migration guide for details.`,docUrl:`${z}/OBJUI-007`},"OBJUI-008":{code:`OBJUI-008`,message:'Read-only scope violation: "${scope}"',suggestion:`You are trying to mutate a read-only data scope. Use a writable scope or clone the data before modifying.`,docUrl:`${z}/OBJUI-008`},"OBJUI-009":{code:`OBJUI-009`,message:'Invalid field configuration: "${field}"',suggestion:`Check the field schema for required properties (type, name). Ensure the field widget is registered.`,docUrl:`${z}/OBJUI-009`},"OBJUI-010":{code:`OBJUI-010`,message:'Action execution failed: "${action}"',suggestion:`Verify the action handler is registered and that all required parameters are provided.`,docUrl:`${z}/OBJUI-010`}},pn=class extends Error{code;details;constructor(e,t,n){super(e),this.code=t,this.details=n,this.name=`ObjectUIError`,Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor)}toJSON(){return{name:this.name,message:this.message,code:this.code,details:this.details,stack:this.stack}}};function mn(e){return e instanceof pn}var B=`__debug`;function hn(e){let t=e;if(t===void 0)try{t=typeof window<`u`?window.location.search:``}catch{t=``}let n=new URLSearchParams(t),r=n.has(B),i=n.has(`${B}_schema`),a=n.has(`${B}_perf`),o=n.has(`${B}_data`),s=n.has(`${B}_expr`),c=n.has(`${B}_events`),l=n.has(`${B}_registry`);return{enabled:r||i||a||o||s||c||l,...i&&{schema:i},...a&&{perf:a},...o&&{data:o},...s&&{expr:s},...c&&{events:c},...l&&{registry:l}}}function gn(){try{if(typeof window<`u`)try{if(hn(window.location.search).enabled)return!0}catch{}let e=typeof globalThis<`u`&&globalThis.OBJECTUI_DEBUG;return e===!0||e===`true`||globalThis.process?.env?.OBJECTUI_DEBUG===`true`}catch{return!1}}function _n(e,t,n){gn()&&(n===void 0?console.log(`[ObjectUI Debug][${e}] ${t}`):console.log(`[ObjectUI Debug][${e}] ${t}`,n))}var vn=new Map;function yn(e){gn()&&vn.set(e,performance.now())}function bn(e){if(!gn())return;let t=vn.get(e);if(t!==void 0){let n=(performance.now()-t).toFixed(2);console.log(`[ObjectUI Debug][perf] ${e}: ${n}ms`),vn.delete(e)}}var xn=200,Sn=class e{static instance=null;entries=[];subscribers=new Set;static getInstance(){return e.instance||=new e,e.instance}static resetInstance(){e.instance=null}addPerf(e){this.push({kind:`perf`,data:e})}addExpr(e){this.push({kind:`expr`,data:e})}addEvent(e){this.push({kind:`event`,data:e})}getEntries(e){return e?this.entries.filter(t=>t.kind===e):this.entries.slice()}clear(){this.entries=[]}subscribe(e){return this.subscribers.add(e),()=>this.subscribers.delete(e)}push(e){this.entries.push(e),this.entries.length>xn&&(this.entries=this.entries.slice(-200));for(let t of this.subscribers)try{t(e)}catch{}}},Cn={medium:991,small:640,xsmall:479},wn=e=>e.replace(/[A-Z]/g,e=>`-${e.toLowerCase()}`),Tn=e=>Object.entries(e).filter(([,e])=>e!=null&&e!==``).map(([e,t])=>`${wn(e)}: ${typeof t==`number`?String(t):t} !important;`).join(` `);function En(e){if(!e||typeof e!=`object`)return!1;let t=e;return!!(t.large||t.medium||t.small||t.xsmall)}function Dn(e){return`os-s-${String(e).replace(/[^a-zA-Z0-9_-]/g,`-`)}`}function On(e,t){let n=[];if(t.large){let r=Tn(t.large);r&&n.push(`${e} { ${r} }`)}for(let r of[`medium`,`small`,`xsmall`]){let i=t[r];if(!i)continue;let a=Tn(i);a&&n.push(`@media (max-width: ${Cn[r]}px) { ${e} { ${a} } }`)}return n.join(`
3
- `)}var kn={"react-pages":!0},V=new Map,An=!1;function jn(){if(An)return;An=!0;let e=globalThis;if(Array.isArray(e.__OBJECTUI_CAPABILITIES__))for(let t of e.__OBJECTUI_CAPABILITIES__)typeof t==`string`&&!V.has(t)&&V.set(t,!0);if(Array.isArray(e.__OBJECTUI_CAPABILITIES_DISABLED__))for(let t of e.__OBJECTUI_CAPABILITIES_DISABLED__)typeof t==`string`&&V.set(t,!1)}function Mn(e){jn();let t=V.get(e);return t===void 0?kn[e]??!1:t}var Nn=`react-pages`,Pn=/\$\{event\.([a-zA-Z0-9_]+)\}/g;function Fn(e,t){return typeof e!=`string`||e.indexOf("${event.")===-1?e:e.replace(Pn,(e,n)=>{let r=t[n];return r==null?``:String(r)})}function In(e,t){if(typeof e==`string`){let n=e.match(/^\$\{event\.([a-zA-Z0-9_]+)\}$/);if(n){let e=t[n[1]];return e===``||e===void 0?null:e}return Fn(e,t)}if(Array.isArray(e))return e.map(e=>In(e,t));if(e&&typeof e==`object`){let n={};for(let[r,i]of Object.entries(e))n[r]=In(i,t);return n}return e}function Ln(e,t,n={}){if(e?.filter)return In(e.filter,t);let r={},{rowField:i,columnField:a,groupByField:o}=n,s=t.scope??`cell`;return s===`total`?r:((s===`cell`||s===`row`)&&i&&`rowKey`in t&&(r[i]=t.rowKey===``?null:t.rowKey),(s===`cell`||s===`column`)&&a&&`colKey`in t&&(r[a]=t.colKey===``?null:t.colKey),o&&`category`in t&&(r[o]=t.category===``?null:t.category),r)}function Rn(e,t,n=`Details`){if(e?.title){let n=Fn(e.title,t).trim();if(n)return n}let r=[];return t.rowLabel&&r.push(t.rowLabel),t.colLabel&&r.push(t.colLabel),t.categoryLabel?r.push(t.categoryLabel):t.category&&r.push(t.category),t.series&&r.push(t.series),r.length>0?r.join(` × `):n}function zn(e){return e?e.enabled!==!1:!1}function H(e,t=new Date){if(e==null)return e;let n=e=>{let t=new Date(e);return t.setHours(0,0,0,0),t},r=e=>{let t=n(e);return`${t.getFullYear()}-${String(t.getMonth()+1).padStart(2,`0`)}-${String(t.getDate()).padStart(2,`0`)}`},i=e=>{let t=n(e),r=(t.getDay()+6)%7;return t.setDate(t.getDate()-r),t},a=e=>new Date(e.getFullYear(),e.getMonth(),1),o=e=>{let t=Math.floor(e.getMonth()/3);return new Date(e.getFullYear(),t*3,1)},s=e=>new Date(e.getFullYear(),0,1),c=(e,t)=>new Date(e.getFullYear(),e.getMonth()+t,1),l=(e,t)=>{let r=n(e);return r.setDate(r.getDate()+t),r},u=e=>l(c(a(e),1),-1),d=e=>l(i(e),6),f=e=>l(c(o(e),3),-1),p=e=>new Date(e.getFullYear(),11,31),m={today:()=>r(t),yesterday:()=>r(l(t,-1)),tomorrow:()=>r(l(t,1)),now:()=>t.toISOString(),current_week_start:()=>r(i(t)),current_week_end:()=>r(d(t)),current_month_start:()=>r(a(t)),current_month_end:()=>r(u(t)),current_quarter_start:()=>r(o(t)),current_quarter_end:()=>r(f(t)),current_year_start:()=>r(s(t)),current_year_end:()=>r(p(t)),last_week_start:()=>r(l(i(t),-7)),last_week_end:()=>r(l(i(t),-1)),last_month_start:()=>r(c(a(t),-1)),last_month_end:()=>r(l(a(t),-1)),last_quarter_start:()=>r(c(o(t),-3)),last_quarter_end:()=>r(l(o(t),-1)),last_year_start:()=>r(new Date(t.getFullYear()-1,0,1)),last_year_end:()=>r(new Date(t.getFullYear()-1,11,31)),next_week_start:()=>r(l(i(t),7)),next_month_start:()=>r(c(a(t),1)),next_quarter_start:()=>r(c(o(t),3)),next_year_start:()=>r(new Date(t.getFullYear()+1,0,1))};for(let[e,t]of Object.entries({week_start:`current_week_start`,week_end:`current_week_end`,month_start:`current_month_start`,month_end:`current_month_end`,quarter_start:`current_quarter_start`,quarter_end:`current_quarter_end`,year_start:`current_year_start`,year_end:`current_year_end`}))m[e]=m[t];let h=/^(\d+)_(minutes?|hours?|days?|weeks?|months?|years?)_(ago|from_now)$/,g=e=>{let n=e.match(h);if(!n)return null;let i=parseInt(n[1],10);if(!Number.isFinite(i))return null;let a=n[3]===`ago`?-1:1,o=n[2].replace(/s$/,``);if(o===`minute`)return new Date(t.getTime()+a*i*60*1e3).toISOString();if(o===`hour`)return new Date(t.getTime()+a*i*60*60*1e3).toISOString();if(o===`day`)return r(l(t,a*i));if(o===`week`)return r(l(t,a*i*7));if(o===`month`){let e=new Date(t.getFullYear(),t.getMonth()+a*i,t.getDate());return r(e)}if(o===`year`){let e=new Date(t.getFullYear()+a*i,t.getMonth(),t.getDate());return r(e)}return null},_=/\$?\{([a-zA-Z0-9_]+)\}/g,v=e=>{if(e==null)return e;if(typeof e==`string`){let t=e.match(/^\$?\{([a-zA-Z0-9_]+)\}$/);if(t){let e=t[1];if(m[e])return m[e]();let n=g(e);if(n!=null)return n}let n=!1,r=e.replace(_,(e,t)=>{if(m[t])return n=!0,m[t]();let r=g(t);return r==null?e:(n=!0,r)});return n?r:e}if(Array.isArray(e))return e.map(v);if(typeof e==`object`){let t={};for(let n of Object.keys(e))t[n]=v(e[n]);return t}return e};return v(e)}var Bn={current_user:`current_user_id`,current_user_email:`current_user_id`,user_id:`current_user_id`,userid:`current_user_id`,me:`current_user_id`,current_organization_id:`current_org_id`,org_id:`current_org_id`,organization_id:`current_org_id`,current_tenant_id:`current_org_id`},Vn=/^\$?\{([a-zA-Z0-9_]+)\}$/;function Hn(e){return s.includes(e)}function Un(e,t={}){if(e==null)return e;let{currentUserId:n,currentOrgId:r}=t,i=t.onUnresolved===null?()=>{}:t.onUnresolved??(e=>{console.warn(`[object-ui] ${e}`)}),a={current_user_id:n,current_org_id:r},o=e=>{if(e==null)return e;if(typeof e==`string`){let t=e.match(Vn);if(!t)return e;let n=t[1];if(Hn(n)){let t=a[n];return t!=null&&t!==``?t:(i(`Filter placeholder "{${n}}" could not be resolved — no ${n===`current_user_id`?`signed-in user`:`active organization`} in scope. The filter will match no records.`),e)}let r=Bn[n.toLowerCase()];return r&&i(`Filter placeholder "{${n}}" is not a recognised token — did you mean "{${r}}"? It is sent to the server as a literal string and will match no records.`),e}if(Array.isArray(e))return e.map(o);if(typeof e==`object`){let t={};for(let n of Object.keys(e))t[n]=o(e[n]);return t}return e};return o(e)}function Wn(e,t={},n=new Date){return e==null?e:Un(H(e,n),t)}var Gn=`dateRange`,Kn=`created_at`,qn={today:{from:`{today}`,to:`{today}`},yesterday:{from:`{yesterday}`,to:`{yesterday}`},this_week:{from:`{current_week_start}`,to:`{current_week_end}`},last_week:{from:`{last_week_start}`,to:`{last_week_end}`},this_month:{from:`{current_month_start}`,to:`{current_month_end}`},last_month:{from:`{last_month_start}`,to:`{last_month_end}`},this_quarter:{from:`{current_quarter_start}`,to:`{current_quarter_end}`},last_quarter:{from:`{last_quarter_start}`,to:`{last_quarter_end}`},this_year:{from:`{current_year_start}`,to:`{current_year_end}`},last_year:{from:`{last_year_start}`,to:`{last_year_end}`},last_7_days:{from:`{7_days_ago}`,to:`{today}`},last_30_days:{from:`{30_days_ago}`,to:`{today}`},last_90_days:{from:`{90_days_ago}`,to:`{today}`}},Jn=Object.keys(qn),Yn=/^\d{4}-\d{2}-\d{2}(?:[T ][\d:.]+(?:Z|[+-]\d{2}:?\d{2})?)?$/;function Xn(e){return H(e)!==e||Yn.test(e)&&!Number.isNaN(Date.parse(e))}function Zn(){return Jn.join(`, `)}function Qn(e){typeof console<`u`&&console.warn(`[dashboard-filters] ${e}`)}function $n(e,t){return e!==`date`&&e!==`dateRange`||typeof t!=`string`?t:t in qn?{preset:t}:t}function er(e){if(!Array.isArray(e)||e.length===0)return;let t=[];for(let n of e)if(n!=null)if(typeof n==`object`){let e=n.value;if(e==null)continue;let r=n.label;t.push({value:String(e),label:typeof r==`string`&&r?r:String(e)})}else t.push({value:String(n),label:String(n)});return t.length>0?t:void 0}function tr(e){let t=new Map;if(e.dateRange){let n=e.dateRange.defaultRange;t.set(Gn,{name:Gn,field:e.dateRange.field||Kn,type:`dateRange`,defaultValue:n&&n!==`custom`?{preset:n}:void 0,allowCustomRange:e.dateRange.allowCustomRange})}for(let n of e.globalFilters??[]){if(!n?.field)continue;let e=n.name||n.field;t.has(e)&&typeof console<`u`&&console.warn(`[dashboard-filters] duplicate filter name "${e}" — the later definition wins`);let r=n.type??`text`;t.set(e,{name:e,field:n.field,label:n.label,type:r,options:er(n.options),optionsFrom:n.optionsFrom,defaultValue:$n(r,n.defaultValue),targetWidgets:n.targetWidgets})}return Array.from(t.values())}function nr(e){return e.map(e=>({name:e.name,type:e.type===`dateRange`?`object`:`string`,defaultValue:e.defaultValue}))}function rr(e,t){if(t==null||t===``)return!0;if(Array.isArray(t))return t.length===0;if(e.type===`dateRange`||e.type===`date`){let e=t;return typeof e==`object`&&!e.preset&&!e.from&&!e.to}return typeof t==`object`&&Object.keys(t).length===0}function ir(e,t){if(!rr(e,t)){if(e.type===`dateRange`||e.type===`date`){let n=t;if(typeof n==`object`){let t=typeof n.preset==`string`&&n.preset?n.preset:void 0,r=t?qn[t]:void 0,i=r?.from??n.from,a=r?.to??n.to;return t&&!r&&Qn(i||a?`filter "${e.name}": ignoring unknown date range preset "${t}" — using the explicit from/to bounds instead; known presets: ${Zn()}`:`skipping filter "${e.name}": unknown date range preset "${t}" — expected one of: ${Zn()}`),!i&&!a?void 0:{...i?{$gte:i}:{},...a?{$lte:a}:{}}}if(typeof n==`string`&&!Xn(n)){Qn(`skipping filter "${e.name}": value "${n}" is neither a known date range preset nor an ISO date — expected one of: ${Zn()}, an ISO date (YYYY-MM-DD), or a date macro such as {today}`);return}return t}return e.type===`select`||e.type===`lookup`?Array.isArray(t)?{$in:t}:t:e.type===`text`?{$contains:t}:t}}function ar(e,t){let n=e.filterBindings?.[t.name];if(n!==!1){if(typeof n==`string`&&n)return n;if(!(t.targetWidgets&&t.targetWidgets.length>0&&(!e.id||!t.targetWidgets.includes(e.id))))return t.field}}function or(e,t,n,r){let i=[];for(let a of t){let t=n[a.name];if(rr(a,t))continue;let o=ar(e,a);if(!o)continue;if(typeof e.filterBindings?.[a.name]!=`string`&&r&&!r.has(o)){typeof console<`u`&&console.warn(`[dashboard-filters] skipping filter "${a.name}" on widget "${e.id??`?`}": default field "${o}" does not exist on the widget's object — map it with filterBindings: { "${a.name}": "<field>" } or opt out with false`);continue}let s=ir(a,t);s!==void 0&&i.push({[o]:s})}if(i.length!==0)return i.length===1?i[0]:{$and:i}}function sr(e,t){let n=e&&Object.keys(e).length>0,r=t&&Object.keys(t).length>0;if(n&&r)return{$and:[e,t]};if(n)return e;if(r)return t}var cr={current_week_start:`last_week_start`,current_week_end:`last_week_end`,current_month_start:`last_month_start`,current_month_end:`last_month_end`,current_quarter_start:`last_quarter_start`,current_quarter_end:`last_quarter_end`,current_year_start:`last_year_start`,current_year_end:`last_year_end`,week_start:`last_week_start`,week_end:`last_week_end`,month_start:`last_month_start`,month_end:`last_month_end`,quarter_start:`last_quarter_start`,quarter_end:`last_quarter_end`,year_start:`last_year_start`,year_end:`last_year_end`,today:`yesterday`};function lr(e,t){if(e==null)return e;if(typeof e==`string`)return e.replace(/\$?\{([a-zA-Z0-9_]+)\}/g,(e,n)=>{let r=t[n];return r?`{${r}}`:e});if(Array.isArray(e))return e.map(e=>lr(e,t));if(typeof e==`object`){let n={};for(let r of Object.keys(e))n[r]=lr(e[r],t);return n}return e}function ur(e,t){let n=t.match(/^(\d+)([dwMy])$/);if(!n)return null;let r=parseInt(n[1],10),i=n[2],a=new Date(e);if(i===`d`)a.setDate(a.getDate()-r);else if(i===`w`)a.setDate(a.getDate()-r*7);else if(i===`M`)a.setMonth(a.getMonth()-r);else if(i===`y`)a.setFullYear(a.getFullYear()-r);else return null;return a}function dr(e,t,n=new Date){if(t===`previousYear`)return H(e,new Date(n.getFullYear()-1,n.getMonth(),n.getDate(),n.getHours(),n.getMinutes(),n.getSeconds()));if(typeof t==`object`&&t&&`offset`in t){let r=ur(n,t.offset);return r?H(e,r):H(e,n)}return H(lr(e,cr),n)}function fr(e,t){if(e===`previousYear`)return`vsLastYear`;if(typeof e==`object`&&e&&`offset`in e)return`vsPreviousPeriod`;let n=t?JSON.stringify(t):``;return/current_year_|year_start|year_end/.test(n)?`vsLastYear`:/current_quarter_|quarter_start|quarter_end/.test(n)?`vsLastQuarter`:/current_month_|month_start|month_end/.test(n)?`vsLastMonth`:/current_week_|week_start|week_end/.test(n)?`vsLastWeek`:/\btoday\b/.test(n)?`vsYesterday`:`vsPreviousPeriod`}function pr(e,t,n,r){let i=(t??[]).filter(Boolean),a=(n??[]).filter(Boolean),o=Array.isArray(e)?e:[],s=e=>(r??[]).find(t=>t.name===e)?.label??e;if(i.length>=2&&a.length===1){let e=i[0],t=i[1],n=a[0],r=[],s=new Map;for(let i of o){let a=i[e],o=String(a??``);s.has(o)||s.set(o,{[e]:a});let c=String(i[t]??``);c!==``&&!r.includes(c)&&r.push(c),s.get(o)[c]=i[n]}return{data:Array.from(s.values()),xAxisKey:e,series:r.map(e=>({dataKey:e,label:e}))}}return{data:o,xAxisKey:i[0],series:a.map(e=>({dataKey:e,label:s(e)}))}}function mr(e,t){let n=Array.isArray(e)?e:[];if(!t)return n;let r=Object.keys(t).filter(e=>t[e]&&Object.keys(t[e]).length>0);return r.length===0?n:n.map(e=>{let n=null;for(let i of r){let r=e[i];if(r==null)continue;let a=t[i][String(r)];a!=null&&a!==r&&(n||={...e},n[i]=a)}return n??e})}function hr(e,t,n,r,i){let a=(t??[]).filter(Boolean),o=(n??[]).filter(Boolean),s=Array.isArray(e)?e:[],c=a[0];if(!c)return-1;let l=String(r??``);if(a.length>=2&&o.length===1){let e=a[1],t=String(i??``);return s.findIndex(n=>String(n[c]??``)===l&&String(n[e]??``)===t)}return s.findIndex(e=>String(e[c]??``)===l)}function gr(e){if(!Array.isArray(e)||e.length===0)return null;let t={};for(let n of e)if(n&&typeof n==`object`){let e=n;typeof e.color==`string`&&e.color&&(e.value!=null&&(t[String(e.value)]=e.color),e.label!=null&&(t[String(e.label)]=e.color))}return Object.keys(t).length>0?t:null}function _r(e){if(!Array.isArray(e)||e.length===0)return null;let t=[];for(let n of e){if(typeof n==`string`||typeof n==`number`||typeof n==`boolean`){t.push(String(n));continue}if(n&&typeof n==`object`){let e=n;e.value!=null&&t.push(String(e.value)),e.label!=null&&String(e.label)!==String(e.value)&&t.push(String(e.label))}}return t.length>0?t:null}function vr(e){if(!Array.isArray(e)||e.length===0)return null;let t=new Map;return e.forEach((e,n)=>{t.has(e)||t.set(e,n)}),t.size>0?t:null}function yr(e){if(!Array.isArray(e)||e.length===0)return null;let t={};for(let n of e)if(n&&typeof n==`object`){let e=n;if(e.value!=null&&e.label!=null){let n=String(e.value),r=String(e.label);r!==n&&(t[n]=r)}}return Object.keys(t).length>0?t:null}function br(e){return e>-1&&e<1?e*100:e}function xr(e,t,n,r){if(e==null)return`—`;if(typeof e!=`number`)return String(e);let i=t?t.split(`.`)[1]?.match(/0/g)?.length??0:void 0;if(n)try{return new Intl.NumberFormat(void 0,{style:`currency`,currency:n,minimumFractionDigits:i??0,maximumFractionDigits:i??2}).format(e)}catch{}if(!t)return Number.isInteger(e)?String(e):e.toLocaleString(void 0,{maximumFractionDigits:2});let a=t.includes(`%`);return`${t.includes(`$`)?`$`:``}${(a?r?r===`fraction`?e*100:e:br(e):e).toLocaleString(void 0,{minimumFractionDigits:i??0,maximumFractionDigits:i??0})}${a?`%`:``}`}function Sr(e){return e==null?`—`:typeof e==`number`?Number.isInteger(e)?String(e):e.toLocaleString(void 0,{maximumFractionDigits:2}):String(e)}function Cr(e,t,n){let r=new Map((e??[]).map(e=>[e.name,e])),i=e=>r.get(e);return{measureField:i,headerLabel:e=>{let r=i(e)?.label??e;return t&&n?n(t,e,r):r}}}function wr(e,t,n,r,i){let a={};for(let r of t){let t=e?.[r];a[n[r]]=t===``||t===void 0?null:t}if(i)for(let e of Object.values(i))e&&e.field&&(a[e.field]={$gte:e.gte,$lt:e.lt});return r?{...r,...a}:a}var Tr=e=>JSON.stringify(e),Er=(e,t)=>JSON.stringify([e,t]),Dr=/[\\/:*?"<>|\u0000-\u001f]+/g,Or=80;function U(e){return e?String(e).replace(Dr,`_`).replace(/\s+/g,` `).replace(/_{2,}/g,`_`).replace(/^[\s._-]+|[\s._-]+$/g,``).slice(0,Or):``}function kr(e,t={},n=new Date){let r=U(t.prefix),i=r||U(t.label)||U(t.objectName)||`export`,a=U(t.viewLabel);!r&&a&&a.toLowerCase()!==i.toLowerCase()&&(i=`${i}-${a}`.slice(0,Or));let o=e=>String(e).padStart(2,`0`),s=`${n.getFullYear()}${o(n.getMonth()+1)}${o(n.getDate())}-${o(n.getHours())}${o(n.getMinutes())}${o(n.getSeconds())}`;return`${i}-${s}.${e}`}function Ar(e){if(!e||typeof e!=`object`)return e;let t=e,n=t.reference_to??t.reference??t.referenceTo;return n==null||n===``?e:(t.reference_to===void 0&&(t.reference_to=n),t.reference===void 0&&(t.reference=n),e)}function jr(e){let t=e&&typeof e==`object`?e.fields:null;if(!t||typeof t!=`object`)return e;let n=Array.isArray(t)?t:Object.values(t);for(let e of n)Ar(e);return e}var Mr={compact:`compact`,comfortable:`medium`,spacious:`tall`},Nr={compact:`compact`,short:`compact`,medium:`comfortable`,tall:`spacious`,extra_tall:`spacious`};function Pr(e){return typeof e==`string`&&e in Nr?Nr[e]:`comfortable`}var W=e=>!!e&&typeof e==`object`&&!Array.isArray(e),Fr={showSearch:`search`,showSort:`sort`,showFilters:`filter`,showDensity:`rowHeight`,showGroup:`group`,showHideFields:`hideFields`,showColor:`rowColor`},Ir={private:`personal`,team:`collaborative`,organization:`collaborative`,public:`collaborative`},Lr={label:`ariaLabel`,describedBy:`ariaDescribedBy`};function Rr(e){if(!e||typeof e!=`object`)return e;let t=e,n=t.fields,r=Array.isArray(n),i=t.densityMode,a=typeof i==`string`&&i in Mr,o=t.filters,s=Array.isArray(o),c=Object.keys(Fr).filter(e=>typeof t[e]==`boolean`),l=typeof t.showDescription==`boolean`,u=W(t.aria)?t.aria:void 0,d=!!u&&Object.keys(Lr).some(e=>u[e]!==void 0),f=W(t.sharing)?t.sharing:void 0,p=!!f&&(f.visibility!==void 0||f.enabled!==void 0),m=t.viewType,h=!m||m===`list`,g=Array.isArray(t.columns)?t.columns:r?n:void 0,_=fe(g),v=_!==g;if(!r&&!a&&!s&&!c.length&&!l&&!d&&!p&&!h&&!v)return e;let y={...t};if(r&&(Array.isArray(y.columns)||(y.columns=n),delete y.fields),v&&(y.columns=_),a&&(typeof y.rowHeight!=`string`&&(y.rowHeight=Mr[i]),delete y.densityMode),s&&(Array.isArray(y.filter)||(y.filter=o),delete y.filters),c.length){let e={...W(y.userActions)?y.userActions:{}};for(let n of c){let r=Fr[n];typeof e[r]!=`boolean`&&(e[r]=t[n]),delete y[n]}y.userActions=e}if(l){let e={...W(y.appearance)?y.appearance:{}};typeof e.showDescription!=`boolean`&&(e.showDescription=t.showDescription),delete y.showDescription,y.appearance=e}if(d&&u){let e={...u};for(let[t,n]of Object.entries(Lr))e[n]===void 0&&u[t]!==void 0&&(e[n]=u[t]),delete e[t];y.aria=e}if(p&&f){let e={...f};if(e.type===void 0){let t=typeof f.visibility==`string`?f.visibility:void 0,n=t?Ir[t]:f.enabled===!0?`personal`:void 0;n&&(e.type=n)}delete e.visibility,delete e.enabled,y.sharing=e}return h&&(y.viewType=`grid`),y}var G=t(i(),1),K=r(),q=(0,G.createContext)(null),zr=({children:e,dataSource:t,debug:n,debugFlags:r,apiFetch:i})=>{let a=(0,G.useContext)(q),o=i??a?.apiFetch,s=(0,G.useMemo)(()=>({dataSource:t,debug:n,debugFlags:r,apiFetch:o}),[t,n,r,o]);return(0,K.jsx)(q.Provider,{value:s,children:e})},Br=()=>{let e=(0,G.useContext)(q);if(!e)throw Error(`useSchemaContext must be used within a SchemaRendererProvider`);return e},Vr=e=>{let t=(0,G.useContext)(q)?.dataSource;if(e&&t)return e.split(`.`).reduce((e,t)=>e&&e[t],t)},Hr=(0,G.createContext)({});function Ur({scope:e,children:t}){return(0,G.createElement)(Hr.Provider,{value:e},t)}function J(){return(0,G.useContext)(Hr)}function Wr(e){if(e!=null&&e!==``){if(typeof e==`boolean`)return e;if(typeof e==`string`)return`\${${e}}`;if(typeof e==`object`&&typeof e.source==`string`){let t=e.source;return t?e.dialect===`cel`?{dialect:`cel`,source:t}:`\${${t}}`:void 0}}}var Gr=new Set;function Kr(e,t={},n){let r=J();return(0,G.useMemo)(()=>{let i=new N({...r,...t});if(n?.throwOnError)try{return i.evaluateCondition(e,{throwOnError:!0})}catch(t){let r=typeof e==`string`?e:String(e),i=`${n?.label??``}::${r}`;if(!Gr.has(i)){Gr.add(i);let e=t instanceof Error?t.message:String(t);console.warn(`[object-ui] ${n?.label??`a component`} was hidden/disabled: its predicate threw — ${e}. Predicate: ${r}.`)}return!1}return i.evaluateCondition(e)},[e,t,r,n?.throwOnError,n?.label])}function qr(e,t,n){let r=J(),i=n?.fallback??!0;return(0,G.useMemo)(()=>typeof e==`boolean`?e:e==null||e===``?i:Je(e,t??{},{fallback:i,scope:r,warnOnError:n?.warnOnError,label:n?.label}),[e,t,r,i,n?.warnOnError,n?.label])}var Jr=(0,G.createContext)(null);function Yr(e){if(!e||e.length===0)return{};let t={};for(let n of e)if(n.defaultValue!==void 0)t[n.name]=n.defaultValue;else switch(n.type){case`number`:t[n.name]=0;break;case`boolean`:t[n.name]=!1;break;case`object`:t[n.name]={};break;case`array`:t[n.name]=[];break;default:t[n.name]=``}return t}var Xr=({definitions:e,children:t})=>{let n=(0,G.useContext)(Jr),[r,i]=(0,G.useState)(()=>Yr(e)),a=(0,G.useMemo)(()=>e??[],[e]),o=(0,G.useMemo)(()=>new Set(a.map(e=>e.name)),[a]),s=(0,G.useCallback)((e,t)=>{if(!o.has(e)&&n&&n.definitions.some(t=>t.name===e)){n.setVariable(e,t);return}i(n=>({...n,[e]:t}))},[o,n]),c=(0,G.useCallback)(e=>{for(let[t,n]of Object.entries(e))s(t,n)},[s]),l=(0,G.useCallback)(()=>{i(Yr(e))},[e]),u=(0,G.useMemo)(()=>n?{...n.variables,...r}:r,[n,r]),d=(0,G.useMemo)(()=>n?[...n.definitions.filter(e=>!o.has(e.name)),...a]:a,[n,a,o]),f=(0,G.useMemo)(()=>({variables:u,definitions:d,setVariable:s,setVariables:c,resetVariables:l}),[u,d,s,c,l]);return(0,K.jsx)(Jr.Provider,{value:f,children:t})};Xr.displayName=`PageVariablesProvider`;function Y(){return(0,G.useContext)(Jr)??Zr}var Zr=Object.freeze({variables:Object.freeze({}),definitions:Object.freeze([]),setVariable:()=>{},setVariables:()=>{},resetVariables:()=>{}});function Qr(e){let{variables:t,definitions:n,setVariable:r}=Y();return(0,G.useMemo)(()=>{if(!e)return null;let i=n.find(t=>t.source===e);return i?{name:i.name,value:t[i.name],setValue:e=>r(i.name,e)}:null},[e,n,t,r])}function $r(e){if(e!=null)return typeof e==`string`?e:e.defaultValue||e.key}var ei=(()=>{try{return!1}catch{return!0}})(),ti=typeof WeakMap<`u`?new WeakMap:{set(){},get(){},has(){return!1}},ni=typeof WeakSet<`u`?new WeakSet:{add(){},has(){return!1}};function ri(e){if(!ei||!e||typeof e!=`object`)return{valid:!0,messages:[]};let t=ti.get(e);if(t)return t;let n={valid:!0,messages:[]};try{let t=v(e);if(!t.valid){let r=t.errors.map(e=>`${e.path}: ${e.message}`);n={valid:!1,messages:r},ni.has(e)||(ni.add(e),console.warn(`[ObjectUI] Invalid schema detected:
4
- `+r.join(`
5
- `),e))}}catch(t){ni.has(e)||(ni.add(e),console.warn(`[ObjectUI] Schema validator threw:`,t))}return ti.set(e,n),n}function ii(e){let t={};return e.ariaLabel&&(t[`aria-label`]=$r(e.ariaLabel)),e.ariaDescribedBy&&(t[`aria-describedby`]=e.ariaDescribedBy),e.role&&(t.role=e.role),t}var ai=class extends G.Component{state={hasError:!1,error:null};static getDerivedStateFromError(e){return{hasError:!0,error:e}}componentDidUpdate(e){this.state.hasError&&(e.componentType!==this.props.componentType||e.resetKey!==this.props.resetKey)&&this.setState({hasError:!1,error:null})}handleRetry=()=>{this.setState({hasError:!1,error:null})};render(){if(this.state.hasError&&this.state.error){let e=this.state.error;return mn(e),(0,K.jsxs)(`div`,{className:`p-4 border border-orange-400 rounded bg-orange-50 text-orange-700 my-2`,role:`alert`,children:[(0,K.jsxs)(`p`,{className:`font-medium`,children:[`Component`,this.props.componentType?` "${this.props.componentType}"`:``,` failed to render`]}),(0,K.jsx)(`p`,{className:`text-sm mt-1`,children:e.message}),!1,(0,K.jsx)(`button`,{onClick:this.handleRetry,className:`mt-2 text-sm underline hover:no-underline`,children:`Retry`})]})}return this.props.children}},oi={},si=(0,G.forwardRef)(({schema:e,...t},n)=>{let r=(0,G.useContext)(q),i=r?.dataSource||oi,a=J(),{variables:o}=Y(),[,s]=(0,G.useReducer)(e=>e+1,0);(0,G.useEffect)(()=>{let e=d.subscribe(s);return s(),e},[]);let[c,l]=(0,G.useState)(null),u=G.useId(),f=(0,G.useMemo)(()=>{if(!e||typeof e==`string`)return e;let t=new N({...a,current_user:a?.user,data:i,page:o}),n={...e};if(n.properties){let e=n.type,t=n.id,r=n.properties;for(let[e,t]of Object.entries(r))e!==`type`&&e!==`id`&&(n[e]=t);e!==void 0&&(n.type=e),t!==void 0&&(n.id=t),n.properties=r}if(typeof n.content==`string`&&(n.content=t.evaluate(n.content)),n.props){let e={...n.props};for(let[n,r]of Object.entries(e))e[n]=t.evaluate(r);n.props=e}return(n.visible===void 0?n.visibleWhen===void 0?n.visibleOn===void 0?n.visibility===void 0?n.hidden===void 0?n.hiddenOn!==void 0&&t.evaluateCondition(n.hiddenOn):t.evaluateCondition(n.hidden):!t.evaluateCondition(n.visibility):!t.evaluateCondition(n.visibleOn):!t.evaluateCondition(n.visibleWhen):!t.evaluateCondition(n.visible))&&(n._hidden=!0),(n.disabled===void 0?n.disabledOn!==void 0&&t.evaluateCondition(n.disabledOn):t.evaluateCondition(n.disabled))&&(n._disabled=!0),n},[e,i,a,o]);if(!f||f?._hidden)return null;if(typeof f==`string`)return(0,K.jsx)(K.Fragment,{children:f});let p=ei?ri(e):{valid:!0,messages:[]};_n(`schema`,`Rendering schema node`,{type:f.type,id:f.id});let m=d.get(f.type);if(!m){if(!c&&d.hasLazy(f.type)){let e=d.loadLazy(f.type);if(e)return e.catch(e=>{l(e instanceof Error?e:Error(String(e)))}),(0,K.jsxs)(`div`,{className:`p-2 text-sm text-muted-foreground animate-pulse`,role:`status`,"aria-live":`polite`,"data-lazy-loading":f.type,children:[`Loading `,(0,K.jsx)(`code`,{children:f.type}),`…`]})}return _n(`schema`,`Component not found in registry`,{type:f.type}),fn[`OBJUI-001`],(0,K.jsxs)(`div`,{className:`p-4 border border-red-500 rounded text-red-500 bg-red-50 my-2`,role:`alert`,children:[(0,K.jsxs)(`p`,{className:`font-medium`,children:[`Unknown component type: `,(0,K.jsx)(`strong`,{children:f.type})]}),c&&(0,K.jsxs)(`p`,{className:`text-xs mt-1`,children:[`Failed to load plugin: `,c.message]}),!1,(0,K.jsx)(`pre`,{className:`text-xs mt-2 overflow-auto`,children:JSON.stringify(f,null,2)})]})}let{type:h,children:g,body:_,schema:v,visible:y,visibleWhen:b,visibleOn:x,visibility:S,hidden:ee,hiddenOn:te,disabled:ne,disabledOn:re,_hidden:ie,_disabled:ae,responsiveStyles:C,...oe}=f,se=En(C),w=se?Dn(f.id??u):``,T=se?On(`.${w}`,C):``,ce=w?[f.className,w].filter(Boolean).join(` `):f.className,le=w?{...f,className:ce}:f,E=ii(f),D=r?.debug||r?.debugFlags?.enabled,O={};D&&(O[`data-debug-type`]=f.type,f.id&&(O[`data-debug-id`]=f.id)),yn(`render:${f.type}:${f.id??`anon`}`);let ue=D?performance.now():0,de=(0,K.jsxs)(ai,{componentType:f.type,resetKey:f.id??null,children:[T?(0,K.jsx)(`style`,{"data-os-scope":w,dangerouslySetInnerHTML:{__html:T}}):null,G.createElement(m,{schema:le,...oe,...f.props||{},...E,...O,disabled:ae||void 0,className:ce,"data-obj-id":f.id,"data-obj-type":f.type,...ei&&!p.valid?{"data-obj-schema-invalid":`true`}:{},...t})]});if(bn(`render:${f.type}:${f.id??`anon`}`),D&&ue){let e=performance.now()-ue;Sn.getInstance().addPerf({type:f.type,id:f.id,durationMs:e,timestamp:Date.now()})}return de});si.displayName=`SchemaRenderer`;var ci=(0,G.createContext)({});function li({currentUserId:e,currentOrgId:t,children:n}){let r=(0,G.useMemo)(()=>({currentUserId:e,currentOrgId:t}),[e,t]);return(0,G.createElement)(ci.Provider,{value:r},n)}function ui(){return(0,G.useContext)(ci)}function di(e={}){let{context:t={},onConfirm:n,onToast:r,onModal:i,onNavigate:a,onParamCollection:o,onResultDialog:s}=`context`in e?e:{context:e},[c,l]=(0,G.useState)(!1),[u,d]=(0,G.useState)(null),[f,p]=(0,G.useState)(null),m=(0,G.useMemo)(()=>{let e=new I(t);return n&&e.setConfirmHandler(n),r&&e.setToastHandler(r),i&&e.setModalHandler(i),a&&e.setNavigationHandler(a),o&&e.setParamCollectionHandler(o),s&&e.setResultDialogHandler(s),e},[JSON.stringify(t)]);return{execute:(0,G.useCallback)(async e=>{l(!0),d(null),p(null);try{let t=await m.execute(e);return p(t),t.success||d(t.error||`Action failed`),t}catch(e){let t=e.message;d(t);let n={success:!1,error:t};return p(n),n}finally{l(!1)}},[m]),loading:c,error:u,result:f,updateContext:(0,G.useCallback)(e=>{m.updateContext(e)},[m]),runner:m}}var fi={sm:`min(92vw, 480px)`,md:`min(92vw, 720px)`,lg:`min(92vw, 960px)`,xl:`min(92vw, 1200px)`,full:`min(92vw, 1600px)`};function pi(e){if(!e)return;if(e.width!==void 0)return e.width;let t=e.size;if(t&&t!==`auto`)return fi[t]}function mi(e){let{navigation:t,objectName:n,onNavigate:r,onRowClick:i}=e,[a,o]=(0,G.useState)(!1),[s,c]=(0,G.useState)(null),l=t?.mode??`page`,u=pi(t),d=t?.view,f=l===`drawer`||l===`modal`||l===`split`||l===`popover`,p=(0,G.useCallback)(()=>{o(!1),c(null)},[]),m=(0,G.useCallback)(e=>{c(e),o(!0)},[]),h=(0,G.useCallback)((e,a)=>{if(i){i(e,a);return}if(a&&(a.metaKey||a.ctrlKey||a.button===1)){let t=e.id||e._id;if(r&&t!=null){r(t,`new_window`);return}}if(!t){let t=e.id||e._id;r&&t!=null&&r(t,d??`view`);return}if(!(l===`none`||t.preventNavigation)){if(l===`new_window`||t.openNewTab){let t=e.id||e._id;if(r&&t!=null){r(t,`new_window`);return}let i=encodeURIComponent(String(t)),a=n?`/${n}/record/${i}`:`/${i}`;window.open(a,`_blank`);return}if(l===`page`){let t=e.id||e._id;r&&t!=null&&r(t,d??`view`);return}if(f){c(e),o(!0);return}}},[i,t,l,n,r,f,d]);return(0,G.useMemo)(()=>({isOpen:a,selectedRecord:s,mode:l,close:p,open:m,setIsOpen:o,handleClick:h,width:u,view:d,isOverlay:f}),[a,s,l,p,m,h,u,d,f])}var hi=(0,G.createContext)(!1),gi=({value:e=!0,children:t})=>(0,K.jsx)(hi.Provider,{value:e,children:t}),_i=()=>(0,G.useContext)(hi),X=(0,G.createContext)(null),vi=({children:e,context:t={},onConfirm:n,onToast:r,onModal:i,onNavigate:a,onParamCollection:o,onResultDialog:s,handlers:c})=>{let[l,u]=(0,G.useState)(!1),[d,f]=(0,G.useState)(null),[p,m]=(0,G.useState)(null),h=(0,G.useMemo)(()=>{let e=new I({...t,ctx:t&&typeof t.ctx==`object`?{...t,...t.ctx}:{...t}});return n&&e.setConfirmHandler(n),r&&e.setToastHandler(r),i&&e.setModalHandler(i),a&&e.setNavigationHandler(a),o&&e.setParamCollectionHandler(o),s&&e.setResultDialogHandler(s),c&&Object.entries(c).forEach(([t,n])=>{e.registerHandler(t,n)}),e},[JSON.stringify(t)]),g=(0,G.useCallback)(async e=>{u(!0),f(null),m(null);try{let t=await h.execute(e);return m(t),t.success||f(t.error||`Action failed`),t}catch(e){let t=e.message;f(t);let n={success:!1,error:t};return m(n),n}finally{u(!1)}},[h]),_=(0,G.useCallback)(async(e,t)=>{u(!0),f(null),m(null);try{let n=await h.executeChain(e,t);return m(n),n.success||f(n.error||`Chain failed`),n}catch(e){let t=e.message;f(t);let n={success:!1,error:t};return m(n),n}finally{u(!1)}},[h]),v=(0,G.useCallback)(e=>{h.updateContext(e)},[h]),y=(0,G.useMemo)(()=>({execute:g,executeChain:_,loading:l,error:d,result:p,runner:h,updateContext:v}),[g,_,l,d,p,h,v]);return(0,K.jsx)(X.Provider,{value:y,children:e})};vi.displayName=`ActionProvider`;function yi(){let e=(0,G.useContext)(X);if(!e){let e=new I;return{execute:t=>e.execute(t),executeChain:(t,n)=>e.executeChain(t,n),loading:!1,error:null,result:null,runner:e,updateContext:t=>e.updateContext(t)}}return e}function bi(){return(0,G.useContext)(X)!==null}(0,G.createContext)(null);var xi={toast:{surface:`delegate`,transient:!0},snackbar:{surface:`snackbar`,transient:!0},banner:{surface:`banner`,transient:!1},alert:{surface:`alert`,transient:!1},inline:{surface:`inline`,transient:!1}};function Si(e){return e===`modal`?`alert`:e&&e in xi?e:`toast`}new Set(Object.keys(xi));var Ci=new Set([`top_left`,`top_center`,`top_right`,`bottom_left`,`bottom_center`,`bottom_right`]);function wi(e={}){return{defaultPosition:e.defaultPosition??e.position,defaultDuration:e.defaultDuration??5e3,maxVisible:e.stacking===!1?1:e.maxVisible??5,stackDirection:e.stackDirection??`down`,pauseOnHover:e.pauseOnHover??!0}}var Ti=0,Ei=(()=>{try{return!1}catch{return!0}})(),Di={delegate:"pass `onToast` to <NotificationProvider>",snackbar:`mount <NotificationSnackbar /> from @object-ui/components`,banner:`mount <NotificationBanners /> from @object-ui/components`,alert:`mount <NotificationAlerts /> from @object-ui/components`,inline:`mount <NotificationInline /> from @object-ui/components at the raising surface`},Oi=(0,G.createContext)(null),ki=({children:e,config:t={},onToast:n})=>{let r=(0,G.useMemo)(()=>wi(t),[JSON.stringify(t)]),[i,a]=(0,G.useState)([]),o=(0,G.useRef)(new Map),s=(0,G.useRef)(new Map),c=(0,G.useCallback)((e,t)=>{let n=setTimeout(()=>{s.current.delete(e),a(t=>t.filter(t=>t.id!==e))},t);s.current.set(e,{handle:n,endsAt:Date.now()+t,left:t})},[]),l=(0,G.useCallback)(e=>{let t=s.current.get(e);t&&(clearTimeout(t.handle),s.current.set(e,{...t,left:Math.max(0,t.endsAt-Date.now())}))},[]),u=(0,G.useCallback)(e=>{let t=s.current.get(e);t&&(clearTimeout(t.handle),c(e,t.left))},[c]);(0,G.useEffect)(()=>()=>{for(let{handle:e}of s.current.values())clearTimeout(e);s.current.clear()},[]);let d=(0,G.useCallback)(e=>{let t=o.current;return t.set(e,(t.get(e)??0)+1),()=>{let n=(t.get(e)??1)-1;n>0?t.set(e,n):t.delete(e)}},[]),f=(0,G.useCallback)(e=>{let t=`notification-${++Ti}`,i=Si(e.displayType),{surface:s,transient:l}=xi[i],u={...e,displayType:i,id:t,createdAt:new Date,read:!1};a(e=>[u,...e]),s===`delegate`&&n?.(u,r),Ei&&s!==`delegate`&&(o.current.get(s)??0)===0&&console.warn(`[NotificationProvider] "${u.title}" declares displayType '${i}' but no ${i} surface is mounted, so it will not be shown. To present it, ${Di[s]}.`);let d=e.duration??(l?r.defaultDuration:0);return d>0&&c(t,d),t},[r,n,c]),p=(0,G.useCallback)((e,t)=>f({title:e,message:t,severity:`info`}),[f]),m=(0,G.useCallback)((e,t)=>f({title:e,message:t,severity:`success`}),[f]),h=(0,G.useCallback)((e,t)=>f({title:e,message:t,severity:`warning`}),[f]),g=(0,G.useCallback)((e,t)=>f({title:e,message:t,severity:`error`}),[f]),_=(0,G.useCallback)(e=>{a(t=>t.map(t=>t.id===e?{...t,read:!0}:t))},[]),v=(0,G.useCallback)(()=>{a(e=>e.map(e=>({...e,read:!0})))},[]),y=(0,G.useCallback)(e=>{let t=s.current.get(e);t&&(clearTimeout(t.handle),s.current.delete(e)),a(t=>t.filter(t=>t.id!==e))},[]),b=(0,G.useCallback)(()=>{a([])},[]),x=(0,G.useMemo)(()=>i.filter(e=>!e.read).length,[i]),S=(0,G.useMemo)(()=>({notifications:i,unreadCount:x,notify:f,info:p,success:m,warning:h,error:g,markAsRead:_,markAllAsRead:v,dismiss:y,clearAll:b,config:r,pauseAutoDismiss:l,resumeAutoDismiss:u,registerSurface:d}),[i,x,f,p,m,h,g,_,v,y,b,r,l,u,d]);return(0,K.jsx)(Oi.Provider,{value:S,children:e})};ki.displayName=`NotificationProvider`;function Ai(){let e=(0,G.useContext)(Oi);if(!e)throw Error(`useNotifications must be used within a <NotificationProvider>. Wrap your app with <NotificationProvider> to use the notification system.`);return e}function ji(){return(0,G.useContext)(Oi)!==null}function Mi(e,t){let n=t.maxVisible>0?e.slice(0,t.maxVisible):e;return t.stackDirection===`up`?n:[...n].reverse()}function Ni(e,t){let n=e.position??t?.defaultPosition;if(!n)return;let r=n.replace(/-/g,`_`);return Ci.has(r)?r:void 0}function Pi(e,t){let{notifications:n,registerSurface:r}=Ai(),{surface:i}=xi[e];return(0,G.useEffect)(()=>r(i),[r,i]),(0,G.useMemo)(()=>n.filter(n=>Si(n.displayType)===e&&(e!==`inline`||(n.scope??void 0)===t)),[n,e,t])}var Fi=(0,G.createContext)(null);function Ii(){let e=(0,G.useContext)(Fi);if(!e)throw Error(`useDnd must be used within a <DndProvider>. Wrap your app with <DndProvider> to use the drag and drop system.`);return e}function Li(){return(0,G.useContext)(Fi)!==null}var Ri=(0,G.createContext)(null);function zi(){return(0,G.useContext)(Ri)}var Bi=(0,G.createContext)(null),Z=Object.freeze([]),Vi=Object.freeze({apps:Z,objects:Z,dashboards:Z,reports:Z,pages:Z,loading:!1,error:null,refresh:async()=>{},invalidate:()=>{},ensureType:async()=>[],getItem:async()=>null,getItemsByType:()=>[],getTypeStatus:()=>`ready`});function Hi(){return(0,G.useContext)(Bi)??Vi}function Ui(e,t){let{getItem:n}=Hi(),[r,i]=(0,G.useState)({item:null,loading:!!t,error:null});return(0,G.useEffect)(()=>{if(!t){i(e=>e.item===null&&!e.loading&&e.error===null?e:{item:null,loading:!1,error:null});return}let r=!1;return i(e=>({...e,loading:!0,error:null})),n(e,t).then(e=>{r||i({item:e,loading:!1,error:null})}).catch(e=>{r||i({item:null,loading:!1,error:e instanceof Error?e:Error(String(e))})}),()=>{r=!0}},[e,t,n]),r}var Wi=G.createContext(null),Gi=({children:e})=>{let t=G.useMemo(()=>{let e=new Map,t=Xi,n=new Set,r=()=>{let r=new Set;for(let t of e.values())for(let e of t)r.add(e);if(r.size===t.size){let e=!0;for(let n of r)if(!t.has(n)){e=!1;break}if(e)return}t=r,n.forEach(e=>e())};return{getNames:()=>t,subscribe:e=>(n.add(e),()=>{n.delete(e)}),register:(t,n)=>{let i=e.get(t);i&&i.length===n.length&&i.every((e,t)=>e===n[t])||(e.set(t,[...n]),r())},unregister:t=>{e.delete(t)&&r()}}},[]);return(0,K.jsx)(Wi.Provider,{value:t,children:e})};function Ki(){let e=G.useContext(Wi);return G.useSyncExternalStore(e?e.subscribe:Ji,e?e.getNames:Yi,e?e.getNames:Yi)}function qi(e,t){let n=G.useContext(Wi),r=t.join(`|`);G.useEffect(()=>{if(n)return n.register(e,r.length===0?[]:r.split(`|`)),()=>n.unregister(e)},[n,e,r])}var Ji=e=>()=>{},Yi=()=>Xi,Xi=new Set,Zi=G.createContext(null),Qi=({children:e,...t})=>{let n=G.useMemo(()=>t,[t.objectName,t.recordId,t.dataSource,t.data,t.objectSchema,t.loading,t.error,t.refresh,t.embedded,t.headerSystemActions,t.isFavorite,t.onToggleFavorite]);return(0,K.jsx)(Zi.Provider,{value:n,children:e})};function $i(){return G.useContext(Zi)}var ea=G.createContext(null),ta=({canEdit:e=!0,locked:t=!1,approvalPending:n,approvalProgress:r,lockedReason:i,children:a})=>{let o=n??t,[s,c]=G.useState(!1),[l,u]=G.useState({}),[d,f]=G.useState(null),[p,m]=G.useState(!1),[h,g]=G.useState(null),_=G.useCallback(t=>{e&&(f(t??null),c(!0),g(null))},[e]),v=G.useCallback((e,t)=>{u(n=>({...n,[e]:t}))},[]),y=G.useCallback(()=>{u({}),c(!1),f(null),m(!1),g(null)},[]),b=G.useMemo(()=>({editing:s,canEdit:e,locked:t,approvalPending:o,approvalProgress:r,lockedReason:i,draft:l,autoFocusField:d,saving:p,error:h,enter:_,setField:v,cancel:y,reset:y,setSaving:m,setError:g}),[s,e,t,o,r,i,l,d,p,h,_,v,y]);return(0,K.jsx)(ea.Provider,{value:b,children:a})};function na(){return G.useContext(ea)}var ra=G.createContext(null),ia=({children:e,...t})=>{let n=G.useMemo(()=>t,[t.items,t.onAddComment,t.onAddReply,t.onToggleReaction,t.mentionSuggestions,t.onUploadAttachments,t.loading,t.error]);return(0,K.jsx)(ra.Provider,{value:n,children:e})};function aa(){return G.useContext(ra)}var oa=(0,G.createContext)({}),sa=({value:e,children:t})=>(0,K.jsx)(oa.Provider,{value:e,children:t});function ca(){return(0,G.useContext)(oa)}var la=(0,G.createContext)(null),ua=({value:e,children:t})=>(0,K.jsx)(la.Provider,{value:e,children:t});function da(){return(0,G.useContext)(la)}function fa(){let{variables:e}=Y(),{updateContext:t}=yi();return G.useEffect(()=>(t({pageVariables:e}),()=>{t({pageVariables:{}})}),[e,t]),null}fa.displayName=`PageVariableActionBridge`;function pa(e){return!e||e.enabled!==!1&&e.handlerReady!==!1&&e.status!==`stub`&&e.status!==`unavailable`}[`a[href]`,`button:not([disabled])`,`input:not([disabled])`,`select:not([disabled])`,`textarea:not([disabled])`,`[tabindex]:not([tabindex="-1"])`].join(`, `);var ma={compact:32,comfortable:40,spacious:52},ha={compact:`py-1 px-2`,comfortable:`py-2 px-3`,spacious:`py-3 px-4`},ga={compact:`text-xs`,comfortable:`text-sm`,spacious:`text-base`},_a=[`compact`,`comfortable`,`spacious`];function va(e=`comfortable`,t){let[n,r]=(0,G.useState)(e),i=t?.rowHeights??ma,a=t?.paddingClasses??ha,o=t?.fontSizeClasses??ga,s=(0,G.useRef)(t?.onChange);(0,G.useEffect)(()=>{s.current=t?.onChange},[t?.onChange]);let c=(0,G.useRef)(e);(0,G.useEffect)(()=>{e!==c.current&&(c.current=e,r(e))},[e]);let l=(0,G.useCallback)(e=>{r(t=>t===e?t:(queueMicrotask(()=>s.current?.(e)),e))},[]),u=(0,G.useCallback)(()=>{r(e=>{let t=_a[(_a.indexOf(e)+1)%_a.length];return queueMicrotask(()=>s.current?.(t)),t})},[]);return(0,G.useMemo)(()=>({mode:n,setMode:l,cycle:u,rowHeight:i[n],paddingClass:a[n],fontSizeClass:o[n]}),[n,l,u,i,a,o])}function ya(e){return typeof window>`u`?()=>{}:(window.addEventListener(`online`,e),window.addEventListener(`offline`,e),()=>{window.removeEventListener(`online`,e),window.removeEventListener(`offline`,e)})}function ba(){return typeof navigator<`u`?navigator.onLine:!0}function xa(){return!0}var Sa=`objectui-offline-queue`;function Ca(){if(typeof localStorage>`u`)return[];try{let e=localStorage.getItem(Sa);return e?JSON.parse(e):[]}catch{return[]}}function wa(e){if(!(typeof localStorage>`u`))try{localStorage.setItem(Sa,JSON.stringify(e))}catch{}}var Ta=0;function Ea(){return Ta+=1,`mut_${Date.now()}_${Ta}`}var Q={enabled:!0,strategy:`network_first`,offlineIndicator:!0,offlineMessage:`You are currently offline. Changes will be synced when reconnected.`,queueMaxSize:100};function Da(e={}){let{enabled:t=Q.enabled,strategy:n=Q.strategy,offlineIndicator:r=Q.offlineIndicator,offlineMessage:i=Q.offlineMessage,queueMaxSize:a=Q.queueMaxSize,sync:o}=e,s=(0,G.useSyncExternalStore)(ya,ba,xa),[c,l]=(0,G.useState)(Ca),[u,d]=(0,G.useState)(`idle`),f=(0,G.useRef)(o);f.current=o,(0,G.useEffect)(()=>{wa(c)},[c]),(0,G.useEffect)(()=>{t&&(s?u===`offline`&&d(`idle`):d(`offline`))},[s,t,u]);let p=(0,G.useCallback)(e=>{t&&l(t=>{let n={...e,id:Ea(),timestamp:Date.now()},r=[...t,n];return r.length>a?r.slice(r.length-a):r})},[t,a]),m=(0,G.useCallback)(()=>{l([])},[]),h=(0,G.useCallback)(async()=>{if(!(!t||c.length===0)){d(`syncing`);try{let e=f.current?.batchSize??c.length,t=c.slice(0,e);await new Promise(e=>setTimeout(e,0)),l(e=>e.filter(e=>!t.some(t=>t.id===e.id))),d(`idle`)}catch{d(`error`)}}},[t,c]);return(0,G.useEffect)(()=>{if(!t||!s||c.length===0)return;let e=setTimeout(()=>{h()},100);return()=>clearTimeout(e)},[s,t]),(0,G.useMemo)(()=>({isOnline:s,enabled:t,syncState:u,strategy:n,pendingCount:c.length,queueMutation:p,sync:h,clearQueue:m,showIndicator:r&&!s,offlineMessage:i}),[s,t,u,n,c.length,p,h,m,r,i])}function Oa(){return{canUndo:F.canUndo,canRedo:F.canRedo,undoDescription:F.peekUndo()?.description,redoDescription:F.peekRedo()?.description,history:F.getHistory()}}function ka(){return{canUndo:!1,canRedo:!1,undoDescription:void 0,redoDescription:void 0,history:[]}}var Aa=Oa();function ja(e){return F.subscribe(()=>{Aa=Oa(),e()})}function Ma(){return Aa}function Na(e={}){let t=(0,G.useRef)(e);t.current=e;let n=(0,G.useSyncExternalStore)(ja,Ma,ka),r=(0,G.useCallback)(async(e,n,r)=>{let i=t.current.dataSource;if(!i)return;let a=r===`undo`?{create:`delete`,update:`update`,delete:`create`}[e.type]:e.type;a===`delete`?await i.delete(e.objectName,e.recordId):a===`update`?await i.update(e.objectName,e.recordId,n):await i.create(e.objectName,n)},[]),i=(0,G.useCallback)(async()=>{let e=F.popUndo();e&&(await r(e,e.undoData,`undo`),t.current.onUndo?.(e))},[r]),a=(0,G.useCallback)(async()=>{let e=F.popRedo();e&&(await r(e,e.redoData,`redo`),t.current.onRedo?.(e))},[r]);return(0,G.useEffect)(()=>{let e=e=>{!(e.ctrlKey||e.metaKey)||e.key.toLowerCase()!==`z`||(e.preventDefault(),e.shiftKey?a():i())};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[i,a]),(0,G.useMemo)(()=>({...n,undo:i,redo:a}),[n,i,a])}function Pa(e={}){let{actions:t=[],context:n={}}=e,r=(0,G.useContext)(X)?.runner??null,i=(0,G.useMemo)(()=>{let e=n&&Object.keys(n).length>0?{...n,ctx:n.ctx&&typeof n.ctx==`object`?{...n,...n.ctx}:{...n}}:n,i=r?new Ht(r):new Ht(e);if(r&&n&&Object.keys(n).length>0){let e=i.getRunner(),t=e.getEvaluator().getContext().toObject(),r=t&&typeof t.ctx==`object`?t.ctx:{},a=n.ctx&&typeof n.ctx==`object`?n.ctx:n,o={...n,ctx:{...r,...a}};e.updateContext(o)}return i.registerActions(t),i},[r,JSON.stringify(t),JSON.stringify(n)]);return{getActionsForLocation:(0,G.useCallback)(e=>i.getActionsForLocation(e),[i]),getBulkActions:(0,G.useCallback)(()=>i.getBulkActions(),[i]),executeAction:(0,G.useCallback)((e,t)=>i.executeAction(e,t),[i]),handleShortcut:(0,G.useCallback)(e=>i.handleShortcut(e),[i]),engine:i}}function Fa(){let e=(0,G.useContext)(X),t=J(),n=e?.runner?.getContext?.()?.user;if(Array.isArray(n?.systemPermissions))return n.systemPermissions;let r=t?.user;if(Array.isArray(r?.systemPermissions))return r.systemPermissions}function Ia(){let e=Fa();return(0,G.useCallback)(t=>!Array.isArray(t)||t.length===0||!Array.isArray(e)||t.every(t=>typeof t==`string`&&e.includes(t)),[e])}function La(e,t){return!0}function Ra(e,t={}){let n=Hi(),[r,i]=(0,G.useState)(!1),[a,o]=(0,G.useState)(null);(0,G.useEffect)(()=>{let e=!1;if(!n.ensureType){i(!0);return}return n.ensureType(`page`).then(()=>{e||(i(!0),o(null))}).catch(t=>{e||(o(t instanceof Error?t:Error(String(t))),i(!0))}),()=>{e=!0}},[n]);let s=(0,G.useMemo)(()=>{if(!e&&!t.pageName)return null;let r=Array.isArray(n.pages)?n.pages:[];if(!r.length)return null;if(t.pageName)return r.find(e=>e?.name===t.pageName)??null;let i=r.filter(n=>!n||(n.pageType??(n.type===`record`?`record`:void 0))!==`record`||n.object!==e?!1:La(n,t));return i.length?(i.sort((e,t)=>(t?.priority??0)-(e?.priority??0)),i[0]):null},[n.pages,e,t.pageName,t.recordType,t.profile,t.app,t.formFactor]),{page:c,slots:l}=(0,G.useMemo)(()=>s?s.kind===`slotted`?{page:null,slots:s.slots??{}}:{page:s,slots:null}:{page:null,slots:null},[s]);return{page:c,slots:l,loading:n.loading||!r,error:a??n.error??null}}function za(e,t,n){if(!e)return 0;let r=e.toLowerCase(),i=(t||``).toLowerCase();return(n||``).toLowerCase()===r?110:i===r?100:i.startsWith(r)?80:i.split(/[\s_\-/.,:;()[\]]+/).filter(Boolean).some(e=>e.startsWith(r))?60:i.includes(r)?40:0}function Ba(e){let{query:t,objects:n,dataSource:r,objectNames:i,maxObjectsQueried:a=8,topPerObject:o=3,minLength:s=2,debounceMs:c=250,enabled:l=!0,getDisplayName:u=Oe}=e,[d,f]=(0,G.useState)([]),[p,m]=(0,G.useState)(!1),[h,g]=(0,G.useState)(void 0),_=(0,G.useMemo)(()=>{if(!Array.isArray(n)||n.length===0)return[];let e;if(Array.isArray(i)&&i.length>0){let t=new Map;for(let e of n){let n=e?.name;typeof n==`string`&&t.set(n,e)}e=i.map(e=>t.get(e)).filter(e=>e!=null)}else e=n.filter(e=>e?.searchable!==!1);return e},[n,i]),v=(0,G.useMemo)(()=>_.map(e=>`${e?.name}:${e?.titleField??``}`).join(`|`),[_]),y=(0,G.useRef)(0);return(0,G.useEffect)(()=>{if(!l||!r||_.length===0){f([]),m(!1),g(void 0);return}let e=(t??``).trim();if(e.length<s){f([]),m(!1),g(void 0);return}let n=++y.current;m(!0),g(void 0);let i=setTimeout(()=>{if(y.current!==n)return;let t=r.searchAll;if(typeof t==`function`){let i=new Map;for(let e of _)typeof e?.name==`string`&&i.set(e.name,e);Promise.resolve().then(()=>t.call(r,e,{limit:a*o,objects:Array.from(i.keys())})).then(t=>{if(y.current!==n)return;let r=Array.isArray(t?.hits)?t.hits:Array.isArray(t)?t:[],a=[];for(let t of r){let n=t?.object??t?.objectName;if(typeof n!=`string`||i.size>0&&!i.has(n))continue;let r=t?.id??t?.record?.id??t?.record?._id;if(r==null)continue;let o=i.get(n)??{name:n},s=(typeof t?.title==`string`&&t.title.trim()!==``?t.title.trim():``)||u(o,t?.record??{})||`Record #${r}`,c=typeof t?.snippet==`string`?t.snippet.trim():``;a.push({objectName:n,objectLabel:typeof o.label==`string`&&o.label.length>0?o.label:n,recordId:String(r),display:s,subtitle:c&&c!==s?c:void 0,icon:o?.icon,score:za(e,s,String(r)),raw:t?.record??t})}a.sort((e,t)=>(t.score===110)-+(e.score===110)),f(a),m(!1),g(void 0)}).catch(e=>{y.current===n&&(f([]),m(!1),g(e instanceof Error?e:Error(String(e))))});return}let i=_.slice(0,a).map(t=>Promise.resolve().then(()=>r.find(t.name,{$search:e,$top:o})).then(e=>({obj:t,res:e,err:null})).catch(e=>({obj:t,res:null,err:e})));Promise.allSettled(i).then(t=>{if(y.current!==n)return;let r=[],i;for(let n of t){if(n.status!==`fulfilled`)continue;let{obj:t,res:a,err:s}=n.value;if(s){let e=s?.httpStatus??s?.status;if(s?.code,e===404||kt(s,`OBJECT_NOT_FOUND`))continue;i=s instanceof Error?s:Error(String(s));continue}let c=Array.isArray(a?.data)?a.data:Array.isArray(a)?a:[];for(let n of c.slice(0,o)){let i=n?.id??n?._id;if(i==null)continue;let a=u(t,n);r.push({objectName:t.name,objectLabel:typeof t.label==`string`&&t.label.length>0?t.label:t.name,recordId:String(i),display:a,icon:t?.icon,score:za(e,a,String(i)),raw:n})}}r.sort((e,t)=>t.score-e.score),f(r),m(!1),g(i)})},c);return()=>{clearTimeout(i)}},[t,l,r,v,o,a,s,c,u]),{results:d,isSearching:p,error:h}}var Va=new Set,Ha=`objectui:related-changed`;function Ua(e){for(let t of Array.from(Va))try{t(e)}catch{}typeof window<`u`&&window.dispatchEvent(new CustomEvent(Ha,{detail:{objectName:e.objectName,recordId:e.recordId}}))}function Wa(e){return Va.add(e),()=>Va.delete(e)}function Ga(e,t,n){return e.objectName===`*`?!0:e.objectName===t?n===void 0||e.recordId===void 0||e.recordId===n:!1}function Ka(e,t){let[n,r]=(0,G.useState)(0);return(0,G.useEffect)(()=>{if(e)return Wa(n=>{Ga(n,e,t)&&r(e=>e+1)})},[e,t]),n}function qa(e){(0,G.useEffect)(()=>{let t=e;if(t?.onMutation)return t.onMutation(e=>{e?.resource&&Ua({objectName:e.resource,recordId:e.id==null?void 0:String(e.id)})})},[e])}function $(...e){for(let t of e)if(typeof t==`string`&&t.trim())return t;return null}function Ja(e){let t=e,n=t&&typeof t==`object`?$(t.details?.error,t.details?.message,t.error):null;if(!n){let r=e instanceof Error?e.message:typeof e==`string`?e:typeof t?.message==`string`?t.message:``,i=r.indexOf(`{`);if(i>=0)try{let e=JSON.parse(r.slice(i));n=$(e?.error,e?.message)}catch{}!n&&r.trim()&&(n=r)}return n&&n.replace(/^\[[^\]]+\]\s*/,``).replace(/^[A-Z][A-Z0-9_]+:\s*/,``).trim()||null}function Ya(e){let t=e;if(!t||typeof t!=`object`)return null;let n=Array.isArray(t.validationErrors)&&t.validationErrors||Array.isArray(t.details?.fields)&&t.details.fields||Array.isArray(t.fields)&&t.fields||null;if(!n||!Array.isArray(n))return null;let r=[];for(let e of n){if(!e||typeof e!=`object`)continue;let t=e,n=$(t.field,t.name,t.path);if(!n)continue;let i=$(t.message,t.error,t.code)??``;r.push({field:n,message:i})}return r.length>0?r:null}function Xa(e){let t=e;if(!t||typeof t!=`object`)return!1;if((t.httpStatus??t.status??t.statusCode)===403)return!0;let n=$(t.code,t.details?.code)??``;if(n===`PERMISSION_DENIED`||n===`FORBIDDEN`)return!0;let r=`${typeof t.message==`string`?t.message:``} ${t.details?.error??t.error??``}`;return/row-level security|access denied|permission denied|not permitted/i.test(r)}var Za=n(((t,n)=>{var r=Object.defineProperty,i=Object.getOwnPropertyDescriptor,a=Object.getOwnPropertyNames,o=Object.prototype.hasOwnProperty,s=(e,t)=>{for(var n in t)r(e,n,{get:t[n],enumerable:!0})},c=(e,t,n,s)=>{if(t&&typeof t==`object`||typeof t==`function`)for(let c of a(t))!o.call(e,c)&&c!==n&&r(e,c,{get:()=>t[c],enumerable:!(s=i(t,c))||s.enumerable});return e},l=e=>c(r({},`__esModule`,{value:!0}),e),u={};s(u,{ObjectLogger:()=>S,createLogger:()=>ee}),n.exports=l(u);var d={debug:0,info:1,warn:2,error:3,fatal:4,silent:5},f={debug:`\x1B[36m`,info:`\x1B[32m`,warn:`\x1B[33m`,error:`\x1B[31m`,fatal:`\x1B[35m`,silent:``},p=`\x1B[0m`;function m(e){return e.replace(/([a-z0-9])([A-Z])/g,`$1 $2`).replace(/([A-Z]+)([A-Z][a-z])/g,`$1 $2`).replace(/([a-zA-Z])([0-9])/g,`$1 $2`).split(/[^A-Za-z0-9]+/).filter(Boolean).map(e=>e.toLowerCase())}function h(e){return/(?:ss|us|is)$/.test(e)?e:/(?:ch|sh|s|x|z)es$/.test(e)?e.slice(0,-2):/[a-z0-9]s$/.test(e)?e.slice(0,-1):e}var g=new Set(`access.account.admin.api.app.auth.bearer.client.csrf.db.database.encryption.id.jwt.master.oauth.private.public.refresh.root.secret.service.session.shared.sign.signing.ssh.token.user.webhook.xsrf`.split(`.`));function _(e,t){for(let n of[e,h(e)])if(!(n.length<=t.length||!n.endsWith(t))&&g.has(n.slice(0,n.length-t.length)))return!0;return!1}function v(e,t){for(let n=0;n+t.length<=e.length;n++)if(t.every((t,r)=>e[n+r]===t))return!0;return!1}function y(e,t){if(t.length===0||e.length===0)return!1;if(t.length>1){let n=t.join(``);return v(e,t)||e.some(e=>e===n||h(e)===n)}let n=t[0],r=e.filter(e=>/[a-z]/.test(e)).length>1;return e.some(e=>e===n||r&&h(e)===n||_(e,n))}function b(e){if(typeof process<`u`){let e={}.NO_COLOR;if(e!==void 0&&e!==``)return!1}return!!e?.isTTY}function x(t){if(typeof process>`u`)return;let n=process.getBuiltinModule;if(typeof n==`function`)try{return n.call(process,`node:${t}`)}catch{return}try{return e(t)}catch{return}}var S=class e{constructor(e={},t={}){this.ownsFileStream=!1,this.fileLoggingDisabled=!1,this.config={name:e.name,level:e.level??`info`,format:e.format??`pretty`,redact:e.redact??[`password`,`token`,`secret`,`key`],sourceLocation:e.sourceLocation??!1,file:e.file,rotation:e.rotation??{maxSize:`10m`,maxFiles:5}},this.bindings=t,this.redactPatterns=this.config.redact.map(m).filter(e=>e.length>0),this.config.file&&typeof process<`u`&&this.openFileStream(this.config.file)}openFileStream(e){let t=x(`fs`),n=x(`path`);if(!t||!n){this.disableFileLogging(e,`no filesystem access in this runtime`);return}try{t.mkdirSync(n.dirname(e),{recursive:!0});let r=t.createWriteStream(e,{flags:`a`});r.on(`error`,t=>this.disableFileLogging(e,t.message)),this.fileStream=r,this.ownsFileStream=!0}catch(t){this.disableFileLogging(e,t.message)}}disableFileLogging(e,t){if(this.fileStream=void 0,this.ownsFileStream=!1,this.fileLoggingDisabled)return;this.fileLoggingDisabled=!0;let n=`${this.config.name?`[${this.config.name}] `:``}logger: file logging disabled \u2014 cannot write to ${e}: ${t}`;typeof process<`u`&&process.stderr?process.stderr.write(n+`
6
- `):typeof console<`u`&&console.warn(n)}isEnabled(e){return d[e]>=d[this.config.level]}isRedactedFieldName(e){let t=m(e);return this.redactPatterns.some(e=>y(t,e))}redactSensitive(e){if(!e||typeof e!=`object`)return e;let t=Array.isArray(e)?[...e]:{...e};for(let e in t)this.isRedactedFieldName(e)?t[e]=`***REDACTED***`:typeof t[e]==`object`&&t[e]!==null&&(t[e]=this.redactSensitive(t[e]));return t}write(e,t,n,r){if(!this.isEnabled(e))return;let i=this.redactSensitive({...this.bindings,...n,...r?{error:{message:r.message,stack:r.stack}}:{}}),a=Object.keys(i).length>0,o=new Date().toISOString(),s=e===`error`||e===`fatal`,c=typeof process<`u`?process:void 0,l=c?s?c.stderr:c.stdout:void 0,u,d;if(this.config.format===`json`)u=d=JSON.stringify({time:o,level:e,...this.config.name?{name:this.config.name}:{},msg:t,...i});else if(this.config.format===`text`){let n=[o,e.toUpperCase(),t];a&&n.push(JSON.stringify(i)),u=d=n.join(` | `)}else{let n=this.config.name?`[${this.config.name}] `:``,r=`${o} ${e.toUpperCase()}`,s=` ${n}${t}`;a&&(s+=` ${JSON.stringify(i)}`),d=r+s;let c=f[e]||``;u=c&&b(l)?`${c}${r}${p}${s}`:d}l?l.write(u+`
7
- `):typeof console<`u`&&(e===`error`||e===`fatal`?console.error:e===`warn`?console.warn:e===`debug`?console.debug:console.log)(u),this.fileStream&&this.fileStream.write(d+`
8
- `)}debug(e,t){this.write(`debug`,e,t)}info(e,t){this.write(`info`,e,t)}warn(e,t){this.write(`warn`,e,t)}error(e,t,n){this.writeErrorLike(`error`,e,t,n)}fatal(e,t,n){this.writeErrorLike(`fatal`,e,t,n)}writeErrorLike(e,t,n,r){if(n instanceof Error){this.write(e,t,r,n);return}let i=n&&r?{...n,...r}:n??r;this.write(e,t,i)}log(e,...t){this.info(e,t.length>0?{args:t}:void 0)}child(t){let n=new e({...this.config,file:void 0},{...this.bindings,...t});return n.config.file=this.config.file,n.fileStream=this.fileStream,n}withTrace(e,t){return this.child({traceId:e,spanId:t})}async destroy(){let e=this.fileStream;this.fileStream=void 0,!(!e||!this.ownsFileStream)&&(this.ownsFileStream=!1,await new Promise(t=>e.end(t)))}};function ee(e){return new S(e)}0&&(n.exports={ObjectLogger:S,createLogger:ee})}));export{ui as $,Zt as $t,qi as A,Ae as An,yr as At,ji as B,C as Bn,tr as Bt,aa as C,rt as Cn,Cr as Ct,Qi as D,N as Dn,_r as Dt,Gi as E,Qe as En,br as Et,Ui as F,he as Fn,dr as Ft,vi as G,d as Gn,Rn as Gt,Pi as H,x as Hn,Wn as Ht,Ii as I,me as In,sr as It,gi as J,hn as Jt,yi as K,Nn as Kt,Li as L,E as Ln,Jn as Lt,Bi as M,xe as Mn,hr as Mt,zi as N,Oe as Nn,mr as Nt,Ki as O,M as On,vr as Ot,Hi as P,pe as Pn,fr as Pt,li as Q,en as Qt,ki as R,se as Rn,or as Rt,ia as S,vt as Sn,wr as St,na as T,Je as Tn,xr as Tt,Mi as U,ne as Un,Ln as Ut,Ai as V,ie as Vn,Un as Vt,X as W,f as Wn,zn as Wt,mi as X,un as Xt,_i as Y,dn as Yt,di as Z,L as Zt,fa as _,St as _n,jr as _t,Ua as a,Nt as an,Ur as at,sa as b,yt as bn,Tr as bt,qa as c,Rt as cn,J as ct,Ia as d,At as dn,zr as dt,Yt as en,si as et,Pa as f,Ot as fn,Vr as ft,pa as g,xt as gn,Pr as gt,va as h,wt as hn,Rr as ht,Xa as i,Ut as in,Y as it,Ri as j,ke as jn,gr as jt,$i as k,ze as kn,pr as kt,Ba as l,Lt as ln,qr as lt,Da as m,Et as mn,Mr as mt,Ya as n,Gt as nn,Xr as nt,Wa as o,It as on,Wr as ot,Na as p,Dt as pn,Br as pt,bi as q,Mn as qt,Ja as r,Wt as rn,Qr as rt,Ka as s,Pt as sn,Kr as st,Za as t,Xt as tn,$r as tt,Ra as u,kt as un,q as ut,ua as v,bt as vn,kr as vt,ta as w,it as wn,Sr as wt,ca as x,_t as xn,Er as xt,da as y,Ct as yn,U as yt,Ni as z,oe as zn,nr as zt};