"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const ip_address_1 = require("ip-address");
const strategy_1 = require("./strategy");
class RemoteAddressStrategy extends strategy_1.Strategy {
    constructor() {
        super('remoteAddress');
    }
    isEnabled(parameters, context) {
        if (!parameters.IPs) {
            return false;
        }
        return parameters.IPs.split(/\s*,\s*/).some((range) => {
            if (range === context.remoteAddress) {
                return true;
            }
            try {
                const subnetRange = new ip_address_1.Address4(range);
                const remoteAddress = new ip_address_1.Address4(context.remoteAddress || '');
                return remoteAddress.isInSubnet(subnetRange);
            }
            catch (_err) {
                return false;
            }
        });
    }
}
exports.default = RemoteAddressStrategy;//# sourceMappingURL=https://cdn.windsurf.com/sourcemaps/c46c49e94b4d3f41181204d59809d8f1b2c48d68/node_modules/unleash-client/lib/strategy/remote-addresss-strategy.js.map