var { useState, useEffect, useCallback, useRef, useMemo } = React;

var API = '';

async function api(path, opts = {}) {
  var token = localStorage.getItem('vibey_token');
  var headers = { 'Content-Type': 'application/json', ...(opts.headers || {}) };
  if (token) headers['Authorization'] = `Bearer ${token}`;
  var res = await fetch(`${API}${path}`, { ...opts, headers });
  var data = await res.json().catch(() => ({}));
  if (!res.ok) throw new Error(data.error || `HTTP ${res.status}`);
  return data;
}
