"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Scraper = exports.ScraperError = exports.ScraperRequestError = exports.Curl = void 0;
const curl_1 = require("./curl");
var curl_2 = require("./curl");
Object.defineProperty(exports, "Curl", { enumerable: true, get: function () { return curl_2.Curl; } });
class ScraperRequestError extends Error {
    constructor({ status, headers, data }) {
        super();
        this.status = status;
        this.headers = headers;
        this.data = data;
    }
}
exports.ScraperRequestError = ScraperRequestError;
class ScraperError extends Error {
}
exports.ScraperError = ScraperError;
class Scraper {
    constructor(adapter, defaultOpts) {
        this.adapter = adapter;
        this.defaultOpts = defaultOpts;
    }
    get(url, opts) {
        var _a, _b;
        const headers = Object.assign(Object.assign({}, (((_a = this.defaultOpts) === null || _a === void 0 ? void 0 : _a.headers) ? (_b = this.defaultOpts) === null || _b === void 0 ? void 0 : _b.headers : {})), ((opts === null || opts === void 0 ? void 0 : opts.headers) ? opts === null || opts === void 0 ? void 0 : opts.headers : {}));
        return this.adapter.get(url, Object.assign(Object.assign({}, opts), { headers }));
    }
    getCurl(url, opts) {
        var _a, _b;
        const headers = Object.assign(Object.assign({}, (((_a = this.defaultOpts) === null || _a === void 0 ? void 0 : _a.headers) ? (_b = this.defaultOpts) === null || _b === void 0 ? void 0 : _b.headers : {})), ((opts === null || opts === void 0 ? void 0 : opts.headers) ? opts === null || opts === void 0 ? void 0 : opts.headers : {}));
        return this.adapter.getCurl(url, Object.assign(Object.assign({}, opts), { headers }));
    }
    fetch(url, opts) {
        var _a, _b;
        const headers = Object.assign(Object.assign({}, (((_a = this.defaultOpts) === null || _a === void 0 ? void 0 : _a.headers) ? (_b = this.defaultOpts) === null || _b === void 0 ? void 0 : _b.headers : {})), ((opts === null || opts === void 0 ? void 0 : opts.headers) ? opts === null || opts === void 0 ? void 0 : opts.headers : {}));
        return this.adapter.fetch(url, Object.assign(Object.assign({}, opts), { headers }));
    }
    post(url, data, opts) {
        var _a, _b;
        const headers = Object.assign(Object.assign({}, (((_a = this.defaultOpts) === null || _a === void 0 ? void 0 : _a.headers) ? (_b = this.defaultOpts) === null || _b === void 0 ? void 0 : _b.headers : {})), ((opts === null || opts === void 0 ? void 0 : opts.headers) ? opts === null || opts === void 0 ? void 0 : opts.headers : {}));
        return this.adapter.post(url, data, Object.assign(Object.assign({}, opts), { headers }));
    }
    useProxy(proxy) {
        this.proxy = proxy;
        this.adapter.proxy = proxy;
    }
    setDefaultOpts(opts) {
        this.defaultOpts = opts;
    }
    setCurlBrowser(browser) {
        if (!(this.adapter instanceof curl_1.Curl)) {
            throw new Error("Adapter isnt Curl");
        }
        else {
            this.adapter.setBrowser(browser);
        }
    }
    getBrowser() {
        if (!(this.adapter instanceof curl_1.Curl)) {
            throw new Error("Adapter isnt Curl");
        }
        else {
            return this.adapter.getBrowser();
        }
    }
}
exports.Scraper = Scraper;
//# sourceMappingURL=index.js.map