// Dashboard widget registry — the single source of truth for the palette and for rendering. Each entry
// maps a widget `type` to its component, title, icon, palette group, and default/min grid sizing
// (grid-layout-plus units: a 12-column grid with ~40px rows). Layout items reference these by `type`.
import PortfolioStatsWidget from '../components/widgets/PortfolioStatsWidget.vue';
import CategoryValueWidget from '../components/widgets/CategoryValueWidget.vue';
import AssetStatusWidget from '../components/widgets/AssetStatusWidget.vue';
import RecentActivityWidget from '../components/widgets/RecentActivityWidget.vue';
import SystemStatusWidget from '../components/widgets/SystemStatusWidget.vue';
import AlertsSummaryWidget from '../components/widgets/AlertsSummaryWidget.vue';
import UpcomingMaintenanceWidget from '../components/widgets/UpcomingMaintenanceWidget.vue';
import QuickLinksWidget from '../components/widgets/QuickLinksWidget.vue';
import DeprYtdByBookWidget from '../components/widgets/DeprYtdByBookWidget.vue';
import DeprTotalByBookWidget from '../components/widgets/DeprTotalByBookWidget.vue';
import DeprByCategoryWidget from '../components/widgets/DeprByCategoryWidget.vue';
import AssetScannerWidget from '../components/widgets/AssetScannerWidget.vue';
import QuickAddAssetWidget from '../components/widgets/QuickAddAssetWidget.vue';
import ContactLookupWidget from '../components/widgets/ContactLookupWidget.vue';
import ContactQuickAddWidget from '../components/widgets/ContactQuickAddWidget.vue';

export const WIDGETS = {
  'portfolio-stats': { title: 'Portfolio overview', icon: 'mdi-chart-box-outline', group: 'Overview', component: PortfolioStatsWidget, w: 12, h: 3, minW: 4, minH: 3 },
  'category-value': { title: 'Category value', icon: 'mdi-shape-outline', group: 'Overview', component: CategoryValueWidget, w: 6, h: 8, minW: 3, minH: 5 },
  'asset-status': { title: 'Assets by status', icon: 'mdi-chart-donut', group: 'Overview', component: AssetStatusWidget, w: 4, h: 6, minW: 3, minH: 5 },
  'recent-activity': { title: 'Recent activity', icon: 'mdi-history', group: 'Overview', component: RecentActivityWidget, w: 4, h: 8, minW: 3, minH: 4 },
  'alerts-summary': { title: 'Alerts summary', icon: 'mdi-bell-alert-outline', group: 'Overview', component: AlertsSummaryWidget, w: 3, h: 4, minW: 2, minH: 3 },
  'system-status': { title: 'System status', icon: 'mdi-heart-pulse', group: 'Overview', component: SystemStatusWidget, w: 3, h: 5, minW: 2, minH: 4 },
  'upcoming-maintenance': { title: 'Upcoming maintenance', icon: 'mdi-wrench-clock', group: 'Maintenance', component: UpcomingMaintenanceWidget, w: 4, h: 6, minW: 3, minH: 4 },
  'depr-ytd-book': { title: 'YTD depreciation by book', icon: 'mdi-chart-bar', group: 'Financial', component: DeprYtdByBookWidget, w: 4, h: 6, minW: 3, minH: 5 },
  'depr-total-book': { title: 'Total depreciation by book', icon: 'mdi-chart-bar-stacked', group: 'Financial', component: DeprTotalByBookWidget, w: 4, h: 6, minW: 3, minH: 5 },
  'depr-category': { title: 'Depreciation by category', icon: 'mdi-chart-line', group: 'Financial', component: DeprByCategoryWidget, w: 4, h: 6, minW: 3, minH: 5 },
  'asset-scanner': { title: 'Asset lookup / scan', icon: 'mdi-barcode-scan', group: 'Tools', component: AssetScannerWidget, w: 4, h: 5, minW: 3, minH: 4 },
  'quick-add-asset': { title: 'Quick-add asset', icon: 'mdi-plus-box-outline', group: 'Tools', component: QuickAddAssetWidget, w: 4, h: 7, minW: 3, minH: 6 },
  'contact-lookup': { title: 'Contact lookup', icon: 'mdi-account-search-outline', group: 'Tools', component: ContactLookupWidget, w: 4, h: 6, minW: 3, minH: 4 },
  'contact-quick-add': { title: 'Quick-add contact', icon: 'mdi-account-plus-outline', group: 'Tools', component: ContactQuickAddWidget, w: 4, h: 7, minW: 3, minH: 6 },
  'quick-links': { title: 'Quick links', icon: 'mdi-link-variant', group: 'Tools', component: QuickLinksWidget, w: 4, h: 4, minW: 2, minH: 3 }
};

export const WIDGET_GROUPS = ['Overview', 'Financial', 'Maintenance', 'Tools'];

// A sensible starter dashboard for users who have not customized one yet.
export function defaultLayout() {
  const item = (type, x, y, w, h) => ({ i: `${type}-${x}-${y}`, type, x, y, w, h });
  return [
    item('portfolio-stats', 0, 0, 12, 3),
    item('depr-ytd-book', 0, 3, 4, 6),
    item('depr-total-book', 4, 3, 4, 6),
    item('upcoming-maintenance', 8, 3, 4, 6),
    item('category-value', 0, 9, 6, 8),
    item('recent-activity', 6, 9, 3, 8),
    item('alerts-summary', 9, 9, 3, 4),
    item('system-status', 9, 13, 3, 4)
  ];
}
