"use strict"; var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); var _typeof = require("@babel/runtime/helpers/typeof"); Object.defineProperty(exports, "__esModule", { value: true }); exports.default = void 0; var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck")); var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass")); var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn")); var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf")); var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits")); var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty")); var _classOrder = _interopRequireDefault(require("./class-order")); var _nodeInternal = _interopRequireDefault(require("./node-internal")); var _types = require("./types"); var Uri = _interopRequireWildcard(require("./uri")); function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); } function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; } function _callSuper(t, o, e) { return o = (0, _getPrototypeOf2.default)(o), (0, _possibleConstructorReturn2.default)(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], (0, _getPrototypeOf2.default)(t).constructor) : o.apply(t, e)); } function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); } /** * Variables are placeholders used in patterns to be matched. * In cwm they are symbols which are the formula's list of quantified variables. * In sparql they are not visibly URIs. Here we compromise, by having * a common special base URI for variables. Their names are uris, * but the ? notation has an implicit base uri of 'varid:' */ var Variable = exports.default = /*#__PURE__*/function (_Node) { /** * Initializes this variable * @param name The variable's name */ function Variable() { var _this; var name = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : ''; (0, _classCallCheck2.default)(this, Variable); _this = _callSuper(this, Variable, [name]); (0, _defineProperty2.default)(_this, "termType", _types.VariableTermType); /** The base string for a variable's name */ (0, _defineProperty2.default)(_this, "base", 'varid:'); (0, _defineProperty2.default)(_this, "classOrder", _classOrder.default.Variable); (0, _defineProperty2.default)(_this, "isVar", 1); /** The unique identifier of this variable */ (0, _defineProperty2.default)(_this, "uri", void 0); _this.base = 'varid:'; _this.uri = Uri.join(name, _this.base); return _this; } (0, _inherits2.default)(Variable, _Node); return (0, _createClass2.default)(Variable, [{ key: "equals", value: function equals(other) { if (!other) { return false; } return this.termType === other.termType && this.value === other.value; } }, { key: "hashString", value: function hashString() { return this.toString(); } }, { key: "substitute", value: function substitute(bindings) { var ref; return (ref = bindings[this.toNT()]) != null ? ref : this; } }, { key: "toString", value: function toString() { return Variable.toString(this); } }], [{ key: "toString", value: function toString(variable) { if (variable.uri.slice(0, variable.base.length) === variable.base) { return "?".concat(variable.uri.slice(variable.base.length)); } return "?".concat(variable.uri); } }]); }(_nodeInternal.default);