{"version":3,"file":"common.cjs","names":[],"sources":["../src/common/call-function.ts","../src/common/resolve-fn-value.ts"],"sourcesContent":["import type { MaybeFn } from 'yummies/types';\n\n/**\n * Normalizes a {@link MaybeFn} — a value that may be either a plain `TValue` or a function\n * `(...args: TArgs) => TValue`. If `fn` is callable, it is invoked with `args` and the return\n * value is returned; otherwise `fn` is returned as-is (treated as the resolved value).\n *\n * Typical uses: config fields that accept a static value or a lazy/computed factory, theme\n * tokens, labels, or callbacks where the caller should not branch on `typeof fn` themselves.\n *\n * @template TValue - Result type when `fn` is not a function, or return type when it is.\n * @template TArgs - Tuple of argument types passed through when `fn` is invoked.\n *\n * @param fn - Either a `TValue` or a function producing `TValue` from `args`.\n * @param args - Arguments forwarded to `fn` only when `fn` is a function.\n * @returns The resolved `TValue`.\n *\n * @example\n * Plain value — returned unchanged (no call):\n * ```ts\n * const n = callFunction(42); // 42\n * const label = callFunction('Hello'); // 'Hello'\n * ```\n *\n * @example\n * Function — called with the given arguments:\n * ```ts\n * const sum = callFunction((a: number, b: number) => a + b, 2, 3); // 5\n * ```\n *\n * @example\n * Same API for “static or factory” props:\n * ```ts\n * type Title = MaybeFn<string, [locale: string]>;\n * const title: Title = (loc) => (loc === 'ru' ? 'Привет' : 'Hi');\n * const text = callFunction(title, 'ru'); // 'Привет'\n * const fixed = callFunction('Hi', 'ru'); // 'Hi' — args ignored\n * ```\n */\nexport const callFunction = <TValue, TArgs extends any[] = []>(\n  fn: MaybeFn<TValue, TArgs>,\n  ...args: TArgs\n) => {\n  if (typeof fn === 'function') {\n    return (fn as any)(...args) as TValue;\n  }\n\n  return fn;\n};\n","import { callFunction } from './call-function.js';\n\n/**\n * @deprecated use {callFunction}\n */\nexport const resolveFnValue = callFunction;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAuCA,IAAa,gBACX,IACA,GAAG,SACA;CACH,IAAI,OAAO,OAAO,YAChB,OAAQ,GAAW,GAAG,IAAI;CAG5B,OAAO;AACT;;;;;;AC3CA,IAAa,iBAAiB"}