{"version":3,"file":"to.cjs","names":["toTransition","_any","toChildSrc","identify"],"sources":["../../../src/machine/functions/to.ts"],"sourcesContent":["import type { ChildConfig } from '../../actor.types';\nimport type { PrimitiveObject } from '#bemedev/globals/types';\nimport type {\n  ActorsConfigMap,\n  EventsMap,\n  ToEventObject,\n  ToEvents,\n} from '#events';\nimport { toTransition } from '#transitions';\nimport _any from '#bemedev/features/common/castings/any';\nimport type { SimpleMachineOptions } from '#machines';\nimport type { Child } from '../types';\nimport { toChildSrc } from './src';\nimport { identify } from '#bemedev/features/functions/functions/identify';\n\nexport type ToChild_F = <\n  E extends EventsMap = EventsMap,\n  A extends ActorsConfigMap = ActorsConfigMap,\n  Pc = any,\n  Tc extends PrimitiveObject = PrimitiveObject,\n  T extends string = string,\n  R extends { eventsMap: any } = { eventsMap: any },\n  Eo extends ToEventObject<ToEvents<E, A>> = ToEventObject<ToEvents<E, A>>,\n>(\n  events: E,\n  actorsMap: A,\n  child: ChildConfig & { __id: string },\n  options?: SimpleMachineOptions<E, A, Pc, Tc, T, Eo>,\n) => Child<Eo, Pc, Tc, T, R>;\n\n/**\n * Converts an emitter config to an emitter object with a source and transitions.\n * @param events of type {@linkcode EventsMap}, the events map.\n * @param actorsMap of type {@linkcode ActorsConfigMap}, the actors map.\n * @param src of type {@linkcode EmitterSrcConfig}, the emitter configuration to convert.\n * @param emitters of type {@linkcode SimpleMachineOptions}, the machine options.\n * @returns an emitter object with a source and transitions.\n *\n * @see {@linkcode toChildSrc} for converting the source.\n * @see {@linkcode toTransition} for converting transitions.\n * @see {@linkcode toArray} for the type of the context.\n * @see {@linkcode ToChild_F} for more details\n */\nexport const toChild: ToChild_F = (events, actorsMap, child, options) => {\n  const tMapper = (config: any) => {\n    return toTransition(events, actorsMap, config, options);\n  };\n\n  const src = toChildSrc(\n    events,\n    actorsMap,\n    child.__id,\n    options?.actors?.children,\n  );\n\n  const on = identify(child.on).map(tMapper);\n  const contexts = Object.keys(child.contexts || {});\n  const out = _any({ src, on, contexts }) as any;\n\n  const { description } = child;\n  if (description) out.description = description;\n\n  return out;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AA2CA,MAAa,WAAsB,QAAQ,WAAW,OAAO,YAAY;CACvE,MAAM,WAAW,WAAgB;AAC/B,SAAOA,2CAAAA,aAAa,QAAQ,WAAW,QAAQ,QAAQ;;CAYzD,MAAM,MAAMC,kDAAK;EAAE,KATPC,8BAAAA,WACV,QACA,WACA,MAAM,MACN,SAAS,QAAQ,SAClB;EAIuB,IAFbC,2DAAAA,SAAS,MAAM,GAAG,CAAC,IAAI,QAAQ;EAEd,UADX,OAAO,KAAK,MAAM,YAAY,EAAE,CAAC;EACZ,CAAC;CAEvC,MAAM,EAAE,gBAAgB;AACxB,KAAI,YAAa,KAAI,cAAc;AAEnC,QAAO"}