import { v as validateAuth } from './auth-DuunT7Cg.js';
import { s as shareStore } from './share-store-B9jMpVg0.js';

function bearerToken(request) {
  const auth = request.headers.get("Authorization") || request.headers.get("authorization");
  if (!auth?.startsWith("Bearer ")) {
    return null;
  }
  return auth.slice(7).trim();
}
function resolveAccess(request, terminalId) {
  if (validateAuth(request) === null) {
    return { level: "owner", mode: null };
  }
  const token = bearerToken(request);
  if (!token) {
    return null;
  }
  const session = shareStore.resolveToken(token);
  if (session?.terminalId !== terminalId) {
    return null;
  }
  return { level: "guest", mode: session.mode };
}

export { resolveAccess as r };
//# sourceMappingURL=share-auth-BS7JuiHf.js.map
