@objectstack/console 16.0.0-rc.0 → 16.0.0-rc.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/.objectui-sha +1 -1
- package/dist/assets/{AdapterProvider-DaQhp5MR.js → AdapterProvider-DkXaFA1A.js} +1 -1
- package/dist/assets/{AiPendingActionsPage-9UZ4_qZW.js → AiPendingActionsPage-C1pkyzWu.js} +1 -1
- package/dist/assets/{ApiConsolePage-DVnQPvbh.js → ApiConsolePage-BCujjvCA.js} +1 -1
- package/dist/assets/{AppDocsIndex-RWbVdvGq.js → AppDocsIndex-DwtDfwnR.js} +1 -1
- package/dist/assets/{AppManagementPage-JlGIV3AH.js → AppManagementPage-KPrmIA-f.js} +1 -1
- package/dist/assets/ApprovalsInboxPage-DFQUv0F_.js +1 -0
- package/dist/assets/{AuditLogPage-C6SMCaHa.js → AuditLogPage-BNkFvefV.js} +1 -1
- package/dist/assets/{ComponentNavView-DpWz8z8w.js → ComponentNavView-FTFk3uvC.js} +1 -1
- package/dist/assets/{CreateViewDialog-DQqqIAwO.js → CreateViewDialog-DTzKynzF.js} +1 -1
- package/dist/assets/{DashboardView-BTS9ygDI.js → DashboardView-Y6nIjjJB.js} +1 -1
- package/dist/assets/{DeveloperHubPage-CX3urxAq.js → DeveloperHubPage-CYPM3AvL.js} +1 -1
- package/dist/assets/{DocShell-CXBgEZhg.js → DocShell-DnXj6ocC.js} +1 -1
- package/dist/assets/{ExpressionProvider-C26LCaQj.js → ExpressionProvider-BrbZIz2M.js} +1 -1
- package/dist/assets/{FlowRunsPage-DKnUh_Ec.js → FlowRunsPage-BAbmqrqx.js} +1 -1
- package/dist/assets/{IntegrationsPage-BvyX5vIh.js → IntegrationsPage-CyD9iolE.js} +1 -1
- package/dist/assets/InterfaceListPage-DdaX7c_c.js +1 -0
- package/dist/assets/ManagedByBadge-DbYycO1m.js +1 -0
- package/dist/assets/{MarketplaceAccessDenied-DFaKQ3Ws.js → MarketplaceAccessDenied-Csr3Jh7C.js} +1 -1
- package/dist/assets/{MarketplaceInstalledPage-CKmxuBaG.js → MarketplaceInstalledPage-BtD9NMRl.js} +1 -1
- package/dist/assets/{MarketplacePackagePage-BjhnLR61.js → MarketplacePackagePage-DHrjr3jY.js} +1 -1
- package/dist/assets/{MarketplacePage-BWLFbDxW.js → MarketplacePage-Dw2yHsdE.js} +1 -1
- package/dist/assets/{MetadataInspector-B9z7wtJS.js → MetadataInspector-C6pU5_lx.js} +1 -1
- package/dist/assets/{MetadataProvider-Dq7I7eh-.js → MetadataProvider-BnfG1pyl.js} +1 -1
- package/dist/assets/{ObjectDataPage-Bm9tSz-w.js → ObjectDataPage-BA93ldBf.js} +1 -1
- package/dist/assets/PageView-jtsz_IPE.js +1 -0
- package/dist/assets/{ProfilePage-DAkDEioN.js → ProfilePage-BhlwjGUP.js} +1 -1
- package/dist/assets/{PublicFormsPage-CRNSj35t.js → PublicFormsPage-D5kg7qJa.js} +1 -1
- package/dist/assets/RecordDetailView-F0k3QMTV.js +9 -0
- package/dist/assets/{RecordFormPage-Cye1lcxq.js → RecordFormPage-BRDfPdPg.js} +1 -1
- package/dist/assets/{ReportDefaultInspector-B0nTPIZ8.js → ReportDefaultInspector-CYCJDOVb.js} +1 -1
- package/dist/assets/{ReportView-BeL2GZLl.js → ReportView-Dtz9IJbH.js} +1 -1
- package/dist/assets/{SearchResultsPage-XP2cdAyq.js → SearchResultsPage-0pCQZ9_u.js} +1 -1
- package/dist/assets/{SettingsHub-yoHgXGvm.js → SettingsHub-DqS8nfs-.js} +1 -1
- package/dist/assets/{SettingsView-BO0qYMbW.js → SettingsView-DHrrHsbU.js} +1 -1
- package/dist/assets/{SystemHubPage-qOFiW2Jq.js → SystemHubPage-BWPXrnc9.js} +1 -1
- package/dist/assets/data-adapter-BR5P3Htq.js +9 -0
- package/dist/assets/framework-brxTxzwx.js +8 -0
- package/dist/assets/{getIcon-CBdepA3t.js → getIcon-EzAarNT8.js} +1 -1
- package/dist/assets/{highlighted-body-OFNGDK62-CYfwZSTb.js → highlighted-body-OFNGDK62-3tGE6imP.js} +1 -1
- package/dist/assets/{i18n-grFi0A0v.js → i18n-CWIk44wT.js} +1 -1
- package/dist/assets/index-LuGaXtX0.js +2 -0
- package/dist/assets/infrastructure-C6pQBkbt.js +3 -0
- package/dist/assets/mermaid-GHXKKRXX-btdeklf1.js +1 -0
- package/dist/assets/{metadata-admin-D3yD8v_g.js → metadata-admin-Buf34qxl.js} +7 -7
- package/dist/assets/plugin-calendar-Bx_Bsdae.js +1 -0
- package/dist/assets/plugin-charts-DqND8tT3.js +7 -0
- package/dist/assets/plugin-chatbot-DwbSyUax.js +120 -0
- package/dist/assets/plugin-dashboard-D2VhHDxA.js +6 -0
- package/dist/assets/plugin-form-HMQsT2Tp.js +1 -0
- package/dist/assets/plugin-gantt-CMpG3oO4.js +63 -0
- package/dist/assets/plugin-grid-Dz4WW_sQ.js +8 -0
- package/dist/assets/plugin-kanban-fgScBnfP.js +1 -0
- package/dist/assets/{plugin-map-fMpIp7jh.js → plugin-map-zagD7Zuk.js} +1 -1
- package/dist/assets/{plugin-markdown-wZpqyjok.js → plugin-markdown-DtcSX8M_.js} +1 -1
- package/dist/assets/{plugin-report-kGtO0FOF.js → plugin-report-BRs6v5vb.js} +3 -3
- package/dist/assets/{plugin-timeline-DZNEy3Y1.js → plugin-timeline-Cl8J9HYj.js} +1 -1
- package/dist/assets/{plugin-tree-CZRX9ChE.js → plugin-tree-B3zTpUOf.js} +1 -1
- package/dist/assets/plugin-view-BDYhOlHx.js +1 -0
- package/dist/assets/plugins-views-Dc4ARhcP.js +4 -0
- package/dist/assets/{skeletons-CX6Ch5Lg.js → skeletons-CPF9cI6N.js} +1 -1
- package/dist/assets/{src-DNd8fJOE.js → src-A4S4Zx5p.js} +1 -1
- package/dist/assets/{src-CIr5NcaF.js → src-By-rFjBo.js} +1 -1
- package/dist/assets/src-CRFYUj2Z.js +19 -0
- package/dist/assets/{types-C0F-S2Id.js → types-CtGENai_.js} +1 -1
- package/dist/assets/ui-components-D1psd5qA.js +72 -0
- package/dist/assets/{ui-layout-CmmmekN3.js → ui-layout-UgL2qgLW.js} +1 -1
- package/dist/assets/{use-book-data-DyDHAzga.js → use-book-data-CWCLCSUn.js} +1 -1
- package/dist/assets/{useMetadata-BMHVJNxp.js → useMetadata-Byeqylbl.js} +1 -1
- package/dist/assets/vendor-objectstack-CjHQG7Oa.js +114 -0
- package/dist/index.html +3 -3
- package/package.json +1 -1
- package/dist/assets/ApprovalsInboxPage-DMfSM-B7.js +0 -1
- package/dist/assets/InterfaceListPage-D00ihpcS.js +0 -1
- package/dist/assets/ManagedByBadge-B4O4Jy3c.js +0 -1
- package/dist/assets/PageView-BTHYu8Z9.js +0 -1
- package/dist/assets/RecordDetailView-C6UiMORv.js +0 -9
- package/dist/assets/data-adapter-CS4onYGf.js +0 -9
- package/dist/assets/framework-Oi7uo_kE.js +0 -8
- package/dist/assets/index-D_-Sh_Rw.js +0 -2
- package/dist/assets/infrastructure-CQFJ5N6p.js +0 -3
- package/dist/assets/mermaid-GHXKKRXX-DtO0m-Vl.js +0 -1
- package/dist/assets/plugin-calendar-Bm0-Kkhu.js +0 -1
- package/dist/assets/plugin-charts-BHxVdXp7.js +0 -7
- package/dist/assets/plugin-chatbot-BRbgUPLw.js +0 -120
- package/dist/assets/plugin-dashboard-ARn_CaB3.js +0 -6
- package/dist/assets/plugin-form-C969LzWi.js +0 -1
- package/dist/assets/plugin-gantt-DrEbvyAE.js +0 -63
- package/dist/assets/plugin-grid-CnxMz-9O.js +0 -8
- package/dist/assets/plugin-kanban-C-mR5I0H.js +0 -1
- package/dist/assets/plugin-view-BhPeq9o5.js +0 -1
- package/dist/assets/plugins-views-DCG6qMPm.js +0 -4
- package/dist/assets/src-CB6vSDbd.js +0 -19
- package/dist/assets/ui-components-BluZyuZX.js +0 -72
- package/dist/assets/vendor-objectstack-DxPvmbmF.js +0 -114
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import{i as e,o as t,t as n}from"./rolldown-runtime-DAXXjFlN.js";import{r,y as i}from"./vendor-react-BKSb6vFP.js";import{D as a,k as o}from"./vendor-objectstack-DxPvmbmF.js";var s=`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.line_items.flex.grid.stack.card.tabs.accordion.container.page:header.text.image.icon.markdown.element:divider.badge.alert.button.html`.split(`.`);new Set(s);var c=new class{components=new Map;lazyEntries=new Map;listeners=new Set;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)}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(){for(let e of this.listeners)try{e()}catch(e){console.error(`[Registry] listener error`,e)}}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())}getAllConfigs(){return Array.from(this.components.values())}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 s)n(e,this.getConfig(e));for(let[e,t]of this.components.entries())t.tier===`public`&&!e.includes(`:`)&&n(e,t);return t}getNamespaceComponents(e){return Array.from(this.components.values()).filter(t=>t.namespace===e)}},l={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 u(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(l).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 d(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 f(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 p(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=m(e,`${t}.children[${r}]`);n.push(...i.errors,...i.warnings)}});else if(typeof r==`object`&&r){let e=m(r,`${t}.children`);n.push(...e.errors,...e.warnings)}}return n}function m(e,t=`schema`){let n=[];n.push(...u(e,t)),n.push(...d(e,t)),n.push(...f(e,t)),n.push(...p(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}}function h(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 g(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`){console.warn(`[ObjectUI] Warning: \$regex operator is not fully supported. Converting to 'contains' which only supports substring matching, not regex patterns. Field: '${n}', Value: ${JSON.stringify(i)}. Consider using $contains or $startsWith instead.`),t.push([n,`contains`,i]);continue}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=h(e);if(r)t.push([n,r,i]);else throw Error(`[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 _(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 v=new Set([`lookup`,`master_detail`,`tree`,`user`]);function y(e){return!!e&&typeof e==`object`&&v.has(e.type)}function ee(e,t){if(!e||typeof e!=`object`)return[];let n=[];for(let[t,r]of Object.entries(e))y(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)if(typeof n==`string`)e.add(n);else if(n&&typeof n==`object`){let t=n.field??n.name??n.fieldName;t&&e.add(t)}return n.filter(t=>e.has(t))}return n}var te=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}},ne={Math,JSON,parseInt,parseFloat,isNaN,isFinite},re=new Set([`constructor`,`__proto__`,`prototype`,`__defineGetter__`,`__defineSetter__`,`__lookupGetter__`,`__lookupSetter__`]),ie=class e{source=``;pos=0;context={};_evaluating=!0;evaluate(e,t){this.source=e.trim(),this.pos=0,this.context={...ne,...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`&&re.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}else{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=null;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;break}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}},ae=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 ie;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)}}},oe=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)=>b(e).reduce((e,t)=>e+t,0)),this.register(`AVG`,(...e)=>{let t=b(e);return t.length===0?0:t.reduce((e,t)=>e+t,0)/t.length}),this.register(`COUNT`,(...e)=>x(e).filter(e=>e!=null).length),this.register(`MIN`,(...e)=>{let t=b(e);return t.length===0?0:Math.min(...t)}),this.register(`MAX`,(...e)=>{let t=b(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/(1e3*60*60*24));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/(1e3*60*60));case`minute`:case`minutes`:return Math.floor(a/(1e3*60));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=b(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=b(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=b(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=b(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 b(e){let t=[];for(let n of e)if(Array.isArray(n))t.push(...b(n));else{let e=Number(n);isNaN(e)||t.push(e)}return t}function x(e){let t=[];for(let n of e)Array.isArray(n)?t.push(...x(n)):t.push(n);return t}function se(e){return typeof e==`string`?{dialect:`cel`,source:e}:{dialect:e.dialect??`cel`,source:e.source}}function S(e,t,n,r,i){if(e==null||typeof e==`string`&&!e.trim())return n;try{let o=a.evaluate(se(e),{record:t,previous:r,...i?{extra:i}:{}});return o.ok?o.value===!0:n}catch{return n}}function C(e,t,n,r,i){let a=e.visibleWhen==null||S(e.visibleWhen,t,!0,r,i),o=n.readonly===!0||e.readonlyWhen!=null&&S(e.readonlyWhen,t,!1,r,i),s=e.requiredWhen??e.conditionalRequired;return{visible:a,readonly:o,required:n.required===!0||s!=null&&S(s,t,!1,r,i)}}var w=class e{context;cache;formulas;constructor(e,t,n){e instanceof te?this.context=e:this.context=new te(e||{}),this.cache=t||new ae,this.formulas=n||new oe}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 S(e,i,!0,void 0,n);let a=S(e,i,!0,void 0,n);if(a!==S(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 ae,new oe;var T=/\$\{|===|!==|\?\.|\?\?|\.(?:includes|indexOf|toUpperCase|toLowerCase|startsWith|endsWith|trim|split|map|filter|reduce|find|some|every|join|slice|charAt|padStart|padEnd|replace|match|test)\s*\(/;function E(e){return T.test(e)}var D=new Set;function ce(e){D.has(e)||(D.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 le=new Set;function O(e,t){let n=(t??``)+`\0`+e;le.has(n)||(le.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 k(e,t,n){let r=S(e,t,!0,void 0,n);return r===S(e,t,!1,void 0,n)?{ok:!0,value:r}:{ok:!1,value:!1}}function A(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&&E(i)){ce(i);try{return new w({...o,record:a}).evaluateCondition(i,{throwOnError:!0})}catch{return n.warnOnError&&O(i,n.label),r}}if(!n.warnOnError)return S(e,a,r,void 0,o);let s=k(e,a,o);return s.ok?s.value:(O(i??`(expression)`,n.label),r)}function j(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(j).join(`, `)}]`:JSON.stringify(String(e))}function ue(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} == ${j(r)}`;case`not_equals`:return`${i} != ${j(r)}`;case`greater_than`:return`${i} > ${j(r)}`;case`less_than`:return`${i} < ${j(r)}`;case`contains`:return`${i}.contains(${j(r)})`;case`in`:return`${i} in ${j(Array.isArray(r)?r:[r])}`;default:return null}}function de(e){return e.condition==null?typeof e.expression==`string`&&e.expression.trim()?e.expression:ue(e):e.condition}function fe(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 pe(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=de(i);if(a!=null&&A(a,r,{fallback:!1,scope:n,label:`conditionalFormatting[${e}]`}))return fe(i)}return{}}function me(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 he(e){return e==null||e===``||Array.isArray(e)&&e.length===0}function ge(e,t){return me(e).some(e=>he(t[e]))}function _e(e,t,n){return!e||e.length===0?[]:e.filter(e=>e?.visibleWhen==null||S(e.visibleWhen,t,!0,void 0,n))}function ve(e,t){return he(e)?!0:Array.isArray(e)?e.every(e=>t.some(t=>t.value===e)):t.some(t=>t.value===e)}function ye(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 M=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(ye)),Array.isArray(n.redoStack)&&(this.redoStack=n.redoStack.filter(ye)),this.undoStack.length>this.maxHistory&&this.undoStack.splice(0,this.undoStack.length-this.maxHistory),this.notify()}catch{}}notify(){this.listeners.forEach(e=>e())}};function be(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 N=class{handlers=new Map;scripts=new Map;evaluator;context;confirmHandler;toastHandler;modalHandler;navigationHandler;paramCollectionHandler;resultDialogHandler;constructor(e={}){this.context=be(e),this.evaluator=new w(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{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;switch(t){case`script`:i=await this.executeScript(e);break;case`url`:i=await this.executeUrl(e);break;case`modal`:i=await this.executeModal(e);break;case`flow`:i=await this.executeFlow(e);break;case`api`:i=await this.executeAPI(e);break;case`form`:i=await this.executeForm(e);break;case`navigation`:i=await this.executeNavigation(e);break;default: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)}return 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{M.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.execute||e.target;if(!t)return{success:!1,error:`No script provided for script action`};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;if(!t)return{success:!1,error:`No URL provided for url action`};let n=this.interpolateTarget(t,e),r=this.evaluator.evaluate(n);if(!this.isValidUrl(r))return{success:!1,error:`Invalid URL scheme. Only http://, https://, and relative URLs are allowed.`};let i=typeof this.context.apiBase==`string`?this.context.apiBase.replace(/\/+$/,``):``;i&&/^\/(api|_auth|_account)\//.test(r)&&(r=`${i}${r}`);let a=r.startsWith(`http://`)||r.startsWith(`https://`);if(/\/(api|_auth|_account)\//.test(r)&&(a||r.startsWith(`/`)))return window.location.href=r,{success:!0};let o=e.openIn===`new-tab`?!0:e.openIn===`self`?!1:e.params?.newTab??a;if(this.navigationHandler)return this.navigationHandler(r,{external:a,newTab:o}),{success:!0};if(o)window.open(r,`_blank`,`noopener,noreferrer`);else return{success:!0,redirect:r};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={success:!0};if(e.api||e.endpoint){let n=await this.executeAPI(e);if(!n.success)return n;t.data=n.data}return e.onClick&&await e.onClick(),t.reload=e.reload!==!1,t.close=e.close!==!1,e.redirect&&(t.redirect=this.evaluator.evaluate(e.redirect)),t}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=this.evaluator.evaluate(t.to||t.target);if(!this.isValidUrl(n))return{success:!1,error:`Invalid URL scheme. Only http://, https://, and relative URLs are allowed.`};let r=t.external||typeof n==`string`&&(n.startsWith(`http://`)||n.startsWith(`https://`));if(this.navigationHandler)return this.navigationHandler(n,{external:r,newTab:t.newTab??r,replace:t.replace}),{success:!0};if(r)window.open(n,`_blank`,`noopener,noreferrer`);else return{success:!0,redirect:n};return{success:!0}}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=xe(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};return this.context.ctx&&typeof this.context.ctx==`object`&&Object.assign(e,this.context.ctx),e}updateContext(e){this.context=be({...this.context,...e}),this.evaluator.updateContext(this.context)}getContext(){return this.context}getEvaluator(){return this.evaluator}};function xe(e,t){if(e!=null)return t.split(`.`).reduce((e,t)=>{if(e!=null)return e[t]},e)}function Se(e){return/^[a-z][a-z0-9]*(_[a-z0-9]+)*$/.test(e)}function Ce(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 we(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 Te=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(`.`));function Ee(e,t){return t?.system===!0||Te.has(e)}function De(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 Oe(e){let t=e.type??`tabular`,n=t===`joined`||t===`tabular`?`tabular`:t,r=(e.values??[]).map(e=>({name:e,label:De(void 0,e)})),i=(e.rows??[]).map(e=>({field:e,sort:`asc`}));return{type:`report`,title:De(e.label,e.name),description:e.description?De(e.description,``):void 0,reportType:n,fields:r,groupBy:i.length>0?i:void 0}}function ke(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)}var Ae=[`list_toolbar`,`list_item`,`record_header`,`record_more`,`record_related`,`record_section`,`global_nav`];o(Ae);function je(e){return e.toLowerCase().split(`+`).map(e=>e.trim()).sort().join(`+`)}var Me=new Set;function Ne(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(Me.has(i))return;Me.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 Pe=class{actions=new Map;mappings=[];shortcuts=[];normalizedShortcutMap=new Map;runner;constructor(e={}){this.runner=e instanceof N?e:new N(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(je(t.shortcut),n))}registerActions(e){for(let t of e)this.registerAction(t,{locations:t.locations,shortcut:t.shortcut,bulkEnabled:t.bulkEnabled})}unregisterAction(e){let t=this.actions.get(e);t?.shortcut&&this.normalizedShortcutMap.delete(je(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;if(typeof n==`string`)r=`\${${n}}`;else if(typeof n==`object`&&typeof n.source==`string`){let e=n.source;if(!e)return!0;r=`\${${e}}`}else r=!!n;try{return t.evaluateCondition(r,{throwOnError:!0})}catch(t){return Ne(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(je(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 Fe(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 Ie(e){if(e!=null)return e.id??e._id??e.recordId}function Le(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=Ie(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 P(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,Le(i.data??{},n));n.push(t);let a=Ie(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,Le(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 Re(e,t){return typeof e.batchTransaction==`function`?e.batchTransaction(t):P(e,t)}function ze(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 Be(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&&(Array.isArray(e.$orderby)?typeof e.$orderby[0]==`string`?t.$orderby=e.$orderby.join(`,`):t.$orderby=e.$orderby.map(e=>`${e.field} ${e.order||`asc`}`).join(`,`):t.$orderby=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 Ve(e,t){return{...e,...t}}var He=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=ze(e.url,t.pathSuffix,r),a=Ve(Ve(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=Be(t),r=await this.request(this.readConfig,{method:`GET`,queryParams:n});return this.normalizeQueryResult(r)}async findOne(e,t,n){try{let e=Be(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 P(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 F(e,t){return t?e[t]:e.id??e._id}function I(e,t){if(!t||t.length===0)return!0;let n=t[0];if(n===`and`)return t.slice(1).every(t=>I(e,t));if(n===`or`)return t.slice(1).some(t=>I(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 Ue(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;break;default:break}else if(t!==r)return!1}return!0}function We(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 Ge(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 Ke=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=>I(e,t.$filter)):!Array.isArray(t.$filter)&&Object.keys(t.$filter).length>0&&(n=n.filter(e=>Ue(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=We(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=>Ge(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(F(e,this.idField))===String(t));return r?n?.$select?.length?Ge(r,n.$select):{...r}:null}async create(e,t){let n={...t};if(!F(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(F(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(F(e,this.idField))===String(t));return n===-1?!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=F(i,this.idField);t!==void 0&&r.push(await this.update(e,t,i));break}case`delete`:{let t=F(i,this.idField);t!==void 0&&await this.delete(e,t);break}}return r}batchTransaction(e){return P(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);break}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 qe(e,t,n){if(!e)return t??null;switch(e.provider){case`object`:return t??null;case`api`:return new He({read:e.read,write:e.write,fetch:n?.fetch,defaultHeaders:n?.defaultHeaders});case`value`:return new Ke({items:e.items??[],idField:n?.idField});default:return t??null}}var L=`https://objectui.dev/docs/errors`,Je={"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:`${L}/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:`${L}/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:`${L}/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:`${L}/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:`${L}/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:`${L}/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:`${L}/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:`${L}/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:`${L}/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:`${L}/OBJUI-010`}},Ye=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 Xe(e){return e instanceof Ye}var R=`__debug`;function Ze(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(R),i=n.has(`${R}_schema`),a=n.has(`${R}_perf`),o=n.has(`${R}_data`),s=n.has(`${R}_expr`),c=n.has(`${R}_events`),l=n.has(`${R}_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 Qe(){try{if(typeof window<`u`)try{if(Ze(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 $e(e,t,n){Qe()&&(n===void 0?console.log(`[ObjectUI Debug][${e}] ${t}`):console.log(`[ObjectUI Debug][${e}] ${t}`,n))}var et=new Map;function tt(e){Qe()&&et.set(e,performance.now())}function nt(e){if(!Qe())return;let t=et.get(e);if(t!==void 0){let n=(performance.now()-t).toFixed(2);console.log(`[ObjectUI Debug][perf] ${e}: ${n}ms`),et.delete(e)}}var rt=200,it=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>rt&&(this.entries=this.entries.slice(-200));for(let t of this.subscribers)try{t(e)}catch{}}},at={medium:991,small:640,xsmall:479},ot=e=>e.replace(/[A-Z]/g,e=>`-${e.toLowerCase()}`),st=e=>Object.entries(e).filter(([,e])=>e!=null&&e!==``).map(([e,t])=>`${ot(e)}: ${typeof t==`number`?String(t):t} !important;`).join(` `);function ct(e){if(!e||typeof e!=`object`)return!1;let t=e;return!!(t.large||t.medium||t.small||t.xsmall)}function lt(e){return`os-s-${String(e).replace(/[^a-zA-Z0-9_-]/g,`-`)}`}function ut(e,t){let n=[];if(t.large){let r=st(t.large);r&&n.push(`${e} { ${r} }`)}for(let r of[`medium`,`small`,`xsmall`]){let i=t[r];if(!i)continue;let a=st(i);a&&n.push(`@media (max-width: ${at[r]}px) { ${e} { ${a} } }`)}return n.join(`
|
|
3
|
-
`)}var dt={"react-pages":!0},z=new Map,ft=!1;function pt(){if(ft)return;ft=!0;let e=globalThis;if(Array.isArray(e.__OBJECTUI_CAPABILITIES__))for(let t of e.__OBJECTUI_CAPABILITIES__)typeof t==`string`&&!z.has(t)&&z.set(t,!0);if(Array.isArray(e.__OBJECTUI_CAPABILITIES_DISABLED__))for(let t of e.__OBJECTUI_CAPABILITIES_DISABLED__)typeof t==`string`&&z.set(t,!1)}function mt(e){pt();let t=z.get(e);return t===void 0?dt[e]??!1:t}var ht=`react-pages`,gt=/\$\{event\.([a-zA-Z0-9_]+)\}/g;function _t(e,t){return typeof e!=`string`||e.indexOf("${event.")===-1?e:e.replace(gt,(e,n)=>{let r=t[n];return r==null?``:String(r)})}function vt(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 _t(e,t)}if(Array.isArray(e))return e.map(e=>vt(e,t));if(e&&typeof e==`object`){let n={};for(let[r,i]of Object.entries(e))n[r]=vt(i,t);return n}return e}function yt(e,t,n={}){if(e?.filter)return vt(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 bt(e,t,n=`Details`){if(e?.title){let n=_t(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 xt(e){return e?e.enabled!==!1:!1}function B(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 St=`dateRange`,Ct=`created_at`,wt={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}`}},Tt=Object.keys(wt);function Et(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 Dt(e){let t=new Map;if(e.dateRange){let n=e.dateRange.defaultRange;t.set(St,{name:St,field:e.dateRange.field||Ct,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`),t.set(e,{name:e,field:n.field,label:n.label,type:n.type??`text`,options:Et(n.options),optionsFrom:n.optionsFrom,defaultValue:n.defaultValue,targetWidgets:n.targetWidgets})}return Array.from(t.values())}function Ot(e){return e.map(e=>({name:e.name,type:e.type===`dateRange`?`object`:`string`,defaultValue:e.defaultValue}))}function kt(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 At(e,t){if(!kt(e,t)){if(e.type===`dateRange`||e.type===`date`){let e=t;if(typeof e==`object`){let t=e.preset?wt[e.preset]:void 0,n=t?.from??e.from,r=t?.to??e.to;return!n&&!r?void 0:{...n?{$gte:n}:{},...r?{$lte:r}:{}}}return t}return e.type===`select`||e.type===`lookup`?Array.isArray(t)?{$in:t}:t:e.type===`text`?{$contains:t}:t}}function jt(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 Mt(e,t,n,r){let i=[];for(let a of t){let t=n[a.name];if(kt(a,t))continue;let o=jt(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=At(a,t);s!==void 0&&i.push({[o]:s})}if(i.length!==0)return i.length===1?i[0]:{$and:i}}function Nt(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 Pt={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 Ft(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=>Ft(e,t));if(typeof e==`object`){let n={};for(let r of Object.keys(e))n[r]=Ft(e[r],t);return n}return e}function It(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 Lt(e,t,n=new Date){if(t===`previousYear`)return B(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=It(n,t.offset);return r?B(e,r):B(e,n)}return B(Ft(e,Pt),n)}function Rt(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 zt(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 Bt(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 Vt(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 Ht(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 Ut(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 Wt(e){return e>-1&&e<1?e*100:e}function Gt(e,t,n){if(e==null)return`—`;if(typeof e!=`number`)return String(e);let r=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:r??0,maximumFractionDigits:r??2}).format(e)}catch{}if(!t)return Number.isInteger(e)?String(e):e.toLocaleString(void 0,{maximumFractionDigits:2});let i=t.includes(`%`);return`${t.includes(`$`)?`$`:``}${(i?Wt(e):e).toLocaleString(void 0,{minimumFractionDigits:r??0,maximumFractionDigits:r??0})}${i?`%`:``}`}function Kt(e){return e==null?`—`:typeof e==`number`?Number.isInteger(e)?String(e):e.toLocaleString(void 0,{maximumFractionDigits:2}):String(e)}function qt(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 Jt(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 V=`\0`,Yt=`[-\\u2013\\u2014|/·,:]`,Xt=[`name`,`title`,`subject`,`label`,`full_name`,`display_name`],Zt=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`]),Qt=new Set([`text`,`string`,`textarea`,`html`]);function $t(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 en(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=$t(a)),a==null||a===``?V:(r=!0,String(a))});if(!r)return``;let a=RegExp(`\\s*${Yt}\\s*${V}`,`g`),o=RegExp(`${V}\\s*${Yt}\\s*`,`g`);return i=i.replace(a,``).replace(o,``).replace(new RegExp(V,`g`),``).replace(/\s+/g,` `).trim(),i}function tn(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 Qt.has(t)}return!Zt.has(t)}function nn(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 H=new WeakMap;function rn(e){let t=nn(e?.fields).filter(([,e])=>tn(e));if(t.length===0)return;for(let e of Xt){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 an(e){if(typeof e!=`object`||!e)return rn(e);if(H.has(e))return H.get(e);let t=rn(e);return H.set(e,t),t}var on=[`name`,`full_name`,`fullName`,`display_name`,`displayName`,`title`,`subject`,`label`];function U(e,t){if(!t||!e||typeof e!=`object`)return;let n=e[t];if(n&&typeof n==`object`&&(n=$t(n)),n==null)return;let r=typeof n==`string`?n.trim():String(n);return r===``?void 0:r}function sn(e,t,n){let r=U(t,n?.titleField)??U(t,e?.titleField);if(r)return r;let i=U(t,e?.nameField??e?.displayNameField??e?.NAME_FIELD_KEY);if(i)return i;if(e?.titleFormat){let n=en(e.titleFormat,t);if(n)return n}let a=U(t,an(e));if(a)return a;if(n?.deriveFromRecordKeys!==!1&&t&&typeof t==`object`){for(let e of on){let n=U(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=U(t,e);if(n)return n}}}let o=t?.id??t?._id;return o!=null&&String(o).trim()!==``?`Record #${o}`:n?.fallback??`Untitled`}var cn=/[\\\/:*?"<>|\u0000-\u001f]+/g,ln=80;function W(e){return e?String(e).replace(cn,`_`).replace(/\s+/g,` `).replace(/_{2,}/g,`_`).replace(/^[\s._-]+|[\s._-]+$/g,``).slice(0,ln):``}function un(e,t={},n=new Date){let r=W(t.prefix),i=r||W(t.label)||W(t.objectName)||`export`,a=W(t.viewLabel);!r&&a&&a.toLowerCase()!==i.toLowerCase()&&(i=`${i}-${a}`.slice(0,ln));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 dn(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 fn(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)dn(e);return e}var G=t(i(),1),K=r(),q=(0,G.createContext)(null),pn=({children:e,dataSource:t,debug:n,debugFlags:r})=>{let i=(0,G.useMemo)(()=>({dataSource:t,debug:n,debugFlags:r}),[t,n,r]);return(0,K.jsx)(q.Provider,{value:i,children:e})},mn=()=>{let e=(0,G.useContext)(q);if(!e)throw Error(`useSchemaContext must be used within a SchemaRendererProvider`);return e},hn=e=>{let t=(0,G.useContext)(q)?.dataSource;if(e&&t)return e.split(`.`).reduce((e,t)=>e&&e[t],t)},gn=(0,G.createContext)({});function _n({scope:e,children:t}){return(0,G.createElement)(gn.Provider,{value:e},t)}function J(){return(0,G.useContext)(gn)}function vn(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 yn=new Set;function bn(e,t={},n){let r=J();return(0,G.useMemo)(()=>{let i=new w({...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(!yn.has(i)){yn.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 xn(e,t,n){let r=J(),i=n?.fallback??!0;return(0,G.useMemo)(()=>typeof e==`boolean`?e:e==null||e===``?i:A(e,t??{},{fallback:i,scope:r,warnOnError:n?.warnOnError,label:n?.label}),[e,t,r,i,n?.warnOnError,n?.label])}var Sn=(0,G.createContext)(null);function Cn(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]=``;break}return t}var wn=({definitions:e,children:t})=>{let n=(0,G.useContext)(Sn),[r,i]=(0,G.useState)(()=>Cn(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(Cn(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)(Sn.Provider,{value:f,children:t})};wn.displayName=`PageVariablesProvider`;function Y(){return(0,G.useContext)(Sn)||{variables:{},definitions:[],setVariable:()=>{},setVariables:()=>{},resetVariables:()=>{}}}function Tn(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 En(e){if(e!=null)return typeof e==`string`?e:e.defaultValue||e.key}var Dn=(()=>{try{return!1}catch{return!0}})(),On=typeof WeakMap<`u`?new WeakMap:{set(){},get(){},has(){return!1}},X=typeof WeakSet<`u`?new WeakSet:{add(){},has(){return!1}};function kn(e){if(!Dn||!e||typeof e!=`object`)return{valid:!0,messages:[]};let t=On.get(e);if(t)return t;let n={valid:!0,messages:[]};try{let t=m(e);if(!t.valid){let r=t.errors.map(e=>`${e.path}: ${e.message}`);n={valid:!1,messages:r},X.has(e)||(X.add(e),console.warn(`[ObjectUI] Invalid schema detected:
|
|
4
|
-
`+r.join(`
|
|
5
|
-
`),e))}}catch(t){X.has(e)||(X.add(e),console.warn(`[ObjectUI] Schema validator threw:`,t))}return On.set(e,n),n}function An(e){let t={};return e.ariaLabel&&(t[`aria-label`]=En(e.ariaLabel)),e.ariaDescribedBy&&(t[`aria-describedby`]=e.ariaDescribedBy),e.role&&(t.role=e.role),t}var jn=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 Xe(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}},Mn=(0,G.forwardRef)(({schema:e,...t},n)=>{let r=(0,G.useContext)(q),i=r?.dataSource||{},a=J(),{variables:o}=Y(),[,s]=(0,G.useReducer)(e=>e+1,0);(0,G.useEffect)(()=>{let e=c.subscribe(s);return s(),e},[]);let[l,u]=(0,G.useState)(null),d=G.useId(),f=(0,G.useMemo)(()=>{if(!e||typeof e==`string`)return e;let t=new w({...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=Dn?kn(e):{valid:!0,messages:[]};$e(`schema`,`Rendering schema node`,{type:f.type,id:f.id});let m=c.get(f.type);if(!m){if(!l&&c.hasLazy(f.type)){let e=c.loadLazy(f.type);if(e)return e.catch(e=>{u(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 $e(`schema`,`Component not found in registry`,{type:f.type}),Je[`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})]}),l&&(0,K.jsxs)(`p`,{className:`text-xs mt-1`,children:[`Failed to load plugin: `,l.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:ee,visibleOn:te,visibility:ne,hidden:re,hiddenOn:ie,disabled:ae,disabledOn:oe,_hidden:b,_disabled:x,responsiveStyles:se,...S}=f,C=ct(se),T=C?lt(f.id??d):``,E=C?ut(`.${T}`,se):``,D=T?[f.className,T].filter(Boolean).join(` `):f.className,ce=T?{...f,className:D}:f,le=An(f),O=r?.debug||r?.debugFlags?.enabled,k={};O&&(k[`data-debug-type`]=f.type,f.id&&(k[`data-debug-id`]=f.id)),tt(`render:${f.type}:${f.id??`anon`}`);let A=O?performance.now():0,j=(0,K.jsxs)(jn,{componentType:f.type,resetKey:f.id??null,children:[E?(0,K.jsx)(`style`,{"data-os-scope":T,dangerouslySetInnerHTML:{__html:E}}):null,G.createElement(m,{schema:ce,...S,...f.props||{},...le,...k,disabled:x||void 0,className:D,"data-obj-id":f.id,"data-obj-type":f.type,...Dn&&!p.valid?{"data-obj-schema-invalid":`true`}:{},...t})]});if(nt(`render:${f.type}:${f.id??`anon`}`),O&&A){let e=performance.now()-A;it.getInstance().addPerf({type:f.type,id:f.id,durationMs:e,timestamp:Date.now()})}return j});Mn.displayName=`SchemaRenderer`;function Nn(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 N(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}}function Pn(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=t?.width,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 Fn=(0,G.createContext)(!1),In=({value:e=!0,children:t})=>(0,K.jsx)(Fn.Provider,{value:e,children:t}),Ln=()=>(0,G.useContext)(Fn),Z=(0,G.createContext)(null),Rn=({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 N({...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)(Z.Provider,{value:y,children:e})};Rn.displayName=`ActionProvider`;function zn(){let e=(0,G.useContext)(Z);if(!e){let e=new N;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 Bn(){return(0,G.useContext)(Z)!==null}(0,G.createContext)(null);var Vn=0,Hn=(0,G.createContext)(null),Un=({children:e,config:t={},onToast:n})=>{let r=(0,G.useMemo)(()=>({position:`top-right`,defaultDuration:5e3,maxVisible:5,stacking:!0,...t}),[JSON.stringify(t)]),[i,a]=(0,G.useState)([]),o=(0,G.useCallback)(e=>{let t=`notification-${++Vn}`,i={...e,id:t,createdAt:new Date,read:!1};a(e=>[i,...e]),n&&n(i);let o=e.duration??r.defaultDuration??5e3;return o>0&&setTimeout(()=>{a(e=>e.filter(e=>e.id!==t))},o),t},[r.defaultDuration,n]),s=(0,G.useCallback)((e,t)=>o({title:e,message:t,severity:`info`}),[o]),c=(0,G.useCallback)((e,t)=>o({title:e,message:t,severity:`success`}),[o]),l=(0,G.useCallback)((e,t)=>o({title:e,message:t,severity:`warning`}),[o]),u=(0,G.useCallback)((e,t)=>o({title:e,message:t,severity:`error`}),[o]),d=(0,G.useCallback)(e=>{a(t=>t.map(t=>t.id===e?{...t,read:!0}:t))},[]),f=(0,G.useCallback)(()=>{a(e=>e.map(e=>({...e,read:!0})))},[]),p=(0,G.useCallback)(e=>{a(t=>t.filter(t=>t.id!==e))},[]),m=(0,G.useCallback)(()=>{a([])},[]),h=(0,G.useMemo)(()=>i.filter(e=>!e.read).length,[i]),g=(0,G.useMemo)(()=>({notifications:i,unreadCount:h,notify:o,info:s,success:c,warning:l,error:u,markAsRead:d,markAllAsRead:f,dismiss:p,clearAll:m,config:r}),[i,h,o,s,c,l,u,d,f,p,m,r]);return(0,K.jsx)(Hn.Provider,{value:g,children:e})};Un.displayName=`NotificationProvider`;var Wn=(0,G.createContext)(null),Gn=({children:e,config:t={},onDragStart:n,onDrop:r,onDragCancel:i})=>{let a=(0,G.useMemo)(()=>({enabled:!0,showPreview:!0,autoScroll:!0,...t}),[JSON.stringify(t)]),[o,s]=(0,G.useState)(null),[c]=(0,G.useState)(()=>new Map),l=(0,G.useCallback)(e=>{a.enabled&&(s(e),n?.({item:e,targetZoneId:null,effect:`move`}))},[a.enabled,n]),u=(0,G.useCallback)(e=>{if(!o)return;let t=(e?c.get(e):void 0)?.effect??`move`;r?.({item:o,targetZoneId:e??null,effect:t}),s(null)},[o,c,r]),d=(0,G.useCallback)(()=>{o&&(i?.({item:o,targetZoneId:null,effect:`none`}),s(null))},[o,i]),f=(0,G.useCallback)(e=>{c.set(e.id,e)},[c]),p=(0,G.useCallback)(e=>{c.delete(e)},[c]),m=(0,G.useCallback)((e,t)=>{let n=c.get(e);return!n||n.disabled?!1:n.acceptTypes.includes(t)},[c]),h=(0,G.useMemo)(()=>({config:a,enabled:a.enabled??!0,activeItem:o,dropZones:c,startDrag:l,endDrag:u,cancelDrag:d,registerDropZone:f,unregisterDropZone:p,canDrop:m}),[a,o,c,l,u,d,f,p,m]);return(0,K.jsx)(Wn.Provider,{value:h,children:e})};Gn.displayName=`DndProvider`;function Kn(){let e=(0,G.useContext)(Wn);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 qn(){return(0,G.useContext)(Wn)!==null}var Jn=(0,G.createContext)(null);function Yn(){return(0,G.useContext)(Jn)}var Xn=(0,G.createContext)(null);function Zn(){return(0,G.useContext)(Xn)||{apps:[],objects:[],dashboards:[],reports:[],pages:[],loading:!1,error:null,refresh:async()=>{},invalidate:()=>{},ensureType:async()=>[],getItem:async()=>null,getItemsByType:()=>[],getTypeStatus:()=>`ready`}}function Qn(e,t){let{getItem:n}=Zn(),[r,i]=(0,G.useState)({item:null,loading:!!t,error:null});return(0,G.useEffect)(()=>{if(!t){i({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 Q=G.createContext(null),$n=({children:e})=>{let t=G.useMemo(()=>{let e=new Map,t=ir,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)(Q.Provider,{value:t,children:e})};function er(){let e=G.useContext(Q);return G.useSyncExternalStore(e?e.subscribe:nr,e?e.getNames:rr,e?e.getNames:rr)}function tr(e,t){let n=G.useContext(Q),r=t.join(`|`);G.useEffect(()=>{if(n)return n.register(e,r.length===0?[]:r.split(`|`)),()=>n.unregister(e)},[n,e,r])}var nr=e=>()=>{},rr=()=>ir,ir=new Set,ar=G.createContext(null),or=({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)(ar.Provider,{value:n,children:e})};function sr(){return G.useContext(ar)}var cr=G.createContext(null),lr=({canEdit:e=!0,locked:t=!1,lockedReason:n,children:r})=>{let[i,a]=G.useState(!1),[o,s]=G.useState({}),[c,l]=G.useState(null),[u,d]=G.useState(!1),[f,p]=G.useState(null),m=G.useCallback(t=>{e&&(l(t??null),a(!0),p(null))},[e]),h=G.useCallback((e,t)=>{s(n=>({...n,[e]:t}))},[]),g=G.useCallback(()=>{s({}),a(!1),l(null),d(!1),p(null)},[]),_=G.useMemo(()=>({editing:i,canEdit:e,locked:t,lockedReason:n,draft:o,autoFocusField:c,saving:u,error:f,enter:m,setField:h,cancel:g,reset:g,setSaving:d,setError:p}),[i,e,t,n,o,c,u,f,m,h,g]);return(0,K.jsx)(cr.Provider,{value:_,children:r})};function ur(){return G.useContext(cr)}var dr=G.createContext(null),fr=({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)(dr.Provider,{value:n,children:e})};function pr(){return G.useContext(dr)}var mr=(0,G.createContext)({}),hr=({value:e,children:t})=>(0,K.jsx)(mr.Provider,{value:e,children:t});function gr(){return(0,G.useContext)(mr)}var _r=(0,G.createContext)(null),vr=({value:e,children:t})=>(0,K.jsx)(_r.Provider,{value:e,children:t});function yr(){return(0,G.useContext)(_r)}function br(){let{variables:e}=Y(),{updateContext:t}=zn();return G.useEffect(()=>(t({pageVariables:e}),()=>{t({pageVariables:{}})}),[e,t]),null}br.displayName=`PageVariableActionBridge`;function xr(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 Sr={compact:32,comfortable:40,spacious:52},Cr={compact:`py-1 px-2`,comfortable:`py-2 px-3`,spacious:`py-3 px-4`},wr={compact:`text-xs`,comfortable:`text-sm`,spacious:`text-base`},Tr=[`compact`,`comfortable`,`spacious`];function Er(e=`comfortable`,t){let[n,r]=(0,G.useState)(e),i=t?.rowHeights??Sr,a=t?.paddingClasses??Cr,o=t?.fontSizeClasses??wr,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=Tr[(Tr.indexOf(e)+1)%Tr.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 Dr(e){return typeof window>`u`?()=>{}:(window.addEventListener(`online`,e),window.addEventListener(`offline`,e),()=>{window.removeEventListener(`online`,e),window.removeEventListener(`offline`,e)})}function Or(){return typeof navigator<`u`?navigator.onLine:!0}function kr(){return!0}var Ar=`objectui-offline-queue`;function jr(){if(typeof localStorage>`u`)return[];try{let e=localStorage.getItem(Ar);return e?JSON.parse(e):[]}catch{return[]}}function Mr(e){if(!(typeof localStorage>`u`))try{localStorage.setItem(Ar,JSON.stringify(e))}catch{}}var Nr=0;function Pr(){return Nr+=1,`mut_${Date.now()}_${Nr}`}var $={enabled:!0,strategy:`network_first`,offlineIndicator:!0,offlineMessage:`You are currently offline. Changes will be synced when reconnected.`,queueMaxSize:100};function Fr(e={}){let{enabled:t=$.enabled,strategy:n=$.strategy,offlineIndicator:r=$.offlineIndicator,offlineMessage:i=$.offlineMessage,queueMaxSize:a=$.queueMaxSize,sync:o}=e,s=(0,G.useSyncExternalStore)(Dr,Or,kr),[c,l]=(0,G.useState)(jr),[u,d]=(0,G.useState)(`idle`),f=(0,G.useRef)(o);f.current=o,(0,G.useEffect)(()=>{Mr(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:Pr(),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 Ir(){return{canUndo:M.canUndo,canRedo:M.canRedo,undoDescription:M.peekUndo()?.description,redoDescription:M.peekRedo()?.description,history:M.getHistory()}}function Lr(){return{canUndo:!1,canRedo:!1,undoDescription:void 0,redoDescription:void 0,history:[]}}var Rr=Ir();function zr(e){return M.subscribe(()=>{Rr=Ir(),e()})}function Br(){return Rr}function Vr(e={}){let t=(0,G.useRef)(e);t.current=e;let n=(0,G.useSyncExternalStore)(zr,Br,Lr),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=M.popUndo();e&&(await r(e,e.undoData,`undo`),t.current.onUndo?.(e))},[r]),a=(0,G.useCallback)(async()=>{let e=M.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 Hr(e={}){let{actions:t=[],context:n={}}=e,r=(0,G.useContext)(Z)?.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 Pe(r):new Pe(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 Ur(e,t){return!0}function Wr(e,t={}){let n=Zn(),[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:Ur(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 Gr(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 Kr(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=sn}=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=n;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.slice(0,a)},[n,i,a]),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=_.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(t).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,t=s?.code;if(e===404||t===`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:Gr(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,s,c,u]),{results:d,isSearching:p,error:h}}var qr=new Set,Jr=`objectui:related-changed`;function Yr(e){for(let t of Array.from(qr))try{t(e)}catch{}typeof window<`u`&&window.dispatchEvent(new CustomEvent(Jr,{detail:{objectName:e.objectName,recordId:e.recordId}}))}function Xr(e){return qr.add(e),()=>qr.delete(e)}function Zr(e,t,n){return e.objectName===`*`?!0:e.objectName===t?n===void 0||e.recordId===void 0||e.recordId===n:!1}function Qr(e,t){let[n,r]=(0,G.useState)(0);return(0,G.useEffect)(()=>{if(e)return Xr(n=>{Zr(n,e,t)&&r(e=>e+1)})},[e,t]),n}function $r(e){(0,G.useEffect)(()=>{let t=e;if(t?.onMutation)return t.onMutation(e=>{e?.resource&&Yr({objectName:e.resource,recordId:e.id==null?void 0:String(e.id)})})},[e])}var ei=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:()=>g,createLogger:()=>_}),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){if(typeof process<`u`){let e={}.NO_COLOR;if(e!==void 0&&e!==``)return!1}return!!e?.isTTY}function h(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 g=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.config.file&&typeof process<`u`&&this.openFileStream(this.config.file)}openFileStream(e){let t=h(`fs`),n=h(`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]}redactSensitive(e){if(!e||typeof e!=`object`)return e;let t=Array.isArray(e)?[...e]:{...e};for(let e in t){let n=e.toLowerCase();this.config.redact.some(e=>n.includes(e.toLowerCase()))?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&&m(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){t instanceof Error?this.write(`error`,e,n,t):this.write(`error`,e,t)}fatal(e,t,n){t instanceof Error?this.write(`fatal`,e,n,t):this.write(`fatal`,e,t)}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 _(e){return new g(e)}0&&(n.exports={ObjectLogger:g,createLogger:_})}));export{pn as $,g as $t,Zn as A,Ze as At,Pn as B,we as Bt,or as C,Dt as Ct,Jn as D,bt as Dt,tr as E,xt as Et,Rn as F,Fe as Ft,Tn as G,me as Gt,Mn as H,Ce as Ht,zn as I,Ae as It,vn as J,w as Jt,Y as K,_e as Kt,Bn as L,ke as Lt,Kn as M,Ke as Mt,qn as N,P as Nt,Xn as O,ht as Ot,Z as P,Re as Pt,q as Q,_ as Qt,In as R,Oe as Rt,$n as S,Ot as St,sr as T,yt as Tt,En as U,ge as Ut,Nn as V,Se as Vt,wn as W,ve as Wt,J as X,C as Xt,bn as Y,S as Yt,xn as Z,ee as Zt,gr as _,Rt as _t,$r as a,en as at,lr as b,Tt as bt,Hr as c,qt as ct,Er as d,Wt as dt,c as en,hn as et,xr as f,zt as ft,hr as g,Bt as gt,yr as h,Vt as ht,Qr as i,W as it,Qn as j,qe as jt,Yn as k,mt as kt,Vr as l,Kt as lt,vr as m,Ht as mt,Yr as n,fn as nt,Kr as o,sn as ot,br as p,Ut as pt,_n as q,pe as qt,Xr as r,un as rt,Wr as s,Jt as st,ei as t,mn as tt,Fr as u,Gt as ut,fr as v,Lt as vt,er as w,B as wt,ur as x,Mt as xt,pr as y,Nt as yt,Ln as z,Ee as zt};
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./ui-components-BL3SEdAz.css","./plugin-dashboard-DnNKJB60.css","./plugin-map-CsMXqW6n.css"])))=>i.map(i=>d[i]);
|
|
2
|
-
import{o as e,r as t}from"./rolldown-runtime-DAXXjFlN.js";import{_ as n,a as r,c as i,d as a,f as o,g as s,h as c,i as l,l as u,m as d,r as f,s as p,u as m,y as h}from"./vendor-react-BKSb6vFP.js";import{a as g,c as _,d as v,h as y,i as b,l as x,m as S,p as C,r as w,s as T,u as ee}from"./infrastructure-CQFJ5N6p.js";import{A as E,F as te,H as D,en as O,k as ne}from"./framework-Oi7uo_kE.js";import{Es as re,Fc as ie,Fr as ae,Fs as oe,Go as se,Gs as ce,Hc as le,Ia as ue,Mc as de,Or as k,Pi as fe,Rs as pe,S as me,T as he,Uc as A,Wa as ge,Yi as _e,Zr as ve,_t as ye,cr as j,ei as be,eo as xe,fr as M,gt as N,ht as Se,lo as Ce,lr as P,ma as we,mc as Te,mn as F,ms as Ee,mt as De,no as Oe,or as I,qa as L,qs as ke,ra as Ae,sr as R,tc as je,ts as Me,ua as Ne,ui as Pe,ur as z,vn as B,vt as V,w as Fe,z as Ie,za as Le}from"./ui-components-BluZyuZX.js";import{r as H}from"./vendor-ui-utils-D-WJ115h.js";import{C as Re,D as U,E as ze,S as Be,T as Ve,_ as He,a as Ue,b as We,c as Ge,d as Ke,f as qe,g as Je,h as Ye,i as Xe,l as Ze,m as Qe,n as $e,o as et,r as tt,s as nt,u as rt,v as it,w as at,x as ot,y as st}from"./src-CB6vSDbd.js";import"./plugin-form-C969LzWi.js";import{j as ct}from"./RecordDetailView-C6UiMORv.js";import{r as lt}from"./plugin-chatbot-BRbgUPLw.js";import{C as W,E as ut,O as dt,T as ft,b as pt,w as mt,x as ht}from"./MarketplaceAccessDenied-DFaKQ3Ws.js";import{a as gt,i as _t,o as vt}from"./plugin-grid-CnxMz-9O.js";import"./plugins-views-DCG6qMPm.js";import"./plugin-view-BhPeq9o5.js";import{n as G}from"./componentRegistry-ByxoJqMW.js";import{r as yt,t as bt}from"./plugin-markdown-wZpqyjok.js";import{t as K}from"./DocShell-CXBgEZhg.js";import{a as xt,i as St,l as Ct,n as wt,o as Tt,r as Et,s as Dt,t as Ot,u as kt}from"./use-book-data-DyDHAzga.js";import{n as At}from"./src-CIr5NcaF.js";var q=e(h(),1),jt=e(n(),1),J=f(),Mt={type:`object-master-detail-form`,objectName:`expense_claim`,mode:`create`,formType:`simple`,title:`New Expense Claim`,submitText:`Create Claim`,fields:[`title`,`applicant`,`department`,`reason`,`currency`,`claim_status`,`payment_status`,`remarks`],details:[{title:`Expense Lines`,childObject:`expense_line`,relationshipField:`expense_claim`,amountField:`amount`,totalField:`total_amount`,columns:[{field:`expense_date`,label:`Date`,type:`date`},{field:`category`,label:`Category`,type:`select`,options:[{label:`Travel & Transport`,value:`travel_transport`},{label:`Lodging`,value:`lodging`},{label:`Meals & Entertainment`,value:`meals_entertainment`},{label:`Office Supplies`,value:`office_supplies`},{label:`Communications`,value:`communications`},{label:`Training & Conference`,value:`training_conference`},{label:`Client / Project`,value:`client_project`},{label:`Other`,value:`other`}]},{field:`description`,label:`Description`,type:`text`},{field:`merchant_vendor`,label:`Merchant`,type:`text`},{field:`amount`,label:`Amount`,type:`currency`}]}]},Nt=()=>(0,J.jsxs)(`div`,{className:`mx-auto max-w-3xl p-6`,children:[(0,J.jsx)(`h1`,{className:`mb-4 text-lg font-semibold`,children:`Dev · Master-Detail Form (ADR-0001)`}),(0,J.jsx)(D,{schema:Mt})]}),Pt={type:`element:definition-list`,properties:{columns:2,items:[{term:`Status`,description:`Active`},{term:`Owner`,description:`Ada Lovelace`},{term:`Plan`,description:`Enterprise`},{term:`Renewal`,description:`2026-12-01`}]}},Ft={type:`element:repeater`,properties:{object:`showcase_category`,titleField:`name`,fields:[`color`],limit:10,emptyText:`No categories`}},It=()=>(0,J.jsxs)(`div`,{className:`mx-auto max-w-2xl space-y-8 p-6`,children:[(0,J.jsxs)(`div`,{children:[(0,J.jsx)(`h1`,{className:`mb-3 text-lg font-semibold`,children:`Dev · element:definition-list`}),(0,J.jsx)(`div`,{className:`rounded-lg border p-4`,children:(0,J.jsx)(D,{schema:Pt})})]}),(0,J.jsxs)(`div`,{children:[(0,J.jsx)(`h1`,{className:`mb-3 text-lg font-semibold`,children:`Dev · element:repeater (showcase_category)`}),(0,J.jsx)(`div`,{className:`rounded-lg border p-4`,children:(0,J.jsx)(D,{schema:Ft})})]})]}),Lt={type:`element:definition-list`,properties:{columns:2,items:[{term:`Status`,description:`Active`},{term:`Owner`,description:`Ada Lovelace`},{term:`Plan`,description:`Enterprise`},{term:`Renewal`,description:`2026-12-01`}]}},Rt=()=>{let{modalHandler:e,modalElement:t}=ct();return(0,J.jsxs)(`div`,{className:`space-y-4 p-6`,children:[(0,J.jsx)(`h1`,{className:`text-lg font-semibold`,children:`Dev · Action modal transport`}),(0,J.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[`One `,(0,J.jsx)(`code`,{children:`onModal`}),` handler, four placements, arbitrary SchemaNode content.`]}),(0,J.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,J.jsx)(k,{"data-testid":`open-center`,onClick:()=>e({placement:`center`,size:`lg`,title:`Center modal`,content:Lt}),children:`Center`}),(0,J.jsx)(k,{"data-testid":`open-side`,variant:`outline`,onClick:()=>e({placement:`side`,title:`Side drawer`,content:Lt}),children:`Side drawer`}),(0,J.jsx)(k,{"data-testid":`open-bottom`,variant:`outline`,onClick:()=>e({placement:`bottom`,title:`Bottom sheet`,content:Lt}),children:`Bottom sheet`}),(0,J.jsx)(k,{"data-testid":`open-fullscreen`,variant:`outline`,onClick:()=>e({placement:`fullscreen`,title:`Fullscreen`,content:Lt}),children:`Fullscreen`})]}),t]})},zt=()=>{let[e,t]=q.useState([{},{}]);return(0,J.jsxs)(`div`,{className:`mx-auto max-w-3xl space-y-4 p-6`,children:[(0,J.jsx)(`h1`,{className:`text-lg font-semibold`,children:`Dev · Line-item grid with a lookup cell`}),(0,J.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[`The `,(0,J.jsx)(`code`,{children:`Account`}),` column is a real lookup picker bound to live `,(0,J.jsx)(`code`,{children:`showcase_account`}),`.`]}),(0,J.jsx)(me,{value:e,onChange:t,field:{columns:[{field:`account`,label:`Account`,type:`lookup`,reference:`showcase_account`,displayField:`name`},{field:`note`,label:`Note`,type:`text`},{field:`amount`,label:`Amount`,type:`currency`}],total_field:`amount`}}),(0,J.jsx)(`pre`,{className:`rounded bg-muted p-3 text-xs`,"data-testid":`rows-json`,children:JSON.stringify(e)})]})},Bt=[{id:`1`,name:`hotcrm-fix-verify`,org:`hotcrm-fix-verify`,type:`production`,status:`running`,host:`os-05ayzz.objectos.app`},{id:`2`,name:`Objectstack`,org:`Objectstack`,type:`production`,status:`running`,host:`os-0zpadn.objectos.app`},{id:`3`,name:`hotcrm`,org:`JIANGUO Zhuang's Workspace`,type:`production`,status:`running`,host:`os-48f50e60.objectos.app`}],Vt=[{name:`open`,label:`Open`,variant:`primary`},{name:`upgrade`,label:`Upgrade Plan`,variant:`primary`},{name:`rename`,label:`Rename`,variant:`secondary`},{name:`archive`,label:`Archive`,variant:`secondary`}],Ht=[{field:`name`,label:`名称`},{field:`org`,label:`所属组织`},{field:`type`,label:`类型`},{field:`status`,label:`状态`},{field:`host`,label:`公开主机名`}];function Ut({maxInlineRowActions:e}){return(0,J.jsx)(te,{children:(0,J.jsx)(_t,{schema:{type:`object-grid`,objectName:`showcase_environment`,columns:Ht,data:{provider:`value`,items:Bt},rowActionDefs:Vt,...e==null?{}:{maxInlineRowActions:e}}})})}var Wt=()=>(0,J.jsxs)(`div`,{className:`mx-auto max-w-none space-y-8 p-6`,children:[(0,J.jsxs)(`div`,{children:[(0,J.jsx)(`h1`,{className:`text-lg font-semibold`,children:`Dev · Row-action overflow (default)`}),(0,J.jsxs)(`p`,{className:`mb-3 text-sm text-muted-foreground`,children:[`Two `,(0,J.jsx)(`code`,{children:`variant:'primary'`}),` row actions. Only `,(0,J.jsx)(`strong`,{children:`Open`}),` stays inline;`,(0,J.jsx)(`strong`,{children:` Upgrade Plan`}),` + the secondaries fold into the `,(0,J.jsx)(`code`,{children:`⋮`}),` menu. The actions column hugs its content and must never clip the inline button.`]}),(0,J.jsx)(`div`,{className:`rounded-lg border`,"data-testid":`grid-default`,children:(0,J.jsx)(Ut,{})})]}),(0,J.jsxs)(`div`,{children:[(0,J.jsx)(`h1`,{className:`text-lg font-semibold`,children:`Dev · Row-action overflow (maxInlineRowActions: 2)`}),(0,J.jsxs)(`p`,{className:`mb-3 text-sm text-muted-foreground`,children:[`Same data, author opts into two inline primaries — both `,(0,J.jsx)(`strong`,{children:`Open`}),` and`,(0,J.jsx)(`strong`,{children:` Upgrade Plan`}),` render inline and the column grows to fit them.`]}),(0,J.jsx)(`div`,{className:`rounded-lg border`,"data-testid":`grid-wide`,children:(0,J.jsx)(Ut,{maxInlineRowActions:2})})]}),(0,J.jsxs)(`div`,{children:[(0,J.jsx)(`h1`,{className:`text-lg font-semibold`,children:`Dev · Row-action sticky-right (narrow / horizontal scroll)`}),(0,J.jsxs)(`p`,{className:`mb-3 text-sm text-muted-foreground`,children:[`A deliberately narrow container so the table scrolls horizontally. The`,(0,J.jsx)(`strong`,{children:` 操作`}),` column stays pinned to the right edge (always reachable), while the first `,(0,J.jsx)(`strong`,{children:`名称`}),` column stays frozen on the left. Scroll the grid sideways to check both edges hold.`]}),(0,J.jsx)(`div`,{className:`max-w-md overflow-hidden rounded-lg border`,"data-testid":`grid-scroll`,children:(0,J.jsx)(Ut,{})})]})]});function Gt({endpoint:e,children:t}){let[n,r]=(0,q.useState)({});return(0,q.useEffect)(()=>{let t=!1;return fetch(e,{credentials:`include`,headers:{Accept:`application/json`}}).then(e=>e.ok?e.json():null).then(e=>{t||!e||r({currency:e.currency??void 0,locale:e.locale??void 0})}).catch(()=>{}),()=>{t=!0}},[e]),(0,J.jsx)(ie,{value:n,children:t})}var Kt=(0,q.lazy)(()=>s(()=>import(`./SystemHubPage-qOFiW2Jq.js`).then(e=>({default:e.SystemHubPage})),__vite__mapDeps([0,1]),import.meta.url)),qt=(0,q.lazy)(()=>s(()=>import(`./AppManagementPage-JlGIV3AH.js`).then(e=>({default:e.AppManagementPage})),__vite__mapDeps([0,1]),import.meta.url)),Jt=(0,q.lazy)(()=>s(()=>import(`./ProfilePage-DAkDEioN.js`).then(e=>({default:e.ProfilePage})),__vite__mapDeps([0]),import.meta.url)),Yt=(0,q.lazy)(()=>s(()=>import(`./ApprovalsInboxPage-DMfSM-B7.js`).then(e=>({default:e.ApprovalsInboxPage})),__vite__mapDeps([0,1]),import.meta.url)),Xt=(0,q.lazy)(()=>s(()=>import(`./AiPendingActionsPage-9UZ4_qZW.js`).then(e=>({default:e.AiPendingActionsPage})),__vite__mapDeps([0]),import.meta.url)),Zt=(0,q.lazy)(()=>s(()=>import(`./AuditLogPage-C6SMCaHa.js`).then(e=>({default:e.AuditLogPage})),__vite__mapDeps([0]),import.meta.url)),Qt=(0,q.lazy)(()=>s(()=>import(`./SettingsHub-yoHgXGvm.js`).then(e=>({default:e.SettingsHub})),__vite__mapDeps([0]),import.meta.url)),$t=(0,q.lazy)(()=>s(()=>import(`./SettingsView-BO0qYMbW.js`).then(e=>({default:e.SettingsView})),__vite__mapDeps([0]),import.meta.url)),en=(0,q.lazy)(()=>s(()=>import(`./DeveloperHubPage-CX3urxAq.js`).then(e=>({default:e.DeveloperHubPage})),__vite__mapDeps([0]),import.meta.url)),tn=(0,q.lazy)(()=>s(()=>import(`./ApiConsolePage-DVnQPvbh.js`).then(e=>({default:e.ApiConsolePage})),__vite__mapDeps([0,1]),import.meta.url)),nn=(0,q.lazy)(()=>s(()=>import(`./FlowRunsPage-DKnUh_Ec.js`).then(e=>({default:e.FlowRunsPage})),__vite__mapDeps([0,1]),import.meta.url)),rn=(0,q.lazy)(()=>s(()=>import(`./PublicFormsPage-CRNSj35t.js`).then(e=>({default:e.PublicFormsPage})),__vite__mapDeps([0,1]),import.meta.url)),an=(0,q.lazy)(()=>s(()=>import(`./IntegrationsPage-BvyX5vIh.js`).then(e=>({default:e.IntegrationsPage})),__vite__mapDeps([0]),import.meta.url)),on=(0,q.lazy)(()=>s(()=>Promise.resolve().then(()=>zn),void 0,import.meta.url)),sn=(0,q.lazy)(()=>s(()=>import(`./AppDocsIndex-RWbVdvGq.js`),__vite__mapDeps([0,1]),import.meta.url)),cn=(0,q.lazy)(()=>s(()=>Promise.resolve().then(()=>Un),void 0,import.meta.url)),ln=(0,q.lazy)(()=>s(()=>Promise.resolve().then(()=>Gn),void 0,import.meta.url));function un(){let{objectName:e}=d(),t=a().pathname.replace(/\/(system\/)?objects(\/.*)?$/,``);return(0,J.jsx)(p,{to:e?`${t}/component/metadata/resource/${e}?type=object`:`${t}/component/metadata/resource?type=object`,replace:!0})}function dn(){let{metadataType:e,itemName:t}=d(),n=a().pathname.replace(/\/(system\/)?metadata(\/.*)?$/,``),r=`${n}/component/metadata/resource`;return(0,J.jsx)(p,{to:e?t?`${r}/${t}?type=${e}`:`${r}?type=${e}`:`${n}/component/metadata/directory`,replace:!0})}var fn=(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(u,{path:`system`,element:(0,J.jsx)(q.Suspense,{fallback:(0,J.jsx)(U,{}),children:(0,J.jsx)(Kt,{})})}),(0,J.jsx)(u,{path:`system/apps`,element:(0,J.jsx)(q.Suspense,{fallback:(0,J.jsx)(U,{}),children:(0,J.jsx)(qt,{})})}),(0,J.jsx)(u,{path:`system/profile`,element:(0,J.jsx)(q.Suspense,{fallback:(0,J.jsx)(U,{}),children:(0,J.jsx)(Jt,{})})}),(0,J.jsx)(u,{path:`system/approvals`,element:(0,J.jsx)(q.Suspense,{fallback:(0,J.jsx)(U,{}),children:(0,J.jsx)(Yt,{})})}),(0,J.jsx)(u,{path:`system/ai-approvals`,element:(0,J.jsx)(q.Suspense,{fallback:(0,J.jsx)(U,{}),children:(0,J.jsx)(Xt,{})})}),(0,J.jsx)(u,{path:`system/audit-log`,element:(0,J.jsx)(q.Suspense,{fallback:(0,J.jsx)(U,{}),children:(0,J.jsx)(Zt,{})})}),(0,J.jsx)(u,{path:`system/settings`,element:(0,J.jsx)(q.Suspense,{fallback:(0,J.jsx)(U,{}),children:(0,J.jsx)(Qt,{})})}),(0,J.jsx)(u,{path:`system/settings/:namespace`,element:(0,J.jsx)(q.Suspense,{fallback:(0,J.jsx)(U,{}),children:(0,J.jsx)($t,{})})}),(0,J.jsx)(u,{path:`developer`,element:(0,J.jsx)(q.Suspense,{fallback:(0,J.jsx)(U,{}),children:(0,J.jsx)(en,{})})}),(0,J.jsx)(u,{path:`developer/api-console`,element:(0,J.jsx)(q.Suspense,{fallback:(0,J.jsx)(U,{}),children:(0,J.jsx)(tn,{})})}),(0,J.jsx)(u,{path:`developer/flow-runs`,element:(0,J.jsx)(q.Suspense,{fallback:(0,J.jsx)(U,{}),children:(0,J.jsx)(nn,{})})}),(0,J.jsx)(u,{path:`developer/public-forms`,element:(0,J.jsx)(q.Suspense,{fallback:(0,J.jsx)(U,{}),children:(0,J.jsx)(rn,{})})}),(0,J.jsx)(u,{path:`developer/integrations`,element:(0,J.jsx)(q.Suspense,{fallback:(0,J.jsx)(U,{}),children:(0,J.jsx)(an,{})})}),(0,J.jsxs)(u,{path:`docs`,element:(0,J.jsx)(q.Suspense,{fallback:(0,J.jsx)(U,{}),children:(0,J.jsx)(ln,{})}),children:[(0,J.jsx)(u,{index:!0,element:(0,J.jsx)(q.Suspense,{fallback:(0,J.jsx)(U,{}),children:(0,J.jsx)(sn,{})})}),(0,J.jsx)(u,{path:`:slug`,element:(0,J.jsx)(q.Suspense,{fallback:(0,J.jsx)(U,{}),children:(0,J.jsx)(cn,{})})}),(0,J.jsx)(u,{path:`:slug/:name`,element:(0,J.jsx)(q.Suspense,{fallback:(0,J.jsx)(U,{}),children:(0,J.jsx)(on,{})})})]}),(0,J.jsx)(u,{path:`system/objects`,element:(0,J.jsx)(un,{})}),(0,J.jsx)(u,{path:`system/objects/:objectName`,element:(0,J.jsx)(un,{})}),(0,J.jsx)(u,{path:`system/metadata`,element:(0,J.jsx)(dn,{})}),(0,J.jsx)(u,{path:`system/metadata/:metadataType`,element:(0,J.jsx)(dn,{})}),(0,J.jsx)(u,{path:`system/metadata/:metadataType/:itemName`,element:(0,J.jsx)(dn,{})})]});function pn(){let e=(0,q.useMemo)(()=>he({baseUrl:``}),[``]);return(0,J.jsx)(w,{endpoint:`/api/v1/auth/me/permissions`,fetcher:(0,q.useMemo)(()=>y(),[]),loadingFallback:(0,J.jsx)(U,{}),children:(0,J.jsx)(Gt,{endpoint:`/api/v1/auth/me/localization`,children:(0,J.jsx)(Fe,{adapter:e,children:(0,J.jsx)(qe,{extraRoutes:fn,extraRoutesNoApp:fn})})})})}function mn(e){let t=(e??[]).filter(e=>!!e?.name),n=t.find(e=>e.isDefault===!0);if(n)return`/apps/${n.name}`;let r=t.filter(e=>e.active!==!1&&e.hidden!==!0);return r.length===1?`/apps/${r[0].name}`:`/home`}function hn(){let{apps:e,loading:t}=E();return t?(0,J.jsx)(Re,{}):(0,J.jsx)(p,{to:mn(e),replace:!0})}var gn=`/api/v1`,_n=new Set([`simple`,`tabbed`,`wizard`,`split`,`drawer`,`modal`]);function vn(e){let t=typeof e==`string`?parseInt(e,10):e;return t===1||t===2||t===3||t===4?t:2}function yn(e){if(Array.isArray(e))return e.map(e=>{if(typeof e==`string`)return{value:e,label:e};if(e&&typeof e==`object`){let t=String(e.value??e.id??``);return{value:t,label:String(e.label??e.name??t)}}return{value:String(e),label:String(e)}})}function bn(e,t){let n=e.sections??e.groups??[],r=t?.fields??{};return n.map(e=>{let t=vn(e.columns),n=[];for(let t of e.fields??[]){let e=typeof t==`string`?{field:t}:{...t},i=r[e.field]??{type:`text`};n.push({name:e.field,label:e.label??i.label??e.field,type:i.type??`text`,required:e.required??i.required??!1,readonly:e.readonly??!1,hidden:e.hidden??!1,placeholder:e.placeholder??i.placeholder,helpText:e.helpText??i.helpText,defaultValue:i.defaultValue,options:yn(i.options),maxLength:i.maxLength,colSpan:e.colSpan??1})}return{label:e.label,columns:t,collapsible:!!e.collapsible,collapsed:!!e.collapsed,fields:n}})}function xn(e,t){let n={};for(let r of e){r.defaultValue!==void 0&&(n[r.name]=r.defaultValue);let e=t.get(`prefill_${r.name}`);e!==null&&(n[r.name]=e)}return n}async function Y(e,t){return fetch(`${gn}${e}`,{credentials:`include`,headers:{"Content-Type":`application/json`,...t?.headers??{}},...t})}async function Sn(e){let t=await Y(`/forms/${encodeURIComponent(e)}`);if(!t.ok){let e=await t.text().catch(()=>``);throw Error(`Failed to load form (${t.status}): ${e||t.statusText}`)}let n=await t.json();return{label:n.label??n.form?.label??n.object,object:n.object,form:n.form,objectSchema:n.objectSchema}}function Cn(e,t){let n=t,r=n?.item??n,i=r?.spec??r,a=i&&typeof i==`object`&&i.config&&typeof i.config==`object`&&(`viewKind`in i||`object`in i),o=i&&typeof i==`object`?i.viewKind:void 0;if(o&&o!==`form`)throw Error(`View "${e}" is a ${o} view, not a form view — check the action or link that targets it.`);let s=a?i.config:i;if(!o&&s&&typeof s==`object`&&typeof s.type==`string`&&!_n.has(s.type))throw Error(`View "${e}" is a ${s.type} view, not a form view — check the action or link that targets it.`);return{label:(a?i.label:void 0)??s?.label??e,object:(a?i.object:void 0)??s?.data?.object??i?.object,form:s}}async function wn(e){let t=await Y(`/meta/view/${encodeURIComponent(e)}`);if(!t.ok)throw Error(`Form metadata not found: view/${e}`);let{label:n,object:r,form:i}=Cn(e,await t.json());if(!r)throw Error(`FormView "${e}" is missing an "object" target`);let a=null;try{let e=await Y(`/meta/object/${encodeURIComponent(r)}`);if(e.ok){let t=await e.json(),n=t?.item??t,i=n?.spec??n;i?.fields&&typeof i.fields==`object`&&(a={name:i.name??r,label:i.label,fields:i.fields})}}catch{}return{label:n,object:r,form:i,objectSchema:a}}async function Tn(e,t){let n=await Y(`/forms/${encodeURIComponent(e)}/submit`,{method:`POST`,body:JSON.stringify(t)});if(!n.ok){let e=await n.text().catch(()=>``);throw Error(`Submit failed (${n.status}): ${e||n.statusText}`)}return n.json().catch(()=>({}))}async function En(e,t){let n=await Y(`/data/${encodeURIComponent(e)}`,{method:`POST`,body:JSON.stringify(t)});if(!n.ok){let e=await n.text().catch(()=>``);throw Error(`Create failed (${n.status}): ${e||n.statusText}`)}return n.json().catch(()=>({}))}var Dn=`w-full rounded-md border border-input bg-background px-3 py-2 text-sm shadow-sm placeholder:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-ring disabled:opacity-50`;function On({field:e,value:t,onChange:n}){let r={id:`f_${e.name}`,name:e.name,required:e.required,disabled:e.readonly,placeholder:e.placeholder,className:Dn},i=t??``;switch(e.type){case`textarea`:case`paragraph`:case`long_text`:return(0,J.jsx)(`textarea`,{...r,rows:5,maxLength:e.maxLength,value:String(i),onChange:e=>n(e.target.value)});case`number`:case`integer`:case`decimal`:case`currency`:return(0,J.jsx)(`input`,{...r,type:`number`,value:i===``?``:Number(i),onChange:e=>n(e.target.value===``?null:Number(e.target.value))});case`email`:return(0,J.jsx)(`input`,{...r,type:`email`,value:String(i),onChange:e=>n(e.target.value)});case`url`:return(0,J.jsx)(`input`,{...r,type:`url`,value:String(i),onChange:e=>n(e.target.value)});case`password`:return(0,J.jsx)(`input`,{...r,type:`password`,value:String(i),onChange:e=>n(e.target.value)});case`date`:return(0,J.jsx)(`input`,{...r,type:`date`,value:String(i),onChange:e=>n(e.target.value)});case`time`:return(0,J.jsx)(`input`,{...r,type:`time`,value:String(i),onChange:e=>n(e.target.value)});case`datetime`:case`timestamp`:return(0,J.jsx)(`input`,{...r,type:`datetime-local`,value:String(i),onChange:e=>n(e.target.value)});case`boolean`:case`toggle`:case`checkbox`:return(0,J.jsxs)(`label`,{className:`inline-flex items-center gap-2 text-sm`,children:[(0,J.jsx)(`input`,{id:r.id,name:r.name,type:`checkbox`,disabled:e.readonly,checked:!!i,onChange:e=>n(e.target.checked),className:`h-4 w-4 rounded border-input`}),(0,J.jsx)(`span`,{children:e.placeholder??e.label})]});case`select`:case`picklist`:case`enum`:{let t=e.options??[];return(0,J.jsxs)(`select`,{...r,value:String(i),onChange:e=>n(e.target.value),children:[(0,J.jsx)(`option`,{value:``,disabled:e.required,children:e.placeholder??`— Select —`}),t.map(e=>(0,J.jsx)(`option`,{value:e.value,children:e.label},e.value))]})}case`radio`:return(0,J.jsx)(`div`,{className:`flex flex-wrap gap-3`,children:(e.options??[]).map(t=>(0,J.jsxs)(`label`,{className:`inline-flex items-center gap-1.5 text-sm`,children:[(0,J.jsx)(`input`,{type:`radio`,name:e.name,value:t.value,checked:String(i)===t.value,disabled:e.readonly,onChange:()=>n(t.value)}),(0,J.jsx)(`span`,{children:t.label})]},t.value))});default:return(0,J.jsx)(`input`,{...r,type:`text`,maxLength:e.maxLength,value:String(i),onChange:e=>n(e.target.value)})}}function kn({mode:e}){let t=d(),[n]=c(),r=(e===`public`?t.slug:t.name)??``,[i,a]=(0,q.useState)(!0),[o,s]=(0,q.useState)(null),[l,u]=(0,q.useState)(null),[f,p]=(0,q.useState)({}),[m,h]=(0,q.useState)(!1),[g,_]=(0,q.useState)(!1);(0,q.useEffect)(()=>{let t=!1;return a(!0),s(null),(e===`public`?Sn(r):wn(r)).then(e=>{if(t)return;u(e);let r=bn(e.form,e.objectSchema).flatMap(e=>e.fields);p(xn(r,n))}).catch(e=>{t||s(e?.message??String(e))}).finally(()=>{t||a(!1)}),()=>{t=!0}},[e,r,n]);let v=(0,q.useMemo)(()=>l?bn(l.form,l.objectSchema):[],[l]),y=l?.form?.submitBehavior??{kind:`thank-you`};return i?(0,J.jsx)(`div`,{className:`flex min-h-[60vh] items-center justify-center`,children:(0,J.jsx)(`div`,{className:`text-sm text-muted-foreground`,children:`Loading…`})}):o&&!l?(0,J.jsx)(`div`,{className:`mx-auto max-w-2xl p-6`,children:(0,J.jsx)(`div`,{className:`rounded-md border border-destructive/40 bg-destructive/10 p-4 text-sm text-destructive`,children:o})}):l?g&&y.kind===`thank-you`?(0,J.jsx)(`div`,{className:`mx-auto max-w-2xl p-6`,children:(0,J.jsxs)(`div`,{className:`rounded-md border bg-card p-6 text-center`,children:[(0,J.jsx)(`h2`,{className:`mb-2 text-lg font-semibold`,children:y.title??`Thanks!`}),(0,J.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:y.message??`Your submission has been received.`})]})}):g&&y.kind===`redirect`?(0,J.jsx)(`div`,{className:`mx-auto max-w-2xl p-6 text-center text-sm text-muted-foreground`,children:`Redirecting…`}):(0,J.jsxs)(`div`,{className:`mx-auto max-w-2xl p-4 sm:p-6`,children:[(0,J.jsxs)(`header`,{className:`mb-6`,children:[(0,J.jsx)(`h1`,{className:`text-xl font-semibold`,children:l.label}),l.form?.label&&l.form.label!==l.label&&(0,J.jsx)(`p`,{className:`mt-1 text-sm text-muted-foreground`,children:l.form.label})]}),(0,J.jsxs)(`form`,{onSubmit:async t=>{if(t.preventDefault(),l){h(!0),s(null);try{switch(e===`public`?await Tn(r,f):await En(l.object,f),H.success(`Submitted`),y.kind){case`redirect`:{let e=y.delayMs??0;setTimeout(()=>window.location.assign(y.url),e),_(!0);break}case`continue`:{let e=v.flatMap(e=>e.fields);p(xn(e,n));break}default:_(!0);break}}catch(e){let t=e?.message??String(e);s(t),H.error(t)}finally{h(!1)}}},className:`space-y-6`,children:[v.map((e,t)=>(0,J.jsxs)(`section`,{className:`rounded-md border bg-card p-4 sm:p-5`,children:[e.label&&(0,J.jsx)(`h2`,{className:`mb-3 text-sm font-medium`,children:e.label}),(0,J.jsx)(`div`,{className:e.columns===1?`grid grid-cols-1 gap-4`:e.columns===2?`grid grid-cols-1 gap-4 sm:grid-cols-2`:e.columns===3?`grid grid-cols-1 gap-4 sm:grid-cols-3`:`grid grid-cols-1 gap-4 sm:grid-cols-4`,children:e.fields.filter(e=>!e.hidden).map(e=>(0,J.jsxs)(`div`,{className:e.colSpan===2?`sm:col-span-2`:e.colSpan===3?`sm:col-span-3`:e.colSpan===4?`sm:col-span-4`:``,children:[(0,J.jsxs)(`label`,{htmlFor:`f_${e.name}`,className:`mb-1 block text-xs font-medium text-foreground`,children:[e.label,e.required&&(0,J.jsx)(`span`,{className:`ml-0.5 text-destructive`,children:`*`})]}),(0,J.jsx)(On,{field:e,value:f[e.name],onChange:t=>p(n=>({...n,[e.name]:t}))}),e.helpText&&(0,J.jsx)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:e.helpText})]},e.name))})]},t)),o&&(0,J.jsx)(`div`,{className:`rounded-md border border-destructive/40 bg-destructive/10 p-3 text-sm text-destructive`,children:o}),(0,J.jsx)(`div`,{className:`flex justify-end gap-2`,children:(0,J.jsx)(`button`,{type:`submit`,disabled:m,className:`rounded-md bg-primary px-4 py-2 text-sm font-medium text-primary-foreground shadow-sm hover:bg-primary/90 disabled:opacity-50`,children:m?`Submitting…`:`Submit`})})]})]}):null}function An({enabled:e=!1,url:t=`/api/v1/dev/metadata-events`,debounceMs:n=400,reconnectDelayMs:r=2e3}){let i=(0,q.useRef)(null);return(0,q.useEffect)(()=>{if(!e||typeof window>`u`||typeof EventSource>`u`)return;let a=null,o=null,s=!1,c=e=>{i.current&&clearTimeout(i.current),i.current=setTimeout(()=>{try{H.info(`Metadata changed (${e}) — reloading…`,{duration:800})}catch{}setTimeout(()=>{try{window.location.reload()}catch{}},150)},n)},l=e=>{try{let t=JSON.parse(e.data),n=t?.name?`${t.metadataType??`metadata`}:${t.name}`:`metadata`;c(n)}catch{c(`change`)}},u=e=>{let t=`rebuild`;try{t=JSON.parse(e.data)?.reason??t}catch{}c(t)},d=()=>{if(!s)try{a=new EventSource(t),a.addEventListener(`metadata-change`,l),a.addEventListener(`reload`,u),a.addEventListener(`error`,()=>{s||a?.readyState===EventSource.CLOSED&&(a=null,o=setTimeout(d,r))})}catch{o=setTimeout(d,r)}};return d(),()=>{if(s=!0,o&&clearTimeout(o),i.current&&clearTimeout(i.current),a)try{a.close()}catch{}}},[e,t,n,r]),null}function jn(){let e={BASE_URL:`./`,DEV:!1,MODE:`production`,PROD:!0,SSR:!1,VITE_SENTRY_DSN:`https://1373a588ceb9da150b11e64bf85f583d@o4510356161757184.ingest.us.sentry.io/4511439670673408`,VITE_SENTRY_ENVIRONMENT:`production`,VITE_SENTRY_SEND_DEFAULT_PII:`true`,VITE_SERVER_URL:``,VITE_USE_MOCK_SERVER:`false`}.VITE_SERVER_URL??``;return e?e.replace(/\/$/,``):typeof window<`u`?window.location.origin:``}function Mn(){let{token:e}=d(),t=`${(0,q.useMemo)(()=>jn(),[])}/api/v1`,[n,r]=(0,q.useState)(null),[i,a]=(0,q.useState)(null),[o,s]=(0,q.useState)(!0),[c,l]=(0,q.useState)(!1),[u,f]=(0,q.useState)(``),[p,m]=(0,q.useState)(null),h=(0,q.useCallback)(async n=>{if(e){s(!0),a(null);try{let i=new URL(`${t}/share-links/${encodeURIComponent(e)}/resolve`);n&&i.searchParams.set(`password`,n);let o=await fetch(i.toString(),{headers:{Accept:`application/json`}});if(o.status===401){l(!0),a(n?`Wrong password.`:null),s(!1);return}if(o.status===404){a(`This link is invalid or no longer available.`),s(!1);return}if(o.status===410){a(`This link has expired or was revoked.`),s(!1);return}if(!o.ok){let e=await o.json().catch(()=>null);a(e?.error?.message??`Failed to load (HTTP ${o.status}).`),s(!1);return}let c=await o.json(),u=`data`in c?c.data:{record:c.record,link:c.link,redactedFields:c.redactFields};r(u),l(!1)}catch(e){a(e?.message??`Failed to load shared content.`)}finally{s(!1)}}},[t,e]);(0,q.useEffect)(()=>{h()},[h]),(0,q.useEffect)(()=>{if(!n||n.link.object_name!==`ai_conversations`)return;let e=`${t}/share-links/${encodeURIComponent(n.link.token)}/messages`;fetch(e,{headers:{Accept:`application/json`}}).then(e=>e.ok?e.json():null).then(e=>m(e?.data??[])).catch(()=>m([]))},[t,n]);let g=(0,q.useMemo)(()=>p?it(We(st(p))):[],[p]);if(o)return(0,J.jsxs)(`div`,{className:`flex h-svh w-full items-center justify-center bg-background text-muted-foreground`,children:[(0,J.jsx)(L,{className:`mr-2 h-4 w-4 animate-spin`}),`Loading…`]});if(c)return(0,J.jsxs)(`div`,{className:`mx-auto flex h-svh max-w-md flex-col items-center justify-center gap-4 px-4 text-center`,children:[(0,J.jsx)(xe,{className:`h-8 w-8 text-muted-foreground`}),(0,J.jsx)(`h1`,{className:`text-lg font-semibold`,children:`Password required`}),(0,J.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`The owner protected this link with a password.`}),(0,J.jsxs)(`form`,{className:`flex w-full flex-col gap-2`,onSubmit:e=>{e.preventDefault(),h(u)},children:[(0,J.jsx)(B,{htmlFor:`share-pw`,className:`sr-only`,children:`Password`}),(0,J.jsx)(F,{id:`share-pw`,type:`password`,value:u,onChange:e=>f(e.target.value),autoFocus:!0,placeholder:`Enter password`}),i&&(0,J.jsx)(`p`,{className:`text-xs text-destructive`,children:i}),(0,J.jsx)(k,{type:`submit`,size:`sm`,children:`Continue`})]})]});if(i)return(0,J.jsxs)(`div`,{className:`mx-auto flex h-svh max-w-md flex-col items-center justify-center gap-3 px-4 text-center`,children:[(0,J.jsx)(ve,{className:`h-8 w-8 text-amber-500`}),(0,J.jsx)(`h1`,{className:`text-lg font-semibold`,children:`Can't open this link`}),(0,J.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:i})]});if(!n)return null;if(n.link.object_name===`ai_conversations`){let e=n.record;return(0,J.jsxs)(`div`,{className:`mx-auto flex h-svh max-w-3xl flex-col bg-background`,children:[(0,J.jsxs)(`header`,{className:`sticky top-0 z-10 flex items-center gap-2 border-b bg-background px-4 py-3`,children:[(0,J.jsx)(ue,{className:`h-5 w-5 text-muted-foreground`}),(0,J.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,J.jsx)(`h1`,{className:`truncate text-sm font-semibold`,children:e.title??`Shared conversation`}),(0,J.jsx)(`p`,{className:`truncate text-[11px] text-muted-foreground`,children:`Read-only · Shared via ObjectStack`})]}),(0,J.jsx)(M,{variant:`outline`,className:`text-[10px] capitalize`,children:n.link.permission})]}),(0,J.jsx)(`main`,{className:`flex min-h-0 flex-1 flex-col`,children:p==null?(0,J.jsxs)(`div`,{className:`flex flex-1 items-center justify-center py-12 text-sm text-muted-foreground`,children:[(0,J.jsx)(L,{className:`mr-2 h-4 w-4 animate-spin`}),`Loading messages…`]}):p.length===0?(0,J.jsx)(`p`,{className:`py-12 text-center text-sm text-muted-foreground`,children:`This conversation has no messages yet.`}):(0,J.jsx)(lt,{readOnly:!0,surface:`plain`,messages:g,showAvatars:!0,maxHeight:`100%`,className:`flex-1`})}),(0,J.jsx)(`footer`,{className:`border-t bg-muted/30 px-4 py-2 text-center text-[11px] text-muted-foreground`,children:`Powered by ObjectStack`})]})}return(0,J.jsxs)(`div`,{className:`mx-auto flex h-svh max-w-3xl flex-col bg-background`,children:[(0,J.jsx)(`header`,{className:`border-b px-4 py-3`,children:(0,J.jsxs)(`h1`,{className:`text-sm font-semibold`,children:[`Shared `,n.link.object_name]})}),(0,J.jsxs)(`main`,{className:`flex-1 overflow-y-auto p-4`,children:[(0,J.jsx)(`pre`,{className:`overflow-x-auto rounded-md border bg-muted/30 p-3 text-[12px]`,children:JSON.stringify(n.record,null,2)}),n.redactedFields&&n.redactedFields.length>0&&(0,J.jsxs)(`p`,{className:`mt-2 text-[11px] text-muted-foreground`,children:[`Some fields are hidden by the owner: `,n.redactedFields.join(`, `)]})]})]})}var Nn=/(^```[^\n]*\n[\s\S]*?\n```[ \t]*$|^~~~[^\n]*\n[\s\S]*?\n~~~[ \t]*$)/m,Pn=/(`[^`\n]+`)/,Fn=/\]\((?:\.\/)?([a-z][a-z0-9_]*)\.md(#[^)\s]*)?\)/g;function In(e){return e.split(Pn).map((e,t)=>t%2==1?e:e.replace(Fn,`](/docs/$1$2)`)).join(``)}function Ln(e){let t=[],n=e;for(;;){let e=Nn.exec(n);if(!e||e.index===void 0)return t.push(In(n)),t.join(``);t.push(In(n.slice(0,e.index)),e[0]),n=n.slice(e.index+e[0].length)}}function Rn({book:e,activeDoc:t,docHref:n}){return(0,J.jsxs)(`nav`,{"aria-label":e.label??e.name,className:`text-sm`,children:[e.label?(0,J.jsx)(`div`,{className:`mb-3 px-2 text-sm font-semibold text-foreground`,children:e.label}):null,(0,J.jsx)(`div`,{className:`space-y-5`,children:e.groups.map(e=>(0,J.jsxs)(`div`,{children:[(0,J.jsx)(`div`,{className:`mb-1 px-2 text-xs font-semibold uppercase tracking-wide text-muted-foreground`,children:e.label}),(0,J.jsx)(`ul`,{className:`space-y-0.5`,children:e.entries.map((e,i)=>{if(e.separator)return(0,J.jsx)(`li`,{className:`my-1.5 border-t border-border/60`,"aria-hidden":!0},`sep-${i}`);if(e.href)return(0,J.jsx)(`li`,{children:(0,J.jsxs)(`a`,{href:e.href,target:`_blank`,rel:`noreferrer`,className:`flex items-center gap-1.5 rounded px-2 py-1 text-muted-foreground hover:bg-muted/50 hover:text-foreground`,children:[(0,J.jsx)(`span`,{className:`truncate`,children:e.label??e.href}),(0,J.jsx)(Me,{className:`h-3 w-3 shrink-0 opacity-60`})]})},`ext-${i}`);if(!e.doc)return null;let a=e.doc===t;return(0,J.jsx)(`li`,{children:(0,J.jsx)(r,{to:n(e.doc),"aria-current":a?`page`:void 0,className:`block truncate rounded px-2 py-1 transition ${a?`bg-primary/10 font-medium text-foreground`:`text-muted-foreground hover:bg-muted/50 hover:text-foreground`}`,children:e.label??e.doc})},e.doc)})})]},e.key))})]})}var zn=t({default:()=>Bn});function Bn(){let{slug:e,name:t,appName:n}=d(),r=o(),i=ne(),{t:a}=A(),[s,c]=(0,q.useState)(null),[l,u]=(0,q.useState)(`loading`),[f,p]=(0,q.useState)(``);(0,q.useEffect)(()=>{let e=!1;async function r(){if(!(!t||!i)){u(`loading`);try{let r=await i.getClient().meta.getItem(`doc`,t,n?{packageId:n}:void 0),a=r?.item??r?.data??r;if(e)return;a&&typeof a.content==`string`?(c({name:t,label:a.label,content:a.content}),u(`ready`)):u(`missing`)}catch(t){if(e)return;(t?.status??t?.response?.status)===404||/not found/i.test(t?.message??``)?u(`missing`):(p(t?.message??`Failed to load documentation`),u(`error`))}}}return r(),()=>{e=!0}},[t,n,i]);let m=(0,q.useCallback)(e=>{document.getElementById(e)?.scrollIntoView({behavior:`smooth`,block:`start`}),window.history.replaceState(null,``,`${window.location.pathname}${window.location.search}#${e}`)},[]),h=(0,q.useCallback)(e=>{if(e.defaultPrevented||e.metaKey||e.ctrlKey||e.shiftKey||e.altKey||e.button!==0)return;let t=e.target.closest(`a`)?.getAttribute(`href`);t&&(t.startsWith(`/docs/`)?(e.preventDefault(),r(t)):t.startsWith(`#`)&&(e.preventDefault(),m(decodeURIComponent(t.slice(1)))))},[r,m]),g=(0,q.useCallback)((e,t)=>{e.defaultPrevented||e.metaKey||e.ctrlKey||e.shiftKey||e.altKey||e.button!==0||(e.preventDefault(),m(t))},[m]),_=(0,q.useMemo)(()=>yt(s?.content??``),[s?.content]),v=a(`help.onThisPage`,{defaultValue:`On this page`}),{books:y,docs:b}=wt(),x=n?`/apps/${n}/docs`:`/docs`,S=(0,q.useMemo)(()=>{let t=y.find(t=>St(t)===e);return t?Ct(t,kt(t,b)):null},[y,b,e]),C=(0,q.useCallback)(t=>`${x}/${e}/${t}`,[x,e]);return l===`loading`?(0,J.jsx)(`div`,{className:`flex h-full items-center justify-center p-10 text-muted-foreground`,children:(0,J.jsx)(L,{className:`h-5 w-5 animate-spin`,"aria-label":`Loading documentation`})}):l===`missing`?(0,J.jsx)(K,{breadcrumb:t,children:(0,J.jsxs)(`div`,{className:`mx-auto flex max-w-3xl flex-col items-center gap-3 p-10 text-center`,children:[(0,J.jsx)(se,{className:`h-10 w-10 text-muted-foreground`}),(0,J.jsx)(`h1`,{className:`text-lg font-semibold`,children:`Documentation not found`}),(0,J.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[`No document named `,(0,J.jsx)(`code`,{className:`rounded bg-muted px-1 py-0.5`,children:t}),` is installed. It may belong to a package that is not installed, or it was removed in a newer version.`]})]})}):l===`error`?(0,J.jsx)(K,{breadcrumb:t,children:(0,J.jsxs)(`div`,{className:`mx-auto flex max-w-3xl flex-col items-center gap-3 p-10 text-center`,children:[(0,J.jsx)(pe,{className:`h-10 w-10 text-destructive`}),(0,J.jsx)(`h1`,{className:`text-lg font-semibold`,children:`Failed to load documentation`}),(0,J.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:f})]})}):(0,J.jsxs)(K,{breadcrumb:s?.label??t,children:[S?(0,J.jsxs)(`details`,{className:`group mx-auto max-w-6xl px-4 pt-4 sm:px-6 lg:hidden`,children:[(0,J.jsxs)(`summary`,{className:`flex cursor-pointer list-none items-center gap-2 rounded-md border bg-muted/30 px-3 py-2 text-sm font-medium [&::-webkit-details-marker]:hidden`,children:[(0,J.jsx)(Le,{className:`h-4 w-4 text-muted-foreground`}),(0,J.jsx)(`span`,{className:`truncate`,children:S.label??`Contents`}),(0,J.jsx)(ce,{className:`ml-auto h-4 w-4 text-muted-foreground transition-transform group-open:rotate-180`})]}),(0,J.jsx)(`div`,{className:`mt-2 rounded-md border p-3`,children:(0,J.jsx)(Rn,{book:S,activeDoc:t,docHref:C})})]}):null,(0,J.jsxs)(`div`,{className:`mx-auto flex gap-8 p-4 sm:p-6 ${S?`max-w-6xl`:`max-w-5xl`}`,children:[S?(0,J.jsx)(`aside`,{className:`hidden w-56 shrink-0 lg:block`,children:(0,J.jsx)(`nav`,{className:`sticky top-20 max-h-[calc(100vh-6rem)] overflow-auto pr-1`,children:(0,J.jsx)(Rn,{book:S,activeDoc:t,docHref:C})})}):null,(0,J.jsx)(`article`,{className:`min-w-0 max-w-3xl flex-1 [&_h1]:scroll-mt-24 [&_h2]:scroll-mt-24 [&_h3]:scroll-mt-24`,onClick:h,children:(0,J.jsx)(bt,{schema:{type:`markdown`,content:Ln(s?.content??``)}})}),_.length>=3?(0,J.jsx)(`aside`,{className:`hidden xl:block w-56 shrink-0`,children:(0,J.jsxs)(`nav`,{"aria-label":v,className:`sticky top-20 max-h-[calc(100vh-6rem)] overflow-auto`,children:[(0,J.jsx)(`div`,{className:`mb-2 text-xs font-semibold uppercase tracking-wide text-muted-foreground`,children:v}),(0,J.jsx)(`ul`,{className:`border-l border-border text-sm`,children:_.map(e=>(0,J.jsx)(`li`,{style:{paddingLeft:(e.depth-2)*12},children:(0,J.jsx)(`a`,{href:`#${e.id}`,onClick:t=>g(t,e.id),className:`-ml-px block border-l border-transparent py-0.5 pl-3 text-muted-foreground hover:border-primary hover:text-foreground`,children:e.text})},e.id))})]})}):null]})]})}function Vn(){let{books:e,docs:t,state:n,error:i}=wt(),a=(0,q.useMemo)(()=>xt(e,t),[e,t]);return n===`loading`?(0,J.jsx)(`div`,{className:`flex h-full items-center justify-center p-10 text-muted-foreground`,children:(0,J.jsx)(L,{className:`h-5 w-5 animate-spin`,"aria-label":`Loading documentation`})}):n===`error`?(0,J.jsxs)(`div`,{className:`mx-auto flex max-w-3xl flex-col items-center gap-3 p-10 text-center`,children:[(0,J.jsx)(pe,{className:`h-10 w-10 text-destructive`}),(0,J.jsx)(`h1`,{className:`text-lg font-semibold`,children:`Failed to load documentation`}),(0,J.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:i})]}):(0,J.jsx)(K,{children:(0,J.jsxs)(`div`,{className:`mx-auto max-w-4xl p-4 sm:p-6`,children:[(0,J.jsxs)(`header`,{className:`mb-6`,children:[(0,J.jsx)(`h1`,{className:`text-2xl font-bold tracking-tight`,children:`Documentation`}),(0,J.jsx)(`p`,{className:`mt-1 text-sm text-muted-foreground`,children:`Books and guides from your installed packages.`})]}),a.length===0?(0,J.jsxs)(`div`,{className:`flex flex-col items-center gap-3 py-16 text-center text-muted-foreground`,children:[(0,J.jsx)(Te,{className:`h-10 w-10`}),(0,J.jsxs)(`p`,{className:`text-sm`,children:[`No documentation is installed. Packages ship docs as flat`,(0,J.jsx)(`code`,{className:`mx-1 rounded bg-muted px-1 py-0.5`,children:`src/docs/*.md`}),`files, organised by a `,(0,J.jsx)(`code`,{className:`rounded bg-muted px-1 py-0.5`,children:`book`}),` (ADR-0046).`]})]}):(0,J.jsx)(`ul`,{className:`grid items-stretch gap-3 sm:grid-cols-2`,children:a.map(e=>(0,J.jsx)(`li`,{className:`h-full`,children:(0,J.jsxs)(r,{to:`/docs/${e.slug}`,className:`flex h-full items-start gap-3 rounded-md border border-border p-3 hover:bg-muted/50`,children:[(0,J.jsx)(Te,{className:`mt-0.5 h-5 w-5 shrink-0 text-muted-foreground`}),(0,J.jsxs)(`div`,{className:`min-w-0`,children:[(0,J.jsx)(`div`,{className:`text-sm font-semibold`,children:e.label}),e.description?(0,J.jsx)(`div`,{className:`mt-0.5 line-clamp-2 text-xs text-muted-foreground`,children:e.description}):e.subtitle?(0,J.jsx)(`div`,{className:`mt-0.5 truncate font-mono text-[11px] text-muted-foreground/70`,children:e.subtitle}):null,(0,J.jsxs)(`div`,{className:`mt-1 text-xs text-muted-foreground/80`,children:[e.docCount,` `,e.docCount===1?`article`:`articles`]})]})]})},e.name))})]})})}function Hn(){let{slug:e,appName:t}=d(),{books:n,docs:r,state:i}=wt(),a=(0,q.useMemo)(()=>n.find(t=>St(t)===e),[n,e]),o=(0,q.useMemo)(()=>a?Tt(Ct(a,kt(a,r))):void 0,[a,r]);return i===`loading`?(0,J.jsx)(`div`,{className:`flex h-full items-center justify-center p-10 text-muted-foreground`,children:(0,J.jsx)(L,{className:`h-5 w-5 animate-spin`,"aria-label":`Loading documentation`})}):a&&o?(0,J.jsx)(p,{to:`${t?`/apps/${t}/docs`:`/docs`}/${e}/${o}`,replace:!0}):(0,J.jsx)(K,{breadcrumb:a?a.label??e:e,children:(0,J.jsx)(`div`,{className:`mx-auto flex max-w-3xl flex-col items-center gap-3 p-10 text-center`,children:a?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(Te,{className:`h-10 w-10 text-muted-foreground`}),(0,J.jsx)(`h1`,{className:`text-lg font-semibold`,children:a.label??e}),(0,J.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`This book has no documents yet.`})]}):(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(se,{className:`h-10 w-10 text-muted-foreground`}),(0,J.jsx)(`h1`,{className:`text-lg font-semibold`,children:`Book not found`}),(0,J.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[`No book named `,(0,J.jsx)(`code`,{className:`rounded bg-muted px-1 py-0.5`,children:e}),` is installed.`]})]})})})}var Un=t({default:()=>Wn});function Wn(){let{slug:e,appName:t}=d(),{books:n,docs:r,state:i}=wt();if(i===`loading`)return(0,J.jsx)(`div`,{className:`flex h-full items-center justify-center p-10 text-muted-foreground`,children:(0,J.jsx)(L,{className:`h-5 w-5 animate-spin`,"aria-label":`Loading documentation`})});if(e&&n.some(t=>St(t)===e))return(0,J.jsx)(Hn,{});let a=t?`/apps/${t}/docs`:`/docs`,o=e?Dt(e,n,r):null;return o&&e?(0,J.jsx)(p,{to:`${a}/${St(o)}/${e}`,replace:!0}):(0,J.jsx)(K,{breadcrumb:e,children:(0,J.jsxs)(`div`,{className:`mx-auto flex max-w-3xl flex-col items-center gap-3 p-10 text-center`,children:[(0,J.jsx)(se,{className:`h-10 w-10 text-muted-foreground`}),(0,J.jsx)(`h1`,{className:`text-lg font-semibold`,children:`Documentation not found`}),(0,J.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[`No book or document named `,(0,J.jsx)(`code`,{className:`rounded bg-muted px-1 py-0.5`,children:e}),` is installed.`]})]})})}var Gn=t({default:()=>Kn});function Kn(){let e=Et();return(0,J.jsx)(Ot.Provider,{value:e,children:(0,J.jsx)(i,{})})}function qn(e){let t=e.split(`:`)[0].toLowerCase();return/^cloud\./.test(t)}function Jn(e){let t=e.split(`:`)[0].toLowerCase();return t===`localhost`||t===`127.0.0.1`||t===`[::1]`||t.endsWith(`.local`)}function Yn(){return typeof window>`u`?null:window.location.host||null}function Xn(){let e=W(),t=ht();return(0,J.jsxs)(`div`,{className:`flex items-center justify-center gap-2.5 select-none`,children:[(0,J.jsx)(`span`,{className:`inline-flex h-9 w-9 items-center justify-center rounded-xl bg-gradient-to-br from-indigo-500 to-indigo-600 text-white shadow-sm shadow-indigo-500/30 overflow-hidden`,children:t?(0,J.jsx)(`img`,{src:t,alt:e,className:`h-full w-full object-contain`}):(0,J.jsxs)(`svg`,{viewBox:`0 0 24 24`,width:`18`,height:`18`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[(0,J.jsx)(`path`,{d:`M12 2 2 7l10 5 10-5-10-5Z`}),(0,J.jsx)(`path`,{d:`m2 17 10 5 10-5`}),(0,J.jsx)(`path`,{d:`m2 12 10 5 10-5`})]})}),(0,J.jsx)(`span`,{className:`text-lg font-semibold tracking-tight text-foreground`,children:e})]})}function X({children:e,formWidth:t=`sm`}){let{t:n}=A(),r=t===`md`?`max-w-md`:`max-w-sm`,i=Yn(),a=!!i&&!qn(i)&&!Jn(i);return(0,q.useEffect)(()=>{if(typeof document>`u`||!i)return;let e=document.title;return a&&(document.title=i),()=>{document.title=e}},[i,a]),(0,J.jsxs)(`div`,{className:`relative flex min-h-svh w-full items-center justify-center overflow-hidden bg-background p-6`,children:[(0,J.jsxs)(`div`,{"aria-hidden":!0,className:`pointer-events-none absolute inset-0 -z-10`,children:[(0,J.jsx)(`div`,{className:`absolute inset-0 opacity-[0.35] dark:opacity-[0.25] [mask-image:radial-gradient(ellipse_at_center,black,transparent_72%)] [-webkit-mask-image:radial-gradient(ellipse_at_center,black,transparent_72%)]`,style:{backgroundImage:`radial-gradient(hsl(var(--border)) 1px, transparent 1px)`,backgroundSize:`22px 22px`}}),(0,J.jsx)(`div`,{className:`absolute left-1/2 top-1/2 h-[34rem] w-[34rem] -translate-x-1/2 -translate-y-1/2 rounded-full bg-gradient-to-br from-indigo-500/10 to-indigo-600/10 blur-3xl dark:from-indigo-500/10 dark:to-indigo-600/10`})]}),(0,J.jsxs)(`div`,{className:de(`flex w-full flex-col gap-5`,r),children:[(0,J.jsx)(Xn,{}),a?(0,J.jsx)(`div`,{className:`flex justify-center`,children:(0,J.jsx)(`span`,{className:`rounded-full border border-border/60 bg-background/60 px-2 py-0.5 font-mono text-[10px] uppercase tracking-wide text-muted-foreground`,title:n(`auth.shell.tenantHostHint`,{defaultValue:`You are signing in to this workspace`}),children:i})}):null,e]})]})}function Zn(e){let t=`/api/v1/auth/oauth2/authorize${e}`,n=()=>window.location.assign(t);fetch(t,{credentials:`include`,redirect:`manual`,headers:{accept:`application/json`}}).then(async e=>{let t=await e.json().catch(()=>null),r=t?.url??t?.redirect_uri??t?.redirectURI;if(e.ok&&r){window.location.href=r;return}n()}).catch(n)}function Qn(e){return!!e&&e.startsWith(`/`)&&!e.startsWith(`//`)}function $n(e){return e.startsWith(`/_`)?e:`./`.replace(/\/$/,``)+(e.startsWith(`/`)?e:`/${e}`)}var er=`os.console.devAdminHintDismissed`;function tr(e){return(0,J.jsx)(r,{to:e.href,className:e.className,children:e.children})}function nr(){let{t:e}=A(),[t]=c(),n=t.get(`redirect`),{user:r,isLoading:i,organizations:a,isOrganizationsLoading:o,activeOrganization:s,switchOrganization:l,getAuthConfig:u}=C(),[d,f]=(0,q.useState)(!1),[p,m]=(0,q.useState)(null),[h,g]=(0,q.useState)(()=>{try{return window.localStorage.getItem(er)===`1`}catch{return!1}}),_=()=>{g(!0);try{window.localStorage.setItem(er,`1`)}catch{}},[v,y]=(0,q.useState)(!1),b=(0,q.useRef)(!1),[x,S]=(0,q.useState)(!1);(0,q.useLayoutEffect)(()=>{i||S(!0)},[i]);let w=(0,q.useMemo)(()=>{if(typeof window>`u`)return null;let e=new URLSearchParams(window.location.search),t=e.get(`redirect_uri`);if(!e.has(`client_id`)||!t)return null;try{return new URL(t).host}catch{return null}},[]),T=(0,q.useMemo)(()=>{let e=t.get(`error`);return e?{code:e,description:t.get(`error_description`)}:null},[]);if((0,q.useEffect)(()=>{let e=!1;return u().then(t=>{if(e)return;f(t?.emailPassword?.disableSignUp===!0);let n=t?.devSeedAdmin;m(n&&typeof n.email==`string`?{email:n.email,password:typeof n.password==`string`?n.password:void 0}:null)}).catch(()=>{}),()=>{e=!0}},[u]),(0,q.useEffect)(()=>{if(r){if(typeof window<`u`){let e=new URLSearchParams(window.location.search);if(e.has(`client_id`)&&e.has(`redirect_uri`)){b.current||(b.current=!0,Zn(window.location.search));return}}if(!s){if(o||v)return;if(a.length===1){y(!0),l(a[0].id).catch(()=>void 0).finally(()=>y(!1));return}if(a.length===0){window.location.assign($n(Qn(n)?n:`/`));return}window.location.assign($n(`/organizations`));return}v||window.location.assign($n(Qn(n)?n:`/`))}},[r,s,a,o,v,n,l]),i&&!x||r)return(0,J.jsx)(X,{children:(0,J.jsxs)(`div`,{className:`flex flex-col items-center gap-3 py-10 text-sm text-muted-foreground`,children:[(0,J.jsx)(`div`,{className:`size-6 animate-spin rounded-full border-2 border-muted-foreground border-t-transparent`}),(0,J.jsx)(`span`,{children:e(`auth.login.signingIn`,{defaultValue:`Signing you in…`})})]})});let E=n?`/register?redirect=${encodeURIComponent(n)}`:`/register`;return(0,J.jsx)(X,{formWidth:`md`,children:(0,J.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[T?(0,J.jsx)(ee,{message:e(`auth.login.errors.oauthCallbackFailed`,{defaultValue:`Single sign-on could not be completed — the sign-in link expired or was already used. Please try again.`})+(T.description?` (${T.description})`:` (${T.code})`)}):null,w?(0,J.jsxs)(`div`,{role:`status`,className:`flex items-start gap-3 rounded-md border border-primary/30 bg-primary/5 px-4 py-3 text-sm text-foreground`,children:[(0,J.jsx)(`span`,{className:`mt-0.5 inline-block size-2 shrink-0 rounded-full bg-primary`}),(0,J.jsx)(`span`,{children:e(`auth.login.ssoHandoff`,{target:w,defaultValue:`Continue to ${w}`})})]}):null,p&&!h?(0,J.jsxs)(`div`,{role:`status`,"data-testid":`dev-admin-hint`,className:`flex items-start gap-3 rounded-md border border-amber-500/40 bg-amber-500/10 px-4 py-3 text-sm text-foreground`,children:[(0,J.jsx)(`span`,{className:`mt-0.5 inline-block size-2 shrink-0 rounded-full bg-amber-500`}),(0,J.jsxs)(`div`,{className:`flex-1`,children:[(0,J.jsx)(`div`,{className:`font-medium`,children:e(`auth.login.devAdminHint.title`,{defaultValue:`Development instance`})}),(0,J.jsxs)(`div`,{className:`text-muted-foreground`,children:[e(`auth.login.devAdminHint.body`,{defaultValue:`Sign in with the seeded dev admin:`}),` `,(0,J.jsx)(`code`,{className:`rounded bg-muted px-1 py-0.5 font-mono text-xs`,children:p.email}),p.password?(0,J.jsxs)(J.Fragment,{children:[` / `,(0,J.jsx)(`code`,{className:`rounded bg-muted px-1 py-0.5 font-mono text-xs`,children:p.password})]}):null]})]}),(0,J.jsx)(`button`,{type:`button`,onClick:_,"aria-label":e(`auth.login.devAdminHint.dismiss`,{defaultValue:`Dismiss`}),className:`shrink-0 rounded p-1 text-muted-foreground transition-colors hover:bg-muted hover:text-foreground`,children:(0,J.jsx)(`svg`,{viewBox:`0 0 16 16`,"aria-hidden":`true`,className:`size-3.5 fill-current`,children:(0,J.jsx)(`path`,{d:`M3.72 3.72a.75.75 0 0 1 1.06 0L8 6.94l3.22-3.22a.75.75 0 1 1 1.06 1.06L9.06 8l3.22 3.22a.75.75 0 1 1-1.06 1.06L8 9.06l-3.22 3.22a.75.75 0 0 1-1.06-1.06L6.94 8 3.72 4.78a.75.75 0 0 1 0-1.06Z`})})})]}):null,(0,J.jsx)(I,{className:`border-border/60 px-4 py-8 shadow-sm shadow-primary/5 backdrop-blur supports-[backdrop-filter]:bg-card/95`,children:(0,J.jsx)(rr,{registerUrl:d?void 0:E,redirect:n})})]})})}function rr({registerUrl:e,redirect:t}){let{t:n}=A(),r=o(),i=(0,q.useRef)(``);return(0,q.useEffect)(()=>{let e=e=>{let t=e.target;t?.id===`login-email`&&(i.current=t.value)};return document.addEventListener(`input`,e,!0),()=>document.removeEventListener(`input`,e,!0)},[]),(0,J.jsx)(x,{onError:e=>{let n=e.message||``,a=e.code,o=n.toLowerCase();if(a===`EMAIL_NOT_VERIFIED`||o.includes(`email`)&&(o.includes(`verif`)||o.includes(`not verified`))){let e=new URLSearchParams;i.current&&e.set(`email`,i.current),t&&e.set(`redirect`,t),r(`/verify-email-prompt?${e.toString()}`)}},title:n(`auth.login.title`,{defaultValue:`Sign in to your account`}),description:n(`auth.login.description`,{defaultValue:`Enter your email and password to continue`}),registerUrl:e,forgotPasswordUrl:`/forgot-password`,linkComponent:tr,errorMessages:{INVALID_EMAIL_OR_PASSWORD:n(`auth.login.errors.invalidCredentials`,{defaultValue:`Invalid email or password`}),EMAIL_NOT_VERIFIED:n(`auth.login.errors.emailNotVerified`,{defaultValue:`Please verify your email address before signing in.`})},labels:{emailLabel:n(`auth.login.emailLabel`,{defaultValue:`Email`}),emailPlaceholder:n(`auth.login.emailPlaceholder`,{defaultValue:`name@example.com`}),emailOrPhoneLabel:n(`auth.login.emailOrPhoneLabel`,{defaultValue:`Email or phone number`}),emailOrPhonePlaceholder:n(`auth.login.emailOrPhonePlaceholder`,{defaultValue:`name@example.com or +1 555 000 0000`}),passwordLabel:n(`auth.login.passwordLabel`,{defaultValue:`Password`}),passwordPlaceholder:n(`auth.login.passwordPlaceholder`,{defaultValue:`Enter your password`}),forgotPasswordText:n(`auth.login.forgotPasswordText`,{defaultValue:`Forgot password?`}),submitButton:n(`auth.login.submitButton`,{defaultValue:`Sign In`}),submittingButton:n(`auth.login.submittingButton`,{defaultValue:`Signing in…`}),noAccountText:n(`auth.login.noAccountText`,{defaultValue:`Don't have an account?`}),signUpText:n(`auth.login.signUpText`,{defaultValue:`Sign up`}),phoneLabel:n(`auth.login.phoneLabel`,{defaultValue:`Phone number`}),phonePlaceholder:n(`auth.login.phonePlaceholder`,{defaultValue:`+1 555 000 0000`}),otpCodeLabel:n(`auth.login.otpCodeLabel`,{defaultValue:`Verification code`}),otpCodePlaceholder:n(`auth.login.otpCodePlaceholder`,{defaultValue:`6-digit code`}),sendOtpButton:n(`auth.login.sendOtpButton`,{defaultValue:`Get code`}),resendOtpCountdownText:n(`auth.login.resendOtpCountdownText`,{defaultValue:`Resend in {seconds}s`}),usePhoneOtpText:n(`auth.login.usePhoneOtpText`,{defaultValue:`Sign in with verification code`}),usePasswordSignInText:n(`auth.login.usePasswordSignInText`,{defaultValue:`Sign in with password instead`})}})}function ir(e){return!!e&&e.startsWith(`/`)&&!e.startsWith(`//`)}function ar(e){return e.startsWith(`/_`)?e:`./`.replace(/\/$/,``)+(e.startsWith(`/`)?e:`/${e}`)}function or(e){return(0,J.jsx)(r,{to:e.href,className:e.className,children:e.children})}function sr(){let{t:e}=A(),t=o(),[n]=c(),r=n.get(`redirect`),{user:i,isLoading:a,organizations:s,isOrganizationsLoading:l,activeOrganization:u,switchOrganization:d,getAuthConfig:f}=C(),[p,m]=(0,q.useState)(null),[h,g]=(0,q.useState)(!1),v=(0,q.useRef)(!1),[y,b]=(0,q.useState)(!1);if((0,q.useLayoutEffect)(()=>{a||b(!0)},[a]),(0,q.useEffect)(()=>{let e=!1;return f().then(n=>{if(e)return;let i=n?.emailPassword?.disableSignUp===!0;if(m(i),i){let e=r?`?redirect=${encodeURIComponent(r)}`:``;t(`/login${e}`,{replace:!0})}}).catch(()=>{e||m(!1)}),()=>{e=!0}},[f,t,r]),(0,q.useEffect)(()=>{if(i){if(typeof window<`u`){let e=new URLSearchParams(window.location.search);if(e.has(`client_id`)&&e.has(`redirect_uri`)){v.current||(v.current=!0,Zn(window.location.search));return}}if(!u){if(l||h)return;if(s.length===1){g(!0),d(s[0].id).catch(()=>void 0).finally(()=>g(!1));return}if(s.length===0){window.location.assign(ar(ir(r)?r:`/`));return}window.location.assign(ar(`/organizations`));return}h||window.location.assign(ar(ir(r)?r:`/`))}},[i,u,s,l,h,r,d]),p===null||a&&!y||i)return(0,J.jsx)(X,{children:(0,J.jsx)(`div`,{className:`flex flex-col items-center gap-3 py-10 text-sm text-muted-foreground`,children:(0,J.jsx)(`div`,{className:`size-6 animate-spin rounded-full border-2 border-muted-foreground border-t-transparent`})})});let x=r?`/login?redirect=${encodeURIComponent(r)}`:`/login`;return(0,J.jsx)(X,{formWidth:`md`,children:(0,J.jsx)(I,{className:`border-border/60 px-4 py-8 shadow-sm shadow-primary/5 backdrop-blur supports-[backdrop-filter]:bg-card/95`,children:(0,J.jsx)(_,{title:e(`auth.register.title`,{defaultValue:`Create your account`}),description:e(`auth.register.description`,{defaultValue:`Sign up to get started`}),loginUrl:x,linkComponent:or,errorMessages:{USER_ALREADY_EXISTS_USE_ANOTHER_EMAIL:e(`auth.register.errors.userExists`,{defaultValue:`An account with this email already exists. Try signing in instead.`}),USER_ALREADY_EXISTS:e(`auth.register.errors.userExists`,{defaultValue:`An account with this email already exists. Try signing in instead.`})},onVerificationRequired:e=>{let n=new URLSearchParams;n.set(`email`,e),r&&n.set(`redirect`,r),t(`/verify-email-prompt?${n.toString()}`,{replace:!0})},labels:{nameLabel:e(`auth.register.nameLabel`,{defaultValue:`Name`}),namePlaceholder:e(`auth.register.namePlaceholder`,{defaultValue:`John Doe`}),emailLabel:e(`auth.register.emailLabel`,{defaultValue:`Email`}),emailPlaceholder:e(`auth.register.emailPlaceholder`,{defaultValue:`name@example.com`}),passwordLabel:e(`auth.register.passwordLabel`,{defaultValue:`Password`}),passwordPlaceholder:e(`auth.register.passwordPlaceholder`,{defaultValue:`Create a password (min. 8 characters)`}),confirmPasswordLabel:e(`auth.register.confirmPasswordLabel`,{defaultValue:`Confirm password`}),confirmPasswordPlaceholder:e(`auth.register.confirmPasswordPlaceholder`,{defaultValue:`Confirm your password`}),passwordMismatchError:e(`auth.register.passwordMismatchError`,{defaultValue:`Passwords do not match`}),passwordTooShortError:e(`auth.register.passwordTooShortError`,{defaultValue:`Password must be at least 8 characters`}),submitButton:e(`auth.register.submitButton`,{defaultValue:`Create account`}),submittingButton:e(`auth.register.submittingButton`,{defaultValue:`Creating account…`}),hasAccountText:e(`auth.register.hasAccountText`,{defaultValue:`Already have an account?`}),signInText:e(`auth.register.signInText`,{defaultValue:`Sign in`})}})})})}function cr(e){return(0,J.jsx)(r,{to:e.href,className:e.className,children:e.children})}function lr(){let{t:e}=A();return(0,J.jsx)(X,{formWidth:`md`,children:(0,J.jsx)(I,{className:`border-border/60 px-4 py-8 shadow-sm shadow-primary/5 backdrop-blur supports-[backdrop-filter]:bg-card/95`,children:(0,J.jsx)(T,{loginUrl:`/login`,linkComponent:cr,title:e(`auth.forgotPassword.title`,{defaultValue:`Reset your password`}),description:e(`auth.forgotPassword.description`,{defaultValue:`Enter your email and we'll send you a reset link.`}),labels:{emailLabel:e(`auth.forgotPassword.emailLabel`,{defaultValue:`Email`}),emailPlaceholder:e(`auth.forgotPassword.emailPlaceholder`,{defaultValue:`name@example.com`}),submitButton:e(`auth.forgotPassword.submitButton`,{defaultValue:`Send reset link`}),submittingButton:e(`auth.forgotPassword.submittingButton`,{defaultValue:`Sending…`}),successTitle:e(`auth.forgotPassword.successTitle`,{defaultValue:`Check your email`}),successDescription:e(`auth.forgotPassword.successDescription`,{defaultValue:`If an account exists, a reset link has been sent.`}),backToSignInText:e(`auth.forgotPassword.backToSignInText`,{defaultValue:`Back to sign in`}),phoneLabel:e(`auth.forgotPassword.phoneLabel`,{defaultValue:`Phone number`}),phonePlaceholder:e(`auth.forgotPassword.phonePlaceholder`,{defaultValue:`+1 555 000 0000`}),otpCodeLabel:e(`auth.forgotPassword.otpCodeLabel`,{defaultValue:`Verification code`}),otpCodePlaceholder:e(`auth.forgotPassword.otpCodePlaceholder`,{defaultValue:`6-digit code`}),sendOtpButton:e(`auth.forgotPassword.sendOtpButton`,{defaultValue:`Get code`}),resendOtpCountdownText:e(`auth.forgotPassword.resendOtpCountdownText`,{defaultValue:`Resend in {seconds}s`}),newPasswordLabel:e(`auth.forgotPassword.newPasswordLabel`,{defaultValue:`New password`}),newPasswordPlaceholder:e(`auth.forgotPassword.newPasswordPlaceholder`,{defaultValue:`Enter a new password`}),resetButton:e(`auth.forgotPassword.resetButton`,{defaultValue:`Reset Password`}),usePhoneResetText:e(`auth.forgotPassword.usePhoneResetText`,{defaultValue:`Reset via SMS code`}),useEmailResetText:e(`auth.forgotPassword.useEmailResetText`,{defaultValue:`Reset via email instead`}),phoneSuccessTitle:e(`auth.forgotPassword.phoneSuccessTitle`,{defaultValue:`Password reset`}),phoneSuccessDescription:e(`auth.forgotPassword.phoneSuccessDescription`,{defaultValue:`Your password has been reset. You can now sign in with your new password.`}),rememberPasswordText:e(`auth.forgotPassword.rememberPasswordText`,{defaultValue:`Remember your password?`}),signInText:e(`auth.forgotPassword.signInText`,{defaultValue:`Sign in`})}})})})}function ur(){let{t:e}=A(),t=o(),[n]=c(),i=n.get(`token`),{resetPassword:a}=C(),[s,l]=(0,q.useState)(``),[u,d]=(0,q.useState)(``),[f,p]=(0,q.useState)(!1);return(0,J.jsx)(X,{children:(0,J.jsxs)(I,{className:`border-border/60 shadow-sm shadow-primary/5 backdrop-blur supports-[backdrop-filter]:bg-card/95`,children:[(0,J.jsxs)(P,{className:`text-center`,children:[(0,J.jsx)(z,{className:`text-xl tracking-tight`,children:e(`auth.resetPassword.title`,{defaultValue:`Set a new password`})}),(0,J.jsx)(j,{children:e(`auth.resetPassword.description`,{defaultValue:`Choose a password you have not used before.`})})]}),(0,J.jsx)(R,{children:i?(0,J.jsxs)(`form`,{onSubmit:async n=>{if(n.preventDefault(),s!==u){H.error(e(`auth.resetPassword.passwordsMismatch`,{defaultValue:`Passwords do not match`}));return}if(!i){H.error(e(`auth.resetPassword.missingToken`,{defaultValue:`Reset link is missing or expired`}));return}p(!0);try{await a(i,s),H.success(e(`auth.resetPassword.success`,{defaultValue:`Password updated`})),t(`/login`)}catch(t){H.error(e(`auth.resetPassword.failed`,{defaultValue:`Reset failed`}),{description:t.message})}finally{p(!1)}},className:`flex flex-col gap-4`,children:[(0,J.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,J.jsx)(B,{htmlFor:`new-password`,children:e(`auth.resetPassword.newPassword`,{defaultValue:`New password`})}),(0,J.jsx)(F,{id:`new-password`,type:`password`,autoComplete:`new-password`,required:!0,minLength:8,value:s,onChange:e=>l(e.target.value)})]}),(0,J.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,J.jsx)(B,{htmlFor:`confirm-password`,children:e(`auth.resetPassword.confirmPassword`,{defaultValue:`Confirm password`})}),(0,J.jsx)(F,{id:`confirm-password`,type:`password`,autoComplete:`new-password`,required:!0,minLength:8,value:u,onChange:e=>d(e.target.value)})]}),(0,J.jsx)(k,{type:`submit`,className:`w-full`,disabled:f,children:f?e(`auth.resetPassword.submitting`,{defaultValue:`Updating…`}):e(`auth.resetPassword.submit`,{defaultValue:`Update password`})})]}):(0,J.jsxs)(`p`,{className:`text-center text-sm text-muted-foreground`,children:[e(`auth.resetPassword.invalidToken`,{defaultValue:`This reset link is invalid or has expired.`}),` `,(0,J.jsx)(r,{to:`/forgot-password`,className:`font-medium text-primary underline-offset-4 hover:underline`,children:e(`auth.resetPassword.requestNewLink`,{defaultValue:`Request a new link`})})]})})]})})}function dr(e){return e&&e.startsWith(`/`)&&!e.startsWith(`//`)?e:`/`}function fr(){let{t:e}=A(),t=o(),[n]=c(),i=dr(n.get(`next`)),{user:a,isLoading:s,setInitialPassword:l}=C(),[u,d]=(0,q.useState)(``),[f,p]=(0,q.useState)(``),[m,h]=(0,q.useState)(!1);return(0,J.jsx)(X,{children:(0,J.jsxs)(I,{className:`border-border/60 shadow-sm shadow-primary/5 backdrop-blur supports-[backdrop-filter]:bg-card/95`,children:[(0,J.jsxs)(P,{className:`text-center`,children:[(0,J.jsx)(z,{className:`text-xl tracking-tight`,children:e(`auth.setPassword.title`,{defaultValue:`Set a recovery password`})}),(0,J.jsx)(j,{children:e(`auth.setPassword.description`,{defaultValue:`You signed in via single sign-on. Set a local password so you can still sign in to this environment directly if SSO ever becomes unavailable.`})})]}),(0,J.jsx)(R,{children:!s&&!a?(0,J.jsxs)(`p`,{className:`text-center text-sm text-muted-foreground`,children:[e(`auth.setPassword.noSession`,{defaultValue:`Your session has expired.`}),` `,(0,J.jsx)(r,{to:`/login`,className:`font-medium text-primary underline-offset-4 hover:underline`,children:e(`auth.setPassword.backToSignIn`,{defaultValue:`Sign in again`})})]}):(0,J.jsxs)(`form`,{onSubmit:async n=>{if(n.preventDefault(),u!==f){H.error(e(`auth.setPassword.passwordsMismatch`,{defaultValue:`Passwords do not match`}));return}h(!0);try{await l(u),H.success(e(`auth.setPassword.success`,{defaultValue:`Local password set`})),t(i)}catch(t){H.error(e(`auth.setPassword.failed`,{defaultValue:`Could not set password`}),{description:t.message})}finally{h(!1)}},className:`flex flex-col gap-4`,children:[a?.email?(0,J.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,J.jsx)(B,{htmlFor:`set-password-email`,children:e(`auth.setPassword.email`,{defaultValue:`Email`})}),(0,J.jsx)(F,{id:`set-password-email`,type:`email`,autoComplete:`username`,value:a.email,disabled:!0,className:`bg-muted text-muted-foreground`})]}):null,(0,J.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,J.jsx)(B,{htmlFor:`new-password`,children:e(`auth.setPassword.newPassword`,{defaultValue:`New password`})}),(0,J.jsx)(F,{id:`new-password`,type:`password`,autoComplete:`new-password`,required:!0,minLength:8,value:u,onChange:e=>d(e.target.value)})]}),(0,J.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,J.jsx)(B,{htmlFor:`confirm-password`,children:e(`auth.setPassword.confirmPassword`,{defaultValue:`Confirm password`})}),(0,J.jsx)(F,{id:`confirm-password`,type:`password`,autoComplete:`new-password`,required:!0,minLength:8,value:f,onChange:e=>p(e.target.value)})]}),(0,J.jsx)(k,{type:`submit`,className:`w-full`,disabled:m,children:m?e(`auth.setPassword.submitting`,{defaultValue:`Saving…`}):e(`auth.setPassword.submit`,{defaultValue:`Set password`})})]})})]})})}var pr=`/api/v1/auth`;function mr(){let{t:e}=A(),[t]=c(),n=t.get(`token`),[i,a]=(0,q.useState)(`loading`),[o,s]=(0,q.useState)(``);return(0,q.useEffect)(()=>{if(!n){a(`error`),s(e(`auth.verifyEmail.missingToken`,{defaultValue:`Verification link is missing a token.`}));return}let t=!1;return(async()=>{try{let e=await fetch(`${pr}/verify-email`,{method:`POST`,headers:{"Content-Type":`application/json`},credentials:`include`,body:JSON.stringify({token:n})});if(!e.ok){let t=await e.json().catch(()=>({}));throw Error(t?.message||`Verification failed: ${e.status}`)}t||a(`success`)}catch(n){t||(a(`error`),s(n.message||e(`auth.verifyEmail.errorDescription`,{defaultValue:`Verification failed. Please request a new link.`})))}})(),()=>{t=!0}},[n,e]),(0,J.jsx)(X,{children:(0,J.jsxs)(I,{className:`border-border/60 shadow-sm shadow-primary/5 backdrop-blur supports-[backdrop-filter]:bg-card/95`,children:[i===`loading`&&(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(P,{className:`text-center`,children:[(0,J.jsx)(z,{className:`text-xl tracking-tight`,children:e(`auth.verifyEmail.verifyingTitle`,{defaultValue:`Verifying…`})}),(0,J.jsx)(j,{children:e(`auth.verifyEmail.verifyingDescription`,{defaultValue:`Hang tight while we confirm your email.`})})]}),(0,J.jsx)(R,{className:`flex justify-center py-6`,children:(0,J.jsx)(`div`,{className:`h-10 w-10 animate-spin rounded-full border-4 border-muted border-t-primary`})})]}),i===`success`&&(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(P,{className:`text-center`,children:[(0,J.jsx)(`div`,{className:`mx-auto mb-2 flex size-12 items-center justify-center rounded-full bg-emerald-500/10 text-emerald-500 ring-1 ring-emerald-500/30`,children:(0,J.jsx)(oe,{className:`size-6`})}),(0,J.jsx)(z,{className:`text-xl tracking-tight`,children:e(`auth.verifyEmail.successTitle`,{defaultValue:`Email verified`})}),(0,J.jsx)(j,{children:e(`auth.verifyEmail.successDescription`,{defaultValue:`Your email is confirmed. You can now sign in.`})})]}),(0,J.jsx)(R,{className:`text-center`,children:(0,J.jsx)(r,{to:`/login`,className:`text-sm font-medium text-primary underline-offset-4 hover:underline`,children:e(`auth.verifyEmail.signInLink`,{defaultValue:`Go to sign in`})})})]}),i===`error`&&(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(P,{className:`text-center`,children:[(0,J.jsx)(`div`,{className:`mx-auto mb-2 flex size-12 items-center justify-center rounded-full bg-destructive/10 text-destructive ring-1 ring-destructive/30`,children:(0,J.jsx)(re,{className:`size-6`})}),(0,J.jsx)(z,{className:`text-xl tracking-tight`,children:e(`auth.verifyEmail.errorTitle`,{defaultValue:`Verification failed`})}),(0,J.jsx)(j,{children:o||e(`auth.verifyEmail.errorDescription`,{defaultValue:`Verification failed. Please request a new link.`})})]}),(0,J.jsx)(R,{className:`text-center`,children:(0,J.jsx)(r,{to:`/login`,className:`text-sm font-medium text-primary underline-offset-4 hover:underline`,children:e(`auth.verifyEmail.backToSignIn`,{defaultValue:`Back to sign in`})})})]})]})})}function hr(){let{t:e}=A(),t=o(),[n]=c(),r=n.get(`email`)??``,i=n.get(`redirect`)??``,{sendVerificationEmail:a}=C(),[s,l]=(0,q.useState)(!1),[u,d]=(0,q.useState)(!1),[f,p]=(0,q.useState)(null);return(0,J.jsx)(X,{children:(0,J.jsxs)(I,{className:`border-border/60 shadow-sm shadow-primary/5 backdrop-blur supports-[backdrop-filter]:bg-card/95`,children:[(0,J.jsxs)(P,{className:`text-center`,children:[(0,J.jsx)(`div`,{className:`mx-auto mb-4 flex size-16 items-center justify-center rounded-full bg-primary/10`,children:(0,J.jsx)(ge,{className:`size-8 text-primary`})}),(0,J.jsx)(z,{className:`text-xl tracking-tight`,children:e(`auth.verifyEmail.title`,{defaultValue:`Verify your email address`})}),(0,J.jsx)(j,{children:e(`auth.verifyEmail.description`,{defaultValue:`We sent a verification link to your email address. Please click the link to verify your account.`})})]}),(0,J.jsx)(R,{children:(0,J.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[r?(0,J.jsxs)(`p`,{className:`text-center text-sm text-muted-foreground`,children:[e(`auth.verifyEmail.sentTo`,{defaultValue:`Sent to:`}),` `,(0,J.jsx)(`span`,{className:`font-medium text-foreground`,children:r})]}):null,f?(0,J.jsxs)(`div`,{role:`alert`,className:`rounded-md border border-destructive/40 bg-destructive/10 px-3 py-2 text-sm text-destructive`,children:[(0,J.jsx)(`p`,{className:`font-medium`,children:e(`auth.verifyEmail.resendFailed`,{defaultValue:`Failed to resend verification email`})}),(0,J.jsx)(`p`,{className:`mt-1 text-destructive/90`,children:f})]}):null,(0,J.jsx)(k,{onClick:async()=>{if(!r){H.error(e(`auth.verifyEmail.resendFailed`,{defaultValue:`Cannot resend verification email`}),{description:e(`auth.verifyEmail.emailMissing`,{defaultValue:`Email address is missing`})});return}l(!0),p(null);try{await a(r,i||`/`),d(!0),H.success(e(`auth.verifyEmail.resentSuccess`,{defaultValue:`Verification email sent!`}),{description:e(`auth.verifyEmail.resentDescription`,{defaultValue:`Please check your inbox and click the verification link.`})})}catch(t){let n=t?.message?.trim()||e(`auth.verifyEmail.resendUnavailable`,{defaultValue:`Email delivery may not be configured for this environment. Contact support if this persists.`});d(!1),p(n),H.error(e(`auth.verifyEmail.resendFailed`,{defaultValue:`Failed to resend verification email`}),{description:n})}finally{l(!1)}},disabled:s||u,className:`w-full`,variant:u?`outline`:`default`,children:s?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(_e,{className:`mr-2 size-4 animate-spin`}),e(`auth.verifyEmail.resending`,{defaultValue:`Sending…`})]}):u?e(`auth.verifyEmail.resent`,{defaultValue:`Email sent! Check your inbox`}):(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(_e,{className:`mr-2 size-4`}),e(`auth.verifyEmail.resendButton`,{defaultValue:`Resend verification email`})]})}),(0,J.jsxs)(`div`,{className:`relative`,children:[(0,J.jsx)(`div`,{className:`absolute inset-0 flex items-center`,children:(0,J.jsx)(`span`,{className:`w-full border-t`})}),(0,J.jsx)(`div`,{className:`relative flex justify-center text-xs uppercase`,children:(0,J.jsx)(`span`,{className:`bg-card px-2 text-muted-foreground`,children:e(`auth.verifyEmail.or`,{defaultValue:`Or`})})})]}),(0,J.jsx)(k,{onClick:()=>{let e=i?`?redirect=${encodeURIComponent(i)}`:``;t(`/login${e}`)},variant:`ghost`,className:`w-full`,children:e(`auth.verifyEmail.backToLogin`,{defaultValue:`Back to login`})}),(0,J.jsx)(`p`,{className:`text-center text-xs text-muted-foreground`,children:e(`auth.verifyEmail.checkSpam`,{defaultValue:`Didn't receive the email? Check your spam folder or contact support.`})})]})})]})})}var gr=`/api/v1/auth`;function _r(e){return e.toLowerCase().replace(/[^a-z0-9]+/g,`-`).replace(/^-+|-+$/g,``)}function vr(){let{t:e}=A(),t=o(),{user:n,signUp:r,refreshOrganizations:i,updateOrganization:a,createOrganization:s,switchOrganization:c}=C(),[l,u]=(0,q.useState)(``),[d,f]=(0,q.useState)(``),[p,m]=(0,q.useState)(``),[h,g]=(0,q.useState)(``),[_,v]=(0,q.useState)(!1),[y,b]=(0,q.useState)(null);return(0,q.useEffect)(()=>{let e=!1;return(async()=>{try{let t=await fetch(`${gr}/bootstrap-status`,{credentials:`include`}),n=t.ok?await t.json().catch(()=>({})):{};e||b(n.hasOwner===!0)}catch{e||b(!1)}})(),()=>{e=!0}},[]),(0,q.useEffect)(()=>{y===!0&&!n&&t(`/login`,{replace:!0})},[y,n,t]),(0,q.useEffect)(()=>{n&&!_&&window.location.assign(`/`)},[n,_]),y===null?(0,J.jsx)(`div`,{className:`flex min-h-svh w-full items-center justify-center bg-muted`,children:(0,J.jsx)(`div`,{className:`h-8 w-8 animate-spin rounded-full border-4 border-muted-foreground/20 border-t-primary`})}):(0,J.jsx)(`div`,{className:`flex min-h-svh w-full items-center justify-center bg-muted p-6`,children:(0,J.jsx)(`div`,{className:`flex w-full max-w-md flex-col gap-6`,children:(0,J.jsxs)(I,{children:[(0,J.jsxs)(P,{className:`text-center`,children:[(0,J.jsx)(z,{children:e(`auth.setup.welcomeTitle`,{defaultValue:`Welcome to ObjectStack`})}),(0,J.jsx)(j,{children:e(`auth.setup.description`,{defaultValue:`Create the first owner account to finish setting up this deployment.`})})]}),(0,J.jsx)(R,{children:(0,J.jsxs)(`form`,{onSubmit:async t=>{t.preventDefault(),v(!0);try{await r(l,d,p);let e=h.trim();if(e)try{let t;for(let e=0;e<4&&!t?.id;e++)e>0&&await new Promise(e=>setTimeout(e,500)),t=(await i())?.[0];let n=_r(e),r;t?.id?(await a(t.id,{name:e,...n?{slug:n}:{}}),r=t.id):r=(await s({name:e,slug:n||`org-${Date.now().toString(36)}`}))?.id,r&&await c(r).catch(()=>void 0)}catch(e){console.warn(`[setup] organization rename/create failed`,e)}window.location.assign(`/`)}catch(t){H.error(e(`auth.setup.failed`,{defaultValue:`Setup failed`}),{description:t.message})}finally{v(!1)}},className:`flex flex-col gap-4`,children:[(0,J.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,J.jsx)(B,{htmlFor:`name`,children:e(`auth.setup.yourName`,{defaultValue:`Your name`})}),(0,J.jsx)(F,{id:`name`,autoComplete:`name`,required:!0,value:l,onChange:e=>u(e.target.value)})]}),(0,J.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,J.jsx)(B,{htmlFor:`orgName`,children:e(`auth.setup.orgName`,{defaultValue:`Organization name`})}),(0,J.jsx)(F,{id:`orgName`,required:!0,placeholder:e(`auth.setup.orgNamePlaceholder`,{defaultValue:`Acme Inc.`}),value:h,onChange:e=>g(e.target.value)})]}),(0,J.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,J.jsx)(B,{htmlFor:`email`,children:e(`auth.setup.emailLabel`,{defaultValue:`Email`})}),(0,J.jsx)(F,{id:`email`,type:`email`,placeholder:e(`auth.setup.emailPlaceholder`,{defaultValue:`name@example.com`}),autoComplete:`email`,required:!0,value:d,onChange:e=>f(e.target.value)})]}),(0,J.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,J.jsx)(B,{htmlFor:`password`,children:e(`auth.setup.passwordLabel`,{defaultValue:`Password`})}),(0,J.jsx)(F,{id:`password`,type:`password`,autoComplete:`new-password`,required:!0,minLength:8,placeholder:e(`auth.setup.passwordHint`,{defaultValue:`Minimum 8 characters`}),value:p,onChange:e=>m(e.target.value)})]}),(0,J.jsx)(k,{type:`submit`,className:`mt-2 w-full`,disabled:_,children:_?e(`auth.setup.submitting`,{defaultValue:`Setting up…`}):e(`auth.setup.submit`,{defaultValue:`Create owner account`})})]})})]})})})}var yr=`/api/v1/auth`;function br(){let{t:e}=A(),t=o(),{user:n,isLoading:r}=C(),[i,a]=(0,q.useState)(!1),[s,c]=(0,q.useState)(null),l=typeof window<`u`?window.location.search:``,u=l.startsWith(`?`)?l.slice(1):l,d=new URLSearchParams(u),f=d.get(`client_id`)??void 0,p=d.get(`scope`)??``;(0,q.useEffect)(()=>{if(!r&&!n){let e=window.location.pathname+window.location.search;t(`/login?redirect=${encodeURIComponent(e)}`,{replace:!0})}},[n,r,t]),(0,q.useEffect)(()=>{if(!f)return;let e=!1;return fetch(`${yr}/oauth2/applications/${encodeURIComponent(f)}/public`,{credentials:`include`}).then(async t=>{if(!t.ok)return;let n=await t.json().catch(()=>({}));if(e)return;let r=n?.data??n;c(r)}).catch(()=>{}),()=>{e=!0}},[f]);let m=p.split(/\s+/).filter(Boolean),h=async t=>{a(!0);try{let n=await fetch(`${yr}/oauth2/consent`,{method:`POST`,headers:{"Content-Type":`application/json`},credentials:`include`,body:JSON.stringify({accept:t,oauth_query:u})}),r=await n.json().catch(()=>({}));if(!n.ok)throw Error(r?.message||`Consent failed: ${n.status}`);let i=r.redirect_uri??r.redirectURI??r.url;if(i){window.location.href=i;return}H(t?e(`oauth.consent.granted`,{defaultValue:`Access granted`}):e(`oauth.consent.denied`,{defaultValue:`Access denied`}),{description:e(`oauth.consent.noRedirect`,{defaultValue:`No redirect URL returned by the server.`})})}catch(t){H.error(e(`oauth.consent.failed`,{defaultValue:`Consent failed`}),{description:t.message})}finally{a(!1)}},g=s?.name??s?.client_name??f??e(`oauth.consent.unknownApp`,{defaultValue:`an application`});return(0,J.jsx)(`div`,{className:`flex min-h-svh w-full flex-1 items-center justify-center bg-background px-4`,children:(0,J.jsxs)(I,{className:`w-full max-w-md`,children:[(0,J.jsxs)(P,{className:`items-center text-center`,children:[(0,J.jsx)(`div`,{className:`mb-3 rounded-full border bg-muted p-3`,children:s?.icon||s?.logo_uri?(0,J.jsx)(`img`,{src:s.icon||s.logo_uri,alt:``,className:`h-8 w-8 rounded`,onError:e=>{e.currentTarget.style.display=`none`}}):(0,J.jsx)(Ce,{className:`h-7 w-7 text-muted-foreground`})}),(0,J.jsx)(z,{className:`text-xl`,children:e(`oauth.consent.title`,{appName:g,defaultValue:`${g} wants to access your account`})}),(0,J.jsx)(j,{children:e(`oauth.consent.request`,{appName:g,suffix:n?.email?` (${n.email})`:``,defaultValue:`${g} is requesting permission${n?.email?` for ${n.email}`:``}.`})})]}),(0,J.jsxs)(R,{className:`space-y-4`,children:[m.length>0&&(0,J.jsxs)(`div`,{children:[(0,J.jsx)(`p`,{className:`mb-2 text-sm font-medium`,children:e(`oauth.consent.willAllow`,{defaultValue:`This app will be able to:`})}),(0,J.jsx)(`ul`,{className:`space-y-1.5 rounded-md border bg-muted/40 p-3 text-sm`,children:m.map(t=>(0,J.jsxs)(`li`,{className:`flex items-start gap-2`,children:[(0,J.jsx)(ke,{className:`mt-0.5 h-4 w-4 text-green-600 dark:text-green-400`}),(0,J.jsx)(`span`,{children:xr(t,e)})]},t))})]}),(0,J.jsxs)(`div`,{className:`grid grid-cols-2 gap-2 pt-2`,children:[(0,J.jsxs)(k,{variant:`outline`,onClick:()=>h(!1),disabled:i,children:[(0,J.jsx)(ae,{className:`mr-2 h-4 w-4`}),e(`oauth.consent.deny`,{defaultValue:`Deny`})]}),(0,J.jsxs)(k,{onClick:()=>h(!0),disabled:i,children:[(0,J.jsx)(ke,{className:`mr-2 h-4 w-4`}),i?e(`oauth.consent.submitting`,{defaultValue:`Authorizing…`}):e(`oauth.consent.authorize`,{defaultValue:`Authorize`})]})]}),(0,J.jsx)(`p`,{className:`pt-2 text-center text-xs text-muted-foreground`,children:e(`oauth.consent.footer`,{defaultValue:`You can revoke access at any time from your account settings.`})})]})]})})}function xr(e,t){switch(e){case`openid`:return t(`oauth.consent.scope.openid`,{defaultValue:`Confirm your identity`});case`profile`:return t(`oauth.consent.scope.profile`,{defaultValue:`Read your basic profile (name, picture)`});case`email`:return t(`oauth.consent.scope.email`,{defaultValue:`Read your email address`});case`offline_access`:return t(`oauth.consent.scope.offlineAccess`,{defaultValue:`Stay signed in (refresh access)`});default:return e}}var Sr=`/api/v1/auth`;function Z({children:e}){return(0,J.jsx)(`div`,{className:`flex min-h-svh w-full flex-col items-center justify-center gap-6 bg-muted p-6 md:p-10`,children:(0,J.jsxs)(`div`,{className:`flex w-full max-w-sm flex-col gap-6`,children:[(0,J.jsxs)(`a`,{href:`#`,className:`flex items-center gap-2 self-center font-medium`,children:[(0,J.jsx)(`div`,{className:`flex size-6 items-center justify-center rounded-md bg-primary text-primary-foreground overflow-hidden`,children:ht()?(0,J.jsx)(`img`,{src:ht(),alt:W(),className:`h-full w-full object-contain`}):(0,J.jsx)(oe,{className:`size-4`})}),W()]}),(0,J.jsx)(`div`,{className:`flex flex-col gap-6`,children:e})]})})}function Cr(){let{t:e}=A(),t=a(),[n]=c(),r=n.get(`user_code`)??n.get(`code`)??``,i=n.get(`runtime_name`)??``,s=n.get(`runtime_version`)??``,{user:l,isLoading:u,getAuthConfig:d}=C(),f=o(),[m,h]=(0,q.useState)(!1),[g,_]=(0,q.useState)(!1),[v,y]=(0,q.useState)(!1),[b,x]=(0,q.useState)(!1),[S,w]=(0,q.useState)(``),[T,ee]=(0,q.useState)(null);if((0,q.useEffect)(()=>{let e=!0;return d().then(t=>{e&&ee(t?.features?.deviceAuthorization===!0)}).catch(()=>{e&&ee(!0)}),()=>{e=!1}},[d]),!r)return(0,J.jsx)(Z,{children:(0,J.jsx)(I,{children:(0,J.jsxs)(P,{className:`text-center`,children:[(0,J.jsx)(z,{children:e(`auth.device.invalidTitle`,{defaultValue:`Invalid device link`})}),(0,J.jsx)(j,{children:e(`auth.device.invalidDescription`,{defaultValue:`No device code was provided in the URL.`})})]})})});if(T===!1)return(0,J.jsx)(Z,{children:(0,J.jsx)(I,{children:(0,J.jsxs)(P,{className:`text-center`,children:[(0,J.jsx)(z,{children:e(`auth.device.disabledTitle`,{defaultValue:`Device authorization not enabled`})}),(0,J.jsx)(j,{children:e(`auth.device.disabledDescription`,{defaultValue:`This deployment does not have device authorization enabled, so this device cannot be approved here.`})})]})})});if(u||T===null)return(0,J.jsx)(Z,{children:(0,J.jsx)(I,{children:(0,J.jsx)(P,{className:`text-center`,children:(0,J.jsx)(j,{children:e(`auth.device.loading`,{defaultValue:`Loading…`})})})})});if(!l)return(0,J.jsx)(p,{to:`/login?redirect=${encodeURIComponent(`/auth/device${t.search}`)}`,replace:!0});if(v)return(0,J.jsx)(Z,{children:(0,J.jsx)(I,{children:(0,J.jsxs)(P,{className:`text-center`,children:[(0,J.jsx)(oe,{className:`mx-auto mb-2 h-10 w-10 text-green-500`}),(0,J.jsx)(z,{children:e(`auth.device.approvedTitle`,{defaultValue:`Device authorized`})}),(0,J.jsx)(j,{children:e(`auth.device.approvedDescription`,{defaultValue:`You can return to the device — it should sign in shortly.`})})]})})});if(b)return(0,J.jsx)(Z,{children:(0,J.jsx)(I,{children:(0,J.jsxs)(P,{className:`text-center`,children:[(0,J.jsx)(z,{children:e(`auth.device.deniedTitle`,{defaultValue:`Access denied`})}),(0,J.jsx)(j,{children:e(`auth.device.deniedDescription`,{defaultValue:`The device will not be granted access.`})})]})})});let E=async()=>{await fetch(`${Sr}/device?user_code=${encodeURIComponent(r)}`,{credentials:`include`}).catch(()=>{})};return(0,J.jsx)(Z,{children:(0,J.jsxs)(I,{children:[(0,J.jsxs)(P,{className:`text-center`,children:[(0,J.jsx)(z,{children:e(`auth.device.title`,{defaultValue:`Authorize new device`})}),(0,J.jsx)(j,{children:e(`auth.device.subtitle`,{email:l.email,defaultValue:`Approve this device to sign in as ${l.email}.`})})]}),(0,J.jsxs)(R,{className:`space-y-4`,children:[i?(0,J.jsxs)(`div`,{className:`rounded-md border bg-background px-4 py-3 text-center`,children:[(0,J.jsx)(`p`,{className:`mb-1 text-xs text-muted-foreground`,children:e(`auth.device.requesterLabel`,{defaultValue:`Connection request from`})}),(0,J.jsx)(`p`,{className:`font-medium`,children:i}),s?(0,J.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[W().toLowerCase(),` `,s]}):null]}):null,(0,J.jsxs)(`div`,{className:`rounded-md border bg-background px-4 py-3 text-center`,children:[(0,J.jsx)(`p`,{className:`mb-1 text-xs text-muted-foreground`,children:e(`auth.device.userCodeLabel`,{defaultValue:`Device code`})}),(0,J.jsx)(`p`,{className:`font-mono text-lg font-semibold tracking-widest`,children:r})]}),(0,J.jsx)(`p`,{className:`text-center text-xs text-muted-foreground`,children:e(`auth.device.approveWarning`,{defaultValue:`Only approve if you started this connection yourself a moment ago. Once approved, this runtime can access your organization's private packages.`})}),(0,J.jsxs)(`div`,{className:`space-y-4`,children:[(0,J.jsx)(`p`,{className:`text-center text-sm text-muted-foreground`,children:e(`auth.device.loggedInAs`,{email:l.email,defaultValue:`Signed in as ${l.email}`})}),S&&(0,J.jsx)(`p`,{className:`text-center text-sm text-destructive`,children:S}),(0,J.jsx)(k,{onClick:async()=>{w(``),h(!0);try{await E();let t=await fetch(`${Sr}/device/approve`,{method:`POST`,headers:{"Content-Type":`application/json`},credentials:`include`,body:JSON.stringify({userCode:r})});if(!t.ok){let n=await t.json().catch(()=>({}));throw Error(n?.message??n?.error?.message??e(`auth.device.approveFailed`,{defaultValue:`Approval failed`}))}y(!0),H.success(e(`auth.device.approveSuccess`,{defaultValue:`Device authorized`}),{description:e(`auth.device.approveSuccessDescription`,{defaultValue:`You can close this window.`})})}catch(t){w(t?.message??e(`auth.device.approveFailed`,{defaultValue:`Approval failed`}))}finally{h(!1)}},className:`w-full`,disabled:m||g,children:m?e(`auth.device.approving`,{defaultValue:`Approving…`}):e(`auth.device.approve`,{defaultValue:`Approve device`})}),(0,J.jsx)(k,{onClick:async()=>{w(``),_(!0);try{await E(),await fetch(`${Sr}/device/deny`,{method:`POST`,headers:{"Content-Type":`application/json`},credentials:`include`,body:JSON.stringify({userCode:r})}),x(!0)}catch(t){w(t?.message??e(`auth.device.denyFailed`,{defaultValue:`Failed to deny request`}))}finally{_(!1)}},variant:`outline`,className:`w-full`,disabled:m||g,children:g?e(`auth.device.denying`,{defaultValue:`Denying…`}):e(`auth.device.deny`,{defaultValue:`Deny request`})}),(0,J.jsx)(`div`,{className:`text-center`,children:(0,J.jsx)(`button`,{type:`button`,className:`text-sm text-muted-foreground underline-offset-4 hover:underline`,onClick:()=>f(`/`),children:e(`auth.device.cancel`,{defaultValue:`Cancel`})})})]})]})]})})}function wr(){let{t:e}=A(),{invitationId:t}=d(),n=o(),{user:r,isLoading:i,acceptInvitation:a,rejectInvitation:s,refreshOrganizations:c}=C(),[l,u]=(0,q.useState)(!1),[f,p]=(0,q.useState)(!1);return(0,q.useEffect)(()=>{if(!i&&!r&&t){let e=`/accept-invitation/${t}`;n(`/login?redirect=${encodeURIComponent(e)}`,{replace:!0})}},[i,r,t,n]),t?(0,J.jsx)(`div`,{className:`flex min-h-svh w-full flex-col items-center justify-center gap-6 bg-muted p-6 md:p-10`,children:(0,J.jsx)(`div`,{className:`flex w-full max-w-sm flex-col gap-6`,children:(0,J.jsxs)(I,{children:[(0,J.jsxs)(P,{className:`text-center`,children:[(0,J.jsx)(z,{className:`text-xl`,children:e(`acceptInvitation.title`,{defaultValue:`Accept organization invitation`})}),(0,J.jsx)(j,{children:e(`acceptInvitation.description`,{defaultValue:`You've been invited to join an organization.`})})]}),(0,J.jsxs)(R,{className:`flex flex-col gap-3`,children:[(0,J.jsx)(k,{className:`w-full`,onClick:async()=>{u(!0);try{await a(t),await c().catch(()=>void 0),H.success(e(`acceptInvitation.accepted`,{defaultValue:`Invitation accepted`})),n(`/organizations`)}catch(t){H.error(e(`acceptInvitation.acceptFailed`,{defaultValue:`Could not accept`}),{description:t.message})}finally{u(!1)}},disabled:l||f,children:l?e(`acceptInvitation.accepting`,{defaultValue:`Accepting…`}):e(`acceptInvitation.accept`,{defaultValue:`Accept invitation`})}),(0,J.jsx)(k,{variant:`outline`,className:`w-full`,onClick:async()=>{p(!0);try{await s(t),H.success(e(`acceptInvitation.declined`,{defaultValue:`Invitation declined`})),n(`/organizations`)}catch(t){H.error(e(`acceptInvitation.declineFailed`,{defaultValue:`Could not decline`}),{description:t.message})}finally{p(!1)}},disabled:l||f,children:f?e(`acceptInvitation.declining`,{defaultValue:`Declining…`}):e(`acceptInvitation.decline`,{defaultValue:`Decline`})})]})]})})}):(0,J.jsx)(`div`,{className:`flex min-h-svh w-full flex-col items-center justify-center bg-muted p-6`,children:(0,J.jsx)(I,{className:`w-full max-w-sm`,children:(0,J.jsxs)(P,{className:`text-center`,children:[(0,J.jsx)(z,{className:`text-xl`,children:e(`acceptInvitation.invalidTitle`,{defaultValue:`Invalid invitation link`})}),(0,J.jsx)(j,{children:e(`acceptInvitation.invalidDescription`,{defaultValue:`The invitation id is missing from the URL.`})})]})})})}var Tr=`/api/v1/auth`;function Er(){try{if(typeof document>`u`)return`/`;let e=document.querySelector(`base`)?.getAttribute(`href`);return e&&new URL(e,window.location.origin).pathname.replace(/\/$/,``)||`/`}catch{return`/`}}var Dr=Er();function Or(){let e=a(),t=e.pathname+e.search;return(0,J.jsx)(p,{to:`/login${t&&t!==`/`?`?redirect=${encodeURIComponent(t)}`:``}`,replace:!0})}function Q({children:e,requireOrganization:t=!0}){return(0,J.jsx)(v,{fallback:(0,J.jsx)(Or,{}),loadingFallback:(0,J.jsx)(Re,{}),children:(0,J.jsx)(ot,{children:t?(0,J.jsx)(Ve,{children:e}):e})})}function kr(){let{user:e}=C();return(0,J.jsx)(Ke,{userId:e?.id,children:(0,J.jsx)(rt,{})})}function Ar(){return(0,q.useEffect)(()=>{document.title=W();let e=pt();if(e){let t=document.getElementById(`favicon`);t&&(t.href=e,t.type=e.endsWith(`.svg`)?`image/svg+xml`:`image/png`)}},[a()]),null}function jr(){return(0,J.jsxs)(S,{authUrl:Tr,children:[(0,J.jsx)(Ye,{position:`bottom-right`}),(0,J.jsx)(An,{}),(0,J.jsxs)(l,{basename:Dr,children:[(0,J.jsx)(Ar,{}),(0,J.jsx)(Be,{children:(0,J.jsxs)(m,{children:[(0,J.jsx)(u,{path:`/login`,element:(0,J.jsx)(nr,{})}),(0,J.jsx)(u,{path:`/register`,element:(0,J.jsx)(sr,{})}),(0,J.jsx)(u,{path:`/forgot-password`,element:(0,J.jsx)(lr,{})}),(0,J.jsx)(u,{path:`/reset-password`,element:(0,J.jsx)(ur,{})}),(0,J.jsx)(u,{path:`/set-password`,element:(0,J.jsx)(fr,{})}),(0,J.jsx)(u,{path:`/verify-email`,element:(0,J.jsx)(mr,{})}),(0,J.jsx)(u,{path:`/verify-email-prompt`,element:(0,J.jsx)(hr,{})}),(0,J.jsx)(u,{path:`/setup`,element:(0,J.jsx)(vr,{})}),(0,J.jsx)(u,{path:`/oauth/consent`,element:(0,J.jsx)(br,{})}),(0,J.jsx)(u,{path:`/auth/device`,element:(0,J.jsx)(Cr,{})}),(0,J.jsx)(u,{path:`/accept-invitation/:invitationId`,element:(0,J.jsx)(wr,{})}),(0,J.jsx)(u,{path:`/f/:slug`,element:(0,J.jsx)(kn,{mode:`public`})}),(0,J.jsx)(u,{path:`/s/:token`,element:(0,J.jsx)(Mn,{})}),(0,J.jsx)(u,{path:`/studio`,element:(0,J.jsx)(Q,{children:(0,J.jsxs)(`div`,{className:`flex min-h-screen flex-col bg-background text-foreground`,children:[(0,J.jsx)(`header`,{className:`flex shrink-0 items-center border-b px-3 py-2`,children:(0,J.jsx)(r,{to:`/home`,title:`返回主页`,className:`inline-flex items-center gap-1.5 rounded-md px-1.5 py-0.5 text-[13px] font-semibold hover:bg-muted`,children:W()})}),(0,J.jsx)(`div`,{className:`min-h-0 flex-1 overflow-auto`,children:(0,J.jsx)($e,{})})]})})}),(0,J.jsx)(u,{path:`/studio/:packageId`,element:(0,J.jsx)(p,{to:`data`,replace:!0})}),(0,J.jsx)(u,{path:`/studio/:packageId/:tab`,element:(0,J.jsx)(Q,{children:(0,J.jsx)(tt,{})})}),(0,J.jsx)(u,{path:`/forms/:name`,element:(0,J.jsx)(Q,{children:(0,J.jsx)(kn,{mode:`internal`})})}),(0,J.jsxs)(u,{path:`/docs`,element:(0,J.jsx)(Q,{children:(0,J.jsx)(Kn,{})}),children:[(0,J.jsx)(u,{index:!0,element:(0,J.jsx)(Vn,{})}),(0,J.jsx)(u,{path:`:slug`,element:(0,J.jsx)(Wn,{})}),(0,J.jsx)(u,{path:`:slug/:name`,element:(0,J.jsx)(Bn,{})})]}),(0,J.jsx)(u,{path:`/home`,element:(0,J.jsx)(Q,{children:(0,J.jsx)(kr,{})})}),(0,J.jsx)(u,{path:`/dev/master-detail`,element:(0,J.jsx)(Q,{children:(0,J.jsx)(Nt,{})})}),(0,J.jsx)(u,{path:`/dev/lists`,element:(0,J.jsx)(Q,{children:(0,J.jsx)(It,{})})}),(0,J.jsx)(u,{path:`/dev/modal`,element:(0,J.jsx)(Q,{children:(0,J.jsx)(Rt,{})})}),(0,J.jsx)(u,{path:`/dev/lookup`,element:(0,J.jsx)(Q,{children:(0,J.jsx)(zt,{})})}),(0,J.jsx)(u,{path:`/dev/row-actions`,element:(0,J.jsx)(Q,{children:(0,J.jsx)(Wt,{})})}),(0,J.jsx)(u,{path:`/organizations`,element:(0,J.jsx)(Q,{requireOrganization:!1,children:(0,J.jsx)(Ze,{children:(0,J.jsx)(Ge,{})})})}),(0,J.jsxs)(u,{path:`/organizations/:slug`,element:(0,J.jsx)(Q,{requireOrganization:!1,children:(0,J.jsx)(nt,{})}),children:[(0,J.jsx)(u,{index:!0,element:(0,J.jsx)(p,{to:`members`,replace:!0})}),(0,J.jsx)(u,{path:`members`,element:(0,J.jsx)(et,{})}),(0,J.jsx)(u,{path:`invitations`,element:(0,J.jsx)(Ue,{})}),(0,J.jsx)(u,{path:`settings`,element:(0,J.jsx)(Xe,{})})]}),(0,J.jsx)(u,{path:`/system/*`,element:(0,J.jsx)(ze,{})}),(0,J.jsx)(u,{path:`/ai`,element:(0,J.jsx)(Q,{children:(0,J.jsx)(at,{children:(0,J.jsx)(He,{})})})}),(0,J.jsx)(u,{path:`/ai/:agent`,element:(0,J.jsx)(Q,{children:(0,J.jsx)(at,{children:(0,J.jsx)(He,{})})})}),(0,J.jsx)(u,{path:`/ai/:agent/:conversationId`,element:(0,J.jsx)(Q,{children:(0,J.jsx)(at,{children:(0,J.jsx)(He,{})})})}),(0,J.jsx)(u,{path:`/apps/:appName/*`,element:(0,J.jsx)(Q,{children:(0,J.jsx)(pn,{})})}),(0,J.jsx)(u,{path:`/`,element:(0,J.jsx)(ot,{children:(0,J.jsx)(hn,{})})}),(0,J.jsx)(u,{path:`*`,element:(0,J.jsx)(p,{to:`/`,replace:!0})})]})})]})]})}async function Mr(e){try{let t=await fetch(`/api/v1/i18n/translations/${e}`);if(!t.ok)return console.warn(`[i18n] Failed to load translations for '${e}': HTTP ${t.status}`),{};let n=await t.json(),r;return r=n?.data?.translations&&typeof n.data.translations==`object`?n.data.translations:n,b(r)?g(r):r}catch(t){return console.warn(`[i18n] Failed to load translations for '${e}':`,t),{}}}var Nr=`auth-session-token`,Pr=`auth-active-organization-id`;async function Fr(e){if(typeof window>`u`)return;let t=null;try{t=localStorage.getItem(Nr)}catch{return}if(t)try{let n=await fetch(`${e}/get-session`,{method:`GET`,credentials:`omit`,headers:{Authorization:`Bearer ${t}`,Accept:`application/json`}});if(n.ok){let e=await n.json().catch(()=>null);if(e?.user??e?.data?.user??null)return}localStorage.removeItem(Nr),localStorage.removeItem(Pr)}catch{}}function Ir(e,t){let n=Array.isArray(e.fields)?e.fields:Object.values(e.fields||{});return{id:e.name||`obj_${t}`,name:e.name||``,label:typeof e.label==`object`?e.label.defaultValue||e.label.key||``:e.label||e.name||``,pluralLabel:e.pluralLabel||e.plural_label||void 0,description:typeof e.description==`object`?e.description.defaultValue:e.description||void 0,icon:e.icon||void 0,group:e.name?.startsWith(`sys_`)?`System Objects`:`Custom Objects`,sortOrder:t,isSystem:e.name?.startsWith(`sys_`)||!1,fieldCount:n.length,relationships:Array.isArray(e.relationships)?e.relationships.map(e=>({relatedObject:e.object||e.relatedObject||``,type:e.type||`one-to-many`,label:e.label||e.name||void 0,foreignKey:e.foreign_key||e.foreignKey||void 0})):void 0}}function Lr(e,t){return{id:e.name||`fld_${t}`,name:e.name||``,label:typeof e.label==`object`?e.label.defaultValue||e.label.key||``:e.label||e.name||``,type:e.type||`text`,group:e.group||void 0,sortOrder:t,description:e.description||e.help||void 0,required:e.required||!1,unique:e.unique||!1,readonly:e.readonly||!1,hidden:e.hidden||!1,defaultValue:e.defaultValue||e.default_value||void 0,placeholder:e.placeholder||void 0,options:Array.isArray(e.options)?e.options.map(e=>typeof e==`string`?{label:e,value:e}:{label:e.label||e.value,value:e.value,color:e.color}):void 0,isSystem:e.readonly===!0&&(e.name===`id`||e.name===`createdAt`||e.name===`updatedAt`),externalId:e.externalId||!1,trackHistory:e.trackHistory||e.track_history||!1,indexed:e.indexed||!1,referenceTo:e.reference_to||e.referenceTo||void 0,formula:e.formula||void 0}}function Rr(e){let{objects:t}=E(),n=(0,q.useMemo)(()=>(t||[]).find(t=>t.name===e),[t,e]);return{object:(0,q.useMemo)(()=>n?Ir(n,0):null,[n]),fields:(0,q.useMemo)(()=>n?(Array.isArray(n.fields)?n.fields:Object.values(n.fields||{})).map(Lr):[],[n]),metadataObject:n}}function zr({label:e,value:t,onSave:n,multiline:r=!1,disabled:i=!1,placeholder:a}){let[o,s]=(0,q.useState)(!1),[c,l]=(0,q.useState)(t),[u,d]=(0,q.useState)(!1),f=(0,q.useRef)(null),p=()=>{l(t),s(!0),setTimeout(()=>f.current?.focus(),0)},m=(0,q.useCallback)(async()=>{if(c===t){s(!1);return}d(!0);try{await n(c),s(!1)}catch{}finally{d(!1)}},[c,t,n]),h=()=>{l(t),s(!1)},g=e=>{e.key===`Enter`&&!r&&(e.preventDefault(),m()),e.key===`Escape`&&h()};return(0,J.jsxs)(`div`,{className:`space-y-1.5 group`,children:[(0,J.jsx)(`dt`,{className:`text-xs font-medium text-muted-foreground`,children:e}),(0,J.jsx)(`dd`,{children:o?(0,J.jsxs)(`div`,{className:`flex items-start gap-1.5`,children:[r?(0,J.jsx)(De,{ref:f,value:c,onChange:e=>l(e.target.value),onKeyDown:g,placeholder:a,rows:3,className:`text-sm flex-1 min-w-0`,disabled:u}):(0,J.jsx)(F,{ref:f,value:c,onChange:e=>l(e.target.value),onKeyDown:g,placeholder:a,className:`text-sm h-7 flex-1 min-w-0`,disabled:u}),(0,J.jsx)(`button`,{onClick:()=>void m(),disabled:u,className:`mt-0.5 p-1 rounded text-green-600 hover:bg-green-50 disabled:opacity-50 shrink-0`,"aria-label":`Save`,children:u?(0,J.jsx)(L,{className:`h-3.5 w-3.5 animate-spin`}):(0,J.jsx)(ke,{className:`h-3.5 w-3.5`})}),(0,J.jsx)(`button`,{onClick:h,disabled:u,className:`mt-0.5 p-1 rounded text-muted-foreground hover:bg-accent shrink-0`,"aria-label":`Cancel`,children:(0,J.jsx)(ae,{className:`h-3.5 w-3.5`})})]}):(0,J.jsxs)(`div`,{className:`flex items-center gap-2 min-h-7`,children:[(0,J.jsx)(`span`,{className:`text-sm flex-1 min-w-0 truncate`,children:t||(0,J.jsx)(`span`,{className:`text-muted-foreground italic`,children:a||`—`})}),!i&&(0,J.jsx)(`button`,{onClick:p,className:`p-1 rounded text-muted-foreground opacity-0 group-hover:opacity-100 hover:bg-accent transition-opacity shrink-0`,"aria-label":`Edit ${e}`,children:(0,J.jsx)(Ne,{className:`h-3 w-3`})})]})})]})}function Br({schema:e}){let t=e.objectName,{object:n,fields:r,metadataObject:i}=Rr(t),{refresh:a}=E(),o=Je(),s=(0,q.useCallback)(async(e,n)=>{if(!o||!i)return;let r={...i,[e]:n};try{await o.saveMetadataItem(`object`,t,r),await a(),H.success(`${e===`label`?`Display name`:`Field`} updated`)}catch(e){throw H.error(e?.message||`Failed to save`),e}},[o,i,t,a]);if(!n)return null;let c=n.isSystem;return(0,J.jsxs)(`div`,{className:`space-y-6`,"data-testid":`object-properties`,children:[(0,J.jsxs)(`div`,{children:[(0,J.jsx)(`h3`,{className:`text-xs font-semibold text-muted-foreground uppercase tracking-wider mb-4`,children:`基本信息`}),(0,J.jsxs)(`dl`,{className:`grid grid-cols-1 sm:grid-cols-2 gap-5`,children:[(0,J.jsx)(zr,{label:`显示名称`,value:n.label,onSave:e=>s(`label`,e),placeholder:`输入显示名称`,disabled:c}),(0,J.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,J.jsx)(`dt`,{className:`text-xs font-medium text-muted-foreground`,children:`API 名称`}),(0,J.jsx)(`dd`,{className:`text-sm font-mono bg-muted/50 rounded px-2 py-1 inline-block`,children:n.name})]}),(0,J.jsx)(zr,{label:`复数名称`,value:n.pluralLabel||``,onSave:e=>s(`pluralLabel`,e),placeholder:`例如:客户们`,disabled:c}),(0,J.jsx)(zr,{label:`分组`,value:n.group||``,onSave:e=>s(`group`,e),placeholder:`对象分组`,disabled:c}),(0,J.jsx)(`div`,{className:`sm:col-span-2`,children:(0,J.jsx)(zr,{label:`描述`,value:n.description||``,onSave:e=>s(`description`,e),multiline:!0,placeholder:`输入对象描述`,disabled:c})})]})]}),(0,J.jsxs)(`div`,{children:[(0,J.jsx)(`h3`,{className:`text-xs font-semibold text-muted-foreground uppercase tracking-wider mb-4`,children:`配置`}),(0,J.jsxs)(`dl`,{className:`grid grid-cols-1 sm:grid-cols-3 gap-4`,children:[(0,J.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,J.jsx)(`dt`,{className:`text-xs font-medium text-muted-foreground`,children:`字段数量`}),(0,J.jsxs)(`dd`,{className:`text-sm font-medium`,children:[n.fieldCount??r.length,` 个字段`]})]}),c&&(0,J.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,J.jsx)(`dt`,{className:`text-xs font-medium text-muted-foreground`,children:`类型`}),(0,J.jsx)(`dd`,{children:(0,J.jsx)(M,{variant:`secondary`,className:`font-normal`,children:`系统对象`})})]})]})]})]})}var Vr=[{label:`一对多`,value:`one-to-many`},{label:`多对多`,value:`many-to-many`},{label:`一对一`,value:`one-to-one`},{label:`多对一`,value:`many-to-one`}];function Hr({schema:e}){let t=e.objectName,{object:n,metadataObject:r}=Rr(t),{refresh:i}=E(),a=Je(),[o,s]=(0,q.useState)(!1),[c,l]=(0,q.useState)(!1),[u,d]=(0,q.useState)({relatedObject:``,type:`one-to-many`,label:``,foreignKey:``}),f=(0,q.useCallback)(async()=>{if(!a||!r||!u.relatedObject.trim())return;let e={relatedObject:u.relatedObject.trim(),type:u.type,label:u.label.trim()||void 0,foreignKey:u.foreignKey.trim()||void 0},n={...r,relationships:[...Array.isArray(r.relationships)?r.relationships:[],e]};l(!0);try{await a.saveMetadataItem(`object`,t,n),await i(),H.success(`关联关系已添加`),s(!1),d({relatedObject:``,type:`one-to-many`,label:``,foreignKey:``})}catch(e){H.error(e?.message||`保存失败`)}finally{l(!1)}},[a,r,n,u,t,i]),p=(0,q.useCallback)(async e=>{if(!a||!r)return;let n=Array.isArray(r.relationships)?[...r.relationships]:[];n.splice(e,1);let o={...r,relationships:n};l(!0);try{await a.saveMetadataItem(`object`,t,o),await i(),H.success(`关联关系已删除`)}catch(e){H.error(e?.message||`删除失败`)}finally{l(!1)}},[a,r,t,i]);if(!n)return null;let m=n.relationships&&n.relationships.length>0;return(0,J.jsx)(`div`,{className:`space-y-4`,"data-testid":`relationships-section`,children:(0,J.jsxs)(`div`,{children:[(0,J.jsxs)(`div`,{className:`flex items-center justify-between mb-3`,children:[(0,J.jsx)(`h3`,{className:`text-xs font-semibold text-muted-foreground uppercase tracking-wider`,children:`关联关系`}),!n.isSystem&&(0,J.jsxs)(k,{size:`sm`,variant:`outline`,onClick:()=>s(e=>!e),className:`h-7 text-xs`,children:[(0,J.jsx)(Ae,{className:`h-3 w-3 mr-1`}),`添加关联`]})]}),o&&(0,J.jsxs)(`div`,{className:`mb-4 p-4 border rounded-lg bg-muted/30 space-y-3`,children:[(0,J.jsx)(`h4`,{className:`text-sm font-medium`,children:`新建关联关系`}),(0,J.jsxs)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 gap-3`,children:[(0,J.jsxs)(`div`,{children:[(0,J.jsx)(`label`,{className:`text-xs text-muted-foreground block mb-1`,children:`关联对象 *`}),(0,J.jsx)(F,{value:u.relatedObject,onChange:e=>d(t=>({...t,relatedObject:e.target.value})),placeholder:`例如:account`,className:`h-7 text-xs`})]}),(0,J.jsxs)(`div`,{children:[(0,J.jsx)(`label`,{className:`text-xs text-muted-foreground block mb-1`,children:`关联类型`}),(0,J.jsx)(`select`,{value:u.type,onChange:e=>d(t=>({...t,type:e.target.value})),className:`w-full h-7 text-xs rounded-md border border-input bg-background px-2`,children:Vr.map(e=>(0,J.jsx)(`option`,{value:e.value,children:e.label},e.value))})]}),(0,J.jsxs)(`div`,{children:[(0,J.jsx)(`label`,{className:`text-xs text-muted-foreground block mb-1`,children:`显示名称`}),(0,J.jsx)(F,{value:u.label,onChange:e=>d(t=>({...t,label:e.target.value})),placeholder:`可选`,className:`h-7 text-xs`})]}),(0,J.jsxs)(`div`,{children:[(0,J.jsx)(`label`,{className:`text-xs text-muted-foreground block mb-1`,children:`外键字段`}),(0,J.jsx)(F,{value:u.foreignKey,onChange:e=>d(t=>({...t,foreignKey:e.target.value})),placeholder:`例如:account_id`,className:`h-7 text-xs`})]})]}),(0,J.jsxs)(`div`,{className:`flex items-center gap-2 justify-end`,children:[(0,J.jsx)(k,{size:`sm`,variant:`ghost`,className:`h-7 text-xs`,onClick:()=>s(!1),disabled:c,children:`取消`}),(0,J.jsxs)(k,{size:`sm`,className:`h-7 text-xs`,onClick:()=>void f(),disabled:c||!u.relatedObject.trim(),children:[c?(0,J.jsx)(L,{className:`h-3 w-3 animate-spin mr-1`}):null,`保存`]})]})]}),m?(0,J.jsx)(`div`,{className:`space-y-2`,children:n.relationships?.map((e,t)=>(0,J.jsxs)(`div`,{className:`flex items-start gap-4 p-3 rounded-lg border bg-card hover:bg-accent/30 transition-colors group`,children:[(0,J.jsx)(M,{variant:`outline`,className:`text-xs shrink-0 mt-0.5`,children:Vr.find(t=>t.value===e.type)?.label||e.type}),(0,J.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,J.jsx)(`p`,{className:`font-medium text-sm`,children:e.label||e.relatedObject}),e.label&&e.label!==e.relatedObject&&(0,J.jsxs)(`p`,{className:`text-xs text-muted-foreground mt-0.5`,children:[`关联对象: `,(0,J.jsx)(`span`,{className:`font-mono`,children:e.relatedObject})]}),e.foreignKey&&(0,J.jsxs)(`p`,{className:`text-xs text-muted-foreground mt-0.5`,children:[`外键: `,(0,J.jsx)(`span`,{className:`font-mono`,children:e.foreignKey})]})]}),!n.isSystem&&(0,J.jsx)(`button`,{onClick:()=>void p(t),disabled:c,className:`p-1 rounded text-muted-foreground opacity-0 group-hover:opacity-100 hover:text-destructive hover:bg-destructive/10 transition-all shrink-0`,"aria-label":`删除关联`,children:(0,J.jsx)(be,{className:`h-3.5 w-3.5`})})]},t))}):!o&&(0,J.jsxs)(`div`,{className:`text-center py-8 px-4 border border-dashed rounded-lg`,children:[(0,J.jsx)(xe,{className:`h-8 w-8 mx-auto mb-2 text-muted-foreground opacity-40`}),(0,J.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`暂无关联关系。`}),!n.isSystem&&(0,J.jsxs)(k,{size:`sm`,variant:`outline`,className:`mt-3 h-7 text-xs`,onClick:()=>s(!0),children:[(0,J.jsx)(Ae,{className:`h-3 w-3 mr-1`}),`添加关联`]})]})]})})}function Ur({schema:e}){let t=e.objectName,{fields:n}=Rr(t),r=(0,q.useMemo)(()=>n.filter(e=>e.unique||e.name===`id`||e.externalId),[n]);return(0,J.jsx)(`div`,{className:`space-y-4`,"data-testid":`keys-section`,children:(0,J.jsxs)(`div`,{children:[(0,J.jsx)(`h3`,{className:`text-xs font-semibold text-muted-foreground uppercase tracking-wider mb-4`,children:`唯一键`}),r.length>0?(0,J.jsx)(`div`,{className:`space-y-2`,children:r.map(e=>(0,J.jsxs)(`div`,{className:`flex items-start gap-4 p-3 rounded-lg border bg-card hover:bg-accent/30 transition-colors`,children:[(0,J.jsx)(M,{variant:e.name===`id`?`default`:`outline`,className:`text-xs shrink-0 mt-0.5`,children:e.name===`id`?`主键`:e.externalId?`外部 ID`:`唯一`}),(0,J.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,J.jsx)(`p`,{className:`font-medium text-sm`,children:e.label||e.name}),(0,J.jsxs)(`p`,{className:`text-xs text-muted-foreground mt-0.5`,children:[`类型: `,(0,J.jsx)(`span`,{className:`font-mono`,children:e.type})]})]})]},e.name))}):(0,J.jsxs)(`div`,{className:`text-center py-8 px-4 border border-dashed rounded-lg`,children:[(0,J.jsx)(Ce,{className:`h-8 w-8 mx-auto mb-2 text-muted-foreground opacity-40`}),(0,J.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`未找到唯一键或主键。`})]})]})})}function Wr(e){return(0,J.jsx)(`div`,{className:`space-y-4`,"data-testid":`data-experience-section`,children:(0,J.jsxs)(`div`,{children:[(0,J.jsx)(`h3`,{className:`text-xs font-semibold text-muted-foreground uppercase tracking-wider mb-4`,children:`数据体验`}),(0,J.jsx)(`p`,{className:`text-sm text-muted-foreground mb-4`,children:`配置用户与此对象数据的交互方式`}),(0,J.jsxs)(`div`,{className:`grid grid-cols-1 sm:grid-cols-3 gap-4`,children:[(0,J.jsxs)(`div`,{className:`rounded-lg border p-5 text-center hover:bg-accent/30 transition-colors cursor-pointer`,"data-testid":`data-experience-forms`,children:[(0,J.jsx)(we,{className:`h-7 w-7 mx-auto mb-2.5 text-muted-foreground`}),(0,J.jsx)(`p`,{className:`text-sm font-semibold mb-1`,children:`表单`}),(0,J.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`设计数据录入表单`})]}),(0,J.jsxs)(`div`,{className:`rounded-lg border p-5 text-center hover:bg-accent/30 transition-colors cursor-pointer`,"data-testid":`data-experience-views`,children:[(0,J.jsx)(Oe,{className:`h-7 w-7 mx-auto mb-2.5 text-muted-foreground`}),(0,J.jsx)(`p`,{className:`text-sm font-semibold mb-1`,children:`视图`}),(0,J.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`配置列表和详情视图`})]}),(0,J.jsxs)(`div`,{className:`rounded-lg border p-5 text-center hover:bg-accent/30 transition-colors cursor-pointer`,"data-testid":`data-experience-dashboards`,children:[(0,J.jsx)(je,{className:`h-7 w-7 mx-auto mb-2.5 text-muted-foreground`}),(0,J.jsx)(`p`,{className:`text-sm font-semibold mb-1`,children:`仪表盘`}),(0,J.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`构建可视化仪表盘`})]})]})]})})}function Gr({schema:e}){let t=e.objectName,{object:n}=Rr(t);return(0,J.jsx)(`div`,{className:`space-y-4`,"data-testid":`data-preview-section`,children:(0,J.jsxs)(`div`,{children:[(0,J.jsx)(`h3`,{className:`text-xs font-semibold text-muted-foreground uppercase tracking-wider mb-4`,children:`数据预览`}),(0,J.jsx)(`p`,{className:`text-sm text-muted-foreground mb-4`,children:`查看此对象的示例记录`}),(0,J.jsxs)(`div`,{className:`rounded-lg border border-dashed p-12 text-center`,children:[(0,J.jsx)(Pe,{className:`h-12 w-12 mx-auto mb-4 text-muted-foreground opacity-40`}),(0,J.jsx)(`p`,{className:`text-sm font-medium mb-1`,children:`示例数据`}),(0,J.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[`“`,n?.label||t,`” 的实时数据预览将在此处显示`]})]})]})})}function Kr(e,t){return{name:e.name,label:e.label,pluralLabel:e.pluralLabel,description:e.description,icon:e.icon,group:e.group,sortOrder:e.sortOrder,fields:t,relationships:e.relationships}}function qr(e){return{name:e.name,label:e.label,type:e.type,group:e.group,description:e.description,required:e.required,unique:e.unique,readonly:e.readonly,hidden:e.hidden,defaultValue:e.defaultValue,placeholder:e.placeholder,options:e.options,externalId:e.externalId,trackHistory:e.trackHistory,indexed:e.indexed,referenceTo:e.referenceTo,formula:e.formula,sortOrder:e.sortOrder}}var Jr=class{adapter;constructor(e){this.adapter=e}async getItems(e){let t=await this.adapter.getClient().meta.getItems(e);return t&&typeof t==`object`&&`items`in t&&Array.isArray(t.items)?t.items:[]}async saveMetadataItem(e,t,n){await this.adapter.getClient().meta.saveItem(e,t,n),this.adapter.invalidateCache(`${e}:${t}`)}async deleteMetadataItem(e,t){await this.adapter.getClient().meta.saveItem(e,t,{name:t,enabled:!1,_deleted:!0}),this.adapter.invalidateCache(`${e}:${t}`)}async saveObject(e,t){let n=this.adapter.getClient(),r=Kr(e,t);await n.meta.saveItem(`object`,e.name,r),this.adapter.invalidateCache(`object:${e.name}`)}async deleteObject(e){await this.adapter.getClient().meta.saveItem(`object`,e,{name:e,enabled:!1,_deleted:!0}),this.adapter.invalidateCache(`object:${e}`)}async saveFields(e,t){let n=this.adapter.getClient(),r={};try{let t=await n.meta.getItem(`object`,e);r=t?.item??t??{}}catch{}let i={...r,name:e,fields:t.map(qr)};await n.meta.saveItem(`object`,e,i),this.adapter.invalidateCache(`object:${e}`)}static diffObjects(e,t){let n=new Map(e.map(e=>[e.id,e])),r=new Map(t.map(e=>[e.id,e]));for(let[e,t]of r)if(!n.has(e))return{type:`create`,object:t};for(let[e,t]of n)if(!r.has(e))return{type:`delete`,object:t};for(let[e,t]of r){let r=n.get(e);if(r&&JSON.stringify(r)!==JSON.stringify(t))return{type:`update`,object:t}}return null}static diffFields(e,t){let n=new Map(e.map(e=>[e.id,e])),r=new Map(t.map(e=>[e.id,e]));for(let[e,t]of r)if(!n.has(e))return{type:`create`,field:t};for(let[e,t]of n)if(!r.has(e))return{type:`delete`,field:t};for(let[e,t]of r){let r=n.get(e);if(r&&JSON.stringify(r)!==JSON.stringify(t))return{type:`update`,field:t}}return null}};function Yr({schema:e}){let t=e.objectName,{objects:n,refresh:r}=E(),i=Je(),a=(0,q.useMemo)(()=>(n||[]).find(e=>e.name===t),[n,t]),o=(0,q.useMemo)(()=>a?(Array.isArray(a.fields)?a.fields:Object.values(a.fields||{})).map(Lr):[],[a]),[s,c]=(0,q.useState)(null),[l,u]=(0,q.useState)(!1),d=s??o,f=(0,q.useRef)(d),p=(0,q.useCallback)(async e=>{let n=f.current;if(c(e),f.current=e,!i){H.error(`Service unavailable — changes saved locally only`);return}let a=Jr.diffFields(n,e),o=a?a.type===`create`?`Field "${a.field.label||a.field.name}" created`:a.type===`update`?`Field "${a.field.label||a.field.name}" updated`:`Field "${a.field.label||a.field.name}" deleted`:`Field configuration updated`;u(!0);try{await i.saveFields(t,e),await r(),H.success(o)}catch(e){c(n),f.current=n,H.error(e?.message||`Failed to save field changes`)}finally{u(!1)}},[i,t,r]);return(0,J.jsxs)(`div`,{className:`space-y-3`,"data-testid":`field-management-section`,children:[l&&(0,J.jsxs)(`div`,{className:`flex items-center gap-2 text-sm text-muted-foreground`,"data-testid":`field-saving-indicator`,children:[(0,J.jsx)(L,{className:`h-4 w-4 animate-spin`}),`Saving field changes…`]}),d.some(e=>e.isSystem)&&(0,J.jsxs)(`div`,{className:`flex items-center gap-2 text-xs text-muted-foreground bg-muted/50 rounded-md px-3 py-2`,"data-testid":`system-field-hint`,children:[(0,J.jsx)(pe,{className:`h-3.5 w-3.5 shrink-0`}),`System fields (e.g. id, createdAt, updatedAt) are read-only and cannot be edited or deleted.`]}),(0,J.jsx)(At,{objectName:t,fields:d,onFieldsChange:p})]})}function Xr({schema:e}){let t=e.objectName,[n,r]=(0,q.useState)(`details`),i={type:`object-properties`,id:`${t}-properties`,objectName:t},a={type:`object-field-designer`,id:`${t}-field-designer`,objectName:t},o={type:`object-relationships`,id:`${t}-relationships`,objectName:t},s={type:`object-keys`,id:`${t}-keys`,objectName:t},c={type:`object-data-experience`,id:`${t}-data-experience`,objectName:t},l={type:`object-data-preview`,id:`${t}-data-preview`,objectName:t};return(0,J.jsx)(`div`,{className:`w-full`,"data-testid":`object-detail-tabs`,children:(0,J.jsxs)(Se,{value:n,onValueChange:r,className:`w-full`,children:[(0,J.jsxs)(ye,{className:`w-full justify-start border-b rounded-none bg-transparent p-0 h-auto`,children:[(0,J.jsxs)(V,{value:`details`,className:`relative rounded-none border-b-2 border-transparent data-[state=active]:border-primary data-[state=active]:bg-transparent data-[state=active]:shadow-none`,children:[(0,J.jsx)(fe,{className:`h-4 w-4 mr-2`}),`详情`]}),(0,J.jsxs)(V,{value:`fields`,className:`relative rounded-none border-b-2 border-transparent data-[state=active]:border-primary data-[state=active]:bg-transparent data-[state=active]:shadow-none`,children:[(0,J.jsx)(Ee,{className:`h-4 w-4 mr-2`}),`字段`]}),(0,J.jsxs)(V,{value:`relationships`,className:`relative rounded-none border-b-2 border-transparent data-[state=active]:border-primary data-[state=active]:bg-transparent data-[state=active]:shadow-none`,children:[(0,J.jsx)(xe,{className:`h-4 w-4 mr-2`}),`关联关系`]}),(0,J.jsxs)(V,{value:`data`,className:`relative rounded-none border-b-2 border-transparent data-[state=active]:border-primary data-[state=active]:bg-transparent data-[state=active]:shadow-none`,children:[(0,J.jsx)(Pe,{className:`h-4 w-4 mr-2`}),`数据`]})]}),(0,J.jsx)(N,{value:`details`,className:`mt-6`,children:(0,J.jsx)(`div`,{className:`space-y-6`,children:(0,J.jsx)(D,{schema:i})})}),(0,J.jsx)(N,{value:`fields`,className:`mt-6`,children:(0,J.jsx)(`div`,{className:`space-y-6`,children:(0,J.jsx)(D,{schema:a})})}),(0,J.jsx)(N,{value:`relationships`,className:`mt-6`,children:(0,J.jsxs)(`div`,{className:`space-y-6`,children:[(0,J.jsx)(D,{schema:o}),(0,J.jsx)(D,{schema:s})]})}),(0,J.jsx)(N,{value:`data`,className:`mt-6`,children:(0,J.jsxs)(`div`,{className:`space-y-6`,children:[(0,J.jsx)(D,{schema:l}),(0,J.jsx)(D,{schema:c})]})})]})})}var $={namespace:`console`,category:`system`};O.register(`object-detail-tabs`,Xr,{...$,label:`Object Detail Tabs`,icon:`LayoutDashboard`}),O.register(`object-properties`,Br,{...$,label:`Object Properties`,icon:`Settings2`}),O.register(`object-relationships`,Hr,{...$,label:`Object Relationships`,icon:`Link2`}),O.register(`object-keys`,Ur,{...$,label:`Object Keys`,icon:`KeyRound`}),O.register(`object-data-experience`,Wr,{...$,label:`Data Experience`,icon:`LayoutList`}),O.register(`object-data-preview`,Gr,{...$,label:`Data Preview`,icon:`Table`}),O.register(`object-field-designer`,Yr,{...$,label:`Field Designer`,icon:`Columns`});var Zr=(0,q.lazy)(()=>s(()=>import(`./ApiConsolePage-DVnQPvbh.js`).then(e=>({default:e.ApiConsolePage})),__vite__mapDeps([0,1]),import.meta.url)),Qr=(0,q.lazy)(()=>s(()=>import(`./FlowRunsPage-DKnUh_Ec.js`).then(e=>({default:e.FlowRunsPage})),__vite__mapDeps([0,1]),import.meta.url)),$r=(0,q.lazy)(()=>s(()=>import(`./PublicFormsPage-CRNSj35t.js`).then(e=>({default:e.PublicFormsPage})),__vite__mapDeps([0,1]),import.meta.url));function ei({label:e}){return(0,J.jsxs)(`div`,{className:`p-6 text-sm text-muted-foreground`,children:[`Loading `,e,`…`]})}G({ref:`developer:api-console`,label:`API Console`,source:`@object-ui/console`,component:e=>(0,J.jsx)(q.Suspense,{fallback:(0,J.jsx)(ei,{label:`API console`}),children:(0,J.jsx)(Zr,{...e})})}),G({ref:`developer:flow-runs`,label:`Flow Runs`,source:`@object-ui/console`,component:e=>(0,J.jsx)(q.Suspense,{fallback:(0,J.jsx)(ei,{label:`flow runs`}),children:(0,J.jsx)(Qr,{...e})})}),G({ref:`developer:public-forms`,label:`Public Forms`,source:`@object-ui/console`,component:e=>(0,J.jsx)(q.Suspense,{fallback:(0,J.jsx)(ei,{label:`public forms`}),children:(0,J.jsx)($r,{...e})})});var ti=(0,q.lazy)(()=>s(()=>import(`./src-CB6vSDbd.js`).then(e=>e.t).then(e=>({default:e.BuilderLanding})),__vite__mapDeps([0,1]),import.meta.url));G({ref:`studio:builder`,label:`应用构建`,source:`@object-ui/console`,component:e=>(0,J.jsx)(q.Suspense,{fallback:(0,J.jsx)(`div`,{className:`p-6 text-sm text-muted-foreground`,children:`加载应用构建器…`}),children:(0,J.jsx)(ti,{...e})})});var ni=(0,q.lazy)(()=>s(()=>import(`./ProfilePage-DAkDEioN.js`).then(e=>({default:e.ProfilePage})),__vite__mapDeps([0]),import.meta.url));function ri(){let{t:e}=A();return(0,J.jsx)(`div`,{className:`p-6 text-sm text-muted-foreground`,children:e(`common.loading`,{defaultValue:`Loading...`})})}G({ref:`account:profile_card`,label:`My Profile`,source:`@object-ui/console`,component:e=>(0,J.jsx)(q.Suspense,{fallback:(0,J.jsx)(ri,{}),children:(0,J.jsx)(ni,{...e})})});var ii=`/api/v1/auth`;Qe(),O.registerLazy(`object-map`,()=>s(()=>import(`./plugin-map-fMpIp7jh.js`).then(e=>e.t),__vite__mapDeps([0,2]),import.meta.url),{namespace:`plugin-map`,category:`view`}),O.registerLazy(`map`,()=>s(()=>import(`./plugin-map-fMpIp7jh.js`).then(e=>e.t),__vite__mapDeps([0,2]),import.meta.url),{namespace:`view`,category:`view`}),O.registerLazy(`object-tree`,()=>s(()=>import(`./plugin-tree-CZRX9ChE.js`).then(e=>e.t),__vite__mapDeps([0]),import.meta.url),{namespace:`plugin-tree`,category:`view`}),O.registerLazy(`tree`,()=>s(()=>import(`./plugin-tree-CZRX9ChE.js`).then(e=>e.t),__vite__mapDeps([0]),import.meta.url),{namespace:`view`,category:`view`});for(let e of[`dashboard`,`metric`,`metric-card`,`object-metric`,`pivot`,`object-pivot`,`dashboard-grid`,`object-data-table`])O.registerLazy(e,()=>s(()=>import(`./plugin-dashboard-ARn_CaB3.js`).then(e=>e.t),__vite__mapDeps([0,1]),import.meta.url),{namespace:`plugin-dashboard`,category:`view`});O.registerLazy(`chart`,()=>s(()=>import(`./plugin-charts-BHxVdXp7.js`).then(e=>e.t),__vite__mapDeps([0]),import.meta.url),{namespace:`plugin-charts`,category:`chart`});for(let e of[`object-chart`,`bar-chart`,`pie-chart`,`donut-chart`,`radar-chart`,`scatter-chart`,`line-chart`,`area-chart`,`advanced-chart`,`chart:bar`])O.registerLazy(e,()=>s(()=>import(`./plugin-charts-BHxVdXp7.js`).then(e=>e.t),__vite__mapDeps([0]),import.meta.url),{namespace:`plugin-charts`,category:`chart`});O.registerLazy(`object-gantt`,()=>s(()=>import(`./plugin-gantt-DrEbvyAE.js`).then(e=>e.t),__vite__mapDeps([0]),import.meta.url),{namespace:`plugin-gantt`,category:`view`}),O.registerLazy(`gantt`,()=>s(()=>import(`./plugin-gantt-DrEbvyAE.js`).then(e=>e.t),__vite__mapDeps([0]),import.meta.url),{namespace:`view`,category:`view`}),O.registerLazy(`markdown`,()=>s(()=>import(`./plugin-markdown-wZpqyjok.js`).then(e=>e.n),__vite__mapDeps([0]),import.meta.url),{namespace:`plugin-markdown`,category:`display`}),O.registerLazy(`object-timeline`,()=>s(()=>import(`./plugin-timeline-DZNEy3Y1.js`).then(e=>e.t),__vite__mapDeps([0]),import.meta.url),{namespace:`plugin-timeline`,category:`view`}),O.registerLazy(`timeline`,()=>s(()=>import(`./plugin-timeline-DZNEy3Y1.js`).then(e=>e.t),__vite__mapDeps([0]),import.meta.url),{namespace:`view`,category:`view`}),O.registerLazy(`object-calendar`,()=>s(()=>import(`./plugin-calendar-Bm0-Kkhu.js`).then(e=>e.t),__vite__mapDeps([0]),import.meta.url),{namespace:`plugin-calendar`,category:`view`}),O.registerLazy(`calendar`,()=>s(()=>import(`./plugin-calendar-Bm0-Kkhu.js`).then(e=>e.t),__vite__mapDeps([0]),import.meta.url),{namespace:`view`,category:`view`}),O.registerLazy(`calendar-view`,()=>s(()=>import(`./plugin-calendar-Bm0-Kkhu.js`).then(e=>e.t),__vite__mapDeps([0]),import.meta.url),{namespace:`plugin-calendar`,category:`view`}),O.registerLazy(`object-kanban`,()=>s(()=>import(`./plugin-kanban-C-mR5I0H.js`).then(e=>e.t),__vite__mapDeps([0]),import.meta.url),{namespace:`plugin-kanban`,category:`view`}),O.registerLazy(`kanban`,()=>s(()=>import(`./plugin-kanban-C-mR5I0H.js`).then(e=>e.t),__vite__mapDeps([0]),import.meta.url),{namespace:`view`,category:`view`});for(let e of[`kanban-ui`,`kanban-enhanced`])O.registerLazy(e,()=>s(()=>import(`./plugin-kanban-C-mR5I0H.js`).then(e=>e.t),__vite__mapDeps([0]),import.meta.url),{namespace:`plugin-kanban`,category:`view`});O.registerLazy(`report`,()=>s(()=>import(`./plugin-report-kGtO0FOF.js`).then(e=>e.t),__vite__mapDeps([0]),import.meta.url),{namespace:`plugin-report`,category:`view`});for(let e of[`report-viewer`,`spec-report`])O.registerLazy(e,()=>s(()=>import(`./plugin-report-kGtO0FOF.js`).then(e=>e.t),__vite__mapDeps([0]),import.meta.url),{namespace:`plugin-report`,category:`view`});Ie();var ai=``.replace(/\/+$/,``);Promise.all([dt(ai),Fr(ii)]).finally(()=>{document.title=W();let e=pt();if(e){let t=document.getElementById(`favicon`);t&&(t.href=e,t.type=e.endsWith(`.svg`)?`image/svg+xml`:`image/png`)}let t=gt({enabled:!0,name:W(),shortName:mt(),description:ft(),themeColor:ut(),backgroundColor:`#ffffff`,display:`standalone`,startUrl:`./`,scope:`./`,orientation:`any`,icons:[{src:e||`./favicon.svg`,sizes:`any`,type:`image/svg+xml`,purpose:`any`}]}),n=new Blob([JSON.stringify(t)],{type:`application/json`}),r=URL.createObjectURL(n),i=document.querySelector(`link[rel="manifest"]`);i&&i.remove();let a=document.createElement(`link`);a.rel=`manifest`,a.href=r,document.head.appendChild(a),jt.createRoot(document.getElementById(`root`)).render((0,J.jsx)(q.StrictMode,{children:(0,J.jsx)(vt,{pwa:{enabled:!0,name:W(),shortName:mt()},children:(0,J.jsx)(le,{loadLanguage:Mr,children:(0,J.jsx)(jr,{})})})}))});
|