"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
    if (k2 === undefined) k2 = k;
    Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
}) : (function(o, m, k, k2) {
    if (k2 === undefined) k2 = k;
    o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
    Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
    o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
    if (mod && mod.__esModule) return mod;
    var result = {};
    if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
    __setModuleDefault(result, mod);
    return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.isLocation = exports.Location = void 0;
const Position = __importStar(require("./Position"));
const String = __importStar(require("./ion/String"));
const Class = __importStar(require("./ion/Class"));
class Location {
    constructor({ start, end, filename }) {
        if (!Position.isPosition(start))
            throw new Error('start is not a Position: ' + Class.toString(start));
        if (!Position.isPosition(end))
            throw new Error('end is not a Position: ' + Class.toString(end));
        if (!String.isString(filename))
            throw new Error('filename is not a String: ' + Class.toString(filename));
        this.start = start;
        this.end = end;
        this.filename = filename;
        Object.freeze(this);
    }
    patch(properties) {
        return new Location({
            ...this,
            ...properties
        });
    }
    static is(value) {
        return isLocation(value);
    }
}
exports.Location = Location;
Location.id = 'Location';
Location.implements = new Set([
    'Location',
    'ion_Object'
]);
function isLocation(value) {
    return Class.isInstance(Location, value);
}
exports.isLocation = isLocation;
exports.default = Location;
