import { HttpRequestBuilder } from "./http-builder.js";
class Http {
  brand = "http";
}
const HTTP_INSTANCE = new Http();
export function registerHttpBuiltins(registry) {
  registry.registerType("http", Http);
  registry.registerType("HttpRequest", HttpRequestBuilder);
  registry.registerVariable({
    name: "http",
    type: "http",
    value: HTTP_INSTANCE,
    description: "HTTP \u5BA2\u6237\u7AEF"
  });
  registry.registerFunctionOverload(
    "http.get(string): HttpRequest",
    (_r, url) => new HttpRequestBuilder(url, "GET")
  );
  registry.registerFunctionOverload(
    "http.post(string): HttpRequest",
    (_r, url) => new HttpRequestBuilder(url, "POST")
  );
  registry.registerFunctionOverload(
    "http.put(string): HttpRequest",
    (_r, url) => new HttpRequestBuilder(url, "PUT")
  );
  registry.registerFunctionOverload(
    "http.patch(string): HttpRequest",
    (_r, url) => new HttpRequestBuilder(url, "PATCH")
  );
  registry.registerFunctionOverload(
    "http.delete(string): HttpRequest",
    (_r, url) => new HttpRequestBuilder(url, "DELETE")
  );
  registry.registerFunctionOverload(
    "HttpRequest.header(string, string): HttpRequest",
    (b, k, v) => b.header(k, v)
  );
  registry.registerFunctionOverload(
    "HttpRequest.query(string, string): HttpRequest",
    (b, k, v) => b.query(k, v)
  );
  registry.registerFunctionOverload(
    "HttpRequest.query(string, number): HttpRequest",
    (b, k, v) => b.query(k, Number(v))
  );
  registry.registerFunctionOverload(
    "HttpRequest.query(dyn): HttpRequest",
    (b, record) => b.query(record)
  );
  registry.registerFunctionOverload(
    "HttpRequest.body(dyn): HttpRequest",
    (b, data) => b.body(data)
  );
}
