// behaviors/types.ts
function getBehaviorMetadata(behavior) {
  const sm = behavior.stateMachine;
  const states = (sm?.states || []).map((s) => s.name);
  const events = (sm?.events || []).map((e) => e.key);
  return {
    name: behavior.name,
    category: behavior.category,
    description: behavior.description || "",
    states,
    events,
    tickCount: behavior.ticks?.length || 0,
    transitionCount: sm?.transitions?.length || 0,
    hasDataEntities: (behavior.dataEntities?.length || 0) > 0
  };
}
function validateBehaviorStructure(behavior) {
  const errors = [];
  if (!behavior.name) {
    errors.push("Behavior must have a name");
  }
  if (!behavior.name.startsWith("std/")) {
    errors.push(`Behavior name should start with 'std/' (got: ${behavior.name})`);
  }
  const sm = behavior.stateMachine;
  if (sm) {
    if (!sm.states || sm.states.length === 0) {
      errors.push("State machine must have at least one state");
    }
    const hasInitialState = sm.states?.some((s) => s.isInitial);
    if (!hasInitialState) {
      errors.push("State machine must have an initial state (set isInitial: true on one state)");
    }
  }
  return errors;
}
function validateBehaviorEvents(behavior) {
  const errors = [];
  const sm = behavior.stateMachine;
  if (!sm) return errors;
  const declaredEvents = new Set(
    (sm.events || []).map((e) => e.key)
  );
  const transitionEvents = new Set(
    (sm.transitions || []).map((t) => t.event)
  );
  for (const event of transitionEvents) {
    if (event && !declaredEvents.has(event)) {
      errors.push(`Transition uses undeclared event: ${event}`);
    }
  }
  return errors;
}
function validateBehaviorStates(behavior) {
  const errors = [];
  const sm = behavior.stateMachine;
  if (!sm) return errors;
  const declaredStates = new Set(
    (sm.states || []).map((s) => s.name)
  );
  for (const t of sm.transitions || []) {
    if (t.from && !declaredStates.has(t.from)) {
      errors.push(`Transition from undeclared state: ${t.from}`);
    }
    if (t.to && !declaredStates.has(t.to)) {
      errors.push(`Transition to undeclared state: ${t.to}`);
    }
  }
  return errors;
}

export { getBehaviorMetadata, validateBehaviorEvents, validateBehaviorStates, validateBehaviorStructure };
//# sourceMappingURL=types.js.map
//# sourceMappingURL=types.js.map