"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var t=require("tslib"),e=require("react/jsx-runtime"),r=require("react"),i={history:{},globalCitations:[]};function s(e,r){var s;switch(r.type){case"SAVE_CITATIONS":return t.__assign(t.__assign({},e),{globalCitations:r.rawCitations,history:t.__assign(t.__assign({},e.history),(s={},s[r.requestId]=r.reasoningMap,s))});case"RESET":return i;default:return e}}var n=r.createContext(void 0);exports.CitationProvider=function(a){var o=a.children,u=r.useReducer(s,i),c=u[0],l=u[1],h=r.useCallback(function(t){var e=Object.keys(c.history);if(0===e.length)return"";for(var r=e.length-1;r>=0;r--){var i=c.history[e[r]][t];if(i)return i}return""},[c.history]);return e.jsx(n.Provider,t.__assign({value:{state:c,dispatch:l,getLatestReasoning:h}},{children:o}))},exports.useCitations=function(){var t=r.useContext(n);if(!t)throw new Error("useCitations must be used within a CitationProvider");return t};
//# sourceMappingURL=CitationsContext.js.map
