{"version":3,"file":"accordion-context.mjs","names":[],"sources":["../../../src/accordion/accordion-context.tsx"],"sourcesContent":["/*!\n *\n *  Copyright (c) \"Neo4j\"\n *  Neo4j Sweden AB [http://neo4j.com]\n *\n *  This file is part of Neo4j.\n *\n *  Neo4j is free software: you can redistribute it and/or modify\n *  it under the terms of the GNU General Public License as published by\n *  the Free Software Foundation, either version 3 of the License, or\n *  (at your option) any later version.\n *\n *  This program is distributed in the hope that it will be useful,\n *  but WITHOUT ANY WARRANTY; without even the implied warranty of\n *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n *  GNU General Public License for more details.\n *\n *  You should have received a copy of the GNU General Public License\n *  along with this program.  If not, see <http://www.gnu.org/licenses/>.\n */\nimport { createContext, useContext } from 'react';\n\nimport {\n  type AccordionIsMultiple,\n  type AccordionIsNotMultiple,\n  type AccordionItemId,\n} from './accordion-types';\n\ntype AccordionContextType<T extends AccordionItemId> =\n  | Required<\n      Pick<\n        AccordionIsMultiple<T>,\n        'onChange' | 'expandedItemIds' | 'isMultiple'\n      >\n    >\n  | Required<\n      Pick<\n        AccordionIsNotMultiple<T>,\n        'onChange' | 'expandedItemId' | 'isMultiple'\n      >\n    >;\n\n// oxlint-disable-next-line @typescript-eslint/no-explicit-any\nexport const AccordionContext = createContext<AccordionContextType<any> | null>(\n  null,\n);\n\nexport const useAccordionContext = () => {\n  const context = useContext(AccordionContext);\n  if (context === null) {\n    throw new Error('Accordion used without context');\n  }\n  return context;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AA2CA,MAAa,mBAAmB,cAC9B,IACF;AAEA,MAAa,4BAA4B;CACvC,MAAM,UAAU,WAAW,gBAAgB;CAC3C,IAAI,YAAY,MACd,MAAM,IAAI,MAAM,gCAAgC;CAElD,OAAO;AACT"}