function generateViewsMetadata(context) {
  const { spec, views = [] } = context;
  const specViews = views.length > 0 ? views : spec?.views || [];
  const viewsArray = Array.isArray(specViews) ? specViews : Object.values(specViews);
  const metadata = {};
  viewsArray.forEach((viewDef) => {
    const viewName = viewDef.name;
    metadata[viewName] = {
      name: viewName,
      type: viewDef.type || "list",
      ...viewDef.description && { description: viewDef.description },
      model: viewDef.model,
      // Keep as-is (string or array for multi-model views)
      ...viewDef.uiComponents && { uiComponents: viewDef.uiComponents },
      ...viewDef.subscriptions && viewDef.subscriptions.length > 0 && {
        subscriptions: viewDef.subscriptions
      },
      routing: viewDef.routing || {
        path: `/${viewName.toLowerCase().replace(/view$/, "")}`
      }
    };
  });
  return JSON.stringify(metadata, null, 2);
}
export {
  generateViewsMetadata as default
};
