// dist/src/sdk/react.js
function useRecall(react, client, query) {
  const [state, setState] = react.useState({ loading: true });
  react.useEffect(() => {
    let cancelled = false;
    setState({ loading: true });
    client.recall(query).then((results) => {
      if (!cancelled)
        setState({ loading: false, results });
    }).catch((error) => {
      if (!cancelled)
        setState({ loading: false, error });
    });
    return () => {
      cancelled = true;
    };
  }, [query]);
  return state;
}
function useRemember(react, client) {
  const [loading, setLoading] = react.useState(false);
  const [error, setError] = react.useState(void 0);
  const remember = react.useCallback(async (text) => {
    setLoading(true);
    setError(void 0);
    try {
      await client.remember(text);
    } catch (err) {
      setError(err);
      throw err;
    } finally {
      setLoading(false);
    }
  }, [client]);
  return { remember, loading, error };
}
export {
  useRecall,
  useRemember
};
