import { Headers } from '@api-client/core/lib/headers/Headers.js';
/**
 * An array that specializes in keeping HTTP headers data.
 */
export class HeadersArray extends Array {
    static fromHeaders(headersStr) {
        const headers = new Headers(headersStr);
        const array = new HeadersArray();
        for (const [name, value] of headers) {
            array.push({
                enabled: true,
                name,
                value,
            });
        }
        return array;
    }
    /**
     * Overrides native toString to generate the headers string.
     * @returns HTTP headers string.
     */
    toString() {
        const headers = new Headers();
        this.forEach((header) => {
            if (header.enabled && (header.name || header.value)) {
                headers.append(header.name, header.value);
            }
        });
        return headers.toString();
    }
}
//# sourceMappingURL=HeadersArray.js.map