@object-ui/runner 14.1.0 → 15.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +11 -0
- package/dist/assets/{AdvancedChartImpl-D3enFgLA.js → AdvancedChartImpl-DQqVKVEy.js} +1 -1
- package/dist/assets/{BarChart-CeSD4J0S.js → BarChart-zF_o74Ix.js} +1 -1
- package/dist/assets/{ChartImpl-BOk8UN2m.js → ChartImpl-B75dFzK8.js} +1 -1
- package/dist/assets/{KanbanEnhanced-DVd-8iF9.js → KanbanEnhanced-CzNXENd5.js} +1 -1
- package/dist/assets/{KanbanImpl-1R6QCwBw.js → KanbanImpl-E9a8UVuL.js} +1 -1
- package/dist/assets/{index-tzY1H_oh.js → index-6qLU6QEv.js} +3 -3
- package/dist/assets/{sortable.esm-B1cbD2PH.js → sortable.esm-C7k4JET8.js} +1 -1
- package/dist/index.html +1 -1
- package/package.json +7 -7
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/dist-B6axm7cl.js","assets/react-B8IZ02wI.js","assets/KanbanImpl-
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/dist-B6axm7cl.js","assets/react-B8IZ02wI.js","assets/KanbanImpl-E9a8UVuL.js","assets/sortable.esm-C7k4JET8.js","assets/KanbanEnhanced-CzNXENd5.js","assets/ChartImpl-B75dFzK8.js","assets/BarChart-zF_o74Ix.js","assets/AdvancedChartImpl-DQqVKVEy.js"])))=>i.map(i=>d[i]);
|
|
2
2
|
import{i as e,n as t,r as n,t as r}from"./react-B8IZ02wI.js";(function(){let e=document.createElement(`link`).relList;if(e&&e.supports&&e.supports(`modulepreload`))return;for(let e of document.querySelectorAll(`link[rel="modulepreload"]`))n(e);new MutationObserver(e=>{for(let t of e)if(t.type===`childList`)for(let e of t.addedNodes)e.tagName===`LINK`&&e.rel===`modulepreload`&&n(e)}).observe(document,{childList:!0,subtree:!0});function t(e){let t={};return e.integrity&&(t.integrity=e.integrity),e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),e.crossOrigin===`use-credentials`?t.credentials=`include`:e.crossOrigin===`anonymous`?t.credentials=`omit`:t.credentials=`same-origin`,t}function n(e){if(e.ep)return;e.ep=!0;let n=t(e);fetch(e.href,n)}})();var i=t((e=>{function t(e,t){var n=e.length;e.push(t);a:for(;0<n;){var r=n-1>>>1,a=e[r];if(0<i(a,t))e[r]=t,e[n]=a,n=r;else break a}}function n(e){return e.length===0?null:e[0]}function r(e){if(e.length===0)return null;var t=e[0],n=e.pop();if(n!==t){e[0]=n;a:for(var r=0,a=e.length,o=a>>>1;r<o;){var s=2*(r+1)-1,c=e[s],l=s+1,u=e[l];if(0>i(c,n))l<a&&0>i(u,c)?(e[r]=u,e[l]=n,r=l):(e[r]=c,e[s]=n,r=s);else if(l<a&&0>i(u,n))e[r]=u,e[l]=n,r=l;else break a}}return t}function i(e,t){var n=e.sortIndex-t.sortIndex;return n===0?e.id-t.id:n}if(e.unstable_now=void 0,typeof performance==`object`&&typeof performance.now==`function`){var a=performance;e.unstable_now=function(){return a.now()}}else{var o=Date,s=o.now();e.unstable_now=function(){return o.now()-s}}var c=[],l=[],u=1,d=null,f=3,p=!1,m=!1,h=!1,g=!1,_=typeof setTimeout==`function`?setTimeout:null,v=typeof clearTimeout==`function`?clearTimeout:null,y=typeof setImmediate<`u`?setImmediate:null;function b(e){for(var i=n(l);i!==null;){if(i.callback===null)r(l);else if(i.startTime<=e)r(l),i.sortIndex=i.expirationTime,t(c,i);else break;i=n(l)}}function x(e){if(h=!1,b(e),!m)if(n(c)!==null)m=!0,S||(S=!0,O());else{var t=n(l);t!==null&&ee(x,t.startTime-e)}}var S=!1,C=-1,w=5,T=-1;function E(){return g?!0:!(e.unstable_now()-T<w)}function D(){if(g=!1,S){var t=e.unstable_now();T=t;var i=!0;try{a:{m=!1,h&&(h=!1,v(C),C=-1),p=!0;var a=f;try{b:{for(b(t),d=n(c);d!==null&&!(d.expirationTime>t&&E());){var o=d.callback;if(typeof o==`function`){d.callback=null,f=d.priorityLevel;var s=o(d.expirationTime<=t);if(t=e.unstable_now(),typeof s==`function`){d.callback=s,b(t),i=!0;break b}d===n(c)&&r(c),b(t)}else r(c);d=n(c)}if(d!==null)i=!0;else{var u=n(l);u!==null&&ee(x,u.startTime-t),i=!1}}break a}finally{d=null,f=a,p=!1}i=void 0}}finally{i?O():S=!1}}}var O;if(typeof y==`function`)O=function(){y(D)};else if(typeof MessageChannel<`u`){var k=new MessageChannel,A=k.port2;k.port1.onmessage=D,O=function(){A.postMessage(null)}}else O=function(){_(D,0)};function ee(t,n){C=_(function(){t(e.unstable_now())},n)}e.unstable_IdlePriority=5,e.unstable_ImmediatePriority=1,e.unstable_LowPriority=4,e.unstable_NormalPriority=3,e.unstable_Profiling=null,e.unstable_UserBlockingPriority=2,e.unstable_cancelCallback=function(e){e.callback=null},e.unstable_forceFrameRate=function(e){0>e||125<e?console.error(`forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported`):w=0<e?Math.floor(1e3/e):5},e.unstable_getCurrentPriorityLevel=function(){return f},e.unstable_next=function(e){switch(f){case 1:case 2:case 3:var t=3;break;default:t=f}var n=f;f=t;try{return e()}finally{f=n}},e.unstable_requestPaint=function(){g=!0},e.unstable_runWithPriority=function(e,t){switch(e){case 1:case 2:case 3:case 4:case 5:break;default:e=3}var n=f;f=e;try{return t()}finally{f=n}},e.unstable_scheduleCallback=function(r,i,a){var o=e.unstable_now();switch(typeof a==`object`&&a?(a=a.delay,a=typeof a==`number`&&0<a?o+a:o):a=o,r){case 1:var s=-1;break;case 2:s=250;break;case 5:s=1073741823;break;case 4:s=1e4;break;default:s=5e3}return s=a+s,r={id:u++,callback:i,priorityLevel:r,startTime:a,expirationTime:s,sortIndex:-1},a>o?(r.sortIndex=a,t(l,r),n(c)===null&&r===n(l)&&(h?(v(C),C=-1):h=!0,ee(x,a-o))):(r.sortIndex=s,t(c,r),m||p||(m=!0,S||(S=!0,O()))),r},e.unstable_shouldYield=E,e.unstable_wrapCallback=function(e){var t=f;return function(){var n=f;f=t;try{return e.apply(this,arguments)}finally{f=n}}}})),a=t(((e,t)=>{t.exports=i()})),o=t((e=>{var t=r();function n(e){var t=`https://react.dev/errors/`+e;if(1<arguments.length){t+=`?args[]=`+encodeURIComponent(arguments[1]);for(var n=2;n<arguments.length;n++)t+=`&args[]=`+encodeURIComponent(arguments[n])}return`Minified React error #`+e+`; visit `+t+` for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`}function i(){}var a={d:{f:i,r:function(){throw Error(n(522))},D:i,C:i,L:i,m:i,X:i,S:i,M:i},p:0,findDOMNode:null},o=Symbol.for(`react.portal`);function s(e,t,n){var r=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:o,key:r==null?null:``+r,children:e,containerInfo:t,implementation:n}}var c=t.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;function l(e,t){if(e===`font`)return``;if(typeof t==`string`)return t===`use-credentials`?t:``}e.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=a,e.createPortal=function(e,t){var r=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!t||t.nodeType!==1&&t.nodeType!==9&&t.nodeType!==11)throw Error(n(299));return s(e,t,null,r)},e.flushSync=function(e){var t=c.T,n=a.p;try{if(c.T=null,a.p=2,e)return e()}finally{c.T=t,a.p=n,a.d.f()}},e.preconnect=function(e,t){typeof e==`string`&&(t?(t=t.crossOrigin,t=typeof t==`string`?t===`use-credentials`?t:``:void 0):t=null,a.d.C(e,t))},e.prefetchDNS=function(e){typeof e==`string`&&a.d.D(e)},e.preinit=function(e,t){if(typeof e==`string`&&t&&typeof t.as==`string`){var n=t.as,r=l(n,t.crossOrigin),i=typeof t.integrity==`string`?t.integrity:void 0,o=typeof t.fetchPriority==`string`?t.fetchPriority:void 0;n===`style`?a.d.S(e,typeof t.precedence==`string`?t.precedence:void 0,{crossOrigin:r,integrity:i,fetchPriority:o}):n===`script`&&a.d.X(e,{crossOrigin:r,integrity:i,fetchPriority:o,nonce:typeof t.nonce==`string`?t.nonce:void 0})}},e.preinitModule=function(e,t){if(typeof e==`string`)if(typeof t==`object`&&t){if(t.as==null||t.as===`script`){var n=l(t.as,t.crossOrigin);a.d.M(e,{crossOrigin:n,integrity:typeof t.integrity==`string`?t.integrity:void 0,nonce:typeof t.nonce==`string`?t.nonce:void 0})}}else t??a.d.M(e)},e.preload=function(e,t){if(typeof e==`string`&&typeof t==`object`&&t&&typeof t.as==`string`){var n=t.as,r=l(n,t.crossOrigin);a.d.L(e,n,{crossOrigin:r,integrity:typeof t.integrity==`string`?t.integrity:void 0,nonce:typeof t.nonce==`string`?t.nonce:void 0,type:typeof t.type==`string`?t.type:void 0,fetchPriority:typeof t.fetchPriority==`string`?t.fetchPriority:void 0,referrerPolicy:typeof t.referrerPolicy==`string`?t.referrerPolicy:void 0,imageSrcSet:typeof t.imageSrcSet==`string`?t.imageSrcSet:void 0,imageSizes:typeof t.imageSizes==`string`?t.imageSizes:void 0,media:typeof t.media==`string`?t.media:void 0})}},e.preloadModule=function(e,t){if(typeof e==`string`)if(t){var n=l(t.as,t.crossOrigin);a.d.m(e,{as:typeof t.as==`string`&&t.as!==`script`?t.as:void 0,crossOrigin:n,integrity:typeof t.integrity==`string`?t.integrity:void 0})}else a.d.m(e)},e.requestFormReset=function(e){a.d.r(e)},e.unstable_batchedUpdates=function(e,t){return e(t)},e.useFormState=function(e,t,n){return c.H.useFormState(e,t,n)},e.useFormStatus=function(){return c.H.useHostTransitionStatus()},e.version=`19.2.7`})),s=t(((e,t)=>{function n(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>`u`||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!=`function`))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(n)}catch(e){console.error(e)}}n(),t.exports=o()})),c=t((e=>{var t=a(),n=r(),i=s();function o(e){var t=`https://react.dev/errors/`+e;if(1<arguments.length){t+=`?args[]=`+encodeURIComponent(arguments[1]);for(var n=2;n<arguments.length;n++)t+=`&args[]=`+encodeURIComponent(arguments[n])}return`Minified React error #`+e+`; visit `+t+` for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`}function c(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11)}function l(e){var t=e,n=e;if(e.alternate)for(;t.return;)t=t.return;else{e=t;do t=e,t.flags&4098&&(n=t.return),e=t.return;while(e)}return t.tag===3?n:null}function u(e){if(e.tag===13){var t=e.memoizedState;if(t===null&&(e=e.alternate,e!==null&&(t=e.memoizedState)),t!==null)return t.dehydrated}return null}function d(e){if(e.tag===31){var t=e.memoizedState;if(t===null&&(e=e.alternate,e!==null&&(t=e.memoizedState)),t!==null)return t.dehydrated}return null}function f(e){if(l(e)!==e)throw Error(o(188))}function p(e){var t=e.alternate;if(!t){if(t=l(e),t===null)throw Error(o(188));return t===e?e:null}for(var n=e,r=t;;){var i=n.return;if(i===null)break;var a=i.alternate;if(a===null){if(r=i.return,r!==null){n=r;continue}break}if(i.child===a.child){for(a=i.child;a;){if(a===n)return f(i),e;if(a===r)return f(i),t;a=a.sibling}throw Error(o(188))}if(n.return!==r.return)n=i,r=a;else{for(var s=!1,c=i.child;c;){if(c===n){s=!0,n=i,r=a;break}if(c===r){s=!0,r=i,n=a;break}c=c.sibling}if(!s){for(c=a.child;c;){if(c===n){s=!0,n=a,r=i;break}if(c===r){s=!0,r=a,n=i;break}c=c.sibling}if(!s)throw Error(o(189))}}if(n.alternate!==r)throw Error(o(190))}if(n.tag!==3)throw Error(o(188));return n.stateNode.current===n?e:t}function m(e){var t=e.tag;if(t===5||t===26||t===27||t===6)return e;for(e=e.child;e!==null;){if(t=m(e),t!==null)return t;e=e.sibling}return null}var h=Object.assign,g=Symbol.for(`react.element`),_=Symbol.for(`react.transitional.element`),v=Symbol.for(`react.portal`),y=Symbol.for(`react.fragment`),b=Symbol.for(`react.strict_mode`),x=Symbol.for(`react.profiler`),S=Symbol.for(`react.consumer`),C=Symbol.for(`react.context`),w=Symbol.for(`react.forward_ref`),T=Symbol.for(`react.suspense`),E=Symbol.for(`react.suspense_list`),D=Symbol.for(`react.memo`),O=Symbol.for(`react.lazy`),k=Symbol.for(`react.activity`),A=Symbol.for(`react.memo_cache_sentinel`),ee=Symbol.iterator;function te(e){return typeof e!=`object`||!e?null:(e=ee&&e[ee]||e[`@@iterator`],typeof e==`function`?e:null)}var j=Symbol.for(`react.client.reference`);function ne(e){if(e==null)return null;if(typeof e==`function`)return e.$$typeof===j?null:e.displayName||e.name||null;if(typeof e==`string`)return e;switch(e){case y:return`Fragment`;case x:return`Profiler`;case b:return`StrictMode`;case T:return`Suspense`;case E:return`SuspenseList`;case k:return`Activity`}if(typeof e==`object`)switch(e.$$typeof){case v:return`Portal`;case C:return e.displayName||`Context`;case S:return(e._context.displayName||`Context`)+`.Consumer`;case w:var t=e.render;return e=e.displayName,e||=(e=t.displayName||t.name||``,e===``?`ForwardRef`:`ForwardRef(`+e+`)`),e;case D:return t=e.displayName||null,t===null?ne(e.type)||`Memo`:t;case O:t=e._payload,e=e._init;try{return ne(e(t))}catch{}}return null}var re=Array.isArray,M=n.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,N=i.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,ie={pending:!1,data:null,method:null,action:null},ae=[],oe=-1;function P(e){return{current:e}}function se(e){0>oe||(e.current=ae[oe],ae[oe]=null,oe--)}function ce(e,t){oe++,ae[oe]=e.current,e.current=t}var le=P(null),ue=P(null),de=P(null),fe=P(null);function pe(e,t){switch(ce(de,t),ce(ue,e),ce(le,null),t.nodeType){case 9:case 11:e=(e=t.documentElement)&&(e=e.namespaceURI)?ld(e):0;break;default:if(e=t.tagName,t=t.namespaceURI)t=ld(t),e=ud(t,e);else switch(e){case`svg`:e=1;break;case`math`:e=2;break;default:e=0}}se(le),ce(le,e)}function me(){se(le),se(ue),se(de)}function he(e){e.memoizedState!==null&&ce(fe,e);var t=le.current,n=ud(t,e.type);t!==n&&(ce(ue,e),ce(le,n))}function ge(e){ue.current===e&&(se(le),se(ue)),fe.current===e&&(se(fe),af._currentValue=ie)}var _e,ve;function ye(e){if(_e===void 0)try{throw Error()}catch(e){var t=e.stack.trim().match(/\n( *(at )?)/);_e=t&&t[1]||``,ve=-1<e.stack.indexOf(`
|
|
3
3
|
at`)?` (<anonymous>)`:-1<e.stack.indexOf(`@`)?`@unknown:0:0`:``}return`
|
|
4
4
|
`+_e+e+ve}var be=!1;function xe(e,t){if(!e||be)return``;be=!0;var n=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{var r={DetermineComponentFrameRoot:function(){try{if(t){var n=function(){throw Error()};if(Object.defineProperty(n.prototype,"props",{set:function(){throw Error()}}),typeof Reflect==`object`&&Reflect.construct){try{Reflect.construct(n,[])}catch(e){var r=e}Reflect.construct(e,[],n)}else{try{n.call()}catch(e){r=e}e.call(n.prototype)}}else{try{throw Error()}catch(e){r=e}(n=e())&&typeof n.catch==`function`&&n.catch(function(){})}}catch(e){if(e&&r&&typeof e.stack==`string`)return[e.stack,r.stack]}return[null,null]}};r.DetermineComponentFrameRoot.displayName=`DetermineComponentFrameRoot`;var i=Object.getOwnPropertyDescriptor(r.DetermineComponentFrameRoot,`name`);i&&i.configurable&&Object.defineProperty(r.DetermineComponentFrameRoot,"name",{value:`DetermineComponentFrameRoot`});var a=r.DetermineComponentFrameRoot(),o=a[0],s=a[1];if(o&&s){var c=o.split(`
|
|
@@ -213,8 +213,8 @@ These keys would previously have been stripped silently at build, shipping dead
|
|
|
213
213
|
${i.join(`
|
|
214
214
|
`)}
|
|
215
215
|
|
|
216
|
-
Remove the unknown key(s), fix the typo, or move the logic to a supported mechanism.`)}function X4t(e){if(!e||typeof e!=`object`||Array.isArray(e))return e;let t=e;return t.nameField==null&&typeof t.displayNameField==`string`?{...t,nameField:t.displayNameField}:e}function Z4t(e){if(!e||typeof e!=`object`||Array.isArray(e))return e;let t=e,n=t;if(Array.isArray(t.fieldGroups)){let e=!1,r=t.fieldGroups.map(t=>{if(!t||typeof t!=`object`||Array.isArray(t))return t;let n=t;if(n.collapse!=null)return t;let r;return typeof n.collapsible==`boolean`||typeof n.collapsed==`boolean`?r=n.collapsed===!0?`collapsed`:n.collapsible===!0?`expanded`:`none`:typeof n.defaultExpanded==`boolean`&&(r=n.defaultExpanded?`expanded`:`collapsed`),r===void 0?t:(e=!0,{...n,collapse:r})});e&&(n={...n,fieldGroups:r})}return n}$(()=>{let e=j9.parse.bind(j9),t=j9.safeParse.bind(j9);return Object.assign(j9,{parse(t,n){return e(Z4t(X4t(t)),n)},safeParse(e,n){return t(Z4t(X4t(e)),n)},create:e=>{let t=e,n=Object.keys(j9.shape),r=Object.keys(t).filter(e=>!n.includes(e));if(r.length>0)throw Y4t(t.name,r,n);let i={...t,label:t.label??G4t(t.name)};return j9.parse(i)}})}),W([`own`,`extend`]),$(()=>V({extend:I().describe(`Target object name (FQN) to extend`),fields:U(I(),y2t).optional().describe(`Fields to add/override`),label:I().optional().describe(`Override label for the extended object`),pluralLabel:I().optional().describe(`Override plural label for the extended object`),description:I().optional().describe(`Override description for the extended object`),validations:B(x9).optional().describe(`Additional validation rules to merge into the target object`),indexes:B(M4t).optional().describe(`Additional indexes to merge into the target object`),priority:L().int().min(0).max(999).default(200).describe(`Merge priority (higher = applied later)`)}));var Q4t=W([`beforeFind`,`afterFind`,`beforeFindOne`,`afterFindOne`,`beforeCount`,`afterCount`,`beforeAggregate`,`afterAggregate`,`beforeInsert`,`afterInsert`,`beforeUpdate`,`afterUpdate`,`beforeDelete`,`afterDelete`,`beforeUpdateMany`,`afterUpdateMany`,`beforeDeleteMany`,`afterDeleteMany`]);$(()=>V({name:I().regex(/^[a-z_][a-z0-9_]*$/).describe(`Hook unique name (snake_case)`),label:I().optional().describe(`Description of what this hook does`),object:H([I(),B(I())]).describe(`Target object(s)`),events:B(Q4t).describe(`Lifecycle events`),handler:H([I(),Al(e=>typeof e==`function`,{message:`Expected function`})]).optional().describe("Handler function name (string, post-build) or inline function (pre-build) — DEPRECATED, prefer `body`"),body:k2t.optional().describe(`Hook body — expression (L1) or sandboxed JS (L2)`),priority:L().default(100).describe(`Execution priority`),async:R().default(!1).describe(`Run specifically as fire-and-forget`),condition:v9.optional().describe('Predicate (CEL); hook runs only when TRUE. e.g. P`record.status == "closed" && record.amount > 1000`'),description:I().optional().describe(`Human-readable description of what this hook does`),retryPolicy:V({maxRetries:L().default(3).describe(`Maximum retry attempts on failure`),backoffMs:L().default(1e3).describe(`Backoff delay between retries in milliseconds`)}).optional().describe(`Retry policy for failed hook executions`),timeout:L().optional().describe(`Maximum execution time in milliseconds before the hook is aborted`),onError:W([`abort`,`log`]).default(`abort`).describe(`Error handling strategy`)})),$(()=>V({id:I().optional().describe(`Unique execution ID for tracing`),object:I(),event:Q4t,input:U(I(),z()).describe(`Mutable input parameters`),result:z().optional().describe(`Operation result (After hooks only)`),previous:U(I(),z()).optional().describe(`Record state before operation`),session:V({userId:I().optional(),tenantId:I().optional(),roles:B(I()).optional(),accessToken:I().optional(),isSystem:R().optional().describe(`True when the call was made with an elevated system context (engine self-writes)`),skipTriggers:R().optional().describe(`True when record-change automation (flow triggers) must be suppressed for this write — e.g. package seed replay. Lifecycle hooks still run.`)}).optional().describe(`Current session context`),transaction:z().optional().describe(`Database transaction handle`),ql:z().describe(`ObjectQL Engine Reference`),api:z().optional().describe(`Cross-object data access (ScopedContext)`),user:V({id:I().optional(),name:I().optional(),email:I().optional()}).optional().describe(`Current user info shortcut`)}));var $4t=W([`none`,`constant`,`lookup`,`split`,`join`,`javascript`,`map`]),e3t=$(()=>V({source:H([I(),B(I())]).describe(`Source column header(s)`),target:H([I(),B(I())]).describe(`Target object field(s)`),transform:$4t.default(`none`),params:V({value:z().optional(),object:I().optional(),fromField:I().optional(),toField:I().optional(),autoCreate:R().optional(),valueMap:U(I(),z()).optional(),separator:I().optional()}).optional()}));$(()=>V({name:g9.describe(`Mapping unique name (lowercase snake_case)`),label:I().optional(),sourceFormat:W([`csv`,`json`,`xml`,`sql`]).default(`csv`),targetObject:I().describe(`Target Object Name`),fieldMapping:B(e3t),mode:W([`insert`,`update`,`upsert`]).default(`insert`),upsertKey:B(I()).optional().describe(`Fields to match for upsert (e.g. email)`),extractQuery:h9.optional().describe(`Query to run for export only`),errorPolicy:W([`skip`,`abort`,`retry`]).default(`skip`),batchSize:L().default(1e3)}));var t3t=$(()=>V({userId:I().optional(),actor:I().optional(),email:I().optional(),tenantId:I().optional(),timezone:I().optional(),locale:I().optional(),currency:I().optional(),positions:B(I()).default([]),principalKind:W([`human`,`agent`,`service`,`guest`,`system`]).optional(),audience:W([`internal`,`external`]).optional(),onBehalfOf:V({userId:I(),principalKind:W([`human`,`agent`,`service`,`guest`,`system`]).optional()}).optional(),permissions:B(I()).default([]),systemPermissions:B(I()).optional(),tabPermissions:U(I(),W([`visible`,`hidden`,`default_on`,`default_off`])).optional(),org_user_ids:B(I()).optional(),rlsMembership:U(I(),B(I())).optional(),isSystem:R().default(!1),skipTriggers:R().optional(),oauthScopes:B(I()).optional(),accessToken:I().optional(),transaction:z().optional(),traceId:I().optional()})),M9=$(()=>H([U(I(),z()),d9]).describe(`Data Engine query filter conditions`)),n3t=$(()=>H([U(I(),W([`asc`,`desc`])),U(I(),H([rl(1),rl(-1)])),B(p9)]).describe(`Sort order definition`)),N9=$(()=>V({context:t3t.optional()})),P9=$(()=>N9.extend({where:H([U(I(),z()),d9]).optional(),fields:B(m9).optional(),orderBy:B(p9).optional(),limit:L().optional(),offset:L().optional(),top:L().optional(),cursor:U(I(),z()).optional(),search:t2t.optional(),expand:wl(()=>U(I(),h9)).optional(),distinct:R().optional()}).describe(`QueryAST-aligned query options for IDataEngine.find() operations`));$(()=>N9.extend({filter:M9.optional(),select:B(I()).optional(),sort:n3t.optional(),limit:L().int().min(1).optional(),skip:L().int().min(0).optional(),top:L().int().min(1).optional(),populate:B(I()).optional()}).describe(`Query options for IDataEngine.find() operations`));var r3t=$(()=>N9.extend({returning:R().default(!0).optional()}).describe(`Options for DataEngine.insert operations`)),i3t=$(()=>N9.extend({where:H([U(I(),z()),d9]).optional(),upsert:R().default(!1).optional(),multi:R().default(!1).optional(),returning:R().default(!1).optional()}).describe(`QueryAST-aligned options for DataEngine.update operations`));$(()=>N9.extend({filter:M9.optional(),upsert:R().default(!1).optional(),multi:R().default(!1).optional(),returning:R().default(!1).optional()}).describe(`Options for DataEngine.update operations`));var a3t=$(()=>N9.extend({where:H([U(I(),z()),d9]).optional(),multi:R().default(!1).optional()}).describe(`QueryAST-aligned options for DataEngine.delete operations`));$(()=>N9.extend({filter:M9.optional(),multi:R().default(!1).optional()}).describe(`Options for DataEngine.delete operations`));var o3t=$(()=>N9.extend({where:H([U(I(),z()),d9]).optional(),groupBy:B(I()).optional(),aggregations:B(J0t).optional(),timezone:I().optional()}).describe(`QueryAST-aligned options for DataEngine.aggregate operations`));$(()=>N9.extend({filter:M9.optional(),groupBy:B(I()).optional(),aggregations:B(V({field:I(),method:W([`count`,`sum`,`avg`,`min`,`max`,`count_distinct`]),alias:I().optional()})).optional()}).describe(`Options for DataEngine.aggregate operations`));var s3t=$(()=>N9.extend({where:H([U(I(),z()),d9]).optional()}).describe(`QueryAST-aligned options for DataEngine.count operations`));$(()=>N9.extend({filter:M9.optional()}).describe(`Options for DataEngine.count operations`)),$(()=>V({find:Ol().input($c([I(),P9.optional()])).output(El(B(z()))),findOne:Ol().input($c([I(),P9.optional()])).output(El(z())),insert:Ol().input($c([I(),H([U(I(),z()),B(U(I(),z()))]),r3t.optional()])).output(El(z())),update:Ol().input($c([I(),U(I(),z()),i3t.optional()])).output(El(z())),delete:Ol().input($c([I(),a3t.optional()])).output(El(z())),count:Ol().input($c([I(),s3t.optional()])).output(El(L())),aggregate:Ol().input($c([I(),o3t])).output(El(B(z())))}).describe(`Standard Data Engine Contract`));var F9={filter:M9.optional()},c3t=P9.extend({...F9,select:B(I()).optional(),sort:n3t.optional(),skip:L().int().min(0).optional(),populate:B(I()).optional()}),l3t=$(()=>V({method:rl(`find`),object:I(),query:c3t.optional()})),u3t=$(()=>V({method:rl(`findOne`),object:I(),query:c3t.optional()})),d3t=$(()=>V({method:rl(`insert`),object:I(),data:H([U(I(),z()),B(U(I(),z()))]),options:r3t.optional()})),f3t=$(()=>V({method:rl(`update`),object:I(),data:U(I(),z()),id:H([I(),L()]).optional().describe(`ID for single update, or use where in options`),options:i3t.extend(F9).optional()})),p3t=$(()=>V({method:rl(`delete`),object:I(),id:H([I(),L()]).optional().describe(`ID for single delete, or use where in options`),options:a3t.extend(F9).optional()})),m3t=$(()=>V({method:rl(`count`),object:I(),query:s3t.extend(F9).optional()})),h3t=$(()=>V({method:rl(`aggregate`),object:I(),query:o3t.extend(F9)})),g3t=$(()=>V({method:rl(`execute`),command:z(),options:U(I(),z()).optional()})),_3t=$(()=>V({method:rl(`vectorFind`),object:I(),vector:B(L()),where:H([U(I(),z()),d9]).optional(),fields:B(I()).optional(),limit:L().int().default(5).optional(),threshold:L().optional()})),v3t=$(()=>V({method:rl(`batch`),requests:B(Yc(`method`,[l3t,u3t,d3t,f3t,p3t,m3t,h3t,g3t,_3t])),transaction:R().default(!0).optional()}));$(()=>Yc(`method`,[l3t,u3t,d3t,f3t,p3t,m3t,h3t,v3t,g3t,_3t]).describe(`Virtual ObjectQL Request Protocol`)),W([`count`,`sum`,`avg`,`min`,`max`,`count_distinct`,`percentile`,`median`,`stddev`,`variance`]).describe(`Standard aggregation functions`);var y3t=W([`asc`,`desc`]).describe(`Sort order direction`);$(()=>V({field:I().describe(`Field name to sort by`),order:y3t.describe(`Sort direction`)}).describe(`Sort field and direction pair`)),W([`insert`,`update`,`delete`,`upsert`]).describe(`Data mutation event types`);var b3t=W([`read_uncommitted`,`read_committed`,`repeatable_read`,`serializable`,`snapshot`]).describe(`Transaction isolation levels (snake_case standard)`);W([`lru`,`lfu`,`ttl`,`fifo`]).describe(`Cache eviction strategy`);var I9=$(()=>V({transaction:z().optional().describe(`Transaction handle`),timeout:L().optional().describe(`Timeout in ms`),skipCache:R().optional().describe(`Bypass cache`),traceContext:U(I(),I()).optional().describe(`OpenTelemetry context or request ID`),tenantId:I().optional().describe(`Tenant Isolation identifier`),timezone:I().optional().describe(`Business reference timezone (IANA) for date-dependent generation, e.g. autonumber date tokens`)})),x3t=$(()=>V({create:R().default(!0).describe(`Supports CREATE operations`),read:R().default(!0).describe(`Supports READ operations`),update:R().default(!0).describe(`Supports UPDATE operations`),delete:R().default(!0).describe(`Supports DELETE operations`),bulkCreate:R().default(!1).describe(`Supports bulk CREATE operations`),bulkUpdate:R().default(!1).describe(`Supports bulk UPDATE operations`),bulkDelete:R().default(!1).describe(`Supports bulk DELETE operations`),transactions:R().default(!1).describe(`Supports ACID transactions`),savepoints:R().default(!1).describe(`Supports transaction savepoints`),isolationLevels:B(b3t).optional().describe(`Supported isolation levels`),queryFilters:R().default(!0).describe(`Supports WHERE clause filtering`),queryAggregations:R().default(!1).describe(`Supports GROUP BY and aggregation functions`),queryDateGranularity:U(K0t,R()).optional().describe(`Per-granularity native date bucketing (day/week/month/quarter/year). Missing keys fall back to in-memory bucketing.`),querySorting:R().default(!0).describe(`Supports ORDER BY sorting`),queryPagination:R().default(!0).describe(`Supports LIMIT/OFFSET pagination`),queryWindowFunctions:R().default(!1).describe(`Supports window functions with OVER clause`),querySubqueries:R().default(!1).describe(`Supports subqueries`),queryCTE:R().default(!1).describe(`Supports Common Table Expressions (WITH clause)`),joins:R().default(!1).describe(`Supports SQL joins`),fullTextSearch:R().default(!1).describe(`Supports full-text search`),jsonQuery:R().default(!1).describe(`Supports JSON field querying`),geospatialQuery:R().default(!1).describe(`Supports geospatial queries`),streaming:R().default(!1).describe(`Supports result streaming (cursors/iterators)`),jsonFields:R().default(!1).describe(`Supports JSON field types`),arrayFields:R().default(!1).describe(`Supports array field types`),vectorSearch:R().default(!1).describe(`Supports vector embeddings and similarity search`),autonumber:R().optional().describe(`Driver natively generates persistent autonumber/sequence values`),schemaSync:R().default(!1).describe(`Supports automatic schema synchronization`),batchSchemaSync:R().default(!1).describe(`Supports batched schema sync to reduce schema DDL round-trips`),migrations:R().default(!1).describe(`Supports database migrations`),indexes:R().default(!1).describe(`Supports index creation and management`),connectionPooling:R().default(!1).describe(`Supports connection pooling`),preparedStatements:R().default(!1).describe(`Supports prepared statements (SQL injection prevention)`),queryCache:R().default(!1).describe(`Supports query result caching`)}));$(()=>V({name:I().describe(`Driver unique name`),version:I().describe(`Driver version`),supports:x3t,connect:Ol().input($c([])).output(El(Uc())).describe(`Establish connection`),disconnect:Ol().input($c([])).output(El(Uc())).describe(`Close connection`),checkHealth:Ol().input($c([])).output(El(R())).describe(`Health check`),getPoolStats:Ol().input($c([])).output(V({total:L(),idle:L(),active:L(),waiting:L()}).optional()).optional().describe(`Get connection pool statistics`),execute:Ol().input($c([z(),B(z()).optional(),I9.optional()])).output(El(z())).describe(`Execute raw command`),find:Ol().input($c([I(),h9,I9.optional()])).output(El(B(U(I(),z())))).describe(`Find records`),findStream:Ol().input($c([I(),h9,I9.optional()])).output(z()).describe(`Stream records (AsyncIterable)`),findOne:Ol().input($c([I(),h9,I9.optional()])).output(El(U(I(),z()).nullable())).describe(`Find one record`),create:Ol().input($c([I(),U(I(),z()),I9.optional()])).output(El(U(I(),z()))).describe(`Create record`),update:Ol().input($c([I(),I().or(L()),U(I(),z()),I9.optional()])).output(El(U(I(),z()))).describe(`Update record`),upsert:Ol().input($c([I(),U(I(),z()),B(I()).optional(),I9.optional()])).output(El(U(I(),z()))).describe(`Upsert record`),delete:Ol().input($c([I(),I().or(L()),I9.optional()])).output(El(R())).describe(`Delete record`),count:Ol().input($c([I(),h9.optional(),I9.optional()])).output(El(L())).describe(`Count records`),bulkCreate:Ol().input($c([I(),B(U(I(),z())),I9.optional()])).output(El(B(U(I(),z())))),bulkUpdate:Ol().input($c([I(),B(V({id:I().or(L()),data:U(I(),z())})),I9.optional()])).output(El(B(U(I(),z())))),bulkDelete:Ol().input($c([I(),B(I().or(L())),I9.optional()])).output(El(Uc())),updateMany:Ol().input($c([I(),h9,U(I(),z()),I9.optional()])).output(El(L())).optional(),deleteMany:Ol().input($c([I(),h9,I9.optional()])).output(El(L())).optional(),beginTransaction:Ol().input($c([V({isolationLevel:b3t.optional()}).optional()])).output(El(z())).describe(`Start transaction`),commit:Ol().input($c([z()])).output(El(Uc())).describe(`Commit transaction`),rollback:Ol().input($c([z()])).output(El(Uc())).describe(`Rollback transaction`),syncSchema:Ol().input($c([I(),z(),I9.optional()])).output(El(Uc())).describe(`Sync object schema to DB`),syncSchemasBatch:Ol().input($c([B(V({object:I(),schema:z()})),I9.optional()])).output(El(Uc())).optional().describe(`Batch sync multiple schemas in one round-trip`),dropTable:Ol().input($c([I(),I9.optional()])).output(El(Uc())),explain:Ol().input($c([I(),h9,I9.optional()])).output(El(z())).optional()}));var S3t=$(()=>V({min:L().min(0).default(2).describe(`Minimum number of connections in pool`),max:L().min(1).default(10).describe(`Maximum number of connections in pool`),idleTimeoutMillis:L().min(0).default(3e4).describe(`Time in ms before idle connection is closed`),connectionTimeoutMillis:L().min(0).default(5e3).describe(`Time in ms to wait for available connection`)})),C3t=$(()=>V({name:I().describe(`Driver instance name`),type:W([`sql`,`nosql`,`cache`,`search`,`graph`,`timeseries`]).describe(`Driver type category`),capabilities:x3t.describe(`Driver capability flags`),connectionString:I().optional().describe(`Database connection string (driver-specific format)`),poolConfig:S3t.optional().describe(`Connection pool configuration`)})),w3t=$(()=>W([`postgresql`,`mysql`,`sqlite`,`mssql`,`oracle`,`mariadb`])),T3t=$(()=>V({text:I().describe(`SQL type for text fields (e.g., VARCHAR, TEXT)`),number:I().describe(`SQL type for number fields (e.g., NUMERIC, DECIMAL, INT)`),boolean:I().describe(`SQL type for boolean fields (e.g., BOOLEAN, BIT)`),date:I().describe(`SQL type for date fields (e.g., DATE)`),datetime:I().describe(`SQL type for datetime fields (e.g., TIMESTAMP, DATETIME)`),json:I().optional().describe(`SQL type for JSON fields (e.g., JSON, JSONB)`),uuid:I().optional().describe(`SQL type for UUID fields (e.g., UUID, CHAR(36))`),binary:I().optional().describe(`SQL type for binary fields (e.g., BLOB, BYTEA)`)})),E3t=$(()=>V({rejectUnauthorized:R().default(!0).describe(`Reject connections with invalid certificates`),ca:I().optional().describe(`CA certificate file path or content`),cert:I().optional().describe(`Client certificate file path or content`),key:I().optional().describe(`Client private key file path or content`)}).refine(e=>e.cert!==void 0==(e.key!==void 0),{message:`Client certificate (cert) and private key (key) must be provided together`}));$(()=>C3t.extend({type:rl(`sql`).describe(`Driver type must be "sql"`),dialect:w3t.describe(`SQL database dialect`),dataTypeMapping:T3t.describe(`SQL data type mapping configuration`),ssl:R().default(!1).describe(`Enable SSL/TLS connection`),sslConfig:E3t.optional().describe(`SSL/TLS configuration (required when ssl is true)`)}).refine(e=>!(e.ssl&&!e.sslConfig),{message:`sslConfig is required when ssl is true`}));var D3t=$(()=>W([`mongodb`,`couchdb`,`dynamodb`,`cassandra`,`redis`,`elasticsearch`,`neo4j`,`orientdb`]));$(()=>W([`find`,`findOne`,`insert`,`update`,`delete`,`aggregate`,`mapReduce`,`count`,`distinct`,`createIndex`,`dropIndex`]));var O3t=$(()=>W([`all`,`quorum`,`one`,`local_quorum`,`each_quorum`,`eventual`])),k3t=$(()=>W([`single`,`compound`,`unique`,`text`,`geospatial`,`hashed`,`ttl`,`sparse`])),A3t=$(()=>V({enabled:R().default(!1).describe(`Enable sharding`),shardKey:I().optional().describe(`Field to use as shard key`),shardingStrategy:W([`hash`,`range`,`zone`]).optional().describe(`Sharding strategy`),numShards:L().int().positive().optional().describe(`Number of shards`)})),j3t=$(()=>V({enabled:R().default(!1).describe(`Enable replication`),replicaSetName:I().optional().describe(`Replica set name`),replicas:L().int().positive().optional().describe(`Number of replicas`),readPreference:W([`primary`,`primaryPreferred`,`secondary`,`secondaryPreferred`,`nearest`]).optional().describe(`Read preference for replica set`),writeConcern:W([`majority`,`acknowledged`,`unacknowledged`]).optional().describe(`Write concern level`)})),M3t=$(()=>V({enabled:R().default(!1).describe(`Enable schema validation`),validationLevel:W([`strict`,`moderate`,`off`]).optional().describe(`Validation strictness`),validationAction:W([`error`,`warn`]).optional().describe(`Action on validation failure`),jsonSchema:U(I(),z()).optional().describe(`JSON Schema for validation`)})),N3t=$(()=>V({text:I().describe(`NoSQL type for text fields`),number:I().describe(`NoSQL type for number fields`),boolean:I().describe(`NoSQL type for boolean fields`),date:I().describe(`NoSQL type for date fields`),datetime:I().describe(`NoSQL type for datetime fields`),json:I().optional().describe(`NoSQL type for JSON/object fields`),uuid:I().optional().describe(`NoSQL type for UUID fields`),binary:I().optional().describe(`NoSQL type for binary fields`),array:I().optional().describe(`NoSQL type for array fields`),objectId:I().optional().describe(`NoSQL type for ObjectID fields (MongoDB)`),geopoint:I().optional().describe(`NoSQL type for geospatial point fields`)}));$(()=>C3t.extend({type:rl(`nosql`).describe(`Driver type must be "nosql"`),databaseType:D3t.describe(`Specific NoSQL database type`),dataTypeMapping:N3t.describe(`NoSQL data type mapping configuration`),consistency:O3t.optional().describe(`Consistency level for operations`),replication:j3t.optional().describe(`Replication configuration`),sharding:A3t.optional().describe(`Sharding configuration`),schemaValidation:M3t.optional().describe(`Document schema validation`),region:I().optional().describe(`AWS region (for managed NoSQL services)`),accessKeyId:I().optional().describe(`AWS access key ID`),secretAccessKey:I().optional().describe(`AWS secret access key`),ttlField:I().optional().describe(`Field name for TTL (auto-deletion)`),maxDocumentSize:L().int().positive().optional().describe(`Maximum document size in bytes`),collectionPrefix:I().optional().describe(`Prefix for collection/table names`)}));var P3t=$(()=>V({consistency:O3t.optional().describe(`Consistency level override`),readFromSecondary:R().optional().describe(`Allow reading from secondary replicas`),projection:U(I(),H([rl(0),rl(1)])).optional().describe(`Field projection`),timeout:L().int().positive().optional().describe(`Query timeout (ms)`),useCursor:R().optional().describe(`Use cursor instead of loading all results`),batchSize:L().int().positive().optional().describe(`Cursor batch size`),profile:R().optional().describe(`Enable query profiling`),hint:I().optional().describe(`Index hint for query optimization`)})),F3t=$(()=>V({operator:I().describe(`Aggregation operator (e.g., $match, $group, $sort)`),options:U(I(),z()).describe(`Stage-specific options`)}));$(()=>V({collection:I().describe(`Collection/table name`),stages:B(F3t).describe(`Aggregation pipeline stages`),options:P3t.optional().describe(`Query options`)})),$(()=>V({name:I().describe(`Index name`),type:k3t.describe(`Index type`),fields:B(V({field:I().describe(`Field name`),order:W([`asc`,`desc`,`text`,`2dsphere`]).optional().describe(`Index order or type`)})).describe(`Fields to index`),unique:R().default(!1).describe(`Enforce uniqueness`),sparse:R().default(!1).describe(`Sparse index`),expireAfterSeconds:L().int().positive().optional().describe(`TTL in seconds`),partialFilterExpression:U(I(),z()).optional().describe(`Partial index filter`),background:R().default(!1).describe(`Create index in background`)})),$(()=>V({readConcern:W([`local`,`majority`,`linearizable`,`snapshot`]).optional().describe(`Read concern level`),writeConcern:W([`majority`,`acknowledged`,`unacknowledged`]).optional().describe(`Write concern level`),readPreference:W([`primary`,`primaryPreferred`,`secondary`,`secondaryPreferred`,`nearest`]).optional().describe(`Read preference`),maxCommitTimeMS:L().int().positive().optional().describe(`Transaction commit timeout (ms)`)}));var L9=W([`insert`,`update`,`upsert`,`replace`,`ignore`]),I3t=$(()=>V({object:I().regex(/^[a-z_][a-z0-9_]*$/).describe(`Target Object Name`),externalId:I().default(`name`).describe(`Field match for uniqueness check`),mode:L9.default(`upsert`).describe(`Conflict resolution strategy`),env:B(W([`prod`,`dev`,`test`])).default([`prod`,`dev`,`test`]).describe(`Applicable environments`),records:B(U(I(),z())).describe(`Data records`)}));k9({schemaId:`object`,type:`simple`,sections:[{name:`basics`,label:`Basics`,description:`Identity, labels, and taxonomy.`,columns:2,fields:[{field:`name`,type:`text`,required:!0,immutable:!0,colSpan:1,helpText:`snake_case unique identifier (immutable after creation)`},{field:`label`,type:`text`,colSpan:1,helpText:`Singular display name (e.g. "Account")`},{field:`pluralLabel`,type:`text`,colSpan:1,helpText:`Plural display name (e.g. "Accounts")`},{field:`icon`,type:`text`,colSpan:1,helpText:`Lucide icon name (e.g. "building", "users")`},{field:`description`,type:`textarea`,colSpan:2,helpText:`Developer documentation`},{field:`tags`,type:`tags`,colSpan:2,helpText:`Categorization tags (e.g. "sales", "system")`},{field:`active`,type:`boolean`,colSpan:1,helpText:`Is the object active and usable`},{field:`isSystem`,type:`boolean`,colSpan:1,helpText:`System object (protected from deletion)`},{field:`abstract`,type:`boolean`,colSpan:1,helpText:`Abstract base (cannot be instantiated)`}]},{name:`fields`,label:`Fields`,description:`Define the data model — each entry becomes a column in the database table.`,fields:[{field:`fields`,type:`record`,required:!0,helpText:`Add the columns this object will store`,keyField:{field:`name`,label:`Name`,placeholder:`snake_case_identifier`,helpText:`snake_case machine name (used as column name and API key)`,regex:`^[a-z_][a-z0-9_]*$`,immutable:!0},fields:[{field:`label`,type:`text`,helpText:`Display label`},{field:`type`,type:`select`,required:!0,helpText:`Field type`,options:[{label:`Text`,value:`text`},{label:`Textarea`,value:`textarea`},{label:`Email`,value:`email`},{label:`URL`,value:`url`},{label:`Phone`,value:`phone`},{label:`Password`,value:`password`},{label:`Markdown`,value:`markdown`},{label:`HTML`,value:`html`},{label:`Rich Text`,value:`richtext`},{label:`Number`,value:`number`},{label:`Currency`,value:`currency`},{label:`Percent`,value:`percent`},{label:`Date`,value:`date`},{label:`Date & Time`,value:`datetime`},{label:`Time`,value:`time`},{label:`Boolean`,value:`boolean`},{label:`Toggle`,value:`toggle`},{label:`Select`,value:`select`},{label:`Multiselect`,value:`multiselect`},{label:`Radio`,value:`radio`},{label:`Checkboxes`,value:`checkboxes`},{label:`Lookup (reference)`,value:`lookup`},{label:`Master–Detail`,value:`master_detail`},{label:`Tree`,value:`tree`},{label:`Image`,value:`image`},{label:`File`,value:`file`},{label:`Avatar`,value:`avatar`},{label:`Video`,value:`video`},{label:`Audio`,value:`audio`},{label:`Formula (computed)`,value:`formula`},{label:`Summary (rollup)`,value:`summary`},{label:`Autonumber`,value:`autonumber`},{label:`Composite (embedded)`,value:`composite`},{label:`Repeater (embedded array)`,value:`repeater`},{label:`Record (keyed map)`,value:`record`},{label:`Location (GPS)`,value:`location`},{label:`Address`,value:`address`},{label:`Code`,value:`code`},{label:`JSON`,value:`json`},{label:`Color`,value:`color`},{label:`Rating`,value:`rating`},{label:`Slider`,value:`slider`},{label:`Signature`,value:`signature`},{label:`QR / Barcode`,value:`qrcode`},{label:`Progress`,value:`progress`},{label:`Tags`,value:`tags`},{label:`Vector embedding`,value:`vector`}]},{field:`description`,type:`textarea`,helpText:`Developer documentation for this column`},{field:`required`,type:`boolean`,helpText:`Must be set on every record`},{field:`unique`,type:`boolean`,helpText:`Disallow duplicate values`},{field:`indexed`,type:`boolean`,helpText:`Create a database index for faster querying`},{field:`readonly`,type:`boolean`,helpText:`Visible but never user-editable`},{field:`immutable`,type:`boolean`,helpText:`Editable on create, locked thereafter`},{field:`hidden`,type:`boolean`,helpText:`Hidden from default UI`},{field:`searchable`,type:`boolean`,helpText:`Include in full-text search`},{field:`sortable`,type:`boolean`,helpText:`Allow sorting on this column`},{field:`filterable`,type:`boolean`,helpText:`Allow filtering on this column`},{field:`defaultValue`,type:`text`,helpText:`Default value for new records (JSON literal)`},{field:`placeholder`,type:`text`,helpText:`Placeholder hint`},{field:`maxLength`,type:`number`,helpText:`Max characters`,visibleOn:`type in ['text','textarea','email','url','phone','password','markdown','html','richtext']`},{field:`minLength`,type:`number`,helpText:`Min characters`,visibleOn:`type in ['text','textarea','email','url','phone','password','markdown','html','richtext']`},{field:`min`,type:`number`,helpText:`Minimum value`,visibleOn:`type in ['number','currency','percent','rating','slider','progress']`},{field:`max`,type:`number`,helpText:`Maximum value`,visibleOn:`type in ['number','currency','percent','rating','slider','progress']`},{field:`precision`,type:`number`,helpText:`Total digits`,visibleOn:`type in ['number','currency','percent']`},{field:`scale`,type:`number`,helpText:`Decimal places`,visibleOn:`type in ['number','currency','percent']`},{field:`options`,type:`repeater`,helpText:`Available choices`,visibleOn:`type in ['select','multiselect','radio','checkboxes']`,fields:[{field:`label`,type:`text`,required:!0},{field:`value`,type:`text`,required:!0},{field:`color`,type:`color`},{field:`icon`,type:`text`,helpText:`Lucide icon name`},{field:`description`,type:`text`}]},{field:`reference`,type:`text`,helpText:`Target object name`,visibleOn:`type in ['lookup','master_detail','tree']`},{field:`referenceFilter`,type:`code`,language:`expression`,helpText:`CEL filter applied to the picker`,visibleOn:`type in ['lookup','master_detail']`},{field:`cascadeDelete`,type:`boolean`,helpText:`Delete children when parent is deleted`,visibleOn:`type == 'master_detail'`},{field:`multiple`,type:`boolean`,helpText:`Allow selecting multiple records`,visibleOn:`type in ['lookup']`},{field:`formula`,type:`code`,language:`expression`,helpText:`CEL formula expression`,visibleOn:`type == 'formula'`},{field:`returnType`,type:`select`,helpText:`Result type for formulas`,visibleOn:`type == 'formula'`,options:[{label:`Text`,value:`text`},{label:`Number`,value:`number`},{label:`Boolean`,value:`boolean`},{label:`Date`,value:`date`},{label:`Datetime`,value:`datetime`},{label:`Currency`,value:`currency`}]},{field:`summaryType`,type:`select`,helpText:`Aggregation`,visibleOn:`type == 'summary'`,options:[{label:`Count`,value:`count`},{label:`Sum`,value:`sum`},{label:`Avg`,value:`avg`},{label:`Min`,value:`min`},{label:`Max`,value:`max`}]},{field:`summaryField`,type:`text`,helpText:`Field on child object to aggregate`,visibleOn:`type == 'summary'`},{field:`displayFormat`,type:`text`,helpText:`e.g. "INV-{0000}"`,visibleOn:`type == 'autonumber'`},{field:`startingNumber`,type:`number`,helpText:`Starting sequence value`,visibleOn:`type == 'autonumber'`},{field:`language`,type:`text`,helpText:`Editor language (e.g. sql, javascript)`,visibleOn:`type == 'code'`},{field:`validation`,type:`code`,language:`expression`,helpText:`CEL predicate — must evaluate true`},{field:`errorMessage`,type:`text`,helpText:`Shown when validation fails`},{field:`audit`,type:`boolean`,helpText:`Audit changes to this field`},{field:`trackHistory`,type:`boolean`,helpText:`Keep change history`},{field:`pii`,type:`boolean`,helpText:`Personally identifiable information`},{field:`encrypted`,type:`boolean`,helpText:`Encrypt at rest`}]}]},{name:`capabilities`,label:`Capabilities`,description:`System features and API exposure.`,collapsible:!0,collapsed:!0,fields:[{field:`capabilities`,type:`composite`,helpText:`Enable/disable system features`,fields:[{field:`trackHistory`,type:`boolean`},{field:`searchable`,type:`boolean`},{field:`apiEnabled`,type:`boolean`},{field:`files`,type:`boolean`},{field:`feeds`,type:`boolean`},{field:`activities`,type:`boolean`},{field:`trash`,type:`boolean`},{field:`mru`,type:`boolean`},{field:`clone`,type:`boolean`}]}]},{name:`advanced`,label:`Advanced`,description:`State machines, actions, and storage.`,collapsible:!0,collapsed:!0,fields:[{field:`datasource`,type:`text`,helpText:`Target datasource ID (default: "default")`},{field:`lifecycle`,type:`composite`,helpText:`Data lifecycle contract (ADR-0057): how long rows live and how space is reclaimed. Leave empty for permanent record semantics. Non-record classes require at least one bounding policy (retention, TTL, or rotation).`,fields:[{field:`class`,type:`select`,helpText:`Persistence contract for the rows of this object`,options:[{label:`Record (business truth — permanent)`,value:`record`},{label:`Audit (compliance ledger — retain → archive → delete)`,value:`audit`},{label:`Telemetry (high-frequency log — short retention)`,value:`telemetry`},{label:`Transient (ephemeral state — TTL expiry)`,value:`transient`},{label:`Event (bus messages — very short TTL)`,value:`event`}]},{field:`retention`,type:`composite`,helpText:`Age-based retention window`,fields:[{field:`maxAge`,type:`text`,helpText:`Rows older than this (by created_at) are reaped. Duration literal: h/d/w/y, e.g. "30d"`}]},{field:`ttl`,type:`composite`,helpText:`Per-row TTL expiry`,fields:[{field:`field`,type:`text`,helpText:`Timestamp field the TTL is measured from (e.g. expires_at)`},{field:`expireAfter`,type:`text`,helpText:`Rows expire this long after the field, e.g. "1d"`}]},{field:`storage`,type:`composite`,helpText:`Physical rotation for high-frequency telemetry (SQLite: O(1) shard DROP)`,fields:[{field:`strategy`,type:`select`,helpText:`Storage strategy`,options:[{label:`Rotation (time-shard + drop oldest)`,value:`rotation`}]},{field:`shards`,type:`number`,min:2,helpText:`Shards retained; total window = shards × unit`},{field:`unit`,type:`select`,helpText:`Time width of one shard`,options:[{label:`Day`,value:`day`},{label:`Week`,value:`week`},{label:`Month`,value:`month`}]}]},{field:`archive`,type:`composite`,helpText:`Cold-store hand-off (audit class). Rows are never hot-deleted before the archive copy succeeded.`,fields:[{field:`after`,type:`text`,helpText:`Archive rows older than this — must equal retention.maxAge`},{field:`to`,type:`text`,helpText:`Target datasource name for cold storage`},{field:`keep`,type:`text`,helpText:`How long the archive keeps rows (empty = forever), e.g. "7y"`}]},{field:`reclaim`,type:`boolean`,helpText:`Reclaim driver space after sweeps (default on for non-record classes)`}]}]}]}),k9({schemaId:`field`,type:`simple`,sections:[{name:`basics`,label:`Basics`,description:`Core field identity and constraints.`,columns:2,fields:[{field:`name`,required:!0,immutable:!0,colSpan:1,helpText:`Unique identifier (snake_case, immutable after creation)`},{field:`label`,required:!0,colSpan:1,helpText:`Display name for users`},{field:`type`,required:!0,colSpan:1,helpText:`Data type of this field`},{field:`group`,colSpan:1,helpText:`Group name for form layout`},{field:`description`,widget:`textarea`,colSpan:2,helpText:`Help text shown to users`},{field:`required`,colSpan:1,helpText:`User must provide a value`},{field:`unique`,colSpan:1,helpText:`No two records can have the same value`},{field:`multiple`,colSpan:1,helpText:`Allow multiple values (for select/lookup)`}]},{name:`configuration`,label:`Configuration`,description:`Field-type specific settings (visible blocks depend on the chosen type).`,fields:[{field:`defaultValue`,helpText:`Default value for new records`},{field:`minLength`,visibleOn:`data.type == 'text' || data.type == 'textarea' || data.type == 'email'`,helpText:`Minimum character length`},{field:`maxLength`,visibleOn:`data.type == 'text' || data.type == 'textarea' || data.type == 'email'`,helpText:`Maximum character length`},{field:`min`,visibleOn:`data.type == 'number' || data.type == 'currency'`,helpText:`Minimum value`},{field:`max`,visibleOn:`data.type == 'number' || data.type == 'currency'`,helpText:`Maximum value`},{field:`precision`,visibleOn:`data.type == 'currency' || data.type == 'number'`,helpText:`Decimal places (e.g., 2 for $10.50)`},{field:`scale`,visibleOn:`data.type == 'number'`,helpText:`Number of decimal digits`},{field:`options`,type:`repeater`,visibleOn:`data.type == 'select' || data.type == 'multiselect'`,helpText:`Available options (label/value pairs)`},{field:`reference`,widget:`ref:object`,visibleOn:`data.type == 'lookup' || data.type == 'master_detail'`,helpText:`Referenced object name`},{field:`referenceFilters`,widget:`string-tags`,visibleOn:`data.type == 'lookup' || data.type == 'master_detail'`,helpText:`Filter expressions (e.g., "active = true")`},{field:`deleteBehavior`,visibleOn:`data.type == 'lookup' || data.type == 'master_detail'`,helpText:`What happens when referenced record is deleted`}]},{name:`formula`,label:`Formula & Computed`,description:`Calculated values and roll-up summaries.`,collapsible:!0,collapsed:!0,fields:[{field:`expression`,widget:`textarea`,helpText:`CEL expression to calculate this field (makes it read-only)`},{field:`summaryOperations`,type:`composite`,helpText:`Roll-up summary configuration (for parent-child relationships)`}]},{name:`advanced`,label:`Advanced`,description:`Database, UI, audit, and security settings.`,collapsible:!0,collapsed:!0,columns:2,fields:[{field:`columnName`,colSpan:2,helpText:`Physical column name in database (defaults to field name)`},{field:`index`,colSpan:1,helpText:`Create database index for faster queries`},{field:`externalId`,colSpan:1,helpText:`Mark as external ID for upsert operations`},{field:`readonly`,colSpan:1,helpText:`Field is read-only in forms`},{field:`hidden`,colSpan:1,helpText:`Hide field from default UI views`},{field:`searchable`,colSpan:1,helpText:`Include in global search results`},{field:`sortable`,colSpan:1,helpText:`Allow sorting lists by this field`}]}]}),k9({schemaId:`hook`,type:`simple`,sections:[{label:`Identity`,description:`What this hook is and when it fires.`,columns:2,fields:[{field:`name`,type:`text`,required:!0,immutable:!0,colSpan:1,helpText:`snake_case identifier (immutable after creation)`},{field:`label`,type:`text`,colSpan:1},{field:`description`,type:`textarea`,colSpan:2},{field:`object`,type:`text`,required:!0,colSpan:1,helpText:`Target object name (or "*" for global)`},{field:`events`,type:`tags`,required:!0,colSpan:1,helpText:`Lifecycle events (e.g. beforeInsert, afterUpdate)`},{field:`priority`,type:`number`,colSpan:1,helpText:`Lower numbers run first`}]},{label:`Body`,description:`Inline expression or sandboxed JavaScript executed when the hook fires.`,fields:[{field:`body`,type:`composite`,helpText:`Either an L1 expression or an L2 sandboxed JS body`,fields:[{field:`language`,type:`select`,required:!0,helpText:`expression = pure formula; js = sandboxed JavaScript`,options:[{label:`Expression (L1)`,value:`expression`},{label:`JavaScript (L2 sandboxed)`,value:`js`}]},{field:`source`,type:`code`,language:`javascript`,required:!0,helpText:`Function body source — no top-level imports`},{field:`capabilities`,type:`tags`,helpText:`Allowed ctx APIs (api.read, api.write, crypto.uuid, log, …)`},{field:`timeoutMs`,type:`number`,helpText:`Per-invocation timeout (ms)`}]}]},{label:`Legacy handler`,description:`Function name reference — deprecated in favour of body.`,collapsible:!0,collapsed:!0,fields:[{field:`handler`,type:`text`,helpText:"Handler function name (deprecated — prefer `body`)"}]},{label:`Execution`,collapsible:!0,collapsed:!0,columns:2,fields:[{field:`async`,type:`boolean`,colSpan:1,helpText:`Run in background, do not block the transaction`},{field:`onError`,type:`select`,colSpan:1,options:[{label:`Abort`,value:`abort`},{label:`Log`,value:`log`}]},{field:`timeout`,type:`number`,colSpan:1,helpText:`Abort the hook after N milliseconds`},{field:`condition`,type:`code`,language:`javascript`,colSpan:2,helpText:`Optional formula — skip the hook when this evaluates to false`},{field:`retryPolicy`,type:`composite`,colSpan:2,helpText:`Retry on failure — most useful for async hooks`,fields:[{field:`maxRetries`,type:`number`,helpText:`Maximum retry attempts`},{field:`backoffMs`,type:`number`,helpText:`Delay between retries (ms)`}]}]}]});var L3t=$(()=>V({field:I().describe(`Source field name containing the reference value`),targetObject:I().regex(/^[a-z_][a-z0-9_]*$/).describe(`Target object name (snake_case)`),targetField:I().default(`name`).describe(`Field on target object used for matching`),fieldType:W([`lookup`,`master_detail`,`user`]).describe(`Relationship field type`)}).describe(`Describes how a field reference is resolved during seed loading`)),R3t=$(()=>V({object:I().regex(/^[a-z_][a-z0-9_]*$/).describe(`Object name (snake_case)`),dependsOn:B(I()).describe(`Objects this object depends on`),references:B(L3t).describe(`Field-level reference details`)}).describe(`Object node in the seed data dependency graph`)),z3t=$(()=>V({nodes:B(R3t).describe(`All objects in the dependency graph`),insertOrder:B(I()).describe(`Topologically sorted insert order`),circularDependencies:B(B(I())).default([]).describe(`Circular dependency chains (e.g., [["a", "b", "a"]])`)}).describe(`Complete object dependency graph for seed data loading`)),B3t=$(()=>V({sourceObject:I().describe(`Object with the broken reference`),field:I().describe(`Field name with unresolved reference`),targetObject:I().describe(`Target object searched for the reference`),targetField:I().describe(`ExternalId field used for matching`),attemptedValue:z().describe(`Value that failed to resolve`),recordIndex:L().int().min(0).describe(`Index of the record in the dataset`),message:I().describe(`Human-readable error description`)}).describe(`Actionable error for a failed reference resolution`)),V3t=V({user:V({id:I().min(1),role:I().optional(),email:I().optional()}).optional().describe(`Subject bound to os.user in seed CEL expressions`),org:V({id:I().min(1),tier:I().optional()}).optional().describe(`Organization bound to os.org in seed CEL expressions`)}).describe(`Identity context for resolving os.user / os.org in seed CEL values`),H3t=$(()=>V({dryRun:R().default(!1).describe(`Validate references without writing data`),haltOnError:R().default(!1).describe(`Stop on first reference resolution error`),multiPass:R().default(!0).describe(`Enable multi-pass loading for circular dependencies`),defaultMode:L9.default(`upsert`).describe(`Default conflict resolution strategy`),batchSize:L().int().min(1).default(1e3).describe(`Maximum records per batch insert/upsert`),transaction:R().default(!1).describe(`Wrap entire load in a transaction (all-or-nothing)`),env:W([`prod`,`dev`,`test`]).optional().describe(`Only load datasets matching this environment`),organizationId:I().min(1).optional().describe(`Target organization id for per-tenant seed replay`),identity:V3t.optional().describe(`Identity bound to os.user / os.org when resolving CEL seed values`)}).describe(`Seed data loader configuration`)),U3t=$(()=>V({object:I().describe(`Object that was loaded`),mode:L9.describe(`Import mode used`),inserted:L().int().min(0).describe(`Records inserted`),updated:L().int().min(0).describe(`Records updated`),skipped:L().int().min(0).describe(`Records skipped`),errored:L().int().min(0).describe(`Records with errors`),total:L().int().min(0).describe(`Total records in dataset`),referencesResolved:L().int().min(0).describe(`References resolved via externalId`),referencesDeferred:L().int().min(0).describe(`References deferred to second pass`),errors:B(B3t).default([]).describe(`Reference resolution errors`)}).describe(`Result of loading a single dataset`));$(()=>V({success:R().describe(`Overall success status`),dryRun:R().describe(`Whether this was a dry-run`),dependencyGraph:z3t.describe(`Object dependency graph`),results:B(U3t).describe(`Per-object load results`),errors:B(B3t).describe(`All reference resolution errors`),summary:V({objectsProcessed:L().int().min(0).describe(`Total objects processed`),totalRecords:L().int().min(0).describe(`Total records across all objects`),totalInserted:L().int().min(0).describe(`Total records inserted`),totalUpdated:L().int().min(0).describe(`Total records updated`),totalSkipped:L().int().min(0).describe(`Total records skipped`),totalErrored:L().int().min(0).describe(`Total records with errors`),totalReferencesResolved:L().int().min(0).describe(`Total references resolved`),totalReferencesDeferred:L().int().min(0).describe(`Total references deferred`),circularDependencyCount:L().int().min(0).describe(`Circular dependency chains detected`),durationMs:L().min(0).describe(`Load duration in milliseconds`)}).describe(`Summary statistics`)}).describe(`Complete seed loader result`)),$(()=>V({seeds:B(I3t).min(1).describe(`Seeds to load`),config:H3t.default(()=>H3t.parse({})).describe(`Loader configuration`)}).describe(`Seed loader request with datasets and configuration`));var W3t=$(()=>V({versionNumber:L().describe(`Version number`),createdAt:L().describe(`Creation timestamp`),createdBy:I().describe(`Creator user ID`),size:L().describe(`File size in bytes`),checksum:I().describe(`File checksum`),downloadUrl:I().url().describe(`Download URL`),isLatest:R().optional().default(!1).describe(`Is latest version`)})),G3t=$(()=>V({id:I().describe(`Template ID`),name:I().describe(`Template name`),description:I().optional().describe(`Template description`),fileUrl:I().url().describe(`Template file URL`),fileType:I().describe(`File MIME type`),placeholders:B(V({key:I().describe(`Placeholder key`),label:I().describe(`Placeholder label`),type:W([`text`,`number`,`date`,`image`]).describe(`Placeholder type`),required:R().optional().default(!1).describe(`Is required`)})).describe(`Template placeholders`)})),K3t=$(()=>V({provider:W([`docusign`,`adobe-sign`,`hellosign`,`custom`]).describe(`E-signature provider`),enabled:R().optional().default(!1).describe(`E-signature enabled`),signers:B(V({email:I().email().describe(`Signer email`),name:I().describe(`Signer name`),role:I().describe(`Signer role`),order:L().describe(`Signing order`)})).describe(`Document signers`),expirationDays:L().optional().default(30).describe(`Expiration days`),reminderDays:L().optional().default(7).describe(`Reminder interval days`)}));$(()=>V({id:I().describe(`Document ID`),name:I().describe(`Document name`),description:I().optional().describe(`Document description`),fileType:I().describe(`File MIME type`),fileSize:L().describe(`File size in bytes`),category:I().optional().describe(`Document category`),tags:B(I()).optional().describe(`Document tags`),versioning:V({enabled:R().describe(`Versioning enabled`),versions:B(W3t).describe(`Version history`),majorVersion:L().describe(`Major version`),minorVersion:L().describe(`Minor version`)}).optional().describe(`Version control`),template:G3t.optional().describe(`Document template`),eSignature:K3t.optional().describe(`E-signature config`),access:V({isPublic:R().optional().default(!1).describe(`Public access`),sharedWith:B(I()).optional().describe(`Shared with`),expiresAt:L().optional().describe(`Access expiration`)}).optional().describe(`Access control`),metadata:U(I(),z()).optional().describe(`Custom metadata`)}));var q3t=$(()=>Yc(`type`,[V({type:rl(`constant`),value:z().describe(`Constant value to use`)}).describe(`Set a constant value`),V({type:rl(`cast`),targetType:W([`string`,`number`,`boolean`,`date`]).describe(`Target data type`)}).describe(`Cast to a specific data type`),V({type:rl(`lookup`),table:I().describe(`Lookup table name`),keyField:I().describe(`Field to match on`),valueField:I().describe(`Field to retrieve`)}).describe(`Lookup value from another table`),V({type:rl(`javascript`),expression:v9.describe(`JS expression (dialect="js" recommended). e.g. value.toUpperCase()`)}).describe(`Custom JavaScript transformation`),V({type:rl(`map`),mappings:U(I(),z()).describe(`Value mappings (e.g., {"Active": "active"})`)}).describe(`Map values using a dictionary`)])),J3t=$(()=>V({source:I().describe(`Source field name`),target:I().describe(`Target field name`),transform:q3t.optional().describe(`Transformation to apply`),defaultValue:z().optional().describe(`Default if source is null/undefined`)})),Y3t=$(()=>V({id:I().describe(`Data source ID`),name:I().describe(`Data source name`),type:W([`odata`,`rest-api`,`graphql`,`custom`]).describe(`Protocol type`),endpoint:I().url().describe(`API endpoint URL`),authentication:V({type:W([`oauth2`,`api-key`,`basic`,`none`]).describe(`Auth type`),config:U(I(),z()).describe(`Auth configuration`)}).describe(`Authentication`)})),X3t=$(()=>J3t.extend({type:I().optional().describe(`Field type`),readonly:R().optional().default(!0).describe(`Read-only field`)}));$(()=>V({fieldName:I().describe(`Field name`),dataSource:Y3t.describe(`External data source`),query:V({endpoint:I().describe(`Query endpoint path`),method:W([`GET`,`POST`]).optional().default(`GET`).describe(`HTTP method`),parameters:U(I(),z()).optional().describe(`Query parameters`)}).describe(`Query configuration`),fieldMappings:B(X3t).describe(`Field mappings`),caching:V({enabled:R().optional().default(!0).describe(`Cache enabled`),ttl:L().optional().default(300).describe(`Cache TTL (seconds)`),strategy:W([`lru`,`lfu`,`ttl`]).optional().default(`ttl`).describe(`Cache strategy`)}).optional().describe(`Caching configuration`),fallback:V({enabled:R().optional().default(!0).describe(`Fallback enabled`),defaultValue:z().optional().describe(`Default fallback value`),showError:R().optional().default(!0).describe(`Show error to user`)}).optional().describe(`Fallback configuration`),rateLimit:V({requestsPerSecond:L().describe(`Requests per second limit`),burstSize:L().optional().describe(`Burst size`)}).optional().describe(`Rate limiting`),retry:V({maxRetries:L().min(0).default(3).describe(`Maximum retry attempts`),initialDelayMs:L().default(1e3).describe(`Initial retry delay in milliseconds`),maxDelayMs:L().default(3e4).describe(`Maximum retry delay in milliseconds`),backoffMultiplier:L().default(2).describe(`Exponential backoff multiplier`),retryableStatusCodes:B(L()).default([429,500,502,503,504]).describe(`HTTP status codes that are retryable`)}).optional().describe(`Retry configuration with exponential backoff`),transform:V({request:V({headers:U(I(),I()).optional().describe(`Additional request headers`),queryParams:U(I(),I()).optional().describe(`Additional query parameters`)}).optional().describe(`Request transformation`),response:V({dataPath:I().optional().describe(`JSONPath to extract data (e.g., "$.data.results")`),totalPath:I().optional().describe(`JSONPath to extract total count (e.g., "$.meta.total")`)}).optional().describe(`Response transformation`)}).optional().describe(`Request/response transformation pipeline`),pagination:V({type:W([`offset`,`cursor`,`page`]).default(`offset`).describe(`Pagination type`),pageSize:L().default(100).describe(`Items per page`),maxPages:L().optional().describe(`Maximum number of pages to fetch`)}).optional().describe(`Pagination configuration for external data`)}));var Z3t=I().describe(`Underlying driver identifier`);$(()=>V({id:I().describe(`Unique driver identifier (e.g. "postgres")`),label:I().describe(`Display label (e.g. "PostgreSQL")`),description:I().optional(),icon:I().optional(),configSchema:U(I(),z()).describe(`JSON Schema for connection configuration`),capabilities:wl(()=>Q3t).optional()}));var Q3t=V({transactions:R().default(!1),queryFilters:R().default(!1),queryAggregations:R().default(!1),querySorting:R().default(!1),queryPagination:R().default(!1),queryWindowFunctions:R().default(!1),querySubqueries:R().default(!1),joins:R().default(!1),fullTextSearch:R().default(!1),readOnly:R().default(!1),dynamicSchema:R().default(!1)}),$3t=W([`managed`,`external`,`validate-only`]).describe(`Schema ownership mode`),e6t=V({label:I().optional().describe(`Display label, e.g. "Snowflake — ANALYTICS / PROD"`),allowedSchemas:B(I()).optional().describe(`Whitelist of remote schemas/databases that may be exposed.`),allowWrites:R().default(!1).describe(`Global write gate. Individual objects must also opt in via object.external.writable.`),validation:V({onMismatch:W([`fail`,`warn`,`ignore`]).default(`fail`).describe(`What to do when a federated object diverges from the remote table.`),checkOnBoot:R().default(!0).describe(`Validate federated objects against the remote schema at boot.`),checkIntervalMs:L().optional().describe(`Optional background drift-check interval in milliseconds.`)}).default({onMismatch:`fail`,checkOnBoot:!0}).describe(`Boot/drift validation policy`),credentialsRef:I().optional().describe(`Reference into the secrets store; never inline credentials.`),queryTimeoutMs:L().default(3e4).describe(`Hard cap on per-query execution time.`),requirePermission:I().optional().describe(`Optional convenience: gate the entire datasource behind a single role.`)}).describe(`External datasource federation settings (schemaMode != "managed")`);$(()=>V({name:I().regex(/^[a-z_][a-z0-9_]*$/).describe(`Unique datasource identifier`),label:I().optional().describe(`Display label`),driver:Z3t.describe(`Underlying driver type`),config:U(I(),z()).describe(`Driver specific configuration`),pool:V({min:L().default(0).describe(`Minimum connections`),max:L().default(10).describe(`Maximum connections`),idleTimeoutMillis:L().default(3e4).describe(`Idle timeout`),connectionTimeoutMillis:L().default(3e3).describe(`Connection establishment timeout`)}).optional().describe(`Connection pool settings`),readReplicas:B(U(I(),z())).optional().describe(`Read-only replica configurations`),capabilities:Q3t.optional().describe(`Capability overrides`),healthCheck:V({enabled:R().default(!0).describe(`Enable health check endpoint`),intervalMs:L().default(3e4).describe(`Health check interval in milliseconds`),timeoutMs:L().default(5e3).describe(`Health check timeout in milliseconds`)}).optional().describe(`Datasource health check configuration`),ssl:V({enabled:R().default(!1).describe(`Enable SSL/TLS for database connection`),rejectUnauthorized:R().default(!0).describe(`Reject connections with invalid/self-signed certificates`),ca:I().optional().describe(`CA certificate (PEM format or path to file)`),cert:I().optional().describe(`Client certificate (PEM format or path to file)`),key:I().optional().describe(`Client private key (PEM format or path to file)`)}).optional().describe(`SSL/TLS configuration for secure database connections`),retryPolicy:V({maxRetries:L().default(3).describe(`Maximum number of retry attempts`),baseDelayMs:L().default(1e3).describe(`Base delay between retries in milliseconds`),maxDelayMs:L().default(3e4).describe(`Maximum delay between retries in milliseconds`),backoffMultiplier:L().default(2).describe(`Exponential backoff multiplier`)}).optional().describe(`Connection retry policy for transient failures`),description:I().optional().describe(`Internal description`),active:R().default(!0).describe(`Is datasource enabled`),autoConnect:R().default(!1).describe(`Force a live driver connection at boot even when managed + unrouted (ADR-0062 D2).`),schemaMode:$3t.default(`managed`),external:e6t.optional(),origin:W([`code`,`runtime`]).default(`code`).describe(`Datasource provenance (server-managed, read-only)`)}).superRefine((e,t)=>{e.schemaMode!==`managed`&&!e.external&&t.addIssue({code:`custom`,path:[`external`],message:`schemaMode='${e.schemaMode}' requires 'external' settings.`}),e.schemaMode===`managed`&&e.external&&t.addIssue({code:`custom`,path:[`external`],message:`'external' settings only apply when schemaMode != 'managed'.`})}));var t6t=V({name:I().describe(`Remote column name`),sqlType:I().describe(`Raw remote SQL type (e.g. "numeric(10,2)")`),nullable:R().describe(`Whether the remote column is nullable`),primaryKey:R().default(!1).describe(`Part of the remote primary key`),suggestedFieldType:I().optional().describe(`ObjectStack field type suggested by the type-compat matrix`)}),n6t=V({remoteSchema:I().optional().describe(`Remote schema/database qualifier`),remoteName:I().describe(`Remote table/view name`),columns:B(t6t).describe(`Remote columns`),indexes:B(V({name:I(),columns:B(I()),unique:R()})).optional().describe(`Remote indexes, when introspectable`),rowCountEstimate:L().optional().describe(`Approximate row count`)});$(()=>V({name:I().regex(/^[a-z_][a-z0-9_]*$/).describe("Catalog id, conventionally `<datasource>_catalog`."),datasource:I().describe(`Datasource.name this catalog snapshots.`),snapshotAt:I().datetime().describe(`When the snapshot was taken (ISO 8601).`),dialect:I().optional().describe(`Remote SQL dialect, when known.`),tables:B(n6t).describe(`Snapshotted remote tables.`)}));var r6t=W([`count`,`sum`,`avg`,`min`,`max`,`count_distinct`,`number`,`string`,`boolean`]),i6t=W([`string`,`number`,`boolean`,`time`,`geo`]),a6t=W([`second`,`minute`,`hour`,`day`,`week`,`month`,`quarter`,`year`]),o6t=$(()=>V({name:I().regex(/^[a-z_][a-z0-9_]*$/).describe(`Unique metric ID`),label:I().describe(`Human readable label`),description:I().optional(),type:r6t,sql:I().describe(`SQL expression or field reference`),filters:B(V({sql:I()})).optional(),format:I().optional()})),s6t=$(()=>V({name:I().regex(/^[a-z_][a-z0-9_]*$/).describe(`Unique dimension ID`),label:I().describe(`Human readable label`),description:I().optional(),type:i6t,sql:I().describe(`SQL expression or column reference`),granularities:B(a6t).optional()})),c6t=$(()=>V({name:I().describe(`Target cube name`),relationship:W([`one_to_one`,`one_to_many`,`many_to_one`]).default(`many_to_one`),sql:I().describe(`Join condition (ON clause)`)}));$(()=>V({name:I().regex(/^[a-z_][a-z0-9_]*$/).describe(`Cube name (snake_case)`),title:I().optional(),description:I().optional(),sql:I().describe(`Base SQL statement or Table Name`),measures:U(I(),o6t).describe(`Quantitative metrics`),dimensions:U(I(),s6t).describe(`Qualitative attributes`),joins:U(I(),c6t).optional(),refreshKey:V({every:I().optional(),sql:I().optional()}).optional(),public:R().default(!1)})),$(()=>V({cube:I().optional().describe(`Target cube name (optional when provided externally, e.g. in API request wrapper)`),measures:B(I()).describe(`List of metrics to calculate`),dimensions:B(I()).optional().describe(`List of dimensions to group by`),where:d9.optional().describe(`Filtering criteria (canonical Query DSL FilterCondition)`),timeDimensions:B(V({dimension:I(),granularity:a6t.optional(),dateRange:H([I(),B(I())]).optional()})).optional(),order:U(I(),W([`asc`,`desc`])).optional(),limit:L().optional(),offset:L().optional(),timezone:I().optional().default(`UTC`)}));var l6t=W([`comment`,`field_change`,`task`,`event`,`email`,`call`,`note`,`file`,`record_create`,`record_delete`,`approval`,`sharing`,`system`]),u6t=$(()=>V({type:W([`user`,`team`,`record`]).describe(`Mention target type`),id:I().describe(`Target ID`),name:I().describe(`Display name for rendering`),offset:L().int().min(0).describe(`Character offset in body text`),length:L().int().min(1).describe(`Length of mention token in body text`)})),d6t=$(()=>V({field:I().describe(`Field machine name`),fieldLabel:I().optional().describe(`Field display label`),oldValue:z().optional().describe(`Previous value`),newValue:z().optional().describe(`New value`),oldDisplayValue:I().optional().describe(`Human-readable old value`),newDisplayValue:I().optional().describe(`Human-readable new value`)})),f6t=$(()=>V({emoji:I().describe(`Emoji character or shortcode (e.g., "👍", ":thumbsup:")`),userIds:B(I()).describe(`Users who reacted`),count:L().int().min(1).describe(`Total reaction count`)})),p6t=$(()=>V({type:W([`user`,`system`,`service`,`automation`]).describe(`Actor type`),id:I().describe(`Actor ID`),name:I().optional().describe(`Actor display name`),avatarUrl:I().url().optional().describe(`Actor avatar URL`),source:I().optional().describe(`Source application (e.g., "Omni", "API", "Studio")`)})),m6t=W([`public`,`internal`,`private`]);$(()=>V({id:I().describe(`Feed item ID`),type:l6t.describe(`Activity type`),object:I().describe(`Object name (e.g., "account")`),recordId:I().describe(`Record ID this feed item belongs to`),actor:p6t.describe(`Who performed this action`),body:I().optional().describe(`Rich text body (Markdown supported)`),mentions:B(u6t).optional().describe(`Mentioned users/teams/records`),changes:B(d6t).optional().describe(`Field-level changes`),reactions:B(f6t).optional().describe(`Emoji reactions on this item`),parentId:I().optional().describe(`Parent feed item ID for threaded replies`),replyCount:L().int().min(0).default(0).describe(`Number of replies`),pinned:R().default(!1).describe(`Whether the feed item is pinned to the top of the timeline`),pinnedAt:I().datetime().optional().describe(`Timestamp when the item was pinned`),pinnedBy:I().optional().describe(`User ID who pinned the item`),starred:R().default(!1).describe(`Whether the feed item is starred/bookmarked by the current user`),starredAt:I().datetime().optional().describe(`Timestamp when the item was starred`),visibility:m6t.default(`public`).describe(`Visibility: public (all users), internal (team only), private (author + mentioned)`),createdAt:I().datetime().describe(`Creation timestamp`),updatedAt:I().datetime().optional().describe(`Last update timestamp`),editedAt:I().datetime().optional().describe(`When comment was last edited`),isEdited:R().default(!1).describe(`Whether comment has been edited`)})),W([`all`,`comments_only`,`changes_only`,`tasks_only`]);var h6t=W([`comment`,`mention`,`field_change`,`task`,`approval`,`all`]),g6t=W([`in_app`,`email`,`push`,`slack`]);$(()=>V({object:I().describe(`Object name`),recordId:I().describe(`Record ID`),userId:I().describe(`Subscribing user ID`),events:B(h6t).default([`all`]).describe(`Event types to receive notifications for`),channels:B(g6t).default([`in_app`]).describe(`Notification delivery channels`),active:R().default(!0).describe(`Whether the subscription is active`),createdAt:I().datetime().describe(`Subscription creation timestamp`)}));var _6t=new Set([`textarea`,`markdown`,`html`,`grid`,`rich-text`,`field:textarea`,`field:markdown`,`field:html`,`field:grid`,`field:rich-text`]);function v6t(e){return _6t.has(e)}function y6t(e,t){let n;return n=e<=3?1:e<=8?2:e<=15?3:4,t!==void 0&&t<640?Math.min(n,1):n}function b6t(e,t){return t<=1?e:e.map(e=>e.span===void 0&&e.type&&v6t(e.type)?{...e,span:t}:e)}function x6t(e,t,n){if(t!==void 0)return{fields:b6t(e,t),columns:t};let r=y6t(e.length,n);return{fields:b6t(e,r),columns:r}}function S6t(e,t){return function(){try{let n=_m();return n.t(t)===t?{t:(t,n)=>{let r=e[t]||t;if(n)for(let[e,t]of Object.entries(n))r=r.replace(`{{${e}}}`,String(t));return r}}:{t:n.t}}catch{return{t:(t,n)=>{let r=e[t]||t;if(n)for(let[e,t]of Object.entries(n))r=r.replace(`{{${e}}}`,String(t));return r}}}}}var R9=S6t({"detail.back":`Back`,"detail.edit":`Edit`,"detail.editInline":`Edit`,"detail.save":`Save`,"detail.saveChanges":`Save changes`,"detail.editFieldsInline":`Edit fields inline`,"detail.editInlineHint":`Double-click to edit`,"detail.cancel":`Cancel`,"detail.cancelEdit":`Discard changes`,"detail.openInNewTab":`Open in new tab`,"detail.share":`Share`,"detail.duplicate":`Duplicate`,"detail.export":`Export`,"detail.viewHistory":`View history`,"detail.delete":`Delete`,"detail.moreActions":`More actions`,"detail.addToFavorites":`Add to favorites`,"detail.removeFromFavorites":`Remove from favorites`,"detail.previousRecord":`Previous record`,"detail.nextRecord":`Next record`,"detail.recordOf":`{{current}} of {{total}}`,"detail.recordNotFound":`Record not found`,"detail.recordNotFoundDescription":`The record you are looking for does not exist or may have been deleted.`,"detail.goBack":`Go back`,"detail.details":`Details`,"detail.related":`Related`,"detail.relatedRecords":`{{count}} records`,"detail.relatedRecordOne":`{{count}} record`,"detail.noRelatedRecords":`No related records found`,"detail.loading":`Loading...`,"detail.copyToClipboard":`Copy to clipboard`,"detail.copied":`Copied!`,"detail.deleteConfirmation":`Are you sure you want to delete this record?`,"detail.editRecord":`Edit record`,"detail.viewAll":`View All`,"detail.new":`New`,"detail.emptyValue":`—`,"detail.noValue":`No value`,"detail.activity":`Activity`,"detail.copyRecordId":`Copy record ID`,"detail.showEmptyFields":`Show {{count}} empty fields`,"detail.hideEmptyFields":`Hide empty fields`,"detail.editRow":`Edit`,"detail.deleteRow":`Delete`,"detail.deleteRowConfirmation":`Are you sure you want to delete this record?`,"detail.actions":`Actions`,"detail.previousPage":`Previous`,"detail.nextPage":`Next`,"detail.pageOf":`Page {{current}} of {{total}}`,"detail.sortBy":`Sort by`,"detail.filterPlaceholder":`Filter...`,"detail.highlightFields":`Key Fields`,"detail.comments":`Comments`,"detail.searchComments":`Search comments…`,"detail.addCommentPlaceholder":`Add a comment… (Ctrl+Enter to submit)`,"detail.noMatchingComments":`No matching comments`,"detail.noCommentsYet":`No comments yet`,"detail.pinned":`Pinned`,"detail.pin":`Pin`,"detail.unpin":`Unpin`,"detail.justNow":`just now`,"detail.minutesAgo":`{{count}}m ago`,"detail.hoursAgo":`{{count}}h ago`,"detail.daysAgo":`{{count}}d ago`,"detail.createdBy":`Created by`,"detail.updatedBy":`Updated by`,"detail.created":`Created`,"detail.updated":`Updated`,"detail.dropFilesToUpload":`Drop files here or click to upload`,"detail.attachmentCount":`{{count}} attachment`,"detail.attachmentCountPlural":`{{count}} attachments`,"detail.removeAttachment":`Remove attachment`,"detail.unifiedDiff":`Unified diff`,"detail.sideBySideDiff":`Side-by-side diff`,"detail.noChanges":`No changes`,"detail.previousVersion":`Previous`,"detail.currentVersion":`Current`,"detail.discussion":`Discussion`,"detail.showDiscussion":`Show Discussion ({{count}})`,"detail.hideDiscussion":`Hide discussion`,"detail.bold":`Bold (Ctrl+B)`,"detail.italic":`Italic (Ctrl+I)`,"detail.listFormat":`List`,"detail.inlineCode":`Inline code`,"detail.mentionSomeone":`Mention someone`,"detail.preview":`Preview`,"detail.submitComment":`Submit (Ctrl+Enter)`,"detail.sendComment":`Send`,"detail.writeComment":`Write a comment…`,"detail.subscribedTooltip":`Subscribed — click to unsubscribe`,"detail.unsubscribedTooltip":`Subscribe to notifications`,"detail.firstRecord":`First record (Home)`,"detail.previousRecordKey":`Previous record (←)`,"detail.nextRecordKey":`Next record (→)`,"detail.lastRecord":`Last record (End)`,"detail.noRecords":`No records`,"detail.showEmptyRelated_one":`+ {{count}} empty`,"detail.showEmptyRelated_other":`+ {{count}} empty`,"detail.searchWhileNavigating":`Search while navigating`,"detail.searchRecords":`Search records…`,"detail.allActivity":`All Activity`,"detail.commentsOnly":`Comments Only`,"detail.fieldChangesFilter":`Field Changes`,"detail.tasksOnly":`Tasks Only`,"detail.leaveCommentPlaceholder":`Leave a comment… (Ctrl+Enter to submit)`,"detail.noActivity":`No activity recorded`,"detail.loadMore":`Load more`,"detail.edited":`(edited)`,"detail.via":`via {{source}}`,"detail.viewSource":`View source`,"detail.replyCount":`{{count}} reply`,"detail.replyCountPlural":`{{count}} replies`,"detail.replyPlaceholder":`Reply…`,"detail.filterActivity":`Filter activity`,"detail.openDiscussion":`Open discussion panel`,"detail.closeDiscussion":`Close discussion panel`,"detail.subscribeAriaLabel":`Subscribe to notifications`,"detail.unsubscribeAriaLabel":`Unsubscribe from notifications`,"detail.clearSearch":`Clear search`,"detail.concurrentUpdateTitle":`This record was modified by someone else`,"detail.concurrentUpdateDescription":`Another user saved a newer version of {{field}} while you were editing. To prevent silently overwriting their change, please choose how to resolve the conflict.`,"detail.concurrentUpdateYourEdit":`Your edit`,"detail.concurrentUpdateCurrentValue":`Current value`,"detail.concurrentUpdateUpdatedBy":`Updated by {{name}}`,"detail.concurrentUpdateUpdatedAt":`Updated at {{when}}`,"detail.concurrentUpdateReload":`Reload latest`,"detail.concurrentUpdateOverwrite":`Overwrite anyway`,"detail.concurrentUpdateCancel":`Cancel`},`detail.back`);function C6t(e){if(typeof e==`string`){let t=e.trim();if(!t)return null;try{return JSON.parse(t)}catch{return t}}return e??null}function w6t(e){let t=C6t(e);return t==null||t===``?0:Array.isArray(t)?t.length:typeof t==`object`?Object.keys(t).length:1}function z9({value:e,field:t}){let{t:n}=R9(),r=Qp(),{appName:i}=P1t(),a=t?.name||``,o=r?.data?.name,s=i&&o?`/apps/${i}/metadata/permission/${encodeURIComponent(String(o))}`:null,c=w6t(e),l=c===0;return(0,q.jsxs)(`span`,{className:`inline-flex flex-wrap items-center gap-x-2 gap-y-1 text-sm`,children:[(()=>{if(l)return(0,q.jsx)(`span`,{className:`text-muted-foreground`,children:n(`perm.facet.none`,{defaultValue:`None`})});if(a===`system_permissions`){let t=aZt(e),r=t.slice(0,6),i=t.length-r.length;return(0,q.jsxs)(`span`,{className:`inline-flex flex-wrap items-center gap-1`,children:[r.map(e=>(0,q.jsx)(cY,{variant:`outline`,children:e},e)),i>0&&(0,q.jsx)(`span`,{className:`text-muted-foreground text-xs`,children:n(`perm.facet.more`,{count:i,defaultValue:`+${i} more`})})]})}return(0,q.jsx)(`span`,{className:`text-foreground`,children:(()=>{switch(a){case`object_permissions`:return n(`perm.facet.objects`,{count:c,defaultValue:`${c} object${c===1?``:`s`}`});case`field_permissions`:return n(`perm.facet.fields`,{count:c,defaultValue:`${c} field rule${c===1?``:`s`}`});case`row_level_security`:return n(`perm.facet.rls`,{count:c,defaultValue:`${c} RLS polic${c===1?`y`:`ies`}`});case`tab_permissions`:return n(`perm.facet.tabs`,{count:c,defaultValue:`${c} tab rule${c===1?``:`s`}`});case`admin_scope`:return n(`perm.facet.adminScope`,{defaultValue:`Delegated admin configured`});default:return String(c)}})()})})(),s?(0,q.jsx)(n9,{to:s,className:`text-primary hover:underline whitespace-nowrap`,children:n(`perm.facet.designInStudio`,{defaultValue:`Design in Studio →`})}):(0,q.jsx)(`span`,{className:`text-muted-foreground/60 whitespace-nowrap`,children:n(`perm.facet.designInStudioHint`,{defaultValue:`Design in Studio`})})]})}var T6t=new Set([`id`,`_id`,`__v`,`created`,`created_at`,`createdAt`,`created_by`,`modified`,`modified_by`,`updated_at`,`updatedAt`,`updated_by`,`deleted_at`,`is_deleted`,`deleted`,`instance_state`]),B9=new Set([`formula`,`summary`,`rollup`,`auto_number`]),E6t=({field:e,value:t,onChange:n,dataSource:r,autoFocus:i})=>{let a=e.type,o=e.widget;if(o===`permission-facet-link`)return(0,q.jsx)(z9,{value:t,field:e});if(o===`capability-multiselect`)return(0,q.jsx)(cZt,{value:t,onChange:e=>n(e),field:e,dataSource:r});if(a===`select`&&Array.isArray(e.options)&&e.options.length>0)return(0,q.jsx)(iXt,{field:e,value:t==null?``:String(t),onChange:e=>n(e)});if(a===`boolean`)return(0,q.jsx)(tXt,{field:e,value:!!t,onChange:e=>n(e)});let s=a===`user`||a===`owner`,c=a===`lookup`||a===`master_detail`||a===`tree`||!!e.reference_to&&!B9.has(a);if(s||c)return(0,q.jsx)(s?LZt:x5,{field:e,value:t,onChange:e=>n(e),dataSource:r});if(a===`number`)return(0,q.jsx)($Yt,{field:e,value:t,onChange:e=>n(e),autoFocus:i});if(a===`currency`)return(0,q.jsx)(gXt,{field:e,value:t,onChange:e=>n(e),autoFocus:i});if(a===`percent`)return(0,q.jsx)(mZt,{field:e,value:t,onChange:e=>n(e),autoFocus:i});let l=a===`date`||a===`datetime`;return(0,q.jsx)(`input`,{type:l?`date`:`text`,autoFocus:i,className:`w-full px-2 py-1.5 text-sm border rounded-md bg-background focus:outline-none focus:ring-2 focus:ring-ring`,value:t==null?``:l?(()=>{let e=String(t);if(/^\d{4}-\d{2}-\d{2}/.test(e))return e.slice(0,10);let n=new Date(e);return isNaN(n.getTime())?``:n.toLocaleDateString(`en-CA`)})():String(typeof t==`object`?a7(t)??``:t),onChange:e=>{let t=e.target.value;n(l&&t?new Date(t+`T00:00:00`).toISOString():t)}})},D6t=({name:e})=>/^[a-z0-9][a-z0-9-]*$/i.test(e)?(0,q.jsx)(v3,{name:e,className:`h-4 w-4 shrink-0 text-muted-foreground`,"aria-hidden":!0}):(0,q.jsx)(`span`,{className:`text-muted-foreground`,children:e});function O6t(e,t){return!e||e<=1||t<=1?``:t===2?e>=2?`md:col-span-2`:``:t===3?e===2?`md:col-span-2`:e>=3?`md:col-span-2 lg:col-span-3`:``:e===2?`md:col-span-2`:e===3?`md:col-span-2 lg:col-span-3`:e>=4?`md:col-span-2 lg:col-span-3 xl:col-span-4`:``}var V9=({section:e,data:t,className:n,objectSchema:r,objectName:i,isEditing:a=!1,onFieldChange:o,onEnterInlineEdit:s,autoFocusField:c,dataSource:l,virtualScroll:u})=>{let[d,f]=K.useState(e.defaultCollapsed??!1),[p,m]=K.useState(null),[h,g]=K.useState(void 0),[_,v]=K.useState(!1),{t:y}=R9(),{fieldLabel:b,translateOptions:x}=ym(),S=K.useCallback((e,t)=>{let n=t==null?``:String(t);navigator.clipboard.writeText(n).then(()=>{m(e),setTimeout(()=>m(null),2e3)})},[]),C=K.useCallback(e=>{let n=t?.[e.name]??e.value;return n==null||n===``},[t]),w=K.useMemo(()=>e.fields.filter(C).length,[e.fields,C]),T=h4(),E=T?3:4,D=T?.2:.25,O=e.fields.length-w,k=!e.hideEmpty&&!a&&e.fields.length>=E&&w/e.fields.length>=D&&O>0,A=!_&&(e.hideEmpty||k)?e.fields.filter(e=>!C(e)):e.fields,{fields:ee,columns:te}=x6t(A,e.columns),j=Math.min(te,Math.max(1,A.length)),ne=e=>{let n=t?.[e.name]??e.value;if(e.render)return(0,q.jsx)(Kp,{schema:e.render,data:{...t,value:n}});let u=O6t(e.span,j),d=r?.fields?.[e.name],f={...e};if(d){!e.type&&d.type&&(f.type=d.type),d.options&&!f.options&&(f.options=d.options),d.currency&&!f.currency&&(f.currency=d.currency),d.precision!==void 0&&f.precision===void 0&&(f.precision=d.precision),d.scale!==void 0&&f.scale===void 0&&(f.scale=d.scale),d.format&&!f.format&&(f.format=d.format),d.widget&&!f.widget&&(f.widget=d.widget);let t=d.reference_to||d.reference;t&&!f.reference_to&&(f.reference_to=t),d.reference_field&&!f.reference_field&&(f.reference_field=d.reference_field),d.dueLike!==void 0&&f.dueLike===void 0&&(f.dueLike=d.dueLike)}i&&Array.isArray(f.options)&&f.options.length>0&&(f.options=x(i,e.name,f.options));let m=f.type||e.type,h=B9.has(m),g=e.readonly===!0||d?.readonly===!0,_=T6t.has(e.name),v=!g&&!h&&!_,C=v&&!!s,w=(()=>{if((f.widget||e.widget)===`permission-facet-link`)return(0,q.jsx)(z9,{value:n,field:f});if(n==null||n===``)return(0,q.jsx)(`span`,{className:`text-muted-foreground/60 text-sm select-none`,"aria-label":y(`detail.noValue`,{defaultValue:`No value`}),title:y(`detail.noValue`,{defaultValue:`No value`}),children:`—`});let t=v7(f)||e.type;if(t){let e=b7(t);if(e)return(0,q.jsx)(e,{value:n,field:f})}return String(n)})(),E=n!=null&&n!==``,D=E&&!C,O=p===e.name,k=b(i||``,e.name,e.label||e.name);return T&&!(a&&v)?(0,q.jsxs)(`div`,{className:J(`flex items-baseline justify-between gap-4 py-2.5 min-h-[44px] group`,E&&`cursor-pointer active:bg-muted/40 transition-colors`),onClick:E?()=>S(e.name,n):void 0,onKeyDown:E?t=>{(t.key===`Enter`||t.key===` `)&&(t.preventDefault(),S(e.name,n))}:void 0,role:E?`button`:void 0,tabIndex:E?0:void 0,children:[(0,q.jsx)(`span`,{className:`text-[15px] text-muted-foreground shrink-0`,children:k}),(0,q.jsx)(`span`,{className:`text-[15px] text-foreground text-right break-words min-w-0 leading-snug`,children:w})]},e.name):(0,q.jsxs)(`div`,{className:J(`space-y-1.5 group min-w-0`,u),children:[(0,q.jsx)(`div`,{className:`text-xs font-medium text-muted-foreground uppercase tracking-wide`,children:b(i||``,e.name,e.label||e.name)}),a&&v?(0,q.jsx)(`div`,{className:`min-h-[44px] sm:min-h-0`,children:(0,q.jsx)(E6t,{field:f,value:n,onChange:t=>o?.(e.name,t),dataSource:l,autoFocus:c===e.name})}):(0,q.jsxs)(`div`,{className:J(`flex items-start justify-between gap-2 min-h-[44px] sm:min-h-0 rounded-md`,D&&`cursor-pointer active:bg-muted/60 transition-colors`,C&&`cursor-pointer hover:bg-muted/40 transition-colors -mx-1.5 px-1.5`),onClick:D?()=>S(e.name,n):void 0,onDoubleClick:C?()=>s?.(e.name):void 0,onKeyDown:D?t=>{(t.key===`Enter`||t.key===` `)&&(t.preventDefault(),S(e.name,n))}:void 0,role:D?`button`:void 0,tabIndex:D?0:void 0,title:C?y(`detail.editInlineHint`):void 0,children:[(0,q.jsx)(`div`,{className:`text-sm flex-1 min-w-0 break-words py-1`,children:w}),C?(0,q.jsx)(E4,{children:(0,q.jsxs)(D4,{children:[(0,q.jsx)(O4,{asChild:!0,children:(0,q.jsx)(Z,{variant:`ghost`,size:`icon`,className:`h-6 w-6 opacity-0 group-hover:opacity-100 transition-opacity shrink-0`,"aria-label":y(`detail.editInlineHint`),onClick:t=>{t.stopPropagation(),s?.(e.name)},children:(0,q.jsx)(mq,{className:`h-3 w-3`})})}),(0,q.jsx)(k4,{children:y(`detail.editInlineHint`)})]})}):E?(0,q.jsx)(E4,{children:(0,q.jsxs)(D4,{children:[(0,q.jsx)(O4,{asChild:!0,children:(0,q.jsx)(Z,{variant:`ghost`,size:`icon`,className:`h-6 w-6 opacity-0 group-hover:opacity-100 transition-opacity shrink-0`,onClick:t=>{t.stopPropagation(),S(e.name,n)},children:O?(0,q.jsx)(sC,{className:`h-3 w-3 text-green-600`}):(0,q.jsx)(qk,{className:`h-3 w-3`})})}),(0,q.jsx)(k4,{children:y(O?`detail.copied`:`detail.copyToClipboard`)})]})}):null]})]},e.name)},re=u?.enabled===!0,M=u?.batchSize??20;if(K.useEffect(()=>{if(!re){g(void 0);return}if(ee.length<=M){g(void 0);return}g(M);let e=setTimeout(()=>g(void 0),100);return()=>clearTimeout(e)},[re,ee.length,M]),A.length===0&&w===e.fields.length)return null;let N=h===void 0?ee:ee.slice(0,h),ie=w>0&&(e.hideEmpty||k),ae=(0,q.jsxs)(q.Fragment,{children:[T?(0,q.jsx)(`div`,{className:`flex flex-col divide-y divide-border/60`,children:N.map(ne)}):(0,q.jsx)(`div`,{className:J(`grid gap-3 sm:gap-4`,j===1?`grid-cols-1`:j===2?`grid-cols-1 md:grid-cols-2`:j===3?`grid-cols-1 md:grid-cols-2 lg:grid-cols-3`:`grid-cols-1 md:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4`),children:N.map(ne)}),ie&&(0,q.jsx)(`div`,{className:`mt-3 -ml-2`,children:(0,q.jsxs)(Z,{type:`button`,variant:`ghost`,size:`sm`,onClick:()=>v(e=>!e),className:`h-7 px-2 text-xs text-muted-foreground hover:text-foreground`,children:[(0,q.jsx)(_?NN:FN,{className:`h-3.5 w-3.5 mr-1.5`}),_?y(`detail.hideEmptyFields`,{defaultValue:`Hide empty fields`}):y(`detail.showEmptyFields`,{count:w,defaultValue:`Show ${w} empty field${w===1?``:`s`}`})]})})]});return!e.title&&!e.collapsible&&e.showBorder===!1?(0,q.jsx)(`div`,{className:J(n),children:ae}):e.collapsible?(0,q.jsx)($X,{open:!d,onOpenChange:e=>f(!e),className:n,children:(0,q.jsxs)(lX,{children:[(0,q.jsx)(eZ,{asChild:!0,children:(0,q.jsxs)(uX,{className:J(`py-3 px-4 sm:py-4 sm:px-6 cursor-pointer hover:bg-muted/50 transition-colors`,e.headerColor&&`bg-${e.headerColor}`),children:[(0,q.jsxs)(dX,{className:`flex items-center justify-between text-base font-semibold tracking-tight`,children:[(0,q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[e.icon&&(0,q.jsx)(D6t,{name:e.icon}),(0,q.jsx)(`span`,{children:e.title})]}),(0,q.jsx)(`div`,{className:`flex items-center gap-2`,children:(0,q.jsx)(d?NC:jC,{className:`h-4 w-4 text-muted-foreground`})})]}),e.description&&!d&&(0,q.jsx)(`p`,{className:`text-xs text-muted-foreground mt-1`,children:e.description})]})}),(0,q.jsx)(tZ,{children:(0,q.jsx)(pX,{className:`pt-3 sm:pt-4 px-3 sm:px-6 pb-4 sm:pb-5`,children:ae})})]})}):(0,q.jsxs)(lX,{className:J(e.showBorder===!1?`border-none shadow-none`:``,n),children:[e.title&&(0,q.jsxs)(uX,{className:J(`py-3 px-4 sm:py-4 sm:px-6`,e.headerColor&&`bg-${e.headerColor}`),children:[(0,q.jsx)(dX,{className:`flex items-center justify-between text-base font-semibold tracking-tight`,children:(0,q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[e.icon&&(0,q.jsx)(D6t,{name:e.icon}),(0,q.jsx)(`span`,{children:e.title})]})}),e.description&&(0,q.jsx)(`p`,{className:`text-xs text-muted-foreground mt-1`,children:e.description})]}),(0,q.jsx)(pX,{className:`pt-3 sm:pt-4 px-3 sm:px-6 pb-4 sm:pb-5`,children:ae})]})},k6t=({tabs:e,data:t,className:n})=>{let[r,i]=K.useState(e[0]?.key),a=e.filter(e=>typeof e.visible==`boolean`?e.visible:(e.visible,!0));return(0,q.jsxs)(o3,{value:r,onValueChange:i,className:n,children:[(0,q.jsx)(s3,{className:`w-full justify-start border-b rounded-none bg-transparent p-0`,children:a.map(e=>(0,q.jsx)(c3,{value:e.key,className:`relative rounded-none border-b-2 border-transparent data-[state=active]:border-primary data-[state=active]:bg-transparent`,children:(0,q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[e.icon&&(0,q.jsx)(`span`,{children:e.icon}),(0,q.jsx)(`span`,{children:e.label}),e.badge&&(0,q.jsx)(cY,{variant:`secondary`,className:`ml-1`,children:e.badge})]})},e.key))}),a.map(e=>(0,q.jsx)(l3,{value:e.key,className:`mt-4 motion-safe:data-[state=active]:animate-in motion-safe:data-[state=active]:fade-in-0 motion-safe:duration-150`,children:(0,q.jsx)(K.Suspense,{fallback:null,children:Array.isArray(e.content)?(0,q.jsx)(`div`,{className:`space-y-4`,children:e.content.map((e,n)=>(0,q.jsx)(Kp,{schema:e,data:t},n))}):(0,q.jsx)(Kp,{schema:e.content,data:t})})},e.key))]})};function A6t(e){return e&&Gq[e.split(/[-_\s]/).filter(Boolean).map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(``)]||GU}var j6t=({action:e,onToolbarAction:t})=>{let n=e.visible,r=Bp(zp(n));if(n&&!r)return null;let i=e.icon?A6t(e.icon):null;return(0,q.jsxs)(Z,{variant:e.variant===`primary`?`default`:`outline`,size:`sm`,onClick:n=>{n.stopPropagation(),t(e)},className:`gap-1 h-9 sm:h-7 text-xs shadow-none`,"data-testid":`related-toolbar-action-${e.name}`,children:[i&&(0,q.jsx)(i,{className:`h-3.5 w-3.5`}),e.label||e.name]})},H9=({title:e,type:t,api:n,data:r,schema:i,columns:a,className:o,dataSource:s,objectName:c,onNew:l,onViewAll:u,onRowEdit:d,onRowDelete:f,onRowClick:p,rowActions:m,onRowAction:h,toolbarActions:g,onToolbarAction:_,add:v,maxColumns:y=6,pageSize:b,sortable:x=!1,filterable:S=!1,collapsible:C=!1,defaultCollapsed:w=!1,referenceField:T,parentId:E,icon:D})=>{let O=r!==void 0,k=r??[],[A,ee]=K.useState(k),[te,j]=K.useState(()=>!!n&&!O),[ne,re]=K.useState(0),[M,N]=K.useState(null),[ie,ae]=K.useState(`asc`),[oe,P]=K.useState(``),[se,ce]=K.useState(null),[le,ue]=K.useState(w),[de,fe]=K.useState(!1),[pe,me]=K.useState(!1),[he,ge]=K.useState(null),[_e,ve]=K.useState(0),[ye,be]=K.useState({}),{t:xe}=R9(),{fieldLabel:Se}=ym();K.useEffect(()=>{O&&ee(r??[])},[r,O]),K.useEffect(()=>{n&&s?.getObjectSchema&&s.getObjectSchema(n).then(ce).catch(e=>{console.warn(`[RelatedList] Failed to fetch schema for ${n}:`,e)})},[n,s]),K.useEffect(()=>{if(n&&!O){if(!(T&&E!=null&&E!==``)){n&&(E==null||E===``)&&!T&&console.warn(`[RelatedList] "${n}" has no referenceField/parentId — refusing to fetch all rows. Pass relationshipField + parentId to scope the query.`),ee([]),j(!1);return}j(!0);let e={[T]:E};if(s&&typeof s.find==`function`)s.find(n,{$filter:e}).then(e=>{let t=Array.isArray(e)?e:Array.isArray(e?.data)?e.data:[];ee(t),j(!1)}).catch(e=>{console.error(`Failed to fetch related data:`,e),j(!1)});else{let e=new URLSearchParams({[`filter[${T}]`]:String(E)}).toString();fetch(`${n}?${e}`).then(e=>e.json()).then(e=>{let t=Array.isArray(e)?e:e?.data||[];ee(t)}).catch(e=>{console.error(`Failed to fetch related data:`,e)}).finally(()=>j(!1))}}},[n,O,s,T,E,_e]),K.useEffect(()=>{if(!n||O)return;let e=e=>{let t=e.detail||{};t.objectName&&t.objectName!==n||ve(e=>e+1)};return window.addEventListener(`objectui:related-changed`,e),()=>window.removeEventListener(`objectui:related-changed`,e)},[n,O]),K.useEffect(()=>{if(!s?.find||!se?.fields||!A.length)return;let e=se.fields,t=[];for(let[n,r]of Object.entries(e)){if(!r||r.type!==`lookup`&&r.type!==`master_detail`)continue;let e=r.reference_to||r.reference;if(!e)continue;let i=new Set;for(let e of A){let t=e?.[n];t!=null&&(typeof t==`string`&&t?i.add(t):typeof t==`number`&&i.add(String(t)))}let a=ye[n]||{},o=Array.from(i).filter(e=>!(e in a));o.length>0&&t.push({fieldName:n,target:e,ids:o})}if(t.length===0)return;let n=!1;return Promise.all(t.map(({fieldName:e,target:t,ids:n})=>s.find(t,{$filter:{id:{$in:n}},$top:n.length}).then(t=>{let n=Array.isArray(t)?t:t?.data||[],r={};for(let e of n){let t=e?.id||e?._id;t&&(r[String(t)]=e?.full_name||e?.fullname||e?.display_name||e?.name||e?.subject||e?.title||e?.label||e?.code||e?.email||String(t))}return{fieldName:e,map:r}}).catch(t=>(console.warn(`[RelatedList] Failed to resolve lookups for ${e}:`,t),{fieldName:e,map:{}})))).then(e=>{n||be(t=>{let n={...t};for(let{fieldName:t,map:r}of e)n[t]={...n[t]||{},...r};return n})}),()=>{n=!0}},[s,se,A]);let Ce=K.useMemo(()=>{if(!oe)return A;let e=oe.toLowerCase();return A.filter(t=>Object.values(t).some(t=>t!=null&&String(t).toLowerCase().includes(e)))},[A,oe]),we=K.useMemo(()=>M?[...Ce].sort((e,t)=>{let n=e[M],r=t[M];if(n==null&&r==null)return 0;if(n==null)return 1;if(r==null)return-1;let i=String(n).localeCompare(String(r),void 0,{numeric:!0});return ie===`asc`?i:-i}):Ce,[Ce,M,ie]),Te=b&&b>0?b:0,Ee=Te?Math.max(1,Math.ceil(we.length/Te)):1,De=Te?we.slice(ne*Te,(ne+1)*Te):we;K.useEffect(()=>{re(0)},[oe,M,ie]);let Oe=K.useCallback(e=>{M===e?ae(e=>e===`asc`?`desc`:`asc`):(N(e),ae(`asc`))},[M]),[ke,Ae]=K.useState(null),je=K.useCallback(e=>{Ae(e)},[]),Me=K.useCallback(async()=>{if(ke)try{await f?.(ke),ve(e=>e+1)}catch(e){console.error(`[RelatedList] remove failed`,e)}Ae(null)},[ke,f]),Ne=K.useCallback(async e=>{if(!v||!s||!n||T==null||E==null)return;let t=v.picker.valueField||`id`;me(!0),ge(null);try{for(let r of e||[]){let e=r?.[t]??r?.id;e!=null&&(v.linkField?await s.create?.(n,{[T]:E,[v.linkField]:e}):await s.update?.(v.picker.object,String(e),{[T]:E}))}ve(e=>e+1)}catch(e){let t=e?.body?.error??e?.error??e?.message??String(e);ge(typeof t==`string`?t:`Failed to add`)}finally{me(!1),fe(!1)}},[v,s,n,T,E]),Pe=s9(),Fe=K.useMemo(()=>{let e=c||n||``,t=t=>!Pe?.isLoaded||!e?t:t.filter(t=>{let n=t?.accessorKey||t?.field||t?.name;return!n||Pe.checkField(e,String(n),`read`)}),r=e=>T?e.filter(e=>(e?.accessorKey||e?.field||e?.name)!==T):e,i=e=>e==null||typeof e==`string`&&e.trim()===``||Array.isArray(e)&&e.length===0,o=e=>A.length?e.filter(e=>{let t=e?.accessorKey||e?.field||e?.name;return!t||A.some(e=>!i(e?.[t]))}):e,s=(e,t)=>{if(!t?.type)return;let n=b7(v7({type:t.type,format:t.format})||t.type);if(!n)return;let r=t.type===`lookup`||t.type===`master_detail`?ye[e]:void 0,i=r&&Object.keys(r).length>0?Object.entries(r).map(([e,t])=>({value:e,label:t})):void 0,a={name:e,label:t.label||e,type:t.type,...(i||t.options)&&{options:i||t.options},...t.currency&&{currency:t.currency},...t.precision!==void 0&&{precision:t.precision},...t.scale!==void 0&&{scale:t.scale},...t.format&&{format:t.format},...(t.reference_to||t.reference)&&{reference_to:t.reference_to||t.reference},...t.reference_field&&{reference_field:t.reference_field}};return e=>e==null?K.createElement(`span`,{className:`text-muted-foreground/50 text-xs italic`},`—`):K.createElement(n,{value:e,field:a})},l=t=>{if(typeof t!=`string`){let e=t?.accessorKey||t?.field||t?.name;if(t&&!t.cell&&!t.render&&e){let n=se?.fields?.[e],r=n?s(String(e),n):void 0;if(r)return{...t,cell:r}}return t}let n=se?.fields?.[t],r={accessorKey:t,header:n?.label||Se(e,t,n)||t,fieldDef:n,fieldType:n?.type},i=n?s(t,n):void 0;return i&&(r.cell=i),r};if(a&&a.length>0)return o(t(r(a.map(l))));if(!se?.fields)return[];let u=Array.isArray(se.highlightFields)?se.highlightFields.filter(e=>typeof e==`string`&&e.length>0):[];if(u.length>0){let e=o(t(r(u.map(l))));if(e.length>0)return e.slice(0,Math.max(1,y))}let d=e,f=new Set([`attachment`,`rich_text`,`html`,`json`]),p=[`name`,`full_name`,`fullname`,`title`,`subject`,`label`,`code`,`number`],m=Object.entries(se.fields).filter(([e,t])=>!(e.startsWith(`_`)||e===`id`||e===T||t?.hidden||t?.type&&f.has(t.type)||Pe?.isLoaded&&d&&!Pe.checkField(d,e,`read`))),h=new Set([`created_at`,`updated_at`,`created_by`,`updated_by`,`owner_id`,`organization_id`]);return m.sort(([e,t],[n,r])=>{let i=h.has(e);if(i!==h.has(n))return i?1:-1;let a=p.indexOf(e),o=p.indexOf(n),s=a>=0?a:100,c=o>=0?o:100;if(s!==c)return s-c;let l=t?.type===`select`||e.includes(`status`);return l===(r?.type===`select`||n.includes(`status`))?0:l?-1:1}),o(m.map(([e,t])=>{let n={accessorKey:e,header:Se(d,e,t.label||e)};if(t.type){let r=s(e,t);r&&(n.cell=r)}return n})).slice(0,Math.max(1,y))},[a,se,c,n,Se,T,A,y,ye,Pe]),Ie=Array.isArray(m)&&m.length>0,Le=!!d||!!f||Ie,Re=h4(),ze=K.useMemo(()=>{if(i)return i;if(Re&&(t===`grid`||t===`table`)){let e=Fe[0]?.accessorKey||Fe[0]?.field||Fe[0]?.name,t=Fe.slice(1,4).map(e=>e.accessorKey||e.field||e.name).filter(Boolean);return{type:`object-gallery`,data:De,objectName:n,gallery:{titleField:e||`name`,visibleFields:t,cardSize:`medium`},onRowClick:p}}switch(t){case`grid`:case`table`:return{type:`data-table`,data:De,columns:Fe,pagination:!1,pageSize:Te||10,searchable:!1,exportable:!1,rowActions:Le,onRowEdit:d,onRowDelete:f?je:void 0,onRowClick:p,rowActionDefs:Ie?m:void 0,onRowActionDef:Ie?h:void 0};case`list`:return{type:`data-list`,data:De};default:return{type:`div`,children:`No view configured`}}},[t,De,Fe,i,Te,Le,Ie,m,h,d,f,je,p,Re,n]),Be=C?`cursor-pointer select-none`:void 0,Ve=C?()=>ue(e=>!e):void 0,He=A6t(D),Ue=!te&&A.length===0,We=S;return(0,q.jsxs)(lX,{className:J(`shadow-none border-border/60 bg-transparent`,Ue&&`bg-muted/10`,o),children:[(0,q.jsx)(uX,{className:J(`py-3 px-4 sm:py-3 min-h-12 sm:min-h-0`,Be),onClick:Ve,children:(0,q.jsxs)(dX,{className:`flex items-center justify-between gap-2 text-sm font-semibold`,children:[(0,q.jsxs)(`div`,{className:`flex items-center gap-2 min-w-0`,children:[C&&(0,q.jsx)(le?NC:jC,{className:`h-3.5 w-3.5 text-muted-foreground shrink-0`}),(0,q.jsx)(He,{className:`h-4 w-4 text-muted-foreground shrink-0`,"aria-hidden":!0}),(0,q.jsx)(`span`,{className:J(`truncate`,Ue&&`text-muted-foreground font-medium`),children:e}),(0,q.jsx)(cY,{variant:`secondary`,className:J(`text-xs font-normal h-5 px-1.5`,A.length===0&&`bg-muted text-muted-foreground`),"aria-label":`${A.length} records`,children:A.length}),Ue&&(0,q.jsx)(`span`,{className:`text-xs text-muted-foreground/70 italic ml-1 truncate`,children:xe(`detail.noRelatedRecords`)})]}),(0,q.jsxs)(`div`,{className:`flex items-center gap-1 shrink-0`,children:[_&&(g??[]).map(e=>(0,q.jsx)(j6t,{action:e,onToolbarAction:_},e.name)),v&&(0,q.jsxs)(Z,{variant:Ue?`ghost`:`outline`,size:`sm`,disabled:pe,onClick:e=>{e.stopPropagation(),ge(null),fe(!0)},className:`gap-1 h-9 sm:h-7 text-xs shadow-none`,children:[(0,q.jsx)(_q,{className:`h-3.5 w-3.5`}),v.label||xe(`detail.add`,{defaultValue:`Add`})]}),l&&(0,q.jsxs)(Z,{variant:Ue?`ghost`:`outline`,size:`sm`,onClick:e=>{e.stopPropagation(),l()},className:`gap-1 h-9 sm:h-7 text-xs shadow-none`,children:[(0,q.jsx)(_q,{className:`h-3.5 w-3.5`}),xe(`detail.new`)]})]})]})}),!le&&!Ue&&(0,q.jsxs)(pX,{className:J(`pt-0 pb-4 px-4`),children:[We&&(0,q.jsx)(`div`,{className:`mb-3`,children:(0,q.jsx)(U1,{placeholder:xe(`detail.filterPlaceholder`),value:oe,onChange:e=>P(e.target.value),className:`h-8 text-sm`})}),x&&Fe&&Fe.length>0&&A.length>0&&(0,q.jsx)(`div`,{className:`flex flex-wrap gap-1 mb-3`,children:Fe.map(e=>{let t=e.accessorKey||e.field||e.name;if(!t)return null;let n=e.header||e.label||t,r=M===t;return(0,q.jsxs)(Z,{variant:r?`secondary`:`ghost`,size:`sm`,className:`gap-1 h-7 text-xs`,onClick:()=>Oe(t),children:[(0,q.jsx)(Th,{className:`h-3 w-3`}),n,r&&(ie===`asc`?` ↑`:` ↓`)]},t)})}),te?(0,q.jsx)(`div`,{className:`flex items-center justify-center py-6 text-muted-foreground text-sm`,children:xe(`detail.loading`)}):(0,q.jsx)(Kp,{schema:ze}),Te>0&&we.length>Te&&(0,q.jsxs)(`div`,{className:`flex items-center justify-between mt-3 pt-3 border-t`,children:[(0,q.jsxs)(Z,{variant:`outline`,size:`sm`,className:`h-7 text-xs gap-1`,disabled:ne===0,onClick:()=>re(e=>Math.max(0,e-1)),children:[(0,q.jsx)(kC,{className:`h-3 w-3`}),xe(`detail.previousPage`)]}),(0,q.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:xe(`detail.pageOf`,{current:ne+1,total:Ee})}),(0,q.jsxs)(Z,{variant:`outline`,size:`sm`,className:`h-7 text-xs gap-1`,disabled:ne>=Ee-1,onClick:()=>re(e=>Math.min(Ee-1,e+1)),children:[xe(`detail.nextPage`),(0,q.jsx)(NC,{className:`h-3 w-3`})]})]}),u&&!Ue&&Te>0&&we.length>Te&&(0,q.jsx)(`div`,{className:`mt-3 pt-3 border-t flex justify-center`,children:(0,q.jsxs)(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),u()},className:`text-xs text-muted-foreground hover:text-foreground inline-flex items-center gap-1 transition-colors`,children:[xe(`detail.viewAll`),(0,q.jsx)(DN,{className:`h-3 w-3`})]})})]}),(0,q.jsx)(WJ,{open:ke!==null,onOpenChange:e=>{e||Ae(null)},children:(0,q.jsxs)(GJ,{children:[(0,q.jsxs)(KJ,{children:[(0,q.jsx)(JJ,{children:xe(`detail.deleteRowTitle`,{defaultValue:`Delete record`})}),(0,q.jsx)(YJ,{children:xe(`detail.deleteRowConfirmation`)})]}),(0,q.jsxs)(qJ,{children:[(0,q.jsx)(ZJ,{children:xe(`detail.cancel`,{defaultValue:`Cancel`})}),(0,q.jsx)(XJ,{onClick:Me,className:`bg-destructive text-destructive-foreground hover:bg-destructive/90`,children:xe(`detail.delete`,{defaultValue:`Delete`})})]})]})}),he&&(0,q.jsx)(`div`,{className:`mx-4 mb-3 rounded-md border border-destructive/40 bg-destructive/10 px-3 py-2 text-xs text-destructive`,role:`alert`,children:he}),v&&s&&(0,q.jsx)(SXt,{open:de,onOpenChange:e=>fe(e),multiple:!0,dataSource:s,objectName:v.picker.object,title:v.label||xe(`detail.add`,{defaultValue:`Add`}),onSelect:()=>{},onSelectRecords:e=>{Ne(e)}})]})},M6t=({group:e,data:t,className:n,objectSchema:r,objectName:i,isEditing:a=!1,onFieldChange:o,onEnterInlineEdit:s,autoFocusField:c,dataSource:l})=>{let u=e.collapsible??!0,[d,f]=K.useState(e.defaultCollapsed??!1),p=(0,q.jsx)(`div`,{className:`space-y-3 sm:space-y-4`,children:e.sections.map((e,n)=>(0,q.jsx)(V9,{section:e,data:t,objectSchema:r,objectName:i,isEditing:a,onFieldChange:o,onEnterInlineEdit:s,autoFocusField:c,dataSource:l},n))});return u?(0,q.jsxs)($X,{open:!d,onOpenChange:e=>f(!e),className:n,children:[(0,q.jsx)(eZ,{asChild:!0,children:(0,q.jsxs)(`div`,{className:`flex items-center gap-2 pb-2 border-b cursor-pointer hover:bg-muted/50 transition-colors rounded-t-md px-2 py-1.5`,children:[(0,q.jsx)(d?NC:jC,{className:`h-4 w-4 text-muted-foreground shrink-0`}),e.icon&&(0,q.jsx)(`span`,{className:`text-muted-foreground`,children:e.icon}),(0,q.jsx)(`h3`,{className:`text-lg font-semibold`,children:e.title})]})}),e.description&&!d&&(0,q.jsx)(`p`,{className:`text-sm text-muted-foreground mt-1`,children:e.description}),(0,q.jsx)(tZ,{children:(0,q.jsx)(`div`,{className:`mt-3`,children:p})})]}):(0,q.jsxs)(`div`,{className:J(`space-y-3`,n),children:[(0,q.jsxs)(`div`,{className:`flex items-center gap-2 pb-2 border-b`,children:[e.icon&&(0,q.jsx)(`span`,{className:`text-muted-foreground`,children:e.icon}),(0,q.jsx)(`h3`,{className:`text-lg font-semibold`,children:e.title})]}),e.description&&(0,q.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:e.description}),p]})},N6t=({fields:e,data:t,className:n,objectName:r,objectSchema:i,dataSource:a})=>{let{fieldLabel:o}=ym(),{t:s}=R9(),c=$p(),l=c?.editing??!1,u=c?.canEdit??!1;if(!e.length||!t)return null;let d=l?e:e.filter(e=>{let n=t?.[e.name];return n!=null&&n!==``});return d.length===0?null:(0,q.jsx)(E4,{children:(0,q.jsx)(`section`,{className:J(`@container border-b border-border/60 pb-4`,n),"aria-label":`Record highlights`,children:(0,q.jsx)(`div`,{className:J(`flex flex-wrap gap-y-4`),children:d.map(e=>{let n=t[e.name],d=i?.fields?.[e.name],f=e.type||d?.type,p=d?.reference_to||d?.reference,m={name:e.name,label:e.label,type:f||`text`,...d?.options&&{options:d.options},...d?.currency&&{currency:d.currency},...d?.currencyConfig&&{currencyConfig:d.currencyConfig},...d?.precision!==void 0&&{precision:d.precision},...d?.scale!==void 0&&{scale:d.scale},...d?.format&&{format:d.format},...p&&{reference_to:p},...d?.reference_field&&{reference_field:d.reference_field},...d?.widget&&{widget:d.widget}},h=c?.draft?.[e.name],g=h===void 0?n:h,_=B9.has(f),v=e.readonly===!0||d?.readonly===!0,y=T6t.has(e.name),b=u&&!_&&!v&&!y,x=l&&b,S=b7(v7(m)||f||`text`),C=f===`number`||f===`integer`||f===`currency`||f===`percent`||f===`decimal`,w=f===`email`||f===`url`||f===`textarea`||f===`reference`||f===`lookup`||f===`master_detail`,T=f===`boolean`,E=g==null||g===``;return(0,q.jsxs)(`div`,{className:J(`group flex flex-col gap-1 min-w-[7rem] px-5 border-l border-border/60 first:border-l-0 first:pl-0`,w||x?`basis-[16rem] max-w-[24rem]`:`basis-[9rem] max-w-[16rem]`),children:[(0,q.jsx)(`span`,{className:`text-xs font-medium text-muted-foreground`,children:o(r||``,e.name,e.label)}),x?(0,q.jsx)(E6t,{field:m,value:g,onChange:t=>c.setField(e.name,t),dataSource:a,autoFocus:c.autoFocusField===e.name}):(0,q.jsxs)(`div`,{className:J(`flex items-start justify-between gap-1`,b&&`cursor-pointer rounded-md -mx-1.5 px-1.5 hover:bg-muted/40 transition-colors`),onDoubleClick:b?()=>c.enter(e.name):void 0,title:b?s(`detail.editInlineHint`):void 0,children:[(0,q.jsx)(`div`,{className:`min-w-0 flex-1`,children:T?g?(0,q.jsxs)(`span`,{className:`inline-flex items-center gap-1 self-start rounded-full bg-emerald-500/10 px-2 py-0.5 text-xs font-medium text-emerald-600 ring-1 ring-inset ring-emerald-500/30 dark:text-emerald-400`,children:[(0,q.jsx)(sC,{className:`h-3 w-3`,"aria-hidden":!0}),`Yes`]}):(0,q.jsxs)(`span`,{className:`inline-flex items-center gap-1 self-start rounded-full bg-amber-500/10 px-2 py-0.5 text-xs font-medium text-amber-700 ring-1 ring-inset ring-amber-500/30 dark:text-amber-400`,children:[(0,q.jsx)(Uq,{className:`h-3 w-3`,"aria-hidden":!0}),`No`]}):E?(0,q.jsx)(`span`,{className:`block text-sm text-muted-foreground/60 select-none`,"aria-label":s(`detail.noValue`,{defaultValue:`No value`}),children:`—`}):(0,q.jsx)(`span`,{title:(Array.isArray(m.options)?m.options.find(e=>e?.value===g)?.label:void 0)??(typeof g==`string`||typeof g==`number`?String(g):void 0),className:J(`block min-w-0 truncate text-sm font-semibold`,C&&`tabular-nums tracking-tight`),children:(0,q.jsx)(S,{value:g,field:m})})}),b&&(0,q.jsxs)(D4,{children:[(0,q.jsx)(O4,{asChild:!0,children:(0,q.jsx)(Z,{variant:`ghost`,size:`icon`,className:`h-5 w-5 shrink-0 opacity-0 group-hover:opacity-100 transition-opacity`,"aria-label":s(`detail.editInlineHint`),onClick:t=>{t.stopPropagation(),c.enter(e.name)},children:(0,q.jsx)(mq,{className:`h-3 w-3`})})}),(0,q.jsx)(k4,{children:s(`detail.editInlineHint`)})]})]})]},e.name)})})})})};function P6t(e){try{let t=new Date(e),n=new Date().getTime()-t.getTime(),r=Math.floor(n/6e4);if(r<1)return`just now`;if(r<60)return`${r}m ago`;let i=Math.floor(r/60);if(i<24)return`${i}h ago`;let a=Math.floor(i/24);return a<7?`${a}d ago`:t.toLocaleDateString()}catch{return e}}var F6t=({comments:e,onAddComment:t,onTogglePin:n,searchable:r=!1,className:i})=>{let{t:a}=R9(),[o,s]=K.useState(``),[c,l]=K.useState(!1),[u,d]=K.useState(``),f=K.useCallback(async()=>{let e=o.trim();if(!(!e||!t)){l(!0);try{await t(e),s(``)}finally{l(!1)}}},[o,t]),p=K.useCallback(e=>{e.key===`Enter`&&(e.ctrlKey||e.metaKey)&&(e.preventDefault(),f())},[f]),m=K.useMemo(()=>[...u.trim()?e.filter(e=>{let t=u.trim().toLowerCase();return e.text.toLowerCase().includes(t)||e.author.toLowerCase().includes(t)}):e].sort((e,t)=>e.pinned&&!t.pinned?-1:!e.pinned&&t.pinned?1:0),[e,u]);return(0,q.jsxs)(lX,{className:J(``,i),children:[(0,q.jsx)(uX,{children:(0,q.jsxs)(dX,{className:`flex items-center gap-2 text-base`,children:[(0,q.jsx)(oq,{className:`h-4 w-4`}),a(`detail.comments`),(0,q.jsxs)(`span`,{className:`text-sm font-normal text-muted-foreground`,children:[`(`,e.length,`)`]})]})}),(0,q.jsxs)(pX,{className:`space-y-4`,children:[r&&(0,q.jsx)(`div`,{className:`flex items-center gap-2`,children:(0,q.jsxs)(`div`,{className:`relative flex-1`,children:[(0,q.jsx)(Sq,{className:`absolute left-2.5 top-1/2 -translate-y-1/2 h-3.5 w-3.5 text-muted-foreground`}),(0,q.jsx)(`input`,{className:`w-full rounded-md border border-input bg-background pl-8 pr-8 py-1.5 text-sm placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring`,placeholder:a(`detail.searchComments`),value:u,onChange:e=>d(e.target.value),"aria-label":a(`detail.searchComments`)}),u&&(0,q.jsx)(`button`,{className:`absolute right-2 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground`,onClick:()=>d(``),"aria-label":a(`detail.clearSearch`),type:`button`,children:(0,q.jsx)(Uq,{className:`h-3.5 w-3.5`})})]})}),t&&(0,q.jsxs)(`div`,{className:`flex gap-2`,children:[(0,q.jsx)(`textarea`,{className:`flex-1 min-h-[60px] rounded-md border border-input bg-background px-3 py-2 text-sm placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring resize-none`,placeholder:a(`detail.addCommentPlaceholder`),value:o,onChange:e=>s(e.target.value),onKeyDown:p,disabled:c}),(0,q.jsx)(Z,{size:`icon`,variant:`default`,onClick:f,disabled:!o.trim()||c,className:`shrink-0 self-end`,children:(0,q.jsx)(Cq,{className:`h-4 w-4`})})]}),m.length===0?(0,q.jsx)(`p`,{className:`text-sm text-muted-foreground text-center py-4`,children:u.trim()?a(`detail.noMatchingComments`):a(`detail.noCommentsYet`)}):(0,q.jsx)(`div`,{className:`space-y-3`,children:m.map(e=>(0,q.jsxs)(`div`,{className:J(`flex gap-3`,e.pinned&&`bg-muted/40 rounded-md p-2 -mx-2`),children:[(0,q.jsx)(`div`,{className:`shrink-0`,children:e.avatarUrl?(0,q.jsx)(`img`,{src:e.avatarUrl,alt:e.author,className:`h-8 w-8 rounded-full object-cover`}):(0,q.jsx)(`div`,{className:`h-8 w-8 rounded-full bg-muted flex items-center justify-center text-xs font-medium text-muted-foreground`,children:e.author.charAt(0).toUpperCase()})}),(0,q.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,q.jsxs)(`div`,{className:`flex items-center gap-2 mb-0.5`,children:[(0,q.jsx)(`span`,{className:`text-sm font-medium truncate`,children:e.author}),(0,q.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:P6t(e.createdAt)}),e.pinned&&(0,q.jsxs)(`span`,{className:`text-xs text-amber-600 flex items-center gap-0.5`,children:[(0,q.jsx)(gq,{className:`h-3 w-3`}),a(`detail.pinned`)]})]}),(0,q.jsx)(`p`,{className:`text-sm whitespace-pre-wrap break-words`,children:e.text}),n&&(0,q.jsxs)(`button`,{type:`button`,className:`mt-1 text-xs text-muted-foreground hover:text-foreground flex items-center gap-1`,onClick:()=>n(e.id),"aria-label":e.pinned?a(`detail.unpin`):a(`detail.pin`),children:[(0,q.jsx)(gq,{className:`h-3 w-3`}),e.pinned?a(`detail.unpin`):a(`detail.pin`)]})]})]},e.id))})]})]})},I6t={field_change:jq,create:GT,delete:Lq,comment:oq,status_change:Ch},L6t={field_change:`bg-blue-100 text-blue-600`,create:`bg-green-100 text-green-600`,delete:`bg-red-100 text-red-600`,comment:`bg-purple-100 text-purple-600`,status_change:`bg-amber-100 text-amber-600`};function R6t(e){try{let t=new Date(e),n=new Date().getTime()-t.getTime(),r=Math.floor(n/6e4);if(r<1)return`just now`;if(r<60)return`${r}m ago`;let i=Math.floor(r/60);if(i<24)return`${i}h ago`;let a=Math.floor(i/24);return a<7?`${a}d ago`:t.toLocaleDateString()}catch{return e}}function z6t(e){return e.description?e.description:e.type===`field_change`&&e.field?`Changed ${e.field.charAt(0).toUpperCase()+e.field.slice(1).replace(/_/g,` `)} from "${e.oldValue==null?`(empty)`:String(e.oldValue)}" to "${e.newValue==null?`(empty)`:String(e.newValue)}"`:e.type===`create`?`Created this record`:e.type===`delete`?`Deleted this record`:e.type===`status_change`&&e.field?`Changed status to "${e.newValue==null?`(empty)`:String(e.newValue)}"`:`Updated record`}var B6t={all:`All`,field_change:`Field Changes`,create:`Creates`,delete:`Deletes`,comment:`Comments`,status_change:`Status Changes`},V6t=({activities:e,filterable:t=!1,defaultFilter:n=`all`,className:r})=>{let[i,a]=K.useState(n),o=K.useMemo(()=>i===`all`?e:e.filter(e=>e.type===i),[e,i]);return(0,q.jsxs)(lX,{className:J(``,r),children:[(0,q.jsx)(uX,{children:(0,q.jsxs)(dX,{className:`flex items-center gap-2 text-base`,children:[(0,q.jsx)(bh,{className:`h-4 w-4`}),`Activity`,(0,q.jsxs)(`span`,{className:`text-sm font-normal text-muted-foreground`,children:[`(`,o.length,`)`]})]})}),(0,q.jsxs)(pX,{children:[t&&(0,q.jsx)(`div`,{className:`flex flex-wrap gap-1.5 mb-4`,role:`group`,"aria-label":`Activity type filter`,children:Object.keys(B6t).map(e=>(0,q.jsxs)(`button`,{type:`button`,className:J(`inline-flex items-center gap-1 rounded-full px-2.5 py-0.5 text-xs font-medium transition-colors`,i===e?`bg-primary text-primary-foreground`:`bg-muted text-muted-foreground hover:bg-muted/80`),onClick:()=>a(e),"aria-pressed":i===e,children:[e!==`all`&&K.createElement(I6t[e]||jq,{className:`h-3 w-3`}),B6t[e]]},e))}),o.length===0?(0,q.jsx)(I3,{title:`No activity recorded`,className:`py-6`}):(0,q.jsxs)(`div`,{className:`relative`,children:[(0,q.jsx)(`div`,{className:`absolute left-4 top-2 bottom-2 w-px bg-border`}),(0,q.jsx)(`div`,{className:`space-y-4`,children:o.map(e=>{let t=I6t[e.type]||jq;return(0,q.jsxs)(`div`,{className:`flex gap-3 relative`,children:[(0,q.jsx)(`div`,{className:J(`shrink-0 h-8 w-8 rounded-full flex items-center justify-center z-10`,L6t[e.type]||`bg-gray-100 text-gray-600`),children:(0,q.jsx)(t,{className:`h-3.5 w-3.5`})}),(0,q.jsxs)(`div`,{className:`flex-1 min-w-0 pt-1`,children:[(0,q.jsxs)(`p`,{className:`text-sm`,children:[(0,q.jsx)(`span`,{className:`font-medium`,children:e.user}),` `,(0,q.jsx)(`span`,{className:`text-muted-foreground`,children:z6t(e)})]}),(0,q.jsx)(`p`,{className:`text-xs text-muted-foreground mt-0.5`,children:R6t(e.timestamp)})]})]},e.id)})})]})]})]})},H6t={create:`default`,update:`secondary`,delete:`destructive`,restore:`outline`,login:`outline`,logout:`outline`,permission_change:`secondary`,config_change:`secondary`,export:`outline`,import:`outline`};function U9(e){if(!e)return``;let t=e instanceof Date?e:new Date(e);return Number.isNaN(t.getTime())?String(e):t.toLocaleString()}var U6t=[[60,`second`],[60,`minute`],[24,`hour`],[7,`day`],[4.34524,`week`],[12,`month`],[1/0,`year`]];function W6t(e,t){if(!e)return``;let n=e instanceof Date?e:new Date(e);if(Number.isNaN(n.getTime()))return String(e);let r=(n.getTime()-Date.now())/1e3;for(let[n,i]of U6t){if(Math.abs(r)<n)try{return new Intl.RelativeTimeFormat(t,{numeric:`auto`}).format(Math.round(r),i)}catch{return U9(e)}r/=n}return U9(e)}function G6t(e){if(!e)return`?`;let t=e.trim().split(/\s+/).filter(Boolean).slice(0,2);return t.length===0?`?`:t.map(e=>e.charAt(0).toUpperCase()).join(``)}function W9(e){if(e==null||e===``)return`—`;if(typeof e==`string`)return e;if(typeof e==`number`||typeof e==`boolean`)return String(e);try{return JSON.stringify(e)}catch{return String(e)}}function K6t({entries:e,loading:t,emptyText:n,className:r,locale:i}){return t?(0,q.jsx)(`div`,{className:J(`space-y-3`,r),children:Array.from({length:4}).map((e,t)=>(0,q.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,q.jsx)(g4,{className:`h-8 w-8 rounded-full`}),(0,q.jsxs)(`div`,{className:`flex-1 space-y-2`,children:[(0,q.jsx)(g4,{className:`h-4 w-1/3`}),(0,q.jsx)(g4,{className:`h-3 w-1/2`})]})]},t))}):!e||e.length===0?(0,q.jsx)(`div`,{className:J(`flex items-center justify-center rounded-md border border-dashed py-10 text-sm text-muted-foreground`,r),children:n??`No history yet`}):(0,q.jsx)(E4,{delayDuration:150,children:(0,q.jsx)(`ol`,{className:J(`space-y-4`,r),children:e.map((e,t)=>{let n=(e.action??``).toLowerCase(),r=H6t[n]??`outline`,a=typeof e.user_name==`string`&&e.user_name.trim()||`Unknown user`,o=U9(e.created_at),s=W6t(e.created_at,i),c=typeof e.user_avatar==`string`?e.user_avatar:void 0;return(0,q.jsxs)(`li`,{className:`flex items-start gap-3`,children:[(0,q.jsxs)(aY,{className:`h-8 w-8 mt-0.5 shrink-0`,children:[c?(0,q.jsx)(oY,{src:c,alt:a}):null,(0,q.jsx)(sY,{className:`text-[10px] font-medium`,children:G6t(e.user_name)})]}),(0,q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,q.jsxs)(`div`,{className:`flex flex-wrap items-baseline gap-x-2 gap-y-1`,children:[(0,q.jsx)(`span`,{className:`text-sm font-medium text-foreground`,children:a}),e.action&&(0,q.jsx)(cY,{variant:r,className:`text-[10px] uppercase tracking-wide`,children:e.action}),o&&(0,q.jsxs)(D4,{children:[(0,q.jsx)(O4,{asChild:!0,children:(0,q.jsx)(`span`,{className:`text-xs text-muted-foreground cursor-help`,"aria-label":o,children:s||o})}),(0,q.jsx)(k4,{children:o})]})]}),e.summary&&(0,q.jsx)(`p`,{className:`mt-1 text-sm text-muted-foreground`,children:e.summary}),e.changes&&e.changes.length>0&&(n===`create`?(0,q.jsxs)(`details`,{className:`mt-1 group`,children:[(0,q.jsxs)(`summary`,{className:`cursor-pointer list-none text-xs text-muted-foreground hover:text-foreground inline-flex items-center gap-1 select-none`,children:[(0,q.jsx)(`span`,{className:`transition-transform group-open:rotate-90`,children:`▸`}),(0,q.jsx)(`span`,{children:e.changes.length===1?`1 field populated`:`${e.changes.length} fields populated`})]}),(0,q.jsx)(`ul`,{className:`mt-1.5 space-y-0.5 text-xs text-muted-foreground pl-4`,children:e.changes.map(e=>(0,q.jsxs)(`li`,{className:`leading-relaxed`,children:[(0,q.jsx)(`span`,{className:`font-medium text-foreground`,children:e.label||e.field}),`: `,(0,q.jsx)(`span`,{className:`text-foreground`,children:W9(e.to)})]},e.field))})]}):(0,q.jsx)(`ul`,{className:`mt-1.5 space-y-0.5 text-xs text-muted-foreground`,children:e.changes.map(e=>(0,q.jsxs)(`li`,{className:`leading-relaxed`,children:[(0,q.jsx)(`span`,{className:`font-medium text-foreground`,children:e.label||e.field}),`: `,(0,q.jsx)(`span`,{className:`line-through opacity-70`,children:W9(e.from)}),` → `,(0,q.jsx)(`span`,{className:`text-foreground`,children:W9(e.to)})]},e.field))}))]})]},e.id??t)})})})}var G9={createdAt:`created_at`,createdBy:`created_by`,updatedAt:`updated_at`,updatedBy:`updated_by`};function q6t(e){if(!e)return null;if(e instanceof Date)return isNaN(e.getTime())?null:e;if(typeof e==`string`||typeof e==`number`){let t=new Date(e);return isNaN(t.getTime())?null:t}return null}function J6t(e,t){let n=Date.now()-e.getTime(),r=Math.max(0,Math.floor(n/1e3));if(r<60)return t(`detail.justNow`);let i=Math.floor(r/60);if(i<60)return t(`detail.minutesAgo`,{count:i});let a=Math.floor(i/60);return a<24?t(`detail.hoursAgo`,{count:a}):t(`detail.daysAgo`,{count:Math.floor(a/24)})}function Y6t(e){try{return new Intl.DateTimeFormat(void 0,{dateStyle:`medium`,timeStyle:`short`}).format(e)}catch{return e.toISOString()}}var X6t=({value:e,objectSchema:t,fieldName:n})=>{if(e==null||e===``)return null;let r=t?.fields?.[n],i=r?.reference_to||r?.reference,a={name:n,type:r?.type||(i?`lookup`:`text`),...i&&{reference_to:i},...r?.reference_field&&{reference_field:r.reference_field}},o=v7(a)||a.type;if(o){let t=b7(o);if(t)return(0,q.jsx)(`span`,{className:`inline-flex items-center [&_a]:text-inherit [&_a]:hover:underline`,children:K.createElement(t,{value:e,field:a})})}return(0,q.jsx)(`span`,{children:String(e)})},Z6t=({label:e,user:t,date:n,objectSchema:r,userField:i,t:a})=>{if(!t&&!n)return null;let o=n?(0,q.jsx)(E4,{delayDuration:200,children:(0,q.jsxs)(D4,{children:[(0,q.jsx)(O4,{asChild:!0,children:(0,q.jsx)(`time`,{dateTime:n.toISOString(),className:`cursor-default underline decoration-dotted decoration-muted-foreground/40 underline-offset-2`,children:J6t(n,a)})}),(0,q.jsx)(k4,{side:`top`,children:Y6t(n)})]})}):null;return(0,q.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[(0,q.jsx)(`span`,{className:`text-muted-foreground/70`,children:e}),t?(0,q.jsx)(X6t,{value:t,objectSchema:r,fieldName:i}):null,t&&o?(0,q.jsx)(`span`,{className:`text-muted-foreground/40`,children:`·`}):null,o]})},Q6t=({data:e,objectSchema:t,objectName:n,className:r})=>{let{t:i}=R9();if(!e)return null;let a=q6t(e[G9.createdAt]),o=q6t(e[G9.updatedAt]),s=e[G9.createdBy],c=e[G9.updatedBy],l=!!(a||s),u=a&&o&&Math.abs(o.getTime()-a.getTime())<2e3,d=!!(o||c)&&!(u&&(s!=null&&c!=null&&String(s)===String(c)||!c));return!l&&!d?null:(0,q.jsxs)(`div`,{className:J(`mt-6 pt-3 border-t border-border/40`,`flex flex-wrap items-center gap-x-4 gap-y-1`,`text-xs text-muted-foreground`,r),"data-testid":`record-meta-footer`,children:[l&&(0,q.jsx)(Z6t,{label:i(s?`detail.createdBy`:`detail.created`),user:s,date:a,objectSchema:t,userField:G9.createdBy,t:i}),d&&(0,q.jsx)(Z6t,{label:i(c?`detail.updatedBy`:`detail.updated`),user:c,date:o,objectSchema:t,userField:G9.updatedBy,t:i})]})},$6t=5,e8t={};function t8t(e,t,n,r){if(e&&typeof e==`object`){if(t.primaryField){let n=e[t.primaryField];if(n!=null&&n!==``)return String(n)}let r=Gae(n?.titleFormat,e);if(r)return r}if(e&&typeof e==`object`){let t=e.id??e._id,r=Fp(n,e,{deriveFromRecordKeys:!1});if(!(r===`Untitled`||t!=null&&r===`Record #${t}`))return r}if(t.title)return t.title;if(e&&typeof e==`object`){let t=e.id??e._id;if(t!=null&&String(t).trim()!==``)return`Record #${t}`}return r}var K9=({schema:e,dataSource:t,className:n,onEdit:r,onDelete:i,onBack:a,inlineEdit:o=!1,discussionSlot:s,rightRail:c,objectLabel:l,onDataLoaded:u,isFavorite:d,onToggleFavorite:f})=>{let[p,m]=K.useState(e.data),[h,g]=K.useState(!e.data&&!!(e.api&&e.resourceId||t&&e.objectName&&e.resourceId)),[_,v]=K.useState(!1),y=d??_,b=$p(),x=b?.editing??!1,S=b?.draft??e8t,w=b?.autoFocusField??null,[T,E]=K.useState(null),[D,O]=K.useState(null),[k,A]=K.useState(!1),[ee,te]=K.useState(0),j=Uoe(e.objectName||void 0,e.resourceId==null?void 0:String(e.resourceId)),[ne,re]=K.useState(!1),{t:M}=R9(),{currency:N}=xm(),{fieldOptionLabel:ie}=ym(),ae=h4(),oe=s9(),P=K.useMemo(()=>{if(!oe?.isLoaded||!e.objectName)return e;let t=t=>oe.checkField(e.objectName,t,`read`),n=e=>e&&e.filter(e=>{let n=typeof e==`string`?e:e?.name;return!n||t(n)});return{...e,fields:n(e.fields),sections:e.sections?.map(e=>({...e,fields:n(e.fields)})),summaryFields:n(e.summaryFields)}},[e,oe]);K.useEffect(()=>{p&&u&&u(p)},[p,u]);let se=K.useMemo(()=>{if(P.summaryFields&&P.summaryFields.length>0)return[];let e=[...P.sections?.flatMap(e=>e.fields)||[],...P.fields||[]],t={};for(let n of e)t[n.name]||(t[n.name]=n);if(D?.fields)for(let[e,n]of Object.entries(D.fields))t[e]={...t[e]||{},...n,name:e};let n=e=>p?.[e]!==void 0&&p?.[e]!==null&&p?.[e]!==``,r=[],i=[`status`,`stage`,`state`,`phase`].find(e=>t[e]&&n(e))||Object.keys(t).find(e=>t[e]?.type===`select`&&n(e));i&&r.push(i);let a=Object.keys(t).find(e=>(t[e]?.type===`currency`||/amount|revenue|value|total|price/i.test(e))&&n(e));a&&!r.includes(a)&&r.push(a);let o=Object.keys(t).find(e=>(t[e]?.type===`date`||t[e]?.type===`datetime`)&&/close|due|start|end|expected/i.test(e)&&n(e));return o&&!r.includes(o)&&r.push(o),r},[P.summaryFields,P.sections,P.fields,D,p]),ce=P.summaryFields&&P.summaryFields.length>0?P.summaryFields:se,le=K.useCallback(()=>{P.resourceId&&navigator.clipboard.writeText(String(P.resourceId)).then(()=>{A(!0),setTimeout(()=>A(!1),1500)})},[P.resourceId]);K.useEffect(()=>{let e=!0;if(P.data)return m(P.data),g(!1),t?.getObjectSchema&&P.objectName&&t.getObjectSchema(P.objectName).then(t=>{e&&O(t)}).catch(()=>{}),()=>{e=!1};if(t&&P.objectName&&P.resourceId){g(!0),O(null),m(null);let n=P.objectName,r=P.resourceId,i=`${n}-`,a=[...P.sections?.flatMap(e=>e.fields)||[],...P.fields||[]];(t.getObjectSchema?t.getObjectSchema(n).catch(()=>null):Promise.resolve(null)).then(o=>{if(!e)return;O(o);let s=C(o?.fields,a),c=s.length>0?{$expand:s}:void 0,l=c?t.findOne(n,r,c):t.findOne(n,r),u=()=>{let a=String(r),o=a.startsWith(i)?a.slice(i.length):`${i}${a}`;return(c?t.findOne(n,o,c):t.findOne(n,o)).then(t=>{e&&(m(t),g(!1))}).catch(()=>{e&&(m(null),g(!1))})};return l.catch(()=>null).then(t=>{if(e){if(t){m(t),g(!1);return}return u()}})}).catch(t=>{e&&(console.error(`Failed to fetch detail data:`,t),g(!1))})}else P.api&&P.resourceId&&(g(!0),fetch(`${P.api}/${P.resourceId}`).then(e=>e.json()).then(t=>{e&&m(t?.data||t)}).catch(e=>{console.error(`Failed to fetch detail data:`,e)}).finally(()=>{e&&g(!1)}));return()=>{e=!1}},[P.api,P.resourceId,P.objectName,t,P.sections,P.fields,ee,j]);let ue=K.useCallback(()=>{if(a)a();else if(P.onNavigate){let e=P.backUrl||(P.objectName?`/${P.objectName}`:`/`);P.onNavigate(e,{replace:!0})}else P.backUrl?window.location.href=P.backUrl:window.history.back()},[a,P]),de=K.useCallback(()=>{r?r():P.onNavigate&&P.editUrl?P.onNavigate(P.editUrl):P.onNavigate&&P.objectName&&P.resourceId?P.onNavigate(`/${P.objectName}/${P.resourceId}/edit`):P.editUrl&&(window.location.href=P.editUrl)},[r,P]),fe=K.useCallback(async()=>{if(!t?.cancelPendingApproval||!P.objectName||!P.resourceId){E(M(`detail.cancelApprovalUnavailable`));return}re(!0),E(null);try{if(await t.cancelPendingApproval(String(P.objectName),String(P.resourceId)),t.findOne)try{let e=await t.findOne(String(P.objectName),String(P.resourceId));e&&m(e)}catch{}te(e=>e+1);try{window.dispatchEvent(new CustomEvent(`objectui:record-changed`,{detail:{objectName:String(P.objectName),recordId:String(P.resourceId),reason:`approval-recalled`}}))}catch{}}catch(e){let t=(e?.message||e?.error||String(e??`Cancel failed`)).replace(/^\[[^\]]+\]\s*/,``).replace(/^[A-Z][A-Z0-9_]+:\s*/,``);E(`${M(`detail.cancelApprovalFailed`)}: ${t}`)}finally{re(!1)}},[t,P.objectName,P.resourceId,M]),pe=K.useCallback(()=>{let e=P.deleteConfirmation||M(`detail.deleteConfirmation`);window.confirm(e)&&(i?.(),P.onNavigate&&P.objectName&&P.onNavigate(`/${P.objectName}`,{replace:!0}))},[i,P]),me=K.useCallback(()=>{navigator.share&&P.objectName&&P.resourceId?navigator.share({title:P.title||M(`detail.details`),text:`${P.objectName} #${P.resourceId}`,url:window.location.href}).catch(e=>console.log(`Share failed:`,e)):navigator.clipboard.writeText(window.location.href).then(()=>{console.log(`Link copied to clipboard`)})},[P]),he=K.useCallback(()=>{let e=!y;f&&f(e),d===void 0&&v(e)},[y,d,f]),ge=b?.setField,_e=b&&b.canEdit?b.enter:void 0;K.useEffect(()=>{if(!P.recordNavigation)return;let e=P.recordNavigation,t=t=>{let n=t.target?.tagName;n===`INPUT`||n===`TEXTAREA`||t.target?.isContentEditable||(t.key===`ArrowLeft`&&e.currentIndex>0?(t.preventDefault(),e.onNavigate(e.recordIds[e.currentIndex-1])):t.key===`ArrowRight`&&e.currentIndex<e.recordIds.length-1&&(t.preventDefault(),e.onNavigate(e.recordIds[e.currentIndex+1])))};return document.addEventListener(`keydown`,t),()=>document.removeEventListener(`keydown`,t)},[P.recordNavigation]);let ve=K.useMemo(()=>P.related??[],[P.related]),ye=K.useMemo(()=>{let e=[];return e.push({name:`sys_share`,label:M(`detail.share`),icon:`share-2`,type:`script`,onClick:me}),P.showEdit&&e.push({name:`sys_edit_mobile`,label:M(`detail.edit`),icon:`edit`,type:`script`,className:`sm:hidden`,onClick:de}),P.showDelete&&e.push({name:`sys_delete`,label:M(`detail.delete`),icon:`trash-2`,type:`script`,variant:`destructive`,tags:[`separator-before`],onClick:pe}),e},[M,P.showEdit,P.showDelete,me,de,pe]),be=K.useMemo(()=>{let e=P.actions??[];if(ye.length===0)return e;let t=!1,n=e.map(e=>{let n=e;if(n&&typeof n==`object`&&n.type===`action:bar`&&(!n.location||n.location===`record_header`)){t=!0;let e=Array.isArray(n.systemActions)?n.systemActions:[];return{...n,systemActions:[...e,...ye]}}return e});return t||n.push({type:`action:bar`,location:`record_header`,systemActions:ye}),n},[P.actions,ye]);return h||P.loading?(0,q.jsxs)(`div`,{className:J(`space-y-4`,n),children:[(0,q.jsx)(g4,{className:`h-10 w-full`}),(0,q.jsx)(g4,{className:`h-64 w-full`}),(0,q.jsx)(g4,{className:`h-48 w-full`})]}):!p&&!P.data?(0,q.jsxs)(`div`,{className:J(`flex flex-col items-center justify-center py-16 text-center`,n),children:[(0,q.jsx)(`p`,{className:`text-lg font-semibold`,children:M(`detail.recordNotFound`)}),(0,q.jsx)(`p`,{className:`text-sm text-muted-foreground mt-1`,children:M(`detail.recordNotFoundDescription`)}),(P.showBack??!0)&&(0,q.jsxs)(Z,{variant:`outline`,size:`sm`,onClick:ue,className:`mt-4 gap-2`,children:[(0,q.jsx)(Sh,{className:`h-4 w-4`}),M(`detail.goBack`)]})]}):(0,q.jsx)(E4,{children:(0,q.jsxs)(`div`,{className:J(`space-y-6`,n),children:[P.showHeader!==!1&&(0,q.jsxs)(`div`,{className:`flex flex-col sm:flex-row items-start justify-between gap-3 sm:gap-4 pb-4 border-b`,children:[(0,q.jsxs)(`div`,{className:`flex items-start gap-2 sm:gap-3 flex-1 min-w-0`,children:[(P.showBack??!0)&&(0,q.jsxs)(D4,{children:[(0,q.jsx)(O4,{asChild:!0,children:(0,q.jsx)(Z,{variant:`ghost`,size:`icon`,onClick:ue,className:`shrink-0 mt-1`,children:(0,q.jsx)(Sh,{className:`h-4 w-4`})})}),(0,q.jsx)(k4,{children:M(`detail.back`)})]}),(0,q.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,q.jsxs)(`div`,{className:`flex items-center gap-2 flex-wrap`,children:[(0,q.jsx)(`h1`,{className:`text-xl sm:text-2xl font-bold truncate`,children:t8t(p,P,D,M(`detail.details`))}),ce.map(e=>{let t=p?.[e];if(t==null||t===``)return null;let n=(P.sections||[]).flatMap(e=>e.fields).concat(P.fields||[]).find(t=>t.name===e),r=D?.fields?.[e],i=n?.type||r?.type,a=String(t),o=null;try{if(i===`currency`){let e=Number(t);if(!Number.isNaN(e)){let t=Sm({...r,...n},N);a=t?new Intl.NumberFormat(void 0,{style:`currency`,currency:t,maximumFractionDigits:0}).format(e):new Intl.NumberFormat(void 0,{maximumFractionDigits:0}).format(e)}}else if(i===`date`||i===`datetime`){let e=new Date(t);Number.isNaN(e.getTime())||(a=i===`datetime`?e.toLocaleString(void 0,{dateStyle:`medium`,timeStyle:`short`}):e.toLocaleDateString(void 0,{dateStyle:`medium`}))}else if(i===`percent`){let e=Number(t);if(!Number.isNaN(e)){a=`${e}%`;let t=e<=1?e*100:e;o=Math.max(0,Math.min(100,t))}}else if(i===`select`||i===`status`||i===`multiselect`){let i=n?.options||r?.options,o=String(t);if(Array.isArray(i)){let e=i.find(e=>String(e?.value??e)===String(t));e?.label&&(o=e.label)}else if(i&&typeof i==`object`){let e=i[String(t)];e?.label&&(o=e.label)}a=P.objectName?ie(P.objectName,e,String(t),o):o}}catch{}return o===null?(0,q.jsx)(cY,{variant:`secondary`,className:`text-xs bg-primary/10 text-primary border-transparent hover:bg-primary/15`,"aria-label":`${e}: ${a}`,children:a},e):(0,q.jsxs)(cY,{variant:`secondary`,className:`text-xs bg-primary/10 text-primary border-transparent hover:bg-primary/15 gap-1.5 pl-2 pr-2`,"aria-label":`${e}: ${a}`,children:[(0,q.jsx)(`span`,{className:`relative inline-block h-1.5 w-12 rounded-full bg-primary/20 overflow-hidden`,"aria-hidden":!0,children:(0,q.jsx)(`span`,{className:`absolute inset-y-0 left-0 rounded-full bg-primary`,style:{width:`${o}%`}})}),a]},e)}),(0,q.jsxs)(D4,{children:[(0,q.jsx)(O4,{asChild:!0,children:(0,q.jsx)(Z,{variant:`ghost`,size:`icon`,className:`h-6 w-6 shrink-0`,onClick:he,"aria-label":M(y?`detail.removeFromFavorites`:`detail.addToFavorites`),children:y?(0,q.jsx)(Nq,{className:`h-4 w-4 fill-yellow-400 text-yellow-400`}):(0,q.jsx)(Nq,{className:`h-4 w-4 text-muted-foreground`})})}),(0,q.jsx)(k4,{children:M(y?`detail.removeFromFavorites`:`detail.addToFavorites`)})]})]}),P.objectName&&(0,q.jsxs)(`p`,{className:`text-sm text-muted-foreground mt-1 flex items-center gap-1`,children:[(0,q.jsx)(`span`,{className:`font-medium`,children:l||P.objectName}),P.resourceId&&(0,q.jsxs)(D4,{children:[(0,q.jsx)(O4,{asChild:!0,children:(0,q.jsx)(Z,{variant:`ghost`,size:`icon`,className:`h-5 w-5 shrink-0 text-muted-foreground/60 hover:text-foreground`,onClick:le,"aria-label":M(`detail.copyRecordId`,{defaultValue:`Copy record ID`}),children:k?(0,q.jsx)(sC,{className:`h-3 w-3 text-green-600`}):(0,q.jsx)(qk,{className:`h-3 w-3`})})}),(0,q.jsx)(k4,{children:k?M(`detail.copied`,{defaultValue:`Copied`}):M(`detail.copyRecordId`,{defaultValue:`Copy record ID`})})]})]})]})]}),(0,q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5 shrink-0 w-full sm:w-auto`,children:[P.recordNavigation&&(0,q.jsxs)(`div`,{className:`flex items-center gap-1 mr-2`,children:[(0,q.jsxs)(D4,{children:[(0,q.jsx)(O4,{asChild:!0,children:(0,q.jsx)(Z,{variant:`outline`,size:`icon`,className:`h-8 w-8`,disabled:P.recordNavigation.currentIndex<=0,onClick:()=>{let e=P.recordNavigation;e.currentIndex>0&&e.onNavigate(e.recordIds[e.currentIndex-1])},children:(0,q.jsx)(kC,{className:`h-4 w-4`})})}),(0,q.jsx)(k4,{children:M(`detail.previousRecord`)})]}),(0,q.jsx)(`span`,{className:`text-xs text-muted-foreground whitespace-nowrap px-1`,children:M(`detail.recordOf`,{current:P.recordNavigation.currentIndex+1,total:P.recordNavigation.recordIds.length})}),(0,q.jsxs)(D4,{children:[(0,q.jsx)(O4,{asChild:!0,children:(0,q.jsx)(Z,{variant:`outline`,size:`icon`,className:`h-8 w-8`,disabled:P.recordNavigation.currentIndex>=P.recordNavigation.recordIds.length-1,onClick:()=>{let e=P.recordNavigation;e.currentIndex<e.recordIds.length-1&&e.onNavigate(e.recordIds[e.currentIndex+1])},children:(0,q.jsx)(NC,{className:`h-4 w-4`})})}),(0,q.jsx)(k4,{children:M(`detail.nextRecord`)})]})]}),P.showEdit&&(0,q.jsxs)(D4,{children:[(0,q.jsx)(O4,{asChild:!0,children:(0,q.jsxs)(Z,{variant:`default`,onClick:de,className:`gap-2 hidden sm:inline-flex`,children:[(0,q.jsx)(jq,{className:`h-4 w-4`}),(0,q.jsx)(`span`,{className:`hidden sm:inline`,children:M(`detail.edit`)})]})}),(0,q.jsx)(k4,{children:M(`detail.editRecord`)})]}),be.map((e,t)=>(0,q.jsx)(Kp,{schema:e,data:p},`header-action-${t}`))]})]}),P.header&&(0,q.jsx)(`div`,{children:(0,q.jsx)(Kp,{schema:P.header,data:p})}),P.highlightFields&&P.highlightFields.length>0&&(0,q.jsx)(N6t,{fields:P.highlightFields,data:p,objectName:P.objectName,objectSchema:D}),o&&P.showHeader===!1&&(()=>{let e=p?.approval_status,n=e===`pending`||e===`in_approval`;return!n&&!T?null:(0,q.jsxs)(`div`,{className:`flex flex-col items-end gap-1`,children:[n&&(0,q.jsxs)(`div`,{className:`flex items-center justify-end gap-2`,children:[(0,q.jsxs)(`span`,{role:`status`,className:`inline-flex items-center gap-1 rounded-md border border-amber-300 bg-amber-50 px-2 py-1 text-xs text-amber-800`,title:M(`detail.lockedTooltip`),children:[(0,q.jsx)(tq,{className:`h-3 w-3`}),(0,q.jsx)(`span`,{children:M(`detail.lockedByApproval`)})]}),t?.cancelPendingApproval&&(0,q.jsxs)(Z,{variant:`outline`,size:`sm`,onClick:fe,disabled:ne,className:`gap-2 border-amber-300 text-amber-800 hover:bg-amber-50`,title:M(`detail.cancelApprovalTooltip`),children:[(0,q.jsx)(Uq,{className:`h-4 w-4`}),(0,q.jsx)(`span`,{children:M(ne?`detail.cancelApprovalInFlight`:`detail.cancelApproval`)})]})]}),T&&(0,q.jsx)(`div`,{role:`alert`,className:`text-xs text-destructive bg-destructive/10 border border-destructive/20 rounded-md px-2 py-1 max-w-md text-right`,children:T})]})})(),P.autoTabs&&!P.tabs?.length?(()=>{let e=ve.length>0,n=!!P.activities&&P.activities.length>0,r=!!s,i=!!P.history,a=[`details`,...e?[`related`]:[],...n?[`activity`]:[],...r?[`discussion`]:[],...i?[`history`]:[]],c=P.defaultTab,l=c&&a.includes(c)?c:`details`,u=P.onTabChange,d=(0,q.jsxs)(`div`,{className:`space-y-3 sm:space-y-4`,children:[P.sectionGroups&&P.sectionGroups.length>0&&P.sectionGroups.map((e,n)=>(0,q.jsx)(M6t,{group:e,data:{...p,...S},objectSchema:D,objectName:P.objectName,isEditing:x,onFieldChange:ge,onEnterInlineEdit:o?_e:void 0,autoFocusField:w,dataSource:t},n)),P.sections&&P.sections.length>0&&P.sections.map((e,n)=>(0,q.jsx)(V9,{section:e,data:{...p,...S},objectSchema:D,objectName:P.objectName,isEditing:x,onFieldChange:ge,onEnterInlineEdit:o?_e:void 0,autoFocusField:w,dataSource:t},n)),P.fields&&P.fields.length>0&&!P.sections?.length&&(0,q.jsx)(V9,{section:{fields:P.fields,columns:P.columns},data:{...p,...S},objectSchema:D,objectName:P.objectName,isEditing:x,onFieldChange:ge,onEnterInlineEdit:o?_e:void 0,autoFocusField:w,dataSource:t}),P.comments&&(0,q.jsx)(F6t,{comments:P.comments,onAddComment:P.onAddComment})]});return!e&&!n&&!r&&!i?(0,q.jsx)(`div`,{className:`mt-2`,children:d}):(0,q.jsxs)(o3,{defaultValue:l,onValueChange:u,className:`w-full`,children:[(0,q.jsxs)(s3,{className:`w-full justify-start border-b rounded-none bg-transparent p-0`,children:[(0,q.jsx)(c3,{value:`details`,className:`relative rounded-none border-b-2 border-transparent data-[state=active]:border-primary data-[state=active]:bg-transparent`,children:M(`detail.details`)}),e&&(0,q.jsx)(c3,{value:`related`,className:`relative rounded-none border-b-2 border-transparent data-[state=active]:border-primary data-[state=active]:bg-transparent`,children:(0,q.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[M(`detail.related`),(0,q.jsx)(cY,{variant:`secondary`,className:`text-xs bg-primary/10 text-primary border-transparent`,children:ve.length})]})}),n&&(0,q.jsx)(c3,{value:`activity`,className:`relative rounded-none border-b-2 border-transparent data-[state=active]:border-primary data-[state=active]:bg-transparent`,children:(0,q.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[M(`detail.activity`),(0,q.jsx)(cY,{variant:`secondary`,className:`text-xs bg-primary/10 text-primary border-transparent`,children:P.activities.length})]})}),r&&(0,q.jsx)(c3,{value:`discussion`,className:`relative rounded-none border-b-2 border-transparent data-[state=active]:border-primary data-[state=active]:bg-transparent`,children:M(`detail.discussion`,{defaultValue:`Discussion`})}),i&&(0,q.jsx)(c3,{value:`history`,className:`relative rounded-none border-b-2 border-transparent data-[state=active]:border-primary data-[state=active]:bg-transparent`,children:(0,q.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[M(`detail.history`,{defaultValue:`History`}),!P.history.loading&&P.history.entries.length>0&&(0,q.jsx)(cY,{variant:`secondary`,className:`text-xs bg-primary/10 text-primary border-transparent`,children:P.history.entries.length})]})})]}),(0,q.jsx)(l3,{value:`details`,className:`mt-4 motion-safe:data-[state=active]:animate-in motion-safe:data-[state=active]:fade-in-0 motion-safe:duration-150`,children:d}),e&&(0,q.jsx)(l3,{value:`related`,className:`mt-4 motion-safe:data-[state=active]:animate-in motion-safe:data-[state=active]:fade-in-0 motion-safe:duration-150`,children:(0,q.jsx)(`div`,{className:`space-y-3`,children:ve.map((e,n)=>(0,q.jsx)(H9,{title:e.title,type:e.type,api:e.api,data:e.data,columns:e.columns,dataSource:t,objectName:e.api,referenceField:e.referenceField,icon:e.icon,onNew:e.onNew,onViewAll:e.onViewAll,onRowClick:e.onRowClick,onRowEdit:e.onRowEdit,onRowDelete:e.onRowDelete,collapsible:!0,defaultCollapsed:ae&&n>0,pageSize:$6t},n))})}),n&&(0,q.jsx)(l3,{value:`activity`,className:`mt-4 motion-safe:data-[state=active]:animate-in motion-safe:data-[state=active]:fade-in-0 motion-safe:duration-150`,children:(0,q.jsx)(V6t,{activities:P.activities})}),r&&(0,q.jsx)(l3,{value:`discussion`,className:`mt-4 motion-safe:data-[state=active]:animate-in motion-safe:data-[state=active]:fade-in-0 motion-safe:duration-150`,children:s}),i&&(0,q.jsx)(l3,{value:`history`,className:`mt-4 motion-safe:data-[state=active]:animate-in motion-safe:data-[state=active]:fade-in-0 motion-safe:duration-150`,children:(0,q.jsx)(K6t,{entries:P.history.entries,loading:P.history.loading,emptyText:P.history.emptyText??M(`detail.historyEmpty`,{defaultValue:`No history yet`})})})]})})():(0,q.jsxs)(q.Fragment,{children:[P.sectionGroups&&P.sectionGroups.length>0&&(0,q.jsx)(`div`,{className:`space-y-3 sm:space-y-4`,children:P.sectionGroups.map((e,n)=>(0,q.jsx)(M6t,{group:e,data:{...p,...S},objectSchema:D,objectName:P.objectName,isEditing:x,onFieldChange:ge,onEnterInlineEdit:o?_e:void 0,autoFocusField:w,dataSource:t},n))}),P.sections&&P.sections.length>0&&(0,q.jsx)(`div`,{className:`space-y-3 sm:space-y-4`,children:P.sections.map((e,n)=>(0,q.jsx)(V9,{section:e,data:{...p,...S},objectSchema:D,objectName:P.objectName,isEditing:x,onFieldChange:ge,onEnterInlineEdit:o?_e:void 0,autoFocusField:w,dataSource:t},n))}),P.fields&&P.fields.length>0&&!P.sections?.length&&(0,q.jsx)(V9,{section:{fields:P.fields,columns:P.columns},data:{...p,...S},objectSchema:D,objectName:P.objectName,isEditing:x,onFieldChange:ge,onEnterInlineEdit:o?_e:void 0,autoFocusField:w,dataSource:t}),P.tabs&&P.tabs.length>0&&(0,q.jsx)(k6t,{tabs:P.tabs,data:p}),ve.length>0&&(0,q.jsxs)(`div`,{className:`space-y-3`,children:[(0,q.jsx)(`h2`,{className:`text-lg font-semibold`,children:M(`detail.related`)}),ve.map((e,n)=>(0,q.jsx)(H9,{title:e.title,type:e.type,api:e.api,data:e.data,columns:e.columns,dataSource:t,objectName:e.api,referenceField:e.referenceField,icon:e.icon,onNew:e.onNew,onViewAll:e.onViewAll,onRowClick:e.onRowClick,onRowEdit:e.onRowEdit,onRowDelete:e.onRowDelete,collapsible:!0,defaultCollapsed:ae&&n>0,pageSize:$6t},n))]}),P.comments&&(0,q.jsx)(F6t,{comments:P.comments,onAddComment:P.onAddComment}),P.activities&&P.activities.length>0&&(0,q.jsx)(V6t,{activities:P.activities})]}),(0,q.jsx)(Q6t,{data:{...p,...S},objectSchema:D,objectName:P.objectName}),P.footer&&(0,q.jsx)(`div`,{children:(0,q.jsx)(Kp,{schema:P.footer,data:p})})]})})},q9=e=>typeof e==`string`?e:e&&typeof e==`object`&&(e.field||e.name)||null,n8t=e=>{let{"data-obj-id":t,"data-obj-type":n,style:r,...i}=e||{};return{designer:{"data-obj-id":t,"data-obj-type":n,style:r},rest:i}},r8t=({schema:e={},className:t,...n})=>{let r=Qp(),{designer:i}=n8t(n),a=r?.objectName||``,o=s9(),{readableFields:s}=c9(a),{sectionLabel:c}=ym(),{language:l}=_m(),u=Coe();if(!r)return(0,q.jsx)(`div`,{className:t,"data-record-details-placeholder":!0,...i,children:(0,q.jsx)(`div`,{className:`text-xs text-muted-foreground italic px-3 py-2 border border-dashed rounded`,children:`record:details — bind a record to preview`})});let d=Array.isArray(e.requiredPermissions)?e.requiredPermissions:[];if(d.length>0&&a&&!d.every(e=>o.can(a,e)))return(0,q.jsx)(`div`,{className:t,...i,role:`status`,"aria-live":`polite`,children:(0,q.jsx)(`p`,{className:`text-sm text-muted-foreground italic`,children:`Insufficient permissions to view details.`})});let f=e.layout===`inline`||e.layout===`compact`?`horizontal`:`vertical`,p=e.enforceFieldSecurity===!0,m=Array.isArray(e.redactFields)?e.redactFields:[],h=e=>{if(!e||!p&&m.length===0)return e;let t=e.map(q9).filter(e=>!!e),n=new Set((p&&a?s(t):t).filter(e=>!m.includes(e)));return e.filter(e=>{let t=q9(e);return!t||n.has(t)})},g=e=>typeof e==`string`?{name:e}:e&&typeof e==`object`&&!e.name&&e.field?{...e,name:e.field}:e,_=e=>Array.isArray(e)?e.map(g):e,v=new Set((Array.isArray(e.hideFields)?e.hideFields:[]).map(e=>typeof e==`string`?e:q9(e)).filter(e=>!!e));for(let e of u)v.add(e);let y=r.objectSchema,b=r.data??{},x=[y?.primaryField,`name`,`full_name`,`title`,`subject`,`display_name`,`label`].filter(e=>typeof e==`string`&&e.length>0);for(let e of x)if(b[e]!==void 0&&b[e]!==null&&b[e]!==``){v.add(e);break}let S=e=>!e||v.size===0?e:e.filter(e=>{let t=q9(e);return!t||!v.has(t)}),C=S(_(h(e.fields))),w=Array.isArray(e.sections)?e.sections.map(e=>{let t=e.title??e.label,n=t==null?void 0:bm(t,l),r=e.name&&a?c(a,e.name,n??e.name):n;return{...e,title:r,showBorder:e.showBorder??!!r,hideEmpty:e.hideEmpty??!0,fields:S(_(h(e.fields)))}}):e.sections,T=new Set([`system`,`append-only`,`better-auth`]),E=y?.managedBy,D=y?.userActions?.edit??!(E!=null&&T.has(E)),O=(e.inlineEdit??!0)&&D,k={type:`detail-view`,objectName:r.objectName,resourceId:r.recordId,data:r.data,layout:f,columns:e.columns,sections:w,fields:C,showBack:!1,showHeader:e.showHeader??!1,inlineEdit:O};return(0,q.jsx)(`div`,{className:t,...i,children:(0,q.jsx)(K9,{schema:k,dataSource:r.dataSource,inlineEdit:O})})},i8t=e=>typeof e==`string`?e:e&&typeof e==`object`&&(e.field||e.name||e.key)||null,J9=e=>e?.id??e?._id??null,a8t=e=>{let{"data-obj-id":t,"data-obj-type":n,style:r,...i}=e||{};return{designer:{"data-obj-id":t,"data-obj-type":n,style:r},rest:i}},o8t=({schema:e={},className:t,...n})=>{let r=Qp(),{designer:i}=a8t(n),a=ym(),{language:o}=_m(),s=e.objectName,c=s&&a.objectLabel?a.objectLabel({name:s,label:o7(s)}):s?o7(s):``,l=bm(e.title,o)||c||`Related`;if(!s)return(0,q.jsx)(`div`,{className:t,...i,children:(0,q.jsx)(`div`,{className:`text-xs text-muted-foreground italic px-3 py-2 border border-dashed rounded`,children:`record:related_list — missing objectName`})});let u=s9(),{readableFields:d}=c9(s),f=e.relationshipValueField||`id`,p=f===`id`?r?.recordId??null:r?.data?.[f]??null,m=Ioe(),h=K.useMemo(()=>m?.resolve({objectName:s,relationshipField:e.relationshipField,parentId:p})??null,[m,s,e.relationshipField,p]);if(u.isLoaded&&!u.can(s,`read`))return null;let g=Array.isArray(e.requiredPermissions)?e.requiredPermissions:[];if(g.length>0&&!g.every(e=>u.can(s,e)))return(0,q.jsx)(`div`,{className:t,...i,role:`status`,"aria-live":`polite`,children:(0,q.jsx)(`p`,{className:`text-sm text-muted-foreground italic`,children:`Insufficient permissions to view related list.`})});let _=e.enforceFieldSecurity===!0,v=Array.isArray(e.redactFields)?e.redactFields:[],y=Array.isArray(e.columns)?e.columns:[],b=y;if(_||v.length>0){let e=y.map(i8t).filter(e=>!!e),t=new Set((_?d(e):e).filter(e=>!v.includes(e)));b=y.filter(e=>{let n=i8t(e);return!n||t.has(n)})}return(0,q.jsx)(`div`,{className:t,...i,children:(0,q.jsx)(H9,{title:l,type:`table`,api:s,objectName:s,referenceField:e.relationshipField,parentId:p,columns:b,pageSize:e.limit,dataSource:r?.dataSource,add:e.add?{...e.add,label:bm(e.add.label,o)||void 0}:void 0,rowActions:h?.rowActions,onRowAction:h?.onRowAction,toolbarActions:h?.toolbarActions,onToolbarAction:h?.onToolbarAction,onNew:h?.onCreate,onRowClick:h?.onView?e=>{let t=J9(e);t!=null&&h.onView(t,e)}:void 0,onRowEdit:h?.onEdit?e=>{let t=J9(e);t!=null&&h.onEdit(t,e)}:void 0,onRowDelete:h?.onDelete?e=>{let t=J9(e);if(t!=null)return h.onDelete(t,e)}:e.add&&r?.dataSource?async e=>{let t=e?.id??e?._id;t!=null&&await r.dataSource.delete?.(s,String(t))}:void 0})})},s8t=e=>{let{"data-obj-id":t,"data-obj-type":n,style:r,...i}=e||{};return{designer:{"data-obj-id":t,"data-obj-type":n,style:r},rest:i}},c8t=({schema:e={},className:t,...n})=>{let r=Qp(),{designer:i}=s8t(n),a=r?.objectName||``,o=s9(),{readableFields:s}=c9(a),c=Array.isArray(e.requiredPermissions)?e.requiredPermissions:[];if(c.length>0&&a&&!c.every(e=>o.can(a,e)))return(0,q.jsx)(`div`,{className:t,...i,role:`status`,"aria-live":`polite`,children:(0,q.jsx)(`p`,{className:`text-sm text-muted-foreground italic`,children:`Insufficient permissions to view highlights.`})});let l=(Array.isArray(e.fields)?e.fields:[]).map(e=>typeof e==`string`?{name:e}:{name:e?.name,label:e?.label,icon:e?.icon,type:e?.type}).filter(e=>typeof e.name==`string`&&e.name.length>0),u=e.enforceFieldSecurity===!0,d=Array.isArray(e.redactFields)?e.redactFields:[],f=u&&a?new Set(s(l.map(e=>e.name))):null,p=l.filter(e=>!(d.includes(e.name)||f&&!f.has(e.name)));return woe(K.useId(),p.map(e=>e.name)),(0,q.jsx)(`div`,{className:t,...i,children:(0,q.jsx)(N6t,{fields:p,data:r?.data,objectName:r?.objectName,objectSchema:r?.objectSchema,dataSource:r?.dataSource})})},l8t=({change:e,className:t})=>{let n=e.fieldLabel??e.field.charAt(0).toUpperCase()+e.field.slice(1).replace(/_/g,` `),r=e.oldDisplayValue??(e.oldValue==null?`(empty)`:String(e.oldValue)),i=e.newDisplayValue??(e.newValue==null?`(empty)`:String(e.newValue));return(0,q.jsxs)(`div`,{className:J(`flex items-center gap-1.5 text-sm flex-wrap`,t),children:[(0,q.jsx)(`span`,{className:`font-medium text-foreground`,children:n}),(0,q.jsx)(`span`,{className:`text-muted-foreground line-through`,children:r}),(0,q.jsx)(wh,{className:`h-3 w-3 text-muted-foreground shrink-0`}),(0,q.jsx)(`span`,{className:`text-foreground`,children:i})]})},u8t=[`👍`,`❤️`,`🎉`,`😂`,`😮`,`😢`],d8t=({reactions:e,onToggleReaction:t,emojiOptions:n=u8t,className:r})=>{let[i,a]=K.useState(!1),o=K.useCallback(e=>{t?.(e),a(!1)},[t]);return(0,q.jsxs)(`div`,{className:J(`flex items-center gap-1 flex-wrap`,r),children:[e.map(e=>(0,q.jsxs)(`button`,{type:`button`,className:J(`inline-flex items-center gap-1 rounded-full px-2 py-0.5 text-xs border transition-colors`,e.reacted?`bg-primary/10 border-primary/30 text-primary`:`bg-muted border-border text-muted-foreground hover:bg-muted/80`),onClick:()=>o(e.emoji),disabled:!t,"aria-label":`${e.emoji} ${e.count} reaction${e.count===1?``:`s`}`,children:[(0,q.jsx)(`span`,{children:e.emoji}),(0,q.jsx)(`span`,{children:e.count})]},e.emoji)),t&&(0,q.jsxs)(`div`,{className:`relative`,children:[(0,q.jsx)(Z,{variant:`ghost`,size:`icon`,className:`h-6 w-6`,onClick:()=>a(!i),"aria-label":`Add reaction`,children:(0,q.jsx)(Eq,{className:`h-3.5 w-3.5`})}),i&&(0,q.jsx)(`div`,{className:`absolute bottom-full mb-1 left-0 bg-popover border rounded-md shadow-md z-50 p-1.5 flex gap-1`,role:`listbox`,"aria-label":`Emoji picker`,children:n.map(t=>(0,q.jsx)(`button`,{type:`button`,className:`hover:bg-accent rounded p-1 text-base transition-colors`,onClick:()=>o(t),role:`option`,"aria-selected":e.some(e=>e.emoji===t&&e.reacted),children:t},t))})]})]})};function f8t(e,t){try{let n=new Date(e),r=new Date().getTime()-n.getTime(),i=Math.floor(r/6e4);if(i<1)return t(`detail.justNow`);if(i<60)return t(`detail.minutesAgo`,{count:i});let a=Math.floor(i/60);if(a<24)return t(`detail.hoursAgo`,{count:a});let o=Math.floor(a/24);return o<7?t(`detail.daysAgo`,{count:o}):n.toLocaleDateString()}catch{return e}}var p8t=({parentItem:e,replies:t,onAddReply:n,showReplyInput:r=!0,className:i})=>{let{t:a}=R9(),[o,s]=K.useState(!1),[c,l]=K.useState(``),[u,d]=K.useState(!1),f=K.useCallback(async()=>{let t=c.trim();if(!(!t||!n)){d(!0);try{await n(e.id,t),l(``)}finally{d(!1)}}},[c,n,e.id]),p=K.useCallback(e=>{e.key===`Enter`&&(e.ctrlKey||e.metaKey)&&(e.preventDefault(),f())},[f]);return t.length===0&&!r?null:(0,q.jsxs)(`div`,{className:J(`ml-10 mt-1`,i),children:[t.length>0&&(0,q.jsxs)(`button`,{type:`button`,className:`flex items-center gap-1 text-xs text-muted-foreground hover:text-foreground transition-colors mb-1`,onClick:()=>s(!o),"aria-expanded":o,children:[(0,q.jsx)(o?jC:NC,{className:`h-3 w-3`}),(0,q.jsx)(oq,{className:`h-3 w-3`}),(0,q.jsx)(`span`,{children:t.length===1?a(`detail.replyCount`,{count:t.length}):a(`detail.replyCountPlural`,{count:t.length})})]}),o&&(0,q.jsx)(`div`,{className:`space-y-2 border-l-2 border-border pl-3`,children:t.map(e=>(0,q.jsxs)(`div`,{className:`flex gap-2`,children:[(0,q.jsx)(`div`,{className:`shrink-0`,children:e.actorAvatarUrl?(0,q.jsx)(`img`,{src:e.actorAvatarUrl,alt:e.actor,className:`h-6 w-6 rounded-full object-cover`}):(0,q.jsx)(`div`,{className:`h-6 w-6 rounded-full bg-muted flex items-center justify-center text-[10px] font-medium text-muted-foreground`,children:e.actor.charAt(0).toUpperCase()})}),(0,q.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,q.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,q.jsx)(`span`,{className:`text-xs font-medium`,children:e.actor}),(0,q.jsx)(`span`,{className:`text-[10px] text-muted-foreground`,children:f8t(e.createdAt,a)})]}),(0,q.jsx)(`p`,{className:`text-xs whitespace-pre-wrap break-words`,children:e.body})]})]},e.id))}),r&&n&&(0,q.jsxs)(`div`,{className:`flex gap-1.5 mt-1.5`,children:[(0,q.jsx)(`input`,{className:`flex-1 rounded-md border border-input bg-background px-2 py-1 text-xs placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring`,placeholder:a(`detail.replyPlaceholder`),value:c,onChange:e=>l(e.target.value),onKeyDown:p,disabled:u}),(0,q.jsx)(Z,{variant:`ghost`,size:`icon`,className:`h-6 w-6 shrink-0`,onClick:f,disabled:!c.trim()||u,"aria-label":`Send reply`,children:(0,q.jsx)(Cq,{className:`h-3 w-3`})})]})]})},m8t=({subscription:e,onToggle:t,className:n})=>{let{t:r}=R9(),[i,a]=K.useState(!1),o=K.useCallback(async()=>{if(t){a(!0);try{await t(!e.subscribed)}finally{a(!1)}}},[t,e.subscribed]);return(0,q.jsx)(Z,{variant:`ghost`,size:`icon`,className:J(`h-8 w-8`,n),onClick:o,disabled:i||!t,"aria-label":e.subscribed?r(`detail.unsubscribeAriaLabel`):r(`detail.subscribeAriaLabel`),title:e.subscribed?r(`detail.subscribedTooltip`):r(`detail.unsubscribedTooltip`),children:e.subscribed?(0,q.jsx)(Fg,{className:`h-4 w-4 text-primary`}):(0,q.jsx)(kg,{className:`h-4 w-4 text-muted-foreground`})})};function h8t(e){let t=e.replace(/&/g,`&`).replace(/</g,`<`).replace(/>/g,`>`).replace(/```([\s\S]*?)```/g,`<pre class="bg-muted rounded p-2 text-xs font-mono my-1 overflow-x-auto">$1</pre>`).replace(/`([^`]+)`/g,`<code class="bg-muted rounded px-1 py-0.5 text-xs font-mono">$1</code>`).replace(/\*\*(.+?)\*\*/g,`<strong>$1</strong>`).replace(/\*(.+?)\*/g,`<em>$1</em>`).replace(/@(\w+)/g,`<span class="text-primary font-medium">@$1</span>`).replace(/^- (.+)$/gm,`<li class="ml-4 list-disc">$1</li>`).replace(/\n/g,`<br/>`);return t=t.replace(/(<li[^>]*>.*?<\/li>(?:<br\/>)?)+/g,e=>`<ul class="my-1">${e.replace(/<br\/>/g,``)}</ul>`),t}var g8t=({value:e,onChange:t,onSubmit:n,mentionSuggestions:r=[],placeholder:i,className:a,disabled:o=!1,extraSlot:s,canSubmitEmpty:c=!1})=>{let{t:l}=R9(),[u,d]=K.useState(!1),[f,p]=K.useState(!1),[m,h]=K.useState(``),[g,_]=K.useState(0),v=K.useRef(null),y=K.useMemo(()=>{if(!m)return r;let e=m.toLowerCase();return r.filter(t=>t.label.toLowerCase().includes(e))},[m,r]),b=K.useCallback((n,r=``)=>{let i=v.current;if(!i)return;let a=i.selectionStart,o=i.selectionEnd,s=e.slice(a,o);t(e.slice(0,a)+n+s+r+e.slice(o)),requestAnimationFrame(()=>{i.focus();let e=a+n.length+s.length;i.setSelectionRange(e,e)})},[e,t]),x=K.useCallback(()=>b(`**`,`**`),[b]),S=K.useCallback(()=>b(`*`,`*`),[b]),C=K.useCallback(()=>b(`
|
|
217
|
-
- `,``),[b]),w=K.useCallback(()=>b("`","`"),[b]),T=K.useCallback(()=>{b(`@`,``),p(!0),h(``),_(0)},[b]),E=K.useCallback(n=>{let r=v.current;if(!r)return;let i=r.selectionStart,a=e.slice(0,i).lastIndexOf(`@`);a!==-1&&t(e.slice(0,a)+`@${n.label} `+e.slice(i)),p(!1),h(``),requestAnimationFrame(()=>r.focus())},[e,t]),D=K.useCallback(e=>{let n=e.target.value;t(n);let r=e.target.selectionStart,i=n.slice(0,r),a=i.lastIndexOf(`@`);if(a!==-1){let e=i.slice(a+1),t=a>0?i[a-1]:` `;if(/\s/.test(t)&&!/\s/.test(e)){p(!0),h(e),_(0);return}}p(!1)},[t]),O=K.useCallback(e=>{if(f&&y.length>0){if(e.key===`ArrowDown`){e.preventDefault(),_(e=>e<y.length-1?e+1:0);return}if(e.key===`ArrowUp`){e.preventDefault(),_(e=>e>0?e-1:y.length-1);return}if(e.key===`Enter`||e.key===`Tab`){e.preventDefault(),E(y[g]);return}if(e.key===`Escape`){p(!1);return}}e.key===`Enter`&&(e.ctrlKey||e.metaKey)&&(e.preventDefault(),n?.())},[f,y,g,E,n]);return(0,q.jsxs)(`div`,{className:J(`border rounded-md`,a),children:[(0,q.jsxs)(`div`,{className:`flex items-center gap-0.5 px-2 py-1.5 border-b bg-muted/30`,children:[(0,q.jsx)(Z,{variant:`ghost`,size:`icon`,className:`h-7 w-7`,onClick:x,disabled:o||u,title:l(`detail.bold`),children:(0,q.jsx)(T_,{className:`h-3.5 w-3.5`})}),(0,q.jsx)(Z,{variant:`ghost`,size:`icon`,className:`h-7 w-7`,onClick:S,disabled:o||u,title:l(`detail.italic`),children:(0,q.jsx)(tW,{className:`h-3.5 w-3.5`})}),(0,q.jsx)(Z,{variant:`ghost`,size:`icon`,className:`h-7 w-7`,onClick:C,disabled:o||u,title:l(`detail.listFormat`),children:(0,q.jsx)(ZK,{className:`h-3.5 w-3.5`})}),(0,q.jsx)(Z,{variant:`ghost`,size:`icon`,className:`h-7 w-7`,onClick:w,disabled:o||u,title:l(`detail.inlineCode`),children:(0,q.jsx)(UO,{className:`h-3.5 w-3.5`})}),(0,q.jsx)(Z,{variant:`ghost`,size:`icon`,className:`h-7 w-7`,onClick:T,disabled:o||u,title:l(`detail.mentionSomeone`),children:(0,q.jsx)(Oh,{className:`h-3.5 w-3.5`})}),(0,q.jsx)(`div`,{className:`flex-1`}),(0,q.jsx)(Z,{variant:`ghost`,size:`icon`,className:`h-7 w-7`,onClick:()=>d(!u),title:l(u?`detail.edit`:`detail.preview`),children:(0,q.jsx)(u?jq:FN,{className:`h-3.5 w-3.5`})}),n&&(0,q.jsx)(Z,{variant:`ghost`,size:`icon`,className:`h-7 w-7`,onClick:n,disabled:o||!c&&!e.trim(),title:l(`detail.submitComment`),children:(0,q.jsx)(Cq,{className:`h-3.5 w-3.5`})})]}),(0,q.jsx)(`div`,{className:`relative`,children:u?(0,q.jsx)(`div`,{className:`min-h-[80px] px-3 py-2 text-sm prose prose-sm max-w-none`,dangerouslySetInnerHTML:{__html:h8t(e)}}):(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(`textarea`,{ref:v,className:`w-full min-h-[80px] px-3 py-2 text-sm bg-transparent resize-none focus:outline-none placeholder:text-muted-foreground`,placeholder:i??l(`detail.writeComment`),value:e,onChange:D,onKeyDown:O,disabled:o}),f&&y.length>0&&(0,q.jsx)(`div`,{className:`absolute left-2 bottom-full mb-1 w-56 bg-popover border rounded-md shadow-md z-50 max-h-40 overflow-y-auto`,children:y.map((e,t)=>(0,q.jsxs)(`button`,{type:`button`,className:J(`w-full text-left px-3 py-1.5 text-sm flex items-center gap-2 hover:bg-accent transition-colors`,t===g&&`bg-accent`),onMouseDown:t=>{t.preventDefault(),E(e)},children:[e.avatarUrl?(0,q.jsx)(`img`,{src:e.avatarUrl,alt:e.label,className:`h-5 w-5 rounded-full object-cover`}):(0,q.jsx)(`div`,{className:`h-5 w-5 rounded-full bg-muted flex items-center justify-center text-[10px] font-medium`,children:e.label.charAt(0).toUpperCase()}),(0,q.jsx)(`span`,{children:e.label})]},e.id))})]})}),s&&(0,q.jsx)(`div`,{className:`border-t px-2 py-2 bg-muted/20`,children:s})]})};function _8t(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`}function v8t(e){return e.startsWith(`image/`)}function y8t(e){return v8t(e)?zU:e.includes(`pdf`)||e.includes(`document`)||e.includes(`text`)?rI:e.includes(`zip`)||e.includes(`archive`)||e.includes(`compressed`)?YN:xI}var b8t=({attachments:e,onUpload:t,onRemove:n,className:r,readOnly:i=!1})=>{let{t:a}=R9(),[o,s]=K.useState(!1),c=K.useRef(null),l=K.useCallback(e=>{e.preventDefault(),e.stopPropagation(),s(!0)},[]),u=K.useCallback(e=>{e.preventDefault(),e.stopPropagation(),s(!1)},[]),d=K.useCallback(e=>{e.preventDefault(),e.stopPropagation(),s(!1),t&&e.dataTransfer.files.length>0&&t(e.dataTransfer.files)},[t]),f=K.useCallback(e=>{t&&e.target.files&&e.target.files.length>0&&(t(e.target.files),e.target.value=``)},[t]);return(0,q.jsxs)(`div`,{className:J(`space-y-2`,r),children:[t&&!i&&(0,q.jsxs)(`div`,{className:J(`border-2 border-dashed rounded-md px-4 py-3 text-center transition-colors cursor-pointer`,o?`border-primary bg-primary/5`:`border-muted-foreground/25 hover:border-muted-foreground/40`),onDragOver:l,onDragLeave:u,onDrop:d,onClick:()=>c.current?.click(),role:`button`,tabIndex:0,onKeyDown:e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),c.current?.click())},children:[(0,q.jsx)(Vq,{className:`h-5 w-5 mx-auto text-muted-foreground mb-1`}),(0,q.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:a(`detail.dropFilesToUpload`)}),(0,q.jsx)(`input`,{ref:c,type:`file`,multiple:!0,className:`hidden`,onChange:f})]}),e.length>0&&(0,q.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,q.jsxs)(`div`,{className:`flex items-center gap-1.5 text-xs text-muted-foreground`,children:[(0,q.jsx)(pq,{className:`h-3 w-3`}),(0,q.jsx)(`span`,{children:e.length===1?a(`detail.attachmentCount`,{count:e.length}):a(`detail.attachmentCountPlural`,{count:e.length})})]}),(0,q.jsx)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 gap-2`,children:e.map(e=>{let t=v8t(e.type),r=y8t(e.type);return(0,q.jsxs)(`div`,{className:`flex items-center gap-2 rounded-md border px-2.5 py-2 bg-muted/30 group`,children:[t&&(e.thumbnailUrl||e.url)?(0,q.jsx)(`img`,{src:e.thumbnailUrl||e.url,alt:e.name,className:`h-10 w-10 rounded object-cover shrink-0`}):(0,q.jsx)(`div`,{className:`h-10 w-10 rounded bg-muted flex items-center justify-center shrink-0`,children:(0,q.jsx)(r,{className:`h-5 w-5 text-muted-foreground`})}),(0,q.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,q.jsx)(`p`,{className:`text-xs font-medium truncate`,children:e.name}),(0,q.jsx)(`p`,{className:`text-[10px] text-muted-foreground`,children:_8t(e.size)})]}),n&&!i&&(0,q.jsx)(Z,{variant:`ghost`,size:`icon`,className:`h-6 w-6 shrink-0 opacity-0 group-hover:opacity-100 transition-opacity`,onClick:()=>n(e.id),title:a(`detail.removeAttachment`),children:(0,q.jsx)(Uq,{className:`h-3.5 w-3.5`})})]},e.id)})})]})]})},x8t={comment:oq,field_change:jq,task:Oq,event:$b,system:Wq,email:nq,call:hq},S8t={comment:`bg-purple-100 text-purple-600`,field_change:`bg-blue-100 text-blue-600`,task:`bg-green-100 text-green-600`,event:`bg-amber-100 text-amber-600`,system:`bg-gray-100 text-gray-600`,email:`bg-indigo-100 text-indigo-600`,call:`bg-teal-100 text-teal-600`};function C8t(e){return[{value:`all`,label:e(`detail.allActivity`)},{value:`comments_only`,label:e(`detail.commentsOnly`)},{value:`changes_only`,label:e(`detail.fieldChangesFilter`)},{value:`tasks_only`,label:e(`detail.tasksOnly`)}]}function w8t(e,t){try{let n=new Date(e),r=new Date().getTime()-n.getTime(),i=Math.floor(r/6e4);if(i<1)return t(`detail.justNow`);if(i<60)return t(`detail.minutesAgo`,{count:i});let a=Math.floor(i/60);if(a<24)return t(`detail.hoursAgo`,{count:a});let o=Math.floor(a/24);return o<7?t(`detail.daysAgo`,{count:o}):n.toLocaleDateString()}catch{return e}}function T8t(e,t){switch(t){case`comments_only`:return e.filter(e=>e.type===`comment`);case`changes_only`:return e.filter(e=>e.type===`field_change`);case`tasks_only`:return e.filter(e=>e.type===`task`);default:return e}}var Y9=({items:e,config:t,filterMode:n,onFilterChange:r,hasMore:i=!1,onLoadMore:a,loading:o=!1,onAddComment:s,onAddReply:c,onToggleReaction:l,subscription:u,onToggleSubscription:d,collapseWhenEmpty:f=!1,mentionSuggestions:p,onUploadAttachments:m,titleLabel:h,emptyLabel:g,className:_})=>{let{t:v}=R9(),[y,b]=K.useState(`all`),[x,S]=K.useState(``),[C,w]=K.useState(!1),[T,E]=K.useState(!1),[D,O]=K.useState([]),[k,A]=K.useState(!1),ee=n??y,te=t?.showFilterToggle!==!1,j=t?.showCommentInput!==!1&&!!s,ne=t?.enableReactions??!1,re=t?.enableThreading??!1,M=t?.showSubscriptionToggle??!1,N=K.useMemo(()=>T8t(e,ee),[e,ee]),ie=K.useMemo(()=>re?N.filter(e=>!e.parentId):N,[N,re]),ae=K.useMemo(()=>{if(!re)return new Map;let e=new Map;for(let t of N)if(t.parentId){let n=e.get(t.parentId)??[];n.push(t),e.set(t.parentId,n)}return e},[N,re]),oe=K.useCallback(e=>{r?r(e):b(e)},[r]),P=K.useCallback(async()=>{let e=x.trim();if(s&&!(!e&&D.length===0)){w(!0);try{await s(e,D.length>0?D:void 0),S(``),O([])}finally{w(!1)}}},[x,D,s]),se=K.useCallback(async e=>{if(!(!m||e.length===0)){A(!0);try{let t=await m(e);Array.isArray(t)&&t.length>0&&O(e=>[...e,...t])}finally{A(!1)}}},[m]),ce=K.useCallback(e=>{O(t=>t.filter(t=>t.id!==e))},[]),le=K.useCallback(async()=>{if(a){E(!0);try{await a()}finally{E(!1)}}},[a]);return(0,q.jsxs)(`section`,{className:J(`border-t border-border/60 pt-5`,_),"aria-label":`Discussion`,children:[(0,q.jsx)(`header`,{className:`mb-4`,children:(0,q.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,q.jsxs)(`h2`,{className:`flex items-center gap-2 text-base font-semibold leading-none tracking-tight`,children:[(0,q.jsx)(bh,{className:`h-4 w-4`}),h??v(`detail.activity`),(0,q.jsxs)(`span`,{className:`text-sm font-normal text-muted-foreground`,children:[`(`,N.length,`)`]})]}),(0,q.jsx)(`div`,{className:`flex items-center gap-1`,children:M&&u&&(0,q.jsx)(m8t,{subscription:u,onToggle:d})})]})}),(0,q.jsxs)(`div`,{className:`space-y-4`,children:[te&&(0,q.jsx)(`div`,{className:`flex items-center gap-2`,children:(0,q.jsxs)(r4,{value:ee,onValueChange:e=>oe(e),children:[(0,q.jsx)(a4,{"aria-label":v(`detail.filterActivity`),className:`h-8 w-auto min-w-[140px] py-1 text-sm`,children:(0,q.jsx)(i4,{})}),(0,q.jsx)(o4,{children:C8t(v).map(e=>(0,q.jsx)(s4,{value:e.value,children:e.label},e.value))})]})}),j&&(0,q.jsx)(g8t,{value:x,onChange:S,onSubmit:P,mentionSuggestions:p,placeholder:v(`detail.leaveCommentPlaceholder`),disabled:C,canSubmitEmpty:D.length>0,extraSlot:m?(0,q.jsx)(b8t,{attachments:D,onUpload:se,onRemove:ce,readOnly:C||k}):D.length>0?(0,q.jsx)(b8t,{attachments:D,onRemove:ce,readOnly:C}):void 0}),N.length===0?f?null:(0,q.jsx)(I3,{title:g??v(`detail.noActivity`),className:`py-6`}):(0,q.jsxs)(`div`,{className:`relative`,children:[(0,q.jsx)(`div`,{className:`absolute left-4 top-2 bottom-2 w-px bg-border`}),(0,q.jsx)(`div`,{className:`space-y-4`,children:ie.map(e=>{let t=x8t[e.type]||Wq,n=S8t[e.type]||`bg-gray-100 text-gray-600`,r=ae.get(e.id)??[];return(0,q.jsxs)(`div`,{children:[(0,q.jsxs)(`div`,{className:`flex gap-3 relative`,children:[(0,q.jsx)(`div`,{className:J(`shrink-0 h-8 w-8 rounded-full flex items-center justify-center z-10`,n),children:e.actorAvatarUrl?(0,q.jsx)(`img`,{src:e.actorAvatarUrl,alt:e.actor,className:`h-8 w-8 rounded-full object-cover`}):(0,q.jsx)(t,{className:`h-3.5 w-3.5`})}),(0,q.jsxs)(`div`,{className:`flex-1 min-w-0 pt-1`,children:[(0,q.jsxs)(`div`,{className:`flex items-center gap-2 mb-0.5`,children:[(0,q.jsx)(`span`,{className:`text-sm font-medium`,children:e.actor}),e.source&&(0,q.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:v(`detail.via`,{source:e.source})}),(0,q.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:w8t(e.createdAt,v)}),e.edited&&(0,q.jsx)(`span`,{className:`text-xs text-muted-foreground italic`,children:v(`detail.edited`)}),e.pinned&&(0,q.jsxs)(`span`,{className:`text-xs text-amber-600`,children:[`📌 `,v(`detail.pinned`)]})]}),e.body&&(0,q.jsx)(`p`,{className:`text-sm whitespace-pre-wrap break-words text-muted-foreground`,children:e.body}),e.sourceObject&&e.sourceId!=null&&(0,q.jsxs)(`a`,{href:`/objects/${e.sourceObject}/${e.sourceId}`,className:`mt-1 inline-flex items-center gap-1 text-xs text-primary hover:underline`,"data-testid":`activity-source-link`,children:[v(`detail.viewSource`),(0,q.jsx)(`span`,{"aria-hidden":!0,children:`→`})]}),e.type===`field_change`&&e.fieldChanges&&(0,q.jsx)(`div`,{className:`space-y-1 mt-1`,children:e.fieldChanges.map((e,t)=>(0,q.jsx)(l8t,{change:e},t))}),ne&&e.reactions&&e.reactions.length>0&&(0,q.jsx)(`div`,{className:`mt-1.5`,children:(0,q.jsx)(d8t,{reactions:e.reactions,onToggleReaction:l?t=>l(e.id,t):void 0})}),ne&&(!e.reactions||e.reactions.length===0)&&l&&(0,q.jsx)(`div`,{className:`mt-1.5`,children:(0,q.jsx)(d8t,{reactions:[],onToggleReaction:t=>l(e.id,t)})})]})]}),re&&(e.replyCount??0)>0&&(0,q.jsx)(p8t,{parentItem:e,replies:r,onAddReply:c,showReplyInput:!!c})]},e.id)})})]}),i&&(0,q.jsx)(`div`,{className:`text-center pt-2`,children:(0,q.jsxs)(Z,{variant:`ghost`,size:`sm`,onClick:le,disabled:T,"aria-label":v(`detail.loadMore`),children:[T?(0,q.jsx)(eq,{className:`h-4 w-4 animate-spin mr-1`}):(0,q.jsx)(jC,{className:`h-4 w-4 mr-1`}),v(`detail.loadMore`)]})})]})]})},E8t=e=>{let{"data-obj-id":t,"data-obj-type":n,style:r,...i}=e||{};return{designer:{"data-obj-id":t,"data-obj-type":n,style:r},rest:i}},D8t=({schema:e={},className:t,...n})=>{Qp();let{designer:r}=E8t(n);return(0,q.jsx)(`div`,{className:t,...r,children:(0,q.jsx)(Y9,{items:[],config:e})})},O8t=({config:e,items:t,hasMore:n,onLoadMore:r,loading:i,onAddComment:a,onAddReply:o,onToggleReaction:s,subscription:c,onToggleSubscription:l,filterMode:u,onFilterChange:d,collapseWhenEmpty:f=!1,mentionSuggestions:p,onUploadAttachments:m,className:h})=>{let g=e?.position??`right`,_=e?.width??`360px`,v=e?.collapsible??!0,y=f&&t.length===0||(e?.defaultCollapsed??!1),{t:b}=R9(),[x,S]=K.useState(y);return g===`right`||g===`left`?x&&v?(0,q.jsx)(`div`,{className:J(`flex items-start pt-4`,g===`right`?`border-l`:`border-r`,h),children:(0,q.jsx)(Z,{variant:`ghost`,size:`icon`,className:`h-8 w-8 mx-1`,onClick:()=>S(!1),"aria-label":b(`detail.openDiscussion`),children:(0,q.jsx)(fq,{className:`h-4 w-4`})})}):(0,q.jsxs)(`div`,{className:J(`flex flex-col overflow-hidden`,g===`right`?`border-l`:`border-r`,h),style:{width:_,minWidth:_},children:[(0,q.jsxs)(`div`,{className:`flex items-center justify-between px-4 py-3 border-b`,children:[(0,q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,q.jsx)(oq,{className:`h-4 w-4`}),(0,q.jsx)(`span`,{className:`text-sm font-medium`,children:b(`detail.discussion`)})]}),v&&(0,q.jsx)(Z,{variant:`ghost`,size:`icon`,className:`h-7 w-7`,onClick:()=>S(!0),"aria-label":b(`detail.closeDiscussion`),children:(0,q.jsx)(Uq,{className:`h-3.5 w-3.5`})})]}),(0,q.jsx)(`div`,{className:`flex-1 overflow-y-auto`,children:(0,q.jsx)(Y9,{items:t,config:e?.feed,hasMore:n,onLoadMore:r,loading:i,onAddComment:a,onAddReply:o,onToggleReaction:s,subscription:c,onToggleSubscription:l,filterMode:u,onFilterChange:d,collapseWhenEmpty:f,mentionSuggestions:p,onUploadAttachments:m,titleLabel:b(`detail.discussion`),emptyLabel:b(`detail.noCommentsYet`),className:`border-0 shadow-none`})})]}):(0,q.jsx)(`div`,{className:J(``,h),children:v&&x?(0,q.jsxs)(Z,{variant:`ghost`,className:`w-full justify-start gap-2 text-muted-foreground`,onClick:()=>S(!1),"aria-label":b(`detail.showDiscussion`,{count:t.length}),children:[(0,q.jsx)(oq,{className:`h-4 w-4`}),(0,q.jsx)(`span`,{children:b(`detail.showDiscussion`,{count:t.length})})]}):(0,q.jsxs)(`div`,{children:[v&&(0,q.jsxs)(`div`,{className:`flex items-center justify-between mb-2`,children:[(0,q.jsxs)(`div`,{className:`flex items-center gap-2 text-sm font-medium`,children:[(0,q.jsx)(oq,{className:`h-4 w-4`}),b(`detail.discussion`)]}),(0,q.jsx)(Z,{variant:`ghost`,size:`icon`,className:`h-7 w-7`,onClick:()=>S(!0),"aria-label":b(`detail.hideDiscussion`),children:(0,q.jsx)(dq,{className:`h-3.5 w-3.5`})})]}),(0,q.jsx)(Y9,{items:t,config:e?.feed,hasMore:n,onLoadMore:r,loading:i,onAddComment:a,onAddReply:o,onToggleReaction:s,subscription:c,onToggleSubscription:l,filterMode:u,onFilterChange:d,collapseWhenEmpty:f,mentionSuggestions:p,onUploadAttachments:m,titleLabel:b(`detail.discussion`),emptyLabel:b(`detail.noCommentsYet`)})]})})},k8t=e=>{let{"data-obj-id":t,"data-obj-type":n,style:r,...i}=e||{};return{designer:{"data-obj-id":t,"data-obj-type":n,style:r},rest:i}},A8t=({schema:e={},className:t,...n})=>{Qp();let r=Moe(),{designer:i}=k8t(n),a={position:`bottom`,collapsible:!1,feed:{enableReactions:!0,enableThreading:!0,showCommentInput:!0},...e};return(0,q.jsx)(`div`,{className:t,...i,children:(0,q.jsx)(O8t,{items:r?.items||[],config:a,onAddComment:r?.onAddComment,onAddReply:r?.onAddReply,onToggleReaction:r?.onToggleReaction,mentionSuggestions:r?.mentionSuggestions,onUploadAttachments:r?.onUploadAttachments})})},j8t=e=>{let{"data-obj-id":t,"data-obj-type":n,style:r,...i}=e||{};return{designer:{"data-obj-id":t,"data-obj-type":n,style:r},rest:i}},M8t=({schema:e={},className:t,...n})=>{let r=Qp(),{translateOptions:i}=ym(),{designer:a}=j8t(n),o=Array.isArray(e.stages)?e.stages:[],s=e.statusField,c=K.useMemo(()=>{if(o.length===0||!s||!r?.objectName)return o;let e=i(r.objectName,s,o);return Array.isArray(e)&&e.length===o.length?o.map((t,n)=>({...t,label:e[n]?.label??t.label})):o},[o,s,r?.objectName,i]),l=s&&r?.data?r.data[s]:void 0,u=/(^|[_-\s])(closed_)?(lost|failed?|cancell?ed|失败|流失|丢单|败)([_-\s]|$)/i,d=/(^|[_-\s])(closed_)?(won|success|成交|赢|完成)([_-\s]|$)/i,f=c.map(e=>{if(e.terminal)return e.terminal;let t=`${String(e.value??``)} ${String(e.label??``)}`;if(u.test(t))return`lost`;if(d.test(t))return`won`}),p=f.findIndex(e=>e===`lost`),m=p===-1?c:c.slice(0,p),h=p===-1?[]:c.slice(p),g=p===-1?f:f.slice(0,p),_=c.findIndex(e=>e.value===l);_<0&&(_=-1);let v=p!==-1&&_>=p;if(c.length===0)return(0,q.jsx)(`div`,{className:t,...a,children:(0,q.jsx)(`div`,{className:`text-xs text-muted-foreground italic px-3 py-2 border border-dashed rounded`,children:`record:path — no stages configured`})});let y=m.length-1;return(0,q.jsxs)(`div`,{className:J(`w-full`,t),...a,children:[(0,q.jsxs)(`div`,{className:`hidden sm:flex w-full items-stretch gap-2`,role:`list`,"aria-label":e.aria?.label||`Record path`,children:[(0,q.jsx)(`div`,{className:`flex flex-1 items-stretch gap-1.5`,children:m.map((e,t)=>{let n=!v&&_>=0&&t<_,r=!v&&t===_,i=g[t]===`won`&&t===y;return(0,q.jsx)(`div`,{role:`listitem`,"aria-current":r?`step`:void 0,className:J(`relative flex-1 min-w-0 px-4 py-2 text-xs font-medium text-center rounded-xl`,r&&`bg-primary text-primary-foreground shadow-sm`,n&&`bg-emerald-500/15 text-emerald-800 dark:text-emerald-200`,!r&&!n&&i&&`bg-emerald-500/10 text-emerald-700/85 dark:text-emerald-300/85`,!r&&!n&&!i&&`bg-muted text-muted-foreground`),children:(0,q.jsxs)(`span`,{className:`inline-flex items-center justify-center gap-1.5 truncate`,children:[n&&(0,q.jsx)(`span`,{"aria-hidden":!0,className:`text-emerald-600 dark:text-emerald-400 font-semibold`,children:`✓`}),i&&!r&&(0,q.jsx)(`span`,{"aria-hidden":!0,className:`opacity-70`,children:`🏆`}),e.label]})},`${e.value}-${t}`)})}),h.length>0&&(0,q.jsx)(`div`,{className:`flex items-stretch gap-1 pl-2 border-l border-border/40`,"aria-label":`Alternative terminal stages`,children:h.map((e,t)=>{let n=p+t===_;return(0,q.jsx)(`div`,{role:`listitem`,"aria-current":n?`step`:void 0,className:J(`shrink-0 px-3 py-2 text-xs font-medium rounded-md border whitespace-nowrap`,n&&`bg-destructive text-destructive-foreground border-destructive shadow-sm ring-1 ring-destructive/40`,!n&&`bg-destructive/5 text-destructive/85 border-destructive/20`),children:(0,q.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,q.jsx)(`span`,{"aria-hidden":!0,className:`opacity-70`,children:`✗`}),e.label]})},`${e.value}-lost-${t}`)})})]}),(0,q.jsx)(`div`,{className:`flex sm:hidden w-full items-stretch gap-1 overflow-x-auto pb-1 -mx-1 px-1 [-ms-overflow-style:none] [scrollbar-width:none] [&::-webkit-scrollbar]:hidden`,role:`list`,"aria-label":e.aria?.label||`Record path`,children:c.map((e,t)=>{let n=f[t]===`lost`,r=!n&&!v&&_>=0&&t<_,i=t===_;return(0,q.jsx)(`div`,{role:`listitem`,"aria-current":i?`step`:void 0,className:J(`shrink-0 px-3 py-1.5 rounded-full text-xs font-medium border whitespace-nowrap`,n&&i&&`bg-destructive text-destructive-foreground border-destructive shadow-sm`,n&&!i&&`bg-destructive/5 text-destructive/85 border-destructive/20`,!n&&i&&`bg-primary text-primary-foreground border-primary shadow-sm ring-1 ring-primary/40`,!n&&r&&`bg-emerald-500/15 text-emerald-800 dark:text-emerald-200 border-emerald-500/30`,!n&&!i&&!r&&`bg-background text-foreground/85 border-border/60`),children:(0,q.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[n&&(0,q.jsx)(`span`,{"aria-hidden":!0,className:`opacity-70`,children:`✗`}),!n&&r&&(0,q.jsx)(`span`,{"aria-hidden":!0,className:`text-emerald-600 dark:text-emerald-400 font-semibold`,children:`✓`}),e.label]})},`${e.value}-${t}-m`)})})]})},N8t=e=>{let{"data-obj-id":t,"data-obj-type":n,style:r,...i}=e||{};return{designer:{"data-obj-id":t,"data-obj-type":n,style:r},rest:i}},P8t=({schema:e={},className:t,...n})=>{let r=Qp(),{designer:i}=N8t(n),a=s9(),{language:o}=_m(),s=ym(),c=Array.isArray(e.actions)?e.actions:Array.isArray(e.properties?.actions)?e.properties.actions:[],l=Array.isArray(e.actionNames)?e.actionNames:Array.isArray(e.properties?.actionNames)?e.properties.actionNames:[],u=r?.objectName||``,d=l.length>0?l:Array.isArray(c)&&c.every(e=>typeof e==`string`)?c:[],f=d.length>0&&!!u,{item:p}=Zp(`object`,f?u:null),m=f?(()=>{let e=Array.isArray(p?.actions)?p.actions:[],t=new Map(e.map(e=>[e.name,e]));return d.map(e=>t.get(e)).filter(e=>!!e)})():Array.isArray(c)?c:[],h=Array.isArray(e.requiredPermissions)?e.requiredPermissions:[];if(h.length>0&&u&&!h.every(e=>a.can(u,e)))return(0,q.jsx)(`div`,{className:t,...i,role:`status`,"aria-live":`polite`,children:(0,q.jsx)(`p`,{className:`text-sm text-muted-foreground italic`,children:`Insufficient permissions to view quick actions.`})});let g=e.location||`record_header`,{getActionsForLocation:_,executeAction:v}=zoe({actions:m,context:{record:r?.data,recordId:r?.recordId,objectName:r?.objectName}}),y=m.length>0?_(g):[];if(y.length===0)return(0,q.jsx)(`div`,{className:t,...i,children:(0,q.jsx)(`div`,{className:`text-xs text-muted-foreground italic px-3 py-2 border border-dashed rounded`,children:`record:quick_actions — no actions configured`})});let b=e.align||`end`,x=b===`start`?`justify-start`:b===`center`?`justify-center`:`justify-end`;return(0,q.jsx)(`div`,{className:J(`flex flex-wrap items-center gap-2`,g===`record_header`&&!e.inline&&`-mt-12 sm:-mt-14 mb-2 relative z-10`,x,t),role:`toolbar`,"aria-label":e.aria?.label||`Quick actions`,...i,children:y.map((t,n)=>(0,q.jsx)(F8t,{action:t,record:r?.data,variant:t.variant||e.variant||`default`,size:t.size||e.size||`sm`,label:(()=>{let e=bm(t.label,o)||t.name||`Action ${n+1}`;return t.name?s.actionLabel(u||void 0,t.name,e):e})(),onRun:async()=>{typeof t.onClick==`function`?await t.onClick():t.name&&await v(t.name)}},t.name||`qa-${n}`))})};function F8t({action:e,record:t,variant:n,size:r,label:i,onRun:a}){let[o,s]=K.useState(!1),c=K.useMemo(()=>({record:t||{}}),[t]),l=zp(e.disabled),u=Bp(typeof l==`string`?l:void 0,c);return(0,q.jsxs)(Z,{variant:n,size:r,disabled:(typeof l==`string`?u:l===!0)||o,onClick:async()=>{s(!0);try{await a()}finally{s(!1)}},children:[o&&(0,q.jsx)(eq,{className:`mr-2 h-4 w-4 animate-spin`}),i]})}var I8t=e=>{let{"data-obj-id":t,"data-obj-type":n,style:r,...i}=e||{};return{designer:{"data-obj-id":t,"data-obj-type":n,style:r},rest:i}},L8t=new Set([`created`,`updated`,`assigned`,`shared`,`deleted`]),R8t=({schema:e={},className:t,...n})=>{let{designer:r}=I8t(n),i=Qp(),a=Array.isArray(e.entries)?e.entries:Array.isArray(e.properties?.entries)?e.properties.entries:void 0,o=e.loading??e.properties?.loading,s=e.emptyText??e.properties?.emptyText,c=Number(e.limit??e.properties?.limit??50)||50,l=i?.objectName,u=i?.data?.id??i?.data?._id??i?.recordId,d=i?.dataSource,f=a===void 0&&!!d?.find&&!!l&&u!=null,[p,m]=K.useState(null),[h,g]=K.useState(!1);K.useEffect(()=>{if(!f)return;let e=!1;return g(!0),Promise.resolve(d.find(`sys_activity`,{$filter:{object_name:l,record_id:u},$orderby:{timestamp:`desc`},$top:Math.max(1,c)})).then(t=>{if(e)return;let n=(t?.data??t?.records??[]).filter(e=>L8t.has(e?.type)).map(e=>{let t=e.timestamp;return(!t||t===`NOW()`||Number.isNaN(Date.parse(t)))&&(t=e.created_at),{id:e.id,created_at:t,action:e.type,user_name:e.actor_name??null,user_avatar:e.actor_avatar_url??null,summary:e.summary??null}});m(n)}).catch(()=>{e||m([])}).finally(()=>{e||g(!1)}),()=>{e=!0}},[f,d,l,u,c]);let _=a??p??[],v=o??(f&&p===null?h||!0:!1);return(0,q.jsx)(`div`,{className:t,...r,children:(0,q.jsx)(K6t,{entries:_,loading:v,emptyText:s})})},z8t=e=>{let{"data-obj-id":t,"data-obj-type":n,style:r,...i}=e||{};return{designer:{"data-obj-id":t,"data-obj-type":n,style:r},rest:i}},X9=e=>e.replace(/[_-]+/g,` `).replace(/\b\w/g,e=>e.toUpperCase()).trim(),B8t=(e,t)=>t&&e?.[t]!=null&&e[t]!==``?String(e[t]):e?.name||e?.title||e?.subject||e?.label||e?.email||e?.username||e?.code||e?.slug||e?.provider_id||e?.user_agent||e?.ip_address||e?.id||`—`,V8t=({schema:e={},className:t,...n})=>{let r=Qp(),i=ym(),{t:a}=R9(),{designer:o}=z8t(n),s=P1t().appName,c=Array.isArray(e.entries)?e.entries:Array.isArray(e.properties?.entries)?e.properties.entries:[],l=r?.recordId,u=r?.dataSource,[d,f]=K.useState({}),p=K.useRef(null),[m,h]=K.useState(!1),g=K.useRef(!0);K.useEffect(()=>(g.current=!0,()=>{g.current=!1}),[]);let _=K.useRef(``);K.useEffect(()=>{if(m)return;let e=p.current;if(!e||typeof IntersectionObserver>`u`){h(!0);return}let t=new IntersectionObserver(e=>{e.some(e=>e.isIntersecting)&&h(!0)},{rootMargin:`200px`});return t.observe(e),()=>t.disconnect()},[m]);let v=JSON.stringify(c.map(e=>`${e.objectName}:${e.relationshipField}:${e.limit??3}`));if(K.useEffect(()=>{if(!m||!u?.find||!l||c.length===0)return;let e=`${l}::${v}`;if(_.current===e)return;_.current=e,f(e=>{let t={...e};for(let n of c)t[n.objectName]={loading:!0,total:0,items:e[n.objectName]?.items||[]};return t});let t=async e=>{let t=e.objectName;try{let n=await u.find(e.objectName,{$filter:{[e.relationshipField]:l},$top:e.limit??3,$count:!0});if(!g.current)return;let r=Array.isArray(n)?n:n?.data||[],i=typeof n?.total==`number`?n.total:typeof n?.count==`number`?n.count:r.length;f(e=>({...e,[t]:{loading:!1,total:i,items:r}}))}catch(e){if(!g.current)return;f(n=>({...n,[t]:{loading:!1,total:0,items:[],error:String(e?.message||e)}}))}},n=[...c],r=async()=>{for(;g.current;){let e=n.shift();if(!e)return;await t(e)}},i=Array.from({length:Math.min(3,n.length)},()=>r());Promise.all(i)},[m,u,l,v]),c.length===0)return null;let y=e.hideEmpty!==!1,[b,x]=K.useState(!1),S=new Set(c.filter(e=>{let t=d[e.objectName];return y&&t&&!t.loading&&!t.error&&t.total===0}).map(e=>e.objectName)),C=c.filter(e=>b||!S.has(e.objectName)),w=c.filter(e=>S.has(e.objectName)).map(e=>e.title||(i?.objectLabel?i.objectLabel({name:e.objectName,label:X9(e.objectName)}):X9(e.objectName)));return(0,q.jsxs)(`div`,{ref:p,className:J(`flex flex-col gap-3`,e.className,t),...o,children:[C.map(e=>{let t=e.objectName,n=d[t]||{loading:!0,total:0,items:[]};return(0,q.jsxs)(lX,{className:`overflow-hidden`,children:[(0,q.jsxs)(uX,{className:`flex flex-row items-center justify-between gap-2 py-3 px-4 space-y-0 border-b`,children:[(0,q.jsx)(dX,{className:`text-sm font-semibold tracking-tight truncate`,children:e.title||(i?.objectLabel?i.objectLabel({name:e.objectName,label:X9(e.objectName)}):X9(e.objectName))}),(0,q.jsxs)(`div`,{className:`flex items-center gap-2 shrink-0`,children:[!n.loading&&(0,q.jsx)(cY,{variant:`secondary`,className:`tabular-nums`,children:n.total}),s&&l&&(0,q.jsx)(n9,{to:`/apps/${s}/${e.objectName}?filter%5B${e.relationshipField}%5D=${encodeURIComponent(String(l))}`,className:`text-[11px] font-medium text-muted-foreground hover:text-foreground transition-colors`,title:a(`detail.viewAll`,{defaultValue:`View all`}),children:a(`detail.viewAll`,{defaultValue:`View all`})})]})]}),(0,q.jsx)(pX,{className:`p-0`,children:n.loading?(0,q.jsxs)(`div`,{className:`space-y-1.5 p-3`,children:[(0,q.jsx)(g4,{className:`h-3.5 w-4/5`}),(0,q.jsx)(g4,{className:`h-3.5 w-3/5`}),(0,q.jsx)(g4,{className:`h-3.5 w-2/3`})]}):n.items.length===0?(0,q.jsx)(`p`,{className:`px-4 py-3 text-xs text-muted-foreground`,children:a(`detail.noRecords`)}):(0,q.jsx)(`ul`,{className:`divide-y`,children:n.items.map(t=>{let n=t.id||t._id,r=B8t(t,e.displayField),i=n?`../${e.objectName}/record/${encodeURIComponent(String(n))}`:void 0;return(0,q.jsx)(`li`,{className:`px-4 py-2`,children:i?(0,q.jsxs)(n9,{to:i,className:`group flex items-center justify-between gap-2 text-xs hover:text-foreground text-muted-foreground transition-colors`,children:[(0,q.jsx)(`span`,{className:`truncate`,children:r}),(0,q.jsx)(NC,{className:`h-3 w-3 shrink-0 opacity-0 group-hover:opacity-100 transition-opacity`})]}):(0,q.jsx)(`span`,{className:`block truncate text-xs text-muted-foreground`,children:r})},String(n||r))})})})]},t)}),!b&&w.length>0&&(0,q.jsxs)(`button`,{type:`button`,onClick:()=>x(!0),className:`self-start inline-flex items-center gap-1.5 text-[11px] text-muted-foreground hover:text-foreground transition-colors px-2.5 py-1 rounded-md border border-dashed border-border/60 hover:border-border bg-background`,title:w.join(` · `),children:[(0,q.jsx)(`span`,{children:a(`detail.showEmptyRelated`,{defaultValue:`+ {{count}} empty`,count:w.length})}),(0,q.jsxs)(`span`,{className:`truncate max-w-[180px] text-muted-foreground/70`,children:[`(`,w.join(` · `),`)`]})]})]})},H8t={info:{wrap:`border-blue-300/60 bg-blue-50 text-blue-900 dark:border-blue-700/40 dark:bg-blue-950/30 dark:text-blue-100 [&>svg]:text-blue-600 dark:[&>svg]:text-blue-300`,icon:`Info`},warning:{wrap:`border-amber-300/60 bg-amber-50 text-amber-900 dark:border-amber-700/40 dark:bg-amber-950/30 dark:text-amber-100 [&>svg]:text-amber-600 dark:[&>svg]:text-amber-300`,icon:`AlertTriangle`},error:{wrap:`border-destructive/60 bg-destructive/10 text-destructive dark:bg-destructive/20 [&>svg]:text-destructive`,icon:`AlertCircle`},success:{wrap:`border-emerald-300/60 bg-emerald-50 text-emerald-900 dark:border-emerald-700/40 dark:bg-emerald-950/30 dark:text-emerald-100 [&>svg]:text-emerald-600 dark:[&>svg]:text-emerald-300`,icon:`CheckCircle2`}};function U8t(e){let t=e?.properties??{};return{...e,...t}}var W8t=({schema:e={},className:t})=>{let n=U8t(e),r=Qp(),i=r?.data,a=r?.objectName||``,o=r?.recordId??i?.id,{language:s}=_m(),c=bm(n.title,s),l=bm(n.body,s),u=bm(n.action?.label,s),d=[`info`,`warning`,`error`,`success`].includes(n.severity)?n.severity:`info`,f=H8t[d],p=n.icon||f.icon,m=zp(n.visible),h=Bp(m,{record:i}),g=K.useMemo(()=>{if(!n.dismissible)return null;let e=n.dismissKey||bm(n.title,`en`)||d;return`os.record-alert:${a}:${o??`_`}:${e}`},[n.dismissible,n.dismissKey,n.title,d,a,o]),[_,v]=K.useState(()=>{if(!g||typeof window>`u`)return!1;try{return window.localStorage.getItem(g)===`1`}catch{return!1}}),y=n.action?.actionName,{item:b}=Zp(`object`,y&&a?a:null),x=K.useMemo(()=>{if(!(!y||!b?.actions))return b.actions.find(e=>e.name===y)},[y,b]),{executeAction:S}=zoe({actions:K.useMemo(()=>x?[x]:[],[x]),context:{record:i,recordId:o,objectName:a}});return _||!i||Object.keys(i).length===0||m!==void 0&&!h?null:(0,q.jsxs)(QJ,{className:J(`relative pr-12`,f.wrap,t),role:d===`error`?`alert`:`status`,"aria-live":d===`error`?`assertive`:`polite`,children:[(0,q.jsx)(v3,{name:p,className:`h-4 w-4`,"aria-hidden":`true`}),c?(0,q.jsx)($J,{children:c}):null,l||x?(0,q.jsxs)(eY,{children:[l?(0,q.jsx)(`p`,{className:`mb-2 last:mb-0`,children:l}):null,x?(0,q.jsx)(Z,{size:`sm`,variant:n.action?.variant||(d===`error`?`destructive`:`default`),onClick:()=>{x?.name&&S(x.name)},children:u||x.label||x.name}):null]}):null,n.dismissible?(0,q.jsx)(`button`,{type:`button`,onClick:()=>{if(v(!0),g)try{window.localStorage.setItem(g,`1`)}catch{}},"aria-label":`Dismiss`,className:`absolute right-3 top-3 inline-flex h-6 w-6 items-center justify-center rounded-md text-muted-foreground/80 hover:bg-foreground/5 hover:text-foreground focus:outline-none focus:ring-2 focus:ring-ring`,children:(0,q.jsx)(v3,{name:`X`,className:`h-4 w-4`,"aria-hidden":`true`})}):null]})},G8t=e=>{if(e==null)return`—`;if(typeof e==`string`)return e.length>0?e:`""`;if(typeof e==`number`||typeof e==`boolean`)return String(e);try{return JSON.stringify(e)}catch{return String(e)}},K8t=e=>{if(typeof e!=`string`||e.length===0)return null;let t=/\d{4}-\d{2}-\d{2}[ T]/.test(e)?e.replace(` `,`T`):e,n=new Date(t);if(Number.isNaN(n.getTime()))return null;try{return n.toLocaleString()}catch{return n.toISOString()}},q8t=({open:e,conflict:t,onReload:n,onOverwrite:r,onCancel:i,busy:a=!1})=>{let{t:o}=R9(),s=t?.label||t?.field||``,c=t?G8t(t.pendingValue):``,l=t?G8t(t.currentValue):``,u=t?.currentRecord??{},d=(()=>{let e=[u.updated_by_name,u.updated_by_label];for(let t of e)if(typeof t==`string`&&t.length>0)return t;let t=u.updated_by;return typeof t!=`string`||t.length===0||t.length>=16&&!/\s/.test(t)&&/^[A-Za-z0-9_-]+$/.test(t)?null:t})(),f=K8t(u.updated_at??t?.currentVersion),[p,m]=o(`detail.concurrentUpdateDescription`,{field:`{{field}}`}).split(`{{field}}`);return(0,q.jsx)(WJ,{open:e,onOpenChange:e=>{!e&&!a&&i()},children:(0,q.jsxs)(GJ,{className:`max-w-lg`,children:[(0,q.jsx)(KJ,{children:(0,q.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,q.jsx)(`span`,{className:`inline-flex h-9 w-9 flex-none items-center justify-center rounded-full bg-amber-100 text-amber-700 dark:bg-amber-500/20 dark:text-amber-300`,"aria-hidden":`true`,children:(0,q.jsx)(Bq,{className:`h-5 w-5`})}),(0,q.jsxs)(`div`,{className:`flex-1`,children:[(0,q.jsx)(JJ,{children:o(`detail.concurrentUpdateTitle`)}),(0,q.jsxs)(YJ,{className:`mt-1`,children:[p,(0,q.jsx)(`strong`,{className:`font-semibold`,children:s}),m]})]})]})}),(0,q.jsxs)(`div`,{className:`space-y-2 text-sm`,children:[(0,q.jsxs)(`div`,{className:`rounded-md border border-amber-200/70 bg-amber-50/60 p-3 dark:border-amber-500/30 dark:bg-amber-500/10`,children:[(0,q.jsx)(`div`,{className:`text-xs font-medium uppercase tracking-wide text-amber-800 dark:text-amber-300`,children:o(`detail.concurrentUpdateYourEdit`)}),(0,q.jsx)(`div`,{className:`mt-1 break-all font-mono text-foreground`,children:c})]}),(0,q.jsxs)(`div`,{className:`rounded-md border border-sky-200/70 bg-sky-50/60 p-3 dark:border-sky-500/30 dark:bg-sky-500/10`,children:[(0,q.jsxs)(`div`,{className:`flex items-baseline justify-between gap-2`,children:[(0,q.jsx)(`div`,{className:`text-xs font-medium uppercase tracking-wide text-sky-800 dark:text-sky-300`,children:o(`detail.concurrentUpdateCurrentValue`)}),(d||f)&&(0,q.jsxs)(`div`,{className:`text-[11px] text-muted-foreground`,children:[d&&(0,q.jsx)(`span`,{children:o(`detail.concurrentUpdateUpdatedBy`,{name:d})}),d&&f&&(0,q.jsx)(`span`,{children:` · `}),f&&(0,q.jsx)(`span`,{children:o(`detail.concurrentUpdateUpdatedAt`,{when:f})})]})]}),(0,q.jsx)(`div`,{className:`mt-1 break-all font-mono text-foreground`,children:l})]})]}),(0,q.jsxs)(qJ,{className:`gap-2 sm:gap-2`,children:[(0,q.jsx)(`button`,{type:`button`,disabled:a,onClick:i,className:J(UJ({variant:`ghost`}),`mt-2 sm:mt-0`),children:o(`detail.concurrentUpdateCancel`)}),(0,q.jsx)(`button`,{type:`button`,disabled:a,onClick:r,className:J(UJ({variant:`outline`}),`mt-2 sm:mt-0 text-destructive border-destructive/40 hover:bg-destructive/10 hover:text-destructive`),children:o(`detail.concurrentUpdateOverwrite`)}),(0,q.jsx)(`button`,{type:`button`,disabled:a,onClick:n,autoFocus:!0,className:J(UJ({variant:`default`}),`mt-2 sm:mt-0`),children:o(`detail.concurrentUpdateReload`)})]})]})})};function J8t(e){if(!e||typeof e!=`object`)return!1;let t=e;return t.code===`CONCURRENT_UPDATE`||t.name===`ConcurrentUpdateError`}function Y8t(e){let t=e?.message||e?.error||String(e??`Save failed`);return String(t).replace(/^\[[^\]]+\]\s*/,``).replace(/^[A-Z][A-Z0-9_]+:\s*/,``)}async function X8t(e,t,n,r,i){if(typeof e?.update==`function`)await e.update(t,n,r,i);else if(typeof e?.updateOne==`function`)await e.updateOne(t,n,r,i);else if(typeof e?.patch==`function`)await e.patch(t,n,r,i);else throw Error(`[InlineEditSaveBar] DataSource exposes no update/updateOne/patch method; cannot persist inline edit`)}var Z8t=({dataSource:e,objectName:t,recordId:n,data:r,refresh:i,fieldLabelFor:a,onFieldSave:o,locked:s=!1,lockedHint:c,className:l})=>{let{t:u}=R9(),d=$p(),[f,p]=K.useState(null),[m,h]=K.useState(!1),g=!!e&&!!t&&n!=null,_=K.useCallback((e,t)=>{let n=Object.keys(e),r=t?.currentRecord??null;if(n.length===1){let i=n[0];return{field:i,label:a?.(i),pendingValue:e[i],currentValue:r?r[i]:void 0,currentVersion:t?.currentVersion,currentRecord:r}}let i=r?Object.fromEntries(n.map(e=>[e,r[e]])):void 0;return{field:n.join(`, `),label:u(`detail.concurrentUpdateRecordLabel`,{defaultValue:`this record`}),pendingValue:e,currentValue:i,currentVersion:t?.currentVersion,currentRecord:r}},[a,u]),v=K.useCallback(async()=>{if(!d)return;let a=d.draft,s=Object.entries(a);if(s.length===0){d.reset();return}d.setSaving(!0),d.setError(null);try{if(o)for(let[e,t]of s)await o(e,t);else if(g){let o=typeof r?.updated_at==`string`?r.updated_at:void 0;await X8t(e,t,n,a,o?{ifMatch:o}:void 0),await i?.()}d.reset()}catch(e){J8t(e)&&g?p(_(a,e)):d.setError(Y8t(e))}finally{d.setSaving(!1)}},[d,o,g,r,e,t,n,i,_]),y=K.useCallback(()=>{p(null),h(!1)},[]),b=K.useCallback(async()=>{h(!0);try{await i?.()}finally{d?.reset(),y()}},[i,d,y]),x=K.useCallback(async()=>{if(!f||!g){y();return}h(!0);try{await X8t(e,t,n,d?.draft??{},f.currentVersion?{ifMatch:f.currentVersion}:void 0),await i?.(),d?.reset()}catch(e){d?.setError(Y8t(e))}finally{y()}},[f,g,d,e,t,n,i,y]),S=!!d?.editing,C=!!d?.saving,w=d?.cancel,T=!!f;return K.useEffect(()=>{if(!S)return;let e=e=>{if(e.key===`Enter`&&(e.metaKey||e.ctrlKey)){if(C||s||T)return;e.preventDefault(),v();return}if(e.key===`Escape`){if(e.defaultPrevented||C||T||document.querySelector(`[data-radix-popper-content-wrapper], [role="dialog"][data-state="open"], [role="alertdialog"][data-state="open"]`))return;e.preventDefault(),w?.()}};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[S,C,s,T,v,w]),!d||!d.editing?null:(0,q.jsxs)(q.Fragment,{children:[(0,q.jsxs)(`div`,{className:J(`sticky bottom-0 z-30 mt-4 flex flex-wrap items-center justify-end gap-2 rounded-md border bg-background/95 px-3 py-2 shadow-sm backdrop-blur supports-[backdrop-filter]:bg-background/80`,l),role:`region`,"aria-label":u(`detail.editFieldsInline`),children:[d.error&&(0,q.jsx)(`div`,{role:`alert`,className:`mr-auto max-w-md rounded-md border border-destructive/20 bg-destructive/10 px-2 py-1 text-xs text-destructive`,children:d.error}),(0,q.jsxs)(Z,{variant:`ghost`,size:`sm`,onClick:d.cancel,disabled:d.saving,className:`gap-2`,children:[(0,q.jsx)(Uq,{className:`h-4 w-4`}),(0,q.jsx)(`span`,{children:u(`detail.cancel`)})]}),(0,q.jsxs)(Z,{variant:`default`,size:`sm`,onClick:v,disabled:d.saving||s,className:`gap-2`,title:s?c:void 0,children:[d.saving?(0,q.jsx)(eq,{className:`h-4 w-4 animate-spin`}):(0,q.jsx)(sC,{className:`h-4 w-4`}),(0,q.jsx)(`span`,{children:d.saving?u(`detail.saving`):u(`detail.save`)})]})]}),(0,q.jsx)(q8t,{open:!!f,conflict:f,busy:m,onCancel:y,onReload:b,onOverwrite:x})]})},Q8t=new Set([`id`,`_id`,`__v`,`created_at`,`updated_at`,`createdAt`,`updatedAt`,`created_by`,`updated_by`,`organization_id`,`tenant_id`,`owner_id`,`deleted_at`,`is_deleted`]),$8t=480,e5t=95;function t5t({open:e,onClose:t,title:n,record:r,objectName:i,recordId:a,dataSource:o,objectSchema:s,width:c=`min(960px, 60vw)`,columns:l=2,systemFields:u=Q8t,onFieldSave:d,onDelete:f,resizable:p=!0,fullPageHref:m}){let{t:h}=R9(),g=`objectui.drawerWidth.${i}`,[_,v]=K.useState(()=>{if(typeof window>`u`||!p)return null;try{let e=window.localStorage.getItem(g);if(e){let t=parseInt(e,10);if(Number.isFinite(t)&&t>=$8t)return t}}catch{}return null}),y=K.useMemo(()=>p&&_!=null?`${_}px`:typeof c==`number`?`${c}px`:c,[p,_,c]),b=y?{width:y,maxWidth:y}:void 0,x=K.useRef(null),S=K.useCallback(e=>{if(!p)return;e.preventDefault();let t=_??(typeof window<`u`?Math.min(window.innerWidth*.6,960):720);x.current={startX:e.clientX,startWidth:t};let n=e=>{let t=x.current;if(!t)return;let n=t.startX-e.clientX,r=typeof window<`u`?window.innerWidth*e5t/100:1600,i=Math.min(r,Math.max($8t,t.startWidth+n));v(Math.round(i))},r=()=>{x.current,x.current=null,window.removeEventListener(`pointermove`,n),window.removeEventListener(`pointerup`,r),window.removeEventListener(`pointercancel`,r);try{v(e=>(e!=null&&window.localStorage.setItem(g,String(e)),e))}catch{}};window.addEventListener(`pointermove`,n),window.addEventListener(`pointerup`,r),window.addEventListener(`pointercancel`,r)},[p,_,g]),C=s?.fields??{},w=(Object.keys(C).length?Object.keys(C):Object.keys(r)).filter(e=>!u.has(e)&&!e.startsWith(`__`)).filter(e=>e in r).filter(e=>!C[e]?.hidden).map(e=>{let t=C[e]||{},n=t.type===`lookup`||t.type===`master_detail`||t.type===`reference`;return{name:e,label:t.label,type:t.type,readonly:!!t.readonly||n,options:t.options,currency:t.currency,precision:t.precision,scale:t.scale,format:t.format,reference_to:t.reference_to??t.reference??t.referenceTo??t.target,reference_field:t.reference_field??t.referenceField,required:t.required,validation:t.validation,placeholder:t.placeholder,description:t.description}});return(0,q.jsx)(l4,{open:e,onOpenChange:e=>{e||t()},children:(0,q.jsxs)(u4,{side:`right`,className:`w-full overflow-y-auto p-0 sm:!max-w-none`,style:b,onOpenAutoFocus:e=>e.preventDefault(),children:[p&&(0,q.jsx)(`div`,{role:`separator`,"aria-orientation":`vertical`,"aria-label":`Resize drawer`,onPointerDown:S,className:`hidden sm:block absolute left-0 top-0 h-full w-1.5 cursor-col-resize select-none bg-transparent hover:bg-primary/30 active:bg-primary/50 transition-colors z-10`}),(0,q.jsx)(d4,{className:`sr-only`,children:(0,q.jsx)(f4,{children:n})}),(0,q.jsx)(`div`,{className:`px-6 pt-6 pb-6`,children:(0,q.jsxs)(Aoe,{canEdit:!!d,children:[(0,q.jsx)(K9,{dataSource:o,inlineEdit:!!d,schema:{type:`detail-view`,objectName:i,resourceId:String(a),data:r,showDelete:!!f,columns:l,fields:w,actions:m?[{type:`action:bar`,location:`record_header`,systemActions:[{name:`sys_open_new_tab`,label:h(`detail.openInNewTab`),icon:`external-link`,type:`script`,onClick:()=>window.open(m,`_blank`,`noopener`)}]}]:void 0},onDelete:f?async()=>{try{await f(),t()}catch(e){console.error(`[RecordDetailDrawer] delete failed:`,e)}}:void 0}),(0,q.jsx)(Z8t,{onFieldSave:d?async(e,t)=>{try{await d(e,t)}catch(e){throw console.error(`[RecordDetailDrawer] inline field save failed:`,e),e}}:void 0})]})})]})})}function n5t(e,t){if(typeof window>`u`)return null;let n=window.location.pathname,r=`/${e}`,i=n.indexOf(r);return`${i>=0?n.slice(0,i):n.replace(/\/$/,``)}/${e}/record/${encodeURIComponent(String(t))}`}p.register(`detail-view`,K9,{namespace:`plugin-detail`,label:`Detail View`,category:`Views`,icon:`FileText`,inputs:[{name:`title`,type:`string`,label:`Title`},{name:`objectName`,type:`string`,label:`Object Name`},{name:`resourceId`,type:`string`,label:`Resource ID`},{name:`api`,type:`string`,label:`API Endpoint`},{name:`data`,type:`object`,label:`Data`},{name:`layout`,type:`enum`,label:`Layout Mode`,enum:[`vertical`,`horizontal`,`grid`]},{name:`columns`,type:`number`,label:`Grid Columns`},{name:`sections`,type:`array`,label:`Sections`},{name:`fields`,type:`array`,label:`Fields`},{name:`tabs`,type:`array`,label:`Tabs`},{name:`related`,type:`array`,label:`Related Lists`},{name:`actions`,type:`array`,label:`Actions`},{name:`showBack`,type:`boolean`,label:`Show Back Button`,defaultValue:!0},{name:`backUrl`,type:`string`,label:`Back URL`},{name:`showEdit`,type:`boolean`,label:`Show Edit Button`,defaultValue:!1},{name:`editUrl`,type:`string`,label:`Edit URL`},{name:`showDelete`,type:`boolean`,label:`Show Delete Button`,defaultValue:!1},{name:`deleteConfirmation`,type:`string`,label:`Delete Confirmation Message`},{name:`loading`,type:`boolean`,label:`Show Loading State`},{name:`header`,type:`object`,label:`Custom Header`},{name:`footer`,type:`object`,label:`Custom Footer`}],defaultProps:{title:`Detail View`,showBack:!0,showEdit:!1,showDelete:!1,sections:[],fields:[],tabs:[],related:[]}}),p.register(`detail-section`,V9,{namespace:`plugin-detail`,label:`Detail Section`,category:`Detail Components`,inputs:[{name:`title`,type:`string`,label:`Title`},{name:`description`,type:`string`,label:`Description`},{name:`fields`,type:`array`,label:`Fields`,required:!0},{name:`collapsible`,type:`boolean`,label:`Collapsible`,defaultValue:!1},{name:`defaultCollapsed`,type:`boolean`,label:`Default Collapsed`,defaultValue:!1},{name:`columns`,type:`number`,label:`Columns`,defaultValue:2},{name:`showBorder`,type:`boolean`,label:`Show Border`,defaultValue:!0},{name:`headerColor`,type:`string`,label:`Header Color`}]}),p.register(`related-list`,H9,{namespace:`plugin-detail`,label:`Related List`,category:`Detail Components`,inputs:[{name:`title`,type:`string`,label:`Title`,required:!0},{name:`type`,type:`enum`,label:`Type`,enum:[{label:`List`,value:`list`},{label:`Grid`,value:`grid`},{label:`Table`,value:`table`}],defaultValue:`table`},{name:`api`,type:`string`,label:`API Endpoint`},{name:`data`,type:`array`,label:`Data`},{name:`columns`,type:`array`,label:`Columns`}]}),p.register(`detail`,K9,{namespace:`view`,category:`view`,label:`Detail`,icon:`FileText`,inputs:[{name:`objectName`,type:`string`,label:`Object Name`,required:!0},{name:`recordId`,type:`string`,label:`Record ID`},{name:`fields`,type:`array`,label:`Fields`}]}),p.register(`record:details`,r8t,{namespace:`record`,category:`record`,label:`Record Details`,icon:`FileText`,inputs:[{name:`columns`,type:`enum`,label:`Columns`,enum:[`1`,`2`,`3`,`4`],defaultValue:`2`,description:`Number of columns for field layout (1-4)`},{name:`layout`,type:`enum`,label:`Layout`,enum:[`auto`,`custom`],defaultValue:`auto`,description:`auto uses the object highlightFields; custom uses explicit sections`},{name:`sections`,type:`array`,label:`Sections`,description:`Section IDs to show (required when layout is "custom")`},{name:`fields`,type:`array`,label:`Fields`,description:`Explicit field list (overrides highlightFields)`}]}),p.register(`record:related_list`,o8t,{namespace:`record`,category:`record`,label:`Related List`,icon:`List`,inputs:[{name:`objectName`,type:`string`,label:`Related Object`,required:!0,description:`Related object name (e.g. "task")`},{name:`relationshipField`,type:`string`,label:`Relationship Field`,required:!0,description:`Field on the related object pointing back to this record`},{name:`columns`,type:`array`,label:`Columns`,required:!0,description:`Fields to display in the related list`},{name:`sort`,type:`array`,label:`Sort`},{name:`limit`,type:`number`,label:`Limit`,defaultValue:5,description:`Records to display initially`},{name:`filter`,type:`array`,label:`Filter`,description:`Additional filter criteria`},{name:`title`,type:`string`,label:`Title`},{name:`showViewAll`,type:`boolean`,label:`Show "View All"`,defaultValue:!0},{name:`actions`,type:`array`,label:`Actions`,description:`Action IDs available for related records`}]}),p.register(`record:highlights`,c8t,{namespace:`record`,category:`record`,label:`Highlights Panel`,icon:`Star`,inputs:[{name:`fields`,type:`array`,label:`Fields`,required:!0,description:`Key fields to highlight (1-7), bare names or {name,label?,icon?,type?}`},{name:`layout`,type:`enum`,label:`Layout`,enum:[`horizontal`,`vertical`],defaultValue:`horizontal`,description:`Layout orientation for highlight fields`}]}),p.register(`record:activity`,D8t,{namespace:`record`,category:`record`,label:`Activity Timeline`,icon:`Activity`}),p.register(`record:chatter`,A8t,{namespace:`record`,category:`record`,label:`Chatter Feed`,icon:`MessageSquare`}),p.register(`record:discussion`,A8t,{namespace:`record`,category:`record`,label:`Discussion`,icon:`MessageSquare`}),p.register(`record:path`,M8t,{namespace:`record`,category:`record`,label:`Path / Stepper`,icon:`GitBranch`,inputs:[{name:`statusField`,type:`string`,label:`Status Field`,required:!0,description:`Field representing the current status/stage`},{name:`stages`,type:`array`,label:`Stages`,description:`Explicit stage definitions [{ value, label }] (else derived from field metadata)`}]}),p.register(`record:quick_actions`,P8t,{namespace:`record`,category:`record`,label:`Quick Actions`,icon:`Zap`}),p.register(`record:history`,R8t,{namespace:`record`,category:`record`,label:`History Timeline`,icon:`Clock`}),p.register(`record:reference_rail`,V8t,{namespace:`record`,category:`record`,label:`Reference Rail`,icon:`PanelRight`}),p.register(`record:alert`,W8t,{namespace:`record`,category:`record`,label:`Alert Banner`,icon:`AlertTriangle`}),p.register(`permission-facet-link`,z9,{namespace:`field`,skipFallback:!0});function r5t(e,t){if(Array.isArray(e)&&e.length>0)return e;let n=t?.highlightFields;return Array.isArray(n)?n.filter(e=>!!t?.fields?.[e]):[]}var i5t=({schema:e,dataSource:t,className:n,data:r,loading:i,onRowClick:a,onCardClick:o,...s})=>{let{translateOptions:c,fieldLabel:l}=ym(),u=Array.isArray(r),[d,f]=(0,K.useState)([]),[p,m]=(0,K.useState)(null),[h,g]=(0,K.useState)(u?i??!1:!1),[_,v]=(0,K.useState)(null),[y,x]=(0,K.useState)(0),S=Lp(e.bind);(0,K.useEffect)(()=>{if(!u&&!(!t?.onMutation||!e.objectName))return t.onMutation(t=>{t.resource===e.objectName&&x(e=>e+1)})},[t,e.objectName,u]),(0,K.useEffect)(()=>{u&&i!==void 0&&g(i)},[i,u]),(0,K.useEffect)(()=>{let n=!0;return(async()=>{if(!(!t||!e.objectName))try{let r=await t.getObjectSchema(e.objectName);n&&m(r)}catch(e){console.warn(`Failed to fetch object def`,e)}})(),()=>{n=!1}},[e.objectName,t]),(0,K.useEffect)(()=>{if(u)return;let n=!0;return e.objectName&&!S&&!e.data&&(async()=>{if(!(!t||typeof t.find!=`function`||!e.objectName)){n&&g(!0);try{let r=C(p?.fields),i=b(await t.find(e.objectName,{options:{$top:100},$filter:e.filter,...r.length>0?{$expand:r}:{}}));n&&f(i)}catch(e){console.error(`[ObjectKanban] Fetch error:`,e),n&&v(e)}finally{n&&g(!1)}}})(),()=>{n=!1}},[e.objectName,t,S,e.data,e.filter,u,p,y]);let w=(u?r:void 0)||S||e.data||d,T=(0,K.useMemo)(()=>{if(!Array.isArray(w))return[];let t=e.cardTitle||e.titleField,n=p?.NAME_FIELD_KEY;return w.map(r=>{let i;if(t&&(i=r[t],typeof i==`string`&&(i=i.trim())),!i){let e=Fp(p,r),t=r.id??r._id;e===`Untitled`||t!=null&&e===`Record #${t}`||(i=e)}let a=e=>e>=1e6?`$${(e/1e6).toFixed(1).replace(/\.0$/,``)}M`:e>=1e3?`$${Math.round(e/1e3)}K`:`$${e}`,o=/^[A-Za-z0-9_-]{12,32}$/,s=e=>{if(typeof e!=`string`||!o.test(e))return!1;let t=/[A-Z]/.test(e),n=/[a-z]/.test(e),r=/[0-9_-]/.test(e);return t&&n||t&&r||n&&r},u=e=>{let t=r[e];if(t==null||t===``)return;if(typeof t==`object`){let e=t;for(let t of[`name`,`full_name`,`display_name`,`label`,`title`,`username`]){let n=e[t];if(typeof n==`string`&&n.trim())return n.trim()}return}if(typeof t!=`string`)return String(t);let n=p?.fields?.[e];if(!((n?.type===`lookup`||n?.type===`master_detail`||n?.type===`reference`)&&s(t))&&!s(t))return t},d=[],f=r5t(e.cardFields,p),m=new Set([...t?[t]:[],...n?[n]:[],`name`,`full_name`,`title`,`subject`,`display_name`]),h=[],g=[];if(f.length>0)for(let t of f){if(m.has(t))continue;let n=p?.fields?.[t],i=r[t];if(!(i==null||i===``))if(n?.type===`picklist`||n?.type===`multipicklist`||Array.isArray(n?.options)&&n.options.length>0){let r=n?.options?.find(e=>String(e.value).toLowerCase()===String(i).toLowerCase()),a=r?.label||String(i),o=p?.name||e.objectName,s=o?c(o,t,[{value:String(r?.value??i),label:a}])[0]?.label??a:a,l=u7(r?.color,i);h.push({label:s,colorClass:l})}else{let r=v7(n??{type:`text`}),a=(0,q.jsx)(b7(r),{value:i,field:n??{name:t,type:r}});g.push({field:t,label:l(p?.name||e.objectName||``,t,n?.label||t),node:a})}}else{let e=[`amount`,`value`,`deal_value`,`expected_value`,`opportunity_value`].find(e=>typeof r[e]==`number`);e&&d.push(a(r[e]));let t=[`company`,`company_name`,`account`,`account_name`,`organization`],n;for(let e of t){let t=u(e);if(t){n=t;break}}n&&(!i||!String(i).includes(n))&&d.push(n);let o=[`owner`,`owner_name`,`assignee`,`assignee_name`],s;for(let e of o){let t=u(e);if(t){s=t;break}}s&&d.push(`@${s}`);for(let e of[`priority`,`severity`,`industry`,`rating`]){let t=r[e];if(t!=null&&t!==``){let n=(p?.fields?.[e])?.options?.find(e=>String(e.value).toLowerCase()===String(t).toLowerCase()),r=n?.label||String(t),i=u7(n?.color,t);if(h.push({label:r,colorClass:i}),h.length>=2)break}}}let _=r.description,v=(_==null||_===``||typeof _==`string`&&s(_))&&d.length>0?d.join(` · `):void 0;return{...r,id:r.id||r._id,title:i||Fp(p,r),...v?{cardSubtitle:v}:{},...g.length>0?{cardFieldCells:g}:{},...!Array.isArray(r.badges)&&h.length>0?{badges:h}:{}}})},[w,e,p]),E=(0,K.useMemo)(()=>{let t=t=>{if(!e.objectName||!e.groupBy)return t;let n=c(e.objectName,e.groupBy,[{value:String(t.id),label:t.title}])[0];return n?.label?{...t,title:n.label}:t};if(e.columns&&e.columns.length>0)if(typeof e.columns[0]==`string`){if(!e.groupBy)return e.columns.map(e=>({id:e,title:e}))}else return e.columns.map(t);if(e.groupBy&&p?.fields?.[e.groupBy]?.options){let t=p.fields[e.groupBy].options.map(e=>({value:e.value,label:e.label}));return(e.objectName?c(e.objectName,e.groupBy,t):t).map(e=>({id:e.value,title:e.label}))}if(e.groupBy&&T.length>0){let t=new Set(T.map(t=>t[e.groupBy]));return Array.from(t).map(e=>({id:String(e),title:String(e)}))}return[]},[e.columns,e.groupBy,e.objectName,T,p,c]),D=e.swimlaneField||e.grouping?.fields?.[0]?.field,O={...e,data:T,columns:E,className:n||e.className,...D?{swimlaneField:D}:{}},k=e.navigation??{mode:`drawer`,width:`min(960px, 60vw)`},A=a??o;!A&&(k.mode===`drawer`||k.mode===`modal`||k.mode===`split`||k.mode);let ee=uoe({navigation:k,objectName:e.objectName,onRowClick:A});if(_)return(0,q.jsxs)(`div`,{className:`p-4 border border-destructive/50 rounded bg-destructive/10 text-destructive`,children:[`Error loading kanban data: `,_.message]});let te=e.objectName?`${e.objectName.charAt(0).toUpperCase()+e.objectName.slice(1).replace(/_/g,` `)} Detail`:`Card Details`,j=K.useCallback(async(n,r,i,a)=>{let o=e.groupBy,s=e.objectName;if(!(!o||r===i)&&(u||f(e=>e.map(e=>String(e.id??e._id)===String(n)?{...e,[o]:i}:e)),!(!s||!t?.update)))try{await t.update(s,String(n),{[o]:i})}catch(e){console.warn(`[ObjectKanban] Failed to persist card move`,e),u||f(e=>e.map(e=>String(e.id??e._id)===String(n)?{...e,[o]:r}:e))}},[e.groupBy,e.objectName,t,u]);return(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(s5t,{schema:{...O,onCardClick:(e,t)=>{ee.handleClick(e,t),o?.(e)},onCardMove:j}}),ee.isOverlay&&ee.isOpen&&ee.selectedRecord&&(()=>{let n=e.objectName,r=ee.selectedRecord,i=r.id??r._id;if(!n||i==null)return null;let a=e.cardTitle??e.titleField,o=a&&r[a]?String(r[a]):te;return(0,q.jsx)(t5t,{open:!0,onClose:ee.close,title:o,record:r,objectName:n,recordId:i,dataSource:t,objectSchema:p,width:ee.width??`min(960px, 60vw)`,fullPageHref:n5t(n,i)??void 0,onFieldSave:async(e,r)=>{t?.update&&(await t.update(n,String(i),{[e]:r}),f(t=>t.map(t=>String(t.id??t._id)===String(i)?{...t,[e]:r}:t)))},onDelete:async()=>{t?.delete&&(await t.delete(n,String(i)),f(e=>e.filter(e=>String(e.id??e._id)!==String(i))))}})})()]})},a5t=K.lazy(()=>Q(()=>import(`./KanbanImpl-1R6QCwBw.js`),__vite__mapDeps([2,1,3]))),o5t=K.lazy(()=>Q(()=>import(`./KanbanEnhanced-DVd-8iF9.js`),__vite__mapDeps([4,1,3]))),s5t=({schema:e})=>{let t=K.useMemo(()=>{let{columns:t=[],data:n,groupBy:r,coverImageField:i}=e,a=e=>{if(!i)return e;let t=e[i];if(!t)return e;let n=typeof t==`string`?t:t?.url;return n?{...e,coverImage:n}:e};if(n&&r&&Array.isArray(n)){let e={};t.forEach(t=>{t.id&&(e[String(t.id).toLowerCase()]=t.id),t.title&&(e[String(t.title).toLowerCase()]=t.id)});let i=n.reduce((t,n)=>{let i=String(n[r]??``),o=e[i.toLowerCase()]??i;return t[o]||(t[o]=[]),t[o].push(a(n)),t},{});return t.map(e=>({...e,cards:[...(e.cards||[]).map(a),...i[e.id]||[]]}))}return t.map(e=>({...e,cards:(e.cards||[]).map(a)}))},[e]);return(0,q.jsx)(K.Suspense,{fallback:(0,q.jsx)(g4,{className:`w-full h-[600px]`}),children:(0,q.jsx)(a5t,{columns:t,onCardMove:e.onCardMove,onCardClick:e.onCardClick,className:e.className,quickAdd:e.quickAdd,onQuickAdd:e.onQuickAdd,coverImageField:e.coverImageField,conditionalFormatting:e.conditionalFormatting,swimlaneField:e.swimlaneField})})};p.register(`kanban-ui`,s5t,{namespace:`plugin-kanban`,label:`Kanban Board`,icon:`LayoutDashboard`,category:`plugin`,inputs:[{name:`columns`,type:`array`,label:`Columns`,description:`Array of { id, title, cards, limit, className }`,required:!0},{name:`onCardMove`,type:`code`,label:`On Card Move`,description:`Callback when a card is moved`,advanced:!0},{name:`className`,type:`string`,label:`CSS Class`}],defaultProps:{columns:[{id:`todo`,title:`To Do`,cards:[{id:`card-1`,title:`Task 1`,description:`This is the first task`,badges:[{label:`High Priority`,variant:`destructive`},{label:`Feature`,variant:`default`}]},{id:`card-2`,title:`Task 2`,description:`This is the second task`,badges:[{label:`Bug`,variant:`destructive`}]}]},{id:`in-progress`,title:`In Progress`,limit:3,cards:[{id:`card-3`,title:`Task 3`,description:`Currently working on this`,badges:[{label:`In Progress`,variant:`default`}]}]},{id:`done`,title:`Done`,cards:[{id:`card-4`,title:`Task 4`,description:`This task is completed`,badges:[{label:`Completed`,variant:`outline`}]},{id:`card-5`,title:`Task 5`,description:`Another completed task`,badges:[{label:`Completed`,variant:`outline`}]}]}],className:`w-full`}}),p.register(`kanban-enhanced`,({schema:e})=>{let t=K.useMemo(()=>{let{columns:t=[],data:n,groupBy:r}=e;if(n&&r&&Array.isArray(n)){let e=n.reduce((e,t)=>{let n=t[r];return e[n]||(e[n]=[]),e[n].push(t),e},{});return t.map(t=>({...t,cards:[...t.cards||[],...e[t.id]||[]]}))}return t},[e]);return(0,q.jsx)(K.Suspense,{fallback:(0,q.jsx)(g4,{className:`w-full h-[600px]`}),children:(0,q.jsx)(o5t,{columns:t,onCardMove:e.onCardMove,onColumnToggle:e.onColumnToggle,enableVirtualScrolling:e.enableVirtualScrolling,virtualScrollThreshold:e.virtualScrollThreshold,className:e.className,quickAdd:e.quickAdd,onQuickAdd:e.onQuickAdd,conditionalFormatting:e.conditionalFormatting})})},{namespace:`plugin-kanban`,label:`Kanban Board (Enhanced)`,icon:`LayoutGrid`,category:`plugin`,inputs:[{name:`columns`,type:`array`,label:`Columns`,required:!0},{name:`enableVirtualScrolling`,type:`boolean`,label:`Virtual Scrolling`,defaultValue:!1},{name:`virtualScrollThreshold`,type:`number`,label:`Virtual Scroll Threshold`,defaultValue:50},{name:`onCardMove`,type:`code`,label:`On Card Move`,advanced:!0},{name:`onColumnToggle`,type:`code`,label:`On Column Toggle`,advanced:!0},{name:`className`,type:`string`,label:`CSS Class`}],defaultProps:{columns:[],enableVirtualScrolling:!1,virtualScrollThreshold:50,className:`w-full`}});var c5t=({schema:e,...t})=>{let{dataSource:n}=$ae()||{};return(0,q.jsx)(i5t,{schema:e,dataSource:n,...t})};p.register(`object-kanban`,c5t,{namespace:`plugin-kanban`,label:`Object Kanban`,category:`view`,inputs:[{name:`objectName`,type:`string`,label:`Object Name`,required:!0},{name:`columns`,type:`array`,label:`Columns`}]}),p.register(`kanban`,c5t,{namespace:`view`,label:`Kanban Board`,category:`view`,inputs:[{name:`objectName`,type:`string`,label:`Object Name`,required:!0},{name:`columns`,type:`array`,label:`Columns`}]});var l5t=K.lazy(()=>Q(()=>import(`./ChartImpl-BOk8UN2m.js`),__vite__mapDeps([5,6,1]))),u5t=K.lazy(()=>Q(()=>import(`./AdvancedChartImpl-D3enFgLA.js`),__vite__mapDeps([7,1,6]))),d5t=({schema:e})=>(0,q.jsx)(K.Suspense,{fallback:(0,q.jsx)(g4,{className:`w-full h-48 sm:h-64 md:h-80 lg:h-[400px]`}),children:(0,q.jsx)(l5t,{data:e.data,dataKey:e.dataKey,xAxisKey:e.xAxisKey,height:e.height,className:e.className,color:e.color})}),Z9=({schema:e,onChartClick:t})=>{let n=K.useMemo(()=>{let t=e.series,n=e.xAxisKey,r=e.config;if(n||(e.index?n=e.index:e.category&&(n=e.category)),t||(e.categories?t=e.categories.map(e=>({dataKey:e})):e.value&&(t=[{dataKey:e.value}])),!r&&t){let n=e.colors||[`hsl(var(--chart-1))`,`hsl(var(--chart-2))`,`hsl(var(--chart-3))`],i={};t.forEach((e,t)=>{i[e.dataKey]={label:e.label||e.dataKey,color:n[t%n.length]}}),r=i}return{chartType:e.chartType,data:Array.isArray(e.data)?e.data:[],config:r,xAxisKey:n,series:t,className:e.className}},[e]);return(0,q.jsx)(K.Suspense,{fallback:(0,q.jsx)(g4,{className:`w-full h-48 sm:h-64 md:h-80 lg:h-[400px]`}),children:(0,q.jsx)(u5t,{chartType:n.chartType,data:n.data,config:n.config,xAxisKey:n.xAxisKey,series:n.series,className:n.className,colors:Array.isArray(e.colors)?e.colors:void 0,categoryColors:e.categoryColors,isAnimationActive:e.isAnimationActive,onChartClick:t})})};function Q9(e){return e.replace(/[_-]/g,` `).replace(/\b\w/g,e=>e.toUpperCase())}function f5t(e,t){let{field:n,function:r,groupBy:i}=t,a={};for(let t of e){let e=String(t[i]??`Unknown`);a[e]||(a[e]=[]),a[e].push(t)}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}})}async function p5t(e,t,n,r,i){if(!e.length||!t)return e;let a=i||((e,t)=>t),o=`__raw_${t}`,s=n?.fields?.[t];if(!s){let n=/^\d{4}-\d{2}-\d{2}/;return e.map(e=>{let r=e[t],i=String(r??``),s=n.test(i)?i:Q9(i);return{...e,[t]:a(i,s),[o]:r}})}let c=s.type;if(c===`select`||c===`picklist`||c===`dropdown`){let n=s.options||[];if(n.length===0)return e.map(e=>{let n=e[t],r=String(n??``),i=Q9(r);return{...e,[t]:a(r,i),[o]:n}});let r={};for(let e of n)typeof e==`string`?r[e]=e:e&&typeof e==`object`&&(r[String(e.value)]=e.label||String(e.value));return e.map(e=>{let n=e[t],i=String(n??``),s=r[i]||Q9(i);return{...e,[t]:a(i,s),[o]:n}})}if(c===`lookup`||c===`master_detail`){let n=s.reference_to||s.reference;if(!n||!r||typeof r.find!=`function`)return e.map(e=>({...e,[o]:e[t]}));let i=[...new Set(e.map(e=>e[t]).filter(e=>e!=null))];if(i.length===0)return e.map(e=>({...e,[o]:e[t]}));let a=s.id_field||`id`;try{let c=b(await r.find(n,{$filter:{[a]:{$in:i}},$top:i.length})),l=s.reference_field||s.display_field||`name`,u={};for(let e of c){let t=String(e[a]??e.id??e._id??``),n=e[l]||e.name||e.label||e.title||t;t&&(u[t]=String(n))}return e.map(e=>{let n=e[t],r=String(n??``);return{...e,[t]:u[r]||r,[o]:n}})}catch(n){return console.warn(`[ObjectChart] Failed to resolve lookup labels:`,n),e.map(e=>({...e,[o]:e[t]}))}}if(c===`date`||c===`datetime`||c===`date_time`||c===`timestamp`||c===`time`)return e.map(e=>({...e,[o]:e[t]}));let l=/^\d{4}-\d{2}-\d{2}/;return e.map(e=>{let n=e[t],r=String(n??``);return{...e,[t]:l.test(r)?r:Q9(r),[o]:n}})}var m5t=e=>{let{schema:t}=e,n=e.onSegmentClick,r=(0,K.useContext)(Ip),i=e.dataSource||r?.dataSource,a=Lp(t.bind),{fieldOptionLabel:o}=ym(),s=(0,K.useRef)(o);(0,K.useEffect)(()=>{s.current=o},[o]);let[c,l]=(0,K.useState)([]),[u,d]=(0,K.useState)(null),[f,p]=(0,K.useState)(()=>!(Array.isArray(t.data)&&t.data.length>0)&&(!!t.objectName||!!t.dataset)),[m,h]=(0,K.useState)(null),[g,_]=(0,K.useState)(null),[v,y]=(0,K.useState)(null),[x,S]=(0,K.useState)(null),{openRecordList:C}=Poe(),w=Yse(),T=(0,K.useMemo)(()=>t.aggregate?JSON.stringify(t.aggregate):``,[t.aggregate]),E=(0,K.useMemo)(()=>t.filter?JSON.stringify(t.filter):``,[t.filter]),D=(0,K.useMemo)(()=>t.compareTo?JSON.stringify(t.compareTo):``,[t.compareTo]),O=(0,K.useMemo)(()=>t.dataset?JSON.stringify({d:t.dataset,dim:t.dimensions??[],val:t.values??[]}):``,[t.dataset,t.dimensions,t.values]),k=e=>e!==`pie`&&e!==`donut`&&e!==`funnel`;(0,K.useEffect)(()=>{let e=!1;return(async()=>{try{let n={headers:{accept:`application/json`},credentials:`include`},r=t.objectName,i,a=null,o=t.aggregate?.groupBy;if(r)i=o&&typeof o==`object`&&!Array.isArray(o)?o.field:typeof o==`string`?o:t.xAxisKey;else if(t.dataset){let e=Array.isArray(t.dimensions)&&t.dimensions.length?t.dimensions[0]:void 0,o=await(await fetch(`/api/v1/meta/dataset/${encodeURIComponent(t.dataset)}`,n)).json().catch(()=>null);a=o?.item??o?.data??o,r=a?.object,i=((a?.dimensions||[]).find(t=>t?.name===e)??(a?.dimensions||[])[0])?.field??e}if(!r||!i){e||(y(null),S(null));return}let s=await(await fetch(`/api/v1/meta/object/${encodeURIComponent(r)}`,n)).json().catch(()=>null),c=s?.item??s?.data??s,l=Lae(c?.fields?.[i]?.options),u=null;if(t.dataset&&Array.isArray(t.dimensions)){let e={};for(let n of t.dimensions){let t=(a?.dimensions||[]).find(e=>e?.name===n)?.field??n,r=Rae(c?.fields?.[t]?.options);r&&(e[n]=r)}Object.keys(e).length>0&&(u=e)}e||(y(l),S(u))}catch{e||(y(null),S(null))}})(),()=>{e=!0}},[t.objectName,t.dataset,O,T,t.xAxisKey]);let A=(0,K.useCallback)(async(e,n)=>{if(t.aggregate&&typeof e.aggregate==`function`){let r=t.aggregate.groupBy;if(r&&typeof r==`object`&&!Array.isArray(r)){let i=t.aggregate.field,a=t.aggregate.function,o={function:a,alias:i||a};a!==`count`&&i&&(o.field=i);let s=await e.aggregate(t.objectName,{groupBy:[r],aggregations:[o],where:n});return Array.isArray(s)?s:[]}let i=await e.aggregate(t.objectName,{field:t.aggregate.field,function:t.aggregate.function,groupBy:r,filter:n});return Array.isArray(i)?i:[]}if(typeof e.find==`function`){let r=b(await e.find(t.objectName,{$filter:n}));return t.aggregate&&r.length>0&&(r=f5t(r,t.aggregate)),r}return[]},[t.objectName,T]),ee=(0,K.useCallback)(async(e,n)=>{if(!e||!t.objectName&&!t.dataset){n.current&&p(!1);return}n.current&&(p(!0),h(null));try{if(t.dataset&&typeof e.queryDataset==`function`){let r=Ap(t.filter),i=await e.queryDataset(t.dataset,{dimensions:Array.isArray(t.dimensions)?t.dimensions:[],measures:Array.isArray(t.values)?t.values:[],...r?{runtimeFilter:r}:{}});n.current&&(l(Array.isArray(i?.rows)?i.rows:[]),d(Array.isArray(i?.fields)?i.fields:null));return}let r=Ap(t.filter),i=t.compareTo,a=!!i&&k(t.chartType),o=a?Nae(t.filter,i):null,[c,u]=await Promise.all([A(e,r),o?A(e,o):Promise.resolve([])]),f=c,p=t.aggregate?.groupBy,m=p&&typeof p==`object`&&!Array.isArray(p)?p.alias||p.field:p||t.xAxisKey;if(a&&u.length>0&&t.aggregate){let e=t.aggregate.field,n=t.aggregate.function,r=t=>{if(t==null)return null;let r=`${e}_${n}`;return r in t?Number(t[r]):n===`count`&&`${e}_count`in t?Number(t[`${e}_count`]):e in t?Number(t[e]):`value`in t?Number(t.value):`count`in t?Number(t.count):null},i=`${e}__comparison`,a=m;if(a&&f.some(e=>e[a]!=null)&&u.some(e=>e[a]!=null)){let e=new Map;for(let t of u){let n=String(t[a]??``);e.set(n,r(t))}f=f.map(t=>{let n=String(t[a]??``),r=e.get(n);return r==null?t:{...t,[i]:r}});let t=new Set(f.map(e=>String(e[a]??``)));for(let e of u){let n=String(e[a]??``);t.has(n)||f.push({[a]:n,[i]:r(e)})}}else{let e=Math.max(f.length,u.length),t=[];for(let n=0;n<e;n++){let e=f[n]||{},a=u[n];t.push(a?{...e,[i]:r(a)}:e)}f=t}}if(m&&typeof e.getObjectSchema==`function`)try{let n=await e.getObjectSchema(t.objectName);f=await p5t(f,m,n,e,(e,n)=>s.current(t.objectName,m,e,n))}catch{}n.current&&l(f)}catch(e){console.error(`[ObjectChart] Fetch error:`,e),n.current&&h(e instanceof Error?e.message:`Failed to load chart data`)}finally{n.current&&p(!1)}},[t.objectName,O,T,E,D,t.xAxisKey,t.chartType,A]);(0,K.useEffect)(()=>{let e={current:!0};return(t.objectName||t.dataset)&&!a&&!t.data?ee(i,e):e.current&&p(!1),()=>{e.current=!1}},[t.objectName,O,i,a,t.data,E,T,D,ee]);let te=a||t.data||c,j=Array.isArray(te)?te:[],ne=t.drillDown,re=t.aggregate?.groupBy||t.xAxisKey,M=(0,K.useMemo)(()=>{if(!re)return new Map;let e=new Map,t=`__raw_${re}`;for(let n of j){let r=n?.[re];if(r==null)continue;let i=t in(n||{})?n[t]:r;e.set(String(r),i)}return e},[j,re]),N=t.compareTo,ie=!!N&&k(t.chartType)&&!!t.aggregate&&j.some(e=>e[`${t.aggregate.field}__comparison`]!=null),ae=(0,K.useMemo)(()=>{let e=Array.isArray(t.series)?t.series:null;if(!ie)return e;let n=e||[{dataKey:t.aggregate.field}],r={vsLastWeek:`Previous week`,vsLastMonth:`Previous month`,vsLastQuarter:`Previous quarter`,vsLastYear:`Previous year`,vsYesterday:`Yesterday`,vsPreviousPeriod:`Previous period`}[Pae(N,t.filter)]||`Previous period`;return[...n.map(e=>({...e,variant:e.variant||`current`})),{dataKey:`${t.aggregate.field}__comparison`,label:r,variant:`comparison`}]},[ie,t.series,t.aggregate,t.filter,N]),oe=t.dataset?Fae(Iae(j,x),t.dimensions,t.values,u):null,P=oe?{...t,data:oe.data,xAxisKey:oe.xAxisKey,series:oe.series}:{...t,data:j,...ae?{series:ae}:{}},se=t.colors&&!Array.isArray(t.colors)&&typeof t.colors==`object`?t.colors:null,ce=Array.isArray(t.colors)?t.colors:void 0,le=v||se?{...v||{},...se||{}}:void 0,ue={...P,colors:ce,...le?{categoryColors:le}:{}};if(f&&j.length===0)return(0,q.jsxs)(`div`,{className:`p-2 `+(t.className||``),"data-testid":`chart-loading`,role:`status`,"aria-busy":`true`,"aria-live":`polite`,children:[(0,q.jsx)(`span`,{className:`sr-only`,children:`Loading chart data…`}),(0,q.jsx)(Wzt,{className:`h-full`})]});if(m)return(0,q.jsxs)(`div`,{className:`flex flex-col items-center justify-center gap-2 p-4 `+(t.className||``),"data-testid":`chart-error`,role:`alert`,children:[(0,q.jsx)(cw,{className:`h-6 w-6 text-destructive opacity-60`}),(0,q.jsx)(`p`,{className:`text-xs text-destructive font-medium`,children:`Failed to load chart data`}),(0,q.jsx)(`p`,{className:`text-xs text-muted-foreground max-w-xs text-center`,children:m})]});if(!i&&t.objectName&&j.length===0)return(0,q.jsxs)(`div`,{className:`flex items-center justify-center text-muted-foreground text-sm p-4 `+(t.className||``),"data-testid":`chart-no-datasource`,children:[`No data source available for “`,t.objectName,`”`]});let de=Aae(ne)?e=>{let t=e.category,n=t!=null&&M.has(String(t))?M.get(String(t)):t;_({...e,category:n,categoryLabel:t,scope:`cell`})}:void 0,fe=n??de,pe=!n&&g&&t.objectName?(()=>{let e=Oae(ne,g,{groupByField:re}),n={...t.filter||{},...e},r=kae(ne,g,t.title||`Details`),a=ne?.target??`drawer`,o=(0,q.jsx)(`div`,{className:`overflow-auto`,"data-testid":`chart-drill-body`,children:(0,q.jsx)(Kp,{schema:{type:`object-data-table`,objectName:t.objectName,filter:n,pagination:!0,pageSize:ne?.maxRows,columns:ne?.columns?.map(e=>({accessorKey:e,header:e})),drillDown:{enabled:!0,mode:`record`,target:`dialog`}},dataSource:i})}),s=C&&t.objectName?(0,q.jsxs)(Z,{type:`button`,variant:`ghost`,size:`sm`,"data-testid":`drill-open-in-list`,onClick:()=>{C(t.objectName,n),_(null)},children:[w(`dashboard.openInList`,`Open in list`),(0,q.jsx)(Eh,{className:`ml-1 h-3.5 w-3.5`})]}):null;return a===`dialog`?(0,q.jsx)(_Z,{open:!0,onOpenChange:e=>!e&&_(null),children:(0,q.jsxs)(yZ,{className:`max-w-4xl`,children:[(0,q.jsxs)(bZ,{className:`flex-row items-center justify-between gap-4 pr-8`,children:[(0,q.jsx)(SZ,{children:r}),s]}),o]})}):(0,q.jsx)(l4,{open:!0,onOpenChange:e=>!e&&_(null),children:(0,q.jsxs)(u4,{side:`right`,className:`w-full sm:max-w-2xl md:max-w-3xl lg:max-w-4xl flex flex-col`,children:[(0,q.jsxs)(d4,{className:`flex-row items-center justify-between gap-4 pr-8`,children:[(0,q.jsx)(f4,{children:r}),s]}),(0,q.jsx)(`div`,{className:`flex-1 overflow-hidden mt-2`,children:o})]})})})():null;return(0,q.jsxs)(`div`,{className:`relative`,children:[(0,q.jsx)(Yzt,{active:f&&j.length>0}),(0,q.jsx)(Z9,{...e,schema:ue,onChartClick:fe}),pe]})};p.register(`object-chart`,m5t,{namespace:`plugin-charts`,label:`Object Chart`,category:`view`,inputs:[{name:`objectName`,type:`string`,label:`Object Name`,required:!0},{name:`data`,type:`array`,label:`Data`,description:`Optional static data`},{name:`filter`,type:`array`,label:`Filter`},{name:`aggregate`,type:`object`,label:`Aggregate`,description:`Aggregation config: { field, function, groupBy }`}]}),p.register(`bar-chart`,d5t,{namespace:`plugin-charts`,label:`Bar Chart`,category:`plugin`,inputs:[{name:`data`,type:`array`,label:`Data`,required:!0},{name:`dataKey`,type:`string`,label:`Data Key`,defaultValue:`value`},{name:`xAxisKey`,type:`string`,label:`X-Axis Key`,defaultValue:`name`},{name:`height`,type:`number`,label:`Height`,defaultValue:400},{name:`color`,type:`color`,label:`Color`,defaultValue:`#8884d8`}],defaultProps:{data:[{name:`Jan`,value:400},{name:`Feb`,value:300},{name:`Mar`,value:600},{name:`Apr`,value:800},{name:`May`,value:500}],dataKey:`value`,xAxisKey:`name`,height:400,color:`#8884d8`}}),p.register(`chart`,m5t,{namespace:`view`,category:`view`,label:`Chart`,skipFallback:!0,inputs:[{name:`objectName`,type:`string`,label:`Object Name`,required:!0},{name:`type`,type:`string`,label:`Chart Type`},{name:`categoryField`,type:`string`,label:`Category Field`},{name:`valueField`,type:`string`,label:`Value Field`}]}),p.register(`chart`,Z9,{namespace:`plugin-charts`,label:`Chart`,category:`plugin`,inputs:[{name:`chartType`,type:`enum`,label:`Chart Type`,enum:[{label:`Bar`,value:`bar`},{label:`Line`,value:`line`},{label:`Area`,value:`area`},{label:`Pie`,value:`pie`},{label:`Donut`,value:`donut`},{label:`Radar`,value:`radar`},{label:`Scatter`,value:`scatter`}],defaultValue:`bar`},{name:`data`,type:`code`,label:`Data (JSON)`,required:!0},{name:`config`,type:`code`,label:`Config (JSON)`},{name:`xAxisKey`,type:`string`,label:`X Axis Key`,defaultValue:`name`},{name:`series`,type:`code`,label:`Series (JSON Array)`,required:!0},{name:`className`,type:`string`,label:`CSS Class`}],defaultProps:{chartType:`bar`,data:[{name:`Jan`,sales:400,revenue:240},{name:`Feb`,sales:300,revenue:139},{name:`Mar`,sales:600,revenue:380},{name:`Apr`,sales:800,revenue:430},{name:`May`,sales:500,revenue:220}],config:{sales:{label:`Sales`,color:`#8884d8`},revenue:{label:`Revenue`,color:`#82ca9d`}},xAxisKey:`name`,series:[{dataKey:`sales`},{dataKey:`revenue`}]}}),p.register(`chart:bar`,Z9,{namespace:`plugin-charts`,label:`Bar Chart (Alias)`,category:`plugin`,defaultProps:{chartType:`bar`}}),p.register(`pie-chart`,Z9,{namespace:`plugin-charts`,label:`Pie Chart`,category:`plugin`,defaultProps:{chartType:`pie`}}),p.register(`donut-chart`,Z9,{namespace:`plugin-charts`,label:`Donut Chart`,category:`plugin`,defaultProps:{chartType:`donut`}}),p.register(`radar-chart`,Z9,{namespace:`plugin-charts`,label:`Radar Chart`,category:`plugin`,defaultProps:{chartType:`radar`}}),p.register(`scatter-chart`,Z9,{namespace:`plugin-charts`,label:`Scatter Chart`,category:`plugin`,defaultProps:{chartType:`scatter`}});var $9=e=>e?SRt(e):null,h5t=({item:e,currentPath:t,isSidebarOpen:n,onNavigate:r,level:i=0})=>{let a=t===e.path,o=e.children?.some(e=>e.path===t),[s,c]=K.useState(o),l=$9(e.icon);return K.useEffect(()=>{o&&c(!0)},[o]),e.children&&e.children.length>0?(0,q.jsxs)($X,{open:s,onOpenChange:c,className:`w-full`,children:[(0,q.jsxs)(eZ,{className:`flex w-full items-center justify-between py-2 text-sm font-medium rounded-md transition-colors text-muted-foreground hover:bg-muted hover:text-foreground ${n?`px-3`:`justify-center px-2 cursor-pointer`}`,children:[(0,q.jsxs)(`div`,{className:`flex items-center overflow-hidden`,children:[l&&(0,q.jsx)(l,{className:`h-4 w-4 shrink-0 ${n?`mr-3`:``}`}),(0,q.jsx)(`span`,{className:`whitespace-nowrap overflow-hidden transition-all duration-300 ${n?`opacity-100 w-auto`:`opacity-0 w-0 hidden`}`,children:e.label})]}),n&&(0,q.jsx)(jC,{className:`h-4 w-4 transition-transform ${s?`rotate-180`:``}`})]}),(0,q.jsx)(tZ,{className:`space-y-1 overflow-hidden data-[state=closed]:animate-collapsible-up data-[state=open]:animate-collapsible-down`,children:n&&e.children.map((e,a)=>(0,q.jsx)(h5t,{item:e,currentPath:t,isSidebarOpen:n,onNavigate:r,level:i+1},a))})]}):(0,q.jsxs)(`a`,{href:e.path||`#`,onClick:t=>e.path&&r(t,e.path),title:n?void 0:e.label,className:`flex items-center py-2 text-sm font-medium rounded-md transition-colors ${a?`bg-primary text-primary-foreground`:`text-muted-foreground hover:bg-muted hover:text-foreground`} ${n?`px-3`:`justify-center px-2`} ${i>0&&n?`pl-10`:``}`,children:[l&&(0,q.jsx)(l,{className:`h-4 w-4 shrink-0 ${n?`mr-3`:``} ${a?`text-primary-foreground`:`text-muted-foreground group-hover:text-foreground`}`}),(0,q.jsx)(`span`,{className:`whitespace-nowrap overflow-hidden transition-all duration-300 ${n?`opacity-100 w-auto`:`opacity-0 w-0 hidden`}`,children:e.label})]})},g5t=({app:e,children:t,currentPath:n,onNavigate:r})=>{let i=e.layout||`sidebar`,[a,o]=K.useState(!0),[s,c]=K.useState(`light`);K.useEffect(()=>{let e=localStorage.getItem(`theme`)===`dark`||!(`theme`in localStorage)&&window.matchMedia(`(prefers-color-scheme: dark)`).matches;c(e?`dark`:`light`)},[]),K.useEffect(()=>{s===`dark`?(document.documentElement.classList.add(`dark`),localStorage.setItem(`theme`,`dark`)):(document.documentElement.classList.remove(`dark`),localStorage.setItem(`theme`,`light`))},[s]);let l=()=>{c(e=>e===`dark`?`light`:`dark`)},u=(e,t)=>{e.preventDefault(),r?r(t):window.location.href=t};if(i===`empty`)return(0,q.jsx)(`main`,{className:e.className,children:t});let d=e.logo&&!e.logo.includes(`/`)&&!e.logo.includes(`.`)?$9(e.logo):null;return(0,q.jsxs)(`div`,{className:`flex min-h-screen w-full bg-background ${e.className||``}`,children:[i===`sidebar`&&(0,q.jsxs)(`aside`,{className:`
|
|
216
|
+
Remove the unknown key(s), fix the typo, or move the logic to a supported mechanism.`)}function X4t(e){if(!e||typeof e!=`object`||Array.isArray(e))return e;let t=e;return t.nameField==null&&typeof t.displayNameField==`string`?{...t,nameField:t.displayNameField}:e}function Z4t(e){if(!e||typeof e!=`object`||Array.isArray(e))return e;let t=e,n=t;if(Array.isArray(t.fieldGroups)){let e=!1,r=t.fieldGroups.map(t=>{if(!t||typeof t!=`object`||Array.isArray(t))return t;let n=t;if(n.collapse!=null)return t;let r;return typeof n.collapsible==`boolean`||typeof n.collapsed==`boolean`?r=n.collapsed===!0?`collapsed`:n.collapsible===!0?`expanded`:`none`:typeof n.defaultExpanded==`boolean`&&(r=n.defaultExpanded?`expanded`:`collapsed`),r===void 0?t:(e=!0,{...n,collapse:r})});e&&(n={...n,fieldGroups:r})}return n}$(()=>{let e=j9.parse.bind(j9),t=j9.safeParse.bind(j9);return Object.assign(j9,{parse(t,n){return e(Z4t(X4t(t)),n)},safeParse(e,n){return t(Z4t(X4t(e)),n)},create:e=>{let t=e,n=Object.keys(j9.shape),r=Object.keys(t).filter(e=>!n.includes(e));if(r.length>0)throw Y4t(t.name,r,n);let i={...t,label:t.label??G4t(t.name)};return j9.parse(i)}})}),W([`own`,`extend`]),$(()=>V({extend:I().describe(`Target object name (FQN) to extend`),fields:U(I(),y2t).optional().describe(`Fields to add/override`),label:I().optional().describe(`Override label for the extended object`),pluralLabel:I().optional().describe(`Override plural label for the extended object`),description:I().optional().describe(`Override description for the extended object`),validations:B(x9).optional().describe(`Additional validation rules to merge into the target object`),indexes:B(M4t).optional().describe(`Additional indexes to merge into the target object`),priority:L().int().min(0).max(999).default(200).describe(`Merge priority (higher = applied later)`)}));var Q4t=W([`beforeFind`,`afterFind`,`beforeFindOne`,`afterFindOne`,`beforeCount`,`afterCount`,`beforeAggregate`,`afterAggregate`,`beforeInsert`,`afterInsert`,`beforeUpdate`,`afterUpdate`,`beforeDelete`,`afterDelete`,`beforeUpdateMany`,`afterUpdateMany`,`beforeDeleteMany`,`afterDeleteMany`]);$(()=>V({name:I().regex(/^[a-z_][a-z0-9_]*$/).describe(`Hook unique name (snake_case)`),label:I().optional().describe(`Description of what this hook does`),object:H([I(),B(I())]).describe(`Target object(s)`),events:B(Q4t).describe(`Lifecycle events`),handler:H([I(),Al(e=>typeof e==`function`,{message:`Expected function`})]).optional().describe("Handler function name (string, post-build) or inline function (pre-build) — DEPRECATED, prefer `body`"),body:k2t.optional().describe(`Hook body — expression (L1) or sandboxed JS (L2)`),priority:L().default(100).describe(`Execution priority`),async:R().default(!1).describe(`Run specifically as fire-and-forget`),condition:v9.optional().describe('Predicate (CEL); hook runs only when TRUE. e.g. P`record.status == "closed" && record.amount > 1000`'),description:I().optional().describe(`Human-readable description of what this hook does`),retryPolicy:V({maxRetries:L().default(3).describe(`Maximum retry attempts on failure`),backoffMs:L().default(1e3).describe(`Backoff delay between retries in milliseconds`)}).optional().describe(`Retry policy for failed hook executions`),timeout:L().optional().describe(`Maximum execution time in milliseconds before the hook is aborted`),onError:W([`abort`,`log`]).default(`abort`).describe(`Error handling strategy`)})),$(()=>V({id:I().optional().describe(`Unique execution ID for tracing`),object:I(),event:Q4t,input:U(I(),z()).describe(`Mutable input parameters`),result:z().optional().describe(`Operation result (After hooks only)`),previous:U(I(),z()).optional().describe(`Record state before operation`),session:V({userId:I().optional(),tenantId:I().optional(),roles:B(I()).optional(),accessToken:I().optional(),isSystem:R().optional().describe(`True when the call was made with an elevated system context (engine self-writes)`),skipTriggers:R().optional().describe(`True when record-change automation (flow triggers) must be suppressed for this write — e.g. package seed replay. Lifecycle hooks still run.`)}).optional().describe(`Current session context`),transaction:z().optional().describe(`Database transaction handle`),ql:z().describe(`ObjectQL Engine Reference`),api:z().optional().describe(`Cross-object data access (ScopedContext)`),user:V({id:I().optional(),name:I().optional(),email:I().optional()}).optional().describe(`Current user info shortcut`)}));var $4t=W([`none`,`constant`,`lookup`,`split`,`join`,`javascript`,`map`]),e3t=$(()=>V({source:H([I(),B(I())]).describe(`Source column header(s)`),target:H([I(),B(I())]).describe(`Target object field(s)`),transform:$4t.default(`none`),params:V({value:z().optional(),object:I().optional(),fromField:I().optional(),toField:I().optional(),autoCreate:R().optional(),valueMap:U(I(),z()).optional(),separator:I().optional()}).optional()}));$(()=>V({name:g9.describe(`Mapping unique name (lowercase snake_case)`),label:I().optional(),sourceFormat:W([`csv`,`json`,`xml`,`sql`]).default(`csv`),targetObject:I().describe(`Target Object Name`),fieldMapping:B(e3t),mode:W([`insert`,`update`,`upsert`]).default(`insert`),upsertKey:B(I()).optional().describe(`Fields to match for upsert (e.g. email)`),extractQuery:h9.optional().describe(`Query to run for export only`),errorPolicy:W([`skip`,`abort`,`retry`]).default(`skip`),batchSize:L().default(1e3)}));var t3t=$(()=>V({userId:I().optional(),actor:I().optional(),email:I().optional(),tenantId:I().optional(),timezone:I().optional(),locale:I().optional(),currency:I().optional(),positions:B(I()).default([]),principalKind:W([`human`,`agent`,`service`,`guest`,`system`]).optional(),audience:W([`internal`,`external`]).optional(),onBehalfOf:V({userId:I(),principalKind:W([`human`,`agent`,`service`,`guest`,`system`]).optional()}).optional(),permissions:B(I()).default([]),systemPermissions:B(I()).optional(),tabPermissions:U(I(),W([`visible`,`hidden`,`default_on`,`default_off`])).optional(),org_user_ids:B(I()).optional(),rlsMembership:U(I(),B(I())).optional(),isSystem:R().default(!1),skipTriggers:R().optional(),oauthScopes:B(I()).optional(),accessToken:I().optional(),transaction:z().optional(),traceId:I().optional()})),M9=$(()=>H([U(I(),z()),d9]).describe(`Data Engine query filter conditions`)),n3t=$(()=>H([U(I(),W([`asc`,`desc`])),U(I(),H([rl(1),rl(-1)])),B(p9)]).describe(`Sort order definition`)),N9=$(()=>V({context:t3t.optional()})),P9=$(()=>N9.extend({where:H([U(I(),z()),d9]).optional(),fields:B(m9).optional(),orderBy:B(p9).optional(),limit:L().optional(),offset:L().optional(),top:L().optional(),cursor:U(I(),z()).optional(),search:t2t.optional(),expand:wl(()=>U(I(),h9)).optional(),distinct:R().optional()}).describe(`QueryAST-aligned query options for IDataEngine.find() operations`));$(()=>N9.extend({filter:M9.optional(),select:B(I()).optional(),sort:n3t.optional(),limit:L().int().min(1).optional(),skip:L().int().min(0).optional(),top:L().int().min(1).optional(),populate:B(I()).optional()}).describe(`Query options for IDataEngine.find() operations`));var r3t=$(()=>N9.extend({returning:R().default(!0).optional()}).describe(`Options for DataEngine.insert operations`)),i3t=$(()=>N9.extend({where:H([U(I(),z()),d9]).optional(),upsert:R().default(!1).optional(),multi:R().default(!1).optional(),returning:R().default(!1).optional()}).describe(`QueryAST-aligned options for DataEngine.update operations`));$(()=>N9.extend({filter:M9.optional(),upsert:R().default(!1).optional(),multi:R().default(!1).optional(),returning:R().default(!1).optional()}).describe(`Options for DataEngine.update operations`));var a3t=$(()=>N9.extend({where:H([U(I(),z()),d9]).optional(),multi:R().default(!1).optional()}).describe(`QueryAST-aligned options for DataEngine.delete operations`));$(()=>N9.extend({filter:M9.optional(),multi:R().default(!1).optional()}).describe(`Options for DataEngine.delete operations`));var o3t=$(()=>N9.extend({where:H([U(I(),z()),d9]).optional(),groupBy:B(I()).optional(),aggregations:B(J0t).optional(),timezone:I().optional()}).describe(`QueryAST-aligned options for DataEngine.aggregate operations`));$(()=>N9.extend({filter:M9.optional(),groupBy:B(I()).optional(),aggregations:B(V({field:I(),method:W([`count`,`sum`,`avg`,`min`,`max`,`count_distinct`]),alias:I().optional()})).optional()}).describe(`Options for DataEngine.aggregate operations`));var s3t=$(()=>N9.extend({where:H([U(I(),z()),d9]).optional()}).describe(`QueryAST-aligned options for DataEngine.count operations`));$(()=>N9.extend({filter:M9.optional()}).describe(`Options for DataEngine.count operations`)),$(()=>V({find:Ol().input($c([I(),P9.optional()])).output(El(B(z()))),findOne:Ol().input($c([I(),P9.optional()])).output(El(z())),insert:Ol().input($c([I(),H([U(I(),z()),B(U(I(),z()))]),r3t.optional()])).output(El(z())),update:Ol().input($c([I(),U(I(),z()),i3t.optional()])).output(El(z())),delete:Ol().input($c([I(),a3t.optional()])).output(El(z())),count:Ol().input($c([I(),s3t.optional()])).output(El(L())),aggregate:Ol().input($c([I(),o3t])).output(El(B(z())))}).describe(`Standard Data Engine Contract`));var F9={filter:M9.optional()},c3t=P9.extend({...F9,select:B(I()).optional(),sort:n3t.optional(),skip:L().int().min(0).optional(),populate:B(I()).optional()}),l3t=$(()=>V({method:rl(`find`),object:I(),query:c3t.optional()})),u3t=$(()=>V({method:rl(`findOne`),object:I(),query:c3t.optional()})),d3t=$(()=>V({method:rl(`insert`),object:I(),data:H([U(I(),z()),B(U(I(),z()))]),options:r3t.optional()})),f3t=$(()=>V({method:rl(`update`),object:I(),data:U(I(),z()),id:H([I(),L()]).optional().describe(`ID for single update, or use where in options`),options:i3t.extend(F9).optional()})),p3t=$(()=>V({method:rl(`delete`),object:I(),id:H([I(),L()]).optional().describe(`ID for single delete, or use where in options`),options:a3t.extend(F9).optional()})),m3t=$(()=>V({method:rl(`count`),object:I(),query:s3t.extend(F9).optional()})),h3t=$(()=>V({method:rl(`aggregate`),object:I(),query:o3t.extend(F9)})),g3t=$(()=>V({method:rl(`execute`),command:z(),options:U(I(),z()).optional()})),_3t=$(()=>V({method:rl(`vectorFind`),object:I(),vector:B(L()),where:H([U(I(),z()),d9]).optional(),fields:B(I()).optional(),limit:L().int().default(5).optional(),threshold:L().optional()})),v3t=$(()=>V({method:rl(`batch`),requests:B(Yc(`method`,[l3t,u3t,d3t,f3t,p3t,m3t,h3t,g3t,_3t])),transaction:R().default(!0).optional()}));$(()=>Yc(`method`,[l3t,u3t,d3t,f3t,p3t,m3t,h3t,v3t,g3t,_3t]).describe(`Virtual ObjectQL Request Protocol`)),W([`count`,`sum`,`avg`,`min`,`max`,`count_distinct`,`percentile`,`median`,`stddev`,`variance`]).describe(`Standard aggregation functions`);var y3t=W([`asc`,`desc`]).describe(`Sort order direction`);$(()=>V({field:I().describe(`Field name to sort by`),order:y3t.describe(`Sort direction`)}).describe(`Sort field and direction pair`)),W([`insert`,`update`,`delete`,`upsert`]).describe(`Data mutation event types`);var b3t=W([`read_uncommitted`,`read_committed`,`repeatable_read`,`serializable`,`snapshot`]).describe(`Transaction isolation levels (snake_case standard)`);W([`lru`,`lfu`,`ttl`,`fifo`]).describe(`Cache eviction strategy`);var I9=$(()=>V({transaction:z().optional().describe(`Transaction handle`),timeout:L().optional().describe(`Timeout in ms`),skipCache:R().optional().describe(`Bypass cache`),traceContext:U(I(),I()).optional().describe(`OpenTelemetry context or request ID`),tenantId:I().optional().describe(`Tenant Isolation identifier`),timezone:I().optional().describe(`Business reference timezone (IANA) for date-dependent generation, e.g. autonumber date tokens`)})),x3t=$(()=>V({create:R().default(!0).describe(`Supports CREATE operations`),read:R().default(!0).describe(`Supports READ operations`),update:R().default(!0).describe(`Supports UPDATE operations`),delete:R().default(!0).describe(`Supports DELETE operations`),bulkCreate:R().default(!1).describe(`Supports bulk CREATE operations`),bulkUpdate:R().default(!1).describe(`Supports bulk UPDATE operations`),bulkDelete:R().default(!1).describe(`Supports bulk DELETE operations`),transactions:R().default(!1).describe(`Supports ACID transactions`),savepoints:R().default(!1).describe(`Supports transaction savepoints`),isolationLevels:B(b3t).optional().describe(`Supported isolation levels`),queryFilters:R().default(!0).describe(`Supports WHERE clause filtering`),queryAggregations:R().default(!1).describe(`Supports GROUP BY and aggregation functions`),queryDateGranularity:U(K0t,R()).optional().describe(`Per-granularity native date bucketing (day/week/month/quarter/year). Missing keys fall back to in-memory bucketing.`),querySorting:R().default(!0).describe(`Supports ORDER BY sorting`),queryPagination:R().default(!0).describe(`Supports LIMIT/OFFSET pagination`),queryWindowFunctions:R().default(!1).describe(`Supports window functions with OVER clause`),querySubqueries:R().default(!1).describe(`Supports subqueries`),queryCTE:R().default(!1).describe(`Supports Common Table Expressions (WITH clause)`),joins:R().default(!1).describe(`Supports SQL joins`),fullTextSearch:R().default(!1).describe(`Supports full-text search`),jsonQuery:R().default(!1).describe(`Supports JSON field querying`),geospatialQuery:R().default(!1).describe(`Supports geospatial queries`),streaming:R().default(!1).describe(`Supports result streaming (cursors/iterators)`),jsonFields:R().default(!1).describe(`Supports JSON field types`),arrayFields:R().default(!1).describe(`Supports array field types`),vectorSearch:R().default(!1).describe(`Supports vector embeddings and similarity search`),autonumber:R().optional().describe(`Driver natively generates persistent autonumber/sequence values`),schemaSync:R().default(!1).describe(`Supports automatic schema synchronization`),batchSchemaSync:R().default(!1).describe(`Supports batched schema sync to reduce schema DDL round-trips`),migrations:R().default(!1).describe(`Supports database migrations`),indexes:R().default(!1).describe(`Supports index creation and management`),connectionPooling:R().default(!1).describe(`Supports connection pooling`),preparedStatements:R().default(!1).describe(`Supports prepared statements (SQL injection prevention)`),queryCache:R().default(!1).describe(`Supports query result caching`)}));$(()=>V({name:I().describe(`Driver unique name`),version:I().describe(`Driver version`),supports:x3t,connect:Ol().input($c([])).output(El(Uc())).describe(`Establish connection`),disconnect:Ol().input($c([])).output(El(Uc())).describe(`Close connection`),checkHealth:Ol().input($c([])).output(El(R())).describe(`Health check`),getPoolStats:Ol().input($c([])).output(V({total:L(),idle:L(),active:L(),waiting:L()}).optional()).optional().describe(`Get connection pool statistics`),execute:Ol().input($c([z(),B(z()).optional(),I9.optional()])).output(El(z())).describe(`Execute raw command`),find:Ol().input($c([I(),h9,I9.optional()])).output(El(B(U(I(),z())))).describe(`Find records`),findStream:Ol().input($c([I(),h9,I9.optional()])).output(z()).describe(`Stream records (AsyncIterable)`),findOne:Ol().input($c([I(),h9,I9.optional()])).output(El(U(I(),z()).nullable())).describe(`Find one record`),create:Ol().input($c([I(),U(I(),z()),I9.optional()])).output(El(U(I(),z()))).describe(`Create record`),update:Ol().input($c([I(),I().or(L()),U(I(),z()),I9.optional()])).output(El(U(I(),z()))).describe(`Update record`),upsert:Ol().input($c([I(),U(I(),z()),B(I()).optional(),I9.optional()])).output(El(U(I(),z()))).describe(`Upsert record`),delete:Ol().input($c([I(),I().or(L()),I9.optional()])).output(El(R())).describe(`Delete record`),count:Ol().input($c([I(),h9.optional(),I9.optional()])).output(El(L())).describe(`Count records`),bulkCreate:Ol().input($c([I(),B(U(I(),z())),I9.optional()])).output(El(B(U(I(),z())))),bulkUpdate:Ol().input($c([I(),B(V({id:I().or(L()),data:U(I(),z())})),I9.optional()])).output(El(B(U(I(),z())))),bulkDelete:Ol().input($c([I(),B(I().or(L())),I9.optional()])).output(El(Uc())),updateMany:Ol().input($c([I(),h9,U(I(),z()),I9.optional()])).output(El(L())).optional(),deleteMany:Ol().input($c([I(),h9,I9.optional()])).output(El(L())).optional(),beginTransaction:Ol().input($c([V({isolationLevel:b3t.optional()}).optional()])).output(El(z())).describe(`Start transaction`),commit:Ol().input($c([z()])).output(El(Uc())).describe(`Commit transaction`),rollback:Ol().input($c([z()])).output(El(Uc())).describe(`Rollback transaction`),syncSchema:Ol().input($c([I(),z(),I9.optional()])).output(El(Uc())).describe(`Sync object schema to DB`),syncSchemasBatch:Ol().input($c([B(V({object:I(),schema:z()})),I9.optional()])).output(El(Uc())).optional().describe(`Batch sync multiple schemas in one round-trip`),dropTable:Ol().input($c([I(),I9.optional()])).output(El(Uc())),explain:Ol().input($c([I(),h9,I9.optional()])).output(El(z())).optional()}));var S3t=$(()=>V({min:L().min(0).default(2).describe(`Minimum number of connections in pool`),max:L().min(1).default(10).describe(`Maximum number of connections in pool`),idleTimeoutMillis:L().min(0).default(3e4).describe(`Time in ms before idle connection is closed`),connectionTimeoutMillis:L().min(0).default(5e3).describe(`Time in ms to wait for available connection`)})),C3t=$(()=>V({name:I().describe(`Driver instance name`),type:W([`sql`,`nosql`,`cache`,`search`,`graph`,`timeseries`]).describe(`Driver type category`),capabilities:x3t.describe(`Driver capability flags`),connectionString:I().optional().describe(`Database connection string (driver-specific format)`),poolConfig:S3t.optional().describe(`Connection pool configuration`)})),w3t=$(()=>W([`postgresql`,`mysql`,`sqlite`,`mssql`,`oracle`,`mariadb`])),T3t=$(()=>V({text:I().describe(`SQL type for text fields (e.g., VARCHAR, TEXT)`),number:I().describe(`SQL type for number fields (e.g., NUMERIC, DECIMAL, INT)`),boolean:I().describe(`SQL type for boolean fields (e.g., BOOLEAN, BIT)`),date:I().describe(`SQL type for date fields (e.g., DATE)`),datetime:I().describe(`SQL type for datetime fields (e.g., TIMESTAMP, DATETIME)`),json:I().optional().describe(`SQL type for JSON fields (e.g., JSON, JSONB)`),uuid:I().optional().describe(`SQL type for UUID fields (e.g., UUID, CHAR(36))`),binary:I().optional().describe(`SQL type for binary fields (e.g., BLOB, BYTEA)`)})),E3t=$(()=>V({rejectUnauthorized:R().default(!0).describe(`Reject connections with invalid certificates`),ca:I().optional().describe(`CA certificate file path or content`),cert:I().optional().describe(`Client certificate file path or content`),key:I().optional().describe(`Client private key file path or content`)}).refine(e=>e.cert!==void 0==(e.key!==void 0),{message:`Client certificate (cert) and private key (key) must be provided together`}));$(()=>C3t.extend({type:rl(`sql`).describe(`Driver type must be "sql"`),dialect:w3t.describe(`SQL database dialect`),dataTypeMapping:T3t.describe(`SQL data type mapping configuration`),ssl:R().default(!1).describe(`Enable SSL/TLS connection`),sslConfig:E3t.optional().describe(`SSL/TLS configuration (required when ssl is true)`)}).refine(e=>!(e.ssl&&!e.sslConfig),{message:`sslConfig is required when ssl is true`}));var D3t=$(()=>W([`mongodb`,`couchdb`,`dynamodb`,`cassandra`,`redis`,`elasticsearch`,`neo4j`,`orientdb`]));$(()=>W([`find`,`findOne`,`insert`,`update`,`delete`,`aggregate`,`mapReduce`,`count`,`distinct`,`createIndex`,`dropIndex`]));var O3t=$(()=>W([`all`,`quorum`,`one`,`local_quorum`,`each_quorum`,`eventual`])),k3t=$(()=>W([`single`,`compound`,`unique`,`text`,`geospatial`,`hashed`,`ttl`,`sparse`])),A3t=$(()=>V({enabled:R().default(!1).describe(`Enable sharding`),shardKey:I().optional().describe(`Field to use as shard key`),shardingStrategy:W([`hash`,`range`,`zone`]).optional().describe(`Sharding strategy`),numShards:L().int().positive().optional().describe(`Number of shards`)})),j3t=$(()=>V({enabled:R().default(!1).describe(`Enable replication`),replicaSetName:I().optional().describe(`Replica set name`),replicas:L().int().positive().optional().describe(`Number of replicas`),readPreference:W([`primary`,`primaryPreferred`,`secondary`,`secondaryPreferred`,`nearest`]).optional().describe(`Read preference for replica set`),writeConcern:W([`majority`,`acknowledged`,`unacknowledged`]).optional().describe(`Write concern level`)})),M3t=$(()=>V({enabled:R().default(!1).describe(`Enable schema validation`),validationLevel:W([`strict`,`moderate`,`off`]).optional().describe(`Validation strictness`),validationAction:W([`error`,`warn`]).optional().describe(`Action on validation failure`),jsonSchema:U(I(),z()).optional().describe(`JSON Schema for validation`)})),N3t=$(()=>V({text:I().describe(`NoSQL type for text fields`),number:I().describe(`NoSQL type for number fields`),boolean:I().describe(`NoSQL type for boolean fields`),date:I().describe(`NoSQL type for date fields`),datetime:I().describe(`NoSQL type for datetime fields`),json:I().optional().describe(`NoSQL type for JSON/object fields`),uuid:I().optional().describe(`NoSQL type for UUID fields`),binary:I().optional().describe(`NoSQL type for binary fields`),array:I().optional().describe(`NoSQL type for array fields`),objectId:I().optional().describe(`NoSQL type for ObjectID fields (MongoDB)`),geopoint:I().optional().describe(`NoSQL type for geospatial point fields`)}));$(()=>C3t.extend({type:rl(`nosql`).describe(`Driver type must be "nosql"`),databaseType:D3t.describe(`Specific NoSQL database type`),dataTypeMapping:N3t.describe(`NoSQL data type mapping configuration`),consistency:O3t.optional().describe(`Consistency level for operations`),replication:j3t.optional().describe(`Replication configuration`),sharding:A3t.optional().describe(`Sharding configuration`),schemaValidation:M3t.optional().describe(`Document schema validation`),region:I().optional().describe(`AWS region (for managed NoSQL services)`),accessKeyId:I().optional().describe(`AWS access key ID`),secretAccessKey:I().optional().describe(`AWS secret access key`),ttlField:I().optional().describe(`Field name for TTL (auto-deletion)`),maxDocumentSize:L().int().positive().optional().describe(`Maximum document size in bytes`),collectionPrefix:I().optional().describe(`Prefix for collection/table names`)}));var P3t=$(()=>V({consistency:O3t.optional().describe(`Consistency level override`),readFromSecondary:R().optional().describe(`Allow reading from secondary replicas`),projection:U(I(),H([rl(0),rl(1)])).optional().describe(`Field projection`),timeout:L().int().positive().optional().describe(`Query timeout (ms)`),useCursor:R().optional().describe(`Use cursor instead of loading all results`),batchSize:L().int().positive().optional().describe(`Cursor batch size`),profile:R().optional().describe(`Enable query profiling`),hint:I().optional().describe(`Index hint for query optimization`)})),F3t=$(()=>V({operator:I().describe(`Aggregation operator (e.g., $match, $group, $sort)`),options:U(I(),z()).describe(`Stage-specific options`)}));$(()=>V({collection:I().describe(`Collection/table name`),stages:B(F3t).describe(`Aggregation pipeline stages`),options:P3t.optional().describe(`Query options`)})),$(()=>V({name:I().describe(`Index name`),type:k3t.describe(`Index type`),fields:B(V({field:I().describe(`Field name`),order:W([`asc`,`desc`,`text`,`2dsphere`]).optional().describe(`Index order or type`)})).describe(`Fields to index`),unique:R().default(!1).describe(`Enforce uniqueness`),sparse:R().default(!1).describe(`Sparse index`),expireAfterSeconds:L().int().positive().optional().describe(`TTL in seconds`),partialFilterExpression:U(I(),z()).optional().describe(`Partial index filter`),background:R().default(!1).describe(`Create index in background`)})),$(()=>V({readConcern:W([`local`,`majority`,`linearizable`,`snapshot`]).optional().describe(`Read concern level`),writeConcern:W([`majority`,`acknowledged`,`unacknowledged`]).optional().describe(`Write concern level`),readPreference:W([`primary`,`primaryPreferred`,`secondary`,`secondaryPreferred`,`nearest`]).optional().describe(`Read preference`),maxCommitTimeMS:L().int().positive().optional().describe(`Transaction commit timeout (ms)`)}));var L9=W([`insert`,`update`,`upsert`,`replace`,`ignore`]),I3t=$(()=>V({object:I().regex(/^[a-z_][a-z0-9_]*$/).describe(`Target Object Name`),externalId:I().default(`name`).describe(`Field match for uniqueness check`),mode:L9.default(`upsert`).describe(`Conflict resolution strategy`),env:B(W([`prod`,`dev`,`test`])).default([`prod`,`dev`,`test`]).describe(`Applicable environments`),records:B(U(I(),z())).describe(`Data records`)}));k9({schemaId:`object`,type:`simple`,sections:[{name:`basics`,label:`Basics`,description:`Identity, labels, and taxonomy.`,columns:2,fields:[{field:`name`,type:`text`,required:!0,immutable:!0,colSpan:1,helpText:`snake_case unique identifier (immutable after creation)`},{field:`label`,type:`text`,colSpan:1,helpText:`Singular display name (e.g. "Account")`},{field:`pluralLabel`,type:`text`,colSpan:1,helpText:`Plural display name (e.g. "Accounts")`},{field:`icon`,type:`text`,colSpan:1,helpText:`Lucide icon name (e.g. "building", "users")`},{field:`description`,type:`textarea`,colSpan:2,helpText:`Developer documentation`},{field:`tags`,type:`tags`,colSpan:2,helpText:`Categorization tags (e.g. "sales", "system")`},{field:`active`,type:`boolean`,colSpan:1,helpText:`Is the object active and usable`},{field:`isSystem`,type:`boolean`,colSpan:1,helpText:`System object (protected from deletion)`},{field:`abstract`,type:`boolean`,colSpan:1,helpText:`Abstract base (cannot be instantiated)`}]},{name:`fields`,label:`Fields`,description:`Define the data model — each entry becomes a column in the database table.`,fields:[{field:`fields`,type:`record`,required:!0,helpText:`Add the columns this object will store`,keyField:{field:`name`,label:`Name`,placeholder:`snake_case_identifier`,helpText:`snake_case machine name (used as column name and API key)`,regex:`^[a-z_][a-z0-9_]*$`,immutable:!0},fields:[{field:`label`,type:`text`,helpText:`Display label`},{field:`type`,type:`select`,required:!0,helpText:`Field type`,options:[{label:`Text`,value:`text`},{label:`Textarea`,value:`textarea`},{label:`Email`,value:`email`},{label:`URL`,value:`url`},{label:`Phone`,value:`phone`},{label:`Password`,value:`password`},{label:`Markdown`,value:`markdown`},{label:`HTML`,value:`html`},{label:`Rich Text`,value:`richtext`},{label:`Number`,value:`number`},{label:`Currency`,value:`currency`},{label:`Percent`,value:`percent`},{label:`Date`,value:`date`},{label:`Date & Time`,value:`datetime`},{label:`Time`,value:`time`},{label:`Boolean`,value:`boolean`},{label:`Toggle`,value:`toggle`},{label:`Select`,value:`select`},{label:`Multiselect`,value:`multiselect`},{label:`Radio`,value:`radio`},{label:`Checkboxes`,value:`checkboxes`},{label:`Lookup (reference)`,value:`lookup`},{label:`Master–Detail`,value:`master_detail`},{label:`Tree`,value:`tree`},{label:`Image`,value:`image`},{label:`File`,value:`file`},{label:`Avatar`,value:`avatar`},{label:`Video`,value:`video`},{label:`Audio`,value:`audio`},{label:`Formula (computed)`,value:`formula`},{label:`Summary (rollup)`,value:`summary`},{label:`Autonumber`,value:`autonumber`},{label:`Composite (embedded)`,value:`composite`},{label:`Repeater (embedded array)`,value:`repeater`},{label:`Record (keyed map)`,value:`record`},{label:`Location (GPS)`,value:`location`},{label:`Address`,value:`address`},{label:`Code`,value:`code`},{label:`JSON`,value:`json`},{label:`Color`,value:`color`},{label:`Rating`,value:`rating`},{label:`Slider`,value:`slider`},{label:`Signature`,value:`signature`},{label:`QR / Barcode`,value:`qrcode`},{label:`Progress`,value:`progress`},{label:`Tags`,value:`tags`},{label:`Vector embedding`,value:`vector`}]},{field:`description`,type:`textarea`,helpText:`Developer documentation for this column`},{field:`required`,type:`boolean`,helpText:`Must be set on every record`},{field:`unique`,type:`boolean`,helpText:`Disallow duplicate values`},{field:`indexed`,type:`boolean`,helpText:`Create a database index for faster querying`},{field:`readonly`,type:`boolean`,helpText:`Visible but never user-editable`},{field:`immutable`,type:`boolean`,helpText:`Editable on create, locked thereafter`},{field:`hidden`,type:`boolean`,helpText:`Hidden from default UI`},{field:`searchable`,type:`boolean`,helpText:`Include in full-text search`},{field:`sortable`,type:`boolean`,helpText:`Allow sorting on this column`},{field:`filterable`,type:`boolean`,helpText:`Allow filtering on this column`},{field:`defaultValue`,type:`text`,helpText:`Default value for new records (JSON literal)`},{field:`placeholder`,type:`text`,helpText:`Placeholder hint`},{field:`maxLength`,type:`number`,helpText:`Max characters`,visibleOn:`type in ['text','textarea','email','url','phone','password','markdown','html','richtext']`},{field:`minLength`,type:`number`,helpText:`Min characters`,visibleOn:`type in ['text','textarea','email','url','phone','password','markdown','html','richtext']`},{field:`min`,type:`number`,helpText:`Minimum value`,visibleOn:`type in ['number','currency','percent','rating','slider','progress']`},{field:`max`,type:`number`,helpText:`Maximum value`,visibleOn:`type in ['number','currency','percent','rating','slider','progress']`},{field:`precision`,type:`number`,helpText:`Total digits`,visibleOn:`type in ['number','currency','percent']`},{field:`scale`,type:`number`,helpText:`Decimal places`,visibleOn:`type in ['number','currency','percent']`},{field:`options`,type:`repeater`,helpText:`Available choices`,visibleOn:`type in ['select','multiselect','radio','checkboxes']`,fields:[{field:`label`,type:`text`,required:!0},{field:`value`,type:`text`,required:!0},{field:`color`,type:`color`},{field:`icon`,type:`text`,helpText:`Lucide icon name`},{field:`description`,type:`text`}]},{field:`reference`,type:`text`,helpText:`Target object name`,visibleOn:`type in ['lookup','master_detail','tree']`},{field:`referenceFilter`,type:`code`,language:`expression`,helpText:`CEL filter applied to the picker`,visibleOn:`type in ['lookup','master_detail']`},{field:`cascadeDelete`,type:`boolean`,helpText:`Delete children when parent is deleted`,visibleOn:`type == 'master_detail'`},{field:`multiple`,type:`boolean`,helpText:`Allow selecting multiple records`,visibleOn:`type in ['lookup']`},{field:`formula`,type:`code`,language:`expression`,helpText:`CEL formula expression`,visibleOn:`type == 'formula'`},{field:`returnType`,type:`select`,helpText:`Result type for formulas`,visibleOn:`type == 'formula'`,options:[{label:`Text`,value:`text`},{label:`Number`,value:`number`},{label:`Boolean`,value:`boolean`},{label:`Date`,value:`date`},{label:`Datetime`,value:`datetime`},{label:`Currency`,value:`currency`}]},{field:`summaryType`,type:`select`,helpText:`Aggregation`,visibleOn:`type == 'summary'`,options:[{label:`Count`,value:`count`},{label:`Sum`,value:`sum`},{label:`Avg`,value:`avg`},{label:`Min`,value:`min`},{label:`Max`,value:`max`}]},{field:`summaryField`,type:`text`,helpText:`Field on child object to aggregate`,visibleOn:`type == 'summary'`},{field:`displayFormat`,type:`text`,helpText:`e.g. "INV-{0000}"`,visibleOn:`type == 'autonumber'`},{field:`startingNumber`,type:`number`,helpText:`Starting sequence value`,visibleOn:`type == 'autonumber'`},{field:`language`,type:`text`,helpText:`Editor language (e.g. sql, javascript)`,visibleOn:`type == 'code'`},{field:`validation`,type:`code`,language:`expression`,helpText:`CEL predicate — must evaluate true`},{field:`errorMessage`,type:`text`,helpText:`Shown when validation fails`},{field:`audit`,type:`boolean`,helpText:`Audit changes to this field`},{field:`trackHistory`,type:`boolean`,helpText:`Keep change history`},{field:`pii`,type:`boolean`,helpText:`Personally identifiable information`},{field:`encrypted`,type:`boolean`,helpText:`Encrypt at rest`}]}]},{name:`capabilities`,label:`Capabilities`,description:`System features and API exposure.`,collapsible:!0,collapsed:!0,fields:[{field:`capabilities`,type:`composite`,helpText:`Enable/disable system features`,fields:[{field:`trackHistory`,type:`boolean`},{field:`searchable`,type:`boolean`},{field:`apiEnabled`,type:`boolean`},{field:`files`,type:`boolean`},{field:`feeds`,type:`boolean`},{field:`activities`,type:`boolean`},{field:`trash`,type:`boolean`},{field:`mru`,type:`boolean`},{field:`clone`,type:`boolean`}]}]},{name:`advanced`,label:`Advanced`,description:`State machines, actions, and storage.`,collapsible:!0,collapsed:!0,fields:[{field:`datasource`,type:`text`,helpText:`Target datasource ID (default: "default")`},{field:`lifecycle`,type:`composite`,helpText:`Data lifecycle contract (ADR-0057): how long rows live and how space is reclaimed. Leave empty for permanent record semantics. Non-record classes require at least one bounding policy (retention, TTL, or rotation).`,fields:[{field:`class`,type:`select`,helpText:`Persistence contract for the rows of this object`,options:[{label:`Record (business truth — permanent)`,value:`record`},{label:`Audit (compliance ledger — retain → archive → delete)`,value:`audit`},{label:`Telemetry (high-frequency log — short retention)`,value:`telemetry`},{label:`Transient (ephemeral state — TTL expiry)`,value:`transient`},{label:`Event (bus messages — very short TTL)`,value:`event`}]},{field:`retention`,type:`composite`,helpText:`Age-based retention window`,fields:[{field:`maxAge`,type:`text`,helpText:`Rows older than this (by created_at) are reaped. Duration literal: h/d/w/y, e.g. "30d"`}]},{field:`ttl`,type:`composite`,helpText:`Per-row TTL expiry`,fields:[{field:`field`,type:`text`,helpText:`Timestamp field the TTL is measured from (e.g. expires_at)`},{field:`expireAfter`,type:`text`,helpText:`Rows expire this long after the field, e.g. "1d"`}]},{field:`storage`,type:`composite`,helpText:`Physical rotation for high-frequency telemetry (SQLite: O(1) shard DROP)`,fields:[{field:`strategy`,type:`select`,helpText:`Storage strategy`,options:[{label:`Rotation (time-shard + drop oldest)`,value:`rotation`}]},{field:`shards`,type:`number`,min:2,helpText:`Shards retained; total window = shards × unit`},{field:`unit`,type:`select`,helpText:`Time width of one shard`,options:[{label:`Day`,value:`day`},{label:`Week`,value:`week`},{label:`Month`,value:`month`}]}]},{field:`archive`,type:`composite`,helpText:`Cold-store hand-off (audit class). Rows are never hot-deleted before the archive copy succeeded.`,fields:[{field:`after`,type:`text`,helpText:`Archive rows older than this — must equal retention.maxAge`},{field:`to`,type:`text`,helpText:`Target datasource name for cold storage`},{field:`keep`,type:`text`,helpText:`How long the archive keeps rows (empty = forever), e.g. "7y"`}]},{field:`reclaim`,type:`boolean`,helpText:`Reclaim driver space after sweeps (default on for non-record classes)`}]}]}]}),k9({schemaId:`field`,type:`simple`,sections:[{name:`basics`,label:`Basics`,description:`Core field identity and constraints.`,columns:2,fields:[{field:`name`,required:!0,immutable:!0,colSpan:1,helpText:`Unique identifier (snake_case, immutable after creation)`},{field:`label`,required:!0,colSpan:1,helpText:`Display name for users`},{field:`type`,required:!0,colSpan:1,helpText:`Data type of this field`},{field:`group`,colSpan:1,helpText:`Group name for form layout`},{field:`description`,widget:`textarea`,colSpan:2,helpText:`Help text shown to users`},{field:`required`,colSpan:1,helpText:`User must provide a value`},{field:`unique`,colSpan:1,helpText:`No two records can have the same value`},{field:`multiple`,colSpan:1,helpText:`Allow multiple values (for select/lookup)`}]},{name:`configuration`,label:`Configuration`,description:`Field-type specific settings (visible blocks depend on the chosen type).`,fields:[{field:`defaultValue`,helpText:`Default value for new records`},{field:`minLength`,visibleOn:`data.type == 'text' || data.type == 'textarea' || data.type == 'email'`,helpText:`Minimum character length`},{field:`maxLength`,visibleOn:`data.type == 'text' || data.type == 'textarea' || data.type == 'email'`,helpText:`Maximum character length`},{field:`min`,visibleOn:`data.type == 'number' || data.type == 'currency'`,helpText:`Minimum value`},{field:`max`,visibleOn:`data.type == 'number' || data.type == 'currency'`,helpText:`Maximum value`},{field:`precision`,visibleOn:`data.type == 'currency' || data.type == 'number'`,helpText:`Decimal places (e.g., 2 for $10.50)`},{field:`scale`,visibleOn:`data.type == 'number'`,helpText:`Number of decimal digits`},{field:`options`,type:`repeater`,visibleOn:`data.type == 'select' || data.type == 'multiselect'`,helpText:`Available options (label/value pairs)`},{field:`reference`,widget:`ref:object`,visibleOn:`data.type == 'lookup' || data.type == 'master_detail'`,helpText:`Referenced object name`},{field:`referenceFilters`,widget:`string-tags`,visibleOn:`data.type == 'lookup' || data.type == 'master_detail'`,helpText:`Filter expressions (e.g., "active = true")`},{field:`deleteBehavior`,visibleOn:`data.type == 'lookup' || data.type == 'master_detail'`,helpText:`What happens when referenced record is deleted`}]},{name:`formula`,label:`Formula & Computed`,description:`Calculated values and roll-up summaries.`,collapsible:!0,collapsed:!0,fields:[{field:`expression`,widget:`textarea`,helpText:`CEL expression to calculate this field (makes it read-only)`},{field:`summaryOperations`,type:`composite`,helpText:`Roll-up summary configuration (for parent-child relationships)`}]},{name:`advanced`,label:`Advanced`,description:`Database, UI, audit, and security settings.`,collapsible:!0,collapsed:!0,columns:2,fields:[{field:`columnName`,colSpan:2,helpText:`Physical column name in database (defaults to field name)`},{field:`index`,colSpan:1,helpText:`Create database index for faster queries`},{field:`externalId`,colSpan:1,helpText:`Mark as external ID for upsert operations`},{field:`readonly`,colSpan:1,helpText:`Field is read-only in forms`},{field:`hidden`,colSpan:1,helpText:`Hide field from default UI views`},{field:`searchable`,colSpan:1,helpText:`Include in global search results`},{field:`sortable`,colSpan:1,helpText:`Allow sorting lists by this field`}]}]}),k9({schemaId:`hook`,type:`simple`,sections:[{label:`Identity`,description:`What this hook is and when it fires.`,columns:2,fields:[{field:`name`,type:`text`,required:!0,immutable:!0,colSpan:1,helpText:`snake_case identifier (immutable after creation)`},{field:`label`,type:`text`,colSpan:1},{field:`description`,type:`textarea`,colSpan:2},{field:`object`,type:`text`,required:!0,colSpan:1,helpText:`Target object name (or "*" for global)`},{field:`events`,type:`tags`,required:!0,colSpan:1,helpText:`Lifecycle events (e.g. beforeInsert, afterUpdate)`},{field:`priority`,type:`number`,colSpan:1,helpText:`Lower numbers run first`}]},{label:`Body`,description:`Inline expression or sandboxed JavaScript executed when the hook fires.`,fields:[{field:`body`,type:`composite`,helpText:`Either an L1 expression or an L2 sandboxed JS body`,fields:[{field:`language`,type:`select`,required:!0,helpText:`expression = pure formula; js = sandboxed JavaScript`,options:[{label:`Expression (L1)`,value:`expression`},{label:`JavaScript (L2 sandboxed)`,value:`js`}]},{field:`source`,type:`code`,language:`javascript`,required:!0,helpText:`Function body source — no top-level imports`},{field:`capabilities`,type:`tags`,helpText:`Allowed ctx APIs (api.read, api.write, crypto.uuid, log, …)`},{field:`timeoutMs`,type:`number`,helpText:`Per-invocation timeout (ms)`}]}]},{label:`Legacy handler`,description:`Function name reference — deprecated in favour of body.`,collapsible:!0,collapsed:!0,fields:[{field:`handler`,type:`text`,helpText:"Handler function name (deprecated — prefer `body`)"}]},{label:`Execution`,collapsible:!0,collapsed:!0,columns:2,fields:[{field:`async`,type:`boolean`,colSpan:1,helpText:`Run in background, do not block the transaction`},{field:`onError`,type:`select`,colSpan:1,options:[{label:`Abort`,value:`abort`},{label:`Log`,value:`log`}]},{field:`timeout`,type:`number`,colSpan:1,helpText:`Abort the hook after N milliseconds`},{field:`condition`,type:`code`,language:`javascript`,colSpan:2,helpText:`Optional formula — skip the hook when this evaluates to false`},{field:`retryPolicy`,type:`composite`,colSpan:2,helpText:`Retry on failure — most useful for async hooks`,fields:[{field:`maxRetries`,type:`number`,helpText:`Maximum retry attempts`},{field:`backoffMs`,type:`number`,helpText:`Delay between retries (ms)`}]}]}]});var L3t=$(()=>V({field:I().describe(`Source field name containing the reference value`),targetObject:I().regex(/^[a-z_][a-z0-9_]*$/).describe(`Target object name (snake_case)`),targetField:I().default(`name`).describe(`Field on target object used for matching`),fieldType:W([`lookup`,`master_detail`,`user`]).describe(`Relationship field type`)}).describe(`Describes how a field reference is resolved during seed loading`)),R3t=$(()=>V({object:I().regex(/^[a-z_][a-z0-9_]*$/).describe(`Object name (snake_case)`),dependsOn:B(I()).describe(`Objects this object depends on`),references:B(L3t).describe(`Field-level reference details`)}).describe(`Object node in the seed data dependency graph`)),z3t=$(()=>V({nodes:B(R3t).describe(`All objects in the dependency graph`),insertOrder:B(I()).describe(`Topologically sorted insert order`),circularDependencies:B(B(I())).default([]).describe(`Circular dependency chains (e.g., [["a", "b", "a"]])`)}).describe(`Complete object dependency graph for seed data loading`)),B3t=$(()=>V({sourceObject:I().describe(`Object with the broken reference`),field:I().describe(`Field name with unresolved reference`),targetObject:I().describe(`Target object searched for the reference`),targetField:I().describe(`ExternalId field used for matching`),attemptedValue:z().describe(`Value that failed to resolve`),recordIndex:L().int().min(0).describe(`Index of the record in the dataset`),message:I().describe(`Human-readable error description`)}).describe(`Actionable error for a failed reference resolution`)),V3t=V({user:V({id:I().min(1),role:I().optional(),email:I().optional()}).optional().describe(`Subject bound to os.user in seed CEL expressions`),org:V({id:I().min(1),tier:I().optional()}).optional().describe(`Organization bound to os.org in seed CEL expressions`)}).describe(`Identity context for resolving os.user / os.org in seed CEL values`),H3t=$(()=>V({dryRun:R().default(!1).describe(`Validate references without writing data`),haltOnError:R().default(!1).describe(`Stop on first reference resolution error`),multiPass:R().default(!0).describe(`Enable multi-pass loading for circular dependencies`),defaultMode:L9.default(`upsert`).describe(`Default conflict resolution strategy`),batchSize:L().int().min(1).default(1e3).describe(`Maximum records per batch insert/upsert`),transaction:R().default(!1).describe(`Wrap entire load in a transaction (all-or-nothing)`),env:W([`prod`,`dev`,`test`]).optional().describe(`Only load datasets matching this environment`),organizationId:I().min(1).optional().describe(`Target organization id for per-tenant seed replay`),identity:V3t.optional().describe(`Identity bound to os.user / os.org when resolving CEL seed values`)}).describe(`Seed data loader configuration`)),U3t=$(()=>V({object:I().describe(`Object that was loaded`),mode:L9.describe(`Import mode used`),inserted:L().int().min(0).describe(`Records inserted`),updated:L().int().min(0).describe(`Records updated`),skipped:L().int().min(0).describe(`Records skipped`),errored:L().int().min(0).describe(`Records with errors`),total:L().int().min(0).describe(`Total records in dataset`),referencesResolved:L().int().min(0).describe(`References resolved via externalId`),referencesDeferred:L().int().min(0).describe(`References deferred to second pass`),errors:B(B3t).default([]).describe(`Reference resolution errors`)}).describe(`Result of loading a single dataset`));$(()=>V({success:R().describe(`Overall success status`),dryRun:R().describe(`Whether this was a dry-run`),dependencyGraph:z3t.describe(`Object dependency graph`),results:B(U3t).describe(`Per-object load results`),errors:B(B3t).describe(`All reference resolution errors`),summary:V({objectsProcessed:L().int().min(0).describe(`Total objects processed`),totalRecords:L().int().min(0).describe(`Total records across all objects`),totalInserted:L().int().min(0).describe(`Total records inserted`),totalUpdated:L().int().min(0).describe(`Total records updated`),totalSkipped:L().int().min(0).describe(`Total records skipped`),totalErrored:L().int().min(0).describe(`Total records with errors`),totalReferencesResolved:L().int().min(0).describe(`Total references resolved`),totalReferencesDeferred:L().int().min(0).describe(`Total references deferred`),circularDependencyCount:L().int().min(0).describe(`Circular dependency chains detected`),durationMs:L().min(0).describe(`Load duration in milliseconds`)}).describe(`Summary statistics`)}).describe(`Complete seed loader result`)),$(()=>V({seeds:B(I3t).min(1).describe(`Seeds to load`),config:H3t.default(()=>H3t.parse({})).describe(`Loader configuration`)}).describe(`Seed loader request with datasets and configuration`));var W3t=$(()=>V({versionNumber:L().describe(`Version number`),createdAt:L().describe(`Creation timestamp`),createdBy:I().describe(`Creator user ID`),size:L().describe(`File size in bytes`),checksum:I().describe(`File checksum`),downloadUrl:I().url().describe(`Download URL`),isLatest:R().optional().default(!1).describe(`Is latest version`)})),G3t=$(()=>V({id:I().describe(`Template ID`),name:I().describe(`Template name`),description:I().optional().describe(`Template description`),fileUrl:I().url().describe(`Template file URL`),fileType:I().describe(`File MIME type`),placeholders:B(V({key:I().describe(`Placeholder key`),label:I().describe(`Placeholder label`),type:W([`text`,`number`,`date`,`image`]).describe(`Placeholder type`),required:R().optional().default(!1).describe(`Is required`)})).describe(`Template placeholders`)})),K3t=$(()=>V({provider:W([`docusign`,`adobe-sign`,`hellosign`,`custom`]).describe(`E-signature provider`),enabled:R().optional().default(!1).describe(`E-signature enabled`),signers:B(V({email:I().email().describe(`Signer email`),name:I().describe(`Signer name`),role:I().describe(`Signer role`),order:L().describe(`Signing order`)})).describe(`Document signers`),expirationDays:L().optional().default(30).describe(`Expiration days`),reminderDays:L().optional().default(7).describe(`Reminder interval days`)}));$(()=>V({id:I().describe(`Document ID`),name:I().describe(`Document name`),description:I().optional().describe(`Document description`),fileType:I().describe(`File MIME type`),fileSize:L().describe(`File size in bytes`),category:I().optional().describe(`Document category`),tags:B(I()).optional().describe(`Document tags`),versioning:V({enabled:R().describe(`Versioning enabled`),versions:B(W3t).describe(`Version history`),majorVersion:L().describe(`Major version`),minorVersion:L().describe(`Minor version`)}).optional().describe(`Version control`),template:G3t.optional().describe(`Document template`),eSignature:K3t.optional().describe(`E-signature config`),access:V({isPublic:R().optional().default(!1).describe(`Public access`),sharedWith:B(I()).optional().describe(`Shared with`),expiresAt:L().optional().describe(`Access expiration`)}).optional().describe(`Access control`),metadata:U(I(),z()).optional().describe(`Custom metadata`)}));var q3t=$(()=>Yc(`type`,[V({type:rl(`constant`),value:z().describe(`Constant value to use`)}).describe(`Set a constant value`),V({type:rl(`cast`),targetType:W([`string`,`number`,`boolean`,`date`]).describe(`Target data type`)}).describe(`Cast to a specific data type`),V({type:rl(`lookup`),table:I().describe(`Lookup table name`),keyField:I().describe(`Field to match on`),valueField:I().describe(`Field to retrieve`)}).describe(`Lookup value from another table`),V({type:rl(`javascript`),expression:v9.describe(`JS expression (dialect="js" recommended). e.g. value.toUpperCase()`)}).describe(`Custom JavaScript transformation`),V({type:rl(`map`),mappings:U(I(),z()).describe(`Value mappings (e.g., {"Active": "active"})`)}).describe(`Map values using a dictionary`)])),J3t=$(()=>V({source:I().describe(`Source field name`),target:I().describe(`Target field name`),transform:q3t.optional().describe(`Transformation to apply`),defaultValue:z().optional().describe(`Default if source is null/undefined`)})),Y3t=$(()=>V({id:I().describe(`Data source ID`),name:I().describe(`Data source name`),type:W([`odata`,`rest-api`,`graphql`,`custom`]).describe(`Protocol type`),endpoint:I().url().describe(`API endpoint URL`),authentication:V({type:W([`oauth2`,`api-key`,`basic`,`none`]).describe(`Auth type`),config:U(I(),z()).describe(`Auth configuration`)}).describe(`Authentication`)})),X3t=$(()=>J3t.extend({type:I().optional().describe(`Field type`),readonly:R().optional().default(!0).describe(`Read-only field`)}));$(()=>V({fieldName:I().describe(`Field name`),dataSource:Y3t.describe(`External data source`),query:V({endpoint:I().describe(`Query endpoint path`),method:W([`GET`,`POST`]).optional().default(`GET`).describe(`HTTP method`),parameters:U(I(),z()).optional().describe(`Query parameters`)}).describe(`Query configuration`),fieldMappings:B(X3t).describe(`Field mappings`),caching:V({enabled:R().optional().default(!0).describe(`Cache enabled`),ttl:L().optional().default(300).describe(`Cache TTL (seconds)`),strategy:W([`lru`,`lfu`,`ttl`]).optional().default(`ttl`).describe(`Cache strategy`)}).optional().describe(`Caching configuration`),fallback:V({enabled:R().optional().default(!0).describe(`Fallback enabled`),defaultValue:z().optional().describe(`Default fallback value`),showError:R().optional().default(!0).describe(`Show error to user`)}).optional().describe(`Fallback configuration`),rateLimit:V({requestsPerSecond:L().describe(`Requests per second limit`),burstSize:L().optional().describe(`Burst size`)}).optional().describe(`Rate limiting`),retry:V({maxRetries:L().min(0).default(3).describe(`Maximum retry attempts`),initialDelayMs:L().default(1e3).describe(`Initial retry delay in milliseconds`),maxDelayMs:L().default(3e4).describe(`Maximum retry delay in milliseconds`),backoffMultiplier:L().default(2).describe(`Exponential backoff multiplier`),retryableStatusCodes:B(L()).default([429,500,502,503,504]).describe(`HTTP status codes that are retryable`)}).optional().describe(`Retry configuration with exponential backoff`),transform:V({request:V({headers:U(I(),I()).optional().describe(`Additional request headers`),queryParams:U(I(),I()).optional().describe(`Additional query parameters`)}).optional().describe(`Request transformation`),response:V({dataPath:I().optional().describe(`JSONPath to extract data (e.g., "$.data.results")`),totalPath:I().optional().describe(`JSONPath to extract total count (e.g., "$.meta.total")`)}).optional().describe(`Response transformation`)}).optional().describe(`Request/response transformation pipeline`),pagination:V({type:W([`offset`,`cursor`,`page`]).default(`offset`).describe(`Pagination type`),pageSize:L().default(100).describe(`Items per page`),maxPages:L().optional().describe(`Maximum number of pages to fetch`)}).optional().describe(`Pagination configuration for external data`)}));var Z3t=I().describe(`Underlying driver identifier`);$(()=>V({id:I().describe(`Unique driver identifier (e.g. "postgres")`),label:I().describe(`Display label (e.g. "PostgreSQL")`),description:I().optional(),icon:I().optional(),configSchema:U(I(),z()).describe(`JSON Schema for connection configuration`),capabilities:wl(()=>Q3t).optional()}));var Q3t=V({transactions:R().default(!1),queryFilters:R().default(!1),queryAggregations:R().default(!1),querySorting:R().default(!1),queryPagination:R().default(!1),queryWindowFunctions:R().default(!1),querySubqueries:R().default(!1),joins:R().default(!1),fullTextSearch:R().default(!1),readOnly:R().default(!1),dynamicSchema:R().default(!1)}),$3t=W([`managed`,`external`,`validate-only`]).describe(`Schema ownership mode`),e6t=V({label:I().optional().describe(`Display label, e.g. "Snowflake — ANALYTICS / PROD"`),allowedSchemas:B(I()).optional().describe(`Whitelist of remote schemas/databases that may be exposed.`),allowWrites:R().default(!1).describe(`Global write gate. Individual objects must also opt in via object.external.writable.`),validation:V({onMismatch:W([`fail`,`warn`,`ignore`]).default(`fail`).describe(`What to do when a federated object diverges from the remote table.`),checkOnBoot:R().default(!0).describe(`Validate federated objects against the remote schema at boot.`),checkIntervalMs:L().optional().describe(`Optional background drift-check interval in milliseconds.`)}).default({onMismatch:`fail`,checkOnBoot:!0}).describe(`Boot/drift validation policy`),credentialsRef:I().optional().describe(`Reference into the secrets store; never inline credentials.`),queryTimeoutMs:L().default(3e4).describe(`Hard cap on per-query execution time.`),requirePermission:I().optional().describe(`Optional convenience: gate the entire datasource behind a single role.`)}).describe(`External datasource federation settings (schemaMode != "managed")`);$(()=>V({name:I().regex(/^[a-z_][a-z0-9_]*$/).describe(`Unique datasource identifier`),label:I().optional().describe(`Display label`),driver:Z3t.describe(`Underlying driver type`),config:U(I(),z()).describe(`Driver specific configuration`),pool:V({min:L().default(0).describe(`Minimum connections`),max:L().default(10).describe(`Maximum connections`),idleTimeoutMillis:L().default(3e4).describe(`Idle timeout`),connectionTimeoutMillis:L().default(3e3).describe(`Connection establishment timeout`)}).optional().describe(`Connection pool settings`),readReplicas:B(U(I(),z())).optional().describe(`Read-only replica configurations`),capabilities:Q3t.optional().describe(`Capability overrides`),healthCheck:V({enabled:R().default(!0).describe(`Enable health check endpoint`),intervalMs:L().default(3e4).describe(`Health check interval in milliseconds`),timeoutMs:L().default(5e3).describe(`Health check timeout in milliseconds`)}).optional().describe(`Datasource health check configuration`),ssl:V({enabled:R().default(!1).describe(`Enable SSL/TLS for database connection`),rejectUnauthorized:R().default(!0).describe(`Reject connections with invalid/self-signed certificates`),ca:I().optional().describe(`CA certificate (PEM format or path to file)`),cert:I().optional().describe(`Client certificate (PEM format or path to file)`),key:I().optional().describe(`Client private key (PEM format or path to file)`)}).optional().describe(`SSL/TLS configuration for secure database connections`),retryPolicy:V({maxRetries:L().default(3).describe(`Maximum number of retry attempts`),baseDelayMs:L().default(1e3).describe(`Base delay between retries in milliseconds`),maxDelayMs:L().default(3e4).describe(`Maximum delay between retries in milliseconds`),backoffMultiplier:L().default(2).describe(`Exponential backoff multiplier`)}).optional().describe(`Connection retry policy for transient failures`),description:I().optional().describe(`Internal description`),active:R().default(!0).describe(`Is datasource enabled`),autoConnect:R().default(!1).describe(`Force a live driver connection at boot even when managed + unrouted (ADR-0062 D2).`),schemaMode:$3t.default(`managed`),external:e6t.optional(),origin:W([`code`,`runtime`]).default(`code`).describe(`Datasource provenance (server-managed, read-only)`)}).superRefine((e,t)=>{e.schemaMode!==`managed`&&!e.external&&t.addIssue({code:`custom`,path:[`external`],message:`schemaMode='${e.schemaMode}' requires 'external' settings.`}),e.schemaMode===`managed`&&e.external&&t.addIssue({code:`custom`,path:[`external`],message:`'external' settings only apply when schemaMode != 'managed'.`})}));var t6t=V({name:I().describe(`Remote column name`),sqlType:I().describe(`Raw remote SQL type (e.g. "numeric(10,2)")`),nullable:R().describe(`Whether the remote column is nullable`),primaryKey:R().default(!1).describe(`Part of the remote primary key`),suggestedFieldType:I().optional().describe(`ObjectStack field type suggested by the type-compat matrix`)}),n6t=V({remoteSchema:I().optional().describe(`Remote schema/database qualifier`),remoteName:I().describe(`Remote table/view name`),columns:B(t6t).describe(`Remote columns`),indexes:B(V({name:I(),columns:B(I()),unique:R()})).optional().describe(`Remote indexes, when introspectable`),rowCountEstimate:L().optional().describe(`Approximate row count`)});$(()=>V({name:I().regex(/^[a-z_][a-z0-9_]*$/).describe("Catalog id, conventionally `<datasource>_catalog`."),datasource:I().describe(`Datasource.name this catalog snapshots.`),snapshotAt:I().datetime().describe(`When the snapshot was taken (ISO 8601).`),dialect:I().optional().describe(`Remote SQL dialect, when known.`),tables:B(n6t).describe(`Snapshotted remote tables.`)}));var r6t=W([`count`,`sum`,`avg`,`min`,`max`,`count_distinct`,`number`,`string`,`boolean`]),i6t=W([`string`,`number`,`boolean`,`time`,`geo`]),a6t=W([`second`,`minute`,`hour`,`day`,`week`,`month`,`quarter`,`year`]),o6t=$(()=>V({name:I().regex(/^[a-z_][a-z0-9_]*$/).describe(`Unique metric ID`),label:I().describe(`Human readable label`),description:I().optional(),type:r6t,sql:I().describe(`SQL expression or field reference`),filters:B(V({sql:I()})).optional(),format:I().optional()})),s6t=$(()=>V({name:I().regex(/^[a-z_][a-z0-9_]*$/).describe(`Unique dimension ID`),label:I().describe(`Human readable label`),description:I().optional(),type:i6t,sql:I().describe(`SQL expression or column reference`),granularities:B(a6t).optional()})),c6t=$(()=>V({name:I().describe(`Target cube name`),relationship:W([`one_to_one`,`one_to_many`,`many_to_one`]).default(`many_to_one`),sql:I().describe(`Join condition (ON clause)`)}));$(()=>V({name:I().regex(/^[a-z_][a-z0-9_]*$/).describe(`Cube name (snake_case)`),title:I().optional(),description:I().optional(),sql:I().describe(`Base SQL statement or Table Name`),measures:U(I(),o6t).describe(`Quantitative metrics`),dimensions:U(I(),s6t).describe(`Qualitative attributes`),joins:U(I(),c6t).optional(),refreshKey:V({every:I().optional(),sql:I().optional()}).optional(),public:R().default(!1)})),$(()=>V({cube:I().optional().describe(`Target cube name (optional when provided externally, e.g. in API request wrapper)`),measures:B(I()).describe(`List of metrics to calculate`),dimensions:B(I()).optional().describe(`List of dimensions to group by`),where:d9.optional().describe(`Filtering criteria (canonical Query DSL FilterCondition)`),timeDimensions:B(V({dimension:I(),granularity:a6t.optional(),dateRange:H([I(),B(I())]).optional()})).optional(),order:U(I(),W([`asc`,`desc`])).optional(),limit:L().optional(),offset:L().optional(),timezone:I().optional().default(`UTC`)}));var l6t=W([`comment`,`field_change`,`task`,`event`,`email`,`call`,`note`,`file`,`record_create`,`record_delete`,`approval`,`sharing`,`system`]),u6t=$(()=>V({type:W([`user`,`team`,`record`]).describe(`Mention target type`),id:I().describe(`Target ID`),name:I().describe(`Display name for rendering`),offset:L().int().min(0).describe(`Character offset in body text`),length:L().int().min(1).describe(`Length of mention token in body text`)})),d6t=$(()=>V({field:I().describe(`Field machine name`),fieldLabel:I().optional().describe(`Field display label`),oldValue:z().optional().describe(`Previous value`),newValue:z().optional().describe(`New value`),oldDisplayValue:I().optional().describe(`Human-readable old value`),newDisplayValue:I().optional().describe(`Human-readable new value`)})),f6t=$(()=>V({emoji:I().describe(`Emoji character or shortcode (e.g., "👍", ":thumbsup:")`),userIds:B(I()).describe(`Users who reacted`),count:L().int().min(1).describe(`Total reaction count`)})),p6t=$(()=>V({type:W([`user`,`system`,`service`,`automation`]).describe(`Actor type`),id:I().describe(`Actor ID`),name:I().optional().describe(`Actor display name`),avatarUrl:I().url().optional().describe(`Actor avatar URL`),source:I().optional().describe(`Source application (e.g., "Omni", "API", "Studio")`)})),m6t=W([`public`,`internal`,`private`]);$(()=>V({id:I().describe(`Feed item ID`),type:l6t.describe(`Activity type`),object:I().describe(`Object name (e.g., "account")`),recordId:I().describe(`Record ID this feed item belongs to`),actor:p6t.describe(`Who performed this action`),body:I().optional().describe(`Rich text body (Markdown supported)`),mentions:B(u6t).optional().describe(`Mentioned users/teams/records`),changes:B(d6t).optional().describe(`Field-level changes`),reactions:B(f6t).optional().describe(`Emoji reactions on this item`),parentId:I().optional().describe(`Parent feed item ID for threaded replies`),replyCount:L().int().min(0).default(0).describe(`Number of replies`),pinned:R().default(!1).describe(`Whether the feed item is pinned to the top of the timeline`),pinnedAt:I().datetime().optional().describe(`Timestamp when the item was pinned`),pinnedBy:I().optional().describe(`User ID who pinned the item`),starred:R().default(!1).describe(`Whether the feed item is starred/bookmarked by the current user`),starredAt:I().datetime().optional().describe(`Timestamp when the item was starred`),visibility:m6t.default(`public`).describe(`Visibility: public (all users), internal (team only), private (author + mentioned)`),createdAt:I().datetime().describe(`Creation timestamp`),updatedAt:I().datetime().optional().describe(`Last update timestamp`),editedAt:I().datetime().optional().describe(`When comment was last edited`),isEdited:R().default(!1).describe(`Whether comment has been edited`)})),W([`all`,`comments_only`,`changes_only`,`tasks_only`]);var h6t=W([`comment`,`mention`,`field_change`,`task`,`approval`,`all`]),g6t=W([`in_app`,`email`,`push`,`slack`]);$(()=>V({object:I().describe(`Object name`),recordId:I().describe(`Record ID`),userId:I().describe(`Subscribing user ID`),events:B(h6t).default([`all`]).describe(`Event types to receive notifications for`),channels:B(g6t).default([`in_app`]).describe(`Notification delivery channels`),active:R().default(!0).describe(`Whether the subscription is active`),createdAt:I().datetime().describe(`Subscription creation timestamp`)}));var _6t=new Set([`textarea`,`markdown`,`html`,`grid`,`rich-text`,`field:textarea`,`field:markdown`,`field:html`,`field:grid`,`field:rich-text`]);function v6t(e){return _6t.has(e)}function y6t(e,t){let n;return n=e<=3?1:e<=8?2:e<=15?3:4,t!==void 0&&t<640?Math.min(n,1):n}function b6t(e,t){return t<=1?e:e.map(e=>e.span===void 0&&e.type&&v6t(e.type)?{...e,span:t}:e)}function x6t(e,t,n){if(t!==void 0)return{fields:b6t(e,t),columns:t};let r=y6t(e.length,n);return{fields:b6t(e,r),columns:r}}function S6t(e,t){return function(){try{let n=_m();return n.t(t)===t?{t:(t,n)=>{let r=e[t]||t;if(n)for(let[e,t]of Object.entries(n))r=r.replace(`{{${e}}}`,String(t));return r}}:{t:n.t}}catch{return{t:(t,n)=>{let r=e[t]||t;if(n)for(let[e,t]of Object.entries(n))r=r.replace(`{{${e}}}`,String(t));return r}}}}}var R9=S6t({"detail.back":`Back`,"detail.edit":`Edit`,"detail.editInline":`Edit`,"detail.save":`Save`,"detail.saveChanges":`Save changes`,"detail.editFieldsInline":`Edit fields inline`,"detail.editInlineHint":`Double-click to edit`,"detail.cancel":`Cancel`,"detail.cancelEdit":`Discard changes`,"detail.openInNewTab":`Open in new tab`,"detail.share":`Share`,"detail.duplicate":`Duplicate`,"detail.export":`Export`,"detail.viewHistory":`View history`,"detail.delete":`Delete`,"detail.moreActions":`More actions`,"detail.addToFavorites":`Add to favorites`,"detail.removeFromFavorites":`Remove from favorites`,"detail.previousRecord":`Previous record`,"detail.nextRecord":`Next record`,"detail.recordOf":`{{current}} of {{total}}`,"detail.recordNotFound":`Record not found`,"detail.recordNotFoundDescription":`The record you are looking for does not exist or may have been deleted.`,"detail.goBack":`Go back`,"detail.details":`Details`,"detail.related":`Related`,"detail.relatedRecords":`{{count}} records`,"detail.relatedRecordOne":`{{count}} record`,"detail.noRelatedRecords":`No related records found`,"detail.loading":`Loading...`,"detail.copyToClipboard":`Copy to clipboard`,"detail.copied":`Copied!`,"detail.deleteConfirmation":`Are you sure you want to delete this record?`,"detail.editRecord":`Edit record`,"detail.viewAll":`View All`,"detail.new":`New`,"detail.emptyValue":`—`,"detail.noValue":`No value`,"detail.activity":`Activity`,"detail.copyRecordId":`Copy record ID`,"detail.showEmptyFields":`Show {{count}} empty fields`,"detail.hideEmptyFields":`Hide empty fields`,"detail.editRow":`Edit`,"detail.deleteRow":`Delete`,"detail.deleteRowConfirmation":`Are you sure you want to delete this record?`,"detail.actions":`Actions`,"detail.previousPage":`Previous`,"detail.nextPage":`Next`,"detail.pageOf":`Page {{current}} of {{total}}`,"detail.sortBy":`Sort by`,"detail.filterPlaceholder":`Filter...`,"detail.highlightFields":`Key Fields`,"detail.comments":`Comments`,"detail.searchComments":`Search comments…`,"detail.addCommentPlaceholder":`Add a comment… (Ctrl+Enter to submit)`,"detail.noMatchingComments":`No matching comments`,"detail.noCommentsYet":`No comments yet`,"detail.pinned":`Pinned`,"detail.pin":`Pin`,"detail.unpin":`Unpin`,"detail.justNow":`just now`,"detail.minutesAgo":`{{count}}m ago`,"detail.hoursAgo":`{{count}}h ago`,"detail.daysAgo":`{{count}}d ago`,"detail.createdBy":`Created by`,"detail.updatedBy":`Updated by`,"detail.created":`Created`,"detail.updated":`Updated`,"detail.dropFilesToUpload":`Drop files here or click to upload`,"detail.attachmentCount":`{{count}} attachment`,"detail.attachmentCountPlural":`{{count}} attachments`,"detail.removeAttachment":`Remove attachment`,"detail.unifiedDiff":`Unified diff`,"detail.sideBySideDiff":`Side-by-side diff`,"detail.noChanges":`No changes`,"detail.previousVersion":`Previous`,"detail.currentVersion":`Current`,"detail.discussion":`Discussion`,"detail.showDiscussion":`Show Discussion ({{count}})`,"detail.hideDiscussion":`Hide discussion`,"detail.bold":`Bold (Ctrl+B)`,"detail.italic":`Italic (Ctrl+I)`,"detail.listFormat":`List`,"detail.inlineCode":`Inline code`,"detail.mentionSomeone":`Mention someone`,"detail.preview":`Preview`,"detail.submitComment":`Submit (Ctrl+Enter)`,"detail.sendComment":`Send`,"detail.writeComment":`Write a comment…`,"detail.subscribedTooltip":`Subscribed — click to unsubscribe`,"detail.unsubscribedTooltip":`Subscribe to notifications`,"detail.firstRecord":`First record (Home)`,"detail.previousRecordKey":`Previous record (←)`,"detail.nextRecordKey":`Next record (→)`,"detail.lastRecord":`Last record (End)`,"detail.noRecords":`No records`,"detail.showEmptyRelated_one":`+ {{count}} empty`,"detail.showEmptyRelated_other":`+ {{count}} empty`,"detail.searchWhileNavigating":`Search while navigating`,"detail.searchRecords":`Search records…`,"detail.allActivity":`All Activity`,"detail.commentsOnly":`Comments Only`,"detail.fieldChangesFilter":`Field Changes`,"detail.tasksOnly":`Tasks Only`,"detail.leaveCommentPlaceholder":`Leave a comment… (Ctrl+Enter to submit)`,"detail.noActivity":`No activity recorded`,"detail.loadMore":`Load more`,"detail.edited":`(edited)`,"detail.via":`via {{source}}`,"detail.viewSource":`View source`,"detail.replyCount":`{{count}} reply`,"detail.replyCountPlural":`{{count}} replies`,"detail.replyPlaceholder":`Reply…`,"detail.filterActivity":`Filter activity`,"detail.openDiscussion":`Open discussion panel`,"detail.closeDiscussion":`Close discussion panel`,"detail.subscribeAriaLabel":`Subscribe to notifications`,"detail.unsubscribeAriaLabel":`Unsubscribe from notifications`,"detail.clearSearch":`Clear search`,"detail.concurrentUpdateTitle":`This record was modified by someone else`,"detail.concurrentUpdateDescription":`Another user saved a newer version of {{field}} while you were editing. To prevent silently overwriting their change, please choose how to resolve the conflict.`,"detail.concurrentUpdateYourEdit":`Your edit`,"detail.concurrentUpdateCurrentValue":`Current value`,"detail.concurrentUpdateUpdatedBy":`Updated by {{name}}`,"detail.concurrentUpdateUpdatedAt":`Updated at {{when}}`,"detail.concurrentUpdateReload":`Reload latest`,"detail.concurrentUpdateOverwrite":`Overwrite anyway`,"detail.concurrentUpdateCancel":`Cancel`},`detail.back`);function C6t(e){if(typeof e==`string`){let t=e.trim();if(!t)return null;try{return JSON.parse(t)}catch{return t}}return e??null}function w6t(e){let t=C6t(e);return t==null||t===``?0:Array.isArray(t)?t.length:typeof t==`object`?Object.keys(t).length:1}function z9({value:e,field:t}){let{t:n}=R9(),r=Qp(),{appName:i}=P1t(),a=t?.name||``,o=r?.data?.name,s=i&&o?`/apps/${i}/metadata/permission/${encodeURIComponent(String(o))}`:null,c=w6t(e),l=c===0;return(0,q.jsxs)(`span`,{className:`inline-flex flex-wrap items-center gap-x-2 gap-y-1 text-sm`,children:[(()=>{if(l)return(0,q.jsx)(`span`,{className:`text-muted-foreground`,children:n(`perm.facet.none`,{defaultValue:`None`})});if(a===`system_permissions`){let t=aZt(e),r=t.slice(0,6),i=t.length-r.length;return(0,q.jsxs)(`span`,{className:`inline-flex flex-wrap items-center gap-1`,children:[r.map(e=>(0,q.jsx)(cY,{variant:`outline`,children:e},e)),i>0&&(0,q.jsx)(`span`,{className:`text-muted-foreground text-xs`,children:n(`perm.facet.more`,{count:i,defaultValue:`+${i} more`})})]})}return(0,q.jsx)(`span`,{className:`text-foreground`,children:(()=>{switch(a){case`object_permissions`:return n(`perm.facet.objects`,{count:c,defaultValue:`${c} object${c===1?``:`s`}`});case`field_permissions`:return n(`perm.facet.fields`,{count:c,defaultValue:`${c} field rule${c===1?``:`s`}`});case`row_level_security`:return n(`perm.facet.rls`,{count:c,defaultValue:`${c} RLS polic${c===1?`y`:`ies`}`});case`tab_permissions`:return n(`perm.facet.tabs`,{count:c,defaultValue:`${c} tab rule${c===1?``:`s`}`});case`admin_scope`:return n(`perm.facet.adminScope`,{defaultValue:`Delegated admin configured`});default:return String(c)}})()})})(),s?(0,q.jsx)(n9,{to:s,className:`text-primary hover:underline whitespace-nowrap`,children:n(`perm.facet.designInStudio`,{defaultValue:`Design in Studio →`})}):(0,q.jsx)(`span`,{className:`text-muted-foreground/60 whitespace-nowrap`,children:n(`perm.facet.designInStudioHint`,{defaultValue:`Design in Studio`})})]})}var T6t=new Set([`id`,`_id`,`__v`,`created`,`created_at`,`createdAt`,`created_by`,`modified`,`modified_by`,`updated_at`,`updatedAt`,`updated_by`,`deleted_at`,`is_deleted`,`deleted`,`instance_state`]),B9=new Set([`formula`,`summary`,`rollup`,`auto_number`]),E6t=({field:e,value:t,onChange:n,dataSource:r,autoFocus:i})=>{let a=e.type,o=e.widget;if(o===`permission-facet-link`)return(0,q.jsx)(z9,{value:t,field:e});if(o===`capability-multiselect`)return(0,q.jsx)(cZt,{value:t,onChange:e=>n(e),field:e,dataSource:r});if(a===`select`&&Array.isArray(e.options)&&e.options.length>0)return(0,q.jsx)(iXt,{field:e,value:t==null?``:String(t),onChange:e=>n(e)});if(a===`boolean`)return(0,q.jsx)(tXt,{field:e,value:!!t,onChange:e=>n(e)});let s=a===`user`||a===`owner`,c=a===`lookup`||a===`master_detail`||a===`tree`||!!e.reference_to&&!B9.has(a);if(s||c)return(0,q.jsx)(s?LZt:x5,{field:e,value:t,onChange:e=>n(e),dataSource:r});if(a===`number`)return(0,q.jsx)($Yt,{field:e,value:t,onChange:e=>n(e),autoFocus:i});if(a===`currency`)return(0,q.jsx)(gXt,{field:e,value:t,onChange:e=>n(e),autoFocus:i});if(a===`percent`)return(0,q.jsx)(mZt,{field:e,value:t,onChange:e=>n(e),autoFocus:i});let l=a===`date`||a===`datetime`;return(0,q.jsx)(`input`,{type:l?`date`:`text`,autoFocus:i,className:`w-full px-2 py-1.5 text-sm border rounded-md bg-background focus:outline-none focus:ring-2 focus:ring-ring`,value:t==null?``:l?(()=>{let e=String(t);if(/^\d{4}-\d{2}-\d{2}/.test(e))return e.slice(0,10);let n=new Date(e);return isNaN(n.getTime())?``:n.toLocaleDateString(`en-CA`)})():String(typeof t==`object`?a7(t)??``:t),onChange:e=>{let t=e.target.value;n(l&&t?new Date(t+`T00:00:00`).toISOString():t)}})},D6t=({name:e})=>/^[a-z0-9][a-z0-9-]*$/i.test(e)?(0,q.jsx)(v3,{name:e,className:`h-4 w-4 shrink-0 text-muted-foreground`,"aria-hidden":!0}):(0,q.jsx)(`span`,{className:`text-muted-foreground`,children:e});function O6t(e,t){return!e||e<=1||t<=1?``:t===2?e>=2?`md:col-span-2`:``:t===3?e===2?`md:col-span-2`:e>=3?`md:col-span-2 lg:col-span-3`:``:e===2?`md:col-span-2`:e===3?`md:col-span-2 lg:col-span-3`:e>=4?`md:col-span-2 lg:col-span-3 xl:col-span-4`:``}var V9=({section:e,data:t,className:n,objectSchema:r,objectName:i,isEditing:a=!1,onFieldChange:o,onEnterInlineEdit:s,autoFocusField:c,dataSource:l,virtualScroll:u})=>{let[d,f]=K.useState(e.defaultCollapsed??!1),[p,m]=K.useState(null),[h,g]=K.useState(void 0),[_,v]=K.useState(!1),{t:y}=R9(),{fieldLabel:b,translateOptions:x}=ym(),S=K.useCallback((e,t)=>{let n=t==null?``:String(t);navigator.clipboard.writeText(n).then(()=>{m(e),setTimeout(()=>m(null),2e3)})},[]),C=K.useCallback(e=>{let n=t?.[e.name]??e.value;return n==null||n===``},[t]),w=K.useMemo(()=>e.fields.filter(C).length,[e.fields,C]),T=h4(),E=T?3:4,D=T?.2:.25,O=e.fields.length-w,k=!e.hideEmpty&&!a&&e.fields.length>=E&&w/e.fields.length>=D&&O>0,A=!_&&(e.hideEmpty||k)?e.fields.filter(e=>!C(e)):e.fields,{fields:ee,columns:te}=x6t(A,e.columns),j=Math.min(te,Math.max(1,A.length)),ne=e=>{let n=t?.[e.name]??e.value;if(e.render)return(0,q.jsx)(Kp,{schema:e.render,data:{...t,value:n}});let u=O6t(e.span,j),d=r?.fields?.[e.name],f={...e};if(d){!e.type&&d.type&&(f.type=d.type),d.options&&!f.options&&(f.options=d.options),d.currency&&!f.currency&&(f.currency=d.currency),d.precision!==void 0&&f.precision===void 0&&(f.precision=d.precision),d.scale!==void 0&&f.scale===void 0&&(f.scale=d.scale),d.min!==void 0&&f.min===void 0&&(f.min=d.min),d.max!==void 0&&f.max===void 0&&(f.max=d.max),d.step!==void 0&&f.step===void 0&&(f.step=d.step),d.format&&!f.format&&(f.format=d.format),d.widget&&!f.widget&&(f.widget=d.widget);let t=d.reference_to||d.reference;t&&!f.reference_to&&(f.reference_to=t),d.reference_field&&!f.reference_field&&(f.reference_field=d.reference_field),d.dueLike!==void 0&&f.dueLike===void 0&&(f.dueLike=d.dueLike)}i&&Array.isArray(f.options)&&f.options.length>0&&(f.options=x(i,e.name,f.options));let m=f.type||e.type,h=B9.has(m),g=e.readonly===!0||d?.readonly===!0,_=T6t.has(e.name),v=!g&&!h&&!_,C=v&&!!s,w=(()=>{if((f.widget||e.widget)===`permission-facet-link`)return(0,q.jsx)(z9,{value:n,field:f});if(n==null||n===``)return(0,q.jsx)(`span`,{className:`text-muted-foreground/60 text-sm select-none`,"aria-label":y(`detail.noValue`,{defaultValue:`No value`}),title:y(`detail.noValue`,{defaultValue:`No value`}),children:`—`});let t=v7(f)||e.type;if(t){let e=b7(t);if(e)return(0,q.jsx)(e,{value:n,field:f})}return String(n)})(),E=n!=null&&n!==``,D=E&&!C,O=p===e.name,k=b(i||``,e.name,e.label||e.name);return T&&!(a&&v)?(0,q.jsxs)(`div`,{className:J(`flex items-baseline justify-between gap-4 py-2.5 min-h-[44px] group`,E&&`cursor-pointer active:bg-muted/40 transition-colors`),onClick:E?()=>S(e.name,n):void 0,onKeyDown:E?t=>{(t.key===`Enter`||t.key===` `)&&(t.preventDefault(),S(e.name,n))}:void 0,role:E?`button`:void 0,tabIndex:E?0:void 0,children:[(0,q.jsx)(`span`,{className:`text-[15px] text-muted-foreground shrink-0`,children:k}),(0,q.jsx)(`span`,{className:`text-[15px] text-foreground text-right break-words min-w-0 leading-snug`,children:w})]},e.name):(0,q.jsxs)(`div`,{className:J(`space-y-1.5 group min-w-0`,u),children:[(0,q.jsx)(`div`,{className:`text-xs font-medium text-muted-foreground uppercase tracking-wide`,children:b(i||``,e.name,e.label||e.name)}),a&&v?(0,q.jsx)(`div`,{className:`min-h-[44px] sm:min-h-0`,children:(0,q.jsx)(E6t,{field:f,value:n,onChange:t=>o?.(e.name,t),dataSource:l,autoFocus:c===e.name})}):(0,q.jsxs)(`div`,{className:J(`flex items-start justify-between gap-2 min-h-[44px] sm:min-h-0 rounded-md`,D&&`cursor-pointer active:bg-muted/60 transition-colors`,C&&`cursor-pointer hover:bg-muted/40 transition-colors -mx-1.5 px-1.5`),onClick:D?()=>S(e.name,n):void 0,onDoubleClick:C?()=>s?.(e.name):void 0,onKeyDown:D?t=>{(t.key===`Enter`||t.key===` `)&&(t.preventDefault(),S(e.name,n))}:void 0,role:D?`button`:void 0,tabIndex:D?0:void 0,title:C?y(`detail.editInlineHint`):void 0,children:[(0,q.jsx)(`div`,{className:`text-sm flex-1 min-w-0 break-words py-1`,children:w}),C?(0,q.jsx)(E4,{children:(0,q.jsxs)(D4,{children:[(0,q.jsx)(O4,{asChild:!0,children:(0,q.jsx)(Z,{variant:`ghost`,size:`icon`,className:`h-6 w-6 opacity-0 group-hover:opacity-100 transition-opacity shrink-0`,"aria-label":y(`detail.editInlineHint`),onClick:t=>{t.stopPropagation(),s?.(e.name)},children:(0,q.jsx)(mq,{className:`h-3 w-3`})})}),(0,q.jsx)(k4,{children:y(`detail.editInlineHint`)})]})}):E?(0,q.jsx)(E4,{children:(0,q.jsxs)(D4,{children:[(0,q.jsx)(O4,{asChild:!0,children:(0,q.jsx)(Z,{variant:`ghost`,size:`icon`,className:`h-6 w-6 opacity-0 group-hover:opacity-100 transition-opacity shrink-0`,onClick:t=>{t.stopPropagation(),S(e.name,n)},children:O?(0,q.jsx)(sC,{className:`h-3 w-3 text-green-600`}):(0,q.jsx)(qk,{className:`h-3 w-3`})})}),(0,q.jsx)(k4,{children:y(O?`detail.copied`:`detail.copyToClipboard`)})]})}):null]})]},e.name)},re=u?.enabled===!0,M=u?.batchSize??20;if(K.useEffect(()=>{if(!re){g(void 0);return}if(ee.length<=M){g(void 0);return}g(M);let e=setTimeout(()=>g(void 0),100);return()=>clearTimeout(e)},[re,ee.length,M]),A.length===0&&w===e.fields.length)return null;let N=h===void 0?ee:ee.slice(0,h),ie=w>0&&(e.hideEmpty||k),ae=(0,q.jsxs)(q.Fragment,{children:[T?(0,q.jsx)(`div`,{className:`flex flex-col divide-y divide-border/60`,children:N.map(ne)}):(0,q.jsx)(`div`,{className:J(`grid gap-3 sm:gap-4`,j===1?`grid-cols-1`:j===2?`grid-cols-1 md:grid-cols-2`:j===3?`grid-cols-1 md:grid-cols-2 lg:grid-cols-3`:`grid-cols-1 md:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4`),children:N.map(ne)}),ie&&(0,q.jsx)(`div`,{className:`mt-3 -ml-2`,children:(0,q.jsxs)(Z,{type:`button`,variant:`ghost`,size:`sm`,onClick:()=>v(e=>!e),className:`h-7 px-2 text-xs text-muted-foreground hover:text-foreground`,children:[(0,q.jsx)(_?NN:FN,{className:`h-3.5 w-3.5 mr-1.5`}),_?y(`detail.hideEmptyFields`,{defaultValue:`Hide empty fields`}):y(`detail.showEmptyFields`,{count:w,defaultValue:`Show ${w} empty field${w===1?``:`s`}`})]})})]});return!e.title&&!e.collapsible&&e.showBorder===!1?(0,q.jsx)(`div`,{className:J(n),children:ae}):e.collapsible?(0,q.jsx)($X,{open:!d,onOpenChange:e=>f(!e),className:n,children:(0,q.jsxs)(lX,{children:[(0,q.jsx)(eZ,{asChild:!0,children:(0,q.jsxs)(uX,{className:J(`py-3 px-4 sm:py-4 sm:px-6 cursor-pointer hover:bg-muted/50 transition-colors`,e.headerColor&&`bg-${e.headerColor}`),children:[(0,q.jsxs)(dX,{className:`flex items-center justify-between text-base font-semibold tracking-tight`,children:[(0,q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[e.icon&&(0,q.jsx)(D6t,{name:e.icon}),(0,q.jsx)(`span`,{children:e.title})]}),(0,q.jsx)(`div`,{className:`flex items-center gap-2`,children:(0,q.jsx)(d?NC:jC,{className:`h-4 w-4 text-muted-foreground`})})]}),e.description&&!d&&(0,q.jsx)(`p`,{className:`text-xs text-muted-foreground mt-1`,children:e.description})]})}),(0,q.jsx)(tZ,{children:(0,q.jsx)(pX,{className:`pt-3 sm:pt-4 px-3 sm:px-6 pb-4 sm:pb-5`,children:ae})})]})}):(0,q.jsxs)(lX,{className:J(e.showBorder===!1?`border-none shadow-none`:``,n),children:[e.title&&(0,q.jsxs)(uX,{className:J(`py-3 px-4 sm:py-4 sm:px-6`,e.headerColor&&`bg-${e.headerColor}`),children:[(0,q.jsx)(dX,{className:`flex items-center justify-between text-base font-semibold tracking-tight`,children:(0,q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[e.icon&&(0,q.jsx)(D6t,{name:e.icon}),(0,q.jsx)(`span`,{children:e.title})]})}),e.description&&(0,q.jsx)(`p`,{className:`text-xs text-muted-foreground mt-1`,children:e.description})]}),(0,q.jsx)(pX,{className:`pt-3 sm:pt-4 px-3 sm:px-6 pb-4 sm:pb-5`,children:ae})]})},k6t=({tabs:e,data:t,className:n})=>{let[r,i]=K.useState(e[0]?.key),a=e.filter(e=>typeof e.visible==`boolean`?e.visible:(e.visible,!0));return(0,q.jsxs)(o3,{value:r,onValueChange:i,className:n,children:[(0,q.jsx)(s3,{className:`w-full justify-start border-b rounded-none bg-transparent p-0`,children:a.map(e=>(0,q.jsx)(c3,{value:e.key,className:`relative rounded-none border-b-2 border-transparent data-[state=active]:border-primary data-[state=active]:bg-transparent`,children:(0,q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[e.icon&&(0,q.jsx)(`span`,{children:e.icon}),(0,q.jsx)(`span`,{children:e.label}),e.badge&&(0,q.jsx)(cY,{variant:`secondary`,className:`ml-1`,children:e.badge})]})},e.key))}),a.map(e=>(0,q.jsx)(l3,{value:e.key,className:`mt-4 motion-safe:data-[state=active]:animate-in motion-safe:data-[state=active]:fade-in-0 motion-safe:duration-150`,children:(0,q.jsx)(K.Suspense,{fallback:null,children:Array.isArray(e.content)?(0,q.jsx)(`div`,{className:`space-y-4`,children:e.content.map((e,n)=>(0,q.jsx)(Kp,{schema:e,data:t},n))}):(0,q.jsx)(Kp,{schema:e.content,data:t})})},e.key))]})};function A6t(e){return e&&Gq[e.split(/[-_\s]/).filter(Boolean).map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(``)]||GU}var j6t=({action:e,onToolbarAction:t})=>{let n=e.visible,r=Bp(zp(n));if(n&&!r)return null;let i=e.icon?A6t(e.icon):null;return(0,q.jsxs)(Z,{variant:e.variant===`primary`?`default`:`outline`,size:`sm`,onClick:n=>{n.stopPropagation(),t(e)},className:`gap-1 h-9 sm:h-7 text-xs shadow-none`,"data-testid":`related-toolbar-action-${e.name}`,children:[i&&(0,q.jsx)(i,{className:`h-3.5 w-3.5`}),e.label||e.name]})},H9=({title:e,type:t,api:n,data:r,schema:i,columns:a,className:o,dataSource:s,objectName:c,onNew:l,onViewAll:u,onRowEdit:d,onRowDelete:f,onRowClick:p,rowActions:m,onRowAction:h,toolbarActions:g,onToolbarAction:_,add:v,maxColumns:y=6,pageSize:b,sortable:x=!1,filterable:S=!1,collapsible:C=!1,defaultCollapsed:w=!1,referenceField:T,parentId:E,icon:D})=>{let O=r!==void 0,k=r??[],[A,ee]=K.useState(k),[te,j]=K.useState(()=>!!n&&!O),[ne,re]=K.useState(0),[M,N]=K.useState(null),[ie,ae]=K.useState(`asc`),[oe,P]=K.useState(``),[se,ce]=K.useState(null),[le,ue]=K.useState(w),[de,fe]=K.useState(!1),[pe,me]=K.useState(!1),[he,ge]=K.useState(null),[_e,ve]=K.useState(0),[ye,be]=K.useState({}),{t:xe}=R9(),{fieldLabel:Se}=ym();K.useEffect(()=>{O&&ee(r??[])},[r,O]),K.useEffect(()=>{n&&s?.getObjectSchema&&s.getObjectSchema(n).then(ce).catch(e=>{console.warn(`[RelatedList] Failed to fetch schema for ${n}:`,e)})},[n,s]),K.useEffect(()=>{if(n&&!O){if(!(T&&E!=null&&E!==``)){n&&(E==null||E===``)&&!T&&console.warn(`[RelatedList] "${n}" has no referenceField/parentId — refusing to fetch all rows. Pass relationshipField + parentId to scope the query.`),ee([]),j(!1);return}j(!0);let e={[T]:E};if(s&&typeof s.find==`function`)s.find(n,{$filter:e}).then(e=>{let t=Array.isArray(e)?e:Array.isArray(e?.data)?e.data:[];ee(t),j(!1)}).catch(e=>{console.error(`Failed to fetch related data:`,e),j(!1)});else{let e=new URLSearchParams({[`filter[${T}]`]:String(E)}).toString();fetch(`${n}?${e}`).then(e=>e.json()).then(e=>{let t=Array.isArray(e)?e:e?.data||[];ee(t)}).catch(e=>{console.error(`Failed to fetch related data:`,e)}).finally(()=>j(!1))}}},[n,O,s,T,E,_e]),K.useEffect(()=>{if(!n||O)return;let e=e=>{let t=e.detail||{};t.objectName&&t.objectName!==n||ve(e=>e+1)};return window.addEventListener(`objectui:related-changed`,e),()=>window.removeEventListener(`objectui:related-changed`,e)},[n,O]),K.useEffect(()=>{if(!s?.find||!se?.fields||!A.length)return;let e=se.fields,t=[];for(let[n,r]of Object.entries(e)){if(!r||r.type!==`lookup`&&r.type!==`master_detail`)continue;let e=r.reference_to||r.reference;if(!e)continue;let i=new Set;for(let e of A){let t=e?.[n];t!=null&&(typeof t==`string`&&t?i.add(t):typeof t==`number`&&i.add(String(t)))}let a=ye[n]||{},o=Array.from(i).filter(e=>!(e in a));o.length>0&&t.push({fieldName:n,target:e,ids:o})}if(t.length===0)return;let n=!1;return Promise.all(t.map(({fieldName:e,target:t,ids:n})=>s.find(t,{$filter:{id:{$in:n}},$top:n.length}).then(t=>{let n=Array.isArray(t)?t:t?.data||[],r={};for(let e of n){let t=e?.id||e?._id;t&&(r[String(t)]=e?.full_name||e?.fullname||e?.display_name||e?.name||e?.subject||e?.title||e?.label||e?.code||e?.email||String(t))}return{fieldName:e,map:r}}).catch(t=>(console.warn(`[RelatedList] Failed to resolve lookups for ${e}:`,t),{fieldName:e,map:{}})))).then(e=>{n||be(t=>{let n={...t};for(let{fieldName:t,map:r}of e)n[t]={...n[t]||{},...r};return n})}),()=>{n=!0}},[s,se,A]);let Ce=K.useMemo(()=>{if(!oe)return A;let e=oe.toLowerCase();return A.filter(t=>Object.values(t).some(t=>t!=null&&String(t).toLowerCase().includes(e)))},[A,oe]),we=K.useMemo(()=>M?[...Ce].sort((e,t)=>{let n=e[M],r=t[M];if(n==null&&r==null)return 0;if(n==null)return 1;if(r==null)return-1;let i=String(n).localeCompare(String(r),void 0,{numeric:!0});return ie===`asc`?i:-i}):Ce,[Ce,M,ie]),Te=b&&b>0?b:0,Ee=Te?Math.max(1,Math.ceil(we.length/Te)):1,De=Te?we.slice(ne*Te,(ne+1)*Te):we;K.useEffect(()=>{re(0)},[oe,M,ie]);let Oe=K.useCallback(e=>{M===e?ae(e=>e===`asc`?`desc`:`asc`):(N(e),ae(`asc`))},[M]),[ke,Ae]=K.useState(null),je=K.useCallback(e=>{Ae(e)},[]),Me=K.useCallback(async()=>{if(ke)try{await f?.(ke),ve(e=>e+1)}catch(e){console.error(`[RelatedList] remove failed`,e)}Ae(null)},[ke,f]),Ne=K.useCallback(async e=>{if(!v||!s||!n||T==null||E==null)return;let t=v.picker.valueField||`id`;me(!0),ge(null);try{for(let r of e||[]){let e=r?.[t]??r?.id;e!=null&&(v.linkField?await s.create?.(n,{[T]:E,[v.linkField]:e}):await s.update?.(v.picker.object,String(e),{[T]:E}))}ve(e=>e+1)}catch(e){let t=e?.body?.error??e?.error??e?.message??String(e);ge(typeof t==`string`?t:`Failed to add`)}finally{me(!1),fe(!1)}},[v,s,n,T,E]),Pe=s9(),Fe=K.useMemo(()=>{let e=c||n||``,t=t=>!Pe?.isLoaded||!e?t:t.filter(t=>{let n=t?.accessorKey||t?.field||t?.name;return!n||Pe.checkField(e,String(n),`read`)}),r=e=>T?e.filter(e=>(e?.accessorKey||e?.field||e?.name)!==T):e,i=e=>e==null||typeof e==`string`&&e.trim()===``||Array.isArray(e)&&e.length===0,o=e=>A.length?e.filter(e=>{let t=e?.accessorKey||e?.field||e?.name;return!t||A.some(e=>!i(e?.[t]))}):e,s=(e,t)=>{if(!t?.type)return;let n=b7(v7({type:t.type,format:t.format})||t.type);if(!n)return;let r=t.type===`lookup`||t.type===`master_detail`?ye[e]:void 0,i=r&&Object.keys(r).length>0?Object.entries(r).map(([e,t])=>({value:e,label:t})):void 0,a={name:e,label:t.label||e,type:t.type,...(i||t.options)&&{options:i||t.options},...t.currency&&{currency:t.currency},...t.precision!==void 0&&{precision:t.precision},...t.scale!==void 0&&{scale:t.scale},...t.format&&{format:t.format},...(t.reference_to||t.reference)&&{reference_to:t.reference_to||t.reference},...t.reference_field&&{reference_field:t.reference_field}};return e=>e==null?K.createElement(`span`,{className:`text-muted-foreground/50 text-xs italic`},`—`):K.createElement(n,{value:e,field:a})},l=t=>{if(typeof t!=`string`){let e=t?.accessorKey||t?.field||t?.name;if(t&&!t.cell&&!t.render&&e){let n=se?.fields?.[e],r=n?s(String(e),n):void 0;if(r)return{...t,cell:r}}return t}let n=se?.fields?.[t],r={accessorKey:t,header:n?.label||Se(e,t,n)||t,fieldDef:n,fieldType:n?.type},i=n?s(t,n):void 0;return i&&(r.cell=i),r};if(a&&a.length>0)return o(t(r(a.map(l))));if(!se?.fields)return[];let u=Array.isArray(se.highlightFields)?se.highlightFields.filter(e=>typeof e==`string`&&e.length>0):[];if(u.length>0){let e=o(t(r(u.map(l))));if(e.length>0)return e.slice(0,Math.max(1,y))}let d=e,f=new Set([`attachment`,`rich_text`,`html`,`json`]),p=[`name`,`full_name`,`fullname`,`title`,`subject`,`label`,`code`,`number`],m=Object.entries(se.fields).filter(([e,t])=>!(e.startsWith(`_`)||e===`id`||e===T||t?.hidden||t?.type&&f.has(t.type)||Pe?.isLoaded&&d&&!Pe.checkField(d,e,`read`))),h=new Set([`created_at`,`updated_at`,`created_by`,`updated_by`,`owner_id`,`organization_id`]);return m.sort(([e,t],[n,r])=>{let i=h.has(e);if(i!==h.has(n))return i?1:-1;let a=p.indexOf(e),o=p.indexOf(n),s=a>=0?a:100,c=o>=0?o:100;if(s!==c)return s-c;let l=t?.type===`select`||e.includes(`status`);return l===(r?.type===`select`||n.includes(`status`))?0:l?-1:1}),o(m.map(([e,t])=>{let n={accessorKey:e,header:Se(d,e,t.label||e)};if(t.type){let r=s(e,t);r&&(n.cell=r)}return n})).slice(0,Math.max(1,y))},[a,se,c,n,Se,T,A,y,ye,Pe]),Ie=Array.isArray(m)&&m.length>0,Le=!!d||!!f||Ie,Re=h4(),ze=K.useMemo(()=>{if(i)return i;if(Re&&(t===`grid`||t===`table`)){let e=Fe[0]?.accessorKey||Fe[0]?.field||Fe[0]?.name,t=Fe.slice(1,4).map(e=>e.accessorKey||e.field||e.name).filter(Boolean);return{type:`object-gallery`,data:De,objectName:n,gallery:{titleField:e||`name`,visibleFields:t,cardSize:`medium`},onRowClick:p}}switch(t){case`grid`:case`table`:return{type:`data-table`,data:De,columns:Fe,pagination:!1,pageSize:Te||10,searchable:!1,exportable:!1,rowActions:Le,onRowEdit:d,onRowDelete:f?je:void 0,onRowClick:p,rowActionDefs:Ie?m:void 0,onRowActionDef:Ie?h:void 0};case`list`:return{type:`data-list`,data:De};default:return{type:`div`,children:`No view configured`}}},[t,De,Fe,i,Te,Le,Ie,m,h,d,f,je,p,Re,n]),Be=C?`cursor-pointer select-none`:void 0,Ve=C?()=>ue(e=>!e):void 0,He=A6t(D),Ue=!te&&A.length===0,We=S;return(0,q.jsxs)(lX,{className:J(`shadow-none border-border/60 bg-transparent`,Ue&&`bg-muted/10`,o),children:[(0,q.jsx)(uX,{className:J(`py-3 px-4 sm:py-3 min-h-12 sm:min-h-0`,Be),onClick:Ve,children:(0,q.jsxs)(dX,{className:`flex items-center justify-between gap-2 text-sm font-semibold`,children:[(0,q.jsxs)(`div`,{className:`flex items-center gap-2 min-w-0`,children:[C&&(0,q.jsx)(le?NC:jC,{className:`h-3.5 w-3.5 text-muted-foreground shrink-0`}),(0,q.jsx)(He,{className:`h-4 w-4 text-muted-foreground shrink-0`,"aria-hidden":!0}),(0,q.jsx)(`span`,{className:J(`truncate`,Ue&&`text-muted-foreground font-medium`),children:e}),(0,q.jsx)(cY,{variant:`secondary`,className:J(`text-xs font-normal h-5 px-1.5`,A.length===0&&`bg-muted text-muted-foreground`),"aria-label":`${A.length} records`,children:A.length}),Ue&&(0,q.jsx)(`span`,{className:`text-xs text-muted-foreground/70 italic ml-1 truncate`,children:xe(`detail.noRelatedRecords`)})]}),(0,q.jsxs)(`div`,{className:`flex items-center gap-1 shrink-0`,children:[_&&(g??[]).map(e=>(0,q.jsx)(j6t,{action:e,onToolbarAction:_},e.name)),v&&(0,q.jsxs)(Z,{variant:Ue?`ghost`:`outline`,size:`sm`,disabled:pe,onClick:e=>{e.stopPropagation(),ge(null),fe(!0)},className:`gap-1 h-9 sm:h-7 text-xs shadow-none`,children:[(0,q.jsx)(_q,{className:`h-3.5 w-3.5`}),v.label||xe(`detail.add`,{defaultValue:`Add`})]}),l&&(0,q.jsxs)(Z,{variant:Ue?`ghost`:`outline`,size:`sm`,onClick:e=>{e.stopPropagation(),l()},className:`gap-1 h-9 sm:h-7 text-xs shadow-none`,children:[(0,q.jsx)(_q,{className:`h-3.5 w-3.5`}),xe(`detail.new`)]})]})]})}),!le&&!Ue&&(0,q.jsxs)(pX,{className:J(`pt-0 pb-4 px-4`),children:[We&&(0,q.jsx)(`div`,{className:`mb-3`,children:(0,q.jsx)(U1,{placeholder:xe(`detail.filterPlaceholder`),value:oe,onChange:e=>P(e.target.value),className:`h-8 text-sm`})}),x&&Fe&&Fe.length>0&&A.length>0&&(0,q.jsx)(`div`,{className:`flex flex-wrap gap-1 mb-3`,children:Fe.map(e=>{let t=e.accessorKey||e.field||e.name;if(!t)return null;let n=e.header||e.label||t,r=M===t;return(0,q.jsxs)(Z,{variant:r?`secondary`:`ghost`,size:`sm`,className:`gap-1 h-7 text-xs`,onClick:()=>Oe(t),children:[(0,q.jsx)(Th,{className:`h-3 w-3`}),n,r&&(ie===`asc`?` ↑`:` ↓`)]},t)})}),te?(0,q.jsx)(`div`,{className:`flex items-center justify-center py-6 text-muted-foreground text-sm`,children:xe(`detail.loading`)}):(0,q.jsx)(Kp,{schema:ze}),Te>0&&we.length>Te&&(0,q.jsxs)(`div`,{className:`flex items-center justify-between mt-3 pt-3 border-t`,children:[(0,q.jsxs)(Z,{variant:`outline`,size:`sm`,className:`h-7 text-xs gap-1`,disabled:ne===0,onClick:()=>re(e=>Math.max(0,e-1)),children:[(0,q.jsx)(kC,{className:`h-3 w-3`}),xe(`detail.previousPage`)]}),(0,q.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:xe(`detail.pageOf`,{current:ne+1,total:Ee})}),(0,q.jsxs)(Z,{variant:`outline`,size:`sm`,className:`h-7 text-xs gap-1`,disabled:ne>=Ee-1,onClick:()=>re(e=>Math.min(Ee-1,e+1)),children:[xe(`detail.nextPage`),(0,q.jsx)(NC,{className:`h-3 w-3`})]})]}),u&&!Ue&&Te>0&&we.length>Te&&(0,q.jsx)(`div`,{className:`mt-3 pt-3 border-t flex justify-center`,children:(0,q.jsxs)(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),u()},className:`text-xs text-muted-foreground hover:text-foreground inline-flex items-center gap-1 transition-colors`,children:[xe(`detail.viewAll`),(0,q.jsx)(DN,{className:`h-3 w-3`})]})})]}),(0,q.jsx)(WJ,{open:ke!==null,onOpenChange:e=>{e||Ae(null)},children:(0,q.jsxs)(GJ,{children:[(0,q.jsxs)(KJ,{children:[(0,q.jsx)(JJ,{children:xe(`detail.deleteRowTitle`,{defaultValue:`Delete record`})}),(0,q.jsx)(YJ,{children:xe(`detail.deleteRowConfirmation`)})]}),(0,q.jsxs)(qJ,{children:[(0,q.jsx)(ZJ,{children:xe(`detail.cancel`,{defaultValue:`Cancel`})}),(0,q.jsx)(XJ,{onClick:Me,className:`bg-destructive text-destructive-foreground hover:bg-destructive/90`,children:xe(`detail.delete`,{defaultValue:`Delete`})})]})]})}),he&&(0,q.jsx)(`div`,{className:`mx-4 mb-3 rounded-md border border-destructive/40 bg-destructive/10 px-3 py-2 text-xs text-destructive`,role:`alert`,children:he}),v&&s&&(0,q.jsx)(SXt,{open:de,onOpenChange:e=>fe(e),multiple:!0,dataSource:s,objectName:v.picker.object,title:v.label||xe(`detail.add`,{defaultValue:`Add`}),onSelect:()=>{},onSelectRecords:e=>{Ne(e)}})]})},M6t=({group:e,data:t,className:n,objectSchema:r,objectName:i,isEditing:a=!1,onFieldChange:o,onEnterInlineEdit:s,autoFocusField:c,dataSource:l})=>{let u=e.collapsible??!0,[d,f]=K.useState(e.defaultCollapsed??!1),p=(0,q.jsx)(`div`,{className:`space-y-3 sm:space-y-4`,children:e.sections.map((e,n)=>(0,q.jsx)(V9,{section:e,data:t,objectSchema:r,objectName:i,isEditing:a,onFieldChange:o,onEnterInlineEdit:s,autoFocusField:c,dataSource:l},n))});return u?(0,q.jsxs)($X,{open:!d,onOpenChange:e=>f(!e),className:n,children:[(0,q.jsx)(eZ,{asChild:!0,children:(0,q.jsxs)(`div`,{className:`flex items-center gap-2 pb-2 border-b cursor-pointer hover:bg-muted/50 transition-colors rounded-t-md px-2 py-1.5`,children:[(0,q.jsx)(d?NC:jC,{className:`h-4 w-4 text-muted-foreground shrink-0`}),e.icon&&(0,q.jsx)(`span`,{className:`text-muted-foreground`,children:e.icon}),(0,q.jsx)(`h3`,{className:`text-lg font-semibold`,children:e.title})]})}),e.description&&!d&&(0,q.jsx)(`p`,{className:`text-sm text-muted-foreground mt-1`,children:e.description}),(0,q.jsx)(tZ,{children:(0,q.jsx)(`div`,{className:`mt-3`,children:p})})]}):(0,q.jsxs)(`div`,{className:J(`space-y-3`,n),children:[(0,q.jsxs)(`div`,{className:`flex items-center gap-2 pb-2 border-b`,children:[e.icon&&(0,q.jsx)(`span`,{className:`text-muted-foreground`,children:e.icon}),(0,q.jsx)(`h3`,{className:`text-lg font-semibold`,children:e.title})]}),e.description&&(0,q.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:e.description}),p]})},N6t=({fields:e,data:t,className:n,objectName:r,objectSchema:i,dataSource:a})=>{let{fieldLabel:o}=ym(),{t:s}=R9(),c=$p(),l=c?.editing??!1,u=c?.canEdit??!1;if(!e.length||!t)return null;let d=l?e:e.filter(e=>{let n=t?.[e.name];return n!=null&&n!==``});return d.length===0?null:(0,q.jsx)(E4,{children:(0,q.jsx)(`section`,{className:J(`@container border-b border-border/60 pb-4`,n),"aria-label":`Record highlights`,children:(0,q.jsx)(`div`,{className:J(`flex flex-wrap gap-y-4`),children:d.map(e=>{let n=t[e.name],d=i?.fields?.[e.name],f=e.type||d?.type,p=d?.reference_to||d?.reference,m={name:e.name,label:e.label,type:f||`text`,...d?.options&&{options:d.options},...d?.currency&&{currency:d.currency},...d?.currencyConfig&&{currencyConfig:d.currencyConfig},...d?.precision!==void 0&&{precision:d.precision},...d?.scale!==void 0&&{scale:d.scale},...d?.min!==void 0&&{min:d.min},...d?.max!==void 0&&{max:d.max},...d?.step!==void 0&&{step:d.step},...d?.format&&{format:d.format},...p&&{reference_to:p},...d?.reference_field&&{reference_field:d.reference_field},...d?.widget&&{widget:d.widget}},h=c?.draft?.[e.name],g=h===void 0?n:h,_=B9.has(f),v=e.readonly===!0||d?.readonly===!0,y=T6t.has(e.name),b=u&&!_&&!v&&!y,x=l&&b,S=b7(v7(m)||f||`text`),C=f===`number`||f===`integer`||f===`currency`||f===`percent`||f===`decimal`,w=f===`email`||f===`url`||f===`textarea`||f===`reference`||f===`lookup`||f===`master_detail`,T=f===`boolean`,E=g==null||g===``;return(0,q.jsxs)(`div`,{className:J(`group flex flex-col gap-1 min-w-[7rem] px-5 border-l border-border/60 first:border-l-0 first:pl-0`,w||x?`basis-[16rem] max-w-[24rem]`:`basis-[9rem] max-w-[16rem]`),children:[(0,q.jsx)(`span`,{className:`text-xs font-medium text-muted-foreground`,children:o(r||``,e.name,e.label)}),x?(0,q.jsx)(E6t,{field:m,value:g,onChange:t=>c.setField(e.name,t),dataSource:a,autoFocus:c.autoFocusField===e.name}):(0,q.jsxs)(`div`,{className:J(`flex items-start justify-between gap-1`,b&&`cursor-pointer rounded-md -mx-1.5 px-1.5 hover:bg-muted/40 transition-colors`),onDoubleClick:b?()=>c.enter(e.name):void 0,title:b?s(`detail.editInlineHint`):void 0,children:[(0,q.jsx)(`div`,{className:`min-w-0 flex-1`,children:T?g?(0,q.jsxs)(`span`,{className:`inline-flex items-center gap-1 self-start rounded-full bg-emerald-500/10 px-2 py-0.5 text-xs font-medium text-emerald-600 ring-1 ring-inset ring-emerald-500/30 dark:text-emerald-400`,children:[(0,q.jsx)(sC,{className:`h-3 w-3`,"aria-hidden":!0}),`Yes`]}):(0,q.jsxs)(`span`,{className:`inline-flex items-center gap-1 self-start rounded-full bg-amber-500/10 px-2 py-0.5 text-xs font-medium text-amber-700 ring-1 ring-inset ring-amber-500/30 dark:text-amber-400`,children:[(0,q.jsx)(Uq,{className:`h-3 w-3`,"aria-hidden":!0}),`No`]}):E?(0,q.jsx)(`span`,{className:`block text-sm text-muted-foreground/60 select-none`,"aria-label":s(`detail.noValue`,{defaultValue:`No value`}),children:`—`}):(0,q.jsx)(`span`,{title:(Array.isArray(m.options)?m.options.find(e=>e?.value===g)?.label:void 0)??(typeof g==`string`||typeof g==`number`?String(g):void 0),className:J(`block min-w-0 truncate text-sm font-semibold`,C&&`tabular-nums tracking-tight`),children:(0,q.jsx)(S,{value:g,field:m})})}),b&&(0,q.jsxs)(D4,{children:[(0,q.jsx)(O4,{asChild:!0,children:(0,q.jsx)(Z,{variant:`ghost`,size:`icon`,className:`h-5 w-5 shrink-0 opacity-0 group-hover:opacity-100 transition-opacity`,"aria-label":s(`detail.editInlineHint`),onClick:t=>{t.stopPropagation(),c.enter(e.name)},children:(0,q.jsx)(mq,{className:`h-3 w-3`})})}),(0,q.jsx)(k4,{children:s(`detail.editInlineHint`)})]})]})]},e.name)})})})})};function P6t(e){try{let t=new Date(e),n=new Date().getTime()-t.getTime(),r=Math.floor(n/6e4);if(r<1)return`just now`;if(r<60)return`${r}m ago`;let i=Math.floor(r/60);if(i<24)return`${i}h ago`;let a=Math.floor(i/24);return a<7?`${a}d ago`:t.toLocaleDateString()}catch{return e}}var F6t=({comments:e,onAddComment:t,onTogglePin:n,searchable:r=!1,className:i})=>{let{t:a}=R9(),[o,s]=K.useState(``),[c,l]=K.useState(!1),[u,d]=K.useState(``),f=K.useCallback(async()=>{let e=o.trim();if(!(!e||!t)){l(!0);try{await t(e),s(``)}finally{l(!1)}}},[o,t]),p=K.useCallback(e=>{e.key===`Enter`&&(e.ctrlKey||e.metaKey)&&(e.preventDefault(),f())},[f]),m=K.useMemo(()=>[...u.trim()?e.filter(e=>{let t=u.trim().toLowerCase();return e.text.toLowerCase().includes(t)||e.author.toLowerCase().includes(t)}):e].sort((e,t)=>e.pinned&&!t.pinned?-1:!e.pinned&&t.pinned?1:0),[e,u]);return(0,q.jsxs)(lX,{className:J(``,i),children:[(0,q.jsx)(uX,{children:(0,q.jsxs)(dX,{className:`flex items-center gap-2 text-base`,children:[(0,q.jsx)(oq,{className:`h-4 w-4`}),a(`detail.comments`),(0,q.jsxs)(`span`,{className:`text-sm font-normal text-muted-foreground`,children:[`(`,e.length,`)`]})]})}),(0,q.jsxs)(pX,{className:`space-y-4`,children:[r&&(0,q.jsx)(`div`,{className:`flex items-center gap-2`,children:(0,q.jsxs)(`div`,{className:`relative flex-1`,children:[(0,q.jsx)(Sq,{className:`absolute left-2.5 top-1/2 -translate-y-1/2 h-3.5 w-3.5 text-muted-foreground`}),(0,q.jsx)(`input`,{className:`w-full rounded-md border border-input bg-background pl-8 pr-8 py-1.5 text-sm placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring`,placeholder:a(`detail.searchComments`),value:u,onChange:e=>d(e.target.value),"aria-label":a(`detail.searchComments`)}),u&&(0,q.jsx)(`button`,{className:`absolute right-2 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground`,onClick:()=>d(``),"aria-label":a(`detail.clearSearch`),type:`button`,children:(0,q.jsx)(Uq,{className:`h-3.5 w-3.5`})})]})}),t&&(0,q.jsxs)(`div`,{className:`flex gap-2`,children:[(0,q.jsx)(`textarea`,{className:`flex-1 min-h-[60px] rounded-md border border-input bg-background px-3 py-2 text-sm placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring resize-none`,placeholder:a(`detail.addCommentPlaceholder`),value:o,onChange:e=>s(e.target.value),onKeyDown:p,disabled:c}),(0,q.jsx)(Z,{size:`icon`,variant:`default`,onClick:f,disabled:!o.trim()||c,className:`shrink-0 self-end`,children:(0,q.jsx)(Cq,{className:`h-4 w-4`})})]}),m.length===0?(0,q.jsx)(`p`,{className:`text-sm text-muted-foreground text-center py-4`,children:u.trim()?a(`detail.noMatchingComments`):a(`detail.noCommentsYet`)}):(0,q.jsx)(`div`,{className:`space-y-3`,children:m.map(e=>(0,q.jsxs)(`div`,{className:J(`flex gap-3`,e.pinned&&`bg-muted/40 rounded-md p-2 -mx-2`),children:[(0,q.jsx)(`div`,{className:`shrink-0`,children:e.avatarUrl?(0,q.jsx)(`img`,{src:e.avatarUrl,alt:e.author,className:`h-8 w-8 rounded-full object-cover`}):(0,q.jsx)(`div`,{className:`h-8 w-8 rounded-full bg-muted flex items-center justify-center text-xs font-medium text-muted-foreground`,children:e.author.charAt(0).toUpperCase()})}),(0,q.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,q.jsxs)(`div`,{className:`flex items-center gap-2 mb-0.5`,children:[(0,q.jsx)(`span`,{className:`text-sm font-medium truncate`,children:e.author}),(0,q.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:P6t(e.createdAt)}),e.pinned&&(0,q.jsxs)(`span`,{className:`text-xs text-amber-600 flex items-center gap-0.5`,children:[(0,q.jsx)(gq,{className:`h-3 w-3`}),a(`detail.pinned`)]})]}),(0,q.jsx)(`p`,{className:`text-sm whitespace-pre-wrap break-words`,children:e.text}),n&&(0,q.jsxs)(`button`,{type:`button`,className:`mt-1 text-xs text-muted-foreground hover:text-foreground flex items-center gap-1`,onClick:()=>n(e.id),"aria-label":e.pinned?a(`detail.unpin`):a(`detail.pin`),children:[(0,q.jsx)(gq,{className:`h-3 w-3`}),e.pinned?a(`detail.unpin`):a(`detail.pin`)]})]})]},e.id))})]})]})},I6t={field_change:jq,create:GT,delete:Lq,comment:oq,status_change:Ch},L6t={field_change:`bg-blue-100 text-blue-600`,create:`bg-green-100 text-green-600`,delete:`bg-red-100 text-red-600`,comment:`bg-purple-100 text-purple-600`,status_change:`bg-amber-100 text-amber-600`};function R6t(e){try{let t=new Date(e),n=new Date().getTime()-t.getTime(),r=Math.floor(n/6e4);if(r<1)return`just now`;if(r<60)return`${r}m ago`;let i=Math.floor(r/60);if(i<24)return`${i}h ago`;let a=Math.floor(i/24);return a<7?`${a}d ago`:t.toLocaleDateString()}catch{return e}}function z6t(e){return e.description?e.description:e.type===`field_change`&&e.field?`Changed ${e.field.charAt(0).toUpperCase()+e.field.slice(1).replace(/_/g,` `)} from "${e.oldValue==null?`(empty)`:String(e.oldValue)}" to "${e.newValue==null?`(empty)`:String(e.newValue)}"`:e.type===`create`?`Created this record`:e.type===`delete`?`Deleted this record`:e.type===`status_change`&&e.field?`Changed status to "${e.newValue==null?`(empty)`:String(e.newValue)}"`:`Updated record`}var B6t={all:`All`,field_change:`Field Changes`,create:`Creates`,delete:`Deletes`,comment:`Comments`,status_change:`Status Changes`},V6t=({activities:e,filterable:t=!1,defaultFilter:n=`all`,className:r})=>{let[i,a]=K.useState(n),o=K.useMemo(()=>i===`all`?e:e.filter(e=>e.type===i),[e,i]);return(0,q.jsxs)(lX,{className:J(``,r),children:[(0,q.jsx)(uX,{children:(0,q.jsxs)(dX,{className:`flex items-center gap-2 text-base`,children:[(0,q.jsx)(bh,{className:`h-4 w-4`}),`Activity`,(0,q.jsxs)(`span`,{className:`text-sm font-normal text-muted-foreground`,children:[`(`,o.length,`)`]})]})}),(0,q.jsxs)(pX,{children:[t&&(0,q.jsx)(`div`,{className:`flex flex-wrap gap-1.5 mb-4`,role:`group`,"aria-label":`Activity type filter`,children:Object.keys(B6t).map(e=>(0,q.jsxs)(`button`,{type:`button`,className:J(`inline-flex items-center gap-1 rounded-full px-2.5 py-0.5 text-xs font-medium transition-colors`,i===e?`bg-primary text-primary-foreground`:`bg-muted text-muted-foreground hover:bg-muted/80`),onClick:()=>a(e),"aria-pressed":i===e,children:[e!==`all`&&K.createElement(I6t[e]||jq,{className:`h-3 w-3`}),B6t[e]]},e))}),o.length===0?(0,q.jsx)(I3,{title:`No activity recorded`,className:`py-6`}):(0,q.jsxs)(`div`,{className:`relative`,children:[(0,q.jsx)(`div`,{className:`absolute left-4 top-2 bottom-2 w-px bg-border`}),(0,q.jsx)(`div`,{className:`space-y-4`,children:o.map(e=>{let t=I6t[e.type]||jq;return(0,q.jsxs)(`div`,{className:`flex gap-3 relative`,children:[(0,q.jsx)(`div`,{className:J(`shrink-0 h-8 w-8 rounded-full flex items-center justify-center z-10`,L6t[e.type]||`bg-gray-100 text-gray-600`),children:(0,q.jsx)(t,{className:`h-3.5 w-3.5`})}),(0,q.jsxs)(`div`,{className:`flex-1 min-w-0 pt-1`,children:[(0,q.jsxs)(`p`,{className:`text-sm`,children:[(0,q.jsx)(`span`,{className:`font-medium`,children:e.user}),` `,(0,q.jsx)(`span`,{className:`text-muted-foreground`,children:z6t(e)})]}),(0,q.jsx)(`p`,{className:`text-xs text-muted-foreground mt-0.5`,children:R6t(e.timestamp)})]})]},e.id)})})]})]})]})},H6t={create:`default`,update:`secondary`,delete:`destructive`,restore:`outline`,login:`outline`,logout:`outline`,permission_change:`secondary`,config_change:`secondary`,export:`outline`,import:`outline`};function U9(e){if(!e)return``;let t=e instanceof Date?e:new Date(e);return Number.isNaN(t.getTime())?String(e):t.toLocaleString()}var U6t=[[60,`second`],[60,`minute`],[24,`hour`],[7,`day`],[4.34524,`week`],[12,`month`],[1/0,`year`]];function W6t(e,t){if(!e)return``;let n=e instanceof Date?e:new Date(e);if(Number.isNaN(n.getTime()))return String(e);let r=(n.getTime()-Date.now())/1e3;for(let[n,i]of U6t){if(Math.abs(r)<n)try{return new Intl.RelativeTimeFormat(t,{numeric:`auto`}).format(Math.round(r),i)}catch{return U9(e)}r/=n}return U9(e)}function G6t(e){if(!e)return`?`;let t=e.trim().split(/\s+/).filter(Boolean).slice(0,2);return t.length===0?`?`:t.map(e=>e.charAt(0).toUpperCase()).join(``)}function W9(e){if(e==null||e===``)return`—`;if(typeof e==`string`)return e;if(typeof e==`number`||typeof e==`boolean`)return String(e);try{return JSON.stringify(e)}catch{return String(e)}}function K6t({entries:e,loading:t,emptyText:n,className:r,locale:i}){return t?(0,q.jsx)(`div`,{className:J(`space-y-3`,r),children:Array.from({length:4}).map((e,t)=>(0,q.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,q.jsx)(g4,{className:`h-8 w-8 rounded-full`}),(0,q.jsxs)(`div`,{className:`flex-1 space-y-2`,children:[(0,q.jsx)(g4,{className:`h-4 w-1/3`}),(0,q.jsx)(g4,{className:`h-3 w-1/2`})]})]},t))}):!e||e.length===0?(0,q.jsx)(`div`,{className:J(`flex items-center justify-center rounded-md border border-dashed py-10 text-sm text-muted-foreground`,r),children:n??`No history yet`}):(0,q.jsx)(E4,{delayDuration:150,children:(0,q.jsx)(`ol`,{className:J(`space-y-4`,r),children:e.map((e,t)=>{let n=(e.action??``).toLowerCase(),r=H6t[n]??`outline`,a=typeof e.user_name==`string`&&e.user_name.trim()||`Unknown user`,o=U9(e.created_at),s=W6t(e.created_at,i),c=typeof e.user_avatar==`string`?e.user_avatar:void 0;return(0,q.jsxs)(`li`,{className:`flex items-start gap-3`,children:[(0,q.jsxs)(aY,{className:`h-8 w-8 mt-0.5 shrink-0`,children:[c?(0,q.jsx)(oY,{src:c,alt:a}):null,(0,q.jsx)(sY,{className:`text-[10px] font-medium`,children:G6t(e.user_name)})]}),(0,q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,q.jsxs)(`div`,{className:`flex flex-wrap items-baseline gap-x-2 gap-y-1`,children:[(0,q.jsx)(`span`,{className:`text-sm font-medium text-foreground`,children:a}),e.action&&(0,q.jsx)(cY,{variant:r,className:`text-[10px] uppercase tracking-wide`,children:e.action}),o&&(0,q.jsxs)(D4,{children:[(0,q.jsx)(O4,{asChild:!0,children:(0,q.jsx)(`span`,{className:`text-xs text-muted-foreground cursor-help`,"aria-label":o,children:s||o})}),(0,q.jsx)(k4,{children:o})]})]}),e.summary&&(0,q.jsx)(`p`,{className:`mt-1 text-sm text-muted-foreground`,children:e.summary}),e.changes&&e.changes.length>0&&(n===`create`?(0,q.jsxs)(`details`,{className:`mt-1 group`,children:[(0,q.jsxs)(`summary`,{className:`cursor-pointer list-none text-xs text-muted-foreground hover:text-foreground inline-flex items-center gap-1 select-none`,children:[(0,q.jsx)(`span`,{className:`transition-transform group-open:rotate-90`,children:`▸`}),(0,q.jsx)(`span`,{children:e.changes.length===1?`1 field populated`:`${e.changes.length} fields populated`})]}),(0,q.jsx)(`ul`,{className:`mt-1.5 space-y-0.5 text-xs text-muted-foreground pl-4`,children:e.changes.map(e=>(0,q.jsxs)(`li`,{className:`leading-relaxed`,children:[(0,q.jsx)(`span`,{className:`font-medium text-foreground`,children:e.label||e.field}),`: `,(0,q.jsx)(`span`,{className:`text-foreground`,children:W9(e.to)})]},e.field))})]}):(0,q.jsx)(`ul`,{className:`mt-1.5 space-y-0.5 text-xs text-muted-foreground`,children:e.changes.map(e=>(0,q.jsxs)(`li`,{className:`leading-relaxed`,children:[(0,q.jsx)(`span`,{className:`font-medium text-foreground`,children:e.label||e.field}),`: `,(0,q.jsx)(`span`,{className:`line-through opacity-70`,children:W9(e.from)}),` → `,(0,q.jsx)(`span`,{className:`text-foreground`,children:W9(e.to)})]},e.field))}))]})]},e.id??t)})})})}var G9={createdAt:`created_at`,createdBy:`created_by`,updatedAt:`updated_at`,updatedBy:`updated_by`};function q6t(e){if(!e)return null;if(e instanceof Date)return isNaN(e.getTime())?null:e;if(typeof e==`string`||typeof e==`number`){let t=new Date(e);return isNaN(t.getTime())?null:t}return null}function J6t(e,t){let n=Date.now()-e.getTime(),r=Math.max(0,Math.floor(n/1e3));if(r<60)return t(`detail.justNow`);let i=Math.floor(r/60);if(i<60)return t(`detail.minutesAgo`,{count:i});let a=Math.floor(i/60);return a<24?t(`detail.hoursAgo`,{count:a}):t(`detail.daysAgo`,{count:Math.floor(a/24)})}function Y6t(e){try{return new Intl.DateTimeFormat(void 0,{dateStyle:`medium`,timeStyle:`short`}).format(e)}catch{return e.toISOString()}}var X6t=({value:e,objectSchema:t,fieldName:n})=>{if(e==null||e===``)return null;let r=t?.fields?.[n],i=r?.reference_to||r?.reference,a={name:n,type:r?.type||(i?`lookup`:`text`),...i&&{reference_to:i},...r?.reference_field&&{reference_field:r.reference_field}},o=v7(a)||a.type;if(o){let t=b7(o);if(t)return(0,q.jsx)(`span`,{className:`inline-flex items-center [&_a]:text-inherit [&_a]:hover:underline`,children:K.createElement(t,{value:e,field:a})})}return(0,q.jsx)(`span`,{children:String(e)})},Z6t=({label:e,user:t,date:n,objectSchema:r,userField:i,t:a})=>{if(!t&&!n)return null;let o=n?(0,q.jsx)(E4,{delayDuration:200,children:(0,q.jsxs)(D4,{children:[(0,q.jsx)(O4,{asChild:!0,children:(0,q.jsx)(`time`,{dateTime:n.toISOString(),className:`cursor-default underline decoration-dotted decoration-muted-foreground/40 underline-offset-2`,children:J6t(n,a)})}),(0,q.jsx)(k4,{side:`top`,children:Y6t(n)})]})}):null;return(0,q.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[(0,q.jsx)(`span`,{className:`text-muted-foreground/70`,children:e}),t?(0,q.jsx)(X6t,{value:t,objectSchema:r,fieldName:i}):null,t&&o?(0,q.jsx)(`span`,{className:`text-muted-foreground/40`,children:`·`}):null,o]})},Q6t=({data:e,objectSchema:t,objectName:n,className:r})=>{let{t:i}=R9();if(!e)return null;let a=q6t(e[G9.createdAt]),o=q6t(e[G9.updatedAt]),s=e[G9.createdBy],c=e[G9.updatedBy],l=!!(a||s),u=a&&o&&Math.abs(o.getTime()-a.getTime())<2e3,d=!!(o||c)&&!(u&&(s!=null&&c!=null&&String(s)===String(c)||!c));return!l&&!d?null:(0,q.jsxs)(`div`,{className:J(`mt-6 pt-3 border-t border-border/40`,`flex flex-wrap items-center gap-x-4 gap-y-1`,`text-xs text-muted-foreground`,r),"data-testid":`record-meta-footer`,children:[l&&(0,q.jsx)(Z6t,{label:i(s?`detail.createdBy`:`detail.created`),user:s,date:a,objectSchema:t,userField:G9.createdBy,t:i}),d&&(0,q.jsx)(Z6t,{label:i(c?`detail.updatedBy`:`detail.updated`),user:c,date:o,objectSchema:t,userField:G9.updatedBy,t:i})]})},$6t=5,e8t={};function t8t(e,t,n,r){if(e&&typeof e==`object`){if(t.primaryField){let n=e[t.primaryField];if(n!=null&&n!==``)return String(n)}let r=Gae(n?.titleFormat,e);if(r)return r}if(e&&typeof e==`object`){let t=e.id??e._id,r=Fp(n,e,{deriveFromRecordKeys:!1});if(!(r===`Untitled`||t!=null&&r===`Record #${t}`))return r}if(t.title)return t.title;if(e&&typeof e==`object`){let t=e.id??e._id;if(t!=null&&String(t).trim()!==``)return`Record #${t}`}return r}var K9=({schema:e,dataSource:t,className:n,onEdit:r,onDelete:i,onBack:a,inlineEdit:o=!1,discussionSlot:s,rightRail:c,objectLabel:l,onDataLoaded:u,isFavorite:d,onToggleFavorite:f})=>{let[p,m]=K.useState(e.data),[h,g]=K.useState(!e.data&&!!(e.api&&e.resourceId||t&&e.objectName&&e.resourceId)),[_,v]=K.useState(!1),y=d??_,b=$p(),x=b?.editing??!1,S=b?.draft??e8t,w=b?.autoFocusField??null,[T,E]=K.useState(null),[D,O]=K.useState(null),[k,A]=K.useState(!1),[ee,te]=K.useState(0),j=Uoe(e.objectName||void 0,e.resourceId==null?void 0:String(e.resourceId)),[ne,re]=K.useState(!1),{t:M}=R9(),{currency:N}=xm(),{fieldOptionLabel:ie}=ym(),ae=h4(),oe=s9(),P=K.useMemo(()=>{if(!oe?.isLoaded||!e.objectName)return e;let t=t=>oe.checkField(e.objectName,t,`read`),n=e=>e&&e.filter(e=>{let n=typeof e==`string`?e:e?.name;return!n||t(n)});return{...e,fields:n(e.fields),sections:e.sections?.map(e=>({...e,fields:n(e.fields)})),summaryFields:n(e.summaryFields)}},[e,oe]);K.useEffect(()=>{p&&u&&u(p)},[p,u]);let se=K.useMemo(()=>{if(P.summaryFields&&P.summaryFields.length>0)return[];let e=[...P.sections?.flatMap(e=>e.fields)||[],...P.fields||[]],t={};for(let n of e)t[n.name]||(t[n.name]=n);if(D?.fields)for(let[e,n]of Object.entries(D.fields))t[e]={...t[e]||{},...n,name:e};let n=e=>p?.[e]!==void 0&&p?.[e]!==null&&p?.[e]!==``,r=[],i=[`status`,`stage`,`state`,`phase`].find(e=>t[e]&&n(e))||Object.keys(t).find(e=>t[e]?.type===`select`&&n(e));i&&r.push(i);let a=Object.keys(t).find(e=>(t[e]?.type===`currency`||/amount|revenue|value|total|price/i.test(e))&&n(e));a&&!r.includes(a)&&r.push(a);let o=Object.keys(t).find(e=>(t[e]?.type===`date`||t[e]?.type===`datetime`)&&/close|due|start|end|expected/i.test(e)&&n(e));return o&&!r.includes(o)&&r.push(o),r},[P.summaryFields,P.sections,P.fields,D,p]),ce=P.summaryFields&&P.summaryFields.length>0?P.summaryFields:se,le=K.useCallback(()=>{P.resourceId&&navigator.clipboard.writeText(String(P.resourceId)).then(()=>{A(!0),setTimeout(()=>A(!1),1500)})},[P.resourceId]);K.useEffect(()=>{let e=!0;if(P.data)return m(P.data),g(!1),t?.getObjectSchema&&P.objectName&&t.getObjectSchema(P.objectName).then(t=>{e&&O(t)}).catch(()=>{}),()=>{e=!1};if(t&&P.objectName&&P.resourceId){g(!0),O(null),m(null);let n=P.objectName,r=P.resourceId,i=`${n}-`,a=[...P.sections?.flatMap(e=>e.fields)||[],...P.fields||[]];(t.getObjectSchema?t.getObjectSchema(n).catch(()=>null):Promise.resolve(null)).then(o=>{if(!e)return;O(o);let s=C(o?.fields,a),c=s.length>0?{$expand:s}:void 0,l=c?t.findOne(n,r,c):t.findOne(n,r),u=()=>{let a=String(r),o=a.startsWith(i)?a.slice(i.length):`${i}${a}`;return(c?t.findOne(n,o,c):t.findOne(n,o)).then(t=>{e&&(m(t),g(!1))}).catch(()=>{e&&(m(null),g(!1))})};return l.catch(()=>null).then(t=>{if(e){if(t){m(t),g(!1);return}return u()}})}).catch(t=>{e&&(console.error(`Failed to fetch detail data:`,t),g(!1))})}else P.api&&P.resourceId&&(g(!0),fetch(`${P.api}/${P.resourceId}`).then(e=>e.json()).then(t=>{e&&m(t?.data||t)}).catch(e=>{console.error(`Failed to fetch detail data:`,e)}).finally(()=>{e&&g(!1)}));return()=>{e=!1}},[P.api,P.resourceId,P.objectName,t,P.sections,P.fields,ee,j]);let ue=K.useCallback(()=>{if(a)a();else if(P.onNavigate){let e=P.backUrl||(P.objectName?`/${P.objectName}`:`/`);P.onNavigate(e,{replace:!0})}else P.backUrl?window.location.href=P.backUrl:window.history.back()},[a,P]),de=K.useCallback(()=>{r?r():P.onNavigate&&P.editUrl?P.onNavigate(P.editUrl):P.onNavigate&&P.objectName&&P.resourceId?P.onNavigate(`/${P.objectName}/${P.resourceId}/edit`):P.editUrl&&(window.location.href=P.editUrl)},[r,P]),fe=K.useCallback(async()=>{if(!t?.cancelPendingApproval||!P.objectName||!P.resourceId){E(M(`detail.cancelApprovalUnavailable`));return}re(!0),E(null);try{if(await t.cancelPendingApproval(String(P.objectName),String(P.resourceId)),t.findOne)try{let e=await t.findOne(String(P.objectName),String(P.resourceId));e&&m(e)}catch{}te(e=>e+1);try{window.dispatchEvent(new CustomEvent(`objectui:record-changed`,{detail:{objectName:String(P.objectName),recordId:String(P.resourceId),reason:`approval-recalled`}}))}catch{}}catch(e){let t=(e?.message||e?.error||String(e??`Cancel failed`)).replace(/^\[[^\]]+\]\s*/,``).replace(/^[A-Z][A-Z0-9_]+:\s*/,``);E(`${M(`detail.cancelApprovalFailed`)}: ${t}`)}finally{re(!1)}},[t,P.objectName,P.resourceId,M]),pe=K.useCallback(()=>{let e=P.deleteConfirmation||M(`detail.deleteConfirmation`);window.confirm(e)&&(i?.(),P.onNavigate&&P.objectName&&P.onNavigate(`/${P.objectName}`,{replace:!0}))},[i,P]),me=K.useCallback(()=>{navigator.share&&P.objectName&&P.resourceId?navigator.share({title:P.title||M(`detail.details`),text:`${P.objectName} #${P.resourceId}`,url:window.location.href}).catch(e=>console.log(`Share failed:`,e)):navigator.clipboard.writeText(window.location.href).then(()=>{console.log(`Link copied to clipboard`)})},[P]),he=K.useCallback(()=>{let e=!y;f&&f(e),d===void 0&&v(e)},[y,d,f]),ge=b?.setField,_e=b&&b.canEdit?b.enter:void 0;K.useEffect(()=>{if(!P.recordNavigation)return;let e=P.recordNavigation,t=t=>{let n=t.target?.tagName;n===`INPUT`||n===`TEXTAREA`||t.target?.isContentEditable||(t.key===`ArrowLeft`&&e.currentIndex>0?(t.preventDefault(),e.onNavigate(e.recordIds[e.currentIndex-1])):t.key===`ArrowRight`&&e.currentIndex<e.recordIds.length-1&&(t.preventDefault(),e.onNavigate(e.recordIds[e.currentIndex+1])))};return document.addEventListener(`keydown`,t),()=>document.removeEventListener(`keydown`,t)},[P.recordNavigation]);let ve=K.useMemo(()=>P.related??[],[P.related]),ye=K.useMemo(()=>{let e=[];return e.push({name:`sys_share`,label:M(`detail.share`),icon:`share-2`,type:`script`,onClick:me}),P.showEdit&&e.push({name:`sys_edit_mobile`,label:M(`detail.edit`),icon:`edit`,type:`script`,className:`sm:hidden`,onClick:de}),P.showDelete&&e.push({name:`sys_delete`,label:M(`detail.delete`),icon:`trash-2`,type:`script`,variant:`destructive`,tags:[`separator-before`],onClick:pe}),e},[M,P.showEdit,P.showDelete,me,de,pe]),be=K.useMemo(()=>{let e=P.actions??[];if(ye.length===0)return e;let t=!1,n=e.map(e=>{let n=e;if(n&&typeof n==`object`&&n.type===`action:bar`&&(!n.location||n.location===`record_header`)){t=!0;let e=Array.isArray(n.systemActions)?n.systemActions:[];return{...n,systemActions:[...e,...ye]}}return e});return t||n.push({type:`action:bar`,location:`record_header`,systemActions:ye}),n},[P.actions,ye]);return h||P.loading?(0,q.jsxs)(`div`,{className:J(`space-y-4`,n),children:[(0,q.jsx)(g4,{className:`h-10 w-full`}),(0,q.jsx)(g4,{className:`h-64 w-full`}),(0,q.jsx)(g4,{className:`h-48 w-full`})]}):!p&&!P.data?(0,q.jsxs)(`div`,{className:J(`flex flex-col items-center justify-center py-16 text-center`,n),children:[(0,q.jsx)(`p`,{className:`text-lg font-semibold`,children:M(`detail.recordNotFound`)}),(0,q.jsx)(`p`,{className:`text-sm text-muted-foreground mt-1`,children:M(`detail.recordNotFoundDescription`)}),(P.showBack??!0)&&(0,q.jsxs)(Z,{variant:`outline`,size:`sm`,onClick:ue,className:`mt-4 gap-2`,children:[(0,q.jsx)(Sh,{className:`h-4 w-4`}),M(`detail.goBack`)]})]}):(0,q.jsx)(E4,{children:(0,q.jsxs)(`div`,{className:J(`space-y-6`,n),children:[P.showHeader!==!1&&(0,q.jsxs)(`div`,{className:`flex flex-col sm:flex-row items-start justify-between gap-3 sm:gap-4 pb-4 border-b`,children:[(0,q.jsxs)(`div`,{className:`flex items-start gap-2 sm:gap-3 flex-1 min-w-0`,children:[(P.showBack??!0)&&(0,q.jsxs)(D4,{children:[(0,q.jsx)(O4,{asChild:!0,children:(0,q.jsx)(Z,{variant:`ghost`,size:`icon`,onClick:ue,className:`shrink-0 mt-1`,children:(0,q.jsx)(Sh,{className:`h-4 w-4`})})}),(0,q.jsx)(k4,{children:M(`detail.back`)})]}),(0,q.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,q.jsxs)(`div`,{className:`flex items-center gap-2 flex-wrap`,children:[(0,q.jsx)(`h1`,{className:`text-xl sm:text-2xl font-bold truncate`,children:t8t(p,P,D,M(`detail.details`))}),ce.map(e=>{let t=p?.[e];if(t==null||t===``)return null;let n=(P.sections||[]).flatMap(e=>e.fields).concat(P.fields||[]).find(t=>t.name===e),r=D?.fields?.[e],i=n?.type||r?.type,a=String(t),o=null;try{if(i===`currency`){let e=Number(t);if(!Number.isNaN(e)){let t=Sm({...r,...n},N);a=t?new Intl.NumberFormat(void 0,{style:`currency`,currency:t,maximumFractionDigits:0}).format(e):new Intl.NumberFormat(void 0,{maximumFractionDigits:0}).format(e)}}else if(i===`date`||i===`datetime`){let e=new Date(t);Number.isNaN(e.getTime())||(a=i===`datetime`?e.toLocaleString(void 0,{dateStyle:`medium`,timeStyle:`short`}):e.toLocaleDateString(void 0,{dateStyle:`medium`}))}else if(i===`percent`){let e=Number(t);if(!Number.isNaN(e)){a=`${e}%`;let t=e<=1?e*100:e;o=Math.max(0,Math.min(100,t))}}else if(i===`select`||i===`status`||i===`multiselect`){let i=n?.options||r?.options,o=String(t);if(Array.isArray(i)){let e=i.find(e=>String(e?.value??e)===String(t));e?.label&&(o=e.label)}else if(i&&typeof i==`object`){let e=i[String(t)];e?.label&&(o=e.label)}a=P.objectName?ie(P.objectName,e,String(t),o):o}}catch{}return o===null?(0,q.jsx)(cY,{variant:`secondary`,className:`text-xs bg-primary/10 text-primary border-transparent hover:bg-primary/15`,"aria-label":`${e}: ${a}`,children:a},e):(0,q.jsxs)(cY,{variant:`secondary`,className:`text-xs bg-primary/10 text-primary border-transparent hover:bg-primary/15 gap-1.5 pl-2 pr-2`,"aria-label":`${e}: ${a}`,children:[(0,q.jsx)(`span`,{className:`relative inline-block h-1.5 w-12 rounded-full bg-primary/20 overflow-hidden`,"aria-hidden":!0,children:(0,q.jsx)(`span`,{className:`absolute inset-y-0 left-0 rounded-full bg-primary`,style:{width:`${o}%`}})}),a]},e)}),(0,q.jsxs)(D4,{children:[(0,q.jsx)(O4,{asChild:!0,children:(0,q.jsx)(Z,{variant:`ghost`,size:`icon`,className:`h-6 w-6 shrink-0`,onClick:he,"aria-label":M(y?`detail.removeFromFavorites`:`detail.addToFavorites`),children:y?(0,q.jsx)(Nq,{className:`h-4 w-4 fill-yellow-400 text-yellow-400`}):(0,q.jsx)(Nq,{className:`h-4 w-4 text-muted-foreground`})})}),(0,q.jsx)(k4,{children:M(y?`detail.removeFromFavorites`:`detail.addToFavorites`)})]})]}),P.objectName&&(0,q.jsxs)(`p`,{className:`text-sm text-muted-foreground mt-1 flex items-center gap-1`,children:[(0,q.jsx)(`span`,{className:`font-medium`,children:l||P.objectName}),P.resourceId&&(0,q.jsxs)(D4,{children:[(0,q.jsx)(O4,{asChild:!0,children:(0,q.jsx)(Z,{variant:`ghost`,size:`icon`,className:`h-5 w-5 shrink-0 text-muted-foreground/60 hover:text-foreground`,onClick:le,"aria-label":M(`detail.copyRecordId`,{defaultValue:`Copy record ID`}),children:k?(0,q.jsx)(sC,{className:`h-3 w-3 text-green-600`}):(0,q.jsx)(qk,{className:`h-3 w-3`})})}),(0,q.jsx)(k4,{children:k?M(`detail.copied`,{defaultValue:`Copied`}):M(`detail.copyRecordId`,{defaultValue:`Copy record ID`})})]})]})]})]}),(0,q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5 shrink-0 w-full sm:w-auto`,children:[P.recordNavigation&&(0,q.jsxs)(`div`,{className:`flex items-center gap-1 mr-2`,children:[(0,q.jsxs)(D4,{children:[(0,q.jsx)(O4,{asChild:!0,children:(0,q.jsx)(Z,{variant:`outline`,size:`icon`,className:`h-8 w-8`,disabled:P.recordNavigation.currentIndex<=0,onClick:()=>{let e=P.recordNavigation;e.currentIndex>0&&e.onNavigate(e.recordIds[e.currentIndex-1])},children:(0,q.jsx)(kC,{className:`h-4 w-4`})})}),(0,q.jsx)(k4,{children:M(`detail.previousRecord`)})]}),(0,q.jsx)(`span`,{className:`text-xs text-muted-foreground whitespace-nowrap px-1`,children:M(`detail.recordOf`,{current:P.recordNavigation.currentIndex+1,total:P.recordNavigation.recordIds.length})}),(0,q.jsxs)(D4,{children:[(0,q.jsx)(O4,{asChild:!0,children:(0,q.jsx)(Z,{variant:`outline`,size:`icon`,className:`h-8 w-8`,disabled:P.recordNavigation.currentIndex>=P.recordNavigation.recordIds.length-1,onClick:()=>{let e=P.recordNavigation;e.currentIndex<e.recordIds.length-1&&e.onNavigate(e.recordIds[e.currentIndex+1])},children:(0,q.jsx)(NC,{className:`h-4 w-4`})})}),(0,q.jsx)(k4,{children:M(`detail.nextRecord`)})]})]}),P.showEdit&&(0,q.jsxs)(D4,{children:[(0,q.jsx)(O4,{asChild:!0,children:(0,q.jsxs)(Z,{variant:`default`,onClick:de,className:`gap-2 hidden sm:inline-flex`,children:[(0,q.jsx)(jq,{className:`h-4 w-4`}),(0,q.jsx)(`span`,{className:`hidden sm:inline`,children:M(`detail.edit`)})]})}),(0,q.jsx)(k4,{children:M(`detail.editRecord`)})]}),be.map((e,t)=>(0,q.jsx)(Kp,{schema:e,data:p},`header-action-${t}`))]})]}),P.header&&(0,q.jsx)(`div`,{children:(0,q.jsx)(Kp,{schema:P.header,data:p})}),P.highlightFields&&P.highlightFields.length>0&&(0,q.jsx)(N6t,{fields:P.highlightFields,data:p,objectName:P.objectName,objectSchema:D}),o&&P.showHeader===!1&&(()=>{let e=p?.approval_status,n=e===`pending`||e===`in_approval`;return!n&&!T?null:(0,q.jsxs)(`div`,{className:`flex flex-col items-end gap-1`,children:[n&&(0,q.jsxs)(`div`,{className:`flex items-center justify-end gap-2`,children:[(0,q.jsxs)(`span`,{role:`status`,className:`inline-flex items-center gap-1 rounded-md border border-amber-300 bg-amber-50 px-2 py-1 text-xs text-amber-800`,title:M(`detail.lockedTooltip`),children:[(0,q.jsx)(tq,{className:`h-3 w-3`}),(0,q.jsx)(`span`,{children:M(`detail.lockedByApproval`)})]}),t?.cancelPendingApproval&&(0,q.jsxs)(Z,{variant:`outline`,size:`sm`,onClick:fe,disabled:ne,className:`gap-2 border-amber-300 text-amber-800 hover:bg-amber-50`,title:M(`detail.cancelApprovalTooltip`),children:[(0,q.jsx)(Uq,{className:`h-4 w-4`}),(0,q.jsx)(`span`,{children:M(ne?`detail.cancelApprovalInFlight`:`detail.cancelApproval`)})]})]}),T&&(0,q.jsx)(`div`,{role:`alert`,className:`text-xs text-destructive bg-destructive/10 border border-destructive/20 rounded-md px-2 py-1 max-w-md text-right`,children:T})]})})(),P.autoTabs&&!P.tabs?.length?(()=>{let e=ve.length>0,n=!!P.activities&&P.activities.length>0,r=!!s,i=!!P.history,a=[`details`,...e?[`related`]:[],...n?[`activity`]:[],...r?[`discussion`]:[],...i?[`history`]:[]],c=P.defaultTab,l=c&&a.includes(c)?c:`details`,u=P.onTabChange,d=(0,q.jsxs)(`div`,{className:`space-y-3 sm:space-y-4`,children:[P.sectionGroups&&P.sectionGroups.length>0&&P.sectionGroups.map((e,n)=>(0,q.jsx)(M6t,{group:e,data:{...p,...S},objectSchema:D,objectName:P.objectName,isEditing:x,onFieldChange:ge,onEnterInlineEdit:o?_e:void 0,autoFocusField:w,dataSource:t},n)),P.sections&&P.sections.length>0&&P.sections.map((e,n)=>(0,q.jsx)(V9,{section:e,data:{...p,...S},objectSchema:D,objectName:P.objectName,isEditing:x,onFieldChange:ge,onEnterInlineEdit:o?_e:void 0,autoFocusField:w,dataSource:t},n)),P.fields&&P.fields.length>0&&!P.sections?.length&&(0,q.jsx)(V9,{section:{fields:P.fields,columns:P.columns},data:{...p,...S},objectSchema:D,objectName:P.objectName,isEditing:x,onFieldChange:ge,onEnterInlineEdit:o?_e:void 0,autoFocusField:w,dataSource:t}),P.comments&&(0,q.jsx)(F6t,{comments:P.comments,onAddComment:P.onAddComment})]});return!e&&!n&&!r&&!i?(0,q.jsx)(`div`,{className:`mt-2`,children:d}):(0,q.jsxs)(o3,{defaultValue:l,onValueChange:u,className:`w-full`,children:[(0,q.jsxs)(s3,{className:`w-full justify-start border-b rounded-none bg-transparent p-0`,children:[(0,q.jsx)(c3,{value:`details`,className:`relative rounded-none border-b-2 border-transparent data-[state=active]:border-primary data-[state=active]:bg-transparent`,children:M(`detail.details`)}),e&&(0,q.jsx)(c3,{value:`related`,className:`relative rounded-none border-b-2 border-transparent data-[state=active]:border-primary data-[state=active]:bg-transparent`,children:(0,q.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[M(`detail.related`),(0,q.jsx)(cY,{variant:`secondary`,className:`text-xs bg-primary/10 text-primary border-transparent`,children:ve.length})]})}),n&&(0,q.jsx)(c3,{value:`activity`,className:`relative rounded-none border-b-2 border-transparent data-[state=active]:border-primary data-[state=active]:bg-transparent`,children:(0,q.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[M(`detail.activity`),(0,q.jsx)(cY,{variant:`secondary`,className:`text-xs bg-primary/10 text-primary border-transparent`,children:P.activities.length})]})}),r&&(0,q.jsx)(c3,{value:`discussion`,className:`relative rounded-none border-b-2 border-transparent data-[state=active]:border-primary data-[state=active]:bg-transparent`,children:M(`detail.discussion`,{defaultValue:`Discussion`})}),i&&(0,q.jsx)(c3,{value:`history`,className:`relative rounded-none border-b-2 border-transparent data-[state=active]:border-primary data-[state=active]:bg-transparent`,children:(0,q.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[M(`detail.history`,{defaultValue:`History`}),!P.history.loading&&P.history.entries.length>0&&(0,q.jsx)(cY,{variant:`secondary`,className:`text-xs bg-primary/10 text-primary border-transparent`,children:P.history.entries.length})]})})]}),(0,q.jsx)(l3,{value:`details`,className:`mt-4 motion-safe:data-[state=active]:animate-in motion-safe:data-[state=active]:fade-in-0 motion-safe:duration-150`,children:d}),e&&(0,q.jsx)(l3,{value:`related`,className:`mt-4 motion-safe:data-[state=active]:animate-in motion-safe:data-[state=active]:fade-in-0 motion-safe:duration-150`,children:(0,q.jsx)(`div`,{className:`space-y-3`,children:ve.map((e,n)=>(0,q.jsx)(H9,{title:e.title,type:e.type,api:e.api,data:e.data,columns:e.columns,dataSource:t,objectName:e.api,referenceField:e.referenceField,icon:e.icon,onNew:e.onNew,onViewAll:e.onViewAll,onRowClick:e.onRowClick,onRowEdit:e.onRowEdit,onRowDelete:e.onRowDelete,collapsible:!0,defaultCollapsed:ae&&n>0,pageSize:$6t},n))})}),n&&(0,q.jsx)(l3,{value:`activity`,className:`mt-4 motion-safe:data-[state=active]:animate-in motion-safe:data-[state=active]:fade-in-0 motion-safe:duration-150`,children:(0,q.jsx)(V6t,{activities:P.activities})}),r&&(0,q.jsx)(l3,{value:`discussion`,className:`mt-4 motion-safe:data-[state=active]:animate-in motion-safe:data-[state=active]:fade-in-0 motion-safe:duration-150`,children:s}),i&&(0,q.jsx)(l3,{value:`history`,className:`mt-4 motion-safe:data-[state=active]:animate-in motion-safe:data-[state=active]:fade-in-0 motion-safe:duration-150`,children:(0,q.jsx)(K6t,{entries:P.history.entries,loading:P.history.loading,emptyText:P.history.emptyText??M(`detail.historyEmpty`,{defaultValue:`No history yet`})})})]})})():(0,q.jsxs)(q.Fragment,{children:[P.sectionGroups&&P.sectionGroups.length>0&&(0,q.jsx)(`div`,{className:`space-y-3 sm:space-y-4`,children:P.sectionGroups.map((e,n)=>(0,q.jsx)(M6t,{group:e,data:{...p,...S},objectSchema:D,objectName:P.objectName,isEditing:x,onFieldChange:ge,onEnterInlineEdit:o?_e:void 0,autoFocusField:w,dataSource:t},n))}),P.sections&&P.sections.length>0&&(0,q.jsx)(`div`,{className:`space-y-3 sm:space-y-4`,children:P.sections.map((e,n)=>(0,q.jsx)(V9,{section:e,data:{...p,...S},objectSchema:D,objectName:P.objectName,isEditing:x,onFieldChange:ge,onEnterInlineEdit:o?_e:void 0,autoFocusField:w,dataSource:t},n))}),P.fields&&P.fields.length>0&&!P.sections?.length&&(0,q.jsx)(V9,{section:{fields:P.fields,columns:P.columns},data:{...p,...S},objectSchema:D,objectName:P.objectName,isEditing:x,onFieldChange:ge,onEnterInlineEdit:o?_e:void 0,autoFocusField:w,dataSource:t}),P.tabs&&P.tabs.length>0&&(0,q.jsx)(k6t,{tabs:P.tabs,data:p}),ve.length>0&&(0,q.jsxs)(`div`,{className:`space-y-3`,children:[(0,q.jsx)(`h2`,{className:`text-lg font-semibold`,children:M(`detail.related`)}),ve.map((e,n)=>(0,q.jsx)(H9,{title:e.title,type:e.type,api:e.api,data:e.data,columns:e.columns,dataSource:t,objectName:e.api,referenceField:e.referenceField,icon:e.icon,onNew:e.onNew,onViewAll:e.onViewAll,onRowClick:e.onRowClick,onRowEdit:e.onRowEdit,onRowDelete:e.onRowDelete,collapsible:!0,defaultCollapsed:ae&&n>0,pageSize:$6t},n))]}),P.comments&&(0,q.jsx)(F6t,{comments:P.comments,onAddComment:P.onAddComment}),P.activities&&P.activities.length>0&&(0,q.jsx)(V6t,{activities:P.activities})]}),(0,q.jsx)(Q6t,{data:{...p,...S},objectSchema:D,objectName:P.objectName}),P.footer&&(0,q.jsx)(`div`,{children:(0,q.jsx)(Kp,{schema:P.footer,data:p})})]})})},q9=e=>typeof e==`string`?e:e&&typeof e==`object`&&(e.field||e.name)||null,n8t=e=>{let{"data-obj-id":t,"data-obj-type":n,style:r,...i}=e||{};return{designer:{"data-obj-id":t,"data-obj-type":n,style:r},rest:i}},r8t=({schema:e={},className:t,...n})=>{let r=Qp(),{designer:i}=n8t(n),a=r?.objectName||``,o=s9(),{readableFields:s}=c9(a),{sectionLabel:c}=ym(),{language:l}=_m(),u=Coe();if(!r)return(0,q.jsx)(`div`,{className:t,"data-record-details-placeholder":!0,...i,children:(0,q.jsx)(`div`,{className:`text-xs text-muted-foreground italic px-3 py-2 border border-dashed rounded`,children:`record:details — bind a record to preview`})});let d=Array.isArray(e.requiredPermissions)?e.requiredPermissions:[];if(d.length>0&&a&&!d.every(e=>o.can(a,e)))return(0,q.jsx)(`div`,{className:t,...i,role:`status`,"aria-live":`polite`,children:(0,q.jsx)(`p`,{className:`text-sm text-muted-foreground italic`,children:`Insufficient permissions to view details.`})});let f=e.layout===`inline`||e.layout===`compact`?`horizontal`:`vertical`,p=e.enforceFieldSecurity===!0,m=Array.isArray(e.redactFields)?e.redactFields:[],h=e=>{if(!e||!p&&m.length===0)return e;let t=e.map(q9).filter(e=>!!e),n=new Set((p&&a?s(t):t).filter(e=>!m.includes(e)));return e.filter(e=>{let t=q9(e);return!t||n.has(t)})},g=e=>typeof e==`string`?{name:e}:e&&typeof e==`object`&&!e.name&&e.field?{...e,name:e.field}:e,_=e=>Array.isArray(e)?e.map(g):e,v=new Set((Array.isArray(e.hideFields)?e.hideFields:[]).map(e=>typeof e==`string`?e:q9(e)).filter(e=>!!e));for(let e of u)v.add(e);let y=r.objectSchema,b=r.data??{},x=[y?.primaryField,`name`,`full_name`,`title`,`subject`,`display_name`,`label`].filter(e=>typeof e==`string`&&e.length>0);for(let e of x)if(b[e]!==void 0&&b[e]!==null&&b[e]!==``){v.add(e);break}let S=e=>!e||v.size===0?e:e.filter(e=>{let t=q9(e);return!t||!v.has(t)}),C=S(_(h(e.fields))),w=Array.isArray(e.sections)?e.sections.map(e=>{let t=e.title??e.label,n=t==null?void 0:bm(t,l),r=e.name&&a?c(a,e.name,n??e.name):n;return{...e,title:r,showBorder:e.showBorder??!!r,hideEmpty:e.hideEmpty??!0,fields:S(_(h(e.fields)))}}):e.sections,T=new Set([`system`,`append-only`,`better-auth`]),E=y?.managedBy,D=y?.userActions?.edit??!(E!=null&&T.has(E)),O=(e.inlineEdit??!0)&&D,k={type:`detail-view`,objectName:r.objectName,resourceId:r.recordId,data:r.data,layout:f,columns:e.columns,sections:w,fields:C,showBack:!1,showHeader:e.showHeader??!1,inlineEdit:O};return(0,q.jsx)(`div`,{className:t,...i,children:(0,q.jsx)(K9,{schema:k,dataSource:r.dataSource,inlineEdit:O})})},i8t=e=>typeof e==`string`?e:e&&typeof e==`object`&&(e.field||e.name||e.key)||null,J9=e=>e?.id??e?._id??null,a8t=e=>{let{"data-obj-id":t,"data-obj-type":n,style:r,...i}=e||{};return{designer:{"data-obj-id":t,"data-obj-type":n,style:r},rest:i}},o8t=({schema:e={},className:t,...n})=>{let r=Qp(),{designer:i}=a8t(n),a=ym(),{language:o}=_m(),s=e.objectName,c=s&&a.objectLabel?a.objectLabel({name:s,label:o7(s)}):s?o7(s):``,l=bm(e.title,o)||c||`Related`;if(!s)return(0,q.jsx)(`div`,{className:t,...i,children:(0,q.jsx)(`div`,{className:`text-xs text-muted-foreground italic px-3 py-2 border border-dashed rounded`,children:`record:related_list — missing objectName`})});let u=s9(),{readableFields:d}=c9(s),f=e.relationshipValueField||`id`,p=f===`id`?r?.recordId??null:r?.data?.[f]??null,m=Ioe(),h=K.useMemo(()=>m?.resolve({objectName:s,relationshipField:e.relationshipField,parentId:p})??null,[m,s,e.relationshipField,p]);if(u.isLoaded&&!u.can(s,`read`))return null;let g=Array.isArray(e.requiredPermissions)?e.requiredPermissions:[];if(g.length>0&&!g.every(e=>u.can(s,e)))return(0,q.jsx)(`div`,{className:t,...i,role:`status`,"aria-live":`polite`,children:(0,q.jsx)(`p`,{className:`text-sm text-muted-foreground italic`,children:`Insufficient permissions to view related list.`})});let _=e.enforceFieldSecurity===!0,v=Array.isArray(e.redactFields)?e.redactFields:[],y=Array.isArray(e.columns)?e.columns:[],b=y;if(_||v.length>0){let e=y.map(i8t).filter(e=>!!e),t=new Set((_?d(e):e).filter(e=>!v.includes(e)));b=y.filter(e=>{let n=i8t(e);return!n||t.has(n)})}return(0,q.jsx)(`div`,{className:t,...i,children:(0,q.jsx)(H9,{title:l,type:`table`,api:s,objectName:s,referenceField:e.relationshipField,parentId:p,columns:b,pageSize:e.limit,dataSource:r?.dataSource,add:e.add?{...e.add,label:bm(e.add.label,o)||void 0}:void 0,rowActions:h?.rowActions,onRowAction:h?.onRowAction,toolbarActions:h?.toolbarActions,onToolbarAction:h?.onToolbarAction,onNew:h?.onCreate,onRowClick:h?.onView?e=>{let t=J9(e);t!=null&&h.onView(t,e)}:void 0,onRowEdit:h?.onEdit?e=>{let t=J9(e);t!=null&&h.onEdit(t,e)}:void 0,onRowDelete:h?.onDelete?e=>{let t=J9(e);if(t!=null)return h.onDelete(t,e)}:e.add&&r?.dataSource?async e=>{let t=e?.id??e?._id;t!=null&&await r.dataSource.delete?.(s,String(t))}:void 0})})},s8t=e=>{let{"data-obj-id":t,"data-obj-type":n,style:r,...i}=e||{};return{designer:{"data-obj-id":t,"data-obj-type":n,style:r},rest:i}},c8t=({schema:e={},className:t,...n})=>{let r=Qp(),{designer:i}=s8t(n),a=r?.objectName||``,o=s9(),{readableFields:s}=c9(a),c=Array.isArray(e.requiredPermissions)?e.requiredPermissions:[];if(c.length>0&&a&&!c.every(e=>o.can(a,e)))return(0,q.jsx)(`div`,{className:t,...i,role:`status`,"aria-live":`polite`,children:(0,q.jsx)(`p`,{className:`text-sm text-muted-foreground italic`,children:`Insufficient permissions to view highlights.`})});let l=(Array.isArray(e.fields)?e.fields:[]).map(e=>typeof e==`string`?{name:e}:{name:e?.name,label:e?.label,icon:e?.icon,type:e?.type}).filter(e=>typeof e.name==`string`&&e.name.length>0),u=e.enforceFieldSecurity===!0,d=Array.isArray(e.redactFields)?e.redactFields:[],f=u&&a?new Set(s(l.map(e=>e.name))):null,p=l.filter(e=>!(d.includes(e.name)||f&&!f.has(e.name)));return woe(K.useId(),p.map(e=>e.name)),(0,q.jsx)(`div`,{className:t,...i,children:(0,q.jsx)(N6t,{fields:p,data:r?.data,objectName:r?.objectName,objectSchema:r?.objectSchema,dataSource:r?.dataSource})})},l8t=({change:e,className:t})=>{let n=e.fieldLabel??e.field.charAt(0).toUpperCase()+e.field.slice(1).replace(/_/g,` `),r=e.oldDisplayValue??(e.oldValue==null?`(empty)`:String(e.oldValue)),i=e.newDisplayValue??(e.newValue==null?`(empty)`:String(e.newValue));return(0,q.jsxs)(`div`,{className:J(`flex items-center gap-1.5 text-sm flex-wrap`,t),children:[(0,q.jsx)(`span`,{className:`font-medium text-foreground`,children:n}),(0,q.jsx)(`span`,{className:`text-muted-foreground line-through`,children:r}),(0,q.jsx)(wh,{className:`h-3 w-3 text-muted-foreground shrink-0`}),(0,q.jsx)(`span`,{className:`text-foreground`,children:i})]})},u8t=[`👍`,`❤️`,`🎉`,`😂`,`😮`,`😢`],d8t=({reactions:e,onToggleReaction:t,emojiOptions:n=u8t,className:r})=>{let[i,a]=K.useState(!1),o=K.useCallback(e=>{t?.(e),a(!1)},[t]);return(0,q.jsxs)(`div`,{className:J(`flex items-center gap-1 flex-wrap`,r),children:[e.map(e=>(0,q.jsxs)(`button`,{type:`button`,className:J(`inline-flex items-center gap-1 rounded-full px-2 py-0.5 text-xs border transition-colors`,e.reacted?`bg-primary/10 border-primary/30 text-primary`:`bg-muted border-border text-muted-foreground hover:bg-muted/80`),onClick:()=>o(e.emoji),disabled:!t,"aria-label":`${e.emoji} ${e.count} reaction${e.count===1?``:`s`}`,children:[(0,q.jsx)(`span`,{children:e.emoji}),(0,q.jsx)(`span`,{children:e.count})]},e.emoji)),t&&(0,q.jsxs)(`div`,{className:`relative`,children:[(0,q.jsx)(Z,{variant:`ghost`,size:`icon`,className:`h-6 w-6`,onClick:()=>a(!i),"aria-label":`Add reaction`,children:(0,q.jsx)(Eq,{className:`h-3.5 w-3.5`})}),i&&(0,q.jsx)(`div`,{className:`absolute bottom-full mb-1 left-0 bg-popover border rounded-md shadow-md z-50 p-1.5 flex gap-1`,role:`listbox`,"aria-label":`Emoji picker`,children:n.map(t=>(0,q.jsx)(`button`,{type:`button`,className:`hover:bg-accent rounded p-1 text-base transition-colors`,onClick:()=>o(t),role:`option`,"aria-selected":e.some(e=>e.emoji===t&&e.reacted),children:t},t))})]})]})};function f8t(e,t){try{let n=new Date(e),r=new Date().getTime()-n.getTime(),i=Math.floor(r/6e4);if(i<1)return t(`detail.justNow`);if(i<60)return t(`detail.minutesAgo`,{count:i});let a=Math.floor(i/60);if(a<24)return t(`detail.hoursAgo`,{count:a});let o=Math.floor(a/24);return o<7?t(`detail.daysAgo`,{count:o}):n.toLocaleDateString()}catch{return e}}var p8t=({parentItem:e,replies:t,onAddReply:n,showReplyInput:r=!0,className:i})=>{let{t:a}=R9(),[o,s]=K.useState(!1),[c,l]=K.useState(``),[u,d]=K.useState(!1),f=K.useCallback(async()=>{let t=c.trim();if(!(!t||!n)){d(!0);try{await n(e.id,t),l(``)}finally{d(!1)}}},[c,n,e.id]),p=K.useCallback(e=>{e.key===`Enter`&&(e.ctrlKey||e.metaKey)&&(e.preventDefault(),f())},[f]);return t.length===0&&!r?null:(0,q.jsxs)(`div`,{className:J(`ml-10 mt-1`,i),children:[t.length>0&&(0,q.jsxs)(`button`,{type:`button`,className:`flex items-center gap-1 text-xs text-muted-foreground hover:text-foreground transition-colors mb-1`,onClick:()=>s(!o),"aria-expanded":o,children:[(0,q.jsx)(o?jC:NC,{className:`h-3 w-3`}),(0,q.jsx)(oq,{className:`h-3 w-3`}),(0,q.jsx)(`span`,{children:t.length===1?a(`detail.replyCount`,{count:t.length}):a(`detail.replyCountPlural`,{count:t.length})})]}),o&&(0,q.jsx)(`div`,{className:`space-y-2 border-l-2 border-border pl-3`,children:t.map(e=>(0,q.jsxs)(`div`,{className:`flex gap-2`,children:[(0,q.jsx)(`div`,{className:`shrink-0`,children:e.actorAvatarUrl?(0,q.jsx)(`img`,{src:e.actorAvatarUrl,alt:e.actor,className:`h-6 w-6 rounded-full object-cover`}):(0,q.jsx)(`div`,{className:`h-6 w-6 rounded-full bg-muted flex items-center justify-center text-[10px] font-medium text-muted-foreground`,children:e.actor.charAt(0).toUpperCase()})}),(0,q.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,q.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,q.jsx)(`span`,{className:`text-xs font-medium`,children:e.actor}),(0,q.jsx)(`span`,{className:`text-[10px] text-muted-foreground`,children:f8t(e.createdAt,a)})]}),(0,q.jsx)(`p`,{className:`text-xs whitespace-pre-wrap break-words`,children:e.body})]})]},e.id))}),r&&n&&(0,q.jsxs)(`div`,{className:`flex gap-1.5 mt-1.5`,children:[(0,q.jsx)(`input`,{className:`flex-1 rounded-md border border-input bg-background px-2 py-1 text-xs placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring`,placeholder:a(`detail.replyPlaceholder`),value:c,onChange:e=>l(e.target.value),onKeyDown:p,disabled:u}),(0,q.jsx)(Z,{variant:`ghost`,size:`icon`,className:`h-6 w-6 shrink-0`,onClick:f,disabled:!c.trim()||u,"aria-label":`Send reply`,children:(0,q.jsx)(Cq,{className:`h-3 w-3`})})]})]})},m8t=({subscription:e,onToggle:t,className:n})=>{let{t:r}=R9(),[i,a]=K.useState(!1),o=K.useCallback(async()=>{if(t){a(!0);try{await t(!e.subscribed)}finally{a(!1)}}},[t,e.subscribed]);return(0,q.jsx)(Z,{variant:`ghost`,size:`icon`,className:J(`h-8 w-8`,n),onClick:o,disabled:i||!t,"aria-label":e.subscribed?r(`detail.unsubscribeAriaLabel`):r(`detail.subscribeAriaLabel`),title:e.subscribed?r(`detail.subscribedTooltip`):r(`detail.unsubscribedTooltip`),children:e.subscribed?(0,q.jsx)(Fg,{className:`h-4 w-4 text-primary`}):(0,q.jsx)(kg,{className:`h-4 w-4 text-muted-foreground`})})};function h8t(e){let t=e.replace(/&/g,`&`).replace(/</g,`<`).replace(/>/g,`>`).replace(/```([\s\S]*?)```/g,`<pre class="bg-muted rounded p-2 text-xs font-mono my-1 overflow-x-auto">$1</pre>`).replace(/`([^`]+)`/g,`<code class="bg-muted rounded px-1 py-0.5 text-xs font-mono">$1</code>`).replace(/\*\*(.+?)\*\*/g,`<strong>$1</strong>`).replace(/\*(.+?)\*/g,`<em>$1</em>`).replace(/@(\w+)/g,`<span class="text-primary font-medium">@$1</span>`).replace(/^- (.+)$/gm,`<li class="ml-4 list-disc">$1</li>`).replace(/\n/g,`<br/>`);return t=t.replace(/(<li[^>]*>.*?<\/li>(?:<br\/>)?)+/g,e=>`<ul class="my-1">${e.replace(/<br\/>/g,``)}</ul>`),t}var g8t=({value:e,onChange:t,onSubmit:n,mentionSuggestions:r=[],placeholder:i,className:a,disabled:o=!1,extraSlot:s,canSubmitEmpty:c=!1})=>{let{t:l}=R9(),[u,d]=K.useState(!1),[f,p]=K.useState(!1),[m,h]=K.useState(``),[g,_]=K.useState(0),v=K.useRef(null),y=K.useMemo(()=>{if(!m)return r;let e=m.toLowerCase();return r.filter(t=>t.label.toLowerCase().includes(e))},[m,r]),b=K.useCallback((n,r=``)=>{let i=v.current;if(!i)return;let a=i.selectionStart,o=i.selectionEnd,s=e.slice(a,o);t(e.slice(0,a)+n+s+r+e.slice(o)),requestAnimationFrame(()=>{i.focus();let e=a+n.length+s.length;i.setSelectionRange(e,e)})},[e,t]),x=K.useCallback(()=>b(`**`,`**`),[b]),S=K.useCallback(()=>b(`*`,`*`),[b]),C=K.useCallback(()=>b(`
|
|
217
|
+
- `,``),[b]),w=K.useCallback(()=>b("`","`"),[b]),T=K.useCallback(()=>{b(`@`,``),p(!0),h(``),_(0)},[b]),E=K.useCallback(n=>{let r=v.current;if(!r)return;let i=r.selectionStart,a=e.slice(0,i).lastIndexOf(`@`);a!==-1&&t(e.slice(0,a)+`@${n.label} `+e.slice(i)),p(!1),h(``),requestAnimationFrame(()=>r.focus())},[e,t]),D=K.useCallback(e=>{let n=e.target.value;t(n);let r=e.target.selectionStart,i=n.slice(0,r),a=i.lastIndexOf(`@`);if(a!==-1){let e=i.slice(a+1),t=a>0?i[a-1]:` `;if(/\s/.test(t)&&!/\s/.test(e)){p(!0),h(e),_(0);return}}p(!1)},[t]),O=K.useCallback(e=>{if(f&&y.length>0){if(e.key===`ArrowDown`){e.preventDefault(),_(e=>e<y.length-1?e+1:0);return}if(e.key===`ArrowUp`){e.preventDefault(),_(e=>e>0?e-1:y.length-1);return}if(e.key===`Enter`||e.key===`Tab`){e.preventDefault(),E(y[g]);return}if(e.key===`Escape`){p(!1);return}}e.key===`Enter`&&(e.ctrlKey||e.metaKey)&&(e.preventDefault(),n?.())},[f,y,g,E,n]);return(0,q.jsxs)(`div`,{className:J(`border rounded-md`,a),children:[(0,q.jsxs)(`div`,{className:`flex items-center gap-0.5 px-2 py-1.5 border-b bg-muted/30`,children:[(0,q.jsx)(Z,{variant:`ghost`,size:`icon`,className:`h-7 w-7`,onClick:x,disabled:o||u,title:l(`detail.bold`),children:(0,q.jsx)(T_,{className:`h-3.5 w-3.5`})}),(0,q.jsx)(Z,{variant:`ghost`,size:`icon`,className:`h-7 w-7`,onClick:S,disabled:o||u,title:l(`detail.italic`),children:(0,q.jsx)(tW,{className:`h-3.5 w-3.5`})}),(0,q.jsx)(Z,{variant:`ghost`,size:`icon`,className:`h-7 w-7`,onClick:C,disabled:o||u,title:l(`detail.listFormat`),children:(0,q.jsx)(ZK,{className:`h-3.5 w-3.5`})}),(0,q.jsx)(Z,{variant:`ghost`,size:`icon`,className:`h-7 w-7`,onClick:w,disabled:o||u,title:l(`detail.inlineCode`),children:(0,q.jsx)(UO,{className:`h-3.5 w-3.5`})}),(0,q.jsx)(Z,{variant:`ghost`,size:`icon`,className:`h-7 w-7`,onClick:T,disabled:o||u,title:l(`detail.mentionSomeone`),children:(0,q.jsx)(Oh,{className:`h-3.5 w-3.5`})}),(0,q.jsx)(`div`,{className:`flex-1`}),(0,q.jsx)(Z,{variant:`ghost`,size:`icon`,className:`h-7 w-7`,onClick:()=>d(!u),title:l(u?`detail.edit`:`detail.preview`),children:(0,q.jsx)(u?jq:FN,{className:`h-3.5 w-3.5`})}),n&&(0,q.jsx)(Z,{variant:`ghost`,size:`icon`,className:`h-7 w-7`,onClick:n,disabled:o||!c&&!e.trim(),title:l(`detail.submitComment`),children:(0,q.jsx)(Cq,{className:`h-3.5 w-3.5`})})]}),(0,q.jsx)(`div`,{className:`relative`,children:u?(0,q.jsx)(`div`,{className:`min-h-[80px] px-3 py-2 text-sm prose prose-sm max-w-none`,dangerouslySetInnerHTML:{__html:h8t(e)}}):(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(`textarea`,{ref:v,className:`w-full min-h-[80px] px-3 py-2 text-sm bg-transparent resize-none focus:outline-none placeholder:text-muted-foreground`,placeholder:i??l(`detail.writeComment`),value:e,onChange:D,onKeyDown:O,disabled:o}),f&&y.length>0&&(0,q.jsx)(`div`,{className:`absolute left-2 bottom-full mb-1 w-56 bg-popover border rounded-md shadow-md z-50 max-h-40 overflow-y-auto`,children:y.map((e,t)=>(0,q.jsxs)(`button`,{type:`button`,className:J(`w-full text-left px-3 py-1.5 text-sm flex items-center gap-2 hover:bg-accent transition-colors`,t===g&&`bg-accent`),onMouseDown:t=>{t.preventDefault(),E(e)},children:[e.avatarUrl?(0,q.jsx)(`img`,{src:e.avatarUrl,alt:e.label,className:`h-5 w-5 rounded-full object-cover`}):(0,q.jsx)(`div`,{className:`h-5 w-5 rounded-full bg-muted flex items-center justify-center text-[10px] font-medium`,children:e.label.charAt(0).toUpperCase()}),(0,q.jsx)(`span`,{children:e.label})]},e.id))})]})}),s&&(0,q.jsx)(`div`,{className:`border-t px-2 py-2 bg-muted/20`,children:s})]})};function _8t(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`}function v8t(e){return e.startsWith(`image/`)}function y8t(e){return v8t(e)?zU:e.includes(`pdf`)||e.includes(`document`)||e.includes(`text`)?rI:e.includes(`zip`)||e.includes(`archive`)||e.includes(`compressed`)?YN:xI}var b8t=({attachments:e,onUpload:t,onRemove:n,className:r,readOnly:i=!1})=>{let{t:a}=R9(),[o,s]=K.useState(!1),c=K.useRef(null),l=K.useCallback(e=>{e.preventDefault(),e.stopPropagation(),s(!0)},[]),u=K.useCallback(e=>{e.preventDefault(),e.stopPropagation(),s(!1)},[]),d=K.useCallback(e=>{e.preventDefault(),e.stopPropagation(),s(!1),t&&e.dataTransfer.files.length>0&&t(e.dataTransfer.files)},[t]),f=K.useCallback(e=>{t&&e.target.files&&e.target.files.length>0&&(t(e.target.files),e.target.value=``)},[t]);return(0,q.jsxs)(`div`,{className:J(`space-y-2`,r),children:[t&&!i&&(0,q.jsxs)(`div`,{className:J(`border-2 border-dashed rounded-md px-4 py-3 text-center transition-colors cursor-pointer`,o?`border-primary bg-primary/5`:`border-muted-foreground/25 hover:border-muted-foreground/40`),onDragOver:l,onDragLeave:u,onDrop:d,onClick:()=>c.current?.click(),role:`button`,tabIndex:0,onKeyDown:e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),c.current?.click())},children:[(0,q.jsx)(Vq,{className:`h-5 w-5 mx-auto text-muted-foreground mb-1`}),(0,q.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:a(`detail.dropFilesToUpload`)}),(0,q.jsx)(`input`,{ref:c,type:`file`,multiple:!0,className:`hidden`,onChange:f})]}),e.length>0&&(0,q.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,q.jsxs)(`div`,{className:`flex items-center gap-1.5 text-xs text-muted-foreground`,children:[(0,q.jsx)(pq,{className:`h-3 w-3`}),(0,q.jsx)(`span`,{children:e.length===1?a(`detail.attachmentCount`,{count:e.length}):a(`detail.attachmentCountPlural`,{count:e.length})})]}),(0,q.jsx)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 gap-2`,children:e.map(e=>{let t=v8t(e.type),r=y8t(e.type);return(0,q.jsxs)(`div`,{className:`flex items-center gap-2 rounded-md border px-2.5 py-2 bg-muted/30 group`,children:[t&&(e.thumbnailUrl||e.url)?(0,q.jsx)(`img`,{src:e.thumbnailUrl||e.url,alt:e.name,className:`h-10 w-10 rounded object-cover shrink-0`}):(0,q.jsx)(`div`,{className:`h-10 w-10 rounded bg-muted flex items-center justify-center shrink-0`,children:(0,q.jsx)(r,{className:`h-5 w-5 text-muted-foreground`})}),(0,q.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,q.jsx)(`p`,{className:`text-xs font-medium truncate`,children:e.name}),(0,q.jsx)(`p`,{className:`text-[10px] text-muted-foreground`,children:_8t(e.size)})]}),n&&!i&&(0,q.jsx)(Z,{variant:`ghost`,size:`icon`,className:`h-6 w-6 shrink-0 opacity-0 group-hover:opacity-100 transition-opacity`,onClick:()=>n(e.id),title:a(`detail.removeAttachment`),children:(0,q.jsx)(Uq,{className:`h-3.5 w-3.5`})})]},e.id)})})]})]})},x8t={comment:oq,field_change:jq,task:Oq,event:$b,system:Wq,email:nq,call:hq},S8t={comment:`bg-purple-100 text-purple-600`,field_change:`bg-blue-100 text-blue-600`,task:`bg-green-100 text-green-600`,event:`bg-amber-100 text-amber-600`,system:`bg-gray-100 text-gray-600`,email:`bg-indigo-100 text-indigo-600`,call:`bg-teal-100 text-teal-600`};function C8t(e){return[{value:`all`,label:e(`detail.allActivity`)},{value:`comments_only`,label:e(`detail.commentsOnly`)},{value:`changes_only`,label:e(`detail.fieldChangesFilter`)},{value:`tasks_only`,label:e(`detail.tasksOnly`)}]}function w8t(e,t){try{let n=new Date(e),r=new Date().getTime()-n.getTime(),i=Math.floor(r/6e4);if(i<1)return t(`detail.justNow`);if(i<60)return t(`detail.minutesAgo`,{count:i});let a=Math.floor(i/60);if(a<24)return t(`detail.hoursAgo`,{count:a});let o=Math.floor(a/24);return o<7?t(`detail.daysAgo`,{count:o}):n.toLocaleDateString()}catch{return e}}function T8t(e,t){switch(t){case`comments_only`:return e.filter(e=>e.type===`comment`);case`changes_only`:return e.filter(e=>e.type===`field_change`);case`tasks_only`:return e.filter(e=>e.type===`task`);default:return e}}var Y9=({items:e,config:t,filterMode:n,onFilterChange:r,hasMore:i=!1,onLoadMore:a,loading:o=!1,onAddComment:s,onAddReply:c,onToggleReaction:l,subscription:u,onToggleSubscription:d,collapseWhenEmpty:f=!1,mentionSuggestions:p,onUploadAttachments:m,titleLabel:h,emptyLabel:g,className:_})=>{let{t:v}=R9(),[y,b]=K.useState(`all`),[x,S]=K.useState(``),[C,w]=K.useState(!1),[T,E]=K.useState(!1),[D,O]=K.useState([]),[k,A]=K.useState(!1),ee=n??y,te=t?.showFilterToggle!==!1,j=t?.showCommentInput!==!1&&!!s,ne=t?.enableReactions??!1,re=t?.enableThreading??!1,M=t?.showSubscriptionToggle??!1,N=K.useMemo(()=>T8t(e,ee),[e,ee]),ie=K.useMemo(()=>re?N.filter(e=>!e.parentId):N,[N,re]),ae=K.useMemo(()=>{if(!re)return new Map;let e=new Map;for(let t of N)if(t.parentId){let n=e.get(t.parentId)??[];n.push(t),e.set(t.parentId,n)}return e},[N,re]),oe=K.useCallback(e=>{r?r(e):b(e)},[r]),P=K.useCallback(async()=>{let e=x.trim();if(s&&!(!e&&D.length===0)){w(!0);try{await s(e,D.length>0?D:void 0),S(``),O([])}finally{w(!1)}}},[x,D,s]),se=K.useCallback(async e=>{if(!(!m||e.length===0)){A(!0);try{let t=await m(e);Array.isArray(t)&&t.length>0&&O(e=>[...e,...t])}finally{A(!1)}}},[m]),ce=K.useCallback(e=>{O(t=>t.filter(t=>t.id!==e))},[]),le=K.useCallback(async()=>{if(a){E(!0);try{await a()}finally{E(!1)}}},[a]);return(0,q.jsxs)(`section`,{className:J(`border-t border-border/60 pt-5`,_),"aria-label":`Discussion`,children:[(0,q.jsx)(`header`,{className:`mb-4`,children:(0,q.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,q.jsxs)(`h2`,{className:`flex items-center gap-2 text-base font-semibold leading-none tracking-tight`,children:[(0,q.jsx)(bh,{className:`h-4 w-4`}),h??v(`detail.activity`),(0,q.jsxs)(`span`,{className:`text-sm font-normal text-muted-foreground`,children:[`(`,N.length,`)`]})]}),(0,q.jsx)(`div`,{className:`flex items-center gap-1`,children:M&&u&&(0,q.jsx)(m8t,{subscription:u,onToggle:d})})]})}),(0,q.jsxs)(`div`,{className:`space-y-4`,children:[te&&(0,q.jsx)(`div`,{className:`flex items-center gap-2`,children:(0,q.jsxs)(r4,{value:ee,onValueChange:e=>oe(e),children:[(0,q.jsx)(a4,{"aria-label":v(`detail.filterActivity`),className:`h-8 w-auto min-w-[140px] py-1 text-sm`,children:(0,q.jsx)(i4,{})}),(0,q.jsx)(o4,{children:C8t(v).map(e=>(0,q.jsx)(s4,{value:e.value,children:e.label},e.value))})]})}),j&&(0,q.jsx)(g8t,{value:x,onChange:S,onSubmit:P,mentionSuggestions:p,placeholder:v(`detail.leaveCommentPlaceholder`),disabled:C,canSubmitEmpty:D.length>0,extraSlot:m?(0,q.jsx)(b8t,{attachments:D,onUpload:se,onRemove:ce,readOnly:C||k}):D.length>0?(0,q.jsx)(b8t,{attachments:D,onRemove:ce,readOnly:C}):void 0}),N.length===0?f?null:(0,q.jsx)(I3,{title:g??v(`detail.noActivity`),className:`py-6`}):(0,q.jsxs)(`div`,{className:`relative`,children:[(0,q.jsx)(`div`,{className:`absolute left-4 top-2 bottom-2 w-px bg-border`}),(0,q.jsx)(`div`,{className:`space-y-4`,children:ie.map(e=>{let t=x8t[e.type]||Wq,n=S8t[e.type]||`bg-gray-100 text-gray-600`,r=ae.get(e.id)??[];return(0,q.jsxs)(`div`,{children:[(0,q.jsxs)(`div`,{className:`flex gap-3 relative`,children:[(0,q.jsx)(`div`,{className:J(`shrink-0 h-8 w-8 rounded-full flex items-center justify-center z-10`,n),children:e.actorAvatarUrl?(0,q.jsx)(`img`,{src:e.actorAvatarUrl,alt:e.actor,className:`h-8 w-8 rounded-full object-cover`}):(0,q.jsx)(t,{className:`h-3.5 w-3.5`})}),(0,q.jsxs)(`div`,{className:`flex-1 min-w-0 pt-1`,children:[(0,q.jsxs)(`div`,{className:`flex items-center gap-2 mb-0.5`,children:[(0,q.jsx)(`span`,{className:`text-sm font-medium`,children:e.actor}),e.source&&(0,q.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:v(`detail.via`,{source:e.source})}),(0,q.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:w8t(e.createdAt,v)}),e.edited&&(0,q.jsx)(`span`,{className:`text-xs text-muted-foreground italic`,children:v(`detail.edited`)}),e.pinned&&(0,q.jsxs)(`span`,{className:`text-xs text-amber-600`,children:[`📌 `,v(`detail.pinned`)]})]}),e.body&&(0,q.jsx)(`p`,{className:`text-sm whitespace-pre-wrap break-words text-muted-foreground`,children:e.body}),e.sourceObject&&e.sourceId!=null&&(0,q.jsxs)(`a`,{href:`/objects/${e.sourceObject}/${e.sourceId}`,className:`mt-1 inline-flex items-center gap-1 text-xs text-primary hover:underline`,"data-testid":`activity-source-link`,children:[v(`detail.viewSource`),(0,q.jsx)(`span`,{"aria-hidden":!0,children:`→`})]}),e.type===`field_change`&&e.fieldChanges&&(0,q.jsx)(`div`,{className:`space-y-1 mt-1`,children:e.fieldChanges.map((e,t)=>(0,q.jsx)(l8t,{change:e},t))}),ne&&e.reactions&&e.reactions.length>0&&(0,q.jsx)(`div`,{className:`mt-1.5`,children:(0,q.jsx)(d8t,{reactions:e.reactions,onToggleReaction:l?t=>l(e.id,t):void 0})}),ne&&(!e.reactions||e.reactions.length===0)&&l&&(0,q.jsx)(`div`,{className:`mt-1.5`,children:(0,q.jsx)(d8t,{reactions:[],onToggleReaction:t=>l(e.id,t)})})]})]}),re&&(e.replyCount??0)>0&&(0,q.jsx)(p8t,{parentItem:e,replies:r,onAddReply:c,showReplyInput:!!c})]},e.id)})})]}),i&&(0,q.jsx)(`div`,{className:`text-center pt-2`,children:(0,q.jsxs)(Z,{variant:`ghost`,size:`sm`,onClick:le,disabled:T,"aria-label":v(`detail.loadMore`),children:[T?(0,q.jsx)(eq,{className:`h-4 w-4 animate-spin mr-1`}):(0,q.jsx)(jC,{className:`h-4 w-4 mr-1`}),v(`detail.loadMore`)]})})]})]})},E8t=e=>{let{"data-obj-id":t,"data-obj-type":n,style:r,...i}=e||{};return{designer:{"data-obj-id":t,"data-obj-type":n,style:r},rest:i}},D8t=({schema:e={},className:t,...n})=>{Qp();let{designer:r}=E8t(n);return(0,q.jsx)(`div`,{className:t,...r,children:(0,q.jsx)(Y9,{items:[],config:e})})},O8t=({config:e,items:t,hasMore:n,onLoadMore:r,loading:i,onAddComment:a,onAddReply:o,onToggleReaction:s,subscription:c,onToggleSubscription:l,filterMode:u,onFilterChange:d,collapseWhenEmpty:f=!1,mentionSuggestions:p,onUploadAttachments:m,className:h})=>{let g=e?.position??`right`,_=e?.width??`360px`,v=e?.collapsible??!0,y=f&&t.length===0||(e?.defaultCollapsed??!1),{t:b}=R9(),[x,S]=K.useState(y);return g===`right`||g===`left`?x&&v?(0,q.jsx)(`div`,{className:J(`flex items-start pt-4`,g===`right`?`border-l`:`border-r`,h),children:(0,q.jsx)(Z,{variant:`ghost`,size:`icon`,className:`h-8 w-8 mx-1`,onClick:()=>S(!1),"aria-label":b(`detail.openDiscussion`),children:(0,q.jsx)(fq,{className:`h-4 w-4`})})}):(0,q.jsxs)(`div`,{className:J(`flex flex-col overflow-hidden`,g===`right`?`border-l`:`border-r`,h),style:{width:_,minWidth:_},children:[(0,q.jsxs)(`div`,{className:`flex items-center justify-between px-4 py-3 border-b`,children:[(0,q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,q.jsx)(oq,{className:`h-4 w-4`}),(0,q.jsx)(`span`,{className:`text-sm font-medium`,children:b(`detail.discussion`)})]}),v&&(0,q.jsx)(Z,{variant:`ghost`,size:`icon`,className:`h-7 w-7`,onClick:()=>S(!0),"aria-label":b(`detail.closeDiscussion`),children:(0,q.jsx)(Uq,{className:`h-3.5 w-3.5`})})]}),(0,q.jsx)(`div`,{className:`flex-1 overflow-y-auto`,children:(0,q.jsx)(Y9,{items:t,config:e?.feed,hasMore:n,onLoadMore:r,loading:i,onAddComment:a,onAddReply:o,onToggleReaction:s,subscription:c,onToggleSubscription:l,filterMode:u,onFilterChange:d,collapseWhenEmpty:f,mentionSuggestions:p,onUploadAttachments:m,titleLabel:b(`detail.discussion`),emptyLabel:b(`detail.noCommentsYet`),className:`border-0 shadow-none`})})]}):(0,q.jsx)(`div`,{className:J(``,h),children:v&&x?(0,q.jsxs)(Z,{variant:`ghost`,className:`w-full justify-start gap-2 text-muted-foreground`,onClick:()=>S(!1),"aria-label":b(`detail.showDiscussion`,{count:t.length}),children:[(0,q.jsx)(oq,{className:`h-4 w-4`}),(0,q.jsx)(`span`,{children:b(`detail.showDiscussion`,{count:t.length})})]}):(0,q.jsxs)(`div`,{children:[v&&(0,q.jsxs)(`div`,{className:`flex items-center justify-between mb-2`,children:[(0,q.jsxs)(`div`,{className:`flex items-center gap-2 text-sm font-medium`,children:[(0,q.jsx)(oq,{className:`h-4 w-4`}),b(`detail.discussion`)]}),(0,q.jsx)(Z,{variant:`ghost`,size:`icon`,className:`h-7 w-7`,onClick:()=>S(!0),"aria-label":b(`detail.hideDiscussion`),children:(0,q.jsx)(dq,{className:`h-3.5 w-3.5`})})]}),(0,q.jsx)(Y9,{items:t,config:e?.feed,hasMore:n,onLoadMore:r,loading:i,onAddComment:a,onAddReply:o,onToggleReaction:s,subscription:c,onToggleSubscription:l,filterMode:u,onFilterChange:d,collapseWhenEmpty:f,mentionSuggestions:p,onUploadAttachments:m,titleLabel:b(`detail.discussion`),emptyLabel:b(`detail.noCommentsYet`)})]})})},k8t=e=>{let{"data-obj-id":t,"data-obj-type":n,style:r,...i}=e||{};return{designer:{"data-obj-id":t,"data-obj-type":n,style:r},rest:i}},A8t=({schema:e={},className:t,...n})=>{Qp();let r=Moe(),{designer:i}=k8t(n),a={position:`bottom`,collapsible:!1,feed:{enableReactions:!0,enableThreading:!0,showCommentInput:!0},...e};return(0,q.jsx)(`div`,{className:t,...i,children:(0,q.jsx)(O8t,{items:r?.items||[],config:a,onAddComment:r?.onAddComment,onAddReply:r?.onAddReply,onToggleReaction:r?.onToggleReaction,mentionSuggestions:r?.mentionSuggestions,onUploadAttachments:r?.onUploadAttachments})})},j8t=e=>{let{"data-obj-id":t,"data-obj-type":n,style:r,...i}=e||{};return{designer:{"data-obj-id":t,"data-obj-type":n,style:r},rest:i}},M8t=({schema:e={},className:t,...n})=>{let r=Qp(),{translateOptions:i}=ym(),{designer:a}=j8t(n),o=Array.isArray(e.stages)?e.stages:[],s=e.statusField,c=K.useMemo(()=>{if(o.length===0||!s||!r?.objectName)return o;let e=i(r.objectName,s,o);return Array.isArray(e)&&e.length===o.length?o.map((t,n)=>({...t,label:e[n]?.label??t.label})):o},[o,s,r?.objectName,i]),l=s&&r?.data?r.data[s]:void 0,u=/(^|[_-\s])(closed_)?(lost|failed?|cancell?ed|失败|流失|丢单|败)([_-\s]|$)/i,d=/(^|[_-\s])(closed_)?(won|success|成交|赢|完成)([_-\s]|$)/i,f=c.map(e=>{if(e.terminal)return e.terminal;let t=`${String(e.value??``)} ${String(e.label??``)}`;if(u.test(t))return`lost`;if(d.test(t))return`won`}),p=f.findIndex(e=>e===`lost`),m=p===-1?c:c.slice(0,p),h=p===-1?[]:c.slice(p),g=p===-1?f:f.slice(0,p),_=c.findIndex(e=>e.value===l);_<0&&(_=-1);let v=p!==-1&&_>=p;if(c.length===0)return(0,q.jsx)(`div`,{className:t,...a,children:(0,q.jsx)(`div`,{className:`text-xs text-muted-foreground italic px-3 py-2 border border-dashed rounded`,children:`record:path — no stages configured`})});let y=m.length-1;return(0,q.jsxs)(`div`,{className:J(`w-full`,t),...a,children:[(0,q.jsxs)(`div`,{className:`hidden sm:flex w-full items-stretch gap-2`,role:`list`,"aria-label":e.aria?.label||`Record path`,children:[(0,q.jsx)(`div`,{className:`flex flex-1 items-stretch gap-1.5`,children:m.map((e,t)=>{let n=!v&&_>=0&&t<_,r=!v&&t===_,i=g[t]===`won`&&t===y;return(0,q.jsx)(`div`,{role:`listitem`,"aria-current":r?`step`:void 0,className:J(`relative flex-1 min-w-0 px-4 py-2 text-xs font-medium text-center rounded-xl`,r&&`bg-primary text-primary-foreground shadow-sm`,n&&`bg-emerald-500/15 text-emerald-800 dark:text-emerald-200`,!r&&!n&&i&&`bg-emerald-500/10 text-emerald-700/85 dark:text-emerald-300/85`,!r&&!n&&!i&&`bg-muted text-muted-foreground`),children:(0,q.jsxs)(`span`,{className:`inline-flex items-center justify-center gap-1.5 truncate`,children:[n&&(0,q.jsx)(`span`,{"aria-hidden":!0,className:`text-emerald-600 dark:text-emerald-400 font-semibold`,children:`✓`}),i&&!r&&(0,q.jsx)(`span`,{"aria-hidden":!0,className:`opacity-70`,children:`🏆`}),e.label]})},`${e.value}-${t}`)})}),h.length>0&&(0,q.jsx)(`div`,{className:`flex items-stretch gap-1 pl-2 border-l border-border/40`,"aria-label":`Alternative terminal stages`,children:h.map((e,t)=>{let n=p+t===_;return(0,q.jsx)(`div`,{role:`listitem`,"aria-current":n?`step`:void 0,className:J(`shrink-0 px-3 py-2 text-xs font-medium rounded-md border whitespace-nowrap`,n&&`bg-destructive text-destructive-foreground border-destructive shadow-sm ring-1 ring-destructive/40`,!n&&`bg-destructive/5 text-destructive/85 border-destructive/20`),children:(0,q.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,q.jsx)(`span`,{"aria-hidden":!0,className:`opacity-70`,children:`✗`}),e.label]})},`${e.value}-lost-${t}`)})})]}),(0,q.jsx)(`div`,{className:`flex sm:hidden w-full items-stretch gap-1 overflow-x-auto pb-1 -mx-1 px-1 [-ms-overflow-style:none] [scrollbar-width:none] [&::-webkit-scrollbar]:hidden`,role:`list`,"aria-label":e.aria?.label||`Record path`,children:c.map((e,t)=>{let n=f[t]===`lost`,r=!n&&!v&&_>=0&&t<_,i=t===_;return(0,q.jsx)(`div`,{role:`listitem`,"aria-current":i?`step`:void 0,className:J(`shrink-0 px-3 py-1.5 rounded-full text-xs font-medium border whitespace-nowrap`,n&&i&&`bg-destructive text-destructive-foreground border-destructive shadow-sm`,n&&!i&&`bg-destructive/5 text-destructive/85 border-destructive/20`,!n&&i&&`bg-primary text-primary-foreground border-primary shadow-sm ring-1 ring-primary/40`,!n&&r&&`bg-emerald-500/15 text-emerald-800 dark:text-emerald-200 border-emerald-500/30`,!n&&!i&&!r&&`bg-background text-foreground/85 border-border/60`),children:(0,q.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[n&&(0,q.jsx)(`span`,{"aria-hidden":!0,className:`opacity-70`,children:`✗`}),!n&&r&&(0,q.jsx)(`span`,{"aria-hidden":!0,className:`text-emerald-600 dark:text-emerald-400 font-semibold`,children:`✓`}),e.label]})},`${e.value}-${t}-m`)})})]})},N8t=e=>{let{"data-obj-id":t,"data-obj-type":n,style:r,...i}=e||{};return{designer:{"data-obj-id":t,"data-obj-type":n,style:r},rest:i}},P8t=({schema:e={},className:t,...n})=>{let r=Qp(),{designer:i}=N8t(n),a=s9(),{language:o}=_m(),s=ym(),c=Array.isArray(e.actions)?e.actions:Array.isArray(e.properties?.actions)?e.properties.actions:[],l=Array.isArray(e.actionNames)?e.actionNames:Array.isArray(e.properties?.actionNames)?e.properties.actionNames:[],u=r?.objectName||``,d=l.length>0?l:Array.isArray(c)&&c.every(e=>typeof e==`string`)?c:[],f=d.length>0&&!!u,{item:p}=Zp(`object`,f?u:null),m=f?(()=>{let e=Array.isArray(p?.actions)?p.actions:[],t=new Map(e.map(e=>[e.name,e]));return d.map(e=>t.get(e)).filter(e=>!!e)})():Array.isArray(c)?c:[],h=Array.isArray(e.requiredPermissions)?e.requiredPermissions:[];if(h.length>0&&u&&!h.every(e=>a.can(u,e)))return(0,q.jsx)(`div`,{className:t,...i,role:`status`,"aria-live":`polite`,children:(0,q.jsx)(`p`,{className:`text-sm text-muted-foreground italic`,children:`Insufficient permissions to view quick actions.`})});let g=e.location||`record_header`,{getActionsForLocation:_,executeAction:v}=zoe({actions:m,context:{record:r?.data,recordId:r?.recordId,objectName:r?.objectName}}),y=m.length>0?_(g):[];if(y.length===0)return(0,q.jsx)(`div`,{className:t,...i,children:(0,q.jsx)(`div`,{className:`text-xs text-muted-foreground italic px-3 py-2 border border-dashed rounded`,children:`record:quick_actions — no actions configured`})});let b=e.align||`end`,x=b===`start`?`justify-start`:b===`center`?`justify-center`:`justify-end`;return(0,q.jsx)(`div`,{className:J(`flex flex-wrap items-center gap-2`,g===`record_header`&&!e.inline&&`-mt-12 sm:-mt-14 mb-2 relative z-10`,x,t),role:`toolbar`,"aria-label":e.aria?.label||`Quick actions`,...i,children:y.map((t,n)=>(0,q.jsx)(F8t,{action:t,record:r?.data,variant:t.variant||e.variant||`default`,size:t.size||e.size||`sm`,label:(()=>{let e=bm(t.label,o)||t.name||`Action ${n+1}`;return t.name?s.actionLabel(u||void 0,t.name,e):e})(),onRun:async()=>{typeof t.onClick==`function`?await t.onClick():t.name&&await v(t.name)}},t.name||`qa-${n}`))})};function F8t({action:e,record:t,variant:n,size:r,label:i,onRun:a}){let[o,s]=K.useState(!1),c=K.useMemo(()=>({record:t||{}}),[t]),l=zp(e.disabled),u=Bp(typeof l==`string`?l:void 0,c);return(0,q.jsxs)(Z,{variant:n,size:r,disabled:(typeof l==`string`?u:l===!0)||o,onClick:async()=>{s(!0);try{await a()}finally{s(!1)}},children:[o&&(0,q.jsx)(eq,{className:`mr-2 h-4 w-4 animate-spin`}),i]})}var I8t=e=>{let{"data-obj-id":t,"data-obj-type":n,style:r,...i}=e||{};return{designer:{"data-obj-id":t,"data-obj-type":n,style:r},rest:i}},L8t=new Set([`created`,`updated`,`assigned`,`shared`,`deleted`]),R8t=({schema:e={},className:t,...n})=>{let{designer:r}=I8t(n),i=Qp(),a=Array.isArray(e.entries)?e.entries:Array.isArray(e.properties?.entries)?e.properties.entries:void 0,o=e.loading??e.properties?.loading,s=e.emptyText??e.properties?.emptyText,c=Number(e.limit??e.properties?.limit??50)||50,l=i?.objectName,u=i?.data?.id??i?.data?._id??i?.recordId,d=i?.dataSource,f=a===void 0&&!!d?.find&&!!l&&u!=null,[p,m]=K.useState(null),[h,g]=K.useState(!1);K.useEffect(()=>{if(!f)return;let e=!1;return g(!0),Promise.resolve(d.find(`sys_activity`,{$filter:{object_name:l,record_id:u},$orderby:{timestamp:`desc`},$top:Math.max(1,c)})).then(t=>{if(e)return;let n=(t?.data??t?.records??[]).filter(e=>L8t.has(e?.type)).map(e=>{let t=e.timestamp;return(!t||t===`NOW()`||Number.isNaN(Date.parse(t)))&&(t=e.created_at),{id:e.id,created_at:t,action:e.type,user_name:e.actor_name??null,user_avatar:e.actor_avatar_url??null,summary:e.summary??null}});m(n)}).catch(()=>{e||m([])}).finally(()=>{e||g(!1)}),()=>{e=!0}},[f,d,l,u,c]);let _=a??p??[],v=o??(f&&p===null?h||!0:!1);return(0,q.jsx)(`div`,{className:t,...r,children:(0,q.jsx)(K6t,{entries:_,loading:v,emptyText:s})})},z8t=e=>{let{"data-obj-id":t,"data-obj-type":n,style:r,...i}=e||{};return{designer:{"data-obj-id":t,"data-obj-type":n,style:r},rest:i}},X9=e=>e.replace(/[_-]+/g,` `).replace(/\b\w/g,e=>e.toUpperCase()).trim(),B8t=(e,t)=>t&&e?.[t]!=null&&e[t]!==``?String(e[t]):e?.name||e?.title||e?.subject||e?.label||e?.email||e?.username||e?.code||e?.slug||e?.provider_id||e?.user_agent||e?.ip_address||e?.id||`—`,V8t=({schema:e={},className:t,...n})=>{let r=Qp(),i=ym(),{t:a}=R9(),{designer:o}=z8t(n),s=P1t().appName,c=Array.isArray(e.entries)?e.entries:Array.isArray(e.properties?.entries)?e.properties.entries:[],l=r?.recordId,u=r?.dataSource,[d,f]=K.useState({}),p=K.useRef(null),[m,h]=K.useState(!1),g=K.useRef(!0);K.useEffect(()=>(g.current=!0,()=>{g.current=!1}),[]);let _=K.useRef(``);K.useEffect(()=>{if(m)return;let e=p.current;if(!e||typeof IntersectionObserver>`u`){h(!0);return}let t=new IntersectionObserver(e=>{e.some(e=>e.isIntersecting)&&h(!0)},{rootMargin:`200px`});return t.observe(e),()=>t.disconnect()},[m]);let v=JSON.stringify(c.map(e=>`${e.objectName}:${e.relationshipField}:${e.limit??3}`));if(K.useEffect(()=>{if(!m||!u?.find||!l||c.length===0)return;let e=`${l}::${v}`;if(_.current===e)return;_.current=e,f(e=>{let t={...e};for(let n of c)t[n.objectName]={loading:!0,total:0,items:e[n.objectName]?.items||[]};return t});let t=async e=>{let t=e.objectName;try{let n=await u.find(e.objectName,{$filter:{[e.relationshipField]:l},$top:e.limit??3,$count:!0});if(!g.current)return;let r=Array.isArray(n)?n:n?.data||[],i=typeof n?.total==`number`?n.total:typeof n?.count==`number`?n.count:r.length;f(e=>({...e,[t]:{loading:!1,total:i,items:r}}))}catch(e){if(!g.current)return;f(n=>({...n,[t]:{loading:!1,total:0,items:[],error:String(e?.message||e)}}))}},n=[...c],r=async()=>{for(;g.current;){let e=n.shift();if(!e)return;await t(e)}},i=Array.from({length:Math.min(3,n.length)},()=>r());Promise.all(i)},[m,u,l,v]),c.length===0)return null;let y=e.hideEmpty!==!1,[b,x]=K.useState(!1),S=new Set(c.filter(e=>{let t=d[e.objectName];return y&&t&&!t.loading&&!t.error&&t.total===0}).map(e=>e.objectName)),C=c.filter(e=>b||!S.has(e.objectName)),w=c.filter(e=>S.has(e.objectName)).map(e=>e.title||(i?.objectLabel?i.objectLabel({name:e.objectName,label:X9(e.objectName)}):X9(e.objectName)));return(0,q.jsxs)(`div`,{ref:p,className:J(`flex flex-col gap-3`,e.className,t),...o,children:[C.map(e=>{let t=e.objectName,n=d[t]||{loading:!0,total:0,items:[]};return(0,q.jsxs)(lX,{className:`overflow-hidden`,children:[(0,q.jsxs)(uX,{className:`flex flex-row items-center justify-between gap-2 py-3 px-4 space-y-0 border-b`,children:[(0,q.jsx)(dX,{className:`text-sm font-semibold tracking-tight truncate`,children:e.title||(i?.objectLabel?i.objectLabel({name:e.objectName,label:X9(e.objectName)}):X9(e.objectName))}),(0,q.jsxs)(`div`,{className:`flex items-center gap-2 shrink-0`,children:[!n.loading&&(0,q.jsx)(cY,{variant:`secondary`,className:`tabular-nums`,children:n.total}),s&&l&&(0,q.jsx)(n9,{to:`/apps/${s}/${e.objectName}?filter%5B${e.relationshipField}%5D=${encodeURIComponent(String(l))}`,className:`text-[11px] font-medium text-muted-foreground hover:text-foreground transition-colors`,title:a(`detail.viewAll`,{defaultValue:`View all`}),children:a(`detail.viewAll`,{defaultValue:`View all`})})]})]}),(0,q.jsx)(pX,{className:`p-0`,children:n.loading?(0,q.jsxs)(`div`,{className:`space-y-1.5 p-3`,children:[(0,q.jsx)(g4,{className:`h-3.5 w-4/5`}),(0,q.jsx)(g4,{className:`h-3.5 w-3/5`}),(0,q.jsx)(g4,{className:`h-3.5 w-2/3`})]}):n.items.length===0?(0,q.jsx)(`p`,{className:`px-4 py-3 text-xs text-muted-foreground`,children:a(`detail.noRecords`)}):(0,q.jsx)(`ul`,{className:`divide-y`,children:n.items.map(t=>{let n=t.id||t._id,r=B8t(t,e.displayField),i=n?`../${e.objectName}/record/${encodeURIComponent(String(n))}`:void 0;return(0,q.jsx)(`li`,{className:`px-4 py-2`,children:i?(0,q.jsxs)(n9,{to:i,className:`group flex items-center justify-between gap-2 text-xs hover:text-foreground text-muted-foreground transition-colors`,children:[(0,q.jsx)(`span`,{className:`truncate`,children:r}),(0,q.jsx)(NC,{className:`h-3 w-3 shrink-0 opacity-0 group-hover:opacity-100 transition-opacity`})]}):(0,q.jsx)(`span`,{className:`block truncate text-xs text-muted-foreground`,children:r})},String(n||r))})})})]},t)}),!b&&w.length>0&&(0,q.jsxs)(`button`,{type:`button`,onClick:()=>x(!0),className:`self-start inline-flex items-center gap-1.5 text-[11px] text-muted-foreground hover:text-foreground transition-colors px-2.5 py-1 rounded-md border border-dashed border-border/60 hover:border-border bg-background`,title:w.join(` · `),children:[(0,q.jsx)(`span`,{children:a(`detail.showEmptyRelated`,{defaultValue:`+ {{count}} empty`,count:w.length})}),(0,q.jsxs)(`span`,{className:`truncate max-w-[180px] text-muted-foreground/70`,children:[`(`,w.join(` · `),`)`]})]})]})},H8t={info:{wrap:`border-blue-300/60 bg-blue-50 text-blue-900 dark:border-blue-700/40 dark:bg-blue-950/30 dark:text-blue-100 [&>svg]:text-blue-600 dark:[&>svg]:text-blue-300`,icon:`Info`},warning:{wrap:`border-amber-300/60 bg-amber-50 text-amber-900 dark:border-amber-700/40 dark:bg-amber-950/30 dark:text-amber-100 [&>svg]:text-amber-600 dark:[&>svg]:text-amber-300`,icon:`AlertTriangle`},error:{wrap:`border-destructive/60 bg-destructive/10 text-destructive dark:bg-destructive/20 [&>svg]:text-destructive`,icon:`AlertCircle`},success:{wrap:`border-emerald-300/60 bg-emerald-50 text-emerald-900 dark:border-emerald-700/40 dark:bg-emerald-950/30 dark:text-emerald-100 [&>svg]:text-emerald-600 dark:[&>svg]:text-emerald-300`,icon:`CheckCircle2`}};function U8t(e){let t=e?.properties??{};return{...e,...t}}var W8t=({schema:e={},className:t})=>{let n=U8t(e),r=Qp(),i=r?.data,a=r?.objectName||``,o=r?.recordId??i?.id,{language:s}=_m(),c=bm(n.title,s),l=bm(n.body,s),u=bm(n.action?.label,s),d=[`info`,`warning`,`error`,`success`].includes(n.severity)?n.severity:`info`,f=H8t[d],p=n.icon||f.icon,m=zp(n.visible),h=Bp(m,{record:i}),g=K.useMemo(()=>{if(!n.dismissible)return null;let e=n.dismissKey||bm(n.title,`en`)||d;return`os.record-alert:${a}:${o??`_`}:${e}`},[n.dismissible,n.dismissKey,n.title,d,a,o]),[_,v]=K.useState(()=>{if(!g||typeof window>`u`)return!1;try{return window.localStorage.getItem(g)===`1`}catch{return!1}}),y=n.action?.actionName,{item:b}=Zp(`object`,y&&a?a:null),x=K.useMemo(()=>{if(!(!y||!b?.actions))return b.actions.find(e=>e.name===y)},[y,b]),{executeAction:S}=zoe({actions:K.useMemo(()=>x?[x]:[],[x]),context:{record:i,recordId:o,objectName:a}});return _||!i||Object.keys(i).length===0||m!==void 0&&!h?null:(0,q.jsxs)(QJ,{className:J(`relative pr-12`,f.wrap,t),role:d===`error`?`alert`:`status`,"aria-live":d===`error`?`assertive`:`polite`,children:[(0,q.jsx)(v3,{name:p,className:`h-4 w-4`,"aria-hidden":`true`}),c?(0,q.jsx)($J,{children:c}):null,l||x?(0,q.jsxs)(eY,{children:[l?(0,q.jsx)(`p`,{className:`mb-2 last:mb-0`,children:l}):null,x?(0,q.jsx)(Z,{size:`sm`,variant:n.action?.variant||(d===`error`?`destructive`:`default`),onClick:()=>{x?.name&&S(x.name)},children:u||x.label||x.name}):null]}):null,n.dismissible?(0,q.jsx)(`button`,{type:`button`,onClick:()=>{if(v(!0),g)try{window.localStorage.setItem(g,`1`)}catch{}},"aria-label":`Dismiss`,className:`absolute right-3 top-3 inline-flex h-6 w-6 items-center justify-center rounded-md text-muted-foreground/80 hover:bg-foreground/5 hover:text-foreground focus:outline-none focus:ring-2 focus:ring-ring`,children:(0,q.jsx)(v3,{name:`X`,className:`h-4 w-4`,"aria-hidden":`true`})}):null]})},G8t=e=>{if(e==null)return`—`;if(typeof e==`string`)return e.length>0?e:`""`;if(typeof e==`number`||typeof e==`boolean`)return String(e);try{return JSON.stringify(e)}catch{return String(e)}},K8t=e=>{if(typeof e!=`string`||e.length===0)return null;let t=/\d{4}-\d{2}-\d{2}[ T]/.test(e)?e.replace(` `,`T`):e,n=new Date(t);if(Number.isNaN(n.getTime()))return null;try{return n.toLocaleString()}catch{return n.toISOString()}},q8t=({open:e,conflict:t,onReload:n,onOverwrite:r,onCancel:i,busy:a=!1})=>{let{t:o}=R9(),s=t?.label||t?.field||``,c=t?G8t(t.pendingValue):``,l=t?G8t(t.currentValue):``,u=t?.currentRecord??{},d=(()=>{let e=[u.updated_by_name,u.updated_by_label];for(let t of e)if(typeof t==`string`&&t.length>0)return t;let t=u.updated_by;return typeof t!=`string`||t.length===0||t.length>=16&&!/\s/.test(t)&&/^[A-Za-z0-9_-]+$/.test(t)?null:t})(),f=K8t(u.updated_at??t?.currentVersion),[p,m]=o(`detail.concurrentUpdateDescription`,{field:`{{field}}`}).split(`{{field}}`);return(0,q.jsx)(WJ,{open:e,onOpenChange:e=>{!e&&!a&&i()},children:(0,q.jsxs)(GJ,{className:`max-w-lg`,children:[(0,q.jsx)(KJ,{children:(0,q.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,q.jsx)(`span`,{className:`inline-flex h-9 w-9 flex-none items-center justify-center rounded-full bg-amber-100 text-amber-700 dark:bg-amber-500/20 dark:text-amber-300`,"aria-hidden":`true`,children:(0,q.jsx)(Bq,{className:`h-5 w-5`})}),(0,q.jsxs)(`div`,{className:`flex-1`,children:[(0,q.jsx)(JJ,{children:o(`detail.concurrentUpdateTitle`)}),(0,q.jsxs)(YJ,{className:`mt-1`,children:[p,(0,q.jsx)(`strong`,{className:`font-semibold`,children:s}),m]})]})]})}),(0,q.jsxs)(`div`,{className:`space-y-2 text-sm`,children:[(0,q.jsxs)(`div`,{className:`rounded-md border border-amber-200/70 bg-amber-50/60 p-3 dark:border-amber-500/30 dark:bg-amber-500/10`,children:[(0,q.jsx)(`div`,{className:`text-xs font-medium uppercase tracking-wide text-amber-800 dark:text-amber-300`,children:o(`detail.concurrentUpdateYourEdit`)}),(0,q.jsx)(`div`,{className:`mt-1 break-all font-mono text-foreground`,children:c})]}),(0,q.jsxs)(`div`,{className:`rounded-md border border-sky-200/70 bg-sky-50/60 p-3 dark:border-sky-500/30 dark:bg-sky-500/10`,children:[(0,q.jsxs)(`div`,{className:`flex items-baseline justify-between gap-2`,children:[(0,q.jsx)(`div`,{className:`text-xs font-medium uppercase tracking-wide text-sky-800 dark:text-sky-300`,children:o(`detail.concurrentUpdateCurrentValue`)}),(d||f)&&(0,q.jsxs)(`div`,{className:`text-[11px] text-muted-foreground`,children:[d&&(0,q.jsx)(`span`,{children:o(`detail.concurrentUpdateUpdatedBy`,{name:d})}),d&&f&&(0,q.jsx)(`span`,{children:` · `}),f&&(0,q.jsx)(`span`,{children:o(`detail.concurrentUpdateUpdatedAt`,{when:f})})]})]}),(0,q.jsx)(`div`,{className:`mt-1 break-all font-mono text-foreground`,children:l})]})]}),(0,q.jsxs)(qJ,{className:`gap-2 sm:gap-2`,children:[(0,q.jsx)(`button`,{type:`button`,disabled:a,onClick:i,className:J(UJ({variant:`ghost`}),`mt-2 sm:mt-0`),children:o(`detail.concurrentUpdateCancel`)}),(0,q.jsx)(`button`,{type:`button`,disabled:a,onClick:r,className:J(UJ({variant:`outline`}),`mt-2 sm:mt-0 text-destructive border-destructive/40 hover:bg-destructive/10 hover:text-destructive`),children:o(`detail.concurrentUpdateOverwrite`)}),(0,q.jsx)(`button`,{type:`button`,disabled:a,onClick:n,autoFocus:!0,className:J(UJ({variant:`default`}),`mt-2 sm:mt-0`),children:o(`detail.concurrentUpdateReload`)})]})]})})};function J8t(e){if(!e||typeof e!=`object`)return!1;let t=e;return t.code===`CONCURRENT_UPDATE`||t.name===`ConcurrentUpdateError`}function Y8t(e){let t=e?.message||e?.error||String(e??`Save failed`);return String(t).replace(/^\[[^\]]+\]\s*/,``).replace(/^[A-Z][A-Z0-9_]+:\s*/,``)}async function X8t(e,t,n,r,i){if(typeof e?.update==`function`)await e.update(t,n,r,i);else if(typeof e?.updateOne==`function`)await e.updateOne(t,n,r,i);else if(typeof e?.patch==`function`)await e.patch(t,n,r,i);else throw Error(`[InlineEditSaveBar] DataSource exposes no update/updateOne/patch method; cannot persist inline edit`)}var Z8t=({dataSource:e,objectName:t,recordId:n,data:r,refresh:i,fieldLabelFor:a,onFieldSave:o,locked:s=!1,lockedHint:c,className:l})=>{let{t:u}=R9(),d=$p(),[f,p]=K.useState(null),[m,h]=K.useState(!1),g=!!e&&!!t&&n!=null,_=K.useCallback((e,t)=>{let n=Object.keys(e),r=t?.currentRecord??null;if(n.length===1){let i=n[0];return{field:i,label:a?.(i),pendingValue:e[i],currentValue:r?r[i]:void 0,currentVersion:t?.currentVersion,currentRecord:r}}let i=r?Object.fromEntries(n.map(e=>[e,r[e]])):void 0;return{field:n.join(`, `),label:u(`detail.concurrentUpdateRecordLabel`,{defaultValue:`this record`}),pendingValue:e,currentValue:i,currentVersion:t?.currentVersion,currentRecord:r}},[a,u]),v=K.useCallback(async()=>{if(!d)return;let a=d.draft,s=Object.entries(a);if(s.length===0){d.reset();return}d.setSaving(!0),d.setError(null);try{if(o)for(let[e,t]of s)await o(e,t);else if(g){let o=typeof r?.updated_at==`string`?r.updated_at:void 0;await X8t(e,t,n,a,o?{ifMatch:o}:void 0),await i?.()}d.reset()}catch(e){J8t(e)&&g?p(_(a,e)):d.setError(Y8t(e))}finally{d.setSaving(!1)}},[d,o,g,r,e,t,n,i,_]),y=K.useCallback(()=>{p(null),h(!1)},[]),b=K.useCallback(async()=>{h(!0);try{await i?.()}finally{d?.reset(),y()}},[i,d,y]),x=K.useCallback(async()=>{if(!f||!g){y();return}h(!0);try{await X8t(e,t,n,d?.draft??{},f.currentVersion?{ifMatch:f.currentVersion}:void 0),await i?.(),d?.reset()}catch(e){d?.setError(Y8t(e))}finally{y()}},[f,g,d,e,t,n,i,y]),S=!!d?.editing,C=!!d?.saving,w=d?.cancel,T=!!f;return K.useEffect(()=>{if(!S)return;let e=e=>{if(e.key===`Enter`&&(e.metaKey||e.ctrlKey)){if(C||s||T)return;e.preventDefault(),v();return}if(e.key===`Escape`){if(e.defaultPrevented||C||T||document.querySelector(`[data-radix-popper-content-wrapper], [role="dialog"][data-state="open"], [role="alertdialog"][data-state="open"]`))return;e.preventDefault(),w?.()}};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[S,C,s,T,v,w]),!d||!d.editing?null:(0,q.jsxs)(q.Fragment,{children:[(0,q.jsxs)(`div`,{className:J(`sticky bottom-0 z-30 mt-4 flex flex-wrap items-center justify-end gap-2 rounded-md border bg-background/95 px-3 py-2 shadow-sm backdrop-blur supports-[backdrop-filter]:bg-background/80`,l),role:`region`,"aria-label":u(`detail.editFieldsInline`),children:[d.error&&(0,q.jsx)(`div`,{role:`alert`,className:`mr-auto max-w-md rounded-md border border-destructive/20 bg-destructive/10 px-2 py-1 text-xs text-destructive`,children:d.error}),(0,q.jsxs)(Z,{variant:`ghost`,size:`sm`,onClick:d.cancel,disabled:d.saving,className:`gap-2`,children:[(0,q.jsx)(Uq,{className:`h-4 w-4`}),(0,q.jsx)(`span`,{children:u(`detail.cancel`)})]}),(0,q.jsxs)(Z,{variant:`default`,size:`sm`,onClick:v,disabled:d.saving||s,className:`gap-2`,title:s?c:void 0,children:[d.saving?(0,q.jsx)(eq,{className:`h-4 w-4 animate-spin`}):(0,q.jsx)(sC,{className:`h-4 w-4`}),(0,q.jsx)(`span`,{children:d.saving?u(`detail.saving`):u(`detail.save`)})]})]}),(0,q.jsx)(q8t,{open:!!f,conflict:f,busy:m,onCancel:y,onReload:b,onOverwrite:x})]})},Q8t=new Set([`id`,`_id`,`__v`,`created_at`,`updated_at`,`createdAt`,`updatedAt`,`created_by`,`updated_by`,`organization_id`,`tenant_id`,`owner_id`,`deleted_at`,`is_deleted`]),$8t=480,e5t=95;function t5t({open:e,onClose:t,title:n,record:r,objectName:i,recordId:a,dataSource:o,objectSchema:s,width:c=`min(960px, 60vw)`,columns:l=2,systemFields:u=Q8t,onFieldSave:d,onDelete:f,resizable:p=!0,fullPageHref:m}){let{t:h}=R9(),g=`objectui.drawerWidth.${i}`,[_,v]=K.useState(()=>{if(typeof window>`u`||!p)return null;try{let e=window.localStorage.getItem(g);if(e){let t=parseInt(e,10);if(Number.isFinite(t)&&t>=$8t)return t}}catch{}return null}),y=K.useMemo(()=>p&&_!=null?`${_}px`:typeof c==`number`?`${c}px`:c,[p,_,c]),b=y?{width:y,maxWidth:y}:void 0,x=K.useRef(null),S=K.useCallback(e=>{if(!p)return;e.preventDefault();let t=_??(typeof window<`u`?Math.min(window.innerWidth*.6,960):720);x.current={startX:e.clientX,startWidth:t};let n=e=>{let t=x.current;if(!t)return;let n=t.startX-e.clientX,r=typeof window<`u`?window.innerWidth*e5t/100:1600,i=Math.min(r,Math.max($8t,t.startWidth+n));v(Math.round(i))},r=()=>{x.current,x.current=null,window.removeEventListener(`pointermove`,n),window.removeEventListener(`pointerup`,r),window.removeEventListener(`pointercancel`,r);try{v(e=>(e!=null&&window.localStorage.setItem(g,String(e)),e))}catch{}};window.addEventListener(`pointermove`,n),window.addEventListener(`pointerup`,r),window.addEventListener(`pointercancel`,r)},[p,_,g]),C=s?.fields??{},w=(Object.keys(C).length?Object.keys(C):Object.keys(r)).filter(e=>!u.has(e)&&!e.startsWith(`__`)).filter(e=>e in r).filter(e=>!C[e]?.hidden).map(e=>{let t=C[e]||{},n=t.type===`lookup`||t.type===`master_detail`||t.type===`reference`;return{name:e,label:t.label,type:t.type,readonly:!!t.readonly||n,options:t.options,currency:t.currency,precision:t.precision,scale:t.scale,format:t.format,reference_to:t.reference_to??t.reference??t.referenceTo??t.target,reference_field:t.reference_field??t.referenceField,required:t.required,validation:t.validation,placeholder:t.placeholder,description:t.description}});return(0,q.jsx)(l4,{open:e,onOpenChange:e=>{e||t()},children:(0,q.jsxs)(u4,{side:`right`,className:`w-full overflow-y-auto p-0 sm:!max-w-none`,style:b,onOpenAutoFocus:e=>e.preventDefault(),children:[p&&(0,q.jsx)(`div`,{role:`separator`,"aria-orientation":`vertical`,"aria-label":`Resize drawer`,onPointerDown:S,className:`hidden sm:block absolute left-0 top-0 h-full w-1.5 cursor-col-resize select-none bg-transparent hover:bg-primary/30 active:bg-primary/50 transition-colors z-10`}),(0,q.jsx)(d4,{className:`sr-only`,children:(0,q.jsx)(f4,{children:n})}),(0,q.jsx)(`div`,{className:`px-6 pt-6 pb-6`,children:(0,q.jsxs)(Aoe,{canEdit:!!d,children:[(0,q.jsx)(K9,{dataSource:o,inlineEdit:!!d,schema:{type:`detail-view`,objectName:i,resourceId:String(a),data:r,showDelete:!!f,columns:l,fields:w,actions:m?[{type:`action:bar`,location:`record_header`,systemActions:[{name:`sys_open_new_tab`,label:h(`detail.openInNewTab`),icon:`external-link`,type:`script`,onClick:()=>window.open(m,`_blank`,`noopener`)}]}]:void 0},onDelete:f?async()=>{try{await f(),t()}catch(e){console.error(`[RecordDetailDrawer] delete failed:`,e)}}:void 0}),(0,q.jsx)(Z8t,{onFieldSave:d?async(e,t)=>{try{await d(e,t)}catch(e){throw console.error(`[RecordDetailDrawer] inline field save failed:`,e),e}}:void 0})]})})]})})}function n5t(e,t){if(typeof window>`u`)return null;let n=window.location.pathname,r=`/${e}`,i=n.indexOf(r);return`${i>=0?n.slice(0,i):n.replace(/\/$/,``)}/${e}/record/${encodeURIComponent(String(t))}`}p.register(`detail-view`,K9,{namespace:`plugin-detail`,label:`Detail View`,category:`Views`,icon:`FileText`,inputs:[{name:`title`,type:`string`,label:`Title`},{name:`objectName`,type:`string`,label:`Object Name`},{name:`resourceId`,type:`string`,label:`Resource ID`},{name:`api`,type:`string`,label:`API Endpoint`},{name:`data`,type:`object`,label:`Data`},{name:`layout`,type:`enum`,label:`Layout Mode`,enum:[`vertical`,`horizontal`,`grid`]},{name:`columns`,type:`number`,label:`Grid Columns`},{name:`sections`,type:`array`,label:`Sections`},{name:`fields`,type:`array`,label:`Fields`},{name:`tabs`,type:`array`,label:`Tabs`},{name:`related`,type:`array`,label:`Related Lists`},{name:`actions`,type:`array`,label:`Actions`},{name:`showBack`,type:`boolean`,label:`Show Back Button`,defaultValue:!0},{name:`backUrl`,type:`string`,label:`Back URL`},{name:`showEdit`,type:`boolean`,label:`Show Edit Button`,defaultValue:!1},{name:`editUrl`,type:`string`,label:`Edit URL`},{name:`showDelete`,type:`boolean`,label:`Show Delete Button`,defaultValue:!1},{name:`deleteConfirmation`,type:`string`,label:`Delete Confirmation Message`},{name:`loading`,type:`boolean`,label:`Show Loading State`},{name:`header`,type:`object`,label:`Custom Header`},{name:`footer`,type:`object`,label:`Custom Footer`}],defaultProps:{title:`Detail View`,showBack:!0,showEdit:!1,showDelete:!1,sections:[],fields:[],tabs:[],related:[]}}),p.register(`detail-section`,V9,{namespace:`plugin-detail`,label:`Detail Section`,category:`Detail Components`,inputs:[{name:`title`,type:`string`,label:`Title`},{name:`description`,type:`string`,label:`Description`},{name:`fields`,type:`array`,label:`Fields`,required:!0},{name:`collapsible`,type:`boolean`,label:`Collapsible`,defaultValue:!1},{name:`defaultCollapsed`,type:`boolean`,label:`Default Collapsed`,defaultValue:!1},{name:`columns`,type:`number`,label:`Columns`,defaultValue:2},{name:`showBorder`,type:`boolean`,label:`Show Border`,defaultValue:!0},{name:`headerColor`,type:`string`,label:`Header Color`}]}),p.register(`related-list`,H9,{namespace:`plugin-detail`,label:`Related List`,category:`Detail Components`,inputs:[{name:`title`,type:`string`,label:`Title`,required:!0},{name:`type`,type:`enum`,label:`Type`,enum:[{label:`List`,value:`list`},{label:`Grid`,value:`grid`},{label:`Table`,value:`table`}],defaultValue:`table`},{name:`api`,type:`string`,label:`API Endpoint`},{name:`data`,type:`array`,label:`Data`},{name:`columns`,type:`array`,label:`Columns`}]}),p.register(`detail`,K9,{namespace:`view`,category:`view`,label:`Detail`,icon:`FileText`,inputs:[{name:`objectName`,type:`string`,label:`Object Name`,required:!0},{name:`recordId`,type:`string`,label:`Record ID`},{name:`fields`,type:`array`,label:`Fields`}]}),p.register(`record:details`,r8t,{namespace:`record`,category:`record`,label:`Record Details`,icon:`FileText`,inputs:[{name:`columns`,type:`enum`,label:`Columns`,enum:[`1`,`2`,`3`,`4`],defaultValue:`2`,description:`Number of columns for field layout (1-4)`},{name:`layout`,type:`enum`,label:`Layout`,enum:[`auto`,`custom`],defaultValue:`auto`,description:`auto uses the object highlightFields; custom uses explicit sections`},{name:`sections`,type:`array`,label:`Sections`,description:`Section IDs to show (required when layout is "custom")`},{name:`fields`,type:`array`,label:`Fields`,description:`Explicit field list (overrides highlightFields)`}]}),p.register(`record:related_list`,o8t,{namespace:`record`,category:`record`,label:`Related List`,icon:`List`,inputs:[{name:`objectName`,type:`string`,label:`Related Object`,required:!0,description:`Related object name (e.g. "task")`},{name:`relationshipField`,type:`string`,label:`Relationship Field`,required:!0,description:`Field on the related object pointing back to this record`},{name:`columns`,type:`array`,label:`Columns`,required:!0,description:`Fields to display in the related list`},{name:`sort`,type:`array`,label:`Sort`},{name:`limit`,type:`number`,label:`Limit`,defaultValue:5,description:`Records to display initially`},{name:`filter`,type:`array`,label:`Filter`,description:`Additional filter criteria`},{name:`title`,type:`string`,label:`Title`},{name:`showViewAll`,type:`boolean`,label:`Show "View All"`,defaultValue:!0},{name:`actions`,type:`array`,label:`Actions`,description:`Action IDs available for related records`}]}),p.register(`record:highlights`,c8t,{namespace:`record`,category:`record`,label:`Highlights Panel`,icon:`Star`,inputs:[{name:`fields`,type:`array`,label:`Fields`,required:!0,description:`Key fields to highlight (1-7), bare names or {name,label?,icon?,type?}`},{name:`layout`,type:`enum`,label:`Layout`,enum:[`horizontal`,`vertical`],defaultValue:`horizontal`,description:`Layout orientation for highlight fields`}]}),p.register(`record:activity`,D8t,{namespace:`record`,category:`record`,label:`Activity Timeline`,icon:`Activity`}),p.register(`record:chatter`,A8t,{namespace:`record`,category:`record`,label:`Chatter Feed`,icon:`MessageSquare`}),p.register(`record:discussion`,A8t,{namespace:`record`,category:`record`,label:`Discussion`,icon:`MessageSquare`}),p.register(`record:path`,M8t,{namespace:`record`,category:`record`,label:`Path / Stepper`,icon:`GitBranch`,inputs:[{name:`statusField`,type:`string`,label:`Status Field`,required:!0,description:`Field representing the current status/stage`},{name:`stages`,type:`array`,label:`Stages`,description:`Explicit stage definitions [{ value, label }] (else derived from field metadata)`}]}),p.register(`record:quick_actions`,P8t,{namespace:`record`,category:`record`,label:`Quick Actions`,icon:`Zap`}),p.register(`record:history`,R8t,{namespace:`record`,category:`record`,label:`History Timeline`,icon:`Clock`}),p.register(`record:reference_rail`,V8t,{namespace:`record`,category:`record`,label:`Reference Rail`,icon:`PanelRight`}),p.register(`record:alert`,W8t,{namespace:`record`,category:`record`,label:`Alert Banner`,icon:`AlertTriangle`}),p.register(`permission-facet-link`,z9,{namespace:`field`,skipFallback:!0});function r5t(e,t){if(Array.isArray(e)&&e.length>0)return e;let n=t?.highlightFields;return Array.isArray(n)?n.filter(e=>!!t?.fields?.[e]):[]}var i5t=({schema:e,dataSource:t,className:n,data:r,loading:i,onRowClick:a,onCardClick:o,...s})=>{let{translateOptions:c,fieldLabel:l}=ym(),u=Array.isArray(r),[d,f]=(0,K.useState)([]),[p,m]=(0,K.useState)(null),[h,g]=(0,K.useState)(u?i??!1:!1),[_,v]=(0,K.useState)(null),[y,x]=(0,K.useState)(0),S=Lp(e.bind);(0,K.useEffect)(()=>{if(!u&&!(!t?.onMutation||!e.objectName))return t.onMutation(t=>{t.resource===e.objectName&&x(e=>e+1)})},[t,e.objectName,u]),(0,K.useEffect)(()=>{u&&i!==void 0&&g(i)},[i,u]),(0,K.useEffect)(()=>{let n=!0;return(async()=>{if(!(!t||!e.objectName))try{let r=await t.getObjectSchema(e.objectName);n&&m(r)}catch(e){console.warn(`Failed to fetch object def`,e)}})(),()=>{n=!1}},[e.objectName,t]),(0,K.useEffect)(()=>{if(u)return;let n=!0;return e.objectName&&!S&&!e.data&&(async()=>{if(!(!t||typeof t.find!=`function`||!e.objectName)){n&&g(!0);try{let r=C(p?.fields),i=b(await t.find(e.objectName,{options:{$top:100},$filter:e.filter,...r.length>0?{$expand:r}:{}}));n&&f(i)}catch(e){console.error(`[ObjectKanban] Fetch error:`,e),n&&v(e)}finally{n&&g(!1)}}})(),()=>{n=!1}},[e.objectName,t,S,e.data,e.filter,u,p,y]);let w=(u?r:void 0)||S||e.data||d,T=(0,K.useMemo)(()=>{if(!Array.isArray(w))return[];let t=e.cardTitle||e.titleField,n=p?.NAME_FIELD_KEY;return w.map(r=>{let i;if(t&&(i=r[t],typeof i==`string`&&(i=i.trim())),!i){let e=Fp(p,r),t=r.id??r._id;e===`Untitled`||t!=null&&e===`Record #${t}`||(i=e)}let a=e=>e>=1e6?`$${(e/1e6).toFixed(1).replace(/\.0$/,``)}M`:e>=1e3?`$${Math.round(e/1e3)}K`:`$${e}`,o=/^[A-Za-z0-9_-]{12,32}$/,s=e=>{if(typeof e!=`string`||!o.test(e))return!1;let t=/[A-Z]/.test(e),n=/[a-z]/.test(e),r=/[0-9_-]/.test(e);return t&&n||t&&r||n&&r},u=e=>{let t=r[e];if(t==null||t===``)return;if(typeof t==`object`){let e=t;for(let t of[`name`,`full_name`,`display_name`,`label`,`title`,`username`]){let n=e[t];if(typeof n==`string`&&n.trim())return n.trim()}return}if(typeof t!=`string`)return String(t);let n=p?.fields?.[e];if(!((n?.type===`lookup`||n?.type===`master_detail`||n?.type===`reference`)&&s(t))&&!s(t))return t},d=[],f=r5t(e.cardFields,p),m=new Set([...t?[t]:[],...n?[n]:[],`name`,`full_name`,`title`,`subject`,`display_name`]),h=[],g=[];if(f.length>0)for(let t of f){if(m.has(t))continue;let n=p?.fields?.[t],i=r[t];if(!(i==null||i===``))if(n?.type===`picklist`||n?.type===`multipicklist`||Array.isArray(n?.options)&&n.options.length>0){let r=n?.options?.find(e=>String(e.value).toLowerCase()===String(i).toLowerCase()),a=r?.label||String(i),o=p?.name||e.objectName,s=o?c(o,t,[{value:String(r?.value??i),label:a}])[0]?.label??a:a,l=u7(r?.color,i);h.push({label:s,colorClass:l})}else{let r=v7(n??{type:`text`}),a=(0,q.jsx)(b7(r),{value:i,field:n??{name:t,type:r}});g.push({field:t,label:l(p?.name||e.objectName||``,t,n?.label||t),node:a})}}else{let e=[`amount`,`value`,`deal_value`,`expected_value`,`opportunity_value`].find(e=>typeof r[e]==`number`);e&&d.push(a(r[e]));let t=[`company`,`company_name`,`account`,`account_name`,`organization`],n;for(let e of t){let t=u(e);if(t){n=t;break}}n&&(!i||!String(i).includes(n))&&d.push(n);let o=[`owner`,`owner_name`,`assignee`,`assignee_name`],s;for(let e of o){let t=u(e);if(t){s=t;break}}s&&d.push(`@${s}`);for(let e of[`priority`,`severity`,`industry`,`rating`]){let t=r[e];if(t!=null&&t!==``){let n=(p?.fields?.[e])?.options?.find(e=>String(e.value).toLowerCase()===String(t).toLowerCase()),r=n?.label||String(t),i=u7(n?.color,t);if(h.push({label:r,colorClass:i}),h.length>=2)break}}}let _=r.description,v=(_==null||_===``||typeof _==`string`&&s(_))&&d.length>0?d.join(` · `):void 0;return{...r,id:r.id||r._id,title:i||Fp(p,r),...v?{cardSubtitle:v}:{},...g.length>0?{cardFieldCells:g}:{},...!Array.isArray(r.badges)&&h.length>0?{badges:h}:{}}})},[w,e,p]),E=(0,K.useMemo)(()=>{let t=t=>{if(!e.objectName||!e.groupBy)return t;let n=c(e.objectName,e.groupBy,[{value:String(t.id),label:t.title}])[0];return n?.label?{...t,title:n.label}:t};if(e.columns&&e.columns.length>0)if(typeof e.columns[0]==`string`){if(!e.groupBy)return e.columns.map(e=>({id:e,title:e}))}else return e.columns.map(t);if(e.groupBy&&p?.fields?.[e.groupBy]?.options){let t=p.fields[e.groupBy].options.map(e=>({value:e.value,label:e.label}));return(e.objectName?c(e.objectName,e.groupBy,t):t).map(e=>({id:e.value,title:e.label}))}if(e.groupBy&&T.length>0){let t=new Set(T.map(t=>t[e.groupBy]));return Array.from(t).map(e=>({id:String(e),title:String(e)}))}return[]},[e.columns,e.groupBy,e.objectName,T,p,c]),D=e.swimlaneField||e.grouping?.fields?.[0]?.field,O={...e,data:T,columns:E,className:n||e.className,...D?{swimlaneField:D}:{}},k=e.navigation??{mode:`drawer`,width:`min(960px, 60vw)`},A=a??o;!A&&(k.mode===`drawer`||k.mode===`modal`||k.mode===`split`||k.mode);let ee=uoe({navigation:k,objectName:e.objectName,onRowClick:A});if(_)return(0,q.jsxs)(`div`,{className:`p-4 border border-destructive/50 rounded bg-destructive/10 text-destructive`,children:[`Error loading kanban data: `,_.message]});let te=e.objectName?`${e.objectName.charAt(0).toUpperCase()+e.objectName.slice(1).replace(/_/g,` `)} Detail`:`Card Details`,j=K.useCallback(async(n,r,i,a)=>{let o=e.groupBy,s=e.objectName;if(!(!o||r===i)&&(u||f(e=>e.map(e=>String(e.id??e._id)===String(n)?{...e,[o]:i}:e)),!(!s||!t?.update)))try{await t.update(s,String(n),{[o]:i})}catch(e){console.warn(`[ObjectKanban] Failed to persist card move`,e),u||f(e=>e.map(e=>String(e.id??e._id)===String(n)?{...e,[o]:r}:e))}},[e.groupBy,e.objectName,t,u]);return(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(s5t,{schema:{...O,onCardClick:(e,t)=>{ee.handleClick(e,t),o?.(e)},onCardMove:j}}),ee.isOverlay&&ee.isOpen&&ee.selectedRecord&&(()=>{let n=e.objectName,r=ee.selectedRecord,i=r.id??r._id;if(!n||i==null)return null;let a=e.cardTitle??e.titleField,o=a&&r[a]?String(r[a]):te;return(0,q.jsx)(t5t,{open:!0,onClose:ee.close,title:o,record:r,objectName:n,recordId:i,dataSource:t,objectSchema:p,width:ee.width??`min(960px, 60vw)`,fullPageHref:n5t(n,i)??void 0,onFieldSave:async(e,r)=>{t?.update&&(await t.update(n,String(i),{[e]:r}),f(t=>t.map(t=>String(t.id??t._id)===String(i)?{...t,[e]:r}:t)))},onDelete:async()=>{t?.delete&&(await t.delete(n,String(i)),f(e=>e.filter(e=>String(e.id??e._id)!==String(i))))}})})()]})},a5t=K.lazy(()=>Q(()=>import(`./KanbanImpl-E9a8UVuL.js`),__vite__mapDeps([2,1,3]))),o5t=K.lazy(()=>Q(()=>import(`./KanbanEnhanced-CzNXENd5.js`),__vite__mapDeps([4,1,3]))),s5t=({schema:e})=>{let t=K.useMemo(()=>{let{columns:t=[],data:n,groupBy:r,coverImageField:i}=e,a=e=>{if(!i)return e;let t=e[i];if(!t)return e;let n=typeof t==`string`?t:t?.url;return n?{...e,coverImage:n}:e};if(n&&r&&Array.isArray(n)){let e={};t.forEach(t=>{t.id&&(e[String(t.id).toLowerCase()]=t.id),t.title&&(e[String(t.title).toLowerCase()]=t.id)});let i=n.reduce((t,n)=>{let i=String(n[r]??``),o=e[i.toLowerCase()]??i;return t[o]||(t[o]=[]),t[o].push(a(n)),t},{});return t.map(e=>({...e,cards:[...(e.cards||[]).map(a),...i[e.id]||[]]}))}return t.map(e=>({...e,cards:(e.cards||[]).map(a)}))},[e]);return(0,q.jsx)(K.Suspense,{fallback:(0,q.jsx)(g4,{className:`w-full h-[600px]`}),children:(0,q.jsx)(a5t,{columns:t,onCardMove:e.onCardMove,onCardClick:e.onCardClick,className:e.className,quickAdd:e.quickAdd,onQuickAdd:e.onQuickAdd,coverImageField:e.coverImageField,conditionalFormatting:e.conditionalFormatting,swimlaneField:e.swimlaneField})})};p.register(`kanban-ui`,s5t,{namespace:`plugin-kanban`,label:`Kanban Board`,icon:`LayoutDashboard`,category:`plugin`,inputs:[{name:`columns`,type:`array`,label:`Columns`,description:`Array of { id, title, cards, limit, className }`,required:!0},{name:`onCardMove`,type:`code`,label:`On Card Move`,description:`Callback when a card is moved`,advanced:!0},{name:`className`,type:`string`,label:`CSS Class`}],defaultProps:{columns:[{id:`todo`,title:`To Do`,cards:[{id:`card-1`,title:`Task 1`,description:`This is the first task`,badges:[{label:`High Priority`,variant:`destructive`},{label:`Feature`,variant:`default`}]},{id:`card-2`,title:`Task 2`,description:`This is the second task`,badges:[{label:`Bug`,variant:`destructive`}]}]},{id:`in-progress`,title:`In Progress`,limit:3,cards:[{id:`card-3`,title:`Task 3`,description:`Currently working on this`,badges:[{label:`In Progress`,variant:`default`}]}]},{id:`done`,title:`Done`,cards:[{id:`card-4`,title:`Task 4`,description:`This task is completed`,badges:[{label:`Completed`,variant:`outline`}]},{id:`card-5`,title:`Task 5`,description:`Another completed task`,badges:[{label:`Completed`,variant:`outline`}]}]}],className:`w-full`}}),p.register(`kanban-enhanced`,({schema:e})=>{let t=K.useMemo(()=>{let{columns:t=[],data:n,groupBy:r}=e;if(n&&r&&Array.isArray(n)){let e=n.reduce((e,t)=>{let n=t[r];return e[n]||(e[n]=[]),e[n].push(t),e},{});return t.map(t=>({...t,cards:[...t.cards||[],...e[t.id]||[]]}))}return t},[e]);return(0,q.jsx)(K.Suspense,{fallback:(0,q.jsx)(g4,{className:`w-full h-[600px]`}),children:(0,q.jsx)(o5t,{columns:t,onCardMove:e.onCardMove,onColumnToggle:e.onColumnToggle,enableVirtualScrolling:e.enableVirtualScrolling,virtualScrollThreshold:e.virtualScrollThreshold,className:e.className,quickAdd:e.quickAdd,onQuickAdd:e.onQuickAdd,conditionalFormatting:e.conditionalFormatting})})},{namespace:`plugin-kanban`,label:`Kanban Board (Enhanced)`,icon:`LayoutGrid`,category:`plugin`,inputs:[{name:`columns`,type:`array`,label:`Columns`,required:!0},{name:`enableVirtualScrolling`,type:`boolean`,label:`Virtual Scrolling`,defaultValue:!1},{name:`virtualScrollThreshold`,type:`number`,label:`Virtual Scroll Threshold`,defaultValue:50},{name:`onCardMove`,type:`code`,label:`On Card Move`,advanced:!0},{name:`onColumnToggle`,type:`code`,label:`On Column Toggle`,advanced:!0},{name:`className`,type:`string`,label:`CSS Class`}],defaultProps:{columns:[],enableVirtualScrolling:!1,virtualScrollThreshold:50,className:`w-full`}});var c5t=({schema:e,...t})=>{let{dataSource:n}=$ae()||{};return(0,q.jsx)(i5t,{schema:e,dataSource:n,...t})};p.register(`object-kanban`,c5t,{namespace:`plugin-kanban`,label:`Object Kanban`,category:`view`,inputs:[{name:`objectName`,type:`string`,label:`Object Name`,required:!0},{name:`columns`,type:`array`,label:`Columns`}]}),p.register(`kanban`,c5t,{namespace:`view`,label:`Kanban Board`,category:`view`,inputs:[{name:`objectName`,type:`string`,label:`Object Name`,required:!0},{name:`columns`,type:`array`,label:`Columns`}]});var l5t=K.lazy(()=>Q(()=>import(`./ChartImpl-B75dFzK8.js`),__vite__mapDeps([5,6,1]))),u5t=K.lazy(()=>Q(()=>import(`./AdvancedChartImpl-DQqVKVEy.js`),__vite__mapDeps([7,1,6]))),d5t=({schema:e})=>(0,q.jsx)(K.Suspense,{fallback:(0,q.jsx)(g4,{className:`w-full h-48 sm:h-64 md:h-80 lg:h-[400px]`}),children:(0,q.jsx)(l5t,{data:e.data,dataKey:e.dataKey,xAxisKey:e.xAxisKey,height:e.height,className:e.className,color:e.color})}),Z9=({schema:e,onChartClick:t})=>{let n=K.useMemo(()=>{let t=e.series,n=e.xAxisKey,r=e.config;if(n||(e.index?n=e.index:e.category&&(n=e.category)),t||(e.categories?t=e.categories.map(e=>({dataKey:e})):e.value&&(t=[{dataKey:e.value}])),!r&&t){let n=e.colors||[`hsl(var(--chart-1))`,`hsl(var(--chart-2))`,`hsl(var(--chart-3))`],i={};t.forEach((e,t)=>{i[e.dataKey]={label:e.label||e.dataKey,color:n[t%n.length]}}),r=i}return{chartType:e.chartType,data:Array.isArray(e.data)?e.data:[],config:r,xAxisKey:n,series:t,className:e.className}},[e]);return(0,q.jsx)(K.Suspense,{fallback:(0,q.jsx)(g4,{className:`w-full h-48 sm:h-64 md:h-80 lg:h-[400px]`}),children:(0,q.jsx)(u5t,{chartType:n.chartType,data:n.data,config:n.config,xAxisKey:n.xAxisKey,series:n.series,className:n.className,colors:Array.isArray(e.colors)?e.colors:void 0,categoryColors:e.categoryColors,isAnimationActive:e.isAnimationActive,onChartClick:t})})};function Q9(e){return e.replace(/[_-]/g,` `).replace(/\b\w/g,e=>e.toUpperCase())}function f5t(e,t){let{field:n,function:r,groupBy:i}=t,a={};for(let t of e){let e=String(t[i]??`Unknown`);a[e]||(a[e]=[]),a[e].push(t)}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}})}async function p5t(e,t,n,r,i){if(!e.length||!t)return e;let a=i||((e,t)=>t),o=`__raw_${t}`,s=n?.fields?.[t];if(!s){let n=/^\d{4}-\d{2}-\d{2}/;return e.map(e=>{let r=e[t],i=String(r??``),s=n.test(i)?i:Q9(i);return{...e,[t]:a(i,s),[o]:r}})}let c=s.type;if(c===`select`||c===`picklist`||c===`dropdown`){let n=s.options||[];if(n.length===0)return e.map(e=>{let n=e[t],r=String(n??``),i=Q9(r);return{...e,[t]:a(r,i),[o]:n}});let r={};for(let e of n)typeof e==`string`?r[e]=e:e&&typeof e==`object`&&(r[String(e.value)]=e.label||String(e.value));return e.map(e=>{let n=e[t],i=String(n??``),s=r[i]||Q9(i);return{...e,[t]:a(i,s),[o]:n}})}if(c===`lookup`||c===`master_detail`){let n=s.reference_to||s.reference;if(!n||!r||typeof r.find!=`function`)return e.map(e=>({...e,[o]:e[t]}));let i=[...new Set(e.map(e=>e[t]).filter(e=>e!=null))];if(i.length===0)return e.map(e=>({...e,[o]:e[t]}));let a=s.id_field||`id`;try{let c=b(await r.find(n,{$filter:{[a]:{$in:i}},$top:i.length})),l=s.reference_field||s.display_field||`name`,u={};for(let e of c){let t=String(e[a]??e.id??e._id??``),n=e[l]||e.name||e.label||e.title||t;t&&(u[t]=String(n))}return e.map(e=>{let n=e[t],r=String(n??``);return{...e,[t]:u[r]||r,[o]:n}})}catch(n){return console.warn(`[ObjectChart] Failed to resolve lookup labels:`,n),e.map(e=>({...e,[o]:e[t]}))}}if(c===`date`||c===`datetime`||c===`date_time`||c===`timestamp`||c===`time`)return e.map(e=>({...e,[o]:e[t]}));let l=/^\d{4}-\d{2}-\d{2}/;return e.map(e=>{let n=e[t],r=String(n??``);return{...e,[t]:l.test(r)?r:Q9(r),[o]:n}})}var m5t=e=>{let{schema:t}=e,n=e.onSegmentClick,r=(0,K.useContext)(Ip),i=e.dataSource||r?.dataSource,a=Lp(t.bind),{fieldOptionLabel:o}=ym(),s=(0,K.useRef)(o);(0,K.useEffect)(()=>{s.current=o},[o]);let[c,l]=(0,K.useState)([]),[u,d]=(0,K.useState)(null),[f,p]=(0,K.useState)(()=>!(Array.isArray(t.data)&&t.data.length>0)&&(!!t.objectName||!!t.dataset)),[m,h]=(0,K.useState)(null),[g,_]=(0,K.useState)(null),[v,y]=(0,K.useState)(null),[x,S]=(0,K.useState)(null),{openRecordList:C}=Poe(),w=Yse(),T=(0,K.useMemo)(()=>t.aggregate?JSON.stringify(t.aggregate):``,[t.aggregate]),E=(0,K.useMemo)(()=>t.filter?JSON.stringify(t.filter):``,[t.filter]),D=(0,K.useMemo)(()=>t.compareTo?JSON.stringify(t.compareTo):``,[t.compareTo]),O=(0,K.useMemo)(()=>t.dataset?JSON.stringify({d:t.dataset,dim:t.dimensions??[],val:t.values??[]}):``,[t.dataset,t.dimensions,t.values]),k=e=>e!==`pie`&&e!==`donut`&&e!==`funnel`;(0,K.useEffect)(()=>{let e=!1;return(async()=>{try{let n={headers:{accept:`application/json`},credentials:`include`},r=t.objectName,i,a=null,o=t.aggregate?.groupBy;if(r)i=o&&typeof o==`object`&&!Array.isArray(o)?o.field:typeof o==`string`?o:t.xAxisKey;else if(t.dataset){let e=Array.isArray(t.dimensions)&&t.dimensions.length?t.dimensions[0]:void 0,o=await(await fetch(`/api/v1/meta/dataset/${encodeURIComponent(t.dataset)}`,n)).json().catch(()=>null);a=o?.item??o?.data??o,r=a?.object,i=((a?.dimensions||[]).find(t=>t?.name===e)??(a?.dimensions||[])[0])?.field??e}if(!r||!i){e||(y(null),S(null));return}let s=await(await fetch(`/api/v1/meta/object/${encodeURIComponent(r)}`,n)).json().catch(()=>null),c=s?.item??s?.data??s,l=Lae(c?.fields?.[i]?.options),u=null;if(t.dataset&&Array.isArray(t.dimensions)){let e={};for(let n of t.dimensions){let t=(a?.dimensions||[]).find(e=>e?.name===n)?.field??n,r=Rae(c?.fields?.[t]?.options);r&&(e[n]=r)}Object.keys(e).length>0&&(u=e)}e||(y(l),S(u))}catch{e||(y(null),S(null))}})(),()=>{e=!0}},[t.objectName,t.dataset,O,T,t.xAxisKey]);let A=(0,K.useCallback)(async(e,n)=>{if(t.aggregate&&typeof e.aggregate==`function`){let r=t.aggregate.groupBy;if(r&&typeof r==`object`&&!Array.isArray(r)){let i=t.aggregate.field,a=t.aggregate.function,o={function:a,alias:i||a};a!==`count`&&i&&(o.field=i);let s=await e.aggregate(t.objectName,{groupBy:[r],aggregations:[o],where:n});return Array.isArray(s)?s:[]}let i=await e.aggregate(t.objectName,{field:t.aggregate.field,function:t.aggregate.function,groupBy:r,filter:n});return Array.isArray(i)?i:[]}if(typeof e.find==`function`){let r=b(await e.find(t.objectName,{$filter:n}));return t.aggregate&&r.length>0&&(r=f5t(r,t.aggregate)),r}return[]},[t.objectName,T]),ee=(0,K.useCallback)(async(e,n)=>{if(!e||!t.objectName&&!t.dataset){n.current&&p(!1);return}n.current&&(p(!0),h(null));try{if(t.dataset&&typeof e.queryDataset==`function`){let r=Ap(t.filter),i=await e.queryDataset(t.dataset,{dimensions:Array.isArray(t.dimensions)?t.dimensions:[],measures:Array.isArray(t.values)?t.values:[],...r?{runtimeFilter:r}:{}});n.current&&(l(Array.isArray(i?.rows)?i.rows:[]),d(Array.isArray(i?.fields)?i.fields:null));return}let r=Ap(t.filter),i=t.compareTo,a=!!i&&k(t.chartType),o=a?Nae(t.filter,i):null,[c,u]=await Promise.all([A(e,r),o?A(e,o):Promise.resolve([])]),f=c,p=t.aggregate?.groupBy,m=p&&typeof p==`object`&&!Array.isArray(p)?p.alias||p.field:p||t.xAxisKey;if(a&&u.length>0&&t.aggregate){let e=t.aggregate.field,n=t.aggregate.function,r=t=>{if(t==null)return null;let r=`${e}_${n}`;return r in t?Number(t[r]):n===`count`&&`${e}_count`in t?Number(t[`${e}_count`]):e in t?Number(t[e]):`value`in t?Number(t.value):`count`in t?Number(t.count):null},i=`${e}__comparison`,a=m;if(a&&f.some(e=>e[a]!=null)&&u.some(e=>e[a]!=null)){let e=new Map;for(let t of u){let n=String(t[a]??``);e.set(n,r(t))}f=f.map(t=>{let n=String(t[a]??``),r=e.get(n);return r==null?t:{...t,[i]:r}});let t=new Set(f.map(e=>String(e[a]??``)));for(let e of u){let n=String(e[a]??``);t.has(n)||f.push({[a]:n,[i]:r(e)})}}else{let e=Math.max(f.length,u.length),t=[];for(let n=0;n<e;n++){let e=f[n]||{},a=u[n];t.push(a?{...e,[i]:r(a)}:e)}f=t}}if(m&&typeof e.getObjectSchema==`function`)try{let n=await e.getObjectSchema(t.objectName);f=await p5t(f,m,n,e,(e,n)=>s.current(t.objectName,m,e,n))}catch{}n.current&&l(f)}catch(e){console.error(`[ObjectChart] Fetch error:`,e),n.current&&h(e instanceof Error?e.message:`Failed to load chart data`)}finally{n.current&&p(!1)}},[t.objectName,O,T,E,D,t.xAxisKey,t.chartType,A]);(0,K.useEffect)(()=>{let e={current:!0};return(t.objectName||t.dataset)&&!a&&!t.data?ee(i,e):e.current&&p(!1),()=>{e.current=!1}},[t.objectName,O,i,a,t.data,E,T,D,ee]);let te=a||t.data||c,j=Array.isArray(te)?te:[],ne=t.drillDown,re=t.aggregate?.groupBy||t.xAxisKey,M=(0,K.useMemo)(()=>{if(!re)return new Map;let e=new Map,t=`__raw_${re}`;for(let n of j){let r=n?.[re];if(r==null)continue;let i=t in(n||{})?n[t]:r;e.set(String(r),i)}return e},[j,re]),N=t.compareTo,ie=!!N&&k(t.chartType)&&!!t.aggregate&&j.some(e=>e[`${t.aggregate.field}__comparison`]!=null),ae=(0,K.useMemo)(()=>{let e=Array.isArray(t.series)?t.series:null;if(!ie)return e;let n=e||[{dataKey:t.aggregate.field}],r={vsLastWeek:`Previous week`,vsLastMonth:`Previous month`,vsLastQuarter:`Previous quarter`,vsLastYear:`Previous year`,vsYesterday:`Yesterday`,vsPreviousPeriod:`Previous period`}[Pae(N,t.filter)]||`Previous period`;return[...n.map(e=>({...e,variant:e.variant||`current`})),{dataKey:`${t.aggregate.field}__comparison`,label:r,variant:`comparison`}]},[ie,t.series,t.aggregate,t.filter,N]),oe=t.dataset?Fae(Iae(j,x),t.dimensions,t.values,u):null,P=oe?{...t,data:oe.data,xAxisKey:oe.xAxisKey,series:oe.series}:{...t,data:j,...ae?{series:ae}:{}},se=t.colors&&!Array.isArray(t.colors)&&typeof t.colors==`object`?t.colors:null,ce=Array.isArray(t.colors)?t.colors:void 0,le=v||se?{...v||{},...se||{}}:void 0,ue={...P,colors:ce,...le?{categoryColors:le}:{}};if(f&&j.length===0)return(0,q.jsxs)(`div`,{className:`p-2 `+(t.className||``),"data-testid":`chart-loading`,role:`status`,"aria-busy":`true`,"aria-live":`polite`,children:[(0,q.jsx)(`span`,{className:`sr-only`,children:`Loading chart data…`}),(0,q.jsx)(Wzt,{className:`h-full`})]});if(m)return(0,q.jsxs)(`div`,{className:`flex flex-col items-center justify-center gap-2 p-4 `+(t.className||``),"data-testid":`chart-error`,role:`alert`,children:[(0,q.jsx)(cw,{className:`h-6 w-6 text-destructive opacity-60`}),(0,q.jsx)(`p`,{className:`text-xs text-destructive font-medium`,children:`Failed to load chart data`}),(0,q.jsx)(`p`,{className:`text-xs text-muted-foreground max-w-xs text-center`,children:m})]});if(!i&&t.objectName&&j.length===0)return(0,q.jsxs)(`div`,{className:`flex items-center justify-center text-muted-foreground text-sm p-4 `+(t.className||``),"data-testid":`chart-no-datasource`,children:[`No data source available for “`,t.objectName,`”`]});let de=Aae(ne)?e=>{let t=e.category,n=t!=null&&M.has(String(t))?M.get(String(t)):t;_({...e,category:n,categoryLabel:t,scope:`cell`})}:void 0,fe=n??de,pe=!n&&g&&t.objectName?(()=>{let e=Oae(ne,g,{groupByField:re}),n={...t.filter||{},...e},r=kae(ne,g,t.title||`Details`),a=ne?.target??`drawer`,o=(0,q.jsx)(`div`,{className:`overflow-auto`,"data-testid":`chart-drill-body`,children:(0,q.jsx)(Kp,{schema:{type:`object-data-table`,objectName:t.objectName,filter:n,pagination:!0,pageSize:ne?.maxRows,columns:ne?.columns?.map(e=>({accessorKey:e,header:e})),drillDown:{enabled:!0,mode:`record`,target:`dialog`}},dataSource:i})}),s=C&&t.objectName?(0,q.jsxs)(Z,{type:`button`,variant:`ghost`,size:`sm`,"data-testid":`drill-open-in-list`,onClick:()=>{C(t.objectName,n),_(null)},children:[w(`dashboard.openInList`,`Open in list`),(0,q.jsx)(Eh,{className:`ml-1 h-3.5 w-3.5`})]}):null;return a===`dialog`?(0,q.jsx)(_Z,{open:!0,onOpenChange:e=>!e&&_(null),children:(0,q.jsxs)(yZ,{className:`max-w-4xl`,children:[(0,q.jsxs)(bZ,{className:`flex-row items-center justify-between gap-4 pr-8`,children:[(0,q.jsx)(SZ,{children:r}),s]}),o]})}):(0,q.jsx)(l4,{open:!0,onOpenChange:e=>!e&&_(null),children:(0,q.jsxs)(u4,{side:`right`,className:`w-full sm:max-w-2xl md:max-w-3xl lg:max-w-4xl flex flex-col`,children:[(0,q.jsxs)(d4,{className:`flex-row items-center justify-between gap-4 pr-8`,children:[(0,q.jsx)(f4,{children:r}),s]}),(0,q.jsx)(`div`,{className:`flex-1 overflow-hidden mt-2`,children:o})]})})})():null;return(0,q.jsxs)(`div`,{className:`relative`,children:[(0,q.jsx)(Yzt,{active:f&&j.length>0}),(0,q.jsx)(Z9,{...e,schema:ue,onChartClick:fe}),pe]})};p.register(`object-chart`,m5t,{namespace:`plugin-charts`,label:`Object Chart`,category:`view`,inputs:[{name:`objectName`,type:`string`,label:`Object Name`,required:!0},{name:`data`,type:`array`,label:`Data`,description:`Optional static data`},{name:`filter`,type:`array`,label:`Filter`},{name:`aggregate`,type:`object`,label:`Aggregate`,description:`Aggregation config: { field, function, groupBy }`}]}),p.register(`bar-chart`,d5t,{namespace:`plugin-charts`,label:`Bar Chart`,category:`plugin`,inputs:[{name:`data`,type:`array`,label:`Data`,required:!0},{name:`dataKey`,type:`string`,label:`Data Key`,defaultValue:`value`},{name:`xAxisKey`,type:`string`,label:`X-Axis Key`,defaultValue:`name`},{name:`height`,type:`number`,label:`Height`,defaultValue:400},{name:`color`,type:`color`,label:`Color`,defaultValue:`#8884d8`}],defaultProps:{data:[{name:`Jan`,value:400},{name:`Feb`,value:300},{name:`Mar`,value:600},{name:`Apr`,value:800},{name:`May`,value:500}],dataKey:`value`,xAxisKey:`name`,height:400,color:`#8884d8`}}),p.register(`chart`,m5t,{namespace:`view`,category:`view`,label:`Chart`,skipFallback:!0,inputs:[{name:`objectName`,type:`string`,label:`Object Name`,required:!0},{name:`type`,type:`string`,label:`Chart Type`},{name:`categoryField`,type:`string`,label:`Category Field`},{name:`valueField`,type:`string`,label:`Value Field`}]}),p.register(`chart`,Z9,{namespace:`plugin-charts`,label:`Chart`,category:`plugin`,inputs:[{name:`chartType`,type:`enum`,label:`Chart Type`,enum:[{label:`Bar`,value:`bar`},{label:`Line`,value:`line`},{label:`Area`,value:`area`},{label:`Pie`,value:`pie`},{label:`Donut`,value:`donut`},{label:`Radar`,value:`radar`},{label:`Scatter`,value:`scatter`}],defaultValue:`bar`},{name:`data`,type:`code`,label:`Data (JSON)`,required:!0},{name:`config`,type:`code`,label:`Config (JSON)`},{name:`xAxisKey`,type:`string`,label:`X Axis Key`,defaultValue:`name`},{name:`series`,type:`code`,label:`Series (JSON Array)`,required:!0},{name:`className`,type:`string`,label:`CSS Class`}],defaultProps:{chartType:`bar`,data:[{name:`Jan`,sales:400,revenue:240},{name:`Feb`,sales:300,revenue:139},{name:`Mar`,sales:600,revenue:380},{name:`Apr`,sales:800,revenue:430},{name:`May`,sales:500,revenue:220}],config:{sales:{label:`Sales`,color:`#8884d8`},revenue:{label:`Revenue`,color:`#82ca9d`}},xAxisKey:`name`,series:[{dataKey:`sales`},{dataKey:`revenue`}]}}),p.register(`chart:bar`,Z9,{namespace:`plugin-charts`,label:`Bar Chart (Alias)`,category:`plugin`,defaultProps:{chartType:`bar`}}),p.register(`pie-chart`,Z9,{namespace:`plugin-charts`,label:`Pie Chart`,category:`plugin`,defaultProps:{chartType:`pie`}}),p.register(`donut-chart`,Z9,{namespace:`plugin-charts`,label:`Donut Chart`,category:`plugin`,defaultProps:{chartType:`donut`}}),p.register(`radar-chart`,Z9,{namespace:`plugin-charts`,label:`Radar Chart`,category:`plugin`,defaultProps:{chartType:`radar`}}),p.register(`scatter-chart`,Z9,{namespace:`plugin-charts`,label:`Scatter Chart`,category:`plugin`,defaultProps:{chartType:`scatter`}});var $9=e=>e?SRt(e):null,h5t=({item:e,currentPath:t,isSidebarOpen:n,onNavigate:r,level:i=0})=>{let a=t===e.path,o=e.children?.some(e=>e.path===t),[s,c]=K.useState(o),l=$9(e.icon);return K.useEffect(()=>{o&&c(!0)},[o]),e.children&&e.children.length>0?(0,q.jsxs)($X,{open:s,onOpenChange:c,className:`w-full`,children:[(0,q.jsxs)(eZ,{className:`flex w-full items-center justify-between py-2 text-sm font-medium rounded-md transition-colors text-muted-foreground hover:bg-muted hover:text-foreground ${n?`px-3`:`justify-center px-2 cursor-pointer`}`,children:[(0,q.jsxs)(`div`,{className:`flex items-center overflow-hidden`,children:[l&&(0,q.jsx)(l,{className:`h-4 w-4 shrink-0 ${n?`mr-3`:``}`}),(0,q.jsx)(`span`,{className:`whitespace-nowrap overflow-hidden transition-all duration-300 ${n?`opacity-100 w-auto`:`opacity-0 w-0 hidden`}`,children:e.label})]}),n&&(0,q.jsx)(jC,{className:`h-4 w-4 transition-transform ${s?`rotate-180`:``}`})]}),(0,q.jsx)(tZ,{className:`space-y-1 overflow-hidden data-[state=closed]:animate-collapsible-up data-[state=open]:animate-collapsible-down`,children:n&&e.children.map((e,a)=>(0,q.jsx)(h5t,{item:e,currentPath:t,isSidebarOpen:n,onNavigate:r,level:i+1},a))})]}):(0,q.jsxs)(`a`,{href:e.path||`#`,onClick:t=>e.path&&r(t,e.path),title:n?void 0:e.label,className:`flex items-center py-2 text-sm font-medium rounded-md transition-colors ${a?`bg-primary text-primary-foreground`:`text-muted-foreground hover:bg-muted hover:text-foreground`} ${n?`px-3`:`justify-center px-2`} ${i>0&&n?`pl-10`:``}`,children:[l&&(0,q.jsx)(l,{className:`h-4 w-4 shrink-0 ${n?`mr-3`:``} ${a?`text-primary-foreground`:`text-muted-foreground group-hover:text-foreground`}`}),(0,q.jsx)(`span`,{className:`whitespace-nowrap overflow-hidden transition-all duration-300 ${n?`opacity-100 w-auto`:`opacity-0 w-0 hidden`}`,children:e.label})]})},g5t=({app:e,children:t,currentPath:n,onNavigate:r})=>{let i=e.layout||`sidebar`,[a,o]=K.useState(!0),[s,c]=K.useState(`light`);K.useEffect(()=>{let e=localStorage.getItem(`theme`)===`dark`||!(`theme`in localStorage)&&window.matchMedia(`(prefers-color-scheme: dark)`).matches;c(e?`dark`:`light`)},[]),K.useEffect(()=>{s===`dark`?(document.documentElement.classList.add(`dark`),localStorage.setItem(`theme`,`dark`)):(document.documentElement.classList.remove(`dark`),localStorage.setItem(`theme`,`light`))},[s]);let l=()=>{c(e=>e===`dark`?`light`:`dark`)},u=(e,t)=>{e.preventDefault(),r?r(t):window.location.href=t};if(i===`empty`)return(0,q.jsx)(`main`,{className:e.className,children:t});let d=e.logo&&!e.logo.includes(`/`)&&!e.logo.includes(`.`)?$9(e.logo):null;return(0,q.jsxs)(`div`,{className:`flex min-h-screen w-full bg-background ${e.className||``}`,children:[i===`sidebar`&&(0,q.jsxs)(`aside`,{className:`
|
|
218
218
|
shrink-0 border-r bg-background hidden md:flex flex-col h-screen sticky top-0 z-30 transition-all duration-300 ease-in-out
|
|
219
219
|
${a?`w-64`:`w-[70px]`}
|
|
220
220
|
`,children:[(0,q.jsxs)(`div`,{className:`h-14 flex items-center border-b font-semibold text-lg tracking-tight transition-all ${a?`px-6`:`justify-center px-0`}`,children:[d?(0,q.jsx)(d,{className:`h-6 w-6`}):e.logo?(0,q.jsx)(`img`,{src:e.logo,alt:e.title,className:`h-6 w-auto`}):(0,q.jsx)(iy,{className:`h-6 w-6`}),(0,q.jsx)(`span`,{className:`ml-2 whitespace-nowrap overflow-hidden transition-all duration-300 ${a?`opacity-100 w-auto`:`opacity-0 w-0 hidden`}`,children:e.title||e.name||`Object UI`})]}),(0,q.jsx)(`nav`,{className:`flex-1 p-2 space-y-1 overflow-y-auto overflow-x-hidden`,children:e.menu?.map((e,t)=>(0,q.jsx)(h5t,{item:e,currentPath:n,isSidebarOpen:a,onNavigate:u},t))}),e.version&&a&&(0,q.jsxs)(`div`,{className:`p-4 border-t text-xs text-muted-foreground`,children:[`v`,e.version]})]}),(0,q.jsxs)(`div`,{className:`flex-1 flex flex-col min-w-0 overflow-hidden`,children:[(0,q.jsxs)(`header`,{className:`h-14 flex items-center justify-between px-4 md:px-6 bg-background/95 backdrop-blur supports-[backdrop-filter]:bg-background/60 border-b z-20 sticky top-0`,children:[(0,q.jsxs)(`div`,{className:`flex items-center gap-4`,children:[(0,q.jsx)(`button`,{onClick:()=>o(!a),className:`p-2 -ml-2 text-muted-foreground hover:bg-muted hover:text-foreground rounded-md transition-colors`,children:(0,q.jsx)(aq,{className:`h-5 w-5`})}),(0,q.jsxs)(`div`,{className:`relative hidden md:block w-96`,children:[(0,q.jsx)(Sq,{className:`absolute left-2.5 top-2.5 h-4 w-4 text-muted-foreground`}),(0,q.jsx)(`input`,{type:`text`,placeholder:`Search...`,className:`w-full h-9 pl-9 pr-4 rounded-md border border-input bg-background text-sm shadow-sm transition-colors file:border-0 file:bg-transparent file:text-sm file:font-medium placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50`})]})]}),(0,q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,q.jsx)(`button`,{onClick:l,className:`p-2 text-muted-foreground hover:text-foreground transition-colors rounded-md hover:bg-muted`,title:`Switch to ${s===`dark`?`light`:`dark`} mode`,children:s===`dark`?(0,q.jsx)(Pq,{className:`h-5 w-5`}):(0,q.jsx)(cq,{className:`h-5 w-5`})}),e.actions?.filter(e=>e.type===`button`).map((e,t)=>{let n=e.icon?$9(e.icon):null;return(0,q.jsxs)(`button`,{className:e.variant===`ghost`?`relative p-2 text-muted-foreground hover:text-foreground transition-colors hover:bg-muted rounded-md`:`p-2`,title:e.label,children:[n&&(0,q.jsx)(n,{className:`h-5 w-5`}),e.label&&!e.icon&&(0,q.jsx)(`span`,{children:e.label})]},t)}),(!e.actions||!e.actions.some(e=>e.type===`button`))&&(0,q.jsxs)(`button`,{className:`relative p-2 text-muted-foreground hover:text-foreground transition-colors`,children:[(0,q.jsx)(Fg,{className:`h-5 w-5`}),(0,q.jsx)(`span`,{className:`absolute top-1.5 right-1.5 h-2 w-2 bg-red-600 rounded-full border-2 border-background`})]}),e.actions?.filter(e=>e.type===`user`).map((e,t)=>(0,q.jsxs)(I$,{children:[(0,q.jsx)(L$,{asChild:!0,children:(0,q.jsx)(`button`,{className:`relative h-8 w-8 rounded-full border bg-muted overflow-hidden focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 hover:opacity-90 transition-opacity`,children:(0,q.jsxs)(aY,{className:`h-full w-full`,children:[(0,q.jsx)(oY,{src:e.avatar,alt:e.label||`User`}),(0,q.jsx)(sY,{children:e.label?.substring(0,2).toUpperCase()||`JD`})]})})}),(0,q.jsxs)(R$,{className:`w-56`,align:`end`,forceMount:!0,children:[(0,q.jsx)(B$,{className:`font-normal`,children:(0,q.jsxs)(`div`,{className:`flex flex-col space-y-1`,children:[(0,q.jsx)(`p`,{className:`text-sm font-medium leading-none`,children:e.label||`User`}),(0,q.jsx)(`p`,{className:`text-xs leading-none text-muted-foreground`,children:e.description||`user@example.com`})]})}),(0,q.jsx)(V$,{}),(0,q.jsx)(tEt,{children:e.items?.map((e,t)=>e.type===`separator`?(0,q.jsx)(V$,{},t):(0,q.jsxs)(z$,{onSelect:()=>{e.onClick&&console.log(`Clicked`,e.label)},children:[e.label,e.shortcut&&(0,q.jsx)(sEt,{children:e.shortcut})]},t))})]})]},t))]})]}),(0,q.jsx)(`main`,{className:`flex-1 overflow-auto p-4 md:p-8 scroll-smooth`,children:(0,q.jsx)(`div`,{className:`mx-auto max-w-7xl animate-in fade-in slide-in-from-bottom-4 duration-500`,children:t})})]})]})},_5t=class{appGlob=Object.assign({});pagesGlob=Object.assign({});rootGlob=Object.assign({});async loadAppConfig(){let e=`../app-data/app.json`;if(this.appGlob[e]){let t=await this.appGlob[e]();return t.default||t}return null}async loadPage(e){let t=e.replace(/^\//,``)||`index`;return await this.tryLoad(`../app-data/pages/${t}.json`)?await this.loadKey(`../app-data/pages/${t}.json`):await this.tryLoad(`../app-data/pages/${t}/index.json`)?await this.loadKey(`../app-data/pages/${t}/index.json`):t===`index`&&await this.tryLoad(`../app-data/index.json`)?await this.loadKey(`../app-data/index.json`):null}async tryLoad(e){return!!(this.pagesGlob[e]||this.rootGlob[e])}async loadKey(e){let t=this.pagesGlob[e]||this.rootGlob[e];if(!t)return null;let n=await t();return n.default||n}},v5t=class{baseUrl;constructor(e=`/api`){this.baseUrl=e}async loadAppConfig(){try{let e=await fetch(`${this.baseUrl}/app.json`);return e.ok?await e.json():null}catch{return null}}async loadPage(e){try{let t=e===`/`?`/index`:e,n=await fetch(`${this.baseUrl}/pages${t}.json`);return n.ok?await n.json():null}catch{return null}}};function y5t(){let[e,t]=(0,K.useState)(null),[n,r]=(0,K.useState)(null),[i,a]=(0,K.useState)(window.location.pathname),[o,s]=(0,K.useState)(null),[c,l]=(0,K.useState)(!0),u=(0,K.useMemo)(()=>{let e=new URLSearchParams(window.location.search).get(`api`);return e?(console.log(`🔌 Using Network Loader:`,e),new v5t(e)):(console.log(`📦 Using Local Bundle Loader`),new _5t)},[]);(0,K.useEffect)(()=>{(async()=>{try{let e=await u.loadAppConfig();e&&t(e)}catch(e){console.error(`Error loading app config`,e)}})()},[u]);let d=(0,K.useCallback)(e=>{window.history.pushState({},``,e),a(e),window.scrollTo(0,0)},[]);if((0,K.useEffect)(()=>{let e=()=>a(window.location.pathname);return window.addEventListener(`popstate`,e),()=>window.removeEventListener(`popstate`,e)},[]),(0,K.useEffect)(()=>{(async()=>{l(!0),s(null);try{let e=await u.loadPage(i);e?r(e):(s(`Page not found: ${i}`),r(i===`/`?{type:`page`,title:`Welcome to Object UI`,body:[{type:`div`,className:`p-10 text-center text-muted-foreground`,body:`No index page found.`}]}:null))}catch(e){console.error(e),s(`Failed to load page.`)}finally{l(!1)}})()},[i,u]),!e&&c)return(0,q.jsxs)(`div`,{className:`flex h-screen items-center justify-center text-slate-400`,children:[(0,q.jsx)(`div`,{className:`h-6 w-6 animate-spin rounded-full border-2 border-slate-200 border-t-slate-600 mr-2`}),`Loading App...`]});let f;return f=c?(0,q.jsxs)(`div`,{className:`flex flex-col items-center justify-center h-full text-slate-400 min-h-[50vh]`,children:[(0,q.jsx)(`div`,{className:`h-6 w-6 animate-spin rounded-full border-2 border-slate-200 border-t-slate-600 mr-2`}),`Loading Page...`]}):o||!n?(0,q.jsxs)(`div`,{className:`flex flex-col items-center justify-center h-full p-12 text-red-600`,children:[(0,q.jsx)(`h1`,{className:`text-2xl font-bold`,children:`404`}),(0,q.jsx)(`p`,{className:`mt-2 text-slate-600`,children:o||`Page not found`}),(0,q.jsx)(`button`,{onClick:()=>d(`/`),className:`mt-4 text-blue-600 hover:underline`,children:`Go Home`})]}):(0,q.jsx)(Kp,{schema:n}),e?(0,q.jsx)(g5t,{app:e,currentPath:i,onNavigate:d,children:f}):(0,q.jsx)(`div`,{className:`object-ui-app`,children:f})}Zae.createRoot(document.getElementById(`root`)).render((0,q.jsx)(K.StrictMode,{children:(0,q.jsx)(y5t,{})}));export{X_t as A,_q as B,avt as C,IX as D,tvt as E,uX as F,Hse as G,jC as H,dX as I,Rp as J,_oe as K,cY as L,lX as M,pX as N,Q_t as O,fX as P,Z as R,mvt as S,LX as T,Cm as U,NC as V,vm as W,d as X,Zie as Y,s as Z,dvt as _,Gvt as a,zX as b,VX as c,uvt as d,ovt as f,pvt as g,RX as h,U1 as i,PX as j,FX as k,hvt as l,cvt as m,I3 as n,Uvt as o,svt as p,voe as q,j2 as r,HX as s,wVt as t,lvt as u,rvt as v,fvt as w,nvt as x,BX as y,Bq as z};
|