/**
 * HTTP transport that calls `agent.neotoma.io` (or a `netlify dev` stub).
 *
 * Auth: AGENT_SITE_BEARER on submit; access_token query on status.
 */
export class HttpFeedbackTransport {
    baseUrl;
    bearer;
    constructor(baseUrl, bearer) {
        this.baseUrl = baseUrl;
        this.bearer = bearer;
    }
    async submit(args, _submitterId) {
        const url = this.baseUrl.replace(/\/$/, "") + "/feedback/submit";
        const res = await fetch(url, {
            method: "POST",
            headers: {
                "content-type": "application/json",
                authorization: `Bearer ${this.bearer}`,
            },
            body: JSON.stringify(args),
        });
        if (!res.ok) {
            const text = await res.text().catch(() => "");
            throw new Error(`submit_feedback HTTP ${res.status}: ${text}`);
        }
        return (await res.json());
    }
    async status(accessToken) {
        const url = this.baseUrl.replace(/\/$/, "") +
            `/feedback/status?access_token=${encodeURIComponent(accessToken)}`;
        const res = await fetch(url, { method: "GET" });
        if (!res.ok) {
            const text = await res.text().catch(() => "");
            throw new Error(`get_feedback_status HTTP ${res.status}: ${text}`);
        }
        return (await res.json());
    }
}
//# sourceMappingURL=feedback_transport_http.js.map