@object-ui/plugin-detail 17.6.0 → 17.7.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 +6741 -0
- package/README.md +404 -71
- package/dist/ActivityTimeline.d.ts.map +1 -1
- package/dist/CommentAttachment.d.ts.map +1 -1
- package/dist/ConcurrentUpdateDialog.d.ts +17 -1
- package/dist/ConcurrentUpdateDialog.d.ts.map +1 -1
- package/dist/DetailSection.d.ts.map +1 -1
- package/dist/DetailSectionNode.d.ts +97 -0
- package/dist/DetailSectionNode.d.ts.map +1 -0
- package/dist/DetailView.d.ts.map +1 -1
- package/dist/HeaderHighlight.d.ts.map +1 -1
- package/dist/HistoryTimeline.d.ts +8 -1
- package/dist/HistoryTimeline.d.ts.map +1 -1
- package/dist/InlineEditSaveBar.d.ts +68 -0
- package/dist/InlineEditSaveBar.d.ts.map +1 -1
- package/dist/InlineFieldInput.d.ts +79 -6
- package/dist/InlineFieldInput.d.ts.map +1 -1
- package/dist/ReactionPicker.d.ts.map +1 -1
- package/dist/RecordActivityTimeline.d.ts +19 -4
- package/dist/RecordActivityTimeline.d.ts.map +1 -1
- package/dist/RecordChatterPanel.d.ts +6 -1
- package/dist/RecordChatterPanel.d.ts.map +1 -1
- package/dist/RecordComments.d.ts +1 -0
- package/dist/RecordComments.d.ts.map +1 -1
- package/dist/RecordDetailDrawer.d.ts +20 -6
- package/dist/RecordDetailDrawer.d.ts.map +1 -1
- package/dist/RecordDetailPanel.d.ts +101 -0
- package/dist/RecordDetailPanel.d.ts.map +1 -0
- package/dist/RecordMetaFooter.d.ts +1 -1
- package/dist/RecordMetaFooter.d.ts.map +1 -1
- package/dist/RelatedList.d.ts +83 -10
- package/dist/RelatedList.d.ts.map +1 -1
- package/dist/ThreadedReplies.d.ts +1 -1
- package/dist/ThreadedReplies.d.ts.map +1 -1
- package/dist/emptiness.d.ts +142 -0
- package/dist/emptiness.d.ts.map +1 -0
- package/dist/fieldEnrichment.d.ts +44 -4
- package/dist/fieldEnrichment.d.ts.map +1 -1
- package/dist/headerColor.d.ts +20 -0
- package/dist/headerColor.d.ts.map +1 -0
- package/dist/index.d.ts +94 -77
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4883 -5255
- package/dist/index.umd.cjs +2 -5
- package/dist/renderers/record-activity.d.ts.map +1 -1
- package/dist/renderers/record-alert.d.ts +23 -3
- package/dist/renderers/record-alert.d.ts.map +1 -1
- package/dist/renderers/record-alert.readProps.d.ts +40 -0
- package/dist/renderers/record-alert.readProps.d.ts.map +1 -0
- package/dist/renderers/record-chatter.d.ts.map +1 -1
- package/dist/renderers/record-details.d.ts +2 -0
- package/dist/renderers/record-details.d.ts.map +1 -1
- package/dist/renderers/record-highlights.d.ts.map +1 -1
- package/dist/renderers/record-history.d.ts +1 -1
- package/dist/renderers/record-history.d.ts.map +1 -1
- package/dist/renderers/record-path.d.ts.map +1 -1
- package/dist/renderers/record-quick-actions.d.ts +16 -6
- package/dist/renderers/record-quick-actions.d.ts.map +1 -1
- package/dist/renderers/record-reference-rail.d.ts +40 -0
- package/dist/renderers/record-reference-rail.d.ts.map +1 -1
- package/dist/renderers/record-related-list.d.ts +37 -3
- package/dist/renderers/record-related-list.d.ts.map +1 -1
- package/dist/renderers/recordActivityFeed.d.ts +272 -20
- package/dist/renderers/recordActivityFeed.d.ts.map +1 -1
- package/dist/renderers/recordComponentAria.d.ts +44 -0
- package/dist/renderers/recordComponentAria.d.ts.map +1 -0
- package/dist/renderers/relatedListActions.d.ts +102 -0
- package/dist/renderers/relatedListActions.d.ts.map +1 -0
- package/dist/summaryChipPercent.d.ts +83 -0
- package/dist/summaryChipPercent.d.ts.map +1 -0
- package/dist/summaryChipRenderers.d.ts +83 -0
- package/dist/summaryChipRenderers.d.ts.map +1 -0
- package/dist/synth/buildDefaultPageSchema.d.ts +98 -17
- package/dist/synth/buildDefaultPageSchema.d.ts.map +1 -1
- package/dist/useDetailTranslation.d.ts.map +1 -1
- package/dist/useRecordEditable.d.ts +1 -1
- package/dist/useRecordEditable.d.ts.map +1 -1
- package/package.json +19 -18
- package/dist/CommentInput.d.ts +0 -24
- package/dist/CommentInput.d.ts.map +0 -1
- package/dist/DiffView.d.ts +0 -24
- package/dist/DiffView.d.ts.map +0 -1
- package/dist/InlineCreateRelated.d.ts +0 -32
- package/dist/InlineCreateRelated.d.ts.map +0 -1
- package/dist/MentionAutocomplete.d.ts +0 -43
- package/dist/MentionAutocomplete.d.ts.map +0 -1
- package/dist/PointInTimeRestore.d.ts +0 -28
- package/dist/PointInTimeRestore.d.ts.map +0 -1
- package/dist/RecordNavigationEnhanced.d.ts +0 -18
- package/dist/RecordNavigationEnhanced.d.ts.map +0 -1
- package/dist/RelationshipGraph.d.ts +0 -23
- package/dist/RelationshipGraph.d.ts.map +0 -1
package/dist/index.umd.cjs
CHANGED
|
@@ -1,5 +1,2 @@
|
|
|
1
|
-
(function(e,t){typeof exports==`object`&&typeof module<`u`?t(exports,require("react"),require("@object-ui/core"),require("@object-ui/react"),require("@object-ui/fields"),require("@object-ui/components"),require("lucide-react"),require("@object-ui/i18n"),require("react-router-dom"),require("react/jsx-runtime"),require("@object-ui/permissions"),require("@object-ui/types"),require("@objectstack/spec/data")):typeof define==`function`&&define.amd?define([`exports`,`react`,`@object-ui/core`,`@object-ui/react`,`@object-ui/fields`,`@object-ui/components`,`lucide-react`,`@object-ui/i18n`,`react-router-dom`,`react/jsx-runtime`,`@object-ui/permissions`,`@object-ui/types`,`@objectstack/spec/data`],t):(e=typeof globalThis<`u`?globalThis:e||self,t(e.ObjectUIPluginDetail={},e.React,e.ObjectUICore,e.ObjectUIReact,e.ObjectUIFields,e.ObjectUIComponents,e.LucideReact,e._object_ui_i18n,e.react_router_dom,e.jsxRuntime,e._object_ui_permissions,e.ObjectUITypes,e._objectstack_spec_data))})(this,function(e,t,n,r,i,a,o,s,c,l,u,d,f){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var p=Object.create,m=Object.defineProperty,h=Object.getOwnPropertyDescriptor,g=Object.getOwnPropertyNames,_=Object.getPrototypeOf,v=Object.prototype.hasOwnProperty,y=(e,t,n,r)=>{if(t&&typeof t==`object`||typeof t==`function`)for(var i=g(t),a=0,o=i.length,s;a<o;a++)s=i[a],!v.call(e,s)&&s!==n&&m(e,s,{get:(e=>t[e]).bind(null,s),enumerable:!(r=h(t,s))||r.enumerable});return e};t=((e,t,n)=>(n=e==null?{}:p(_(e)),y(t||!e||!e.__esModule||!v.call(e,`default`)?m(n,`default`,{value:e,enumerable:!0}):n,e)))(t,1);var b=new Set([`textarea`,`markdown`,`html`,`grid`,`richtext`,`field:textarea`,`field:markdown`,`field:html`,`field:grid`,`field:richtext`]);function x(e){return b.has(e)}function S(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 C(e,t){return t<=1?e:e.map(e=>e.span===void 0&&e.type&&x(e.type)?{...e,span:t}:e)}function w(e,t,n){if(t!==void 0)return{fields:C(e,t),columns:t};let r=S(e.length,n);return{fields:C(e,r),columns:r}}var T=s.createSafeTranslation,E={"common.resizeDrawer":`Resize drawer`,"detail.back":`Back`,"detail.edit":`Edit`,"detail.editInline":`Edit`,"detail.save":`Save`,"detail.saveChanges":`Save changes`,"detail.saving":`Saving…`,"detail.editFieldsInline":`Edit fields`,"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.addReaction":`Add reaction`,"detail.emojiPicker":`Emoji picker`,"detail.reactionCount":`{{emoji}} {{count}} reactions`,"detail.reactionCountOne":`{{emoji}} {{count}} reaction`,"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":`+ {{count}} empty`,"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.lockedByApproval":`Locked for approval`,"detail.lockedTooltip":`This record has a pending approval request; editing is locked`,"detail.approvalPendingEditable":`In approval · editable`,"detail.approvalPendingTooltip":`This record has a pending approval request; this step still allows editing`,"detail.approvalProgress":`Approvals — {{got}} of {{need}}`,"detail.approvalProgressGroups":`Sign-off — {{got}} of {{need}} groups`,"detail.approvalProgressLabel":`Approval progress`,"detail.cancelApproval":`Recall approval`,"detail.cancelApprovalInFlight":`Recalling…`,"detail.cancelApprovalTooltip":`Recall the pending approval request to unlock this record`,"detail.cancelApprovalTooltipUnlocked":`Recall the pending approval request`,"detail.cancelApprovalFailed":`Failed to recall approval`,"detail.cancelApprovalUnavailable":`Recalling approvals is not supported on this data source`,"detail.pathLabel":`Record path`,"detail.pathStageCompleted":`{{stage}}, completed`,"detail.pathStageCurrent":`{{stage}}, current stage`,"detail.pathStageUpcoming":`{{stage}}, upcoming`,"detail.pathStageLostCurrent":`{{stage}}, closed lost, current stage`,"detail.pathStageLostUpcoming":`{{stage}}, closed lost, not reached`,"detail.pathStageWonUpcoming":`{{stage}}, goal stage, not reached`},D=T(E,`detail.back`);function O(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 k(e){let t=O(e);return t==null||t===``?0:Array.isArray(t)?t.length:typeof t==`object`?Object.keys(t).length:1}function A({value:e,field:t}){let{t:n}=D(),o=(0,r.useRecordContext)(),{appName:s}=(0,c.useParams)(),u=t?.name||``,d=o?.data?.name,f=s&&d?`/apps/${s}/metadata/permission/${encodeURIComponent(String(d))}`:null,p=k(e),m=p===0,h=(()=>{if(m)return(0,l.jsx)(`span`,{className:`text-muted-foreground`,children:n(`perm.facet.none`,{defaultValue:`None`})});if(u===`system_permissions`){let t=(0,i.parseCapabilityNames)(e),r=t.slice(0,6),o=t.length-r.length;return(0,l.jsxs)(`span`,{className:`inline-flex flex-wrap items-center gap-1`,children:[r.map(e=>(0,l.jsx)(a.Badge,{variant:`outline`,children:e},e)),o>0&&(0,l.jsx)(`span`,{className:`text-muted-foreground text-xs`,children:n(`perm.facet.more`,{count:o,defaultValue:`+${o} more`})})]})}let t=(()=>{switch(u){case`object_permissions`:return n(`perm.facet.objects`,{count:p,defaultValue:`${p} object${p===1?``:`s`}`});case`field_permissions`:return n(`perm.facet.fields`,{count:p,defaultValue:`${p} field rule${p===1?``:`s`}`});case`row_level_security`:return n(`perm.facet.rls`,{count:p,defaultValue:`${p} RLS polic${p===1?`y`:`ies`}`});case`tab_permissions`:return n(`perm.facet.tabs`,{count:p,defaultValue:`${p} tab rule${p===1?``:`s`}`});case`admin_scope`:return n(`perm.facet.adminScope`,{defaultValue:`Delegated admin configured`});default:return String(p)}})();return(0,l.jsx)(`span`,{className:`text-foreground`,children:t})})();return(0,l.jsxs)(`span`,{className:`inline-flex flex-wrap items-center gap-x-2 gap-y-1 text-sm`,children:[h,f?(0,l.jsx)(c.Link,{to:f,className:`text-primary hover:underline whitespace-nowrap`,children:n(`perm.facet.designInStudio`,{defaultValue:`Design in Studio →`})}):(0,l.jsx)(`span`,{className:`text-muted-foreground/60 whitespace-nowrap`,children:n(`perm.facet.designInStudioHint`,{defaultValue:`Design in Studio`})})]})}var j=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`]),M=new Set([`formula`,`summary`,`rollup`,`autonumber`,`auto_number`]);function N(e,t){return M.has(e)||M.has(t)}var P=new Set([`image`,`avatar`,`signature`,`file`,`video`,`audio`]);function F(e,t){return I(e)||I(t)}function I(e){return typeof e!=`string`||P.has(e)?!1:(0,i.isInlineExcludedFieldType)(e)}var L=`options.currency.currencyConfig.precision.scale.min.max.step.format.widget.dueLike.multiple.reference_field.display_field.displayField.description_field.descriptionField.id_field.allow_create.allowCreate.lookup_columns.lookupColumns.lookup_page_size.lookupPageSize.lookup_filters.lookupFilters.picker.subtitle.avatar_field.avatarField.depends_on.dependsOn`.split(`.`);function R(e,t){let n={...e};if(!t)return n;!n.type&&t.type&&(n.type=t.type);for(let e of L){let r=t[e];r!==void 0&&n[e]===void 0&&(n[e]=r)}let r=t.reference_to||t.reference;return r&&n.reference_to===void 0&&(n.reference_to=r),n}var ee=`inline-plain-text-input`,z=new Set([`text`,`textarea`,`email`,`phone`,`url`]);function te(e){return e?i.FORM_FIELD_TYPES.includes(e)||(0,i.mapFieldTypeToFormType)(e)!==`field:text`:!1}function B(e){let t=e?.type;return!t||z.has(t)?!0:t===`select`&&!e.multiple}function V(e){if(e==null)return e;if(Array.isArray(e))return e.map(V);if(typeof e==`object`){let t=e;return t.id??t._id??t.value??``}return e}var H=({field:e,value:t,onChange:n,dataSource:r,autoFocus:a})=>{let o=e.type;if(e.widget===`permission-facet-link`)return(0,l.jsx)(A,{value:t,field:e});if(typeof o==`string`&&i.RETIRED_FIELD_TYPES[o])return(0,l.jsx)(i.RetiredFieldTombstone,{field:e});let s=o===`multiselect`||!!e.multiple;if((o===`select`||o===`multiselect`)&&Array.isArray(e.options)&&e.options.length>0)return s?(0,l.jsx)(i.SelectField,{field:{...e,multiple:!0},value:Array.isArray(t)?t:t==null||t===``?[]:[t],onChange:e=>n(e)}):(0,l.jsx)(i.SelectField,{field:e,value:t==null?``:String(t),onChange:e=>n(e)});if(o===`boolean`)return(0,l.jsx)(i.BooleanField,{field:e,value:!!t,onChange:e=>n(e)});if(o===`image`)return(0,l.jsx)(i.ImageField,{field:e,value:t,onChange:e=>n(e)});if(o===`avatar`)return(0,l.jsx)(i.AvatarField,{field:e,value:t,onChange:e=>n(e)});if(o===`signature`)return(0,l.jsx)(i.SignatureField,{field:e,value:t,onChange:e=>n(e)});if(o===`file`||o===`video`||o===`audio`)return(0,l.jsx)(i.FileField,{field:e,value:t,onChange:e=>n(e)});let c=o===`user`,u=o===`lookup`||o===`master_detail`||o===`tree`||!!e.reference_to&&!M.has(o);if(c||u)return(0,l.jsx)(c?i.UserField:i.LookupField,{field:e,value:t,onChange:e=>n(e),dataSource:r});if(o===`number`)return(0,l.jsx)(i.NumberField,{field:e,value:t,onChange:e=>n(e),autoFocus:a});if(o===`currency`)return(0,l.jsx)(i.CurrencyField,{field:e,value:t,onChange:e=>n(e),autoFocus:a});if(o===`percent`)return(0,l.jsx)(i.PercentField,{field:e,value:t,onChange:e=>n(e),autoFocus:a});if(o===`address`)return(0,l.jsx)(i.AddressField,{field:e,value:t,onChange:e=>n(e),autoFocus:a});if(o===`location`)return(0,l.jsx)(i.LocationField,{field:e,value:t,onChange:e=>n(e),autoFocus:a});if(o===`geolocation`)return(0,l.jsx)(i.GeolocationField,{field:e,value:t,onChange:e=>n(e),autoFocus:a});let d=o===`date`||o===`datetime`;if(!d&&!B(e)&&te(o)&&(0,i.hasFieldEditWidget)(o))return(0,l.jsx)(i.FieldEditWidget,{field:e,value:t,onChange:e=>n(e),autoFocus:a});let f=d?`date`:`text`,p=t==null?``:d?(()=>{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`?(0,i.coerceToSafeValue)(t)??``:t);return(0,l.jsx)(`input`,{type:f,"data-testid":d?void 0:ee,autoFocus:a,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:p,onChange:e=>{let t=e.target.value;n(d&&t?new Date(t+`T00:00:00`).toISOString():t)}})},ne=({name:e})=>/^[a-z0-9][a-z0-9-]*$/i.test(e)?(0,l.jsx)(a.LazyIcon,{name:e,className:`h-4 w-4 shrink-0 text-muted-foreground`,"aria-hidden":!0}):(0,l.jsx)(`span`,{className:`text-muted-foreground`,children:e});function U(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 W=({section:e,data:n,className:s,objectSchema:c,objectName:u,isEditing:d=!1,onFieldChange:f,onEnterInlineEdit:p,autoFocusField:m,dataSource:h,virtualScroll:g})=>{let[_,v]=t.useState(e.defaultCollapsed??!1),[y,b]=t.useState(null),[x,S]=t.useState(void 0),[C,T]=t.useState(!1),{t:E}=D(),{fieldLabel:O,translateOptions:k}=(0,r.useSafeFieldLabel)(),M=t.useCallback((e,t)=>{let n=t==null?``:String(t);navigator.clipboard.writeText(n).then(()=>{b(e),setTimeout(()=>b(null),2e3)})},[]),P=t.useCallback(e=>{let t=n?.[e.name]??e.value;return t==null||t===``},[n]),I=t.useMemo(()=>e.fields.filter(P).length,[e.fields,P]),L=(0,a.useIsMobile)(),ee=L?3:4,z=L?.2:.25,te=e.fields.length-I,B=!e.hideEmpty&&!d&&e.fields.length>=ee&&I/e.fields.length>=z&&te>0,V=!C&&(e.hideEmpty||B)?e.fields.filter(e=>!P(e)):e.fields,{fields:W,columns:G}=w(V,e.columns),re=Math.min(G,Math.max(1,V.length)),ie=e=>{let t=n?.[e.name]??e.value;if(e.render)return(0,l.jsx)(r.SchemaRenderer,{schema:(0,r.toRenderableSchema)(e.render),data:{...n,value:t}});let s=U(e.span,re),g=c?.fields?.[e.name],_=R(e,g);u&&Array.isArray(_.options)&&_.options.length>0&&(_.options=k(u,e.name,_.options));let v=N(e.type,g?.type),b=e.readonly===!0||g?.readonly===!0,x=j.has(e.name),S=F(e.type,g?.type),C=!b&&!v&&!x&&!S,w=C&&!!p,T=(()=>{if((_.widget||e.widget)===`permission-facet-link`)return(0,l.jsx)(A,{value:t,field:_});if(t==null||t===``)return(0,l.jsx)(`span`,{className:`text-muted-foreground/60 text-sm select-none`,"aria-label":E(`detail.noValue`,{defaultValue:`No value`}),title:E(`detail.noValue`,{defaultValue:`No value`}),children:`—`});let n=(0,i.resolveCellRendererType)(_)||e.type;if(n){let e=(0,i.getCellRenderer)(n);if(e)return(0,l.jsx)(e,{value:t,field:_})}return String(t)})(),D=t!=null&&t!==``,P=D&&!w,I=y===e.name,ee=O(u||``,e.name,e.label||e.name);return L&&!(d&&C)?(0,l.jsxs)(`div`,{className:(0,a.cn)(`flex items-baseline justify-between gap-4 py-2.5 min-h-[44px] group`,D&&`cursor-pointer active:bg-muted/40 transition-colors`),onClick:D?()=>M(e.name,t):void 0,onKeyDown:D?n=>{(n.key===`Enter`||n.key===` `)&&(n.preventDefault(),M(e.name,t))}:void 0,role:D?`button`:void 0,tabIndex:D?0:void 0,children:[(0,l.jsx)(`span`,{className:`text-[15px] text-muted-foreground shrink-0`,children:ee}),(0,l.jsx)(`span`,{className:`text-[15px] text-foreground text-right break-words min-w-0 leading-snug`,children:T})]},e.name):(0,l.jsxs)(`div`,{className:(0,a.cn)(`space-y-1.5 group min-w-0`,s),children:[(0,l.jsx)(`div`,{className:`text-xs font-medium text-muted-foreground uppercase tracking-wide`,children:O(u||``,e.name,e.label||e.name)}),d&&C?(0,l.jsx)(`div`,{className:`min-h-[44px] sm:min-h-0`,children:(0,l.jsx)(H,{field:_,value:t,onChange:t=>f?.(e.name,t),dataSource:h,autoFocus:m===e.name})}):(0,l.jsxs)(`div`,{className:(0,a.cn)(`flex items-start justify-between gap-2 min-h-[44px] sm:min-h-0 rounded-md`,P&&`cursor-pointer active:bg-muted/60 transition-colors`,w&&`cursor-pointer hover:bg-muted/40 transition-colors -mx-1.5 px-1.5`),onClick:P?()=>M(e.name,t):void 0,onDoubleClick:w?()=>p?.(e.name):void 0,onKeyDown:P?n=>{(n.key===`Enter`||n.key===` `)&&(n.preventDefault(),M(e.name,t))}:void 0,role:P?`button`:void 0,tabIndex:P?0:void 0,title:w?E(`detail.editInlineHint`):void 0,children:[(0,l.jsx)(`div`,{className:`text-sm flex-1 min-w-0 break-words py-1`,children:T}),w?(0,l.jsx)(a.TooltipProvider,{children:(0,l.jsxs)(a.Tooltip,{children:[(0,l.jsx)(a.TooltipTrigger,{asChild:!0,children:(0,l.jsx)(a.Button,{variant:`ghost`,size:`icon`,className:`h-6 w-6 opacity-0 group-hover:opacity-100 transition-opacity shrink-0`,"aria-label":E(`detail.editInlineHint`),onClick:t=>{t.stopPropagation(),p?.(e.name)},children:(0,l.jsx)(o.Pencil,{className:`h-3 w-3`})})}),(0,l.jsx)(a.TooltipContent,{children:E(`detail.editInlineHint`)})]})}):D?(0,l.jsx)(a.TooltipProvider,{children:(0,l.jsxs)(a.Tooltip,{children:[(0,l.jsx)(a.TooltipTrigger,{asChild:!0,children:(0,l.jsx)(a.Button,{variant:`ghost`,size:`icon`,className:`h-6 w-6 opacity-0 group-hover:opacity-100 transition-opacity shrink-0`,onClick:n=>{n.stopPropagation(),M(e.name,t)},children:I?(0,l.jsx)(o.Check,{className:`h-3 w-3 text-green-600`}):(0,l.jsx)(o.Copy,{className:`h-3 w-3`})})}),(0,l.jsx)(a.TooltipContent,{children:E(I?`detail.copied`:`detail.copyToClipboard`)})]})}):null]})]},e.name)},ae=g?.enabled===!0,oe=g?.batchSize??20;if(t.useEffect(()=>{if(!ae){S(void 0);return}if(W.length<=oe){S(void 0);return}S(oe);let e=setTimeout(()=>S(void 0),100);return()=>clearTimeout(e)},[ae,W.length,oe]),V.length===0&&I===e.fields.length)return null;let se=x===void 0?W:W.slice(0,x),ce=I>0&&(e.hideEmpty||B),le=(0,l.jsxs)(l.Fragment,{children:[L?(0,l.jsx)(`div`,{className:`flex flex-col divide-y divide-border/60`,children:se.map(ie)}):(0,l.jsx)(`div`,{className:(0,a.cn)(`grid gap-3 sm:gap-4`,re===1?`grid-cols-1`:re===2?`grid-cols-1 md:grid-cols-2`:re===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:se.map(ie)}),ce&&(0,l.jsx)(`div`,{className:`mt-3 -ml-2`,children:(0,l.jsxs)(a.Button,{type:`button`,variant:`ghost`,size:`sm`,onClick:()=>T(e=>!e),className:`h-7 px-2 text-xs text-muted-foreground hover:text-foreground`,children:[C?(0,l.jsx)(o.EyeOff,{className:`h-3.5 w-3.5 mr-1.5`}):(0,l.jsx)(o.Eye,{className:`h-3.5 w-3.5 mr-1.5`}),C?E(`detail.hideEmptyFields`,{defaultValue:`Hide empty fields`}):E(`detail.showEmptyFields`,{count:I,defaultValue:`Show ${I} empty field${I===1?``:`s`}`})]})})]});return!e.title&&!e.collapsible&&e.showBorder===!1?(0,l.jsx)(`div`,{className:(0,a.cn)(s),children:le}):e.collapsible?(0,l.jsx)(a.Collapsible,{open:!_,onOpenChange:e=>v(!e),className:s,children:(0,l.jsxs)(a.Card,{children:[(0,l.jsx)(a.CollapsibleTrigger,{asChild:!0,children:(0,l.jsxs)(a.CardHeader,{className:(0,a.cn)(`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,l.jsxs)(a.CardTitle,{className:`flex items-center justify-between text-base font-semibold tracking-tight`,children:[(0,l.jsxs)(`div`,{className:`flex items-center gap-2`,children:[e.icon&&(0,l.jsx)(ne,{name:e.icon}),(0,l.jsx)(`span`,{children:e.title})]}),(0,l.jsx)(`div`,{className:`flex items-center gap-2`,children:_?(0,l.jsx)(o.ChevronRight,{className:`h-4 w-4 text-muted-foreground`}):(0,l.jsx)(o.ChevronDown,{className:`h-4 w-4 text-muted-foreground`})})]}),e.description&&!_&&(0,l.jsx)(`p`,{className:`text-xs text-muted-foreground mt-1`,children:e.description})]})}),(0,l.jsx)(a.CollapsibleContent,{children:(0,l.jsx)(a.CardContent,{className:`pt-3 sm:pt-4 px-3 sm:px-6 pb-4 sm:pb-5`,children:le})})]})}):(0,l.jsxs)(a.Card,{className:(0,a.cn)(e.showBorder===!1?`border-none shadow-none`:``,s),children:[e.title&&(0,l.jsxs)(a.CardHeader,{className:(0,a.cn)(`py-3 px-4 sm:py-4 sm:px-6`,e.headerColor&&`bg-${e.headerColor}`),children:[(0,l.jsx)(a.CardTitle,{className:`flex items-center justify-between text-base font-semibold tracking-tight`,children:(0,l.jsxs)(`div`,{className:`flex items-center gap-2`,children:[e.icon&&(0,l.jsx)(ne,{name:e.icon}),(0,l.jsx)(`span`,{children:e.title})]})}),e.description&&(0,l.jsx)(`p`,{className:`text-xs text-muted-foreground mt-1`,children:e.description})]}),(0,l.jsx)(a.CardContent,{className:`pt-3 sm:pt-4 px-3 sm:px-6 pb-4 sm:pb-5`,children:le})]})},G=({tabs:e,data:n,className:i})=>{let[o,s]=t.useState(e[0]?.key),c=e.filter(e=>typeof e.visible==`boolean`?e.visible:(e.visible,!0));return(0,l.jsxs)(a.Tabs,{value:o,onValueChange:s,className:i,children:[(0,l.jsx)(a.TabsList,{className:`w-full justify-start border-b rounded-none bg-transparent p-0`,children:c.map(e=>(0,l.jsx)(a.TabsTrigger,{value:e.key,className:`relative rounded-none border-b-2 border-transparent data-[state=active]:border-primary data-[state=active]:bg-transparent`,children:(0,l.jsxs)(`div`,{className:`flex items-center gap-2`,children:[e.icon&&(0,l.jsx)(`span`,{children:e.icon}),(0,l.jsx)(`span`,{children:e.label}),e.badge&&(0,l.jsx)(a.Badge,{variant:`secondary`,className:`ml-1`,children:e.badge})]})},e.key))}),c.map(e=>(0,l.jsx)(a.TabsContent,{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,l.jsx)(t.Suspense,{fallback:null,children:Array.isArray(e.content)?(0,l.jsx)(`div`,{className:`space-y-4`,children:e.content.map((e,t)=>(0,l.jsx)(r.SchemaRenderer,{schema:(0,r.toRenderableSchema)(e),data:n},t))}):(0,l.jsx)(r.SchemaRenderer,{schema:(0,r.toRenderableSchema)(e.content),data:n})})},e.key))]})};function re(e){if(!e)return o.Inbox;let t=e.split(/[-_\s]/).filter(Boolean).map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(``);return o.icons[t]||o.Inbox}function ie(e,t){let r=e?.id??e?._id;if(t){let i=(0,n.getRecordDisplayName)(t,e),a=i===`Untitled`||r!=null&&i===`Record #${r}`;if(i&&!a)return i}return e?.full_name||e?.fullname||e?.display_name||e?.name||e?.subject||e?.title||e?.label||e?.code||e?.email||(r==null?void 0:String(r))}function ae(e){if(!e)return[];if(typeof e==`string`){let t=e.trim();return t?t.startsWith(`-`)?[{field:t.slice(1),order:`desc`}]:[{field:t,order:`asc`}]:[]}return e.filter(e=>!!e?.field)}var oe=({action:e,onToolbarAction:t})=>{let n=e.visible,i=(0,r.useCondition)((0,r.toPredicateInput)(n));if(n&&!i)return null;let o=e.icon?re(e.icon):null;return(0,l.jsxs)(a.Button,{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:[o&&(0,l.jsx)(o,{className:`h-3.5 w-3.5`}),e.label||e.name]})},se=({title:e,type:s,api:c,data:d,schema:f,columns:p,className:m,dataSource:h,objectName:g,onNew:_,newDisabled:v,onViewAll:y,onRowEdit:b,onRowDelete:x,onRowClick:S,rowActions:C,onRowAction:w,toolbarActions:T,onToolbarAction:E,add:O,maxColumns:k=6,pageSize:A,defaultSort:j,sortable:M=!1,filter:N,filterable:P=!1,collapsible:F=!1,defaultCollapsed:I=!1,referenceField:L,parentId:R,icon:ee})=>{let z=d!==void 0,te=d??[],[B,V]=t.useState(te),[H,ne]=t.useState(()=>!!c&&!z),[U,W]=t.useState(0),[G,se]=t.useState(null),[ce,le]=t.useState(`asc`),[ue,de]=t.useState(``),[fe,pe]=t.useState(null),[me,he]=t.useState(!1),[K,ge]=t.useState(null),[_e,ve]=t.useState(I),[ye,be]=t.useState(!1),[xe,Se]=t.useState(!1),[Ce,we]=t.useState(null),[q,Te]=t.useState(0),[Ee,De]=t.useState({}),{t:J}=D(),{fieldLabel:Oe}=(0,r.useSafeFieldLabel)(),Y=A&&A>0?A:0,ke=P&&ue!==``,X=!z&&!!c&&Y>0&&!!h&&typeof h.find==`function`&&!ke,Ae=X?U:0,je=X?G:null,Me=X?ce:`asc`,Ne=JSON.stringify(j??null),Pe=t.useMemo(()=>ae(j),[Ne]),Fe=JSON.stringify(N??null),Ie=t.useMemo(()=>(0,n.toFilterNode)(N),[Fe]);t.useEffect(()=>{z&&V(d??[])},[d,z]),t.useEffect(()=>{c&&h?.getObjectSchema&&h.getObjectSchema(c).then(ge).catch(e=>{console.warn(`[RelatedList] Failed to fetch schema for ${c}:`,e)})},[c,h]);let Z=O?.picker?.object,[Q,Le]=t.useState(null);t.useEffect(()=>{if(!ye||!Z||Q||!h?.getObjectSchema)return;let e=!1;return h.getObjectSchema(Z).then(t=>{e||Le(t)}).catch(e=>{console.warn(`[RelatedList] Failed to fetch schema for ${Z}:`,e)}),()=>{e=!0}},[ye,Z,Q,h]);let Re=O?.picker?.labelField||`name`,ze=t.useMemo(()=>{let e=(0,i.deriveLookupColumns)(Q,{displayField:Re});return e.length>0?e:void 0},[Q,Re]);t.useEffect(()=>{!O||Z||console.warn(`[RelatedList] "${c||g||`related list`}" declares add without add.picker.object — the Add affordance is not rendered. add.picker is required by the spec (RecordRelatedListProps.add): set add.picker.object to the object the picker should list.`)},[O,Z,c,g]),t.useEffect(()=>{let e=!1;if(c&&!z){if(!(L&&R!=null&&R!==``)){c&&(R==null||R===``)&&!L&&console.warn(`[RelatedList] "${c}" has no referenceField/parentId — refusing to fetch all rows. Pass relationshipField + parentId to scope the query.`),V([]),pe(null),he(!1),ne(!1);return}ne(!0);let t={[L]:R},r=Ie===void 0?t:(0,n.mergeFilterNodes)(t,Ie);if(h&&typeof h.find==`function`){let t={$filter:r};if(X){t.$top=Y,t.$skip=Ae*Y;let e=je?[{field:je,order:Me}]:Pe;e.length>0&&(t.$orderby=e)}h.find(c,t).then(t=>{if(e)return;let n=Array.isArray(t),r=n?t:Array.isArray(t?.data)?t.data:[];if(V(r),X){let e=!n&&typeof t?.total==`number`?t.total:null;pe(e),he(!n&&typeof t?.hasMore==`boolean`?t.hasMore:r.length===Y)}else pe(null),he(!1);ne(!1)}).catch(t=>{console.error(`Failed to fetch related data:`,t),e||ne(!1)})}else if(Ie!==void 0)console.warn(`[RelatedList] "${c}" declares a filter but has no dataSource adapter — the raw-URL fallback cannot express it, so no rows are fetched. Pass a dataSource (RecordContext) to use a filtered related list.`),V([]),pe(null),he(!1),ne(!1);else{let t=new URLSearchParams({[`filter[${L}]`]:String(R)}).toString();fetch(`${c}?${t}`).then(e=>e.json()).then(t=>{if(e)return;let n=Array.isArray(t)?t:t?.data||[];V(n),pe(null),he(!1)}).catch(e=>{console.error(`Failed to fetch related data:`,e)}).finally(()=>{e||ne(!1)})}}return()=>{e=!0}},[c,z,h,L,R,q,X,Y,Ae,je,Me,Pe,Ie]),t.useEffect(()=>{!X||H||U>0&&B.length===0&&W(e=>Math.max(0,e-1))},[X,H,B,U]),t.useEffect(()=>{W(0)},[c,L,R,Fe]),t.useEffect(()=>{if(!c||z)return;let e=e=>{let t=e.detail||{};t.objectName&&t.objectName!==`*`&&t.objectName!==c||Te(e=>e+1)};return window.addEventListener(`objectui:related-changed`,e),()=>window.removeEventListener(`objectui:related-changed`,e)},[c,z]),t.useEffect(()=>{if(!h?.find||!K?.fields||!B.length)return;let e=K.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 B){let t=e?.[n];t!=null&&(typeof t==`string`&&t?i.add(t):typeof t==`number`&&i.add(String(t)))}let a=Ee[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})=>Promise.all([h.find(t,{$filter:{id:{$in:n}},$top:n.length}),typeof h.getObjectSchema==`function`?h.getObjectSchema(t).catch(()=>void 0):Promise.resolve(void 0)]).then(([t,n])=>{let r=Array.isArray(t)?t:t?.data||[],i={};for(let e of r){let t=e?.id||e?._id;t&&(i[String(t)]=ie(e,n)??String(t))}return{fieldName:e,map:i}}).catch(t=>(console.warn(`[RelatedList] Failed to resolve lookups for ${e}:`,t),{fieldName:e,map:{}})))).then(e=>{n||De(t=>{let n={...t};for(let{fieldName:t,map:r}of e)n[t]={...n[t]||{},...r};return n})}),()=>{n=!0}},[h,K,B]);let Be=t.useMemo(()=>{if(X||!ue)return B;let e=ue.toLowerCase();return B.filter(t=>Object.values(t).some(t=>t!=null&&String(t).toLowerCase().includes(e)))},[B,ue,X]),Ve=t.useMemo(()=>{if(X||!G)return Be;let e=Ee[G],t=Be.map(t=>({row:t,key:(0,n.getSortValue)(t[G],{labels:e})}));return t.sort((e,t)=>{let r=(0,n.compareSortValues)(e.key,t.key);return ce===`asc`?r:-r}),t.map(e=>e.row)},[Be,G,ce,X,Ee]),He=Y&&!X?Ve.slice(U*Y,(U+1)*Y):Ve,Ue=Y?X?fe==null?U+(me?2:1):Math.max(1,Math.ceil(fe/Y)):Math.max(1,Math.ceil(Ve.length/Y)):1,We=X?fe==null?me:(U+1)*Y<fe:U<Ue-1,Ge=Y>0&&(X?U>0||We:Ve.length>Y);t.useEffect(()=>{W(0)},[ue,G,ce]);let Ke=t.useCallback(e=>{W(0),G===e?le(e=>e===`asc`?`desc`:`asc`):(se(e),le(`asc`))},[G]),qe=t.useMemo(()=>G?[{field:G,order:ce}]:Pe,[G,ce,Pe]),Je=t.useCallback(e=>{let t=e[0];t&&(W(0),se(t.field),le(t.order))},[]),[Ye,Xe]=t.useState(null),Ze=t.useCallback(e=>{Xe(e)},[]),Qe=t.useCallback(async()=>{if(Ye)try{await x?.(Ye),Te(e=>e+1)}catch(e){console.error(`[RelatedList] remove failed`,e)}Xe(null)},[Ye,x]),$e=t.useCallback(async e=>{if(!O||!h||!c||L==null||R==null)return;let t=O.picker.valueField||`id`;Se(!0),we(null);try{for(let n of e||[]){let e=n?.[t]??n?.id;e!=null&&(O.linkField?await h.create?.(c,{[L]:R,[O.linkField]:e}):await h.update?.(O.picker.object,String(e),{[L]:R}))}Te(e=>e+1)}catch(e){let t=e?.body?.error??e?.error??e?.message??String(e);we(typeof t==`string`?t:`Failed to add`)}finally{Se(!1),be(!1)}},[O,h,c,L,R]),et=(0,u.usePermissions)(),tt=t.useMemo(()=>{let e=g||c||``,r=t=>!et?.isLoaded||!e?t:t.filter(t=>{let r=t?.accessorKey||(0,n.columnIdentity)(t);return!r||et.checkField(e,String(r),`read`)}),a=e=>L?e.filter(e=>(e?.accessorKey||(0,n.columnIdentity)(e))!==L):e,o=e=>e==null||typeof e==`string`&&e.trim()===``||Array.isArray(e)&&e.length===0,s=e=>B.length?e.filter(e=>{let t=e?.accessorKey||(0,n.columnIdentity)(e);return!t||B.some(e=>!o(e?.[t]))}):e,l=(e,n)=>{if(!n?.type)return;let r=(0,i.resolveCellRendererType)({type:n.type,format:n.format})||n.type,a=(0,i.getCellRenderer)(r);if(!a)return;let o=n.type===`lookup`||n.type===`master_detail`?Ee[e]:void 0,s=o&&Object.keys(o).length>0?Object.entries(o).map(([e,t])=>({value:e,label:t})):void 0,c={name:e,label:n.label||e,type:n.type,...(s||n.options)&&{options:s||n.options},...n.currency&&{currency:n.currency},...n.precision!==void 0&&{precision:n.precision},...n.scale!==void 0&&{scale:n.scale},...n.format&&{format:n.format},...(n.reference_to||n.reference)&&{reference_to:n.reference_to||n.reference},...n.reference_field&&{reference_field:n.reference_field}};return e=>e==null?t.createElement(`span`,{className:`text-muted-foreground/50 text-xs italic`},`—`):t.createElement(a,{value:e,field:c})},u=t=>{if(typeof t!=`string`){let e=t?.accessorKey||(0,n.columnIdentity)(t);if(!t||!e)return t;let r={};if(t.accessorKey||(r.accessorKey=e),!t.header){let e=(0,n.columnHeader)(t);e&&(r.header=e)}if(!t.cell&&!t.render){let t=K?.fields?.[e],n=t?l(String(e),t):void 0;n&&(r.cell=n)}return Object.keys(r).length>0?{...t,...r}:t}let r=K?.fields?.[t],i={accessorKey:t,header:r?.label||Oe(e,t,r)||t,fieldDef:r,fieldType:r?.type},a=r?l(t,r):void 0;return a&&(i.cell=a),i};if(p&&p.length>0)return s(r(a(p.map(u))));if(!K?.fields)return[];let d=Array.isArray(K.highlightFields)?K.highlightFields.filter(e=>typeof e==`string`&&e.length>0):[];if(d.length>0){let e=s(r(a(d.map(u))));if(e.length>0)return e.slice(0,Math.max(1,k))}let f=e,m=new Set([`richtext`,`markdown`,`html`,`json`]),h=[`name`,`full_name`,`fullname`,`title`,`subject`,`label`,`code`,`number`],_=Object.entries(K.fields).filter(([e,t])=>!(e.startsWith(`_`)||e===`id`||e===L||t?.hidden||t?.type&&m.has(t.type)||et?.isLoaded&&f&&!et.checkField(f,e,`read`))),v=new Set([`created_at`,`updated_at`,`created_by`,`updated_by`,`owner_id`,`organization_id`]);return _.sort(([e,t],[n,r])=>{let i=v.has(e);if(i!==v.has(n))return i?1:-1;let a=h.indexOf(e),o=h.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}),s(_.map(([e,t])=>{let n={accessorKey:e,header:Oe(f,e,t.label||e)};if(t.type){let r=l(e,t);r&&(n.cell=r)}return n})).slice(0,Math.max(1,k))},[p,K,g,c,Oe,L,B,k,Ee,et]),nt=t.useMemo(()=>X?tt.map(e=>{let t=e.accessorKey||(0,n.columnIdentity)(e),r=t?K?.fields?.[t]:void 0;return(0,n.isExpandableFieldType)(r)||(0,n.isUnmaterializedFieldType)(r)?{...e,sortable:!1}:e}):tt,[tt,X,K]),rt=!f&&(s===`grid`||s===`table`),it=Array.isArray(C)&&C.length>0,at=!!b||!!x||it,ot=(0,a.useIsMobile)(),st=t.useMemo(()=>{if(f)return f;if(ot&&(s===`grid`||s===`table`)){let e=tt[0]?.accessorKey||(0,n.columnIdentity)(tt[0]),t=tt.slice(1,4).map(e=>e.accessorKey||(0,n.columnIdentity)(e)).filter(Boolean);return{type:`object-gallery`,data:He,objectName:c,gallery:{titleField:e||`name`,visibleFields:t,cardSize:`medium`},onRowClick:S}}let e=(0,n.userActionPredicates)(K?.userActions?.edit),t=(0,n.userActionPredicates)(K?.userActions?.delete);switch(s){case`grid`:case`table`:return{type:`data-table`,data:He,columns:nt,pagination:!1,pageSize:Y||10,searchable:!1,exportable:!1,manualSorting:!0,sort:qe,onSortChange:Je,rowActions:at,onRowEdit:b,onRowDelete:x?Ze:void 0,rowEditPredicates:e,rowDeletePredicates:t,onRowClick:S,rowActionDefs:it?C:void 0,onRowActionDef:it?w:void 0};case`list`:return{type:`data-list`,data:He};default:return{type:`div`,children:`No view configured`}}},[s,He,nt,tt,f,Y,at,it,C,w,b,x,Ze,S,ot,c,K,qe,Je]),ct=F?`cursor-pointer select-none`:void 0,lt=F?()=>ve(e=>!e):void 0,ut=re(ee),dt=X&&fe!=null?fe:B.length,ft=!H&&B.length===0&&(!X||U===0),pt=P;return(0,l.jsxs)(a.Card,{className:(0,a.cn)(`shadow-none border-border/60 bg-transparent`,ft&&`bg-muted/10`,m),children:[(0,l.jsx)(a.CardHeader,{className:(0,a.cn)(`py-3 px-4 sm:py-3 min-h-12 sm:min-h-0`,ct),onClick:lt,children:(0,l.jsxs)(a.CardTitle,{className:`flex items-center justify-between gap-2 text-sm font-semibold`,children:[(0,l.jsxs)(`div`,{className:`flex items-center gap-2 min-w-0`,children:[F&&(_e?(0,l.jsx)(o.ChevronRight,{className:`h-3.5 w-3.5 text-muted-foreground shrink-0`}):(0,l.jsx)(o.ChevronDown,{className:`h-3.5 w-3.5 text-muted-foreground shrink-0`})),(0,l.jsx)(ut,{className:`h-4 w-4 text-muted-foreground shrink-0`,"aria-hidden":!0}),(0,l.jsx)(`span`,{className:(0,a.cn)(`truncate`,ft&&`text-muted-foreground font-medium`),children:e}),(0,l.jsx)(a.Badge,{variant:`secondary`,className:(0,a.cn)(`text-xs font-normal h-5 px-1.5`,dt===0&&`bg-muted text-muted-foreground`),"aria-label":`${dt} records`,children:dt}),ft&&(0,l.jsx)(`span`,{className:`text-xs text-muted-foreground/70 italic ml-1 truncate`,children:J(`detail.noRelatedRecords`)})]}),(0,l.jsxs)(`div`,{className:`flex items-center gap-1 shrink-0`,children:[E&&(T??[]).map(e=>(0,l.jsx)(oe,{action:e,onToolbarAction:E},e.name)),O&&Z&&h&&(0,l.jsxs)(a.Button,{variant:ft?`ghost`:`outline`,size:`sm`,disabled:xe,onClick:e=>{e.stopPropagation(),we(null),be(!0)},className:`gap-1 h-9 sm:h-7 text-xs shadow-none`,children:[(0,l.jsx)(o.Plus,{className:`h-3.5 w-3.5`}),O.label||J(`detail.add`,{defaultValue:`Add`})]}),_&&(0,l.jsxs)(a.Button,{variant:ft?`ghost`:`outline`,size:`sm`,disabled:v,"data-testid":`related-list-new`,onClick:e=>{e.stopPropagation(),_()},className:`gap-1 h-9 sm:h-7 text-xs shadow-none`,children:[(0,l.jsx)(o.Plus,{className:`h-3.5 w-3.5`}),J(`detail.new`)]})]})]})}),!_e&&!ft&&(0,l.jsxs)(a.CardContent,{className:(0,a.cn)(`pt-0 pb-4 px-4`),children:[pt&&(0,l.jsx)(`div`,{className:`mb-3`,children:(0,l.jsx)(a.Input,{placeholder:J(`detail.filterPlaceholder`),value:ue,onChange:e=>de(e.target.value),className:`h-8 text-sm`})}),M&&!rt&&tt&&tt.length>0&&B.length>0&&(0,l.jsx)(`div`,{className:`flex flex-wrap gap-1 mb-3`,children:tt.map(e=>{let t=e.accessorKey||(0,n.columnIdentity)(e);if(!t)return null;let r=K?.fields?.[t];if(X&&((0,n.isExpandableFieldType)(r)||(0,n.isUnmaterializedFieldType)(r)))return null;let i=e.header||e.label||t,s=G===t;return(0,l.jsxs)(a.Button,{variant:s?`secondary`:`ghost`,size:`sm`,className:`gap-1 h-7 text-xs`,onClick:()=>Ke(t),children:[(0,l.jsx)(o.ArrowUpDown,{className:`h-3 w-3`}),i,s&&(ce===`asc`?` ↑`:` ↓`)]},t)})}),H&&B.length===0?(0,l.jsx)(`div`,{className:`flex items-center justify-center py-6 text-muted-foreground text-sm`,children:J(`detail.loading`)}):(0,l.jsx)(`div`,{className:(0,a.cn)(H&&`opacity-60 pointer-events-none transition-opacity`),children:(0,l.jsx)(r.SchemaRenderer,{schema:st})}),Ge&&(0,l.jsxs)(`div`,{className:`flex items-center justify-between mt-3 pt-3 border-t`,children:[(0,l.jsxs)(a.Button,{variant:`outline`,size:`sm`,className:`h-7 text-xs gap-1`,disabled:U===0,onClick:()=>W(e=>Math.max(0,e-1)),children:[(0,l.jsx)(o.ChevronLeft,{className:`h-3 w-3`}),J(`detail.previousPage`)]}),(0,l.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:J(`detail.pageOf`,{current:U+1,total:Ue})}),(0,l.jsxs)(a.Button,{variant:`outline`,size:`sm`,className:`h-7 text-xs gap-1`,disabled:!We,onClick:()=>W(e=>We?e+1:e),children:[J(`detail.nextPage`),(0,l.jsx)(o.ChevronRight,{className:`h-3 w-3`})]})]}),y&&!ft&&Ge&&(0,l.jsx)(`div`,{className:`mt-3 pt-3 border-t flex justify-center`,children:(0,l.jsxs)(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),y()},className:`text-xs text-muted-foreground hover:text-foreground inline-flex items-center gap-1 transition-colors`,children:[J(`detail.viewAll`),(0,l.jsx)(o.ExternalLink,{className:`h-3 w-3`})]})})]}),(0,l.jsx)(a.AlertDialog,{open:Ye!==null,onOpenChange:e=>{e||Xe(null)},children:(0,l.jsxs)(a.AlertDialogContent,{children:[(0,l.jsxs)(a.AlertDialogHeader,{children:[(0,l.jsx)(a.AlertDialogTitle,{children:J(`detail.deleteRowTitle`,{defaultValue:`Delete record`})}),(0,l.jsx)(a.AlertDialogDescription,{children:J(`detail.deleteRowConfirmation`)})]}),(0,l.jsxs)(a.AlertDialogFooter,{children:[(0,l.jsx)(a.AlertDialogCancel,{children:J(`detail.cancel`,{defaultValue:`Cancel`})}),(0,l.jsx)(a.AlertDialogAction,{onClick:Qe,className:`bg-destructive text-destructive-foreground hover:bg-destructive/90`,children:J(`detail.delete`,{defaultValue:`Delete`})})]})]})}),Ce&&(0,l.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:Ce}),O&&Z&&h&&(0,l.jsx)(i.RecordPickerDialog,{open:ye,onOpenChange:e=>be(e),multiple:!0,dataSource:h,objectName:Z,title:O.label||J(`detail.add`,{defaultValue:`Add`}),displayField:Re,columns:ze,cellRenderer:i.getCellRenderer,fieldsMeta:Q?.fields,baseFilter:O.picker.filter,onSelect:()=>{},onSelectRecords:e=>{$e(e)}})]})},ce=({group:e,data:n,className:r,objectSchema:i,objectName:s,isEditing:c=!1,onFieldChange:u,onEnterInlineEdit:d,autoFocusField:f,dataSource:p})=>{let m=e.collapsible??!0,[h,g]=t.useState(e.defaultCollapsed??!1),_=(0,l.jsx)(`div`,{className:`space-y-3 sm:space-y-4`,children:e.sections.map((e,t)=>(0,l.jsx)(W,{section:e,data:n,objectSchema:i,objectName:s,isEditing:c,onFieldChange:u,onEnterInlineEdit:d,autoFocusField:f,dataSource:p},t))});return m?(0,l.jsxs)(a.Collapsible,{open:!h,onOpenChange:e=>g(!e),className:r,children:[(0,l.jsx)(a.CollapsibleTrigger,{asChild:!0,children:(0,l.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:[h?(0,l.jsx)(o.ChevronRight,{className:`h-4 w-4 text-muted-foreground shrink-0`}):(0,l.jsx)(o.ChevronDown,{className:`h-4 w-4 text-muted-foreground shrink-0`}),e.icon&&(0,l.jsx)(`span`,{className:`text-muted-foreground`,children:e.icon}),(0,l.jsx)(`h3`,{className:`text-lg font-semibold`,children:e.title})]})}),e.description&&!h&&(0,l.jsx)(`p`,{className:`text-sm text-muted-foreground mt-1`,children:e.description}),(0,l.jsx)(a.CollapsibleContent,{children:(0,l.jsx)(`div`,{className:`mt-3`,children:_})})]}):(0,l.jsxs)(`div`,{className:(0,a.cn)(`space-y-3`,r),children:[(0,l.jsxs)(`div`,{className:`flex items-center gap-2 pb-2 border-b`,children:[e.icon&&(0,l.jsx)(`span`,{className:`text-muted-foreground`,children:e.icon}),(0,l.jsx)(`h3`,{className:`text-lg font-semibold`,children:e.title})]}),e.description&&(0,l.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:e.description}),_]})},le=({fields:e,data:t,className:n,objectName:s,objectSchema:c,dataSource:u})=>{let{fieldLabel:d}=(0,r.useSafeFieldLabel)(),{t:f}=D(),p=(0,r.useInlineEdit)(),m=p?.editing??!1,h=p?.canEdit??!1;if(!e.length||!t)return null;let g=m?e:e.filter(e=>{let n=t?.[e.name];return n!=null&&n!==``});return g.length===0?null:(0,l.jsx)(a.TooltipProvider,{children:(0,l.jsx)(`section`,{className:(0,a.cn)(`@container border-b border-border/60 pb-4`,n),"aria-label":`Record highlights`,children:(0,l.jsx)(`div`,{className:(0,a.cn)(`flex flex-wrap gap-y-4`),children:g.map(e=>{let n=t[e.name],r=c?.fields?.[e.name],g=e.type||r?.type,_=R({name:e.name,label:e.label,type:g||`text`},r),v=p?.draft?.[e.name],y=v===void 0?n:v,b=N(e.type,r?.type),x=e.readonly===!0||r?.readonly===!0,S=j.has(e.name),C=F(e.type,r?.type),w=h&&!b&&!x&&!S&&!C,T=m&&w,E=(0,i.getCellRenderer)((0,i.resolveCellRendererType)(_)||g||`text`),D=g===`number`||g===`integer`||g===`currency`||g===`percent`||g===`decimal`,O=g===`email`||g===`url`||g===`textarea`||g===`reference`||g===`lookup`||g===`master_detail`,k=g===`boolean`,A=y==null||y===``;return(0,l.jsxs)(`div`,{className:(0,a.cn)(`group flex flex-col gap-1 min-w-[7rem] px-5 border-l border-border/60 first:border-l-0 first:pl-0`,O||T?`basis-[16rem] max-w-[24rem]`:`basis-[9rem] max-w-[16rem]`),children:[(0,l.jsx)(`span`,{className:`text-xs font-medium text-muted-foreground`,children:d(s||``,e.name,e.label)}),T?(0,l.jsx)(H,{field:_,value:y,onChange:t=>p.setField(e.name,t),dataSource:u,autoFocus:p.autoFocusField===e.name}):(0,l.jsxs)(`div`,{className:(0,a.cn)(`flex items-start justify-between gap-1`,w&&`cursor-pointer rounded-md -mx-1.5 px-1.5 hover:bg-muted/40 transition-colors`),onDoubleClick:w?()=>p.enter(e.name):void 0,title:w?f(`detail.editInlineHint`):void 0,children:[(0,l.jsx)(`div`,{className:`min-w-0 flex-1`,children:k?y?(0,l.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,l.jsx)(o.Check,{className:`h-3 w-3`,"aria-hidden":!0}),`Yes`]}):(0,l.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,l.jsx)(o.X,{className:`h-3 w-3`,"aria-hidden":!0}),`No`]}):A?(0,l.jsx)(`span`,{className:`block text-sm text-muted-foreground/60 select-none`,"aria-label":f(`detail.noValue`,{defaultValue:`No value`}),children:`—`}):(0,l.jsx)(`span`,{title:(Array.isArray(_.options)?_.options.find(e=>e?.value===y)?.label:void 0)??(typeof y==`string`||typeof y==`number`?String(y):void 0),className:(0,a.cn)(`block min-w-0 truncate text-sm font-semibold`,D&&`tabular-nums tracking-tight`),children:(0,l.jsx)(E,{value:y,field:_})})}),w&&(0,l.jsxs)(a.Tooltip,{children:[(0,l.jsx)(a.TooltipTrigger,{asChild:!0,children:(0,l.jsx)(a.Button,{variant:`ghost`,size:`icon`,className:`h-5 w-5 shrink-0 opacity-0 group-hover:opacity-100 transition-opacity`,"aria-label":f(`detail.editInlineHint`),onClick:t=>{t.stopPropagation(),p.enter(e.name)},children:(0,l.jsx)(o.Pencil,{className:`h-3 w-3`})})}),(0,l.jsx)(a.TooltipContent,{children:f(`detail.editInlineHint`)})]})]})]},e.name)})})})})};function ue(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 de=({comments:e,onAddComment:n,onTogglePin:r,searchable:i=!1,className:s})=>{let{t:c}=D(),[u,d]=t.useState(``),[f,p]=t.useState(!1),[m,h]=t.useState(``),g=t.useCallback(async()=>{let e=u.trim();if(!(!e||!n)){p(!0);try{await n(e),d(``)}finally{p(!1)}}},[u,n]),_=t.useCallback(e=>{e.key===`Enter`&&(e.ctrlKey||e.metaKey)&&(e.preventDefault(),g())},[g]),v=t.useMemo(()=>[...m.trim()?e.filter(e=>{let t=m.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,m]);return(0,l.jsxs)(a.Card,{className:(0,a.cn)(``,s),children:[(0,l.jsx)(a.CardHeader,{children:(0,l.jsxs)(a.CardTitle,{className:`flex items-center gap-2 text-base`,children:[(0,l.jsx)(o.MessageSquare,{className:`h-4 w-4`}),c(`detail.comments`),(0,l.jsxs)(`span`,{className:`text-sm font-normal text-muted-foreground`,children:[`(`,e.length,`)`]})]})}),(0,l.jsxs)(a.CardContent,{className:`space-y-4`,children:[i&&(0,l.jsx)(`div`,{className:`flex items-center gap-2`,children:(0,l.jsxs)(`div`,{className:`relative flex-1`,children:[(0,l.jsx)(o.Search,{className:`absolute left-2.5 top-1/2 -translate-y-1/2 h-3.5 w-3.5 text-muted-foreground`}),(0,l.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:c(`detail.searchComments`),value:m,onChange:e=>h(e.target.value),"aria-label":c(`detail.searchComments`)}),m&&(0,l.jsx)(`button`,{className:`absolute right-2 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground`,onClick:()=>h(``),"aria-label":c(`detail.clearSearch`),type:`button`,children:(0,l.jsx)(o.X,{className:`h-3.5 w-3.5`})})]})}),n&&(0,l.jsxs)(`div`,{className:`flex gap-2`,children:[(0,l.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:c(`detail.addCommentPlaceholder`),value:u,onChange:e=>d(e.target.value),onKeyDown:_,disabled:f}),(0,l.jsx)(a.Button,{size:`icon`,variant:`default`,onClick:g,disabled:!u.trim()||f,className:`shrink-0 self-end`,children:(0,l.jsx)(o.Send,{className:`h-4 w-4`})})]}),v.length===0?(0,l.jsx)(`p`,{className:`text-sm text-muted-foreground text-center py-4`,children:m.trim()?c(`detail.noMatchingComments`):c(`detail.noCommentsYet`)}):(0,l.jsx)(`div`,{className:`space-y-3`,children:v.map(e=>(0,l.jsxs)(`div`,{className:(0,a.cn)(`flex gap-3`,e.pinned&&`bg-muted/40 rounded-md p-2 -mx-2`),children:[(0,l.jsx)(`div`,{className:`shrink-0`,children:e.avatarUrl?(0,l.jsx)(`img`,{src:e.avatarUrl,alt:e.author,className:`h-8 w-8 rounded-full object-cover`}):(0,l.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,l.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,l.jsxs)(`div`,{className:`flex items-center gap-2 mb-0.5`,children:[(0,l.jsx)(`span`,{className:`text-sm font-medium truncate`,children:e.author}),(0,l.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:ue(e.createdAt)}),e.pinned&&(0,l.jsxs)(`span`,{className:`text-xs text-amber-600 flex items-center gap-0.5`,children:[(0,l.jsx)(o.Pin,{className:`h-3 w-3`}),c(`detail.pinned`)]})]}),(0,l.jsx)(`p`,{className:`text-sm whitespace-pre-wrap break-words`,children:e.text}),r&&(0,l.jsxs)(`button`,{type:`button`,className:`mt-1 text-xs text-muted-foreground hover:text-foreground flex items-center gap-1`,onClick:()=>r(e.id),"aria-label":e.pinned?c(`detail.unpin`):c(`detail.pin`),children:[(0,l.jsx)(o.Pin,{className:`h-3 w-3`}),e.pinned?c(`detail.unpin`):c(`detail.pin`)]})]})]},e.id))})]})]})},fe={field_change:o.Edit,create:o.PlusCircle,delete:o.Trash2,comment:o.MessageSquare,status_change:o.ArrowRightLeft},pe={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 me(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 he(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 K={all:`All`,field_change:`Field Changes`,create:`Creates`,delete:`Deletes`,comment:`Comments`,status_change:`Status Changes`},ge=({activities:e,filterable:n=!1,defaultFilter:r=`all`,className:i})=>{let[s,c]=t.useState(r),u=t.useMemo(()=>s===`all`?e:e.filter(e=>e.type===s),[e,s]);return(0,l.jsxs)(a.Card,{className:(0,a.cn)(``,i),children:[(0,l.jsx)(a.CardHeader,{children:(0,l.jsxs)(a.CardTitle,{className:`flex items-center gap-2 text-base`,children:[(0,l.jsx)(o.Activity,{className:`h-4 w-4`}),`Activity`,(0,l.jsxs)(`span`,{className:`text-sm font-normal text-muted-foreground`,children:[`(`,u.length,`)`]})]})}),(0,l.jsxs)(a.CardContent,{children:[n&&(0,l.jsx)(`div`,{className:`flex flex-wrap gap-1.5 mb-4`,role:`group`,"aria-label":`Activity type filter`,children:Object.keys(K).map(e=>(0,l.jsxs)(`button`,{type:`button`,className:(0,a.cn)(`inline-flex items-center gap-1 rounded-full px-2.5 py-0.5 text-xs font-medium transition-colors`,s===e?`bg-primary text-primary-foreground`:`bg-muted text-muted-foreground hover:bg-muted/80`),onClick:()=>c(e),"aria-pressed":s===e,children:[e!==`all`&&t.createElement(fe[e]||o.Edit,{className:`h-3 w-3`}),K[e]]},e))}),u.length===0?(0,l.jsx)(a.DataEmptyState,{title:`No activity recorded`,className:`py-6`}):(0,l.jsxs)(`div`,{className:`relative`,children:[(0,l.jsx)(`div`,{className:`absolute left-4 top-2 bottom-2 w-px bg-border`}),(0,l.jsx)(`div`,{className:`space-y-4`,children:u.map(e=>{let t=fe[e.type]||o.Edit,n=pe[e.type]||`bg-gray-100 text-gray-600`;return(0,l.jsxs)(`div`,{className:`flex gap-3 relative`,children:[(0,l.jsx)(`div`,{className:(0,a.cn)(`shrink-0 h-8 w-8 rounded-full flex items-center justify-center z-10`,n),children:(0,l.jsx)(t,{className:`h-3.5 w-3.5`})}),(0,l.jsxs)(`div`,{className:`flex-1 min-w-0 pt-1`,children:[(0,l.jsxs)(`p`,{className:`text-sm`,children:[(0,l.jsx)(`span`,{className:`font-medium`,children:e.user}),` `,(0,l.jsx)(`span`,{className:`text-muted-foreground`,children:he(e)})]}),(0,l.jsx)(`p`,{className:`text-xs text-muted-foreground mt-0.5`,children:me(e.timestamp)})]})]},e.id)})})]})]})]})},_e={create:`default`,update:`secondary`,delete:`destructive`,login:`outline`,logout:`outline`,config_change:`secondary`,import:`outline`};function ve(e){if(!e)return``;let t=e instanceof Date?e:new Date(e);return Number.isNaN(t.getTime())?String(e):t.toLocaleString()}var ye=[[60,`second`],[60,`minute`],[24,`hour`],[7,`day`],[4.34524,`week`],[12,`month`],[1/0,`year`]];function be(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 ye){if(Math.abs(r)<n)try{return new Intl.RelativeTimeFormat(t,{numeric:`auto`}).format(Math.round(r),i)}catch{return ve(e)}r/=n}return ve(e)}function xe(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 Se(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 Ce({entries:e,loading:t,emptyText:n,unknownUserText:r,className:i,locale:o}){return t?(0,l.jsx)(`div`,{className:(0,a.cn)(`space-y-3`,i),children:Array.from({length:4}).map((e,t)=>(0,l.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,l.jsx)(a.Skeleton,{className:`h-8 w-8 rounded-full`}),(0,l.jsxs)(`div`,{className:`flex-1 space-y-2`,children:[(0,l.jsx)(a.Skeleton,{className:`h-4 w-1/3`}),(0,l.jsx)(a.Skeleton,{className:`h-3 w-1/2`})]})]},t))}):!e||e.length===0?(0,l.jsx)(`div`,{className:(0,a.cn)(`flex items-center justify-center rounded-md border border-dashed py-10 text-sm text-muted-foreground`,i),children:n??`No history yet`}):(0,l.jsx)(a.TooltipProvider,{delayDuration:150,children:(0,l.jsx)(`ol`,{className:(0,a.cn)(`space-y-4`,i),children:e.map((e,t)=>{let n=(e.action??``).toLowerCase(),i=_e[n]??`outline`,s=typeof e.user_name==`string`&&e.user_name.trim()||r||`Unknown user`,c=ve(e.created_at),u=be(e.created_at,o),d=typeof e.user_avatar==`string`?e.user_avatar:void 0;return(0,l.jsxs)(`li`,{className:`flex items-start gap-3`,children:[(0,l.jsxs)(a.Avatar,{className:`h-8 w-8 mt-0.5 shrink-0`,children:[d?(0,l.jsx)(a.AvatarImage,{src:d,alt:s}):null,(0,l.jsx)(a.AvatarFallback,{className:`text-[10px] font-medium`,children:xe(e.user_name)})]}),(0,l.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,l.jsxs)(`div`,{className:`flex flex-wrap items-baseline gap-x-2 gap-y-1`,children:[(0,l.jsx)(`span`,{className:`text-sm font-medium text-foreground`,children:s}),e.action&&(0,l.jsx)(a.Badge,{variant:i,className:`text-[10px] uppercase tracking-wide`,children:e.action}),c&&(0,l.jsxs)(a.Tooltip,{children:[(0,l.jsx)(a.TooltipTrigger,{asChild:!0,children:(0,l.jsx)(`span`,{className:`text-xs text-muted-foreground cursor-help`,"aria-label":c,children:u||c})}),(0,l.jsx)(a.TooltipContent,{children:c})]})]}),e.summary&&(0,l.jsx)(`p`,{className:`mt-1 text-sm text-muted-foreground`,children:e.summary}),e.changes&&e.changes.length>0&&(n===`create`?(0,l.jsxs)(`details`,{className:`mt-1 group`,children:[(0,l.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,l.jsx)(`span`,{className:`transition-transform group-open:rotate-90`,children:`▸`}),(0,l.jsx)(`span`,{children:e.changes.length===1?`1 field populated`:`${e.changes.length} fields populated`})]}),(0,l.jsx)(`ul`,{className:`mt-1.5 space-y-0.5 text-xs text-muted-foreground pl-4`,children:e.changes.map(e=>(0,l.jsxs)(`li`,{className:`leading-relaxed`,children:[(0,l.jsx)(`span`,{className:`font-medium text-foreground`,children:e.label||e.field}),`: `,(0,l.jsx)(`span`,{className:`text-foreground`,children:Se(e.to)})]},e.field))})]}):(0,l.jsx)(`ul`,{className:`mt-1.5 space-y-0.5 text-xs text-muted-foreground`,children:e.changes.map(e=>(0,l.jsxs)(`li`,{className:`leading-relaxed`,children:[(0,l.jsx)(`span`,{className:`font-medium text-foreground`,children:e.label||e.field}),`: `,(0,l.jsx)(`span`,{className:`line-through opacity-70`,children:Se(e.from)}),` → `,(0,l.jsx)(`span`,{className:`text-foreground`,children:Se(e.to)})]},e.field))}))]})]},e.id??t)})})})}var we=d.AUDIT_FIELD_BY_ROLE;function q(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 Te(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 Ee(e){try{return new Intl.DateTimeFormat(void 0,{dateStyle:`medium`,timeStyle:`short`}).format(e)}catch{return e.toISOString()}}var De=({value:e,objectSchema:n,fieldName:r})=>{if(e==null||e===``)return null;let a=n?.fields?.[r],o=a?.reference_to||a?.reference||`sys_user`,s={name:r,type:a?.type||`lookup`,reference_to:o,...a?.reference_field&&{reference_field:a.reference_field}},c=(0,i.resolveCellRendererType)(s)||s.type;if(c){let n=(0,i.getCellRenderer)(c);if(n)return(0,l.jsx)(`span`,{className:`inline-flex items-center [&_a]:text-inherit [&_a]:hover:underline`,children:t.createElement(n,{value:e,field:s})})}return(0,l.jsx)(`span`,{children:String(e)})},J=({label:e,user:t,date:n,objectSchema:r,userField:i,t:o})=>{if(!t&&!n)return null;let s=n?(0,l.jsx)(a.TooltipProvider,{delayDuration:200,children:(0,l.jsxs)(a.Tooltip,{children:[(0,l.jsx)(a.TooltipTrigger,{asChild:!0,children:(0,l.jsx)(`time`,{dateTime:n.toISOString(),className:`cursor-default underline decoration-dotted decoration-muted-foreground/40 underline-offset-2`,children:Te(n,o)})}),(0,l.jsx)(a.TooltipContent,{side:`top`,children:Ee(n)})]})}):null;return(0,l.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[(0,l.jsx)(`span`,{className:`text-muted-foreground/70`,children:e}),t?(0,l.jsx)(De,{value:t,objectSchema:r,fieldName:i}):null,t&&s?(0,l.jsx)(`span`,{className:`text-muted-foreground/40`,children:`·`}):null,s]})},Oe=({data:e,objectSchema:t,objectName:n,className:r})=>{let{t:i}=D();if(!e)return null;let o=q(e[we.createdAt]),s=q(e[we.updatedAt]),c=e[we.createdBy],u=e[we.updatedBy],d=!!(o||c),f=o&&s&&Math.abs(s.getTime()-o.getTime())<2e3,p=!!(s||u)&&!(f&&(c!=null&&u!=null&&String(c)===String(u)||!u));return!d&&!p?null:(0,l.jsxs)(`div`,{className:(0,a.cn)(`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:[d&&(0,l.jsx)(J,{label:i(c?`detail.createdBy`:`detail.created`),user:c,date:o,objectSchema:t,userField:we.createdBy,t:i}),p&&(0,l.jsx)(J,{label:i(u?`detail.updatedBy`:`detail.updated`),user:u,date:s,objectSchema:t,userField:we.updatedBy,t:i})]})},Y=new Map;function ke(e,n,i=`update`,a=!0){let o=e&&n?`${e}:${n}:${i}`:``,[s,c]=t.useState(()=>o&&Y.has(o)?Y.get(o):!0),l=t.useContext(r.SchemaRendererContext)?.apiFetch;return t.useEffect(()=>{if(!a||!o){c(!0);return}if(Y.has(o)){c(Y.get(o));return}let t=!1;return(async()=>{try{let r=await(l??fetch)(`/api/v1/security/explain`,{method:`POST`,headers:{"Content-Type":`application/json`},credentials:`include`,body:JSON.stringify({object:e,operation:i,recordId:n})});if(!r.ok)return;let a=(await r.json())?.record?.visible;if(typeof a!=`boolean`)return;Y.set(o,a),t||c(a)}catch{}})(),()=>{t=!0}},[o,e,n,i,a,l]),s}function X(){Y.clear()}var Ae=5,je={};function Me(e,t,r,i){if(e&&typeof e==`object`){if(t.primaryField){let n=e[t.primaryField];if(n!=null&&n!==``)return String(n)}let i=(0,n.formatTitleTemplate)(r?.titleFormat,e);if(i)return i}if(e&&typeof e==`object`){let t=e.id??e._id,i=(0,n.getRecordDisplayName)(r,e,{deriveFromRecordKeys:!1});if(!(i===`Untitled`||t!=null&&i===`Record #${t}`))return i}if(t.title)return t.title;if(e&&typeof e==`object`){let t=e.id??e._id,i=(0,n.getRecordDisplayName)(r,e);if(!(i===`Untitled`||t!=null&&i===`Record #${t}`))return i}if(e&&typeof e==`object`){let t=e.id??e._id;if(t!=null&&String(t).trim()!==``)return`Record #${t}`}return i}var Ne=({schema:e,dataSource:i,className:c,onEdit:d,onDelete:f,onBack:p,inlineEdit:m=!1,discussionSlot:h,rightRail:g,objectLabel:_,onDataLoaded:v,isFavorite:y,onToggleFavorite:b})=>{let[x,S]=t.useState(e.data),[C,w]=t.useState(!e.data&&!!(e.api&&e.resourceId||i&&e.objectName&&e.resourceId)),[T,E]=t.useState(!1),O=y??T,k=(0,r.useInlineEdit)(),A=k?.editing??!1,j=k?.draft??je,M=k?.autoFocusField??null,[N,P]=t.useState(null),[F,I]=t.useState(null),[L,R]=t.useState(!1),[ee,z]=t.useState(0),te=(0,r.useDataInvalidation)(e.objectName||void 0,e.resourceId==null?void 0:String(e.resourceId)),[B,V]=t.useState(!1),{t:H}=D(),{currency:ne}=(0,s.useLocalization)(),{fieldOptionLabel:U}=(0,r.useSafeFieldLabel)(),re=(0,a.useIsMobile)(),ie=(0,u.usePermissions)(),ae=t.useMemo(()=>{if(!ie?.isLoaded||!e.objectName)return e;let t=t=>ie.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,ie]),oe=t.useMemo(()=>!ie?.isLoaded||!e.objectName||ie.can(e.objectName,`update`),[ie,e.objectName]),ue=t.useMemo(()=>!ie?.isLoaded||!e.objectName||ie.can(e.objectName,`delete`),[ie,e.objectName]),fe=e.resourceId==null?void 0:String(e.resourceId),pe=ke(e.objectName,fe,`update`,oe),me=ke(e.objectName,fe,`delete`,ue),he=t.useMemo(()=>(0,n.userActionPredicates)(F?.userActions?.edit),[F]),K=t.useMemo(()=>(0,n.userActionPredicates)(F?.userActions?.delete),[F]),_e=F?.fields,ve=(0,r.useRowPredicate)(he?.visibleWhen??!0,x,{fallback:!1,warnOnError:!0,label:`builtin:edit:visibleWhen`,fields:_e}),ye=(0,r.useRowPredicate)(K?.visibleWhen??!0,x,{fallback:!1,warnOnError:!0,label:`builtin:delete:visibleWhen`,fields:_e}),be=(0,r.useRowPredicate)(he?.disabledWhen,x,{fallback:!1,warnOnError:!0,label:`builtin:edit:disabledWhen`,fields:_e}),xe=(0,r.useRowPredicate)(K?.disabledWhen,x,{fallback:!1,warnOnError:!0,label:`builtin:delete:disabledWhen`,fields:_e}),Se=he?.disabledWhen!=null&&be,we=K?.disabledWhen!=null&&xe,q=t.useMemo(()=>({...ae,showEdit:ae.showEdit&&oe&&pe&&ve,showDelete:ae.showDelete&&ue&&me&&ye}),[ae,oe,pe,ve,ue,me,ye]);t.useEffect(()=>{x&&v&&v(x)},[x,v]);let Te=t.useMemo(()=>{if(q.summaryFields&&q.summaryFields.length>0)return[];let e=[...q.sections?.flatMap(e=>e.fields)||[],...q.fields||[]],t={};for(let n of e)t[n.name]||(t[n.name]=n);if(F?.fields)for(let[e,n]of Object.entries(F.fields))t[e]={...t[e]||{},...n,name:e};let n=e=>x?.[e]!==void 0&&x?.[e]!==null&&x?.[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},[q.summaryFields,q.sections,q.fields,F,x]),Ee=q.summaryFields&&q.summaryFields.length>0?q.summaryFields:Te,De=t.useCallback(()=>{q.resourceId&&navigator.clipboard.writeText(String(q.resourceId)).then(()=>{R(!0),setTimeout(()=>R(!1),1500)})},[q.resourceId]);t.useEffect(()=>{let e=!0;if(q.data)return S(q.data),w(!1),i?.getObjectSchema&&q.objectName&&i.getObjectSchema(q.objectName).then(t=>{e&&I(t)}).catch(()=>{}),()=>{e=!1};if(i&&q.objectName&&q.resourceId){w(!0),I(null),S(null);let t=q.objectName,r=q.resourceId,a=`${t}-`,o=[...q.sections?.flatMap(e=>e.fields)||[],...q.fields||[]];(i.getObjectSchema?i.getObjectSchema(t).catch(()=>null):Promise.resolve(null)).then(s=>{if(!e)return;I(s);let c=(0,n.buildExpandFields)(s?.fields,o),l=c.length>0?{$expand:c}:void 0,u=l?i.findOne(t,r,l):i.findOne(t,r),d=()=>{let n=String(r),o=n.startsWith(a)?n.slice(a.length):`${a}${n}`;return(l?i.findOne(t,o,l):i.findOne(t,o)).then(t=>{e&&(S(t),w(!1))}).catch(()=>{e&&(S(null),w(!1))})};return u.catch(()=>null).then(t=>{if(e){if(t){S(t),w(!1);return}return d()}})}).catch(t=>{e&&(console.error(`Failed to fetch detail data:`,t),w(!1))})}else q.api&&q.resourceId&&(w(!0),fetch(`${q.api}/${q.resourceId}`).then(e=>e.json()).then(t=>{e&&S(t?.data||t)}).catch(e=>{console.error(`Failed to fetch detail data:`,e)}).finally(()=>{e&&w(!1)}));return()=>{e=!1}},[q.api,q.resourceId,q.objectName,i,q.sections,q.fields,ee,te]);let J=t.useCallback(()=>{if(p)p();else if(q.onNavigate){let e=q.backUrl||(q.objectName?`/${q.objectName}`:`/`);q.onNavigate(e,{replace:!0})}else q.backUrl?window.location.href=q.backUrl:window.history.back()},[p,q]),Y=t.useCallback(()=>{d?d():q.onNavigate&&q.editUrl?q.onNavigate(q.editUrl):q.onNavigate&&q.objectName&&q.resourceId?q.onNavigate(`/${q.objectName}/${q.resourceId}/edit`):q.editUrl&&(window.location.href=q.editUrl)},[d,q]),X=t.useCallback(async()=>{if(!i?.cancelPendingApproval||!q.objectName||!q.resourceId){P(H(`detail.cancelApprovalUnavailable`));return}V(!0),P(null);try{if(await i.cancelPendingApproval(String(q.objectName),String(q.resourceId)),i.findOne)try{let e=await i.findOne(String(q.objectName),String(q.resourceId));e&&S(e)}catch{}z(e=>e+1);try{window.dispatchEvent(new CustomEvent(`objectui:record-changed`,{detail:{objectName:String(q.objectName),recordId:String(q.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*/,``);P(`${H(`detail.cancelApprovalFailed`)}: ${t}`)}finally{V(!1)}},[i,q.objectName,q.resourceId,H]),Ne=t.useCallback(()=>{let e=q.deleteConfirmation||H(`detail.deleteConfirmation`);window.confirm(e)&&(f?.(),q.onNavigate&&q.objectName&&q.onNavigate(`/${q.objectName}`,{replace:!0}))},[f,q]),Pe=t.useCallback(()=>{navigator.share&&q.objectName&&q.resourceId?navigator.share({title:q.title||H(`detail.details`),text:`${q.objectName} #${q.resourceId}`,url:window.location.href}).catch(e=>{console.error(`Share failed:`,e)}):navigator.clipboard.writeText(window.location.href)},[q]),Fe=t.useCallback(()=>{let e=!O;b&&b(e),y===void 0&&E(e)},[O,y,b]),Ie=k?.setField,Z=k&&k.canEdit?k.enter:void 0;t.useEffect(()=>{if(!q.recordNavigation)return;let e=q.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)},[q.recordNavigation]);let Q=t.useMemo(()=>q.related??[],[q.related]),Le=t.useMemo(()=>{let e=[];return e.push({name:`sys_share`,label:H(`detail.share`),icon:`share-2`,type:`script`,onClick:Pe}),q.showEdit&&e.push({name:`sys_edit_mobile`,label:H(`detail.edit`),icon:`square-pen`,type:`script`,className:`sm:hidden`,...Se?{disabled:!0}:null,onClick:Y}),q.showDelete&&e.push({name:`sys_delete`,label:H(`detail.delete`),icon:`trash-2`,type:`script`,variant:`destructive`,tags:[`separator-before`],...we?{disabled:!0}:null,onClick:Ne}),e},[H,q.showEdit,q.showDelete,Se,we,Pe,Y,Ne]),Re=t.useMemo(()=>{let e=q.actions??[];if(Le.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,...Le]}}return e});return t||n.push({type:`action:bar`,location:`record_header`,systemActions:Le}),n},[q.actions,Le]);return C||q.loading?(0,l.jsxs)(`div`,{className:(0,a.cn)(`space-y-4`,c),children:[(0,l.jsx)(a.Skeleton,{className:`h-10 w-full`}),(0,l.jsx)(a.Skeleton,{className:`h-64 w-full`}),(0,l.jsx)(a.Skeleton,{className:`h-48 w-full`})]}):!x&&!q.data?(0,l.jsxs)(`div`,{className:(0,a.cn)(`flex flex-col items-center justify-center py-16 text-center`,c),children:[(0,l.jsx)(`p`,{className:`text-lg font-semibold`,children:H(`detail.recordNotFound`)}),(0,l.jsx)(`p`,{className:`text-sm text-muted-foreground mt-1`,children:H(`detail.recordNotFoundDescription`)}),(q.showBack??!0)&&(0,l.jsxs)(a.Button,{variant:`outline`,size:`sm`,onClick:J,className:`mt-4 gap-2`,children:[(0,l.jsx)(o.ArrowLeft,{className:`h-4 w-4`}),H(`detail.goBack`)]})]}):(0,l.jsx)(a.TooltipProvider,{children:(0,l.jsxs)(`div`,{className:(0,a.cn)(`space-y-6`,c),children:[q.showHeader!==!1&&(0,l.jsxs)(`div`,{className:`flex flex-col sm:flex-row items-start justify-between gap-3 sm:gap-4 pb-4 border-b`,children:[(0,l.jsxs)(`div`,{className:`flex items-start gap-2 sm:gap-3 flex-1 min-w-0`,children:[(q.showBack??!0)&&(0,l.jsxs)(a.Tooltip,{children:[(0,l.jsx)(a.TooltipTrigger,{asChild:!0,children:(0,l.jsx)(a.Button,{variant:`ghost`,size:`icon`,onClick:J,className:`shrink-0 mt-1`,children:(0,l.jsx)(o.ArrowLeft,{className:`h-4 w-4`})})}),(0,l.jsx)(a.TooltipContent,{children:H(`detail.back`)})]}),(0,l.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,l.jsxs)(`div`,{className:`flex items-center gap-2 flex-wrap`,children:[(0,l.jsx)(`h1`,{className:`text-xl sm:text-2xl font-bold truncate`,children:Me(x,q,F,H(`detail.details`))}),Ee.map(e=>{let t=x?.[e];if(t==null||t===``)return null;let n=(q.sections||[]).flatMap(e=>e.fields).concat(q.fields||[]).find(t=>t.name===e),r=F?.fields?.[e],i=n?.type||r?.type,o=String(t),c=null;try{if(i===`currency`){let e=Number(t);if(!Number.isNaN(e)){let t=(0,s.resolveFieldCurrency)({...r,...n},ne);o=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())||(o=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)){o=`${e}%`;let t=e<=1?e*100:e;c=Math.max(0,Math.min(100,t))}}else if(i===`select`||i===`status`||i===`multiselect`){let i=n?.options||r?.options,a=String(t);if(Array.isArray(i)){let e=i.find(e=>String(e?.value??e)===String(t));e?.label&&(a=e.label)}else if(i&&typeof i==`object`){let e=i[String(t)];e?.label&&(a=e.label)}o=q.objectName?U(q.objectName,e,String(t),a):a}}catch{}return c===null?(0,l.jsx)(a.Badge,{variant:`secondary`,className:`text-xs bg-primary/10 text-primary border-transparent hover:bg-primary/15`,"aria-label":`${e}: ${o}`,children:o},e):(0,l.jsxs)(a.Badge,{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}: ${o}`,children:[(0,l.jsx)(`span`,{className:`relative inline-block h-1.5 w-12 rounded-full bg-primary/20 overflow-hidden`,"aria-hidden":!0,children:(0,l.jsx)(`span`,{className:`absolute inset-y-0 left-0 rounded-full bg-primary`,style:{width:`${c}%`}})}),o]},e)}),(0,l.jsxs)(a.Tooltip,{children:[(0,l.jsx)(a.TooltipTrigger,{asChild:!0,children:(0,l.jsx)(a.Button,{variant:`ghost`,size:`icon`,className:`h-6 w-6 shrink-0`,onClick:Fe,"aria-label":H(O?`detail.removeFromFavorites`:`detail.addToFavorites`),children:O?(0,l.jsx)(o.Star,{className:`h-4 w-4 fill-yellow-400 text-yellow-400`}):(0,l.jsx)(o.Star,{className:`h-4 w-4 text-muted-foreground`})})}),(0,l.jsx)(a.TooltipContent,{children:H(O?`detail.removeFromFavorites`:`detail.addToFavorites`)})]})]}),q.objectName&&(0,l.jsxs)(`p`,{className:`text-sm text-muted-foreground mt-1 flex items-center gap-1`,children:[(0,l.jsx)(`span`,{className:`font-medium`,children:_||q.objectName}),q.resourceId&&(0,l.jsxs)(a.Tooltip,{children:[(0,l.jsx)(a.TooltipTrigger,{asChild:!0,children:(0,l.jsx)(a.Button,{variant:`ghost`,size:`icon`,className:`h-5 w-5 shrink-0 text-muted-foreground/60 hover:text-foreground`,onClick:De,"aria-label":H(`detail.copyRecordId`,{defaultValue:`Copy record ID`}),children:L?(0,l.jsx)(o.Check,{className:`h-3 w-3 text-green-600`}):(0,l.jsx)(o.Copy,{className:`h-3 w-3`})})}),(0,l.jsx)(a.TooltipContent,{children:L?H(`detail.copied`,{defaultValue:`Copied!`}):H(`detail.copyRecordId`,{defaultValue:`Copy record ID`})})]})]})]})]}),(0,l.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5 shrink-0 w-full sm:w-auto`,children:[q.recordNavigation&&(0,l.jsxs)(`div`,{className:`flex items-center gap-1 mr-2`,children:[(0,l.jsxs)(a.Tooltip,{children:[(0,l.jsx)(a.TooltipTrigger,{asChild:!0,children:(0,l.jsx)(a.Button,{variant:`outline`,size:`icon`,className:`h-8 w-8`,disabled:q.recordNavigation.currentIndex<=0,onClick:()=>{let e=q.recordNavigation;e.currentIndex>0&&e.onNavigate(e.recordIds[e.currentIndex-1])},children:(0,l.jsx)(o.ChevronLeft,{className:`h-4 w-4`})})}),(0,l.jsx)(a.TooltipContent,{children:H(`detail.previousRecord`)})]}),(0,l.jsx)(`span`,{className:`text-xs text-muted-foreground whitespace-nowrap px-1`,children:H(`detail.recordOf`,{current:q.recordNavigation.currentIndex+1,total:q.recordNavigation.recordIds.length})}),(0,l.jsxs)(a.Tooltip,{children:[(0,l.jsx)(a.TooltipTrigger,{asChild:!0,children:(0,l.jsx)(a.Button,{variant:`outline`,size:`icon`,className:`h-8 w-8`,disabled:q.recordNavigation.currentIndex>=q.recordNavigation.recordIds.length-1,onClick:()=>{let e=q.recordNavigation;e.currentIndex<e.recordIds.length-1&&e.onNavigate(e.recordIds[e.currentIndex+1])},children:(0,l.jsx)(o.ChevronRight,{className:`h-4 w-4`})})}),(0,l.jsx)(a.TooltipContent,{children:H(`detail.nextRecord`)})]})]}),q.showEdit&&(0,l.jsxs)(a.Tooltip,{children:[(0,l.jsx)(a.TooltipTrigger,{asChild:!0,children:(0,l.jsxs)(a.Button,{variant:`default`,disabled:Se,onClick:()=>{Se||Y()},className:`gap-2 hidden sm:inline-flex`,children:[(0,l.jsx)(o.Edit,{className:`h-4 w-4`}),(0,l.jsx)(`span`,{className:`hidden sm:inline`,children:H(`detail.edit`)})]})}),(0,l.jsx)(a.TooltipContent,{children:H(`detail.editRecord`)})]}),Re.map((e,t)=>(0,l.jsx)(r.SchemaRenderer,{schema:(0,r.toRenderableSchema)(e),data:x},`header-action-${t}`))]})]}),q.header&&(0,l.jsx)(`div`,{children:(0,l.jsx)(r.SchemaRenderer,{schema:(0,r.toRenderableSchema)(q.header),data:x})}),q.highlightFields&&q.highlightFields.length>0&&(0,l.jsx)(le,{fields:q.highlightFields,data:x,objectName:q.objectName,objectSchema:F}),m&&q.showHeader===!1&&(()=>{let e=x?.approval_status,t=e===`pending`||e===`in_approval`,n=k?.approvalPending??!1,r=n&&!(k?.locked??!1)?!1:(k?.locked??!1)||t,s=r||n||t,c=s?k?.approvalProgress:void 0,u=!!c&&c.need>0&&c.need<=12;return!s&&!N?null:(0,l.jsxs)(`div`,{className:`flex flex-col items-end gap-1`,children:[s&&(0,l.jsxs)(`div`,{className:`flex items-center justify-end gap-2`,children:[(0,l.jsxs)(`span`,{role:`status`,className:r?`inline-flex items-center gap-1 rounded-md border border-amber-300 bg-amber-50 px-2 py-1 text-xs text-amber-800`:`inline-flex items-center gap-1 rounded-md border border-sky-300 bg-sky-50 px-2 py-1 text-xs text-sky-800`,title:r?k?.lockedReason??H(`detail.lockedTooltip`):H(`detail.approvalPendingTooltip`),children:[r?(0,l.jsx)(o.Lock,{className:`h-3 w-3`}):(0,l.jsx)(o.Clock,{className:`h-3 w-3`}),(0,l.jsx)(`span`,{children:H(r?`detail.lockedByApproval`:`detail.approvalPendingEditable`)})]}),i?.cancelPendingApproval&&(0,l.jsxs)(a.Button,{variant:`outline`,size:`sm`,onClick:X,disabled:B,className:r?`gap-2 border-amber-300 text-amber-800 hover:bg-amber-50`:`gap-2 border-sky-300 text-sky-800 hover:bg-sky-50`,title:H(r?`detail.cancelApprovalTooltip`:`detail.cancelApprovalTooltipUnlocked`),children:[(0,l.jsx)(o.X,{className:`h-4 w-4`}),(0,l.jsx)(`span`,{children:H(B?`detail.cancelApprovalInFlight`:`detail.cancelApproval`)})]})]}),c&&(0,l.jsxs)(`div`,{className:`flex flex-col items-end gap-1 max-w-[16rem]`,children:[(0,l.jsxs)(`div`,{role:`progressbar`,"aria-valuemin":0,"aria-valuemax":c.need,"aria-valuenow":Math.min(c.got,c.need),"aria-label":H(`detail.approvalProgressLabel`),className:`flex items-center gap-2 w-full justify-end`,children:[(0,l.jsx)(`span`,{className:`text-[11px] text-muted-foreground whitespace-nowrap`,children:c.behavior===`per_group`?H(`detail.approvalProgressGroups`,{got:c.got,need:c.need}):H(`detail.approvalProgress`,{got:c.got,need:c.need})}),u&&(0,l.jsx)(`span`,{className:`flex items-center gap-1 w-20 shrink-0`,children:Array.from({length:c.need}).map((e,t)=>(0,l.jsx)(`span`,{"aria-hidden":`true`,className:(0,a.cn)(`h-1.5 flex-1 rounded-full`,t<c.got?`bg-emerald-500`:`bg-muted`)},t))})]}),c.groups&&c.groups.length>0&&(0,l.jsx)(`div`,{className:`flex flex-wrap justify-end gap-1`,children:c.groups.map(e=>(0,l.jsxs)(`span`,{title:`${e.got}/${e.need}`,className:(0,a.cn)(`inline-flex items-center gap-1 rounded-md border px-1.5 py-0.5 text-[11px]`,e.satisfied?`border-emerald-300 text-emerald-700`:`border-border text-muted-foreground`),children:[e.satisfied?(0,l.jsx)(o.Check,{className:`h-3 w-3`}):(0,l.jsx)(o.Circle,{className:`h-2.5 w-2.5`}),(0,l.jsx)(`span`,{children:`${e.group} ${e.got}/${e.need}`})]},e.group))})]}),N&&(0,l.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:N})]})})(),q.autoTabs&&!q.tabs?.length?(()=>{let e=Q.length>0,t=!!q.activities&&q.activities.length>0,n=!!h,r=!!q.history,o=[`details`,...e?[`related`]:[],...t?[`activity`]:[],...n?[`discussion`]:[],...r?[`history`]:[]],s=q.defaultTab,c=s&&o.includes(s)?s:`details`,u=q.onTabChange,d=(0,l.jsxs)(`div`,{className:`space-y-3 sm:space-y-4`,children:[q.sectionGroups&&q.sectionGroups.length>0&&q.sectionGroups.map((e,t)=>(0,l.jsx)(ce,{group:e,data:{...x,...j},objectSchema:F,objectName:q.objectName,isEditing:A,onFieldChange:Ie,onEnterInlineEdit:m?Z:void 0,autoFocusField:M,dataSource:i},t)),q.sections&&q.sections.length>0&&q.sections.map((e,t)=>(0,l.jsx)(W,{section:e,data:{...x,...j},objectSchema:F,objectName:q.objectName,isEditing:A,onFieldChange:Ie,onEnterInlineEdit:m?Z:void 0,autoFocusField:M,dataSource:i},t)),q.fields&&q.fields.length>0&&!q.sections?.length&&(0,l.jsx)(W,{section:{fields:q.fields,columns:q.columns},data:{...x,...j},objectSchema:F,objectName:q.objectName,isEditing:A,onFieldChange:Ie,onEnterInlineEdit:m?Z:void 0,autoFocusField:M,dataSource:i}),q.comments&&(0,l.jsx)(de,{comments:q.comments,onAddComment:q.onAddComment})]});return!e&&!t&&!n&&!r?(0,l.jsx)(`div`,{className:`mt-2`,children:d}):(0,l.jsxs)(a.Tabs,{defaultValue:c,onValueChange:u,className:`w-full`,children:[(0,l.jsxs)(a.TabsList,{className:`w-full justify-start border-b rounded-none bg-transparent p-0`,children:[(0,l.jsx)(a.TabsTrigger,{value:`details`,className:`relative rounded-none border-b-2 border-transparent data-[state=active]:border-primary data-[state=active]:bg-transparent`,children:H(`detail.details`)}),e&&(0,l.jsx)(a.TabsTrigger,{value:`related`,className:`relative rounded-none border-b-2 border-transparent data-[state=active]:border-primary data-[state=active]:bg-transparent`,children:(0,l.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[H(`detail.related`),(0,l.jsx)(a.Badge,{variant:`secondary`,className:`text-xs bg-primary/10 text-primary border-transparent`,children:Q.length})]})}),t&&(0,l.jsx)(a.TabsTrigger,{value:`activity`,className:`relative rounded-none border-b-2 border-transparent data-[state=active]:border-primary data-[state=active]:bg-transparent`,children:(0,l.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[H(`detail.activity`),(0,l.jsx)(a.Badge,{variant:`secondary`,className:`text-xs bg-primary/10 text-primary border-transparent`,children:q.activities.length})]})}),n&&(0,l.jsx)(a.TabsTrigger,{value:`discussion`,className:`relative rounded-none border-b-2 border-transparent data-[state=active]:border-primary data-[state=active]:bg-transparent`,children:H(`detail.discussion`,{defaultValue:`Discussion`})}),r&&(0,l.jsx)(a.TabsTrigger,{value:`history`,className:`relative rounded-none border-b-2 border-transparent data-[state=active]:border-primary data-[state=active]:bg-transparent`,children:(0,l.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[H(`detail.history`,{defaultValue:`History`}),!q.history.loading&&q.history.entries.length>0&&(0,l.jsx)(a.Badge,{variant:`secondary`,className:`text-xs bg-primary/10 text-primary border-transparent`,children:q.history.entries.length})]})})]}),(0,l.jsx)(a.TabsContent,{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,l.jsx)(a.TabsContent,{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,l.jsx)(`div`,{className:`space-y-3`,children:Q.map((e,t)=>(0,l.jsx)(se,{title:e.title,type:e.type,api:e.api,data:e.data,columns:e.columns,dataSource:i,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:re&&t>0,pageSize:Ae},t))})}),t&&(0,l.jsx)(a.TabsContent,{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,l.jsx)(ge,{activities:q.activities})}),n&&(0,l.jsx)(a.TabsContent,{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:h}),r&&(0,l.jsx)(a.TabsContent,{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,l.jsx)(Ce,{entries:q.history.entries,loading:q.history.loading,emptyText:q.history.emptyText??H(`detail.historyEmpty`,{defaultValue:`No history yet`})})})]})})():(0,l.jsxs)(l.Fragment,{children:[q.sectionGroups&&q.sectionGroups.length>0&&(0,l.jsx)(`div`,{className:`space-y-3 sm:space-y-4`,children:q.sectionGroups.map((e,t)=>(0,l.jsx)(ce,{group:e,data:{...x,...j},objectSchema:F,objectName:q.objectName,isEditing:A,onFieldChange:Ie,onEnterInlineEdit:m?Z:void 0,autoFocusField:M,dataSource:i},t))}),q.sections&&q.sections.length>0&&(0,l.jsx)(`div`,{className:`space-y-3 sm:space-y-4`,children:q.sections.map((e,t)=>(0,l.jsx)(W,{section:e,data:{...x,...j},objectSchema:F,objectName:q.objectName,isEditing:A,onFieldChange:Ie,onEnterInlineEdit:m?Z:void 0,autoFocusField:M,dataSource:i},t))}),q.fields&&q.fields.length>0&&!q.sections?.length&&(0,l.jsx)(W,{section:{fields:q.fields,columns:q.columns},data:{...x,...j},objectSchema:F,objectName:q.objectName,isEditing:A,onFieldChange:Ie,onEnterInlineEdit:m?Z:void 0,autoFocusField:M,dataSource:i}),q.tabs&&q.tabs.length>0&&(0,l.jsx)(G,{tabs:q.tabs,data:x}),Q.length>0&&(0,l.jsxs)(`div`,{className:`space-y-3`,children:[(0,l.jsx)(`h2`,{className:`text-lg font-semibold`,children:H(`detail.related`)}),Q.map((e,t)=>(0,l.jsx)(se,{title:e.title,type:e.type,api:e.api,data:e.data,columns:e.columns,dataSource:i,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:re&&t>0,pageSize:Ae},t))]}),q.comments&&(0,l.jsx)(de,{comments:q.comments,onAddComment:q.onAddComment}),q.activities&&q.activities.length>0&&(0,l.jsx)(ge,{activities:q.activities})]}),(0,l.jsx)(Oe,{data:{...x,...j},objectSchema:F,objectName:q.objectName}),q.footer&&(0,l.jsx)(`div`,{children:(0,l.jsx)(r.SchemaRenderer,{schema:(0,r.toRenderableSchema)(q.footer),data:x})})]})})},Pe=e=>(0,n.columnIdentity)(e)??null,Fe=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}},Ie=({schema:e={},className:t,...i})=>{let a=(0,r.useRecordContext)(),{designer:o}=Fe(i),c=a?.objectName||``,d=(0,u.usePermissions)(),{readableFields:f}=(0,u.useFieldPermissions)(c),{sectionLabel:p}=(0,r.useSafeFieldLabel)(),{language:m}=(0,s.useObjectTranslation)(),h=(0,r.useHighlightFieldNames)();if(!a)return(0,l.jsx)(`div`,{className:t,"data-record-details-placeholder":!0,...o,children:(0,l.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 g=Array.isArray(e.requiredPermissions)?e.requiredPermissions:[];if(g.length>0&&c&&!g.every(e=>d.can(c,e)))return(0,l.jsx)(`div`,{className:t,...o,role:`status`,"aria-live":`polite`,children:(0,l.jsx)(`p`,{className:`text-sm text-muted-foreground italic`,children:`Insufficient permissions to view details.`})});let _=e.enforceFieldSecurity===!0,v=Array.isArray(e.redactFields)?e.redactFields:[],y=e=>{if(!e||!_&&v.length===0)return e;let t=e.map(Pe).filter(e=>!!e),n=new Set((_&&c?f(t):t).filter(e=>!v.includes(e)));return e.filter(e=>{let t=Pe(e);return!t||n.has(t)})},b=e=>typeof e==`string`?{name:e}:e&&typeof e==`object`&&!e.name&&e.field?{...e,name:e.field}:e,x=e=>Array.isArray(e)?e.map(b):e,S=new Set((Array.isArray(e.hideFields)?e.hideFields:[]).map(e=>typeof e==`string`?e:Pe(e)).filter(e=>!!e));for(let e of h)S.add(e);let C=a.objectSchema,w=a.data??{},T=[C?.primaryField,`name`,`full_name`,`title`,`subject`,`display_name`,`label`].filter(e=>typeof e==`string`&&e.length>0);for(let e of T)if(w[e]!==void 0&&w[e]!==null&&w[e]!==``){S.add(e);break}let E=e=>!e||S.size===0?e:e.filter(e=>{let t=Pe(e);return!t||!S.has(t)}),D=E(x(y(e.fields))),O=Array.isArray(e.sections)?e.sections.map(e=>{let t=e.title??e.label,n=t==null?void 0:(0,s.pickLocalized)(t,m),r=e.name&&c?p(c,e.name,n??e.name):n;return{...e,title:r,showBorder:e.showBorder??!!r,hideEmpty:e.hideEmpty??!0,fields:E(x(y(e.fields)))}}):e.sections,k=(0,n.isObjectInlineEditable)(C,d?.getObjectApiOperations?.(c)),A=(e.inlineEdit??!0)&&k,j={type:`detail-view`,objectName:a.objectName,resourceId:a.recordId,data:a.data,layout:`vertical`,columns:e.columns,sections:O,fields:D,showBack:!1,showHeader:e.showHeader??!1,inlineEdit:A};return(0,l.jsx)(`div`,{className:t,...o,children:(0,l.jsx)(Ne,{schema:j,dataSource:a.dataSource,inlineEdit:A})})},Z=e=>(0,n.columnIdentity)(e)||(e&&typeof e==`object`?e.key:null)||null,Q=e=>e?.id??e?._id??null,Le=5,Re=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}},ze=({schema:e={},className:n,...a})=>{let o=(0,r.useRecordContext)(),{designer:c}=Re(a),d=(0,r.useSafeFieldLabel)(),{language:f}=(0,s.useObjectTranslation)(),p=e.objectName,m=p&&d.objectLabel?d.objectLabel({name:p,label:(0,i.humanizeLabel)(p)}):p?(0,i.humanizeLabel)(p):``,h=(0,s.pickLocalized)(e.title,f)||m||`Related`,g=(0,u.usePermissions)(),{readableFields:_}=(0,u.useFieldPermissions)(p||``),v=e.relationshipValueField||`id`,y=v===`id`?o?.recordId??null:o?.data?.[v]??null,b=(0,r.useRelatedRecordActions)(),x=t.default.useMemo(()=>b?.resolve({objectName:p,relationshipField:e.relationshipField,parentId:y})??null,[b,p,e.relationshipField,y]);if(!p)return(0,l.jsx)(`div`,{className:n,...c,children:(0,l.jsx)(`div`,{className:`text-xs text-muted-foreground italic px-3 py-2 border border-dashed rounded`,children:`record:related_list — missing objectName`})});if(g.isLoaded&&!g.can(p,`read`))return null;let S=Array.isArray(e.requiredPermissions)?e.requiredPermissions:[];if(S.length>0&&!S.every(e=>g.can(p,e)))return(0,l.jsx)(`div`,{className:n,...c,role:`status`,"aria-live":`polite`,children:(0,l.jsx)(`p`,{className:`text-sm text-muted-foreground italic`,children:`Insufficient permissions to view related list.`})});let C=e.enforceFieldSecurity===!0,w=Array.isArray(e.redactFields)?e.redactFields:[],T=Array.isArray(e.columns)?e.columns:[],E=T;if(C||w.length>0){let e=T.map(Z).filter(e=>!!e),t=new Set((C?_(e):e).filter(e=>!w.includes(e)));E=T.filter(e=>{let n=Z(e);return!n||t.has(n)})}return(0,l.jsx)(`div`,{className:n,...c,children:(0,l.jsx)(se,{title:h,type:`table`,api:p,objectName:p,referenceField:e.relationshipField,parentId:y,columns:E,pageSize:typeof e.limit==`number`&&e.limit>0?e.limit:Le,defaultSort:e.sort,filter:e.filter,dataSource:o?.dataSource,add:e.add?{...e.add,label:(0,s.pickLocalized)(e.add.label,f)||void 0}:void 0,rowActions:x?.rowActions,onRowAction:x?.onRowAction,toolbarActions:x?.toolbarActions,onToolbarAction:x?.onToolbarAction,onNew:x?.onCreate,newDisabled:x?.createDisabled,onRowClick:x?.onView?e=>{let t=Q(e);t!=null&&x.onView(t,e)}:void 0,onRowEdit:x?.onEdit?e=>{let t=Q(e);t!=null&&x.onEdit(t,e)}:void 0,onRowDelete:x?.onDelete?e=>{let t=Q(e);if(t!=null)return x.onDelete(t,e)}:e.add&&o?.dataSource?async e=>{let t=e?.id??e?._id;t!=null&&await o.dataSource.delete?.(p,String(t))}:void 0})})},Be={columns:!0,filter:!0,sort:!0,limit:`limit`},Ve={},He=e=>{let t=(0,r.useRecordContext)();return(0,l.jsx)(r.ElementDataSourceGate,{schema:e.schema??Ve,mapping:Be,dataSource:t?.dataSource,testId:`record-related-list`,errorTitle:`This related list’s data source could not be resolved`,children:t=>(0,l.jsx)(ze,{...e,schema:t})})},Ue=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}},We=({schema:e={},className:n,...i})=>{let a=(0,r.useRecordContext)(),{designer:o}=Ue(i),s=a?.objectName||``,c=(0,u.usePermissions)(),{readableFields:d}=(0,u.useFieldPermissions)(s),f=Array.isArray(e.requiredPermissions)?e.requiredPermissions:[],p=!(f.length>0&&s)||f.every(e=>c.can(s,e)),m=(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,readonly:e?.readonly===!0}).filter(e=>typeof e.name==`string`&&e.name.length>0),h=e.enforceFieldSecurity===!0,g=Array.isArray(e.redactFields)?e.redactFields:[],_=h&&s?new Set(d(m.map(e=>e.name))):null,v=m.filter(e=>!(g.includes(e.name)||_&&!_.has(e.name))),y=t.default.useId();return(0,r.useRegisterHighlightFields)(y,p?v.map(e=>e.name):[]),p?(0,l.jsx)(`div`,{className:n,...o,children:(0,l.jsx)(le,{fields:v,data:a?.data,objectName:a?.objectName,objectSchema:a?.objectSchema,dataSource:a?.dataSource})}):(0,l.jsx)(`div`,{className:n,...o,role:`status`,"aria-live":`polite`,children:(0,l.jsx)(`p`,{className:`text-sm text-muted-foreground italic`,children:`Insufficient permissions to view highlights.`})})},Ge=({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,l.jsxs)(`div`,{className:(0,a.cn)(`flex items-center gap-1.5 text-sm flex-wrap`,t),children:[(0,l.jsx)(`span`,{className:`font-medium text-foreground`,children:n}),(0,l.jsx)(`span`,{className:`text-muted-foreground line-through`,children:r}),(0,l.jsx)(o.ArrowRight,{className:`h-3 w-3 text-muted-foreground shrink-0`}),(0,l.jsx)(`span`,{className:`text-foreground`,children:i})]})},Ke=[`👍`,`❤️`,`🎉`,`😂`,`😮`,`😢`],qe=({reactions:e,onToggleReaction:n,emojiOptions:r=Ke,className:i})=>{let[s,c]=t.useState(!1),{t:u}=D(),d=t.useCallback(e=>{n?.(e),c(!1)},[n]);return(0,l.jsxs)(`div`,{className:(0,a.cn)(`flex items-center gap-1 flex-wrap`,i),children:[e.map(e=>{let t=u(e.count===1?`detail.reactionCountOne`:`detail.reactionCount`,{emoji:e.emoji,count:e.count});return(0,l.jsxs)(`button`,{type:`button`,className:(0,a.cn)(`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:()=>d(e.emoji),disabled:!n,"aria-label":t,children:[(0,l.jsx)(`span`,{children:e.emoji}),(0,l.jsx)(`span`,{children:e.count})]},e.emoji)}),n&&(0,l.jsxs)(`div`,{className:`relative`,children:[(0,l.jsx)(a.Button,{variant:`ghost`,size:`icon`,className:`h-6 w-6`,onClick:()=>c(!s),"aria-label":u(`detail.addReaction`),children:(0,l.jsx)(o.SmilePlus,{className:`h-3.5 w-3.5`})}),s&&(0,l.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":u(`detail.emojiPicker`),children:r.map(t=>(0,l.jsx)(`button`,{type:`button`,className:`hover:bg-accent rounded p-1 text-base transition-colors`,onClick:()=>d(t),role:`option`,"aria-selected":e.some(e=>e.emoji===t&&e.reacted),children:t},t))})]})]})};function Je(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 Ye=({parentItem:e,replies:n,onAddReply:r,showReplyInput:i=!0,className:s})=>{let{t:c}=D(),[u,d]=t.useState(!1),[f,p]=t.useState(``),[m,h]=t.useState(!1),g=t.useCallback(async()=>{let t=f.trim();if(!(!t||!r)){h(!0);try{await r(e.id,t),p(``)}finally{h(!1)}}},[f,r,e.id]),_=t.useCallback(e=>{e.key===`Enter`&&(e.ctrlKey||e.metaKey)&&(e.preventDefault(),g())},[g]);return n.length===0&&!i?null:(0,l.jsxs)(`div`,{className:(0,a.cn)(`ml-10 mt-1`,s),children:[n.length>0&&(0,l.jsxs)(`button`,{type:`button`,className:`flex items-center gap-1 text-xs text-muted-foreground hover:text-foreground transition-colors mb-1`,onClick:()=>d(!u),"aria-expanded":u,children:[u?(0,l.jsx)(o.ChevronDown,{className:`h-3 w-3`}):(0,l.jsx)(o.ChevronRight,{className:`h-3 w-3`}),(0,l.jsx)(o.MessageSquare,{className:`h-3 w-3`}),(0,l.jsx)(`span`,{children:n.length===1?c(`detail.replyCount`,{count:n.length}):c(`detail.replyCountPlural`,{count:n.length})})]}),u&&(0,l.jsx)(`div`,{className:`space-y-2 border-l-2 border-border pl-3`,children:n.map(e=>(0,l.jsxs)(`div`,{className:`flex gap-2`,children:[(0,l.jsx)(`div`,{className:`shrink-0`,children:e.actorAvatarUrl?(0,l.jsx)(`img`,{src:e.actorAvatarUrl,alt:e.actor,className:`h-6 w-6 rounded-full object-cover`}):(0,l.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,l.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,l.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,l.jsx)(`span`,{className:`text-xs font-medium`,children:e.actor}),(0,l.jsx)(`span`,{className:`text-[10px] text-muted-foreground`,children:Je(e.createdAt,c)})]}),(0,l.jsx)(`p`,{className:`text-xs whitespace-pre-wrap break-words`,children:e.body})]})]},e.id))}),i&&r&&(0,l.jsxs)(`div`,{className:`flex gap-1.5 mt-1.5`,children:[(0,l.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:c(`detail.replyPlaceholder`),value:f,onChange:e=>p(e.target.value),onKeyDown:_,disabled:m}),(0,l.jsx)(a.Button,{variant:`ghost`,size:`icon`,className:`h-6 w-6 shrink-0`,onClick:g,disabled:!f.trim()||m,"aria-label":`Send reply`,children:(0,l.jsx)(o.Send,{className:`h-3 w-3`})})]})]})},Xe=({subscription:e,onToggle:n,className:r})=>{let{t:i}=D(),[s,c]=t.useState(!1),u=t.useCallback(async()=>{if(n){c(!0);try{await n(!e.subscribed)}finally{c(!1)}}},[n,e.subscribed]);return(0,l.jsx)(a.Button,{variant:`ghost`,size:`icon`,className:(0,a.cn)(`h-8 w-8`,r),onClick:u,disabled:s||!n,"aria-label":e.subscribed?i(`detail.unsubscribeAriaLabel`):i(`detail.subscribeAriaLabel`),title:e.subscribed?i(`detail.subscribedTooltip`):i(`detail.unsubscribedTooltip`),children:e.subscribed?(0,l.jsx)(o.Bell,{className:`h-4 w-4 text-primary`}):(0,l.jsx)(o.BellOff,{className:`h-4 w-4 text-muted-foreground`})})};function Ze(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 Qe=({value:e,onChange:n,onSubmit:r,mentionSuggestions:i=[],placeholder:s,className:c,disabled:u=!1,extraSlot:d,canSubmitEmpty:f=!1})=>{let{t:p}=D(),[m,h]=t.useState(!1),[g,_]=t.useState(!1),[v,y]=t.useState(``),[b,x]=t.useState(0),S=t.useRef(null),C=t.useMemo(()=>{if(!v)return i;let e=v.toLowerCase();return i.filter(t=>t.label.toLowerCase().includes(e))},[v,i]),w=t.useCallback((t,r=``)=>{let i=S.current;if(!i)return;let a=i.selectionStart,o=i.selectionEnd,s=e.slice(a,o);n(e.slice(0,a)+t+s+r+e.slice(o)),requestAnimationFrame(()=>{i.focus();let e=a+t.length+s.length;i.setSelectionRange(e,e)})},[e,n]),T=t.useCallback(()=>w(`**`,`**`),[w]),E=t.useCallback(()=>w(`*`,`*`),[w]),O=t.useCallback(()=>w(`
|
|
2
|
-
- `,``),[w]),k=t.useCallback(()=>w("`","`"),[w]),A=t.useCallback(()=>{w(`@`,``),_(!0),y(``),x(0)},[w]),j=t.useCallback(t=>{let r=S.current;if(!r)return;let i=r.selectionStart,a=e.slice(0,i).lastIndexOf(`@`);a!==-1&&n(e.slice(0,a)+`@${t.label} `+e.slice(i)),_(!1),y(``),requestAnimationFrame(()=>r.focus())},[e,n]),M=t.useCallback(e=>{let t=e.target.value;n(t);let r=e.target.selectionStart,i=t.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)){_(!0),y(e),x(0);return}}_(!1)},[n]),N=t.useCallback(e=>{if(g&&C.length>0){if(e.key===`ArrowDown`){e.preventDefault(),x(e=>e<C.length-1?e+1:0);return}if(e.key===`ArrowUp`){e.preventDefault(),x(e=>e>0?e-1:C.length-1);return}if(e.key===`Enter`||e.key===`Tab`){e.preventDefault(),j(C[b]);return}if(e.key===`Escape`){_(!1);return}}e.key===`Enter`&&(e.ctrlKey||e.metaKey)&&(e.preventDefault(),r?.())},[g,C,b,j,r]);return(0,l.jsxs)(`div`,{className:(0,a.cn)(`border rounded-md`,c),children:[(0,l.jsxs)(`div`,{className:`flex items-center gap-0.5 px-2 py-1.5 border-b bg-muted/30`,children:[(0,l.jsx)(a.Button,{variant:`ghost`,size:`icon`,className:`h-7 w-7`,onClick:T,disabled:u||m,title:p(`detail.bold`),children:(0,l.jsx)(o.Bold,{className:`h-3.5 w-3.5`})}),(0,l.jsx)(a.Button,{variant:`ghost`,size:`icon`,className:`h-7 w-7`,onClick:E,disabled:u||m,title:p(`detail.italic`),children:(0,l.jsx)(o.Italic,{className:`h-3.5 w-3.5`})}),(0,l.jsx)(a.Button,{variant:`ghost`,size:`icon`,className:`h-7 w-7`,onClick:O,disabled:u||m,title:p(`detail.listFormat`),children:(0,l.jsx)(o.List,{className:`h-3.5 w-3.5`})}),(0,l.jsx)(a.Button,{variant:`ghost`,size:`icon`,className:`h-7 w-7`,onClick:k,disabled:u||m,title:p(`detail.inlineCode`),children:(0,l.jsx)(o.Code,{className:`h-3.5 w-3.5`})}),(0,l.jsx)(a.Button,{variant:`ghost`,size:`icon`,className:`h-7 w-7`,onClick:A,disabled:u||m,title:p(`detail.mentionSomeone`),children:(0,l.jsx)(o.AtSign,{className:`h-3.5 w-3.5`})}),(0,l.jsx)(`div`,{className:`flex-1`}),(0,l.jsx)(a.Button,{variant:`ghost`,size:`icon`,className:`h-7 w-7`,onClick:()=>h(!m),title:p(m?`detail.edit`:`detail.preview`),children:m?(0,l.jsx)(o.Edit,{className:`h-3.5 w-3.5`}):(0,l.jsx)(o.Eye,{className:`h-3.5 w-3.5`})}),r&&(0,l.jsx)(a.Button,{variant:`ghost`,size:`icon`,className:`h-7 w-7`,onClick:r,disabled:u||!f&&!e.trim(),title:p(`detail.submitComment`),children:(0,l.jsx)(o.Send,{className:`h-3.5 w-3.5`})})]}),(0,l.jsx)(`div`,{className:`relative`,children:m?(0,l.jsx)(`div`,{className:`min-h-[80px] px-3 py-2 text-sm prose prose-sm max-w-none`,dangerouslySetInnerHTML:{__html:Ze(e)}}):(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(`textarea`,{ref:S,className:`w-full min-h-[80px] px-3 py-2 text-sm bg-transparent resize-none focus:outline-none placeholder:text-muted-foreground`,placeholder:s??p(`detail.writeComment`),value:e,onChange:M,onKeyDown:N,disabled:u}),g&&C.length>0&&(0,l.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:C.map((e,t)=>(0,l.jsxs)(`button`,{type:`button`,className:(0,a.cn)(`w-full text-left px-3 py-1.5 text-sm flex items-center gap-2 hover:bg-accent transition-colors`,t===b&&`bg-accent`),onMouseDown:t=>{t.preventDefault(),j(e)},children:[e.avatarUrl?(0,l.jsx)(`img`,{src:e.avatarUrl,alt:e.label,className:`h-5 w-5 rounded-full object-cover`}):(0,l.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,l.jsx)(`span`,{children:e.label})]},e.id))})]})}),d&&(0,l.jsx)(`div`,{className:`border-t px-2 py-2 bg-muted/20`,children:d})]})};function $e(e){return e<1024?`${e} B`:e<1048576?`${(e/1024).toFixed(1)} KB`:`${(e/1048576).toFixed(1)} MB`}function et(e){return e.startsWith(`image/`)}function tt(e){return et(e)?o.Image:e.includes(`pdf`)||e.includes(`document`)||e.includes(`text`)?o.FileText:e.includes(`zip`)||e.includes(`archive`)||e.includes(`compressed`)?o.FileArchive:o.File}var nt=({attachments:e,onUpload:n,onRemove:r,className:i,readOnly:s=!1})=>{let{t:c}=D(),[u,d]=t.useState(!1),f=t.useRef(null),p=t.useCallback(e=>{e.preventDefault(),e.stopPropagation(),d(!0)},[]),m=t.useCallback(e=>{e.preventDefault(),e.stopPropagation(),d(!1)},[]),h=t.useCallback(e=>{e.preventDefault(),e.stopPropagation(),d(!1),n&&e.dataTransfer.files.length>0&&n(e.dataTransfer.files)},[n]),g=t.useCallback(e=>{n&&e.target.files&&e.target.files.length>0&&(n(e.target.files),e.target.value=``)},[n]);return(0,l.jsxs)(`div`,{className:(0,a.cn)(`space-y-2`,i),children:[n&&!s&&(0,l.jsxs)(`div`,{className:(0,a.cn)(`border-2 border-dashed rounded-md px-4 py-3 text-center transition-colors cursor-pointer`,u?`border-primary bg-primary/5`:`border-muted-foreground/25 hover:border-muted-foreground/40`),onDragOver:p,onDragLeave:m,onDrop:h,onClick:()=>f.current?.click(),role:`button`,tabIndex:0,onKeyDown:e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),f.current?.click())},children:[(0,l.jsx)(o.Upload,{className:`h-5 w-5 mx-auto text-muted-foreground mb-1`}),(0,l.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:c(`detail.dropFilesToUpload`)}),(0,l.jsx)(`input`,{ref:f,type:`file`,multiple:!0,className:`hidden`,onChange:g})]}),e.length>0&&(0,l.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,l.jsxs)(`div`,{className:`flex items-center gap-1.5 text-xs text-muted-foreground`,children:[(0,l.jsx)(o.Paperclip,{className:`h-3 w-3`}),(0,l.jsx)(`span`,{children:e.length===1?c(`detail.attachmentCount`,{count:e.length}):c(`detail.attachmentCountPlural`,{count:e.length})})]}),(0,l.jsx)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 gap-2`,children:e.map(e=>{let t=et(e.type),n=tt(e.type);return(0,l.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,l.jsx)(`img`,{src:e.thumbnailUrl||e.url,alt:e.name,className:`h-10 w-10 rounded object-cover shrink-0`}):(0,l.jsx)(`div`,{className:`h-10 w-10 rounded bg-muted flex items-center justify-center shrink-0`,children:(0,l.jsx)(n,{className:`h-5 w-5 text-muted-foreground`})}),(0,l.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,l.jsx)(`p`,{className:`text-xs font-medium truncate`,children:e.name}),(0,l.jsx)(`p`,{className:`text-[10px] text-muted-foreground`,children:$e(e.size)})]}),r&&!s&&(0,l.jsx)(a.Button,{variant:`ghost`,size:`icon`,className:`h-6 w-6 shrink-0 opacity-0 group-hover:opacity-100 transition-opacity`,onClick:()=>r(e.id),title:c(`detail.removeAttachment`),children:(0,l.jsx)(o.X,{className:`h-3.5 w-3.5`})})]},e.id)})})]})]})},rt={comment:o.MessageSquare,field_change:o.Edit,task:o.CheckSquare,event:o.Calendar,system:o.Zap,email:o.Mail,call:o.Phone,note:o.StickyNote,file:o.FileText,sharing:o.Share2,record_create:o.PlusCircle,record_delete:o.Trash2,approval:o.BadgeCheck},it={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`,note:`bg-yellow-100 text-yellow-700`,file:`bg-slate-100 text-slate-600`,sharing:`bg-sky-100 text-sky-600`,record_create:`bg-emerald-100 text-emerald-600`,record_delete:`bg-red-100 text-red-600`,approval:`bg-violet-100 text-violet-600`};function at(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 ot(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 st(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 ct=({items:e,config:n,filterMode:r,onFilterChange:i,hasMore:s=!1,onLoadMore:c,loading:u=!1,onAddComment:d,onAddReply:f,onToggleReaction:p,subscription:m,onToggleSubscription:h,collapseWhenEmpty:g=!1,mentionSuggestions:_,onUploadAttachments:v,titleLabel:y,emptyLabel:b,className:x})=>{let{t:S}=D(),[C,w]=t.useState(`all`),[T,E]=t.useState(``),[O,k]=t.useState(!1),[A,j]=t.useState(!1),[M,N]=t.useState([]),[P,F]=t.useState(!1),I=r??C,L=n?.showFilterToggle!==!1,R=n?.showCommentInput!==!1&&!!d,ee=n?.enableReactions??!1,z=n?.enableThreading??!1,te=n?.showSubscriptionToggle??!1,B=t.useMemo(()=>st(e,I),[e,I]),V=t.useMemo(()=>z?B.filter(e=>!e.parentId):B,[B,z]),H=t.useMemo(()=>{if(!z)return new Map;let e=new Map;for(let t of B)if(t.parentId){let n=e.get(t.parentId)??[];n.push(t),e.set(t.parentId,n)}return e},[B,z]),ne=t.useCallback(e=>{i?i(e):w(e)},[i]),U=t.useCallback(async()=>{let e=T.trim();if(d&&!(!e&&M.length===0)){k(!0);try{await d(e,M.length>0?M:void 0),E(``),N([])}finally{k(!1)}}},[T,M,d]),W=t.useCallback(async e=>{if(!(!v||e.length===0)){F(!0);try{let t=await v(e);Array.isArray(t)&&t.length>0&&N(e=>[...e,...t])}finally{F(!1)}}},[v]),G=t.useCallback(e=>{N(t=>t.filter(t=>t.id!==e))},[]),re=t.useCallback(async()=>{if(c){j(!0);try{await c()}finally{j(!1)}}},[c]);return(0,l.jsxs)(`section`,{className:(0,a.cn)(`border-t border-border/60 pt-5`,x),"aria-label":`Discussion`,children:[(0,l.jsx)(`header`,{className:`mb-4`,children:(0,l.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,l.jsxs)(`h2`,{className:`flex items-center gap-2 text-base font-semibold leading-none tracking-tight`,children:[(0,l.jsx)(o.Activity,{className:`h-4 w-4`}),y??S(`detail.activity`),(0,l.jsxs)(`span`,{className:`text-sm font-normal text-muted-foreground`,children:[`(`,B.length,`)`]})]}),(0,l.jsx)(`div`,{className:`flex items-center gap-1`,children:te&&m&&(0,l.jsx)(Xe,{subscription:m,onToggle:h})})]})}),(0,l.jsxs)(`div`,{className:`space-y-4`,children:[L&&(0,l.jsx)(`div`,{className:`flex items-center gap-2`,children:(0,l.jsxs)(a.Select,{value:I,onValueChange:e=>ne(e),children:[(0,l.jsx)(a.SelectTrigger,{"aria-label":S(`detail.filterActivity`),className:`h-8 w-auto min-w-[140px] py-1 text-sm`,children:(0,l.jsx)(a.SelectValue,{})}),(0,l.jsx)(a.SelectContent,{children:at(S).map(e=>(0,l.jsx)(a.SelectItem,{value:e.value,children:e.label},e.value))})]})}),R&&(0,l.jsx)(Qe,{value:T,onChange:E,onSubmit:U,mentionSuggestions:_,placeholder:S(`detail.leaveCommentPlaceholder`),disabled:O,canSubmitEmpty:M.length>0,extraSlot:v?(0,l.jsx)(nt,{attachments:M,onUpload:W,onRemove:G,readOnly:O||P}):M.length>0?(0,l.jsx)(nt,{attachments:M,onRemove:G,readOnly:O}):void 0}),u&&B.length===0?(0,l.jsxs)(`div`,{role:`status`,"aria-live":`polite`,"data-testid":`activity-loading`,className:`flex items-center justify-center gap-2 py-6 text-sm text-muted-foreground`,children:[(0,l.jsx)(o.Loader2,{className:`h-4 w-4 animate-spin`}),(0,l.jsx)(`span`,{children:S(`detail.loading`)})]}):B.length===0?g?null:(0,l.jsx)(a.DataEmptyState,{title:b??S(`detail.noActivity`),className:`py-6`}):(0,l.jsxs)(`div`,{className:`relative`,children:[(0,l.jsx)(`div`,{className:`absolute left-4 top-2 bottom-2 w-px bg-border`}),(0,l.jsx)(`div`,{className:`space-y-4`,children:V.map(e=>{let t=rt[e.type]||o.Zap,n=it[e.type]||`bg-gray-100 text-gray-600`,r=H.get(e.id)??[];return(0,l.jsxs)(`div`,{children:[(0,l.jsxs)(`div`,{className:`flex gap-3 relative`,children:[(0,l.jsx)(`div`,{className:(0,a.cn)(`shrink-0 h-8 w-8 rounded-full flex items-center justify-center z-10`,n),children:e.actorAvatarUrl?(0,l.jsx)(`img`,{src:e.actorAvatarUrl,alt:e.actor,className:`h-8 w-8 rounded-full object-cover`}):(0,l.jsx)(t,{className:`h-3.5 w-3.5`})}),(0,l.jsxs)(`div`,{className:`flex-1 min-w-0 pt-1`,children:[(0,l.jsxs)(`div`,{className:`flex items-center gap-2 mb-0.5`,children:[(0,l.jsx)(`span`,{className:`text-sm font-medium`,children:e.actor}),e.source&&(0,l.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:S(`detail.via`,{source:e.source})}),(0,l.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:ot(e.createdAt,S)}),e.edited&&(0,l.jsx)(`span`,{className:`text-xs text-muted-foreground italic`,children:S(`detail.edited`)}),e.pinned&&(0,l.jsxs)(`span`,{className:`text-xs text-amber-600`,children:[`📌 `,S(`detail.pinned`)]})]}),e.body&&(0,l.jsx)(`p`,{className:`text-sm whitespace-pre-wrap break-words text-muted-foreground`,children:e.body}),e.sourceObject&&e.sourceId!=null&&(0,l.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:[S(`detail.viewSource`),(0,l.jsx)(`span`,{"aria-hidden":!0,children:`→`})]}),e.type===`field_change`&&e.fieldChanges&&(0,l.jsx)(`div`,{className:`space-y-1 mt-1`,children:e.fieldChanges.map((e,t)=>(0,l.jsx)(Ge,{change:e},t))}),ee&&e.reactions&&e.reactions.length>0&&(0,l.jsx)(`div`,{className:`mt-1.5`,children:(0,l.jsx)(qe,{reactions:e.reactions,onToggleReaction:p?t=>p(e.id,t):void 0})}),ee&&(!e.reactions||e.reactions.length===0)&&p&&(0,l.jsx)(`div`,{className:`mt-1.5`,children:(0,l.jsx)(qe,{reactions:[],onToggleReaction:t=>p(e.id,t)})})]})]}),z&&(e.replyCount??0)>0&&(0,l.jsx)(Ye,{parentItem:e,replies:r,onAddReply:f,showReplyInput:!!f})]},e.id)})})]}),s&&(0,l.jsx)(`div`,{className:`text-center pt-2`,children:(0,l.jsxs)(a.Button,{variant:`ghost`,size:`sm`,onClick:re,disabled:A,"aria-label":S(`detail.loadMore`),children:[A?(0,l.jsx)(o.Loader2,{className:`h-4 w-4 animate-spin mr-1`}):(0,l.jsx)(o.ChevronDown,{className:`h-4 w-4 mr-1`}),S(`detail.loadMore`)]})})]})]})},lt=f.FeedFilterMode.options,ut=f.FeedItemType.options,dt={created:`field_change`,updated:`field_change`,deleted:`field_change`,assigned:`field_change`,shared:`field_change`,system:`system`,completed:`task`,scheduled:`event`,commented:void 0,mentioned:void 0,login:void 0,logout:void 0},ft=new Set([`task`]);function pt(e){return typeof e==`string`&<.includes(e)?e:`all`}function mt(e,t,n){let r=t.filter(t=>!e.has(t));if(r.length!==0){for(let t of r)e.add(t);console.warn(n(r))}}var ht=new Set;function gt(e){if(e==null)return;if(!Array.isArray(e)){let t=typeof e==`string`?`"${e}"`:typeof e;return mt(ht,[`non-array ${t}`],()=>`[record:activity] ignoring an authored \`types\` that is not an array (${t}). \`types\` must be a LIST of feed item types. The timeline renders empty rather than falling back to every kind, because a filter that cannot be read is not a request to remove the filter. Declared feed item types: ${ut.join(`, `)}.`),[]}let t=[],n=[];for(let r of e)typeof r==`string`&&ut.includes(r)?t.push(r):n.push(typeof r==`string`?r:String(r));return n.length>0&&mt(ht,n,e=>`[record:activity] ignoring ${e.length} unrecognised \`types\` entr${e.length===1?`y`:`ies`}: ${e.map(e=>`"${e}"`).join(`, `)}. No declared feed item type matches, so they select nothing; only the recognised entries narrow the timeline, and a list with NO recognised entry renders an EMPTY timeline rather than every kind. Declared feed item types: ${ut.join(`, `)}.`),t}function _t(e){let t=Math.floor(Number(e));return Number.isFinite(t)&&t>0?t:20}function vt(e){let t=e.timestamp;return String(!t||t===`NOW()`||Number.isNaN(Date.parse(String(t)))?e.created_at??``:t)}var yt=new Set;function bt(e){mt(yt,[e],()=>`[record:activity] dropped a sys_activity row with type "${e}": no feed item type is mapped for it, so it cannot appear on any timeline whatever the page authors. \`sys_activity.type\` is not validated on write (every field on that object is readonly), so a producer can store a value the platform never declared. Map it in ACTIVITY_TYPE_TO_FEED_TYPE (@object-ui/plugin-detail) if it is record activity.`)}function xt(e,t){let n=String(e?.type);if(!Object.prototype.hasOwnProperty.call(dt,n))return bt(n),null;let r=dt[n];return r?{id:e.id,type:r,actor:e.actor_name??t,actorAvatarUrl:e.actor_avatar_url??void 0,body:e.summary??``,createdAt:vt(e),sourceObject:e.source_object??void 0,sourceId:e.source_id??void 0}:null}function St(e,t,n){let r=e.slice();t.unifiedTimeline===!1&&(r=r.filter(e=>e.type!==`field_change`)),t.showCompleted!==!0&&(r=r.filter(e=>!ft.has(e.type)));let i=gt(t.types);if(i!==void 0){let e=new Set(i);r=r.filter(t=>e.has(t.type))}let a=r.length,o=Math.max(1,Math.floor(n)||20);return{items:a>o?r.slice(a-o):r,total:a,hasMore:a>o}}function Ct(...e){let t=new Map;for(let n of e)for(let e of n)t.set(String(e.id),e);return Array.from(t.values()).sort((e,t)=>{let n=e.createdAt?Date.parse(e.createdAt):0,r=t.createdAt?Date.parse(t.createdAt):0;return(Number.isNaN(n)?0:n)-(Number.isNaN(r)?0:r)})}var wt=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}},Tt=({schema:e={},className:n,...i})=>{let{designer:a}=wt(i),o=(0,r.useRecordContext)(),c=(0,r.useDiscussionContext)(),u=(0,s.useSafeTranslate)(),d=e.properties??{},f=t=>e[t]??d[t],p=_t(f(`limit`)),m=pt(f(`filterMode`)),h=f(`types`),g=f(`showCompleted`),_=f(`unifiedTimeline`),v={types:h,filterMode:m,showFilterToggle:f(`showFilterToggle`),limit:p,showCompleted:g,unifiedTimeline:_,showCommentInput:f(`showCommentInput`),enableMentions:f(`enableMentions`),enableReactions:f(`enableReactions`),enableThreading:f(`enableThreading`),showSubscriptionToggle:f(`showSubscriptionToggle`)},y=Array.isArray(e.items)?e.items:Array.isArray(d.items)?d.items:void 0,b=e.loading??d.loading,x=o?.objectName,S=o?.data?.id??o?.data?._id??o?.recordId,C=o?.dataSource,w=y===void 0&&!c&&typeof C?.find==`function`&&!!x&&S!=null,[T,E]=t.default.useState(0),D=p*(T+1),[O,k]=t.default.useState(null),[A,j]=t.default.useState(!1),[M,N]=t.default.useState(!1),P=u(`detail.systemActor`,`System`);t.default.useEffect(()=>{if(!w)return;let e=!1;return N(!0),Promise.resolve(C.find(`sys_activity`,{$filter:{object_name:x,record_id:S},$orderby:{timestamp:`desc`},$top:Math.max(1,D)+1})).then(t=>{if(e)return;let n=t?.data??t?.records??[],r=Array.isArray(n)?n:[],i=[];for(let e of r){let t=xt(e,P);t&&i.push(t)}j(r.length>Math.max(1,D)),k(Ct(i))}).catch(()=>{e||(k([]),j(!1))}).finally(()=>{e||N(!1)}),()=>{e=!0}},[w,C,x,S,D,P]);let F=c?.items,I=t.default.useMemo(()=>St(y??F??O??[],{types:h,showCompleted:g,unifiedTimeline:_},D),[y,F,O,h,g,_,D]),L=I.items,R=I.hasMore||w&&A,ee=b??c?.loading??(w&&O===null?!0:M),[z,te]=t.default.useState(m);t.default.useEffect(()=>{te(m)},[m]);let B=t.default.useCallback(()=>{E(e=>e+1)},[]),V=v.enableMentions!==!1;return(0,l.jsx)(`div`,{className:n,...a,children:(0,l.jsx)(ct,{items:L,config:v,loading:ee,filterMode:z,onFilterChange:te,hasMore:R,onLoadMore:B,onAddComment:c?.onAddComment,onAddReply:c?.onAddReply,onToggleReaction:c?.onToggleReaction,mentionSuggestions:V?c?.mentionSuggestions:void 0,onUploadAttachments:c?.onUploadAttachments})})},Et=({config:e,items:n,hasMore:r,onLoadMore:i,loading:s,onAddComment:c,onAddReply:u,onToggleReaction:d,subscription:f,onToggleSubscription:p,filterMode:m,onFilterChange:h,collapseWhenEmpty:g=!1,mentionSuggestions:_,onUploadAttachments:v,className:y})=>{let b=e?.position??`right`,x=e?.width??`360px`,S=e?.collapsible??!0,C=g&&n.length===0||(e?.defaultCollapsed??!1),{t:w}=D(),[T,E]=t.useState(C);return b===`right`||b===`left`?T&&S?(0,l.jsx)(`div`,{className:(0,a.cn)(`flex items-start pt-4`,b===`right`?`border-l`:`border-r`,y),children:(0,l.jsx)(a.Button,{variant:`ghost`,size:`icon`,className:`h-8 w-8 mx-1`,onClick:()=>E(!1),"aria-label":w(`detail.openDiscussion`),children:(0,l.jsx)(o.PanelRightOpen,{className:`h-4 w-4`})})}):(0,l.jsxs)(`div`,{className:(0,a.cn)(`flex flex-col overflow-hidden`,b===`right`?`border-l`:`border-r`,y),style:{width:x,minWidth:x},children:[(0,l.jsxs)(`div`,{className:`flex items-center justify-between px-4 py-3 border-b`,children:[(0,l.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,l.jsx)(o.MessageSquare,{className:`h-4 w-4`}),(0,l.jsx)(`span`,{className:`text-sm font-medium`,children:w(`detail.discussion`)})]}),S&&(0,l.jsx)(a.Button,{variant:`ghost`,size:`icon`,className:`h-7 w-7`,onClick:()=>E(!0),"aria-label":w(`detail.closeDiscussion`),children:(0,l.jsx)(o.X,{className:`h-3.5 w-3.5`})})]}),(0,l.jsx)(`div`,{className:`flex-1 overflow-y-auto`,children:(0,l.jsx)(ct,{items:n,config:e?.feed,hasMore:r,onLoadMore:i,loading:s,onAddComment:c,onAddReply:u,onToggleReaction:d,subscription:f,onToggleSubscription:p,filterMode:m,onFilterChange:h,collapseWhenEmpty:g,mentionSuggestions:_,onUploadAttachments:v,titleLabel:w(`detail.discussion`),emptyLabel:w(`detail.noCommentsYet`),className:`border-0 shadow-none`})})]}):(0,l.jsx)(`div`,{className:(0,a.cn)(``,y),children:S&&T?(0,l.jsxs)(a.Button,{variant:`ghost`,className:`w-full justify-start gap-2 text-muted-foreground`,onClick:()=>E(!1),"aria-label":w(`detail.showDiscussion`,{count:n.length}),children:[(0,l.jsx)(o.MessageSquare,{className:`h-4 w-4`}),(0,l.jsx)(`span`,{children:w(`detail.showDiscussion`,{count:n.length})})]}):(0,l.jsxs)(`div`,{children:[S&&(0,l.jsxs)(`div`,{className:`flex items-center justify-between mb-2`,children:[(0,l.jsxs)(`div`,{className:`flex items-center gap-2 text-sm font-medium`,children:[(0,l.jsx)(o.MessageSquare,{className:`h-4 w-4`}),w(`detail.discussion`)]}),(0,l.jsx)(a.Button,{variant:`ghost`,size:`icon`,className:`h-7 w-7`,onClick:()=>E(!0),"aria-label":w(`detail.hideDiscussion`),children:(0,l.jsx)(o.PanelRightClose,{className:`h-3.5 w-3.5`})})]}),(0,l.jsx)(ct,{items:n,config:e?.feed,hasMore:r,onLoadMore:i,loading:s,onAddComment:c,onAddReply:u,onToggleReaction:d,subscription:f,onToggleSubscription:p,filterMode:m,onFilterChange:h,collapseWhenEmpty:g,mentionSuggestions:_,onUploadAttachments:v,titleLabel:w(`detail.discussion`),emptyLabel:w(`detail.noCommentsYet`)})]})})},Dt=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}},Ot=({schema:e={},className:t,...n})=>{(0,r.useRecordContext)();let i=(0,r.useDiscussionContext)(),{designer:a}=Dt(n),o={position:`bottom`,collapsible:!1,feed:{enableReactions:!0,enableThreading:!0,showCommentInput:!0},...e};return(0,l.jsx)(`div`,{className:t,...a,children:(0,l.jsx)(Et,{items:i?.items||[],config:o,loading:i?.loading,onAddComment:i?.onAddComment,onAddReply:i?.onAddReply,onToggleReaction:i?.onToggleReaction,mentionSuggestions:i?.mentionSuggestions,onUploadAttachments:i?.onUploadAttachments})})},kt=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}},At=({schema:e={},className:n,...i})=>{let o=(0,r.useRecordContext)(),{translateOptions:s}=(0,r.useSafeFieldLabel)(),{t:c}=D(),{designer:u}=kt(i),d=Array.isArray(e.stages)?e.stages:[],f=e.statusField,p=t.default.useMemo(()=>{if(d.length===0||!f||!o?.objectName)return d;let e=s(o.objectName,f,d);return Array.isArray(e)&&e.length===d.length?d.map((t,n)=>({...t,label:e[n]?.label??t.label})):d},[d,f,o?.objectName,s]),m=f&&o?.data?o.data[f]:void 0,h=/(^|[_-\s])(closed_)?(lost|failed?|cancell?ed|失败|流失|丢单|败)([_-\s]|$)/i,g=/(^|[_-\s])(closed_)?(won|success|成交|赢|完成)([_-\s]|$)/i,_=p.map(e=>{if(e.terminal)return e.terminal;let t=`${String(e.value??``)} ${String(e.label??``)}`;if(h.test(t))return`lost`;if(g.test(t))return`won`}),v=_.findIndex(e=>e===`lost`),y=v===-1?p:p.slice(0,v),b=v===-1?[]:p.slice(v),x=y.length-1,S=_.map((e,t)=>e===`won`?t===x?`won`:void 0:e),C=p.findIndex(e=>e.value===m);C<0&&(C=-1);let w=v!==-1&&C>=v;if(p.length===0)return(0,l.jsx)(`div`,{className:n,...u,children:(0,l.jsx)(`div`,{className:`text-xs text-muted-foreground italic px-3 py-2 border border-dashed rounded`,children:`record:path — no stages configured`})});let T=(e,t)=>(0,a.cn)(`h-1.5 w-full rounded-full`,t===`lost`&&(e===`current`?`bg-destructive`:`bg-destructive/25`),t!==`lost`&&e===`current`&&`bg-primary`,t!==`lost`&&e===`completed`&&`bg-emerald-500`,t!==`lost`&&e===`upcoming`&&(t===`won`?`bg-emerald-500/30`:`bg-muted`)),E=(e,t)=>(0,a.cn)(`block min-w-0 text-xs`,e===`current`&&(t===`lost`?`font-semibold text-destructive`:`font-semibold text-foreground`),e===`completed`&&`font-normal text-muted-foreground`,e===`upcoming`&&`font-normal text-muted-foreground`),O=(e,t,n)=>c(n===`lost`?t===`current`?`detail.pathStageLostCurrent`:`detail.pathStageLostUpcoming`:n===`won`&&t===`upcoming`?`detail.pathStageWonUpcoming`:t===`current`?`detail.pathStageCurrent`:t===`completed`?`detail.pathStageCompleted`:`detail.pathStageUpcoming`,{stage:e}),k=e=>(0,l.jsxs)(`div`,{role:`listitem`,"data-stage-state":e.state,"data-stage-terminal":e.terminal,"aria-current":e.state===`current`?`step`:void 0,"aria-label":O(e.stage.label,e.state,e.terminal),className:(0,a.cn)(`flex flex-col gap-1.5`,e.className),children:[(0,l.jsx)(`span`,{"aria-hidden":`true`,"data-stage-rail":``,className:T(e.state,e.terminal)}),(0,l.jsxs)(`span`,{className:(0,a.cn)(E(e.state,e.terminal),e.labelClassName),children:[e.terminal===`lost`&&(0,l.jsx)(`span`,{"aria-hidden":`true`,className:`mr-1 opacity-70`,children:`✗`}),e.terminal!==`lost`&&e.state===`completed`&&(0,l.jsx)(`span`,{"aria-hidden":`true`,className:`mr-1 text-emerald-600 dark:text-emerald-400 font-semibold`,children:`✓`}),e.stage.label]})]},e.key);return(0,l.jsxs)(`div`,{className:(0,a.cn)(`w-full`,n),...u,children:[(0,l.jsxs)(`div`,{className:`hidden sm:flex w-full items-start gap-2`,role:`list`,"aria-label":e.aria?.label||c(`detail.pathLabel`),children:[(0,l.jsx)(`div`,{className:`flex flex-1 items-start gap-1.5`,children:y.map((e,t)=>{let n=!w&&C>=0&&t<C,r=!w&&t===C;return k({key:`${e.value}-${t}`,stage:e,state:r?`current`:n?`completed`:`upcoming`,terminal:S[t],className:`flex-1 min-w-0`,labelClassName:`text-center truncate`})})}),b.length>0&&(0,l.jsx)(`div`,{className:`flex items-start gap-1.5 pl-2 border-l border-border/40`,children:b.map((e,t)=>{let n=v+t;return k({key:`${e.value}-lost-${t}`,stage:e,state:n===C?`current`:`upcoming`,terminal:S[n],className:`shrink-0`,labelClassName:`text-center whitespace-nowrap`})})})]}),(0,l.jsx)(`div`,{className:`flex sm:hidden w-full items-start gap-2 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||c(`detail.pathLabel`),children:p.map((e,t)=>{let n=S[t],r=n!==`lost`&&!w&&C>=0&&t<C,i=t===C;return k({key:`${e.value}-${t}-m`,stage:e,state:i?`current`:r?`completed`:`upcoming`,terminal:n,className:`shrink-0`,labelClassName:`whitespace-nowrap`})})})]})},jt=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}},Mt=({schema:e={},className:t,...n})=>{let i=(0,r.useRecordContext)(),{designer:o}=jt(n),s=(0,u.usePermissions)(),c=(0,r.useActionTextLocalizer)(),d=Array.isArray(e.actions)?e.actions:Array.isArray(e.properties?.actions)?e.properties.actions:[],f=Array.isArray(e.actionNames)?e.actionNames:Array.isArray(e.properties?.actionNames)?e.properties.actionNames:[],p=i?.objectName||``,m=f.length>0?f:Array.isArray(d)&&d.every(e=>typeof e==`string`)?d:[],h=m.length>0&&!!p,{item:g}=(0,r.useMetadataItem)(`object`,h?p:null),_=(h?(()=>{let e=Array.isArray(g?.actions)?g.actions:[],t=new Map(e.map(e=>[e.name,e]));return m.map(e=>t.get(e)).filter(e=>!!e)})():Array.isArray(d)?d:[]).map((e,t)=>c(p||void 0,e,{fallbackLabel:`Action ${t+1}`})),v=Array.isArray(e.requiredPermissions)?e.requiredPermissions:[],y=e.location||`record_header`,{getActionsForLocation:b,executeAction:x}=(0,r.useActionEngine)({actions:_,context:{record:i?.data,recordId:i?.recordId,objectName:i?.objectName}});if(v.length>0&&p&&!v.every(e=>s.can(p,e)))return(0,l.jsx)(`div`,{className:t,...o,role:`status`,"aria-live":`polite`,children:(0,l.jsx)(`p`,{className:`text-sm text-muted-foreground italic`,children:`Insufficient permissions to view quick actions.`})});let S=_.length>0?b(y):[];if(S.length===0)return(0,l.jsx)(`div`,{className:t,...o,children:(0,l.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 C=e.align||`end`,w=C===`start`?`justify-start`:C===`center`?`justify-center`:`justify-end`,T=y===`record_header`&&!e.inline,E=(e.aria?.ariaLabel??e.aria?.label)||`Quick actions`;return(0,l.jsx)(`div`,{className:(0,a.cn)(`flex flex-wrap items-center gap-2`,T&&`-mt-12 sm:-mt-14 mb-2 relative z-10`,w,t),role:`toolbar`,"aria-label":E,...o,children:S.map((t,n)=>(0,l.jsx)(Nt,{action:t,record:i?.data,variant:t.variant||e.variant||`default`,size:t.size||e.size||`sm`,label:t.label||`Action ${n+1}`,onRun:async()=>{typeof t.onClick==`function`?await t.onClick():t.name&&await x(t.name)}},t.name||`qa-${n}`))})};function Nt({action:e,record:n,variant:i,size:s,label:c,onRun:u}){let[d,f]=t.default.useState(!1),p=t.default.useMemo(()=>({record:n||{}}),[n]),m=(0,r.useCondition)((0,r.toPredicateInput)(e.disabled),p),h=((0,a.hasDeclaredVisibilityGate)(e.disabled)?m:!1)||d;return(0,l.jsxs)(a.Button,{variant:i,size:s,disabled:h,onClick:async()=>{f(!0);try{await u()}finally{f(!1)}},children:[d&&(0,l.jsx)(o.Loader2,{className:`mr-2 h-4 w-4 animate-spin`}),c]})}var Pt=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}},Ft=new Set([`created`,`updated`,`assigned`,`shared`,`deleted`]),It=({schema:e={},className:n,...i})=>{let{designer:a}=Pt(i),o=(0,r.useRecordContext)(),s=Array.isArray(e.entries)?e.entries:Array.isArray(e.properties?.entries)?e.properties.entries:void 0,c=e.loading??e.properties?.loading,u=e.emptyText??e.properties?.emptyText,d=e.unknownUserText??e.properties?.unknownUserText,f=Number(e.limit??e.properties?.limit??50)||50,p=o?.objectName,m=o?.data?.id??o?.data?._id??o?.recordId,h=o?.dataSource,g=s===void 0&&!!h?.find&&!!p&&m!=null,[_,v]=t.default.useState(null),[y,b]=t.default.useState(!1);t.default.useEffect(()=>{if(!g)return;let e=!1;return b(!0),Promise.resolve(h.find(`sys_activity`,{$filter:{object_name:p,record_id:m},$orderby:{timestamp:`desc`},$top:Math.max(1,f)})).then(t=>{if(e)return;let n=(t?.data??t?.records??[]).filter(e=>Ft.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}});v(n)}).catch(()=>{e||v([])}).finally(()=>{e||b(!1)}),()=>{e=!0}},[g,h,p,m,f]);let x=s??_??[],S=c??(g&&_===null?y||!0:!1);return(0,l.jsx)(`div`,{className:n,...a,children:(0,l.jsx)(Ce,{entries:x,loading:S,emptyText:u,unknownUserText:d})})},Lt=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}},Rt=e=>e.replace(/[_-]+/g,` `).replace(/\b\w/g,e=>e.toUpperCase()).trim(),zt=(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||`—`,Bt=({schema:e={},className:n,...i})=>{let s=(0,r.useRecordContext)(),u=(0,r.useSafeFieldLabel)(),{t:d}=D(),{designer:f}=Lt(i),p=(0,c.useParams)().appName,m=Array.isArray(e.entries)?e.entries:Array.isArray(e.properties?.entries)?e.properties.entries:[],h=s?.recordId,g=s?.dataSource,[_,v]=t.default.useState({}),y=t.default.useRef(null),[b,x]=t.default.useState(!1),S=t.default.useRef(!0);t.default.useEffect(()=>(S.current=!0,()=>{S.current=!1}),[]);let C=t.default.useRef(``);t.default.useEffect(()=>{if(b)return;let e=y.current;if(!e||typeof IntersectionObserver>`u`){x(!0);return}let t=new IntersectionObserver(e=>{e.some(e=>e.isIntersecting)&&x(!0)},{rootMargin:`200px`});return t.observe(e),()=>t.disconnect()},[b]);let w=JSON.stringify(m.map(e=>`${e.objectName}:${e.relationshipField}:${e.limit??3}`));t.default.useEffect(()=>{if(!b||!g?.find||!h||m.length===0)return;let e=`${h}::${w}`;if(C.current===e)return;C.current=e,v(e=>{let t={...e};for(let n of m)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 g.find(e.objectName,{$filter:{[e.relationshipField]:h},$top:e.limit??3,$count:!0});if(!S.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;v(e=>({...e,[t]:{loading:!1,total:i,items:r}}))}catch(e){if(!S.current)return;v(n=>({...n,[t]:{loading:!1,total:0,items:[],error:String(e?.message||e)}}))}},n=[...m],r=async()=>{for(;S.current;){let e=n.shift();if(!e)return;await t(e)}},i=Array.from({length:Math.min(3,n.length)},()=>r());Promise.all(i)},[b,g,h,w]);let[T,E]=t.default.useState(!1);if(m.length===0)return null;let O=e.hideEmpty!==!1,k=new Set(m.filter(e=>{let t=_[e.objectName];return O&&t&&!t.loading&&!t.error&&t.total===0}).map(e=>e.objectName)),A=m.filter(e=>T||!k.has(e.objectName)),j=m.filter(e=>k.has(e.objectName)).map(e=>e.title||(u?.objectLabel?u.objectLabel({name:e.objectName,label:Rt(e.objectName)}):Rt(e.objectName)));return(0,l.jsxs)(`div`,{ref:y,className:(0,a.cn)(`flex flex-col gap-3`,e.className,n),...f,children:[A.map(e=>{let t=e.objectName,n=_[t]||{loading:!0,total:0,items:[]},r=e.title||(u?.objectLabel?u.objectLabel({name:e.objectName,label:Rt(e.objectName)}):Rt(e.objectName));return(0,l.jsxs)(a.Card,{className:`overflow-hidden`,children:[(0,l.jsxs)(a.CardHeader,{className:`flex flex-row items-center justify-between gap-2 py-3 px-4 space-y-0 border-b`,children:[(0,l.jsx)(a.CardTitle,{className:`text-sm font-semibold tracking-tight truncate`,children:r}),(0,l.jsxs)(`div`,{className:`flex items-center gap-2 shrink-0`,children:[!n.loading&&(0,l.jsx)(a.Badge,{variant:`secondary`,className:`tabular-nums`,children:n.total}),p&&h&&(0,l.jsx)(c.Link,{to:`/apps/${p}/${e.objectName}?filter%5B${e.relationshipField}%5D=${encodeURIComponent(String(h))}`,className:`text-[11px] font-medium text-muted-foreground hover:text-foreground transition-colors`,title:d(`detail.viewAll`,{defaultValue:`View All`}),children:d(`detail.viewAll`,{defaultValue:`View All`})})]})]}),(0,l.jsx)(a.CardContent,{className:`p-0`,children:n.loading?(0,l.jsxs)(`div`,{className:`space-y-1.5 p-3`,children:[(0,l.jsx)(a.Skeleton,{className:`h-3.5 w-4/5`}),(0,l.jsx)(a.Skeleton,{className:`h-3.5 w-3/5`}),(0,l.jsx)(a.Skeleton,{className:`h-3.5 w-2/3`})]}):n.items.length===0?(0,l.jsx)(`p`,{className:`px-4 py-3 text-xs text-muted-foreground`,children:d(`detail.noRecords`)}):(0,l.jsx)(`ul`,{className:`divide-y`,children:n.items.map(t=>{let n=t.id||t._id,r=zt(t,e.displayField),i=n?`../${e.objectName}/record/${encodeURIComponent(String(n))}`:void 0;return(0,l.jsx)(`li`,{className:`px-4 py-2`,children:i?(0,l.jsxs)(c.Link,{to:i,className:`group flex items-center justify-between gap-2 text-xs hover:text-foreground text-muted-foreground transition-colors`,children:[(0,l.jsx)(`span`,{className:`truncate`,children:r}),(0,l.jsx)(o.ChevronRight,{className:`h-3 w-3 shrink-0 opacity-0 group-hover:opacity-100 transition-opacity`})]}):(0,l.jsx)(`span`,{className:`block truncate text-xs text-muted-foreground`,children:r})},String(n||r))})})})]},t)}),!T&&j.length>0&&(0,l.jsxs)(`button`,{type:`button`,onClick:()=>E(!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:j.join(` · `),children:[(0,l.jsx)(`span`,{children:d(`detail.showEmptyRelated`,{defaultValue:`+ {{count}} empty`,count:j.length})}),(0,l.jsxs)(`span`,{className:`truncate max-w-[180px] text-muted-foreground/70`,children:[`(`,j.join(` · `),`)`]})]})]})},Vt={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 Ht(e){let t=e?.properties??{};return{...e,...t}}var Ut=({schema:e={},className:n})=>{let i=Ht(e),o=(0,r.useRecordContext)(),c=o?.data,u=o?.objectName||``,d=o?.recordId??c?.id,{language:f}=(0,s.useObjectTranslation)(),p=(0,s.pickLocalized)(i.title,f),m=(0,s.pickLocalized)(i.body,f),h=(0,s.pickLocalized)(i.action?.label,f),g=[`info`,`warning`,`error`,`success`].includes(i.severity)?i.severity:`info`,_=Vt[g],v=i.icon||_.icon,y=(0,r.usePredicateRecordContext)(c),b=(0,r.toPredicateInput)(i.visible),x=!!c&&Object.keys(c).length>0,S=(0,r.useCondition)(x?b:void 0,y),C=t.useMemo(()=>{if(!i.dismissible)return null;let e=i.dismissKey||(0,s.pickLocalized)(i.title,`en`)||g;return`os.record-alert:${u}:${d??`_`}:${e}`},[i.dismissible,i.dismissKey,i.title,g,u,d]),[w,T]=t.useState(()=>{if(!C||typeof window>`u`)return!1;try{return window.localStorage.getItem(C)===`1`}catch{return!1}}),E=i.action?.actionName,{item:D}=(0,r.useMetadataItem)(`object`,E&&u?u:null),O=t.useMemo(()=>{if(!(!E||!D?.actions))return D.actions.find(e=>e.name===E)},[E,D]),k=t.useMemo(()=>O?[O]:[],[O]),{executeAction:A}=(0,r.useActionEngine)({actions:k,context:{record:c,recordId:d,objectName:u}});return w||!x||b!==void 0&&!S?null:(0,l.jsxs)(a.Alert,{className:(0,a.cn)(`relative pr-12`,_.wrap,n),role:g===`error`?`alert`:`status`,"aria-live":g===`error`?`assertive`:`polite`,children:[(0,l.jsx)(a.LazyIcon,{name:v,className:`h-4 w-4`,"aria-hidden":`true`}),p?(0,l.jsx)(a.AlertTitle,{children:p}):null,m||O?(0,l.jsxs)(a.AlertDescription,{children:[m?(0,l.jsx)(`p`,{className:`mb-2 last:mb-0`,children:m}):null,O?(0,l.jsx)(a.Button,{size:`sm`,variant:i.action?.variant||(g===`error`?`destructive`:`default`),onClick:()=>{O?.name&&A(O.name)},children:h||O.label||O.name}):null]}):null,i.dismissible?(0,l.jsx)(`button`,{type:`button`,onClick:()=>{if(T(!0),C)try{window.localStorage.setItem(C,`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,l.jsx)(a.LazyIcon,{name:`X`,className:`h-4 w-4`,"aria-hidden":`true`})}):null]})},Wt=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)}},Gt=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()}},Kt=({open:e,conflict:t,onReload:n,onOverwrite:r,onCancel:i,busy:s=!1})=>{let{t:c}=D(),u=t?.label||t?.field||``,d=t?Wt(t.pendingValue):``,f=t?Wt(t.currentValue):``,p=t?.currentRecord??{},m=(()=>{let e=[p.updated_by_name,p.updated_by_label];for(let t of e)if(typeof t==`string`&&t.length>0)return t;let t=p.updated_by;return typeof t!=`string`||t.length===0||t.length>=16&&!/\s/.test(t)&&/^[A-Za-z0-9_-]+$/.test(t)?null:t})(),h=Gt(p.updated_at??t?.currentVersion),[g,_]=c(`detail.concurrentUpdateDescription`,{field:`{{field}}`}).split(`{{field}}`);return(0,l.jsx)(a.AlertDialog,{open:e,onOpenChange:e=>{!e&&!s&&i()},children:(0,l.jsxs)(a.AlertDialogContent,{className:`max-w-lg`,children:[(0,l.jsx)(a.AlertDialogHeader,{children:(0,l.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,l.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,l.jsx)(o.AlertTriangle,{className:`h-5 w-5`})}),(0,l.jsxs)(`div`,{className:`flex-1`,children:[(0,l.jsx)(a.AlertDialogTitle,{children:c(`detail.concurrentUpdateTitle`)}),(0,l.jsxs)(a.AlertDialogDescription,{className:`mt-1`,children:[g,(0,l.jsx)(`strong`,{className:`font-semibold`,children:u}),_]})]})]})}),(0,l.jsxs)(`div`,{className:`space-y-2 text-sm`,children:[(0,l.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,l.jsx)(`div`,{className:`text-xs font-medium uppercase tracking-wide text-amber-800 dark:text-amber-300`,children:c(`detail.concurrentUpdateYourEdit`)}),(0,l.jsx)(`div`,{className:`mt-1 break-all font-mono text-foreground`,children:d})]}),(0,l.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,l.jsxs)(`div`,{className:`flex items-baseline justify-between gap-2`,children:[(0,l.jsx)(`div`,{className:`text-xs font-medium uppercase tracking-wide text-sky-800 dark:text-sky-300`,children:c(`detail.concurrentUpdateCurrentValue`)}),(m||h)&&(0,l.jsxs)(`div`,{className:`text-[11px] text-muted-foreground`,children:[m&&(0,l.jsx)(`span`,{children:c(`detail.concurrentUpdateUpdatedBy`,{name:m})}),m&&h&&(0,l.jsx)(`span`,{children:` · `}),h&&(0,l.jsx)(`span`,{children:c(`detail.concurrentUpdateUpdatedAt`,{when:h})})]})]}),(0,l.jsx)(`div`,{className:`mt-1 break-all font-mono text-foreground`,children:f})]})]}),(0,l.jsxs)(a.AlertDialogFooter,{className:`gap-2 sm:gap-2`,children:[(0,l.jsx)(`button`,{type:`button`,disabled:s,onClick:i,className:(0,a.cn)((0,a.buttonVariants)({variant:`ghost`}),`mt-2 sm:mt-0`),children:c(`detail.concurrentUpdateCancel`)}),(0,l.jsx)(`button`,{type:`button`,disabled:s,onClick:r,className:(0,a.cn)((0,a.buttonVariants)({variant:`outline`}),`mt-2 sm:mt-0 text-destructive border-destructive/40 hover:bg-destructive/10 hover:text-destructive`),children:c(`detail.concurrentUpdateOverwrite`)}),(0,l.jsx)(`button`,{type:`button`,disabled:s,onClick:n,autoFocus:!0,className:(0,a.cn)((0,a.buttonVariants)({variant:`default`}),`mt-2 sm:mt-0`),children:c(`detail.concurrentUpdateReload`)})]})]})})};function qt(e){if(!e||typeof e!=`object`)return!1;let t=e;return t.code===`CONCURRENT_UPDATE`||t.name===`ConcurrentUpdateError`}function Jt(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 Yt(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 Xt=({dataSource:e,objectName:n,recordId:i,data:s,refresh:c,fieldLabelFor:u,onFieldSave:d,locked:f=!1,lockedHint:p,className:m})=>{let{t:h}=D(),g=(0,r.useInlineEdit)(),[_,v]=t.useState(null),[y,b]=t.useState(!1),x=!!e&&!!n&&i!=null,S=t.useCallback((e,t)=>{let n=Object.keys(e),r=t?.currentRecord??null;if(n.length===1){let i=n[0];return{field:i,label:u?.(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:h(`detail.concurrentUpdateRecordLabel`,{defaultValue:`this record`}),pendingValue:e,currentValue:i,currentVersion:t?.currentVersion,currentRecord:r}},[u,h]),C=t.useCallback(async()=>{if(!g)return;let t=g.draft,r=Object.entries(t);if(r.length===0){g.reset();return}g.setSaving(!0),g.setError(null);try{if(d)for(let[e,t]of r)await d(e,t);else if(x){let r=typeof s?.updated_at==`string`?s.updated_at:void 0;await Yt(e,n,i,t,r?{ifMatch:r}:void 0),await c?.()}g.reset()}catch(e){qt(e)&&x?v(S(t,e)):g.setError(Jt(e))}finally{g.setSaving(!1)}},[g,d,x,s,e,n,i,c,S]),w=t.useCallback(()=>{v(null),b(!1)},[]),T=t.useCallback(async()=>{b(!0);try{await c?.()}finally{g?.reset(),w()}},[c,g,w]),E=t.useCallback(async()=>{if(!_||!x){w();return}b(!0);try{await Yt(e,n,i,g?.draft??{},_.currentVersion?{ifMatch:_.currentVersion}:void 0),await c?.(),g?.reset()}catch(e){g?.setError(Jt(e))}finally{w()}},[_,x,g,e,n,i,c,w]),O=!!g?.editing,k=!!g?.saving,A=g?.cancel,j=!!_;return t.useEffect(()=>{if(!O)return;let e=e=>{if(e.key===`Enter`&&(e.metaKey||e.ctrlKey)){if(k||f||j)return;e.preventDefault(),C();return}if(e.key===`Escape`){if(e.defaultPrevented||k||j||document.querySelector(`[data-radix-popper-content-wrapper], [role="dialog"][data-state="open"], [role="alertdialog"][data-state="open"]`))return;e.preventDefault(),A?.()}};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[O,k,f,j,C,A]),!g||!g.editing?null:(0,l.jsxs)(l.Fragment,{children:[(0,l.jsxs)(`div`,{className:(0,a.cn)(`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`,m),role:`region`,"aria-label":h(`detail.editFieldsInline`),children:[g.error&&(0,l.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:g.error}),(0,l.jsxs)(a.Button,{variant:`ghost`,size:`sm`,onClick:g.cancel,disabled:g.saving,className:`gap-2`,children:[(0,l.jsx)(o.X,{className:`h-4 w-4`}),(0,l.jsx)(`span`,{children:h(`detail.cancel`)})]}),(0,l.jsxs)(a.Button,{variant:`default`,size:`sm`,onClick:C,disabled:g.saving||f,className:`gap-2`,title:f?p:void 0,children:[g.saving?(0,l.jsx)(o.Loader2,{className:`h-4 w-4 animate-spin`}):(0,l.jsx)(o.Check,{className:`h-4 w-4`}),(0,l.jsx)(`span`,{children:g.saving?h(`detail.saving`):h(`detail.save`)})]})]}),(0,l.jsx)(Kt,{open:!!_,conflict:_,busy:y,onCancel:w,onReload:T,onOverwrite:E})]})},Zt=new Set(d.SYSTEM_MANAGED_FIELD_NAMES),Qt=480,$t=95;function en({open:e,onClose:n,title:i,record:o,objectName:s,recordId:c,dataSource:u,objectSchema:d,width:f=`min(960px, 60vw)`,columns:p=2,systemFields:m=Zt,onFieldSave:h,onDelete:g,resizable:_=!0,fullPageHref:v}){let{t:y}=D(),b=`objectui.drawerWidth.${s}`,[x,S]=t.default.useState(()=>{if(typeof window>`u`||!_)return null;try{let e=window.localStorage.getItem(b);if(e){let t=parseInt(e,10);if(Number.isFinite(t)&&t>=Qt)return t}}catch{}return null}),C=t.default.useMemo(()=>_&&x!=null?`${x}px`:typeof f==`number`?`${f}px`:f,[_,x,f]),w=C?{width:C,maxWidth:C}:void 0,T=t.default.useRef(null),E=t.default.useCallback(e=>{if(!_)return;e.preventDefault();let t=x??(typeof window<`u`?Math.min(window.innerWidth*.6,960):720);T.current={startX:e.clientX,startWidth:t};let n=e=>{let t=T.current;if(!t)return;let n=t.startX-e.clientX,r=typeof window<`u`?window.innerWidth*$t/100:1600,i=Math.min(r,Math.max(Qt,t.startWidth+n));S(Math.round(i))},r=()=>{T.current,T.current=null,window.removeEventListener(`pointermove`,n),window.removeEventListener(`pointerup`,r),window.removeEventListener(`pointercancel`,r);try{S(e=>(e!=null&&window.localStorage.setItem(b,String(e)),e))}catch{}};window.addEventListener(`pointermove`,n),window.addEventListener(`pointerup`,r),window.addEventListener(`pointercancel`,r)},[_,x,b]),O=d?.fields??{},k=(Object.keys(O).length?Object.keys(O):Object.keys(o)).filter(e=>!m.has(e)&&!e.startsWith(`__`)).filter(e=>e in o).filter(e=>!O[e]?.hidden).map(e=>{let t=O[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,l.jsx)(a.Sheet,{open:e,onOpenChange:e=>{e||n()},children:(0,l.jsxs)(a.SheetContent,{side:`right`,className:`w-full overflow-y-auto p-0 sm:!max-w-none`,style:w,onOpenAutoFocus:e=>e.preventDefault(),children:[_&&(0,l.jsx)(`div`,{role:`separator`,"aria-orientation":`vertical`,"aria-label":y(`common.resizeDrawer`),onPointerDown:E,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,l.jsx)(a.SheetHeader,{className:`sr-only`,children:(0,l.jsx)(a.SheetTitle,{children:i})}),(0,l.jsx)(`div`,{className:`px-6 pt-6 pb-6`,children:(0,l.jsxs)(r.InlineEditProvider,{canEdit:!!h,children:[(0,l.jsx)(Ne,{dataSource:u,inlineEdit:!!h,schema:{type:`detail-view`,objectName:s,resourceId:String(c),data:o,showDelete:!!g,columns:p,fields:k,actions:v?[{type:`action:bar`,location:`record_header`,systemActions:[{name:`sys_open_new_tab`,label:y(`detail.openInNewTab`),icon:`external-link`,type:`script`,onClick:()=>window.open(v,`_blank`,`noopener`)}]}]:void 0},onDelete:g?async()=>{try{await g(),n()}catch(e){console.error(`[RecordDetailDrawer] delete failed:`,e)}}:void 0}),(0,l.jsx)(Xt,{onFieldSave:h?async(e,t)=>{try{await h(e,t)}catch(e){throw console.error(`[RecordDetailDrawer] inline field save failed:`,e),e}}:void 0})]})})]})})}function tn(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))}`}var nn=({objectName:e,relationshipField:n,fields:r,onCreateRecord:i,onLinkRecord:s,onSearch:c,existingRecords:u=[],className:d})=>{let[f,p]=t.useState(!1),[m,h]=t.useState(`create`),[g,_]=t.useState({}),[v,y]=t.useState(``),[b,x]=t.useState(u),[S,C]=t.useState(!1),[w,T]=t.useState(!1),E=t.useId(),D=t.useCallback(e=>`inline-create-${E}-${e}`,[E]),O=`inline-create-${E}-link-search`,k=`Search ${e}`,A=t.useMemo(()=>{if(!v.trim())return b;let e=v.toLowerCase();return b.filter(t=>t.label.toLowerCase().includes(e)||t.description?.toLowerCase().includes(e))},[v,b]),j=t.useCallback(async e=>{if(y(e),c&&e.trim().length>=2){T(!0);try{let t=await c(e);x(t)}finally{T(!1)}}},[c]),M=t.useCallback((e,t)=>{_(n=>({...n,[e]:t}))},[]),N=t.useCallback(async()=>{if(i){C(!0);try{await i({...g,[n]:!0}),_({}),p(!1)}finally{C(!1)}}},[i,g,n]),P=t.useCallback(async e=>{if(s){C(!0);try{await s(e),y(``),p(!1)}finally{C(!1)}}},[s]),F=t.useMemo(()=>r.filter(e=>e.required).every(e=>g[e.name]?.toString().trim()),[r,g]);return f?(0,l.jsxs)(a.Card,{className:(0,a.cn)(``,d),children:[(0,l.jsx)(a.CardHeader,{className:`pb-3`,children:(0,l.jsxs)(a.CardTitle,{className:`flex items-center justify-between text-sm`,children:[(0,l.jsxs)(`span`,{children:[m===`create`?`Create`:`Link`,` `,e]}),(0,l.jsx)(a.Button,{variant:`ghost`,size:`icon`,className:`h-6 w-6`,"aria-label":`Close`,onClick:()=>p(!1),children:(0,l.jsx)(o.X,{"aria-hidden":`true`,className:`h-3.5 w-3.5`})})]})}),(0,l.jsx)(a.CardContent,{children:(0,l.jsxs)(a.Tabs,{value:m,onValueChange:h,children:[(0,l.jsxs)(a.TabsList,{className:`mb-3 w-full`,children:[i&&(0,l.jsxs)(a.TabsTrigger,{value:`create`,className:`flex-1 gap-1.5`,children:[(0,l.jsx)(o.Plus,{className:`h-3.5 w-3.5`}),`Create New`]}),s&&(0,l.jsxs)(a.TabsTrigger,{value:`link`,className:`flex-1 gap-1.5`,children:[(0,l.jsx)(o.Link,{className:`h-3.5 w-3.5`}),`Link Existing`]})]}),i&&(0,l.jsxs)(a.TabsContent,{value:`create`,className:`space-y-3 mt-0`,children:[r.map(e=>(0,l.jsxs)(`div`,{children:[(0,l.jsxs)(`label`,{htmlFor:D(e.name),className:`text-xs font-medium text-muted-foreground mb-1 block`,children:[e.label,e.required&&(0,l.jsx)(`span`,{className:`text-destructive ml-0.5`,"aria-hidden":`true`,children:`*`})]}),(0,l.jsx)(a.Input,{id:D(e.name),"aria-required":e.required||void 0,type:e.type===`number`?`number`:e.type===`date`?`date`:`text`,placeholder:e.placeholder||`Enter ${e.label.toLowerCase()}`,value:g[e.name]||``,onChange:t=>M(e.name,t.target.value),className:`h-8 text-sm`})]},e.name)),(0,l.jsxs)(`div`,{className:`flex justify-end gap-2 pt-1`,children:[(0,l.jsx)(a.Button,{variant:`ghost`,size:`sm`,onClick:()=>p(!1),children:`Cancel`}),(0,l.jsxs)(a.Button,{size:`sm`,onClick:N,disabled:!F||S,className:`gap-1.5`,children:[S&&(0,l.jsx)(o.Loader2,{className:`h-3.5 w-3.5 animate-spin`}),`Create`]})]})]}),s&&(0,l.jsxs)(a.TabsContent,{value:`link`,className:`space-y-3 mt-0`,children:[(0,l.jsxs)(`div`,{className:`relative`,children:[(0,l.jsx)(`label`,{htmlFor:O,className:`sr-only`,children:k}),(0,l.jsx)(o.Search,{"aria-hidden":`true`,className:`absolute left-2.5 top-1/2 -translate-y-1/2 h-3.5 w-3.5 text-muted-foreground`}),(0,l.jsx)(a.Input,{id:O,placeholder:`${k}…`,value:v,onChange:e=>j(e.target.value),className:`h-8 text-sm pl-8`})]}),(0,l.jsx)(`div`,{className:`max-h-48 overflow-y-auto space-y-1`,children:w?(0,l.jsxs)(`div`,{className:`flex items-center justify-center py-4 text-sm text-muted-foreground`,children:[(0,l.jsx)(o.Loader2,{className:`h-4 w-4 animate-spin mr-2`}),`Searching…`]}):A.length===0?(0,l.jsx)(`p`,{className:`text-sm text-muted-foreground text-center py-4`,children:v?`No records found`:`Type to search records`}):A.map(e=>(0,l.jsxs)(`button`,{type:`button`,className:`w-full text-left px-3 py-2 rounded-md hover:bg-accent text-sm transition-colors`,onClick:()=>P(e.id),disabled:S,children:[(0,l.jsx)(`span`,{className:`font-medium`,children:e.label}),e.description&&(0,l.jsx)(`span`,{className:`block text-xs text-muted-foreground mt-0.5`,children:e.description})]},e.id))})]})]})})]}):(0,l.jsxs)(`div`,{className:(0,a.cn)(`flex gap-2`,d),children:[i&&(0,l.jsxs)(a.Button,{variant:`outline`,size:`sm`,onClick:()=>{h(`create`),p(!0)},className:`gap-1.5`,children:[(0,l.jsx)(o.Plus,{className:`h-3.5 w-3.5`}),`New `,e]}),s&&(0,l.jsxs)(a.Button,{variant:`outline`,size:`sm`,onClick:()=>{h(`link`),p(!0)},className:`gap-1.5`,children:[(0,l.jsx)(o.Link,{className:`h-3.5 w-3.5`}),`Link Existing`]})]})};function rn(e,t){if(e==null)return[`(empty)`];switch(t){case`json`:try{let t=typeof e==`string`?JSON.parse(e):e;return JSON.stringify(t,null,2).split(`
|
|
3
|
-
`)}catch{return String(e).split(`
|
|
4
|
-
`)}case`boolean`:return[String(!!e)];case`number`:return[String(e)];case`date`:try{return[new Date(e).toLocaleString()]}catch{return[String(e)]}default:return String(e).split(`
|
|
5
|
-
`)}}function an(e,t){let n=[],r=Math.max(e.length,t.length);for(let i=0;i<r;i++){let r=i<e.length?e[i]:void 0,a=i<t.length?t[i]:void 0;r===a?n.push({type:`unchanged`,value:r}):(r!==void 0&&n.push({type:`removed`,value:r}),a!==void 0&&n.push({type:`added`,value:a}))}return n}var on={added:`bg-green-50 text-green-800 dark:bg-green-950/30 dark:text-green-300`,removed:`bg-red-50 text-red-800 dark:bg-red-950/30 dark:text-red-300`,unchanged:`text-muted-foreground`},sn={added:`+`,removed:`-`,unchanged:` `},cn=({oldValue:e,newValue:n,fieldName:r,fieldType:i=`string`,mode:s=`unified`,className:c})=>{let{t:u}=D(),[d,f]=t.useState(s),p=t.useMemo(()=>rn(e,i),[e,i]),m=t.useMemo(()=>rn(n,i),[n,i]),h=t.useMemo(()=>an(p,m),[p,m]),g=h.some(e=>e.type!==`unchanged`),_=t.useMemo(()=>{if(d!==`side-by-side`)return[];let e=[],t=0;for(;t<h.length;){let n=h[t];if(n.type===`unchanged`)e.push({left:n,right:n}),t++;else if(n.type===`removed`){let r=t+1<h.length?h[t+1]:null;r&&r.type===`added`?(e.push({left:n,right:r}),t+=2):(e.push({left:n,right:null}),t++)}else e.push({left:null,right:n}),t++}return e},[d,h]);return(0,l.jsxs)(a.Card,{className:(0,a.cn)(`overflow-hidden`,c),children:[(0,l.jsx)(a.CardHeader,{className:`pb-2`,children:(0,l.jsxs)(a.CardTitle,{className:`flex items-center justify-between text-sm`,children:[(0,l.jsx)(`span`,{className:`font-medium`,children:r}),(0,l.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,l.jsx)(a.Button,{variant:d===`unified`?`secondary`:`ghost`,size:`icon`,className:`h-7 w-7`,onClick:()=>f(`unified`),title:u(`detail.unifiedDiff`),children:(0,l.jsx)(o.Rows3,{className:`h-3.5 w-3.5`})}),(0,l.jsx)(a.Button,{variant:d===`side-by-side`?`secondary`:`ghost`,size:`icon`,className:`h-7 w-7`,onClick:()=>f(`side-by-side`),title:u(`detail.sideBySideDiff`),children:(0,l.jsx)(o.Columns2,{className:`h-3.5 w-3.5`})})]})]})}),(0,l.jsx)(a.CardContent,{className:`p-0`,children:g?d===`unified`?(0,l.jsx)(`div`,{className:`font-mono text-xs overflow-x-auto`,children:h.map((e,t)=>(0,l.jsxs)(`div`,{className:(0,a.cn)(`px-4 py-0.5 whitespace-pre-wrap border-l-2`,on[e.type],e.type===`added`&&`border-l-green-500`,e.type===`removed`&&`border-l-red-500`,e.type===`unchanged`&&`border-l-transparent`),children:[(0,l.jsx)(`span`,{className:`select-none mr-2 inline-block w-3 text-center opacity-60`,children:sn[e.type]}),e.value]},t))}):(0,l.jsx)(`div`,{className:`overflow-x-auto`,children:(0,l.jsxs)(`div`,{className:`grid grid-cols-2 divide-x font-mono text-xs min-w-0`,children:[(0,l.jsx)(`div`,{className:`px-3 py-1.5 text-xs font-medium text-muted-foreground bg-muted/50`,children:u(`detail.previousVersion`)}),(0,l.jsx)(`div`,{className:`px-3 py-1.5 text-xs font-medium text-muted-foreground bg-muted/50`,children:u(`detail.currentVersion`)}),_.map((e,n)=>(0,l.jsxs)(t.Fragment,{children:[(0,l.jsx)(`div`,{className:(0,a.cn)(`px-3 py-0.5 whitespace-pre-wrap min-h-[1.5em]`,e.left?on[e.left.type]:`bg-muted/20`),children:e.left?.value??``}),(0,l.jsx)(`div`,{className:(0,a.cn)(`px-3 py-0.5 whitespace-pre-wrap min-h-[1.5em]`,e.right?on[e.right.type]:`bg-muted/20`),children:e.right?.value??``})]},n))]})}):(0,l.jsx)(`p`,{className:`px-4 py-3 text-sm text-muted-foreground`,children:u(`detail.noChanges`)})})]})},ln=({currentIndex:e,totalRecords:n,recordIds:r,onNavigate:i,onSearch:s,className:c})=>{let{t:u}=D(),[d,f]=t.useState(``),[p,m]=t.useState(!1),h=t.useRef(null),g=e>0,_=e>0,v=e<n-1,y=e<n-1,b=t.useCallback(()=>{g&&i(r[0])},[g,i,r]),x=t.useCallback(()=>{_&&i(r[e-1])},[_,i,r,e]),S=t.useCallback(()=>{v&&i(r[e+1])},[v,i,r,e]),C=t.useCallback(()=>{y&&i(r[r.length-1])},[y,i,r]),w=t.useCallback(e=>{let t=e.target.value;f(t),s?.(t)},[s]),T=t.useCallback(()=>{m(e=>(e?(f(``),s?.(``)):requestAnimationFrame(()=>h.current?.focus()),!e))},[s]);return t.useEffect(()=>{let t=t=>{let n=t.target?.tagName;if(!((n===`INPUT`||n===`TEXTAREA`||t.target?.isContentEditable)&&t.target!==h.current)){if(t.target===h.current){t.key===`Escape`&&(t.preventDefault(),m(!1),f(``),s?.(``),t.target.blur());return}switch(t.key){case`Home`:t.preventDefault(),g&&i(r[0]);break;case`End`:t.preventDefault(),y&&i(r[r.length-1]);break;case`ArrowLeft`:t.preventDefault(),_&&i(r[e-1]);break;case`ArrowRight`:t.preventDefault(),v&&i(r[e+1])}}};return document.addEventListener(`keydown`,t),()=>document.removeEventListener(`keydown`,t)},[e,r,g,_,v,y,i,s]),(0,l.jsxs)(`div`,{className:(0,a.cn)(`flex items-center gap-1.5`,c),children:[(0,l.jsx)(a.Button,{variant:`outline`,size:`icon`,className:`h-8 w-8`,disabled:!g,onClick:b,title:u(`detail.firstRecord`),children:(0,l.jsx)(o.ChevronsLeft,{className:`h-4 w-4`})}),(0,l.jsx)(a.Button,{variant:`outline`,size:`icon`,className:`h-8 w-8`,disabled:!_,onClick:x,title:u(`detail.previousRecordKey`),children:(0,l.jsx)(o.ChevronLeft,{className:`h-4 w-4`})}),(0,l.jsx)(`span`,{className:`text-xs text-muted-foreground whitespace-nowrap px-1.5 tabular-nums`,children:n>0?u(`detail.recordOf`,{current:e+1,total:n}):u(`detail.noRecords`)}),(0,l.jsx)(a.Button,{variant:`outline`,size:`icon`,className:`h-8 w-8`,disabled:!v,onClick:S,title:u(`detail.nextRecordKey`),children:(0,l.jsx)(o.ChevronRight,{className:`h-4 w-4`})}),(0,l.jsx)(a.Button,{variant:`outline`,size:`icon`,className:`h-8 w-8`,disabled:!y,onClick:C,title:u(`detail.lastRecord`),children:(0,l.jsx)(o.ChevronsRight,{className:`h-4 w-4`})}),s&&(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(a.Button,{variant:p?`secondary`:`ghost`,size:`icon`,className:`h-8 w-8`,onClick:T,title:u(`detail.searchWhileNavigating`),children:(0,l.jsx)(o.Search,{className:`h-4 w-4`})}),p&&(0,l.jsx)(`div`,{className:`relative`,children:(0,l.jsx)(a.Input,{ref:h,type:`text`,placeholder:u(`detail.searchRecords`),value:d,onChange:w,className:`h-8 w-48 text-sm`})})]})]})},un=28,dn=[`fill-primary stroke-primary`,`fill-blue-500 stroke-blue-500`,`fill-emerald-500 stroke-emerald-500`,`fill-amber-500 stroke-amber-500`],fn=[`fill-primary-foreground`,`fill-white`,`fill-white`,`fill-white`];function pn(e,t,n,r,i){let a=[],o=[],s=new Set,c=r/2,l=i/2;a.push({id:e.id,label:e.label,type:e.type,x:c,y:l,level:0}),s.add(e.id);let u=Math.min(r,i)*.32,d=t.filter(e=>!s.has(e.id));if(d.forEach((t,n)=>{let r=2*Math.PI*n/d.length-Math.PI/2,i=c+u*Math.cos(r),f=l+u*Math.sin(r);a.push({id:t.id,label:t.label,type:t.type,x:i,y:f,level:1}),o.push({fromId:e.id,toId:t.id,fromX:c,fromY:l,toX:i,toY:f}),s.add(t.id)}),n>=2){let e=Math.min(r,i)*.46,t=[];d.forEach(e=>{let n=a.find(t=>t.id===e.id);n&&(e.relatedRecords||[]).filter(e=>!s.has(e.id)).forEach(r=>{t.push({node:r,parentX:n.x,parentY:n.y,parentId:e.id}),s.add(r.id)})}),t.forEach((n,r)=>{let i=2*Math.PI*r/Math.max(t.length,1)-Math.PI/2,s=c+e*Math.cos(i),u=l+e*Math.sin(i);a.push({id:n.node.id,label:n.node.label,type:n.node.type,x:s,y:u,level:2}),o.push({fromId:n.parentId,toId:n.node.id,fromX:n.parentX,fromY:n.parentY,toX:s,toY:u})})}return{nodes:a,edges:o}}function mn(e,t=6){return e.length<=t?e:e.slice(0,t-1)+`…`}var hn=({record:e,relatedRecords:n,levels:r=1,onNodeClick:i,className:s})=>{let c=t.useRef(null),[u,d]=t.useState({width:500,height:400}),[f,p]=t.useState(null);t.useEffect(()=>{let e=c.current;if(!e)return;let t=e.parentElement;if(!t)return;let n=new ResizeObserver(e=>{for(let t of e){let{width:e}=t.contentRect;e>0&&d({width:e,height:Math.max(300,e*.7)})}});return n.observe(t),()=>n.disconnect()},[]);let{nodes:m,edges:h}=t.useMemo(()=>pn(e,n,r,u.width,u.height),[e,n,r,u]);return(0,l.jsxs)(a.Card,{className:(0,a.cn)(`overflow-hidden`,s),children:[(0,l.jsx)(a.CardHeader,{className:`pb-2`,children:(0,l.jsxs)(a.CardTitle,{className:`flex items-center gap-2 text-base`,children:[(0,l.jsx)(o.Network,{className:`h-4 w-4`}),`Relationships`,(0,l.jsxs)(`span`,{className:`text-sm font-normal text-muted-foreground`,children:[`(`,n.length,` related)`]})]})}),(0,l.jsx)(a.CardContent,{className:`p-0`,children:(0,l.jsxs)(`svg`,{ref:c,width:`100%`,height:u.height,viewBox:`0 0 ${u.width} ${u.height}`,className:`select-none`,children:[h.map((e,t)=>(0,l.jsx)(`line`,{x1:e.fromX,y1:e.fromY,x2:e.toX,y2:e.toY,className:`stroke-border`,strokeWidth:1.5,strokeOpacity:.5},`edge-${t}`)),m.map(e=>{let t=f===e.id,n=dn[Math.min(e.level,dn.length-1)],r=fn[Math.min(e.level,fn.length-1)],o=e.level===0?34:un;return(0,l.jsxs)(`g`,{className:(0,a.cn)(`cursor-pointer transition-transform`,i&&`hover:opacity-80`),onClick:()=>i?.(e.id),onMouseEnter:()=>p(e.id),onMouseLeave:()=>p(null),children:[(0,l.jsx)(`circle`,{cx:e.x,cy:e.y,r:t?o+3:o,className:n,fillOpacity:e.level===0?1:.85,strokeWidth:2,strokeOpacity:.3}),(0,l.jsx)(`text`,{x:e.x,y:e.y,textAnchor:`middle`,dominantBaseline:`central`,className:(0,a.cn)(`text-[10px] font-medium pointer-events-none`,r),children:mn(e.label)}),e.type&&(0,l.jsx)(`text`,{x:e.x,y:e.y+o+12,textAnchor:`middle`,className:`fill-muted-foreground text-[9px] pointer-events-none`,children:e.type}),t&&(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(`rect`,{x:e.x-50,y:e.y-o-28,width:100,height:20,rx:4,className:`fill-popover stroke-border`,strokeWidth:1}),(0,l.jsx)(`text`,{x:e.x,y:e.y-o-16,textAnchor:`middle`,dominantBaseline:`central`,className:`fill-popover-foreground text-[10px] pointer-events-none`,children:e.label})]})]},e.id)})]})})]})};function gn(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);return i<24?`${i}h ago`:t.toLocaleString()}catch{return e}}var _n=({recordId:e,revisions:n,onRestore:r,className:i})=>{let[s,c]=t.useState(null),[u,d]=t.useState(!1),[f,p]=t.useState(!1),m=t.useMemo(()=>n.find(e=>e.id===s)??null,[n,s]),h=t.useCallback(async()=>{if(!(!m||!r)){if(!u){d(!0);return}p(!0);try{let e=m.snapshot??{};await r(m.id,e),d(!1),c(null)}finally{p(!1)}}},[m,r,u]),g=t.useCallback(()=>{d(!1)},[]);return(0,l.jsxs)(a.Card,{className:(0,a.cn)(``,i),children:[(0,l.jsx)(a.CardHeader,{className:`pb-3`,children:(0,l.jsxs)(a.CardTitle,{className:`flex items-center gap-2 text-base`,children:[(0,l.jsx)(o.History,{className:`h-4 w-4`}),`Revision History`,(0,l.jsxs)(`span`,{className:`text-sm font-normal text-muted-foreground`,children:[`(`,n.length,`)`]})]})}),(0,l.jsx)(a.CardContent,{children:n.length===0?(0,l.jsx)(`p`,{className:`text-sm text-muted-foreground text-center py-4`,children:`No revisions recorded`}):(0,l.jsxs)(`div`,{className:`flex flex-col lg:flex-row gap-4`,children:[(0,l.jsx)(`div`,{className:`flex-1 min-w-0`,children:(0,l.jsxs)(`div`,{className:`relative`,children:[(0,l.jsx)(`div`,{className:`absolute left-3 top-2 bottom-2 w-px bg-border`}),(0,l.jsx)(`div`,{className:`space-y-1`,children:n.map(e=>{let t=e.id===s;return(0,l.jsxs)(`button`,{type:`button`,className:(0,a.cn)(`w-full text-left flex items-start gap-3 py-2 px-2 rounded-md transition-colors relative`,t?`bg-accent`:`hover:bg-accent/50`),onClick:()=>{c(e.id),d(!1)},children:[(0,l.jsx)(`div`,{className:(0,a.cn)(`shrink-0 h-6 w-6 rounded-full border-2 flex items-center justify-center z-10 mt-0.5`,t?`border-primary bg-primary`:`border-border bg-background`),children:t&&(0,l.jsx)(o.ChevronRight,{className:`h-3 w-3 text-primary-foreground`})}),(0,l.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,l.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,l.jsx)(`span`,{className:`text-sm font-medium`,children:e.user}),(0,l.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:gn(e.timestamp)})]}),(0,l.jsxs)(`p`,{className:`text-xs text-muted-foreground mt-0.5`,children:[e.changes.length,` field`,e.changes.length===1?``:`s`,` `,`changed`]})]})]},e.id)})})]})}),m&&(0,l.jsxs)(`div`,{className:`lg:w-80 border rounded-md p-3 space-y-3`,children:[(0,l.jsxs)(`div`,{className:`flex items-center gap-2 text-sm font-medium`,children:[(0,l.jsx)(o.Eye,{className:`h-4 w-4 text-muted-foreground`}),`Revision Preview`]}),(0,l.jsx)(`div`,{className:`space-y-2`,children:m.changes.map((e,t)=>(0,l.jsxs)(`div`,{className:`text-xs`,children:[(0,l.jsx)(`span`,{className:`font-medium text-muted-foreground`,children:e.field}),(0,l.jsxs)(`div`,{className:`flex items-center gap-1.5 mt-0.5`,children:[(0,l.jsx)(`span`,{className:`line-through text-red-600 dark:text-red-400 truncate max-w-[120px]`,children:e.oldValue==null?`(empty)`:String(e.oldValue)}),(0,l.jsx)(o.ChevronRight,{className:`h-3 w-3 text-muted-foreground shrink-0`}),(0,l.jsx)(`span`,{className:`text-green-600 dark:text-green-400 truncate max-w-[120px]`,children:e.newValue==null?`(empty)`:String(e.newValue)})]})]},t))}),m.snapshot&&(0,l.jsxs)(`div`,{className:`border-t pt-2 space-y-1`,children:[(0,l.jsx)(`p`,{className:`text-xs font-medium text-muted-foreground`,children:`Record state at this point`}),(0,l.jsx)(`div`,{className:`max-h-40 overflow-y-auto space-y-1`,children:Object.entries(m.snapshot).map(([e,t])=>(0,l.jsxs)(`div`,{className:`flex justify-between text-xs gap-2`,children:[(0,l.jsx)(`span`,{className:`text-muted-foreground truncate`,children:e}),(0,l.jsx)(`span`,{className:`font-mono truncate max-w-[140px]`,children:t==null?`–`:String(t)})]},e))})]}),r&&(0,l.jsx)(`div`,{className:`pt-1 space-y-2`,children:u?(0,l.jsxs)(l.Fragment,{children:[(0,l.jsxs)(`p`,{className:`text-xs text-amber-600 dark:text-amber-400`,children:[`This will restore the record to its state at`,` `,gn(m.timestamp),`. Continue?`]}),(0,l.jsxs)(`div`,{className:`flex gap-2`,children:[(0,l.jsxs)(a.Button,{variant:`destructive`,size:`sm`,className:`gap-1.5 flex-1`,onClick:h,disabled:f,children:[(0,l.jsx)(o.RotateCcw,{className:`h-3.5 w-3.5`}),f?`Restoring…`:`Confirm Restore`]}),(0,l.jsx)(a.Button,{variant:`ghost`,size:`sm`,onClick:g,disabled:f,children:`Cancel`})]})]}):(0,l.jsxs)(a.Button,{variant:`outline`,size:`sm`,className:`w-full gap-1.5`,onClick:h,children:[(0,l.jsx)(o.RotateCcw,{className:`h-3.5 w-3.5`}),`Restore to this point`]})})]})]})})]})},vn=({onSubmit:e,placeholder:n=`Leave a comment…`,disabled:r=!1,className:i})=>{let[s,c]=t.useState(``),[u,d]=t.useState(!1),f=t.useCallback(async()=>{let t=s.trim();if(t){d(!0);try{await e(t),c(``)}finally{d(!1)}}},[s,e]),p=t.useCallback(e=>{e.key===`Enter`&&(e.ctrlKey||e.metaKey)&&(e.preventDefault(),f())},[f]);return(0,l.jsxs)(`div`,{className:(0,a.cn)(`flex gap-2`,i),children:[(0,l.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:n,value:s,onChange:e=>c(e.target.value),onKeyDown:p,disabled:r||u}),(0,l.jsx)(a.Button,{size:`icon`,variant:`default`,onClick:f,disabled:!s.trim()||u||r,className:`shrink-0 self-end`,"aria-label":`Submit comment`,children:(0,l.jsx)(o.Send,{className:`h-4 w-4`})})]})},yn=({query:e,suggestions:n,onSelect:r,visible:i=!0,activeIndex:o=0,className:s})=>{let c=t.useMemo(()=>{if(!e)return n;let t=e.toLowerCase();return n.filter(e=>e.name.toLowerCase().includes(t)||e.id.toLowerCase().includes(t))},[e,n]);return!i||c.length===0?null:(0,l.jsx)(`div`,{className:(0,a.cn)(`bg-popover border rounded-md shadow-md z-50 max-h-48 overflow-y-auto w-56`,s),role:`listbox`,"aria-label":`Mention suggestions`,children:c.map((e,t)=>(0,l.jsxs)(`button`,{type:`button`,role:`option`,"aria-selected":t===o,className:(0,a.cn)(`w-full text-left px-3 py-1.5 text-sm flex items-center gap-2 hover:bg-accent transition-colors`,t===o&&`bg-accent`),onMouseDown:t=>{t.preventDefault(),r(e)},children:[e.avatarUrl?(0,l.jsx)(`img`,{src:e.avatarUrl,alt:e.name,className:`h-5 w-5 rounded-full object-cover`}):(0,l.jsx)(`div`,{className:`h-5 w-5 rounded-full bg-muted flex items-center justify-center text-[10px] font-medium`,children:e.name.charAt(0).toUpperCase()}),(0,l.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,l.jsx)(`span`,{className:`truncate`,children:e.name}),e.type!==`user`&&(0,l.jsxs)(`span`,{className:`ml-1 text-xs text-muted-foreground capitalize`,children:[`(`,e.type,`)`]})]})]},e.id))})};function bn(e,t,n){return{type:e.type,id:e.id,name:e.name,offset:t,length:n}}function xn(e,t){if(!e||!t.length)return[];let n=[...t].sort((e,t)=>t.label.length-e.label.length),r=e,i=new Set;for(let e of n){if(!e.label)continue;let t=e.label.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`),n=RegExp(`@${t}(?![\\p{L}\\p{N}_])`,`gu`);n.test(r)&&(i.add(e.id),r=r.replace(n,e=>` `.repeat(e.length)))}return[...i]}function Sn(e){return e==null?[]:Array.isArray(e)?e.filter(e=>e!=null):[e]}function $(e,t={}){let n={};for(let e of Object.keys(t))t[e]!==void 0&&(n[e]=t[e]);return Object.keys(n).length>0?{type:e,properties:n}:{type:e}}function Cn(e,t){if(!e||!t)return null;let n=e.fields?.[t]?.options;return!Array.isArray(n)||n.length===0?null:n.map(e=>({value:e.value,label:e.label}))}function wn(e){if(!e)return null;let t=e.fields||{};for(let n of[e.primaryField,e.nameField,e.displayNameField])if(typeof n==`string`&&n.length>0&&n in t)return n;for(let e of[`name`,`full_name`,`title`,`subject`,`display_name`])if(e in t)return e;return null}function Tn(e,t,r=4){if(!e)return[];let i=Array.isArray(e.highlightFields)&&e.highlightFields.length>0?e.highlightFields:null;if(i){let t=wn(e);return i.filter(e=>typeof e==`string`&&e.length>0&&e!==t).slice(0,r)}let a=new Set([`id`,`_id`,`created_at`,`updated_at`,`deleted_at`,`created_by`,`updated_by`,`deleted_by`,`organization_id`,`workspace_id`,`tenant_id`,`org_id`]);t&&a.add(t),e.primaryField&&a.add(e.primaryField),e.nameField&&a.add(e.nameField),e.displayNameField&&a.add(e.displayNameField);for(let t of[`name`,`full_name`,`title`,`subject`,`display_name`])t in(e.fields||{})&&a.add(t);let o=[`owner`,`owner_id`,`amount`,`rating`,`source`,`priority`,`industry`,`phone`,`email`,`close_date`,`due_date`,`start_date`,`expected_close_date`,`account`,`account_id`,`contact`,`contact_id`],s=new Set([`currency`,`number`,`integer`,`decimal`,`percent`,`date`,`datetime`,`time`,`reference`,`lookup`,`user`,`select`,`enum`,`multiselect`,`status`,`email`,`phone`,`url`,`text`,`string`]),c=[],l=e.fields||{},u=e=>{let t=l[e]?.type;return typeof t!=`string`||!(0,n.isRetiredFieldType)(t)?!1:((0,n.reportRetiredFieldType)(t),!0)};for(let e of o)if(e in l&&!a.has(e)&&!u(e)&&c.push(e),c.length>=r)return c;for(let e of Object.keys(l)){if(c.includes(e)||a.has(e)||u(e))continue;let t=l[e]?.type;if(!(t&&!s.has(t))&&(c.push(e),c.length>=r))break}return c}function En(e,t={}){return $(`page:header`,{recordChrome:t.recordChrome!==!1,...Array.isArray(t.actions)&&t.actions.length>0?{actions:t.actions}:{}})}function Dn(e,t){return!Array.isArray(t)||t.length===0?null:$(`record:quick_actions`,{actions:t,location:`record_header`})}function On(e,t={}){let n=t.statusField??(0,d.detectStatusField)(e),r=t.stages??(n?Cn(e,n):null),i=t.highlightFields??Tn(e,n),a=[];return!t.hideHighlights&&i.length>0&&a.push($(`record:highlights`,{fields:i})),!t.hidePath&&n&&r&&r.length>0&&a.push($(`record:path`,{statusField:n,stages:r})),a}function kn(e){if(!e)return null;let t=(0,f.deriveFieldGroupLayout)(e);if(!t)return null;let n=e.fields||{},r=e=>{let t=n[e]||{};return{name:e,label:t.label||e,type:t.type||`text`,...t.options?{options:t.options}:{},...t.reference_to||t.reference?{reference_to:t.reference_to||t.reference}:{},...t.reference_field?{reference_field:t.reference_field}:{},...t.currency?{currency:t.currency}:{},...t.currencyConfig?{currencyConfig:t.currencyConfig}:{}}},i=S(t.reduce((e,t)=>e+t.fields.length,0));return t.map(e=>({...e.key===void 0?{}:{name:e.key,title:e.label??e.key},...e.icon?{icon:e.icon}:{},...e.description?{description:e.description}:{},...e.collapse===`none`?{}:{collapsible:!0},...e.collapse===`collapsed`?{defaultCollapsed:!0}:{},columns:i,fields:e.fields.map(r)}))}function An(e,t){return Array.isArray(t)&&t.length>0?t:kn(e)??void 0}function jn(e,t,n){return $(`record:details`,{sections:An(e,t),...n&&n.length>0?{hideFields:n}:{}})}function Mn(e,t={}){let n=t.statusField??(0,d.detectStatusField)(e),r=t.highlightFields??Tn(e,n),i=[{label:`Details`,value:`details`,children:[jn(e,t.sections,r)]}];if(!t.hideRelatedTab&&Array.isArray(t.related)&&t.related.length>0){let e=e=>$(`record:related_list`,{title:e.title,objectName:e.objectName,relationshipField:e.relationshipField,...e.columns?{columns:e.columns}:{},...e.limit?{limit:e.limit}:{},...e.icon?{icon:e.icon}:{}}),n=t=>({label:t.title||t.objectName,value:`related:${t.objectName}`,...t.icon?{icon:t.icon}:{},children:[e(t)]});if(t.relatedLayout===`tabs`)for(let e of t.related)i.push(n(e));else if(t.relatedLayout===`stack`)i.push({label:`Related`,value:`related`,children:t.related.map(e)});else{let r=t.related.filter(e=>e.isPrimary),a=t.related.filter(e=>!e.isPrimary);for(let e of r)i.push(n(e));a.length>0&&i.push({label:`Related`,value:`related`,children:a.map(e)})}}return t.approvals&&i.push({label:`Approvals`,value:`approvals`,...t.approvals.count==null?{}:{count:t.approvals.count},children:[$(`record:approvals`,{...t.approvals.node||{}})]}),e?.enable?.files===!0&&!t.hideAttachments&&i.push({label:`Attachments`,value:`attachments`,children:[Pn()]}),t.showActivity&&i.push({label:`Activity`,value:`activity`,children:[$(`record:activity`)]}),t.history&&i.push({label:`History`,value:`history`,children:[$(`record:history`,{entries:t.history.entries,loading:t.history.loading,emptyText:t.history.emptyText,unknownUserText:t.history.unknownUserText})]}),$(`page:tabs`,{items:i})}function Nn(){return $(`record:discussion`)}function Pn(){return $(`record:attachments`)}function Fn(e,t={}){let n=t.slots||{},r=[];`header`in n&&n.header!==void 0?r.push(...Sn(n.header)):r.push(En(e,{recordChrome:t.recordChrome,actions:t.headerActions})),`actions`in n&&n.actions!==void 0&&r.push(...Sn(n.actions)),`alerts`in n&&n.alerts!==void 0&&r.push(...Sn(n.alerts)),`highlights`in n&&n.highlights!==void 0?r.push(...Sn(n.highlights)):r.push(...On(e,{highlightFields:t.highlightFields,statusField:t.statusField,stages:t.stages,hideHighlights:t.hideHighlights,hidePath:t.hidePath}));let i=t.showReferenceRail===!0&&!t.hideReferenceRail&&Array.isArray(t.related)&&t.related.length>=2,a=t.hideRelatedTab??i;if(`tabs`in n&&n.tabs!==void 0)r.push(...Sn(n.tabs));else if(`details`in n&&n.details!==void 0){let i=Sn(n.details),o=Mn(e,{sections:t.sections,related:t.related,showActivity:t.showActivity,history:t.history,approvals:t.approvals,highlightFields:t.highlightFields,statusField:t.statusField,hideRelatedTab:a,relatedLayout:t.relatedLayout,hideAttachments:t.hideAttachments}),s=o.properties?.items;Array.isArray(s)&&s.length>0&&(s[0]={...s[0],children:i}),r.push(o)}else r.push(Mn(e,{sections:t.sections,related:t.related,showActivity:t.showActivity,history:t.history,approvals:t.approvals,highlightFields:t.highlightFields,statusField:t.statusField,hideRelatedTab:a,relatedLayout:t.relatedLayout,hideAttachments:t.hideAttachments}));`discussion`in n&&n.discussion!==void 0?r.push(...Sn(n.discussion)):t.hideDiscussion||r.push(Nn());let o=[{name:`main`,width:`full`,components:r}],s=Sn(n.rightRail);if(i||s.length>0){let e=[];i&&e.push($(`record:reference_rail`,{entries:t.related.map(e=>({objectName:e.objectName,relationshipField:e.relationshipField,title:e.title,displayField:e.displayField,limit:3}))})),s.length>0&&e.push(...s),o.push({name:`aside`,width:`small`,className:`hidden xl:flex flex-col gap-4`,components:e})}return{type:`record`,pageType:`record`,object:e?.name,template:`full-width`,regions:o}}var In=({schema:e,dataSource:t,...n})=>{let i=(0,r.useResolvedDataSource)(t);return(0,l.jsx)(r.ElementDataSourceGate,{schema:e,dataSource:i,testId:`detail-view`,errorTitle:`This detail view’s data source could not be resolved`,requiresDataSource:e?.data==null&&e?.api==null&&typeof e?.objectName==`string`&&e.objectName.length>0,noDataSourceMessage:(0,r.noDataSourceMessage)(`detail-view`,e?.objectName),children:e=>(0,l.jsx)(Ne,{schema:e,dataSource:i,...n})})};n.ComponentRegistry.register(`detail-view`,In,{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:[]}}),n.ComponentRegistry.register(`detail-section`,W,{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`}]}),n.ComponentRegistry.register(`related-list`,se,{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`}]}),n.ComponentRegistry.register(`detail`,Ne,{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`}]}),n.ComponentRegistry.register(`details`,Ie,{namespace:`record`,skipFallback:!0,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:`sections`,type:`array`,label:`Sections`,description:"Field groups rendered as the detail body, in order. Every entry is an OBJECT — `{ name?, label?, columns?, fields }` — a bare section-id string is NOT accepted (the spec retired that spelling in objectstack#5611, and the renderer reads name/label/fields off each entry, so a string entry renders no fields at all). `fields` (required) are the field names shown in this section, in order. `label` is the section heading; omit it for an untitled, borderless section. `name` is a stable snake_case identifier and the i18n anchor — the heading resolves through objects.<object>._sections.<name>.label, so a section without a name shows its authored label in every locale. `columns` (1-4) is THIS section's field-grid width; omit it and the renderer derives the width. Authoring `sections` at all makes it the only source of the detail body; omit it and the body falls back to the object's highlightFields."},{name:`fields`,type:`array`,label:`Fields`,description:`Explicit field list (overrides highlightFields)`},{name:`hideFields`,type:`array`,label:`Hide Fields`,description:"Field names to omit from the body — applied to the top-level `fields` list AND to every section's `fields`. Bare field names only. Authors rarely need it: the synth pipeline fills it with the fields already shown in `record:highlights`, and hand-authored pages get the same dedup live from HighlightFieldsContext, so its purpose is suppressing a field you do not want repeated (the page H1 title field is dropped for you too). Hiding every field of a section leaves that section out entirely."},{name:`inlineEdit`,type:`boolean`,label:`Inline Edit`,defaultValue:!0,description:"Offer the per-field double-click / pencil inline-edit affordances in the detail body. On by default, and an OPT-OUT only: the value is combined with the object's own editability (system, engine-owned, append-only and better-auth objects are not user-editable unless they opened userActions.edit) and with the server's effective API operation set for the object, so `false` always wins while `true` cannot open editing the platform refuses. The edit session and the atomic Save bar are hosted by the page, so one draft spans the highlights strip and this body."},{name:`showHeader`,type:`boolean`,label:`Show Body Header`,defaultValue:!1,description:"Render the detail body's own title / follow-star / copy-id chip above the fields. Off by default because this block is normally composed under a `page:header` that already draws that chrome, and turning it on there shows the record title twice. Set it true only when this block is the whole page."}]}),n.ComponentRegistry.register(`related_list`,He,{namespace:`record`,skipFallback:!0,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:`relationshipValueField`,type:`string`,label:`Relationship Value Field`,defaultValue:`id`,description:'Which field OF THIS PARENT record `relationshipField` stores. Defaults to "id"; set it to the field a name-keyed junction points at (e.g. "name" when sys_user_position.position holds sys_position.name). The resolved value drives three things at once — the list filter, the Add-picker link value, and the pre-filled create form — so they cannot drift apart. While the parent record is still loading, a non-"id" field resolves to null and the list holds its fetch rather than querying on an empty value.'},{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, as spec `ViewFilterRule` entries (`[{ field, operator, value }]`). AND-combined with the parent relationship condition, never a replacement for it: it can only narrow this record's children. Also the key a per-element `dataSource` binding's composed filter lands on."},{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`},{name:`add`,type:`object`,label:`Add Existing`,description:'Adds an "Add" button that assigns EXISTING records instead of creating one — the m2m/junction case. Shape: `{ picker: { object, valueField?, labelField?, filter? }, linkField?, label? }`. `picker.object` (required) is the object whose records the dialog offers. `picker.valueField` is the field of the picked record used as the link value (default "id"); `picker.labelField` is the column shown in the picker rows (default "name", and the other columns are derived from that object\'s schema). With `linkField` set, selecting records CREATES rows in this list\'s own object as `{ [relationshipField]: parentValue, [linkField]: pickedId }` — the junction case; omit `linkField` and the picked child is RE-PARENTED instead, by setting its own `relationshipField` to this parent. `label` is the button text (default "Add", localizable inline). Setting `add` also enables generic link removal on rows when no host delete handler is wired. `picker.filter` restricts which records the dialog offers — a list of `{ field, operator, value }` rules in the same vocabulary as this list\'s own `filter`, applied as a hard constraint the user cannot widen (it never appears as an editable filter row).'}]}),n.ComponentRegistry.register(`highlights`,We,{namespace:`record`,skipFallback:!0,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?,readonly?}. Set readonly: true on an entry to render that chip read-only — it suppresses the inline-edit affordance and the HeaderHighlight editability gate enforces it. Use it for hook/automation-maintained columns that must not be hand-edited from the record header; marking the OBJECT field readonly instead would also strip the hook's own write-back.`},{name:`layout`,type:`enum`,label:`Layout`,enum:[`horizontal`,`vertical`],defaultValue:`horizontal`,description:`Layout orientation for highlight fields`}]}),n.ComponentRegistry.register(`activity`,Tt,{namespace:`record`,skipFallback:!0,category:`record`,label:`Activity Timeline`,icon:`Activity`,inputs:[{name:`types`,type:`array`,label:`Activity Types`,description:`Allow-list of feed item types to show (comment, field_change, task, event, email, call, note, file, record_create, record_delete, approval, sharing, system). Omit for all; unrecognised entries are ignored.`},{name:`filterMode`,type:`enum`,label:`Filter Mode`,enum:[`all`,`comments_only`,`changes_only`,`tasks_only`],defaultValue:`all`,description:`Filter the timeline dropdown starts on. The user can still change it; an unrecognised value falls back to "all".`},{name:`showFilterToggle`,type:`boolean`,label:`Show Filter Toggle`,defaultValue:!0,description:`Expose the activity-type filter dropdown in the panel header`},{name:`limit`,type:`number`,label:`Limit`,defaultValue:20,description:`Items per page. Also caps the scoped sys_activity read; "Load more" grows the window by this much.`},{name:`showCompleted`,type:`boolean`,label:`Show Completed`,defaultValue:!1,description:`Include completed activities (sys_activity type "completed", which surfaces as a task item). Off by default.`},{name:`unifiedTimeline`,type:`boolean`,label:`Unified Timeline`,defaultValue:!0,description:`Mix field changes and comments in one timeline (Airtable style). Off keeps the panel a discussion stream — field changes stay in record:history.`},{name:`showCommentInput`,type:`boolean`,label:`Show Comment Input`,defaultValue:!0,description:`Show the composer. Requires a host discussion context to persist the comment (record detail pages provide one); without it the feed is read-only.`},{name:`enableMentions`,type:`boolean`,label:`Enable @mentions`,defaultValue:!0,description:`Offer @-mention autocomplete in the composer, from the host discussion context's user list. Off withholds the suggestions.`},{name:`enableReactions`,type:`boolean`,label:`Enable Reactions`,defaultValue:!1,description:`Show emoji reactions on feed items. Toggling one requires a host discussion context; without it existing reactions still render, read-only.`},{name:`enableThreading`,type:`boolean`,label:`Enable Threaded Replies`,defaultValue:!1,description:`Group replies under their parent comment. Posting a reply requires a host discussion context.`},{name:`showSubscriptionToggle`,type:`boolean`,label:`Show Subscribe Toggle`,description:`NOT IMPLEMENTED — no record-subscription backend exists yet, so this renders nothing whatever it is set to. Declared for spec parity only (objectui#3165).`}]});var Ln=[{name:`position`,type:`enum`,label:`Position`,enum:[`bottom`,`right`,`left`],defaultValue:`bottom`,description:`Where the panel docks relative to the record body`},{name:`width`,type:`string`,label:`Width`,description:`Panel width as a CSS value (side positions only)`},{name:`collapsible`,type:`boolean`,label:`Collapsible`,defaultValue:!1},{name:`defaultCollapsed`,type:`boolean`,label:`Start Collapsed`},{name:`feed`,type:`object`,label:`Feed Options`,description:`Activity-feed config nested inside the panel — same shape as record:activity`}];n.ComponentRegistry.register(`chatter`,Ot,{namespace:`record`,skipFallback:!0,category:`record`,label:`Chatter Feed`,icon:`MessageSquare`,inputs:Ln}),n.ComponentRegistry.register(`discussion`,Ot,{namespace:`record`,skipFallback:!0,category:`record`,label:`Discussion`,icon:`MessageSquare`,inputs:Ln}),n.ComponentRegistry.register(`path`,At,{namespace:`record`,skipFallback:!0,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)`}]}),n.ComponentRegistry.register(`quick_actions`,Mt,{namespace:`record`,skipFallback:!0,category:`record`,label:`Quick Actions`,icon:`Zap`,inputs:[{name:`actionNames`,type:`array`,label:`Actions`,description:`Action names to expose, in order — resolved from the actions declared on the object. With no names (and no host-supplied actions) nothing is looked up and the bar renders its empty placeholder`},{name:`requiredPermissions`,type:`array`,label:`Required Permissions`,description:`Hide the whole bar unless the user holds these permissions`},{name:`location`,type:`enum`,label:`Location`,enum:[...d.ACTION_LOCATIONS],defaultValue:`record_header`,description:`Which declared action location this bar renders`},{name:`align`,type:`enum`,label:`Align`,enum:[`start`,`center`,`end`],defaultValue:`end`},{name:`inline`,type:`boolean`,label:`Inline`,description:`Render in the flow instead of folding into the record header`},{name:`variant`,type:`string`,label:`Button Variant`,defaultValue:`default`,description:`Passed to the Button primitive; a per-action variant overrides it`},{name:`size`,type:`string`,label:`Button Size`,defaultValue:`sm`,description:`Passed to the Button primitive; a per-action size overrides it`}]}),n.ComponentRegistry.register(`history`,It,{namespace:`record`,skipFallback:!0,category:`record`,label:`History Timeline`,icon:`Clock`,inputs:[{name:`limit`,type:`number`,label:`Limit`,defaultValue:50,description:`Maximum history entries to display`},{name:`emptyText`,type:`string`,label:`Empty Text`,description:`Copy shown when the record has no history`},{name:`unknownUserText`,type:`string`,label:`Unknown User Text`,description:`Copy substituted when an entry has no resolvable actor`}]}),n.ComponentRegistry.register(`reference_rail`,Bt,{namespace:`record`,skipFallback:!0,category:`record`,label:`Reference Rail`,icon:`PanelRight`,inputs:[{name:`hideEmpty`,type:`boolean`,label:`Hide When Empty`,defaultValue:!0,description:`Drop the rail entirely when no entries resolve`}]}),n.ComponentRegistry.register(`alert`,Ut,{namespace:`record`,skipFallback:!0,category:`record`,label:`Alert Banner`,icon:`AlertTriangle`,inputs:[{name:`severity`,type:`enum`,label:`Severity`,enum:[`info`,`warning`,`error`,`success`],defaultValue:`info`},{name:`title`,type:[`string`,`object`],label:`Title`,description:`Accepts an inline translation map ({ en, "zh-CN", … })`},{name:`body`,type:[`string`,`object`],label:`Body`,description:`Accepts an inline translation map ({ en, "zh-CN", … })`},{name:`visible`,type:`string`,label:`Visible When`,description:`Expression gating the banner against the current record`},{name:`icon`,type:`string`,label:`Icon`,description:`Lucide icon name; defaults to the severity icon`},{name:`action`,type:`object`,label:`Call to Action`,description:`{ actionName, label?, variant? } — the action the banner offers`},{name:`dismissible`,type:`boolean`,label:`Dismissible`},{name:`dismissKey`,type:`string`,label:`Dismiss Key`,description:`Stable key the dismissal is remembered under`}]}),n.ComponentRegistry.register(`permission-facet-link`,(0,i.withFieldCarrier)(A),{namespace:`field`,skipFallback:!0}),e.ACTIVITY_TYPE_TO_FEED_TYPE=dt,e.ActivityTimeline=ge,e.CommentAttachment=nt,e.CommentInput=vn,e.ConcurrentUpdateDialog=Kt,e.DETAIL_DEFAULT_TRANSLATIONS=E,e.DetailSection=W,e.DetailTabs=G,e.DetailView=Ne,e.DetailViewRenderer=In,e.DiffView=cn,e.FieldChangeItem=Ge,e.HeaderHighlight=le,e.HistoryTimeline=Ce,e.InlineCreateRelated=nn,e.InlineEditSaveBar=Xt,e.InlineFieldInput=H,e.MentionAutocomplete=yn,e.PointInTimeRestore=_n,e.ReactionPicker=qe,e.RecordActivityRenderer=Tt,e.RecordActivityTimeline=ct,e.RecordAlertRenderer=Ut,e.RecordChatterPanel=Et,e.RecordChatterRenderer=Ot,e.RecordComments=de,e.RecordDetailDrawer=en,e.RecordDetailsRenderer=Ie,e.RecordHighlightsRenderer=We,e.RecordHistoryRenderer=It,e.RecordMetaFooter=Oe,e.RecordNavigationEnhanced=ln,e.RecordPathRenderer=At,e.RecordQuickActionsRenderer=Mt,e.RecordReferenceRailRenderer=Bt,e.RecordRelatedListRenderer=He,e.RelatedList=se,e.RelationshipGraph=hn,e.RichTextCommentInput=Qe,e.SectionGroup=ce,e.SubscriptionToggle=Xe,e.TEXTUAL_REF_FALLBACK_TYPES=M,e.ThreadedReplies=Ye,e.__clearRecordEditableCache=X,e.applyAutoSpan=C,e.applyDetailAutoLayout=w,e.buildDefaultActions=Dn,e.buildDefaultDetails=jn,e.buildDefaultDiscussion=Nn,e.buildDefaultHeader=En,e.buildDefaultHighlights=On,e.buildDefaultPageSchema=Fn,e.buildDefaultTabs=Mn,e.createMentionFromSuggestion=bn,e.createSafeTranslationHook=T,e.deriveFieldGroupDetailSections=kn,e.deriveHighlightFields=Tn,e.deriveRecordPageHref=tn,e.deriveStages=Cn,e.detectStatusField=d.detectStatusField,e.extractLookupId=V,e.extractMentions=xn,e.inferDetailColumns=S,e.isConcurrentUpdateError=qt,e.isWideFieldType=x,e.resolveDetailSections=An,e.resolveTitleField=wn,e.useDetailTranslation=D,e.useRecordEditable=ke});
|
|
1
|
+
(function(e,t){typeof exports==`object`&&typeof module<`u`?t(exports,require("react"),require("@object-ui/core"),require("@object-ui/react"),require("@object-ui/fields"),require("@object-ui/components"),require("lucide-react"),require("@object-ui/i18n"),require("react-router-dom"),require("react/jsx-runtime"),require("@object-ui/types"),require("@object-ui/permissions"),require("@objectstack/spec/data")):typeof define==`function`&&define.amd?define([`exports`,`react`,`@object-ui/core`,`@object-ui/react`,`@object-ui/fields`,`@object-ui/components`,`lucide-react`,`@object-ui/i18n`,`react-router-dom`,`react/jsx-runtime`,`@object-ui/types`,`@object-ui/permissions`,`@objectstack/spec/data`],t):(e=typeof globalThis<`u`?globalThis:e||self,t(e.ObjectUIPluginDetail={},e.React,e.ObjectUICore,e.ObjectUIReact,e.ObjectUIFields,e.ObjectUIComponents,e.LucideReact,e._object_ui_i18n,e.react_router_dom,e.jsxRuntime,e.ObjectUITypes,e._object_ui_permissions,e._objectstack_spec_data))})(this,function(e,t,n,r,i,a,o,s,c,l,u,d,f){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var p=Object.create,m=Object.defineProperty,h=Object.getOwnPropertyDescriptor,g=Object.getOwnPropertyNames,_=Object.getPrototypeOf,v=Object.prototype.hasOwnProperty,y=(e,t,n,r)=>{if(t&&typeof t==`object`||typeof t==`function`)for(var i=g(t),a=0,o=i.length,s;a<o;a++)s=i[a],!v.call(e,s)&&s!==n&&m(e,s,{get:(e=>t[e]).bind(null,s),enumerable:!(r=h(t,s))||r.enumerable});return e};t=((e,t,n)=>(n=e==null?{}:p(_(e)),y(t||!e||!e.__esModule||!v.call(e,`default`)?m(n,`default`,{value:e,enumerable:!0}):n,e)))(t,1);var b=new Set([`textarea`,`markdown`,`html`,`grid`,`richtext`,`field:textarea`,`field:markdown`,`field:html`,`field:grid`,`field:richtext`]);function x(e){return b.has(e)}function S(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 C(e,t){return t<=1?e:e.map(e=>e.span===void 0&&e.type&&x(e.type)?{...e,span:t}:e)}function w(e,t,n){if(t!==void 0)return{fields:C(e,t),columns:t};let r=S(e.length,n);return{fields:C(e,r),columns:r}}var T=s.createSafeTranslation,E={"common.resizeDrawer":`Resize drawer`,"detail.back":`Back`,"detail.edit":`Edit`,"detail.editInline":`Edit`,"detail.save":`Save`,"detail.saveChanges":`Save changes`,"detail.saving":`Saving…`,"detail.editFieldsInline":`Edit fields`,"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.addReaction":`Add reaction`,"detail.emojiPicker":`Emoji picker`,"detail.reactionCount":`{{emoji}} {{count}} reactions`,"detail.reactionCount_one":`{{emoji}} {{count}} reaction`,"detail.reactionCount_other":`{{emoji}} {{count}} reactions`,"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.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.noValue":`No value`,"detail.activity":`Activity`,"detail.copyRecordId":`Copy record ID`,"detail.showEmptyFields":`Show {{count}} empty fields`,"detail.showEmptyFields_one":`Show {{count}} empty field`,"detail.showEmptyFields_other":`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.highlightsLabel":`Record highlights`,"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.attachmentCount_one":`{{count}} attachment`,"detail.attachmentCount_other":`{{count}} attachments`,"detail.removeAttachment":`Remove attachment`,"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.noRecords":`No records`,"detail.showEmptyRelated":`+ {{count}} empty`,"detail.showEmptyRelated_one":`+ {{count}} empty`,"detail.showEmptyRelated_other":`+ {{count}} empty`,"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.activityAccessDenied":`You don't have permission to view activity on this record.`,"detail.commentsAccessDenied":`You don't have permission to view comments on this record.`,"detail.allFilter":`All`,"detail.createsFilter":`Creates`,"detail.deletesFilter":`Deletes`,"detail.statusChangesFilter":`Status Changes`,"detail.activityEmptyValue":`(empty)`,"detail.activityFieldChanged":`Changed {{field}} from "{{old}}" to "{{new}}"`,"detail.activityCreated":`Created this record`,"detail.activityDeleted":`Deleted this record`,"detail.activityStatusChanged":`Changed status to "{{value}}"`,"detail.activityUpdated":`Updated record`,"detail.loadMore":`Load more`,"detail.edited":`(edited)`,"detail.via":`via {{source}}`,"detail.viewSource":`View source`,"detail.replyCount":`{{count}} reply`,"detail.replyCount_one":`{{count}} reply`,"detail.replyCount_other":`{{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.lockedByApproval":`Locked for approval`,"detail.lockedTooltip":`This record has a pending approval request; editing is locked`,"detail.approvalPendingEditable":`In approval · editable`,"detail.approvalPendingTooltip":`This record has a pending approval request; this step still allows editing`,"detail.approvalProgress":`Approvals — {{got}} of {{need}}`,"detail.approvalProgressGroups":`Sign-off — {{got}} of {{need}} groups`,"detail.approvalProgressLabel":`Approval progress`,"detail.cancelApproval":`Recall approval`,"detail.cancelApprovalInFlight":`Recalling…`,"detail.cancelApprovalTooltip":`Recall the pending approval request to unlock this record`,"detail.cancelApprovalTooltipUnlocked":`Recall the pending approval request`,"detail.cancelApprovalFailed":`Failed to recall approval`,"detail.cancelApprovalUnavailable":`Recalling approvals is not supported on this data source`,"detail.pathLabel":`Record path`,"detail.pathStageCompleted":`{{stage}}, completed`,"detail.pathStageCurrent":`{{stage}}, current stage`,"detail.pathStageUpcoming":`{{stage}}, upcoming`,"detail.pathStageLostCurrent":`{{stage}}, closed lost, current stage`,"detail.pathStageLostUpcoming":`{{stage}}, closed lost, not reached`,"detail.pathStageWonUpcoming":`{{stage}}, goal stage, not reached`,"view.malformedFilter":`This view’s filter is malformed, so no records are shown: the {{subject}} condition cannot be applied.`},D=T(E,`detail.back`);function O(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 k(e){let t=O(e);return t==null||t===``?0:Array.isArray(t)?t.length:typeof t==`object`?Object.keys(t).length:1}function A({value:e,field:t}){let{t:n}=D(),o=(0,r.useRecordContext)(),{appName:s}=(0,c.useParams)(),u=t?.name||``,d=o?.data?.name,f=s&&d?`/apps/${s}/metadata/permission/${encodeURIComponent(String(d))}`:null,p=k(e),m=p===0,h=(()=>{if(m)return(0,l.jsx)(`span`,{className:`text-muted-foreground`,children:n(`perm.facet.none`,{defaultValue:`None`})});if(u===`system_permissions`){let t=(0,i.parseCapabilityNames)(e),r=t.slice(0,6),o=t.length-r.length;return(0,l.jsxs)(`span`,{className:`inline-flex flex-wrap items-center gap-1`,children:[r.map(e=>(0,l.jsx)(a.Badge,{variant:`outline`,children:e},e)),o>0&&(0,l.jsx)(`span`,{className:`text-muted-foreground text-xs`,children:n(`perm.facet.more`,{count:o,defaultValue:`+${o} more`})})]})}let t=(()=>{switch(u){case`object_permissions`:return n(`perm.facet.objects`,{count:p,defaultValue:`${p} object${p===1?``:`s`}`});case`field_permissions`:return n(`perm.facet.fields`,{count:p,defaultValue:`${p} field rule${p===1?``:`s`}`});case`row_level_security`:return n(`perm.facet.rls`,{count:p,defaultValue:`${p} RLS polic${p===1?`y`:`ies`}`});case`tab_permissions`:return n(`perm.facet.tabs`,{count:p,defaultValue:`${p} tab rule${p===1?``:`s`}`});case`admin_scope`:return n(`perm.facet.adminScope`,{defaultValue:`Delegated admin configured`});default:return String(p)}})();return(0,l.jsx)(`span`,{className:`text-foreground`,children:t})})();return(0,l.jsxs)(`span`,{className:`inline-flex flex-wrap items-center gap-x-2 gap-y-1 text-sm`,children:[h,f?(0,l.jsx)(c.Link,{to:f,className:`text-primary hover:underline whitespace-nowrap`,children:n(`perm.facet.designInStudio`,{defaultValue:`Design in Studio →`})}):(0,l.jsx)(`span`,{className:`text-muted-foreground/60 whitespace-nowrap`,children:n(`perm.facet.designInStudioHint`,{defaultValue:`Design in Studio`})})]})}var j=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`]),M=new Set([`formula`,`summary`,`rollup`,`autonumber`,`auto_number`]);function N(e,t){return M.has(e)||M.has(t)}var P=new Set([`image`,`avatar`,`signature`,`file`,`video`,`audio`,`markdown`]);function F(e,t){return I(e)||I(t)}function I(e){return typeof e!=`string`||P.has(e)?!1:(0,i.isInlineExcludedFieldType)(e)}function L(e,t){return R(e)||R(t)}function R(e){return typeof e==`string`&&(0,i.isMaskedFieldType)(e)}var z=`options.currency.currencyConfig.precision.scale.useGrouping.min.max.step.format.widget.dueLike.multiple.reference_field.displayField.descriptionField.idField.allow_create.allowCreate.lookup_columns.lookupColumns.lookup_page_size.lookupPageSize.lookupFilters.picker.subtitle.avatar_field.avatarField.depends_on.dependsOn`.split(`.`);function B(e,t){let n={...e};if(!t)return n;!n.type&&t.type&&(n.type=t.type);for(let e of z){let r=t[e];r!==void 0&&n[e]===void 0&&(n[e]=r)}let r=t.reference;return r&&n.reference===void 0&&(n.reference=r),n}var ee=`inline-plain-text-input`,te=new Set([`text`,`email`,`phone`,`url`]);function ne(e){return e?i.FORM_FIELD_TYPES.includes(e)||(0,i.mapFieldTypeToFormType)(e)!==`field:text`:!1}function V(e){let t=e?.type;return!t||te.has(t)?!0:t===`select`&&!e.multiple}function re(e){if(e==null)return e;if(Array.isArray(e))return e.map(re);if(typeof e==`object`){let t=e;return t.id??t._id??t.value??``}return e}var ie=({field:e,value:t,onChange:n,dataSource:r,autoFocus:a,error:o,dependentValues:s})=>{let c=e.type;if(e.widget===`permission-facet-link`)return(0,l.jsx)(A,{value:t,field:e});if(typeof c==`string`&&i.RETIRED_FIELD_TYPES[c])return(0,l.jsx)(i.RetiredFieldTombstone,{field:e});let u=c===`multiselect`||!!e.multiple;if((c===`select`||c===`multiselect`)&&Array.isArray(e.options)&&e.options.length>0)return u?(0,l.jsx)(i.SelectField,{field:{...e,multiple:!0},value:Array.isArray(t)?t:t==null||t===``?[]:[t],onChange:e=>n(e),error:o,dependentValues:s}):(0,l.jsx)(i.SelectField,{field:e,value:t==null?``:String(t),onChange:e=>n(e),error:o,dependentValues:s});if(c===`boolean`)return(0,l.jsx)(i.BooleanField,{field:e,value:!!t,onChange:e=>n(e),error:o});if(c===`image`)return(0,l.jsx)(i.ImageField,{field:e,value:t,onChange:e=>n(e),error:o});if(c===`avatar`)return(0,l.jsx)(i.AvatarField,{field:e,value:t,onChange:e=>n(e),error:o});if(c===`signature`)return(0,l.jsx)(i.SignatureField,{field:e,value:t,onChange:e=>n(e),error:o});if(c===`file`||c===`video`||c===`audio`)return(0,l.jsx)(i.FileField,{field:e,value:t,onChange:e=>n(e),error:o});if(c===`markdown`||c===`textarea`)return(0,l.jsx)(i.TextAreaField,{field:e,value:t,onChange:e=>n(e),autoFocus:a,error:o});let d=c===`user`,f=c===`lookup`||c===`master_detail`||c===`tree`||!!e.reference&&!M.has(c);if(d||f)return(0,l.jsx)(d?i.UserField:i.LookupField,{field:e,value:t,onChange:e=>n(e),dataSource:r,error:o,dependentValues:s});if(c===`number`)return(0,l.jsx)(i.NumberField,{field:e,value:t,onChange:e=>n(e),autoFocus:a,error:o});if(c===`currency`)return(0,l.jsx)(i.CurrencyField,{field:e,value:t,onChange:e=>n(e),autoFocus:a,error:o});if(c===`percent`)return(0,l.jsx)(i.PercentField,{field:e,value:t,onChange:e=>n(e),autoFocus:a,error:o});if(c===`address`)return(0,l.jsx)(i.AddressField,{field:e,value:t,onChange:e=>n(e),autoFocus:a,error:o});if(c===`location`)return(0,l.jsx)(i.LocationField,{field:e,value:t,onChange:e=>n(e),autoFocus:a,error:o});if(c===`geolocation`)return(0,l.jsx)(i.GeolocationField,{field:e,value:t,onChange:e=>n(e),autoFocus:a,error:o});let p=c===`date`||c===`datetime`;if(!p&&!V(e)&&ne(c)&&(0,i.hasFieldEditWidget)(c))return(0,l.jsx)(i.FieldEditWidget,{field:e,value:t,onChange:e=>n(e),autoFocus:a,error:o,dependentValues:s});if(p)return(0,l.jsx)(i.DateField,{field:e,value:t,onChange:e=>n(e&&new Date(e+`T00:00:00`).toISOString()),autoFocus:a,error:o});let m=t==null?``:String(typeof t==`object`?(0,i.coerceToSafeValue)(t)??``:t);return(0,l.jsx)(`input`,{type:`text`,"data-testid":ee,autoFocus:a,"aria-invalid":o?!0:void 0,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:m,onChange:e=>n(e.target.value)})},H=Object.freeze({muted:`bg-muted`,"muted/50":`bg-muted/50`,accent:`bg-accent`,"primary/10":`bg-primary/10`,"secondary/10":`bg-secondary/10`,"destructive/10":`bg-destructive/10`}),U=H;function ae(e){if(!e)return;let t=e.trim();if(t)return t.startsWith(`bg-`)?t:Object.prototype.hasOwnProperty.call(H,t)?H[t]:void 0}function W(e){return(0,n.isEmptyValue)(e)?!1:typeof e==`object`&&e?!0:(0,n.recordDisplayValueAt)({value:e},`value`)!==void 0}var oe=({name:e})=>/^[a-z0-9][a-z0-9-]*$/i.test(e)?(0,l.jsx)(a.LazyIcon,{name:e,className:`h-4 w-4 shrink-0 text-muted-foreground`,"aria-hidden":!0}):(0,l.jsx)(`span`,{className:`text-muted-foreground`,children:e});function se(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 ce=({section:e,data:n,className:s,objectSchema:c,objectName:u,isEditing:d=!1,onFieldChange:f,onEnterInlineEdit:p,autoFocusField:m,dataSource:h,virtualScroll:g})=>{let[_,v]=t.useState(e.defaultCollapsed??!1),[y,b]=t.useState(null),[x,S]=t.useState(void 0),[C,T]=t.useState(!1),{t:E}=D(),{fieldLabel:O,translateOptions:k}=(0,r.useSafeFieldLabel)(),M=(0,r.useInlineEdit)()?.fieldErrors??null,P=t.useCallback((e,t)=>{let n;if(t==null)n=``;else if(typeof t==`object`)try{n=JSON.stringify(t)}catch{n=String(t)}else n=String(t);navigator.clipboard.writeText(n).then(()=>{b(e),setTimeout(()=>b(null),2e3)})},[]),I=t.useCallback(e=>!W(n?.[e.name]??e.value),[n]),R=t.useMemo(()=>e.fields.filter(I).length,[e.fields,I]),z=(0,a.useIsMobile)(),ee=z?3:4,te=z?.2:.25,ne=e.fields.length-R,V=!d&&e.fields.length>=ee&&R/e.fields.length>=te&&ne>0,re=e.fields.length>0&&ne===0,H=e.hideEmpty===!0&&re&&!d,U=!C&&(V||H)?e.fields.filter(e=>!I(e)):e.fields,{fields:ce,columns:le}=w(U,e.columns),ue=Math.min(le,Math.max(1,U.length)),de=e=>{let t=n?.[e.name]??e.value;if(e.render)return(0,l.jsx)(r.SchemaRenderer,{schema:(0,r.toRenderableSchema)(e.render),data:{...n,value:t}});let s=se(e.span,ue),g=c?.fields?.[e.name],_=B(e,g);u&&Array.isArray(_.options)&&_.options.length>0&&(_.options=k(u,e.name,_.options));let v=N(e.type,g?.type),b=e.readonly===!0||g?.readonly===!0,x=j.has(e.name),S=F(e.type,g?.type),C=L(e.type,g?.type),w=!b&&!v&&!x&&!S,T=w&&!!p,D=(()=>{if((_.widget||e.widget)===`permission-facet-link`)return(0,l.jsx)(A,{value:t,field:_});if(!W(t))return(0,l.jsx)(a.EmptyValue,{className:`pointer-events-auto`,title:E(`detail.noValue`,{defaultValue:`No value`})});let n=(0,i.resolveCellRendererType)(_)||e.type;if(n){let e=(0,i.getCellRenderer)(n);if(e)return(0,l.jsx)(e,{value:t,field:_})}return String(t)})(),I=W(t)&&!C,R=I&&!T,ee=y===e.name,te=O(u||``,e.name,e.label||e.name);return z&&!(d&&w)?(0,l.jsxs)(`div`,{className:(0,a.cn)(`flex items-baseline justify-between gap-4 py-2.5 min-h-[44px] group`,I&&`cursor-pointer active:bg-muted/40 transition-colors`),onClick:I?()=>P(e.name,t):void 0,onKeyDown:I?n=>{(n.key===`Enter`||n.key===` `)&&(n.preventDefault(),P(e.name,t))}:void 0,role:I?`button`:void 0,tabIndex:I?0:void 0,children:[(0,l.jsx)(`span`,{className:`text-[15px] text-muted-foreground shrink-0`,children:te}),(0,l.jsx)(`span`,{className:`text-[15px] text-foreground text-right break-words min-w-0 leading-snug`,children:D})]},e.name):(0,l.jsxs)(`div`,{className:(0,a.cn)(`space-y-1.5 group min-w-0`,s),children:[(0,l.jsx)(`div`,{className:`text-xs font-medium text-muted-foreground uppercase tracking-wide`,children:O(u||``,e.name,e.label||e.name)}),d&&w?(0,l.jsxs)(`div`,{className:`min-h-[44px] sm:min-h-0`,children:[(0,l.jsx)(ie,{field:_,value:t,onChange:t=>f?.(e.name,t),dataSource:h,autoFocus:m===e.name,error:M?.[e.name],dependentValues:n}),M?.[e.name]&&(0,l.jsx)(`p`,{role:`alert`,"data-inline-field-hint":e.name,className:`mt-1 text-xs text-destructive`,children:M[e.name]})]}):(0,l.jsxs)(`div`,{className:(0,a.cn)(`flex items-start justify-between gap-2 min-h-[44px] sm:min-h-0 rounded-md`,R&&`cursor-pointer active:bg-muted/60 transition-colors`,T&&`cursor-pointer hover:bg-muted/40 transition-colors -mx-1.5 px-1.5`),onClick:R?()=>P(e.name,t):void 0,onDoubleClick:T?()=>p?.(e.name):void 0,onKeyDown:R?n=>{(n.key===`Enter`||n.key===` `)&&(n.preventDefault(),P(e.name,t))}:void 0,role:R?`button`:void 0,tabIndex:R?0:void 0,title:T?E(`detail.editInlineHint`):void 0,children:[(0,l.jsx)(`div`,{className:`text-sm flex-1 min-w-0 break-words py-1`,children:D}),T?(0,l.jsx)(a.TooltipProvider,{children:(0,l.jsxs)(a.Tooltip,{children:[(0,l.jsx)(a.TooltipTrigger,{asChild:!0,children:(0,l.jsx)(a.Button,{variant:`ghost`,size:`icon`,className:`h-6 w-6 opacity-0 group-hover:opacity-100 transition-opacity shrink-0`,"aria-label":E(`detail.editInlineHint`),onClick:t=>{t.stopPropagation(),p?.(e.name)},children:(0,l.jsx)(o.Pencil,{className:`h-3 w-3`})})}),(0,l.jsx)(a.TooltipContent,{children:E(`detail.editInlineHint`)})]})}):I?(0,l.jsx)(a.TooltipProvider,{children:(0,l.jsxs)(a.Tooltip,{children:[(0,l.jsx)(a.TooltipTrigger,{asChild:!0,children:(0,l.jsx)(a.Button,{variant:`ghost`,size:`icon`,className:`h-6 w-6 opacity-0 group-hover:opacity-100 transition-opacity shrink-0`,onClick:n=>{n.stopPropagation(),P(e.name,t)},children:ee?(0,l.jsx)(o.Check,{className:`h-3 w-3 text-green-600`}):(0,l.jsx)(o.Copy,{className:`h-3 w-3`})})}),(0,l.jsx)(a.TooltipContent,{children:E(ee?`detail.copied`:`detail.copyToClipboard`)})]})}):null]})]},e.name)},G=g?.enabled===!0,fe=g?.batchSize??20;if(t.useEffect(()=>{if(!G){S(void 0);return}if(ce.length<=fe){S(void 0);return}S(fe);let e=setTimeout(()=>S(void 0),100);return()=>clearTimeout(e)},[G,ce.length,fe]),U.length===0&&R===e.fields.length)return null;let pe=x===void 0?ce:ce.slice(0,x),me=R>0&&V,K=(0,l.jsxs)(l.Fragment,{children:[z?(0,l.jsx)(`div`,{className:`flex flex-col divide-y divide-border/60`,children:pe.map(de)}):(0,l.jsx)(`div`,{className:(0,a.cn)(`grid gap-3 sm:gap-4`,ue===1?`grid-cols-1`:ue===2?`grid-cols-1 md:grid-cols-2`:ue===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:pe.map(de)}),me&&(0,l.jsx)(`div`,{className:`mt-3 -ml-2`,children:(0,l.jsxs)(a.Button,{type:`button`,variant:`ghost`,size:`sm`,onClick:()=>T(e=>!e),className:`h-7 px-2 text-xs text-muted-foreground hover:text-foreground`,children:[C?(0,l.jsx)(o.EyeOff,{className:`h-3.5 w-3.5 mr-1.5`}):(0,l.jsx)(o.Eye,{className:`h-3.5 w-3.5 mr-1.5`}),C?E(`detail.hideEmptyFields`,{defaultValue:`Hide empty fields`}):E(`detail.showEmptyFields`,{count:R,defaultValue:`Show {{count}} empty fields`})]})})]});return!e.title&&!e.collapsible&&e.showBorder===!1?(0,l.jsx)(`div`,{className:(0,a.cn)(s),children:K}):e.collapsible?(0,l.jsx)(a.Collapsible,{open:!_,onOpenChange:e=>v(!e),className:s,children:(0,l.jsxs)(a.Card,{className:(0,a.cn)(e.showBorder===!1?`border-none shadow-none`:``),children:[(0,l.jsx)(a.CollapsibleTrigger,{asChild:!0,children:(0,l.jsxs)(a.CardHeader,{className:(0,a.cn)(`py-3 px-4 sm:py-4 sm:px-6 cursor-pointer hover:bg-muted/50 transition-colors`,ae(e.headerColor)),children:[(0,l.jsxs)(a.CardTitle,{className:`flex items-center justify-between text-base font-semibold tracking-tight`,children:[(0,l.jsxs)(`div`,{className:`flex items-center gap-2`,children:[e.icon&&(0,l.jsx)(oe,{name:e.icon}),(0,l.jsx)(`span`,{children:e.title})]}),(0,l.jsx)(`div`,{className:`flex items-center gap-2`,children:_?(0,l.jsx)(o.ChevronRight,{className:`h-4 w-4 text-muted-foreground`}):(0,l.jsx)(o.ChevronDown,{className:`h-4 w-4 text-muted-foreground`})})]}),e.description&&!_&&(0,l.jsx)(`p`,{className:`text-xs text-muted-foreground mt-1`,children:e.description})]})}),(0,l.jsx)(a.CollapsibleContent,{children:(0,l.jsx)(a.CardContent,{className:`pt-3 sm:pt-4 px-3 sm:px-6 pb-4 sm:pb-5`,children:K})})]})}):(0,l.jsxs)(a.Card,{className:(0,a.cn)(e.showBorder===!1?`border-none shadow-none`:``,s),children:[e.title&&(0,l.jsxs)(a.CardHeader,{className:(0,a.cn)(`py-3 px-4 sm:py-4 sm:px-6`,ae(e.headerColor)),children:[(0,l.jsx)(a.CardTitle,{className:`flex items-center justify-between text-base font-semibold tracking-tight`,children:(0,l.jsxs)(`div`,{className:`flex items-center gap-2`,children:[e.icon&&(0,l.jsx)(oe,{name:e.icon}),(0,l.jsx)(`span`,{children:e.title})]})}),e.description&&(0,l.jsx)(`p`,{className:`text-xs text-muted-foreground mt-1`,children:e.description})]}),(0,l.jsx)(a.CardContent,{className:`pt-3 sm:pt-4 px-3 sm:px-6 pb-4 sm:pb-5`,children:K})]})},le=({tabs:e,data:n,className:i})=>{let[o,s]=t.useState(e[0]?.key),c=e.filter(e=>typeof e.visible==`boolean`?e.visible:(e.visible,!0));return(0,l.jsxs)(a.Tabs,{value:o,onValueChange:s,className:i,children:[(0,l.jsx)(a.TabsList,{className:`w-full justify-start border-b rounded-none bg-transparent p-0`,children:c.map(e=>(0,l.jsx)(a.TabsTrigger,{value:e.key,className:`relative rounded-none border-b-2 border-transparent data-[state=active]:border-primary data-[state=active]:bg-transparent`,children:(0,l.jsxs)(`div`,{className:`flex items-center gap-2`,children:[e.icon&&(0,l.jsx)(`span`,{children:e.icon}),(0,l.jsx)(`span`,{children:e.label}),e.badge&&(0,l.jsx)(a.Badge,{variant:`secondary`,className:`ml-1`,children:e.badge})]})},e.key))}),c.map(e=>(0,l.jsx)(a.TabsContent,{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,l.jsx)(t.Suspense,{fallback:null,children:Array.isArray(e.content)?(0,l.jsx)(`div`,{className:`space-y-4`,children:e.content.map((e,t)=>(0,l.jsx)(r.SchemaRenderer,{schema:(0,r.toRenderableSchema)(e),data:n},t))}):(0,l.jsx)(r.SchemaRenderer,{schema:(0,r.toRenderableSchema)(e.content),data:n})})},e.key))]})},ue=({group:e,data:n,className:r,objectSchema:i,objectName:s,isEditing:c=!1,onFieldChange:u,onEnterInlineEdit:d,autoFocusField:f,dataSource:p})=>{let m=e.collapsible??!0,[h,g]=t.useState(e.defaultCollapsed??!1),_=(0,l.jsx)(`div`,{className:`space-y-3 sm:space-y-4`,children:e.sections.map((e,t)=>(0,l.jsx)(ce,{section:e,data:n,objectSchema:i,objectName:s,isEditing:c,onFieldChange:u,onEnterInlineEdit:d,autoFocusField:f,dataSource:p},t))});return m?(0,l.jsxs)(a.Collapsible,{open:!h,onOpenChange:e=>g(!e),className:r,children:[(0,l.jsx)(a.CollapsibleTrigger,{asChild:!0,children:(0,l.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:[h?(0,l.jsx)(o.ChevronRight,{className:`h-4 w-4 text-muted-foreground shrink-0`}):(0,l.jsx)(o.ChevronDown,{className:`h-4 w-4 text-muted-foreground shrink-0`}),e.icon&&(0,l.jsx)(`span`,{className:`text-muted-foreground`,children:e.icon}),(0,l.jsx)(`h3`,{className:`text-lg font-semibold`,children:e.title})]})}),e.description&&!h&&(0,l.jsx)(`p`,{className:`text-sm text-muted-foreground mt-1`,children:e.description}),(0,l.jsx)(a.CollapsibleContent,{children:(0,l.jsx)(`div`,{className:`mt-3`,children:_})})]}):(0,l.jsxs)(`div`,{className:(0,a.cn)(`space-y-3`,r),children:[(0,l.jsxs)(`div`,{className:`flex items-center gap-2 pb-2 border-b`,children:[e.icon&&(0,l.jsx)(`span`,{className:`text-muted-foreground`,children:e.icon}),(0,l.jsx)(`h3`,{className:`text-lg font-semibold`,children:e.title})]}),e.description&&(0,l.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:e.description}),_]})},de=({fields:e,data:s,className:c,objectName:u,objectSchema:d,dataSource:f})=>{let{fieldLabel:p}=(0,r.useSafeFieldLabel)(),{t:m}=D(),h=(0,r.useInlineEdit)(),g=h?.editing??!1,_=h?.canEdit??!1,v=h?.draft,y=t.useMemo(()=>s&&v?{...s,...v}:s,[s,v]);if(!e.length||!s)return null;let b=g?e:e.filter(e=>{let t=s?.[e.name];return t!=null&&t!==``});return b.length===0?null:(0,l.jsx)(a.TooltipProvider,{children:(0,l.jsx)(`section`,{className:(0,a.cn)(`@container border-b border-border/60 pb-4`,c),"aria-label":m(`detail.highlightsLabel`),children:(0,l.jsx)(`div`,{className:(0,a.cn)(`flex flex-wrap gap-y-4`),children:b.map(e=>{let t=s[e.name],r=d?.fields?.[e.name],c=e.type||r?.type,v=B({name:e.name,label:e.label,type:c||`text`},r),b=y?y[e.name]:t,x=N(e.type,r?.type),S=e.readonly===!0||r?.readonly===!0,C=j.has(e.name),w=F(e.type,r?.type),T=_&&!x&&!S&&!C&&!w,E=g&&T,D=(0,i.getCellRenderer)((0,i.resolveCellRendererType)(v)||c||`text`),O=c===`number`||c===`integer`||c===`currency`||c===`percent`||c===`decimal`,k=c===`email`||c===`url`||c===`textarea`||!!c&&n.EXPANDABLE_FIELD_TYPES.has(c),A=c===`boolean`,M=!W(b);return(0,l.jsxs)(`div`,{className:(0,a.cn)(`group flex flex-col gap-1 min-w-[7rem] px-5 border-l border-border/60 first:border-l-0 first:pl-0`,k||E?`basis-[16rem] max-w-[24rem]`:`basis-[9rem] max-w-[16rem]`),children:[(0,l.jsx)(`span`,{className:`text-xs font-medium text-muted-foreground`,children:p(u||``,e.name,e.label)}),E?(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(ie,{field:v,value:b,onChange:t=>h.setField(e.name,t),dataSource:f,autoFocus:h.autoFocusField===e.name,error:h.fieldErrors?.[e.name],dependentValues:y}),h.fieldErrors?.[e.name]&&(0,l.jsx)(`p`,{role:`alert`,"data-inline-field-hint":e.name,className:`mt-1 text-xs text-destructive`,children:h.fieldErrors[e.name]})]}):(0,l.jsxs)(`div`,{className:(0,a.cn)(`flex items-start justify-between gap-1`,T&&`cursor-pointer rounded-md -mx-1.5 px-1.5 hover:bg-muted/40 transition-colors`),onDoubleClick:T?()=>h.enter(e.name):void 0,title:T?m(`detail.editInlineHint`):void 0,children:[(0,l.jsx)(`div`,{className:`min-w-0 flex-1`,children:A?b?(0,l.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,l.jsx)(o.Check,{className:`h-3 w-3`,"aria-hidden":!0}),`Yes`]}):(0,l.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,l.jsx)(o.X,{className:`h-3 w-3`,"aria-hidden":!0}),`No`]}):M?(0,l.jsx)(a.EmptyValue,{className:`block`}):(0,l.jsx)(`span`,{title:(Array.isArray(v.options)?v.options.find(e=>e?.value===b)?.label:void 0)??(typeof b==`string`||typeof b==`number`?String(b):void 0),className:(0,a.cn)(`block min-w-0 truncate text-sm font-semibold`,O&&`tabular-nums tracking-tight`),children:(0,l.jsx)(D,{value:b,field:v})})}),T&&(0,l.jsxs)(a.Tooltip,{children:[(0,l.jsx)(a.TooltipTrigger,{asChild:!0,children:(0,l.jsx)(a.Button,{variant:`ghost`,size:`icon`,className:`h-5 w-5 shrink-0 opacity-0 group-hover:opacity-100 transition-opacity`,"aria-label":m(`detail.editInlineHint`),onClick:t=>{t.stopPropagation(),h.enter(e.name)},children:(0,l.jsx)(o.Pencil,{className:`h-3 w-3`})})}),(0,l.jsx)(a.TooltipContent,{children:m(`detail.editInlineHint`)})]})]})]},e.name)})})})})};function G(e,t,n){try{let r=new Date(e),i=new Date().getTime()-r.getTime(),a=Math.floor(i/6e4);if(a<1)return t(`detail.justNow`);if(a<60)return t(`detail.minutesAgo`,{count:a});let o=Math.floor(a/60);if(o<24)return t(`detail.hoursAgo`,{count:o});let s=Math.floor(o/24);return s<7?t(`detail.daysAgo`,{count:s}):r.toLocaleDateString(n)}catch{return e}}var fe=({comments:e,onAddComment:n,onTogglePin:r,searchable:i=!1,className:c})=>{let{t:u}=D(),d=(0,s.useDisplayLocale)(),[f,p]=t.useState(``),[m,h]=t.useState(!1),[g,_]=t.useState(``),v=t.useCallback(async()=>{let e=f.trim();if(e&&n){h(!0);try{await n(e),p(``)}catch{}finally{h(!1)}}},[f,n]),y=t.useCallback(e=>{e.key===`Enter`&&(e.ctrlKey||e.metaKey)&&(e.preventDefault(),v())},[v]),b=t.useMemo(()=>[...g.trim()?e.filter(e=>{let t=g.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,g]);return(0,l.jsxs)(a.Card,{className:(0,a.cn)(``,c),children:[(0,l.jsx)(a.CardHeader,{children:(0,l.jsxs)(a.CardTitle,{className:`flex items-center gap-2 text-base`,children:[(0,l.jsx)(o.MessageSquare,{className:`h-4 w-4`}),u(`detail.comments`),(0,l.jsxs)(`span`,{className:`text-sm font-normal text-muted-foreground`,children:[`(`,e.length,`)`]})]})}),(0,l.jsxs)(a.CardContent,{className:`space-y-4`,children:[i&&(0,l.jsx)(`div`,{className:`flex items-center gap-2`,children:(0,l.jsxs)(`div`,{className:`relative flex-1`,children:[(0,l.jsx)(o.Search,{className:`absolute left-2.5 top-1/2 -translate-y-1/2 h-3.5 w-3.5 text-muted-foreground`}),(0,l.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:u(`detail.searchComments`),value:g,onChange:e=>_(e.target.value),"aria-label":u(`detail.searchComments`)}),g&&(0,l.jsx)(`button`,{className:`absolute right-2 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground`,onClick:()=>_(``),"aria-label":u(`detail.clearSearch`),type:`button`,children:(0,l.jsx)(o.X,{className:`h-3.5 w-3.5`})})]})}),n&&(0,l.jsxs)(`div`,{className:`flex gap-2`,children:[(0,l.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:u(`detail.addCommentPlaceholder`),value:f,onChange:e=>p(e.target.value),onKeyDown:y,disabled:m}),(0,l.jsx)(a.Button,{size:`icon`,variant:`default`,onClick:v,disabled:!f.trim()||m,className:`shrink-0 self-end`,children:(0,l.jsx)(o.Send,{className:`h-4 w-4`})})]}),b.length===0?(0,l.jsx)(`p`,{className:`text-sm text-muted-foreground text-center py-4`,children:g.trim()?u(`detail.noMatchingComments`):u(`detail.noCommentsYet`)}):(0,l.jsx)(`div`,{className:`space-y-3`,children:b.map(e=>(0,l.jsxs)(`div`,{className:(0,a.cn)(`flex gap-3`,e.pinned&&`bg-muted/40 rounded-md p-2 -mx-2`),children:[(0,l.jsx)(`div`,{className:`shrink-0`,children:e.avatarUrl?(0,l.jsx)(`img`,{src:e.avatarUrl,alt:e.author,className:`h-8 w-8 rounded-full object-cover`}):(0,l.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,l.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,l.jsxs)(`div`,{className:`flex items-center gap-2 mb-0.5`,children:[(0,l.jsx)(`span`,{className:`text-sm font-medium truncate`,children:e.author}),(0,l.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:G(e.createdAt,u,d)}),e.pinned&&(0,l.jsxs)(`span`,{className:`text-xs text-amber-600 flex items-center gap-0.5`,children:[(0,l.jsx)(o.Pin,{className:`h-3 w-3`}),u(`detail.pinned`)]})]}),(0,l.jsx)(`p`,{className:`text-sm whitespace-pre-wrap break-words`,children:e.text}),r&&(0,l.jsxs)(`button`,{type:`button`,className:`mt-1 text-xs text-muted-foreground hover:text-foreground flex items-center gap-1`,onClick:()=>r(e.id),"aria-label":e.pinned?u(`detail.unpin`):u(`detail.pin`),children:[(0,l.jsx)(o.Pin,{className:`h-3 w-3`}),e.pinned?u(`detail.unpin`):u(`detail.pin`)]})]})]},e.id))})]})]})},pe={field_change:o.Edit,create:o.PlusCircle,delete:o.Trash2,comment:o.MessageSquare,status_change:o.ArrowRightLeft},me={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 K(e,t,n){try{let r=new Date(e),i=new Date().getTime()-r.getTime(),a=Math.floor(i/6e4);if(a<1)return t(`detail.justNow`);if(a<60)return t(`detail.minutesAgo`,{count:a});let o=Math.floor(a/60);if(o<24)return t(`detail.hoursAgo`,{count:o});let s=Math.floor(o/24);return s<7?t(`detail.daysAgo`,{count:s}):r.toLocaleDateString(n)}catch{return e}}function he(e,t){if(e.description)return e.description;let n=t(`detail.activityEmptyValue`);return e.type===`field_change`&&e.field?t(`detail.activityFieldChanged`,{field:e.field.charAt(0).toUpperCase()+e.field.slice(1).replace(/_/g,` `),old:e.oldValue==null?n:String(e.oldValue),new:e.newValue==null?n:String(e.newValue)}):e.type===`create`?t(`detail.activityCreated`):e.type===`delete`?t(`detail.activityDeleted`):e.type===`status_change`&&e.field?t(`detail.activityStatusChanged`,{value:e.newValue==null?n:String(e.newValue)}):t(`detail.activityUpdated`)}var ge=[`all`,`field_change`,`create`,`delete`,`comment`,`status_change`];function _e(e,t){switch(e){case`field_change`:return t(`detail.fieldChangesFilter`);case`create`:return t(`detail.createsFilter`);case`delete`:return t(`detail.deletesFilter`);case`comment`:return t(`detail.comments`);case`status_change`:return t(`detail.statusChangesFilter`);default:return t(`detail.allFilter`)}}var ve=({activities:e,filterable:n=!1,defaultFilter:r=`all`,className:i})=>{let{t:c}=D(),u=(0,s.useDisplayLocale)(),[d,f]=t.useState(r),p=t.useMemo(()=>d===`all`?e:e.filter(e=>e.type===d),[e,d]);return(0,l.jsxs)(a.Card,{className:(0,a.cn)(``,i),children:[(0,l.jsx)(a.CardHeader,{children:(0,l.jsxs)(a.CardTitle,{className:`flex items-center gap-2 text-base`,children:[(0,l.jsx)(o.Activity,{className:`h-4 w-4`}),c(`detail.activity`),(0,l.jsxs)(`span`,{className:`text-sm font-normal text-muted-foreground`,children:[`(`,p.length,`)`]})]})}),(0,l.jsxs)(a.CardContent,{children:[n&&(0,l.jsx)(`div`,{className:`flex flex-wrap gap-1.5 mb-4`,role:`group`,"aria-label":c(`detail.filterActivity`),children:ge.map(e=>(0,l.jsxs)(`button`,{type:`button`,className:(0,a.cn)(`inline-flex items-center gap-1 rounded-full px-2.5 py-0.5 text-xs font-medium transition-colors`,d===e?`bg-primary text-primary-foreground`:`bg-muted text-muted-foreground hover:bg-muted/80`),onClick:()=>f(e),"aria-pressed":d===e,children:[e!==`all`&&t.createElement(pe[e]||o.Edit,{className:`h-3 w-3`}),_e(e,c)]},e))}),p.length===0?(0,l.jsx)(a.DataEmptyState,{title:c(`detail.noActivity`),className:`py-6`}):(0,l.jsxs)(`div`,{className:`relative`,children:[(0,l.jsx)(`div`,{className:`absolute left-4 top-2 bottom-2 w-px bg-border`}),(0,l.jsx)(`div`,{className:`space-y-4`,children:p.map(e=>{let t=pe[e.type]||o.Edit,n=me[e.type]||`bg-gray-100 text-gray-600`;return(0,l.jsxs)(`div`,{className:`flex gap-3 relative`,children:[(0,l.jsx)(`div`,{className:(0,a.cn)(`shrink-0 h-8 w-8 rounded-full flex items-center justify-center z-10`,n),children:(0,l.jsx)(t,{className:`h-3.5 w-3.5`})}),(0,l.jsxs)(`div`,{className:`flex-1 min-w-0 pt-1`,children:[(0,l.jsxs)(`p`,{className:`text-sm`,children:[(0,l.jsx)(`span`,{className:`font-medium`,children:e.user}),` `,(0,l.jsx)(`span`,{className:`text-muted-foreground`,children:he(e,c)})]}),(0,l.jsx)(`p`,{className:`text-xs text-muted-foreground mt-0.5`,children:K(e.timestamp,c,u)})]})]},e.id)})})]})]})]})},ye={create:`default`,update:`secondary`,delete:`destructive`,login:`outline`,logout:`outline`,config_change:`secondary`,import:`outline`};function be(e,t){if(!e)return``;let n=e instanceof Date?e:new Date(e);return Number.isNaN(n.getTime())?String(e):n.toLocaleString(t)}var xe=[[60,`second`],[60,`minute`],[24,`hour`],[7,`day`],[4.34524,`week`],[12,`month`],[1/0,`year`]];function Se(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 xe){if(Math.abs(r)<n)try{return new Intl.RelativeTimeFormat(t,{numeric:`auto`}).format(Math.round(r),i)}catch{return be(e,t)}r/=n}return be(e,t)}function Ce(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 we(e){if(!W(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 Te({entries:e,loading:t,emptyText:n,unknownUserText:r,className:i,locale:o}){let c=(0,s.useDisplayLocale)(),u=o??c;return t?(0,l.jsx)(`div`,{className:(0,a.cn)(`space-y-3`,i),children:Array.from({length:4}).map((e,t)=>(0,l.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,l.jsx)(a.Skeleton,{className:`h-8 w-8 rounded-full`}),(0,l.jsxs)(`div`,{className:`flex-1 space-y-2`,children:[(0,l.jsx)(a.Skeleton,{className:`h-4 w-1/3`}),(0,l.jsx)(a.Skeleton,{className:`h-3 w-1/2`})]})]},t))}):!e||e.length===0?(0,l.jsx)(`div`,{className:(0,a.cn)(`flex items-center justify-center rounded-md border border-dashed py-10 text-sm text-muted-foreground`,i),children:n??`No history yet`}):(0,l.jsx)(a.TooltipProvider,{delayDuration:150,children:(0,l.jsx)(`ol`,{className:(0,a.cn)(`space-y-4`,i),children:e.map((e,t)=>{let n=(e.action??``).toLowerCase(),i=ye[n]??`outline`,o=typeof e.user_name==`string`&&e.user_name.trim()||r||`Unknown user`,s=be(e.created_at,u),c=Se(e.created_at,u),d=typeof e.user_avatar==`string`?e.user_avatar:void 0;return(0,l.jsxs)(`li`,{className:`flex items-start gap-3`,children:[(0,l.jsxs)(a.Avatar,{className:`h-8 w-8 mt-0.5 shrink-0`,children:[d?(0,l.jsx)(a.AvatarImage,{src:d,alt:o}):null,(0,l.jsx)(a.AvatarFallback,{className:`text-[10px] font-medium`,children:Ce(e.user_name)})]}),(0,l.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,l.jsxs)(`div`,{className:`flex flex-wrap items-baseline gap-x-2 gap-y-1`,children:[(0,l.jsx)(`span`,{className:`text-sm font-medium text-foreground`,children:o}),e.action&&(0,l.jsx)(a.Badge,{variant:i,className:`text-[10px] uppercase tracking-wide`,children:e.action}),s&&(0,l.jsxs)(a.Tooltip,{children:[(0,l.jsx)(a.TooltipTrigger,{asChild:!0,children:(0,l.jsx)(`span`,{className:`text-xs text-muted-foreground cursor-help`,"aria-label":s,children:c||s})}),(0,l.jsx)(a.TooltipContent,{children:s})]})]}),e.summary&&(0,l.jsx)(`p`,{className:`mt-1 text-sm text-muted-foreground`,children:e.summary}),e.changes&&e.changes.length>0&&(n===`create`?(0,l.jsxs)(`details`,{className:`mt-1 group`,children:[(0,l.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,l.jsx)(`span`,{className:`transition-transform group-open:rotate-90`,children:`▸`}),(0,l.jsx)(`span`,{children:e.changes.length===1?`1 field populated`:`${e.changes.length} fields populated`})]}),(0,l.jsx)(`ul`,{className:`mt-1.5 space-y-0.5 text-xs text-muted-foreground pl-4`,children:e.changes.map(e=>(0,l.jsxs)(`li`,{className:`leading-relaxed`,children:[(0,l.jsx)(`span`,{className:`font-medium text-foreground`,children:e.label||e.field}),`: `,(0,l.jsx)(`span`,{className:`text-foreground`,children:we(e.to)})]},e.field))})]}):(0,l.jsx)(`ul`,{className:`mt-1.5 space-y-0.5 text-xs text-muted-foreground`,children:e.changes.map(e=>(0,l.jsxs)(`li`,{className:`leading-relaxed`,children:[(0,l.jsx)(`span`,{className:`font-medium text-foreground`,children:e.label||e.field}),`: `,(0,l.jsx)(`span`,{className:`line-through opacity-70`,children:we(e.from)}),` → `,(0,l.jsx)(`span`,{className:`text-foreground`,children:we(e.to)})]},e.field))}))]})]},e.id??t)})})})}var Ee=u.AUDIT_FIELD_BY_ROLE;function q(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 De(e){return W(e)?e:void 0}function Oe(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 J(e,t){try{return new Intl.DateTimeFormat(t,{dateStyle:`medium`,timeStyle:`short`}).format(e)}catch{return e.toISOString()}}var ke=({value:e,objectSchema:n,fieldName:r})=>{if(!W(e))return null;let a=n?.fields?.[r],o=a?.reference||`sys_user`,s={name:r,type:a?.type||`lookup`,reference:o,...a?.reference_field&&{reference_field:a.reference_field}},c=(0,i.resolveCellRendererType)(s)||s.type;if(c){let n=(0,i.getCellRenderer)(c);if(n)return(0,l.jsx)(`span`,{className:`inline-flex items-center [&_a]:text-inherit [&_a]:hover:underline`,children:t.createElement(n,{value:e,field:s})})}return(0,l.jsx)(`span`,{children:String(e)})},Y=({label:e,user:t,date:n,objectSchema:r,userField:i,t:o,locale:s})=>{if(!t&&!n)return null;let c=n?(0,l.jsx)(a.TooltipProvider,{delayDuration:200,children:(0,l.jsxs)(a.Tooltip,{children:[(0,l.jsx)(a.TooltipTrigger,{asChild:!0,children:(0,l.jsx)(`time`,{dateTime:n.toISOString(),className:`cursor-default underline decoration-dotted decoration-muted-foreground/40 underline-offset-2`,children:Oe(n,o)})}),(0,l.jsx)(a.TooltipContent,{side:`top`,children:J(n,s)})]})}):null;return(0,l.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[(0,l.jsx)(`span`,{className:`text-muted-foreground/70`,children:e}),t?(0,l.jsx)(ke,{value:t,objectSchema:r,fieldName:i}):null,t&&c?(0,l.jsx)(`span`,{className:`text-muted-foreground/40`,children:`·`}):null,c]})},Ae=({data:e,objectSchema:t,objectName:n,className:r})=>{let{t:i}=D(),o=(0,s.useDisplayLocale)();if(!e)return null;let c=q(e[Ee.createdAt]),u=q(e[Ee.updatedAt]),d=De(e[Ee.createdBy]),f=De(e[Ee.updatedBy]),p=!!(c||d),m=c&&u&&Math.abs(u.getTime()-c.getTime())<2e3,h=!!(u||f)&&!(m&&(d!=null&&f!=null&&String(d)===String(f)||!f));return!p&&!h?null:(0,l.jsxs)(`div`,{className:(0,a.cn)(`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:[p&&(0,l.jsx)(Y,{label:i(d?`detail.createdBy`:`detail.created`),user:d,date:c,objectSchema:t,userField:Ee.createdBy,t:i,locale:o}),h&&(0,l.jsx)(Y,{label:i(f?`detail.updatedBy`:`detail.updated`),user:f,date:u,objectSchema:t,userField:Ee.updatedBy,t:i,locale:o})]})},X=new Map,je=new Set;function Me(e){for(let t of Array.from(X.keys())){let[,n,i]=JSON.parse(t);(0,r.dataChangeMatches)(e,n,i)&&X.delete(t)}for(let t of je)for(let n of t.recordIds)(0,r.dataChangeMatches)(e,t.object,n)&&t.staled.add(n)}(0,r.subscribeDataChanges)(Me);var Ne;function Pe(e){Ne!==void 0&&Ne!==e&&X.clear(),Ne=e}function Fe(e,n,i=`update`,a=!0){let o=(0,d.usePermissions)().userId,s=e&&n?JSON.stringify([o,e,n,i]):``,c=(0,r.useDataInvalidation)(e,n),[l,u]=t.useState(()=>s&&X.has(s)?X.get(s):!0),f=t.useContext(r.SchemaRendererContext)?.apiFetch;return t.useEffect(()=>{if(Pe(o),!a||!e||!n){u(!0);return}if(X.has(s)){u(X.get(s));return}u(!0);let t=!1,r={object:e,recordIds:[n],staled:new Set};return je.add(r),(async()=>{try{let a=await(f??fetch)(`/api/v1/security/explain`,{method:`POST`,headers:{"Content-Type":`application/json`},credentials:`include`,body:JSON.stringify({object:e,operation:i,recordId:n})});if(!a.ok)return;let o=(await a.json())?.record?.visible;if(typeof o!=`boolean`||r.staled.size>0)return;X.set(s,o),t||u(o)}catch{}finally{je.delete(r)}})(),()=>{t=!0}},[s,o,e,n,i,a,f,c]),l}function Ie(){X.clear(),Ne=void 0}var Le=new Set([`select`,`status`,`multiselect`,`radio`,`checkboxes`,`tags`,`user`,`image`,`avatar`,`signature`,`boolean`,`toggle`,`date`,`datetime`,`repeater`,`file`,`video`,`audio`]);function Re(e){return!Le.has(e)}function ze(e,t){let r=(0,n.percentDisplayValue)(e,t);return t===`whole`?r:Number(r.toPrecision(12))}var Be={};function Ve(e,t,r,i){if(e&&typeof e==`object`){if(t.primaryField){let n=e[t.primaryField];if(n!=null&&n!==``)return String(n)}let i=(0,n.recordDisplayValueAt)(e,(0,n.declaredNameField)(r));if(i){let t=e.id??e._id;if(!(i===`Untitled`||t!=null&&i===`Record #${t}`))return i}let a=(0,n.formatTitleTemplate)(r?.titleFormat,e);if(a)return a}if(e&&typeof e==`object`){let t=e.id??e._id,i=(0,n.getRecordDisplayName)(r,e,{deriveFromRecordKeys:!1});if(!(i===`Untitled`||t!=null&&i===`Record #${t}`))return i}if(t.title)return t.title;if(e&&typeof e==`object`){let t=e.id??e._id,i=(0,n.getRecordDisplayName)(r,e);if(!(i===`Untitled`||t!=null&&i===`Record #${t}`))return i}if(e&&typeof e==`object`){let t=e.id??e._id;if(t!=null&&String(t).trim()!==``)return`Record #${t}`}return i}var He=e=>(e||[]).flatMap(e=>Array.isArray(e?.fields)?e.fields:[]),Ue=({section:e,index:t,children:n})=>(0,l.jsx)(r.SchemaErrorBoundary,{componentType:`record:details section ${e?.name??e?.group??e?.title??e?.label??`#${t+1}`}`,children:n}),Z=({schema:e,dataSource:c,className:u,onEdit:p,onDelete:m,onBack:h,inlineEdit:g=!1,discussionSlot:_,rightRail:v,objectLabel:y,onDataLoaded:b,isFavorite:x,onToggleFavorite:S})=>{let[C,w]=t.useState(e.data),[T,E]=t.useState(!e.data&&!!(e.api&&e.resourceId||c&&e.objectName&&e.resourceId)),[O,k]=t.useState(!1),A=x??O,j=(0,r.useInlineEdit)(),M=j?.editing??!1,N=j?.draft??Be,P=j?.autoFocusField??null,[F,I]=t.useState(null),[L,R]=t.useState(null),[z,ee]=t.useState(!1),[te,ne]=t.useState(0),V=(0,r.useDataInvalidation)(e.objectName||void 0,e.resourceId==null?void 0:String(e.resourceId)),[re,ie]=t.useState(!1),{t:H}=D(),{currency:U}=(0,s.useLocalization)(),ae=(0,s.useDisplayLocale)(),{fieldOptionLabel:oe,fieldLabel:se}=(0,r.useSafeFieldLabel)(),G=(0,d.usePermissions)(),pe=t.useMemo(()=>{if(!G?.isLoaded||!e.objectName)return e;let t=t=>G.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,G]),me=t.useMemo(()=>(0,n.withoutDeniedFields)(C,G,e.objectName),[C,G,e.objectName]),K=t.useMemo(()=>!G?.isLoaded||!e.objectName||G.can(e.objectName,`update`),[G,e.objectName]),he=t.useMemo(()=>!G?.isLoaded||!e.objectName||G.can(e.objectName,`delete`),[G,e.objectName]),ge=e.resourceId==null?void 0:String(e.resourceId),_e=Fe(e.objectName,ge,`update`,K),ye=Fe(e.objectName,ge,`delete`,he),be=t.useMemo(()=>(0,n.userActionPredicates)(L?.userActions?.edit),[L]),xe=t.useMemo(()=>(0,n.userActionPredicates)(L?.userActions?.delete),[L]),Se=L?.fields,Ce=(0,r.useRowPredicate)(be?.visibleWhen??!0,C,{fallback:!1,warnOnError:!0,label:`builtin:edit:visibleWhen`,fields:Se}),we=(0,r.useRowPredicate)(xe?.visibleWhen??!0,C,{fallback:!1,warnOnError:!0,label:`builtin:delete:visibleWhen`,fields:Se}),Ee=(0,r.useRowPredicate)(be?.disabledWhen,C,{fallback:!1,warnOnError:!0,label:`builtin:edit:disabledWhen`,fields:Se}),q=(0,r.useRowPredicate)(xe?.disabledWhen,C,{fallback:!1,warnOnError:!0,label:`builtin:delete:disabledWhen`,fields:Se}),De=be?.disabledWhen!=null&&Ee,Oe=xe?.disabledWhen!=null&&q,J=t.useMemo(()=>({...pe,showEdit:pe.showEdit&&K&&_e&&Ce,showDelete:pe.showDelete&&he&&ye&&we}),[pe,K,_e,Ce,he,ye,we]);t.useEffect(()=>{C&&b&&b(C)},[C,b]);let ke=t.useMemo(()=>{if(J.summaryFields&&J.summaryFields.length>0)return[];let e=[...He(J.sections),...J.fields||[]],t={};for(let n of e)t[n.name]||(t[n.name]=n);if(L?.fields)for(let[e,n]of Object.entries(L.fields))t[e]={...t[e]||{},...n,name:e};let n=e=>W(C?.[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},[J.summaryFields,J.sections,J.fields,L,C]),Y=J.summaryFields&&J.summaryFields.length>0?J.summaryFields:ke,X=t.useCallback(()=>{J.resourceId&&navigator.clipboard.writeText(String(J.resourceId)).then(()=>{ee(!0),setTimeout(()=>ee(!1),1500)})},[J.resourceId]);t.useEffect(()=>{let e=!0;if(J.data)return w(J.data),E(!1),c?.getObjectSchema&&J.objectName&&c.getObjectSchema(J.objectName).then(t=>{e&&R(t)}).catch(()=>{}),()=>{e=!1};if(c&&J.objectName&&J.resourceId){E(!0),R(null),w(null);let t=J.objectName,r=J.resourceId,i=`${t}-`,a=[...He(J.sections),...J.fields||[]];(c.getObjectSchema?c.getObjectSchema(t).catch(()=>null):Promise.resolve(null)).then(o=>{if(!e)return;R(o);let s=(0,n.buildExpandFields)(o?.fields,a),l=G?.isLoaded?s.filter(e=>G.checkField(t,e,`read`)):s,u=l.length>0?{$expand:l}:void 0,d=u?c.findOne(t,r,u):c.findOne(t,r),f=()=>{let n=String(r),a=n.startsWith(i)?n.slice(i.length):`${i}${n}`;return(u?c.findOne(t,a,u):c.findOne(t,a)).then(t=>{e&&(w(t),E(!1))}).catch(()=>{e&&(w(null),E(!1))})};return d.catch(()=>null).then(t=>{if(e){if(t){w(t),E(!1);return}return f()}})}).catch(t=>{e&&(console.error(`Failed to fetch detail data:`,t),E(!1))})}else J.api&&J.resourceId&&(E(!0),fetch(`${J.api}/${J.resourceId}`).then(e=>e.json()).then(t=>{e&&w(t?.data||t)}).catch(e=>{console.error(`Failed to fetch detail data:`,e)}).finally(()=>{e&&E(!1)}));return()=>{e=!1}},[J.api,J.resourceId,J.objectName,c,J.sections,J.fields,te,V,G]);let je=t.useCallback(()=>{if(h)h();else if(J.onNavigate){let e=J.backUrl||(J.objectName?`/${J.objectName}`:`/`);J.onNavigate(e,{replace:!0})}else J.backUrl?window.location.href=J.backUrl:window.history.back()},[h,J]),Me=t.useCallback(()=>{p?p():J.onNavigate&&J.editUrl?J.onNavigate(J.editUrl):J.onNavigate&&J.objectName&&J.resourceId?J.onNavigate(`/${J.objectName}/${J.resourceId}/edit`):J.editUrl&&(window.location.href=J.editUrl)},[p,J]),Ne=t.useCallback(async()=>{if(!c?.cancelPendingApproval||!J.objectName||!J.resourceId){I(H(`detail.cancelApprovalUnavailable`));return}ie(!0),I(null);try{if(await c.cancelPendingApproval(String(J.objectName),String(J.resourceId)),c.findOne)try{let e=await c.findOne(String(J.objectName),String(J.resourceId));e&&w(e)}catch{}ne(e=>e+1);try{window.dispatchEvent(new CustomEvent(`objectui:record-changed`,{detail:{objectName:String(J.objectName),recordId:String(J.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*/,``);I(`${H(`detail.cancelApprovalFailed`)}: ${t}`)}finally{ie(!1)}},[c,J.objectName,J.resourceId,H]),Pe=t.useCallback(()=>{let e=J.deleteConfirmation||H(`detail.deleteConfirmation`);window.confirm(e)&&(m?.(),J.onNavigate&&J.objectName&&J.onNavigate(`/${J.objectName}`,{replace:!0}))},[m,J]),Ie=t.useCallback(()=>{navigator.share&&J.objectName&&J.resourceId?navigator.share({title:J.title||H(`detail.details`),text:`${J.objectName} #${J.resourceId}`,url:window.location.href}).catch(e=>{console.error(`Share failed:`,e)}):navigator.clipboard.writeText(window.location.href)},[J]),Le=t.useCallback(()=>{let e=!A;S&&S(e),x===void 0&&k(e)},[A,x,S]),Z=j?.setField,We=j&&j.canEdit?j.enter:void 0;t.useEffect(()=>{if(!J.recordNavigation)return;let e=J.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)},[J.recordNavigation]);let Ge=t.useMemo(()=>{let e=[];return e.push({name:`sys_share`,label:H(`detail.share`),icon:`share-2`,type:`script`,onClick:Ie}),J.showEdit&&e.push({name:`sys_edit_mobile`,label:H(`detail.edit`),icon:`square-pen`,type:`script`,className:`sm:hidden`,...De?{disabled:!0}:null,onClick:Me}),J.showDelete&&e.push({name:`sys_delete`,label:H(`detail.delete`),icon:`trash`,type:`script`,variant:`destructive`,tags:[`separator-before`],...Oe?{disabled:!0}:null,onClick:Pe}),e},[H,J.showEdit,J.showDelete,De,Oe,Ie,Me,Pe]),Ke=t.useMemo(()=>{let e=J.actions??[];if(Ge.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,...Ge]}}return e});return t||n.push({type:`action:bar`,location:`record_header`,systemActions:Ge}),n},[J.actions,Ge]);return T||J.loading?(0,l.jsxs)(`div`,{className:(0,a.cn)(`space-y-4`,u),children:[(0,l.jsx)(a.Skeleton,{className:`h-10 w-full`}),(0,l.jsx)(a.Skeleton,{className:`h-64 w-full`}),(0,l.jsx)(a.Skeleton,{className:`h-48 w-full`})]}):!C&&!J.data?(0,l.jsxs)(`div`,{className:(0,a.cn)(`flex flex-col items-center justify-center py-16 text-center`,u),children:[(0,l.jsx)(`p`,{className:`text-lg font-semibold`,children:H(`detail.recordNotFound`)}),(0,l.jsx)(`p`,{className:`text-sm text-muted-foreground mt-1`,children:H(`detail.recordNotFoundDescription`)}),(J.showBack??!0)&&(0,l.jsxs)(a.Button,{variant:`outline`,size:`sm`,onClick:je,className:`mt-4 gap-2`,children:[(0,l.jsx)(o.ArrowLeft,{className:`h-4 w-4`}),H(`detail.goBack`)]})]}):(0,l.jsx)(a.TooltipProvider,{children:(0,l.jsxs)(`div`,{className:(0,a.cn)(`space-y-6`,u),children:[J.showHeader!==!1&&(0,l.jsxs)(`div`,{className:`flex flex-col sm:flex-row sm:flex-wrap items-start justify-between gap-3 sm:gap-4 pb-4 border-b`,children:[(0,l.jsxs)(`div`,{className:`flex items-start gap-2 sm:gap-3 flex-1 min-w-0 sm:min-w-64 w-full sm:w-auto`,children:[(J.showBack??!0)&&(0,l.jsxs)(a.Tooltip,{children:[(0,l.jsx)(a.TooltipTrigger,{asChild:!0,children:(0,l.jsx)(a.Button,{variant:`ghost`,size:`icon`,onClick:je,className:`shrink-0 mt-1`,children:(0,l.jsx)(o.ArrowLeft,{className:`h-4 w-4`})})}),(0,l.jsx)(a.TooltipContent,{children:H(`detail.back`)})]}),(0,l.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,l.jsxs)(`div`,{className:`flex items-center gap-2 flex-wrap`,children:[(0,l.jsx)(`h1`,{className:`text-xl sm:text-2xl font-bold truncate`,children:Ve(me,J,L,H(`detail.details`))}),Y.map(e=>{let t=C?.[e];if(!W(t))return null;let r=He(J.sections).concat(J.fields||[]).find(t=>t.name===e),o=L?.fields?.[e],c=r?.type||o?.type,u=se(J.objectName||``,e,r?.label||o?.label||e),d=String(t),p=null;try{if(c===`currency`){let e=Number(t);if(!Number.isNaN(e)){let t=(0,s.resolveFieldCurrency)({...o,...r},U);d=t?new Intl.NumberFormat(ae,{style:`currency`,currency:t,maximumFractionDigits:0}).format(e):new Intl.NumberFormat(ae,{maximumFractionDigits:0}).format(e)}}else if(c===`date`||c===`datetime`){let e=(0,n.toDisplayDate)(t);Number.isNaN(e.getTime())||(d=c===`datetime`?e.toLocaleString(ae,{dateStyle:`medium`,timeStyle:`short`}):e.toLocaleDateString(ae,{dateStyle:`medium`}))}else if(c===`percent`){let e=Number(t);if(!Number.isNaN(e)){let t={...o,...r},n=(0,f.resolveFieldScale)({type:c,scale:t.scale}),a=(0,i.percentCellScale)({type:c,max:t.max});d=(0,i.formatPercent)(e,a,n,ae);let s=ze(e,a);p=Math.max(0,Math.min(100,s))}}else if(c===`select`||c===`status`||c===`multiselect`){let n=r?.options||o?.options,i=String(t);if(Array.isArray(n)){let e=n.find(e=>String(e?.value??e)===String(t));e?.label&&(i=e.label)}else if(n&&typeof n==`object`){let e=n[String(t)];e?.label&&(i=e.label)}d=J.objectName?oe(J.objectName,e,String(t),i):i}}catch{}let m=B({name:e,label:r?.label,type:c||`text`},o),h=(0,i.resolveCellRendererType)(m)||c||`text`,g=d.includes(`[object Object]`),_=g&&Re(h)?(0,i.getCellRenderer)(h):null;return g&&!_&&(d=String((0,i.coerceToSafeValue)(t)??``)),_?(0,l.jsxs)(a.Badge,{variant:`secondary`,className:`text-xs bg-primary/10 text-primary border-transparent hover:bg-primary/15`,"data-summary-chip":e,children:[(0,l.jsx)(`span`,{className:`sr-only`,children:`${u}: `}),(0,l.jsx)(_,{value:t,field:m})]},e):p===null?(0,l.jsx)(a.Badge,{variant:`secondary`,className:`text-xs bg-primary/10 text-primary border-transparent hover:bg-primary/15`,"aria-label":`${u}: ${d}`,"data-summary-chip":e,children:d},e):(0,l.jsxs)(a.Badge,{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":`${u}: ${d}`,"data-summary-chip":e,children:[(0,l.jsx)(`span`,{className:`relative inline-block h-1.5 w-12 rounded-full bg-primary/20 overflow-hidden`,"aria-hidden":!0,children:(0,l.jsx)(`span`,{className:`absolute inset-y-0 left-0 rounded-full bg-primary`,style:{width:`${p}%`}})}),d]},e)}),(0,l.jsxs)(a.Tooltip,{children:[(0,l.jsx)(a.TooltipTrigger,{asChild:!0,children:(0,l.jsx)(a.Button,{variant:`ghost`,size:`icon`,className:`h-6 w-6 shrink-0`,onClick:Le,"aria-label":H(A?`detail.removeFromFavorites`:`detail.addToFavorites`),children:A?(0,l.jsx)(o.Star,{className:`h-4 w-4 fill-yellow-400 text-yellow-400`}):(0,l.jsx)(o.Star,{className:`h-4 w-4 text-muted-foreground`})})}),(0,l.jsx)(a.TooltipContent,{children:H(A?`detail.removeFromFavorites`:`detail.addToFavorites`)})]})]}),J.objectName&&(0,l.jsxs)(`p`,{className:`text-sm text-muted-foreground mt-1 flex items-center gap-1`,children:[(0,l.jsx)(`span`,{className:`font-medium`,children:y||J.objectName}),J.resourceId&&(0,l.jsxs)(a.Tooltip,{children:[(0,l.jsx)(a.TooltipTrigger,{asChild:!0,children:(0,l.jsx)(a.Button,{variant:`ghost`,size:`icon`,className:`h-5 w-5 shrink-0 text-muted-foreground/60 hover:text-foreground`,onClick:X,"aria-label":H(`detail.copyRecordId`,{defaultValue:`Copy record ID`}),children:z?(0,l.jsx)(o.Check,{className:`h-3 w-3 text-green-600`}):(0,l.jsx)(o.Copy,{className:`h-3 w-3`})})}),(0,l.jsx)(a.TooltipContent,{children:z?H(`detail.copied`,{defaultValue:`Copied!`}):H(`detail.copyRecordId`,{defaultValue:`Copy record ID`})})]})]})]})]}),(0,l.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5 shrink-0 w-full sm:w-auto`,children:[J.recordNavigation&&(0,l.jsxs)(`div`,{className:`flex items-center gap-1 mr-2`,children:[(0,l.jsxs)(a.Tooltip,{children:[(0,l.jsx)(a.TooltipTrigger,{asChild:!0,children:(0,l.jsx)(a.Button,{variant:`outline`,size:`icon`,className:`h-8 w-8`,disabled:J.recordNavigation.currentIndex<=0,onClick:()=>{let e=J.recordNavigation;e.currentIndex>0&&e.onNavigate(e.recordIds[e.currentIndex-1])},children:(0,l.jsx)(o.ChevronLeft,{className:`h-4 w-4`})})}),(0,l.jsx)(a.TooltipContent,{children:H(`detail.previousRecord`)})]}),(0,l.jsx)(`span`,{className:`text-xs text-muted-foreground whitespace-nowrap px-1`,children:H(`detail.recordOf`,{current:J.recordNavigation.currentIndex+1,total:J.recordNavigation.recordIds.length})}),(0,l.jsxs)(a.Tooltip,{children:[(0,l.jsx)(a.TooltipTrigger,{asChild:!0,children:(0,l.jsx)(a.Button,{variant:`outline`,size:`icon`,className:`h-8 w-8`,disabled:J.recordNavigation.currentIndex>=J.recordNavigation.recordIds.length-1,onClick:()=>{let e=J.recordNavigation;e.currentIndex<e.recordIds.length-1&&e.onNavigate(e.recordIds[e.currentIndex+1])},children:(0,l.jsx)(o.ChevronRight,{className:`h-4 w-4`})})}),(0,l.jsx)(a.TooltipContent,{children:H(`detail.nextRecord`)})]})]}),J.showEdit&&(0,l.jsxs)(a.Tooltip,{children:[(0,l.jsx)(a.TooltipTrigger,{asChild:!0,children:(0,l.jsxs)(a.Button,{variant:`default`,disabled:De,onClick:()=>{De||Me()},className:`gap-2 hidden sm:inline-flex`,children:[(0,l.jsx)(o.Edit,{className:`h-4 w-4`}),(0,l.jsx)(`span`,{className:`hidden sm:inline`,children:H(`detail.edit`)})]})}),(0,l.jsx)(a.TooltipContent,{children:H(`detail.editRecord`)})]}),Ke.map((e,t)=>(0,l.jsx)(r.SchemaRenderer,{schema:(0,r.toRenderableSchema)(e),data:C},`header-action-${t}`))]})]}),(0,a.renderNodeSlot)(J.header,e=>(0,l.jsx)(`div`,{children:(0,l.jsx)(r.SchemaRenderer,{schema:(0,r.toRenderableSchema)(e),data:C})})),J.highlightFields&&J.highlightFields.length>0&&(0,l.jsx)(de,{fields:J.highlightFields,data:C,objectName:J.objectName,objectSchema:L}),g&&J.showHeader===!1&&(()=>{let e=C?.approval_status,t=e===`pending`||e===`in_approval`,n=j?.approvalPending??!1,r=n&&!(j?.locked??!1)?!1:(j?.locked??!1)||t,i=r||n||t,s=i?j?.approvalProgress:void 0,u=!!s&&s.need>0&&s.need<=12;return!i&&!F?null:(0,l.jsxs)(`div`,{className:`flex flex-col items-end gap-1`,children:[i&&(0,l.jsxs)(`div`,{className:`flex items-center justify-end gap-2`,children:[(0,l.jsxs)(`span`,{role:`status`,className:r?`inline-flex items-center gap-1 rounded-md border border-amber-300 bg-amber-50 px-2 py-1 text-xs text-amber-800`:`inline-flex items-center gap-1 rounded-md border border-sky-300 bg-sky-50 px-2 py-1 text-xs text-sky-800`,title:r?j?.lockedReason??H(`detail.lockedTooltip`):H(`detail.approvalPendingTooltip`),children:[r?(0,l.jsx)(o.Lock,{className:`h-3 w-3`}):(0,l.jsx)(o.Clock,{className:`h-3 w-3`}),(0,l.jsx)(`span`,{children:H(r?`detail.lockedByApproval`:`detail.approvalPendingEditable`)})]}),c?.cancelPendingApproval&&j?.approvalIsSubmitter!==!1&&(0,l.jsxs)(a.Button,{variant:`outline`,size:`sm`,onClick:Ne,disabled:re,className:r?`gap-2 border-amber-300 text-amber-800 hover:bg-amber-50`:`gap-2 border-sky-300 text-sky-800 hover:bg-sky-50`,title:H(r?`detail.cancelApprovalTooltip`:`detail.cancelApprovalTooltipUnlocked`),children:[(0,l.jsx)(o.X,{className:`h-4 w-4`}),(0,l.jsx)(`span`,{children:H(re?`detail.cancelApprovalInFlight`:`detail.cancelApproval`)})]})]}),s&&(0,l.jsxs)(`div`,{className:`flex flex-col items-end gap-1 max-w-[16rem]`,children:[(0,l.jsxs)(`div`,{role:`progressbar`,"aria-valuemin":0,"aria-valuemax":s.need,"aria-valuenow":Math.min(s.got,s.need),"aria-label":H(`detail.approvalProgressLabel`),className:`flex items-center gap-2 w-full justify-end`,children:[(0,l.jsx)(`span`,{className:`text-[11px] text-muted-foreground whitespace-nowrap`,children:s.behavior===`per_group`?H(`detail.approvalProgressGroups`,{got:s.got,need:s.need}):H(`detail.approvalProgress`,{got:s.got,need:s.need})}),u&&(0,l.jsx)(`span`,{className:`flex items-center gap-1 w-20 shrink-0`,children:Array.from({length:s.need}).map((e,t)=>(0,l.jsx)(`span`,{"aria-hidden":`true`,className:(0,a.cn)(`h-1.5 flex-1 rounded-full`,t<s.got?`bg-emerald-500`:`bg-muted`)},t))})]}),s.groups&&s.groups.length>0&&(0,l.jsx)(`div`,{className:`flex flex-wrap justify-end gap-1`,children:s.groups.map(e=>(0,l.jsxs)(`span`,{title:`${e.got}/${e.need}`,className:(0,a.cn)(`inline-flex items-center gap-1 rounded-md border px-1.5 py-0.5 text-[11px]`,e.satisfied?`border-emerald-300 text-emerald-700`:`border-border text-muted-foreground`),children:[e.satisfied?(0,l.jsx)(o.Check,{className:`h-3 w-3`}):(0,l.jsx)(o.Circle,{className:`h-2.5 w-2.5`}),(0,l.jsx)(`span`,{children:`${e.group} ${e.got}/${e.need}`})]},e.group))})]}),F&&(0,l.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:F})]})})(),J.autoTabs&&!J.tabs?.length?(()=>{let e=!!J.activities&&J.activities.length>0,t=!!_,n=!!J.history,r=[`details`,...e?[`activity`]:[],...t?[`discussion`]:[],...n?[`history`]:[]],i=J.defaultTab,o=i&&r.includes(i)?i:`details`,s=J.onTabChange,u=(0,l.jsxs)(`div`,{className:`space-y-3 sm:space-y-4`,children:[J.sectionGroups&&J.sectionGroups.length>0&&J.sectionGroups.map((e,t)=>(0,l.jsx)(ue,{group:e,data:{...C,...N},objectSchema:L,objectName:J.objectName,isEditing:M,onFieldChange:Z,onEnterInlineEdit:g?We:void 0,autoFocusField:P,dataSource:c},t)),J.sections&&J.sections.length>0&&J.sections.map((e,t)=>(0,l.jsx)(Ue,{section:e,index:t,children:(0,l.jsx)(ce,{section:e,data:{...C,...N},objectSchema:L,objectName:J.objectName,isEditing:M,onFieldChange:Z,onEnterInlineEdit:g?We:void 0,autoFocusField:P,dataSource:c})},t)),J.fields&&J.fields.length>0&&!J.sections?.length&&(0,l.jsx)(ce,{section:{fields:J.fields,columns:J.columns},data:{...C,...N},objectSchema:L,objectName:J.objectName,isEditing:M,onFieldChange:Z,onEnterInlineEdit:g?We:void 0,autoFocusField:P,dataSource:c}),J.comments&&(0,l.jsx)(fe,{comments:J.comments,onAddComment:J.onAddComment})]});return!e&&!t&&!n?(0,l.jsx)(`div`,{className:`mt-2`,children:u}):(0,l.jsxs)(a.Tabs,{defaultValue:o,onValueChange:s,className:`w-full`,children:[(0,l.jsxs)(a.TabsList,{className:`w-full justify-start border-b rounded-none bg-transparent p-0`,children:[(0,l.jsx)(a.TabsTrigger,{value:`details`,className:`relative rounded-none border-b-2 border-transparent data-[state=active]:border-primary data-[state=active]:bg-transparent`,children:H(`detail.details`)}),e&&(0,l.jsx)(a.TabsTrigger,{value:`activity`,className:`relative rounded-none border-b-2 border-transparent data-[state=active]:border-primary data-[state=active]:bg-transparent`,children:(0,l.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[H(`detail.activity`),(0,l.jsx)(a.Badge,{variant:`secondary`,className:`text-xs bg-primary/10 text-primary border-transparent`,children:J.activities.length})]})}),t&&(0,l.jsx)(a.TabsTrigger,{value:`discussion`,className:`relative rounded-none border-b-2 border-transparent data-[state=active]:border-primary data-[state=active]:bg-transparent`,children:H(`detail.discussion`,{defaultValue:`Discussion`})}),n&&(0,l.jsx)(a.TabsTrigger,{value:`history`,className:`relative rounded-none border-b-2 border-transparent data-[state=active]:border-primary data-[state=active]:bg-transparent`,children:(0,l.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[H(`detail.history`,{defaultValue:`History`}),!J.history.loading&&J.history.entries.length>0&&(0,l.jsx)(a.Badge,{variant:`secondary`,className:`text-xs bg-primary/10 text-primary border-transparent`,children:J.history.entries.length})]})})]}),(0,l.jsx)(a.TabsContent,{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:u}),e&&(0,l.jsx)(a.TabsContent,{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,l.jsx)(ve,{activities:J.activities})}),t&&(0,l.jsx)(a.TabsContent,{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:_}),n&&(0,l.jsx)(a.TabsContent,{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,l.jsx)(Te,{entries:J.history.entries,loading:J.history.loading,emptyText:J.history.emptyText??H(`detail.historyEmpty`,{defaultValue:`No history yet`})})})]})})():(0,l.jsxs)(l.Fragment,{children:[J.sectionGroups&&J.sectionGroups.length>0&&(0,l.jsx)(`div`,{className:`space-y-3 sm:space-y-4`,children:J.sectionGroups.map((e,t)=>(0,l.jsx)(ue,{group:e,data:{...C,...N},objectSchema:L,objectName:J.objectName,isEditing:M,onFieldChange:Z,onEnterInlineEdit:g?We:void 0,autoFocusField:P,dataSource:c},t))}),J.sections&&J.sections.length>0&&(0,l.jsx)(`div`,{className:`space-y-3 sm:space-y-4`,children:J.sections.map((e,t)=>(0,l.jsx)(Ue,{section:e,index:t,children:(0,l.jsx)(ce,{section:e,data:{...C,...N},objectSchema:L,objectName:J.objectName,isEditing:M,onFieldChange:Z,onEnterInlineEdit:g?We:void 0,autoFocusField:P,dataSource:c})},t))}),J.fields&&J.fields.length>0&&!J.sections?.length&&(0,l.jsx)(ce,{section:{fields:J.fields,columns:J.columns},data:{...C,...N},objectSchema:L,objectName:J.objectName,isEditing:M,onFieldChange:Z,onEnterInlineEdit:g?We:void 0,autoFocusField:P,dataSource:c}),J.tabs&&J.tabs.length>0&&(0,l.jsx)(le,{tabs:J.tabs,data:C}),J.comments&&(0,l.jsx)(fe,{comments:J.comments,onAddComment:J.onAddComment}),J.activities&&J.activities.length>0&&(0,l.jsx)(ve,{activities:J.activities})]}),(0,l.jsx)(Ae,{data:{...C,...N},objectSchema:L,objectName:J.objectName}),(0,a.renderNodeSlot)(J.footer,e=>(0,l.jsx)(`div`,{children:(0,l.jsx)(r.SchemaRenderer,{schema:(0,r.toRenderableSchema)(e),data:C})}))]})})},We=new Set([`title`,`description`,`icon`,`fields`,`collapsible`,`defaultCollapsed`,`columns`,`showBorder`,`headerColor`,`hideEmpty`]),Ge=e=>{let t={},n={};for(let[r,i]of Object.entries(e))(We.has(r)?t:n)[r]=i;return(0,l.jsx)(ce,{...n,section:t})};Ge.displayName=`DetailSectionNode(DetailSection)`;function Ke(e){return(0,a.resolveIcon)(e)??o.Inbox}function qe(e,t){let r=e?.id??e?._id;if(t){let i=(0,n.getRecordDisplayName)(t,e),a=i===`Untitled`||r!=null&&i===`Record #${r}`;if(i&&!a)return i}return e?.full_name||e?.fullname||e?.display_name||e?.name||e?.subject||e?.title||e?.label||e?.code||e?.email||(r==null?void 0:String(r))}function Je(e){if(!e)return[];if(typeof e==`string`){let t=e.trim();return t?t.startsWith(`-`)?[{field:t.slice(1),order:`desc`}]:[{field:t,order:`asc`}]:[]}return e.filter(e=>!!e?.field)}var Ye=`image`;function Xe(e){return t.createElement(i.MaskedCellRenderer,{value:e})}function Ze(e){let t=e?.accessorKey||(0,n.columnIdentity)(e);return t?String(t):void 0}function Qe(e){return JSON.parse(e)}function $e(e,t,n){return!t?.isLoaded||!n?e:e.filter(e=>{let r=Ze(e);return!r||t.checkField(n,r,`read`)})}function et(e,t){return t?e.filter(e=>Ze(e)!==t):e}function tt(e,t){return t.size===0?e:e.filter(e=>{let n=Ze(e);return!(n&&t.has(n))})}var nt=({action:e,onToolbarAction:t})=>{let n=e.visible,i=(0,r.useCondition)((0,r.toPredicateInput)(n),void 0,{throwOnError:!0,label:`related-list toolbar action "${e.name}" (visible)`});if((0,a.hasDeclaredVisibilityGate)(n)&&!i)return null;let o=e.icon?Ke(e.icon):null;return(0,l.jsxs)(a.Button,{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:[o&&(0,l.jsx)(o,{className:`h-3.5 w-3.5`}),e.label||e.name]})},rt=({title:e,type:s,api:c,data:u,schema:f,columns:p,className:m,dataSource:h,objectName:g,onNew:_,newDisabled:v,onViewAll:y,onRowEdit:b,onRowDelete:x,onRowClick:S,rowActions:C,onRowAction:w,toolbarActions:T,onToolbarAction:E,add:O,redactFields:k,maxColumns:A=6,pageSize:j,defaultSort:M,sortable:N=!1,filter:P,filterable:F=!1,collapsible:I=!1,defaultCollapsed:R=!1,referenceField:z,parentId:B,icon:ee})=>{let te=u!==void 0,ne=u??[],[V,re]=t.useState(ne),[ie,H]=t.useState(()=>!!c&&!te),[U,ae]=t.useState(0),[W,oe]=t.useState(null),[se,ce]=t.useState(`asc`),[le,ue]=t.useState(``),[de,G]=t.useState(null),[fe,pe]=t.useState(!1),{ready:me,def:K}=(0,r.useSettledSchema)(c??``,h),[he,ge]=t.useState(R),[_e,ve]=t.useState(!1),[ye,be]=t.useState(!1),[xe,Se]=t.useState(null),[Ce,we]=t.useState(0),[Te,Ee]=t.useState({}),{t:q}=D(),{fieldLabel:De}=(0,r.useSafeFieldLabel)(),Oe=(0,d.usePermissions)(),J=(0,r.useCapabilityGate)(),ke=t.useMemo(()=>(T??[]).filter(e=>J(e?.requiredPermissions)),[T,J]),Y=j&&j>0?j:0,Ae=F&&le!==``,X=!te&&!!c&&Y>0&&!!h&&typeof h.find==`function`&&!Ae,je=X?U:0,Me=X?W:null,Ne=X?se:`asc`,Pe=JSON.stringify(M??null),Fe=t.useMemo(()=>Je(M),[Pe]),Ie=(0,r.useFilterScope)(),Le=(0,r.useResolvedFilter)(P,Ie),Re=JSON.stringify(Le??null),ze=t.useMemo(()=>(0,n.toFilterNodeSafely)(Le),[Re]),Be=ze.ok?void 0:ze.refusal,Ve=ze.ok?ze.node:void 0,He=t.useMemo(()=>{let e=Array.isArray(p)?p.map(e=>typeof e==`string`?e:e?.accessorKey||(0,n.columnIdentity)(e)).filter(e=>typeof e==`string`&&e.length>0):[],t=(0,n.buildExpandFields)(K?.fields,e.length>0?e:void 0).filter(e=>e!==z),r=g||c||``;return!Oe?.isLoaded||!r?t:t.filter(e=>Oe.checkField(r,e,`read`))},[p,K,z,g,c,Oe]),Ue=He.join(`,`),Z=t.useMemo(()=>new Set((Array.isArray(k)?k:[]).filter(e=>typeof e==`string`&&e.length>0)),[k]),We=t.useMemo(()=>{let e=tt(Array.isArray(p)?p:[],Z);if(e.length===0)return;let t=g||c||``,r=new Set([`id`]);for(let n of $e(et(e,z),Oe,t)){let e=Ze(n);e&&r.add(e)}for(let e of He)r.add(e);let i=K?.fields;if(i&&typeof i==`object`){let e=e=>!Oe?.isLoaded||!t||Oe.checkField(t,e,`read`),a=(0,n.collectPredicateFieldRefs)((0,n.listViewPredicates)({rowActionDefs:C,objectActions:K?.actions,userActions:K?.userActions}));for(let t of a){let a=(0,n.parentRelationshipFieldDef)(i,t)!==void 0;(a||n.PLATFORM_RECORD_COLUMNS.has(t))&&(!a||e(t))&&r.add(t)}(0,n.parentRelationshipFieldDef)(i,Ye)!==void 0&&e(Ye)&&r.add(Ye)}return Array.from(r)},[p,Z,z,g,c,Oe,He,K,C]),Ge=We?We.join(`,`):``;t.useEffect(()=>{te&&re(u??[])},[u,te]);let rt=t.useMemo(()=>(0,n.isMultiValueRelationship)(K?.fields,z),[K,z]),Q=O?.picker?.object,[$,it]=t.useState(null);t.useEffect(()=>{if(!_e||!Q||$||!h?.getObjectSchema)return;let e=!1;return h.getObjectSchema(Q).then(t=>{e||it(t)}).catch(e=>{console.warn(`[RelatedList] Failed to fetch schema for ${Q}:`,e)}),()=>{e=!0}},[_e,Q,$,h]);let at=O?.picker?.labelField||`name`,ot=t.useMemo(()=>{let e=(0,i.deriveLookupColumns)($,{displayField:at});return e.length>0?e:void 0},[$,at]);t.useEffect(()=>{O&&!Q&&console.warn(`[RelatedList] "${c||g||`related list`}" declares add without add.picker.object — the Add affordance is not rendered. add.picker is required by the spec (RecordRelatedListProps.add): set add.picker.object to the object the picker should list.`)},[O,Q,c,g]),t.useEffect(()=>{let e=!1;if(Be){H(!1);return}if(c&&!te){if(!(z&&B!=null&&B!==``)){c&&(B==null||B===``)&&!z&&console.warn(`[RelatedList] "${c}" has no referenceField/parentId — refusing to fetch all rows. Pass relationshipField + parentId to scope the query.`),re([]),G(null),pe(!1),H(!1);return}if(H(!0),!me)return;let t=(0,n.composeParentScopeFilter)(z,B,K?.fields),r=Ve===void 0?t:(0,n.mergeFilterNodes)(t,Ve);if(h&&typeof h.find==`function`){let t={$filter:r};if(He.length>0&&(t.$expand=He),We&&(t.$select=We),X){t.$top=Y,t.$skip=je*Y;let e=Me?[{field:Me,order:Ne}]:Fe;e.length>0&&(t.$orderby=e)}h.find(c,t).then(t=>{if(e)return;let n=Array.isArray(t),r=n?t:Array.isArray(t?.data)?t.data:[];if(re(r),X){let e=!n&&typeof t?.total==`number`?t.total:null;G(e),pe(!n&&typeof t?.hasMore==`boolean`?t.hasMore:r.length===Y)}else G(null),pe(!1);H(!1)}).catch(t=>{console.error(`Failed to fetch related data:`,t),e||H(!1)})}else if(Ve!==void 0)console.warn(`[RelatedList] "${c}" declares a filter but has no dataSource adapter — the raw-URL fallback cannot express it, so no rows are fetched. Pass a dataSource (RecordContext) to use a filtered related list.`),re([]),G(null),pe(!1),H(!1);else if(rt)console.warn(`[RelatedList] "${c}" relates through the multi-value field "${z}" but has no dataSource adapter — the raw-URL fallback's \`filter[<field>]=<value>\` grammar has no membership operator, so no rows are fetched. Pass a dataSource (RecordContext) to use a related list on a multi-value relationship field.`),re([]),G(null),pe(!1),H(!1);else{let t=new URLSearchParams({[`filter[${z}]`]:String(B)}).toString();fetch(`${c}?${t}`).then(e=>e.json()).then(t=>{if(e)return;let n=Array.isArray(t)?t:t?.data||[];re(n),G(null),pe(!1)}).catch(e=>{console.error(`Failed to fetch related data:`,e)}).finally(()=>{e||H(!1)})}}return()=>{e=!0}},[c,te,h,z,rt,B,Ce,X,Y,je,Me,Ne,Pe,Re,Ue,Ge,me]),t.useEffect(()=>{X&&!ie&&U>0&&V.length===0&&ae(e=>Math.max(0,e-1))},[X,ie,V,U]),t.useEffect(()=>{ae(0)},[c,z,B,Re]),t.useEffect(()=>{if(!c||te)return;let e=e=>{let t=e.detail||{};t.objectName&&t.objectName!==`*`&&t.objectName!==c||we(e=>e+1)};return window.addEventListener(`objectui:related-changed`,e),()=>window.removeEventListener(`objectui:related-changed`,e)},[c,te]),t.useEffect(()=>{if(!h?.find||!K?.fields||!V.length)return;let e=K.fields,t=[];for(let[r,i]of Object.entries(e)){if(!(0,n.isExpandableFieldType)(i))continue;let e=i.reference;if(!e)continue;let a=new Set;for(let e of V){let t=e?.[r];t!=null&&(typeof t==`string`&&t?a.add(t):typeof t==`number`&&a.add(String(t)))}let o=Te[r]||{},s=Array.from(a).filter(e=>!(e in o));s.length>0&&t.push({fieldName:r,target:e,ids:s})}if(t.length===0)return;let r=!1;return Promise.all(t.map(({fieldName:e,target:t,ids:n})=>Promise.all([h.find(t,{$filter:{id:{$in:n}},$top:n.length}),typeof h.getObjectSchema==`function`?h.getObjectSchema(t).catch(()=>void 0):Promise.resolve(void 0)]).then(([t,n])=>{let r=Array.isArray(t)?t:t?.data||[],i={};for(let e of r){let t=e?.id||e?._id;t&&(i[String(t)]=qe(e,n)??String(t))}return{fieldName:e,map:i}}).catch(t=>(console.warn(`[RelatedList] Failed to resolve lookups for ${e}:`,t),{fieldName:e,map:{}})))).then(e=>{r||Ee(t=>{let n={...t};for(let{fieldName:t,map:r}of e)n[t]={...n[t]||{},...r};return n})}),()=>{r=!0}},[h,K,V]);let[st,ct]=t.useState(null),lt=t.useCallback(e=>{ct(e)},[]),ut=t.useCallback(async()=>{if(st)try{await x?.(st),we(e=>e+1)}catch(e){console.error(`[RelatedList] remove failed`,e)}ct(null)},[st,x]),dt=t.useCallback(async e=>{if(!O||!h||!c||z==null||B==null)return;let t=O.picker.valueField||`id`;be(!0),Se(null);try{for(let n of e||[]){let e=n?.[t]??n?.id;e!=null&&(O.linkField?await h.create?.(c,{[z]:B,[O.linkField]:e}):await h.update?.(O.picker.object,String(e),{[z]:B}))}we(e=>e+1)}catch(e){let t=e?.body?.error??e?.error??e?.message??String(e);Se(typeof t==`string`?t:`Failed to add`)}finally{be(!1),ve(!1)}},[O,h,c,z,B]),ft=t.useMemo(()=>{let e=g||c||``,r=t=>$e(t,Oe,e),o=e=>et(e,z),s=e=>Z.size>0&&!!e&&Z.has(String(e)),l=e=>tt(e,Z),u=e=>(0,n.isEmptyValue)(e)||typeof e==`string`&&e.trim()===``,d=e=>V.length?e.filter(e=>{let t=e?.accessorKey||(0,n.columnIdentity)(e);return!t||V.some(e=>!u(e?.[t]))}):e,f=(e,r)=>{if(!r?.type)return;let o=(0,i.resolveCellRendererType)({type:r.type,format:r.format})||r.type,s=(0,i.getCellRenderer)(o);if(!s)return;let c=r.type===`lookup`||r.type===`master_detail`,l=(0,n.isExpandableFieldType)(r)?Te[e]:void 0,d=c&&l&&Object.keys(l).length>0?Object.entries(l).map(([e,t])=>({value:e,label:t})):void 0,f=e=>{if(r.type!==`user`||!l||typeof e!=`string`&&typeof e!=`number`)return e;let t=l[String(e)];return t?{name:t}:e},p={name:e,label:r.label||e,type:r.type,...(d||r.options)&&{options:d||r.options},...r.currency&&{currency:r.currency},...r.precision!==void 0&&{precision:r.precision},...r.scale!==void 0&&{scale:r.scale},...r.useGrouping!==void 0&&{useGrouping:r.useGrouping},...r.max!==void 0&&{max:r.max},...r.format&&{format:r.format},...r.reference&&{reference:r.reference},...r.reference_field&&{reference_field:r.reference_field}};return e=>u(e)?t.createElement(a.EmptyValue):t.createElement(s,{value:f(e),field:p})},m=t=>{if(typeof t!=`string`){let e=t?.accessorKey||(0,n.columnIdentity)(t);if(!t||!e)return t;let r={};if(t.accessorKey||(r.accessorKey=e),!t.header){let e=(0,n.columnHeader)(t);e&&(r.header=e)}if(!t.cell&&!t.render){let t=K?.fields?.[e],n=t?f(String(e),t):void 0;n&&(r.cell=n)}return Object.keys(r).length>0?{...t,...r}:t}let r=K?.fields?.[t],i={accessorKey:t,header:r?.label||De(e,t,r)||t,fieldDef:r,fieldType:r?.type},a=r?f(t,r):void 0;return a&&(i.cell=a),i};if(p&&p.length>0){let e=l(p.map(m));if(e.length>0)return d(r(o(e)))}if(!K?.fields)return[];let h=Array.isArray(K.highlightFields)?K.highlightFields.filter(e=>typeof e==`string`&&e.length>0):[];if(h.length>0){let e=d(r(o(l(h.map(m)))));if(e.length>0)return e.slice(0,Math.max(1,A))}let _=e,v=new Set([`richtext`,`markdown`,`html`,`json`]),y=[`name`,`full_name`,`fullname`,`title`,`subject`,`label`,`code`,`number`],b=Object.entries(K.fields).filter(([e,t])=>!(e.startsWith(`_`)||e===`id`||e===z||t?.hidden||t?.type&&v.has(t.type)||s(e)||Oe?.isLoaded&&_&&!Oe.checkField(_,e,`read`))),x=new Set([`created_at`,`updated_at`,`created_by`,`updated_by`,`owner_id`,`organization_id`]);return b.sort(([e,t],[n,r])=>{let i=x.has(e);if(i!==x.has(n))return i?1:-1;let a=y.indexOf(e),o=y.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}),d(b.map(([e,t])=>{let n={accessorKey:e,header:De(_,e,t.label||e)};if(t.type){let r=f(e,t);r&&(n.cell=r)}return n})).slice(0,Math.max(1,A))},[p,K,g,c,De,z,V,A,Te,Oe,Z]),pt=(0,n.readObjectSortability)(K),mt=t.useCallback((e,t)=>(0,n.isExpandableFieldType)(t)?!0:pt?!(0,n.isPlatformSortableField)(pt,e):(0,n.isUnmaterializedFieldType)(t),[pt]),ht=t.useMemo(()=>X?ft.map(e=>{let t=e.accessorKey||(0,n.columnIdentity)(e),r=t?K?.fields?.[t]:void 0;return mt(t,r)?{...e,sortable:!1}:e}):ft,[ft,X,K,mt]),gt=!!c&&typeof h?.getObjectSchema==`function`&&!K?.fields,_t=t.useMemo(()=>{let e=ht.map(e=>{if(!e||typeof e!=`object`)return e;let t=e.accessorKey||(0,n.columnIdentity)(e),r=t?K?.fields?.[t]:void 0,i=gt||L(e.type,r?.type);return gt&&typeof e.cell!=`function`?{...e,masked:!0,cell:Xe}:i&&e.masked!==!0?{...e,masked:!0}:e});return e.every((e,t)=>e===ht[t])?ht:e},[ht,K,gt]),vt=t.useMemo(()=>JSON.stringify(_t.flatMap(e=>{if(!e||typeof e!=`object`||e.masked===!0)return[];let t=Ze(e);return t?[t]:[]})),[_t]),yt=Qe(vt),bt=t.useMemo(()=>{if(X||!le)return V;let e=le.toLowerCase(),t=Qe(vt);return V.filter(n=>t.some(t=>{let r=n?.[t];return r!=null&&String(r).toLowerCase().includes(e)}))},[V,le,X,vt]),xt=t.useMemo(()=>{if(X||!W||!Qe(vt).includes(W))return bt;let e=Te[W],t=bt.map(t=>({row:t,key:(0,n.getSortValue)(t[W],{labels:e})}));return t.sort((e,t)=>{let r=(0,n.compareSortValues)(e.key,t.key);return se===`asc`?r:-r}),t.map(e=>e.row)},[bt,W,se,X,Te,vt]),St=Y&&!X?xt.slice(U*Y,(U+1)*Y):xt,Ct=Y?X?de==null?U+(fe?2:1):Math.max(1,Math.ceil(de/Y)):Math.max(1,Math.ceil(xt.length/Y)):1,wt=X?de==null?fe:(U+1)*Y<de:U<Ct-1,Tt=Y>0&&(X?U>0||wt:xt.length>Y);t.useEffect(()=>{ae(0)},[le,W,se]);let Et=t.useCallback(e=>{Qe(vt).includes(e)&&(ae(0),W===e?ce(e=>e===`asc`?`desc`:`asc`):(oe(e),ce(`asc`)))},[W,vt]),Dt=t.useMemo(()=>W?[{field:W,order:se}]:Fe,[W,se,Fe]),Ot=t.useCallback(e=>{let t=e[0];t&&Qe(vt).includes(t.field)&&(ae(0),oe(t.field),ce(t.order))},[vt]),kt=!f&&(s===`grid`||s===`table`),At=Array.isArray(C)&&C.length>0,jt=!!b||!!x||At,Mt=(0,a.useIsMobile)(),Nt=t.useMemo(()=>{if(f)return f;if(Mt&&(s===`grid`||s===`table`)){let e=ft[0]?.accessorKey||(0,n.columnIdentity)(ft[0]),t=ft.slice(1,4).map(e=>e.accessorKey||(0,n.columnIdentity)(e)).filter(Boolean);return{type:`object-gallery`,data:St,objectName:c,gallery:{titleField:e||`name`,visibleFields:t,coverField:Ye,cardSize:`medium`},onRowClick:S}}let e=(0,n.userActionPredicates)(K?.userActions?.edit),t=(0,n.userActionPredicates)(K?.userActions?.delete);switch(s){case`grid`:case`table`:return{type:`data-table`,data:St,columns:_t,pagination:!1,pageSize:Y||10,searchable:!1,exportable:!1,manualSorting:!0,sort:Dt,onSortChange:Ot,rowActions:jt,onRowEdit:b,onRowDelete:x?lt:void 0,rowEditPredicates:e,rowDeletePredicates:t,onRowClick:S,rowActionDefs:At?C:void 0,onRowActionDef:At?w:void 0};case`list`:return{type:`data-list`,data:St};default:return{type:`div`,children:`No view configured`}}},[s,St,_t,ft,f,Y,jt,At,C,w,b,x,lt,S,Mt,c,K,Dt,Ot]),Pt=I?`cursor-pointer select-none`:void 0,Ft=I?()=>ge(e=>!e):void 0,It=Ke(ee),Lt=X&&de!=null?de:V.length,Rt=!ie&&V.length===0&&(!X||U===0),zt=F;return Be?(0,l.jsxs)(a.Card,{className:(0,a.cn)(`shadow-none border-border/60 bg-transparent`,m),children:[(0,l.jsx)(a.CardHeader,{className:`py-3 px-4 sm:py-3 min-h-12 sm:min-h-0`,children:(0,l.jsxs)(a.CardTitle,{className:`flex items-center gap-2 text-sm font-semibold`,children:[(0,l.jsx)(It,{className:`h-4 w-4 text-muted-foreground shrink-0`,"aria-hidden":!0}),(0,l.jsx)(`span`,{className:`truncate`,children:e})]})}),(0,l.jsx)(a.CardContent,{className:`pt-0 pb-4 px-4`,children:(0,l.jsxs)(`div`,{role:`alert`,className:`rounded-md border border-amber-300 bg-amber-50 p-3 text-sm text-amber-800`,"data-testid":`related-list-malformed-filter`,children:[(0,l.jsx)(`p`,{className:`font-medium`,"data-testid":`related-list-malformed-filter-subject`,children:q(`view.malformedFilter`,{subject:(0,n.filterRefusalSubject)(Be)??``})}),(0,l.jsx)(`p`,{className:`mt-1 text-xs opacity-80`,children:Be.message})]})})]}):(0,l.jsxs)(a.Card,{className:(0,a.cn)(`shadow-none border-border/60 bg-transparent`,Rt&&`bg-muted/10`,m),children:[(0,l.jsx)(a.CardHeader,{className:(0,a.cn)(`py-3 px-4 sm:py-3 min-h-12 sm:min-h-0`,Pt),onClick:Ft,children:(0,l.jsxs)(a.CardTitle,{className:`flex items-center justify-between gap-2 text-sm font-semibold`,children:[(0,l.jsxs)(`div`,{className:`flex items-center gap-2 min-w-0`,children:[I&&(he?(0,l.jsx)(o.ChevronRight,{className:`h-3.5 w-3.5 text-muted-foreground shrink-0`}):(0,l.jsx)(o.ChevronDown,{className:`h-3.5 w-3.5 text-muted-foreground shrink-0`})),(0,l.jsx)(It,{className:`h-4 w-4 text-muted-foreground shrink-0`,"aria-hidden":!0}),(0,l.jsx)(`span`,{className:(0,a.cn)(`truncate`,Rt&&`text-muted-foreground font-medium`),children:e}),(0,l.jsx)(a.Badge,{variant:`secondary`,className:(0,a.cn)(`text-xs font-normal h-5 px-1.5`,Lt===0&&`bg-muted text-muted-foreground`),"aria-label":`${Lt} records`,children:Lt}),Rt&&(0,l.jsx)(`span`,{className:`text-xs text-muted-foreground/70 italic ml-1 truncate`,children:q(`detail.noRelatedRecords`)})]}),(0,l.jsxs)(`div`,{className:`flex items-center gap-1 shrink-0`,children:[E&&ke.map(e=>(0,l.jsx)(nt,{action:e,onToolbarAction:E},e.name)),O&&Q&&h&&(0,l.jsxs)(a.Button,{variant:Rt?`ghost`:`outline`,size:`sm`,disabled:ye,onClick:e=>{e.stopPropagation(),Se(null),ve(!0)},className:`gap-1 h-9 sm:h-7 text-xs shadow-none`,children:[(0,l.jsx)(o.Plus,{className:`h-3.5 w-3.5`}),O.label||q(`detail.add`,{defaultValue:`Add`})]}),_&&(0,l.jsxs)(a.Button,{variant:Rt?`ghost`:`outline`,size:`sm`,disabled:v,"data-testid":`related-list-new`,onClick:e=>{e.stopPropagation(),_()},className:`gap-1 h-9 sm:h-7 text-xs shadow-none`,children:[(0,l.jsx)(o.Plus,{className:`h-3.5 w-3.5`}),q(`detail.new`)]})]})]})}),!he&&!Rt&&(0,l.jsxs)(a.CardContent,{className:(0,a.cn)(`pt-0 pb-4 px-4`),children:[zt&&(0,l.jsx)(`div`,{className:`mb-3`,children:(0,l.jsx)(a.Input,{placeholder:q(`detail.filterPlaceholder`),value:le,onChange:e=>ue(e.target.value),className:`h-8 text-sm`})}),N&&!kt&&ft&&ft.length>0&&V.length>0&&(0,l.jsx)(`div`,{className:`flex flex-wrap gap-1 mb-3`,children:ft.map(e=>{let t=e.accessorKey||(0,n.columnIdentity)(e);if(!t)return null;let r=K?.fields?.[t];if(X&&mt(t,r)||!yt.includes(t))return null;let i=e.header||e.label||t,s=W===t;return(0,l.jsxs)(a.Button,{variant:s?`secondary`:`ghost`,size:`sm`,className:`gap-1 h-7 text-xs`,onClick:()=>Et(t),children:[(0,l.jsx)(o.ArrowUpDown,{className:`h-3 w-3`}),i,s&&(se===`asc`?` ↑`:` ↓`)]},t)})}),ie&&V.length===0?(0,l.jsx)(`div`,{className:`flex items-center justify-center py-6 text-muted-foreground text-sm`,children:q(`detail.loading`)}):(0,l.jsx)(`div`,{className:(0,a.cn)(ie&&`opacity-60 pointer-events-none transition-opacity`),children:(0,l.jsx)(r.SchemaRenderer,{schema:Nt})}),Tt&&(0,l.jsxs)(`div`,{className:`flex items-center justify-between mt-3 pt-3 border-t`,children:[(0,l.jsxs)(a.Button,{variant:`outline`,size:`sm`,className:`h-7 text-xs gap-1`,disabled:U===0,onClick:()=>ae(e=>Math.max(0,e-1)),children:[(0,l.jsx)(o.ChevronLeft,{className:`h-3 w-3`}),q(`detail.previousPage`)]}),(0,l.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:q(`detail.pageOf`,{current:U+1,total:Ct})}),(0,l.jsxs)(a.Button,{variant:`outline`,size:`sm`,className:`h-7 text-xs gap-1`,disabled:!wt,onClick:()=>ae(e=>wt?e+1:e),children:[q(`detail.nextPage`),(0,l.jsx)(o.ChevronRight,{className:`h-3 w-3`})]})]}),y&&!Rt&&Tt&&(0,l.jsx)(`div`,{className:`mt-3 pt-3 border-t flex justify-center`,children:(0,l.jsxs)(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),y()},className:`text-xs text-muted-foreground hover:text-foreground inline-flex items-center gap-1 transition-colors`,children:[q(`detail.viewAll`),(0,l.jsx)(o.ExternalLink,{className:`h-3 w-3`})]})})]}),(0,l.jsx)(a.AlertDialog,{open:st!==null,onOpenChange:e=>{e||ct(null)},children:(0,l.jsxs)(a.AlertDialogContent,{children:[(0,l.jsxs)(a.AlertDialogHeader,{children:[(0,l.jsx)(a.AlertDialogTitle,{children:q(`detail.deleteRowTitle`,{defaultValue:`Delete record`})}),(0,l.jsx)(a.AlertDialogDescription,{children:q(`detail.deleteRowConfirmation`)})]}),(0,l.jsxs)(a.AlertDialogFooter,{children:[(0,l.jsx)(a.AlertDialogCancel,{children:q(`detail.cancel`,{defaultValue:`Cancel`})}),(0,l.jsx)(a.AlertDialogAction,{onClick:ut,className:`bg-destructive text-destructive-foreground hover:bg-destructive/90`,children:q(`detail.delete`,{defaultValue:`Delete`})})]})]})}),xe&&(0,l.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:xe}),O&&Q&&h&&(0,l.jsx)(i.RecordPickerDialog,{open:_e,onOpenChange:e=>ve(e),multiple:!0,dataSource:h,objectName:Q,title:O.label||q(`detail.add`,{defaultValue:`Add`}),displayField:at,columns:ot,cellRenderer:i.getCellRenderer,fieldsMeta:$?.fields,baseFilter:O.picker.filter,onSelect:()=>{},onSelectRecords:e=>{dt(e)}})]})};function Q(e){return e==null?[]:Array.isArray(e)?e.filter(e=>e!=null):[e]}function $(e,t={}){let n={};for(let e of Object.keys(t))t[e]!==void 0&&(n[e]=t[e]);return Object.keys(n).length>0?{type:e,properties:n}:{type:e}}function it(e,t){if(!e||!t)return null;let n=e.fields?.[t]?.options;return!Array.isArray(n)||n.length===0?null:n.map(e=>({value:e.value,label:e.label}))}function at(e){return(0,n.resolveNameField)(e)??null}function ot(e,t,r=4){if(!e)return[];let i=Array.isArray(e.highlightFields)&&e.highlightFields.length>0?e.highlightFields:null;if(i){let t=at(e);return i.filter(e=>typeof e==`string`&&e.length>0&&e!==t).slice(0,r)}let a=new Set([`id`,`_id`,`created_at`,`updated_at`,`deleted_at`,`created_by`,`updated_by`,`deleted_by`,`organization_id`,`workspace_id`,`tenant_id`,`org_id`]);t&&a.add(t);for(let t of[`name`,`full_name`,`title`,`subject`,`display_name`])t in(e.fields||{})&&a.add(t);let o=[`owner`,`owner_id`,`amount`,`rating`,`source`,`priority`,`industry`,`phone`,`email`,`close_date`,`due_date`,`start_date`,`expected_close_date`,`account`,`account_id`,`contact`,`contact_id`],s=new Set([`currency`,`number`,`integer`,`decimal`,`percent`,`date`,`datetime`,`time`,`reference`,`lookup`,`user`,`select`,`enum`,`multiselect`,`status`,`email`,`phone`,`url`,`text`,`string`]),c=[],l=e.fields||{},u=e=>{let t=l[e]?.type;return typeof t!=`string`||!(0,n.isRetiredFieldType)(t)?!1:((0,n.reportRetiredFieldType)(t),!0)},d=at(e);d&&(u(d),a.add(d));for(let e of o)if(e in l&&!a.has(e)&&!u(e)&&c.push(e),c.length>=r)return c;for(let e of Object.keys(l)){if(c.includes(e)||a.has(e)||u(e))continue;let t=l[e]?.type;if((!t||s.has(t))&&(c.push(e),c.length>=r))break}return c}function st(e,t={}){return $(`page:header`,{recordChrome:t.recordChrome!==!1,...Array.isArray(t.actions)&&t.actions.length>0?{actions:t.actions}:{}})}function ct(e,t){return!Array.isArray(t)||t.length===0?null:$(`record:quick_actions`,{actions:t,location:`record_header`})}function lt(e,t={}){let n=t.statusField??(0,u.detectStatusField)(e),r=t.stages??(n?it(e,n):null),i=t.highlightFields??ot(e,n),a=[];return!t.hideHighlights&&i.length>0&&a.push($(`record:highlights`,{fields:i})),!t.hidePath&&n&&r&&r.length>0&&a.push($(`record:path`,{statusField:n,stages:r})),a}function ut(e){if(!e)return null;let t=(0,f.deriveFieldGroupLayout)(e);if(!t)return null;let n=e.fields||{},r=e=>{let t=n[e]||{};return{name:e,label:t.label||e,type:t.type||`text`,...t.options?{options:t.options}:{},...t.reference?{reference:t.reference}:{},...t.reference_field?{reference_field:t.reference_field}:{},...t.currency?{currency:t.currency}:{},...t.currencyConfig?{currencyConfig:t.currencyConfig}:{}}},i=S(t.reduce((e,t)=>e+t.fields.length,0));return t.map(e=>({...e.key===void 0?{}:{name:e.key,label:e.label??e.key},...e.icon?{icon:e.icon}:{},...e.description?{description:e.description}:{},...e.collapse===`none`?{}:{collapsible:!0},...e.collapse===`collapsed`?{defaultCollapsed:!0}:{},columns:i,fields:e.fields.map(r)}))}function dt(e,t){return Array.isArray(t)&&t.length>0?t:ut(e)??void 0}function ft(e,t,n){return $(`record:details`,{sections:dt(e,t),...n&&n.length>0?{hideFields:n}:{}})}function pt(e,t={}){let n=t.statusField??(0,u.detectStatusField)(e),r=t.highlightFields??ot(e,n),i=[{label:`Details`,value:`details`,children:[ft(e,t.sections,r)]}];if(!t.hideRelatedTab&&Array.isArray(t.related)&&t.related.length>0){let e=e=>$(`record:related_list`,{title:e.title,objectName:e.objectName,relationshipField:e.relationshipField,...e.columns?{columns:e.columns}:{},...e.limit?{limit:e.limit}:{},...e.icon?{icon:e.icon}:{},...e.sort?{sort:e.sort}:{},...e.filter?{filter:e.filter}:{}}),n=t=>({label:t.title||t.objectName,value:`related:${t.objectName}`,...t.icon?{icon:t.icon}:{},children:[e(t)]});if(t.relatedLayout===`tabs`)for(let e of t.related)i.push(n(e));else if(t.relatedLayout===`stack`)i.push({label:`Related`,value:`related`,children:t.related.map(e)});else{let r=t.related.filter(e=>e.isPrimary),a=t.related.filter(e=>!e.isPrimary);for(let e of r)i.push(n(e));a.length>0&&i.push({label:`Related`,value:`related`,children:a.map(e)})}}return t.approvals&&i.push({label:`Approvals`,value:`approvals`,...t.approvals.count==null?{}:{count:t.approvals.count},children:[$(`record:approvals`,{...t.approvals.node||{}})]}),e?.enable?.files===!0&&!t.hideAttachments&&i.push({label:`Attachments`,value:`attachments`,children:[ht()]}),t.showActivity&&i.push({label:`Activity`,value:`activity`,children:[$(`record:activity`)]}),t.history&&i.push({label:`History`,value:`history`,children:[$(`record:history`,{entries:t.history.entries,loading:t.history.loading,emptyText:t.history.emptyText,unknownUserText:t.history.unknownUserText})]}),$(`page:tabs`,{items:i})}function mt(){return $(`record:discussion`)}function ht(){return $(`record:attachments`)}function gt(e,t={}){let n=t.slots||{},r=[];`header`in n&&n.header!==void 0?r.push(...Q(n.header)):r.push(st(e,{recordChrome:t.recordChrome,actions:t.headerActions})),`actions`in n&&n.actions!==void 0&&r.push(...Q(n.actions)),`alerts`in n&&n.alerts!==void 0&&r.push(...Q(n.alerts)),`highlights`in n&&n.highlights!==void 0?r.push(...Q(n.highlights)):r.push(...lt(e,{highlightFields:t.highlightFields,statusField:t.statusField,stages:t.stages,hideHighlights:t.hideHighlights,hidePath:t.hidePath}));let i=t.showReferenceRail===!0&&!t.hideReferenceRail&&Array.isArray(t.related)&&t.related.length>=2,a=t.hideRelatedTab??i;if(`tabs`in n&&n.tabs!==void 0)r.push(...Q(n.tabs));else if(`details`in n&&n.details!==void 0){let i=Q(n.details),o=pt(e,{sections:t.sections,related:t.related,showActivity:t.showActivity,history:t.history,approvals:t.approvals,highlightFields:t.highlightFields,statusField:t.statusField,hideRelatedTab:a,relatedLayout:t.relatedLayout,hideAttachments:t.hideAttachments}),s=o.properties?.items;Array.isArray(s)&&s.length>0&&(s[0]={...s[0],children:i}),r.push(o)}else r.push(pt(e,{sections:t.sections,related:t.related,showActivity:t.showActivity,history:t.history,approvals:t.approvals,highlightFields:t.highlightFields,statusField:t.statusField,hideRelatedTab:a,relatedLayout:t.relatedLayout,hideAttachments:t.hideAttachments}));`discussion`in n&&n.discussion!==void 0?r.push(...Q(n.discussion)):t.hideDiscussion||r.push(mt());let o=[{name:`main`,width:`full`,components:r}],s=Q(n.rightRail);if(i||s.length>0){let e=[];i&&e.push($(`record:reference_rail`,{entries:t.related.map(e=>({objectName:e.objectName,relationshipField:e.relationshipField,title:e.title,displayField:e.displayField,limit:3}))})),s.length>0&&e.push(...s),o.push({name:`aside`,width:`small`,className:`hidden xl:flex flex-col gap-4`,components:e})}return{type:`record`,pageType:`record`,object:e?.name,template:`full-width`,regions:o}}function _t(e,t){return!e||t?.label===void 0?null:`[ObjectUI] ${e} accessible name: \`aria.label\` is not read. The spec's AriaPropsSchema refuses that spelling (it is the alias of \`aria.ariaLabel\`), so this block announces its \`aria.ariaLabel\` when one is declared and its default name otherwise. Declare the name as \`aria.ariaLabel\`.`}function vt(e,n){let r=_t(e,n);(0,t.useEffect)(()=>{r&&console.warn(r)},[r])}function yt(e,{defaultRole:t,defaultLabel:n,block:i}={}){let a=(0,s.useDisplayLocale)();vt(i,e);let o=(0,r.resolveInlineAriaProps)(e,a),c=o[`aria-label`]||n,l=o[`aria-describedby`],u=o.role||t||(c||l?`region`:void 0);return{...c?{"aria-label":c}:{},...l?{"aria-describedby":l}:{},...u?{role:u}:{}}}var bt=e=>(0,n.columnIdentity)(e)??null;function xt(e){return e===void 0?void 0:Number(e)}var St=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}},Ct=new Set;function wt(e,t){let n=`${e}.${t}`;Ct.has(n)||(Ct.add(n),console.error(`[record:details] section group "${t}" is not declared in fieldGroups on object "${e}" — the section renders nothing. Declare the group on the object, or enumerate \`fields\` on the section. (\`@objectstack/lint\` reports this as \`page-section-group-unknown\`.)`))}var Tt=({schema:e={},className:t,...i})=>{let a=(0,r.useRecordContext)(),{designer:o}=St(i),c=yt(e.aria),u=a?.objectName||``,f=(0,d.usePermissions)(),{readableFields:p}=(0,d.useFieldPermissions)(u),{sectionLabel:m}=(0,r.useSafeFieldLabel)(),{language:h}=(0,s.useObjectTranslation)(),g=(0,r.useHighlightFieldNames)();if(!a)return(0,l.jsx)(`div`,{className:t,"data-record-details-placeholder":!0,...o,children:(0,l.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 _=Array.isArray(e.requiredPermissions)?e.requiredPermissions:[];if(_.length>0&&!f.hasCapabilities(_))return(0,l.jsx)(`div`,{className:t,...o,role:`status`,"aria-live":`polite`,children:(0,l.jsx)(`p`,{className:`text-sm text-muted-foreground italic`,children:`Insufficient permissions to view details.`})});let v=e.enforceFieldSecurity===!0,y=Array.isArray(e.redactFields)?e.redactFields:[],b=e=>{if(!e||!v&&y.length===0)return e;let t=e.map(bt).filter(e=>!!e),n=new Set((v&&u?p(t):t).filter(e=>!y.includes(e)));return e.filter(e=>{let t=bt(e);return t?n.has(t):!1})},x=a.objectSchema,S=x?.fields,C=e=>{if(!e||typeof e!=`object`||typeof e.name!=`string`||e.label!==void 0)return e;let t=S?.[e.name]?.label;if(t==null)return e;let n=(0,s.pickLocalized)(t,h);return n?{...e,label:n}:e},w=e=>typeof e==`string`?C({name:e}):e&&typeof e==`object`&&!e.name&&e.field?C({...e,name:e.field}):C(e),T=e=>Array.isArray(e)?e.map(w):e,E=new Set((Array.isArray(e.hideFields)?e.hideFields:[]).map(e=>typeof e==`string`?e:bt(e)).filter(e=>!!e));for(let e of g)E.add(e);let D=(0,n.withoutDeniedFields)(a.data??{},f,u),O=[(0,n.resolveNameField)(x),(0,n.deriveTitleField)(x),`name`,`full_name`,`title`,`subject`,`display_name`,`label`].filter(e=>typeof e==`string`&&e.length>0),k=(0,n.declaredNameField)(x);if((0,n.recordDisplayValueAt)(D,k)!==void 0)E.add(k);else{let e=x?.titleFormat,t=(0,n.formatTitleTemplate)(e,D);if(t){let r=e=>(0,n.recordDisplayValueAt)(D,e)===t,i=O.find(r)??Object.keys(D).find(i=>r(i)&&(0,n.formatTitleTemplate)(e,{...D,[i]:void 0})!==t);i&&E.add(i)}else for(let e of O)if((0,n.recordDisplayValueAt)(D,e)!==void 0){E.add(e);break}}let A=e=>!e||E.size===0?e:e.filter(e=>{let t=bt(e);return!t||!E.has(t)}),j=A(T(b(e.fields))),M=Array.isArray(e.sections)?e.sections:[],N=new Map;if(M.some(e=>e&&typeof e==`object`&&typeof e.group==`string`))for(let e of ut(x)??[])typeof e.name==`string`&&N.set(e.name,e);let P=Array.isArray(e.sections)?e.sections.map(e=>{if(!e||typeof e!=`object`||typeof e.group!=`string`)return e;let t=N.get(e.group);if(!t)return wt(u,e.group),null;let{group:n,...r}=e;return{...t,...r}}).filter(e=>e!=null).map(e=>{let t=e.label,n=t==null?void 0:(0,s.pickLocalized)(t,h),r=e.name&&u?m(u,e.name,n??e.name):n;return{...e,title:r,showBorder:e.showBorder??!!r,hideEmpty:e.hideEmpty??!0,fields:A(T(b(e.fields)))}}):e.sections,F=(0,n.isObjectInlineEditable)(x,f?.getObjectApiOperations?.(u)),I=(e.inlineEdit??!0)&&F,L={type:`detail-view`,objectName:a.objectName,resourceId:a.recordId,data:a.data,layout:`vertical`,columns:xt(e.columns),sections:P,fields:j,showBack:!1,showHeader:e.showHeader??!1,inlineEdit:I};return(0,l.jsx)(`div`,{className:t,...o,...c,children:(0,l.jsx)(Z,{schema:L,dataSource:a.dataSource,inlineEdit:I})})},Et=e=>({toolbar:[],row:[],refused:e});function Dt(e){if(!Array.isArray(e))return!1;let t=(0,u.resolveDeclaredActionIds)(e,void 0);return t.kind===`ids`&&t.ids.length>0}function Ot(e,t){if(!Array.isArray(e))return Et([{kind:`array`,message:"`actions` is not an array; it is a list of action ids"}]);let n=(0,u.resolveDeclaredActionIds)(e,t);if(n.kind===`refused`)return Et([{kind:`array`,message:`${n.message} (on this block: action ids only)`}]);if(n.kind===`objects`)return e.length===0?Et([]):Et([{kind:`array`,message:"`actions` holds inline action objects; it is a list of action ids, each the `name` of an action declared on the related object's own `actions`"}]);let r=[],i=[],a=n.unresolved.map(({id:e})=>({kind:`unresolved`,id:e})),o=new Set;for(let e of n.actions){if(o.has(e.name))continue;o.add(e.name);let t={locations:Array.isArray(e.locations)?e.locations:void 0},n=(0,u.actionRendersAt)(t,`list_toolbar`),s=(0,u.actionRendersAt)(t,`list_item`)||(0,u.actionRendersAt)(t,`record_related`);n&&r.push(e),s&&i.push(e),!n&&!s&&a.push({kind:`unplaced`,id:String(e.name)})}return{toolbar:r,row:i,refused:a}}function kt(e,t,n){return`record:related_list — actions refused: ${e.map(e=>e.kind===`array`?e.message:e.kind===`unplaced`?`"${e.id}" declares none of list_toolbar (header), list_item (row menu) or record_related (row menu inside a record) in its locations, so this list has nowhere to draw it`:n?`"${e.id}" is not an action of "${t}"`:`"${e.id}" could not be resolved: no metadata for "${t}" was found`).join(`; `)}.`}var At=e=>(0,n.columnIdentity)(e)||(e&&typeof e==`object`?e.key:null)||null;function jt(e,t){let n=null;for(let r=0;r<e.length;r++){let i=e[r],a=i&&typeof i==`object`?i.label:void 0;typeof a==`object`&&a&&(n??=[...e],n[r]={...i,label:(0,s.pickLocalized)(a,t)})}return n??e}var Mt=e=>e?.id??e?._id??null,Nt=5,Pt=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}},Ft=({schema:e={},className:n,...a})=>{let o=(0,r.useRecordContext)(),{designer:c}=Pt(a),u=yt(e.aria),f=(0,r.useSafeFieldLabel)(),{language:p}=(0,s.useObjectTranslation)(),m=e.objectName,h=m&&f.objectLabel?f.objectLabel({name:m,label:(0,i.humanizeLabel)(m)}):m?(0,i.humanizeLabel)(m):``,g=(0,s.pickLocalized)(e.title,p)||h||`Related`,_=(0,d.usePermissions)(),{readableFields:v}=(0,d.useFieldPermissions)(m||``),y=e.relationshipValueField||`id`,b=y===`id`?o?.recordId??null:o?.data?.[y]??null,x=(0,r.useRelatedRecordActions)(),S=t.default.useMemo(()=>m?x?.resolve({objectName:m,relationshipField:e.relationshipField,parentId:b})??null:null,[x,m,e.relationshipField,b]),C=e.actions,w=C!==void 0,T=!!m&&Dt(C),{item:E,loading:D}=(0,r.useMetadataItem)(`object`,T?m:null),O=(0,r.useActionTextLocalizer)(),k=t.default.useMemo(()=>{if(!w)return null;if(T&&D)return{toolbar:[],row:[],refused:[]};let e=Array.isArray(E?.actions)?E.actions:[],t=Ot(C,e),n=e=>O(m||void 0,e);return{toolbar:t.toolbar.map(n),row:t.row.map(n),refused:t.refused}},[w,C,T,E,D,m,O]);if(!m)return(0,l.jsx)(`div`,{className:n,...c,children:(0,l.jsx)(`div`,{className:`text-xs text-muted-foreground italic px-3 py-2 border border-dashed rounded`,children:`record:related_list — missing objectName`})});if(_.isLoaded&&!_.can(m,`read`))return null;let A=Array.isArray(e.requiredPermissions)?e.requiredPermissions:[];if(A.length>0&&!_.hasCapabilities(A))return(0,l.jsx)(`div`,{className:n,...c,role:`status`,"aria-live":`polite`,children:(0,l.jsx)(`p`,{className:`text-sm text-muted-foreground italic`,children:`Insufficient permissions to view related list.`})});let j=e.enforceFieldSecurity===!0,M=Array.isArray(e.redactFields)?e.redactFields:[],N=Array.isArray(e.columns)?e.columns:[],P=N;if(j||M.length>0){let e=N.map(At).filter(e=>!!e),t=new Set((j?v(e):e).filter(e=>!M.includes(e)));P=N.filter(e=>{let n=At(e);return n?t.has(n):!1})}let F=k?S?.onToolbarAction&&k.toolbar.length>0?k.toolbar:void 0:S?.toolbarActions,I=k?S?.onRowAction&&k.row.length>0?k.row:void 0:S?.rowActions,L=k?.refused??[];return(0,l.jsxs)(`div`,{className:n,...c,...u,children:[L.length>0&&(0,l.jsx)(`div`,{role:`status`,"aria-live":`polite`,"data-testid":`record-related-list-actions-refused`,className:`mb-2 text-xs text-muted-foreground italic px-3 py-2 border border-dashed rounded`,children:kt(L,m,!!E)}),(0,l.jsx)(rt,{title:g,type:`table`,api:m,objectName:m,referenceField:e.relationshipField,parentId:b,columns:jt(P,p),redactFields:M.length>0?M:void 0,pageSize:typeof e.limit==`number`&&e.limit>0?e.limit:Nt,defaultSort:e.sort,filter:e.filter,dataSource:o?.dataSource,add:e.add?{...e.add,label:(0,s.pickLocalized)(e.add.label,p)||void 0}:void 0,rowActions:I,onRowAction:S?.onRowAction,toolbarActions:F,onToolbarAction:S?.onToolbarAction,onNew:S?.onCreate,newDisabled:S?.createDisabled,onRowClick:S?.onView?e=>{let t=Mt(e);t!=null&&S.onView(t,e)}:void 0,onRowEdit:S?.onEdit?e=>{let t=Mt(e);t!=null&&S.onEdit(t,e)}:void 0,onRowDelete:S?.onDelete?e=>{let t=Mt(e);if(t!=null)return S.onDelete(t,e)}:e.add&&o?.dataSource?async e=>{let t=e?.id??e?._id;t!=null&&await o?.dataSource?.delete?.(m,String(t))}:void 0})]})},It={columns:!0,filter:!0,sort:!0,limit:`limit`},Lt={},Rt=(0,n.elementDataSourceBlock)(e=>{let t=(0,r.useRecordContext)();return(0,l.jsx)(r.ElementDataSourceGate,{schema:e.schema??Lt,mapping:It,dataSource:t?.dataSource,testId:`record-related-list`,errorTitle:`This related list’s data source could not be resolved`,children:t=>(0,l.jsx)(Ft,{...e,schema:t})})}),zt=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}},Bt=({schema:e={},className:n,...i})=>{let a=(0,r.useRecordContext)(),{designer:o}=zt(i),s=yt(e.aria),c=a?.objectName||``,u=(0,d.usePermissions)(),{readableFields:f}=(0,d.useFieldPermissions)(c),p=Array.isArray(e.requiredPermissions)?e.requiredPermissions:[],m=p.length===0||u.hasCapabilities(p),h=(Array.isArray(e.fields)?e.fields:[]).map(e=>typeof e==`string`?{name:e}:{name:e?.name,label:e?.label,type:e?.type,readonly:e?.readonly===!0}).filter(e=>typeof e.name==`string`&&e.name.length>0),g=e.enforceFieldSecurity===!0,_=Array.isArray(e.redactFields)?e.redactFields:[],v=g&&c?new Set(f(h.map(e=>e.name))):null,y=h.filter(e=>!(_.includes(e.name)||v&&!v.has(e.name))),b=t.default.useId();return(0,r.useRegisterHighlightFields)(b,m?y.map(e=>e.name):[]),m?(0,l.jsx)(`div`,{className:n,...o,...s,children:(0,l.jsx)(de,{fields:y,data:a?.data,objectName:a?.objectName,objectSchema:a?.objectSchema,dataSource:a?.dataSource})}):(0,l.jsx)(`div`,{className:n,...o,role:`status`,"aria-live":`polite`,children:(0,l.jsx)(`p`,{className:`text-sm text-muted-foreground italic`,children:`Insufficient permissions to view highlights.`})})},Vt=({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,l.jsxs)(`div`,{className:(0,a.cn)(`flex items-center gap-1.5 text-sm flex-wrap`,t),children:[(0,l.jsx)(`span`,{className:`font-medium text-foreground`,children:n}),(0,l.jsx)(`span`,{className:`text-muted-foreground line-through`,children:r}),(0,l.jsx)(o.ArrowRight,{className:`h-3 w-3 text-muted-foreground shrink-0`}),(0,l.jsx)(`span`,{className:`text-foreground`,children:i})]})},Ht=[`👍`,`❤️`,`🎉`,`😂`,`😮`,`😢`],Ut=({reactions:e,onToggleReaction:n,emojiOptions:r=Ht,className:i})=>{let[s,c]=t.useState(!1),{t:u}=D(),d=t.useCallback(e=>{n?.(e),c(!1)},[n]);return(0,l.jsxs)(`div`,{className:(0,a.cn)(`flex items-center gap-1 flex-wrap`,i),children:[e.map(e=>{let t=u(`detail.reactionCount`,{emoji:e.emoji,count:e.count});return(0,l.jsxs)(`button`,{type:`button`,className:(0,a.cn)(`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:()=>d(e.emoji),disabled:!n,"aria-label":t,children:[(0,l.jsx)(`span`,{children:e.emoji}),(0,l.jsx)(`span`,{children:e.count})]},e.emoji)}),n&&(0,l.jsxs)(`div`,{className:`relative`,children:[(0,l.jsx)(a.Button,{variant:`ghost`,size:`icon`,className:`h-6 w-6`,onClick:()=>c(!s),"aria-label":u(`detail.addReaction`),children:(0,l.jsx)(o.SmilePlus,{className:`h-3.5 w-3.5`})}),s&&(0,l.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":u(`detail.emojiPicker`),children:r.map(t=>(0,l.jsx)(`button`,{type:`button`,className:`hover:bg-accent rounded p-1 text-base transition-colors`,onClick:()=>d(t),role:`option`,"aria-selected":e.some(e=>e.emoji===t&&e.reacted),children:t},t))})]})]})};function Wt(e,t,n){try{let r=new Date(e),i=new Date().getTime()-r.getTime(),a=Math.floor(i/6e4);if(a<1)return t(`detail.justNow`);if(a<60)return t(`detail.minutesAgo`,{count:a});let o=Math.floor(a/60);if(o<24)return t(`detail.hoursAgo`,{count:o});let s=Math.floor(o/24);return s<7?t(`detail.daysAgo`,{count:s}):r.toLocaleDateString(n)}catch{return e}}var Gt=({parentItem:e,replies:n,onAddReply:r,showReplyInput:i=!0,className:c})=>{let{t:u}=D(),d=(0,s.useDisplayLocale)(),[f,p]=t.useState(!1),[m,h]=t.useState(``),[g,_]=t.useState(!1),v=t.useCallback(async()=>{let t=m.trim();if(t&&r){_(!0);try{await r(e.id,t),h(``)}catch{}finally{_(!1)}}},[m,r,e.id]),y=t.useCallback(e=>{e.key===`Enter`&&(e.ctrlKey||e.metaKey)&&(e.preventDefault(),v())},[v]);return n.length===0&&!i?null:(0,l.jsxs)(`div`,{className:(0,a.cn)(`ml-10 mt-1`,c),children:[n.length>0&&(0,l.jsxs)(`button`,{type:`button`,className:`flex items-center gap-1 text-xs text-muted-foreground hover:text-foreground transition-colors mb-1`,onClick:()=>p(!f),"aria-expanded":f,children:[f?(0,l.jsx)(o.ChevronDown,{className:`h-3 w-3`}):(0,l.jsx)(o.ChevronRight,{className:`h-3 w-3`}),(0,l.jsx)(o.MessageSquare,{className:`h-3 w-3`}),(0,l.jsx)(`span`,{children:u(`detail.replyCount`,{count:n.length})})]}),f&&(0,l.jsx)(`div`,{className:`space-y-2 border-l-2 border-border pl-3`,children:n.map(e=>(0,l.jsxs)(`div`,{className:`flex gap-2`,children:[(0,l.jsx)(`div`,{className:`shrink-0`,children:e.actorAvatarUrl?(0,l.jsx)(`img`,{src:e.actorAvatarUrl,alt:e.actor,className:`h-6 w-6 rounded-full object-cover`}):(0,l.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,l.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,l.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,l.jsx)(`span`,{className:`text-xs font-medium`,children:e.actor}),(0,l.jsx)(`span`,{className:`text-[10px] text-muted-foreground`,children:Wt(e.createdAt,u,d)})]}),(0,l.jsx)(`p`,{className:`text-xs whitespace-pre-wrap break-words`,children:e.body})]})]},e.id))}),i&&r&&(0,l.jsxs)(`div`,{className:`flex gap-1.5 mt-1.5`,children:[(0,l.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:u(`detail.replyPlaceholder`),value:m,onChange:e=>h(e.target.value),onKeyDown:y,disabled:g}),(0,l.jsx)(a.Button,{variant:`ghost`,size:`icon`,className:`h-6 w-6 shrink-0`,onClick:v,disabled:!m.trim()||g,"aria-label":`Send reply`,children:(0,l.jsx)(o.Send,{className:`h-3 w-3`})})]})]})},Kt=({subscription:e,onToggle:n,className:r})=>{let{t:i}=D(),[s,c]=t.useState(!1),u=t.useCallback(async()=>{if(n){c(!0);try{await n(!e.subscribed)}finally{c(!1)}}},[n,e.subscribed]);return(0,l.jsx)(a.Button,{variant:`ghost`,size:`icon`,className:(0,a.cn)(`h-8 w-8`,r),onClick:u,disabled:s||!n,"aria-label":e.subscribed?i(`detail.unsubscribeAriaLabel`):i(`detail.subscribeAriaLabel`),title:e.subscribed?i(`detail.subscribedTooltip`):i(`detail.unsubscribedTooltip`),children:e.subscribed?(0,l.jsx)(o.Bell,{className:`h-4 w-4 text-primary`}):(0,l.jsx)(o.BellOff,{className:`h-4 w-4 text-muted-foreground`})})};function qt(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 Jt=({value:e,onChange:n,onSubmit:r,mentionSuggestions:i=[],placeholder:s,className:c,disabled:u=!1,extraSlot:d,canSubmitEmpty:f=!1})=>{let{t:p}=D(),[m,h]=t.useState(!1),[g,_]=t.useState(!1),[v,y]=t.useState(``),[b,x]=t.useState(0),S=t.useRef(null),C=t.useMemo(()=>{if(!v)return i;let e=v.toLowerCase();return i.filter(t=>t.label.toLowerCase().includes(e))},[v,i]),w=t.useCallback((t,r=``)=>{let i=S.current;if(!i)return;let a=i.selectionStart,o=i.selectionEnd,s=e.slice(a,o);n(e.slice(0,a)+t+s+r+e.slice(o)),requestAnimationFrame(()=>{i.focus();let e=a+t.length+s.length;i.setSelectionRange(e,e)})},[e,n]),T=t.useCallback(()=>w(`**`,`**`),[w]),E=t.useCallback(()=>w(`*`,`*`),[w]),O=t.useCallback(()=>w(`
|
|
2
|
+
- `,``),[w]),k=t.useCallback(()=>w("`","`"),[w]),A=t.useCallback(()=>{w(`@`,``),_(!0),y(``),x(0)},[w]),j=t.useCallback(t=>{let r=S.current;if(!r)return;let i=r.selectionStart,a=e.slice(0,i).lastIndexOf(`@`);a!==-1&&n(e.slice(0,a)+`@${t.label} `+e.slice(i)),_(!1),y(``),requestAnimationFrame(()=>r.focus())},[e,n]),M=t.useCallback(e=>{let t=e.target.value;n(t);let r=e.target.selectionStart,i=t.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)){_(!0),y(e),x(0);return}}_(!1)},[n]),N=t.useCallback(e=>{if(g&&C.length>0){if(e.key===`ArrowDown`){e.preventDefault(),x(e=>e<C.length-1?e+1:0);return}if(e.key===`ArrowUp`){e.preventDefault(),x(e=>e>0?e-1:C.length-1);return}if(e.key===`Enter`||e.key===`Tab`){e.preventDefault(),j(C[b]);return}if(e.key===`Escape`){_(!1);return}}e.key===`Enter`&&(e.ctrlKey||e.metaKey)&&(e.preventDefault(),r?.())},[g,C,b,j,r]);return(0,l.jsxs)(`div`,{className:(0,a.cn)(`border rounded-md`,c),children:[(0,l.jsxs)(`div`,{className:`flex items-center gap-0.5 px-2 py-1.5 border-b bg-muted/30`,children:[(0,l.jsx)(a.Button,{variant:`ghost`,size:`icon`,className:`h-7 w-7`,onClick:T,disabled:u||m,title:p(`detail.bold`),children:(0,l.jsx)(o.Bold,{className:`h-3.5 w-3.5`})}),(0,l.jsx)(a.Button,{variant:`ghost`,size:`icon`,className:`h-7 w-7`,onClick:E,disabled:u||m,title:p(`detail.italic`),children:(0,l.jsx)(o.Italic,{className:`h-3.5 w-3.5`})}),(0,l.jsx)(a.Button,{variant:`ghost`,size:`icon`,className:`h-7 w-7`,onClick:O,disabled:u||m,title:p(`detail.listFormat`),children:(0,l.jsx)(o.List,{className:`h-3.5 w-3.5`})}),(0,l.jsx)(a.Button,{variant:`ghost`,size:`icon`,className:`h-7 w-7`,onClick:k,disabled:u||m,title:p(`detail.inlineCode`),children:(0,l.jsx)(o.Code,{className:`h-3.5 w-3.5`})}),(0,l.jsx)(a.Button,{variant:`ghost`,size:`icon`,className:`h-7 w-7`,onClick:A,disabled:u||m,title:p(`detail.mentionSomeone`),children:(0,l.jsx)(o.AtSign,{className:`h-3.5 w-3.5`})}),(0,l.jsx)(`div`,{className:`flex-1`}),(0,l.jsx)(a.Button,{variant:`ghost`,size:`icon`,className:`h-7 w-7`,onClick:()=>h(!m),title:p(m?`detail.edit`:`detail.preview`),children:m?(0,l.jsx)(o.Edit,{className:`h-3.5 w-3.5`}):(0,l.jsx)(o.Eye,{className:`h-3.5 w-3.5`})}),r&&(0,l.jsx)(a.Button,{variant:`ghost`,size:`icon`,className:`h-7 w-7`,onClick:r,disabled:u||!f&&!e.trim(),title:p(`detail.submitComment`),children:(0,l.jsx)(o.Send,{className:`h-3.5 w-3.5`})})]}),(0,l.jsx)(`div`,{className:`relative`,children:m?(0,l.jsx)(`div`,{className:`min-h-[80px] px-3 py-2 text-sm prose prose-sm max-w-none`,dangerouslySetInnerHTML:{__html:qt(e)}}):(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(`textarea`,{ref:S,className:`w-full min-h-[80px] px-3 py-2 text-sm bg-transparent resize-none focus:outline-none placeholder:text-muted-foreground`,placeholder:s??p(`detail.writeComment`),value:e,onChange:M,onKeyDown:N,disabled:u}),g&&C.length>0&&(0,l.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:C.map((e,t)=>(0,l.jsxs)(`button`,{type:`button`,className:(0,a.cn)(`w-full text-left px-3 py-1.5 text-sm flex items-center gap-2 hover:bg-accent transition-colors`,t===b&&`bg-accent`),onMouseDown:t=>{t.preventDefault(),j(e)},children:[e.avatarUrl?(0,l.jsx)(`img`,{src:e.avatarUrl,alt:e.label,className:`h-5 w-5 rounded-full object-cover`}):(0,l.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,l.jsx)(`span`,{children:e.label})]},e.id))})]})}),d&&(0,l.jsx)(`div`,{className:`border-t px-2 py-2 bg-muted/20`,children:d})]})};function Yt(e){return e<1024?`${e} B`:e<1048576?`${(e/1024).toFixed(1)} KB`:`${(e/1048576).toFixed(1)} MB`}function Xt(e){return e.startsWith(`image/`)}function Zt(e){return Xt(e)?o.Image:e.includes(`pdf`)||e.includes(`document`)||e.includes(`text`)?o.FileText:e.includes(`zip`)||e.includes(`archive`)||e.includes(`compressed`)?o.FileArchive:o.File}var Qt=({attachments:e,onUpload:n,onRemove:r,className:i,readOnly:s=!1})=>{let{t:c}=D(),[u,d]=t.useState(!1),f=t.useRef(null),p=t.useCallback(e=>{e.preventDefault(),e.stopPropagation(),d(!0)},[]),m=t.useCallback(e=>{e.preventDefault(),e.stopPropagation(),d(!1)},[]),h=t.useCallback(e=>{e.preventDefault(),e.stopPropagation(),d(!1),n&&e.dataTransfer.files.length>0&&n(e.dataTransfer.files)},[n]),g=t.useCallback(e=>{n&&e.target.files&&e.target.files.length>0&&(n(e.target.files),e.target.value=``)},[n]);return(0,l.jsxs)(`div`,{className:(0,a.cn)(`space-y-2`,i),children:[n&&!s&&(0,l.jsxs)(`div`,{className:(0,a.cn)(`border-2 border-dashed rounded-md px-4 py-3 text-center transition-colors cursor-pointer`,u?`border-primary bg-primary/5`:`border-muted-foreground/25 hover:border-muted-foreground/40`),onDragOver:p,onDragLeave:m,onDrop:h,onClick:()=>f.current?.click(),role:`button`,tabIndex:0,onKeyDown:e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),f.current?.click())},children:[(0,l.jsx)(o.Upload,{className:`h-5 w-5 mx-auto text-muted-foreground mb-1`}),(0,l.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:c(`detail.dropFilesToUpload`)}),(0,l.jsx)(`input`,{ref:f,type:`file`,multiple:!0,className:`hidden`,onChange:g})]}),e.length>0&&(0,l.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,l.jsxs)(`div`,{className:`flex items-center gap-1.5 text-xs text-muted-foreground`,children:[(0,l.jsx)(o.Paperclip,{className:`h-3 w-3`}),(0,l.jsx)(`span`,{children:c(`detail.attachmentCount`,{count:e.length})})]}),(0,l.jsx)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 gap-2`,children:e.map(e=>{let t=Xt(e.type),n=Zt(e.type);return(0,l.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,l.jsx)(`img`,{src:e.thumbnailUrl||e.url,alt:e.name,className:`h-10 w-10 rounded object-cover shrink-0`}):(0,l.jsx)(`div`,{className:`h-10 w-10 rounded bg-muted flex items-center justify-center shrink-0`,children:(0,l.jsx)(n,{className:`h-5 w-5 text-muted-foreground`})}),(0,l.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,l.jsx)(`p`,{className:`text-xs font-medium truncate`,children:e.name}),(0,l.jsx)(`p`,{className:`text-[10px] text-muted-foreground`,children:Yt(e.size)})]}),r&&!s&&(0,l.jsx)(a.Button,{variant:`ghost`,size:`icon`,className:`h-6 w-6 shrink-0 opacity-0 group-hover:opacity-100 transition-opacity`,onClick:()=>r(e.id),title:c(`detail.removeAttachment`),children:(0,l.jsx)(o.X,{className:`h-3.5 w-3.5`})})]},e.id)})})]})]})},$t={comment:o.MessageSquare,field_change:o.Edit,task:o.CheckSquare,event:o.Calendar,system:o.Zap,email:o.Mail,call:o.Phone,note:o.StickyNote,file:o.FileText,sharing:o.Share2,record_create:o.PlusCircle,record_delete:o.Trash2,approval:o.BadgeCheck},en={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`,note:`bg-yellow-100 text-yellow-700`,file:`bg-slate-100 text-slate-600`,sharing:`bg-sky-100 text-sky-600`,record_create:`bg-emerald-100 text-emerald-600`,record_delete:`bg-red-100 text-red-600`,approval:`bg-violet-100 text-violet-600`};function tn(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 nn(e,t,n){try{let r=new Date(e),i=new Date().getTime()-r.getTime(),a=Math.floor(i/6e4);if(a<1)return t(`detail.justNow`);if(a<60)return t(`detail.minutesAgo`,{count:a});let o=Math.floor(a/60);if(o<24)return t(`detail.hoursAgo`,{count:o});let s=Math.floor(o/24);return s<7?t(`detail.daysAgo`,{count:s}):r.toLocaleDateString(n)}catch{return e}}function rn(e){return e.type===`comment`}function an(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 on=({items:e,config:n,filterMode:r,onFilterChange:i,hasMore:c=!1,onLoadMore:u,loading:d=!1,onAddComment:f,onAddReply:p,onToggleReaction:m,subscription:h,onToggleSubscription:g,collapseWhenEmpty:_=!1,mentionSuggestions:v,onUploadAttachments:y,titleLabel:b,emptyLabel:x,activityDenied:S=!1,commentsDenied:C=!1,className:w})=>{let{t:T}=D(),E=(0,s.useDisplayLocale)(),[O,k]=t.useState(`all`),[A,j]=t.useState(``),[M,N]=t.useState(!1),[P,F]=t.useState(!1),[I,L]=t.useState([]),[R,z]=t.useState(!1),B=b??T(`detail.activity`),ee=S||C?(0,l.jsxs)(`div`,{role:`status`,"data-testid":`activity-access-denied`,className:`flex flex-col gap-2 py-4 text-sm text-muted-foreground`,children:[S&&(0,l.jsxs)(`p`,{"data-denied-source":`activity`,className:`flex items-center gap-2`,children:[(0,l.jsx)(o.Lock,{className:`h-4 w-4 shrink-0`,"aria-hidden":`true`}),(0,l.jsx)(`span`,{children:T(`detail.activityAccessDenied`)})]}),C&&(0,l.jsxs)(`p`,{"data-denied-source":`comments`,className:`flex items-center gap-2`,children:[(0,l.jsx)(o.Lock,{className:`h-4 w-4 shrink-0`,"aria-hidden":`true`}),(0,l.jsx)(`span`,{children:T(`detail.commentsAccessDenied`)})]})]}):null,te=r??O,ne=n?.showFilterToggle!==!1,V=n?.showCommentInput!==!1&&!!f,re=n?.enableReactions??!1,ie=n?.enableThreading??!1,H=n?.showSubscriptionToggle??!1,U=t.useMemo(()=>an(e,te),[e,te]),ae=t.useMemo(()=>ie?U.filter(e=>!e.parentId):U,[U,ie]),W=t.useMemo(()=>{if(!ie)return new Map;let e=new Map;for(let t of U)if(t.parentId){let n=e.get(t.parentId)??[];n.push(t),e.set(t.parentId,n)}return e},[U,ie]),oe=t.useCallback(e=>{i?i(e):k(e)},[i]),se=t.useCallback(async()=>{let e=A.trim();if(f&&(e||I.length!==0)){N(!0);try{await f(e,I.length>0?I:void 0),j(``),L([])}catch{}finally{N(!1)}}},[A,I,f]),ce=t.useCallback(async e=>{if(y&&e.length!==0){z(!0);try{let t=await y(e);Array.isArray(t)&&t.length>0&&L(e=>[...e,...t])}finally{z(!1)}}},[y]),le=t.useCallback(e=>{L(t=>t.filter(t=>t.id!==e))},[]),ue=t.useCallback(async()=>{if(u){F(!0);try{await u()}finally{F(!1)}}},[u]);return(0,l.jsxs)(`section`,{className:(0,a.cn)(`border-t border-border/60 pt-5`,w),"aria-label":B,children:[(0,l.jsx)(`header`,{className:`mb-4`,children:(0,l.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,l.jsxs)(`h2`,{className:`flex items-center gap-2 text-base font-semibold leading-none tracking-tight`,children:[(0,l.jsx)(o.Activity,{className:`h-4 w-4`}),B,(0,l.jsxs)(`span`,{className:`text-sm font-normal text-muted-foreground`,children:[`(`,U.length,`)`]})]}),(0,l.jsx)(`div`,{className:`flex items-center gap-1`,children:H&&h&&(0,l.jsx)(Kt,{subscription:h,onToggle:g})})]})}),(0,l.jsxs)(`div`,{className:`space-y-4`,children:[ne&&(0,l.jsx)(`div`,{className:`flex items-center gap-2`,children:(0,l.jsxs)(a.Select,{value:te,onValueChange:e=>oe(e),children:[(0,l.jsx)(a.SelectTrigger,{"aria-label":T(`detail.filterActivity`),className:`h-8 w-auto min-w-[140px] py-1 text-sm`,children:(0,l.jsx)(a.SelectValue,{})}),(0,l.jsx)(a.SelectContent,{children:tn(T).map(e=>(0,l.jsx)(a.SelectItem,{value:e.value,children:e.label},e.value))})]})}),V&&(0,l.jsx)(Jt,{value:A,onChange:j,onSubmit:se,mentionSuggestions:v,placeholder:T(`detail.leaveCommentPlaceholder`),disabled:M,canSubmitEmpty:I.length>0,extraSlot:y?(0,l.jsx)(Qt,{attachments:I,onUpload:ce,onRemove:le,readOnly:M||R}):I.length>0?(0,l.jsx)(Qt,{attachments:I,onRemove:le,readOnly:M}):void 0}),U.length>0&&ee,d&&U.length===0?(0,l.jsxs)(`div`,{role:`status`,"aria-live":`polite`,"data-testid":`activity-loading`,className:`flex items-center justify-center gap-2 py-6 text-sm text-muted-foreground`,children:[(0,l.jsx)(o.Loader2,{className:`h-4 w-4 animate-spin`}),(0,l.jsx)(`span`,{children:T(`detail.loading`)})]}):(S||C)&&U.length===0?ee:U.length===0?_?null:(0,l.jsx)(a.DataEmptyState,{title:x??T(`detail.noActivity`),className:`py-6`}):(0,l.jsxs)(`div`,{className:`relative`,children:[(0,l.jsx)(`div`,{className:`absolute left-4 top-2 bottom-2 w-px bg-border`}),(0,l.jsx)(`div`,{className:`space-y-4`,children:ae.map(e=>{let t=$t[e.type]||o.Zap,n=en[e.type]||`bg-gray-100 text-gray-600`,r=W.get(e.id)??[],i=re&&m&&rn(e)?t=>m(e.id,t):void 0;return(0,l.jsxs)(`div`,{children:[(0,l.jsxs)(`div`,{className:`flex gap-3 relative`,children:[(0,l.jsx)(`div`,{className:(0,a.cn)(`shrink-0 h-8 w-8 rounded-full flex items-center justify-center z-10`,n),children:e.actorAvatarUrl?(0,l.jsx)(`img`,{src:e.actorAvatarUrl,alt:e.actor,className:`h-8 w-8 rounded-full object-cover`}):(0,l.jsx)(t,{className:`h-3.5 w-3.5`})}),(0,l.jsxs)(`div`,{className:`flex-1 min-w-0 pt-1`,children:[(0,l.jsxs)(`div`,{className:`flex items-center gap-2 mb-0.5`,children:[(0,l.jsx)(`span`,{className:`text-sm font-medium`,children:e.actor}),e.source&&(0,l.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:T(`detail.via`,{source:e.source})}),(0,l.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:nn(e.createdAt,T,E)}),e.edited&&(0,l.jsx)(`span`,{className:`text-xs text-muted-foreground italic`,children:T(`detail.edited`)}),e.pinned&&(0,l.jsxs)(`span`,{className:`text-xs text-amber-600`,children:[`📌 `,T(`detail.pinned`)]})]}),e.body&&(0,l.jsx)(`p`,{className:`text-sm whitespace-pre-wrap break-words text-muted-foreground`,children:e.body}),e.sourceObject&&e.sourceId!=null&&(0,l.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:[T(`detail.viewSource`),(0,l.jsx)(`span`,{"aria-hidden":!0,children:`→`})]}),e.type===`field_change`&&e.fieldChanges&&(0,l.jsx)(`div`,{className:`space-y-1 mt-1`,children:e.fieldChanges.map((e,t)=>(0,l.jsx)(Vt,{change:e},t))}),re&&e.reactions&&e.reactions.length>0&&(0,l.jsx)(`div`,{className:`mt-1.5`,children:(0,l.jsx)(Ut,{reactions:e.reactions,onToggleReaction:i})}),(!e.reactions||e.reactions.length===0)&&i&&(0,l.jsx)(`div`,{className:`mt-1.5`,children:(0,l.jsx)(Ut,{reactions:[],onToggleReaction:i})})]})]}),ie&&(e.replyCount??0)>0&&(0,l.jsx)(Gt,{parentItem:e,replies:r,onAddReply:p,showReplyInput:!!p})]},e.id)})})]}),c&&(0,l.jsx)(`div`,{className:`text-center pt-2`,children:(0,l.jsxs)(a.Button,{variant:`ghost`,size:`sm`,onClick:ue,disabled:P,"aria-label":T(`detail.loadMore`),children:[P?(0,l.jsx)(o.Loader2,{className:`h-4 w-4 animate-spin mr-1`}):(0,l.jsx)(o.ChevronDown,{className:`h-4 w-4 mr-1`}),T(`detail.loadMore`)]})})]})]})},sn=f.FeedFilterMode.options,cn=f.FeedItemType.options,ln={created:`field_change`,updated:`field_change`,deleted:`field_change`,assigned:`field_change`,shared:`field_change`,system:`system`,completed:`task`,scheduled:`event`,commented:void 0,mentioned:void 0,login:void 0,logout:void 0},un=`system`,dn=[`comment`],fn=[`record_create`,`record_delete`,`sharing`],pn=new Set([...Object.values(ln).filter(e=>!!e),un,...dn]),mn=new Set([`task`]);function hn(e,t,n,r){let i=n.filter(n=>!e.has(JSON.stringify([t,n])));if(i.length!==0){for(let n of i)e.add(JSON.stringify([t,n]));console.warn(r(i))}}var gn=new Set,_n=new Set,vn=new Set;function yn(e,t){if(typeof e==`string`&&sn.includes(e))return e;if(e!=null){let n=typeof e==`string`?`"${e}"`:typeof e;hn(vn,t,[typeof e==`string`?e:`non-string ${n}`],()=>`[${t}] ignoring an unrecognised \`filterMode\` (${n}) and opening on "all" instead — the WIDEST mode, which shows EVERY activity rather than the slice that was asked for. No declared filter mode matches it. The fallback is kept rather than passing the value through because a dropdown handed a value with no matching item renders blank (objectui#3151), so this is a diagnostic, not a refusal. Declared filter modes: ${sn.join(`, `)}.`)}return`all`}function bn(e,t){let n=e.filter(e=>!pn.has(e));n.length!==0&&hn(_n,t,n,e=>{let n=e=>e.map(e=>`"${e}"`).join(`, `),r=e.filter(e=>fn.includes(e)),i=e.filter(e=>!fn.includes(e)),a=`[${t}] \`types\` names ${e.length} declared feed item type${e.length===1?``:`s`} that NO ObjectUI producer emits, so ${e.length===1?`it selects`:`they select`} nothing: ${n(e)}. The entr${e.length===1?`y is`:`ies are`} honoured as authored — nothing is dropped or widened — but a timeline filtered to ${e.length===1?`it`:`them`} alone renders permanently empty, which is the thing that used to happen with no diagnostic at all.`;return r.length>0&&(a+=` DELIBERATELY NOT ADOPTED, a decision rather than a gap: ${n(r)} — \`created\` / \`deleted\` / \`shared\` activity is mapped to \`field_change\` on purpose, because the record page and this block have to agree about what a \`created\` row IS before either can move to the richer kind. Adopting them is a change to that shared map (ACTIVITY_TYPE_TO_FEED_TYPE, @object-ui/plugin-detail), not to one block.`),i.length>0&&(a+=` NO PRODUCER on any ObjectUI surface: ${n(i)} — @objectstack/spec declares the kind and nothing here emits it. Whether that is a gap or a decision nobody wrote down is not recorded anywhere this diagnostic can read, so it reports the measurement and stops there.`),a+=` Feed item types ObjectUI produces today: ${[...pn].sort().join(`, `)}. If your HOST supplies the feed — \`items\` on the node, or a DiscussionContext it mounts — it may produce kinds this census cannot see, and this warning does not apply to them.`,a})}function xn(e,t){if(e==null)return;if(!Array.isArray(e)){let n=typeof e==`string`?`"${e}"`:typeof e;return hn(gn,t,[`non-array ${n}`],()=>`[${t}] ignoring an authored \`types\` that is not an array (${n}). \`types\` must be a LIST of feed item types. The timeline renders empty rather than falling back to every kind, because a filter that cannot be read is not a request to remove the filter. Declared feed item types: ${cn.join(`, `)}.`),[]}let n=[],r=[];for(let t of e)typeof t==`string`&&cn.includes(t)?n.push(t):r.push(typeof t==`string`?t:String(t));return r.length>0&&hn(gn,t,r,e=>`[${t}] ignoring ${e.length} unrecognised \`types\` entr${e.length===1?`y`:`ies`}: ${e.map(e=>`"${e}"`).join(`, `)}. No declared feed item type matches, so they select nothing; only the recognised entries narrow the timeline, and a list with NO recognised entry renders an EMPTY timeline rather than every kind. Declared feed item types: ${cn.join(`, `)}.`),bn(n,t),n}function Sn(e){return typeof e==`number`&&Number.isInteger(e)&&e>0}function Cn(e){return Sn(e)?e:20}function wn(e){if(typeof e==`number`)return String(e);if(typeof e==`string`)return JSON.stringify(e);try{let t=JSON.stringify(e);if(t!==void 0)return t}catch{}return String(e)}function Tn(e,t){return t==null||Sn(t)?null:`[ObjectUI] ${e} row cap: declared limit: ${wn(t)} (${Array.isArray(t)?`array`:typeof t}), which is not a positive integer number. The spec declares \`limit\` as z.number().int().positive() and refuses strings, booleans, fractions, zero and negatives, so it was ignored and this block fell back to its default row cap (20).`}function En(e){let t=e.timestamp;return String(!t||t===`NOW()`||Number.isNaN(Date.parse(String(t)))?e.created_at??``:t)}var Dn=new Set;function On(e){hn(Dn,``,[e],()=>`[record:activity] rendered a sys_activity row with type "${e}" through the generic "${un}" presentation: no feed item type is mapped for it. \`sys_activity.type\` is author-extensible (ruled 2026-08-24) and is not validated on write, so a producer can store a value the platform never declared — the row is shown rather than dropped. Map it in ACTIVITY_TYPE_TO_FEED_TYPE (@object-ui/plugin-detail) to give it its own presentation.`)}function kn(){Dn.clear()}function An(e,t){let n=String(e?.type),r=Object.prototype.hasOwnProperty.call(ln,n);r||On(n);let i=r?ln[n]:un;return i?{id:e.id,type:i,actor:e.actor_name??t,actorAvatarUrl:e.actor_avatar_url??void 0,body:e.summary??``,createdAt:En(e),sourceObject:e.source_object??void 0,sourceId:e.source_id??void 0}:null}function jn(e,t,n,r){let i=e.slice();t.unifiedTimeline===!1&&(i=i.filter(e=>e.type!==`field_change`)),t.showCompleted!==!0&&(i=i.filter(e=>!mn.has(e.type)));let a=xn(t.types,r);if(a!==void 0){let e=new Set(a);i=i.filter(t=>e.has(t.type))}let o=i.length,s=Math.max(1,Math.floor(n)||20);return{items:o>s?i.slice(o-s):i,total:o,hasMore:o>s}}function Mn(...e){let t=new Map;for(let n of e)for(let e of n)t.set(String(e.id),e);return Array.from(t.values()).sort((e,t)=>{let n=e.createdAt?Date.parse(e.createdAt):0,r=t.createdAt?Date.parse(t.createdAt):0;return(Number.isNaN(n)?0:n)-(Number.isNaN(r)?0:r)})}function Nn(e){let t=(0,r.classifyLoadError)(e);return t===`forbidden`||t===`unauthorized`}var Pn=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}},Fn=`record:activity`,In=({schema:e={},className:n,...i})=>{let{designer:a}=Pn(i),o=yt(e.aria),c=(0,r.useRecordContext)(),u=(0,r.useDiscussionContext)(),d=(0,s.useSafeTranslate)(),f=e.properties??{},p=t=>e[t]??f[t],m=p(`limit`),h=Cn(m),g=Tn(Fn,m);t.default.useEffect(()=>{g&&console.warn(g)},[g]);let _=yn(p(`filterMode`),Fn),v=p(`types`),y=p(`showCompleted`),b=p(`unifiedTimeline`),x={types:v,filterMode:_,showFilterToggle:p(`showFilterToggle`),limit:h,showCompleted:y,unifiedTimeline:b,showCommentInput:p(`showCommentInput`),enableMentions:p(`enableMentions`),enableReactions:p(`enableReactions`),enableThreading:p(`enableThreading`),showSubscriptionToggle:p(`showSubscriptionToggle`)},S=Array.isArray(e.items)?e.items:Array.isArray(f.items)?f.items:void 0,C=e.loading??f.loading,w=c?.objectName,T=c?.data?.id??c?.data?._id??c?.recordId,E=c?.dataSource,D=S===void 0&&!u&&typeof E?.find==`function`&&!!w&&T!=null,[O,k]=t.default.useState(0),A=h*(O+1),[j,M]=t.default.useState(null),[N,P]=t.default.useState(!1),[F,I]=t.default.useState(!1),[L,R]=t.default.useState(!1),z=d(`detail.systemActor`,`System`);t.default.useEffect(()=>{if(!D)return;let e=!1;return I(!0),Promise.resolve(E.find(`sys_activity`,{$filter:{object_name:w,record_id:T},$orderby:{timestamp:`desc`},$top:Math.max(1,A)+1})).then(t=>{if(e)return;let n=t?.data??[],r=Array.isArray(n)?n:[],i=[];for(let e of r){let t=An(e,z);t&&i.push(t)}P(r.length>Math.max(1,A)),M(Mn(i)),R(!1)}).catch(t=>{e||(M([]),P(!1),R(Nn(t)))}).finally(()=>{e||I(!1)}),()=>{e=!0}},[D,E,w,T,A,z]);let B=u?.items,ee=t.default.useMemo(()=>jn(S??B??j??[],{types:v,showCompleted:y,unifiedTimeline:b},A,Fn),[S,B,j,v,y,b,A]),te=ee.items,ne=ee.hasMore||D&&N,V=C??u?.loading??(D&&j===null?!0:F),re=S===void 0?u?!!u.activityDenied:D&&L:!1,ie=S===void 0&&!!u?.commentsDenied,[H,U]=t.default.useState(_);t.default.useEffect(()=>{U(_)},[_]);let ae=t.default.useCallback(()=>{k(e=>e+1)},[]),W=x.enableMentions!==!1;return(0,l.jsx)(`div`,{className:n,...a,...o,children:(0,l.jsx)(on,{items:te,config:x,loading:V,filterMode:H,onFilterChange:U,hasMore:ne,onLoadMore:ae,onAddComment:u?.onAddComment,onAddReply:u?.onAddReply,onToggleReaction:u?.onToggleReaction,mentionSuggestions:W?u?.mentionSuggestions:void 0,onUploadAttachments:u?.onUploadAttachments,activityDenied:re,commentsDenied:ie})})},Ln=({config:e,items:n,hasMore:r,onLoadMore:i,loading:s,onAddComment:c,onAddReply:u,onToggleReaction:d,subscription:f,onToggleSubscription:p,filterMode:m,onFilterChange:h,collapseWhenEmpty:g=!1,mentionSuggestions:_,onUploadAttachments:v,activityDenied:y,commentsDenied:b,className:x})=>{let S=e?.position??`right`,C=e?.width??`360px`,w=e?.collapsible??!0,T=g&&n.length===0||(e?.defaultCollapsed??!1),{t:E}=D(),[O,k]=t.useState(T),A=yt(e?.feed?.aria);return S===`right`||S===`left`?O&&w?(0,l.jsx)(`div`,{className:(0,a.cn)(`flex items-start pt-4`,S===`right`?`border-l`:`border-r`,x),children:(0,l.jsx)(a.Button,{variant:`ghost`,size:`icon`,className:`h-8 w-8 mx-1`,onClick:()=>k(!1),"aria-label":E(`detail.openDiscussion`),children:(0,l.jsx)(o.PanelRightOpen,{className:`h-4 w-4`})})}):(0,l.jsxs)(`div`,{className:(0,a.cn)(`flex flex-col overflow-hidden`,S===`right`?`border-l`:`border-r`,x),style:{width:C,minWidth:C},children:[(0,l.jsxs)(`div`,{className:`flex items-center justify-between px-4 py-3 border-b`,children:[(0,l.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,l.jsx)(o.MessageSquare,{className:`h-4 w-4`}),(0,l.jsx)(`span`,{className:`text-sm font-medium`,children:E(`detail.discussion`)})]}),w&&(0,l.jsx)(a.Button,{variant:`ghost`,size:`icon`,className:`h-7 w-7`,onClick:()=>k(!0),"aria-label":E(`detail.closeDiscussion`),children:(0,l.jsx)(o.X,{className:`h-3.5 w-3.5`})})]}),(0,l.jsx)(`div`,{className:`flex-1 overflow-y-auto`,children:(0,l.jsx)(`div`,{...A,children:(0,l.jsx)(on,{items:n,config:e?.feed,hasMore:r,onLoadMore:i,loading:s,onAddComment:c,onAddReply:u,onToggleReaction:d,subscription:f,onToggleSubscription:p,filterMode:m,onFilterChange:h,collapseWhenEmpty:g,mentionSuggestions:_,onUploadAttachments:v,titleLabel:E(`detail.discussion`),emptyLabel:E(`detail.noCommentsYet`),activityDenied:y,commentsDenied:b,className:`border-0 shadow-none`})})})]}):(0,l.jsx)(`div`,{className:(0,a.cn)(``,x),children:w&&O?(0,l.jsxs)(a.Button,{variant:`ghost`,className:`w-full justify-start gap-2 text-muted-foreground`,onClick:()=>k(!1),"aria-label":E(`detail.showDiscussion`,{count:n.length}),children:[(0,l.jsx)(o.MessageSquare,{className:`h-4 w-4`}),(0,l.jsx)(`span`,{children:E(`detail.showDiscussion`,{count:n.length})})]}):(0,l.jsxs)(`div`,{children:[w&&(0,l.jsxs)(`div`,{className:`flex items-center justify-between mb-2`,children:[(0,l.jsxs)(`div`,{className:`flex items-center gap-2 text-sm font-medium`,children:[(0,l.jsx)(o.MessageSquare,{className:`h-4 w-4`}),E(`detail.discussion`)]}),(0,l.jsx)(a.Button,{variant:`ghost`,size:`icon`,className:`h-7 w-7`,onClick:()=>k(!0),"aria-label":E(`detail.hideDiscussion`),children:(0,l.jsx)(o.PanelRightClose,{className:`h-3.5 w-3.5`})})]}),(0,l.jsx)(`div`,{...A,children:(0,l.jsx)(on,{items:n,config:e?.feed,hasMore:r,onLoadMore:i,loading:s,onAddComment:c,onAddReply:u,onToggleReaction:d,subscription:f,onToggleSubscription:p,filterMode:m,onFilterChange:h,collapseWhenEmpty:g,mentionSuggestions:_,onUploadAttachments:v,titleLabel:E(`detail.discussion`),emptyLabel:E(`detail.noCommentsYet`),activityDenied:y,commentsDenied:b})})]})})},Rn=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}},zn=({schema:e={},className:n,...i})=>{(0,r.useRecordContext)();let a=(0,r.useDiscussionContext)(),{designer:o}=Rn(i),s=yt(e.aria),c={position:`bottom`,collapsible:!1,feed:{enableReactions:!0,enableThreading:!0,showCommentInput:!0},...e},u=c.feed,[d,f]=t.default.useState(0),p=Cn(u?.limit),m=typeof e.type==`string`&&e.type?e.type:`record:chatter`,h=Tn(`${m} feed`,u?.limit);t.default.useEffect(()=>{h&&console.warn(h)},[h]);let g=p*(d+1),_=yn(u?.filterMode,m),[v,y]=t.default.useState(_);t.default.useEffect(()=>{y(_)},[_]);let b=a?.items,x=t.default.useMemo(()=>jn(b??[],{types:u?.types,showCompleted:u?.showCompleted,unifiedTimeline:u?.unifiedTimeline},g,m),[b,u?.types,u?.showCompleted,u?.unifiedTimeline,g,m]),S=t.default.useCallback(()=>{f(e=>e+1)},[f]),C=u?.enableMentions!==!1;return(0,l.jsx)(`div`,{className:n,...o,...s,children:(0,l.jsx)(Ln,{items:x.items,config:c,hasMore:x.hasMore,onLoadMore:S,loading:a?.loading,filterMode:v,onFilterChange:y,onAddComment:a?.onAddComment,onAddReply:a?.onAddReply,onToggleReaction:a?.onToggleReaction,mentionSuggestions:C?a?.mentionSuggestions:void 0,onUploadAttachments:a?.onUploadAttachments,activityDenied:a?.activityDenied,commentsDenied:a?.commentsDenied})})},Bn=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}};function Vn(e,t){if(!Array.isArray(e))return[];let n=null;for(let r=0;r<e.length;r++){let i=e[r],a=i?.label;typeof a==`object`&&a&&(n??=[...e],n[r]={...i,label:(0,s.pickLocalized)(a,t)})}return n??e}var Hn=({schema:e={},className:n,...i})=>{let o=(0,r.useRecordContext)(),{translateOptions:c}=(0,r.useSafeFieldLabel)(),{t:u}=D(),{designer:d}=Bn(i),f=yt(e.aria,{defaultRole:`list`,defaultLabel:u(`detail.pathLabel`),block:`record:path`}),{language:p}=(0,s.useObjectTranslation)(),m=e.statusField,h=e.stages,g=h===void 0,_=o?.objectSchema,v=t.default.useMemo(()=>Vn(g?it(_,m??null):h,p),[g,h,_,m,p]),y=t.default.useMemo(()=>{if(v.length===0||!m||!o?.objectName)return v;let e=c(o.objectName,m,v);return Array.isArray(e)&&e.length===v.length?v.map((t,n)=>({...t,label:e[n]?.label??t.label})):v},[v,m,o?.objectName,c]),b=m&&o?.data?o.data[m]:void 0,x=/(^|[_-\s])(closed_)?(lost|failed?|cancell?ed|失败|流失|丢单|败)([_-\s]|$)/i,S=/(^|[_-\s])(closed_)?(won|success|成交|赢|完成)([_-\s]|$)/i,C=y.map(e=>{if(e.terminal)return e.terminal;let t=`${String(e.value??``)} ${String(e.label??``)}`;if(x.test(t))return`lost`;if(S.test(t))return`won`}),w=C.findIndex(e=>e===`lost`),T=w===-1?y:y.slice(0,w),E=w===-1?[]:y.slice(w),O=T.length-1,k=C.map((e,t)=>e===`won`?t===O?`won`:void 0:e),A=y.findIndex(e=>e.value===b);A<0&&(A=-1);let j=w!==-1&&A>=w;if(y.length===0){let e=g&&!!m&&_!=null;return(0,l.jsx)(`div`,{className:n,...d,children:(0,l.jsx)(`div`,{className:`text-xs text-muted-foreground italic px-3 py-2 border border-dashed rounded`,children:e?`record:path — no stages configured, and field "${m}" has no picklist options to derive them from`:`record:path — no stages configured`})})}let M=(e,t)=>(0,a.cn)(`h-1.5 w-full rounded-full`,t===`lost`&&(e===`current`?`bg-destructive`:`bg-destructive/25`),t!==`lost`&&e===`current`&&`bg-primary`,t!==`lost`&&e===`completed`&&`bg-emerald-500`,t!==`lost`&&e===`upcoming`&&(t===`won`?`bg-emerald-500/30`:`bg-muted`)),N=(e,t)=>(0,a.cn)(`block min-w-0 text-xs`,e===`current`&&(t===`lost`?`font-semibold text-destructive`:`font-semibold text-foreground`),e===`completed`&&`font-normal text-muted-foreground`,e===`upcoming`&&`font-normal text-muted-foreground`),P=(e,t,n)=>u(n===`lost`?t===`current`?`detail.pathStageLostCurrent`:`detail.pathStageLostUpcoming`:n===`won`&&t===`upcoming`?`detail.pathStageWonUpcoming`:t===`current`?`detail.pathStageCurrent`:t===`completed`?`detail.pathStageCompleted`:`detail.pathStageUpcoming`,{stage:e}),F=e=>(0,l.jsxs)(`div`,{role:`listitem`,"data-stage-state":e.state,"data-stage-terminal":e.terminal,"aria-current":e.state===`current`?`step`:void 0,"aria-label":P(e.stage.label,e.state,e.terminal),className:(0,a.cn)(`flex flex-col gap-1.5`,e.className),children:[(0,l.jsx)(`span`,{"aria-hidden":`true`,"data-stage-rail":``,className:M(e.state,e.terminal)}),(0,l.jsxs)(`span`,{className:(0,a.cn)(N(e.state,e.terminal),e.labelClassName),children:[e.terminal===`lost`&&(0,l.jsx)(`span`,{"aria-hidden":`true`,className:`mr-1 opacity-70`,children:`✗`}),e.terminal!==`lost`&&e.state===`completed`&&(0,l.jsx)(`span`,{"aria-hidden":`true`,className:`mr-1 text-emerald-600 dark:text-emerald-400 font-semibold`,children:`✓`}),e.stage.label]})]},e.key);return(0,l.jsxs)(`div`,{className:(0,a.cn)(`w-full`,n),...d,children:[(0,l.jsxs)(`div`,{className:`hidden sm:flex w-full items-start gap-2`,...f,children:[(0,l.jsx)(`div`,{className:`flex flex-1 items-start gap-1.5`,children:T.map((e,t)=>{let n=!j&&A>=0&&t<A,r=!j&&t===A;return F({key:`${e.value}-${t}`,stage:e,state:r?`current`:n?`completed`:`upcoming`,terminal:k[t],className:`flex-1 min-w-0`,labelClassName:`text-center truncate`})})}),E.length>0&&(0,l.jsx)(`div`,{className:`flex items-start gap-1.5 pl-2 border-l border-border/40`,children:E.map((e,t)=>{let n=w+t;return F({key:`${e.value}-lost-${t}`,stage:e,state:n===A?`current`:`upcoming`,terminal:k[n],className:`shrink-0`,labelClassName:`text-center whitespace-nowrap`})})})]}),(0,l.jsx)(`div`,{className:`flex sm:hidden w-full items-start gap-2 overflow-x-auto pb-1 -mx-1 px-1 [-ms-overflow-style:none] [scrollbar-width:none] [&::-webkit-scrollbar]:hidden`,...f,children:y.map((e,t)=>{let n=k[t],r=n!==`lost`&&!j&&A>=0&&t<A,i=t===A;return F({key:`${e.value}-${t}-m`,stage:e,state:i?`current`:r?`completed`:`upcoming`,terminal:n,className:`shrink-0`,labelClassName:`whitespace-nowrap`})})})]})},Un=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}},Wn=Object.freeze([]),Gn=new Set;function Kn(e,t,n){let r=`${e}::${t}::${n.index}::${n.message}`;Gn.has(r)||(Gn.add(r),console.error(`[record:quick_actions] ${t} refused at index ${n.index} — ${n.message}. None of the authored actions is rendered. \`actionNames\` is a list of ACTION IDS resolved from the object's own \`actions\`; an inline action object is the host's runtime channel and must not share an array with ids.`))}var qn=({schema:e={},className:t,...n})=>{let i=(0,r.useRecordContext)(),{designer:o}=Un(n),s=yt(e.aria,{defaultRole:`toolbar`,defaultLabel:`Quick actions`,block:`record:quick_actions`}),c=(0,d.usePermissions)(),f=(0,r.useActionTextLocalizer)(),p=Array.isArray(e.actions)?e.actions:Array.isArray(e.properties?.actions)?e.properties.actions:Wn,m=Array.isArray(e.actionNames)?e.actionNames:Array.isArray(e.properties?.actionNames)?e.properties.actionNames:Wn,h=i?.objectName||``,g=m.length>0?`actionNames`:`actions`,_=m.length>0?m:p,v=(0,u.resolveDeclaredActionIds)(_,void 0),y=v.kind===`ids`&&v.ids.length>0&&!!h,{item:b}=(0,r.useMetadataItem)(`object`,y?h:null),x=(0,u.resolveDeclaredActionIds)(_,Array.isArray(b?.actions)?b.actions:[]);x.kind===`refused`&&Kn(h,g,x);let S=(x.kind===`refused`?[]:x.actions).map((e,t)=>f(h||void 0,e,{fallbackLabel:`Action ${t+1}`})),C=Array.isArray(e.requiredPermissions)?e.requiredPermissions:[],w=e.location||`record_header`,{getActionsForLocation:T,executeAction:E}=(0,r.useActionEngine)({actions:S,context:{record:i?.data,recordId:i?.recordId,objectName:i?.objectName}});if(C.length>0&&!c.hasCapabilities(C))return(0,l.jsx)(`div`,{className:t,...o,role:`status`,"aria-live":`polite`,children:(0,l.jsx)(`p`,{className:`text-sm text-muted-foreground italic`,children:`Insufficient permissions to view quick actions.`})});let D=S.length>0?T(w):[];if(D.length===0)return(0,l.jsx)(`div`,{className:t,...o,children:(0,l.jsx)(`div`,{className:`text-xs text-muted-foreground italic px-3 py-2 border border-dashed rounded`,children:x.kind===`refused`?`record:quick_actions — ${g} refused at index ${x.index} (see console)`:`record:quick_actions — no actions configured`})});let O=e.align||`end`,k=O===`start`?`justify-start`:O===`center`?`justify-center`:`justify-end`,A=w===`record_header`&&!e.inline;return(0,l.jsx)(`div`,{className:(0,a.cn)(`flex flex-wrap items-center gap-2`,A&&`-mt-12 sm:-mt-14 mb-2 relative z-10`,k,t),...s,...o,children:D.map((t,n)=>(0,l.jsx)(Jn,{action:t,record:i?.data,variant:t.variant||e.variant||`default`,size:t.size||e.size||`sm`,label:t.label||`Action ${n+1}`,onRun:async()=>{typeof t.onClick==`function`?await t.onClick():t.name&&await E(t.name)}},t.name||`qa-${n}`))})};function Jn({action:e,record:n,variant:i,size:s,label:c,onRun:u}){let[d,f]=t.default.useState(!1),p=t.default.useMemo(()=>({record:n||{}}),[n]),m=(0,r.useCondition)((0,r.toPredicateInput)(e.disabled),p),h=((0,a.hasDeclaredVisibilityGate)(e.disabled)?m:!1)||d;return(0,l.jsxs)(a.Button,{variant:i,size:s,disabled:h,onClick:async()=>{f(!0);try{await u()}finally{f(!1)}},children:[d&&(0,l.jsx)(o.Loader2,{className:`mr-2 h-4 w-4 animate-spin`}),c]})}var Yn=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}},Xn=new Set([`created`,`updated`,`assigned`,`shared`,`deleted`]),Zn=50;function Qn(e){return typeof e==`number`&&Number.isInteger(e)&&e>0}function $n(e){return Qn(e)?e:Zn}function er(e){if(typeof e==`number`)return String(e);if(typeof e==`string`)return JSON.stringify(e);try{let t=JSON.stringify(e);if(t!==void 0)return t}catch{}return String(e)}function tr(e){return e==null||Qn(e)?null:`[ObjectUI] record:history row cap: declared limit: ${er(e)} (${Array.isArray(e)?`array`:typeof e}), which is not a positive integer number. The spec declares \`limit\` as z.number().int().positive() and refuses strings, booleans, fractions, zero and negatives, so it was ignored and this block fell back to its default row cap (${Zn}).`}var nr=({schema:e={},className:n,...i})=>{let{designer:a}=Yn(i),o=(0,r.useRecordContext)(),s=Array.isArray(e.entries)?e.entries:Array.isArray(e.properties?.entries)?e.properties.entries:void 0,c=e.loading??e.properties?.loading,u=e.emptyText??e.properties?.emptyText,d=e.unknownUserText??e.properties?.unknownUserText,f=e.limit??e.properties?.limit,p=$n(f),m=tr(f);t.default.useEffect(()=>{m&&console.warn(m)},[m]);let h=o?.objectName,g=o?.data?.id??o?.data?._id??o?.recordId,_=o?.dataSource,v=s===void 0&&!!_?.find&&!!h&&g!=null,[y,b]=t.default.useState(null),[x,S]=t.default.useState(!1);t.default.useEffect(()=>{if(!v)return;let e=!1;return S(!0),Promise.resolve(_.find(`sys_activity`,{$filter:{object_name:h,record_id:g},$orderby:{timestamp:`desc`},$top:p})).then(t=>{if(e)return;let n=(t?.data??[]).filter(e=>Xn.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}});b(n)}).catch(()=>{e||b([])}).finally(()=>{e||S(!1)}),()=>{e=!0}},[v,_,h,g,p]);let C=s??y??[],w=c??(v&&y===null?x||!0:!1);return(0,l.jsx)(`div`,{className:n,...a,children:(0,l.jsx)(Te,{entries:C,loading:w,emptyText:u,unknownUserText:d})})},rr=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}};function ir(e){return typeof e==`number`&&Number.isInteger(e)&&e>0}function ar(e,t){return ir(e)?e:t}function or(e,t){return e==null||ir(e)?null:`[ObjectUI] RecordReferenceRail row cap: ${typeof t==`string`&&t?`record:reference_rail entry for ${t}`:`record:reference_rail entry`} declared limit: ${String(e)}, which is not a positive integer. A row cap must be a positive integer (the spec refuses zero and negative values), so it was ignored and this entry fell back to its default preview-row cap (3).`}var sr=e=>e.replace(/[_-]+/g,` `).replace(/\b\w/g,e=>e.toUpperCase()).trim(),cr=(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||`—`,lr=({schema:e={},className:i,...s})=>{let u=(0,r.useRecordContext)(),d=(0,r.useSafeFieldLabel)(),{t:f}=D(),{designer:p}=rr(s),m=(0,c.useParams)().appName,h=Array.isArray(e.entries)?e.entries:Array.isArray(e.properties?.entries)?e.properties.entries:[],g=u?.recordId,_=u?.dataSource,[v,y]=t.default.useState({}),b=t.default.useRef(null),[x,S]=t.default.useState(!1),C=t.default.useRef(!0);t.default.useEffect(()=>(C.current=!0,()=>{C.current=!1}),[]);let w=t.default.useRef(``);t.default.useEffect(()=>{if(x)return;let e=b.current;if(!e||typeof IntersectionObserver>`u`){S(!0);return}let t=new IntersectionObserver(e=>{e.some(e=>e.isIntersecting)&&S(!0)},{rootMargin:`200px`});return t.observe(e),()=>t.disconnect()},[x]);let[T,E]=t.default.useState({}),O=t.default.useRef(new Set),k=t.default.useRef(new Set),A=JSON.stringify(h.map(e=>`${e.objectName}:${e.relationshipField}:${ar(e.limit,3)}`)),j=JSON.stringify(h.map(e=>[e.objectName,e.limit??null]));t.default.useEffect(()=>{for(let e of h){let t=or(e.limit,e.objectName);if(!t)continue;let n=`${e.objectName}:${String(e.limit)}`;k.current.has(n)||(k.current.add(n),console.warn(t))}},[j]),t.default.useEffect(()=>{if(!x||!_?.find||!g||h.length===0)return;let e=`${g}::${A}`;if(w.current===e)return;w.current=e;let t=()=>C.current&&w.current===e;y(e=>{let t={...e};for(let n of h)t[n.objectName]={loading:!0,total:0,items:e[n.objectName]?.items||[]};return t});let r=async(e,r)=>{let i=e.objectName;try{let a=await _.find(e.objectName,{$filter:(0,n.composeParentScopeFilter)(e.relationshipField,g,r),$top:ar(e.limit,3),$count:!0});if(!t())return;let o=Array.isArray(a)?a:a?.data||[],s=typeof a?.total==`number`?a.total:o.length;y(e=>({...e,[i]:{loading:!1,total:s,items:o}}))}catch(e){if(!t())return;y(t=>({...t,[i]:{loading:!1,total:0,items:[],error:String(e?.message||e)}}))}};(async()=>{let e=new Map;if(typeof _.getObjectSchema==`function`&&await Promise.all(Array.from(new Set(h.map(e=>e.objectName))).map(async t=>{try{e.set(t,(await _.getObjectSchema(t))?.fields)}catch{}})),!t())return;E(Object.fromEntries(e));for(let t of h){if(!(0,n.isMultiValueRelationship)(e.get(t.objectName),t.relationshipField))continue;let r=`${t.objectName}.${t.relationshipField}`;O.current.has(r)||(O.current.add(r),console.warn(`[RecordReferenceRail] "${t.objectName}" relates through the multi-value field "${t.relationshipField}", so the "View All" link is suppressed for it. The console list URL's \`filter[<field>]=<value>\` grammar has no membership operator and no unrecognised suffix narrows it, so the link would open the entire child table dressed as this parent's related records. The rail's own rows are still scoped correctly.`))}let i=[...h],a=async()=>{for(;C.current;){let t=i.shift();if(!t)return;await r(t,e.get(t.objectName))}};await Promise.all(Array.from({length:Math.min(3,i.length)},()=>a()))})()},[x,_,g,A]);let[M,N]=t.default.useState(!1);if(h.length===0)return null;let P=e.hideEmpty!==!1,F=new Set(h.filter(e=>{let t=v[e.objectName];return P&&t&&!t.loading&&!t.error&&t.total===0}).map(e=>e.objectName)),I=h.filter(e=>M||!F.has(e.objectName)),L=h.filter(e=>F.has(e.objectName)).map(e=>e.title||(d?.objectLabel?d.objectLabel({name:e.objectName,label:sr(e.objectName)}):sr(e.objectName)));return(0,l.jsxs)(`div`,{ref:b,className:(0,a.cn)(`flex flex-col gap-3`,e.className,i),...p,children:[I.map(e=>{let t=e.objectName,r=v[t]||{loading:!0,total:0,items:[]},i=(0,n.isMultiValueRelationship)(T[t],e.relationshipField),s=e.title||(d?.objectLabel?d.objectLabel({name:e.objectName,label:sr(e.objectName)}):sr(e.objectName));return(0,l.jsxs)(a.Card,{className:`overflow-hidden`,children:[(0,l.jsxs)(a.CardHeader,{className:`flex flex-row items-center justify-between gap-2 py-3 px-4 space-y-0 border-b`,children:[(0,l.jsx)(a.CardTitle,{className:`text-sm font-semibold tracking-tight truncate`,children:s}),(0,l.jsxs)(`div`,{className:`flex items-center gap-2 shrink-0`,children:[!r.loading&&(0,l.jsx)(a.Badge,{variant:`secondary`,className:`tabular-nums`,children:r.total}),m&&g&&!i&&(0,l.jsx)(c.Link,{to:`/apps/${m}/${e.objectName}?filter%5B${e.relationshipField}%5D=${encodeURIComponent(String(g))}`,className:`text-[11px] font-medium text-muted-foreground hover:text-foreground transition-colors`,title:f(`detail.viewAll`,{defaultValue:`View All`}),children:f(`detail.viewAll`,{defaultValue:`View All`})})]})]}),(0,l.jsx)(a.CardContent,{className:`p-0`,children:r.loading?(0,l.jsxs)(`div`,{className:`space-y-1.5 p-3`,children:[(0,l.jsx)(a.Skeleton,{className:`h-3.5 w-4/5`}),(0,l.jsx)(a.Skeleton,{className:`h-3.5 w-3/5`}),(0,l.jsx)(a.Skeleton,{className:`h-3.5 w-2/3`})]}):r.items.length===0?(0,l.jsx)(`p`,{className:`px-4 py-3 text-xs text-muted-foreground`,children:f(`detail.noRecords`)}):(0,l.jsx)(`ul`,{className:`divide-y`,children:r.items.map(t=>{let n=t.id||t._id,r=cr(t,e.displayField),i=n?`../${e.objectName}/record/${encodeURIComponent(String(n))}`:void 0;return(0,l.jsx)(`li`,{className:`px-4 py-2`,children:i?(0,l.jsxs)(c.Link,{to:i,className:`group flex items-center justify-between gap-2 text-xs hover:text-foreground text-muted-foreground transition-colors`,children:[(0,l.jsx)(`span`,{className:`truncate`,children:r}),(0,l.jsx)(o.ChevronRight,{className:`h-3 w-3 shrink-0 opacity-0 group-hover:opacity-100 transition-opacity`})]}):(0,l.jsx)(`span`,{className:`block truncate text-xs text-muted-foreground`,children:r})},String(n||r))})})})]},t)}),!M&&L.length>0&&(0,l.jsxs)(`button`,{type:`button`,onClick:()=>N(!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:L.join(` · `),children:[(0,l.jsx)(`span`,{children:f(`detail.showEmptyRelated`,{defaultValue:`+ {{count}} empty`,count:L.length})}),(0,l.jsxs)(`span`,{className:`truncate max-w-[180px] text-muted-foreground/70`,children:[`(`,L.join(` · `),`)`]})]})]})};function ur(e){let t=(0,r.isConfigBag)(e?.properties)?e.properties:{};return{...e,...t}}var dr={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:`circle-check`}},fr=({schema:e={},className:n})=>{let i=ur(e),o=(0,r.useRecordContext)(),c=o?.data,d=o?.objectName||``,f=o?.recordId??c?.id,{language:p}=(0,s.useObjectTranslation)(),m=(0,s.pickLocalized)(i.title,p),h=(0,s.pickLocalized)(i.body,p),g=(0,s.pickLocalized)(i.action?.label,p),_=[`info`,`warning`,`error`,`success`].includes(i.severity)?i.severity:`info`,v=dr[_],y=i.icon||v.icon,b=(0,r.usePredicateRecordContext)(c),x=(0,r.toPredicateInput)(i.visible),S=!!c&&Object.keys(c).length>0,C=(0,r.useCondition)(S?x:void 0,b),w=t.useMemo(()=>{if(!i.dismissible)return null;let e=i.dismissKey||(0,s.pickLocalized)(i.title,`en`)||_;return`os.record-alert:${d}:${f??`_`}:${e}`},[i.dismissible,i.dismissKey,i.title,_,d,f]),[T,E]=t.useState(()=>{if(!w||typeof window>`u`)return!1;try{return window.localStorage.getItem(w)===`1`}catch{return!1}}),D=i.action?.actionName,{item:O}=(0,r.useMetadataItem)(`object`,D&&d?d:null),k=t.useMemo(()=>{let e=(0,u.resolveDeclaredActionIds)(D?[D]:[],Array.isArray(O?.actions)?O.actions:void 0);return e.kind===`ids`?e.actions[0]:void 0},[D,O]),A=t.useMemo(()=>k?[k]:[],[k]),{executeAction:j}=(0,r.useActionEngine)({actions:A,context:{record:c,recordId:f,objectName:d}});return T||!S||x!==void 0&&!C?null:(0,l.jsxs)(a.Alert,{className:(0,a.cn)(`relative pr-12`,v.wrap,n),role:_===`error`?`alert`:`status`,"aria-live":_===`error`?`assertive`:`polite`,children:[(0,l.jsx)(a.LazyIcon,{name:y,className:`h-4 w-4`,"aria-hidden":`true`}),m?(0,l.jsx)(a.AlertTitle,{children:m}):null,h||k?(0,l.jsxs)(a.AlertDescription,{children:[h?(0,l.jsx)(`p`,{className:`mb-2 last:mb-0`,children:h}):null,k?(0,l.jsx)(a.Button,{size:`sm`,variant:i.action?.variant||(_===`error`?`destructive`:`default`),onClick:()=>{k?.name&&j(k.name)},children:g||k.label||k.name}):null]}):null,i.dismissible?(0,l.jsx)(`button`,{type:`button`,onClick:()=>{if(E(!0),w)try{window.localStorage.setItem(w,`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,l.jsx)(a.LazyIcon,{name:`X`,className:`h-4 w-4`,"aria-hidden":`true`})}):null]})},pr=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)}},mr=(e,t)=>{if(typeof e!=`string`||e.length===0)return null;let n=/\d{4}-\d{2}-\d{2}[ T]/.test(e)?e.replace(` `,`T`):e,r=new Date(n);if(Number.isNaN(r.getTime()))return null;try{return r.toLocaleString(t)}catch{return r.toISOString()}},hr=({open:e,conflict:t,onReload:n,onOverwrite:r,onCancel:i,busy:c=!1})=>{let{t:u}=D(),d=(0,s.useDisplayLocale)(),f=t?.label||t?.field||``,p=t?pr(t.pendingValue):``,m=t?pr(t.currentValue):``,h=t?.currentRecord??{},g=(()=>{let e=[h.updated_by_name,h.updated_by_label];for(let t of e)if(typeof t==`string`&&t.length>0)return t;let t=h.updated_by;return typeof t!=`string`||t.length===0||t.length>=16&&!/\s/.test(t)&&/^[A-Za-z0-9_-]+$/.test(t)?null:t})(),_=mr(h.updated_at??t?.currentVersion,d),[v,y]=u(`detail.concurrentUpdateDescription`,{field:`{{field}}`}).split(`{{field}}`);return(0,l.jsx)(a.AlertDialog,{open:e,onOpenChange:e=>{!e&&!c&&i()},children:(0,l.jsxs)(a.AlertDialogContent,{className:`max-w-lg`,children:[(0,l.jsx)(a.AlertDialogHeader,{children:(0,l.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,l.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,l.jsx)(o.AlertTriangle,{className:`h-5 w-5`})}),(0,l.jsxs)(`div`,{className:`flex-1`,children:[(0,l.jsx)(a.AlertDialogTitle,{children:u(`detail.concurrentUpdateTitle`)}),(0,l.jsxs)(a.AlertDialogDescription,{className:`mt-1`,children:[v,(0,l.jsx)(`strong`,{className:`font-semibold`,children:f}),y]})]})]})}),(0,l.jsxs)(`div`,{className:`space-y-2 text-sm`,children:[(0,l.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,l.jsx)(`div`,{className:`text-xs font-medium uppercase tracking-wide text-amber-800 dark:text-amber-300`,children:u(`detail.concurrentUpdateYourEdit`)}),(0,l.jsx)(`div`,{className:`mt-1 break-all font-mono text-foreground`,children:p})]}),(0,l.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,l.jsxs)(`div`,{className:`flex items-baseline justify-between gap-2`,children:[(0,l.jsx)(`div`,{className:`text-xs font-medium uppercase tracking-wide text-sky-800 dark:text-sky-300`,children:u(`detail.concurrentUpdateCurrentValue`)}),(g||_)&&(0,l.jsxs)(`div`,{className:`text-[11px] text-muted-foreground`,children:[g&&(0,l.jsx)(`span`,{children:u(`detail.concurrentUpdateUpdatedBy`,{name:g})}),g&&_&&(0,l.jsx)(`span`,{children:` · `}),_&&(0,l.jsx)(`span`,{children:u(`detail.concurrentUpdateUpdatedAt`,{when:_})})]})]}),(0,l.jsx)(`div`,{className:`mt-1 break-all font-mono text-foreground`,children:m})]})]}),(0,l.jsxs)(a.AlertDialogFooter,{className:`gap-2 sm:gap-2`,children:[(0,l.jsx)(`button`,{type:`button`,disabled:c,onClick:i,className:(0,a.cn)((0,a.buttonVariants)({variant:`ghost`}),`mt-2 sm:mt-0`),children:u(`detail.concurrentUpdateCancel`)}),(0,l.jsx)(`button`,{type:`button`,disabled:c,onClick:r,className:(0,a.cn)((0,a.buttonVariants)({variant:`outline`}),`mt-2 sm:mt-0 text-destructive border-destructive/40 hover:bg-destructive/10 hover:text-destructive`),children:u(`detail.concurrentUpdateOverwrite`)}),(0,l.jsx)(`button`,{type:`button`,disabled:c,onClick:n,autoFocus:!0,className:(0,a.cn)((0,a.buttonVariants)({variant:`default`}),`mt-2 sm:mt-0`),children:u(`detail.concurrentUpdateReload`)})]})]})})};function gr(e){if(!e||typeof e!=`object`)return!1;let t=e;return t.code===`CONCURRENT_UPDATE`||t.name===`ConcurrentUpdateError`}function _r(e){let t=e?.message||e?.error||String(e??`Save failed`);return String(t).replace(/^\[[^\]]+\]\s*/,``).replace(/^[A-Z][A-Z0-9_]+:\s*/,``)}function vr(e,t){return(0,r.extractFieldErrors)(e)||(t?[{field:t,message:(0,r.extractWriteErrorMessage)(e)||_r(e)}]:null)}async function yr(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 br=({dataSource:e,objectName:n,recordId:i,data:s,refresh:c,fieldLabelFor:u,onFieldSave:d,locked:f=!1,lockedHint:p,className:m})=>{let{t:h}=D(),g=(0,r.useInlineEdit)(),[_,v]=t.useState(null),[y,b]=t.useState(!1),x=t.useCallback(e=>u?.(e)||e,[u]),S=!!e&&!!n&&i!=null,C=t.useCallback((e,t)=>{if(!g)return;let n=vr(e,t);if(!n){g.setFieldErrors(null),g.setError(_r(e));return}let r=e=>u?.(e)||e;g.setFieldErrors(Object.fromEntries(n.map(e=>[e.field,e.message]))),g.setError(n.map(e=>`${r(e.field)}: ${e.message}`).join(`; `))},[g,u]),w=t.useCallback((e,t)=>{let n=Object.keys(e),r=t?.currentRecord??null;if(n.length===1){let i=n[0];return{field:i,label:u?.(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:h(`detail.concurrentUpdateRecordLabel`,{defaultValue:`this record`}),pendingValue:e,currentValue:i,currentVersion:t?.currentVersion,currentRecord:r}},[u,h]),T=t.useCallback(async()=>{if(!g)return;let t=g.draft,r=Object.entries(t);if(r.length===0){g.reset();return}g.setSaving(!0),g.setError(null),g.setFieldErrors(null);let a;try{if(d){for(let[e,t]of r)a=e,await d(e,t);a=void 0}else if(S){let r=typeof s?.updated_at==`string`?s.updated_at:void 0;await yr(e,n,i,t,r?{ifMatch:r}:void 0),await c?.()}g.reset()}catch(e){gr(e)&&S?v(w(t,e)):C(e,a)}finally{g.setSaving(!1)}},[g,d,S,s,e,n,i,c,w,C]),E=t.useCallback(()=>{v(null),b(!1)},[]),O=t.useCallback(async()=>{b(!0);try{await c?.()}finally{g?.reset(),E()}},[c,g,E]),k=t.useCallback(async()=>{if(!_||!S){E();return}b(!0);try{await yr(e,n,i,g?.draft??{},_.currentVersion?{ifMatch:_.currentVersion}:void 0),await c?.(),g?.reset()}catch(e){C(e)}finally{E()}},[_,S,g,e,n,i,c,E,C]),A=!!g?.editing,j=!!g?.saving,M=g?.cancel,N=!!_;return t.useEffect(()=>{if(!A)return;let e=e=>{if(e.key===`Enter`&&(e.metaKey||e.ctrlKey)){if(j||f||N)return;e.preventDefault(),T();return}if(e.key===`Escape`){if(e.defaultPrevented||j||N||document.querySelector(`[data-radix-popper-content-wrapper], [role="dialog"][data-state="open"], [role="alertdialog"][data-state="open"]`))return;e.preventDefault(),M?.()}};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[A,j,f,N,T,M]),!g||!g.editing?null:(0,l.jsxs)(l.Fragment,{children:[(0,l.jsxs)(`div`,{className:(0,a.cn)(`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`,m),role:`region`,"aria-label":h(`detail.editFieldsInline`),children:[g.error&&(0,l.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:g.fieldErrors?(0,l.jsx)(`ul`,{className:`space-y-0.5`,children:Object.entries(g.fieldErrors).map(([e,t])=>(0,l.jsxs)(`li`,{"data-inline-field-error":e,children:[(0,l.jsx)(`span`,{className:`font-medium`,children:x(e)}),`: `,t]},e))}):g.error}),(0,l.jsxs)(a.Button,{variant:`ghost`,size:`sm`,onClick:g.cancel,disabled:g.saving,className:`gap-2`,children:[(0,l.jsx)(o.X,{className:`h-4 w-4`}),(0,l.jsx)(`span`,{children:h(`detail.cancel`)})]}),(0,l.jsxs)(a.Button,{variant:`default`,size:`sm`,onClick:T,disabled:g.saving||f,className:`gap-2`,title:f?p:void 0,children:[g.saving?(0,l.jsx)(o.Loader2,{className:`h-4 w-4 animate-spin`}):(0,l.jsx)(o.Check,{className:`h-4 w-4`}),(0,l.jsx)(`span`,{children:g.saving?h(`detail.saving`):h(`detail.save`)})]})]}),(0,l.jsx)(hr,{open:!!_,conflict:_,busy:y,onCancel:E,onReload:O,onOverwrite:k})]})},xr=new Set(u.SYSTEM_MANAGED_FIELD_NAMES);function Sr(e,t,r){let i=t?.fields??{};return(Object.keys(i).length?Object.keys(i):Object.keys(e)).filter(e=>!r.has(e)&&!e.startsWith(`__`)).filter(t=>t in e).filter(e=>!i[e]?.hidden).map(e=>{let t=i[e]||{},r=(0,n.isExpandableFieldType)(t);return{name:e,label:t.label,type:t.type,readonly:!!t.readonly||r,options:t.options,currency:t.currency,precision:t.precision,scale:t.scale,useGrouping:t.useGrouping,format:t.format,reference:t.reference,reference_field:t.reference_field??t.referenceField,required:t.required,validation:t.validation,placeholder:t.placeholder,description:t.description}})}var Cr=`min(960px, 60vw)`;function wr({record:e,objectName:t,recordId:n,dataSource:i,objectSchema:a,columns:o=2,systemFields:s=xr,onFieldSave:c,onDelete:u,onClose:d,fullPageHref:f}){let{t:p}=D(),m=Sr(e,a,s);return(0,l.jsxs)(r.InlineEditProvider,{canEdit:!!c,children:[(0,l.jsx)(Z,{dataSource:i,inlineEdit:!!c,schema:{type:`detail-view`,objectName:t,resourceId:String(n),data:e,showDelete:!!u,columns:o,fields:m,actions:f?[{type:`action:bar`,location:`record_header`,systemActions:[{name:`sys_open_new_tab`,label:p(`detail.openInNewTab`),icon:`external-link`,type:`script`,onClick:()=>window.open(f,`_blank`,`noopener`)}]}]:void 0},onDelete:u?async()=>{try{await u(),d?.()}catch(e){console.error(`[RecordDetailPanel] delete failed:`,e)}}:void 0}),(0,l.jsx)(br,{onFieldSave:c?async(e,t)=>{try{await c(e,t)}catch(e){throw console.error(`[RecordDetailPanel] inline field save failed:`,e),e}}:void 0})]})}function Tr({open:e,onClose:t,title:n,record:r,objectName:i,recordId:o,dataSource:s,objectSchema:c,width:u=Cr,columns:d=2,systemFields:f=xr,onFieldSave:p,onDelete:m,resizable:h=!0,fullPageHref:g}){return(0,l.jsx)(a.NavigationOverlay,{isOpen:e,isOverlay:!0,mode:`drawer`,selectedRecord:r,close:t,setIsOpen:e=>{e||t()},width:u,title:n,storageKey:h?(0,a.recordOverlayWidthStorageKey)(i):void 0,legacyStorageKey:h?(0,a.legacyRecordDrawerWidthKey)(i):void 0,children:()=>(0,l.jsx)(`div`,{className:`px-6 pt-6 pb-6`,children:(0,l.jsx)(wr,{record:r,objectName:i,recordId:o,dataSource:s,objectSchema:c,columns:d,systemFields:f,onFieldSave:p,onDelete:m,onClose:t,fullPageHref:g})})})}function Er(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))}`}function Dr(e,t){if(!e||!t.length)return[];let n=[...t].sort((e,t)=>t.label.length-e.label.length),r=e,i=new Set;for(let e of n){if(!e.label)continue;let t=e.label.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`),n=RegExp(`@${t}(?![\\p{L}\\p{N}_])`,`gu`);n.test(r)&&(i.add(e.id),r=r.replace(n,e=>` `.repeat(e.length)))}return[...i]}var Or=(0,n.elementDataSourceBlock)(({schema:e,dataSource:t,...n})=>{let i=(0,r.useResolvedDataSource)(t);return(0,l.jsx)(r.ElementDataSourceGate,{schema:e,dataSource:i,testId:`detail-view`,errorTitle:`This detail view’s data source could not be resolved`,requiresDataSource:e?.data==null&&e?.api==null&&typeof e?.objectName==`string`&&e.objectName.length>0,noDataSourceMessage:(0,r.noDataSourceMessage)(`detail-view`,e?.objectName),children:e=>(0,l.jsx)(Z,{schema:e,dataSource:i,...n})})});n.ComponentRegistry.register(`detail-view`,Or,{namespace:`plugin-detail`,label:`Detail View`,category:`Views`,icon:`FileText`,inputs:[{name:`title`,type:`string`},{name:`objectName`,type:`string`},{name:`resourceId`,type:`string`},{name:`api`,type:`string`},{name:`data`,type:`object`},{name:`layout`,type:`enum`,enum:[`vertical`,`horizontal`,`grid`]},{name:`columns`,type:`number`},{name:`sections`,type:`array`},{name:`fields`,type:`array`},{name:`tabs`,type:`array`},{name:`actions`,type:`array`},{name:`showBack`,type:`boolean`},{name:`backUrl`,type:`string`},{name:`showEdit`,type:`boolean`},{name:`editUrl`,type:`string`},{name:`showDelete`,type:`boolean`},{name:`deleteConfirmation`,type:`string`},{name:`loading`,type:`boolean`},{name:`header`,type:`object`},{name:`footer`,type:`object`}],defaultProps:{title:`Detail View`,showBack:!0,showEdit:!1,showDelete:!1,sections:[],fields:[],tabs:[]}}),n.ComponentRegistry.register(`detail-section`,Ge,{namespace:`plugin-detail`,label:`Detail Section`,category:`Detail Components`,inputs:[{name:`title`,type:`string`},{name:`description`,type:`string`},{name:`icon`,type:`string`,description:"Section header icon, drawn before the title: a Lucide icon name such as `map-pin`."},{name:`fields`,type:`array`,required:!0},{name:`collapsible`,type:`boolean`},{name:`defaultCollapsed`,type:`boolean`},{name:`columns`,type:`number`},{name:`showBorder`,type:`boolean`},{name:`headerColor`,type:`enum`,enum:Object.keys(U),description:"Header tint, from the design system's closed palette: one of `muted`, `muted/50`, `accent`, `primary/10`, `secondary/10`, `destructive/10`. Any other value is refused — `@object-ui/types` parses this key as that same six-member enum (objectui#6594), matching @objectstack/spec's strict `record:details` section schema. Omit the key for no tint."},{name:`hideEmpty`,type:`boolean`,description:"When every field in the section is empty, `true` hides the whole section (no heading, no skeleton). Omitted or `false`, an all-empty section keeps its heading and label skeleton. Empty fields in a section that still has a filled one are not governed by this key."}]}),n.ComponentRegistry.register(`detail`,Z,{namespace:`view`,category:`view`,label:`Detail`,icon:`FileText`,inputs:[{name:`objectName`,type:`string`,required:!0},{name:`recordId`,type:`string`},{name:`fields`,type:`array`}]}),n.ComponentRegistry.register(`details`,Tt,{namespace:`record`,skipFallback:!0,category:`record`,label:`Record Details`,icon:`FileText`,inputs:[{name:`columns`,type:`enum`,enum:[`1`,`2`,`3`,`4`],description:`Number of columns for field layout (1-4)`},{name:`sections`,type:`array`,of:`object`,description:"Field groups rendered as the detail body, in order. Every entry is an OBJECT — `{ name?, label?, columns?, fields }` — a bare section-id string is NOT accepted (the spec retired that spelling in objectstack#5611, and the renderer reads name/label/fields off each entry, so a string entry renders no fields at all). `fields` are the field names shown in this section, in order — required unless `group` supplies the members instead (the spec refuses a section carrying neither, and refuses one carrying both). `label` is the section heading; omit it for an untitled, borderless section. `name` is a stable snake_case identifier and the i18n anchor — the heading resolves through objects.<object>._sections.<name>.label, so a section without a name shows its authored label in every locale. `columns` (1-4) is THIS section's field-grid width; omit it and the renderer derives the width. Authoring `sections` at all makes it the only source of the detail body; omit it and the body falls back to the object's highlightFields. @objectstack/spec 17.3.0 declares eight more member keys on an entry, and this renderer honours all eight: `icon` (a Lucide name on the section header), `description` (sub-heading copy under the heading), `collapsible` and `defaultCollapsed` (a foldable section and its initial state), `showBorder` (force the Card wrapper on or off, overriding the heading-derived default) and `headerColor` (a header tint from the shared palette) through DetailSection, plus `group` — the ADR-0085 §5 REFERENCE form, the alternative to enumerating `fields`. `{ group: 'contact_info' }` inherits the object's `fieldGroups` entry with that key: its members (every visible field pointing at it, in declaration order) and its presentation (label, icon, description, collapse) all come from the group, so the section restates none of it and the spec refuses those keys beside `group`; `columns`, `showBorder` and `headerColor` stay yours because they are how THIS page lays the section out. A `group` naming no declared group renders nothing and is reported to the console (`@objectstack/lint` flags it as `page-section-group-unknown`). `hideEmpty` is the eighth, and it decides whether an ALL-empty section exists: it defaults to on, so a section whose fields are every one of them empty renders nothing at all — no heading, no skeleton — and `hideEmpty: false` is the spelling that keeps that heading and its label skeleton on a brand-new record. It decides ONLY the all-empty case; the empty rows of a section that still has a filled one belong to DetailSection's auto-hide heuristic plus the reader's show-empty toggle, which no authored value overrides in either polarity (objectui#7129 Q2-C), and inline-edit mode renders the section either way so its fields stay reachable. Restored under objectui#8603 (maintainer 2026-09-15) after objectui#7129 retired it on the premise, since falsified upstream, that the spec refused the key. None of the eight has a designer control yet; they are authorable in source mode only, tracked as a deferred feature."},{name:`fields`,type:`array`,of:`string`,description:`Explicit field list (overrides highlightFields)`},{name:`hideFields`,type:`array`,of:`string`,description:"Field names to omit from the body — applied to the top-level `fields` list AND to every section's `fields`. Bare field names only. Authors rarely need it: the synth pipeline fills it with the fields already shown in `record:highlights`, and hand-authored pages get the same dedup live from HighlightFieldsContext, so its purpose is suppressing a field you do not want repeated (the page H1 title field is dropped for you too). Hiding every field of a section leaves that section out entirely."},{name:`inlineEdit`,type:`boolean`,description:"Offer the per-field double-click / pencil inline-edit affordances in the detail body. On by default, and an OPT-OUT only: the value is combined with the object's own editability (system, engine-owned, append-only and better-auth objects are not user-editable unless they opened userActions.edit) and with the server's effective API operation set for the object, so `false` always wins while `true` cannot open editing the platform refuses. The edit session and the atomic Save bar are hosted by the page, so one draft spans the highlights strip and this body."},{name:`showHeader`,type:`boolean`,description:"Render the detail body's own title / follow-star / copy-id chip above the fields. Off by default because this block is normally composed under a `page:header` that already draws that chrome, and turning it on there shows the record title twice. Set it true only when this block is the whole page."},{name:`enforceFieldSecurity`,type:`boolean`,description:`Fold this block's field list through the caller's FIELD-read permissions before rendering, so a field the permission set denies leaves no empty row behind (renderer default: off). Presentation only: it re-applies the same field-read answer the server already enforced (ADR-0066 D3) and never widens access — with it off a denied field still arrives masked or stripped, and with it on the server still decides every value.`},{name:`redactFields`,type:`array`,of:`string`,description:"Field names this block never renders, whatever the permission answer (renderer default: render everything authored). Presentation only, evaluated in the browser after the record is fetched — the values are still in the page, so this is NOT a data-access control and NOT the object's `publicSharing.redactFields`, which removes them server-side. To keep a value from the caller, gate the field itself (`requiredPermissions` / `maskingRule`, ADR-0066 D3) or the permission set. Neighbours `hideFields`, which is the dedupe channel the renderer also writes to."},{name:`requiredPermissions`,type:`array`,of:`string`,description:"[ADR-0066] Capabilities the user must ALL hold — names that permission sets grant through `systemPermissions`, not object actions: `read` or `update` here is an ordinary capability name, not the object's read or edit permission. When the client has resolved the user's capabilities and any of these is missing, this block does not render its content; wherever it would otherwise render, an insufficient-permissions notice takes its place. Presentation only: it authorises nothing, and the data API still serves the same data to the same user. A client that cannot resolve the user's capabilities (no permission provider, or one that does not report `systemPermissions`) renders this block as if they were held — it fails open."}]}),n.ComponentRegistry.register(`related_list`,Rt,{namespace:`record`,skipFallback:!0,category:`record`,label:`Related List`,icon:`List`,inputs:[{name:`objectName`,type:`string`,required:!0,description:`Related object name (e.g. "task")`},{name:`relationshipField`,type:`string`,required:!0,description:`Field on the related object pointing back to this record`},{name:`relationshipValueField`,type:`string`,description:'Which field OF THIS PARENT record `relationshipField` stores. Defaults to "id"; set it to the field a name-keyed junction points at (e.g. "name" when sys_user_position.position holds sys_position.name). The resolved value drives three things at once — the list filter, the Add-picker link value, and the pre-filled create form — so they cannot drift apart. While the parent record is still loading, a non-"id" field resolves to null and the list holds its fetch rather than querying on an empty value.'},{name:`columns`,type:`array`,of:`string`,required:!0,description:`Fields to display in the related list`},{name:`sort`,type:`array`},{name:`limit`,type:`number`,description:`Records to display initially`},{name:`filter`,type:`array`,of:`object`,description:"Additional filter criteria, as spec `ViewFilterRule` entries (`[{ field, operator, value }]`). AND-combined with the parent relationship condition, never a replacement for it: it can only narrow this record's children. Also the key a per-element `dataSource` binding's composed filter lands on."},{name:`title`,type:[`string`,`object`],description:'Heading of the list. Defaults to the related object\'s label (its translation when one is loaded, otherwise the humanized object name). Accepts either a plain string or an inline per-locale map (`{ en: "Open tasks", "zh-CN": "未完成任务" }`) — the `I18nLabel` union the contract admits on this key — and the list resolves the map against the active UI language, falling back through base language, a region-qualified sibling, `default`, then `en`, and finally to any remaining entry.'},{name:`showViewAll`,type:`boolean`},{name:`actions`,type:`array`,of:`string`,description:`Action IDs available for related records`},{name:`add`,type:`object`,description:'Adds an "Add" button that assigns EXISTING records instead of creating one — the m2m/junction case. Shape: `{ picker: { object, valueField?, labelField?, filter? }, linkField?, label? }`. `picker.object` (required) is the object whose records the dialog offers. `picker.valueField` is the field of the picked record used as the link value (default "id"); `picker.labelField` is the column shown in the picker rows (default "name", and the other columns are derived from that object\'s schema). With `linkField` set, selecting records CREATES rows in this list\'s own object as `{ [relationshipField]: parentValue, [linkField]: pickedId }` — the junction case; omit `linkField` and the picked child is RE-PARENTED instead, by setting its own `relationshipField` to this parent. `label` is the button text (default "Add", localizable inline). Setting `add` also enables generic link removal on rows when no host delete handler is wired. `picker.filter` restricts which records the dialog offers — a list of `{ field, operator, value }` rules in the same vocabulary as this list\'s own `filter`, applied as a hard constraint the user cannot widen (it never appears as an editable filter row).'},{name:`enforceFieldSecurity`,type:`boolean`,description:"Fold this list's `columns` through the caller's FIELD-read permissions on the RELATED object before rendering (renderer default: off). Presentation only: it re-applies the same field-read answer the server already enforced (ADR-0066 D3) and never widens access — the rows are fetched either way and the server still decides every value."},{name:`redactFields`,type:`array`,of:`string`,description:"Field names this list never renders, whatever the permission answer (renderer default: render every column authored or derived). Applies to the authored `columns` AND to the columns the list derives for itself when none are authored. Presentation only, evaluated in the browser after the rows are fetched — the values are still in the page, so this is NOT a data-access control and NOT the object's `publicSharing.redactFields`, which removes them server-side. To keep a value from the caller, gate the field itself (`requiredPermissions` / `maskingRule`, ADR-0066 D3) or the permission set."},{name:`requiredPermissions`,type:`array`,of:`string`,description:"[ADR-0066] Capabilities the user must ALL hold — names that permission sets grant through `systemPermissions`, not object actions: `read` or `update` here is an ordinary capability name, not the object's read or edit permission. When the client has resolved the user's capabilities and any of these is missing, this block does not render its content; wherever it would otherwise render, an insufficient-permissions notice takes its place. Presentation only: it authorises nothing, and the data API still serves the same data to the same user. A client that cannot resolve the user's capabilities (no permission provider, or one that does not report `systemPermissions`) renders this block as if they were held — it fails open."}]}),n.ComponentRegistry.register(`highlights`,Bt,{namespace:`record`,skipFallback:!0,category:`record`,label:`Highlights Panel`,icon:`Star`,inputs:[{name:`fields`,type:`array`,required:!0,description:`Key fields to highlight (1-7), bare names or {name,label?,type?,readonly?}. Set readonly: true on an entry to render that chip read-only — it suppresses the inline-edit affordance and the HeaderHighlight editability gate enforces it. Use it for hook/automation-maintained columns that must not be hand-edited from the record header; marking the OBJECT field readonly instead would also strip the hook's own write-back.`},{name:`layout`,type:`enum`,enum:[`horizontal`,`vertical`],description:`Layout orientation for highlight fields`},{name:`enforceFieldSecurity`,type:`boolean`,description:`Fold this block's highlight chips through the caller's FIELD-read permissions before rendering, so a field the permission set denies leaves no empty chip behind (renderer default: off). Presentation only: it re-applies the same field-read answer the server already enforced (ADR-0066 D3) and never widens access — the record is fetched either way and the server still decides every value.`},{name:`redactFields`,type:`array`,of:`string`,description:"Field names this block never renders as a chip, whatever the permission answer (renderer default: render every field authored). Presentation only, evaluated in the browser after the record is fetched — the values are still in the page, so this is NOT a data-access control and NOT the object's `publicSharing.redactFields`, which removes them server-side. To keep a value from the caller, gate the field itself (`requiredPermissions` / `maskingRule`, ADR-0066 D3) or the permission set."},{name:`requiredPermissions`,type:`array`,of:`string`,description:"[ADR-0066] Capabilities the user must ALL hold — names that permission sets grant through `systemPermissions`, not object actions: `read` or `update` here is an ordinary capability name, not the object's read or edit permission. When the client has resolved the user's capabilities and any of these is missing, this block does not render its content; wherever it would otherwise render, an insufficient-permissions notice takes its place. Presentation only: it authorises nothing, and the data API still serves the same data to the same user. A client that cannot resolve the user's capabilities (no permission provider, or one that does not report `systemPermissions`) renders this block as if they were held — it fails open."}]}),n.ComponentRegistry.register(`activity`,In,{namespace:`record`,skipFallback:!0,category:`record`,label:`Activity Timeline`,icon:`Activity`,inputs:[{name:`types`,type:`array`,of:`string`,description:`Allow-list of feed item types to show (comment, field_change, task, event, email, call, note, file, record_create, record_delete, approval, sharing, system). Omit for all; unrecognised entries are ignored.`},{name:`filterMode`,type:`enum`,enum:[`all`,`comments_only`,`changes_only`,`tasks_only`],description:`Filter the timeline dropdown starts on. The user can still change it; an unrecognised value falls back to "all".`},{name:`showFilterToggle`,type:`boolean`,description:`Expose the activity-type filter dropdown in the panel header`},{name:`limit`,type:`number`,description:`Items per page. Also caps the scoped sys_activity read; "Load more" grows the window by this much.`},{name:`showCompleted`,type:`boolean`,description:`Include completed activities (sys_activity type "completed", which surfaces as a task item). Off by default.`},{name:`unifiedTimeline`,type:`boolean`,description:`Mix field changes and comments in one timeline (Airtable style). Off keeps the panel a discussion stream — field changes stay in record:history.`},{name:`showCommentInput`,type:`boolean`,description:`Show the composer. Requires a host discussion context to persist the comment (record detail pages provide one); without it the feed is read-only.`},{name:`enableMentions`,type:`boolean`,description:`Offer @-mention autocomplete in the composer, from the host discussion context's user list. Off withholds the suggestions.`},{name:`enableReactions`,type:`boolean`,description:`Show emoji reactions on feed items. Toggling one requires a host discussion context; without it existing reactions still render, read-only.`},{name:`enableThreading`,type:`boolean`,description:`Group replies under their parent comment. Posting a reply requires a host discussion context.`},{name:`showSubscriptionToggle`,type:`boolean`,description:`NOT IMPLEMENTED — no record-subscription backend exists yet, so this renders nothing whatever it is set to. Declared for spec parity only (objectui#3165).`}]});var kr=[{name:`position`,type:`enum`,enum:[`bottom`,`right`,`left`],description:`Where the panel docks relative to the record body`},{name:`width`,type:`string`,description:`Panel width as a CSS value (side positions only)`},{name:`collapsible`,type:`boolean`},{name:`defaultCollapsed`,type:`boolean`},{name:`feed`,type:`object`,description:`Activity-feed configuration nested inside the panel — the same shape as record:activity. The spec declares this key as RecordActivityProps (RecordChatterProps.feed), so its members are the inputs record:activity declares; see that block for what each one does.`}];n.ComponentRegistry.register(`chatter`,zn,{namespace:`record`,skipFallback:!0,category:`record`,label:`Chatter Feed`,icon:`MessageSquare`,inputs:kr}),n.ComponentRegistry.register(`discussion`,zn,{namespace:`record`,skipFallback:!0,category:`record`,label:`Discussion`,icon:`MessageSquare`,inputs:kr}),n.ComponentRegistry.register(`path`,Hn,{namespace:`record`,skipFallback:!0,category:`record`,label:`Path / Stepper`,icon:`GitBranch`,inputs:[{name:`statusField`,type:`string`,required:!0,description:`Field representing the current status/stage`},{name:`stages`,type:`array`,of:`object`,description:`Explicit stage definitions [{ value, label }] (else derived from field metadata)`}]}),n.ComponentRegistry.register(`quick_actions`,qn,{namespace:`record`,skipFallback:!0,category:`record`,label:`Quick Actions`,icon:`Zap`,inputs:[{name:`actionNames`,type:`array`,of:`string`,description:`Action names to expose, in order — resolved from the actions declared on the object. With no names (and no host-supplied actions) nothing is looked up and the bar renders its empty placeholder`},{name:`requiredPermissions`,type:`array`,of:`string`,description:"[ADR-0066] Capabilities the user must ALL hold — names that permission sets grant through `systemPermissions`, not object actions: `read` or `update` here is an ordinary capability name, not the object's read or edit permission. When the client has resolved the user's capabilities and any of these is missing, this block does not render its content; wherever it would otherwise render, an insufficient-permissions notice takes its place. Presentation only: it authorises nothing, and the data API still serves the same data to the same user. A client that cannot resolve the user's capabilities (no permission provider, or one that does not report `systemPermissions`) renders this block as if they were held — it fails open."},{name:`location`,type:`enum`,enum:[...u.ACTION_LOCATIONS],description:`Which declared action location this bar renders`},{name:`align`,type:`enum`,enum:[`start`,`center`,`end`]},{name:`inline`,type:`boolean`,description:`Render in the flow instead of folding into the record header`},{name:`variant`,type:`string`,description:`Passed to the Button primitive; a per-action variant overrides it`},{name:`size`,type:`string`,description:`Passed to the Button primitive; a per-action size overrides it`}]}),n.ComponentRegistry.register(`history`,nr,{namespace:`record`,skipFallback:!0,category:`record`,label:`History Timeline`,icon:`Clock`,inputs:[{name:`limit`,type:`number`,description:`Maximum history entries to display`},{name:`emptyText`,type:`string`,description:`Copy shown when the record has no history`},{name:`unknownUserText`,type:`string`,description:`Copy substituted when an entry has no resolvable actor`}]}),n.ComponentRegistry.register(`reference_rail`,lr,{namespace:`record`,skipFallback:!0,category:`record`,label:`Reference Rail`,icon:`PanelRight`,inputs:[{name:`hideEmpty`,type:`boolean`,description:`Drop the rail entirely when no entries resolve`}]}),n.ComponentRegistry.register(`alert`,fr,{namespace:`record`,skipFallback:!0,category:`record`,label:`Alert Banner`,icon:`triangle-alert`,inputs:[{name:`severity`,type:`enum`,enum:[`info`,`warning`,`error`,`success`]},{name:`title`,type:[`string`,`object`],description:`Accepts an inline translation map ({ en, "zh-CN", … })`},{name:`body`,type:[`string`,`object`],description:`Accepts an inline translation map ({ en, "zh-CN", … })`},{name:`visible`,type:[`boolean`,`string`,`object`],description:"Gates the banner against the current record: `true`/`false`, a bare CEL expression, or the `{ dialect: 'cel', source }` envelope"},{name:`icon`,type:`string`,description:`Lucide icon name; defaults to the severity icon`},{name:`action`,type:`object`,description:`{ actionName, label?, variant? } — the action the banner offers`},{name:`dismissible`,type:`boolean`},{name:`dismissKey`,type:`string`,description:`Stable key the dismissal is remembered under`}]}),n.ComponentRegistry.register(`permission-facet-link`,(0,i.withFieldCarrier)(A),{namespace:`field`,skipFallback:!0}),e.ACTIVITY_TYPE_TO_FEED_TYPE=ln,e.ActivityTimeline=ve,e.CommentAttachment=Qt,e.ConcurrentUpdateDialog=hr,e.DEFAULT_SYSTEM_FIELDS=xr,e.DETAIL_DEFAULT_TRANSLATIONS=E,e.DetailSection=ce,e.DetailTabs=le,e.DetailView=Z,e.DetailViewRenderer=Or,e.FieldChangeItem=Vt,e.HeaderHighlight=de,e.HistoryTimeline=Te,e.InlineEditSaveBar=br,e.InlineFieldInput=ie,e.RECORD_OVERLAY_DEFAULT_WIDTH=Cr,e.ReactionPicker=Ut,e.RecordActivityRenderer=In,e.RecordActivityTimeline=on,e.RecordAlertRenderer=fr,e.RecordChatterPanel=Ln,e.RecordChatterRenderer=zn,e.RecordComments=fe,e.RecordDetailDrawer=Tr,e.RecordDetailPanel=wr,e.RecordDetailsRenderer=Tt,e.RecordHighlightsRenderer=Bt,e.RecordHistoryRenderer=nr,e.RecordMetaFooter=Ae,e.RecordPathRenderer=Hn,e.RecordQuickActionsRenderer=qn,e.RecordReferenceRailRenderer=lr,e.RecordRelatedListRenderer=Rt,e.RelatedList=rt,e.RichTextCommentInput=Jt,e.SectionGroup=ue,e.SubscriptionToggle=Kt,e.TEXTUAL_REF_FALLBACK_TYPES=M,e.ThreadedReplies=Gt,e.UNMAPPED_ACTIVITY_FEED_TYPE=un,e.__clearRecordEditableCache=Ie,e.activityRowToFeedItem=An,e.applyAutoSpan=C,e.applyDetailAutoLayout=w,e.buildDefaultActions=ct,e.buildDefaultDetails=ft,e.buildDefaultDiscussion=mt,e.buildDefaultHeader=st,e.buildDefaultHighlights=lt,e.buildDefaultPageSchema=gt,e.buildDefaultTabs=pt,e.buildRecordDetailFields=Sr,e.createSafeTranslationHook=T,e.deriveFieldGroupDetailSections=ut,e.deriveHighlightFields=ot,e.deriveRecordPageHref=Er,e.deriveStages=it,e.detectStatusField=u.detectStatusField,e.extractLookupId=re,e.extractMentions=Dr,e.inferDetailColumns=S,e.isConcurrentUpdateError=gr,e.isRefusedFeedRead=Nn,e.isWideFieldType=x,e.resetUnknownActivityTypeWarnings=kn,e.resolveDetailSections=dt,e.resolveTitleField=at,e.useDetailTranslation=D,e.useRecordEditable=Fe});
|