/**
 * 消息类型 → 定制展示组件注册表
 * 点击消息时优先按 type_code 选视图，再叠加 action_type 打开业务审核
 */
import type { Component } from 'vue';

import DoctorInputNoticeView from './DoctorInputNoticeView.vue';
import InvoiceNoticeView from './InvoiceNoticeView.vue';
import PeriodReportView from './PeriodReportView.vue';
import PriceChangeNoticeView from './PriceChangeNoticeView.vue';
import QueueFailureView from './QueueFailureView.vue';
import RichTextNoticeView from './RichTextNoticeView.vue';
import ScheduleChangeNoticeView from './ScheduleChangeNoticeView.vue';
import StoreInputNoticeView from './StoreInputNoticeView.vue';
import VipNoticeView from './VipNoticeView.vue';
import WarehouseProductNoticeView from './WarehouseProductNoticeView.vue';
import WithdrawNoticeView from './WithdrawNoticeView.vue';

export const NOTICE_TYPE_VIEW: Record<string, Component> = {
  vip: VipNoticeView,
  period_report: PeriodReportView,
  withdraw_audit: WithdrawNoticeView,
  invoice_todo: InvoiceNoticeView,
  queue_failure: QueueFailureView,
  doctor_input_audit: DoctorInputNoticeView,
  store_input_audit: StoreInputNoticeView,
  warehouse_product_audit: WarehouseProductNoticeView,
  price_change: PriceChangeNoticeView,
  schedule_change: ScheduleChangeNoticeView,
  system: RichTextNoticeView,
  broadcast: RichTextNoticeView,
  prescription_audit: RichTextNoticeView,
};

export function resolveNoticeView(typeCode?: string): Component {
  const code = String(typeCode || '').trim();
  return NOTICE_TYPE_VIEW[code] || RichTextNoticeView;
}

/** 仍需继续打开外部业务审核 Modal 的类型（视图内 emit audit） */
export const AUDIT_TYPE_CODES = new Set([
  'withdraw_audit',
  'warehouse_product_audit',
  'invoice_todo',
]);
