

export const RUNTIME_HELPER_ROLES = new Set<string>([
  'tool',
  'drawingAreaDraft',
  'clipPath',
  'snapVertical',
  'snapHorizontal',
  'shapePreview',
  'drawingZoneOutline',
  'drawingZonePicker',
  'selectionMenuAnchor',
  'curvedGuidePath',
]);

export const isRuntimeHelperRole = (role: any): boolean => {
  const normalized = String(role ?? '').trim();
  if (!normalized) return false;
  // Drawing-area visuals use a few runtime-only roles
  // (`drawingZoneOutline`, `drawingZonePicker`, `drawingZonePlaceholder`, ...).
  // Treat the whole prefix as helper state so old/imported JSON cannot persist
  // those Fabric overlays as real document objects and duplicate them on reload.
  if (normalized === 'drawingZone' || normalized.startsWith('drawingZone')) return true;
  return RUNTIME_HELPER_ROLES.has(normalized);
};

export const isRuntimeHelperObject = (obj: any): boolean => {
  if (!obj) return false;
  if ((obj as any)?.excludeFromExport) return true;
  return isRuntimeHelperRole((obj as any)?._asukaRole);
};

export const isExportHelperObject = (obj: any): boolean => isRuntimeHelperObject(obj);
