@object-ui/plugin-detail 4.0.7 → 4.0.9
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 +4 -0
- package/dist/index.js +1490 -1195
- package/dist/index.umd.cjs +3 -3
- package/dist/packages/plugin-detail/src/DetailSection.d.ts.map +1 -1
- package/dist/packages/plugin-detail/src/DetailView.d.ts.map +1 -1
- package/dist/packages/plugin-detail/src/HeaderHighlight.d.ts.map +1 -1
- package/dist/packages/plugin-detail/src/RecordDetailDrawer.d.ts +83 -0
- package/dist/packages/plugin-detail/src/RecordDetailDrawer.d.ts.map +1 -0
- package/dist/packages/plugin-detail/src/RelatedList.d.ts +4 -0
- package/dist/packages/plugin-detail/src/RelatedList.d.ts.map +1 -1
- package/dist/packages/plugin-detail/src/index.d.ts +2 -0
- package/dist/packages/plugin-detail/src/index.d.ts.map +1 -1
- package/dist/packages/plugin-detail/src/useDetailTranslation.d.ts.map +1 -1
- package/package.json +13 -13
package/dist/index.umd.cjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
(function(e,t){typeof exports==`object`&&typeof module<`u`?t(exports,require(`@object-ui/core`),require(`react`),require(`@object-ui/components`),require(`lucide-react`),require(`@object-ui/react`),require(`@object-ui/fields`),require(`react/jsx-runtime`)):typeof define==`function`&&define.amd?define([`exports`,`@object-ui/core`,`react`,`@object-ui/components`,`lucide-react`,`@object-ui/react`,`@object-ui/fields`,`react/jsx-runtime`],t):(e=typeof globalThis<`u`?globalThis:e||self,t(e.ObjectUIPluginDetail={},e.ObjectUICore,e.React,e.ObjectUIComponents,e.LucideReact,e.ObjectUIReact,e.ObjectUIFields,e.jsxRuntime))})(this,function(e,t,n,r,i,a,o,s){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var c=Object.create,l=Object.defineProperty,u=Object.getOwnPropertyDescriptor,d=Object.getOwnPropertyNames,f=Object.getPrototypeOf,p=Object.prototype.hasOwnProperty,m=(e,t,n,r)=>{if(t&&typeof t==`object`||typeof t==`function`)for(var i=d(t),a=0,o=i.length,s;a<o;a++)s=i[a],!p.call(e,s)&&s!==n&&l(e,s,{get:(e=>t[e]).bind(null,s),enumerable:!(r=u(t,s))||r.enumerable});return e};n=((e,t,n)=>(n=e==null?{}:c(f(e)),m(t||!e||!e.__esModule?l(n,`default`,{value:e,enumerable:!0}):n,e)))(n,1);var h=new Set([`textarea`,`markdown`,`html`,`grid`,`rich-text`,`field:textarea`,`field:markdown`,`field:html`,`field:grid`,`field:rich-text`]);function g(e){return h.has(e)}function _(e,t){let n;if(n=e<=3?1:e<=10?2:3,t!==void 0){if(t<640)return Math.min(n,1);if(t<900)return Math.min(n,2)}return n}function v(e,t){return t<=1?e:e.map(e=>e.span===void 0&&e.type&&g(e.type)?{...e,span:t}:e)}function y(e,t,n){if(t!==void 0)return{fields:v(e,t),columns:t};let r=_(e.length,n);return{fields:v(e,r),columns:r}}function b(e,t){return function(){try{let n=(0,a.useObjectTranslation)();return n.t(t)===t?{t:(t,n)=>{let r=e[t]||t;if(n)for(let[e,t]of Object.entries(n))r=r.replace(`{{${e}}}`,String(t));return r}}:{t:n.t}}catch{return{t:(t,n)=>{let r=e[t]||t;if(n)for(let[e,t]of Object.entries(n))r=r.replace(`{{${e}}}`,String(t));return r}}}}}var x={"detail.back":`Back`,"detail.edit":`Edit`,"detail.editInline":`Edit inline`,"detail.save":`Save`,"detail.saveChanges":`Save changes`,"detail.editFieldsInline":`Edit fields inline`,"detail.share":`Share`,"detail.duplicate":`Duplicate`,"detail.export":`Export`,"detail.viewHistory":`View history`,"detail.delete":`Delete`,"detail.moreActions":`More actions`,"detail.addToFavorites":`Add to favorites`,"detail.removeFromFavorites":`Remove from favorites`,"detail.previousRecord":`Previous record`,"detail.nextRecord":`Next record`,"detail.recordOf":`{{current}} of {{total}}`,"detail.recordNotFound":`Record not found`,"detail.recordNotFoundDescription":`The record you are looking for does not exist or may have been deleted.`,"detail.goBack":`Go back`,"detail.details":`Details`,"detail.related":`Related`,"detail.relatedRecords":`{{count}} records`,"detail.relatedRecordOne":`{{count}} record`,"detail.noRelatedRecords":`No related records found`,"detail.loading":`Loading...`,"detail.copyToClipboard":`Copy to clipboard`,"detail.copied":`Copied!`,"detail.deleteConfirmation":`Are you sure you want to delete this record?`,"detail.editRecord":`Edit record`,"detail.viewAll":`View All`,"detail.new":`New`,"detail.emptyValue":`—`,"detail.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.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.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.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.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`},S=b(x,`detail.back`);function C(e,t){return!e||e<=1||t<=1?``:t===2?e>=2?`md:col-span-2`:``:e===2?`md:col-span-2`:e>=3?`md:col-span-2 lg:col-span-3`:``}var w=({section:e,data:t,className:c,objectSchema:l,objectName:u,isEditing:d=!1,onFieldChange:f,virtualScroll:p})=>{let[m,h]=n.useState(e.defaultCollapsed??!1),[g,_]=n.useState(null),[v,b]=n.useState(void 0),[x,w]=n.useState(!1),{t:T}=S(),{fieldLabel:E}=(0,a.useSafeFieldLabel)(),D=n.useCallback((e,t)=>{let n=t==null?``:String(t);navigator.clipboard.writeText(n).then(()=>{_(e),setTimeout(()=>_(null),2e3)})},[]),O=n.useCallback(e=>{let n=t?.[e.name]??e.value;return n==null||n===``},[t]),k=n.useMemo(()=>e.fields.filter(O).length,[e.fields,O]),A=(0,r.useIsMobile)(),j=A?3:6,M=A?.2:.5,N=e.fields.length-k,P=!e.hideEmpty&&!d&&e.fields.length>=j&&k/e.fields.length>=M&&N>0,F=!x&&(e.hideEmpty||P)?e.fields.filter(e=>!O(e)):e.fields;if(F.length===0&&k===e.fields.length)return null;let{fields:I,columns:L}=y(F,e.columns),R=e=>{let n=t?.[e.name]??e.value;if(e.render)return(0,s.jsx)(a.SchemaRenderer,{schema:e.render,data:{...t,value:n}});let c=C(e.span,L),p=(()=>{if(n==null)return(0,s.jsx)(`span`,{className:`text-muted-foreground/50 text-xs italic`,children:`—`});let t=l?.fields?.[e.name],r=e.type||t?.type,i={...e};if(t){!e.type&&t.type&&(i.type=t.type),t.options&&!i.options&&(i.options=t.options),t.currency&&!i.currency&&(i.currency=t.currency),t.precision!==void 0&&i.precision===void 0&&(i.precision=t.precision),t.format&&!i.format&&(i.format=t.format);let n=t.reference_to||t.reference;n&&!i.reference_to&&(i.reference_to=n),t.reference_field&&!i.reference_field&&(i.reference_field=t.reference_field)}if(r){let e=(0,o.getCellRenderer)(r);if(e)return(0,s.jsx)(e,{value:n,field:i})}return String(n)})(),m=n!=null&&n!==``,h=g===e.name;return(0,s.jsxs)(`div`,{className:(0,r.cn)(`space-y-1.5 group`,c),children:[(0,s.jsx)(`div`,{className:`text-xs font-medium text-muted-foreground uppercase tracking-wide`,children:E(u||``,e.name,e.label||e.name)}),d&&!e.readonly?(0,s.jsx)(`div`,{className:`min-h-[44px] sm:min-h-0`,children:(0,s.jsx)(`input`,{type:e.type===`number`?`number`:e.type===`date`?`date`:`text`,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:n==null?``:String(n),onChange:t=>f?.(e.name,t.target.value)})}):(0,s.jsxs)(`div`,{className:(0,r.cn)(`flex items-start justify-between gap-2 min-h-[44px] sm:min-h-0 rounded-md`,m&&`cursor-pointer active:bg-muted/60 transition-colors`),onClick:m?()=>D(e.name,n):void 0,onKeyDown:m?t=>{(t.key===`Enter`||t.key===` `)&&(t.preventDefault(),D(e.name,n))}:void 0,role:m?`button`:void 0,tabIndex:m?0:void 0,children:[(0,s.jsx)(`div`,{className:`text-sm flex-1 break-words py-1`,children:p}),m&&(0,s.jsx)(r.TooltipProvider,{children:(0,s.jsxs)(r.Tooltip,{children:[(0,s.jsx)(r.TooltipTrigger,{asChild:!0,children:(0,s.jsx)(r.Button,{variant:`ghost`,size:`icon`,className:`h-6 w-6 opacity-0 group-hover:opacity-100 transition-opacity shrink-0`,onClick:t=>{t.stopPropagation(),D(e.name,n)},children:h?(0,s.jsx)(i.Check,{className:`h-3 w-3 text-green-600`}):(0,s.jsx)(i.Copy,{className:`h-3 w-3`})})}),(0,s.jsx)(r.TooltipContent,{children:T(h?`detail.copied`:`detail.copyToClipboard`)})]})})]})]},e.name)},z=p?.enabled===!0,B=p?.batchSize??20;n.useEffect(()=>{if(!z){b(void 0);return}if(I.length<=B){b(void 0);return}b(B);let e=setTimeout(()=>b(void 0),100);return()=>clearTimeout(e)},[z,I.length,B]);let ee=v===void 0?I:I.slice(0,v),V=k>0&&(e.hideEmpty||P),H=(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(`div`,{className:(0,r.cn)(`grid gap-3 sm:gap-4`,L===1?`grid-cols-1`:L===2?`grid-cols-1 md:grid-cols-2`:`grid-cols-1 md:grid-cols-2 lg:grid-cols-3`),children:ee.map(R)}),V&&(0,s.jsx)(`div`,{className:`mt-3 -ml-2`,children:(0,s.jsxs)(r.Button,{type:`button`,variant:`ghost`,size:`sm`,onClick:()=>w(e=>!e),className:`h-7 px-2 text-xs text-muted-foreground hover:text-foreground`,children:[x?(0,s.jsx)(i.EyeOff,{className:`h-3.5 w-3.5 mr-1.5`}):(0,s.jsx)(i.Eye,{className:`h-3.5 w-3.5 mr-1.5`}),x?T(`detail.hideEmptyFields`,{defaultValue:`Hide empty fields`}):T(`detail.showEmptyFields`,{count:k,defaultValue:`Show ${k} empty field${k===1?``:`s`}`})]})})]});return!e.title&&!e.collapsible&&e.showBorder===!1?(0,s.jsx)(`div`,{className:(0,r.cn)(c),children:H}):e.collapsible?(0,s.jsx)(r.Collapsible,{open:!m,onOpenChange:e=>h(!e),className:c,children:(0,s.jsxs)(r.Card,{children:[(0,s.jsx)(r.CollapsibleTrigger,{asChild:!0,children:(0,s.jsxs)(r.CardHeader,{className:(0,r.cn)(`cursor-pointer hover:bg-muted/50 transition-colors`,e.headerColor&&`bg-${e.headerColor}`),children:[(0,s.jsxs)(r.CardTitle,{className:`flex items-center justify-between`,children:[(0,s.jsxs)(`div`,{className:`flex items-center gap-2`,children:[e.icon&&(0,s.jsx)(`span`,{className:`text-muted-foreground`,children:e.icon}),(0,s.jsx)(`span`,{children:e.title}),e.fields&&(0,s.jsx)(r.Badge,{variant:`secondary`,className:`ml-2 text-xs`,children:e.fields.length})]}),(0,s.jsx)(`div`,{className:`flex items-center gap-2`,children:m?(0,s.jsx)(i.ChevronRight,{className:`h-4 w-4 text-muted-foreground`}):(0,s.jsx)(i.ChevronDown,{className:`h-4 w-4 text-muted-foreground`})})]}),e.description&&!m&&(0,s.jsx)(`p`,{className:`text-sm text-muted-foreground mt-1.5`,children:e.description})]})}),(0,s.jsx)(r.CollapsibleContent,{children:(0,s.jsx)(r.CardContent,{className:`pt-4 sm:pt-6 px-3 sm:px-6`,children:H})})]})}):(0,s.jsxs)(r.Card,{className:(0,r.cn)(e.showBorder===!1?`border-none shadow-none`:``,c),children:[e.title&&(0,s.jsxs)(r.CardHeader,{className:(0,r.cn)(e.headerColor&&`bg-${e.headerColor}`),children:[(0,s.jsx)(r.CardTitle,{className:`flex items-center justify-between`,children:(0,s.jsxs)(`div`,{className:`flex items-center gap-2`,children:[e.icon&&(0,s.jsx)(`span`,{className:`text-muted-foreground`,children:e.icon}),(0,s.jsx)(`span`,{children:e.title})]})}),e.description&&(0,s.jsx)(`p`,{className:`text-sm text-muted-foreground mt-1.5`,children:e.description})]}),(0,s.jsx)(r.CardContent,{className:`pt-4 sm:pt-6 px-3 sm:px-6`,children:H})]})},T=({tabs:e,data:t,className:i})=>{let[o,c]=n.useState(e[0]?.key),l=e.filter(e=>typeof e.visible==`boolean`?e.visible:(e.visible,!0));return(0,s.jsxs)(r.Tabs,{value:o,onValueChange:c,className:i,children:[(0,s.jsx)(r.TabsList,{className:`w-full justify-start border-b rounded-none bg-transparent p-0`,children:l.map(e=>(0,s.jsx)(r.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,s.jsxs)(`div`,{className:`flex items-center gap-2`,children:[e.icon&&(0,s.jsx)(`span`,{children:e.icon}),(0,s.jsx)(`span`,{children:e.label}),e.badge&&(0,s.jsx)(r.Badge,{variant:`secondary`,className:`ml-1`,children:e.badge})]})},e.key))}),l.map(e=>(0,s.jsx)(r.TabsContent,{value:e.key,className:`mt-4`,children:(0,s.jsx)(n.Suspense,{fallback:null,children:Array.isArray(e.content)?(0,s.jsx)(`div`,{className:`space-y-4`,children:e.content.map((e,n)=>(0,s.jsx)(a.SchemaRenderer,{schema:e,data:t},n))}):(0,s.jsx)(a.SchemaRenderer,{schema:e.content,data:t})})},e.key))]})};function E(e){return e&&i.icons[e.split(/[-_\s]/).filter(Boolean).map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(``)]||i.Inbox}var D=({title:e,type:t,api:c,data:l=[],schema:u,columns:d,className:f,dataSource:p,objectName:m,onNew:h,onViewAll:g,onRowEdit:_,onRowDelete:v,pageSize:y,sortable:b=!1,filterable:x=!1,collapsible:C=!1,defaultCollapsed:w=!1,referenceField:T,icon:D})=>{let[O,k]=n.useState(l),[A,j]=n.useState(!1),[M,N]=n.useState(0),[P,F]=n.useState(null),[I,L]=n.useState(`asc`),[R,z]=n.useState(``),[B,ee]=n.useState(null),[V,H]=n.useState(w),{t:U}=S(),{fieldLabel:te}=(0,a.useSafeFieldLabel)();n.useEffect(()=>{k(l)},[l]),n.useEffect(()=>{c&&p?.getObjectSchema&&!d?.length&&p.getObjectSchema(c).then(ee).catch(e=>{console.warn(`[RelatedList] Failed to fetch schema for ${c}:`,e)})},[c,p,d]),n.useEffect(()=>{c&&!l.length&&(j(!0),p&&typeof p.find==`function`?p.find(c).then(e=>{k(Array.isArray(e)?e:Array.isArray(e?.data)?e.data:[]),j(!1)}).catch(e=>{console.error(`Failed to fetch related data:`,e),j(!1)}):fetch(c).then(e=>e.json()).then(e=>{k(Array.isArray(e)?e:e?.data||[])}).catch(e=>{console.error(`Failed to fetch related data:`,e)}).finally(()=>j(!1)))},[c,l,p]);let W=n.useMemo(()=>{if(!R)return O;let e=R.toLowerCase();return O.filter(t=>Object.values(t).some(t=>t!=null&&String(t).toLowerCase().includes(e)))},[O,R]),G=n.useMemo(()=>P?[...W].sort((e,t)=>{let n=e[P],r=t[P];if(n==null&&r==null)return 0;if(n==null)return 1;if(r==null)return-1;let i=String(n).localeCompare(String(r),void 0,{numeric:!0});return I===`asc`?i:-i}):W,[W,P,I]),K=y&&y>0?y:0,q=K?Math.max(1,Math.ceil(G.length/K)):1,J=K?G.slice(M*K,(M+1)*K):G;n.useEffect(()=>{N(0)},[R,P,I]);let Y=n.useCallback(e=>{P===e?L(e=>e===`asc`?`desc`:`asc`):(F(e),L(`asc`))},[P]),X=n.useCallback(e=>{window.confirm(U(`detail.deleteRowConfirmation`))&&v?.(e)},[v,U]),Z=n.useMemo(()=>{let e=e=>T?e.filter(e=>(e?.accessorKey||e?.field||e?.name)!==T):e;if(d&&d.length>0)return e(d);if(!B?.fields)return[];let t=m||c||``;return Object.entries(B.fields).filter(([e])=>!e.startsWith(`_`)&&e!==`id`&&e!==T).map(([e,r])=>{let i={accessorKey:e,header:te(t,e,r.label||e)};if(r.type){let t=(0,o.getCellRenderer)(r.type);if(t){let a={name:e,label:r.label||e,type:r.type,...r.options&&{options:r.options},...r.currency&&{currency:r.currency},...r.precision!==void 0&&{precision:r.precision},...r.format&&{format:r.format},...(r.reference_to||r.reference)&&{reference_to:r.reference_to||r.reference},...r.reference_field&&{reference_field:r.reference_field}};i.cell=e=>e==null?n.createElement(`span`,{className:`text-muted-foreground/50 text-xs italic`},`—`):n.createElement(t,{value:e,field:a})}}return i})},[d,B,m,c,te,T]),Q=n.useMemo(()=>{if(u)return u;switch(t){case`grid`:case`table`:return{type:`data-table`,data:J,columns:Z,pagination:!1,pageSize:K||10,searchable:!1,exportable:!1};case`list`:return{type:`data-list`,data:J};default:return{type:`div`,children:`No view configured`}}},[t,J,Z,u,K]),$=!!_||!!v,ne=C?`cursor-pointer select-none`:void 0,re=C?()=>H(e=>!e):void 0,ie=E(D),ae=!A&&O.length===0,oe=x;return(0,s.jsxs)(r.Card,{className:(0,r.cn)(`shadow-none`,ae&&`bg-muted/20`,f),children:[(0,s.jsx)(r.CardHeader,{className:(0,r.cn)(`py-3 px-4`,ne),onClick:re,children:(0,s.jsxs)(r.CardTitle,{className:`flex items-center justify-between gap-2 text-sm font-semibold`,children:[(0,s.jsxs)(`div`,{className:`flex items-center gap-2 min-w-0`,children:[C&&(V?(0,s.jsx)(i.ChevronRight,{className:`h-3.5 w-3.5 text-muted-foreground shrink-0`}):(0,s.jsx)(i.ChevronDown,{className:`h-3.5 w-3.5 text-muted-foreground shrink-0`})),(0,s.jsx)(ie,{className:`h-4 w-4 text-muted-foreground shrink-0`,"aria-hidden":!0}),(0,s.jsx)(`span`,{className:`truncate`,children:e}),(0,s.jsx)(r.Badge,{variant:`secondary`,className:(0,r.cn)(`text-xs font-normal h-5 px-1.5`,O.length===0&&`bg-muted text-muted-foreground`),"aria-label":`${O.length} records`,children:O.length})]}),(0,s.jsxs)(`div`,{className:`flex items-center gap-1 shrink-0`,children:[h&&(0,s.jsxs)(r.Button,{variant:`ghost`,size:`sm`,onClick:e=>{e.stopPropagation(),h()},className:`gap-1 h-7 text-xs`,children:[(0,s.jsx)(i.Plus,{className:`h-3.5 w-3.5`}),U(`detail.new`)]}),g&&(0,s.jsxs)(r.Button,{variant:`ghost`,size:`sm`,onClick:e=>{e.stopPropagation(),g()},className:`gap-1 h-7 text-xs`,children:[U(`detail.viewAll`),(0,s.jsx)(i.ExternalLink,{className:`h-3 w-3`})]})]})]})}),!V&&(0,s.jsxs)(r.CardContent,{className:(0,r.cn)(`pt-0`,ae?`pb-3 px-4`:`pb-4 px-4`),children:[oe&&(0,s.jsx)(`div`,{className:`mb-3`,children:(0,s.jsx)(r.Input,{placeholder:U(`detail.filterPlaceholder`),value:R,onChange:e=>z(e.target.value),className:`h-8 text-sm`})}),b&&Z&&Z.length>0&&O.length>0&&(0,s.jsx)(`div`,{className:`flex flex-wrap gap-1 mb-3`,children:Z.map(e=>{let t=e.accessorKey||e.field||e.name;if(!t)return null;let n=e.header||e.label||t,a=P===t;return(0,s.jsxs)(r.Button,{variant:a?`secondary`:`ghost`,size:`sm`,className:`gap-1 h-7 text-xs`,onClick:()=>Y(t),children:[(0,s.jsx)(i.ArrowUpDown,{className:`h-3 w-3`}),n,a&&(I===`asc`?` ↑`:` ↓`)]},t)})}),A?(0,s.jsx)(`div`,{className:`flex items-center justify-center py-6 text-muted-foreground text-sm`,children:U(`detail.loading`)}):ae?(0,s.jsxs)(`div`,{className:`flex items-center justify-between gap-2 py-2 text-sm`,children:[(0,s.jsx)(`span`,{className:`text-muted-foreground italic`,children:U(`detail.noRelatedRecords`)}),h===void 0&&(0,s.jsx)(`span`,{className:`text-xs text-muted-foreground/70`})]}):(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(a.SchemaRenderer,{schema:Q}),$&&J.length>0&&(0,s.jsx)(`div`,{className:`mt-2 space-y-1`,"data-testid":`row-actions`,children:J.map((e,t)=>(0,s.jsxs)(`div`,{className:`flex items-center justify-between px-2 py-1 text-xs border-b last:border-b-0`,children:[(0,s.jsx)(`span`,{className:`truncate text-muted-foreground`,children:e.name||e.title||e.id||`Row ${t+1}`}),(0,s.jsxs)(`div`,{className:`flex items-center gap-1`,children:[_&&(0,s.jsxs)(r.Button,{variant:`ghost`,size:`sm`,className:`h-6 text-xs gap-1 px-2`,onClick:()=>_(e),children:[(0,s.jsx)(i.Edit,{className:`h-3 w-3`}),U(`detail.editRow`)]}),v&&(0,s.jsxs)(r.Button,{variant:`ghost`,size:`sm`,className:`h-6 text-xs gap-1 px-2 text-destructive hover:text-destructive`,onClick:()=>X(e),children:[(0,s.jsx)(i.Trash2,{className:`h-3 w-3`}),U(`detail.deleteRow`)]})]})]},e.id||t))})]}),K>0&&G.length>K&&(0,s.jsxs)(`div`,{className:`flex items-center justify-between mt-3 pt-3 border-t`,children:[(0,s.jsxs)(r.Button,{variant:`outline`,size:`sm`,className:`h-7 text-xs gap-1`,disabled:M===0,onClick:()=>N(e=>Math.max(0,e-1)),children:[(0,s.jsx)(i.ChevronLeft,{className:`h-3 w-3`}),U(`detail.previousPage`)]}),(0,s.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:U(`detail.pageOf`,{current:M+1,total:q})}),(0,s.jsxs)(r.Button,{variant:`outline`,size:`sm`,className:`h-7 text-xs gap-1`,disabled:M>=q-1,onClick:()=>N(e=>Math.min(q-1,e+1)),children:[U(`detail.nextPage`),(0,s.jsx)(i.ChevronRight,{className:`h-3 w-3`})]})]})]})]})},O=({group:e,data:t,className:a,objectSchema:o,objectName:c,isEditing:l=!1,onFieldChange:u})=>{let d=e.collapsible??!0,[f,p]=n.useState(e.defaultCollapsed??!1),m=(0,s.jsx)(`div`,{className:`space-y-3 sm:space-y-4`,children:e.sections.map((e,n)=>(0,s.jsx)(w,{section:e,data:t,objectSchema:o,objectName:c,isEditing:l,onFieldChange:u},n))});return d?(0,s.jsxs)(r.Collapsible,{open:!f,onOpenChange:e=>p(!e),className:a,children:[(0,s.jsx)(r.CollapsibleTrigger,{asChild:!0,children:(0,s.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:[f?(0,s.jsx)(i.ChevronRight,{className:`h-4 w-4 text-muted-foreground shrink-0`}):(0,s.jsx)(i.ChevronDown,{className:`h-4 w-4 text-muted-foreground shrink-0`}),e.icon&&(0,s.jsx)(`span`,{className:`text-muted-foreground`,children:e.icon}),(0,s.jsx)(`h3`,{className:`text-lg font-semibold`,children:e.title})]})}),e.description&&!f&&(0,s.jsx)(`p`,{className:`text-sm text-muted-foreground mt-1`,children:e.description}),(0,s.jsx)(r.CollapsibleContent,{children:(0,s.jsx)(`div`,{className:`mt-3`,children:m})})]}):(0,s.jsxs)(`div`,{className:(0,r.cn)(`space-y-3`,a),children:[(0,s.jsxs)(`div`,{className:`flex items-center gap-2 pb-2 border-b`,children:[e.icon&&(0,s.jsx)(`span`,{className:`text-muted-foreground`,children:e.icon}),(0,s.jsx)(`h3`,{className:`text-lg font-semibold`,children:e.title})]}),e.description&&(0,s.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:e.description}),m]})},k=({fields:e,data:t,className:n,objectName:i,objectSchema:c})=>{let{fieldLabel:l}=(0,a.useSafeFieldLabel)();if(!e.length||!t)return null;let u=e.filter(e=>{let n=t?.[e.name];return n!=null&&n!==``});return u.length===0?null:(0,s.jsx)(r.Card,{className:(0,r.cn)(`bg-muted/30 border-dashed`,n),children:(0,s.jsx)(r.CardContent,{className:`py-3 px-4`,children:(0,s.jsx)(`div`,{className:(0,r.cn)(`grid gap-4`,u.length===1?`grid-cols-1`:u.length===2?`grid-cols-2`:u.length===3?`grid-cols-3`:`grid-cols-2 md:grid-cols-4`),children:u.map(e=>{let n=t[e.name],r=c?.fields?.[e.name],a=e.type||r?.type,u={name:e.name,label:e.label,type:a||`text`,...r?.options&&{options:r.options},...r?.currency&&{currency:r.currency},...r?.precision!==void 0&&{precision:r.precision},...r?.format&&{format:r.format}},d=(0,o.getCellRenderer)(a||`text`);return(0,s.jsxs)(`div`,{className:`flex flex-col gap-0.5`,children:[(0,s.jsxs)(`span`,{className:`text-xs font-medium text-muted-foreground uppercase tracking-wide`,children:[e.icon&&(0,s.jsx)(`span`,{className:`mr-1`,children:e.icon}),l(i||``,e.name,e.label)]}),(0,s.jsx)(`span`,{className:`text-sm font-semibold truncate`,children:(0,s.jsx)(d,{value:n,field:u})})]},e.name)})})})})};function A(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 j=({comments:e,onAddComment:t,onTogglePin:a,searchable:o=!1,className:c})=>{let{t:l}=S(),[u,d]=n.useState(``),[f,p]=n.useState(!1),[m,h]=n.useState(``),g=n.useCallback(async()=>{let e=u.trim();if(!(!e||!t)){p(!0);try{await t(e),d(``)}finally{p(!1)}}},[u,t]),_=n.useCallback(e=>{e.key===`Enter`&&(e.ctrlKey||e.metaKey)&&(e.preventDefault(),g())},[g]),v=n.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,s.jsxs)(r.Card,{className:(0,r.cn)(``,c),children:[(0,s.jsx)(r.CardHeader,{children:(0,s.jsxs)(r.CardTitle,{className:`flex items-center gap-2 text-base`,children:[(0,s.jsx)(i.MessageSquare,{className:`h-4 w-4`}),l(`detail.comments`),(0,s.jsxs)(`span`,{className:`text-sm font-normal text-muted-foreground`,children:[`(`,e.length,`)`]})]})}),(0,s.jsxs)(r.CardContent,{className:`space-y-4`,children:[o&&(0,s.jsx)(`div`,{className:`flex items-center gap-2`,children:(0,s.jsxs)(`div`,{className:`relative flex-1`,children:[(0,s.jsx)(i.Search,{className:`absolute left-2.5 top-1/2 -translate-y-1/2 h-3.5 w-3.5 text-muted-foreground`}),(0,s.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:l(`detail.searchComments`),value:m,onChange:e=>h(e.target.value),"aria-label":l(`detail.searchComments`)}),m&&(0,s.jsx)(`button`,{className:`absolute right-2 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground`,onClick:()=>h(``),"aria-label":l(`detail.clearSearch`),type:`button`,children:(0,s.jsx)(i.X,{className:`h-3.5 w-3.5`})})]})}),t&&(0,s.jsxs)(`div`,{className:`flex gap-2`,children:[(0,s.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:l(`detail.addCommentPlaceholder`),value:u,onChange:e=>d(e.target.value),onKeyDown:_,disabled:f}),(0,s.jsx)(r.Button,{size:`icon`,variant:`default`,onClick:g,disabled:!u.trim()||f,className:`shrink-0 self-end`,children:(0,s.jsx)(i.Send,{className:`h-4 w-4`})})]}),v.length===0?(0,s.jsx)(`p`,{className:`text-sm text-muted-foreground text-center py-4`,children:m.trim()?l(`detail.noMatchingComments`):l(`detail.noCommentsYet`)}):(0,s.jsx)(`div`,{className:`space-y-3`,children:v.map(e=>(0,s.jsxs)(`div`,{className:(0,r.cn)(`flex gap-3`,e.pinned&&`bg-muted/40 rounded-md p-2 -mx-2`),children:[(0,s.jsx)(`div`,{className:`shrink-0`,children:e.avatarUrl?(0,s.jsx)(`img`,{src:e.avatarUrl,alt:e.author,className:`h-8 w-8 rounded-full object-cover`}):(0,s.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,s.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,s.jsxs)(`div`,{className:`flex items-center gap-2 mb-0.5`,children:[(0,s.jsx)(`span`,{className:`text-sm font-medium truncate`,children:e.author}),(0,s.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:A(e.createdAt)}),e.pinned&&(0,s.jsxs)(`span`,{className:`text-xs text-amber-600 flex items-center gap-0.5`,children:[(0,s.jsx)(i.Pin,{className:`h-3 w-3`}),l(`detail.pinned`)]})]}),(0,s.jsx)(`p`,{className:`text-sm whitespace-pre-wrap break-words`,children:e.text}),a&&(0,s.jsxs)(`button`,{type:`button`,className:`mt-1 text-xs text-muted-foreground hover:text-foreground flex items-center gap-1`,onClick:()=>a(e.id),"aria-label":e.pinned?l(`detail.unpin`):l(`detail.pin`),children:[(0,s.jsx)(i.Pin,{className:`h-3 w-3`}),e.pinned?l(`detail.unpin`):l(`detail.pin`)]})]})]},e.id))})]})]})},M={field_change:i.Edit,create:i.PlusCircle,delete:i.Trash2,comment:i.MessageSquare,status_change:i.ArrowRightLeft},N={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 P(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 F(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 I={all:`All`,field_change:`Field Changes`,create:`Creates`,delete:`Deletes`,comment:`Comments`,status_change:`Status Changes`},L=({activities:e,filterable:t=!1,defaultFilter:a=`all`,className:o})=>{let[c,l]=n.useState(a),u=n.useMemo(()=>c===`all`?e:e.filter(e=>e.type===c),[e,c]);return(0,s.jsxs)(r.Card,{className:(0,r.cn)(``,o),children:[(0,s.jsx)(r.CardHeader,{children:(0,s.jsxs)(r.CardTitle,{className:`flex items-center gap-2 text-base`,children:[(0,s.jsx)(i.Activity,{className:`h-4 w-4`}),`Activity`,(0,s.jsxs)(`span`,{className:`text-sm font-normal text-muted-foreground`,children:[`(`,u.length,`)`]})]})}),(0,s.jsxs)(r.CardContent,{children:[t&&(0,s.jsx)(`div`,{className:`flex flex-wrap gap-1.5 mb-4`,role:`group`,"aria-label":`Activity type filter`,children:Object.keys(I).map(e=>(0,s.jsxs)(`button`,{type:`button`,className:(0,r.cn)(`inline-flex items-center gap-1 rounded-full px-2.5 py-0.5 text-xs font-medium transition-colors`,c===e?`bg-primary text-primary-foreground`:`bg-muted text-muted-foreground hover:bg-muted/80`),onClick:()=>l(e),"aria-pressed":c===e,children:[e!==`all`&&n.createElement(M[e]||i.Edit,{className:`h-3 w-3`}),I[e]]},e))}),u.length===0?(0,s.jsx)(`p`,{className:`text-sm text-muted-foreground text-center py-4`,children:`No activity recorded`}):(0,s.jsxs)(`div`,{className:`relative`,children:[(0,s.jsx)(`div`,{className:`absolute left-4 top-2 bottom-2 w-px bg-border`}),(0,s.jsx)(`div`,{className:`space-y-4`,children:u.map(e=>{let t=M[e.type]||i.Edit;return(0,s.jsxs)(`div`,{className:`flex gap-3 relative`,children:[(0,s.jsx)(`div`,{className:(0,r.cn)(`shrink-0 h-8 w-8 rounded-full flex items-center justify-center z-10`,N[e.type]||`bg-gray-100 text-gray-600`),children:(0,s.jsx)(t,{className:`h-3.5 w-3.5`})}),(0,s.jsxs)(`div`,{className:`flex-1 min-w-0 pt-1`,children:[(0,s.jsxs)(`p`,{className:`text-sm`,children:[(0,s.jsx)(`span`,{className:`font-medium`,children:e.user}),` `,(0,s.jsx)(`span`,{className:`text-muted-foreground`,children:F(e)})]}),(0,s.jsx)(`p`,{className:`text-xs text-muted-foreground mt-0.5`,children:P(e.timestamp)})]})]},e.id)})})]})]})]})},R=5;function z(e,t,n,r){if(e&&typeof e==`object`){if(t.primaryField){let n=e[t.primaryField];if(n!=null&&n!==``)return String(n)}let r=n?.titleFormat,i=typeof r==`string`?r:r&&typeof r==`object`&&typeof r.source==`string`?r.source:void 0;if(i){let t=`[-\\u2013\\u2014|/·,:]`,n=!1,r=i.replace(/\{([^{}]+)\}/g,(t,r)=>{let i=e[r.trim()];return i!=null&&i!==``?(n=!0,String(i)):`\0`});if(n){let e=r.replace(RegExp(`\\s*${t}\\s*`,`g`),``).replace(RegExp(`\\s*${t}\\s*`,`g`),``).replace(RegExp(`\0`,`g`),``).replace(/\s+/g,` `).trim();if(e)return e}}}if(t.title)return t.title;if(e&&typeof e==`object`)for(let t of[`name`,`full_name`,`fullName`,`title`,`subject`,`label`,`display_name`,`displayName`]){let n=e[t];if(typeof n==`string`&&n.trim())return n.trim();if(n!=null&&n!==``)return String(n)}return r}var B=({schema:e,dataSource:o,className:c,onEdit:l,onDelete:u,onBack:d,inlineEdit:f=!1,onFieldSave:p,discussionSlot:m,rightRail:h,objectLabel:g,onDataLoaded:_})=>{let[v,y]=n.useState(e.data),[b,x]=n.useState(!e.data&&!!(e.api&&e.resourceId||o&&e.objectName&&e.resourceId)),[C,E]=n.useState(!1),[A,M]=n.useState(!1),[N,P]=n.useState({}),[F,I]=n.useState(null),[B,ee]=n.useState(!1),{t:V}=S();n.useEffect(()=>{v&&_&&_(v)},[v,_]);let H=n.useMemo(()=>{if(e.summaryFields&&e.summaryFields.length>0)return[];let t=[...e.sections?.flatMap(e=>e.fields)||[],...e.fields||[]],n={};for(let e of t)n[e.name]||(n[e.name]=e);if(F?.fields)for(let[e,t]of Object.entries(F.fields))n[e]={...n[e]||{},...t,name:e};let r=e=>v?.[e]!==void 0&&v?.[e]!==null&&v?.[e]!==``,i=[],a=[`status`,`stage`,`state`,`phase`].find(e=>n[e]&&r(e))||Object.keys(n).find(e=>n[e]?.type===`select`&&r(e));a&&i.push(a);let o=Object.keys(n).find(e=>(n[e]?.type===`currency`||/amount|revenue|value|total|price/i.test(e))&&r(e));o&&!i.includes(o)&&i.push(o);let s=Object.keys(n).find(e=>(n[e]?.type===`date`||n[e]?.type===`datetime`)&&/close|due|start|end|expected/i.test(e)&&r(e));return s&&!i.includes(s)&&i.push(s),i},[e.summaryFields,e.sections,e.fields,F,v]),U=e.summaryFields&&e.summaryFields.length>0?e.summaryFields:H,te=n.useCallback(()=>{e.resourceId&&navigator.clipboard.writeText(String(e.resourceId)).then(()=>{ee(!0),setTimeout(()=>ee(!1),1500)})},[e.resourceId]);n.useEffect(()=>{let n=!0;if(e.data){y(e.data),x(!1);return}if(o&&e.objectName&&e.resourceId){x(!0),I(null),y(null);let r=e.objectName,i=e.resourceId,a=`${r}-`,s=[...e.sections?.flatMap(e=>e.fields)||[],...e.fields||[]];(o.getObjectSchema?o.getObjectSchema(r).catch(()=>null):Promise.resolve(null)).then(e=>{if(!n)return;I(e);let c=(0,t.buildExpandFields)(e?.fields,s),l=c.length>0?{$expand:c}:void 0,u=l?o.findOne(r,i,l):o.findOne(r,i),d=()=>{let e=String(i),t=e.startsWith(a)?e.slice(a.length):`${a}${e}`;return(l?o.findOne(r,t,l):o.findOne(r,t)).then(e=>{n&&(y(e),x(!1))}).catch(()=>{n&&(y(null),x(!1))})};return u.catch(()=>null).then(e=>{if(n){if(e){y(e),x(!1);return}return d()}})}).catch(e=>{n&&(console.error(`Failed to fetch detail data:`,e),x(!1))})}else e.api&&e.resourceId&&(x(!0),fetch(`${e.api}/${e.resourceId}`).then(e=>e.json()).then(e=>{n&&y(e?.data||e)}).catch(e=>{console.error(`Failed to fetch detail data:`,e)}).finally(()=>{n&&x(!1)}));return()=>{n=!1}},[e.api,e.resourceId,e.objectName,o,e.sections,e.fields]);let W=n.useCallback(()=>{if(d)d();else if(e.onNavigate){let t=e.backUrl||(e.objectName?`/${e.objectName}`:`/`);e.onNavigate(t,{replace:!0})}else e.backUrl?window.location.href=e.backUrl:window.history.back()},[d,e]),G=n.useCallback(()=>{l?l():e.onNavigate&&e.editUrl?e.onNavigate(e.editUrl):e.onNavigate&&e.objectName&&e.resourceId?e.onNavigate(`/${e.objectName}/${e.resourceId}/edit`):e.editUrl&&(window.location.href=e.editUrl)},[l,e]),K=n.useCallback(()=>{let t=e.deleteConfirmation||V(`detail.deleteConfirmation`);window.confirm(t)&&(u?.(),e.onNavigate&&e.objectName&&e.onNavigate(`/${e.objectName}`,{replace:!0}))},[u,e]),q=n.useCallback(()=>{navigator.share&&e.objectName&&e.resourceId?navigator.share({title:e.title||V(`detail.details`),text:`${e.objectName} #${e.resourceId}`,url:window.location.href}).catch(e=>console.log(`Share failed:`,e)):navigator.clipboard.writeText(window.location.href).then(()=>{console.log(`Link copied to clipboard`)})},[e]),J=n.useCallback(()=>{E(!C)},[C]),Y=n.useCallback(()=>{if(A){let e=Object.entries(N);if(e.length>0){let t={...v,...N};y(t),e.forEach(([e,n])=>{p?.(e,n,t)})}P({})}M(!A)},[A,N,v,p]),X=n.useCallback((e,t)=>{P(n=>({...n,[e]:t}))},[]);n.useEffect(()=>{if(!e.recordNavigation)return;let t=e.recordNavigation,n=e=>{let n=e.target?.tagName;n===`INPUT`||n===`TEXTAREA`||e.target?.isContentEditable||(e.key===`ArrowLeft`&&t.currentIndex>0?(e.preventDefault(),t.onNavigate(t.recordIds[t.currentIndex-1])):e.key===`ArrowRight`&&t.currentIndex<t.recordIds.length-1&&(e.preventDefault(),t.onNavigate(t.recordIds[t.currentIndex+1])))};return document.addEventListener(`keydown`,n),()=>document.removeEventListener(`keydown`,n)},[e.recordNavigation]);let Z=n.useMemo(()=>{if(!e.autoDiscoverRelated||!F?.fields||e.related&&e.related.length>0)return[];let t=[],n=F.fields;for(let[e,r]of Object.entries(n)){let n=r?.reference_to||r?.reference;r&&(r.type===`lookup`||r.type===`master_detail`)&&n&&t.push({title:r.label||e.charAt(0).toUpperCase()+e.slice(1),type:`table`,objectName:n,referenceField:e})}return t},[e.autoDiscoverRelated,e.related,F]),Q=n.useMemo(()=>e.related&&e.related.length>0?e.related:Z.map(e=>({title:e.title,type:e.type,api:e.objectName,data:[],referenceField:e.referenceField})),[e.related,Z]),$=n.useMemo(()=>{let t=[];return t.push({name:`sys_share`,label:V(`detail.share`),icon:`share-2`,type:`script`,onClick:q}),e.showEdit&&t.push({name:`sys_edit_mobile`,label:V(`detail.edit`),icon:`edit`,type:`script`,className:`sm:hidden`,onClick:G}),f&&t.push({name:`sys_toggle_inline_edit_mobile`,label:V(A?`detail.save`:`detail.editInline`),icon:`edit`,type:`script`,className:`sm:hidden`,onClick:Y}),e.showDelete&&t.push({name:`sys_delete`,label:V(`detail.delete`),icon:`trash-2`,type:`script`,variant:`destructive`,tags:[`separator-before`],onClick:K}),t},[V,e.showEdit,e.showDelete,f,A,q,G,Y,K]),ne=n.useMemo(()=>{let t=e.actions??[];if($.length===0)return t;let n=!1,r=t.map(e=>{let t=e;if(t&&typeof t==`object`&&t.type===`action:bar`&&(!t.location||t.location===`record_header`)){n=!0;let e=Array.isArray(t.systemActions)?t.systemActions:[];return{...t,systemActions:[...e,...$]}}return e});return n||r.push({type:`action:bar`,location:`record_header`,systemActions:$}),r},[e.actions,$]);return b||e.loading?(0,s.jsxs)(`div`,{className:(0,r.cn)(`space-y-4`,c),children:[(0,s.jsx)(r.Skeleton,{className:`h-10 w-full`}),(0,s.jsx)(r.Skeleton,{className:`h-64 w-full`}),(0,s.jsx)(r.Skeleton,{className:`h-48 w-full`})]}):!v&&!e.data?(0,s.jsxs)(`div`,{className:(0,r.cn)(`flex flex-col items-center justify-center py-16 text-center`,c),children:[(0,s.jsx)(`p`,{className:`text-lg font-semibold`,children:V(`detail.recordNotFound`)}),(0,s.jsx)(`p`,{className:`text-sm text-muted-foreground mt-1`,children:V(`detail.recordNotFoundDescription`)}),(e.showBack??!0)&&(0,s.jsxs)(r.Button,{variant:`outline`,size:`sm`,onClick:W,className:`mt-4 gap-2`,children:[(0,s.jsx)(i.ArrowLeft,{className:`h-4 w-4`}),V(`detail.goBack`)]})]}):(0,s.jsx)(r.TooltipProvider,{children:(0,s.jsxs)(`div`,{className:(0,r.cn)(`space-y-6`,c),children:[(0,s.jsxs)(`div`,{className:`flex flex-col sm:flex-row items-start justify-between gap-3 sm:gap-4 pb-4 border-b`,children:[(0,s.jsxs)(`div`,{className:`flex items-start gap-2 sm:gap-3 flex-1 min-w-0`,children:[(e.showBack??!0)&&(0,s.jsxs)(r.Tooltip,{children:[(0,s.jsx)(r.TooltipTrigger,{asChild:!0,children:(0,s.jsx)(r.Button,{variant:`ghost`,size:`icon`,onClick:W,className:`shrink-0 mt-1`,children:(0,s.jsx)(i.ArrowLeft,{className:`h-4 w-4`})})}),(0,s.jsx)(r.TooltipContent,{children:V(`detail.back`)})]}),(0,s.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,s.jsxs)(`div`,{className:`flex items-center gap-2 flex-wrap`,children:[(0,s.jsx)(`h1`,{className:`text-xl sm:text-2xl font-bold truncate`,children:z(v,e,F,V(`detail.details`))}),U.map(t=>{let n=v?.[t];if(n==null||n===``)return null;let i=(e.sections||[]).flatMap(e=>e.fields).concat(e.fields||[]).find(e=>e.name===t),a=F?.fields?.[t],o=i?.type||a?.type,c=String(n),l=null;try{if(o===`currency`){let e=Number(n);Number.isNaN(e)||(c=new Intl.NumberFormat(void 0,{style:`currency`,currency:i?.currency||a?.currency||`USD`,maximumFractionDigits:0}).format(e))}else if(o===`date`||o===`datetime`){let e=new Date(n);Number.isNaN(e.getTime())||(c=o===`datetime`?e.toLocaleString(void 0,{dateStyle:`medium`,timeStyle:`short`}):e.toLocaleDateString(void 0,{dateStyle:`medium`}))}else if(o===`percent`){let e=Number(n);if(!Number.isNaN(e)){c=`${e}%`;let t=e<=1?e*100:e;l=Math.max(0,Math.min(100,t))}}}catch{}return l===null?(0,s.jsx)(r.Badge,{variant:`secondary`,className:`text-xs bg-primary/10 text-primary border-transparent hover:bg-primary/15`,"aria-label":`${t}: ${c}`,children:c},t):(0,s.jsxs)(r.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":`${t}: ${c}`,children:[(0,s.jsx)(`span`,{className:`relative inline-block h-1.5 w-12 rounded-full bg-primary/20 overflow-hidden`,"aria-hidden":!0,children:(0,s.jsx)(`span`,{className:`absolute inset-y-0 left-0 rounded-full bg-primary`,style:{width:`${l}%`}})}),c]},t)}),(0,s.jsxs)(r.Tooltip,{children:[(0,s.jsx)(r.TooltipTrigger,{asChild:!0,children:(0,s.jsx)(r.Button,{variant:`ghost`,size:`icon`,className:`h-6 w-6 shrink-0`,onClick:J,"aria-label":V(C?`detail.removeFromFavorites`:`detail.addToFavorites`),children:C?(0,s.jsx)(i.Star,{className:`h-4 w-4 fill-yellow-400 text-yellow-400`}):(0,s.jsx)(i.StarOff,{className:`h-4 w-4 text-muted-foreground`})})}),(0,s.jsx)(r.TooltipContent,{children:V(C?`detail.removeFromFavorites`:`detail.addToFavorites`)})]})]}),e.objectName&&(0,s.jsxs)(`p`,{className:`text-sm text-muted-foreground mt-1 flex items-center gap-1`,children:[(0,s.jsx)(`span`,{className:`font-medium`,children:g||e.objectName}),e.resourceId&&(0,s.jsxs)(r.Tooltip,{children:[(0,s.jsx)(r.TooltipTrigger,{asChild:!0,children:(0,s.jsx)(r.Button,{variant:`ghost`,size:`icon`,className:`h-5 w-5 shrink-0 text-muted-foreground/60 hover:text-foreground`,onClick:te,"aria-label":V(`detail.copyRecordId`,{defaultValue:`Copy record ID`}),children:B?(0,s.jsx)(i.Check,{className:`h-3 w-3 text-green-600`}):(0,s.jsx)(i.Copy,{className:`h-3 w-3`})})}),(0,s.jsx)(r.TooltipContent,{children:B?V(`detail.copied`,{defaultValue:`Copied`}):V(`detail.copyRecordId`,{defaultValue:`Copy record ID`})})]})]})]})]}),(0,s.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5 shrink-0 w-full sm:w-auto`,children:[e.recordNavigation&&(0,s.jsxs)(`div`,{className:`flex items-center gap-1 mr-2`,children:[(0,s.jsxs)(r.Tooltip,{children:[(0,s.jsx)(r.TooltipTrigger,{asChild:!0,children:(0,s.jsx)(r.Button,{variant:`outline`,size:`icon`,className:`h-8 w-8`,disabled:e.recordNavigation.currentIndex<=0,onClick:()=>{let t=e.recordNavigation;t.currentIndex>0&&t.onNavigate(t.recordIds[t.currentIndex-1])},children:(0,s.jsx)(i.ChevronLeft,{className:`h-4 w-4`})})}),(0,s.jsx)(r.TooltipContent,{children:V(`detail.previousRecord`)})]}),(0,s.jsx)(`span`,{className:`text-xs text-muted-foreground whitespace-nowrap px-1`,children:V(`detail.recordOf`,{current:e.recordNavigation.currentIndex+1,total:e.recordNavigation.recordIds.length})}),(0,s.jsxs)(r.Tooltip,{children:[(0,s.jsx)(r.TooltipTrigger,{asChild:!0,children:(0,s.jsx)(r.Button,{variant:`outline`,size:`icon`,className:`h-8 w-8`,disabled:e.recordNavigation.currentIndex>=e.recordNavigation.recordIds.length-1,onClick:()=>{let t=e.recordNavigation;t.currentIndex<t.recordIds.length-1&&t.onNavigate(t.recordIds[t.currentIndex+1])},children:(0,s.jsx)(i.ChevronRight,{className:`h-4 w-4`})})}),(0,s.jsx)(r.TooltipContent,{children:V(`detail.nextRecord`)})]})]}),ne.map((e,t)=>(0,s.jsx)(a.SchemaRenderer,{schema:e,data:v},t)),f&&(0,s.jsxs)(r.Tooltip,{children:[(0,s.jsx)(r.TooltipTrigger,{asChild:!0,children:(0,s.jsx)(r.Button,{variant:A?`default`:`outline`,size:`sm`,onClick:Y,className:`gap-2 hidden sm:inline-flex`,children:A?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(i.Check,{className:`h-4 w-4`}),(0,s.jsx)(`span`,{className:`hidden sm:inline`,children:V(`detail.save`)})]}):(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(i.Edit,{className:`h-4 w-4`}),(0,s.jsx)(`span`,{className:`hidden sm:inline`,children:V(`detail.editInline`)})]})})}),(0,s.jsx)(r.TooltipContent,{children:V(A?`detail.saveChanges`:`detail.editFieldsInline`)})]}),e.showEdit&&(0,s.jsxs)(r.Tooltip,{children:[(0,s.jsx)(r.TooltipTrigger,{asChild:!0,children:(0,s.jsxs)(r.Button,{variant:`default`,onClick:G,className:`gap-2 hidden sm:inline-flex`,children:[(0,s.jsx)(i.Edit,{className:`h-4 w-4`}),(0,s.jsx)(`span`,{className:`hidden sm:inline`,children:V(`detail.edit`)})]})}),(0,s.jsx)(r.TooltipContent,{children:V(`detail.editRecord`)})]})]})]}),e.header&&(0,s.jsx)(`div`,{children:(0,s.jsx)(a.SchemaRenderer,{schema:e.header,data:v})}),e.highlightFields&&e.highlightFields.length>0&&(0,s.jsx)(k,{fields:e.highlightFields,data:v,objectName:e.objectName,objectSchema:F}),e.autoTabs&&!e.tabs?.length?(()=>{let t=Q.length>0,n=!!e.activities&&e.activities.length>0,i=!!m,a=(0,s.jsxs)(`div`,{className:`space-y-3 sm:space-y-4`,children:[e.sectionGroups&&e.sectionGroups.length>0&&e.sectionGroups.map((t,n)=>(0,s.jsx)(O,{group:t,data:{...v,...N},objectSchema:F,objectName:e.objectName,isEditing:A,onFieldChange:X},n)),e.sections&&e.sections.length>0&&e.sections.map((t,n)=>(0,s.jsx)(w,{section:t,data:{...v,...N},objectSchema:F,objectName:e.objectName,isEditing:A,onFieldChange:X},n)),e.fields&&e.fields.length>0&&!e.sections?.length&&(0,s.jsx)(w,{section:{fields:e.fields,columns:e.columns},data:{...v,...N},objectSchema:F,objectName:e.objectName,isEditing:A,onFieldChange:X}),e.comments&&(0,s.jsx)(j,{comments:e.comments,onAddComment:e.onAddComment})]});return!t&&!n&&!i?(0,s.jsx)(`div`,{className:`mt-2`,children:a}):(0,s.jsxs)(r.Tabs,{defaultValue:`details`,className:`w-full`,children:[(0,s.jsxs)(r.TabsList,{className:`w-full justify-start border-b rounded-none bg-transparent p-0`,children:[(0,s.jsx)(r.TabsTrigger,{value:`details`,className:`relative rounded-none border-b-2 border-transparent data-[state=active]:border-primary data-[state=active]:bg-transparent`,children:V(`detail.details`)}),t&&(0,s.jsx)(r.TabsTrigger,{value:`related`,className:`relative rounded-none border-b-2 border-transparent data-[state=active]:border-primary data-[state=active]:bg-transparent`,children:(0,s.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[V(`detail.related`),(0,s.jsx)(r.Badge,{variant:`secondary`,className:`text-xs bg-primary/10 text-primary border-transparent`,children:Q.length})]})}),n&&(0,s.jsx)(r.TabsTrigger,{value:`activity`,className:`relative rounded-none border-b-2 border-transparent data-[state=active]:border-primary data-[state=active]:bg-transparent`,children:(0,s.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[V(`detail.activity`),(0,s.jsx)(r.Badge,{variant:`secondary`,className:`text-xs bg-primary/10 text-primary border-transparent`,children:e.activities.length})]})}),i&&(0,s.jsx)(r.TabsTrigger,{value:`discussion`,className:`relative rounded-none border-b-2 border-transparent data-[state=active]:border-primary data-[state=active]:bg-transparent`,children:V(`detail.discussion`,{defaultValue:`Discussion`})})]}),(0,s.jsx)(r.TabsContent,{value:`details`,className:`mt-4`,children:a}),t&&(0,s.jsx)(r.TabsContent,{value:`related`,className:`mt-4`,children:(0,s.jsx)(`div`,{className:`space-y-3`,children:Q.map((e,t)=>(0,s.jsx)(D,{title:e.title,type:e.type,api:e.api,data:e.data,columns:e.columns,dataSource:o,objectName:e.api,referenceField:e.referenceField,icon:e.icon,collapsible:!0,pageSize:R},t))})}),n&&(0,s.jsx)(r.TabsContent,{value:`activity`,className:`mt-4`,children:(0,s.jsx)(L,{activities:e.activities})}),i&&(0,s.jsx)(r.TabsContent,{value:`discussion`,className:`mt-4`,children:m})]})})():(0,s.jsxs)(s.Fragment,{children:[e.sectionGroups&&e.sectionGroups.length>0&&(0,s.jsx)(`div`,{className:`space-y-3 sm:space-y-4`,children:e.sectionGroups.map((t,n)=>(0,s.jsx)(O,{group:t,data:{...v,...N},objectSchema:F,objectName:e.objectName,isEditing:A,onFieldChange:X},n))}),e.sections&&e.sections.length>0&&(0,s.jsx)(`div`,{className:`space-y-3 sm:space-y-4`,children:e.sections.map((t,n)=>(0,s.jsx)(w,{section:t,data:{...v,...N},objectSchema:F,objectName:e.objectName,isEditing:A,onFieldChange:X},n))}),e.fields&&e.fields.length>0&&!e.sections?.length&&(0,s.jsx)(w,{section:{fields:e.fields,columns:e.columns},data:{...v,...N},objectSchema:F,objectName:e.objectName,isEditing:A,onFieldChange:X}),e.tabs&&e.tabs.length>0&&(0,s.jsx)(T,{tabs:e.tabs,data:v}),Q.length>0&&(0,s.jsxs)(`div`,{className:`space-y-3`,children:[(0,s.jsx)(`h2`,{className:`text-lg font-semibold`,children:V(`detail.related`)}),Q.map((e,t)=>(0,s.jsx)(D,{title:e.title,type:e.type,api:e.api,data:e.data,columns:e.columns,dataSource:o,objectName:e.api,referenceField:e.referenceField,icon:e.icon,collapsible:!0,pageSize:R},t))]}),e.comments&&(0,s.jsx)(j,{comments:e.comments,onAddComment:e.onAddComment}),e.activities&&e.activities.length>0&&(0,s.jsx)(L,{activities:e.activities})]}),e.footer&&(0,s.jsx)(`div`,{children:(0,s.jsx)(a.SchemaRenderer,{schema:e.footer,data:v})})]})})},ee=({objectName:e,relationshipField:t,fields:a,onCreateRecord:o,onLinkRecord:c,onSearch:l,existingRecords:u=[],className:d})=>{let[f,p]=n.useState(!1),[m,h]=n.useState(`create`),[g,_]=n.useState({}),[v,y]=n.useState(``),[b,x]=n.useState(u),[S,C]=n.useState(!1),[w,T]=n.useState(!1),E=n.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]),D=n.useCallback(async e=>{if(y(e),l&&e.trim().length>=2){T(!0);try{x(await l(e))}finally{T(!1)}}},[l]),O=n.useCallback((e,t)=>{_(n=>({...n,[e]:t}))},[]),k=n.useCallback(async()=>{if(o){C(!0);try{await o({...g,[t]:!0}),_({}),p(!1)}finally{C(!1)}}},[o,g,t]),A=n.useCallback(async e=>{if(c){C(!0);try{await c(e),y(``),p(!1)}finally{C(!1)}}},[c]),j=n.useMemo(()=>a.filter(e=>e.required).every(e=>g[e.name]?.toString().trim()),[a,g]);return f?(0,s.jsxs)(r.Card,{className:(0,r.cn)(``,d),children:[(0,s.jsx)(r.CardHeader,{className:`pb-3`,children:(0,s.jsxs)(r.CardTitle,{className:`flex items-center justify-between text-sm`,children:[(0,s.jsxs)(`span`,{children:[m===`create`?`Create`:`Link`,` `,e]}),(0,s.jsx)(r.Button,{variant:`ghost`,size:`icon`,className:`h-6 w-6`,onClick:()=>p(!1),children:(0,s.jsx)(i.X,{className:`h-3.5 w-3.5`})})]})}),(0,s.jsx)(r.CardContent,{children:(0,s.jsxs)(r.Tabs,{value:m,onValueChange:h,children:[(0,s.jsxs)(r.TabsList,{className:`mb-3 w-full`,children:[o&&(0,s.jsxs)(r.TabsTrigger,{value:`create`,className:`flex-1 gap-1.5`,children:[(0,s.jsx)(i.Plus,{className:`h-3.5 w-3.5`}),`Create New`]}),c&&(0,s.jsxs)(r.TabsTrigger,{value:`link`,className:`flex-1 gap-1.5`,children:[(0,s.jsx)(i.Link,{className:`h-3.5 w-3.5`}),`Link Existing`]})]}),o&&(0,s.jsxs)(r.TabsContent,{value:`create`,className:`space-y-3 mt-0`,children:[a.map(e=>(0,s.jsxs)(`div`,{children:[(0,s.jsxs)(`label`,{className:`text-xs font-medium text-muted-foreground mb-1 block`,children:[e.label,e.required&&(0,s.jsx)(`span`,{className:`text-destructive ml-0.5`,children:`*`})]}),(0,s.jsx)(r.Input,{type:e.type===`number`?`number`:e.type===`date`?`date`:`text`,placeholder:e.placeholder||`Enter ${e.label.toLowerCase()}`,value:g[e.name]||``,onChange:t=>O(e.name,t.target.value),className:`h-8 text-sm`})]},e.name)),(0,s.jsxs)(`div`,{className:`flex justify-end gap-2 pt-1`,children:[(0,s.jsx)(r.Button,{variant:`ghost`,size:`sm`,onClick:()=>p(!1),children:`Cancel`}),(0,s.jsxs)(r.Button,{size:`sm`,onClick:k,disabled:!j||S,className:`gap-1.5`,children:[S&&(0,s.jsx)(i.Loader2,{className:`h-3.5 w-3.5 animate-spin`}),`Create`]})]})]}),c&&(0,s.jsxs)(r.TabsContent,{value:`link`,className:`space-y-3 mt-0`,children:[(0,s.jsxs)(`div`,{className:`relative`,children:[(0,s.jsx)(i.Search,{className:`absolute left-2.5 top-1/2 -translate-y-1/2 h-3.5 w-3.5 text-muted-foreground`}),(0,s.jsx)(r.Input,{placeholder:`Search ${e}…`,value:v,onChange:e=>D(e.target.value),className:`h-8 text-sm pl-8`})]}),(0,s.jsx)(`div`,{className:`max-h-48 overflow-y-auto space-y-1`,children:w?(0,s.jsxs)(`div`,{className:`flex items-center justify-center py-4 text-sm text-muted-foreground`,children:[(0,s.jsx)(i.Loader2,{className:`h-4 w-4 animate-spin mr-2`}),`Searching…`]}):E.length===0?(0,s.jsx)(`p`,{className:`text-sm text-muted-foreground text-center py-4`,children:v?`No records found`:`Type to search records`}):E.map(e=>(0,s.jsxs)(`button`,{type:`button`,className:`w-full text-left px-3 py-2 rounded-md hover:bg-accent text-sm transition-colors`,onClick:()=>A(e.id),disabled:S,children:[(0,s.jsx)(`span`,{className:`font-medium`,children:e.label}),e.description&&(0,s.jsx)(`span`,{className:`block text-xs text-muted-foreground mt-0.5`,children:e.description})]},e.id))})]})]})})]}):(0,s.jsxs)(`div`,{className:(0,r.cn)(`flex gap-2`,d),children:[o&&(0,s.jsxs)(r.Button,{variant:`outline`,size:`sm`,onClick:()=>{h(`create`),p(!0)},className:`gap-1.5`,children:[(0,s.jsx)(i.Plus,{className:`h-3.5 w-3.5`}),`New `,e]}),c&&(0,s.jsxs)(r.Button,{variant:`outline`,size:`sm`,onClick:()=>{h(`link`),p(!0)},className:`gap-1.5`,children:[(0,s.jsx)(i.Link,{className:`h-3.5 w-3.5`}),`Link Existing`]})]})};function V(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 H=({value:e,onChange:t,onSubmit:a,mentionSuggestions:o=[],placeholder:c,className:l,disabled:u=!1})=>{let{t:d}=S(),[f,p]=n.useState(!1),[m,h]=n.useState(!1),[g,_]=n.useState(``),[v,y]=n.useState(0),b=n.useRef(null),x=n.useMemo(()=>{if(!g)return o;let e=g.toLowerCase();return o.filter(t=>t.label.toLowerCase().includes(e))},[g,o]),C=n.useCallback((n,r=``)=>{let i=b.current;if(!i)return;let a=i.selectionStart,o=i.selectionEnd,s=e.slice(a,o);t(e.slice(0,a)+n+s+r+e.slice(o)),requestAnimationFrame(()=>{i.focus();let e=a+n.length+s.length;i.setSelectionRange(e,e)})},[e,t]),w=n.useCallback(()=>C(`**`,`**`),[C]),T=n.useCallback(()=>C(`*`,`*`),[C]),E=n.useCallback(()=>C(`
|
|
2
|
-
- `,``),[C]),D=n.useCallback(()=>C("`","`"),[C]),O=n.useCallback(()=>{C(`@`,``),h(!0),_(``),y(0)},[C]),k=n.useCallback(n=>{let r=b.current;if(!r)return;let i=r.selectionStart,a=e.slice(0,i).lastIndexOf(`@`);a!==-1&&t(e.slice(0,a)+`@${n.label} `+e.slice(i)),h(!1),_(``),requestAnimationFrame(()=>r.focus())},[e,t]),A=n.useCallback(e=>{let n=e.target.value;t(n);let r=e.target.selectionStart,i=n.slice(0,r),a=i.lastIndexOf(`@`);if(a!==-1){let e=i.slice(a+1),t=a>0?i[a-1]:` `;if(/\s/.test(t)&&!/\s/.test(e)){h(!0),_(e),y(0);return}}h(!1)},[t]),j=n.useCallback(e=>{if(m&&x.length>0){if(e.key===`ArrowDown`){e.preventDefault(),y(e=>e<x.length-1?e+1:0);return}if(e.key===`ArrowUp`){e.preventDefault(),y(e=>e>0?e-1:x.length-1);return}if(e.key===`Enter`||e.key===`Tab`){e.preventDefault(),k(x[v]);return}if(e.key===`Escape`){h(!1);return}}e.key===`Enter`&&(e.ctrlKey||e.metaKey)&&(e.preventDefault(),a?.())},[m,x,v,k,a]);return(0,s.jsxs)(`div`,{className:(0,r.cn)(`border rounded-md`,l),children:[(0,s.jsxs)(`div`,{className:`flex items-center gap-0.5 px-2 py-1.5 border-b bg-muted/30`,children:[(0,s.jsx)(r.Button,{variant:`ghost`,size:`icon`,className:`h-7 w-7`,onClick:w,disabled:u||f,title:d(`detail.bold`),children:(0,s.jsx)(i.Bold,{className:`h-3.5 w-3.5`})}),(0,s.jsx)(r.Button,{variant:`ghost`,size:`icon`,className:`h-7 w-7`,onClick:T,disabled:u||f,title:d(`detail.italic`),children:(0,s.jsx)(i.Italic,{className:`h-3.5 w-3.5`})}),(0,s.jsx)(r.Button,{variant:`ghost`,size:`icon`,className:`h-7 w-7`,onClick:E,disabled:u||f,title:d(`detail.listFormat`),children:(0,s.jsx)(i.List,{className:`h-3.5 w-3.5`})}),(0,s.jsx)(r.Button,{variant:`ghost`,size:`icon`,className:`h-7 w-7`,onClick:D,disabled:u||f,title:d(`detail.inlineCode`),children:(0,s.jsx)(i.Code,{className:`h-3.5 w-3.5`})}),(0,s.jsx)(r.Button,{variant:`ghost`,size:`icon`,className:`h-7 w-7`,onClick:O,disabled:u||f,title:d(`detail.mentionSomeone`),children:(0,s.jsx)(i.AtSign,{className:`h-3.5 w-3.5`})}),(0,s.jsx)(`div`,{className:`flex-1`}),(0,s.jsx)(r.Button,{variant:`ghost`,size:`icon`,className:`h-7 w-7`,onClick:()=>p(!f),title:d(f?`detail.edit`:`detail.preview`),children:f?(0,s.jsx)(i.Edit,{className:`h-3.5 w-3.5`}):(0,s.jsx)(i.Eye,{className:`h-3.5 w-3.5`})}),a&&(0,s.jsx)(r.Button,{variant:`ghost`,size:`icon`,className:`h-7 w-7`,onClick:a,disabled:u||!e.trim(),title:d(`detail.submitComment`),children:(0,s.jsx)(i.Send,{className:`h-3.5 w-3.5`})})]}),(0,s.jsx)(`div`,{className:`relative`,children:f?(0,s.jsx)(`div`,{className:`min-h-[80px] px-3 py-2 text-sm prose prose-sm max-w-none`,dangerouslySetInnerHTML:{__html:
|
|
1
|
+
(function(e,t){typeof exports==`object`&&typeof module<`u`?t(exports,require(`@object-ui/core`),require(`react`),require(`@object-ui/components`),require(`lucide-react`),require(`@object-ui/react`),require(`@object-ui/fields`),require(`react/jsx-runtime`)):typeof define==`function`&&define.amd?define([`exports`,`@object-ui/core`,`react`,`@object-ui/components`,`lucide-react`,`@object-ui/react`,`@object-ui/fields`,`react/jsx-runtime`],t):(e=typeof globalThis<`u`?globalThis:e||self,t(e.ObjectUIPluginDetail={},e.ObjectUICore,e.React,e.ObjectUIComponents,e.LucideReact,e.ObjectUIReact,e.ObjectUIFields,e.jsxRuntime))})(this,function(e,t,n,r,i,a,o,s){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var c=Object.create,l=Object.defineProperty,u=Object.getOwnPropertyDescriptor,d=Object.getOwnPropertyNames,f=Object.getPrototypeOf,p=Object.prototype.hasOwnProperty,m=(e,t,n,r)=>{if(t&&typeof t==`object`||typeof t==`function`)for(var i=d(t),a=0,o=i.length,s;a<o;a++)s=i[a],!p.call(e,s)&&s!==n&&l(e,s,{get:(e=>t[e]).bind(null,s),enumerable:!(r=u(t,s))||r.enumerable});return e};n=((e,t,n)=>(n=e==null?{}:c(f(e)),m(t||!e||!e.__esModule?l(n,`default`,{value:e,enumerable:!0}):n,e)))(n,1);var h=new Set([`textarea`,`markdown`,`html`,`grid`,`rich-text`,`field:textarea`,`field:markdown`,`field:html`,`field:grid`,`field:rich-text`]);function g(e){return h.has(e)}function _(e,t){let n;if(n=e<=3?1:e<=10?2:3,t!==void 0){if(t<640)return Math.min(n,1);if(t<900)return Math.min(n,2)}return n}function v(e,t){return t<=1?e:e.map(e=>e.span===void 0&&e.type&&g(e.type)?{...e,span:t}:e)}function y(e,t,n){if(t!==void 0)return{fields:v(e,t),columns:t};let r=_(e.length,n);return{fields:v(e,r),columns:r}}function b(e,t){return function(){try{let n=(0,a.useObjectTranslation)();return n.t(t)===t?{t:(t,n)=>{let r=e[t]||t;if(n)for(let[e,t]of Object.entries(n))r=r.replace(`{{${e}}}`,String(t));return r}}:{t:n.t}}catch{return{t:(t,n)=>{let r=e[t]||t;if(n)for(let[e,t]of Object.entries(n))r=r.replace(`{{${e}}}`,String(t));return r}}}}}var x={"detail.back":`Back`,"detail.edit":`Edit`,"detail.editInline":`Edit`,"detail.save":`Save`,"detail.saveChanges":`Save changes`,"detail.editFieldsInline":`Edit fields inline`,"detail.cancel":`Cancel`,"detail.cancelEdit":`Discard changes`,"detail.openInNewTab":`Open in new tab`,"detail.share":`Share`,"detail.duplicate":`Duplicate`,"detail.export":`Export`,"detail.viewHistory":`View history`,"detail.delete":`Delete`,"detail.moreActions":`More actions`,"detail.addToFavorites":`Add to favorites`,"detail.removeFromFavorites":`Remove from favorites`,"detail.previousRecord":`Previous record`,"detail.nextRecord":`Next record`,"detail.recordOf":`{{current}} of {{total}}`,"detail.recordNotFound":`Record not found`,"detail.recordNotFoundDescription":`The record you are looking for does not exist or may have been deleted.`,"detail.goBack":`Go back`,"detail.details":`Details`,"detail.related":`Related`,"detail.relatedRecords":`{{count}} records`,"detail.relatedRecordOne":`{{count}} record`,"detail.noRelatedRecords":`No related records found`,"detail.loading":`Loading...`,"detail.copyToClipboard":`Copy to clipboard`,"detail.copied":`Copied!`,"detail.deleteConfirmation":`Are you sure you want to delete this record?`,"detail.editRecord":`Edit record`,"detail.viewAll":`View All`,"detail.new":`New`,"detail.emptyValue":`—`,"detail.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.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.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.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.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`},S=b(x,`detail.back`);function C(e,t){return!e||e<=1||t<=1?``:t===2?e>=2?`md:col-span-2`:``:e===2?`md:col-span-2`:e>=3?`md:col-span-2 lg:col-span-3`:``}var w=({section:e,data:t,className:c,objectSchema:l,objectName:u,isEditing:d=!1,onFieldChange:f,virtualScroll:p})=>{let[m,h]=n.useState(e.defaultCollapsed??!1),[g,_]=n.useState(null),[v,b]=n.useState(void 0),[x,w]=n.useState(!1),{t:T}=S(),{fieldLabel:E,translateOptions:D}=(0,a.useSafeFieldLabel)(),O=n.useCallback((e,t)=>{let n=t==null?``:String(t);navigator.clipboard.writeText(n).then(()=>{_(e),setTimeout(()=>_(null),2e3)})},[]),k=n.useCallback(e=>{let n=t?.[e.name]??e.value;return n==null||n===``},[t]),A=n.useMemo(()=>e.fields.filter(k).length,[e.fields,k]),j=(0,r.useIsMobile)(),M=j?3:6,N=j?.2:.5,P=e.fields.length-A,F=!e.hideEmpty&&!d&&e.fields.length>=M&&A/e.fields.length>=N&&P>0,I=!x&&(e.hideEmpty||F)?e.fields.filter(e=>!k(e)):e.fields;if(I.length===0&&A===e.fields.length)return null;let{fields:L,columns:R}=y(I,e.columns),ee=e=>{let n=t?.[e.name]??e.value;if(e.render)return(0,s.jsx)(a.SchemaRenderer,{schema:e.render,data:{...t,value:n}});let c=C(e.span,R),p=l?.fields?.[e.name],m={...e};if(p){!e.type&&p.type&&(m.type=p.type),p.options&&!m.options&&(m.options=p.options),p.currency&&!m.currency&&(m.currency=p.currency),p.precision!==void 0&&m.precision===void 0&&(m.precision=p.precision),p.format&&!m.format&&(m.format=p.format);let t=p.reference_to||p.reference;t&&!m.reference_to&&(m.reference_to=t),p.reference_field&&!m.reference_field&&(m.reference_field=p.reference_field)}u&&Array.isArray(m.options)&&m.options.length>0&&(m.options=D(u,e.name,m.options));let h=(()=>{if(n==null)return(0,s.jsx)(`span`,{className:`text-muted-foreground/50 text-xs italic`,children:`—`});let t=(0,o.resolveCellRendererType)(m)||e.type;if(t){let e=(0,o.getCellRenderer)(t);if(e)return(0,s.jsx)(e,{value:n,field:m})}return String(n)})(),_=n!=null&&n!==``,v=g===e.name;return(0,s.jsxs)(`div`,{className:(0,r.cn)(`space-y-1.5 group`,c),children:[(0,s.jsx)(`div`,{className:`text-xs font-medium text-muted-foreground uppercase tracking-wide`,children:E(u||``,e.name,e.label||e.name)}),d&&!e.readonly?(0,s.jsx)(`div`,{className:`min-h-[44px] sm:min-h-0`,children:(()=>{let t=m.type||e.type;if(t===`select`&&Array.isArray(m.options)&&m.options.length>0)return(0,s.jsx)(o.SelectField,{field:m,value:n==null?``:String(n),onChange:t=>f?.(e.name,t)});if(t===`boolean`)return(0,s.jsx)(o.BooleanField,{field:m,value:!!n,onChange:t=>f?.(e.name,t)});let r=t===`date`||t===`datetime`;return(0,s.jsx)(`input`,{type:t===`number`?`number`:r?`date`:`text`,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:n==null?``:r?(()=>{let e=String(n);if(/^\d{4}-\d{2}-\d{2}/.test(e))return e.slice(0,10);let t=new Date(e);return isNaN(t.getTime())?``:t.toLocaleDateString(`en-CA`)})():String(n),onChange:t=>{let n=t.target.value;if(r&&n){let t=new Date(n+`T00:00:00`).toISOString();f?.(e.name,t)}else f?.(e.name,n)}})})()}):(0,s.jsxs)(`div`,{className:(0,r.cn)(`flex items-start justify-between gap-2 min-h-[44px] sm:min-h-0 rounded-md`,_&&`cursor-pointer active:bg-muted/60 transition-colors`),onClick:_?()=>O(e.name,n):void 0,onKeyDown:_?t=>{(t.key===`Enter`||t.key===` `)&&(t.preventDefault(),O(e.name,n))}:void 0,role:_?`button`:void 0,tabIndex:_?0:void 0,children:[(0,s.jsx)(`div`,{className:`text-sm flex-1 break-words py-1`,children:h}),_&&(0,s.jsx)(r.TooltipProvider,{children:(0,s.jsxs)(r.Tooltip,{children:[(0,s.jsx)(r.TooltipTrigger,{asChild:!0,children:(0,s.jsx)(r.Button,{variant:`ghost`,size:`icon`,className:`h-6 w-6 opacity-0 group-hover:opacity-100 transition-opacity shrink-0`,onClick:t=>{t.stopPropagation(),O(e.name,n)},children:v?(0,s.jsx)(i.Check,{className:`h-3 w-3 text-green-600`}):(0,s.jsx)(i.Copy,{className:`h-3 w-3`})})}),(0,s.jsx)(r.TooltipContent,{children:T(v?`detail.copied`:`detail.copyToClipboard`)})]})})]})]},e.name)},z=p?.enabled===!0,B=p?.batchSize??20;n.useEffect(()=>{if(!z){b(void 0);return}if(L.length<=B){b(void 0);return}b(B);let e=setTimeout(()=>b(void 0),100);return()=>clearTimeout(e)},[z,L.length,B]);let V=v===void 0?L:L.slice(0,v),te=A>0&&(e.hideEmpty||F),H=(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(`div`,{className:(0,r.cn)(`grid gap-3 sm:gap-4`,R===1?`grid-cols-1`:R===2?`grid-cols-1 md:grid-cols-2`:`grid-cols-1 md:grid-cols-2 lg:grid-cols-3`),children:V.map(ee)}),te&&(0,s.jsx)(`div`,{className:`mt-3 -ml-2`,children:(0,s.jsxs)(r.Button,{type:`button`,variant:`ghost`,size:`sm`,onClick:()=>w(e=>!e),className:`h-7 px-2 text-xs text-muted-foreground hover:text-foreground`,children:[x?(0,s.jsx)(i.EyeOff,{className:`h-3.5 w-3.5 mr-1.5`}):(0,s.jsx)(i.Eye,{className:`h-3.5 w-3.5 mr-1.5`}),x?T(`detail.hideEmptyFields`,{defaultValue:`Hide empty fields`}):T(`detail.showEmptyFields`,{count:A,defaultValue:`Show ${A} empty field${A===1?``:`s`}`})]})})]});return!e.title&&!e.collapsible&&e.showBorder===!1?(0,s.jsx)(`div`,{className:(0,r.cn)(c),children:H}):e.collapsible?(0,s.jsx)(r.Collapsible,{open:!m,onOpenChange:e=>h(!e),className:c,children:(0,s.jsxs)(r.Card,{children:[(0,s.jsx)(r.CollapsibleTrigger,{asChild:!0,children:(0,s.jsxs)(r.CardHeader,{className:(0,r.cn)(`cursor-pointer hover:bg-muted/50 transition-colors`,e.headerColor&&`bg-${e.headerColor}`),children:[(0,s.jsxs)(r.CardTitle,{className:`flex items-center justify-between`,children:[(0,s.jsxs)(`div`,{className:`flex items-center gap-2`,children:[e.icon&&(0,s.jsx)(`span`,{className:`text-muted-foreground`,children:e.icon}),(0,s.jsx)(`span`,{children:e.title}),e.fields&&(0,s.jsx)(r.Badge,{variant:`secondary`,className:`ml-2 text-xs`,children:e.fields.length})]}),(0,s.jsx)(`div`,{className:`flex items-center gap-2`,children:m?(0,s.jsx)(i.ChevronRight,{className:`h-4 w-4 text-muted-foreground`}):(0,s.jsx)(i.ChevronDown,{className:`h-4 w-4 text-muted-foreground`})})]}),e.description&&!m&&(0,s.jsx)(`p`,{className:`text-sm text-muted-foreground mt-1.5`,children:e.description})]})}),(0,s.jsx)(r.CollapsibleContent,{children:(0,s.jsx)(r.CardContent,{className:`pt-4 sm:pt-6 px-3 sm:px-6`,children:H})})]})}):(0,s.jsxs)(r.Card,{className:(0,r.cn)(e.showBorder===!1?`border-none shadow-none`:``,c),children:[e.title&&(0,s.jsxs)(r.CardHeader,{className:(0,r.cn)(e.headerColor&&`bg-${e.headerColor}`),children:[(0,s.jsx)(r.CardTitle,{className:`flex items-center justify-between`,children:(0,s.jsxs)(`div`,{className:`flex items-center gap-2`,children:[e.icon&&(0,s.jsx)(`span`,{className:`text-muted-foreground`,children:e.icon}),(0,s.jsx)(`span`,{children:e.title})]})}),e.description&&(0,s.jsx)(`p`,{className:`text-sm text-muted-foreground mt-1.5`,children:e.description})]}),(0,s.jsx)(r.CardContent,{className:`pt-4 sm:pt-6 px-3 sm:px-6`,children:H})]})},T=({tabs:e,data:t,className:i})=>{let[o,c]=n.useState(e[0]?.key),l=e.filter(e=>typeof e.visible==`boolean`?e.visible:(e.visible,!0));return(0,s.jsxs)(r.Tabs,{value:o,onValueChange:c,className:i,children:[(0,s.jsx)(r.TabsList,{className:`w-full justify-start border-b rounded-none bg-transparent p-0`,children:l.map(e=>(0,s.jsx)(r.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,s.jsxs)(`div`,{className:`flex items-center gap-2`,children:[e.icon&&(0,s.jsx)(`span`,{children:e.icon}),(0,s.jsx)(`span`,{children:e.label}),e.badge&&(0,s.jsx)(r.Badge,{variant:`secondary`,className:`ml-1`,children:e.badge})]})},e.key))}),l.map(e=>(0,s.jsx)(r.TabsContent,{value:e.key,className:`mt-4`,children:(0,s.jsx)(n.Suspense,{fallback:null,children:Array.isArray(e.content)?(0,s.jsx)(`div`,{className:`space-y-4`,children:e.content.map((e,n)=>(0,s.jsx)(a.SchemaRenderer,{schema:e,data:t},n))}):(0,s.jsx)(a.SchemaRenderer,{schema:e.content,data:t})})},e.key))]})};function E(e){return e&&i.icons[e.split(/[-_\s]/).filter(Boolean).map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(``)]||i.Inbox}var D=({title:e,type:t,api:c,data:l,schema:u,columns:d,className:f,dataSource:p,objectName:m,onNew:h,onViewAll:g,onRowEdit:_,onRowDelete:v,onRowClick:y,maxColumns:b=6,pageSize:x,sortable:C=!1,filterable:w=!1,collapsible:T=!1,defaultCollapsed:D=!1,referenceField:O,icon:k})=>{let A=l!==void 0,j=l??[],[M,N]=n.useState(j),[P,F]=n.useState(!1),[I,L]=n.useState(0),[R,ee]=n.useState(null),[z,B]=n.useState(`asc`),[V,te]=n.useState(``),[H,ne]=n.useState(null),[re,ie]=n.useState(D),[U,W]=n.useState({}),{t:G}=S(),{fieldLabel:K}=(0,a.useSafeFieldLabel)();n.useEffect(()=>{A&&N(l??[])},[l,A]),n.useEffect(()=>{c&&p?.getObjectSchema&&!d?.length&&p.getObjectSchema(c).then(ne).catch(e=>{console.warn(`[RelatedList] Failed to fetch schema for ${c}:`,e)})},[c,p,d]),n.useEffect(()=>{c&&!A&&(F(!0),p&&typeof p.find==`function`?p.find(c).then(e=>{N(Array.isArray(e)?e:Array.isArray(e?.data)?e.data:[]),F(!1)}).catch(e=>{console.error(`Failed to fetch related data:`,e),F(!1)}):fetch(c).then(e=>e.json()).then(e=>{N(Array.isArray(e)?e:e?.data||[])}).catch(e=>{console.error(`Failed to fetch related data:`,e)}).finally(()=>F(!1)))},[c,A,p]),n.useEffect(()=>{if(!p?.find||!H?.fields||!M.length)return;let e=H.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 M){let t=e?.[n];t!=null&&(typeof t==`string`&&t?i.add(t):typeof t==`number`&&i.add(String(t)))}let a=U[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})=>p.find(t,{$filter:{id:{$in:n}},$top:n.length}).then(t=>{let n=Array.isArray(t)?t:t?.data||[],r={};for(let e of n){let t=e?.id||e?._id;t&&(r[String(t)]=e?.full_name||e?.fullname||e?.display_name||e?.name||e?.subject||e?.title||e?.label||e?.code||String(t))}return{fieldName:e,map:r}}).catch(t=>(console.warn(`[RelatedList] Failed to resolve lookups for ${e}:`,t),{fieldName:e,map:{}})))).then(e=>{n||W(t=>{let n={...t};for(let{fieldName:t,map:r}of e)n[t]={...n[t]||{},...r};return n})}),()=>{n=!0}},[p,H,M]);let q=n.useMemo(()=>{if(!V)return M;let e=V.toLowerCase();return M.filter(t=>Object.values(t).some(t=>t!=null&&String(t).toLowerCase().includes(e)))},[M,V]),J=n.useMemo(()=>R?[...q].sort((e,t)=>{let n=e[R],r=t[R];if(n==null&&r==null)return 0;if(n==null)return 1;if(r==null)return-1;let i=String(n).localeCompare(String(r),void 0,{numeric:!0});return z===`asc`?i:-i}):q,[q,R,z]),Y=x&&x>0?x:0,X=Y?Math.max(1,Math.ceil(J.length/Y)):1,Z=Y?J.slice(I*Y,(I+1)*Y):J;n.useEffect(()=>{L(0)},[V,R,z]);let ae=n.useCallback(e=>{R===e?B(e=>e===`asc`?`desc`:`asc`):(ee(e),B(`asc`))},[R]),[Q,oe]=n.useState(null),se=n.useCallback(e=>{oe(e)},[]),ce=n.useCallback(()=>{Q&&v?.(Q),oe(null)},[Q,v]),$=n.useMemo(()=>{let e=e=>O?e.filter(e=>(e?.accessorKey||e?.field||e?.name)!==O):e,t=e=>e==null||typeof e==`string`&&e.trim()===``||Array.isArray(e)&&e.length===0,r=e=>M.length?e.filter(e=>{let n=e?.accessorKey||e?.field||e?.name;return n?M.some(e=>!t(e?.[n])):!0}):e;if(d&&d.length>0)return r(e(d));if(!H?.fields)return[];let i=m||c||``,a=new Set([`image`,`file`,`attachment`,`rich_text`,`html`,`json`]),s=[`name`,`full_name`,`fullname`,`title`,`subject`,`label`,`code`,`number`],l=Object.entries(H.fields).filter(([e,t])=>!(e.startsWith(`_`)||e===`id`||e===O||t?.hidden||t?.type&&a.has(t.type)));return l.sort(([e,t],[n,r])=>{let i=s.indexOf(e),a=s.indexOf(n),o=i>=0?i:100,c=a>=0?a:100;if(o!==c)return o-c;let l=t?.type===`select`||e.includes(`status`);return l===(r?.type===`select`||n.includes(`status`))?0:l?-1:1}),r(l.map(([e,t])=>{let r={accessorKey:e,header:K(i,e,t.label||e)};if(t.type){let i=(0,o.getCellRenderer)((0,o.resolveCellRendererType)({type:t.type,format:t.format})||t.type);if(i){let a=t.type===`lookup`||t.type===`master_detail`?U[e]:void 0,o=a&&Object.keys(a).length>0?Object.entries(a).map(([e,t])=>({value:e,label:t})):void 0,s={name:e,label:t.label||e,type:t.type,...(o||t.options)&&{options:o||t.options},...t.currency&&{currency:t.currency},...t.precision!==void 0&&{precision:t.precision},...t.format&&{format:t.format},...(t.reference_to||t.reference)&&{reference_to:t.reference_to||t.reference},...t.reference_field&&{reference_field:t.reference_field}};r.cell=e=>e==null?n.createElement(`span`,{className:`text-muted-foreground/50 text-xs italic`},`—`):n.createElement(i,{value:e,field:s})}}return r})).slice(0,Math.max(1,b))},[d,H,m,c,K,O,M,b,U]),le=!!_||!!v,ue=n.useMemo(()=>{if(u)return u;switch(t){case`grid`:case`table`:return{type:`data-table`,data:Z,columns:$,pagination:!1,pageSize:Y||10,searchable:!1,exportable:!1,rowActions:le,onRowEdit:_,onRowDelete:v?se:void 0,onRowClick:y};case`list`:return{type:`data-list`,data:Z};default:return{type:`div`,children:`No view configured`}}},[t,Z,$,u,Y,le,_,v,se,y]),de=T?`cursor-pointer select-none`:void 0,fe=T?()=>ie(e=>!e):void 0,pe=E(k),me=!P&&M.length===0,he=w;return(0,s.jsxs)(r.Card,{className:(0,r.cn)(`shadow-none`,me&&`bg-muted/20`,f),children:[(0,s.jsx)(r.CardHeader,{className:(0,r.cn)(`py-3 px-4`,de),onClick:fe,children:(0,s.jsxs)(r.CardTitle,{className:`flex items-center justify-between gap-2 text-sm font-semibold`,children:[(0,s.jsxs)(`div`,{className:`flex items-center gap-2 min-w-0`,children:[T&&(re?(0,s.jsx)(i.ChevronRight,{className:`h-3.5 w-3.5 text-muted-foreground shrink-0`}):(0,s.jsx)(i.ChevronDown,{className:`h-3.5 w-3.5 text-muted-foreground shrink-0`})),(0,s.jsx)(pe,{className:`h-4 w-4 text-muted-foreground shrink-0`,"aria-hidden":!0}),(0,s.jsx)(`span`,{className:`truncate`,children:e}),(0,s.jsx)(r.Badge,{variant:`secondary`,className:(0,r.cn)(`text-xs font-normal h-5 px-1.5`,M.length===0&&`bg-muted text-muted-foreground`),"aria-label":`${M.length} records`,children:M.length})]}),(0,s.jsx)(`div`,{className:`flex items-center gap-1 shrink-0`,children:h&&(0,s.jsxs)(r.Button,{variant:`outline`,size:`sm`,onClick:e=>{e.stopPropagation(),h()},className:`gap-1 h-7 text-xs shadow-none`,children:[(0,s.jsx)(i.Plus,{className:`h-3.5 w-3.5`}),G(`detail.new`)]})})]})}),!re&&(0,s.jsxs)(r.CardContent,{className:(0,r.cn)(`pt-0`,me?`pb-3 px-4`:`pb-4 px-4`),children:[he&&(0,s.jsx)(`div`,{className:`mb-3`,children:(0,s.jsx)(r.Input,{placeholder:G(`detail.filterPlaceholder`),value:V,onChange:e=>te(e.target.value),className:`h-8 text-sm`})}),C&&$&&$.length>0&&M.length>0&&(0,s.jsx)(`div`,{className:`flex flex-wrap gap-1 mb-3`,children:$.map(e=>{let t=e.accessorKey||e.field||e.name;if(!t)return null;let n=e.header||e.label||t,a=R===t;return(0,s.jsxs)(r.Button,{variant:a?`secondary`:`ghost`,size:`sm`,className:`gap-1 h-7 text-xs`,onClick:()=>ae(t),children:[(0,s.jsx)(i.ArrowUpDown,{className:`h-3 w-3`}),n,a&&(z===`asc`?` ↑`:` ↓`)]},t)})}),P?(0,s.jsx)(`div`,{className:`flex items-center justify-center py-6 text-muted-foreground text-sm`,children:G(`detail.loading`)}):me?(0,s.jsxs)(`div`,{className:`flex flex-col items-center justify-center gap-2 py-6 text-sm`,children:[(0,s.jsx)(pe,{className:`h-8 w-8 text-muted-foreground/40`,"aria-hidden":!0}),(0,s.jsx)(`span`,{className:`text-muted-foreground italic`,children:G(`detail.noRelatedRecords`)}),h&&(0,s.jsxs)(r.Button,{variant:`outline`,size:`sm`,onClick:h,className:`gap-1 h-7 text-xs mt-1`,children:[(0,s.jsx)(i.Plus,{className:`h-3.5 w-3.5`}),G(`detail.new`)]})]}):(0,s.jsx)(a.SchemaRenderer,{schema:ue}),Y>0&&J.length>Y&&(0,s.jsxs)(`div`,{className:`flex items-center justify-between mt-3 pt-3 border-t`,children:[(0,s.jsxs)(r.Button,{variant:`outline`,size:`sm`,className:`h-7 text-xs gap-1`,disabled:I===0,onClick:()=>L(e=>Math.max(0,e-1)),children:[(0,s.jsx)(i.ChevronLeft,{className:`h-3 w-3`}),G(`detail.previousPage`)]}),(0,s.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:G(`detail.pageOf`,{current:I+1,total:X})}),(0,s.jsxs)(r.Button,{variant:`outline`,size:`sm`,className:`h-7 text-xs gap-1`,disabled:I>=X-1,onClick:()=>L(e=>Math.min(X-1,e+1)),children:[G(`detail.nextPage`),(0,s.jsx)(i.ChevronRight,{className:`h-3 w-3`})]})]}),g&&!me&&Y>0&&J.length>Y&&(0,s.jsx)(`div`,{className:`mt-3 pt-3 border-t flex justify-center`,children:(0,s.jsxs)(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),g()},className:`text-xs text-muted-foreground hover:text-foreground inline-flex items-center gap-1 transition-colors`,children:[G(`detail.viewAll`),(0,s.jsx)(i.ExternalLink,{className:`h-3 w-3`})]})})]}),(0,s.jsx)(r.AlertDialog,{open:Q!==null,onOpenChange:e=>{e||oe(null)},children:(0,s.jsxs)(r.AlertDialogContent,{children:[(0,s.jsxs)(r.AlertDialogHeader,{children:[(0,s.jsx)(r.AlertDialogTitle,{children:G(`detail.deleteRowTitle`,{defaultValue:`Delete record`})}),(0,s.jsx)(r.AlertDialogDescription,{children:G(`detail.deleteRowConfirmation`)})]}),(0,s.jsxs)(r.AlertDialogFooter,{children:[(0,s.jsx)(r.AlertDialogCancel,{children:G(`detail.cancel`,{defaultValue:`Cancel`})}),(0,s.jsx)(r.AlertDialogAction,{onClick:ce,className:`bg-destructive text-destructive-foreground hover:bg-destructive/90`,children:G(`detail.delete`,{defaultValue:`Delete`})})]})]})})]})},O=({group:e,data:t,className:a,objectSchema:o,objectName:c,isEditing:l=!1,onFieldChange:u})=>{let d=e.collapsible??!0,[f,p]=n.useState(e.defaultCollapsed??!1),m=(0,s.jsx)(`div`,{className:`space-y-3 sm:space-y-4`,children:e.sections.map((e,n)=>(0,s.jsx)(w,{section:e,data:t,objectSchema:o,objectName:c,isEditing:l,onFieldChange:u},n))});return d?(0,s.jsxs)(r.Collapsible,{open:!f,onOpenChange:e=>p(!e),className:a,children:[(0,s.jsx)(r.CollapsibleTrigger,{asChild:!0,children:(0,s.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:[f?(0,s.jsx)(i.ChevronRight,{className:`h-4 w-4 text-muted-foreground shrink-0`}):(0,s.jsx)(i.ChevronDown,{className:`h-4 w-4 text-muted-foreground shrink-0`}),e.icon&&(0,s.jsx)(`span`,{className:`text-muted-foreground`,children:e.icon}),(0,s.jsx)(`h3`,{className:`text-lg font-semibold`,children:e.title})]})}),e.description&&!f&&(0,s.jsx)(`p`,{className:`text-sm text-muted-foreground mt-1`,children:e.description}),(0,s.jsx)(r.CollapsibleContent,{children:(0,s.jsx)(`div`,{className:`mt-3`,children:m})})]}):(0,s.jsxs)(`div`,{className:(0,r.cn)(`space-y-3`,a),children:[(0,s.jsxs)(`div`,{className:`flex items-center gap-2 pb-2 border-b`,children:[e.icon&&(0,s.jsx)(`span`,{className:`text-muted-foreground`,children:e.icon}),(0,s.jsx)(`h3`,{className:`text-lg font-semibold`,children:e.title})]}),e.description&&(0,s.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:e.description}),m]})},k=({fields:e,data:t,className:n,objectName:i,objectSchema:c})=>{let{fieldLabel:l}=(0,a.useSafeFieldLabel)();if(!e.length||!t)return null;let u=e.filter(e=>{let n=t?.[e.name];return n!=null&&n!==``});return u.length===0?null:(0,s.jsx)(r.Card,{className:(0,r.cn)(`bg-muted/30 border-dashed`,n),children:(0,s.jsx)(r.CardContent,{className:`py-3 px-4`,children:(0,s.jsx)(`div`,{className:(0,r.cn)(`grid gap-4`,u.length===1?`grid-cols-1`:u.length===2?`grid-cols-2`:u.length===3?`grid-cols-3`:`grid-cols-2 md:grid-cols-4`),children:u.map(e=>{let n=t[e.name],r=c?.fields?.[e.name],a=e.type||r?.type,u={name:e.name,label:e.label,type:a||`text`,...r?.options&&{options:r.options},...r?.currency&&{currency:r.currency},...r?.precision!==void 0&&{precision:r.precision},...r?.format&&{format:r.format}},d=(0,o.getCellRenderer)((0,o.resolveCellRendererType)(u)||a||`text`);return(0,s.jsxs)(`div`,{className:`flex flex-col gap-0.5`,children:[(0,s.jsxs)(`span`,{className:`text-xs font-medium text-muted-foreground uppercase tracking-wide`,children:[e.icon&&(0,s.jsx)(`span`,{className:`mr-1`,children:e.icon}),l(i||``,e.name,e.label)]}),(0,s.jsx)(`span`,{className:`text-sm font-semibold truncate`,children:(0,s.jsx)(d,{value:n,field:u})})]},e.name)})})})})};function A(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 j=({comments:e,onAddComment:t,onTogglePin:a,searchable:o=!1,className:c})=>{let{t:l}=S(),[u,d]=n.useState(``),[f,p]=n.useState(!1),[m,h]=n.useState(``),g=n.useCallback(async()=>{let e=u.trim();if(!(!e||!t)){p(!0);try{await t(e),d(``)}finally{p(!1)}}},[u,t]),_=n.useCallback(e=>{e.key===`Enter`&&(e.ctrlKey||e.metaKey)&&(e.preventDefault(),g())},[g]),v=n.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,s.jsxs)(r.Card,{className:(0,r.cn)(``,c),children:[(0,s.jsx)(r.CardHeader,{children:(0,s.jsxs)(r.CardTitle,{className:`flex items-center gap-2 text-base`,children:[(0,s.jsx)(i.MessageSquare,{className:`h-4 w-4`}),l(`detail.comments`),(0,s.jsxs)(`span`,{className:`text-sm font-normal text-muted-foreground`,children:[`(`,e.length,`)`]})]})}),(0,s.jsxs)(r.CardContent,{className:`space-y-4`,children:[o&&(0,s.jsx)(`div`,{className:`flex items-center gap-2`,children:(0,s.jsxs)(`div`,{className:`relative flex-1`,children:[(0,s.jsx)(i.Search,{className:`absolute left-2.5 top-1/2 -translate-y-1/2 h-3.5 w-3.5 text-muted-foreground`}),(0,s.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:l(`detail.searchComments`),value:m,onChange:e=>h(e.target.value),"aria-label":l(`detail.searchComments`)}),m&&(0,s.jsx)(`button`,{className:`absolute right-2 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground`,onClick:()=>h(``),"aria-label":l(`detail.clearSearch`),type:`button`,children:(0,s.jsx)(i.X,{className:`h-3.5 w-3.5`})})]})}),t&&(0,s.jsxs)(`div`,{className:`flex gap-2`,children:[(0,s.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:l(`detail.addCommentPlaceholder`),value:u,onChange:e=>d(e.target.value),onKeyDown:_,disabled:f}),(0,s.jsx)(r.Button,{size:`icon`,variant:`default`,onClick:g,disabled:!u.trim()||f,className:`shrink-0 self-end`,children:(0,s.jsx)(i.Send,{className:`h-4 w-4`})})]}),v.length===0?(0,s.jsx)(`p`,{className:`text-sm text-muted-foreground text-center py-4`,children:m.trim()?l(`detail.noMatchingComments`):l(`detail.noCommentsYet`)}):(0,s.jsx)(`div`,{className:`space-y-3`,children:v.map(e=>(0,s.jsxs)(`div`,{className:(0,r.cn)(`flex gap-3`,e.pinned&&`bg-muted/40 rounded-md p-2 -mx-2`),children:[(0,s.jsx)(`div`,{className:`shrink-0`,children:e.avatarUrl?(0,s.jsx)(`img`,{src:e.avatarUrl,alt:e.author,className:`h-8 w-8 rounded-full object-cover`}):(0,s.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,s.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,s.jsxs)(`div`,{className:`flex items-center gap-2 mb-0.5`,children:[(0,s.jsx)(`span`,{className:`text-sm font-medium truncate`,children:e.author}),(0,s.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:A(e.createdAt)}),e.pinned&&(0,s.jsxs)(`span`,{className:`text-xs text-amber-600 flex items-center gap-0.5`,children:[(0,s.jsx)(i.Pin,{className:`h-3 w-3`}),l(`detail.pinned`)]})]}),(0,s.jsx)(`p`,{className:`text-sm whitespace-pre-wrap break-words`,children:e.text}),a&&(0,s.jsxs)(`button`,{type:`button`,className:`mt-1 text-xs text-muted-foreground hover:text-foreground flex items-center gap-1`,onClick:()=>a(e.id),"aria-label":e.pinned?l(`detail.unpin`):l(`detail.pin`),children:[(0,s.jsx)(i.Pin,{className:`h-3 w-3`}),e.pinned?l(`detail.unpin`):l(`detail.pin`)]})]})]},e.id))})]})]})},M={field_change:i.Edit,create:i.PlusCircle,delete:i.Trash2,comment:i.MessageSquare,status_change:i.ArrowRightLeft},N={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 P(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 F(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 I={all:`All`,field_change:`Field Changes`,create:`Creates`,delete:`Deletes`,comment:`Comments`,status_change:`Status Changes`},L=({activities:e,filterable:t=!1,defaultFilter:a=`all`,className:o})=>{let[c,l]=n.useState(a),u=n.useMemo(()=>c===`all`?e:e.filter(e=>e.type===c),[e,c]);return(0,s.jsxs)(r.Card,{className:(0,r.cn)(``,o),children:[(0,s.jsx)(r.CardHeader,{children:(0,s.jsxs)(r.CardTitle,{className:`flex items-center gap-2 text-base`,children:[(0,s.jsx)(i.Activity,{className:`h-4 w-4`}),`Activity`,(0,s.jsxs)(`span`,{className:`text-sm font-normal text-muted-foreground`,children:[`(`,u.length,`)`]})]})}),(0,s.jsxs)(r.CardContent,{children:[t&&(0,s.jsx)(`div`,{className:`flex flex-wrap gap-1.5 mb-4`,role:`group`,"aria-label":`Activity type filter`,children:Object.keys(I).map(e=>(0,s.jsxs)(`button`,{type:`button`,className:(0,r.cn)(`inline-flex items-center gap-1 rounded-full px-2.5 py-0.5 text-xs font-medium transition-colors`,c===e?`bg-primary text-primary-foreground`:`bg-muted text-muted-foreground hover:bg-muted/80`),onClick:()=>l(e),"aria-pressed":c===e,children:[e!==`all`&&n.createElement(M[e]||i.Edit,{className:`h-3 w-3`}),I[e]]},e))}),u.length===0?(0,s.jsx)(`p`,{className:`text-sm text-muted-foreground text-center py-4`,children:`No activity recorded`}):(0,s.jsxs)(`div`,{className:`relative`,children:[(0,s.jsx)(`div`,{className:`absolute left-4 top-2 bottom-2 w-px bg-border`}),(0,s.jsx)(`div`,{className:`space-y-4`,children:u.map(e=>{let t=M[e.type]||i.Edit;return(0,s.jsxs)(`div`,{className:`flex gap-3 relative`,children:[(0,s.jsx)(`div`,{className:(0,r.cn)(`shrink-0 h-8 w-8 rounded-full flex items-center justify-center z-10`,N[e.type]||`bg-gray-100 text-gray-600`),children:(0,s.jsx)(t,{className:`h-3.5 w-3.5`})}),(0,s.jsxs)(`div`,{className:`flex-1 min-w-0 pt-1`,children:[(0,s.jsxs)(`p`,{className:`text-sm`,children:[(0,s.jsx)(`span`,{className:`font-medium`,children:e.user}),` `,(0,s.jsx)(`span`,{className:`text-muted-foreground`,children:F(e)})]}),(0,s.jsx)(`p`,{className:`text-xs text-muted-foreground mt-0.5`,children:P(e.timestamp)})]})]},e.id)})})]})]})]})},R=5;function ee(e,t,n,r){if(e&&typeof e==`object`){if(t.primaryField){let n=e[t.primaryField];if(n!=null&&n!==``)return String(n)}let r=n?.titleFormat,i=typeof r==`string`?r:r&&typeof r==`object`&&typeof r.source==`string`?r.source:void 0;if(i){let t=`[-\\u2013\\u2014|/·,:]`,n=!1,r=i.replace(/\{([^{}]+)\}/g,(t,r)=>{let i=e[r.trim()];return i!=null&&i!==``?(n=!0,String(i)):`\0`});if(n){let e=r.replace(RegExp(`\\s*${t}\\s*`,`g`),``).replace(RegExp(`\\s*${t}\\s*`,`g`),``).replace(RegExp(`\0`,`g`),``).replace(/\s+/g,` `).trim();if(e)return e}}}if(t.title)return t.title;if(e&&typeof e==`object`)for(let t of[`name`,`full_name`,`fullName`,`title`,`subject`,`label`,`display_name`,`displayName`]){let n=e[t];if(typeof n==`string`&&n.trim())return n.trim();if(n!=null&&n!==``)return String(n)}return r}var z=({schema:e,dataSource:o,className:c,onEdit:l,onDelete:u,onBack:d,inlineEdit:f=!1,onFieldSave:p,discussionSlot:m,rightRail:h,objectLabel:g,onDataLoaded:_})=>{let[v,y]=n.useState(e.data),[b,x]=n.useState(!e.data&&!!(e.api&&e.resourceId||o&&e.objectName&&e.resourceId)),[C,E]=n.useState(!1),[A,M]=n.useState(!1),[N,P]=n.useState({}),[F,I]=n.useState(null),[z,B]=n.useState(!1),{t:V}=S(),{fieldOptionLabel:te}=(0,a.useSafeFieldLabel)();n.useEffect(()=>{v&&_&&_(v)},[v,_]);let H=n.useMemo(()=>{if(e.summaryFields&&e.summaryFields.length>0)return[];let t=[...e.sections?.flatMap(e=>e.fields)||[],...e.fields||[]],n={};for(let e of t)n[e.name]||(n[e.name]=e);if(F?.fields)for(let[e,t]of Object.entries(F.fields))n[e]={...n[e]||{},...t,name:e};let r=e=>v?.[e]!==void 0&&v?.[e]!==null&&v?.[e]!==``,i=[],a=[`status`,`stage`,`state`,`phase`].find(e=>n[e]&&r(e))||Object.keys(n).find(e=>n[e]?.type===`select`&&r(e));a&&i.push(a);let o=Object.keys(n).find(e=>(n[e]?.type===`currency`||/amount|revenue|value|total|price/i.test(e))&&r(e));o&&!i.includes(o)&&i.push(o);let s=Object.keys(n).find(e=>(n[e]?.type===`date`||n[e]?.type===`datetime`)&&/close|due|start|end|expected/i.test(e)&&r(e));return s&&!i.includes(s)&&i.push(s),i},[e.summaryFields,e.sections,e.fields,F,v]),ne=e.summaryFields&&e.summaryFields.length>0?e.summaryFields:H,re=n.useCallback(()=>{e.resourceId&&navigator.clipboard.writeText(String(e.resourceId)).then(()=>{B(!0),setTimeout(()=>B(!1),1500)})},[e.resourceId]);n.useEffect(()=>{let n=!0;if(e.data){y(e.data),x(!1);return}if(o&&e.objectName&&e.resourceId){x(!0),I(null),y(null);let r=e.objectName,i=e.resourceId,a=`${r}-`,s=[...e.sections?.flatMap(e=>e.fields)||[],...e.fields||[]];(o.getObjectSchema?o.getObjectSchema(r).catch(()=>null):Promise.resolve(null)).then(e=>{if(!n)return;I(e);let c=(0,t.buildExpandFields)(e?.fields,s),l=c.length>0?{$expand:c}:void 0,u=l?o.findOne(r,i,l):o.findOne(r,i),d=()=>{let e=String(i),t=e.startsWith(a)?e.slice(a.length):`${a}${e}`;return(l?o.findOne(r,t,l):o.findOne(r,t)).then(e=>{n&&(y(e),x(!1))}).catch(()=>{n&&(y(null),x(!1))})};return u.catch(()=>null).then(e=>{if(n){if(e){y(e),x(!1);return}return d()}})}).catch(e=>{n&&(console.error(`Failed to fetch detail data:`,e),x(!1))})}else e.api&&e.resourceId&&(x(!0),fetch(`${e.api}/${e.resourceId}`).then(e=>e.json()).then(e=>{n&&y(e?.data||e)}).catch(e=>{console.error(`Failed to fetch detail data:`,e)}).finally(()=>{n&&x(!1)}));return()=>{n=!1}},[e.api,e.resourceId,e.objectName,o,e.sections,e.fields]);let ie=n.useCallback(()=>{if(d)d();else if(e.onNavigate){let t=e.backUrl||(e.objectName?`/${e.objectName}`:`/`);e.onNavigate(t,{replace:!0})}else e.backUrl?window.location.href=e.backUrl:window.history.back()},[d,e]),U=n.useCallback(()=>{l?l():e.onNavigate&&e.editUrl?e.onNavigate(e.editUrl):e.onNavigate&&e.objectName&&e.resourceId?e.onNavigate(`/${e.objectName}/${e.resourceId}/edit`):e.editUrl&&(window.location.href=e.editUrl)},[l,e]),W=n.useCallback(()=>{let t=e.deleteConfirmation||V(`detail.deleteConfirmation`);window.confirm(t)&&(u?.(),e.onNavigate&&e.objectName&&e.onNavigate(`/${e.objectName}`,{replace:!0}))},[u,e]),G=n.useCallback(()=>{navigator.share&&e.objectName&&e.resourceId?navigator.share({title:e.title||V(`detail.details`),text:`${e.objectName} #${e.resourceId}`,url:window.location.href}).catch(e=>console.log(`Share failed:`,e)):navigator.clipboard.writeText(window.location.href).then(()=>{console.log(`Link copied to clipboard`)})},[e]),K=n.useCallback(()=>{E(!C)},[C]),q=n.useCallback(()=>{if(A){let e=Object.entries(N);if(e.length>0){let t={...v,...N};y(t),e.forEach(([e,n])=>{p?.(e,n,t)})}P({})}M(!A)},[A,N,v,p]),J=n.useCallback(()=>{P({}),M(!1)},[]),Y=n.useCallback((e,t)=>{P(n=>({...n,[e]:t}))},[]);n.useEffect(()=>{if(!e.recordNavigation)return;let t=e.recordNavigation,n=e=>{let n=e.target?.tagName;n===`INPUT`||n===`TEXTAREA`||e.target?.isContentEditable||(e.key===`ArrowLeft`&&t.currentIndex>0?(e.preventDefault(),t.onNavigate(t.recordIds[t.currentIndex-1])):e.key===`ArrowRight`&&t.currentIndex<t.recordIds.length-1&&(e.preventDefault(),t.onNavigate(t.recordIds[t.currentIndex+1])))};return document.addEventListener(`keydown`,n),()=>document.removeEventListener(`keydown`,n)},[e.recordNavigation]);let X=n.useMemo(()=>e.related??[],[e.related]),Z=n.useMemo(()=>{let t=[];return t.push({name:`sys_share`,label:V(`detail.share`),icon:`share-2`,type:`script`,onClick:G}),e.showEdit&&t.push({name:`sys_edit_mobile`,label:V(`detail.edit`),icon:`edit`,type:`script`,className:`sm:hidden`,onClick:U}),f&&t.push({name:`sys_toggle_inline_edit_mobile`,label:V(A?`detail.save`:`detail.editInline`),icon:`edit`,type:`script`,className:`sm:hidden`,onClick:q}),e.showDelete&&t.push({name:`sys_delete`,label:V(`detail.delete`),icon:`trash-2`,type:`script`,variant:`destructive`,tags:[`separator-before`],onClick:W}),t},[V,e.showEdit,e.showDelete,f,A,G,U,q,W]),ae=n.useMemo(()=>{let t=e.actions??[];if(Z.length===0)return t;let n=!1,r=t.map(e=>{let t=e;if(t&&typeof t==`object`&&t.type===`action:bar`&&(!t.location||t.location===`record_header`)){n=!0;let e=Array.isArray(t.systemActions)?t.systemActions:[];return{...t,systemActions:[...e,...Z]}}return e});return n||r.push({type:`action:bar`,location:`record_header`,systemActions:Z}),r},[e.actions,Z]);return b||e.loading?(0,s.jsxs)(`div`,{className:(0,r.cn)(`space-y-4`,c),children:[(0,s.jsx)(r.Skeleton,{className:`h-10 w-full`}),(0,s.jsx)(r.Skeleton,{className:`h-64 w-full`}),(0,s.jsx)(r.Skeleton,{className:`h-48 w-full`})]}):!v&&!e.data?(0,s.jsxs)(`div`,{className:(0,r.cn)(`flex flex-col items-center justify-center py-16 text-center`,c),children:[(0,s.jsx)(`p`,{className:`text-lg font-semibold`,children:V(`detail.recordNotFound`)}),(0,s.jsx)(`p`,{className:`text-sm text-muted-foreground mt-1`,children:V(`detail.recordNotFoundDescription`)}),(e.showBack??!0)&&(0,s.jsxs)(r.Button,{variant:`outline`,size:`sm`,onClick:ie,className:`mt-4 gap-2`,children:[(0,s.jsx)(i.ArrowLeft,{className:`h-4 w-4`}),V(`detail.goBack`)]})]}):(0,s.jsx)(r.TooltipProvider,{children:(0,s.jsxs)(`div`,{className:(0,r.cn)(`space-y-6`,c),children:[(0,s.jsxs)(`div`,{className:`flex flex-col sm:flex-row items-start justify-between gap-3 sm:gap-4 pb-4 border-b`,children:[(0,s.jsxs)(`div`,{className:`flex items-start gap-2 sm:gap-3 flex-1 min-w-0`,children:[(e.showBack??!0)&&(0,s.jsxs)(r.Tooltip,{children:[(0,s.jsx)(r.TooltipTrigger,{asChild:!0,children:(0,s.jsx)(r.Button,{variant:`ghost`,size:`icon`,onClick:ie,className:`shrink-0 mt-1`,children:(0,s.jsx)(i.ArrowLeft,{className:`h-4 w-4`})})}),(0,s.jsx)(r.TooltipContent,{children:V(`detail.back`)})]}),(0,s.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,s.jsxs)(`div`,{className:`flex items-center gap-2 flex-wrap`,children:[(0,s.jsx)(`h1`,{className:`text-xl sm:text-2xl font-bold truncate`,children:ee(v,e,F,V(`detail.details`))}),ne.map(t=>{let n=v?.[t];if(n==null||n===``)return null;let i=(e.sections||[]).flatMap(e=>e.fields).concat(e.fields||[]).find(e=>e.name===t),a=F?.fields?.[t],o=i?.type||a?.type,c=String(n),l=null;try{if(o===`currency`){let e=Number(n);Number.isNaN(e)||(c=new Intl.NumberFormat(void 0,{style:`currency`,currency:i?.currency||a?.currency||`USD`,maximumFractionDigits:0}).format(e))}else if(o===`date`||o===`datetime`){let e=new Date(n);Number.isNaN(e.getTime())||(c=o===`datetime`?e.toLocaleString(void 0,{dateStyle:`medium`,timeStyle:`short`}):e.toLocaleDateString(void 0,{dateStyle:`medium`}))}else if(o===`percent`){let e=Number(n);if(!Number.isNaN(e)){c=`${e}%`;let t=e<=1?e*100:e;l=Math.max(0,Math.min(100,t))}}else if(o===`select`||o===`status`||o===`multiselect`){let r=i?.options||a?.options,o=String(n);if(Array.isArray(r)){let e=r.find(e=>String(e?.value??e)===String(n));e?.label&&(o=e.label)}else if(r&&typeof r==`object`){let e=r[String(n)];e?.label&&(o=e.label)}c=e.objectName?te(e.objectName,t,String(n),o):o}}catch{}return l===null?(0,s.jsx)(r.Badge,{variant:`secondary`,className:`text-xs bg-primary/10 text-primary border-transparent hover:bg-primary/15`,"aria-label":`${t}: ${c}`,children:c},t):(0,s.jsxs)(r.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":`${t}: ${c}`,children:[(0,s.jsx)(`span`,{className:`relative inline-block h-1.5 w-12 rounded-full bg-primary/20 overflow-hidden`,"aria-hidden":!0,children:(0,s.jsx)(`span`,{className:`absolute inset-y-0 left-0 rounded-full bg-primary`,style:{width:`${l}%`}})}),c]},t)}),(0,s.jsxs)(r.Tooltip,{children:[(0,s.jsx)(r.TooltipTrigger,{asChild:!0,children:(0,s.jsx)(r.Button,{variant:`ghost`,size:`icon`,className:`h-6 w-6 shrink-0`,onClick:K,"aria-label":V(C?`detail.removeFromFavorites`:`detail.addToFavorites`),children:C?(0,s.jsx)(i.Star,{className:`h-4 w-4 fill-yellow-400 text-yellow-400`}):(0,s.jsx)(i.Star,{className:`h-4 w-4 text-muted-foreground`})})}),(0,s.jsx)(r.TooltipContent,{children:V(C?`detail.removeFromFavorites`:`detail.addToFavorites`)})]})]}),e.objectName&&(0,s.jsxs)(`p`,{className:`text-sm text-muted-foreground mt-1 flex items-center gap-1`,children:[(0,s.jsx)(`span`,{className:`font-medium`,children:g||e.objectName}),e.resourceId&&(0,s.jsxs)(r.Tooltip,{children:[(0,s.jsx)(r.TooltipTrigger,{asChild:!0,children:(0,s.jsx)(r.Button,{variant:`ghost`,size:`icon`,className:`h-5 w-5 shrink-0 text-muted-foreground/60 hover:text-foreground`,onClick:re,"aria-label":V(`detail.copyRecordId`,{defaultValue:`Copy record ID`}),children:z?(0,s.jsx)(i.Check,{className:`h-3 w-3 text-green-600`}):(0,s.jsx)(i.Copy,{className:`h-3 w-3`})})}),(0,s.jsx)(r.TooltipContent,{children:z?V(`detail.copied`,{defaultValue:`Copied`}):V(`detail.copyRecordId`,{defaultValue:`Copy record ID`})})]})]})]})]}),(0,s.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5 shrink-0 w-full sm:w-auto`,children:[e.recordNavigation&&(0,s.jsxs)(`div`,{className:`flex items-center gap-1 mr-2`,children:[(0,s.jsxs)(r.Tooltip,{children:[(0,s.jsx)(r.TooltipTrigger,{asChild:!0,children:(0,s.jsx)(r.Button,{variant:`outline`,size:`icon`,className:`h-8 w-8`,disabled:e.recordNavigation.currentIndex<=0,onClick:()=>{let t=e.recordNavigation;t.currentIndex>0&&t.onNavigate(t.recordIds[t.currentIndex-1])},children:(0,s.jsx)(i.ChevronLeft,{className:`h-4 w-4`})})}),(0,s.jsx)(r.TooltipContent,{children:V(`detail.previousRecord`)})]}),(0,s.jsx)(`span`,{className:`text-xs text-muted-foreground whitespace-nowrap px-1`,children:V(`detail.recordOf`,{current:e.recordNavigation.currentIndex+1,total:e.recordNavigation.recordIds.length})}),(0,s.jsxs)(r.Tooltip,{children:[(0,s.jsx)(r.TooltipTrigger,{asChild:!0,children:(0,s.jsx)(r.Button,{variant:`outline`,size:`icon`,className:`h-8 w-8`,disabled:e.recordNavigation.currentIndex>=e.recordNavigation.recordIds.length-1,onClick:()=>{let t=e.recordNavigation;t.currentIndex<t.recordIds.length-1&&t.onNavigate(t.recordIds[t.currentIndex+1])},children:(0,s.jsx)(i.ChevronRight,{className:`h-4 w-4`})})}),(0,s.jsx)(r.TooltipContent,{children:V(`detail.nextRecord`)})]})]}),f&&(0,s.jsxs)(s.Fragment,{children:[A&&(0,s.jsxs)(r.Tooltip,{children:[(0,s.jsx)(r.TooltipTrigger,{asChild:!0,children:(0,s.jsxs)(r.Button,{variant:`ghost`,size:`sm`,onClick:J,className:`gap-2 hidden sm:inline-flex`,children:[(0,s.jsx)(i.X,{className:`h-4 w-4`}),(0,s.jsx)(`span`,{className:`hidden sm:inline`,children:V(`detail.cancel`)})]})}),(0,s.jsx)(r.TooltipContent,{children:V(`detail.cancelEdit`)})]}),(0,s.jsxs)(r.Tooltip,{children:[(0,s.jsx)(r.TooltipTrigger,{asChild:!0,children:(0,s.jsx)(r.Button,{variant:A?`default`:`outline`,size:`sm`,onClick:q,className:`gap-2 hidden sm:inline-flex`,children:A?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(i.Check,{className:`h-4 w-4`}),(0,s.jsx)(`span`,{className:`hidden sm:inline`,children:V(`detail.save`)})]}):(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(i.Edit,{className:`h-4 w-4`}),(0,s.jsx)(`span`,{className:`hidden sm:inline`,children:V(`detail.editInline`)})]})})}),(0,s.jsx)(r.TooltipContent,{children:V(A?`detail.saveChanges`:`detail.editFieldsInline`)})]})]}),e.showEdit&&(0,s.jsxs)(r.Tooltip,{children:[(0,s.jsx)(r.TooltipTrigger,{asChild:!0,children:(0,s.jsxs)(r.Button,{variant:`default`,onClick:U,className:`gap-2 hidden sm:inline-flex`,children:[(0,s.jsx)(i.Edit,{className:`h-4 w-4`}),(0,s.jsx)(`span`,{className:`hidden sm:inline`,children:V(`detail.edit`)})]})}),(0,s.jsx)(r.TooltipContent,{children:V(`detail.editRecord`)})]}),ae.map((e,t)=>(0,s.jsx)(a.SchemaRenderer,{schema:e,data:v},`header-action-${t}`))]})]}),e.header&&(0,s.jsx)(`div`,{children:(0,s.jsx)(a.SchemaRenderer,{schema:e.header,data:v})}),e.highlightFields&&e.highlightFields.length>0&&(0,s.jsx)(k,{fields:e.highlightFields,data:v,objectName:e.objectName,objectSchema:F}),e.autoTabs&&!e.tabs?.length?(()=>{let t=X.length>0,n=!!e.activities&&e.activities.length>0,i=!!m,a=(0,s.jsxs)(`div`,{className:`space-y-3 sm:space-y-4`,children:[e.sectionGroups&&e.sectionGroups.length>0&&e.sectionGroups.map((t,n)=>(0,s.jsx)(O,{group:t,data:{...v,...N},objectSchema:F,objectName:e.objectName,isEditing:A,onFieldChange:Y},n)),e.sections&&e.sections.length>0&&e.sections.map((t,n)=>(0,s.jsx)(w,{section:t,data:{...v,...N},objectSchema:F,objectName:e.objectName,isEditing:A,onFieldChange:Y},n)),e.fields&&e.fields.length>0&&!e.sections?.length&&(0,s.jsx)(w,{section:{fields:e.fields,columns:e.columns},data:{...v,...N},objectSchema:F,objectName:e.objectName,isEditing:A,onFieldChange:Y}),e.comments&&(0,s.jsx)(j,{comments:e.comments,onAddComment:e.onAddComment})]});return!t&&!n&&!i?(0,s.jsx)(`div`,{className:`mt-2`,children:a}):(0,s.jsxs)(r.Tabs,{defaultValue:`details`,className:`w-full`,children:[(0,s.jsxs)(r.TabsList,{className:`w-full justify-start border-b rounded-none bg-transparent p-0`,children:[(0,s.jsx)(r.TabsTrigger,{value:`details`,className:`relative rounded-none border-b-2 border-transparent data-[state=active]:border-primary data-[state=active]:bg-transparent`,children:V(`detail.details`)}),t&&(0,s.jsx)(r.TabsTrigger,{value:`related`,className:`relative rounded-none border-b-2 border-transparent data-[state=active]:border-primary data-[state=active]:bg-transparent`,children:(0,s.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[V(`detail.related`),(0,s.jsx)(r.Badge,{variant:`secondary`,className:`text-xs bg-primary/10 text-primary border-transparent`,children:X.length})]})}),n&&(0,s.jsx)(r.TabsTrigger,{value:`activity`,className:`relative rounded-none border-b-2 border-transparent data-[state=active]:border-primary data-[state=active]:bg-transparent`,children:(0,s.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[V(`detail.activity`),(0,s.jsx)(r.Badge,{variant:`secondary`,className:`text-xs bg-primary/10 text-primary border-transparent`,children:e.activities.length})]})}),i&&(0,s.jsx)(r.TabsTrigger,{value:`discussion`,className:`relative rounded-none border-b-2 border-transparent data-[state=active]:border-primary data-[state=active]:bg-transparent`,children:V(`detail.discussion`,{defaultValue:`Discussion`})})]}),(0,s.jsx)(r.TabsContent,{value:`details`,className:`mt-4`,children:a}),t&&(0,s.jsx)(r.TabsContent,{value:`related`,className:`mt-4`,children:(0,s.jsx)(`div`,{className:`space-y-3`,children:X.map((e,t)=>(0,s.jsx)(D,{title:e.title,type:e.type,api:e.api,data:e.data,columns:e.columns,dataSource:o,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,pageSize:R},t))})}),n&&(0,s.jsx)(r.TabsContent,{value:`activity`,className:`mt-4`,children:(0,s.jsx)(L,{activities:e.activities})}),i&&(0,s.jsx)(r.TabsContent,{value:`discussion`,className:`mt-4`,children:m})]})})():(0,s.jsxs)(s.Fragment,{children:[e.sectionGroups&&e.sectionGroups.length>0&&(0,s.jsx)(`div`,{className:`space-y-3 sm:space-y-4`,children:e.sectionGroups.map((t,n)=>(0,s.jsx)(O,{group:t,data:{...v,...N},objectSchema:F,objectName:e.objectName,isEditing:A,onFieldChange:Y},n))}),e.sections&&e.sections.length>0&&(0,s.jsx)(`div`,{className:`space-y-3 sm:space-y-4`,children:e.sections.map((t,n)=>(0,s.jsx)(w,{section:t,data:{...v,...N},objectSchema:F,objectName:e.objectName,isEditing:A,onFieldChange:Y},n))}),e.fields&&e.fields.length>0&&!e.sections?.length&&(0,s.jsx)(w,{section:{fields:e.fields,columns:e.columns},data:{...v,...N},objectSchema:F,objectName:e.objectName,isEditing:A,onFieldChange:Y}),e.tabs&&e.tabs.length>0&&(0,s.jsx)(T,{tabs:e.tabs,data:v}),X.length>0&&(0,s.jsxs)(`div`,{className:`space-y-3`,children:[(0,s.jsx)(`h2`,{className:`text-lg font-semibold`,children:V(`detail.related`)}),X.map((e,t)=>(0,s.jsx)(D,{title:e.title,type:e.type,api:e.api,data:e.data,columns:e.columns,dataSource:o,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,pageSize:R},t))]}),e.comments&&(0,s.jsx)(j,{comments:e.comments,onAddComment:e.onAddComment}),e.activities&&e.activities.length>0&&(0,s.jsx)(L,{activities:e.activities})]}),e.footer&&(0,s.jsx)(`div`,{children:(0,s.jsx)(a.SchemaRenderer,{schema:e.footer,data:v})})]})})},B=new Set([`id`,`_id`,`__v`,`created_at`,`updated_at`,`createdAt`,`updatedAt`,`created_by`,`updated_by`,`organization_id`,`tenant_id`,`owner_id`,`deleted_at`,`is_deleted`]),V=480,te=95;function H({open:e,onClose:t,title:i,record:a,objectName:o,recordId:c,dataSource:l,objectSchema:u,width:d=`min(960px, 60vw)`,columns:f=2,systemFields:p=B,onFieldSave:m,onDelete:h,resizable:g=!0,fullPageHref:_}){let{t:v}=S(),y=`objectui.drawerWidth.${o}`,[b,x]=n.default.useState(()=>{if(typeof window>`u`||!g)return null;try{let e=window.localStorage.getItem(y);if(e){let t=parseInt(e,10);if(Number.isFinite(t)&&t>=V)return t}}catch{}return null}),C=n.default.useMemo(()=>g&&b!=null?`${b}px`:typeof d==`number`?`${d}px`:d,[g,b,d]),w=C?{width:C,maxWidth:C}:void 0,T=n.default.useRef(null),E=n.default.useCallback(e=>{if(!g)return;e.preventDefault();let t=b??(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*te/100:1600,i=Math.min(r,Math.max(V,t.startWidth+n));x(Math.round(i))},r=()=>{T.current,T.current=null,window.removeEventListener(`pointermove`,n),window.removeEventListener(`pointerup`,r),window.removeEventListener(`pointercancel`,r);try{x(e=>(e!=null&&window.localStorage.setItem(y,String(e)),e))}catch{}};window.addEventListener(`pointermove`,n),window.addEventListener(`pointerup`,r),window.addEventListener(`pointercancel`,r)},[g,b,y]),D=u?.fields??{},O=(Object.keys(D).length?Object.keys(D):Object.keys(a)).filter(e=>!p.has(e)&&!e.startsWith(`__`)).filter(e=>e in a).map(e=>{let t=D[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,format:t.format,reference_to:t.reference_to??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,s.jsx)(r.Sheet,{open:e,onOpenChange:e=>{e||t()},children:(0,s.jsxs)(r.SheetContent,{side:`right`,className:`w-full overflow-y-auto p-0 sm:!max-w-none`,style:w,onOpenAutoFocus:e=>e.preventDefault(),children:[g&&(0,s.jsx)(`div`,{role:`separator`,"aria-orientation":`vertical`,"aria-label":`Resize drawer`,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,s.jsx)(r.SheetHeader,{className:`sr-only`,children:(0,s.jsx)(r.SheetTitle,{children:i})}),(0,s.jsx)(`div`,{className:`px-6 pt-6 pb-6`,children:(0,s.jsx)(z,{dataSource:l,inlineEdit:!0,schema:{type:`detail-view`,objectName:o,resourceId:String(c),data:a,showDelete:!0,columns:f,fields:O,actions:_?[{type:`action:bar`,location:`record_header`,systemActions:[{name:`sys_open_new_tab`,label:v(`detail.openInNewTab`),icon:`external-link`,type:`script`,onClick:()=>window.open(_,`_blank`,`noopener`)}]}]:void 0},onFieldSave:async(e,t)=>{try{await m?.(e,t)}catch(e){console.error(`[RecordDetailDrawer] inline field save failed:`,e)}},onDelete:async()=>{try{await h?.(),t()}catch(e){console.error(`[RecordDetailDrawer] delete failed:`,e)}}})})]})})}function ne(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 re=({objectName:e,relationshipField:t,fields:a,onCreateRecord:o,onLinkRecord:c,onSearch:l,existingRecords:u=[],className:d})=>{let[f,p]=n.useState(!1),[m,h]=n.useState(`create`),[g,_]=n.useState({}),[v,y]=n.useState(``),[b,x]=n.useState(u),[S,C]=n.useState(!1),[w,T]=n.useState(!1),E=n.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]),D=n.useCallback(async e=>{if(y(e),l&&e.trim().length>=2){T(!0);try{x(await l(e))}finally{T(!1)}}},[l]),O=n.useCallback((e,t)=>{_(n=>({...n,[e]:t}))},[]),k=n.useCallback(async()=>{if(o){C(!0);try{await o({...g,[t]:!0}),_({}),p(!1)}finally{C(!1)}}},[o,g,t]),A=n.useCallback(async e=>{if(c){C(!0);try{await c(e),y(``),p(!1)}finally{C(!1)}}},[c]),j=n.useMemo(()=>a.filter(e=>e.required).every(e=>g[e.name]?.toString().trim()),[a,g]);return f?(0,s.jsxs)(r.Card,{className:(0,r.cn)(``,d),children:[(0,s.jsx)(r.CardHeader,{className:`pb-3`,children:(0,s.jsxs)(r.CardTitle,{className:`flex items-center justify-between text-sm`,children:[(0,s.jsxs)(`span`,{children:[m===`create`?`Create`:`Link`,` `,e]}),(0,s.jsx)(r.Button,{variant:`ghost`,size:`icon`,className:`h-6 w-6`,onClick:()=>p(!1),children:(0,s.jsx)(i.X,{className:`h-3.5 w-3.5`})})]})}),(0,s.jsx)(r.CardContent,{children:(0,s.jsxs)(r.Tabs,{value:m,onValueChange:h,children:[(0,s.jsxs)(r.TabsList,{className:`mb-3 w-full`,children:[o&&(0,s.jsxs)(r.TabsTrigger,{value:`create`,className:`flex-1 gap-1.5`,children:[(0,s.jsx)(i.Plus,{className:`h-3.5 w-3.5`}),`Create New`]}),c&&(0,s.jsxs)(r.TabsTrigger,{value:`link`,className:`flex-1 gap-1.5`,children:[(0,s.jsx)(i.Link,{className:`h-3.5 w-3.5`}),`Link Existing`]})]}),o&&(0,s.jsxs)(r.TabsContent,{value:`create`,className:`space-y-3 mt-0`,children:[a.map(e=>(0,s.jsxs)(`div`,{children:[(0,s.jsxs)(`label`,{className:`text-xs font-medium text-muted-foreground mb-1 block`,children:[e.label,e.required&&(0,s.jsx)(`span`,{className:`text-destructive ml-0.5`,children:`*`})]}),(0,s.jsx)(r.Input,{type:e.type===`number`?`number`:e.type===`date`?`date`:`text`,placeholder:e.placeholder||`Enter ${e.label.toLowerCase()}`,value:g[e.name]||``,onChange:t=>O(e.name,t.target.value),className:`h-8 text-sm`})]},e.name)),(0,s.jsxs)(`div`,{className:`flex justify-end gap-2 pt-1`,children:[(0,s.jsx)(r.Button,{variant:`ghost`,size:`sm`,onClick:()=>p(!1),children:`Cancel`}),(0,s.jsxs)(r.Button,{size:`sm`,onClick:k,disabled:!j||S,className:`gap-1.5`,children:[S&&(0,s.jsx)(i.Loader2,{className:`h-3.5 w-3.5 animate-spin`}),`Create`]})]})]}),c&&(0,s.jsxs)(r.TabsContent,{value:`link`,className:`space-y-3 mt-0`,children:[(0,s.jsxs)(`div`,{className:`relative`,children:[(0,s.jsx)(i.Search,{className:`absolute left-2.5 top-1/2 -translate-y-1/2 h-3.5 w-3.5 text-muted-foreground`}),(0,s.jsx)(r.Input,{placeholder:`Search ${e}…`,value:v,onChange:e=>D(e.target.value),className:`h-8 text-sm pl-8`})]}),(0,s.jsx)(`div`,{className:`max-h-48 overflow-y-auto space-y-1`,children:w?(0,s.jsxs)(`div`,{className:`flex items-center justify-center py-4 text-sm text-muted-foreground`,children:[(0,s.jsx)(i.Loader2,{className:`h-4 w-4 animate-spin mr-2`}),`Searching…`]}):E.length===0?(0,s.jsx)(`p`,{className:`text-sm text-muted-foreground text-center py-4`,children:v?`No records found`:`Type to search records`}):E.map(e=>(0,s.jsxs)(`button`,{type:`button`,className:`w-full text-left px-3 py-2 rounded-md hover:bg-accent text-sm transition-colors`,onClick:()=>A(e.id),disabled:S,children:[(0,s.jsx)(`span`,{className:`font-medium`,children:e.label}),e.description&&(0,s.jsx)(`span`,{className:`block text-xs text-muted-foreground mt-0.5`,children:e.description})]},e.id))})]})]})})]}):(0,s.jsxs)(`div`,{className:(0,r.cn)(`flex gap-2`,d),children:[o&&(0,s.jsxs)(r.Button,{variant:`outline`,size:`sm`,onClick:()=>{h(`create`),p(!0)},className:`gap-1.5`,children:[(0,s.jsx)(i.Plus,{className:`h-3.5 w-3.5`}),`New `,e]}),c&&(0,s.jsxs)(r.Button,{variant:`outline`,size:`sm`,onClick:()=>{h(`link`),p(!0)},className:`gap-1.5`,children:[(0,s.jsx)(i.Link,{className:`h-3.5 w-3.5`}),`Link Existing`]})]})};function ie(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 U=({value:e,onChange:t,onSubmit:a,mentionSuggestions:o=[],placeholder:c,className:l,disabled:u=!1})=>{let{t:d}=S(),[f,p]=n.useState(!1),[m,h]=n.useState(!1),[g,_]=n.useState(``),[v,y]=n.useState(0),b=n.useRef(null),x=n.useMemo(()=>{if(!g)return o;let e=g.toLowerCase();return o.filter(t=>t.label.toLowerCase().includes(e))},[g,o]),C=n.useCallback((n,r=``)=>{let i=b.current;if(!i)return;let a=i.selectionStart,o=i.selectionEnd,s=e.slice(a,o);t(e.slice(0,a)+n+s+r+e.slice(o)),requestAnimationFrame(()=>{i.focus();let e=a+n.length+s.length;i.setSelectionRange(e,e)})},[e,t]),w=n.useCallback(()=>C(`**`,`**`),[C]),T=n.useCallback(()=>C(`*`,`*`),[C]),E=n.useCallback(()=>C(`
|
|
2
|
+
- `,``),[C]),D=n.useCallback(()=>C("`","`"),[C]),O=n.useCallback(()=>{C(`@`,``),h(!0),_(``),y(0)},[C]),k=n.useCallback(n=>{let r=b.current;if(!r)return;let i=r.selectionStart,a=e.slice(0,i).lastIndexOf(`@`);a!==-1&&t(e.slice(0,a)+`@${n.label} `+e.slice(i)),h(!1),_(``),requestAnimationFrame(()=>r.focus())},[e,t]),A=n.useCallback(e=>{let n=e.target.value;t(n);let r=e.target.selectionStart,i=n.slice(0,r),a=i.lastIndexOf(`@`);if(a!==-1){let e=i.slice(a+1),t=a>0?i[a-1]:` `;if(/\s/.test(t)&&!/\s/.test(e)){h(!0),_(e),y(0);return}}h(!1)},[t]),j=n.useCallback(e=>{if(m&&x.length>0){if(e.key===`ArrowDown`){e.preventDefault(),y(e=>e<x.length-1?e+1:0);return}if(e.key===`ArrowUp`){e.preventDefault(),y(e=>e>0?e-1:x.length-1);return}if(e.key===`Enter`||e.key===`Tab`){e.preventDefault(),k(x[v]);return}if(e.key===`Escape`){h(!1);return}}e.key===`Enter`&&(e.ctrlKey||e.metaKey)&&(e.preventDefault(),a?.())},[m,x,v,k,a]);return(0,s.jsxs)(`div`,{className:(0,r.cn)(`border rounded-md`,l),children:[(0,s.jsxs)(`div`,{className:`flex items-center gap-0.5 px-2 py-1.5 border-b bg-muted/30`,children:[(0,s.jsx)(r.Button,{variant:`ghost`,size:`icon`,className:`h-7 w-7`,onClick:w,disabled:u||f,title:d(`detail.bold`),children:(0,s.jsx)(i.Bold,{className:`h-3.5 w-3.5`})}),(0,s.jsx)(r.Button,{variant:`ghost`,size:`icon`,className:`h-7 w-7`,onClick:T,disabled:u||f,title:d(`detail.italic`),children:(0,s.jsx)(i.Italic,{className:`h-3.5 w-3.5`})}),(0,s.jsx)(r.Button,{variant:`ghost`,size:`icon`,className:`h-7 w-7`,onClick:E,disabled:u||f,title:d(`detail.listFormat`),children:(0,s.jsx)(i.List,{className:`h-3.5 w-3.5`})}),(0,s.jsx)(r.Button,{variant:`ghost`,size:`icon`,className:`h-7 w-7`,onClick:D,disabled:u||f,title:d(`detail.inlineCode`),children:(0,s.jsx)(i.Code,{className:`h-3.5 w-3.5`})}),(0,s.jsx)(r.Button,{variant:`ghost`,size:`icon`,className:`h-7 w-7`,onClick:O,disabled:u||f,title:d(`detail.mentionSomeone`),children:(0,s.jsx)(i.AtSign,{className:`h-3.5 w-3.5`})}),(0,s.jsx)(`div`,{className:`flex-1`}),(0,s.jsx)(r.Button,{variant:`ghost`,size:`icon`,className:`h-7 w-7`,onClick:()=>p(!f),title:d(f?`detail.edit`:`detail.preview`),children:f?(0,s.jsx)(i.Edit,{className:`h-3.5 w-3.5`}):(0,s.jsx)(i.Eye,{className:`h-3.5 w-3.5`})}),a&&(0,s.jsx)(r.Button,{variant:`ghost`,size:`icon`,className:`h-7 w-7`,onClick:a,disabled:u||!e.trim(),title:d(`detail.submitComment`),children:(0,s.jsx)(i.Send,{className:`h-3.5 w-3.5`})})]}),(0,s.jsx)(`div`,{className:`relative`,children:f?(0,s.jsx)(`div`,{className:`min-h-[80px] px-3 py-2 text-sm prose prose-sm max-w-none`,dangerouslySetInnerHTML:{__html:ie(e)}}):(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(`textarea`,{ref:b,className:`w-full min-h-[80px] px-3 py-2 text-sm bg-transparent resize-none focus:outline-none placeholder:text-muted-foreground`,placeholder:c??d(`detail.writeComment`),value:e,onChange:A,onKeyDown:j,disabled:u}),m&&x.length>0&&(0,s.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:x.map((e,t)=>(0,s.jsxs)(`button`,{type:`button`,className:(0,r.cn)(`w-full text-left px-3 py-1.5 text-sm flex items-center gap-2 hover:bg-accent transition-colors`,t===v&&`bg-accent`),onMouseDown:t=>{t.preventDefault(),k(e)},children:[e.avatarUrl?(0,s.jsx)(`img`,{src:e.avatarUrl,alt:e.label,className:`h-5 w-5 rounded-full object-cover`}):(0,s.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,s.jsx)(`span`,{children:e.label})]},e.id))})]})})]})};function W(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
3
|
`)}catch{return String(e).split(`
|
|
4
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 te(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 W={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`},G={added:`+`,removed:`-`,unchanged:` `},K=({oldValue:e,newValue:t,fieldName:a,fieldType:o=`string`,mode:c=`unified`,className:l})=>{let{t:u}=S(),[d,f]=n.useState(c),p=n.useMemo(()=>U(e,o),[e,o]),m=n.useMemo(()=>U(t,o),[t,o]),h=n.useMemo(()=>te(p,m),[p,m]),g=h.some(e=>e.type!==`unchanged`),_=n.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,s.jsxs)(r.Card,{className:(0,r.cn)(`overflow-hidden`,l),children:[(0,s.jsx)(r.CardHeader,{className:`pb-2`,children:(0,s.jsxs)(r.CardTitle,{className:`flex items-center justify-between text-sm`,children:[(0,s.jsx)(`span`,{className:`font-medium`,children:a}),(0,s.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,s.jsx)(r.Button,{variant:d===`unified`?`secondary`:`ghost`,size:`icon`,className:`h-7 w-7`,onClick:()=>f(`unified`),title:u(`detail.unifiedDiff`),children:(0,s.jsx)(i.Rows3,{className:`h-3.5 w-3.5`})}),(0,s.jsx)(r.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,s.jsx)(i.Columns2,{className:`h-3.5 w-3.5`})})]})]})}),(0,s.jsx)(r.CardContent,{className:`p-0`,children:g?d===`unified`?(0,s.jsx)(`div`,{className:`font-mono text-xs overflow-x-auto`,children:h.map((e,t)=>(0,s.jsxs)(`div`,{className:(0,r.cn)(`px-4 py-0.5 whitespace-pre-wrap border-l-2`,W[e.type],e.type===`added`&&`border-l-green-500`,e.type===`removed`&&`border-l-red-500`,e.type===`unchanged`&&`border-l-transparent`),children:[(0,s.jsx)(`span`,{className:`select-none mr-2 inline-block w-3 text-center opacity-60`,children:G[e.type]}),e.value]},t))}):(0,s.jsx)(`div`,{className:`overflow-x-auto`,children:(0,s.jsxs)(`div`,{className:`grid grid-cols-2 divide-x font-mono text-xs min-w-0`,children:[(0,s.jsx)(`div`,{className:`px-3 py-1.5 text-xs font-medium text-muted-foreground bg-muted/50`,children:u(`detail.previousVersion`)}),(0,s.jsx)(`div`,{className:`px-3 py-1.5 text-xs font-medium text-muted-foreground bg-muted/50`,children:u(`detail.currentVersion`)}),_.map((e,t)=>(0,s.jsxs)(n.Fragment,{children:[(0,s.jsx)(`div`,{className:(0,r.cn)(`px-3 py-0.5 whitespace-pre-wrap min-h-[1.5em]`,e.left?W[e.left.type]:`bg-muted/20`),children:e.left?.value??``}),(0,s.jsx)(`div`,{className:(0,r.cn)(`px-3 py-0.5 whitespace-pre-wrap min-h-[1.5em]`,e.right?W[e.right.type]:`bg-muted/20`),children:e.right?.value??``})]},t))]})}):(0,s.jsx)(`p`,{className:`px-4 py-3 text-sm text-muted-foreground`,children:u(`detail.noChanges`)})})]})},q=({currentIndex:e,totalRecords:t,recordIds:a,onNavigate:o,onSearch:c,className:l})=>{let{t:u}=S(),[d,f]=n.useState(``),[p,m]=n.useState(!1),h=n.useRef(null),g=e>0,_=e>0,v=e<t-1,y=e<t-1,b=n.useCallback(()=>{g&&o(a[0])},[g,o,a]),x=n.useCallback(()=>{_&&o(a[e-1])},[_,o,a,e]),C=n.useCallback(()=>{v&&o(a[e+1])},[v,o,a,e]),w=n.useCallback(()=>{y&&o(a[a.length-1])},[y,o,a]),T=n.useCallback(e=>{let t=e.target.value;f(t),c?.(t)},[c]),E=n.useCallback(()=>{m(e=>(e?(f(``),c?.(``)):requestAnimationFrame(()=>h.current?.focus()),!e))},[c]);return n.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(``),c?.(``),t.target.blur());return}switch(t.key){case`Home`:t.preventDefault(),g&&o(a[0]);break;case`End`:t.preventDefault(),y&&o(a[a.length-1]);break;case`ArrowLeft`:t.preventDefault(),_&&o(a[e-1]);break;case`ArrowRight`:t.preventDefault(),v&&o(a[e+1]);break}}};return document.addEventListener(`keydown`,t),()=>document.removeEventListener(`keydown`,t)},[e,a,g,_,v,y,o,c]),(0,s.jsxs)(`div`,{className:(0,r.cn)(`flex items-center gap-1.5`,l),children:[(0,s.jsx)(r.Button,{variant:`outline`,size:`icon`,className:`h-8 w-8`,disabled:!g,onClick:b,title:u(`detail.firstRecord`),children:(0,s.jsx)(i.ChevronsLeft,{className:`h-4 w-4`})}),(0,s.jsx)(r.Button,{variant:`outline`,size:`icon`,className:`h-8 w-8`,disabled:!_,onClick:x,title:u(`detail.previousRecordKey`),children:(0,s.jsx)(i.ChevronLeft,{className:`h-4 w-4`})}),(0,s.jsx)(`span`,{className:`text-xs text-muted-foreground whitespace-nowrap px-1.5 tabular-nums`,children:t>0?u(`detail.recordOf`,{current:e+1,total:t}):u(`detail.noRecords`)}),(0,s.jsx)(r.Button,{variant:`outline`,size:`icon`,className:`h-8 w-8`,disabled:!v,onClick:C,title:u(`detail.nextRecordKey`),children:(0,s.jsx)(i.ChevronRight,{className:`h-4 w-4`})}),(0,s.jsx)(r.Button,{variant:`outline`,size:`icon`,className:`h-8 w-8`,disabled:!y,onClick:w,title:u(`detail.lastRecord`),children:(0,s.jsx)(i.ChevronsRight,{className:`h-4 w-4`})}),c&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(r.Button,{variant:p?`secondary`:`ghost`,size:`icon`,className:`h-8 w-8`,onClick:E,title:u(`detail.searchWhileNavigating`),children:(0,s.jsx)(i.Search,{className:`h-4 w-4`})}),p&&(0,s.jsx)(`div`,{className:`relative`,children:(0,s.jsx)(r.Input,{ref:h,type:`text`,placeholder:u(`detail.searchRecords`),value:d,onChange:T,className:`h-8 w-48 text-sm`})})]})]})},J=28,Y=[`fill-primary stroke-primary`,`fill-blue-500 stroke-blue-500`,`fill-emerald-500 stroke-emerald-500`,`fill-amber-500 stroke-amber-500`],X=[`fill-primary-foreground`,`fill-white`,`fill-white`,`fill-white`];function Z(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 Q(e,t=6){return e.length<=t?e:e.slice(0,t-1)+`…`}var $=({record:e,relatedRecords:t,levels:a=1,onNodeClick:o,className:c})=>{let l=n.useRef(null),[u,d]=n.useState({width:500,height:400}),[f,p]=n.useState(null);n.useEffect(()=>{let e=l.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}=n.useMemo(()=>Z(e,t,a,u.width,u.height),[e,t,a,u]);return(0,s.jsxs)(r.Card,{className:(0,r.cn)(`overflow-hidden`,c),children:[(0,s.jsx)(r.CardHeader,{className:`pb-2`,children:(0,s.jsxs)(r.CardTitle,{className:`flex items-center gap-2 text-base`,children:[(0,s.jsx)(i.Network,{className:`h-4 w-4`}),`Relationships`,(0,s.jsxs)(`span`,{className:`text-sm font-normal text-muted-foreground`,children:[`(`,t.length,` related)`]})]})}),(0,s.jsx)(r.CardContent,{className:`p-0`,children:(0,s.jsxs)(`svg`,{ref:l,width:`100%`,height:u.height,viewBox:`0 0 ${u.width} ${u.height}`,className:`select-none`,children:[h.map((e,t)=>(0,s.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=Y[Math.min(e.level,Y.length-1)],i=X[Math.min(e.level,X.length-1)],a=e.level===0?J+6:J;return(0,s.jsxs)(`g`,{className:(0,r.cn)(`cursor-pointer transition-transform`,o&&`hover:opacity-80`),onClick:()=>o?.(e.id),onMouseEnter:()=>p(e.id),onMouseLeave:()=>p(null),children:[(0,s.jsx)(`circle`,{cx:e.x,cy:e.y,r:t?a+3:a,className:n,fillOpacity:e.level===0?1:.85,strokeWidth:2,strokeOpacity:.3}),(0,s.jsx)(`text`,{x:e.x,y:e.y,textAnchor:`middle`,dominantBaseline:`central`,className:(0,r.cn)(`text-[10px] font-medium pointer-events-none`,i),children:Q(e.label)}),e.type&&(0,s.jsx)(`text`,{x:e.x,y:e.y+a+12,textAnchor:`middle`,className:`fill-muted-foreground text-[9px] pointer-events-none`,children:e.type}),t&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(`rect`,{x:e.x-50,y:e.y-a-28,width:100,height:20,rx:4,className:`fill-popover stroke-border`,strokeWidth:1}),(0,s.jsx)(`text`,{x:e.x,y:e.y-a-16,textAnchor:`middle`,dominantBaseline:`central`,className:`fill-popover-foreground text-[10px] pointer-events-none`,children:e.label})]})]},e.id)})]})})]})};function ne(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`}function re(e){return e.startsWith(`image/`)}function ie(e){return re(e)?i.Image:e.includes(`pdf`)||e.includes(`document`)||e.includes(`text`)?i.FileText:e.includes(`zip`)||e.includes(`archive`)||e.includes(`compressed`)?i.FileArchive:i.File}var ae=({attachments:e,onUpload:t,onRemove:a,className:o,readOnly:c=!1})=>{let{t:l}=S(),[u,d]=n.useState(!1),f=n.useRef(null),p=n.useCallback(e=>{e.preventDefault(),e.stopPropagation(),d(!0)},[]),m=n.useCallback(e=>{e.preventDefault(),e.stopPropagation(),d(!1)},[]),h=n.useCallback(e=>{e.preventDefault(),e.stopPropagation(),d(!1),t&&e.dataTransfer.files.length>0&&t(e.dataTransfer.files)},[t]),g=n.useCallback(e=>{t&&e.target.files&&e.target.files.length>0&&(t(e.target.files),e.target.value=``)},[t]);return(0,s.jsxs)(`div`,{className:(0,r.cn)(`space-y-2`,o),children:[t&&!c&&(0,s.jsxs)(`div`,{className:(0,r.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,s.jsx)(i.Upload,{className:`h-5 w-5 mx-auto text-muted-foreground mb-1`}),(0,s.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:l(`detail.dropFilesToUpload`)}),(0,s.jsx)(`input`,{ref:f,type:`file`,multiple:!0,className:`hidden`,onChange:g})]}),e.length>0&&(0,s.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,s.jsxs)(`div`,{className:`flex items-center gap-1.5 text-xs text-muted-foreground`,children:[(0,s.jsx)(i.Paperclip,{className:`h-3 w-3`}),(0,s.jsx)(`span`,{children:e.length===1?l(`detail.attachmentCount`,{count:e.length}):l(`detail.attachmentCountPlural`,{count:e.length})})]}),(0,s.jsx)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 gap-2`,children:e.map(e=>{let t=re(e.type),n=ie(e.type);return(0,s.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,s.jsx)(`img`,{src:e.thumbnailUrl||e.url,alt:e.name,className:`h-10 w-10 rounded object-cover shrink-0`}):(0,s.jsx)(`div`,{className:`h-10 w-10 rounded bg-muted flex items-center justify-center shrink-0`,children:(0,s.jsx)(n,{className:`h-5 w-5 text-muted-foreground`})}),(0,s.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,s.jsx)(`p`,{className:`text-xs font-medium truncate`,children:e.name}),(0,s.jsx)(`p`,{className:`text-[10px] text-muted-foreground`,children:ne(e.size)})]}),a&&!c&&(0,s.jsx)(r.Button,{variant:`ghost`,size:`icon`,className:`h-6 w-6 shrink-0 opacity-0 group-hover:opacity-100 transition-opacity`,onClick:()=>a(e.id),title:l(`detail.removeAttachment`),children:(0,s.jsx)(i.X,{className:`h-3.5 w-3.5`})})]},e.id)})})]})]})};function oe(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 se=({recordId:e,revisions:t,onRestore:a,className:o})=>{let[c,l]=n.useState(null),[u,d]=n.useState(!1),[f,p]=n.useState(!1),m=n.useMemo(()=>t.find(e=>e.id===c)??null,[t,c]),h=n.useCallback(async()=>{if(!(!m||!a)){if(!u){d(!0);return}p(!0);try{let e=m.snapshot??{};await a(m.id,e),d(!1),l(null)}finally{p(!1)}}},[m,a,u]),g=n.useCallback(()=>{d(!1)},[]);return(0,s.jsxs)(r.Card,{className:(0,r.cn)(``,o),children:[(0,s.jsx)(r.CardHeader,{className:`pb-3`,children:(0,s.jsxs)(r.CardTitle,{className:`flex items-center gap-2 text-base`,children:[(0,s.jsx)(i.History,{className:`h-4 w-4`}),`Revision History`,(0,s.jsxs)(`span`,{className:`text-sm font-normal text-muted-foreground`,children:[`(`,t.length,`)`]})]})}),(0,s.jsx)(r.CardContent,{children:t.length===0?(0,s.jsx)(`p`,{className:`text-sm text-muted-foreground text-center py-4`,children:`No revisions recorded`}):(0,s.jsxs)(`div`,{className:`flex flex-col lg:flex-row gap-4`,children:[(0,s.jsx)(`div`,{className:`flex-1 min-w-0`,children:(0,s.jsxs)(`div`,{className:`relative`,children:[(0,s.jsx)(`div`,{className:`absolute left-3 top-2 bottom-2 w-px bg-border`}),(0,s.jsx)(`div`,{className:`space-y-1`,children:t.map(e=>{let t=e.id===c;return(0,s.jsxs)(`button`,{type:`button`,className:(0,r.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:()=>{l(e.id),d(!1)},children:[(0,s.jsx)(`div`,{className:(0,r.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,s.jsx)(i.ChevronRight,{className:`h-3 w-3 text-primary-foreground`})}),(0,s.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,s.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,s.jsx)(`span`,{className:`text-sm font-medium`,children:e.user}),(0,s.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:oe(e.timestamp)})]}),(0,s.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,s.jsxs)(`div`,{className:`lg:w-80 border rounded-md p-3 space-y-3`,children:[(0,s.jsxs)(`div`,{className:`flex items-center gap-2 text-sm font-medium`,children:[(0,s.jsx)(i.Eye,{className:`h-4 w-4 text-muted-foreground`}),`Revision Preview`]}),(0,s.jsx)(`div`,{className:`space-y-2`,children:m.changes.map((e,t)=>(0,s.jsxs)(`div`,{className:`text-xs`,children:[(0,s.jsx)(`span`,{className:`font-medium text-muted-foreground`,children:e.field}),(0,s.jsxs)(`div`,{className:`flex items-center gap-1.5 mt-0.5`,children:[(0,s.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,s.jsx)(i.ChevronRight,{className:`h-3 w-3 text-muted-foreground shrink-0`}),(0,s.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,s.jsxs)(`div`,{className:`border-t pt-2 space-y-1`,children:[(0,s.jsx)(`p`,{className:`text-xs font-medium text-muted-foreground`,children:`Record state at this point`}),(0,s.jsx)(`div`,{className:`max-h-40 overflow-y-auto space-y-1`,children:Object.entries(m.snapshot).map(([e,t])=>(0,s.jsxs)(`div`,{className:`flex justify-between text-xs gap-2`,children:[(0,s.jsx)(`span`,{className:`text-muted-foreground truncate`,children:e}),(0,s.jsx)(`span`,{className:`font-mono truncate max-w-[140px]`,children:t==null?`–`:String(t)})]},e))})]}),a&&(0,s.jsx)(`div`,{className:`pt-1 space-y-2`,children:u?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)(`p`,{className:`text-xs text-amber-600 dark:text-amber-400`,children:[`This will restore the record to its state at`,` `,oe(m.timestamp),`. Continue?`]}),(0,s.jsxs)(`div`,{className:`flex gap-2`,children:[(0,s.jsxs)(r.Button,{variant:`destructive`,size:`sm`,className:`gap-1.5 flex-1`,onClick:h,disabled:f,children:[(0,s.jsx)(i.RotateCcw,{className:`h-3.5 w-3.5`}),f?`Restoring…`:`Confirm Restore`]}),(0,s.jsx)(r.Button,{variant:`ghost`,size:`sm`,onClick:g,disabled:f,children:`Cancel`})]})]}):(0,s.jsxs)(r.Button,{variant:`outline`,size:`sm`,className:`w-full gap-1.5`,onClick:h,children:[(0,s.jsx)(i.RotateCcw,{className:`h-3.5 w-3.5`}),`Restore to this point`]})})]})]})})]})},ce=({change:e,className:t})=>{let n=e.fieldLabel??e.field.charAt(0).toUpperCase()+e.field.slice(1).replace(/_/g,` `),a=e.oldDisplayValue??(e.oldValue==null?`(empty)`:String(e.oldValue)),o=e.newDisplayValue??(e.newValue==null?`(empty)`:String(e.newValue));return(0,s.jsxs)(`div`,{className:(0,r.cn)(`flex items-center gap-1.5 text-sm flex-wrap`,t),children:[(0,s.jsx)(`span`,{className:`font-medium text-foreground`,children:n}),(0,s.jsx)(`span`,{className:`text-muted-foreground line-through`,children:a}),(0,s.jsx)(i.ArrowRight,{className:`h-3 w-3 text-muted-foreground shrink-0`}),(0,s.jsx)(`span`,{className:`text-foreground`,children:o})]})},le=[`👍`,`❤️`,`🎉`,`😂`,`😮`,`😢`],ue=({reactions:e,onToggleReaction:t,emojiOptions:a=le,className:o})=>{let[c,l]=n.useState(!1),u=n.useCallback(e=>{t?.(e),l(!1)},[t]);return(0,s.jsxs)(`div`,{className:(0,r.cn)(`flex items-center gap-1 flex-wrap`,o),children:[e.map(e=>(0,s.jsxs)(`button`,{type:`button`,className:(0,r.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:()=>u(e.emoji),disabled:!t,"aria-label":`${e.emoji} ${e.count} reaction${e.count===1?``:`s`}`,children:[(0,s.jsx)(`span`,{children:e.emoji}),(0,s.jsx)(`span`,{children:e.count})]},e.emoji)),t&&(0,s.jsxs)(`div`,{className:`relative`,children:[(0,s.jsx)(r.Button,{variant:`ghost`,size:`icon`,className:`h-6 w-6`,onClick:()=>l(!c),"aria-label":`Add reaction`,children:(0,s.jsx)(i.SmilePlus,{className:`h-3.5 w-3.5`})}),c&&(0,s.jsx)(`div`,{className:`absolute bottom-full mb-1 left-0 bg-popover border rounded-md shadow-md z-50 p-1.5 flex gap-1`,role:`listbox`,"aria-label":`Emoji picker`,children:a.map(t=>(0,s.jsx)(`button`,{type:`button`,className:`hover:bg-accent rounded p-1 text-base transition-colors`,onClick:()=>u(t),role:`option`,"aria-selected":e.some(e=>e.emoji===t&&e.reacted),children:t},t))})]})]})};function de(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 fe=({parentItem:e,replies:t,onAddReply:a,showReplyInput:o=!0,className:c})=>{let{t:l}=S(),[u,d]=n.useState(!1),[f,p]=n.useState(``),[m,h]=n.useState(!1),g=n.useCallback(async()=>{let t=f.trim();if(!(!t||!a)){h(!0);try{await a(e.id,t),p(``)}finally{h(!1)}}},[f,a,e.id]),_=n.useCallback(e=>{e.key===`Enter`&&(e.ctrlKey||e.metaKey)&&(e.preventDefault(),g())},[g]);return t.length===0&&!o?null:(0,s.jsxs)(`div`,{className:(0,r.cn)(`ml-10 mt-1`,c),children:[t.length>0&&(0,s.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,s.jsx)(i.ChevronDown,{className:`h-3 w-3`}):(0,s.jsx)(i.ChevronRight,{className:`h-3 w-3`}),(0,s.jsx)(i.MessageSquare,{className:`h-3 w-3`}),(0,s.jsx)(`span`,{children:t.length===1?l(`detail.replyCount`,{count:t.length}):l(`detail.replyCountPlural`,{count:t.length})})]}),u&&(0,s.jsx)(`div`,{className:`space-y-2 border-l-2 border-border pl-3`,children:t.map(e=>(0,s.jsxs)(`div`,{className:`flex gap-2`,children:[(0,s.jsx)(`div`,{className:`shrink-0`,children:e.actorAvatarUrl?(0,s.jsx)(`img`,{src:e.actorAvatarUrl,alt:e.actor,className:`h-6 w-6 rounded-full object-cover`}):(0,s.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,s.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,s.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,s.jsx)(`span`,{className:`text-xs font-medium`,children:e.actor}),(0,s.jsx)(`span`,{className:`text-[10px] text-muted-foreground`,children:de(e.createdAt)})]}),(0,s.jsx)(`p`,{className:`text-xs whitespace-pre-wrap break-words`,children:e.body})]})]},e.id))}),o&&a&&(0,s.jsxs)(`div`,{className:`flex gap-1.5 mt-1.5`,children:[(0,s.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:l(`detail.replyPlaceholder`),value:f,onChange:e=>p(e.target.value),onKeyDown:_,disabled:m}),(0,s.jsx)(r.Button,{variant:`ghost`,size:`icon`,className:`h-6 w-6 shrink-0`,onClick:g,disabled:!f.trim()||m,"aria-label":`Send reply`,children:(0,s.jsx)(i.Send,{className:`h-3 w-3`})})]})]})},pe=({subscription:e,onToggle:t,className:a})=>{let{t:o}=S(),[c,l]=n.useState(!1),u=n.useCallback(async()=>{if(t){l(!0);try{await t(!e.subscribed)}finally{l(!1)}}},[t,e.subscribed]);return(0,s.jsx)(r.Button,{variant:`ghost`,size:`icon`,className:(0,r.cn)(`h-8 w-8`,a),onClick:u,disabled:c||!t,"aria-label":e.subscribed?o(`detail.unsubscribeAriaLabel`):o(`detail.subscribeAriaLabel`),title:e.subscribed?o(`detail.subscribedTooltip`):o(`detail.unsubscribedTooltip`),children:e.subscribed?(0,s.jsx)(i.Bell,{className:`h-4 w-4 text-primary`}):(0,s.jsx)(i.BellOff,{className:`h-4 w-4 text-muted-foreground`})})},me={comment:i.MessageSquare,field_change:i.Edit,task:i.CheckSquare,event:i.Calendar,system:i.Zap,email:i.Mail,call:i.Phone},he={comment:`bg-purple-100 text-purple-600`,field_change:`bg-blue-100 text-blue-600`,task:`bg-green-100 text-green-600`,event:`bg-amber-100 text-amber-600`,system:`bg-gray-100 text-gray-600`,email:`bg-indigo-100 text-indigo-600`,call:`bg-teal-100 text-teal-600`};function ge(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 _e(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 ve(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 ye=({items:e,config:t,filterMode:a,onFilterChange:o,hasMore:c=!1,onLoadMore:l,loading:u=!1,onAddComment:d,onAddReply:f,onToggleReaction:p,subscription:m,onToggleSubscription:h,collapseWhenEmpty:g=!1,className:_})=>{let{t:v}=S(),[y,b]=n.useState(`all`),[x,C]=n.useState(``),[w,T]=n.useState(!1),[E,D]=n.useState(!1),O=a??y,k=t?.showFilterToggle!==!1,A=t?.showCommentInput!==!1&&!!d,j=t?.enableReactions??!1,M=t?.enableThreading??!1,N=t?.showSubscriptionToggle??!1,P=n.useMemo(()=>ve(e,O),[e,O]),F=n.useMemo(()=>M?P.filter(e=>!e.parentId):P,[P,M]),I=n.useMemo(()=>{if(!M)return new Map;let e=new Map;for(let t of P)if(t.parentId){let n=e.get(t.parentId)??[];n.push(t),e.set(t.parentId,n)}return e},[P,M]),L=n.useCallback(e=>{o?o(e):b(e)},[o]),R=n.useCallback(async()=>{let e=x.trim();if(!(!e||!d)){T(!0);try{await d(e),C(``)}finally{T(!1)}}},[x,d]),z=n.useCallback(e=>{e.key===`Enter`&&(e.ctrlKey||e.metaKey)&&(e.preventDefault(),R())},[R]),B=n.useCallback(async()=>{if(l){D(!0);try{await l()}finally{D(!1)}}},[l]);return(0,s.jsxs)(r.Card,{className:(0,r.cn)(``,_),children:[(0,s.jsx)(r.CardHeader,{children:(0,s.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,s.jsxs)(r.CardTitle,{className:`flex items-center gap-2 text-base`,children:[(0,s.jsx)(i.Activity,{className:`h-4 w-4`}),v(`detail.activity`),(0,s.jsxs)(`span`,{className:`text-sm font-normal text-muted-foreground`,children:[`(`,P.length,`)`]})]}),(0,s.jsx)(`div`,{className:`flex items-center gap-1`,children:N&&m&&(0,s.jsx)(pe,{subscription:m,onToggle:h})})]})}),(0,s.jsxs)(r.CardContent,{className:`space-y-4`,children:[k&&(0,s.jsx)(`div`,{className:`flex items-center gap-2`,children:(0,s.jsx)(`select`,{className:`rounded-md border border-input bg-background px-2.5 py-1.5 text-sm focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring`,value:O,onChange:e=>L(e.target.value),"aria-label":v(`detail.filterActivity`),children:ge(v).map(e=>(0,s.jsx)(`option`,{value:e.value,children:e.label},e.value))})}),A&&(0,s.jsxs)(`div`,{className:`flex gap-2`,children:[(0,s.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:v(`detail.leaveCommentPlaceholder`),value:x,onChange:e=>C(e.target.value),onKeyDown:z,disabled:w}),(0,s.jsx)(r.Button,{size:`icon`,variant:`default`,onClick:R,disabled:!x.trim()||w,className:`shrink-0 self-end`,"aria-label":v(`detail.submitComment`),children:(0,s.jsx)(i.MessageSquare,{className:`h-4 w-4`})})]}),P.length===0?g?null:(0,s.jsx)(`p`,{className:`text-sm text-muted-foreground text-center py-4`,children:v(`detail.noActivity`)}):(0,s.jsxs)(`div`,{className:`relative`,children:[(0,s.jsx)(`div`,{className:`absolute left-4 top-2 bottom-2 w-px bg-border`}),(0,s.jsx)(`div`,{className:`space-y-4`,children:F.map(e=>{let t=me[e.type]||i.Zap,n=he[e.type]||`bg-gray-100 text-gray-600`,a=I.get(e.id)??[];return(0,s.jsxs)(`div`,{children:[(0,s.jsxs)(`div`,{className:`flex gap-3 relative`,children:[(0,s.jsx)(`div`,{className:(0,r.cn)(`shrink-0 h-8 w-8 rounded-full flex items-center justify-center z-10`,n),children:e.actorAvatarUrl?(0,s.jsx)(`img`,{src:e.actorAvatarUrl,alt:e.actor,className:`h-8 w-8 rounded-full object-cover`}):(0,s.jsx)(t,{className:`h-3.5 w-3.5`})}),(0,s.jsxs)(`div`,{className:`flex-1 min-w-0 pt-1`,children:[(0,s.jsxs)(`div`,{className:`flex items-center gap-2 mb-0.5`,children:[(0,s.jsx)(`span`,{className:`text-sm font-medium`,children:e.actor}),e.source&&(0,s.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:v(`detail.via`,{source:e.source})}),(0,s.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:_e(e.createdAt)}),e.edited&&(0,s.jsx)(`span`,{className:`text-xs text-muted-foreground italic`,children:v(`detail.edited`)}),e.pinned&&(0,s.jsxs)(`span`,{className:`text-xs text-amber-600`,children:[`📌 `,v(`detail.pinned`)]})]}),e.body&&(0,s.jsx)(`p`,{className:`text-sm whitespace-pre-wrap break-words text-muted-foreground`,children:e.body}),e.type===`field_change`&&e.fieldChanges&&(0,s.jsx)(`div`,{className:`space-y-1 mt-1`,children:e.fieldChanges.map((e,t)=>(0,s.jsx)(ce,{change:e},t))}),j&&e.reactions&&e.reactions.length>0&&(0,s.jsx)(`div`,{className:`mt-1.5`,children:(0,s.jsx)(ue,{reactions:e.reactions,onToggleReaction:p?t=>p(e.id,t):void 0})}),j&&(!e.reactions||e.reactions.length===0)&&p&&(0,s.jsx)(`div`,{className:`mt-1.5`,children:(0,s.jsx)(ue,{reactions:[],onToggleReaction:t=>p(e.id,t)})})]})]}),M&&(e.replyCount??0)>0&&(0,s.jsx)(fe,{parentItem:e,replies:a,onAddReply:f,showReplyInput:!!f})]},e.id)})})]}),c&&(0,s.jsx)(`div`,{className:`text-center pt-2`,children:(0,s.jsxs)(r.Button,{variant:`ghost`,size:`sm`,onClick:B,disabled:E,"aria-label":v(`detail.loadMore`),children:[E?(0,s.jsx)(i.Loader2,{className:`h-4 w-4 animate-spin mr-1`}):(0,s.jsx)(i.ChevronDown,{className:`h-4 w-4 mr-1`}),v(`detail.loadMore`)]})})]})]})},be=({config:e,items:t,hasMore:a,onLoadMore:o,loading:c,onAddComment:l,onAddReply:u,onToggleReaction:d,subscription:f,onToggleSubscription:p,filterMode:m,onFilterChange:h,collapseWhenEmpty:g=!1,className:_})=>{let v=e?.position??`right`,y=e?.width??`360px`,b=e?.collapsible??!0,x=g&&t.length===0||(e?.defaultCollapsed??!1),{t:C}=S(),[w,T]=n.useState(x);return v===`right`||v===`left`?w&&b?(0,s.jsx)(`div`,{className:(0,r.cn)(`flex items-start pt-4`,v===`right`?`border-l`:`border-r`,_),children:(0,s.jsx)(r.Button,{variant:`ghost`,size:`icon`,className:`h-8 w-8 mx-1`,onClick:()=>T(!1),"aria-label":C(`detail.openDiscussion`),children:(0,s.jsx)(i.PanelRightOpen,{className:`h-4 w-4`})})}):(0,s.jsxs)(`div`,{className:(0,r.cn)(`flex flex-col overflow-hidden`,v===`right`?`border-l`:`border-r`,_),style:{width:y,minWidth:y},children:[(0,s.jsxs)(`div`,{className:`flex items-center justify-between px-4 py-3 border-b`,children:[(0,s.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,s.jsx)(i.MessageSquare,{className:`h-4 w-4`}),(0,s.jsx)(`span`,{className:`text-sm font-medium`,children:C(`detail.discussion`)})]}),b&&(0,s.jsx)(r.Button,{variant:`ghost`,size:`icon`,className:`h-7 w-7`,onClick:()=>T(!0),"aria-label":C(`detail.closeDiscussion`),children:(0,s.jsx)(i.X,{className:`h-3.5 w-3.5`})})]}),(0,s.jsx)(`div`,{className:`flex-1 overflow-y-auto`,children:(0,s.jsx)(ye,{items:t,config:e?.feed,hasMore:a,onLoadMore:o,loading:c,onAddComment:l,onAddReply:u,onToggleReaction:d,subscription:f,onToggleSubscription:p,filterMode:m,onFilterChange:h,collapseWhenEmpty:g,className:`border-0 shadow-none`})})]}):(0,s.jsx)(`div`,{className:(0,r.cn)(``,_),children:b&&w?(0,s.jsxs)(r.Button,{variant:`ghost`,className:`w-full justify-start gap-2 text-muted-foreground`,onClick:()=>T(!1),"aria-label":C(`detail.showDiscussion`,{count:t.length}),children:[(0,s.jsx)(i.MessageSquare,{className:`h-4 w-4`}),(0,s.jsx)(`span`,{children:C(`detail.showDiscussion`,{count:t.length})})]}):(0,s.jsxs)(`div`,{children:[b&&(0,s.jsxs)(`div`,{className:`flex items-center justify-between mb-2`,children:[(0,s.jsxs)(`div`,{className:`flex items-center gap-2 text-sm font-medium`,children:[(0,s.jsx)(i.MessageSquare,{className:`h-4 w-4`}),C(`detail.discussion`)]}),(0,s.jsx)(r.Button,{variant:`ghost`,size:`icon`,className:`h-7 w-7`,onClick:()=>T(!0),"aria-label":C(`detail.hideDiscussion`),children:(0,s.jsx)(i.PanelRightClose,{className:`h-3.5 w-3.5`})})]}),(0,s.jsx)(ye,{items:t,config:e?.feed,hasMore:a,onLoadMore:o,loading:c,onAddComment:l,onAddReply:u,onToggleReaction:d,subscription:f,onToggleSubscription:p,filterMode:m,onFilterChange:h,collapseWhenEmpty:g})]})})},xe=({onSubmit:e,placeholder:t=`Leave a comment…`,disabled:a=!1,className:o})=>{let[c,l]=n.useState(``),[u,d]=n.useState(!1),f=n.useCallback(async()=>{let t=c.trim();if(t){d(!0);try{await e(t),l(``)}finally{d(!1)}}},[c,e]),p=n.useCallback(e=>{e.key===`Enter`&&(e.ctrlKey||e.metaKey)&&(e.preventDefault(),f())},[f]);return(0,s.jsxs)(`div`,{className:(0,r.cn)(`flex gap-2`,o),children:[(0,s.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:t,value:c,onChange:e=>l(e.target.value),onKeyDown:p,disabled:a||u}),(0,s.jsx)(r.Button,{size:`icon`,variant:`default`,onClick:f,disabled:!c.trim()||u||a,className:`shrink-0 self-end`,"aria-label":`Submit comment`,children:(0,s.jsx)(i.Send,{className:`h-4 w-4`})})]})},Se=({query:e,suggestions:t,onSelect:i,visible:a=!0,activeIndex:o=0,className:c})=>{let l=n.useMemo(()=>{if(!e)return t;let n=e.toLowerCase();return t.filter(e=>e.name.toLowerCase().includes(n)||e.id.toLowerCase().includes(n))},[e,t]);return!a||l.length===0?null:(0,s.jsx)(`div`,{className:(0,r.cn)(`bg-popover border rounded-md shadow-md z-50 max-h-48 overflow-y-auto w-56`,c),role:`listbox`,"aria-label":`Mention suggestions`,children:l.map((e,t)=>(0,s.jsxs)(`button`,{type:`button`,role:`option`,"aria-selected":t===o,className:(0,r.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(),i(e)},children:[e.avatarUrl?(0,s.jsx)(`img`,{src:e.avatarUrl,alt:e.name,className:`h-5 w-5 rounded-full object-cover`}):(0,s.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,s.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,s.jsx)(`span`,{className:`truncate`,children:e.name}),e.type!==`user`&&(0,s.jsxs)(`span`,{className:`ml-1 text-xs text-muted-foreground capitalize`,children:[`(`,e.type,`)`]})]})]},e.id))})};function Ce(e,t,n){return{type:e.type,id:e.id,name:e.name,offset:t,length:n}}t.ComponentRegistry.register(`detail-view`,B,{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:[]}}),t.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`}]}),t.ComponentRegistry.register(`related-list`,D,{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`}]}),t.ComponentRegistry.register(`detail`,B,{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`}]}),e.ActivityTimeline=L,e.CommentAttachment=ae,e.CommentInput=xe,e.DETAIL_DEFAULT_TRANSLATIONS=x,e.DetailSection=w,e.DetailTabs=T,e.DetailView=B,e.DiffView=K,e.FieldChangeItem=ce,e.HeaderHighlight=k,e.InlineCreateRelated=ee,e.MentionAutocomplete=Se,e.PointInTimeRestore=se,e.ReactionPicker=ue,e.RecordActivityTimeline=ye,e.RecordChatterPanel=be,e.RecordComments=j,e.RecordNavigationEnhanced=q,e.RelatedList=D,e.RelationshipGraph=$,e.RichTextCommentInput=H,e.SectionGroup=O,e.SubscriptionToggle=pe,e.ThreadedReplies=fe,e.applyAutoSpan=v,e.applyDetailAutoLayout=y,e.createMentionFromSuggestion=Ce,e.createSafeTranslationHook=b,e.inferDetailColumns=_,e.isWideFieldType=g,e.useDetailTranslation=S});
|
|
5
|
+
`)}}function G(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 K={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`},q={added:`+`,removed:`-`,unchanged:` `},J=({oldValue:e,newValue:t,fieldName:a,fieldType:o=`string`,mode:c=`unified`,className:l})=>{let{t:u}=S(),[d,f]=n.useState(c),p=n.useMemo(()=>W(e,o),[e,o]),m=n.useMemo(()=>W(t,o),[t,o]),h=n.useMemo(()=>G(p,m),[p,m]),g=h.some(e=>e.type!==`unchanged`),_=n.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,s.jsxs)(r.Card,{className:(0,r.cn)(`overflow-hidden`,l),children:[(0,s.jsx)(r.CardHeader,{className:`pb-2`,children:(0,s.jsxs)(r.CardTitle,{className:`flex items-center justify-between text-sm`,children:[(0,s.jsx)(`span`,{className:`font-medium`,children:a}),(0,s.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,s.jsx)(r.Button,{variant:d===`unified`?`secondary`:`ghost`,size:`icon`,className:`h-7 w-7`,onClick:()=>f(`unified`),title:u(`detail.unifiedDiff`),children:(0,s.jsx)(i.Rows3,{className:`h-3.5 w-3.5`})}),(0,s.jsx)(r.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,s.jsx)(i.Columns2,{className:`h-3.5 w-3.5`})})]})]})}),(0,s.jsx)(r.CardContent,{className:`p-0`,children:g?d===`unified`?(0,s.jsx)(`div`,{className:`font-mono text-xs overflow-x-auto`,children:h.map((e,t)=>(0,s.jsxs)(`div`,{className:(0,r.cn)(`px-4 py-0.5 whitespace-pre-wrap border-l-2`,K[e.type],e.type===`added`&&`border-l-green-500`,e.type===`removed`&&`border-l-red-500`,e.type===`unchanged`&&`border-l-transparent`),children:[(0,s.jsx)(`span`,{className:`select-none mr-2 inline-block w-3 text-center opacity-60`,children:q[e.type]}),e.value]},t))}):(0,s.jsx)(`div`,{className:`overflow-x-auto`,children:(0,s.jsxs)(`div`,{className:`grid grid-cols-2 divide-x font-mono text-xs min-w-0`,children:[(0,s.jsx)(`div`,{className:`px-3 py-1.5 text-xs font-medium text-muted-foreground bg-muted/50`,children:u(`detail.previousVersion`)}),(0,s.jsx)(`div`,{className:`px-3 py-1.5 text-xs font-medium text-muted-foreground bg-muted/50`,children:u(`detail.currentVersion`)}),_.map((e,t)=>(0,s.jsxs)(n.Fragment,{children:[(0,s.jsx)(`div`,{className:(0,r.cn)(`px-3 py-0.5 whitespace-pre-wrap min-h-[1.5em]`,e.left?K[e.left.type]:`bg-muted/20`),children:e.left?.value??``}),(0,s.jsx)(`div`,{className:(0,r.cn)(`px-3 py-0.5 whitespace-pre-wrap min-h-[1.5em]`,e.right?K[e.right.type]:`bg-muted/20`),children:e.right?.value??``})]},t))]})}):(0,s.jsx)(`p`,{className:`px-4 py-3 text-sm text-muted-foreground`,children:u(`detail.noChanges`)})})]})},Y=({currentIndex:e,totalRecords:t,recordIds:a,onNavigate:o,onSearch:c,className:l})=>{let{t:u}=S(),[d,f]=n.useState(``),[p,m]=n.useState(!1),h=n.useRef(null),g=e>0,_=e>0,v=e<t-1,y=e<t-1,b=n.useCallback(()=>{g&&o(a[0])},[g,o,a]),x=n.useCallback(()=>{_&&o(a[e-1])},[_,o,a,e]),C=n.useCallback(()=>{v&&o(a[e+1])},[v,o,a,e]),w=n.useCallback(()=>{y&&o(a[a.length-1])},[y,o,a]),T=n.useCallback(e=>{let t=e.target.value;f(t),c?.(t)},[c]),E=n.useCallback(()=>{m(e=>(e?(f(``),c?.(``)):requestAnimationFrame(()=>h.current?.focus()),!e))},[c]);return n.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(``),c?.(``),t.target.blur());return}switch(t.key){case`Home`:t.preventDefault(),g&&o(a[0]);break;case`End`:t.preventDefault(),y&&o(a[a.length-1]);break;case`ArrowLeft`:t.preventDefault(),_&&o(a[e-1]);break;case`ArrowRight`:t.preventDefault(),v&&o(a[e+1]);break}}};return document.addEventListener(`keydown`,t),()=>document.removeEventListener(`keydown`,t)},[e,a,g,_,v,y,o,c]),(0,s.jsxs)(`div`,{className:(0,r.cn)(`flex items-center gap-1.5`,l),children:[(0,s.jsx)(r.Button,{variant:`outline`,size:`icon`,className:`h-8 w-8`,disabled:!g,onClick:b,title:u(`detail.firstRecord`),children:(0,s.jsx)(i.ChevronsLeft,{className:`h-4 w-4`})}),(0,s.jsx)(r.Button,{variant:`outline`,size:`icon`,className:`h-8 w-8`,disabled:!_,onClick:x,title:u(`detail.previousRecordKey`),children:(0,s.jsx)(i.ChevronLeft,{className:`h-4 w-4`})}),(0,s.jsx)(`span`,{className:`text-xs text-muted-foreground whitespace-nowrap px-1.5 tabular-nums`,children:t>0?u(`detail.recordOf`,{current:e+1,total:t}):u(`detail.noRecords`)}),(0,s.jsx)(r.Button,{variant:`outline`,size:`icon`,className:`h-8 w-8`,disabled:!v,onClick:C,title:u(`detail.nextRecordKey`),children:(0,s.jsx)(i.ChevronRight,{className:`h-4 w-4`})}),(0,s.jsx)(r.Button,{variant:`outline`,size:`icon`,className:`h-8 w-8`,disabled:!y,onClick:w,title:u(`detail.lastRecord`),children:(0,s.jsx)(i.ChevronsRight,{className:`h-4 w-4`})}),c&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(r.Button,{variant:p?`secondary`:`ghost`,size:`icon`,className:`h-8 w-8`,onClick:E,title:u(`detail.searchWhileNavigating`),children:(0,s.jsx)(i.Search,{className:`h-4 w-4`})}),p&&(0,s.jsx)(`div`,{className:`relative`,children:(0,s.jsx)(r.Input,{ref:h,type:`text`,placeholder:u(`detail.searchRecords`),value:d,onChange:T,className:`h-8 w-48 text-sm`})})]})]})},X=28,Z=[`fill-primary stroke-primary`,`fill-blue-500 stroke-blue-500`,`fill-emerald-500 stroke-emerald-500`,`fill-amber-500 stroke-amber-500`],ae=[`fill-primary-foreground`,`fill-white`,`fill-white`,`fill-white`];function Q(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 oe(e,t=6){return e.length<=t?e:e.slice(0,t-1)+`…`}var se=({record:e,relatedRecords:t,levels:a=1,onNodeClick:o,className:c})=>{let l=n.useRef(null),[u,d]=n.useState({width:500,height:400}),[f,p]=n.useState(null);n.useEffect(()=>{let e=l.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}=n.useMemo(()=>Q(e,t,a,u.width,u.height),[e,t,a,u]);return(0,s.jsxs)(r.Card,{className:(0,r.cn)(`overflow-hidden`,c),children:[(0,s.jsx)(r.CardHeader,{className:`pb-2`,children:(0,s.jsxs)(r.CardTitle,{className:`flex items-center gap-2 text-base`,children:[(0,s.jsx)(i.Network,{className:`h-4 w-4`}),`Relationships`,(0,s.jsxs)(`span`,{className:`text-sm font-normal text-muted-foreground`,children:[`(`,t.length,` related)`]})]})}),(0,s.jsx)(r.CardContent,{className:`p-0`,children:(0,s.jsxs)(`svg`,{ref:l,width:`100%`,height:u.height,viewBox:`0 0 ${u.width} ${u.height}`,className:`select-none`,children:[h.map((e,t)=>(0,s.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=Z[Math.min(e.level,Z.length-1)],i=ae[Math.min(e.level,ae.length-1)],a=e.level===0?X+6:X;return(0,s.jsxs)(`g`,{className:(0,r.cn)(`cursor-pointer transition-transform`,o&&`hover:opacity-80`),onClick:()=>o?.(e.id),onMouseEnter:()=>p(e.id),onMouseLeave:()=>p(null),children:[(0,s.jsx)(`circle`,{cx:e.x,cy:e.y,r:t?a+3:a,className:n,fillOpacity:e.level===0?1:.85,strokeWidth:2,strokeOpacity:.3}),(0,s.jsx)(`text`,{x:e.x,y:e.y,textAnchor:`middle`,dominantBaseline:`central`,className:(0,r.cn)(`text-[10px] font-medium pointer-events-none`,i),children:oe(e.label)}),e.type&&(0,s.jsx)(`text`,{x:e.x,y:e.y+a+12,textAnchor:`middle`,className:`fill-muted-foreground text-[9px] pointer-events-none`,children:e.type}),t&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(`rect`,{x:e.x-50,y:e.y-a-28,width:100,height:20,rx:4,className:`fill-popover stroke-border`,strokeWidth:1}),(0,s.jsx)(`text`,{x:e.x,y:e.y-a-16,textAnchor:`middle`,dominantBaseline:`central`,className:`fill-popover-foreground text-[10px] pointer-events-none`,children:e.label})]})]},e.id)})]})})]})};function ce(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`}function $(e){return e.startsWith(`image/`)}function le(e){return $(e)?i.Image:e.includes(`pdf`)||e.includes(`document`)||e.includes(`text`)?i.FileText:e.includes(`zip`)||e.includes(`archive`)||e.includes(`compressed`)?i.FileArchive:i.File}var ue=({attachments:e,onUpload:t,onRemove:a,className:o,readOnly:c=!1})=>{let{t:l}=S(),[u,d]=n.useState(!1),f=n.useRef(null),p=n.useCallback(e=>{e.preventDefault(),e.stopPropagation(),d(!0)},[]),m=n.useCallback(e=>{e.preventDefault(),e.stopPropagation(),d(!1)},[]),h=n.useCallback(e=>{e.preventDefault(),e.stopPropagation(),d(!1),t&&e.dataTransfer.files.length>0&&t(e.dataTransfer.files)},[t]),g=n.useCallback(e=>{t&&e.target.files&&e.target.files.length>0&&(t(e.target.files),e.target.value=``)},[t]);return(0,s.jsxs)(`div`,{className:(0,r.cn)(`space-y-2`,o),children:[t&&!c&&(0,s.jsxs)(`div`,{className:(0,r.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,s.jsx)(i.Upload,{className:`h-5 w-5 mx-auto text-muted-foreground mb-1`}),(0,s.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:l(`detail.dropFilesToUpload`)}),(0,s.jsx)(`input`,{ref:f,type:`file`,multiple:!0,className:`hidden`,onChange:g})]}),e.length>0&&(0,s.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,s.jsxs)(`div`,{className:`flex items-center gap-1.5 text-xs text-muted-foreground`,children:[(0,s.jsx)(i.Paperclip,{className:`h-3 w-3`}),(0,s.jsx)(`span`,{children:e.length===1?l(`detail.attachmentCount`,{count:e.length}):l(`detail.attachmentCountPlural`,{count:e.length})})]}),(0,s.jsx)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 gap-2`,children:e.map(e=>{let t=$(e.type),n=le(e.type);return(0,s.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,s.jsx)(`img`,{src:e.thumbnailUrl||e.url,alt:e.name,className:`h-10 w-10 rounded object-cover shrink-0`}):(0,s.jsx)(`div`,{className:`h-10 w-10 rounded bg-muted flex items-center justify-center shrink-0`,children:(0,s.jsx)(n,{className:`h-5 w-5 text-muted-foreground`})}),(0,s.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,s.jsx)(`p`,{className:`text-xs font-medium truncate`,children:e.name}),(0,s.jsx)(`p`,{className:`text-[10px] text-muted-foreground`,children:ce(e.size)})]}),a&&!c&&(0,s.jsx)(r.Button,{variant:`ghost`,size:`icon`,className:`h-6 w-6 shrink-0 opacity-0 group-hover:opacity-100 transition-opacity`,onClick:()=>a(e.id),title:l(`detail.removeAttachment`),children:(0,s.jsx)(i.X,{className:`h-3.5 w-3.5`})})]},e.id)})})]})]})};function de(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 fe=({recordId:e,revisions:t,onRestore:a,className:o})=>{let[c,l]=n.useState(null),[u,d]=n.useState(!1),[f,p]=n.useState(!1),m=n.useMemo(()=>t.find(e=>e.id===c)??null,[t,c]),h=n.useCallback(async()=>{if(!(!m||!a)){if(!u){d(!0);return}p(!0);try{let e=m.snapshot??{};await a(m.id,e),d(!1),l(null)}finally{p(!1)}}},[m,a,u]),g=n.useCallback(()=>{d(!1)},[]);return(0,s.jsxs)(r.Card,{className:(0,r.cn)(``,o),children:[(0,s.jsx)(r.CardHeader,{className:`pb-3`,children:(0,s.jsxs)(r.CardTitle,{className:`flex items-center gap-2 text-base`,children:[(0,s.jsx)(i.History,{className:`h-4 w-4`}),`Revision History`,(0,s.jsxs)(`span`,{className:`text-sm font-normal text-muted-foreground`,children:[`(`,t.length,`)`]})]})}),(0,s.jsx)(r.CardContent,{children:t.length===0?(0,s.jsx)(`p`,{className:`text-sm text-muted-foreground text-center py-4`,children:`No revisions recorded`}):(0,s.jsxs)(`div`,{className:`flex flex-col lg:flex-row gap-4`,children:[(0,s.jsx)(`div`,{className:`flex-1 min-w-0`,children:(0,s.jsxs)(`div`,{className:`relative`,children:[(0,s.jsx)(`div`,{className:`absolute left-3 top-2 bottom-2 w-px bg-border`}),(0,s.jsx)(`div`,{className:`space-y-1`,children:t.map(e=>{let t=e.id===c;return(0,s.jsxs)(`button`,{type:`button`,className:(0,r.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:()=>{l(e.id),d(!1)},children:[(0,s.jsx)(`div`,{className:(0,r.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,s.jsx)(i.ChevronRight,{className:`h-3 w-3 text-primary-foreground`})}),(0,s.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,s.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,s.jsx)(`span`,{className:`text-sm font-medium`,children:e.user}),(0,s.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:de(e.timestamp)})]}),(0,s.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,s.jsxs)(`div`,{className:`lg:w-80 border rounded-md p-3 space-y-3`,children:[(0,s.jsxs)(`div`,{className:`flex items-center gap-2 text-sm font-medium`,children:[(0,s.jsx)(i.Eye,{className:`h-4 w-4 text-muted-foreground`}),`Revision Preview`]}),(0,s.jsx)(`div`,{className:`space-y-2`,children:m.changes.map((e,t)=>(0,s.jsxs)(`div`,{className:`text-xs`,children:[(0,s.jsx)(`span`,{className:`font-medium text-muted-foreground`,children:e.field}),(0,s.jsxs)(`div`,{className:`flex items-center gap-1.5 mt-0.5`,children:[(0,s.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,s.jsx)(i.ChevronRight,{className:`h-3 w-3 text-muted-foreground shrink-0`}),(0,s.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,s.jsxs)(`div`,{className:`border-t pt-2 space-y-1`,children:[(0,s.jsx)(`p`,{className:`text-xs font-medium text-muted-foreground`,children:`Record state at this point`}),(0,s.jsx)(`div`,{className:`max-h-40 overflow-y-auto space-y-1`,children:Object.entries(m.snapshot).map(([e,t])=>(0,s.jsxs)(`div`,{className:`flex justify-between text-xs gap-2`,children:[(0,s.jsx)(`span`,{className:`text-muted-foreground truncate`,children:e}),(0,s.jsx)(`span`,{className:`font-mono truncate max-w-[140px]`,children:t==null?`–`:String(t)})]},e))})]}),a&&(0,s.jsx)(`div`,{className:`pt-1 space-y-2`,children:u?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)(`p`,{className:`text-xs text-amber-600 dark:text-amber-400`,children:[`This will restore the record to its state at`,` `,de(m.timestamp),`. Continue?`]}),(0,s.jsxs)(`div`,{className:`flex gap-2`,children:[(0,s.jsxs)(r.Button,{variant:`destructive`,size:`sm`,className:`gap-1.5 flex-1`,onClick:h,disabled:f,children:[(0,s.jsx)(i.RotateCcw,{className:`h-3.5 w-3.5`}),f?`Restoring…`:`Confirm Restore`]}),(0,s.jsx)(r.Button,{variant:`ghost`,size:`sm`,onClick:g,disabled:f,children:`Cancel`})]})]}):(0,s.jsxs)(r.Button,{variant:`outline`,size:`sm`,className:`w-full gap-1.5`,onClick:h,children:[(0,s.jsx)(i.RotateCcw,{className:`h-3.5 w-3.5`}),`Restore to this point`]})})]})]})})]})},pe=({change:e,className:t})=>{let n=e.fieldLabel??e.field.charAt(0).toUpperCase()+e.field.slice(1).replace(/_/g,` `),a=e.oldDisplayValue??(e.oldValue==null?`(empty)`:String(e.oldValue)),o=e.newDisplayValue??(e.newValue==null?`(empty)`:String(e.newValue));return(0,s.jsxs)(`div`,{className:(0,r.cn)(`flex items-center gap-1.5 text-sm flex-wrap`,t),children:[(0,s.jsx)(`span`,{className:`font-medium text-foreground`,children:n}),(0,s.jsx)(`span`,{className:`text-muted-foreground line-through`,children:a}),(0,s.jsx)(i.ArrowRight,{className:`h-3 w-3 text-muted-foreground shrink-0`}),(0,s.jsx)(`span`,{className:`text-foreground`,children:o})]})},me=[`👍`,`❤️`,`🎉`,`😂`,`😮`,`😢`],he=({reactions:e,onToggleReaction:t,emojiOptions:a=me,className:o})=>{let[c,l]=n.useState(!1),u=n.useCallback(e=>{t?.(e),l(!1)},[t]);return(0,s.jsxs)(`div`,{className:(0,r.cn)(`flex items-center gap-1 flex-wrap`,o),children:[e.map(e=>(0,s.jsxs)(`button`,{type:`button`,className:(0,r.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:()=>u(e.emoji),disabled:!t,"aria-label":`${e.emoji} ${e.count} reaction${e.count===1?``:`s`}`,children:[(0,s.jsx)(`span`,{children:e.emoji}),(0,s.jsx)(`span`,{children:e.count})]},e.emoji)),t&&(0,s.jsxs)(`div`,{className:`relative`,children:[(0,s.jsx)(r.Button,{variant:`ghost`,size:`icon`,className:`h-6 w-6`,onClick:()=>l(!c),"aria-label":`Add reaction`,children:(0,s.jsx)(i.SmilePlus,{className:`h-3.5 w-3.5`})}),c&&(0,s.jsx)(`div`,{className:`absolute bottom-full mb-1 left-0 bg-popover border rounded-md shadow-md z-50 p-1.5 flex gap-1`,role:`listbox`,"aria-label":`Emoji picker`,children:a.map(t=>(0,s.jsx)(`button`,{type:`button`,className:`hover:bg-accent rounded p-1 text-base transition-colors`,onClick:()=>u(t),role:`option`,"aria-selected":e.some(e=>e.emoji===t&&e.reacted),children:t},t))})]})]})};function ge(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 _e=({parentItem:e,replies:t,onAddReply:a,showReplyInput:o=!0,className:c})=>{let{t:l}=S(),[u,d]=n.useState(!1),[f,p]=n.useState(``),[m,h]=n.useState(!1),g=n.useCallback(async()=>{let t=f.trim();if(!(!t||!a)){h(!0);try{await a(e.id,t),p(``)}finally{h(!1)}}},[f,a,e.id]),_=n.useCallback(e=>{e.key===`Enter`&&(e.ctrlKey||e.metaKey)&&(e.preventDefault(),g())},[g]);return t.length===0&&!o?null:(0,s.jsxs)(`div`,{className:(0,r.cn)(`ml-10 mt-1`,c),children:[t.length>0&&(0,s.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,s.jsx)(i.ChevronDown,{className:`h-3 w-3`}):(0,s.jsx)(i.ChevronRight,{className:`h-3 w-3`}),(0,s.jsx)(i.MessageSquare,{className:`h-3 w-3`}),(0,s.jsx)(`span`,{children:t.length===1?l(`detail.replyCount`,{count:t.length}):l(`detail.replyCountPlural`,{count:t.length})})]}),u&&(0,s.jsx)(`div`,{className:`space-y-2 border-l-2 border-border pl-3`,children:t.map(e=>(0,s.jsxs)(`div`,{className:`flex gap-2`,children:[(0,s.jsx)(`div`,{className:`shrink-0`,children:e.actorAvatarUrl?(0,s.jsx)(`img`,{src:e.actorAvatarUrl,alt:e.actor,className:`h-6 w-6 rounded-full object-cover`}):(0,s.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,s.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,s.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,s.jsx)(`span`,{className:`text-xs font-medium`,children:e.actor}),(0,s.jsx)(`span`,{className:`text-[10px] text-muted-foreground`,children:ge(e.createdAt)})]}),(0,s.jsx)(`p`,{className:`text-xs whitespace-pre-wrap break-words`,children:e.body})]})]},e.id))}),o&&a&&(0,s.jsxs)(`div`,{className:`flex gap-1.5 mt-1.5`,children:[(0,s.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:l(`detail.replyPlaceholder`),value:f,onChange:e=>p(e.target.value),onKeyDown:_,disabled:m}),(0,s.jsx)(r.Button,{variant:`ghost`,size:`icon`,className:`h-6 w-6 shrink-0`,onClick:g,disabled:!f.trim()||m,"aria-label":`Send reply`,children:(0,s.jsx)(i.Send,{className:`h-3 w-3`})})]})]})},ve=({subscription:e,onToggle:t,className:a})=>{let{t:o}=S(),[c,l]=n.useState(!1),u=n.useCallback(async()=>{if(t){l(!0);try{await t(!e.subscribed)}finally{l(!1)}}},[t,e.subscribed]);return(0,s.jsx)(r.Button,{variant:`ghost`,size:`icon`,className:(0,r.cn)(`h-8 w-8`,a),onClick:u,disabled:c||!t,"aria-label":e.subscribed?o(`detail.unsubscribeAriaLabel`):o(`detail.subscribeAriaLabel`),title:e.subscribed?o(`detail.subscribedTooltip`):o(`detail.unsubscribedTooltip`),children:e.subscribed?(0,s.jsx)(i.Bell,{className:`h-4 w-4 text-primary`}):(0,s.jsx)(i.BellOff,{className:`h-4 w-4 text-muted-foreground`})})},ye={comment:i.MessageSquare,field_change:i.Edit,task:i.CheckSquare,event:i.Calendar,system:i.Zap,email:i.Mail,call:i.Phone},be={comment:`bg-purple-100 text-purple-600`,field_change:`bg-blue-100 text-blue-600`,task:`bg-green-100 text-green-600`,event:`bg-amber-100 text-amber-600`,system:`bg-gray-100 text-gray-600`,email:`bg-indigo-100 text-indigo-600`,call:`bg-teal-100 text-teal-600`};function xe(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 Se(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 Ce(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 we=({items:e,config:t,filterMode:a,onFilterChange:o,hasMore:c=!1,onLoadMore:l,loading:u=!1,onAddComment:d,onAddReply:f,onToggleReaction:p,subscription:m,onToggleSubscription:h,collapseWhenEmpty:g=!1,className:_})=>{let{t:v}=S(),[y,b]=n.useState(`all`),[x,C]=n.useState(``),[w,T]=n.useState(!1),[E,D]=n.useState(!1),O=a??y,k=t?.showFilterToggle!==!1,A=t?.showCommentInput!==!1&&!!d,j=t?.enableReactions??!1,M=t?.enableThreading??!1,N=t?.showSubscriptionToggle??!1,P=n.useMemo(()=>Ce(e,O),[e,O]),F=n.useMemo(()=>M?P.filter(e=>!e.parentId):P,[P,M]),I=n.useMemo(()=>{if(!M)return new Map;let e=new Map;for(let t of P)if(t.parentId){let n=e.get(t.parentId)??[];n.push(t),e.set(t.parentId,n)}return e},[P,M]),L=n.useCallback(e=>{o?o(e):b(e)},[o]),R=n.useCallback(async()=>{let e=x.trim();if(!(!e||!d)){T(!0);try{await d(e),C(``)}finally{T(!1)}}},[x,d]),ee=n.useCallback(e=>{e.key===`Enter`&&(e.ctrlKey||e.metaKey)&&(e.preventDefault(),R())},[R]),z=n.useCallback(async()=>{if(l){D(!0);try{await l()}finally{D(!1)}}},[l]);return(0,s.jsxs)(r.Card,{className:(0,r.cn)(``,_),children:[(0,s.jsx)(r.CardHeader,{children:(0,s.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,s.jsxs)(r.CardTitle,{className:`flex items-center gap-2 text-base`,children:[(0,s.jsx)(i.Activity,{className:`h-4 w-4`}),v(`detail.activity`),(0,s.jsxs)(`span`,{className:`text-sm font-normal text-muted-foreground`,children:[`(`,P.length,`)`]})]}),(0,s.jsx)(`div`,{className:`flex items-center gap-1`,children:N&&m&&(0,s.jsx)(ve,{subscription:m,onToggle:h})})]})}),(0,s.jsxs)(r.CardContent,{className:`space-y-4`,children:[k&&(0,s.jsx)(`div`,{className:`flex items-center gap-2`,children:(0,s.jsx)(`select`,{className:`rounded-md border border-input bg-background px-2.5 py-1.5 text-sm focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring`,value:O,onChange:e=>L(e.target.value),"aria-label":v(`detail.filterActivity`),children:xe(v).map(e=>(0,s.jsx)(`option`,{value:e.value,children:e.label},e.value))})}),A&&(0,s.jsxs)(`div`,{className:`flex gap-2`,children:[(0,s.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:v(`detail.leaveCommentPlaceholder`),value:x,onChange:e=>C(e.target.value),onKeyDown:ee,disabled:w}),(0,s.jsx)(r.Button,{size:`icon`,variant:`default`,onClick:R,disabled:!x.trim()||w,className:`shrink-0 self-end`,"aria-label":v(`detail.submitComment`),children:(0,s.jsx)(i.MessageSquare,{className:`h-4 w-4`})})]}),P.length===0?g?null:(0,s.jsx)(`p`,{className:`text-sm text-muted-foreground text-center py-4`,children:v(`detail.noActivity`)}):(0,s.jsxs)(`div`,{className:`relative`,children:[(0,s.jsx)(`div`,{className:`absolute left-4 top-2 bottom-2 w-px bg-border`}),(0,s.jsx)(`div`,{className:`space-y-4`,children:F.map(e=>{let t=ye[e.type]||i.Zap,n=be[e.type]||`bg-gray-100 text-gray-600`,a=I.get(e.id)??[];return(0,s.jsxs)(`div`,{children:[(0,s.jsxs)(`div`,{className:`flex gap-3 relative`,children:[(0,s.jsx)(`div`,{className:(0,r.cn)(`shrink-0 h-8 w-8 rounded-full flex items-center justify-center z-10`,n),children:e.actorAvatarUrl?(0,s.jsx)(`img`,{src:e.actorAvatarUrl,alt:e.actor,className:`h-8 w-8 rounded-full object-cover`}):(0,s.jsx)(t,{className:`h-3.5 w-3.5`})}),(0,s.jsxs)(`div`,{className:`flex-1 min-w-0 pt-1`,children:[(0,s.jsxs)(`div`,{className:`flex items-center gap-2 mb-0.5`,children:[(0,s.jsx)(`span`,{className:`text-sm font-medium`,children:e.actor}),e.source&&(0,s.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:v(`detail.via`,{source:e.source})}),(0,s.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:Se(e.createdAt)}),e.edited&&(0,s.jsx)(`span`,{className:`text-xs text-muted-foreground italic`,children:v(`detail.edited`)}),e.pinned&&(0,s.jsxs)(`span`,{className:`text-xs text-amber-600`,children:[`📌 `,v(`detail.pinned`)]})]}),e.body&&(0,s.jsx)(`p`,{className:`text-sm whitespace-pre-wrap break-words text-muted-foreground`,children:e.body}),e.type===`field_change`&&e.fieldChanges&&(0,s.jsx)(`div`,{className:`space-y-1 mt-1`,children:e.fieldChanges.map((e,t)=>(0,s.jsx)(pe,{change:e},t))}),j&&e.reactions&&e.reactions.length>0&&(0,s.jsx)(`div`,{className:`mt-1.5`,children:(0,s.jsx)(he,{reactions:e.reactions,onToggleReaction:p?t=>p(e.id,t):void 0})}),j&&(!e.reactions||e.reactions.length===0)&&p&&(0,s.jsx)(`div`,{className:`mt-1.5`,children:(0,s.jsx)(he,{reactions:[],onToggleReaction:t=>p(e.id,t)})})]})]}),M&&(e.replyCount??0)>0&&(0,s.jsx)(_e,{parentItem:e,replies:a,onAddReply:f,showReplyInput:!!f})]},e.id)})})]}),c&&(0,s.jsx)(`div`,{className:`text-center pt-2`,children:(0,s.jsxs)(r.Button,{variant:`ghost`,size:`sm`,onClick:z,disabled:E,"aria-label":v(`detail.loadMore`),children:[E?(0,s.jsx)(i.Loader2,{className:`h-4 w-4 animate-spin mr-1`}):(0,s.jsx)(i.ChevronDown,{className:`h-4 w-4 mr-1`}),v(`detail.loadMore`)]})})]})]})},Te=({config:e,items:t,hasMore:a,onLoadMore:o,loading:c,onAddComment:l,onAddReply:u,onToggleReaction:d,subscription:f,onToggleSubscription:p,filterMode:m,onFilterChange:h,collapseWhenEmpty:g=!1,className:_})=>{let v=e?.position??`right`,y=e?.width??`360px`,b=e?.collapsible??!0,x=g&&t.length===0||(e?.defaultCollapsed??!1),{t:C}=S(),[w,T]=n.useState(x);return v===`right`||v===`left`?w&&b?(0,s.jsx)(`div`,{className:(0,r.cn)(`flex items-start pt-4`,v===`right`?`border-l`:`border-r`,_),children:(0,s.jsx)(r.Button,{variant:`ghost`,size:`icon`,className:`h-8 w-8 mx-1`,onClick:()=>T(!1),"aria-label":C(`detail.openDiscussion`),children:(0,s.jsx)(i.PanelRightOpen,{className:`h-4 w-4`})})}):(0,s.jsxs)(`div`,{className:(0,r.cn)(`flex flex-col overflow-hidden`,v===`right`?`border-l`:`border-r`,_),style:{width:y,minWidth:y},children:[(0,s.jsxs)(`div`,{className:`flex items-center justify-between px-4 py-3 border-b`,children:[(0,s.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,s.jsx)(i.MessageSquare,{className:`h-4 w-4`}),(0,s.jsx)(`span`,{className:`text-sm font-medium`,children:C(`detail.discussion`)})]}),b&&(0,s.jsx)(r.Button,{variant:`ghost`,size:`icon`,className:`h-7 w-7`,onClick:()=>T(!0),"aria-label":C(`detail.closeDiscussion`),children:(0,s.jsx)(i.X,{className:`h-3.5 w-3.5`})})]}),(0,s.jsx)(`div`,{className:`flex-1 overflow-y-auto`,children:(0,s.jsx)(we,{items:t,config:e?.feed,hasMore:a,onLoadMore:o,loading:c,onAddComment:l,onAddReply:u,onToggleReaction:d,subscription:f,onToggleSubscription:p,filterMode:m,onFilterChange:h,collapseWhenEmpty:g,className:`border-0 shadow-none`})})]}):(0,s.jsx)(`div`,{className:(0,r.cn)(``,_),children:b&&w?(0,s.jsxs)(r.Button,{variant:`ghost`,className:`w-full justify-start gap-2 text-muted-foreground`,onClick:()=>T(!1),"aria-label":C(`detail.showDiscussion`,{count:t.length}),children:[(0,s.jsx)(i.MessageSquare,{className:`h-4 w-4`}),(0,s.jsx)(`span`,{children:C(`detail.showDiscussion`,{count:t.length})})]}):(0,s.jsxs)(`div`,{children:[b&&(0,s.jsxs)(`div`,{className:`flex items-center justify-between mb-2`,children:[(0,s.jsxs)(`div`,{className:`flex items-center gap-2 text-sm font-medium`,children:[(0,s.jsx)(i.MessageSquare,{className:`h-4 w-4`}),C(`detail.discussion`)]}),(0,s.jsx)(r.Button,{variant:`ghost`,size:`icon`,className:`h-7 w-7`,onClick:()=>T(!0),"aria-label":C(`detail.hideDiscussion`),children:(0,s.jsx)(i.PanelRightClose,{className:`h-3.5 w-3.5`})})]}),(0,s.jsx)(we,{items:t,config:e?.feed,hasMore:a,onLoadMore:o,loading:c,onAddComment:l,onAddReply:u,onToggleReaction:d,subscription:f,onToggleSubscription:p,filterMode:m,onFilterChange:h,collapseWhenEmpty:g})]})})},Ee=({onSubmit:e,placeholder:t=`Leave a comment…`,disabled:a=!1,className:o})=>{let[c,l]=n.useState(``),[u,d]=n.useState(!1),f=n.useCallback(async()=>{let t=c.trim();if(t){d(!0);try{await e(t),l(``)}finally{d(!1)}}},[c,e]),p=n.useCallback(e=>{e.key===`Enter`&&(e.ctrlKey||e.metaKey)&&(e.preventDefault(),f())},[f]);return(0,s.jsxs)(`div`,{className:(0,r.cn)(`flex gap-2`,o),children:[(0,s.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:t,value:c,onChange:e=>l(e.target.value),onKeyDown:p,disabled:a||u}),(0,s.jsx)(r.Button,{size:`icon`,variant:`default`,onClick:f,disabled:!c.trim()||u||a,className:`shrink-0 self-end`,"aria-label":`Submit comment`,children:(0,s.jsx)(i.Send,{className:`h-4 w-4`})})]})},De=({query:e,suggestions:t,onSelect:i,visible:a=!0,activeIndex:o=0,className:c})=>{let l=n.useMemo(()=>{if(!e)return t;let n=e.toLowerCase();return t.filter(e=>e.name.toLowerCase().includes(n)||e.id.toLowerCase().includes(n))},[e,t]);return!a||l.length===0?null:(0,s.jsx)(`div`,{className:(0,r.cn)(`bg-popover border rounded-md shadow-md z-50 max-h-48 overflow-y-auto w-56`,c),role:`listbox`,"aria-label":`Mention suggestions`,children:l.map((e,t)=>(0,s.jsxs)(`button`,{type:`button`,role:`option`,"aria-selected":t===o,className:(0,r.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(),i(e)},children:[e.avatarUrl?(0,s.jsx)(`img`,{src:e.avatarUrl,alt:e.name,className:`h-5 w-5 rounded-full object-cover`}):(0,s.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,s.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,s.jsx)(`span`,{className:`truncate`,children:e.name}),e.type!==`user`&&(0,s.jsxs)(`span`,{className:`ml-1 text-xs text-muted-foreground capitalize`,children:[`(`,e.type,`)`]})]})]},e.id))})};function Oe(e,t,n){return{type:e.type,id:e.id,name:e.name,offset:t,length:n}}t.ComponentRegistry.register(`detail-view`,z,{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:[]}}),t.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`}]}),t.ComponentRegistry.register(`related-list`,D,{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`}]}),t.ComponentRegistry.register(`detail`,z,{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`}]}),e.ActivityTimeline=L,e.CommentAttachment=ue,e.CommentInput=Ee,e.DETAIL_DEFAULT_TRANSLATIONS=x,e.DetailSection=w,e.DetailTabs=T,e.DetailView=z,e.DiffView=J,e.FieldChangeItem=pe,e.HeaderHighlight=k,e.InlineCreateRelated=re,e.MentionAutocomplete=De,e.PointInTimeRestore=fe,e.ReactionPicker=he,e.RecordActivityTimeline=we,e.RecordChatterPanel=Te,e.RecordComments=j,e.RecordDetailDrawer=H,e.RecordNavigationEnhanced=Y,e.RelatedList=D,e.RelationshipGraph=se,e.RichTextCommentInput=U,e.SectionGroup=O,e.SubscriptionToggle=ve,e.ThreadedReplies=_e,e.applyAutoSpan=v,e.applyDetailAutoLayout=y,e.createMentionFromSuggestion=Oe,e.createSafeTranslationHook=b,e.deriveRecordPageHref=ne,e.inferDetailColumns=_,e.isWideFieldType=g,e.useDetailTranslation=S});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DetailSection.d.ts","sourceRoot":"","sources":["../../../../src/DetailSection.tsx"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAqB/B,OAAO,KAAK,EAAE,iBAAiB,IAAI,qBAAqB,EAAkC,MAAM,kBAAkB,CAAC;AAKnH;;;;;;;GAOG;AACH,wBAAgB,sBAAsB,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,EAAE,OAAO,EAAE,MAAM,GAAG,MAAM,CAYxF;AAED,MAAM,WAAW,oBAAoB;IACnC,oDAAoD;IACpD,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,mDAAmD;IACnD,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,yFAAyF;IACzF,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,kBAAkB;IACjC,OAAO,EAAE,qBAAqB,CAAC;IAC/B,IAAI,CAAC,EAAE,GAAG,CAAC;IACX,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,8DAA8D;IAC9D,YAAY,CAAC,EAAE,GAAG,CAAC;IACnB,kDAAkD;IAClD,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,uCAAuC;IACvC,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,gEAAgE;IAChE,aAAa,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,KAAK,IAAI,CAAC;IACpD,oEAAoE;IACpE,aAAa,CAAC,EAAE,oBAAoB,CAAC;CACtC;AAED,eAAO,MAAM,aAAa,EAAE,KAAK,CAAC,EAAE,CAAC,kBAAkB,
|
|
1
|
+
{"version":3,"file":"DetailSection.d.ts","sourceRoot":"","sources":["../../../../src/DetailSection.tsx"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAqB/B,OAAO,KAAK,EAAE,iBAAiB,IAAI,qBAAqB,EAAkC,MAAM,kBAAkB,CAAC;AAKnH;;;;;;;GAOG;AACH,wBAAgB,sBAAsB,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,EAAE,OAAO,EAAE,MAAM,GAAG,MAAM,CAYxF;AAED,MAAM,WAAW,oBAAoB;IACnC,oDAAoD;IACpD,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,mDAAmD;IACnD,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,yFAAyF;IACzF,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,kBAAkB;IACjC,OAAO,EAAE,qBAAqB,CAAC;IAC/B,IAAI,CAAC,EAAE,GAAG,CAAC;IACX,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,8DAA8D;IAC9D,YAAY,CAAC,EAAE,GAAG,CAAC;IACnB,kDAAkD;IAClD,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,uCAAuC;IACvC,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,gEAAgE;IAChE,aAAa,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,KAAK,IAAI,CAAC;IACpD,oEAAoE;IACpE,aAAa,CAAC,EAAE,oBAAoB,CAAC;CACtC;AAED,eAAO,MAAM,aAAa,EAAE,KAAK,CAAC,EAAE,CAAC,kBAAkB,CAsXtD,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DetailView.d.ts","sourceRoot":"","sources":["../../../../src/DetailView.tsx"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAkC/B,OAAO,KAAK,EAAE,gBAAgB,EAAE,UAAU,EAA4B,MAAM,kBAAkB,CAAC;AAqE/F,MAAM,WAAW,eAAe;IAC9B,MAAM,EAAE,gBAAgB,CAAC;IACzB,UAAU,CAAC,EAAE,UAAU,CAAC;IACxB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,MAAM,CAAC,EAAE,MAAM,IAAI,CAAC;IACpB,QAAQ,CAAC,EAAE,MAAM,IAAI,CAAC;IACtB,MAAM,CAAC,EAAE,MAAM,IAAI,CAAC;IACpB,qDAAqD;IACrD,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,kDAAkD;IAClD,WAAW,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,EAAE,MAAM,EAAE,GAAG,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC/E;;;;OAIG;IACH,cAAc,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IACjC;;;;OAIG;IACH,SAAS,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAC5B;;;OAGG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB;;;;;OAKG;IACH,YAAY,CAAC,EAAE,CAAC,MAAM,EAAE,GAAG,KAAK,IAAI,CAAC;CACtC;AAED,eAAO,MAAM,UAAU,EAAE,KAAK,CAAC,EAAE,CAAC,eAAe,
|
|
1
|
+
{"version":3,"file":"DetailView.d.ts","sourceRoot":"","sources":["../../../../src/DetailView.tsx"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAkC/B,OAAO,KAAK,EAAE,gBAAgB,EAAE,UAAU,EAA4B,MAAM,kBAAkB,CAAC;AAqE/F,MAAM,WAAW,eAAe;IAC9B,MAAM,EAAE,gBAAgB,CAAC;IACzB,UAAU,CAAC,EAAE,UAAU,CAAC;IACxB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,MAAM,CAAC,EAAE,MAAM,IAAI,CAAC;IACpB,QAAQ,CAAC,EAAE,MAAM,IAAI,CAAC;IACtB,MAAM,CAAC,EAAE,MAAM,IAAI,CAAC;IACpB,qDAAqD;IACrD,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,kDAAkD;IAClD,WAAW,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,EAAE,MAAM,EAAE,GAAG,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC/E;;;;OAIG;IACH,cAAc,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IACjC;;;;OAIG;IACH,SAAS,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAC5B;;;OAGG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB;;;;;OAKG;IACH,YAAY,CAAC,EAAE,CAAC,MAAM,EAAE,GAAG,KAAK,IAAI,CAAC;CACtC;AAED,eAAO,MAAM,UAAU,EAAE,KAAK,CAAC,EAAE,CAAC,eAAe,CAggChD,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"HeaderHighlight.d.ts","sourceRoot":"","sources":["../../../../src/HeaderHighlight.tsx"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAIvD,MAAM,WAAW,oBAAoB;IACnC,MAAM,EAAE,cAAc,EAAE,CAAC;IACzB,IAAI,CAAC,EAAE,GAAG,CAAC;IACX,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,kDAAkD;IAClD,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,kDAAkD;IAClD,YAAY,CAAC,EAAE,GAAG,CAAC;CACpB;AAED,eAAO,MAAM,eAAe,EAAE,KAAK,CAAC,EAAE,CAAC,oBAAoB,
|
|
1
|
+
{"version":3,"file":"HeaderHighlight.d.ts","sourceRoot":"","sources":["../../../../src/HeaderHighlight.tsx"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAIvD,MAAM,WAAW,oBAAoB;IACnC,MAAM,EAAE,cAAc,EAAE,CAAC;IACzB,IAAI,CAAC,EAAE,GAAG,CAAC;IACX,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,kDAAkD;IAClD,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,kDAAkD;IAClD,YAAY,CAAC,EAAE,GAAG,CAAC;CACpB;AAED,eAAO,MAAM,eAAe,EAAE,KAAK,CAAC,EAAE,CAAC,oBAAoB,CAiE1D,CAAC"}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { DataSource } from '../../types/src';
|
|
2
|
+
export interface RecordDetailDrawerProps {
|
|
3
|
+
/** Whether the drawer is currently open. */
|
|
4
|
+
open: boolean;
|
|
5
|
+
/** Called when the user dismisses the drawer (overlay click, Esc, after delete). */
|
|
6
|
+
onClose: () => void;
|
|
7
|
+
/** Drawer header title (typically the record's primary label). */
|
|
8
|
+
title: string;
|
|
9
|
+
/** The record being displayed. */
|
|
10
|
+
record: Record<string, any>;
|
|
11
|
+
/** Logical object name used by the data source. */
|
|
12
|
+
objectName: string;
|
|
13
|
+
/** Record id (string-coerced before issuing update/delete). */
|
|
14
|
+
recordId: string | number;
|
|
15
|
+
/** Active data source — used for inline updates and deletion. */
|
|
16
|
+
dataSource?: DataSource;
|
|
17
|
+
/**
|
|
18
|
+
* Optional objectSchema (as returned by `dataSource.getObjectSchema`).
|
|
19
|
+
* When provided the drawer infers field types so dates / picklists /
|
|
20
|
+
* currency render with their proper widgets.
|
|
21
|
+
*/
|
|
22
|
+
objectSchema?: {
|
|
23
|
+
fields?: Record<string, any>;
|
|
24
|
+
} | null;
|
|
25
|
+
/**
|
|
26
|
+
* Drawer width — accepts any CSS width value. Defaults to
|
|
27
|
+
* `min(960px, 60vw)` which fills ~60% of typical desktop viewports
|
|
28
|
+
* (the prior `max-w-2xl` cap felt cramped on wide screens).
|
|
29
|
+
*
|
|
30
|
+
* Note: when `resizable` is true (the default), this is only used
|
|
31
|
+
* as the initial width — the user's drag-resized width takes over
|
|
32
|
+
* and is persisted to localStorage keyed by `objectName`.
|
|
33
|
+
*/
|
|
34
|
+
width?: string | number;
|
|
35
|
+
/** Number of columns the field grid should use. Default `2`. */
|
|
36
|
+
columns?: number;
|
|
37
|
+
/**
|
|
38
|
+
* Optional override for the SYSTEM_FIELDS filter. Defaults to a
|
|
39
|
+
* standard set (id, timestamps, audit fields).
|
|
40
|
+
*/
|
|
41
|
+
systemFields?: Set<string>;
|
|
42
|
+
/**
|
|
43
|
+
* Persist an inline field edit. Plugins usually update local state
|
|
44
|
+
* here so the drawer stays in sync after the network round-trip.
|
|
45
|
+
*/
|
|
46
|
+
onFieldSave?: (field: string, value: unknown) => void | Promise<void>;
|
|
47
|
+
/**
|
|
48
|
+
* Persist record deletion. Plugins are expected to remove the record
|
|
49
|
+
* from their local state; the drawer auto-closes after this resolves.
|
|
50
|
+
*/
|
|
51
|
+
onDelete?: () => void | Promise<void>;
|
|
52
|
+
/**
|
|
53
|
+
* Allow the user to drag the left edge to resize the drawer width.
|
|
54
|
+
* Resized width is persisted per-objectName in localStorage. Default `true`.
|
|
55
|
+
*/
|
|
56
|
+
resizable?: boolean;
|
|
57
|
+
/**
|
|
58
|
+
* Optional URL to the full record page. When provided, the drawer
|
|
59
|
+
* shows an "Open in new tab" button in the header that opens this
|
|
60
|
+
* URL in a new browser tab. The drawer itself stays open.
|
|
61
|
+
* Typically `/console/apps/{appName}/{objectName}/record/{recordId}`.
|
|
62
|
+
*/
|
|
63
|
+
fullPageHref?: string;
|
|
64
|
+
}
|
|
65
|
+
/** Right-side drawer wrapping {@link DetailView} for a single record. */
|
|
66
|
+
export declare function RecordDetailDrawer({ open, onClose, title, record, objectName, recordId, dataSource, objectSchema, width, columns, systemFields, onFieldSave, onDelete, resizable, fullPageHref, }: RecordDetailDrawerProps): import("react/jsx-runtime").JSX.Element;
|
|
67
|
+
export default RecordDetailDrawer;
|
|
68
|
+
/**
|
|
69
|
+
* Derive a full record-page URL from the current browser location.
|
|
70
|
+
*
|
|
71
|
+
* Used by plugin-gantt / plugin-calendar / plugin-kanban to populate
|
|
72
|
+
* `RecordDetailDrawer.fullPageHref` without each plugin needing direct
|
|
73
|
+
* access to the router. Strips any `/view/{viewId}` suffix so the
|
|
74
|
+
* resulting URL points at the canonical record page.
|
|
75
|
+
*
|
|
76
|
+
* @param objectName - The object name segment in the URL
|
|
77
|
+
* (e.g. `campaign`, `lead`).
|
|
78
|
+
* @param recordId - The record's primary key, will be URL-encoded.
|
|
79
|
+
* @returns A path like `/console/apps/{app}/{objectName}/record/{id}`,
|
|
80
|
+
* or `null` when called outside the browser.
|
|
81
|
+
*/
|
|
82
|
+
export declare function deriveRecordPageHref(objectName: string, recordId: string | number): string | null;
|
|
83
|
+
//# sourceMappingURL=RecordDetailDrawer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RecordDetailDrawer.d.ts","sourceRoot":"","sources":["../../../../src/RecordDetailDrawer.tsx"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAuBH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAUnD,MAAM,WAAW,uBAAuB;IACtC,4CAA4C;IAC5C,IAAI,EAAE,OAAO,CAAC;IACd,oFAAoF;IACpF,OAAO,EAAE,MAAM,IAAI,CAAC;IACpB,kEAAkE;IAClE,KAAK,EAAE,MAAM,CAAC;IACd,kCAAkC;IAClC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAC5B,mDAAmD;IACnD,UAAU,EAAE,MAAM,CAAC;IACnB,+DAA+D;IAC/D,QAAQ,EAAE,MAAM,GAAG,MAAM,CAAC;IAC1B,iEAAiE;IACjE,UAAU,CAAC,EAAE,UAAU,CAAC;IACxB;;;;OAIG;IACH,YAAY,CAAC,EAAE;QAAE,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;KAAE,GAAG,IAAI,CAAC;IACvD;;;;;;;;OAQG;IACH,KAAK,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IACxB,gEAAgE;IAChE,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB;;;OAGG;IACH,YAAY,CAAC,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;IAC3B;;;OAGG;IACH,WAAW,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACtE;;;OAGG;IACH,QAAQ,CAAC,EAAE,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACtC;;;OAGG;IACH,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB;;;;;OAKG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAKD,yEAAyE;AACzE,wBAAgB,kBAAkB,CAAC,EACjC,IAAI,EACJ,OAAO,EACP,KAAK,EACL,MAAM,EACN,UAAU,EACV,QAAQ,EACR,UAAU,EACV,YAAY,EACZ,KAA0B,EAC1B,OAAW,EACX,YAAoC,EACpC,WAAW,EACX,QAAQ,EACR,SAAgB,EAChB,YAAY,GACb,EAAE,uBAAuB,2CAyMzB;AAED,eAAe,kBAAkB,CAAC;AAElC;;;;;;;;;;;;;GAaG;AACH,wBAAgB,oBAAoB,CAAC,UAAU,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,GAAG,IAAI,CAQjG"}
|