/**
 * 资源分页列表在 RecordBoard 表格中的列配置（对齐 FormResourcePageItem）
 */
import { locales } from '@pisell/utils';
import reservationLocales from "../locales/locales";
var I18N_RES_ID = 'pisell-reservation.resource-grid.id';
var I18N_RES_NAME = 'pisell-reservation.resource-grid.name';
var I18N_RES_FORM = 'pisell-reservation.resource-grid.form-code';
var I18N_RES_CAP = 'pisell-reservation.resource-grid.capacity';
var I18N_RES_SCHEDULE = 'pisell-reservation.resource-grid.schedule';
var I18N_RES_FORM_ID = 'pisell-reservation.resource-grid.form-id';
function initGridLocales(lang) {
  locales.init(reservationLocales, lang);
}
function renderSchedule(v) {
  if (v == null) return '—';
  if (Array.isArray(v)) return v.length ? v.join(', ') : '—';
  if (typeof v === 'string') return v.trim() || '—';
  return String(v);
}
export function getReservationResourceGridColumns(engineLocale) {
  initGridLocales(engineLocale);
  return [{
    key: 'id',
    title: locales.getText(I18N_RES_ID),
    dataIndex: 'id',
    width: 88,
    filterable: false,
    sortable: false
  }, {
    key: 'main_field',
    title: locales.getText(I18N_RES_NAME),
    dataIndex: 'main_field',
    ellipsis: true,
    filterable: false,
    sortable: false,
    render: function render(v) {
      var _s$split$0$trim, _s$split$;
      var s = typeof v === 'string' ? v : '';
      var first = (_s$split$0$trim = (_s$split$ = s.split(' ## ')[0]) === null || _s$split$ === void 0 ? void 0 : _s$split$.trim()) !== null && _s$split$0$trim !== void 0 ? _s$split$0$trim : '';
      return first || '—';
    }
  }, {
    key: 'form_code',
    title: locales.getText(I18N_RES_FORM),
    dataIndex: 'form_code',
    width: 120,
    ellipsis: true,
    filterable: false,
    sortable: false,
    render: function render(v) {
      return typeof v === 'string' && v.trim() ? v : '—';
    }
  }, {
    key: 'capacity',
    title: locales.getText(I18N_RES_CAP),
    dataIndex: 'capacity',
    width: 88,
    filterable: false,
    sortable: false,
    render: function render(v) {
      return v != null && v !== '' ? String(v) : '—';
    }
  }, {
    key: 'schedule',
    title: locales.getText(I18N_RES_SCHEDULE),
    dataIndex: 'schedule',
    width: 120,
    ellipsis: true,
    filterable: false,
    sortable: false,
    render: function render(_, record) {
      return renderSchedule(record.schedule);
    }
  }, {
    key: 'form_id',
    title: locales.getText(I18N_RES_FORM_ID),
    dataIndex: 'form_id',
    width: 96,
    filterable: false,
    sortable: false,
    render: function render(v) {
      return v != null && v !== '' ? String(v) : '—';
    }
  }];
}