{"version":3,"file":"limit-actions.cjs","names":["isActionsGroup"],"sources":["../src/limit-actions.ts"],"sourcesContent":["import { isActionsGroup } from './is-actions-group';\nimport type { SpotlightActionData, SpotlightActions } from './Spotlight';\n\nexport function limitActions(actions: SpotlightActions[], limit: number) {\n  if (!Array.isArray(actions)) {\n    return [];\n  }\n\n  let count = 0;\n  return actions.reduce<SpotlightActions[]>((acc, item) => {\n    if (count >= limit) {\n      return acc;\n    }\n\n    if (isActionsGroup(item)) {\n      const groupActions = limitActions(item.actions, limit - count);\n      acc.push({\n        group: item.group,\n        actions: groupActions as SpotlightActionData[],\n      });\n      count += groupActions.length;\n    } else {\n      acc.push(item);\n      count += 1;\n    }\n\n    return acc;\n  }, []);\n}\n"],"mappings":";;;AAGA,SAAgB,aAAa,SAA6B,OAAe;CACvE,IAAI,CAAC,MAAM,QAAQ,OAAO,GACxB,OAAO,CAAC;CAGV,IAAI,QAAQ;CACZ,OAAO,QAAQ,QAA4B,KAAK,SAAS;EACvD,IAAI,SAAS,OACX,OAAO;EAGT,IAAIA,yBAAAA,eAAe,IAAI,GAAG;GACxB,MAAM,eAAe,aAAa,KAAK,SAAS,QAAQ,KAAK;GAC7D,IAAI,KAAK;IACP,OAAO,KAAK;IACZ,SAAS;GACX,CAAC;GACD,SAAS,aAAa;EACxB,OAAO;GACL,IAAI,KAAK,IAAI;GACb,SAAS;EACX;EAEA,OAAO;CACT,GAAG,CAAC,CAAC;AACP"}