{"version":3,"file":"errors.cjs","names":[],"sources":["../../src/constants/errors.ts"],"sourcesContent":["import type { UnionToIntersection } from '#bemedev/globals/types';\nimport type { STR } from './types';\n\nconst action = {\n  normal: 'action',\n  capital: 'Action',\n} as const satisfies STR;\n\nconst guard = {\n  normal: 'guard',\n  capital: 'Guard',\n} as const satisfies STR;\n\nconst delay = {\n  normal: 'delay',\n  capital: 'Delay',\n} as const satisfies STR;\n\nconst promise = {\n  normal: 'promise',\n  capital: 'Promise',\n} as const satisfies STR;\n\nconst machine = {\n  normal: 'machine',\n  capital: 'Machine',\n} as const satisfies STR;\n\nconst notDefined = 'is undefined' as const;\nconst notDescribed = 'is not described' as const;\nconst notProvided = 'is not provided' as const;\n\nconst notDefinedF = <T extends string>(type: T) => {\n  const string = `${type} ${notDefined}` as const;\n  return { string, error: new Error(string) };\n};\n\nconst notDescribedF = <T extends string>(type: T) => {\n  const string = `${type} ${notDescribed}` as const;\n  return { string, error: new Error(string) };\n};\n\nconst notProvidedF = <T extends string>(type: T) => {\n  const string = `${type} ${notProvided}` as const;\n  return { string, error: new Error(string) };\n};\n\nconst produceErrors = <const T extends STR[]>(...types: T) => {\n  const out = {};\n\n  types.forEach(value => {\n    Object.assign(out, {\n      [value.normal]: {\n        notDefined: notDefinedF(value['capital']),\n        notDescribed: notDescribedF(value['capital']),\n        notProvided: notProvidedF(value['capital']),\n      },\n    });\n  });\n\n  type Out = T[number] extends infer N extends STR\n    ? N extends any\n      ? {\n          [key in N['normal']]: {\n            notDefined: ReturnType<typeof notDefinedF<N['capital']>>;\n            notDescribed: ReturnType<typeof notDescribedF<N['capital']>>;\n            notProvided: ReturnType<typeof notProvidedF<N['capital']>>;\n          };\n        }\n      : never\n    : never;\n\n  return out as UnionToIntersection<Out>;\n};\n\n/**\n * Contains error messages for various machine components.\n * Each component (action, guard, delay, promise, machine) has three types of errors:\n * - `notDefined`: Indicates that the component is not defined.\n * - `notDescribed`: Indicates that the component is not described.\n * - `notProvided`: Indicates that the component is not provided.\n */\nexport const ERRORS = produceErrors(\n  action,\n  guard,\n  delay,\n  promise,\n  machine,\n);\n"],"mappings":";;AAGA,MAAM,SAAS;CACb,QAAQ;CACR,SAAS;CACV;AAED,MAAM,QAAQ;CACZ,QAAQ;CACR,SAAS;CACV;AAED,MAAM,QAAQ;CACZ,QAAQ;CACR,SAAS;CACV;AAED,MAAM,UAAU;CACd,QAAQ;CACR,SAAS;CACV;AAED,MAAM,UAAU;CACd,QAAQ;CACR,SAAS;CACV;AAED,MAAM,aAAa;AACnB,MAAM,eAAe;AACrB,MAAM,cAAc;AAEpB,MAAM,eAAiC,SAAY;CACjD,MAAM,SAAS,GAAG,KAAK,GAAG;AAC1B,QAAO;EAAE;EAAQ,OAAO,IAAI,MAAM,OAAO;EAAE;;AAG7C,MAAM,iBAAmC,SAAY;CACnD,MAAM,SAAS,GAAG,KAAK,GAAG;AAC1B,QAAO;EAAE;EAAQ,OAAO,IAAI,MAAM,OAAO;EAAE;;AAG7C,MAAM,gBAAkC,SAAY;CAClD,MAAM,SAAS,GAAG,KAAK,GAAG;AAC1B,QAAO;EAAE;EAAQ,OAAO,IAAI,MAAM,OAAO;EAAE;;AAG7C,MAAM,iBAAwC,GAAG,UAAa;CAC5D,MAAM,MAAM,EAAE;AAEd,OAAM,SAAQ,UAAS;AACrB,SAAO,OAAO,KAAK,GAChB,MAAM,SAAS;GACd,YAAY,YAAY,MAAM,WAAW;GACzC,cAAc,cAAc,MAAM,WAAW;GAC7C,aAAa,aAAa,MAAM,WAAW;GAC5C,EACF,CAAC;GACF;AAcF,QAAO;;;;;;;;;AAUT,MAAa,SAAS,cACpB,QACA,OACA,OACA,SACA,QACD"}