-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathterminusdb-client.min.js
executable file
·148 lines (148 loc) · 262 KB
/
terminusdb-client.min.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.TerminusClient=e():t.TerminusClient=e()}(window,(function(){return function(t){var e={};function r(i){if(e[i])return e[i].exports;var n=e[i]={i:i,l:!1,exports:{}};return t[i].call(n.exports,n,n.exports,r),n.l=!0,n.exports}return r.m=t,r.c=e,r.d=function(t,e,i){r.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:i})},r.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},r.t=function(t,e){if(1&e&&(t=r(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var i=Object.create(null);if(r.r(i),Object.defineProperty(i,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var n in t)r.d(i,n,function(e){return t[e]}.bind(null,n));return i},r.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return r.d(e,"a",e),e},r.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},r.p="",r(r.s=31)}([function(t,e){function r(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){if("undefined"==typeof Symbol||!(Symbol.iterator in Object(t)))return;var r=[],i=!0,n=!1,o=void 0;try{for(var s,a=t[Symbol.iterator]();!(i=(s=a.next()).done)&&(r.push(s.value),!e||r.length!==e);i=!0);}catch(t){n=!0,o=t}finally{try{i||null==a.return||a.return()}finally{if(n)throw o}}return r}(t,e)||function(t,e){if(!t)return;if("string"==typeof t)return i(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);"Object"===r&&t.constructor&&(r=t.constructor.name);if("Map"===r||"Set"===r)return Array.from(t);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return i(t,e)}(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function i(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,i=new Array(e);r<e;r++)i[r]=t[r];return i}function n(t){return(n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}
/**
* @file Terminus Client Utility Functions
* @license Apache Version 2
* Object for bunding up common Terminus Utility Functions
*/var o={standard_urls:{rdf:"http://www.w3.org/1999/02/22-rdf-syntax-ns#",rdfs:"http://www.w3.org/2000/01/rdf-schema#",xsd:"http://www.w3.org/2001/XMLSchema#",xdd:"http://terminusdb.com/schema/xdd#",owl:"http://www.w3.org/2002/07/owl#",system:"http://terminusdb.com/schema/system#",vio:"http://terminusdb.com/schema/vio#",repo:"http://terminusdb.com/schema/repository#",layer:"http://terminusdb.com/schema/layer#",woql:"http://terminusdb.com/schema/woql#",ref:"http://terminusdb.com/schema/ref#",api:"http://terminusdb.com/schema/api#"},URIEncodePayload:function(t){if("string"==typeof t)return encodeURIComponent(t);for(var e=[],r=0,i=Object.keys(t);r<i.length;r++){var o=i[r];if("object"===n(t[o]))for(var s=0,a=Object.keys(t[o]);s<a.length;s++){var u=a[s],h=t[o][u];e.push("".concat(encodeURIComponent(u),"=").concat(encodeURIComponent(h)))}else e.push("".concat(encodeURIComponent(o),"=").concat(encodeURIComponent(t[o])))}return e.join("&")},addURLPrefix:function(t,e){this.standard_urls[t]=e},empty:function(t){if(!t)return!0;if(t.length>0)return!1;if(0===t.length)return!0;if("object"===n(t))for(var e=0,r=Object.keys(t);e<r.length;e++){var i=r[e];if(Object.prototype.hasOwnProperty.call(t,i))return!1}return!0},genBNID:function(){var t=Math.random().toString(36).substring(7),e=new Date;return"_:".concat(t).concat(e.getTime())},getShorthand:function(t){if("object"===n(t)&&t.length&&(t=t[0]),t&&"string"==typeof t)for(var e=0,r=Object.keys(this.standard_urls);e<r.length;e++){var i=r[e],o=this.standard_urls[i];if(t.substring(0,o.length)===o)return"".concat(i,":").concat(t.substring(o.length))}return!1},compareIDs:function(t,e){if(t===e)return!0;if(this.unshorten(t)===e)return!0;if(this.unshorten(t)===this.unshorten(e))return!0;var r=this.getShorthand(t),i=this.getShorthand(e);return!(!r||r!==e&&r!==i)||!(!i||i!==t)},shorten:function(t,e){for(var r in e=e||o.standard_urls)if(e[r]==t.substring(0,e[r].length))return"".concat(r,":").concat(t.substring(e[r].length));return t},unshorten:function(t){if(this.validURL(t))return t;if(!t)return t;var e=t.split(":");return e[1]&&this.standard_urls[e[0]]?this.standard_urls[e[0]]+e[1]:t},validURL:function(t){return!(!t||"http://"!==t.substring(0,7)&&"https://"!==t.substring(0,8))},labelFromURL:function(t){var e=this.urlFragment(t);return(e=e||t).lastIndexOf("/")<e.length-1&&(e=e.substring(e.lastIndexOf("/")+1)),(e=e.replace(/_/g," ")).charAt(0).toUpperCase()+e.slice(1)},labelFromVariable:function(t){return(t=t.replace(/_/g," ")).charAt(0).toUpperCase()+t.slice(1)},urlFragment:function(t){var e=(t="string"!=typeof t?window.location.href:t).split("#");if(e.length<=1&&(this.validURL(t)||(e=t.split(":"))),e.length>=1){var i=r(e,2)[1];if(i)t=r(i.split("?"),1)[0]}return t},lastURLBit:function(t){var e=r((t=void 0===t?window.location.href:t).split("#"),1);return t=r(e[0].split("?"),1)[0].substring(t.lastIndexOf("/")+1)},getStdURL:function(t,e,r){if(this.standard_urls[t]){if(!r)return this.standard_urls[t]+e;if(r===this.standard_urls[t]+e)return r}return!1},addNamespacesToVariables:function(t){for(var e=[],r=0;r<t.length;r++)t[r]&&e.push(this.addNamespaceToVariable(t[r]));return e},addNamespaceToVariable:function(t){return"string"==typeof t&&"v:"!=t.substring(0,2)?"v:"+t:t},removeNamespaceFromVariable:function(t){return"v:"==t.substring(0,2)?t.substring(2):t},removeNamespacesFromVariables:function(t){for(var e=[],r=0;r<t.length;r++)e.push(this.removeNamespaceFromVariable(t[r]));return e},getConfigValue:function(t,e){if("string"==typeof t&&"v:"==t.substring(0,2)){var r=e[t];return r&&r["@value"]?r["@value"]:r}return t},TypeHelper:{}};o.TypeHelper.isStringType=function(t){return"http://www.w3.org/2001/XMLSchema#string"===t||"xsd:string"===t},o.TypeHelper.isDatatype=function(t){var e=o.shorten(t);return!!(e&&"xsd:"==e.substring(0,4)||"xdd:"==e.substring(0,4))},o.TypeHelper.numberWithCommas=function(t,e){if(e=e||",",t>=1e3||t<=-1e3){var r=t.toString().split(".");t<=-1e3&&(r[0]=r[0].substring(1)),r[0]=r[0].replace(/\B(?=(\d{3})+(?!\d))/g,e),t=t<=-1e3?"-".concat(r.join(".")):r.join(".")}return t},o.TypeHelper.datatypes=["xdd:coordinate","xdd:coordinatePolyline","xdd:coordinatePolygon","xdd:dateRange","xdd:gYearRange","xdd:integerRange","xdd:decimalRange","xdd:cc","xdd:email","xdd:html","xdd:url","xsd:anySimpleType","xsd:string","xsd:boolean","xsd:decimal","xsd:double","xsd:float","xsd:time","xsd:date","xsd:dateTime","xsd:dateTimeStamp","xsd:gYear","xsd:gMonth","xsd:gDay","xsd:gYearMonth","xsd:gMonthDay","xsd:duration","xsd:yearMonthDuration","xsd:dayTimeDuration","xsd:byte","xsd:short","xsd:integer","xsd:long","xsd:unsignedByte","xsd:unsignedInt","xsd:unsignedLong","xsd:nonNegativeInteger","xsd:positiveInteger","xsd:negativeInteger","xsd:nonPositiveInteger","xsd:base64Binary","xsd:anyURI","xsd:language","xsd:normalizedString","xsd:token","xsd:NMTOKEN","xsd:Name","xsd:NCName","xsd:NOTATION","xsd:QName","xsd:ID","xsd:IDREF","xsd:ENTITY","rdf:XMLLiteral","rdf:PlainLiteral","rdfs:Literal","xdd:json"],o.TypeHelper.parseRangeValue=function(t,e){e=e||",";var r=[];return"object"===n(t)&&t.length?r=t:t&&("string"!=typeof t&&(t="".concat(t)),t.length&&"["===t.charAt(0)&&"]"===t.charAt(t.length-1)?(r.push(t.substring(1,t.indexOf(e))),r.push(t.substring(t.indexOf(e)+1,t.length-1))):r.push(t)),r},o.DateHelper={},o.DateHelper.parseXsdTime=function(t){if(!t)return{};var e=this.extractXsdTimezone(t);return e&&(t=t.substring(0,t.length-e.length)),{hour:t.substring(0,2),minute:t.substring(3,5),second:t.substring(6),timezone:e}},o.DateHelper.parseXsdDate=function(t){var e,r,i=this.extractXsdTimezone(t);if(i&&(t=t.substring(0,t.length-i.length)),(e="-"===t.substring(0,1)?t.substring(0,5):t.substring(0,4))&&Math.abs(e)<1e4){var n=t.substring(e.length+1,e.length+3);if(!n)return!1;n=parseInt(n,10);var o=t.substring(e.length+4);if(!o)return!1;r={year:e,month:n,day:o=parseInt(o,10),timezone:i}}return r},o.DateHelper.parseDate=function(t,e){var r;if("xsd:date"===t)r=this.parseXsdDate(e);else if("xsd:time"===t)r=this.parseXsdTime(e);else if("xsd:dateTime"===t)r=this.parseXsdDateTime(e);else if("xsd:gYear"===t)r={year:e};else if("xsd:gYearRange"===t)r={year:e};else if("xsd:gMonth"===t)r={month:e.substring(2)};else if("xsd:gDay"===t)r={day:e};else if("xsd:gYearMonth"===t){for(var i=e.split("-");i.length<2;)i.push("");r={year:i[0],month:i[1]}}else if("xsd:gMonthDay"===t){for(var n=e.split("-");n.length<2;)n.push("");r={month:n[0],day:n[1]}}else"xsd:dateTimeStamp"===t&&(r=this.parseXsdDateTime(e));return r},o.DateHelper.addXsdPadding=function(t){var e={};return void 0!==t.year&&!1!==t.year&&t.year<1e3?Math.abs(t.year)<10?e.year=t.year<0?"-000".concat(Math.abs(t.year)):"000".concat(t.year):Math.abs(t.year)<100?e.year=t.year<0?"-00".concat(Math.abs(t.year)):"00".concat(t.year):e.year=t.year<0?"-0".concat(Math.abs(t.year)):"0".concat(t.year):t.year&&(e.year=t.year),void 0!==t.month&&!1!==t.month&&t.month<10?e.month="0".concat(t.month):t.month&&(e.month=t.month),void 0!==t.day&&!1!==t.day&&t.day<10?e.day="0".concat(t.day):t.day&&(e.day=t.day),void 0!==t.hour&&!1!==t.hour&&t.hour<10?e.hour="0".concat(t.hour):t.hour&&(e.hour=t.hour),void 0!==t.minute&&!1!==t.minute&&t.minute<10?e.minute="0".concat(t.minute):t.minute&&(e.minute=t.minute),void 0!==t.second&&!1!==t.second&&t.second<10?e.second="0".concat(t.second):t.second&&(e.second=t.second),e},o.DateHelper.xsdFromParsed=function(t,e){var r,i=this.addXsdPadding(t);if("xsd:gYear"===e)r=!!i.year&&i.year;else{if("xsd:time"===e)return!!(i.hour&&i.minute&&i.second)&&"".concat(i.hour,":").concat(i.minute,":").concat(i.second);if("xsd:date"===e)return!!(i.year&&i.month&&i.day)&&"".concat(i.year,"-").concat(i.month,"-").concat(i.day);"xsd:dateTime"===e||"xsd:dateTimeStamp"===e?(r=!!(i.year&&i.month&&i.day)&&"".concat(i.year,"-").concat(i.month,"-").concat(i.day,"T"))&&(r+="".concat(i.hour?i.hour:"12",":").concat(i.minute?i.minute:"00",":").concat(i.second?i.second:"00")):"xsd:gMonth"===e?r=!!i.month&&"--".concat(i.month):"xsd:gDay"===e?r=!!i.day&&"---".concat(i.day):"xsd:gYearMonth"===e?r=!(!i.year||!i.month)&&"".concat(i.year,"-").concat(i.month):"xsd:gMonthDay"===e&&(r=!(!i.day||!i.month)&&"--".concat(i.month,"-").concat(i.day))}return i.timezone&&(r+=i.timezone),r},o.DateHelper.convertTimestampToXsd=function(t){var e=new Date(1e3*t);return{year:e.getFullYear(),month:e.getMonth()+1,day:e.getDate(),hour:e.getHours(),minute:e.getMinutes(),second:e.getSeconds()}},o.DateHelper.parseXsdDateTime=function(t){if(!t)return{};if("number"==typeof t)return this.convertTimestampToXsd(t);var e=this.extractXsdTimezone(t);e&&(t=t.substring(0,t.length-e.length));for(var r=this.parseXsdDate(t),i=this.parseXsdTime(t.substring(t.indexOf("T")+1)),n=0,o=Object.keys(i);n<o.length;n++){var s=o[n];r[s]=i[s]}return r.timezone=e,r},o.DateHelper.extractXsdTimezone=function(t){return t&&"Z"===t.charAt(t.length-1)?"Z":(!t||"+"!==t.charAt(t.length-6)&&"-"!==t.charAt(t.length-6)||t.substring(t.length-6),!1)},t.exports=o},function(t,e,r){"use strict";var i=r(10),n=Object.prototype.toString;function o(t){return"[object Array]"===n.call(t)}function s(t){return void 0===t}function a(t){return null!==t&&"object"==typeof t}function u(t){return"[object Function]"===n.call(t)}function h(t,e){if(null!=t)if("object"!=typeof t&&(t=[t]),o(t))for(var r=0,i=t.length;r<i;r++)e.call(null,t[r],r,t);else for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&e.call(null,t[n],n,t)}t.exports={isArray:o,isArrayBuffer:function(t){return"[object ArrayBuffer]"===n.call(t)},isBuffer:function(t){return null!==t&&!s(t)&&null!==t.constructor&&!s(t.constructor)&&"function"==typeof t.constructor.isBuffer&&t.constructor.isBuffer(t)},isFormData:function(t){return"undefined"!=typeof FormData&&t instanceof FormData},isArrayBufferView:function(t){return"undefined"!=typeof ArrayBuffer&&ArrayBuffer.isView?ArrayBuffer.isView(t):t&&t.buffer&&t.buffer instanceof ArrayBuffer},isString:function(t){return"string"==typeof t},isNumber:function(t){return"number"==typeof t},isObject:a,isUndefined:s,isDate:function(t){return"[object Date]"===n.call(t)},isFile:function(t){return"[object File]"===n.call(t)},isBlob:function(t){return"[object Blob]"===n.call(t)},isFunction:u,isStream:function(t){return a(t)&&u(t.pipe)},isURLSearchParams:function(t){return"undefined"!=typeof URLSearchParams&&t instanceof URLSearchParams},isStandardBrowserEnv:function(){return("undefined"==typeof navigator||"ReactNative"!==navigator.product&&"NativeScript"!==navigator.product&&"NS"!==navigator.product)&&("undefined"!=typeof window&&"undefined"!=typeof document)},forEach:h,merge:function t(){var e={};function r(r,i){"object"==typeof e[i]&&"object"==typeof r?e[i]=t(e[i],r):e[i]=r}for(var i=0,n=arguments.length;i<n;i++)h(arguments[i],r);return e},deepMerge:function t(){var e={};function r(r,i){"object"==typeof e[i]&&"object"==typeof r?e[i]=t(e[i],r):e[i]="object"==typeof r?t({},r):r}for(var i=0,n=arguments.length;i<n;i++)h(arguments[i],r);return e},extend:function(t,e,r){return h(e,(function(e,n){t[n]=r&&"function"==typeof e?i(e,r):e})),t},trim:function(t){return t.replace(/^\s*/,"").replace(/\s*$/,"")}}},function(t,e,r){function i(t){return(i="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}var n=r(0),o=r(18);function s(t){return this.query=t||{},this.errors=[],this.cursor=this.query,this.chain_ended=!1,this.contains_update=!1,this.paging_transitive_properties=["select","from","start","when","opt","limit"],this.update_operators=["woql:AddTriple","woql:DeleteTriple","woql:AddQuad","woql:DeleteQuad","woql:DeleteObject","woql:UpdateObject"],this.vocab=this.loadDefaultVocabulary(),this.tripleBuilder=!1,this}function a(t){for(var e=u(t),r=[];2==e.length;)r.push(e[0]),e=u(e[1]);return r.push(e[0]),r}function u(t){var e=1;if("("==(t=t.trim()).charAt(0)){for(var r=1;r<t.length;r++)if("("==t.charAt(r)?e++:")"==t.charAt(r)&&e--,0==e){var i=t.substring(r+1).trim();return i?[t.substring(1,r),i]:u(t.substring(1,r))}return[]}if("+"==t[0]||","==t[0]||"|"==t[0]){var n=[t[0]];return t.substring(1)&&n.push(t.substring(1)),n}if("{"==t.charAt(0)){var o=[t.substring(0,t.indexOf("}")+1)];return t.substring(t.indexOf("}")+1)&&o.push(t.substring(t.indexOf("}")+1)),o}for(r=1;r<t.length;r++)if(","==t[r]||"|"==t[r]||"+"==t[r]||"{"==t[r])return[t.substring(0,r),t.substring(r)];return[t]}function h(t,e){if(Array.isArray(t))return t;if(e){if(-1!=["woql:And","woql:Or"].indexOf(t["@type"])){if(!t["woql:query_list"]||!t["woql:query_list"].length)return{};if(1==t["woql:query_list"].length)return h(t["woql:query_list"][0]["woql:query"],e)}if(void 0!==t["woql:query"]&&"woql:Comment"!=t["@type"]){if(!t["woql:query"]["@type"])return{}}else if("woql:Comment"==t["@type"]&&t["woql:comment"]&&(!t["woql:query"]||!t["woql:query"]["@type"]))return{"@type":"woql:Comment","woql:comment":t["woql:comment"]};if(void 0!==t["woql:consequent"]&&!t["woql:consequent"]["@type"])return{}}var r={};for(var o in t){var s=t[o];if(Array.isArray(s)){for(var a=[],u=0;u<s.length;u++)if("object"==i(s[u])){var p=h(s[u],e);p&&n.empty(p)||a.push(p)}else a.push(s[u]);r[o]=a}else if("object"==i(s)){var c=h(s,e);c&&n.empty(c)||(r[o]=c)}else r[o]=s}return r}s.prototype.parameterError=function(t){return this.errors.push({type:this.cursor["@type"],message:t}),this},s.prototype.hasErrors=function(){return this.errors.length>0},s.prototype.addSubQuery=function(t){if(t)this.cursor["woql:query"]=this.jobj(t);else{var e={};this.cursor["woql:query"]=e,this.cursor=e}return this},s.prototype.containsUpdate=function(t){if(t=t||this.query,-1!==this.update_operators.indexOf(t["@type"]))return!0;if(t["woql:consequent"]&&this.containsUpdate(t["woql:consequent"]))return!0;if(t["woql:query"])return this.containsUpdate(t["woql:query"]);if(t["woql:query_list"])for(var e=0;e<t["woql:query_list"].length;e++)if(this.containsUpdate(t["woql:query_list"][e]))return!0;return!1},s.prototype.updated=function(){return this.contains_update=!0,this},s.prototype.jlt=function(t,e){return{"@type":e=e?-1==e.indexOf(":")?"xsd:"+e:e:"xsd:string","@value":t}},s.prototype.varj=function(t){return"v:"==t.substring(0,2)&&(t=t.substring(2)),"string"==typeof t?{"@type":"woql:Variable","woql:variable_name":{"@value":t,"@type":"xsd:string"}}:t},s.prototype.jobj=function(t){return t.json?t.json():!0===t?{"@type":"woql:True"}:t},s.prototype.asv=function(t,e,r){var i={};return"number"==typeof t?(i["@type"]="woql:IndexedAsVar",i["woql:index"]=this.jlt(t,"xsd:nonNegativeInteger")):"string"==typeof t&&(i["@type"]="woql:NamedAsVar",i["woql:identifier"]=this.jlt(t)),"v:"==e.substring(0,2)&&(e=e.substring(2)),i["woql:variable_name"]={"@type":"xsd:string","@value":e},r&&(i["woql:var_type"]=this.jlt(r,"xsd:anyURI")),i},s.prototype.addASV=function(t,e){"woql:IndexedAsVar"==e["@type"]?(t["woql:indexed_as_var"]||(t["woql:indexed_as_var"]=[]),t["woql:indexed_as_var"].push(e)):(t["woql:named_as_var"]||(t["woql:named_as_var"]=[]),t["woql:named_as_var"].push(e))},s.prototype.wform=function(t){return t&&t.type&&(this.cursor["woql:format"]={"@type":"woql:Format","woql:format_type":{"@value":t.type,"@type":"xsd:string"}},t.format_header&&(this.cursor["woql:format"]["woql:format_header"]={"@value":!0,"@type":"xsd:boolean"})),this},s.prototype.arop=function(t){return"object"==i(t)?t.json?t.json():t:this.cleanObject(t,"xsd:decimal")},s.prototype.vlist=function(t){if(!t)return{};var e={"@type":"woql:Array","woql:array_element":[]};Array.isArray(t)||(t=[t]);for(var r=0;r<t.length;r++){var i=this.cleanObject(t[r]);i["@type"]="woql:ArrayElement",i["woql:index"]=this.jlt(r,"xsd:nonNegativeInteger"),e["woql:array_element"].push(i)}return e},s.prototype.wlist=function(t){if("string"==typeof t)return this.expandVariable(t,!0);if(Array.isArray(t)){for(var e={"@type":"woql:Array","woql:array_element":[]},r=0;r<t.length;r++){var i=this.cleanObject(t[r]);"string"==typeof i&&(i={node:i}),i["@type"]="woql:ArrayElement",i["woql:index"]=this.jlt(r,"xsd:nonNegativeInteger"),e["woql:array_element"].push(i)}return e}},s.prototype.qle=function(t,e){var r=this.jobj(t);return{"@type":"woql:QueryListElement","woql:index":this.jlt(e,"nonNegativeInteger"),"woql:query":r}},s.prototype.cleanSubject=function(t){var e=!1;return"object"==i(t)?t:"string"==typeof t?(e=-1!=t.indexOf(":")?t:this.vocab&&this.vocab[t]?this.vocab[t]:"doc:"+t,this.expandVariable(e)):(this.parameterError("Subject must be a URI string"),""+t)},s.prototype.cleanPredicate=function(t){var e=!1;return"object"==i(t)?t:"string"!=typeof t?(this.parameterError("Predicate must be a URI string"),""+t):(e=-1!=t.indexOf(":")?t:this.vocab&&this.vocab[t]?this.vocab[t]:"scm:"+t,this.expandVariable(e))},s.prototype.cleanPathPredicate=function(t){return-1!=t.indexOf(":")?t:this.vocab&&this.vocab[t]?this.vocab[t]:"scm:"+t},s.prototype.cleanObject=function(t,e){var r={"@type":"woql:Datatype"};if("string"==typeof t){if(this.looksLikeClass(t))return this.cleanClass(t);if(this.vocab&&this.vocab[t])return this.cleanClass(this.vocab[t]);r["woql:datatype"]=this.jlt(t,e)}else if("number"==typeof t)e=e||"xsd:decimal",r["woql:datatype"]=this.jlt(t,e);else if("object"==i(t)&&t){if(!t["@value"])return t;r["woql:datatype"]=t}return r},s.prototype.looksLikeClass=function(t){if(-1===t.indexOf(":"))return!1;var e=t.split(":")[0];return"v"==e||"scm"==e||"doc"==e||"terminusdb"==e||!!n.standard_urls[e]},s.prototype.cleanGraph=function(t){return{"@type":"xsd:string","@value":t}},s.prototype.expandVariable=function(t,e){return"v:"==t.substring(0,2)||e?("v:"==t.substring(0,2)&&(t=t.substring(2)),{"@type":"woql:Variable","woql:variable_name":{"@value":t,"@type":"xsd:string"}}):{"@type":"woql:Node","woql:node":t}},s.prototype.cleanClass=function(t,e){return"string"!=typeof t?"":(-1==t.indexOf(":")&&(t=this.vocab&&this.vocab[t]?this.vocab[t]:"scm:"+t),e?t:this.expandVariable(t))},s.prototype.cleanType=function(t,e){return this.cleanClass(t,e)},s.prototype.defaultContext=function(t){var e={};for(var r in n.standard_urls)e[r]=n.standard_urls[r];return e.scm=t+"/schema#",e.doc=t+"/data/",e},s.prototype.getContext=function(t){t=t||this.query;for(var e=0,r=Object.keys(t);e<r.length;e++){var i=r[e];if("@context"==i)return t[i];if(-1!==this.paging_transitive_properties.indexOf(i)){var n=t[i][1],o=this.getContext(n);if(o)return o}}},s.prototype.context=function(t){this.query["@context"]=t},s.prototype.loadDefaultVocabulary=function(){var t={type:"rdf:type",label:"rdfs:label",Class:"owl:Class",DatatypeProperty:"owl:DatatypeProperty",ObjectProperty:"owl:ObjectProperty",Document:"system:Document",abstract:"system:abstract",comment:"rdfs:comment",range:"rdfs:range",domain:"rdfs:domain",subClassOf:"rdfs:subClassOf",string:"xsd:string",integer:"xsd:integer",decimal:"xsd:decimal",boolean:"xdd:boolean",email:"xdd:email",json:"xdd:json",dateTime:"xsd:dateTime",date:"xsd:date",coordinate:"xdd:coordinate",line:"xdd:coordinatePolyline",polygon:"xdd:coordinatePolygon"};return t},s.prototype.setVocabulary=function(t){this.vocab=t},s.prototype.getVocabulary=function(t){return this.vocab},s.prototype.loadVocabulary=function(t){var e=this;(new s).quad("v:S","v:P","v:O","schema/*").execute(t).then((function(t){if(t.bindings&&t.bindings.length>0)for(var r=0;r<t.bindings.length;r++)for(var i in t.bindings[r]){var n=t.bindings[r][i];if("string"==typeof n){var o=n.split(":");2==o.length&&o[1]&&"_"!=o[0]&&(e.vocab[o[0]]=o[1])}}}))},s.prototype.execute=function(t,e){return t.query(this,e)},s.prototype.json=function(t){return t?(this.query=h(t),this):h(this.query,!0)},s.prototype.prettyPrint=function(t){return t=t||"js",new o(this.vocab,t).printJSON(this.query)},s.prototype.wrapCursorWithAnd=function(){if(this.cursor&&"woql:And"==this.cursor["@type"]){var t=this.cursor["woql:query_list"].length;return this.and({}),void(this.cursor=this.cursor["woql:query_list"][t]["woql:query"])}var e=(new s).json(this.cursor);for(var r in this.cursor)delete this.cursor[r];this.and(e,{}),this.cursor=this.cursor["woql:query_list"][1]["woql:query"]},s.prototype.findLastSubject=function(t){if(t&&t["woql:query_list"])for(var e=t["woql:query_list"].length-1;e>=0;e--){var r=this.findLastSubject(t["woql:query_list"][e]);if(r)return r}if(t&&t["woql:query"]){var i=this.findLastSubject(t["woql:query"]);if(i)return i}return!(!t||!t["woql:subject"])&&t},s.prototype.findLastProperty=function(t){if(t&&t["woql:query_list"])for(var e=t["woql:query_list"].length-1;e>=0;e--){var r=this.findLastProperty(t["woql:query_list"][e]);if(r)return r}if(t&&t["woql:query"]){var i=this.findLastProperty(t["woql:query"]);if(i)return i}return!!(t&&t["woql:subject"]&&this._is_property_triple(t["woql:predicate"],t["woql:object"]))&&t},s.prototype._is_property_triple=function(t,e){var r=t["woql:node"]?t["woql:node"]:t,i=e["woql:node"]?e["woql:node"]:e;return"owl:ObjectProperty"==i||"owl:DatatypeProperty"==i||("rdfs:domain"==r||"rdfs:range"==r)},s.prototype.compilePathPattern=function(t){var e=a(t);if(e&&e.length)return function t(e,r){if(1==e.length){var i=a(e[0]);return 1==i.length?function(t,e){if(-1!=t.indexOf("<")&&-1!=t.indexOf(">")){t.slice(1,t.length-1);var r="owl:topObjectProperty";return{"@type":"woql:PathOr","woql:path_left":{"@type":"woql:InvertedPathPredicate","woql:path_predicate":{"@id":r}},"woql:path_right":{"@type":"woql:PathPredicate","woql:path_predicate":{"@id":r}}}}if(-1!=t.indexOf("<")){var i=t.slice(1,t.length);return{"@type":"woql:InvertedPathPredicate","woql:path_predicate":{"@id":"*"==i?"owl:topObjectProperty":e.cleanPathPredicate(i)}}}if(-1!=t.indexOf(">")){var n=t.slice(0,t.length-1);return{"@type":"woql:PathPredicate","woql:path_predicate":{"@id":"*"==n?"owl:topObjectProperty":e.cleanPathPredicate(n)}}}return{"@type":"woql:PathPredicate","woql:path_predicate":{"@id":"*"==t?"owl:topObjectProperty":e.cleanPathPredicate(t)}}}(i[0].trim(),r):t(i,r)}if(-1!=e.indexOf("|")){var n=e.slice(0,e.indexOf("|")),o=e.slice(e.indexOf("|")+1);return{"@type":"woql:PathOr","woql:path_left":t(n,r),"woql:path_right":t(o,r)}}if(-1!=e.indexOf(",")){var s=e.slice(0,e.indexOf(",")),u=e.slice(e.indexOf(",")+1);return{"@type":"woql:PathSequence","woql:path_first":t(s,r),"woql:path_second":t(u,r)}}if("+"==e[1])return{"@type":"woql:PathPlus","woql:path_pattern":t([e[0]],r)};if("{"==e[1].charAt(0)){var h=e[1].substring(1,e[1].length-1).split(",");return{"@type":"woql:PathTimes","woql:path_minimum":{"@type":"xsd:positiveInteger","@value":h[0]},"woql:path_maximum":{"@type":"xsd:positiveInteger","@value":h[1]},"woql:path_pattern":t([e[0]],r)}}return r.parameterError("Pattern error - could not be parsed "+e[0]),{"@type":"woql:PathPredicate","rdfs:label":"failed to parse query "+e[0]}}(e,this);this.parameterError("Pattern error - could not be parsed "+t)},t.exports=s},function(t,e,r){var i=r(4);function n(){this.rules=[]}function o(){i.call(this),this.rule={}}n.prototype.render=function(t){return t&&(this.view_render=t),this.view_render},n.prototype.renderer=function(t){return t&&(this.view_renderer=t),this.view_renderer},n.prototype.getRulesJSON=function(){for(var t=[],e=0;e<this.rules.length;e++)t.push(this.rules[e].json());return t},n.prototype.getBasicJSON=function(){var t={};return this.view_render&&(t.render=this.view_render),this.view_renderer&&(t.renderer=this.view_renderer),t},n.prototype.loadBasicJSON=function(t){t.render&&(this.view_render=t.view_render),t.renderer&&(this.view_renderer=t.view_renderer)},n.prototype.getBasicprettyPrint=function(){var t="";return void 0!==this.render()&&(t+="view.render("+this.render()+")\n"),void 0!==this.renderer()&&(t+="view.renderer('"+this.renderer()+"')\n"),t},o.prototype=Object.create(i.prototype),o.prototype.constructor=i,o.prototype.prettyPrint=function(t){var e="";return this.pattern&&(e=this.pattern.prettyPrint(t)),void 0!==this.color()&&(e+=".color(["+this.color().join(",")+"])"),void 0!==this.hidden()&&(e+=".hidden("+this.hidden()+")"),void 0!==this.size()&&(e+=".size('"+this.size()+"')"),void 0!==this.icon()&&(e+=".icon("+JSON.stringify(this.icon())+")"),void 0!==this.text()&&(e+=".text("+JSON.stringify(this.text())+")"),void 0!==this.border()&&(e+=".border("+JSON.stringify(this.border())+")"),void 0!==this.args()&&(e+=".args("+JSON.stringify(this.args())+")"),void 0!==this.renderer()&&(e+=".renderer('"+this.renderer()+"')"),void 0!==this.render()&&(e+=".render("+this.render()+")"),void 0!==this.click()&&(e+=".click("+this.click()+")"),void 0!==this.hover()&&(e+=".hover("+this.hover()+")"),e},o.prototype.json=function(t){if(!t){var e={};return this.pattern&&(e.pattern=this.pattern.json()),e.rule=this.rule,e}return this.rule=t.rule||{},t.pattern&&this.pattern.setPattern(t.pattern),this},o.prototype.size=function(t){return void 0===t?this.rule.size:(this.rule.size=t,this)},o.prototype.color=function(t){return void 0===t?this.rule.color:(this.rule.color=t,this)},o.prototype.icon=function(t){return t?(this.rule.icon=t,this):this.rule.icon},o.prototype.text=function(t){return t?(this.rule.text=t,this):this.rule.text},o.prototype.border=function(t){return t?(this.rule.border=t,this):this.rule.border},o.prototype.renderer=function(t){return void 0===t?this.rule.renderer:(this.rule.renderer=t,this)},o.prototype.render=function(t){return void 0===t?this.rule.render:(this.rule.render=t,this)},o.prototype.click=function(t){return t?(this.rule.click=t,this):this.rule.click},o.prototype.hover=function(t){return t?(this.rule.hover=t,this):this.rule.hover},o.prototype.hidden=function(t){return void 0===t?this.rule.hidden:(this.rule.hidden=t,this)},o.prototype.args=function(t){return void 0===t?this.rule.args:(this.rule.args=t,this)},t.exports={WOQLViewRule:o,ViewConfig:n}},function(t,e,r){var i=r(22),n=r(0);
/**
* @file WOQL Rules
* @license Apache Version 2
* WOQL Rules support pattern matching on results of WOQL Queries
*/
function o(){i.TerminusRule.call(this),this.pattern=new s}function s(t){i.TerminusPattern.call(this,t)}o.prototype=Object.create(i.TerminusRule.prototype),o.prototype.constructor=i.TerminusRule,o.prototype.setVariables=function(t){return t&&t.length&&(this.pattern.variables=n.addNamespacesToVariables(t),this.current_variable=this.pattern.variables[this.pattern.variables.length-1]),this},o.prototype.vars=function(){for(var t=arguments.length,e=new Array(t),r=0;r<t;r++)e[r]=arguments[r];return this.setVariables(e)},o.prototype.v=function(t){return t?(this.current_variable=n.addNamespaceToVariable(t),this):this.current_variable},o.prototype.edge=function(t,e){if(this.scope("edge"),t){var r=n.addNamespaceToVariable(t);this.setVariables([r]),this.pattern.source=r}if(e){var i=n.addNamespaceToVariable(e);t||this.setVariables([i]),this.pattern.target=i}return this},o.prototype.rownum=function(t){return void 0===t?this.pattern.rownum:(this.pattern.rownum=t,this)},o.prototype.in=function(){if(this.current_variable){this.pattern.constraints||(this.pattern.constraints={}),this.pattern.constraints[this.current_variable]||(this.pattern.constraints[this.current_variable]=[]);for(var t=arguments.length,e=new Array(t),r=0;r<t;r++)e[r]=arguments[r];this.pattern.constraints[this.current_variable].push(e)}return this},o.prototype.filter=function(t){return this.current_variable&&(this.pattern.constraints||(this.pattern.constraints={}),this.pattern.constraints[this.current_variable]||(this.pattern.constraints[this.current_variable]=[]),this.pattern.constraints[this.current_variable].push(t)),this},o.prototype.matchRow=function(t,e,r,i){for(var n=[],o=0;o<t.length;o++)i&&this.rule&&void 0===this.rule[i]||t[o].pattern.matchRow(e,r)&&n.push(t[o]);return n},o.prototype.matchCell=function(t,e,r,i,n){for(var o=[],s=0;s<t.length;s++)n&&this.rule&&void 0===this.rule[n]||t[s].pattern.matchCell(e,r,i)&&o.push(t[s]);return o},o.prototype.matchColumn=function(t,e,r){for(var i=[],n=0;n<t.length;n++)r&&this.rule&&void 0===this.rule[r]||t[n].pattern.matchColumn(e)&&i.push(t[n]);return i},o.prototype.matchNode=function(t,e,r,i,n){for(var o=[],s=0;s<t.length;s++)n&&this.rule&&void 0===this.rule[n]||t[s].pattern.matchNode(e,r,i)&&o.push(t[s]);return o},o.prototype.matchPair=function(t,e,r,i,n){for(var o=[],s=0;s<t.length;s++)n&&this.rule&&void 0===this.rule[n]||t[s].pattern.matchPair(e,r,i)&&o.push(t[s]);return o},o.prototype.matchEdge=o.prototype.matchPair,s.prototype=Object.create(i.TerminusPattern.prototype),s.prototype.constructor=i.TerminusPattern,s.prototype.prettyPrint=function(t){var e=this.scope+"('";for(var r in this.variables&&(e+=this.variables.join("', '")),e+="')",void 0!==this.literal&&(e+=".literal("+this.literal+")"),void 0!==this.type&&(e+=".type("+this.unpack(this.type)+")"),void 0!==this.value&&(e+=".value("+this.unpack(this.value,!0)+")"),this.constraints){e+=".v('"+r+"')";for(var i=0;i<this.constraints[r].length;i++)"function"==typeof this.constraints[r][i]?e+=".filter("+this.constraints[r][i]+")":e+=".in("+json.unpack(this.constraints[r][i])+")"}return e},s.prototype.matchRow=function(t,e){return!(void 0!==this.rownum&&void 0!==e&&!this.numberMatch(this.rownum,e))&&((!this.scope||"row"==this.scope)&&!!this.testVariableConstraints(t))},s.prototype.matchCell=function(t,e,r){return!(void 0!==this.rownum&&void 0!==r&&!this.numberMatch(this.rownum,r))&&(!!this.testBasics("column",t[e])&&((!this.variables||!this.variables.length||-1!=this.variables.indexOf(e))&&!!this.testVariableConstraints(t)))},s.prototype.matchNode=function(t,e,r){return!!this.testBasics("node",t[e])&&((!this.variables||!this.variables.length||-1!=this.variables.indexOf(e))&&!!this.testVariableConstraints(t))},s.prototype.matchColumn=function(t){return(!this.scope||"column"==this.scope)&&(!this.variables||!this.variables.length||-1!=this.variables.indexOf(t))},s.prototype.matchPair=function(t,e,r){return(!this.scope||"edge"==this.scope)&&((!this.source||this.source==e)&&((!this.target||this.target==r)&&!!this.testVariableConstraints(t)))},s.prototype.testVariableConstraints=function(t){for(var e in this.constraints)if(!this.testVariableConstraint(e,t[e]))return!1;return!0},s.prototype.testVariableConstraint=function(t,e){if(!this.constraints[t])return!0;for(var r=0;r<this.constraints[t].length;r++)if(!this.testValue(e,this.constraints[t][r]))return!1;return!0},s.prototype.setPattern=function(t){for(var e in t)this[e]=t[e]},s.prototype.json=function(){var t={};return this.scope&&(t.scope=this.scope),this.value&&(t.value=this.value),this.rownum&&(t.rownum=this.rownum),this.variables&&(t.variables=this.variables),this.literal&&(t.literal=this.literal),this.type&&(t.type=this.type),this.constraints&&(t.constraints=this.constraints),this.source&&(t.source=this.source),this.target&&(t.target=this.target),t},t.exports=o},function(module,exports,__webpack_require__){var WOQLQuery=__webpack_require__(2),WOQLJSON=__webpack_require__(58),WOQLBuilder=__webpack_require__(59),WOQLSchema=__webpack_require__(19),WOQLPrinter=__webpack_require__(18),WOQLLibrary=__webpack_require__(20),WOQL={using:function(t,e){return(new WOQLQuery).using(t,e)},comment:function(t,e){return(new WOQLQuery).comment(t,e)},select:function(){var t;return(t=new WOQLQuery).select.apply(t,arguments)},distinct:function(){var t;return(t=new WOQLQuery).distinct.apply(t,arguments)},and:function(){var t;return(t=new WOQLQuery).and.apply(t,arguments)},or:function(){var t;return(t=new WOQLQuery).or.apply(t,arguments)},from:function(t,e){return(new WOQLQuery).from(t,e)},into:function(t,e){return(new WOQLQuery).into(t,e)},triple:function(t,e,r){return(new WOQLQuery).triple(t,e,r)},quad:function(t,e,r,i){return(new WOQLQuery).quad(t,e,r,i)},sub:function(t,e){return(new WOQLQuery).sub(t,e)}};WOQL.subsumption=WOQL.sub,WOQL.eq=function(t,e){return(new WOQLQuery).eq(t,e)},WOQL.equals=WOQL.eq,WOQL.substr=function(t,e,r,i,n){return(new WOQLQuery).substr(t,e,r,i,n)},WOQL.substring=WOQL.substr,WOQL.update_object=function(t){return(new WOQLQuery).update_object(t)},WOQL.delete_object=function(t){return(new WOQLQuery).delete_object(t)},WOQL.read_object=function(t,e,r){return(new WOQLQuery).read_object(t,e,r)},WOQL.get=function(t,e){return(new WOQLQuery).get(t,e)},WOQL.put=function(t,e,r){return(new WOQLQuery).put(t,e,r)},WOQL.as=function(t,e,r){return(new WOQLQuery).as(t,e,r)},WOQL.remote=function(t,e){return(new WOQLQuery).remote(t,e)},WOQL.file=function(t,e){return(new WOQLQuery).file(t,e)},WOQL.post=function(t,e){return(new WOQLQuery).post(t,e)},WOQL.delete_triple=function(t,e,r){return(new WOQLQuery).delete_triple(t,e,r)},WOQL.delete_quad=function(t,e,r,i){return(new WOQLQuery).delete_quad(t,e,r,i)},WOQL.add_triple=function(t,e,r){return(new WOQLQuery).add_triple(t,e,r)},WOQL.add_quad=function(t,e,r,i){return(new WOQLQuery).add_quad(t,e,r,i)},WOQL.when=function(t,e){return(new WOQLQuery).when(t,e)},WOQL.trim=function(t,e){return(new WOQLQuery).trim(t,e)},WOQL.eval=function(t,e){return(new WOQLQuery).eval(t,e)},WOQL.evaluate=WOQL.eval,WOQL.plus=function(){var t;return(t=new WOQLQuery).plus.apply(t,arguments)},WOQL.minus=function(){var t;return(t=new WOQLQuery).minus.apply(t,arguments)},WOQL.times=function(){var t;return(t=new WOQLQuery).times.apply(t,arguments)},WOQL.divide=function(){var t;return(t=new WOQLQuery).divide.apply(t,arguments)},WOQL.div=function(){var t;return(t=new WOQLQuery).div.apply(t,arguments)},WOQL.exp=function(t,e){return(new WOQLQuery).exp(t,e)},WOQL.floor=function(t){return(new WOQLQuery).floor(t)},WOQL.isa=function(t,e){return(new WOQLQuery).isa(t,e)},WOQL.like=function(t,e,r){return(new WOQLQuery).like(t,e,r)},WOQL.less=function(t,e){return(new WOQLQuery).less(t,e)},WOQL.greater=function(t,e){return(new WOQLQuery).greater(t,e)},WOQL.opt=function(t){return(new WOQLQuery).opt(t)},WOQL.optional=WOQL.opt,WOQL.unique=function(t,e,r){return(new WOQLQuery).unique(t,e,r)},WOQL.idgen=function(t,e,r){return(new WOQLQuery).idgen(t,e,r)},WOQL.idgenerator=WOQL.idgen,WOQL.upper=function(t,e){return(new WOQLQuery).upper(t,e)},WOQL.lower=function(t,e){return(new WOQLQuery).lower(t,e)},WOQL.pad=function(t,e,r,i){return(new WOQLQuery).pad(t,e,r,i)},WOQL.split=function(t,e,r){return(new WOQLQuery).split(t,e,r)},WOQL.member=function(t,e){return(new WOQLQuery).member(t,e)},WOQL.concat=function(t,e){return(new WOQLQuery).concat(t,e)},WOQL.join=function(t,e,r){return(new WOQLQuery).join(t,e,r)},WOQL.sum=function(t,e){return(new WOQLQuery).sum(t,e)},WOQL.start=function(t,e){return(new WOQLQuery).start(t,e)},WOQL.limit=function(t,e){return(new WOQLQuery).limit(t,e)},WOQL.re=function(t,e,r){return(new WOQLQuery).re(t,e,r)},WOQL.regexp=WOQL.re,WOQL.length=function(t,e){return(new WOQLQuery).length(t,e)},WOQL.not=function(t){return(new WOQLQuery).not(t)},WOQL.count=function(t,e){return(new WOQLQuery).count(t,e)},WOQL.typecast=function(t,e,r){return(new WOQLQuery).typecast(t,e,r)},WOQL.cast=WOQL.typecast,WOQL.order_by=function(){var t;return(t=new WOQLQuery).order_by.apply(t,arguments)},WOQL.group_by=function(t,e,r,i){return(new WOQLQuery).group_by(t,e,r,i)},WOQL.true=function(){return(new WOQLQuery).true()},WOQL.path=function(t,e,r,i){return(new WOQLQuery).path(t,e,r,i)},WOQL.size=function(t,e){return(new WOQLQuery).size(t,e)},WOQL.triple_count=function(t,e){return(new WOQLQuery).triple_count(t,e)},WOQL.star=function(t,e,r,i){return(new WOQLQuery).star(t,e,r,i)},WOQL.all=function(t,e,r,i){return(new WOQLQuery).all(t,e,r,i)},WOQL.node=function(t,e){return(new WOQLQuery).node(t,e)},WOQL.insert=function(t,e,r){return(new WOQLQuery).insert(t,e,r)},WOQL.schema=function(t){var e=new WOQLQuery;return t&&e.graph(t),e},WOQL.graph=function(t){return(new WOQLQuery).graph(t)},WOQL.add_class=function(t,e){return(new WOQLQuery).add_class(t,e)},WOQL.add_property=function(t,e,r){return(new WOQLQuery).add_property(t,e,r)},WOQL.delete_class=function(t,e){return(new WOQLQuery).delete_class(t,e)},WOQL.delete_property=function(t,e){return(new WOQLQuery).delete_property(t,e)},WOQL.doctype=function(t,e){return WOQL.add_class(t,e).parent("Document")},WOQL.insert_data=function(t,e){return(new WOQLQuery).insert_data(t,e)},WOQL.insert_class_data=function(t,e){return(new WOQLQuery).insert_class_data(t,e)},WOQL.insert_doctype_data=function(t,e){return(new WOQLQuery).insert_doctype_data(t,e)},WOQL.insert_property_data=function(t,e){return(new WOQLQuery).insert_property_data(t,e)},WOQL.nuke=function(t){return(new WOQLQuery).nuke(t)},WOQL.query=function(){return new WOQLQuery},WOQL.json=function(t){return(new WOQLQuery).json(t)},WOQL.lib=function(t){return new((new WOQLQuery).lib)(t)},WOQL.string=function(t){return new((new WOQLQuery).string)(t)},WOQL.literal=function(t,e){return new((new WOQLQuery).literal)(t,e)},WOQL.iri=function(t){return new((new WOQLQuery).iri)(t)},WOQL.vars=function(){for(var t=arguments.length,e=new Array(t),r=0;r<t;r++)e[r]=arguments[r];return e.map((function(t){return"v:"+t}))},WOQL.client=function(t){return t&&(this._client=t),this._client},WOQL.emerge=function(auto_eval){var unemerged=["emerge","true","eval"];function _emerge_str(t){return"function ".concat(t,"(...args){\n return WOQL.").concat(t,"(...args)\n }")}var funcs=[];for(var k in this)"function"==typeof this[k]&&-1==unemerged.indexOf(k)&&funcs.push(_emerge_str(k));var str=funcs.join(";\n");return auto_eval&&eval(str),str},module.exports=WOQL},function(t,e){
/**
* @file Terminus Constants
* @license Apache Version 2
* Constants representing API actions
*/
t.exports=Object.freeze({CONNECT:"connect",CREATE_DATABASE:"create_database",READ_DATABASE:"read_database",UPDATE_DATABASE:"update_database",DELETE_DATABASE:"delete_database",CREATE_USER:"create_user",READ_USER:"read_user",UPDATE_USER:"update_user",DELETE_USER:"delete_user",CREATE_ORGANIZATION:"create_organization",READ_ORGANIZATION:"read_organization",UPDATE_ORGANIZATION:"update_organization",DELETE_ORGANIZATION:"delete_organization",GET_ROLES:"get_roles",UPDATE_ROLES:"update_roles",CREATE_GRAPH:"create_graph",DELETE_GRAPH:"delete_graph",GET_TRIPLES:"get_triples",UPDATE_TRIPLES:"update_triples",CLASS_FRAME:"class_frame",WOQL_QUERY:"woql_query",CLONE:"clone",PUSH:"push",PULL:"pull",FETCH:"fetch",REBASE:"rebase",BRANCH:"branch"})},function(t,e){function r(t){return(r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function i(t,e,r){var i="";return r.response?(r=r.response).data&&(i+="".concat(n(r.data))):r.body&&(i+="".concat(n(r.body))),t=t.split("?")[0],r.status&&(i+="Code: ".concat(r.status)),r.action&&(i+=" Action: ".concat(r.action)),r.type&&(i+=" Type: ".concat(r.type)),t&&(i+=" url: ".concat(t)),e&&e.method&&(i+=" method: ".concat(e.method)),i}function n(t){if("object"===r(t)){for(var e="",i=0,n=Object.keys(t);i<n.length;i++){var o=n[i];t[o]&&"object"!=r(t[o])&&(e+="".concat(o," ").concat(t[o]," "))}return e}return t}t.exports={getErrorAsMessage:i,getAPIErrorMessage:function(t,e,r){return"API Error ".concat(i(t,e,r))},getAccessDeniedMessage:function(t,e,r){return"Access Denied ".concat(i(t,e,r))},accessDenied:function(t,e,r){var i={status:403};return i.url=(r||"")+(e||""),i.type="client",i.action=t,i.body="".concat(i.action," not permitted for ").concat(i.url),i},getInvalidURIMessage:function(t,e){return"Invalid argument to\n ".concat(e,". \n ").concat(t,"\n is not a valid Terminus DB API endpoint")},getInvalidParameterMessage:function(t,e){return"Invalid Parameter to\n ".concat(t,". \n ").concat(e)},parseAPIError:function(t){var e={};if(e.status=t.status,e.type=t.type,t.data&&"object"===r(t.data)){var i;try{i=t.text()}catch(e){try{i=t.json()}catch(e){i=t.toString()}}e.body=i}else t.data&&(e.body=t.data);return e.url=t.url,e.headers=t.headers,e.redirected=t.redirected,e}}},function(t,e,r){function i(t){return(i="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}var n=r(22);
/**
* @file Frame Rule
* @license Apache Version 2
*/function o(){n.TerminusRule.call(this),this.pattern=new s}function s(){n.TerminusPattern.call(this)}o.prototype=Object.create(n.TerminusRule.prototype),o.prototype.constructor=n.TerminusRule,o.prototype.testRules=function(t,e,r){var i=[];if(t&&t.length)for(var n=0;n<t.length;n++){(!t[n].pattern||this.patternMatchesFrame(t[n].pattern,e))&&(i.push(t[n]),r&&"function"==typeof r&&r(e,t[n]))}return i},o.prototype.patternMatchesFrame=function(t,e){return t.checkFrame?t.checkFrame(e):(new s).setPattern(t).checkFrame(e)},o.prototype.property=function(){for(var t=arguments.length,e=new Array(t),r=0;r<t;r++)e[r]=arguments[r];return e&&0!=e.length?(this.pattern.property=e,this):this.pattern.property},o.prototype.frame_type=function(){for(var t=arguments.length,e=new Array(t),r=0;r<t;r++)e[r]=arguments[r];return e&&0!=e.length?(this.pattern.frame_type=e,this):this.pattern.frame_type},o.prototype.label=function(){for(var t=arguments.length,e=new Array(t),r=0;r<t;r++)e[r]=arguments[r];return e&&0!=e.length?(this.pattern.label=e,this):this.pattern.label},o.prototype.subject=function(){for(var t=arguments.length,e=new Array(t),r=0;r<t;r++)e[r]=arguments[r];return e&&0!=e.length?(this.pattern.subject=e,this):this.pattern.subject},o.prototype.subjectClass=function(){for(var t=arguments.length,e=new Array(t),r=0;r<t;r++)e[r]=arguments[r];return e&&0!=e.length?(this.pattern.subjectClass=e,this):this.pattern.subjectClass},o.prototype.range=function(){for(var t=arguments.length,e=new Array(t),r=0;r<t;r++)e[r]=arguments[r];return e&&0!=e.length?(this.pattern.range=e,this):this.pattern.range},o.prototype.depth=function(t){return void 0===t?this.pattern.depth:(this.pattern.depth=t,this)},o.prototype.index=function(){for(var t=arguments.length,e=new Array(t),r=0;r<t;r++)e[r]=arguments[r];return e&&0!=e.length?(this.pattern.index=e,this):this.pattern.index},o.prototype.status=function(){for(var t=arguments.length,e=new Array(t),r=0;r<t;r++)e[r]=arguments[r];return e&&0!=e.length?(this.pattern.status=e,this):this.pattern.status},o.prototype.parent=function(t){return t?(this.pattern.parent=t,this):this.pattern.parent},o.prototype.children=function(){for(var t=arguments.length,e=new Array(t),r=0;r<t;r++)e[r]=arguments[r];if(void 0===e||0==e.length)return this.pattern.children;void 0===this.pattern.children&&(this.pattern.children=[]);for(var i=0;i<e.length;i++)this.pattern.children.push(e[i]);return this},s.prototype=Object.create(n.TerminusPattern.prototype),s.prototype.constructor=n.TerminusPattern,s.prototype.setPattern=function(t){if(t.scope&&(this.scope=t.scope),void 0!==t.literal&&(this.literal=t.literal),void 0!==t.type&&(this.type=t.type),void 0!==t.label&&(this.label=t.label),void 0!==t.frame_type&&(this.frame_type=t.frame_type),void 0!==t.subject&&(this.subject=t.subject),void 0!==t.subjectClass&&(this.subjectClass=t.subjectClass),void 0!==t.range&&(this.range=t.range),void 0!==t.property&&(this.property=t.property),void 0!==t.value&&(this.value=t.value),void 0!==t.parent){var e=t.parent;"function"!=typeof e.json&&(e=(new s).setPattern(e)),this.parent=e}if(t.children){this.children=[];for(var r=0;r<t.children.length;r++){var i=t.children[r];"function"!=typeof i.json&&(i=(new s).setPattern(i)),this.children.push(i)}}void 0!==t.depth&&(this.depth=t.depth),void 0!==t.index&&(this.index=t.index),void 0!==t.status&&(this.status=t.status)},s.prototype.json=function(){var t={};if(void 0!==this.literal&&(t.literal=this.literal),this.type&&(t.type=this.type),this.scope&&(t.scope=this.scope),void 0!==this.value&&(t.value=this.value),void 0!==this.label&&(t.label=this.label),void 0!==this.frame_type&&(t.frame_type=this.frame_type),void 0!==this.subject&&(t.subject=this.subject),void 0!==this.subjectClass&&(t.subjectClass=this.subjectClass),void 0!==this.range&&(t.range=this.range),void 0!==this.property&&(t.property=this.property),void 0!==this.parent&&(t.parent=this.parent.json?this.parent.json():this.parent),void 0!==this.children){t.children=[];for(var e=0;e<this.children.length;e++)t.children.push(this.children[e].json?this.children[e].json():this.children[e])}return void 0!==this.depth&&(t.depth=this.depth),void 0!==this.index&&(t.index=this.index),void 0!==this.status&&(t.status=this.status),t},s.prototype.checkFrame=function(t){var e=this.getRendererType(t);return!!e&&((!this.scope||this.scope==e||"*"==this.scope)&&(!this.illegalRuleType(e)&&(!(this.frame_type&&!this.checkFrameType(e,t))&&(!(this.label&&!this.checkLabel(e,t))&&(!(this.subject&&!this.checkSubject(e,t))&&(!(this.subjectClass&&!this.checkSubjectClass(e,t))&&(!(this.property&&!this.checkProperty(e,t))&&(!(void 0!==this.depth&&!this.checkDepth(e,t))&&(!(this.range&&!this.checkRange(e,t))&&(!(void 0!==this.value&&!this.checkValue(e,t))&&(!(this.type&&!this.checkType(e,t))&&(!(void 0!==this.literal&&!this.checkLiteral(e,t))&&(!(this.parent&&!this.checkParent(e,t))&&(!(this.children&&this.children.length&&!this.checkChildren(e,t))&&(!(this.index&&!this.checkIndex(e,t))&&!(this.status&&!this.checkStatus(e,t)))))))))))))))))},s.prototype.prettyPrint=function(t){if("*"==this.scope)var e="all()";else e=this.scope+"()";if(void 0!==this.literal&&(e+=".literal("+this.literal+")"),void 0!==this.type&&(e+=".type("+this.unpack(this.type)+")"),void 0!==this.range&&(e+=".range("+this.unpack(this.range)+")"),void 0!==this.frame_type&&(e+=".frame_type("+this.unpack(this.frameType)+")"),void 0!==this.label&&(e+=".label("+this.unpack(this.label)+")"),void 0!==this.subject&&(e+=".subject("+this.unpack(this.subject)+")"),void 0!==this.subjectClass&&(e+=".subjectClass("+this.unpack(this.subjectClass)+")"),void 0!==this.property&&(e+=".property("+this.unpack(this.property)+")"),void 0!==this.value&&(e+=".value("+this.unpack(this.value,!0)+")"),void 0!==this.children&&this.children.length>0){e+=".children(\n";for(var r=this.children,i=0;i<r.length;i++)e+="View.pattern()."+r[i].prettyPrint(),i<r.length-1&&(e+=","),e+="\n";e+=")"}return void 0!==this.parent&&(e+=".parent(View.pattern()."+this.parent.prettyPrint()+")"),void 0!==this.depth&&(e+=".depth("+this.unpack(this.depth,!0)+")"),void 0!==this.index&&(e+=".index("+this.unpack(this.index,!0)+")"),void 0!==this.status&&(e+=".status("+this.unpack(this.status)+")"),e},s.prototype.illegalRuleType=function(t){return!("data"!=t||!this.children||!this.children.length)||!("object"!=t||!this.range)},s.prototype.checkSubject=function(t,e){"object"===i(this.subject)&&this.subject.length||(this.subject=[this.subject]);for(var r=e.subject(),n=0;n<this.subject.length;n++)if(this.IDsMatch(t[n],r))return!0;return!1},s.prototype.checkChildren=function(t,e){for(var r=0;r<this.children.length;r++){var i=!1;if("object"==t)for(var n in e.properties)this.children[r].checkFrame(e.properties[n])&&(i=!0);else if("property"==t)for(var o=0;o<=renderer.values.length;o++)this.children[o].checkFrame(e.values[o])&&(i=!0);if(!i)return!1}return!0},s.prototype.checkStatus=function(t,e){"object"===i(this.status)&&0!=this.status.length||(this.status=[this.status]);for(var r=0;r<this.status.length;r++){if("updated"==this.status[r]&&!e.isUpdated())return!1;if("new"==this.status[r]&&!e.isNew())return!1;if("unchanged"==this.status[r]&&e.isUpdated())return!1}return!0},s.prototype.checkDepth=function(t,e){return this.numberMatch(this.depth,e.depth())},s.prototype.checkParent=function(t,e){return this.parent.checkFrame(e.parent)},s.prototype.checkIndex=function(t,e){return"data"==t&&this.index==e.index},s.prototype.checkProperty=function(t,e){"object"===i(this.property)&&this.property.length||(this.property=[this.property]);for(var r=0;r<this.property.length;r++)if(this.propertyIDsMatch(e.property(),this.property[r]))return!0;return!1},s.prototype.checkType=function(t,e){if("object"==t)var r=e.subjectClass();else r=e.range();return Array.isArray(this.type)||(this.type=[this.type]),-1!==this.type.indexOf(r)},s.prototype.checkLiteral=function(t,e){return"object"!=t&&("property"!=t&&("data"!=t||e.isDatatypeProperty()))},s.prototype.checkValue=function(t,e){"object"===i(this.value)&&this.value.length||(this.value=[this.value]);for(var r=0;r<this.value.length;r++)if("data"==t){if(this.valuesMatch(e.value(),this.value[r]))return!0}else if("property"==t){for(var n=0;n<=e.values.length;n++)if("data"==this.getRendererType(e.values[r])&&this.valuesMatch(e.values[r].get(),this.value[r]))return!0}else if("object"==t)for(var o in e.properties)if(this.checkValue(this.getRendererType(e.properties[o]),e.properties[o]))return!0;return!1},s.prototype.checkRange=function(t,e){"object"===i(this.range)&&this.range.length||(this.range=[this.range]);for(var r=0;r<this.range.length;r++)if(this.rangeIDsMatch(e.range(),this.range[r]))return!0;return!1},s.prototype.checkSubjectClass=function(t,e){"object"===i(this.subjectClass)&&this.subjectClass.length||(this.subjectClass=[this.subjectClass]);for(var r=e.subjectClass(),n=0;n<this.subjectClass.length;n++)if(this.classIDsMatch(this.subjectClass[n],r))return!0;return!1},s.prototype.checkFrameType=function(t,e){return"object"==t?-1!=this.frame_type.indexOf("object"):"data"==t&&e.frame?-1!=this.frame_type.indexOf(e.frame.ftype()):"property"!=t&&void 0},s.prototype.checkLabel=function(t,e){if("function"!=typeof e.getLabel)return console.log(new Error("Rule passed to check label with broken renderer object - no getLabel")),!1;for(var r=0;r<this.label.length;r++)if(this.stringMatch(this.label[r],e.getLabel()))return!0;return!1},s.prototype.getRendererType=function(t){return t.isProperty()?"property":t.isObject()?"object":t.isData()?"data":t.renderer_type?t.renderer_type:(console.log(new Error("frame configuration passed non-renderer type ".concat(t.constructor.name))),console.log(renderer),!1)},t.exports=o},function(t,e,r){var i=r(39).create();t.exports=i},function(t,e,r){"use strict";t.exports=function(t,e){return function(){for(var r=new Array(arguments.length),i=0;i<r.length;i++)r[i]=arguments[i];return t.apply(e,r)}}},function(t,e,r){"use strict";var i=r(1);function n(t){return encodeURIComponent(t).replace(/%40/gi,"@").replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}t.exports=function(t,e,r){if(!e)return t;var o;if(r)o=r(e);else if(i.isURLSearchParams(e))o=e.toString();else{var s=[];i.forEach(e,(function(t,e){null!=t&&(i.isArray(t)?e+="[]":t=[t],i.forEach(t,(function(t){i.isDate(t)?t=t.toISOString():i.isObject(t)&&(t=JSON.stringify(t)),s.push(n(e)+"="+n(t))})))})),o=s.join("&")}if(o){var a=t.indexOf("#");-1!==a&&(t=t.slice(0,a)),t+=(-1===t.indexOf("?")?"?":"&")+o}return t}},function(t,e,r){"use strict";t.exports=function(t){return!(!t||!t.__CANCEL__)}},function(t,e,r){"use strict";var i=r(1),n=r(45),o={"Content-Type":"application/x-www-form-urlencoded"};function s(t,e){!i.isUndefined(t)&&i.isUndefined(t["Content-Type"])&&(t["Content-Type"]=e)}var a,u={adapter:(("undefined"!=typeof XMLHttpRequest||"undefined"!=typeof process&&"[object process]"===Object.prototype.toString.call(process))&&(a=r(14)),a),transformRequest:[function(t,e){return n(e,"Accept"),n(e,"Content-Type"),i.isFormData(t)||i.isArrayBuffer(t)||i.isBuffer(t)||i.isStream(t)||i.isFile(t)||i.isBlob(t)?t:i.isArrayBufferView(t)?t.buffer:i.isURLSearchParams(t)?(s(e,"application/x-www-form-urlencoded;charset=utf-8"),t.toString()):i.isObject(t)?(s(e,"application/json;charset=utf-8"),JSON.stringify(t)):t}],transformResponse:[function(t){if("string"==typeof t)try{t=JSON.parse(t)}catch(t){}return t}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,validateStatus:function(t){return t>=200&&t<300}};u.headers={common:{Accept:"application/json, text/plain, */*"}},i.forEach(["delete","get","head"],(function(t){u.headers[t]={}})),i.forEach(["post","put","patch"],(function(t){u.headers[t]=i.merge(o)})),t.exports=u},function(t,e,r){"use strict";var i=r(1),n=r(46),o=r(11),s=r(48),a=r(51),u=r(52),h=r(15);t.exports=function(t){return new Promise((function(e,p){var c=t.data,l=t.headers;i.isFormData(c)&&delete l["Content-Type"];var d=new XMLHttpRequest;if(t.auth){var f=t.auth.username||"",y=t.auth.password||"";l.Authorization="Basic "+btoa(f+":"+y)}var m=s(t.baseURL,t.url);if(d.open(t.method.toUpperCase(),o(m,t.params,t.paramsSerializer),!0),d.timeout=t.timeout,d.onreadystatechange=function(){if(d&&4===d.readyState&&(0!==d.status||d.responseURL&&0===d.responseURL.indexOf("file:"))){var r="getAllResponseHeaders"in d?a(d.getAllResponseHeaders()):null,i={data:t.responseType&&"text"!==t.responseType?d.response:d.responseText,status:d.status,statusText:d.statusText,headers:r,config:t,request:d};n(e,p,i),d=null}},d.onabort=function(){d&&(p(h("Request aborted",t,"ECONNABORTED",d)),d=null)},d.onerror=function(){p(h("Network Error",t,null,d)),d=null},d.ontimeout=function(){var e="timeout of "+t.timeout+"ms exceeded";t.timeoutErrorMessage&&(e=t.timeoutErrorMessage),p(h(e,t,"ECONNABORTED",d)),d=null},i.isStandardBrowserEnv()){var g=r(53),v=(t.withCredentials||u(m))&&t.xsrfCookieName?g.read(t.xsrfCookieName):void 0;v&&(l[t.xsrfHeaderName]=v)}if("setRequestHeader"in d&&i.forEach(l,(function(t,e){void 0===c&&"content-type"===e.toLowerCase()?delete l[e]:d.setRequestHeader(e,t)})),i.isUndefined(t.withCredentials)||(d.withCredentials=!!t.withCredentials),t.responseType)try{d.responseType=t.responseType}catch(e){if("json"!==t.responseType)throw e}"function"==typeof t.onDownloadProgress&&d.addEventListener("progress",t.onDownloadProgress),"function"==typeof t.onUploadProgress&&d.upload&&d.upload.addEventListener("progress",t.onUploadProgress),t.cancelToken&&t.cancelToken.promise.then((function(t){d&&(d.abort(),p(t),d=null)})),void 0===c&&(c=null),d.send(c)}))}},function(t,e,r){"use strict";var i=r(47);t.exports=function(t,e,r,n,o){var s=new Error(t);return i(s,e,r,n,o)}},function(t,e,r){"use strict";var i=r(1);t.exports=function(t,e){e=e||{};var r={},n=["url","method","params","data"],o=["headers","auth","proxy"],s=["baseURL","url","transformRequest","transformResponse","paramsSerializer","timeout","withCredentials","adapter","responseType","xsrfCookieName","xsrfHeaderName","onUploadProgress","onDownloadProgress","maxContentLength","validateStatus","maxRedirects","httpAgent","httpsAgent","cancelToken","socketPath"];i.forEach(n,(function(t){void 0!==e[t]&&(r[t]=e[t])})),i.forEach(o,(function(n){i.isObject(e[n])?r[n]=i.deepMerge(t[n],e[n]):void 0!==e[n]?r[n]=e[n]:i.isObject(t[n])?r[n]=i.deepMerge(t[n]):void 0!==t[n]&&(r[n]=t[n])})),i.forEach(s,(function(i){void 0!==e[i]?r[i]=e[i]:void 0!==t[i]&&(r[i]=t[i])}));var a=n.concat(o).concat(s),u=Object.keys(e).filter((function(t){return-1===a.indexOf(t)}));return i.forEach(u,(function(i){void 0!==e[i]?r[i]=e[i]:void 0!==t[i]&&(r[i]=t[i])})),r}},function(t,e,r){"use strict";function i(t){this.message=t}i.prototype.toString=function(){return"Cancel"+(this.message?": "+this.message:"")},i.prototype.__CANCEL__=!0,t.exports=i},function(t,e){function r(t){return(r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function i(t,e){this.vocab=t,this.language=e,this.indent_spaces=4,this.boxed_predicates=["woql:datatype","woql:variable","woql:array_element","woql:variable_list_element","woql:node","woql:arithmetic_value","woql:variable_name"],this.subject_cleaned_predicates=["woql:subject","woql:element"],this.schema_cleaned_predicates=["woql:predicate","woql:parent","woql:child","woql:uri","woql:of_type"],this.list_operators=["ValueList","Array","NamedAsVar","IndexedAsVar","AsVar"],this.query_list_operators=["And","Or"],this.operator_maps={IDGenerator:"idgen",IsA:"isa",PostResource:"post",FileResource:"file",RemoteResource:"remote",AsVars:"as",NamedAsVars:"as",IndexedAsVars:"as"},this.shortcuts={optional:"opt",substring:"substr",regexp:"re",subsumption:"sub",equals:"eq",concatenate:"concat"},this.pythonic={and:"woql_and",or:"woql_or",as:"woql_as",with:"woql_with",from:"woql_from",not:"woql_not"},this.show_context=!1}function n(t){return noparens=["woql:PathPredicate","woql:PathPlus","woql:PathTimes"],-1==noparens.indexOf(t["@type"])}function o(t){for(var e="",r=0;r<t;r++)e+=" ";return e}i.prototype.printJSON=function(t,e,r,i){e=e||0,r=r||!1;var n="";if(!t["@type"])return console.log("Bad structure passed to print json, no type: ",t),"";if("woql:Variable"==t["@type"]||"woql:VariableListElement"==t["@type"])return this.pvar(t);if(void 0!==t["@value"])return this.plit(t);var s=t["@type"].split(":")[1];if(s){var a=this.unboxJSON(s,t);if(a){var u=this.printArgument(s,this.getBoxedPredicate(s,t),a,e,r);return this.isListOperator(s)?"["+u+"]":u}if(this.isListOperator(s))n+="[";else{var h=this.getFunctionForOperator(s),p=i?e*this.indent_spaces:0;n+=this.getWOQLPrelude(h,r,p)+"("}for(var c=this.getArgumentOrder(s,t),l=0;l<c.length;l++){var d="woql:query"==c[l]&&"When"!=s||"woql:consequent"==c[l];n+=this.printArgument(s,c[l],t[c[l]],e,d),l<(-1==c.indexOf("woql:query")?c.length-1:c.length-2)&&(n+=", ")}this.isListOperator(s)?n+="]":(this.argumentTakesNewline(s)&&(n+="\n"+o(e*this.indent_spaces)),r||(n+=")"))}else console.log("wrong structure passed to print json ",t);return n},i.prototype.getArgumentOrder=function(t,e){var r=Object.keys(e);return r.splice(r.indexOf("@type"),1),r},i.prototype.argumentTakesNewline=function(t){return this.isQueryListOperator(t)},i.prototype.argumentRequiresArray=function(t,e){return("woql:group_by"==t||"woql:group_template"==t)&&e.length>1},i.prototype.printArgument=function(t,e,i,n,s){var a="";s&&(a+=")");var u=this.argumentTakesNewline(t);if(u&&(a+="\n"+o((n+1)*this.indent_spaces)),"woql:True"==i["@type"])return"true";if("woql:document"==e)return JSON.stringify(i);if("woql:path_pattern"==e)return'"'+this.decompilePathPattern(i)+'"';if("woql:concat_list"==e)return this.decompileConcatList(i);if("woql:as_vars"==e)return this.decompileAsVars(i,n+1);if(Array.isArray(i)){for(var h=[],p=0;p<i.length;p++){var c=u?n+1:n;h.push(this.printJSON(i[p],c,s,u))}var l=u?",\n"+o(++n*this.indent_spaces):",";this.argumentRequiresArray(e,h)?a+="["+h.join(l)+"]":a+=h.join(l)}else if("object"==r(i)){a+=this.printJSON(i,n,s)}else"string"==typeof i&&(a+=this.uncleanArgument(i,t,e));return a},i.prototype.plit=function(t){if("xsd:string"==t["@type"]||"xsd:anyURI"==t["@type"]||t["@language"]){var e=t["@value"];return/\r|\n/.exec(e)?"`"+e+"`":'"'+e+'"'}return"xsd:decimal"==t["@type"]||"xsd:boolean"==t["@type"]||"xsd:integer"==t["@type"]||"xsd:nonNegativeInteger"==t["@type"]?t["@value"]:JSON.stringify(t)},i.prototype.pvar=function(t){if(t["woql:variable_name"]&&void 0!==t["woql:variable_name"]["@value"]){var e=t["woql:variable_name"]["@value"];return-1==e.indexOf(":")&&(e="v:"+e),'"'+e+'"'}return!1},i.prototype.getWOQLPrelude=function(t,e,r){if("true"===t||"false"===t)return"python"==this.language?t.charAt(0).toUpperCase()+t.slice(1):t;var i="WOQL.";return"python"==this.language&&(this.pythonic[t]&&(t=this.pythonic[t]),i="WOQLQuery()."),e?"."+t:(r?"\n"+o(r):"")+i+t},i.prototype.uncleanArgument=function(t,e,r){if(-1!=t.indexOf(":")){for(var i in this.vocab)if(this.vocab[i]==t)return'"'+i+'"';-1!=this.subject_cleaned_predicates.indexOf(r)&&"doc:"==t.substring(0,4)&&(t=t.substring(4)),-1!=this.schema_cleaned_predicates.indexOf(r)&&"scm:"==t.substring(0,4)&&(t=t.substring(4))}return'"'+t+'"'},i.prototype.isListOperator=function(t){return-1!=this.list_operators.indexOf(t)},i.prototype.isQueryListOperator=function(t){return-1!=this.query_list_operators.indexOf(t)},i.prototype.getFunctionForOperator=function(t){if(this.operator_maps[t])return this.operator_maps[t];var e=t.replace(/[\w]([A-Z])/g,(function(t){return t[0]+"_"+t[1]})).toLowerCase();return this.shortcuts[e]?this.shortcuts[e]:e},i.prototype.getBoxedPredicate=function(t,e){for(var r=0;r<this.boxed_predicates.length;r++)if(e[this.boxed_predicates[r]])return this.boxed_predicates[r];return"QueryListElement"==t&&"woql:query"},i.prototype.unboxJSON=function(t,e){var r=this.getBoxedPredicate(t,e);return!!r&&e[r]},i.prototype.decompileAsVars=function(t,e){for(var r="",i=0;i<t.length;i++){var n=t[i];r+="\n"+o(e*this.indent_spaces)+(0==i?"WOQL":""),"woql:NamedAsVar"==n["@type"]?r+='.as("'+n["woql:identifier"]["@value"]+'", "'+n["woql:variable_name"]["@value"]+'")':"woql:IndexedAsVar"==n["@type"]&&(r+='.as("'+n["woql:index"]["@value"]+'", "'+n["woql:variable_name"]["@value"]+'")')}return r},i.prototype.decompileConcatList=function(t){var e=t["woql:array_element"],r=[];can_concat=!0;for(var i=0;i<e.length;i++){var n=e[i];if(n["woql:datatype"])r.push(n["woql:datatype"]["@value"]);else if(n["woql:variable_name"]&&(r.push("v:"+n["woql:variable_name"]["@value"]),can_concat&&i<e.length-1)){var o=e[i+1];if(o["woql:datatype"]){var s=o["woql:datatype"]["@value"];/^[\w_]/.test(s)&&(can_concat=!1)}}}return can_concat?'"'+r.join("")+'"':'["'+r.join('","')+'"]'},i.prototype.decompilePathPattern=function(t){switch(t["@type"]){case"woql:PathPredicate":return t["woql:path_predicate"]["@id"];case"woql:PathPlus":var e=t["woql:path_pattern"];return Array.isArray(e)&&(e=e[0]),n(e)?"("+this.decompilePathPattern(e)+")+":this.decompilePathPattern(e)+"+";case"woql:PathTimes":e=t["woql:path_pattern"];var r="{"+t["woql:path_minimum"]["@value"]+","+t["woql:path_maximum"]["@value"]+"}";return Array.isArray(e)&&(e=e[0]),n(e)?"("+this.decompilePathPattern(e)+")"+r:this.decompilePathPattern(e)+r;case"woql:PathSequence":var i=t["woql:path_first"],o=t["woql:path_second"];Array.isArray(i)&&(i=i[0]);var s="";return n(i)&&(s+="("),s+=this.decompilePathPattern(i),n(i)&&(s+=")"),s+=",",n(o)&&(s+="("),s+=this.decompilePathPattern(o),n(o)&&(s+=")"),s;case"woql:PathOr":i=t["woql:path_left"],o=t["woql:path_right"];Array.isArray(i)&&(i=i[0]);s="";return n(i)&&(s+="("),s+=this.decompilePathPattern(i),n(i)&&(s+=")"),s+="|",n(o)&&(s+="("),s+=this.decompilePathPattern(o),n(o)&&(s+=")"),s}return"error"},t.exports=i},function(e,r,i){function n(t){return function(t){if(Array.isArray(t))return o(t)}(t)||function(t){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(t))return Array.from(t)}(t)||function(t,e){if(!t)return;if("string"==typeof t)return o(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);"Object"===r&&t.constructor&&(r=t.constructor.name);if("Map"===r||"Set"===r)return Array.from(t);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return o(t,e)}(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function o(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,i=new Array(e);r<e;r++)i[r]=t[r];return i}var s=i(2),a=i(0);function u(t){(new s).graph(t)}s.prototype._sg=function(t){return t||(this.triple_builder_context&&this.triple_builder_context.graph?this.triple_builder_context.graph:"schema/main")},s.prototype.add_class=function(t,e){return e=this._sg(e),t&&(t=this.cleanClass(t,!0),this.add_quad(t,"rdf:type","owl:Class",e),this._set_adding_class(t)),this},s.prototype.insert_class_data=function(t,e){if(e=this._sg(e),t.id)for(var r in c=this.cleanClass(t.id,!0),this.add_class(c,e),t.label&&this.label(t.label),t.description&&this.description(t.description),t.parent&&(Array.isArray(t.parent)||(t.parent=[t.parent]),this.parent.apply(this,n(t.parent))),t)-1==["id","label","description","parent"].indexOf(r)&&(t[r].id=r,t[r].domain=c,this.insert_property_data(t[r],e));return this},s.prototype.insert_doctype_data=function(t,e){return t.parent||(t.parent=[]),Array.isArray(t.parent)||(t.parent=[t.parent]),t.parent.push("Document"),this.insert_class_data(t,e)},s.prototype.add_property=function(t,e,r){return r=this._sg(r),e=e?this.cleanType(e,!0):"xsd:string",r=r||this.graph,t&&(t=this.cleanPathPredicate(t),a.TypeHelper.isDatatype(e)?this.and((new s).add_quad(t,"rdf:type","owl:DatatypeProperty",r),(new s).add_quad(t,"rdfs:range",e,r)):this.and((new s).add_quad(t,"rdf:type","owl:ObjectProperty",r),(new s).add_quad(t,"rdfs:range",e,r)),this.updated()),this},s.prototype.insert_property_data=function(e,r){return r=this._sg(r),e.id&&(p=this.cleanPathPredicate(e.id),t=e.range?this.cleanType(e.range,!0):"xsd:string",this.add_property(p,t,r),e.label&&this.label(e.label),e.description&&this.description(e.description),e.domain&&this.domain(e.domain),e.max&&this.max(e.max),e.min&&this.min(e.min),e.cardinality&&this.cardinality(e.cardinality)),this},s.prototype.delete_class=function(t,e,r){return r=r||"v:Class",t=this.cleanClass(t,!0),this.and((new s).eq(t,r),(new s)._nuke_schema_element(r,e))},s.prototype.delete_property=function(t,e,r){return r=r||"v:Property",t=this.cleanClass(t,!0),this.and((new s).eq(t,r),(new s)._nuke_schema_element(r,e))},s.prototype._nuke_schema_element=function(t,e){t=t||"v:SchemaElement",e=this._sg(e);var r=t+"_pout",i=t+"_vout",n=t+"_pin",o=t+"_sin";return this.and((new s).opt().and((new s).quad(t,r,i,e),(new s).delete_quad(t,r,i,e)),(new s).opt().and((new s).quad(o,n,t,e),(new s).delete_quad(o,n,t,e)))},s.prototype.generateChoiceList=function(t,e,r,i,n,o){var h;n=this._sg(n);var p=[],c="_:"+(-1==t.indexOf(":")?t:t.split(":")[1]),l=c,d=(new u).add_class(t,n).label(e);r&&d.description(r),o&&d.parent(o);for(var f=[d],y=0;y<i.length;y++)if(i[y]){if(Array.isArray(i[y]))var m=i[y][0],g=i[y][1],v=i[y][2]||!1;else m=i[y],g=a.labelFromURL(m),v=!1;var _=(new s).insert(m,t,n).label(g);v&&_.description(v),f.push(_);var w=y<i.length-1?c+"_"+y:"rdf:nil";p.push((new s).add_quad(l,"rdf:first",m,n)),p.push((new s).add_quad(l,"rdf:rest",w,n)),l=w}var b=(h=new s).and.apply(h,[(new s).add_quad(t,"owl:oneOf",c,n)].concat(p));return this.and.apply(this,f.concat([b]))},s.prototype.loadXDD=function(t){return t=this._sg(t),(new s).and(this.addDatatype("xdd:coordinate","Coordinate","A latitude / longitude pair making up a coordinate, encoded as: [lat,long]",t),this.addDatatype("xdd:coordinatePolygon","Coordinate Polygon","A JSON list of [[lat,long]] coordinates forming a closed polygon.",t),this.addDatatype("xdd:coordinatePolyline","Coordinate Polyline","A JSON list of [[lat,long]] coordinates interpreted as a .",t),this.addDatatype("xdd:dateRange","Date Range","A date (YYYY-MM-DD) or an uncertain date range [YYYY-MM-DD1,YYYY-MM-DD2]. Enables uncertainty to be encoded directly in the data",t),this.addDatatype("xdd:decimalRange","Decimal Range","Either a decimal value (e.g. 23.34) or an uncertain range of decimal values (e.g.[23.4, 4.143]. Enables uncertainty to be encoded directly in the data",t),this.addDatatype("xdd:integerRange","Integer Range","Either an integer (e.g. 30) or an uncertain range of integers [28,30]. Enables uncertainty to be encoded directly in the data",t),this.addDatatype("xdd:gYearRange","Year Range","A year (e.g. 1999) or an uncertain range of years: (e.g. [1999,2001]).Enables uncertainty to be encoded directly in the data",t),this.addDatatype("xdd:email","Email","A valid email address",t),this.addDatatype("xdd:html","HTML","A string with embedded HTML",t),this.addDatatype("xdd:json","JSON","A JSON encoded string",t),this.addDatatype("xdd:url","URL","A valid http(s) URL",t))},s.prototype.addDatatype=function(t,e,r,i){i=this._sg(i);var n=this.insert(t,"rdfs:Datatype",i).label(e);return r&&this.description(r),n},s.prototype.loadXSDBoxes=function(t,e,r){return e=this._sg(e),this.and(this.boxDatatype("xsd:anySimpleType","Any Simple Type","Any basic data type such as string or integer. An xsd:anySimpleType value.",t,e,r),this.boxDatatype("xsd:string","String","Any text or sequence of characters",t,e,r),this.boxDatatype("xsd:boolean","Boolean","A true or false value. An xsd:boolean value.",t,e,r),this.boxDatatype("xsd:decimal","Decimal","A decimal number. An xsd:decimal value.",t,e,r),this.boxDatatype("xsd:double","Double","A double-precision decimal number. An xsd:double value.",t,e,r),this.boxDatatype("xsd:float","Float","A floating-point number. An xsd:float value.",t,e,r),this.boxDatatype("xsd:time","Time","A time. An xsd:time value. hh:mm:ss.ssss",t,e,r),this.boxDatatype("xsd:date","Date","A date. An xsd:date value. YYYY-MM-DD",t,e,r),this.boxDatatype("xsd:dateTime","Date Time","A date and time. An xsd:dateTime value.",t,e,r),this.boxDatatype("xsd:dateTimeStamp","Date-Time Stamp","An xsd:dateTimeStamp value.",t,e,r),this.boxDatatype("xsd:gYear","Year"," A particular 4 digit year YYYY - negative years are BCE.",t,e,r),this.boxDatatype("xsd:gMonth","Month","A particular month. An xsd:gMonth value. --MM",t,e,r),this.boxDatatype("xsd:gDay","Day","A particular day. An xsd:gDay value. ---DD",t,e,r),this.boxDatatype("xsd:gYearMonth","Year / Month","A year and a month. An xsd:gYearMonth value.",t,e,r),this.boxDatatype("xsd:gMonthDay","Month / Day","A month and a day. An xsd:gMonthDay value.",t,e,r),this.boxDatatype("xsd:duration","Duration","A period of time. An xsd:duration value.",t,e,r),this.boxDatatype("xsd:yearMonthDuration","Year / Month Duration","A duration measured in years and months. An xsd:yearMonthDuration value.",t,e,r),this.boxDatatype("xsd:dayTimeDuration","Day / Time Duration","A duration measured in days and time. An xsd:dayTimeDuration value.",t,e,r),this.boxDatatype("xsd:byte","Byte","An xsd:byte value.",t,e,r),this.boxDatatype("xsd:short","Short","An xsd:short value.",t,e,r),this.boxDatatype("xsd:integer","Integer","A simple number. An xsd:integer value.",t,e,r),this.boxDatatype("xsd:long","Long","An xsd:long value.",t,e,r),this.boxDatatype("xsd:unsignedByte","Unsigned Byte","An xsd:unsignedByte value.",t,e,r),this.boxDatatype("xsd:unsignedInt","Unsigned Integer","An xsd:unsignedInt value.",t,e,r),this.boxDatatype("xsd:unsignedLong","Unsigned Long Integer","An xsd:unsignedLong value.",t,e,r),this.boxDatatype("xsd:positiveInteger","Positive Integer","A simple number greater than 0. An xsd:positiveInteger value.",t,e,r),this.boxDatatype("xsd:nonNegativeInteger","Non-Negative Integer","A simple number that can't be less than 0. An xsd:nonNegativeInteger value.",t,e,r),this.boxDatatype("xsd:negativeInteger","Negative Integer","A negative integer. An xsd:negativeInteger value.",t,e,r),this.boxDatatype("xsd:nonPositiveInteger","Non-Positive Integer","A number less than or equal to zero. An xsd:nonPositiveInteger value.",t,e,r),this.boxDatatype("xsd:base64Binary","Base 64 Binary","An xsd:base64Binary value.",t,e,r),this.boxDatatype("xsd:anyURI","Any URI","Any URl. An xsd:anyURI value.",t,e,r),this.boxDatatype("xsd:language","Language","A natural language identifier as defined by by [RFC 3066] . An xsd:language value.",t,e,r),this.boxDatatype("xsd:normalizedString","Normalized String","An xsd:normalizedString value.",t,e,r),this.boxDatatype("xsd:token","Token","An xsd:token value.",t,e,r),this.boxDatatype("xsd:NMTOKEN","NMTOKEN","An xsd:NMTOKEN value.",t,e,r),this.boxDatatype("xsd:Name","Name","An xsd:Name value.",t,e,r),this.boxDatatype("xsd:NCName","NCName","An xsd:NCName value.",t,e,r),this.boxDatatype("xsd:NOTATION","NOTATION","An xsd:NOTATION value.",t,e,r),this.boxDatatype("xsd:QName","QName","An xsd:QName value.",t,e,r),this.boxDatatype("xsd:ID","ID","An xsd:ID value.",t,e,r),this.boxDatatype("xsd:IDREF","IDREF","An xsd:IDREF value.",t,e,r),this.boxDatatype("xsd:ENTITY","ENTITY","An xsd:ENTITY value.",t,e,r))},s.prototype.loadXDDBoxes=function(t,e,r){return e=this._sg(e),(new s).and(this.boxDatatype("xdd:coordinate","Coordinate","A particular location on the surface of the earth, defined by latitude and longitude . An xdd:coordinate value.",t,e,r),this.boxDatatype("xdd:coordinatePolygon","Geographic Area","A shape on a map which defines an area. within the defined set of coordinates An xdd:coordinatePolygon value.",t,e,r),this.boxDatatype("xdd:coordinatePolyline","Coordinate Path","A set of coordinates forming a line on a map, representing a route. An xdd:coordinatePolyline value.",t,e,r),this.boxDatatype("xdd:url","URL","A valid url.",t,e,r),this.boxDatatype("xdd:email","Email","A valid email address.",t,e,r),this.boxDatatype("xdd:html","HTML","A safe HTML string",t,e,r),this.boxDatatype("xdd:json","JSON","A JSON Encoded String"),this.boxDatatype("xdd:gYearRange","Year","A 4-digit year, YYYY, or if uncertain, a range of years. An xdd:gYearRange value.",t,e,r),this.boxDatatype("xdd:integerRange","Integer","A simple number or range of numbers. An xdd:integerRange value.",t,e,r),this.boxDatatype("xdd:decimalRange","Decimal Number","A decimal value or, if uncertain, a range of decimal values. An xdd:decimalRange value.",t,e,r),this.boxDatatype("xdd:dateRange","Date Range","A date or a range of dates YYYY-MM-DD",t,e,r))},s.prototype.boxDatatype=function(t,e,r,i,n,o){n=this._sg(n),o=o||"scm:";var a=t.split(":")[1],u=o+a.charAt(0).toUpperCase()+a.slice(1),h=o+a.charAt(0).toLowerCase()+a.slice(1),p=(new s).add_class(u,n).label(e);p.description("Boxed Class for "+t),i&&p.parent(i);var c=(new s).add_property(h,t,n).label(e).domain(u);return r&&c.description(r),this.and(p,c)},s.prototype.libs=function(t,e,r,i){var n=[];return-1!=t.indexOf("xdd")?(n.push((new s).loadXDD(r)),-1!=t.indexOf("box")&&(n.push((new s).loadXDDBoxes(e,r,i)),n.push((new s).loadXSDBoxes(e,r,i)))):-1!=t.indexOf("box")&&n.push((new s).loadXSDBoxes(e,r,i)),n.length>1?this.and.apply(this,n):n[0]},s.prototype.boxClasses=function(t,e,r,i){var n;i=i||this.graph,t=t||"scm:";for(var o=[],a=0;a<e.length;a++)o.push((new s).sub(e[a],"v:Cid"));var h=[];for(a=0;a<r.length;a++)h.push((new s).not().sub(r[a],"v:Cid"));var p,c,l=[(new s).re("#(.)(.*)","v:Cid",["v:AllB","v:FirstB","v:RestB"]),(new s).lower("v:FirstB","v:Lower"),(new s).concat(["v:Lower","v:RestB"],"v:Propname"),(new s).concat(["Scoped","v:FirstB","v:RestB"],"v:Cname"),(new s).idgen(t,["v:Cname"],"v:ClassID"),(new s).idgen(t,["v:Propname"],"v:PropID")],d=(new s).and((new s).quad("v:Cid","rdf:type","owl:Class",i),(new s).not().node("v:Cid").abstract(i),(n=new s).and.apply(n,l),(new s).quad("v:Cid","label","v:Label",i),(new s).concat("Box Class generated for class v:Cid","v:CDesc",i),(new s).concat("Box Property generated to link box v:ClassID to class v:Cid","v:PDesc",i));o.length&&(1==o.length?d.and(o[0]):d.and((p=new s).or.apply(p,o)));h.length&&d.and((c=new s).and.apply(c,h));var f=new u(i).add_class("v:ClassID").label("v:Label").description("v:CDesc"),y=new u(i).add_property("v:PropID","v:Cid").label("v:Label").description("v:PDesc").domain("v:ClassID");return(new s).when(d).and(f,y).updated()},e.exports=u},function(t,e,r){function i(t){return(i="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function n(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){if("undefined"==typeof Symbol||!(Symbol.iterator in Object(t)))return;var r=[],i=!0,n=!1,o=void 0;try{for(var s,a=t[Symbol.iterator]();!(i=(s=a.next()).done)&&(r.push(s.value),!e||r.length!==e);i=!0);}catch(t){n=!0,o=t}finally{try{i||null==a.return||a.return()}finally{if(n)throw o}}return r}(t,e)||s(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function o(t){return function(t){if(Array.isArray(t))return a(t)}(t)||function(t){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(t))return Array.from(t)}(t)||s(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function s(t,e){if(t){if("string"==typeof t)return a(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?a(t,e):void 0}}function a(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,i=new Array(e);r<e;r++)i[r]=t[r];return i}var u=r(2);r(5);function h(t){this.mode=t||"query",this.user_variables=[],this.user_values=[],this.default_variables=[],this.parameters=[],this.default_schema_resource="schema/main",this.default_commit_resource="_commits",this.default_meta_resource="_meta",this.masterdb_resource="_system",this.empty=""}function p(t){for(var e=[],r=0;r<t.length;r++)e.push({prefix:t[r][0]["@value"],url:t[r][1]["@value"]});return e}function c(t){for(var e=[],r={updated:0},i=0;i<t.length;i++)e.push({branch:t[i][0]["@value"],head:t[i][1]["@value"],updated:t[i][2]["@value"]}),t[i][2]["@value"]>r.updated&&(r.updated=t[i][2]["@value"],r.author=t[i][3]["@value"],r.message=t[i][4]["@value"]);return r.branches=e,r}h.prototype.classes=function(t,e,r){var i,n=r||this.default_schema_resource;this.default_variables=["Class ID","Class Name","Description","Parents","Children","Abstract","Parent","Child"],e&&this._set_user_variables(e);var s=this._get_varlist().slice(0,6),a=(i=new u).select.apply(i,o(s)).and((new u).quad(this._varn("Class ID"),"type","owl:Class",n),(new u).limit(1).or((new u).quad(this._varn("Class ID"),"comment",this._varn("Description"),n),(new u).eq(this._varn("Description"),this.empty)),(new u).limit(1).or((new u).quad(this._varn("Class ID"),"label",this._varn("Class Name"),n),(new u).eq(this._varn("Class Name"),"")),(new u).limit(1).or((new u).quad(this._varn("Class ID"),"system:tag","system:abstract",n).eq(this._varn("Abstract"),"Yes"),(new u).eq(this._varn("Abstract"),"No")),(new u).limit(1).or((new u).group_by(this._varn("Class ID"),this._varn("Parent"),this._varn("Parents")).and((new u).quad(this._varn("Class ID"),"subClassOf",this._varn("Parent"),n),(new u).or((new u).eq(this._varn("Parent"),this._docroot()),(new u).quad(this._varn("Parent"),"type","owl:Class",n))),(new u).eq(this._varn("Parents"),"")),(new u).limit(1).or((new u).group_by(this._varn("Class ID"),this._varn("Child"),this._varn("Children")).and((new u).quad(this._varn("Child"),"subClassOf",this._varn("Class ID"),n),(new u).quad(this._varn("Child"),"type","owl:Class",n)),(new u).eq(this._varn("Children"),"")));return this._add_constraints(a,t)},h.prototype.properties=function(t,e,r){var i,n=r||this.default_schema_resource;this.default_variables=["Property ID","Property Name","Property Domain","Property Type","Property Range","Property Description","OWL Type"],e&&this._set_user_variables(e);var s=this._get_varlist().slice(0,6),a=(i=new u).select.apply(i,o(s)).and((new u).quad(this._varn("Property ID"),"type",this._varn("OWL Type"),n).quad(this._varn("Property ID"),"domain",this._varn("Property Domain"),n).quad(this._varn("Property ID"),"range",this._varn("Property Range"),n),(new u).limit(1).or((new u).eq(this._varn("OWL Type"),"owl:DatatypeProperty").eq(this._varn("Property Type"),"Data"),(new u).eq(this._varn("OWL Type"),"owl:ObjectProperty").eq(this._varn("Property Type"),"Object")),(new u).limit(1).or((new u).quad(this._varn("Property ID"),"label",this._varn("Property Name"),n),(new u).eq(this._varn("Property Name"),"")),(new u).limit(1).or((new u).quad(this._varn("Property ID"),"comment",this._varn("Property Description"),n),(new u).eq(this._varn("Property Description"),"")));return this._add_constraints(a,t)},h.prototype.graphs=function(t,e,r){r=r||this.default_commit_resource,this.default_variables=["Graph ID","Graph Type","Branch ID","Commit ID","Graph IRI","Branch IRI","Commit IRI"],e&&this._set_user_variables(e);var i=(new u).and((new u).triple(this._varn("Graph IRI"),"ref:graph_name",this._varn("Graph ID")),(new u).or((new u).triple(this._varn("Commit IRI"),"ref:instance",this._varn("Graph IRI")).eq(this._varn("Graph Type"),"instance"),(new u).triple(this._varn("Commit IRI"),"ref:schema",this._varn("Graph IRI")).eq(this._varn("Graph Type"),"schema"),(new u).triple(this._varn("Commit IRI"),"ref:inference",this._varn("Graph IRI")).eq(this._varn("Graph Type"),"inference")),(new u).triple(this._varn("Commit IRI"),"ref:commit_id",this._varn("Commit ID")),(new u).limit(1).or((new u).triple(this._varn("Branch IRI"),"ref:ref_commit",this._varn("Commit IRI")).triple(this._varn("Branch IRI"),"ref:branch_name",this._varn("Branch ID")),(new u).eq(this._varn("Branch IRI"),"").eq(this._varn("Branch ID"),""))),n=this._add_constraints(i,t);return(new u).using(r,n)},h.prototype.branches=function(t,e,r){r=r||this.default_commit_resource,this.default_variables=["Branch ID","Time","Commit ID","Branch IRI","Commit IRI"],e&&this._set_user_variables(e);var i=(new u).triple(this._varn("Branch IRI"),"ref:branch_name",this._varn("Branch ID")).opt().triple(this._varn("Branch IRI"),"ref:ref_commit",this._varn("Commit IRI")).triple(this._varn("Commit IRI"),"ref:commit_id",this._varn("Commit ID")).triple(this._varn("Commit IRI"),"ref:commit_timestamp",this._varn("Time")),n=this._add_constraints(i,t);return(new u).using(r,n)},h.prototype.objects=function(t,e){this.default_variables=["Object Type","Object ID"],e&&this._set_user_variables(e);var r=(new u).triple(this._varn("Object ID"),"type",this._varn("Object Type"));return this._add_constraints(r,t)},h.prototype.property_values=function(t,e){var r;this.default_variables=["Object ID","Property ID","Property Value","Value ID","Value Class","Any Class"],e&&this._set_user_variables(e);var i=this._get_varlist().slice(0,5),n=(r=new u).select.apply(r,o(i)).or((new u).triple(this._varn("Object ID"),this._varn("Property ID"),this._varn("Value ID")).triple(this._varn("Value ID"),"type",this._varn("Value Class")).read_object(this._varn("Value ID"),this._varn("Property Value")).comment("If the value of the property has a type, that means it is an object property and we retrieve the full object as the property value"),(new u).triple(this._varn("Object ID"),this._varn("Property ID"),this._varn("Property Value")).not().triple(this._varn("Property Value"),"type",this._varn("Any Class")).comment("If the value of the property has no type, that means it is a datatype property and we retrieve the datatype value as usual"));return this._add_constraints(n,t)},h.prototype.object_metadata=function(t,e,r){var i=r||this.default_schema_resource;this.default_variables=["Object ID","Name","Description","Type ID","Type Name","Type Description"],e&&this._set_user_variables(e);var n=(new u).triple(this._varn("Object ID"),"type",this._varn("Type ID")).and((new u).limit(1).or((new u).triple(this._varn("Object ID"),"label",this._varn("Name")),(new u).eq(this._varn("Name"),this.empty)),(new u).limit(1).or((new u).triple(this._varn("Object ID"),"comment",this._varn("Description")),(new u).eq(this._varn("Description"),this.empty)),(new u).limit(1).or((new u).quad(this._varn("Type ID"),"label",this._varn("Type Name"),i),(new u).eq(this._varn("Type Name"),this.empty)),(new u).limit(1).or((new u).quad(this._varn("Type ID"),"comment",this._varn("Type Description"),i),(new u).eq(this._varn("Type Description"),this.empty))).comment("Returns an object(s) with its id, name and descriptions, and the object type, type id and type description");return this._add_constraints(n,t)},h.prototype.property_metadata=function(t,e,r){var i=r||this.default_schema_resource;this.default_variables=["Object ID","Property ID","Property Name","Property Value","Property Description"],e&&this._set_user_variables(e);var n=(new u).triple(this._varn("Object ID"),this._varn("Property ID"),this._varn("Property Value")).limit(1).or((new u).quad(this._varn("Property ID"),"label",this._varn("Property Name"),i),(new u).eq(this._varn("Property Name"),this.empty)).limit(1).or((new u).quad(this._varn("Property ID"),"comment",this._varn("Property Description"),i),(new u).eq(this._varn("Property Description"),this.empty)).comment("Returns a property and its value and the basic metadata associated with the property (name, id, description)");return this._add_constraints(n,t)},h.prototype.commits=function(t,e,r){r=r||this.default_commit_resource,this.default_variables=["Commit ID","Commit IRI","Time","Author","Message","Parent ID","Parent IRI","Children","Child ID","Child IRI","Branch IRI","Branch ID"],e&&this._set_user_variables(e);var i=(new u).order_by(this._varn("Time"),"desc").triple(this._varn("Commit IRI"),"ref:commit_id",this._varn("Commit ID")).triple(this._varn("Commit IRI"),"ref:commit_timestamp",this._varn("Time")).limit(1).or((new u).triple(this._varn("Commit IRI"),"ref:commit_author",this._varn("Author")),(new u).eq(this._varn("Author"),this.empty)).limit(1).or((new u).triple(this._varn("Commit IRI"),"ref:commit_message",this._varn("Message")),(new u).eq(this._varn("Message"),this.empty)).limit(1).or((new u).triple(this._varn("Commit IRI"),"ref:commit_parent",this._varn("Parent IRI")).triple(this._varn("Parent IRI"),"ref:commit_id",this._varn("Parent ID")),(new u).eq(this._varn("Parent IRI"),this.empty).eq(this._varn("Parent ID"),this.empty)).limit(1).or((new u).select(this._varn("Children")).group_by([this._varn("Commit IRI"),this._varn("Child IRI")],this._varn("Child ID"),this._varn("Children")).triple(this._varn("Child IRI"),"ref:commit_parent",this._varn("Commit IRI")).triple(this._varn("Child IRI"),"ref:commit_id",this._varn("Child ID")),(new u).eq(this._varn("Children"),this.empty)).limit(1).or((new u).triple(this._varn("Branch IRI"),"ref:ref_commit",this._varn("Commit IRI")).triple(this._varn("Branch IRI"),"ref:branch_name",this._varn("Branch ID")),(new u).eq(this._varn("Branch IRI"),this.empty).eq(this._varn("Branch ID"),this.empty)),n=this._add_constraints(i,t);return(new u).using(r,n)},h.prototype.commit_chain=function(t,e,r){r=r||this.default_commit_resource,this.default_variables=["Head IRI","Tail IRI","Path"],e&&this._set_user_variables(e);var i=(new u).path(this._varn("Head IRI"),"ref:commit_parent+",this._varn("Tail IRI"),this._varn("Path")),n=this._add_constraints(i,t);return(new u).using(r,n)},h.prototype.repos=function(t,e,r){r=r||this.default_meta_resource,this.default_variables=["Repository IRI","Repository Name","Repository Type","Remote URL","Repository Head IRI"],e&&this._set_user_variables(e);var i=(new u).and((new u).triple(this._varn("Repository IRI"),"repo:repository_name",this._varn("Repository Name")).triple(this._varn("Repository IRI"),"type",this._varn("Repository Type")),(new u).opt().triple(this._varn("Repository IRI"),"repo:repository_head",this._varn("Repository Head IRI")),(new u).or((new u).eq(this._varn("Repository Type"),"repo:Local"),(new u).eq(this._varn("Repository Type"),"repo:Remote").triple(this._varn("Repository IRI"),"repo:remote_url",this._varn("Remote URL")))),n=this._add_constraints(i,t);return(new u).using(r,n)},h.prototype.dbs=function(t,e){this.default_variables=["DB Name","DB ID","Organization","Description","DB IRI","Organization IRI"],e&&this._set_user_variables(e);var r=(new u).and((new u).triple(this._varn("DB IRI"),"type","system:Database").triple(this._varn("DB IRI"),"system:resource_name",this._varn("DB ID")).triple(this._varn("Organization IRI"),"system:organization_database",this._varn("DB IRI")).triple(this._varn("Organization IRI"),"system:organization_name",this._varn("Organization")).and((new u).limit(1).or((new u).triple(this._varn("DB IRI"),"label",this._varn("DB Name")),(new u).eq(this._varn("DB Name"),this.empty)),(new u).limit(1).or((new u).triple(this._varn("DB IRI"),"comment",this._varn("Description")),(new u).eq(this._varn("Description"),this.empty)))),i=this._add_constraints(r,t);return(new u).using(this.masterdb_resource,i)},h.prototype.prefixes=function(t,e,r){r=r||this.default_commit_resource,this.default_variables=["Prefix","IRI","Prefix Pair IRI"],e&&this._set_user_variables(e);var i=(new u).triple("ref:default_prefixes","ref:prefix_pair",this._varn("Prefix Pair IRI")).triple(this._varn("Prefix Pair IRI"),"ref:prefix_uri",this._varn("IRI")).triple(this._varn("Prefix Pair IRI"),"ref:prefix",this._varn("Prefix")),n=this._add_constraints(i,t);return(new u).using(r,n)},h.prototype.insert_prefix=function(t,e,r){return r=r||this.default_commit_resource,this.default_variables=["Prefix Pair IRI"],e&&this._set_user_variables(e),(new u).using(r).idgen("terminusdb://repository/data/PrefixPair",t[0],this._varn("Prefix Pair IRI")).add_triple("ref:default_prefixes","ref:prefix_pair",this._varn("Prefix Pair IRI")).insert(this._varn("Prefix Pair IRI"),"ref:PrefixPair").property("ref:prefix",t[0]).property("ref:prefix_uri",t[1])},h.prototype.create_prefix=function(t,e,r){r=r||this.default_commit_resource;var i=n(this.vars("Prefix Pair IRI"),1)[0];return(new u).using(r).idgen("terminusdb://repository/data/PrefixPair",t,i).add_triple("ref:default_prefixes","ref:prefix_pair",i).insert(i,"ref:PrefixPair").property("ref:prefix",t).property("ref:prefix_uri",e)},h.prototype.delete_prefix=function(t,e){e=e||this.default_commit_resource;var r=n(this.vars("Prefix Pair IRI","Any Property IRI","Any Value"),3),i=r[0],o=r[1],s=r[2];return(new u).using(e).triple(i,"ref:prefix",t).triple(i,o,s).delete_triple("ref:default_prefixes","ref:prefix_pair",i).delete_triple(i,o,s)},h.prototype.update_prefix=function(t,e,r){r=r||this.default_commit_resource;var i=n(this.vars("Prefix Pair IRI","Prefix IRI"),2),o=i[0],s=i[1];return(new u).using(r).triple(o,"ref:prefix",t).triple(o,"ref:prefix_uri",s).delete_triple(o,"ref:prefix_uri",s).add_triple(o,"ref:prefix_uri",e)},h.prototype.document_classes=function(t,e,r){var i=this.classes(t,e,r);return this._add_doctype_constraint(i,this._varn("Class ID"))},h.prototype.commit_chain_full=function(t,e){cresource=e||this.default_commit_resource;var r=(new u).or((new u).and((new u).lib().commit_chain(void 0,["Commit IRI"]),(new u).lib().commits()),(new u).and((new u).lib().commit_chain(void 0,["Head IRI","Commit IRI"]),(new u).lib().commits())),i=this._add_constraints(r,t);return(new u).using(cresource,i)},h.prototype.concrete_document_classes=function(t,e,r){var i=this.document_classes(t,e,r),n=r||this.default_schema_resource;return this._add_constraint(i,(new u).not().quad(this._varn("Document IRI"),"system:tag","system:abstract",n).comment("Does not match document class(es) marked as abstract"))},h.prototype.document_metadata=function(t,e,r){e||(e=[]),e[0]="Document ID";var i=this.object_metadata(t,e,r);return this._add_doctype_constraint(i,this._varn("Type ID"))},h.prototype.documents=function(t,e){e||(e=["Document Type","Document ID"]);var r=this.objects(t,e);return this._add_constraints(r,t)},h.prototype.first_commit=function(){var t=this.commits(),e=(new u).using("_commits").and((new u).triple(this._varn("Any Commit IRI"),"ref:commit_id",this._varn("Commit ID")),(new u).not().triple(this._varn("Any Commit IRI"),"ref:commit_parent",this._varn("Parent IRI")));return this._add_constraint(t,e)},h.prototype.vars=function(){for(var t=arguments.length,e=new Array(t),r=0;r<t;r++)e[r]=arguments[r];return e.map((function(t){return"v:"+t}))},h.prototype.active_commit=function(t,e){return(new u).limit(1).and((new u).lib().active_commit_id(t,e),(new u).lib().commits())},h.prototype.commit_history=function(t,e){return(new u).and((new u).lib().history_ids(t,e),(new u).lib().commits())},h.prototype.previous_commits=function(t,e){return(new u).and((new u).lib().previous_commit_ids(t,e),(new u).lib().commits())},h.prototype.commit_future=function(t,e,r){return(new u).and((new u).lib().future_ids(t,e,r),(new u).lib().commits())},h.prototype.commit_timeline=function(t,e,r,i){return r=r||10,i=i||r,(new u).order_by("v:Time","desc").or(this.commit_future(t,e,i+1),this.previous_commits(t,r))},h.prototype.next_commits=function(t,e,r){return(new u).and((new u).lib().next_commit_ids(t,e,r),(new u).lib().commits())},h.prototype.active_commit_id=function(t,e,r){r=r||"Commit ID",e=e||Date.now()/1e3;var i=n(this.vars("My Branch IRI","My Head IRI","My Child IRI","Commit Path","My Child Timestamp","My Tail IRI","My Tail Timestamp",r,"My Head TS"),9),o=i[0],s=i[1],a=i[2],h=i[3],p=i[4],c=i[5],l=i[6],d=i[7],f=i[8];return(new u).using("_commits").limit(1).select(d).triple(o,"ref:branch_name",t).triple(o,"ref:ref_commit",s).or((new u).triple(s,"ref:commit_timestamp",f).triple(s,"ref:commit_id",d).not().greater(f,e),(new u).or((new u).path(s,"ref:commit_parent+",a,h).triple(a,"ref:commit_parent",c),(new u).triple(a,"ref:commit_parent",c)).triple(a,"ref:commit_timestamp",p).triple(c,"ref:commit_timestamp",l).triple(c,"ref:commit_id",d).greater(p,e).not().greater(l,e))},h.prototype.history_ids=function(t,e,r){e=e||10,r=r||"Commit ID";var i=n(this.vars("My Head IRI","Commit Path","My Tail IRI",r),4),o=i[0],s=i[1],a=i[2],h=i[3];return(new u).using("_commits").select(h).limit(e).triple(o,"ref:commit_id",t).or((new u).eq(h,t),(new u).path(o,"ref:commit_parent+",a,s).triple(a,"ref:commit_id",h).not().eq(h,t))},h.prototype.future_ids=function(t,e,r,i){r=r||10,i=i||"Commit ID";var o=n(this.vars("My Branch IRI","My Head IRI","My Child IRI","Branch Path","Commit Path","My Tail IRI",i),7),s=o[0],a=o[1],h=o[2],p=o[3],c=o[4],l=o[5],d=o[6];return(new u).using("_commits").limit(r).select(d).triple(l,"ref:commit_id",t).triple(s,"ref:branch_name",e).triple(s,"ref:ref_commit",a).triple(h,"ref:commit_id",d).or((new u).eq(d,t),(new u).path(h,"ref:commit_parent+",l,c).or((new u).path(a,"ref:commit_parent+",h,p),(new u).eq(a,h)).not().eq(d,t))},h.prototype.next_commit_ids=function(t,e,r,i){r=r||1,i=i||"Commit ID";var o=n(this.vars("My Branch IRI","My Head IRI","My Child IRI","Branch Path","Commit Path","My Tail IRI",i),7),s=o[0],a=o[1],h=o[2],p=o[3],c=o[4],l=o[5],d=o[6];return(new u).using("_commits").limit(r).select(d).triple(l,"ref:commit_id",t).triple(s,"ref:branch_name",e).triple(s,"ref:ref_commit",a).triple(h,"ref:commit_id",d).path(h,"ref:commit_parent+",l,c).or((new u).path(a,"ref:commit_parent+",h,p),(new u).eq(a,h))},h.prototype.previous_commit_ids=function(t,e,r){r=r||"Commit ID",e=e||1;var i=n(this.vars("My Head IRI","Commit Path","My Tail IRI",r),4),o=i[0],s=i[1],a=i[2],h=i[3];return(new u).using("_commits").select(h).limit(e).triple(o,"ref:commit_id",t).path(o,"ref:commit_parent+",a,s).triple(a,"ref:commit_id",h)},h.prototype._add_constraints=function(t,e){if(!e)return t;if(Array.isArray(e)){for(var r=new u,n=0;n<e.length;n++)void 0!==e[n]&&r.and((new u).eq(e[n],this._var(n)));return this._add_constraint(t,r)}if("object"==i(e)){if(e.json)return this._add_constraint(t,e);var o=this._get_varlist(),s=new u;for(var a in e){var h=o.indexOf(a);-1!=h&&s.and((new u).eq(e[a],this._var(h)))}return this._add_constraint(t,s)}return this._add_constraint(t,(new u).eq(this._var(0),e))},h.prototype._add_constraint=function(t,e){return(new u).and(e,t)},h.prototype._set_user_variables=function(t){this.user_variables=t},h.prototype._var=function(t){return"v:"+(this.user_variables[t]?this.user_variables[t]:this.default_variables[t])},h.prototype._varn=function(t){return this._var(this.default_variables.indexOf(t))},h.prototype._get_varlist=function(){for(var t=[],e=0;e<this.default_variables.length;e++)this.user_variables[e]?t.push(this.user_variables[e]):t.push(this.default_variables[e]);return t},h.prototype._get_meta=function(t){var e={variables:this._get_varlist(),default_variables:this.default_variables,query:t.json()};return this.user_variables&&(e.user_variables=this.user_variables),this.user_values&&(e.user_values=this.user_value),e},h.prototype._docroot=function(){return"system:Document"},h.prototype._add_doctype_constraint=function(t,e){return this._add_constraint(t,(new u).sub(this._docroot(),e).comment("Only matches classes subsumed by system:Document class"))},h.prototype.add_multiple=function(t,e,r,i,n,o){var s=new u;return vars=e.map((function(t,e){nvarlist=r.map((function(t){return t+"_"+e})),s.and(i(t,nvarlist,n))})),t.query(s,o).then((function(t){var e=[];if(t&&t.bindings&&t.bindings.length)for(var r=0;r<t.bindings.length;r++)for(var i in t.bindings[r])if(t.bindings[r][i]){var n=i.substring(0,i.lastIndexOf("_")),o=i.substring(i.lastIndexOf("_")+1);e[o]||(e[o]={}),e[o][n]=t.bindings[r][i]}return e}))},h.prototype.asset_overview=function(t,e,r){var i,o=new u,s=t+"/local/_commits",a=t+"/_meta",h=n(e,20),p=h[0],c=h[1],l=h[2],d=h[3],f=h[4],y=h[5],m=h[6],g=h[7],v=h[8],_=h[9],w=h[10],b=h[11],q=h[12],x=h[13],O=h[14],R=h[15],A=h[16],I=h[17],C=h[18],j=h[19],P=[];return P.push((new u).opt().limit(1).triple(l,"ref:schema",d)),P.push((new u).opt().group_by(f,[f,y],g).triple("ref:default_prefixes","ref:prefix_pair",m).triple(m,"ref:prefix",f).triple(m,"ref:prefix_uri",y)),P.push((new u).opt().group_by(_,[_,b,q,x,O],R).triple(v,"ref:branch_name",_).triple(v,"ref:ref_commit",w).triple(w,"ref:commit_id",b).triple(w,"ref:commit_timestamp",q).triple(w,"ref:commit_author",x).triple(w,"ref:commit_message",O)),P.push((new u).opt().limit(1).triple(A,"ref:commit_timestamp",C).not().triple(A,"ref:commit_parent",I)),o.and((new u).using(a).opt().limit(1).triple(p,"repo:remote_url",c),(i=(new u).using(s)).and.apply(i,P)),r&&o.and((new u).using(t).size(t,j)),o},h.prototype.assets_overview=function(t,e,r){return this.add_multiple(e,t,["v:RemoteIRI","v:remote_url","v:AnyCommit","v:schema","v:prefix","v:prefix_URI","v:PrefixPairIRI","v:prefixes","v:BranchIRI","v:branch","v:BranchHeadIRI","v:branch_head","v:branch_time","v:author","v:message","v:branches","v:FirstCommitIRI","v:NoParent","v:created","v:size"],this.asset_overview,r).then((function(e){for(var r=[],i=0;i<t.length;i++){var n={organization:t[i].substring(0,t[i].lastIndexOf("/")),id:t[i].substring(t[i].lastIndexOf("/")+1)};"/"==n.organization[0]&&(n.organization=n.organization.substring(1));var o=e[i];if(o){if(o.branches&&"system:unknown"!=o.branches)for(var s in mbranches=c(o.branches),mbranches)n[s]=mbranches[s];o.created&&o.created["@value"]&&(n.created=o.created["@value"]),o.remote_url&&o.remote_url["@value"]&&(n.remote_url=o.remote_url["@value"]),o.schema&&"system:unknown"!=o.schema&&(n.schema=!0),o.size&&o.size["@value"]&&(n.size=o.size["@value"]),o.prefixes&&"system:unknown"!=o.prefixes&&(n.prefixes=p(o.prefixes))}r.push(n)}return r}))},h.prototype.delete_remote=function(t,e){return e=e||"origin",riri="terminusdb:///repository/data/Remote_"+e,(new u).using(t).into("instance/main").and((new u).triple(riri,"type","repo:Remote").triple(riri,"v:all_props","v:all_vals").delete_triple(riri,"v:all_props","v:all_vals"))},h.prototype.add_remote=function(t,e,r){return r=r||"origin",riri="terminusdb:///repository/data/Remote_"+r,(new u).using(t).into("instance/main").and((new u).add_triple(riri,"type","repo:Remote").add_triple(riri,"repo:repository_name",r).add_triple(riri,"repo:remote_url",{"@type":"xdd:url","@value":e}))},h.prototype.user_roles=function(t,e){this.roles(!1,e);this.default_variables.push("User IRI"),this.default_variables.push("User ID"),e&&this._set_user_variables(e);var r=(new u).triple(this._varn("User IRI"),"system:agent_name",this._varn("User ID")).triple(this._varn("User IRI"),"system:role",this._varn("Role IRI"));return(new u).lib().roles(r,e)},h.prototype.users=function(t,e){var r;this.default_variables=["User ID","Display Name","Commit Log ID","User Notes","Roles","User IRI","Role IRI"],e&&this._set_user_variables(e);var i=this._get_varlist().slice(0,6),n=(r=new u).select.apply(r,o(i)).and((new u).triple(this._varn("User IRI"),"type","system:User").triple(this._varn("User IRI"),"system:agent_name",this._varn("User ID")).and((new u).limit(1).or((new u).triple(this._varn("User IRI"),"label",this._varn("Display Name")),(new u).eq(this._varn("Display Name"),this.empty)),(new u).limit(1).or((new u).triple(this._varn("User IRI"),"system:user_identifier",this._varn("Commit Log ID")),(new u).eq(this._varn("Commit Log ID"),this.empty)),(new u).limit(1).or((new u).triple(this._varn("User IRI"),"comment",this._varn("User Notes")),(new u).eq(this._varn("User Notes"),this.empty)),(new u).limit(1).or((new u).group_by(this._varn("User IRI"),this._varn("Role IRI"),this._varn("Roles")).triple(this._varn("User IRI"),"system:role",this._varn("Role IRI")),(new u).eq(this._varn("Roles"),this.empty)))),s=this._add_constraints(n,t);return(new u).using(this.masterdb_resource,s)},h.prototype.organizations=function(t,e){var r;this.default_variables=["Organization ID","Display Name","Notes","Databases","Children","Organization IRI","Database IRI","Child IRI"],e&&this._set_user_variables(e);var i=this._get_varlist().slice(0,6),n=(r=new u).select.apply(r,o(i)).and((new u).triple(this._varn("Organization IRI"),"type","system:Organization").triple(this._varn("Organization IRI"),"system:resource_name",this._varn("Organization ID")).and((new u).limit(1).or((new u).triple(this._varn("Organization IRI"),"label",this._varn("Display Name")),(new u).eq(this._varn("Display Name"),this.empty)),(new u).limit(1).or((new u).triple(this._varn("Organization IRI"),"comment",this._varn("Notes")),(new u).eq(this._varn("Notes"),this.empty)),(new u).limit(1).or((new u).group_by(this._varn("Organization IRI"),this._varn("Database IRI"),this._varn("Databases")).triple(this._varn("Organization IRI"),"system:organization_database",this._varn("Database IRI")),(new u).eq(this._varn("Databases"),this.empty)),(new u).limit(1).or((new u).group_by(this._varn("Organization IRI"),this._varn("Child IRI"),this._varn("Children")).triple(this._varn("Organization IRI"),"system:organization_child",this._varn("Child IRI")),(new u).eq(this._varn("Children"),this.empty)))),s=this._add_constraints(n,t);return(new u).using(this.masterdb_resource,s)},h.prototype.roles=function(t,e){this.default_variables=["Role Name","Description","Role IRI","Capability IRI","Permissions","Resources","Permission ID","Resource ID"],e&&this._set_user_variables(e);this._get_varlist().slice(0,7);var r=(new u).and((new u).triple(this._varn("Role IRI"),"type","system:Role"),(new u).limit(1).or((new u).triple(this._varn("Role IRI"),"label",this._varn("Role Name")),(new u).eq(this._varn("Role Name"),this.empty)),(new u).limit(1).or((new u).triple(this._varn("Role IRI"),"comment",this._varn("Description")),(new u).eq(this._varn("Description"),this.empty)),(new u).triple(this._varn("Role IRI"),"system:capability",this._varn("Capability IRI")).group_by(this._varn("Capability IRI"),this._varn("Permission ID"),this._varn("Permissions")).triple(this._varn("Capability IRI"),"system:action",this._varn("Permission ID")),(new u).triple(this._varn("Role IRI"),"system:capability",this._varn("Capability IRI")).group_by(this._varn("Capability IRI"),this._varn("Resource ID"),this._varn("Resources")).triple(this._varn("Capability IRI"),"system:capability_scope",this._varn("Resource ID"))),i=this._add_constraints(r,t);return(new u).using(this.masterdb_resource,i)},h.prototype.add_role=function(t,e,r){var i=(new u).add_triple(t,"type","system:Role");return e&&i.add_triple(t,"label",e),r&&i.add_triple(t,"comment",r),(new u).using(this.masterdb_resource,i)},h.prototype.add_capability=function(t,e,r,i,n){var o=new u;t||(t="v:Capability IRI",o.when((new u).idgen("doc:Access",[e.concat(r)],t))),o.add_triple(t,"type","system:Capability");for(var s=0;s<e.length;s++)o.add_triple(t,"system:action",e[s]);for(s=0;s<r.length;s++)o.add_triple(t,"system:capability_scope",r[s]);return i&&o.add_triple(t,"label",i),n&&o.add_triple(t,"comment",n),(new u).using(this.masterdb_resource,o)},h.prototype.grant_capability=function(t,e){var r=(new u).add_triple(t,"system:capability",e);return(new u).using(this.masterdb_resource,r)},h.prototype.grant_role=function(t,e){var r=(new u).add_triple(t,"system:role",e);return(new u).using(this.masterdb_resource,r)},h.prototype.revoke_role=function(t,e){var r=(new u).delete_triple(t,"system:role",e);return(new u).using(this.masterdb_resource,r)},t.exports=h},function(t,e,r){function i(t){return function(t){if(Array.isArray(t))return n(t)}(t)||function(t){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(t))return Array.from(t)}(t)||function(t,e){if(!t)return;if("string"==typeof t)return n(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);"Object"===r&&t.constructor&&(r=t.constructor.name);if("Map"===r||"Set"===r)return Array.from(t);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return n(t,e)}(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function n(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,i=new Array(e);r<e;r++)i[r]=t[r];return i}var o=r(3),s=r(23),a=r(0);function u(){o.ViewConfig.call(this),this.type="table"}function h(){o.WOQLViewRule.call(this)}u.prototype=Object.create(o.ViewConfig.prototype),u.prototype.constructor=o.ViewConfig,u.prototype.create=function(t){return new s(t,this)},u.prototype.json=function(){for(var t=[],e=0;e<this.rules.length;e++)t.push(this.rules[e].json());var r={};return void 0!==this.column_order()&&(r.column_order=this.column_order()),void 0!==this.pagesize()&&(r.pagesize=this.pagesize()),void 0!==this.renderer()&&(r.renderer=this.renderer()),void 0!==this.pager()&&(r.pager=this.pager()),void 0!==this.page()&&(r.page=this.page()),void 0!==this.changesize()&&(r.changesize=this.changesize()),{table:r,rules:t}},u.prototype.loadJSON=function(t,e){for(var r=[],n=0;n<e.length;n++){var o=new h;o.json(e[n]),r.push(o)}return this.rules=r,void 0!==t.column_order&&this.column_order.apply(this,i(t.column_order)),void 0!==t.pagesize&&this.pagesize(t.pagesize),void 0!==t.renderer&&this.renderer(t.renderer),void 0!==t.pager&&this.pager(t.pager),void 0!==t.page&&this.page(t.page),void 0!==t.changesize&&this.changesize(t.changesize),this},u.prototype.prettyPrint=function(){var t="view = View.table();\n";void 0!==this.column_order()&&(t+="view.column_order('"+this.column_order()+"')\n"),void 0!==this.pagesize()&&(t+="view.pagesize("+this.pagesize()+")\n"),void 0!==this.renderer()&&(t+="view.renderer('"+this.renderer()+"')\n"),void 0!==this.pager()&&(t+="view.pager("+this.pager()+")\n"),void 0!==this.page()&&(t+="view.page("+this.page()+")\n"),void 0!==this.changesize()&&(t+="view.changesize("+this.changesize()+")\n");for(var e=0;e<this.rules.length;e++){var r=this.rules[e].prettyPrint();r&&(t+="view."+r+"\n")}return t},u.prototype.renderer=function(t){return t?(this.trenderer=t,this):this.trenderer},u.prototype.header=function(t){return void 0===t?this.theader:(this.theader=t,this)},u.prototype.column_order=function(){for(var t=arguments.length,e=new Array(t),r=0;r<t;r++)e[r]=arguments[r];return void 0===e||0==e.length?this.order:(this.order=a.removeNamespacesFromVariables(e),this)},u.prototype.pager=function(t){return void 0===t?this.show_pager:(this.show_pager=t,this)},u.prototype.changesize=function(t){return void 0===t?this.change_pagesize:(this.change_pagesize=t,this)},u.prototype.pagesize=function(t){return void 0===t?this.show_pagesize:(this.show_pagesize=t,this)},u.prototype.page=function(t){return void 0===t?this.show_pagenumber:(this.show_pagenumber=t,this)},u.prototype.column=function(){for(var t=(new h).scope("column"),e=arguments.length,r=new Array(e),i=0;i<e;i++)r[i]=arguments[i];return t.setVariables(r),this.rules.push(t),t},u.prototype.row=function(){var t=(new h).scope("row");return this.rules.push(t),t},h.prototype=Object.create(o.WOQLViewRule.prototype),h.prototype.constructor=o.WOQLViewRule,h.prototype.header=function(t){return void 0===t?this.rule.header:(this.rule.header=t,this)},h.prototype.prettyPrint=function(t){var e=o.WOQLViewRule.prototype.prettyPrint.apply(this);return void 0!==this.header()&&(e+=".header("+this.header()+")"),e},t.exports=u},function(module,exports,__webpack_require__){var UTILS=__webpack_require__(0);
/**
* @file Terminus Rules
* @license Apache Version 2
* Abstract object to support applying matching rules to result sets and documents
* sub-classes are FrameRule and WOQLRule - this just has common functions
*/function TerminusRule(){}function TerminusPattern(t){}TerminusRule.prototype.literal=function(t){return void 0===t?this.pattern.literal:(this.pattern.literal=t,this)},TerminusRule.prototype.type=function(){for(var t=arguments.length,e=new Array(t),r=0;r<t;r++)e[r]=arguments[r];return void 0===e||0==e.length?this.pattern.type:(this.pattern.type=e,this)},TerminusRule.prototype.scope=function(t){return void 0===t?this.pattern.scope:(this.pattern.scope=t,this)},TerminusRule.prototype.value=function(){for(var t=arguments.length,e=new Array(t),r=0;r<t;r++)e[r]=arguments[r];return void 0===e?this.pattern.value:(this.pattern.value=e,this)},TerminusRule.prototype.json=function(t){if(!t){var e={};return this.pattern&&(e.pattern=this.pattern.json()),this.rule&&(e.rule=this.rule),e}return t.pattern&&this.pattern.setPattern(t.pattern),t.rule&&(this.rule=t.rule),this},TerminusPattern.prototype.setPattern=function(t){void 0!==t.literal&&(this.literal=t.literal),t.type&&(this.type=t.type),t.scope&&(this.scope=t.scope),t.value&&(this.value=t.value)},TerminusPattern.prototype.json=function(){var t={};return void 0!==this.literal&&(t.literal=this.literal),this.type&&(t.type=this.type),this.scope&&(t.scope=this.scope),this.value&&(t.value=this.value),t},TerminusPattern.prototype.testBasics=function(t,e){if(this.scope&&t&&this.scope!=t)return!1;if(this.type){var r=e["@type"];if(!r||!this.testValue(r,this.type))return!1}return(void 0===this.literal||this.literal==!(void 0===e["@type"]))&&!(void 0!==this.value&&!this.testValue(e,this.value))},TerminusPattern.prototype.testValue=function(t,e){var r=t["@value"]?t["@value"]:t;if("function"==typeof e)return e(r);e&&!Array.isArray(e)&&(e=[e]);for(var i=0;i<e.length;i++){var n=e[i];if("string"==typeof r){if(this.stringMatch(n,r))return!0}else if("number"==typeof r&&this.numberMatch(n,r))return!0}return!1},TerminusPattern.prototype.unpack=function(t,e){var r="";if(e)for(var i=0;i<t.length;i++)"string"==typeof t[i]?r+='"'+t[i]+'"':r+=t[i],i<t.length-1&&(r+=", ");else r='"'+t.join('","')+'"';return r},TerminusPattern.prototype.IDsMatch=function(t,e){return UTILS.compareIDs(t,e)},TerminusPattern.prototype.classIDsMatch=function(t,e){return this.IDsMatch(t,e)},TerminusPattern.prototype.propertyIDsMatch=function(t,e){return this.IDsMatch(t,e)},TerminusPattern.prototype.rangeIDsMatch=function(t,e){return this.IDsMatch(t,e)},TerminusPattern.prototype.valuesMatch=function(t,e){return t==e},TerminusPattern.prototype.numberMatch=function(vala,valb){if("string"==typeof vala)try{return eval(valb+vala)}catch(t){return!1}return vala===valb},TerminusPattern.prototype.stringMatch=function(t,e){return"/"==t.substring(0,1)?new RegExp(t.substring(1)).test(e):t===e},module.exports={TerminusRule:TerminusRule,TerminusPattern:TerminusPattern}},function(t,e,r){var i=r(21),n=r(0),o=r(4),s=r(24);
/**
* @file WOQL Table
* @license Apache Version 2
*/
function a(t,e){return this.client=t,this.config=e||new i,this}function u(t,e){this.datavalue="system:unknown"==t?"":t,this.datatype=e}a.prototype.options=function(t){return this.config=t,this},a.prototype.setResult=function(t){return this.result=t,this},a.prototype.count=function(){return this.result.count()},a.prototype.first=function(){return this.result.first()},a.prototype.prev=function(){return this.result.prev()},a.prototype.next=function(){return this.result.next()},a.prototype.canAdvancePage=function(){return this.result.count()==this.result.query.getLimit()},a.prototype.canChangePage=function(){return this.canAdvancePage()||this.canRetreatPage()},a.prototype.canRetreatPage=function(){return this.result.query.getPage()>1},a.prototype.getPageSize=function(){return this.result.query.getLimit()},a.prototype.setPage=function(t){return this.result.query.setPage(t)},a.prototype.getPage=function(){return this.result.query.getPage()},a.prototype.setPageSize=function(t){return this.update(this.result.query.setPageSize(t))},a.prototype.nextPage=function(){return this.update(this.result.query.nextPage())},a.prototype.firstPage=function(){return this.update(this.result.query.firstPage())},a.prototype.previousPage=function(){return this.update(this.result.query.previousPage())},a.prototype.getColumnsToRender=function(){if(this.hasColumnOrder())var t=this.getColumnOrder();else if(this.result.query.hasSelect())t=this.result.query.getSelectVariables();else t=this.result.getVariableList();var e=this;return t?t.filter((function(t){return!e.hidden(t)})):[]},a.prototype.isSortableColumn=function(){return!0},a.prototype.isFilterableColumn=function(){return!0},a.prototype.getColumnHeaderContents=function(t){t=n.removeNamespaceFromVariable(t);var e=(new o).matchColumn(this.config.rules,t,"header");if(e&&e.length){var r=e[e.length-1].rule.header;return"string"==typeof r?r:"function"==typeof r?r(t):r}return n.labelFromVariable(t)},a.prototype.hidden=function(t){colid=n.addNamespaceToVariable(t);var e=(new o).matchColumn(this.config.rules,colid,"hidden");return!!e.length&&e[e.length-1].rule.hidden},a.prototype.update=function(t){var e=this;return t.execute(this.client).then((function(r){var i=new s(r,t);return e.setResult(i),e.notify&&e.notify(i),i}))},a.prototype.hasDefinedEvent=function(t,e,r,i,n){if("row"==r)var s=(new o).matchRow(this.config.rules,t,this.result.cursor,i);else s=(new o).matchCell(this.config.rules,t,e,this.result.cursor,i);return!(!s||!s.length)},a.prototype.getDefinedEvent=function(t,e,r,i,n){if("row"==r)var s=(new o).matchRow(this.config.rules,t,this.result.cursor,i);else s=(new o).matchCell(this.config.rules,t,e,this.result.cursor,i);if(s&&s.length)return s[s.length-1].rule[i]},a.prototype.getRowClick=function(t){return this.getDefinedEvent(t,!1,"row","click")},a.prototype.getCellClick=function(t,e){return this.getDefinedEvent(t,e,"column","click")},a.prototype.getRowHover=function(t){return this.getDefinedEvent(t,!1,"row","hover")},a.prototype.getCellHover=function(t,e){return this.getDefinedEvent(t,e,"column","hover")},a.prototype.getColumnOrder=function(){return this.config.column_order()},a.prototype.hasColumnOrder=a.prototype.getColumnOrder,a.prototype.hasCellClick=a.prototype.getCellClick,a.prototype.hasRowClick=a.prototype.getRowClick,a.prototype.hasCellHover=a.prototype.getCellHover,a.prototype.hasRowHover=a.prototype.getRowHover,a.prototype.getRenderer=function(t,e,r){var i=this.getSpecificRender(t,e);if(i)return i;var n=this.getDefinedEvent(e,t,"column","renderer",r),o=this.getDefinedEvent(e,t,"column","args",r);if(!n){var s=this.getRendererForDatatype(e[t]);n=s.name,o||(o=s.args)}return n?this.datatypes.createRenderer(n,o):void 0},a.prototype.renderValue=function(t,e,r,i){if(e&&e["@type"]){t.type=e["@type"];var n=new u(e["@value"],e["@type"],r,i)}else if(e&&e["@language"]){t.type="xsd:string";n=new u(e["@value"],t.type,r,i)}else if(e&&"string"==typeof e){t.type="id";n=new u(e,"id",r,i)}return n?t.renderValue(n):""},u.prototype.value=function(t){return t?(this.datavalue=t,this):this.datavalue},a.prototype.getRendererForDatatype=function(t){return t&&t["@type"]?this.datatypes.getRenderer(t["@type"],t["@value"]):t&&t["@language"]?this.datatypes.getRenderer("xsd:string",t["@value"]):!(!t||"string"!=typeof t)&&this.datatypes.getRenderer("id",t)},a.prototype.getSpecificRender=function(t,e){return this.getDefinedEvent(e,t,"column","render")},t.exports=a},function(t,e,r){var i=r(0),n=r(5);r(61);
/**
* @file WOQL Result Object
* @license Apache Version 2
* Object representing the result of a WOQL Query
* @param {Object} results result JSON object as returned by WOQL query
* @param {WOQLQuery} query the query object that generated the result
* @param {Object} [config] optional result configuration options object
* [config.no_compress] by default all URLs are compressed where possible (v:X rather than http://.../variable/x) set to true to return non-compressed values
* [config.context] specify the JSON-LD context to use for compressing results - by default the query context will be used
*/
function o(t,e,r){if(this.bindings=t?t.bindings:[],this.insert_count=t?t.inserts:0,this.delete_count=t?t.deletes:0,this.transaction_retry_count=t?t.transaction_retry_count:0,this.query=e||n.query(),this.cursor=0,!r||!r.no_compress){var i=!(!r||!r.context)&&r.context;this.compress(i)}}o.prototype.compress=function(t){t=t||this.query.getContext();for(var e=0;e<this.bindings.length;e++)for(var r=0,n=Object.keys(this.bindings[e]);r<n.length;r++){var o=n[r],s=i.shorten(o,t),a=this.bindings[e][o];if("string"==typeof this.bindings[e][o])a=i.shorten(this.bindings[e][o],t);else if(Array.isArray(this.bindings[e][o])){a=[];for(var u=0;u<this.bindings[e][o].length;u++){var h=this.bindings[e][o][u];if("string"==typeof h)h=i.shorten(h,t);else if(Array.isArray(h)){for(var p=[],c=0;c<h.length;c++){var l=h[c];"string"==typeof l&&(l=i.shorten(l,t)),p.push(l)}h=p}a.push(h)}}delete this.bindings[e][o],this.bindings[e][s]=a}return this},o.prototype.hasBindings=function(){return!(!this.bindings||!this.count())},o.prototype.hasUpdates=function(){return this.inserts()>0||this.deletes()>0},o.prototype.getBindings=function(){return this.bindings},o.prototype.getVariableList=function(){return this.bindings&&this.bindings[0]?Object.keys(this.bindings[0]):[]},o.prototype.count=function(){return this.bindings.length},o.prototype.inserts=function(){return this.insert_count},o.prototype.deletes=function(){return this.delete_count},o.prototype.first=function(){return this.cursor=0,this.bindings[0]},o.prototype.last=function(){return this.cursor=this.bindings.length-1,this.bindings[this.bindings.length-1]},o.prototype.next=function(){if(this.cursor>=this.bindings.length)return!1;var t=this.bindings[this.cursor];return this.cursor++,t},o.prototype.prev=function(){if(this.cursor>0)return this.cursor--,this.bindings[this.cursor]},o.prototype.sort=function(t,e){var r=this;this.bindings.sort((function(i,n){return r.compareValues(i[t],n[t],e)}))},o.prototype.compareValues=function(t,e){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"asc";return t&&e?(void 0!==t["@value"]&&void 0!==e["@value"]&&(t=t["@value"],e=e["@value"]),t>e?r&&"asc"==r?1:-1:e>t?r&&"asc"==r?-1:1:void 0):0},t.exports=o},function(t,e,r){var i=r(3),n=r(62),o=r(0);function s(){i.ViewConfig.call(this),this.type="chooser"}function a(t){i.WOQLViewRule.call(this,t)}s.prototype=Object.create(i.ViewConfig.prototype),s.prototype.constructor=i.ViewConfig,s.prototype.create=function(t){return new n(t,this)},s.prototype.prettyPrint=function(){var t="view = View.chooser();\n";t+=this.getBasicPrettyPrint(),void 0!==this.change()&&(t+="view.change("+this.change()+")\n"),void 0!==this.show_empty()&&(t+="view.show_empty('"+this.show_empty()+"')\n"),void 0!==this.values()&&(t+="view.values('"+o.removeNamespaceFromVariable(this.values())+"')\n"),void 0!==this.labels()&&(t+="view.labels('"+o.removeNamespaceFromVariable(this.labels())+"')\n"),void 0!==this.titles()&&(t+="view.titles('"+o.removeNamespaceFromVariable(this.titles())+"')\n"),void 0!==this.sort()&&(t+="view.sort("+this.sort()+")\n"),void 0!==this.direction()&&(t+="view.direction('"+this.direction()+"')\n");for(var e=0;e<this.rules.length;e++)t+="view."+this.rules[e].prettyPrint("chooser")+"\n";return t},s.prototype.json=function(){var t=this.getBasicJSON();return void 0!==this.change()&&(t.change=this.change()),void 0!==this.show_empty()&&(t.show_empty=this.show_empty()),void 0!==this.values()&&(t.values=this.values()),void 0!==this.labels()&&(t.labels=this.labels()),void 0!==this.titles()&&(t.titles=this.titles()),void 0!==this.sort()&&(t.sort=this.sort()),void 0!==this.direction()&&(t.direction=this.direction()),{chooser:t,rules:this.getRulesJSON()}},s.prototype.loadJSON=function(t,e){for(var r=[],i=0;i<e.length;i++){var n=new a;n.json(e[i]),r.push(n)}this.rules=r,this.loadBasicJSON(t),void 0!==t.change&&this.change(t.change),void 0!==t.show_empty&&this.show_empty(t.show_empty),void 0!==t.values&&this.values(t.values),void 0!==t.labels&&this.labels(t.labels),void 0!==t.titles&&this.titles(t.titles),void 0!==t.sort&&this.sort(t.sort),void 0!==t.direction&&this.direction(t.direction)},s.prototype.change=function(t){return void 0!==t?(this.onChange=t,this):this.onChange},s.prototype.show_empty=function(t){return void 0!==t?(this.placeholder=t,this):this.placeholder},s.prototype.rule=function(t){var e=(new a).scope("row");return this.rules.push(e),t&&e.vars(t),e},s.prototype.values=function(t){return void 0!==t?("v:"==t.substring(0,2)&&(t=t.substring(2)),this.value_variable=t,this):this.value_variable},s.prototype.labels=function(t){return t?("v:"==t.substring(0,2)&&(t=t.substring(2)),this.label_variable=t,this):this.label_variable},s.prototype.titles=function(t){return t?("v:"==t.substring(0,2)&&(t=t.substring(2)),this.title_variable=t,this):this.title_variable},s.prototype.sort=function(t){return t?("v:"==t.substring(0,2)&&(t=t.substring(2)),this.sort_variable=t,this):this.sort_variable},s.prototype.direction=function(t){return t?(this.sort_direction=t,this):this.sort_direction},a.prototype=Object.create(i.WOQLViewRule.prototype),a.prototype.constructor=i.WOQLViewRule,a.prototype.label=function(t){return t?(this.rule.label=t,this):this.rule.label},a.prototype.title=function(t){return t?(this.rule.title=t,this):this.rule.title},a.prototype.values=function(t){return t?(this.rule.values=t,this):this.rule.values},a.prototype.selected=function(t){return void 0!==t?(this.rule.selected=t,this):this.rule.selected},a.prototype.prettyPrint=function(t){var e=WOQLViewRule.prototype.prettyPrint.apply(this);return void 0!==this.selected()&&(e+=".selected("+this.selected()+")"),void 0!==this.label()&&(e+='.label("'+this.label()+'")'),void 0!==this.title()&&(e+='.title("'+this.title()+'")'),void 0!==this.values()&&(e+='.values("'+this.values()+'")'),e},t.exports=s},function(t,e,r){function i(t){return function(t){if(Array.isArray(t))return n(t)}(t)||function(t){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(t))return Array.from(t)}(t)||function(t,e){if(!t)return;if("string"==typeof t)return n(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);"Object"===r&&t.constructor&&(r=t.constructor.name);if("Map"===r||"Set"===r)return Array.from(t);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return n(t,e)}(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function n(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,i=new Array(e);r<e;r++)i[r]=t[r];return i}var o=r(3),s=r(27),a=r(0);function u(){o.ViewConfig.call(this),this.type="graph"}function h(t){o.WOQLViewRule.call(this,t)}u.prototype=Object.create(o.ViewConfig.prototype),u.prototype.constructor=o.ViewConfig,u.prototype.create=function(t){return new s(t,this)},u.prototype.literals=function(t){return void 0!==t?(this.show_literals=t,this):this.show_literals},u.prototype.source=function(t){return t?(this.source_variable=a.removeNamespaceFromVariable(t),this):this.source_variable},u.prototype.fontfamily=function(t){return void 0!==t?(this.fontfam=t,this):this.fontfam},u.prototype.show_force=function(t){return void 0!==t?(this.force=t,this):this.force},u.prototype.fix_nodes=function(t){return void 0!==t?(this.fixed=t,this):this.fixed},u.prototype.explode_out=function(t){return void 0!==t?(this.explode=t,this):this.explode},u.prototype.selected_grows=function(t){return void 0!==t?(this.bigsel=t,this):this.bigsel},u.prototype.width=function(t){return void 0!==t?(this.gwidth=t,this):this.gwidth},u.prototype.height=function(t){return void 0!==t?(this.gheight=t,this):this.gheight},u.prototype.edges=function(){for(var t=arguments.length,e=new Array(t),r=0;r<t;r++)e[r]=arguments[r];if(e&&e.length){for(var i=[],n=0;n<e.length;n++)i.push(a.removeNamespacesFromVariables(e[n]));return this.show_edges=i,this}return this.show_edges},u.prototype.edge=function(t,e){var r=(new h).edge(t,e);return this.rules.push(r),r},u.prototype.node=function(){for(var t=new h,e=arguments.length,r=new Array(e),i=0;i<e;i++)r[i]=arguments[i];return r&&r.length?t.scope("node").setVariables(r):t.scope("row"),this.rules.push(t),t},u.prototype.loadJSON=function(t,e){for(var r=[],n=0;n<e.length;n++){var o=new h;o.json(e[n]),r.push(o)}this.rules=r,void 0!==t.literals&&this.literals(t.literals),void 0!==t.source&&this.source(t.source),void 0!==t.fontfamily&&this.fontfamily(t.fontfamily),void 0!==t.show_force&&this.show_force(t.show_force),void 0!==t.fix_nodes&&this.fix_nodes(t.fix_nodes),void 0!==t.explode_out&&this.explode_out(t.explode_out),void 0!==t.selected_grows&&this.selected_grows(t.selected_grows),void 0!==t.width&&this.width(t.width),void 0!==t.height&&this.height(t.height),void 0!==t.edges&&this.edges.apply(this,i(t.edges))},u.prototype.prettyPrint=function(){var t="view = View.graph();\n";if(void 0!==this.literals()&&(t+="view.literals('"+this.literals()+"')\n"),void 0!==this.source()&&(t+="view.source('"+a.removeNamespaceFromVariable(this.source())+"')\n"),void 0!==this.fontfamily()&&(t+="view.fontfamily('"+this.fontfamily()+"')\n"),void 0!==this.show_force()&&(t+="view.show_force('"+this.show_force()+"')\n"),void 0!==this.fix_nodes()&&(t+="view.fix_nodes('"+this.fix_nodes()+"')\n"),void 0!==this.explode_out()&&(t+="view.explode_out('"+this.explode_out()+"')\n"),void 0!==this.selected_grows()&&(t+="view.selected_grows('"+this.selected_grows()+"')\n"),void 0!==this.width()&&(t+="view.width('"+this.width()+"')\n"),void 0!==this.height()&&(t+="view.height('"+this.height()+"')\n"),void 0!==this.edges()){for(var e=this.edges(),r=[],i=0;i<e.length;i++)r.push("['"+e[i][0]+", "+e[i][1]+"']");t+="view.edges('"+r.join(", ")+"')\n"}for(i=0;i<this.rules.length;i++){var n=this.rules[i].prettyPrint();n&&(t+="view."+n+"\n")}return t},u.prototype.json=function(){for(var t=[],e=0;e<this.rules.length;e++)t.push(this.rules[e].json());var r={};return void 0!==this.literals()&&(r.literals=this.literals()),void 0!==this.source()&&(r.source=this.source()),void 0!==this.fontfamily()&&(r.fontfamily=this.fontfamily()),void 0!==this.show_force()&&(r.show_force=this.show_force()),void 0!==this.fix_nodes()&&(r.fix_nodes=this.fix_nodes()),void 0!==this.explode_out()&&(r.explode_out=this.explode_out()),void 0!==this.selected_grows()&&(r.selected_grows=this.selected_grows()),void 0!==this.width()&&(r.width=this.width()),void 0!==this.height()&&(r.height=this.height()),void 0!==this.edges()&&(r.edges=this.edges()),{graph:r,rules:t}},h.prototype=Object.create(o.WOQLViewRule.prototype),h.prototype.constructor=o.WOQLViewRule,h.prototype.charge=function(t){return void 0===t?this.rule.charge:(this.rule.charge=t,this)},h.prototype.collisionRadius=function(t){return void 0===t?this.rule.collisionRadius:(this.rule.collisionRadius=t,this)},h.prototype.arrow=function(t){return t?(this.rule.arrow=t,this):this.rule.arrow},h.prototype.distance=function(t){return void 0!==t?(this.rule.distance=t,this):this.rule.distance},h.prototype.symmetric=function(t){return void 0!==t?(this.rule.symmetric=t,this):this.rule.symmetric},h.prototype.weight=function(t){return void 0!==t?(this.rule.weight=t,this):this.rule.weight},h.prototype.prettyPrint=function(t){var e=o.WOQLViewRule.prototype.prettyPrint.apply(this);return void 0!==this.charge()&&(e+=".charge('"+this.charge()+"')"),void 0!==this.distance()&&(e+=".distance('"+this.distance()+"')"),void 0!==this.weight()&&(e+=".weight('"+this.weight()+"')"),void 0!==this.symmetric()&&(e+=".symmetric("+this.symmetric()+")"),void 0!==this.collisionRadius()&&(e+=".collisionRadius("+this.collisionRadius()+")"),void 0!==this.arrow()&&(e+=".arrow("+JSON.stringify(this.arrow())+")"),e},t.exports=u},function(t,e,r){var i=r(26),n=r(0),o=r(4);function s(t,e){this.client=t,this.config=e||new i,this.nodes=[],this.edges=[]}s.prototype.options=function(t){return this.config=t,this},s.prototype.setResult=function(t){this.result=t,this.calculateVariableTypes(t)},s.prototype.calculateVariableTypes=function(){var t=this.result.getBindings();if(t&&t.length)for(var e=0;e<t.length;e++)this.extractFromBinding(t[e],e);this.edges=this.combineEdges(this.edges),this.nodes=this.combineNodes(this.nodes)},s.prototype.extractFromBinding=function(t,e){if(this.includeRow(t,e)){var r=[];for(var i in t)"string"==typeof t[i]?t[i]&&"system:unknown"!=t[i]&&this.includeNode(i,t)&&r.push(i):t[i]["@value"]&&this.includeLiteralNode(i,t)&&r.push(i);if(0==r.length)return;this.createEdgesFromIDs(r,t);for(var n=0;n<r.length;n++){var o=t[r[n]];o=o["@value"]?o["@value"]:o,this.addAdornedNode(o,r[n],t)}}},s.prototype.addAdornedEdge=function(t,e,r,i,s){t=t["@value"]?t["@value"]:t;for(var a={type:"link",target:e=e["@value"]?e["@value"]:e,source:t,text:i},u=(new o).matchEdge(this.config.rules,s,r,i),h=!1,p=0;p<u.length;p++){var c=u[p].rule;void 0!==c.hidden&&(h=c.hidden),c.size&&(a.radius=n.getConfigValue(c.size,s)),c.text&&(a.text=n.getConfigValue(c.text,s)),c.color&&(a.color=n.getConfigValue(c.color,s)),c.distance&&(a.distance=n.getConfigValue(c.distance,s)),c.arrow&&(a.arrow=n.getConfigValue(c.arrow,s)),c.symmetric&&(a.symmetric=n.getConfigValue(c.symmetric,s)),c.weight&&(a.weight=n.getConfigValue(c.weight,s))}h||this.edges.push(a)},s.prototype.addAdornedNode=function(t,e,r){for(var i={type:"node",id:t,nodetype:e},s=(new o).matchNode(this.config.rules,r,e,t),a=0;a<s.length;a++){var u=s[a].rule;u.size&&(i.radius=n.getConfigValue(u.size,r)),u.color&&(i.color=n.getConfigValue(u.color,r)),u.charge&&(i.charge=n.getConfigValue(u.charge,r)),u.collisionRadius&&(i.collisionRadius=n.getConfigValue(u.collisionRadius,r)),u.icon&&(i.icon=n.getConfigValue(u.icon,r)),u.text&&(i.text=n.getConfigValue(u.text,r)),u.border&&(i.border=n.getConfigValue(u.border,r))}i.text||("string"==typeof r[e]?i.text=r[e]:r[e]["@value"]&&(i.text=r[e]["@value"])),this.nodes.push(i)},s.prototype.getLiteralOwner=function(t,e,r){var i=this.config.source();if(i&&r[i])return i;var n=this.config.edges();if(n){for(var o=0;o<n.length;o++)if(n[o][1]==e)return n[o][0];return!1}return t[0]},s.prototype.createEdgesFromIDs=function(t,e){if(!(t.length<2)){var r=this.config.source(),i=this.config.edges();if(!r&&i&&i.length)for(var n=0;n<i.length;n++)-1!=t.indexOf(i[n][0])&&-1!=t.indexOf(i[n][1])&&this.addAdornedEdge(e[i[n][0]],e[i[n][1]],i[n][0],i[n][1],e);else{var o=r&&-1!=t.indexOf(r)?r:t[0];for(n=0;n<t.length;n++)t[n]!=o&&this.addAdornedEdge(e[o],e[t[n]],o,t[n],e)}}},s.prototype.getEdges=function(){return this.edges},s.prototype.combineNodes=function(t){for(var e={},r=0;r<t.length;r++){var i=t[r];if(-1!=this.nodes_referenced_by_edges.indexOf(i.id))if(void 0===e[i.id])e[i.id]=i;else for(var n in i)void 0===e[i.id][n]&&(e[i.id][n]=i[n])}return Object.values(e)},s.prototype.combineEdges=function(t){this.nodes_referenced_by_edges=[];for(var e={},r=0;r<t.length;r++){var i=t[r];if(void 0===e[i.source]&&(e[i.source]={}),void 0===e[i.source][i.target])e[i.source][i.target]=i;else for(var n in i)void 0===e[i.source][i.target][n]&&(e[i.source][i.target][n]=i[n]);-1==this.nodes_referenced_by_edges.indexOf(i.source)&&this.nodes_referenced_by_edges.push(i.source),-1==this.nodes_referenced_by_edges.indexOf(i.target)&&this.nodes_referenced_by_edges.push(i.target)}var o=[];for(var n in e)for(var s in e[n])o.push(e[n][s]);return o},s.prototype.getNodes=function(){return this.nodes},s.prototype.includeNode=function(t,e){for(var r=(new o).matchNode(this.config.rules,e,t,!1,"hidden"),i=0;i<r.length;i++)if(r[i].rule.hidden)return!1;return!0},s.prototype.includeLiteralNode=function(t,e){var r=this.config.literals();if(void 0!==r||!r)return!0;for(var i=(new o).matchNode(this.config.rules,e,t,!1,"hidden"),n=0;n<i.length;n++)if(i[n].rule.hidden)return!1;return!0},s.prototype.includeRow=function(t,e){for(var r=(new o).matchRow(this.config.rules,t,e,"hidden"),i=0;i<r.length;i++)if(r[i].rule.hidden)return!1;return!0},t.exports=s},function(t,e,r){var i=r(3);r(63);function n(){i.ViewConfig.call(this),this.type="chart"}function o(){i.WOQLViewRule.call(this)}n.prototype=Object.create(i.ViewConfig.prototype),n.prototype.constructor=i.ViewConfig,n.prototype.prettyPrint=function(){for(var t="view = View.chart();\n",e=0;e<this.rules.length;e++)t+="view."+this.rules[e].prettyPrint()+"\n";return void 0!==this.margin()&&(t+="view.margin("+this.margin()+")\n"),void 0!==this.title()&&(t+="view.title('"+this.title()+"')\n"),void 0!==this.description()&&(t+="view.description('"+this.description()+"')\n"),void 0!==this.layout()&&(t+="view.layout('"+this.layout()+"')\n"),t+=this.getBasicPrettyPrint()},n.prototype.json=function(){var t={};return void 0!==this.margin()&&(t.margin=this.margin()),void 0!==this.title()&&(t.title=this.title()),void 0!==this.description()&&(t.description=this.description()),void 0!==this.layout()&&(t.layout=this.layout()),{chart:t,rules:this.getRulesJSON()}},n.prototype.loadJSON=function(t,e){this.loadBasicJSON(t);for(var r=[],i=0;i<e.length;i++){var n=new o;n.json(e[i]),r.push(n)}this.rules=r,void 0!==t.margin&&this.margin(t.margin),void 0!==t.title&&this.title(t.title),void 0!==t.description&&this.description(t.description),void 0!==t.layout&&this.layout(t.layout)},n.prototype.title=function(t){return void 0===t?this._title:(this._title=t,this)},n.prototype.description=function(t){return t?(this._description=t,this):this._description},n.prototype.layout=function(t){return t?(this._layout=t,this):this._layout},n.prototype.margin=function(t){return t?(this._margin=t,this):this._margin},n.prototype.create=function(t){return new n(t,this)},n.prototype.xAxis=function(){for(var t=(new o).scope("XAxis"),e=arguments.length,r=new Array(e),i=0;i<e;i++)r[i]=arguments[i];return t.setVariables(r),this.rules.push(t),t},n.prototype.legend=function(){for(var t=(new o).scope("Legend"),e=arguments.length,r=new Array(e),i=0;i<e;i++)r[i]=arguments[i];return t.setVariables(r),this.rules.push(t),t},n.prototype.yAxis=function(){for(var t=(new o).scope("YAxis"),e=arguments.length,r=new Array(e),i=0;i<e;i++)r[i]=arguments[i];return t.setVariables(r),this.rules.push(t),t},n.prototype.bar=function(){for(var t=(new o).scope("Bar"),e=arguments.length,r=new Array(e),i=0;i<e;i++)r[i]=arguments[i];return t.setVariables(r),this.rules.push(t),t},n.prototype.line=function(){for(var t=(new o).scope("Line"),e=arguments.length,r=new Array(e),i=0;i<e;i++)r[i]=arguments[i];return t.setVariables(r),this.rules.push(t),t},n.prototype.point=function(){for(var t=(new o).scope("Point"),e=arguments.length,r=new Array(e),i=0;i<e;i++)r[i]=arguments[i];return t.setVariables(r),this.rules.push(t),t},n.prototype.area=function(){for(var t=(new o).scope("Area"),e=arguments.length,r=new Array(e),i=0;i<e;i++)r[i]=arguments[i];return t.setVariables(r),this.rules.push(t),t},o.prototype=Object.create(i.WOQLViewRule.prototype),o.prototype.constructor=i.WOQLViewRule,o.prototype.style=function(t,e){return e?(this.rule[t]=e,this):this.rule[t]},o.prototype.label=function(t){return t?(this.rule.label=t,this):this.rule.label},o.prototype.legendType=function(t){return t?(this.rule.legendType=t,this):this.rule.legendType},o.prototype.fillOpacity=function(t){return t||0===t?(this.rule.fillOpacity=t,this):this.rule.fillOpacity},o.prototype.fill=function(t){return t?(this.rule.fill=t,this):this.rule.fill},o.prototype.stroke=function(t){return t?(this.rule.stroke=t,this):this.rule.stroke},o.prototype.strokeWidth=function(t){return void 0!==t?(this.rule.strokeWidth=t,this):this.rule.strokeWidth},o.prototype.dot=function(t){return void 0!==t?(this.rule.dot=t,this):this.rule.dot},o.prototype.labelRotate=function(t){return void 0!==t?(this.rule.labelRotate=t,this):this.rule.labelRotate},o.prototype.padding=function(t){return t?(this.rule.padding=t,this):this.rule.padding},o.prototype.labelDateInput=function(t){return t?(this.rule.labelDateInput=t,this):this.rule.labelDateInput},o.prototype.labelDateOutput=function(t){return t?(this.rule.labelDateOutput=t,this):this.rule.labelDateOutput},o.prototype.stackId=function(t){return t?(this.rule.stackId=t,this):this.rule.stackId},o.prototype.type=function(t){return t?(this.rule.type=t,this):this.rule.type},o.prototype.axisDomain=function(t){return t?(this.rule.domain=t,this):this.rule.domain},o.prototype.colorEntry=function(t){return t?(this.rule.colorEntry=t,this):this.rule.colorEntry},o.prototype.customColors=function(t){return t?(this.rule.customColors=t,this):this.rule.customColors},o.prototype.payload=function(t){return t?(this.rule.payload=t,this):this.rule.payload},o.prototype.barSize=function(t){return t?(this.rule.barSize=t,this):this.rule.barSize},t.exports=n},function(t,e,r){var i=r(3),n=r(64);function o(){i.ViewConfig.call(this),this.type="stream"}function s(){i.WOQLViewRule.call(this)}o.prototype=Object.create(i.ViewConfig.prototype),o.prototype.constructor=i.ViewConfig,o.prototype.create=function(t){return new n(t,this)},o.prototype.row=function(){var t=(new s).scope("row");return this.rules.push(t),t},o.prototype.template=function(t){return t?(this.mtemplate=t,this):this.mtemplate},o.prototype.prettyPrint=function(){var t="view = View.stream();\n";void 0!==this.template()&&(t+="view.template("+JSON.stringify(this.template())+")\n");for(var e=0;e<this.rules.length;e++)t+="view."+this.rules[e].prettyPrint()+"\n";return t},o.prototype.loadJSON=function(t,e){for(var r=[],i=0;i<e.length;i++){var n=new s;n.json(e[i]),r.push(n)}this.rules=r,t.template&&(this.mtemplate=t.template)},o.prototype.json=function(){for(var t=[],e=0;e<this.rules.length;e++)t.push(this.rules[e].json());var r={};return this.mtemplate&&(r.template=this.mtemplate),{stream:r,rules:t}},s.prototype=Object.create(i.WOQLViewRule.prototype),s.prototype.constructor=i.WOQLViewRule,s.prototype.template=function(t){return t?(this.rule.template=t,this):this.rule.template},t.exports=o},function(t,e,r){function i(t){return function(t){if(Array.isArray(t))return n(t)}(t)||function(t){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(t))return Array.from(t)}(t)||function(t,e){if(!t)return;if("string"==typeof t)return n(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);"Object"===r&&t.constructor&&(r=t.constructor.name);if("Map"===r||"Set"===r)return Array.from(t);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return n(t,e)}(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function n(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,i=new Array(e);r<e;r++)i[r]=t[r];return i}function o(t){return(o="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}var s=r(3),a=r(8),u=r(65);
/**
* @file Frame Config
* @license Apache Version 2
*/
function h(){s.ViewConfig.call(this),this.type="document"}
/**
* @file Document Rule
* @license Apache Version 2
*/
function p(){a.call(this),this.rule={}}h.prototype=Object.create(s.ViewConfig.prototype),h.prototype.constructor=s.ViewConfig,h.prototype.create=function(t){return new u(t,this)},h.prototype.prettyPrint=function(){var t="view = View.document();\n";t+=this.getBasicPrettyPrint(),void 0!==this.load_schema()&&(t+="view.load_schema("+this.load_schema()+")\n");for(var e=0;e<this.rules.length;e++)t+="view."+this.rules[e].prettyPrint()+"\n";return t},h.prototype.json=function(){var t=this.getBasicJSON();return void 0!==this.load_schema()&&(t.load_schema=this.load_schema()),{frame:t,rules:this.getRulesJSON()}},h.prototype.loadJSON=function(t,e){for(var r=[],i=0;i<e.length;i++){var n=new p;n.json(e[i]),r.push(n)}return this.rules=r,this.loadBasicJSON(t),void 0!==t.load_schema&&this.load_schema(t.load_schema),this},h.prototype.json_rules=function(){for(var t=[],e=0;e<this.rules.length;e++)t.push(this.rules[e].json());return t},h.prototype.load_schema=function(t){return void 0===t?this.get_schema:(this.get_schema=t,this)},h.prototype.show_all=function(t){return this.all().renderer(t),this},h.prototype.show_parts=function(t,e,r){return this.object().renderer(t),this.property().renderer(e),this.data().renderer(r),this},h.prototype.object=function(){var t=(new p).scope("object");return this.rules.push(t),t},h.prototype.property=function(){var t=(new p).scope("property");return this.rules.push(t),t},h.prototype.scope=function(t){var e=(new p).scope(t);return this.rules.push(e),e},h.prototype.data=function(){var t=(new p).scope("data");return this.rules.push(t),t},h.prototype.all=function(){var t=(new p).scope("*");return this.rules.push(t),t},h.prototype.setFrameDisplayOptions=function(t,e){void 0===t.display_options&&(t.display_options={}),void 0!==e.mode()&&(t.display_options.mode=e.mode()),void 0!==e.view()&&(t.display_options.view=e.view()),void 0!==e.showDisabledButtons()&&(t.display_options.show_disabled_buttons=e.showDisabledButtons()),void 0!==e.hidden()&&(t.display_options.hidden=e.hidden()),void 0!==e.collapse()&&(t.display_options.collapse=e.collapse()),void 0!==e.style()&&(t.display_options.style=e.style()),void 0!==e.headerStyle()&&(t.display_options.header_style=e.headerStyle()),void 0!==e.features()&&(t.display_options.features=this.setFrameFeatures(t.display_options.features,e.features())),void 0!==e.headerFeatures()&&(t.display_options.header_features=this.setFrameFeatures(t.display_options.header_features,e.headerFeatures())),void 0!==e.header()&&(t.display_options.header=e.header()),void 0!==e.showEmpty()&&(t.display_options.show_empty=e.showEmpty()),void 0!==e.dataviewer()&&(t.display_options.dataviewer=e.dataviewer()),void 0!==e.args()&&(t.display_options.args=this.setFrameArgs(t.display_options.args,e.args()))},h.prototype.setFrameFeatures=function(t,e){if(!t||!t.length)return e;if(!e||!e.length)return t;for(var r=[],i=0;i<t.length;i++){var n="string"==typeof t[i]?t[i]:Object.keys(t[i])[0];r.push(n)}for(var s=0;s<e.length;s++){var a="string"==typeof e[s]?e[s]:Object.keys(e[s])[0],u=r.indexOf(a);if(-1==u)t.push(e[s]);else if("object"==o(e[s])){var h=t[u];if("string"==typeof h)t[u]=e[s];else if("object"==o(h)){var p=e[s][a];for(var c in p)t[u][a][c]=p[c]}}}return t},h.prototype.setFrameArgs=function(t,e){if(!t)return e;if(!e)return t;for(var r in e)t[r]=e[r];return t},p.prototype=Object.create(a.prototype),p.prototype.constructor=a,p.prototype.renderer=function(t){return void 0===t?this.rule.renderer:(this.rule.renderer=t,this)},p.prototype.compare=function(t){return void 0===t?this.rule.compare:(this.rule.compare=t,this)},p.prototype.mode=function(t){return void 0===t?this.rule.mode:(this.rule.mode=t,this)},p.prototype.collapse=function(t){return void 0===t?this.rule.collapse:(this.rule.collapse=t,this)},p.prototype.view=function(t){return t?(this.rule.view=t,this):this.rule.view},p.prototype.showDisabledButtons=function(t){return void 0===t?this.rule.show_disabled_buttons:(this.rule.show_disabled_buttons=t,this)},p.prototype.header=function(t){return t?(this.rule.header=t,this):this.rule.header},p.prototype.headerStyle=function(t){return t?(this.rule.headerStyle=t,this):this.rule.headerStyle},p.prototype.showEmpty=function(t){return t?(this.rule.show_empty=t,this):this.rule.show_empty},p.prototype.dataviewer=function(t){return t?(this.rule.dataviewer=t,this):this.rule.dataviewer},p.prototype.features=function(){for(var t=arguments.length,e=new Array(t),r=0;r<t;r++)e[r]=arguments[r];return void 0===e||0==e.length?this.rule.features:(this.rule.features=e,this)},p.prototype.headerFeatures=function(){for(var t=arguments.length,e=new Array(t),r=0;r<t;r++)e[r]=arguments[r];return void 0===e||0==e.length?this.rule.header_features:(this.rule.header_features=e,this)},p.prototype.render=function(t){if(!t)return this.rule.render;var e=this.headerFeatures(),r=this.features();if(e&&e.length){var n=this.applyFeatureProperty(e,"render",t);this.headerFeatures.apply(this,i(n))}else if(r&&r.length){n=this.applyFeatureProperty(r,"render",t);this.features.apply(this,i(n))}else this.rule.render=t;return this},p.prototype.style=function(t){if(void 0===t)return this.rule.style;var e=this.headerFeatures(),r=this.features();if(e&&e.length){var n=this.applyFeatureProperty(e,"style",t);this.headerFeatures.apply(this,i(n))}else if(r&&r.length){n=this.applyFeatureProperty(r,"style",t);this.features.apply(this,i(n))}else this.rule.style=t;return this},p.prototype.hidden=function(t){if(void 0===t)return this.rule.hidden;var e=this.headerFeatures(),r=this.features();if(e&&e.length){var n=this.applyFeatureProperty(e,"hidden",t);this.headerFeatures.apply(this,i(n))}else if(r&&r.length){n=this.applyFeatureProperty(r,"hidden",t);this.features.apply(this,i(n))}else this.rule.hidden=t;return this},p.prototype.args=function(t){if(!t)return this.rule.args;var e=this.headerFeatures(),r=this.features();if(e&&e.length){var n=this.applyFeatureProperty(e,"args",t);this.headerFeatures.apply(this,i(n))}else if(r&&r.length){n=this.applyFeatureProperty(r,"args",t);this.features.apply(this,i(n))}else this.rule.args=t;return this},p.prototype.applyFeatureProperty=function(t,e,r){for(var i=[],n=0;n<t.length;n++){if("string"==typeof t[n])(s={})[t[n]]={},s[t[n]][e]=r,i.push(s);else if("object"==o(t[n])){var s,a=Object.keys(t[n])[0];if(a)(s=t[n])[a][e]=r,i.push(s)}}return i},p.prototype.unpackFeatures=function(t){for(var e={},r="",i=0;i<t.length;i++){if("string"==typeof t[i])r+='"'+t[i]+'"';else if("object"==o(t[i])){var n=Object.keys(t[i])[0];for(var s in r+='"'+n+'"',t[i][n])e[s]=t[i][n][s]}i<t.length-1&&(r+=", ")}for(var a=0;a<Object.keys(e).length;a++){var u=Object.keys(e)[a],h=e[u];r+=")."+u+"(","function"==typeof h?r+=h:"string"==typeof h?r+='"'+h+'"':"object"==o(h)&&(r+=JSON.stringify(h))}return r},p.prototype.prettyPrint=function(){return this.pattern&&(str=this.pattern.prettyPrint()),void 0!==this.renderer()&&(str+=".renderer('"+this.renderer()+"')"),void 0!==this.render()&&(str+=".render("+this.render+")"),void 0!==this.compare()&&(str+=".compare("+this.compare()+")"),void 0!==this.mode()&&(str+=".mode('"+this.mode()+"')"),void 0!==this.collapse()&&(str+=".collapse("+this.collapse()+")"),void 0!==this.hidden()&&(str+=".hidden("+this.hidden()+")"),void 0!==this.view()&&(str+=".view('"+this.view()+"')"),void 0!==this.showDisabledButtons()&&(str+=".showDisabledButtons("+this.showDisabledButtons()+")"),void 0!==this.header()&&(str+=".header("+this.header()+")"),void 0!==this.style()&&(str+='.style("'+this.style()+'")'),void 0!==this.headerStyle()&&(str+='.headerStyle("'+this.headerStyle()+'")'),void 0!==this.args()&&(str+=".args("+JSON.stringify(this.args())+")"),void 0!==this.showEmpty()&&(str+=".showEmpty("+this.show_empty()+")"),void 0!==this.dataviewer()&&(str+='.dataviewer("'+this.dataviewer()+'")'),void 0!==this.features()&&(str+=".features("+this.unpackFeatures(this.features())+")"),void 0!==this.headerFeatures()&&(str+=".headerFeatures("+this.unpackFeatures(this.headerFeatures())+")"),str},t.exports=h},function(t,e,r){t.exports={WOQLClient:r(32),UTILS:r(0),View:r(60),WOQL:r(5),WOQLResult:r(24),WOQLTable:r(23),WOQLGraph:r(27),axiosInstance:r(9)}},function(t,e,r){function i(t){return(i="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}var n=r(6),o=r(33),s=r(7),a=r(56),u=r(57),h=r(5);
/**
* @file Javascript WOQL client object
* @license Apache Version 2
* Simple Javascript Client for accessing the Terminus DB API
* Constructor
* @param {serverUrl} string
* @param {object} params - a json object with the following connection parameters:
* key: api key for basic auth
* user: basic auth user id
* jwt: jwt token
* jwt_user: jwt user id
* organization: set organization to this id
* db: set cursor to this db
* repo: set cursor to this repo
* branch: set branch to this id
*/
function p(t,e){this.connectionConfig=new u(t,e),this.connection=new a}p.CONST=n,p.prototype.copy=function(){var t=new p(this.server());return t.connection=this.connection,t.connectionConfig=this.connectionConfig.copy(),t},p.prototype.server=function(){return this.connectionConfig.serverURL()},p.prototype.api=function(){return this.connectionConfig.apiURL()},p.prototype.organization=function(t){return void 0!==t?this.connectionConfig.setOrganization(t):this.connectionConfig.organization()},p.prototype.user=function(){return this.connection.get_user()},p.prototype.uid=function(){return this.user().id},p.prototype.user_organization=function(){return this.uid()},p.prototype.databases=function(t){return t&&this.connection.set_databases(t),this.connection.get_databases()},p.prototype.get_database=function(t,e){return t=t||this.db(),e=e||this.organization(),this.connection.get_database(t,e)},p.prototype.db=function(t){return void 0!==t&&this.connectionConfig.setDB(t),this.connectionConfig.db()},p.prototype.set_system_db=function(){this.db(this.connectionConfig.system_db)},p.prototype.repo=function(t){return void 0!==t&&this.connectionConfig.setRepo(t),this.connectionConfig.repo()},p.prototype.checkout=function(t){return void 0!==t&&this.connectionConfig.setBranch(t),this.connectionConfig.branch()},p.prototype.ref=function(t){return void 0!==t&&this.connectionConfig.setRef(t),this.connectionConfig.ref()},p.prototype.local_auth=function(t,e,r){return void 0!==t&&this.connectionConfig.setLocalAuth(t,e,r),this.connectionConfig.localAuth()},p.prototype.remote_auth=function(t){return void 0!==t&&this.connectionConfig.setRemoteAuth(t),this.connectionConfig.remoteAuth()},p.prototype.user=function(){return this.connection.get_user()},p.prototype.author=function(t){return t&&(this.connection.user.author=t),this.connection.author()||this.connection.user.id||this.connectionConfig.local_user()},p.prototype.set=function(t){this.connectionConfig.update(t)},p.prototype.resource=function(t,e){var r="".concat(this.organization(),"/").concat(this.db(),"/");return"db"==t?r:"meta"==t?"".concat(r,"_meta"):(r+="".concat(this.repo()),"repo"==t?r:"commits"==t?"".concat(r,"/_commits"):(e=e||("ref"==t?this.ref():this.checkout()),"branch"==t?"".concat(r,"/branch/").concat(e):"ref"==t?"".concat(r,"/commit/").concat(e):void 0))},p.prototype.connect=function(t){var e=this;if(t&&this.connectionConfig.update(t),!this.server()){var r=t&&t.server?t.server:"Missing URL";return Promise.reject(new URIError(s.getInvalidURIMessage(r,n.CONNECT)))}return this.dispatch(n.CONNECT,this.api()).then((function(t){return e.connection.setCapabilities(t),t}))},p.prototype.createDatabase=function(t,e,r){if(r=r||this.user_organization(),this.organization(r),t&&this.db(t))return this.dispatch(n.CREATE_DATABASE,this.connectionConfig.dbURL(),e);var i="Create database parameter error - you must specify a valid database id - ".concat(t," is invalid");return Promise.reject(new Error(s.getInvalidParameterMessage(n.CREATE_DATABASE,i)))},p.prototype.deleteDatabase=function(t,e){if(e=e||this.organization(),this.organization(e),t&&this.db(t))return this.dispatch(n.DELETE_DATABASE,this.connectionConfig.dbURL());var r="Delete database parameter error - you must specify a valid database id - ".concat(t," is invalid");return Promise.reject(new Error(s.getInvalidParameterMessage(n.DELETE_DATABASE,r)))},p.prototype.createGraph=function(t,e,r){if(t&&-1!=["inference","schema","instance"].indexOf(t)&&e&&r){var i=this.generateCommitInfo(r);return this.dispatch(n.CREATE_GRAPH,this.connectionConfig.graphURL(t,e),i)}return Promise.reject(new Error(s.getInvalidParameterMessage(n.CREATE_GRAPH,"Create graph parameter error - you must specify a valid type (inference, instance, schema), graph id and commit message")))},p.prototype.deleteGraph=function(t,e,r){if(t&&-1!=["inference","schema","instance"].indexOf(t)&&e){var i=this.generateCommitInfo(r);return this.dispatch(n.DELETE_GRAPH,this.connectionConfig.graphURL(t,e),i)}return Promise.reject(new Error(s.getInvalidParameterMessage(n.DELETE_GRAPH,"Delete graph parameter error - you must specify a valid type (inference, instance, schema), graph id and commit message")))},p.prototype.getTriples=function(t,e){if(t&&e)return this.dispatch(n.GET_TRIPLES,this.connectionConfig.triplesURL(t,e));return Promise.reject(new Error(s.getInvalidParameterMessage(n.GET_TRIPLES,"Get triples parameter error - you must specify a valid graph type (inference, instance, schema), and graph id")))},p.prototype.updateTriples=function(t,e,r,i){if(i&&r&&e&&t){var o=this.generateCommitInfo(i);return o.turtle=r,this.dispatch(n.UPDATE_TRIPLES,this.connectionConfig.triplesURL(t,e),o)}return Promise.reject(new Error(s.getInvalidParameterMessage(n.UPDATE_TRIPLES,"Update triples parameter error - you must specify a valid graph id, graph type, turtle contents and commit message")))},p.prototype.query=function(t,e){if(e=e||"Commit generated with javascript client without message",t&&t.json&&(!t.containsUpdate()||e)){t.context(this.connection.getContextForOutboundQuery(t,this.db(),this.organization()));var r=t.containsUpdate()?this.generateCommitInfo(e):{};return r.query=t.json(),this.dispatch(n.WOQL_QUERY,this.connectionConfig.queryURL(),r)}var i="WOQL query parameter error";return t&&t.json&&t.containsUpdate()&&!e?i+=" - you must include a textual commit message to perform this update":i+=" - you must specify a valid WOQL Query",Promise.reject(new Error(s.getInvalidParameterMessage(n.WOQL_QUERY,i)))},p.prototype.branch=function(t,e){if(t){var r=this.ref()?{origin:"".concat(this.organization(),"/").concat(this.db(),"/").concat(this.repo(),"/commit/").concat(this.ref())}:{origin:"".concat(this.organization(),"/").concat(this.db(),"/").concat(this.repo(),"/branch/").concat(this.checkout())};return e&&!0===e&&(r={}),this.dispatch(n.BRANCH,this.connectionConfig.branchURL(t),r)}return Promise.reject(new Error(s.getInvalidParameterMessage(n.BRANCH,"Branch parameter error - you must specify a valid new branch id")))},p.prototype.pull=function(t){var e=this.prepareRevisionControlArgs(t);if(e&&e.remote&&e.remote_branch)return this.dispatch(n.PULL,this.connectionConfig.pullURL(),e);return Promise.reject(new Error(s.getInvalidParameterMessage(n.PULL,"Pull parameter error - you must specify a valid remote source and branch to pull from")))},p.prototype.fetch=function(t){return this.dispatch(n.FETCH,this.connectionConfig.fetchURL(t))},p.prototype.push=function(t){var e=this.prepareRevisionControlArgs(t);if(e&&e.remote&&e.remote_branch)return this.dispatch(n.PUSH,this.connectionConfig.pushURL(),e);return Promise.reject(new Error(s.getInvalidParameterMessage(n.PUSH,"Push parameter error - you must specify a valid remote target")))},p.prototype.rebase=function(t){var e=this.prepareRevisionControlArgs(t);if(e&&e.rebase_from)return this.dispatch(n.REBASE,this.connectionConfig.rebaseURL(this.checkout()),e);return Promise.reject(new Error(s.getInvalidParameterMessage(n.REBASE,"Rebase parameter error - you must specify a valid rebase source to rebase from")))},p.prototype.clonedb=function(t,e,r){r=r||this.user_organization(),this.organization(r);var i=this.prepareRevisionControlArgs(t);if(e&&i&&i.remote_url)return this.dispatch(n.CLONE,this.connectionConfig.cloneURL(e),i);return Promise.reject(new Error(s.getInvalidParameterMessage(n.BRANCH,"Clone parameter error - you must specify a valid id for the cloned database")))},p.prototype.dispatch=function(t,e,r){return e?o(e,t,r,this.local_auth(),this.remote_auth()):Promise.reject(new Error(s.getInvalidParameterMessage(t,this.connectionConfig.connection_error)))},p.prototype.generateCommitInfo=function(t,e){return e||(e=this.author()),{commit_info:{author:e,message:t}}},p.prototype.prepareRevisionControlArgs=function(t){return!!t&&(t.author||(t.author=this.author()),t)},p.prototype._load_db_prefixes=function(t){var e=this;t=t||this.databases();for(var r=[],i=0;i<t.length;i++){var n="".concat(t[i].organization,"/").concat(t[i].id,"/local/_commits"),o=["Prefix_"+i,"IRI_"+i,"Prefix Pair IRI_"+i];r.push(h.lib().prefixes(!1,o,n))}var s=this.copy();s.set_system_db();var a=h.or.apply(h,r);return s.query(a).then((function(r){if(r&&r.bindings&&r.bindings.length){for(var i=0;i<r.bindings.length;i++)for(var n=r.bindings[i],o=0;o<t.length;o++){var s=t[o];s.prefix_pairs||(s.prefix_pairs={}),n["Prefix_"+o]&&n["Prefix_"+o]["@value"]&&n["IRI_"+o]["@value"]&&(s.prefix_pairs[n["Prefix_"+o]["@value"]]=n["IRI_"+o]["@value"])}e.connection.buildContextsFromPrefixes()}}))},p.prototype.getClassFrame=function(t){if(t)return opts={class:t},this.dispatch(n.CLASS_FRAME,this.connectionConfig.classFrameURL(t),opts);return Promise.reject(new Error(s.getInvalidParameterMessage(n.UPDATE_SCHEMA,"Get class frame parameter error - you must specify a valid class id (URI)")))},p.prototype.getDatabase=function(){return this.dispatch(n.READ_DATABASE,this.connectionConfig.dbURL())},p.prototype.updateDatabase=function(t){var e=t.id||this.db(),r=t.organization||this.organization();return this.createDatabase(e,t,r)},p.prototype.user_organizations=function(){return this.connection.get_organizations()},p.prototype.get_organization=function(t){return this.connection.get_organization(t)},p.prototype.organizations=function(t){return t&&this.connection.set_organizations(t),this.connection.get_organization()},p.prototype.action_permitted=function(t,e){return this.connection.actions_permitted(t,e)},p.prototype.createUser=function(t,e){if(t)return this.dispatch(n.CREATE_USER,this.connectionConfig.userURL(),e);return Promise.reject(new Error(s.getInvalidParameterMessage(n.CREATE_USER,"Create user parameter error - you must specify a valid user id")))},p.prototype.getUser=function(t){return this.dispatch(n.READ_USER,this.connectionConfig.userURL(t))},p.prototype.updateUser=function(t,e){if(t)return this.dispatch(n.UPDATE_USER,this.connectionConfig.userURL(t),e);return Promise.reject(new Error(s.getInvalidParameterMessage(n.UPDATE_USER,"Update user parameter error - you must specify a valid user id")))},p.prototype.deleteUser=function(t){if(t)return this.dispatch(n.DELETE_USER,this.connectionConfig.userURL(t));return Promise.reject(new Error(s.getInvalidParameterMessage(n.DELETE_USER,"Delete user parameter error - you must specify a valid user id")))},p.prototype.createOrganization=function(t,e){if(t)return this.dispatch(n.CREATE_ORGANIZATION,this.connectionConfig.organizationURL(),e);return Promise.reject(new Error(s.getInvalidParameterMessage(n.CREATE_ORGANIZATION,"Create organization parameter error - you must specify a valid organization id")))},p.prototype.getOrganization=function(t){return this.dispatch(n.READ_ORGANIZATION,this.connectionConfig.organizationURL(t))},p.prototype.updateOrganization=function(t,e){if(t)return this.dispatch(n.CREATE_ORGANIZATION,this.connectionConfig.organizationURL(t),e);return Promise.reject(new Error(s.getInvalidParameterMessage(n.UPDATE_ORGANIZATION,"Update organization parameter error - you must specify a valid organization id")))},p.prototype.deleteOrganization=function(t){if(uid)return this.dispatch(n.DELETE_ORGANIZATION,this.connectionConfig.organizationURL(t));return Promise.reject(new Error(s.getInvalidParameterMessage(n.DELETE_ORGANIZATION,"Delete organization parameter error - you must specify a valid organization id")))},p.prototype.getRoles=function(t,e,r){var o={};return"object"!=("undefined"==typeof uids?"undefined":i(uids))||Array.isArray(uids)||(o=uids),t&&(o.agent_name=t),r&&(o.database_name=r),e&&(o.organization_name=e),this.dispatch(n.GET_ROLES,this.connectionConfig.rolesURL(),o)},p.prototype.updateRoles=function(t,e,r,o){var s={};return"object"!=i(t)||Array.isArray(t)?(t&&(s.agent_names=t),r&&(s.database_name=r),e&&(s.organization_name=e),s.actions=o||[]):s=t,this.dispatch(n.UPDATE_ROLES,this.connectionConfig.updateRolesURL(),s)},t.exports=p},function(t,e,r){(function(e){var i=r(9),n=r(0),o=r(6),s=r(7);function a(t){try{return btoa(t)}catch(r){return e.from(t).toString("base64")}}
/**
* @file Dispatch Request
* @license Apache Version 2
* @description Functions for dispatching API requests via the axios library.
* @param {String} url API endpoint URL
* @param {String} action API action
* @param {Object} payload data to be transmitted to endpoint
* @param {String} key optional basic auth string to be passed
*/t.exports=function(t,e,r,u){var h=arguments.length>4&&void 0!==arguments[4]?arguments[4]:null,p={mode:"cors",redirect:"follow",referrer:"client"};if(u&&"basic"==u.type){var c=a(u.user+":"+u.key);p.headers={Authorization:"Basic ".concat(c)}}else u&&"jwt"==u.type&&(p.headers={Authorization:"Bearer ".concat(u.key)});if(h&&"jwt"==h.type)p.headers||(p.headers={}),p.headers["Authorization-Remote"]="Bearer ".concat(h.key);else if(h&&"basic"==h.type){var l=a(h.user+":"+h.key);p.headers||(p.headers={}),p.headers["Authorization-Remote"]="Basic ".concat(l)}switch(e){case o.DELETE_DATABASE:case o.DELETE_GRAPH:case o.DELETE_USER:case o.DELETE_ORGANIZATION:return r&&(p.headers=p.headers?p.headers:{},p.headers["Content-Type"]="application/json",p.data=r),i.delete(t,p).then((function(t){return t.data})).catch((function(e){var r=new Error(s.getAPIErrorMessage(t,p,e));throw e.response&&e.response.data&&(r.data=e.response.data),r}));case o.GET_TRIPLES:case o.READ_USER:case o.READ_DATABASE:case o.READ_ORGANIZATION:case o.CONNECT:case o.CLASS_FRAME:if(r){var d=n.URIEncodePayload(r);d&&(t+="?".concat(d))}return i.get(t,p).then((function(t){return t.data})).catch((function(e){var r=new Error(s.getAPIErrorMessage(t,p,e));throw e.response&&e.response.data&&(r.data=e.response.data),r}));default:return p.headers=p.headers?p.headers:{},p.headers["Content-Type"]="application/json",i.post(t,r,p).then((function(t){return t.data})).catch((function(e){var r=new Error(s.getAPIErrorMessage(t,p,e));throw e.response&&e.response.data&&(r.data=e.response.data),r}))}}}).call(this,r(34).Buffer)},function(t,e,r){"use strict";(function(t){
/*!
* The buffer module from node.js, for the browser.
*
* @author Feross Aboukhadijeh <http://feross.org>
* @license MIT
*/
var i=r(36),n=r(37),o=r(38);function s(){return u.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function a(t,e){if(s()<e)throw new RangeError("Invalid typed array length");return u.TYPED_ARRAY_SUPPORT?(t=new Uint8Array(e)).__proto__=u.prototype:(null===t&&(t=new u(e)),t.length=e),t}function u(t,e,r){if(!(u.TYPED_ARRAY_SUPPORT||this instanceof u))return new u(t,e,r);if("number"==typeof t){if("string"==typeof e)throw new Error("If encoding is specified then the first argument must be a string");return c(this,t)}return h(this,t,e,r)}function h(t,e,r,i){if("number"==typeof e)throw new TypeError('"value" argument must not be a number');return"undefined"!=typeof ArrayBuffer&&e instanceof ArrayBuffer?function(t,e,r,i){if(e.byteLength,r<0||e.byteLength<r)throw new RangeError("'offset' is out of bounds");if(e.byteLength<r+(i||0))throw new RangeError("'length' is out of bounds");e=void 0===r&&void 0===i?new Uint8Array(e):void 0===i?new Uint8Array(e,r):new Uint8Array(e,r,i);u.TYPED_ARRAY_SUPPORT?(t=e).__proto__=u.prototype:t=l(t,e);return t}(t,e,r,i):"string"==typeof e?function(t,e,r){"string"==typeof r&&""!==r||(r="utf8");if(!u.isEncoding(r))throw new TypeError('"encoding" must be a valid string encoding');var i=0|f(e,r),n=(t=a(t,i)).write(e,r);n!==i&&(t=t.slice(0,n));return t}(t,e,r):function(t,e){if(u.isBuffer(e)){var r=0|d(e.length);return 0===(t=a(t,r)).length||e.copy(t,0,0,r),t}if(e){if("undefined"!=typeof ArrayBuffer&&e.buffer instanceof ArrayBuffer||"length"in e)return"number"!=typeof e.length||(i=e.length)!=i?a(t,0):l(t,e);if("Buffer"===e.type&&o(e.data))return l(t,e.data)}var i;throw new TypeError("First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.")}(t,e)}function p(t){if("number"!=typeof t)throw new TypeError('"size" argument must be a number');if(t<0)throw new RangeError('"size" argument must not be negative')}function c(t,e){if(p(e),t=a(t,e<0?0:0|d(e)),!u.TYPED_ARRAY_SUPPORT)for(var r=0;r<e;++r)t[r]=0;return t}function l(t,e){var r=e.length<0?0:0|d(e.length);t=a(t,r);for(var i=0;i<r;i+=1)t[i]=255&e[i];return t}function d(t){if(t>=s())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+s().toString(16)+" bytes");return 0|t}function f(t,e){if(u.isBuffer(t))return t.length;if("undefined"!=typeof ArrayBuffer&&"function"==typeof ArrayBuffer.isView&&(ArrayBuffer.isView(t)||t instanceof ArrayBuffer))return t.byteLength;"string"!=typeof t&&(t=""+t);var r=t.length;if(0===r)return 0;for(var i=!1;;)switch(e){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":case void 0:return B(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return V(t).length;default:if(i)return B(t).length;e=(""+e).toLowerCase(),i=!0}}function y(t,e,r){var i=!1;if((void 0===e||e<0)&&(e=0),e>this.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if((r>>>=0)<=(e>>>=0))return"";for(t||(t="utf8");;)switch(t){case"hex":return j(this,e,r);case"utf8":case"utf-8":return A(this,e,r);case"ascii":return I(this,e,r);case"latin1":case"binary":return C(this,e,r);case"base64":return R(this,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return P(this,e,r);default:if(i)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),i=!0}}function m(t,e,r){var i=t[e];t[e]=t[r],t[r]=i}function g(t,e,r,i,n){if(0===t.length)return-1;if("string"==typeof r?(i=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),r=+r,isNaN(r)&&(r=n?0:t.length-1),r<0&&(r=t.length+r),r>=t.length){if(n)return-1;r=t.length-1}else if(r<0){if(!n)return-1;r=0}if("string"==typeof e&&(e=u.from(e,i)),u.isBuffer(e))return 0===e.length?-1:v(t,e,r,i,n);if("number"==typeof e)return e&=255,u.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?n?Uint8Array.prototype.indexOf.call(t,e,r):Uint8Array.prototype.lastIndexOf.call(t,e,r):v(t,[e],r,i,n);throw new TypeError("val must be string, number or Buffer")}function v(t,e,r,i,n){var o,s=1,a=t.length,u=e.length;if(void 0!==i&&("ucs2"===(i=String(i).toLowerCase())||"ucs-2"===i||"utf16le"===i||"utf-16le"===i)){if(t.length<2||e.length<2)return-1;s=2,a/=2,u/=2,r/=2}function h(t,e){return 1===s?t[e]:t.readUInt16BE(e*s)}if(n){var p=-1;for(o=r;o<a;o++)if(h(t,o)===h(e,-1===p?0:o-p)){if(-1===p&&(p=o),o-p+1===u)return p*s}else-1!==p&&(o-=o-p),p=-1}else for(r+u>a&&(r=a-u),o=r;o>=0;o--){for(var c=!0,l=0;l<u;l++)if(h(t,o+l)!==h(e,l)){c=!1;break}if(c)return o}return-1}function _(t,e,r,i){r=Number(r)||0;var n=t.length-r;i?(i=Number(i))>n&&(i=n):i=n;var o=e.length;if(o%2!=0)throw new TypeError("Invalid hex string");i>o/2&&(i=o/2);for(var s=0;s<i;++s){var a=parseInt(e.substr(2*s,2),16);if(isNaN(a))return s;t[r+s]=a}return s}function w(t,e,r,i){return k(B(e,t.length-r),t,r,i)}function b(t,e,r,i){return k(function(t){for(var e=[],r=0;r<t.length;++r)e.push(255&t.charCodeAt(r));return e}(e),t,r,i)}function q(t,e,r,i){return b(t,e,r,i)}function x(t,e,r,i){return k(V(e),t,r,i)}function O(t,e,r,i){return k(function(t,e){for(var r,i,n,o=[],s=0;s<t.length&&!((e-=2)<0);++s)r=t.charCodeAt(s),i=r>>8,n=r%256,o.push(n),o.push(i);return o}(e,t.length-r),t,r,i)}function R(t,e,r){return 0===e&&r===t.length?i.fromByteArray(t):i.fromByteArray(t.slice(e,r))}function A(t,e,r){r=Math.min(t.length,r);for(var i=[],n=e;n<r;){var o,s,a,u,h=t[n],p=null,c=h>239?4:h>223?3:h>191?2:1;if(n+c<=r)switch(c){case 1:h<128&&(p=h);break;case 2:128==(192&(o=t[n+1]))&&(u=(31&h)<<6|63&o)>127&&(p=u);break;case 3:o=t[n+1],s=t[n+2],128==(192&o)&&128==(192&s)&&(u=(15&h)<<12|(63&o)<<6|63&s)>2047&&(u<55296||u>57343)&&(p=u);break;case 4:o=t[n+1],s=t[n+2],a=t[n+3],128==(192&o)&&128==(192&s)&&128==(192&a)&&(u=(15&h)<<18|(63&o)<<12|(63&s)<<6|63&a)>65535&&u<1114112&&(p=u)}null===p?(p=65533,c=1):p>65535&&(p-=65536,i.push(p>>>10&1023|55296),p=56320|1023&p),i.push(p),n+=c}return function(t){var e=t.length;if(e<=4096)return String.fromCharCode.apply(String,t);var r="",i=0;for(;i<e;)r+=String.fromCharCode.apply(String,t.slice(i,i+=4096));return r}(i)}e.Buffer=u,e.SlowBuffer=function(t){+t!=t&&(t=0);return u.alloc(+t)},e.INSPECT_MAX_BYTES=50,u.TYPED_ARRAY_SUPPORT=void 0!==t.TYPED_ARRAY_SUPPORT?t.TYPED_ARRAY_SUPPORT:function(){try{var t=new Uint8Array(1);return t.__proto__={__proto__:Uint8Array.prototype,foo:function(){return 42}},42===t.foo()&&"function"==typeof t.subarray&&0===t.subarray(1,1).byteLength}catch(t){return!1}}(),e.kMaxLength=s(),u.poolSize=8192,u._augment=function(t){return t.__proto__=u.prototype,t},u.from=function(t,e,r){return h(null,t,e,r)},u.TYPED_ARRAY_SUPPORT&&(u.prototype.__proto__=Uint8Array.prototype,u.__proto__=Uint8Array,"undefined"!=typeof Symbol&&Symbol.species&&u[Symbol.species]===u&&Object.defineProperty(u,Symbol.species,{value:null,configurable:!0})),u.alloc=function(t,e,r){return function(t,e,r,i){return p(e),e<=0?a(t,e):void 0!==r?"string"==typeof i?a(t,e).fill(r,i):a(t,e).fill(r):a(t,e)}(null,t,e,r)},u.allocUnsafe=function(t){return c(null,t)},u.allocUnsafeSlow=function(t){return c(null,t)},u.isBuffer=function(t){return!(null==t||!t._isBuffer)},u.compare=function(t,e){if(!u.isBuffer(t)||!u.isBuffer(e))throw new TypeError("Arguments must be Buffers");if(t===e)return 0;for(var r=t.length,i=e.length,n=0,o=Math.min(r,i);n<o;++n)if(t[n]!==e[n]){r=t[n],i=e[n];break}return r<i?-1:i<r?1:0},u.isEncoding=function(t){switch(String(t).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},u.concat=function(t,e){if(!o(t))throw new TypeError('"list" argument must be an Array of Buffers');if(0===t.length)return u.alloc(0);var r;if(void 0===e)for(e=0,r=0;r<t.length;++r)e+=t[r].length;var i=u.allocUnsafe(e),n=0;for(r=0;r<t.length;++r){var s=t[r];if(!u.isBuffer(s))throw new TypeError('"list" argument must be an Array of Buffers');s.copy(i,n),n+=s.length}return i},u.byteLength=f,u.prototype._isBuffer=!0,u.prototype.swap16=function(){var t=this.length;if(t%2!=0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(var e=0;e<t;e+=2)m(this,e,e+1);return this},u.prototype.swap32=function(){var t=this.length;if(t%4!=0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(var e=0;e<t;e+=4)m(this,e,e+3),m(this,e+1,e+2);return this},u.prototype.swap64=function(){var t=this.length;if(t%8!=0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(var e=0;e<t;e+=8)m(this,e,e+7),m(this,e+1,e+6),m(this,e+2,e+5),m(this,e+3,e+4);return this},u.prototype.toString=function(){var t=0|this.length;return 0===t?"":0===arguments.length?A(this,0,t):y.apply(this,arguments)},u.prototype.equals=function(t){if(!u.isBuffer(t))throw new TypeError("Argument must be a Buffer");return this===t||0===u.compare(this,t)},u.prototype.inspect=function(){var t="",r=e.INSPECT_MAX_BYTES;return this.length>0&&(t=this.toString("hex",0,r).match(/.{2}/g).join(" "),this.length>r&&(t+=" ... ")),"<Buffer "+t+">"},u.prototype.compare=function(t,e,r,i,n){if(!u.isBuffer(t))throw new TypeError("Argument must be a Buffer");if(void 0===e&&(e=0),void 0===r&&(r=t?t.length:0),void 0===i&&(i=0),void 0===n&&(n=this.length),e<0||r>t.length||i<0||n>this.length)throw new RangeError("out of range index");if(i>=n&&e>=r)return 0;if(i>=n)return-1;if(e>=r)return 1;if(this===t)return 0;for(var o=(n>>>=0)-(i>>>=0),s=(r>>>=0)-(e>>>=0),a=Math.min(o,s),h=this.slice(i,n),p=t.slice(e,r),c=0;c<a;++c)if(h[c]!==p[c]){o=h[c],s=p[c];break}return o<s?-1:s<o?1:0},u.prototype.includes=function(t,e,r){return-1!==this.indexOf(t,e,r)},u.prototype.indexOf=function(t,e,r){return g(this,t,e,r,!0)},u.prototype.lastIndexOf=function(t,e,r){return g(this,t,e,r,!1)},u.prototype.write=function(t,e,r,i){if(void 0===e)i="utf8",r=this.length,e=0;else if(void 0===r&&"string"==typeof e)i=e,r=this.length,e=0;else{if(!isFinite(e))throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");e|=0,isFinite(r)?(r|=0,void 0===i&&(i="utf8")):(i=r,r=void 0)}var n=this.length-e;if((void 0===r||r>n)&&(r=n),t.length>0&&(r<0||e<0)||e>this.length)throw new RangeError("Attempt to write outside buffer bounds");i||(i="utf8");for(var o=!1;;)switch(i){case"hex":return _(this,t,e,r);case"utf8":case"utf-8":return w(this,t,e,r);case"ascii":return b(this,t,e,r);case"latin1":case"binary":return q(this,t,e,r);case"base64":return x(this,t,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return O(this,t,e,r);default:if(o)throw new TypeError("Unknown encoding: "+i);i=(""+i).toLowerCase(),o=!0}},u.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function I(t,e,r){var i="";r=Math.min(t.length,r);for(var n=e;n<r;++n)i+=String.fromCharCode(127&t[n]);return i}function C(t,e,r){var i="";r=Math.min(t.length,r);for(var n=e;n<r;++n)i+=String.fromCharCode(t[n]);return i}function j(t,e,r){var i=t.length;(!e||e<0)&&(e=0),(!r||r<0||r>i)&&(r=i);for(var n="",o=e;o<r;++o)n+=U(t[o]);return n}function P(t,e,r){for(var i=t.slice(e,r),n="",o=0;o<i.length;o+=2)n+=String.fromCharCode(i[o]+256*i[o+1]);return n}function D(t,e,r){if(t%1!=0||t<0)throw new RangeError("offset is not uint");if(t+e>r)throw new RangeError("Trying to access beyond buffer length")}function L(t,e,r,i,n,o){if(!u.isBuffer(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>n||e<o)throw new RangeError('"value" argument is out of bounds');if(r+i>t.length)throw new RangeError("Index out of range")}function S(t,e,r,i){e<0&&(e=65535+e+1);for(var n=0,o=Math.min(t.length-r,2);n<o;++n)t[r+n]=(e&255<<8*(i?n:1-n))>>>8*(i?n:1-n)}function E(t,e,r,i){e<0&&(e=4294967295+e+1);for(var n=0,o=Math.min(t.length-r,4);n<o;++n)t[r+n]=e>>>8*(i?n:3-n)&255}function T(t,e,r,i,n,o){if(r+i>t.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function Q(t,e,r,i,o){return o||T(t,0,r,4),n.write(t,e,r,i,23,4),r+4}function N(t,e,r,i,o){return o||T(t,0,r,8),n.write(t,e,r,i,52,8),r+8}u.prototype.slice=function(t,e){var r,i=this.length;if((t=~~t)<0?(t+=i)<0&&(t=0):t>i&&(t=i),(e=void 0===e?i:~~e)<0?(e+=i)<0&&(e=0):e>i&&(e=i),e<t&&(e=t),u.TYPED_ARRAY_SUPPORT)(r=this.subarray(t,e)).__proto__=u.prototype;else{var n=e-t;r=new u(n,void 0);for(var o=0;o<n;++o)r[o]=this[o+t]}return r},u.prototype.readUIntLE=function(t,e,r){t|=0,e|=0,r||D(t,e,this.length);for(var i=this[t],n=1,o=0;++o<e&&(n*=256);)i+=this[t+o]*n;return i},u.prototype.readUIntBE=function(t,e,r){t|=0,e|=0,r||D(t,e,this.length);for(var i=this[t+--e],n=1;e>0&&(n*=256);)i+=this[t+--e]*n;return i},u.prototype.readUInt8=function(t,e){return e||D(t,1,this.length),this[t]},u.prototype.readUInt16LE=function(t,e){return e||D(t,2,this.length),this[t]|this[t+1]<<8},u.prototype.readUInt16BE=function(t,e){return e||D(t,2,this.length),this[t]<<8|this[t+1]},u.prototype.readUInt32LE=function(t,e){return e||D(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},u.prototype.readUInt32BE=function(t,e){return e||D(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},u.prototype.readIntLE=function(t,e,r){t|=0,e|=0,r||D(t,e,this.length);for(var i=this[t],n=1,o=0;++o<e&&(n*=256);)i+=this[t+o]*n;return i>=(n*=128)&&(i-=Math.pow(2,8*e)),i},u.prototype.readIntBE=function(t,e,r){t|=0,e|=0,r||D(t,e,this.length);for(var i=e,n=1,o=this[t+--i];i>0&&(n*=256);)o+=this[t+--i]*n;return o>=(n*=128)&&(o-=Math.pow(2,8*e)),o},u.prototype.readInt8=function(t,e){return e||D(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},u.prototype.readInt16LE=function(t,e){e||D(t,2,this.length);var r=this[t]|this[t+1]<<8;return 32768&r?4294901760|r:r},u.prototype.readInt16BE=function(t,e){e||D(t,2,this.length);var r=this[t+1]|this[t]<<8;return 32768&r?4294901760|r:r},u.prototype.readInt32LE=function(t,e){return e||D(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},u.prototype.readInt32BE=function(t,e){return e||D(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},u.prototype.readFloatLE=function(t,e){return e||D(t,4,this.length),n.read(this,t,!0,23,4)},u.prototype.readFloatBE=function(t,e){return e||D(t,4,this.length),n.read(this,t,!1,23,4)},u.prototype.readDoubleLE=function(t,e){return e||D(t,8,this.length),n.read(this,t,!0,52,8)},u.prototype.readDoubleBE=function(t,e){return e||D(t,8,this.length),n.read(this,t,!1,52,8)},u.prototype.writeUIntLE=function(t,e,r,i){(t=+t,e|=0,r|=0,i)||L(this,t,e,r,Math.pow(2,8*r)-1,0);var n=1,o=0;for(this[e]=255&t;++o<r&&(n*=256);)this[e+o]=t/n&255;return e+r},u.prototype.writeUIntBE=function(t,e,r,i){(t=+t,e|=0,r|=0,i)||L(this,t,e,r,Math.pow(2,8*r)-1,0);var n=r-1,o=1;for(this[e+n]=255&t;--n>=0&&(o*=256);)this[e+n]=t/o&255;return e+r},u.prototype.writeUInt8=function(t,e,r){return t=+t,e|=0,r||L(this,t,e,1,255,0),u.TYPED_ARRAY_SUPPORT||(t=Math.floor(t)),this[e]=255&t,e+1},u.prototype.writeUInt16LE=function(t,e,r){return t=+t,e|=0,r||L(this,t,e,2,65535,0),u.TYPED_ARRAY_SUPPORT?(this[e]=255&t,this[e+1]=t>>>8):S(this,t,e,!0),e+2},u.prototype.writeUInt16BE=function(t,e,r){return t=+t,e|=0,r||L(this,t,e,2,65535,0),u.TYPED_ARRAY_SUPPORT?(this[e]=t>>>8,this[e+1]=255&t):S(this,t,e,!1),e+2},u.prototype.writeUInt32LE=function(t,e,r){return t=+t,e|=0,r||L(this,t,e,4,4294967295,0),u.TYPED_ARRAY_SUPPORT?(this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=255&t):E(this,t,e,!0),e+4},u.prototype.writeUInt32BE=function(t,e,r){return t=+t,e|=0,r||L(this,t,e,4,4294967295,0),u.TYPED_ARRAY_SUPPORT?(this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t):E(this,t,e,!1),e+4},u.prototype.writeIntLE=function(t,e,r,i){if(t=+t,e|=0,!i){var n=Math.pow(2,8*r-1);L(this,t,e,r,n-1,-n)}var o=0,s=1,a=0;for(this[e]=255&t;++o<r&&(s*=256);)t<0&&0===a&&0!==this[e+o-1]&&(a=1),this[e+o]=(t/s>>0)-a&255;return e+r},u.prototype.writeIntBE=function(t,e,r,i){if(t=+t,e|=0,!i){var n=Math.pow(2,8*r-1);L(this,t,e,r,n-1,-n)}var o=r-1,s=1,a=0;for(this[e+o]=255&t;--o>=0&&(s*=256);)t<0&&0===a&&0!==this[e+o+1]&&(a=1),this[e+o]=(t/s>>0)-a&255;return e+r},u.prototype.writeInt8=function(t,e,r){return t=+t,e|=0,r||L(this,t,e,1,127,-128),u.TYPED_ARRAY_SUPPORT||(t=Math.floor(t)),t<0&&(t=255+t+1),this[e]=255&t,e+1},u.prototype.writeInt16LE=function(t,e,r){return t=+t,e|=0,r||L(this,t,e,2,32767,-32768),u.TYPED_ARRAY_SUPPORT?(this[e]=255&t,this[e+1]=t>>>8):S(this,t,e,!0),e+2},u.prototype.writeInt16BE=function(t,e,r){return t=+t,e|=0,r||L(this,t,e,2,32767,-32768),u.TYPED_ARRAY_SUPPORT?(this[e]=t>>>8,this[e+1]=255&t):S(this,t,e,!1),e+2},u.prototype.writeInt32LE=function(t,e,r){return t=+t,e|=0,r||L(this,t,e,4,2147483647,-2147483648),u.TYPED_ARRAY_SUPPORT?(this[e]=255&t,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24):E(this,t,e,!0),e+4},u.prototype.writeInt32BE=function(t,e,r){return t=+t,e|=0,r||L(this,t,e,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),u.TYPED_ARRAY_SUPPORT?(this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t):E(this,t,e,!1),e+4},u.prototype.writeFloatLE=function(t,e,r){return Q(this,t,e,!0,r)},u.prototype.writeFloatBE=function(t,e,r){return Q(this,t,e,!1,r)},u.prototype.writeDoubleLE=function(t,e,r){return N(this,t,e,!0,r)},u.prototype.writeDoubleBE=function(t,e,r){return N(this,t,e,!1,r)},u.prototype.copy=function(t,e,r,i){if(r||(r=0),i||0===i||(i=this.length),e>=t.length&&(e=t.length),e||(e=0),i>0&&i<r&&(i=r),i===r)return 0;if(0===t.length||0===this.length)return 0;if(e<0)throw new RangeError("targetStart out of bounds");if(r<0||r>=this.length)throw new RangeError("sourceStart out of bounds");if(i<0)throw new RangeError("sourceEnd out of bounds");i>this.length&&(i=this.length),t.length-e<i-r&&(i=t.length-e+r);var n,o=i-r;if(this===t&&r<e&&e<i)for(n=o-1;n>=0;--n)t[n+e]=this[n+r];else if(o<1e3||!u.TYPED_ARRAY_SUPPORT)for(n=0;n<o;++n)t[n+e]=this[n+r];else Uint8Array.prototype.set.call(t,this.subarray(r,r+o),e);return o},u.prototype.fill=function(t,e,r,i){if("string"==typeof t){if("string"==typeof e?(i=e,e=0,r=this.length):"string"==typeof r&&(i=r,r=this.length),1===t.length){var n=t.charCodeAt(0);n<256&&(t=n)}if(void 0!==i&&"string"!=typeof i)throw new TypeError("encoding must be a string");if("string"==typeof i&&!u.isEncoding(i))throw new TypeError("Unknown encoding: "+i)}else"number"==typeof t&&(t&=255);if(e<0||this.length<e||this.length<r)throw new RangeError("Out of range index");if(r<=e)return this;var o;if(e>>>=0,r=void 0===r?this.length:r>>>0,t||(t=0),"number"==typeof t)for(o=e;o<r;++o)this[o]=t;else{var s=u.isBuffer(t)?t:B(new u(t,i).toString()),a=s.length;for(o=0;o<r-e;++o)this[o+e]=s[o%a]}return this};var W=/[^+\/0-9A-Za-z-_]/g;function U(t){return t<16?"0"+t.toString(16):t.toString(16)}function B(t,e){var r;e=e||1/0;for(var i=t.length,n=null,o=[],s=0;s<i;++s){if((r=t.charCodeAt(s))>55295&&r<57344){if(!n){if(r>56319){(e-=3)>-1&&o.push(239,191,189);continue}if(s+1===i){(e-=3)>-1&&o.push(239,191,189);continue}n=r;continue}if(r<56320){(e-=3)>-1&&o.push(239,191,189),n=r;continue}r=65536+(n-55296<<10|r-56320)}else n&&(e-=3)>-1&&o.push(239,191,189);if(n=null,r<128){if((e-=1)<0)break;o.push(r)}else if(r<2048){if((e-=2)<0)break;o.push(r>>6|192,63&r|128)}else if(r<65536){if((e-=3)<0)break;o.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((e-=4)<0)break;o.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return o}function V(t){return i.toByteArray(function(t){if((t=function(t){return t.trim?t.trim():t.replace(/^\s+|\s+$/g,"")}(t).replace(W,"")).length<2)return"";for(;t.length%4!=0;)t+="=";return t}(t))}function k(t,e,r,i){for(var n=0;n<i&&!(n+r>=e.length||n>=t.length);++n)e[n+r]=t[n];return n}}).call(this,r(35))},function(t,e){var r;r=function(){return this}();try{r=r||new Function("return this")()}catch(t){"object"==typeof window&&(r=window)}t.exports=r},function(t,e,r){"use strict";e.byteLength=function(t){var e=h(t),r=e[0],i=e[1];return 3*(r+i)/4-i},e.toByteArray=function(t){var e,r,i=h(t),s=i[0],a=i[1],u=new o(function(t,e,r){return 3*(e+r)/4-r}(0,s,a)),p=0,c=a>0?s-4:s;for(r=0;r<c;r+=4)e=n[t.charCodeAt(r)]<<18|n[t.charCodeAt(r+1)]<<12|n[t.charCodeAt(r+2)]<<6|n[t.charCodeAt(r+3)],u[p++]=e>>16&255,u[p++]=e>>8&255,u[p++]=255&e;2===a&&(e=n[t.charCodeAt(r)]<<2|n[t.charCodeAt(r+1)]>>4,u[p++]=255&e);1===a&&(e=n[t.charCodeAt(r)]<<10|n[t.charCodeAt(r+1)]<<4|n[t.charCodeAt(r+2)]>>2,u[p++]=e>>8&255,u[p++]=255&e);return u},e.fromByteArray=function(t){for(var e,r=t.length,n=r%3,o=[],s=0,a=r-n;s<a;s+=16383)o.push(p(t,s,s+16383>a?a:s+16383));1===n?(e=t[r-1],o.push(i[e>>2]+i[e<<4&63]+"==")):2===n&&(e=(t[r-2]<<8)+t[r-1],o.push(i[e>>10]+i[e>>4&63]+i[e<<2&63]+"="));return o.join("")};for(var i=[],n=[],o="undefined"!=typeof Uint8Array?Uint8Array:Array,s="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",a=0,u=s.length;a<u;++a)i[a]=s[a],n[s.charCodeAt(a)]=a;function h(t){var e=t.length;if(e%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var r=t.indexOf("=");return-1===r&&(r=e),[r,r===e?0:4-r%4]}function p(t,e,r){for(var n,o,s=[],a=e;a<r;a+=3)n=(t[a]<<16&16711680)+(t[a+1]<<8&65280)+(255&t[a+2]),s.push(i[(o=n)>>18&63]+i[o>>12&63]+i[o>>6&63]+i[63&o]);return s.join("")}n["-".charCodeAt(0)]=62,n["_".charCodeAt(0)]=63},function(t,e){e.read=function(t,e,r,i,n){var o,s,a=8*n-i-1,u=(1<<a)-1,h=u>>1,p=-7,c=r?n-1:0,l=r?-1:1,d=t[e+c];for(c+=l,o=d&(1<<-p)-1,d>>=-p,p+=a;p>0;o=256*o+t[e+c],c+=l,p-=8);for(s=o&(1<<-p)-1,o>>=-p,p+=i;p>0;s=256*s+t[e+c],c+=l,p-=8);if(0===o)o=1-h;else{if(o===u)return s?NaN:1/0*(d?-1:1);s+=Math.pow(2,i),o-=h}return(d?-1:1)*s*Math.pow(2,o-i)},e.write=function(t,e,r,i,n,o){var s,a,u,h=8*o-n-1,p=(1<<h)-1,c=p>>1,l=23===n?Math.pow(2,-24)-Math.pow(2,-77):0,d=i?0:o-1,f=i?1:-1,y=e<0||0===e&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(a=isNaN(e)?1:0,s=p):(s=Math.floor(Math.log(e)/Math.LN2),e*(u=Math.pow(2,-s))<1&&(s--,u*=2),(e+=s+c>=1?l/u:l*Math.pow(2,1-c))*u>=2&&(s++,u/=2),s+c>=p?(a=0,s=p):s+c>=1?(a=(e*u-1)*Math.pow(2,n),s+=c):(a=e*Math.pow(2,c-1)*Math.pow(2,n),s=0));n>=8;t[r+d]=255&a,d+=f,a/=256,n-=8);for(s=s<<n|a,h+=n;h>0;t[r+d]=255&s,d+=f,s/=256,h-=8);t[r+d-f]|=128*y}},function(t,e){var r={}.toString;t.exports=Array.isArray||function(t){return"[object Array]"==r.call(t)}},function(t,e,r){t.exports=r(40)},function(t,e,r){"use strict";var i=r(1),n=r(10),o=r(41),s=r(16);function a(t){var e=new o(t),r=n(o.prototype.request,e);return i.extend(r,o.prototype,e),i.extend(r,e),r}var u=a(r(13));u.Axios=o,u.create=function(t){return a(s(u.defaults,t))},u.Cancel=r(17),u.CancelToken=r(54),u.isCancel=r(12),u.all=function(t){return Promise.all(t)},u.spread=r(55),t.exports=u,t.exports.default=u},function(t,e,r){"use strict";var i=r(1),n=r(11),o=r(42),s=r(43),a=r(16);function u(t){this.defaults=t,this.interceptors={request:new o,response:new o}}u.prototype.request=function(t){"string"==typeof t?(t=arguments[1]||{}).url=arguments[0]:t=t||{},(t=a(this.defaults,t)).method?t.method=t.method.toLowerCase():this.defaults.method?t.method=this.defaults.method.toLowerCase():t.method="get";var e=[s,void 0],r=Promise.resolve(t);for(this.interceptors.request.forEach((function(t){e.unshift(t.fulfilled,t.rejected)})),this.interceptors.response.forEach((function(t){e.push(t.fulfilled,t.rejected)}));e.length;)r=r.then(e.shift(),e.shift());return r},u.prototype.getUri=function(t){return t=a(this.defaults,t),n(t.url,t.params,t.paramsSerializer).replace(/^\?/,"")},i.forEach(["delete","get","head","options"],(function(t){u.prototype[t]=function(e,r){return this.request(i.merge(r||{},{method:t,url:e}))}})),i.forEach(["post","put","patch"],(function(t){u.prototype[t]=function(e,r,n){return this.request(i.merge(n||{},{method:t,url:e,data:r}))}})),t.exports=u},function(t,e,r){"use strict";var i=r(1);function n(){this.handlers=[]}n.prototype.use=function(t,e){return this.handlers.push({fulfilled:t,rejected:e}),this.handlers.length-1},n.prototype.eject=function(t){this.handlers[t]&&(this.handlers[t]=null)},n.prototype.forEach=function(t){i.forEach(this.handlers,(function(e){null!==e&&t(e)}))},t.exports=n},function(t,e,r){"use strict";var i=r(1),n=r(44),o=r(12),s=r(13);function a(t){t.cancelToken&&t.cancelToken.throwIfRequested()}t.exports=function(t){return a(t),t.headers=t.headers||{},t.data=n(t.data,t.headers,t.transformRequest),t.headers=i.merge(t.headers.common||{},t.headers[t.method]||{},t.headers),i.forEach(["delete","get","head","post","put","patch","common"],(function(e){delete t.headers[e]})),(t.adapter||s.adapter)(t).then((function(e){return a(t),e.data=n(e.data,e.headers,t.transformResponse),e}),(function(e){return o(e)||(a(t),e&&e.response&&(e.response.data=n(e.response.data,e.response.headers,t.transformResponse))),Promise.reject(e)}))}},function(t,e,r){"use strict";var i=r(1);t.exports=function(t,e,r){return i.forEach(r,(function(r){t=r(t,e)})),t}},function(t,e,r){"use strict";var i=r(1);t.exports=function(t,e){i.forEach(t,(function(r,i){i!==e&&i.toUpperCase()===e.toUpperCase()&&(t[e]=r,delete t[i])}))}},function(t,e,r){"use strict";var i=r(15);t.exports=function(t,e,r){var n=r.config.validateStatus;!n||n(r.status)?t(r):e(i("Request failed with status code "+r.status,r.config,null,r.request,r))}},function(t,e,r){"use strict";t.exports=function(t,e,r,i,n){return t.config=e,r&&(t.code=r),t.request=i,t.response=n,t.isAxiosError=!0,t.toJSON=function(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:this.config,code:this.code}},t}},function(t,e,r){"use strict";var i=r(49),n=r(50);t.exports=function(t,e){return t&&!i(e)?n(t,e):e}},function(t,e,r){"use strict";t.exports=function(t){return/^([a-z][a-z\d\+\-\.]*:)?\/\//i.test(t)}},function(t,e,r){"use strict";t.exports=function(t,e){return e?t.replace(/\/+$/,"")+"/"+e.replace(/^\/+/,""):t}},function(t,e,r){"use strict";var i=r(1),n=["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"];t.exports=function(t){var e,r,o,s={};return t?(i.forEach(t.split("\n"),(function(t){if(o=t.indexOf(":"),e=i.trim(t.substr(0,o)).toLowerCase(),r=i.trim(t.substr(o+1)),e){if(s[e]&&n.indexOf(e)>=0)return;s[e]="set-cookie"===e?(s[e]?s[e]:[]).concat([r]):s[e]?s[e]+", "+r:r}})),s):s}},function(t,e,r){"use strict";var i=r(1);t.exports=i.isStandardBrowserEnv()?function(){var t,e=/(msie|trident)/i.test(navigator.userAgent),r=document.createElement("a");function n(t){var i=t;return e&&(r.setAttribute("href",i),i=r.href),r.setAttribute("href",i),{href:r.href,protocol:r.protocol?r.protocol.replace(/:$/,""):"",host:r.host,search:r.search?r.search.replace(/^\?/,""):"",hash:r.hash?r.hash.replace(/^#/,""):"",hostname:r.hostname,port:r.port,pathname:"/"===r.pathname.charAt(0)?r.pathname:"/"+r.pathname}}return t=n(window.location.href),function(e){var r=i.isString(e)?n(e):e;return r.protocol===t.protocol&&r.host===t.host}}():function(){return!0}},function(t,e,r){"use strict";var i=r(1);t.exports=i.isStandardBrowserEnv()?{write:function(t,e,r,n,o,s){var a=[];a.push(t+"="+encodeURIComponent(e)),i.isNumber(r)&&a.push("expires="+new Date(r).toGMTString()),i.isString(n)&&a.push("path="+n),i.isString(o)&&a.push("domain="+o),!0===s&&a.push("secure"),document.cookie=a.join("; ")},read:function(t){var e=document.cookie.match(new RegExp("(^|;\\s*)("+t+")=([^;]*)"));return e?decodeURIComponent(e[3]):null},remove:function(t){this.write(t,"",Date.now()-864e5)}}:{write:function(){},read:function(){return null},remove:function(){}}},function(t,e,r){"use strict";var i=r(17);function n(t){if("function"!=typeof t)throw new TypeError("executor must be a function.");var e;this.promise=new Promise((function(t){e=t}));var r=this;t((function(t){r.reason||(r.reason=new i(t),e(r.reason))}))}n.prototype.throwIfRequested=function(){if(this.reason)throw this.reason},n.source=function(){var t;return{token:new n((function(e){t=e})),cancel:t}},t.exports=n},function(t,e,r){"use strict";t.exports=function(t){return function(e){return t.apply(null,e)}}},function(t,e,r){r(6),r(7);var i=r(0);
/**
* @file Connection Capabilities
* @license Apache Version 2
* @description Object which helps manage the capabilities available for a given TerminusDB connection
* Creates an entry in the connection registry for the server
* and all the databases that the client has access to
* maps the input authorties to a per-db array for internal storage and easy
* access control checks
* @param {String} key API key
*/
function n(){this.clear(),this.databases=!1,this.organizations=!1}function o(t){var e={};for(var r in i.standard_urls)e[r]=i.standard_urls[r];if(t)for(var n in t)e[n]=t[n];return e}n.prototype.clear=function(){this.user={},this.dbdocs={},this.orgdocs={},this.jsonld_context={},this.systemdb_context={}},n.prototype.setCapabilities=function(t){return this.clear(),this.databases=!1,t["@context"]&&this._load_connection_context(t["@context"]),this.user=this._extract_user_info(t),this._extract_database_organizations(),this.user},n.prototype.get_user=function(){return this.user},n.prototype.author=function(){return!(!this.user||!this.user.author)&&this.user.author},n.prototype.get_databases=function(){return this.databases||(this.databases=this._databases_from_dbdocs()),this.databases},n.prototype.set_databases=function(t){this.databases=t},n.prototype.get_database=function(t,e){this.databases||(this.databases=this._databases_from_dbdocs());for(var r=0;r<this.databases.length;r++)if(this.databases[r].id==t&&this.databases[r].organization==e)return this.databases[r]},n.prototype._databases_from_dbdocs=function(){var t=[];for(var e in this.dbdocs)0==this.dbdocs[e].system&&t.push(this._get_db_rec(this.dbdocs[e]));return t},n.prototype.set_roles=function(t){var e=t.bindings;if(!e)return!1;for(var r=0;r<e.length;r++){var i={};i.dbdocid=e[r].Database_ID,i.organization=e[r].Organization["@value"],roles=this._multiple_rdf_objects(e[r].Owner_Role_Obj,"system:Role"),this.dbdocs[i.dbdocid]=roles}this._extract_database_organizations(),t.databases&&this.set_databases(t.databases),t.organizations&&this.set_organizations(t.organizations)},n.prototype.get_organizations=function(){return this.organizations||(this.organizations=this._organizations_from_orgdocs()),this.organizations},n.prototype.set_organizations=function(t){this.organizations=t},n.prototype.get_organization=function(t){this.organizations||(this.organizations=this._organizations_from_orgdocs());for(var e=0;e<this.organizations.length;e++)if(this.organizations[e].id==t)return this.organizations[e]},n.prototype._organizations_from_orgdocs=function(){return Object.values(this.orgdocs)},n.prototype.actions_permitted=function(t,e){for(var r=Array.isArray(t)?t:[t],i=Array.isArray(e)?e:[e],n=0;n<r.length;n++)for(var o=0;o<i.length;o++)if(!this._roles_cover_resource_action(r[n],i[o]))return!1;return!0},n.prototype.buildContextsFromPrefixes=function(){for(var t=this.get_databases(),e=0;e<t.length;e++)t[e].jsonld_context=o(t[e].prefix_pairs)},n.prototype.updateDatabasePrefixes=function(t,e){t.prefix_pairs=e,t.jsonld_context=o(e)},n.prototype.getContextForOutboundQuery=function(t,e,r){var n={};if(t.getContext())n=t.getContext();else{if(this._is_system_db(e))n=this.getSystemContext();else{var o=this.get_database(e,r),s=o&&o.jsonld_context?o.jsonld_context:this.jsonld_context;for(var a in s)n[a]=s[a]}if(0==Object.keys(n).length)for(var a in i.standard_urls)n[a]=i.standard_urls[a];n._="_:"}return n},n.prototype._is_system_db=function(t){return"_system"==t},n.prototype.getJSONContext=function(){return this.jsonld_context},n.prototype.setJSONContext=function(t){this.jsonld_context=t},n.prototype.getSystemContext=function(){return this.systemdb_context},n.prototype._roles_cover_resource_action=function(t,e){for(var r in this.user.roles)if(this._role_covers_resource_action(this.user.roles[r],t,e))return!0;return!1},n.prototype._role_covers_resource_action=function(t,e,r){for(var i in t.capabilities)if(this._capability_covers_resource_action(t.capabilities[i],e,r))return!0;return!1},n.prototype._capability_covers_resource_action=function(t,e,r){var i="system:"==e.substring(0,7)?e:"system:"+e;return-1!=t.actions.indexOf(i)&&-1!=t.resources.indexOf(r)},n.prototype._extract_user_info=function(t){var e=this._extract_rdf_basics(t);return e.id=this._single_rdf_value("system:agent_name",t),e.author=this._single_rdf_value("system:user_identifier",t),e.roles=this._multiple_rdf_objects(t["system:role"],"system:Role"),e},n.prototype._extract_user_role=function(t){var e=this._extract_rdf_basics(t);return e.capabilities=this._multiple_rdf_objects(t["system:capability"],"system:Capability"),e},n.prototype._extract_role_capability=function(t){var e=this._extract_rdf_basics(t);return e.actions=this._extract_multiple_ids(t["system:action"]),e.resources=this._extract_capability_resources(t["system:capability_scope"]),e},n.prototype._extract_capability_resources=function(t){var e=[];if(t)for(var r=Array.isArray(t)?t:[t],i=0;i<r.length;i++)e.push(this._extract_resource_name(r[i])),r[i]["@id"]&&r[i]["@type"]&&(("system:SystemDatabase"==r[i]["@type"]||"system:Database"==r[i]["@type"]&&!this.dbdocs[r[i]["@id"]])&&(this.dbdocs[r[i]["@id"]]=this._extract_database(r[i])),"system:Organization"!=r[i]["@type"]||this.orgdocs[r[i]["@id"]]||(this.orgdocs[r[i]["@id"]]=this._extract_organization(r[i])));return e},n.prototype._extract_resource_name=function(t){var e=this._single_rdf_value("system:resource_name",t);return e||(e=this._single_rdf_value("system:organization_name",t)),e||(e=this._single_rdf_value("system:database_name",t)),e},n.prototype._extract_database=function(t){var e=this._extract_rdf_basics(t);return e.id=this._extract_resource_name(t),e.system="system:SystemDatabase"==t["@type"],e},n.prototype._get_db_rec=function(t){var e={};for(var r in t)"system"!=r&&(e[r]=t[r]);return e},n.prototype._extract_database_organizations=function(){for(var t in this.dbdocs)for(var e in this.orgdocs)-1!=this.orgdocs[e].databases.indexOf(t)&&(this.dbdocs[t].organization=this.orgdocs[e].id)},n.prototype._extract_organization=function(t){var e=this._extract_rdf_basics(t);return e.id=this._extract_resource_name(t),e.databases=this._extract_multiple_ids(t["system:organization_database"]),e.children=this._extract_multiple_ids(t["system:organization_child"]),e.includes=this._extract_multiple_ids(t["system:resource_includes"]),e},n.prototype._extract_multiple_ids=function(t){var e=[];if(t){var r=t;Array.isArray(r)||(r=[r]),e=r.map((function(t){return t["@id"]}))}return e},n.prototype._multiple_rdf_objects=function(t,e){var r={};if(!t)return r;for(var i=t&&Array.isArray(t)?t:[t],n=0;n<i.length;n++){var o=i[n]["@id"];o&&(r[o]=this._extract_rdf_object(e,i[n]))}return r},n.prototype._extract_rdf_object=function(t,e){return"system:Role"==t?this._extract_user_role(e):"system:Capability"==t?this._extract_role_capability(e):void 0},n.prototype._extract_rdf_basics=function(t){var e={};return e.label=this._single_rdf_value("rdfs:label",t),e.comment=this._single_rdf_value("rdfs:comment",t),e},n.prototype._single_rdf_value=function(t,e){return e[t]?Array.isArray(e[t])?e[t][e[t].length-1]["@value"]:e[t]["@value"]:""},n.prototype._multiple_rdf_values=function(t,e){var r=[];if(!e[t])return r;for(var i=e[t]&&Array.isArray(e[t])?e[t]:[e[t]],n=0;n<i.length;n++)r.push(i[n]["@value"]);return r},n.prototype._load_connection_context=function(t){for(var e in this.systemdb_context=t,t)"doc"!=e&&(this.jsonld_context[e]=t[e])},t.exports=n},function(t,e){
/**
* @file Terminus DB connection configuration
* @license Apache Version 2
* @description Object representing the state of a connection to a terminus db - these are:
* 1. server url (set on connect)
* 2. current organization id
* 2. dbid, organization, api key, remote auth
* along with some configuration information (key, connected mode, client_side_access_control)
* provides methods for getting and setting connection parameters
*/
function r(t,e){this.server=!1,this.remote_auth=!1,this.local_auth=!1,this.organizationid=!1,this.dbid=!1,this.default_branch_id=e&&e.default_branch_id?e.default_branch_id:"main",this.default_repo_id="local",this.system_db="_system",this.api_extension="api/",this.branchid=this.default_branch_id,this.repoid=this.default_repo_id,this.refid=!1,this.connection_error=!1;var r=this.parseServerURL(t);r?(this.server=r,e&&this.update(e)):this.setError("Invalid Server URL: ".concat(t))}r.prototype.copy=function(){var t=new r(this.server);return t.remote_auth=this.remote_auth,t.local_auth=this.local_auth,t.organizationid=this.organizationid,t.dbid=this.dbid,t.branchid=this.branchid,t.repoid=this.repoid,t.refid=this.refid,t},r.prototype.update=function(t){var e=t||{};void 0!==e.organization&&this.setOrganization(e.organization),void 0!==e.db&&this.setDB(e.db),void 0!==e.remote_auth&&this.setRemoteAuth(e.remote_auth),void 0!==e.local_auth&&this.setLocalAuth(e.local_auth),void 0!==e.key&&this.setLocalBasicAuth(e.key,e.user),void 0!==e.branch&&this.setBranch(e.branch),void 0!==e.ref&&this.setRef(e.ref),void 0!==e.repo&&this.setRepo(e.repo)},r.prototype.serverURL=function(){return this.server},r.prototype.apiURL=function(){return this.server+this.api_extension},r.prototype.db=function(){return this.dbid},r.prototype.branch=function(){return this.branchid},r.prototype.ref=function(){return this.refid},r.prototype.organization=function(){return this.organizationid},r.prototype.repo=function(){return this.repoid},r.prototype.localAuth=function(){return this.local_auth},r.prototype.local_user=function(){if(this.local_auth)return this.local_auth.user},r.prototype.remoteAuth=function(){return this.remote_auth},r.prototype.user=function(t){return!t&&this.remote_auth&&"jwt"==this.remote_auth.type?this.remote_auth.user:this.local_auth?this.local_auth.user:void 0},r.prototype.parseServerURL=function(t){return!(!t||"http://"!==t.substring(0,7)&&"https://"!==t.substring(0,8))&&(t.lastIndexOf("/")!==t.length-1&&(t+="/"),t)},r.prototype.clearCursor=function(){this.branchid=this.default_branch_id,this.repoid=this.default_repo_id,this.organizationid=!1,this.dbid=!1,this.refid=!1},r.prototype.setCursor=function(t,e,r,i,n){return!(t&&!this.setOrganization(t))&&(!(e&&!this.setDB(e))&&(!(r&&!this.setRepo(r))&&(!(i&&!this.setBranch(i))&&!(n&&!this.setRef(n)))))},r.prototype.setError=function(t){this.connection_error=t},r.prototype.setOrganization=function(t){return this.organizationid=t||!1,this.organizationid},r.prototype.setDB=function(t){return this.dbid=t,this.dbid},r.prototype.setRepo=function(t){return this.repoid=t,this.repoid},r.prototype.setBranch=function(t){return this.branchid=t,this.branchid||(this.branchid=this.default_branch_id),this.branchid},r.prototype.setRef=function(t){return this.refid=t,this.refid},r.prototype.setLocalBasicAuth=function(t,e){if(!t)return this.local_auth=!1,!1;var r=e||"admin";return t?(this.local_auth={type:"basic",user:r,key:t},this.local_auth):void 0},r.prototype.setLocalAuth=function(t){this.local_auth=t},r.prototype.setRemoteAuth=function(t){this.remote_auth=t},r.prototype.remoteAuth=function(){return this.remote_auth},r.prototype.serverURL=function(){return this.server},r.prototype.dbURL=function(){return this.dbBase("db")},r.prototype.userURL=function(t){var e="".concat(this.apiURL(),"user");return t&&(e+="/".concat(encodeURIComponent(t))),e},r.prototype.organizationURL=function(t){var e="".concat(this.apiURL(),"organization");return t&&(e+="/".concat(encodeURIComponent(t))),e},r.prototype.rolesURL=function(){return"".concat(this.apiURL(),"role")},r.prototype.updateRolesURL=function(){return"".concat(this.apiURL(),"update_role")},r.prototype.graphURL=function(t,e){return this.branchBase("graph")+"/".concat(t,"/").concat(e)},r.prototype.triplesURL=function(t,e){if(this.db()==this.system_db)var r=this.dbBase("triples");else r=this.branchBase("triples");var i=e||"main";return r+="/".concat(t,"/").concat(i)},r.prototype.queryURL=function(){return this.db()==this.system_db?this.dbBase("woql"):this.branchBase("woql")},r.prototype.classFrameURL=function(){return this.db()==this.system_db?this.dbBase("frame"):this.branchBase("frame")},r.prototype.cloneURL=function(t){var e="".concat(this.apiURL(),"clone/").concat(this.organization());return t&&(e+="/".concat(t)),e},r.prototype.cloneableURL=function(){return"".concat(this.serverURL()).concat(this.organization(),"/").concat(this.db())},r.prototype.pullURL=function(){return this.branchBase("pull")},r.prototype.fetchURL=function(t){return this.dbBase("fetch")+"/"+t+"/_commits"},r.prototype.rebaseURL=function(){return this.branchBase("rebase")},r.prototype.pushURL=function(){return this.branchBase("push")},r.prototype.branchURL=function(t){return this.repoBase("branch")+"/branch/".concat(t)},r.prototype.dbBase=function(t){return"".concat(this.apiURL()).concat(t,"/").concat(this.dbURLFragment())},r.prototype.repoBase=function(t){var e=this.dbBase(t);return this.repo()?e+="/".concat(this.repo()):e+="/"+this.default_repo_id,e},r.prototype.branchBase=function(t){var e=this.repoBase(t);return"_meta"==this.repo()?e:"_commits"==this.branch()?e+"/".concat(this.branch()):this.ref()?e+"/commit/".concat(this.ref()):this.branch()?e+"/branch/".concat(this.branch()):e+="/branch/"+this.default_branch_id},r.prototype.dbURLFragment=function(){return this.db()==this.system_db?this.db():this.organization()+"/"+this.db()},t.exports=r},function(t,e,r){function i(t){return function(t){if(Array.isArray(t))return n(t)}(t)||function(t){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(t))return Array.from(t)}(t)||function(t,e){if(!t)return;if("string"==typeof t)return n(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);"Object"===r&&t.constructor&&(r=t.constructor.name);if("Map"===r||"Set"===r)return Array.from(t);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return n(t,e)}(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function n(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,i=new Array(e);r<e;r++)i[r]=t[r];return i}function o(t){return(o="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}var s=r(2);s.prototype.using=function(t,e){return t&&"woql:args"==t?["woql:collection","woql:query"]:(this.cursor["@type"]&&this.wrapCursorWithAnd(),this.cursor["@type"]="woql:Using",t&&"string"==typeof t?(this.cursor["woql:collection"]=this.jlt(t),this.addSubQuery(e)):this.parameterError("The first parameter to using must be a Collection ID (string)"))},s.prototype.comment=function(t,e){return t&&"woql:args"==t?["woql:comment","woql:query"]:(this.cursor["@type"]&&this.wrapCursorWithAnd(),this.cursor["@type"]="woql:Comment",this.cursor["woql:comment"]=this.jlt(t),this.addSubQuery(e))},s.prototype.select=function(){for(var t=arguments.length,e=new Array(t),r=0;r<t;r++)e[r]=arguments[r];if(e&&"woql:args"==e[0])return["woql:variable_list","woql:query"];if(this.cursor["@type"]&&this.wrapCursorWithAnd(),this.cursor["@type"]="woql:Select",!e||e.length<=0)return this.parameterError("Select must be given a list of variable names");var i=e[e.length-1];if("object"==o(i)&&i.json)var n=e.pop();else n=!1;this.cursor["woql:variable_list"]=[];for(var s=0;s<e.length;s++){var a=this.varj(e[s]);a["@type"]="woql:VariableListElement",a["woql:index"]=this.jlt(s,"nonNegativeInteger"),this.cursor["woql:variable_list"].push(a)}return this.addSubQuery(n)},s.prototype.distinct=function(){for(var t=arguments.length,e=new Array(t),r=0;r<t;r++)e[r]=arguments[r];if(e&&"woql:args"==e[0])return["woql:variable_list","woql:query"];if(this.cursor["@type"]&&this.wrapCursorWithAnd(),this.cursor["@type"]="woql:Distinct",!e||e.length<=0)return this.parameterError("Distinct must be given a list of variable names");var i=e[e.length-1];if("object"==o(i)&&i.json)var n=e.pop();else n=!1;this.cursor["woql:variable_list"]=[];for(var s=0;s<e.length;s++){var a=this.varj(e[s]);a["@type"]="woql:VariableListElement",a["woql:index"]=this.jlt(s,"nonNegativeInteger"),this.cursor["woql:variable_list"].push(a)}return this.addSubQuery(n)},s.prototype.and=function(){for(var t=arguments.length,e=new Array(t),r=0;r<t;r++)e[r]=arguments[r];if(this.cursor["@type"]&&"woql:And"!=this.cursor["@type"]){var i=(new s).json(this.cursor);for(var n in this.cursor)delete this.cursor[n];e.unshift(i)}if(e&&"woql:args"==e[0])return["woql:query_list"];this.cursor["@type"]="woql:And",void 0===this.cursor["woql:query_list"]&&(this.cursor["woql:query_list"]=[]);for(var o=0;o<e.length;o++){var a=this.cursor["woql:query_list"].length,u=this.qle(e[o],a);if("woql:And"==u["woql:query"]["@type"]&&u["woql:query"]["woql:query_list"])for(var h=0;h<u["woql:query"]["woql:query_list"].length;h++){var p=u["woql:query"]["woql:query_list"][h]["woql:query"];if(p){a=this.cursor["woql:query_list"].length;var c=this.qle(p,a);this.cursor["woql:query_list"].push(c)}}else this.cursor["woql:query_list"].push(u)}return this},s.prototype.or=function(){for(var t=arguments.length,e=new Array(t),r=0;r<t;r++)e[r]=arguments[r];if(e&&"woql:args"==e[0])return["woql:query_list"];this.cursor["@type"]&&this.wrapCursorWithAnd(),this.cursor["@type"]="woql:Or",void 0===this.cursor["woql:query_list"]&&(this.cursor["woql:query_list"]=[]);for(var i=0;i<e.length;i++){var n=this.qle(e[i],i);this.cursor["woql:query_list"].push(n)}return this},s.prototype.from=function(t,e){return t&&"woql:args"==t?["woql:graph_filter","woql:query"]:(this.cursor["@type"]&&this.wrapCursorWithAnd(),this.cursor["@type"]="woql:From",t&&"string"==typeof t?(this.cursor["woql:graph_filter"]=this.jlt(t),this.addSubQuery(e)):this.parameterError("The first parameter to from must be a Graph Filter Expression (string)"))},s.prototype.into=function(t,e){return t&&"woql:args"==t?["woql:graph","woql:query"]:(this.cursor["@type"]&&this.wrapCursorWithAnd(),this.cursor["@type"]="woql:Into",t&&"string"==typeof t?(this.cursor["woql:graph"]=this.jlt(t),this.addSubQuery(e)):this.parameterError("The first parameter to from must be a Graph Filter Expression (string)"))},s.prototype.triple=function(t,e,r){return t&&"woql:args"==t?["woql:subject","woql:predicate","woql:object"]:(this.cursor["@type"]&&this.wrapCursorWithAnd(),this.cursor["@type"]="woql:Triple",this.cursor["woql:subject"]=this.cleanSubject(t),this.cursor["woql:predicate"]=this.cleanPredicate(e),this.cursor["woql:object"]=this.cleanObject(r),this)},s.prototype.quad=function(t,e,r,i){this.cursor["@type"]&&this.wrapCursorWithAnd();var n=this.triple(t,e,r);return t&&"woql:args"==t?n.concat(["woql:graph_filter"]):i?(this.cursor["@type"]="woql:Quad",this.cursor["woql:graph_filter"]=this.cleanGraph(i),this):this.parameterError("Quad takes four parameters, the last should be a graph filter")},s.prototype.sub=function(t,e){return t&&"woql:args"==t?["woql:parent","woql:child"]:t&&e?(this.cursor["@type"]&&this.wrapCursorWithAnd(),this.cursor["@type"]="woql:Subsumption",this.cursor["woql:parent"]=this.cleanClass(t),this.cursor["woql:child"]=this.cleanClass(e),this):this.parameterError("Subsumption takes two parameters, both URIs")},s.prototype.subsumption=s.prototype.sub,s.prototype.eq=function(t,e){return t&&"woql:args"==t?["woql:left","woql:right"]:void 0===t||void 0===e?this.parameterError("Equals takes two parameters"):(this.cursor["@type"]&&this.wrapCursorWithAnd(),this.cursor["@type"]="woql:Equals",this.cursor["woql:left"]=this.cleanObject(t),this.cursor["woql:right"]=this.cleanObject(e),this)},s.prototype.equals=s.prototype.eq,s.prototype.substr=function(t,e,r,i,n){return t&&"woql:args"==t?["woql:string","woql:before","woql:length","woql:after","woql:substring"]:(n||(n=i,i=0),n||(r=(n=r).length+e),t&&n&&"string"==typeof n?(this.cursor["@type"]&&this.wrapCursorWithAnd(),this.cursor["@type"]="woql:Substring",this.cursor["woql:string"]=this.cleanObject(t),this.cursor["woql:before"]=this.cleanObject(e,"xsd:nonNegativeInteger"),this.cursor["woql:length"]=this.cleanObject(r,"xsd:nonNegativeInteger"),this.cursor["woql:after"]=this.cleanObject(i,"xsd:nonNegativeInteger"),this.cursor["woql:substring"]=this.cleanObject(n),this):this.parameterError("Substr - the first and last parameters must be strings representing the full and substring variables / literals"))},s.prototype.substring=s.prototype.substr,s.prototype.update_object=function(t){return t&&"woql:args"==t?["woql:document"]:(this.cursor["@type"]&&this.wrapCursorWithAnd(),this.cursor["@type"]="woql:UpdateObject",this.cursor["woql:document"]="string"==typeof t?this.expandVariable(t,!0):t,this.updated())},s.prototype.update=s.prototype.update_object,s.prototype.delete_object=function(t){return t&&"woql:args"==t?["woql:document"]:(this.cursor["@type"]&&this.wrapCursorWithAnd(),this.cursor["@type"]="woql:DeleteObject",this.cursor["woql:document_uri"]=this.expandVariable(t),this.updated())},s.prototype.delete=s.prototype.delete_object,s.prototype.read_object=function(t,e,r){return t&&"woql:args"==t?["woql:document_uri","woql:document"]:(this.cursor["@type"]&&this.wrapCursorWithAnd(),this.cursor["@type"]="woql:ReadObject",this.cursor["woql:document_uri"]=this.expandVariable(t),this.cursor["woql:document"]=this.expandVariable(e),this.wform(r))},s.prototype.read=s.prototype.read_object,s.prototype.get=function(t,e){var r;return t&&"woql:args"==t?["woql:as_vars","woql:query_resource"]:(this.cursor["@type"]="woql:Get",this.cursor["woql:as_vars"]=t.json?t.json():(r=new s).as.apply(r,i(t)).json(),this.cursor["woql:query_resource"]=e?this.jobj(e):{},this.cursor=this.cursor["woql:query_resource"],this)},s.prototype.put=function(t,e,r){if(t&&"woql:args"==t)return["woql:as_vars","woql:query","woql:query_resource"];var n;if(this.cursor["@type"]&&this.wrapCursorWithAnd(),this.cursor["@type"]="woql:Put",Array.isArray(t)&&"object"!=o(t[0]))for(var a=[],u=0;u<t.length;u++){var h=this.asv(u,t[u]);a.push(h),this.cursor["woql:as_vars"]=a}else this.cursor["woql:as_vars"]=t.json?t.json():(n=new s).as.apply(n,i(t)).json();return this.cursor["woql:query"]=this.jobj(e),this.cursor["woql:query_resource"]=r?this.jobj(r):{},this.cursor=this.cursor["woql:query_resource"],this},s.prototype.as=function(){for(var t=arguments.length,e=new Array(t),r=0;r<t;r++)e[r]=arguments[r];if(e&&"woql:args"==e[0])return[["woql:indexed_as_var","woql:named_as_var"]];if(Array.isArray(this.query)||(this.query=[]),Array.isArray(e[0]))if(e[1])for(a=0;a<e.length;a++){var i=e[a];if(Array.isArray(i)&&i.length>=2){var n=!!(i&&i.length>2)&&i[2],s=this.asv(i[0],i[1],n);this.query.push(s)}}else for(var a=0;a<e[0].length;a++){var u=this.asv(a,e[0][a]);this.query.push(u)}else if("number"==typeof e[0]||"string"==typeof e[0]){if(e[2]&&"string"==typeof e[2])var h=this.asv(e[0],e[1],e[2]);else if(e[1]&&"string"==typeof e[1])if("xsd:"==e[1].substring(0,4)||"xdd:"==e[1].substring(0,4))h=this.asv(this.query.length,e[0],e[1]);else h=this.asv(e[0],e[1]);else h=this.asv(this.query.length,e[0]);this.query.push(h)}else"object"==o(e[0])&&this.query.push(e[0].json?e[0].json():e[0]);return this},s.prototype.file=function(t,e){return t&&"woql:args"==t?["woql:file","woql:format"]:(this.cursor["@type"]&&this.wrapCursorWithAnd(),this.cursor["@type"]="woql:FileResource",this.cursor["woql:file"]="string"==typeof t?{"@type":"xsd:string","@value":t}:t,this.wform(e))},s.prototype.remote=function(t,e){return t&&"woql:args"==t?["woql:remote_uri","woql:format"]:(this.cursor["@type"]&&this.wrapCursorWithAnd(),this.cursor["@type"]="woql:RemoteResource",this.cursor["woql:remote_uri"]={"@type":"xsd:anyURI","@value":t},this.wform(e))},s.prototype.post=function(t,e){return t&&"woql:args"==t?["woql:file","woql:format"]:(this.cursor["@type"]&&this.wrapCursorWithAnd(),this.cursor["@type"]="woql:PostResource",this.cursor["woql:file"]={"@type":"xsd:string","@value":t},this.wform(e))},s.prototype.delete_triple=function(t,e,r){this.cursor["@type"]&&this.wrapCursorWithAnd();var i=this.triple(t,e,r);return t&&"woql:args"==t?i:(this.cursor["@type"]="woql:DeleteTriple",this.updated())},s.prototype.add_triple=function(t,e,r){this.cursor["@type"]&&this.wrapCursorWithAnd();var i=this.triple(t,e,r);return t&&"woql:args"==t?i:(this.cursor["@type"]="woql:AddTriple",this.updated())},s.prototype.delete_quad=function(t,e,r,i){this.cursor["@type"]&&this.wrapCursorWithAnd();var n=this.triple(t,e,r);return t&&"woql:args"==t?n.concat(["woql:graph"]):i?(this.cursor["@type"]="woql:DeleteQuad",this.cursor["woql:graph"]=this.cleanGraph(i),this.updated()):this.parameterError("Delete Quad takes four parameters, the last should be a graph id")},s.prototype.add_quad=function(t,e,r,i){this.cursor["@type"]&&this.wrapCursorWithAnd();var n=this.triple(t,e,r);return t&&"woql:args"==t?n.concat(["woql:graph"]):i?(this.cursor["@type"]="woql:AddQuad",this.cursor["woql:graph"]=this.cleanGraph(i),this.updated()):this.parameterError("Add Quad takes four parameters, the last should be a graph id")},s.prototype.when=function(t,e){return t&&"woql:args"==t?["woql:query","woql:consequent"]:(this.cursor["@type"]&&this.wrapCursorWithAnd(),this.cursor["@type"]="woql:When",this.addSubQuery(t),this.cursor["woql:consequent"]=e?this.jobj(e):{},this.cursor=this.cursor["woql:consequent"],this)},s.prototype.with=function(t,e,r){return t&&"woql:args"==t?["woql:graph","woql:query_resource","woql:query"]:(this.cursor["@type"]&&this.wrapCursorWithAnd(),this.cursor["@type"]="woql:With",this.cursor["woql:graph"]=this.cleanObject(this.string(t)),this.cursor["woql:query_resource"]=this.jobj(e),this.addSubQuery(r))},s.prototype.trim=function(t,e){return t&&"woql:args"==t?["woql:untrimmed","woql:trimmed"]:(this.cursor["@type"]&&this.wrapCursorWithAnd(),this.cursor["@type"]="woql:Trim",this.cursor["woql:untrimmed"]=this.cleanObject(t),this.cursor["woql:trimmed"]=this.cleanObject(e),this)},s.prototype.eval=function(t,e){return t&&"woql:args"==t?["woql:expression","woql:result"]:(this.cursor["@type"]&&this.wrapCursorWithAnd(),this.cursor["@type"]="woql:Eval",this.cursor["woql:expression"]=t.json?t.json():t,this.cursor["woql:result"]=this.cleanObject(e),this)},s.prototype.plus=function(){for(var t=arguments.length,e=new Array(t),r=0;r<t;r++)e[r]=arguments[r];if(e&&"woql:args"==e[0])return["woql:first","woql:second"];var i;(this.cursor["@type"]&&this.wrapCursorWithAnd(),this.cursor["@type"]="woql:Plus",this.cursor["woql:first"]=this.arop(e.shift()),e.length>1)?this.cursor["woql:second"]=this.jobj((i=new s).plus.apply(i,e)):this.cursor["woql:second"]=this.arop(e[0]);return this},s.prototype.minus=function(){for(var t=arguments.length,e=new Array(t),r=0;r<t;r++)e[r]=arguments[r];if(e&&"woql:args"==e[0])return["woql:first","woql:second"];var i;(this.cursor["@type"]&&this.wrapCursorWithAnd(),this.cursor["@type"]="woql:Minus",this.cursor["woql:first"]=this.arop(e.shift()),e.length>1)?this.cursor["woql:second"]=this.jobj((i=new s).minus.apply(i,e)):this.cursor["woql:second"]=this.arop(e[0]);return this},s.prototype.times=function(){for(var t=arguments.length,e=new Array(t),r=0;r<t;r++)e[r]=arguments[r];if(e&&"woql:args"==e[0])return["woql:first","woql:second"];var i;(this.cursor["@type"]&&this.wrapCursorWithAnd(),this.cursor["@type"]="woql:Times",this.cursor["woql:first"]=this.arop(e.shift()),e.length>1)?this.cursor["woql:second"]=this.jobj((i=new s).times.apply(i,e)):this.cursor["woql:second"]=this.arop(e[0]);return this},s.prototype.divide=function(){for(var t=arguments.length,e=new Array(t),r=0;r<t;r++)e[r]=arguments[r];if(e&&"woql:args"==e[0])return["woql:first","woql:second"];var i;(this.cursor["@type"]&&this.wrapCursorWithAnd(),this.cursor["@type"]="woql:Divide",this.cursor["woql:first"]=this.arop(e.shift()),e.length>1)?this.cursor["woql:second"]=this.jobj((i=new s).divide.apply(i,e)):this.cursor["woql:second"]=this.arop(e[0]);return this},s.prototype.div=function(){for(var t=arguments.length,e=new Array(t),r=0;r<t;r++)e[r]=arguments[r];if(e&&"woql:args"==e[0])return["woql:first","woql:second"];var i;(this.cursor["@type"]&&this.wrapCursorWithAnd(),this.cursor["@type"]="woql:Div",this.cursor["woql:first"]=this.arop(e.shift()),e.length>1)?this.cursor["woql:second"]=this.jobj((i=new s).div.apply(i,e)):this.cursor["woql:second"]=this.arop(e[0]);return this},s.prototype.exp=function(t,e){return t&&"woql:args"==t?["woql:first","woql:second"]:(this.cursor["@type"]&&this.wrapCursorWithAnd(),this.cursor["@type"]="woql:Exp",this.cursor["woql:first"]=this.arop(t),this.cursor["woql:second"]=this.arop(e),this)},s.prototype.floor=function(t){return t&&"woql:args"==t?["woql:argument"]:(this.cursor["@type"]&&this.wrapCursorWithAnd(),this.cursor["@type"]="woql:Floor",this.cursor["woql:argument"]=this.arop(t),this)},s.prototype.isa=function(t,e){return t&&"woql:args"==t?["woql:element","woql:of_type"]:(this.cursor["@type"]&&this.wrapCursorWithAnd(),this.cursor["@type"]="woql:IsA",this.cursor["woql:element"]=this.cleanSubject(t),this.cursor["woql:of_type"]=this.cleanClass(e),this)},s.prototype.like=function(t,e,r){return t&&"woql:args"==t?["woql:left","woql:right","woql:like_similarity"]:(this.cursor["@type"]&&this.wrapCursorWithAnd(),this.cursor["@type"]="woql:Like",this.cursor["woql:left"]=this.cleanObject(t),this.cursor["woql:right"]=this.cleanObject(e),r&&(this.cursor["woql:like_similarity"]=this.cleanObject(r,"xsd:decimal")),this)},s.prototype.less=function(t,e){return t&&"woql:args"==t?["woql:left","woql:right"]:(this.cursor["@type"]&&this.wrapCursorWithAnd(),this.cursor["@type"]="woql:Less",this.cursor["woql:left"]=this.cleanObject(t),this.cursor["woql:right"]=this.cleanObject(e),this)},s.prototype.greater=function(t,e){return t&&"woql:args"==t?["woql:left","woql:right"]:(this.cursor["@type"]&&this.wrapCursorWithAnd(),this.cursor["@type"]="woql:Greater",this.cursor["woql:left"]=this.cleanObject(t),this.cursor["woql:right"]=this.cleanObject(e),this)},s.prototype.opt=function(t){return t&&"woql:args"==t?["woql:query"]:(this.cursor["@type"]&&this.wrapCursorWithAnd(),this.cursor["@type"]="woql:Optional",this.addSubQuery(t),this)},s.prototype.optional=s.prototype.opt,s.prototype.unique=function(t,e,r){return t&&"woql:args"==t?["woql:base","woql:key_list","woql:uri"]:(this.cursor["@type"]&&this.wrapCursorWithAnd(),this.cursor["@type"]="woql:Unique",this.cursor["woql:base"]=this.cleanObject(t),this.cursor["woql:key_list"]=this.vlist(e),this.cursor["woql:uri"]=this.cleanClass(r),this)},s.prototype.idgen=function(t,e,r){return t&&"woql:args"==t?["woql:base","woql:key_list","woql:uri"]:(this.cursor["@type"]&&this.wrapCursorWithAnd(),this.cursor["@type"]="woql:IDGenerator",this.cursor["woql:base"]={"@type":"woql:Datatype"},this.cursor["woql:base"]["woql:datatype"]=this.cleanObject(this.iri(t)),this.cursor["woql:key_list"]=this.vlist(e),this.cursor["woql:uri"]=this.cleanClass(r),this)},s.prototype.idgenerator=s.prototype.idgen,s.prototype.upper=function(t,e){return t&&"woql:args"==t?["woql:left","woql:right"]:(this.cursor["@type"]&&this.wrapCursorWithAnd(),this.cursor["@type"]="woql:Upper",this.cursor["woql:left"]=this.cleanObject(t),this.cursor["woql:right"]=this.cleanObject(e),this)},s.prototype.lower=function(t,e){return t&&"woql:args"==t?["woql:left","woql:right"]:(this.cursor["@type"]&&this.wrapCursorWithAnd(),this.cursor["@type"]="woql:Lower",this.cursor["woql:left"]=this.cleanObject(t),this.cursor["woql:right"]=this.cleanObject(e),this)},s.prototype.pad=function(t,e,r,i){return t&&"woql:args"==t?["woql:pad_string","woql:pad_char","woql:pad_times","woql:pad_result"]:(this.cursor["@type"]&&this.wrapCursorWithAnd(),this.cursor["@type"]="woql:Pad",this.cursor["woql:pad_string"]=this.cleanObject(t),this.cursor["woql:pad_char"]=this.cleanObject(e),this.cursor["woql:pad_times"]=this.cleanObject(r,"xsd:integer"),this.cursor["woql:pad_result"]=this.cleanObject(i),this)},s.prototype.split=function(t,e,r){return t&&"woql:args"==t?["woql:split_string","woql:split_pattern","woql:split_list"]:(this.cursor["@type"]&&this.wrapCursorWithAnd(),this.cursor["@type"]="woql:Split",this.cursor["woql:split_string"]=this.cleanObject(t),this.cursor["woql:split_pattern"]=this.cleanObject(e),this.cursor["woql:split_list"]=this.wlist(r),this)},s.prototype.member=function(t,e){return t&&"woql:args"==t?["woql:member","woql:member_list"]:(this.cursor["@type"]&&this.wrapCursorWithAnd(),this.cursor["@type"]="woql:Member",this.cursor["woql:member"]=this.cleanObject(t),this.cursor["woql:member_list"]=this.wlist(e),this)},s.prototype.concat=function(t,e){if(t&&"woql:args"==t)return["woql:concat_list","woql:concatenated"];if("string"==typeof t){var r=t.split(/(v:)/),i=[];r[0]&&i.push(r[0]);for(var n=1;n<r.length;n+=2)if(r[n]&&"v:"==r[n]){var o=r[n+1].split(/([^\w_])/),s=o.shift();i.push("v:"+s);var a=o.join("");a&&i.push(a)}t=i}return Array.isArray(t)&&(this.cursor["@type"]&&this.wrapCursorWithAnd(),this.cursor["@type"]="woql:Concatenate",this.cursor["woql:concat_list"]=this.wlist(t),this.cursor["woql:concatenated"]=this.cleanObject(e)),this},s.prototype.concatenate=s.prototype.concat,s.prototype.join=function(t,e,r){return t&&"woql:args"==t?["woql:join_list","woql:join_separator","woql:join"]:(this.cursor["@type"]&&this.wrapCursorWithAnd(),this.cursor["@type"]="woql:Join",this.cursor["woql:join_list"]=this.wlist(t),this.cursor["woql:join_separator"]=this.cleanObject(e),this.cursor["woql:join"]=this.cleanObject(r),this)},s.prototype.sum=function(t,e){return t&&"woql:args"==t?["woql:sum_list","woql:sum"]:(this.cursor["@type"]&&this.wrapCursorWithAnd(),this.cursor["@type"]="woql:Sum",this.cursor["woql:sum_list"]=this.wlist(t),this.cursor["woql:sum"]=this.cleanObject(e),this)},s.prototype.start=function(t,e){return t&&"woql:args"==t?["woql:start","woql:query"]:(this.cursor["@type"]&&this.wrapCursorWithAnd(),this.cursor["@type"]="woql:Start",this.cursor["woql:start"]=this.cleanObject(t,"xsd:nonNegativeInteger"),this.addSubQuery(e))},s.prototype.limit=function(t,e){return t&&"woql:args"==t?["woql:limit","woql:query"]:(this.cursor["@type"]&&this.wrapCursorWithAnd(),this.cursor["@type"]="woql:Limit",this.cursor["woql:limit"]=this.cleanObject(t,"xsd:nonNegativeInteger"),this.addSubQuery(e))},s.prototype.re=function(t,e,r){return t&&"woql:args"==t?["woql:pattern","woql:regexp_string","woql:regexp_list"]:(this.cursor["@type"]&&this.wrapCursorWithAnd(),this.cursor["@type"]="woql:Regexp",this.cursor["woql:pattern"]=this.cleanObject(t),this.cursor["woql:regexp_string"]=this.cleanObject(e),this.cursor["woql:regexp_list"]=this.wlist(r),this)},s.prototype.regexp=s.prototype.re,s.prototype.length=function(t,e){return t&&"woql:args"==t?["woql:length_list","woql:length"]:(this.cursor["@type"]&&this.wrapCursorWithAnd(),this.cursor["@type"]="woql:Length",this.cursor["woql:length_list"]=this.cleanObject(t),"number"==typeof e?this.cursor["woql:length"]=this.cleanObject(e,"xsd:nonNegativeInteger"):"string"==typeof e&&(this.cursor["woql:length"]=this.varj(e)),this)},s.prototype.not=function(t){return t&&"woql:args"==t?["woql:query"]:(this.cursor["@type"]&&this.wrapCursorWithAnd(),this.cursor["@type"]="woql:Not",this.addSubQuery(t))},s.prototype.count=function(t,e){return t&&"woql:args"==t?["woql:count","woql:query"]:(this.cursor["@type"]&&this.wrapCursorWithAnd(),this.cursor["@type"]="woql:Count",this.cursor["woql:count"]=this.cleanObject(t),this.addSubQuery(e))},s.prototype.cast=function(t,e,r){return t&&"woql:args"==t?["woql:typecast_value","woql:typecast_type","woql:typecast_result"]:(this.cursor["@type"]&&this.wrapCursorWithAnd(),this.cursor["@type"]="woql:Typecast",this.cursor["woql:typecast_value"]=this.cleanObject(t),this.cursor["woql:typecast_type"]=this.cleanObject(e),this.cursor["woql:typecast_result"]=this.cleanObject(r),this)},s.prototype.typecast=s.prototype.cast,s.prototype.order_by=function(){for(var t=arguments.length,e=new Array(t),r=0;r<t;r++)e[r]=arguments[r];if(e&&"woql:args"==e[0])return["woql:variable_ordering","woql:query"];if(this.cursor["@type"]&&this.wrapCursorWithAnd(),this.cursor["@type"]="woql:OrderBy",this.cursor["woql:variable_ordering"]=[],!e||0===e.length)return this.parameterError("Order by must be passed at least one variables to order the query");for(var i=!("object"!==o(e[e.length-1])||!e[e.length-1].json)&&e.pop(),n=[],s=0;s<e.length;s++)"asc"==e[s]?n[n.length-1].order="woql:ascending":"desc"==e[s]?n[n.length-1].order="woql:descending":"string"==typeof e[s]?n.push({varname:e[s],order:"woql:ascending"}):n.push(e[s]);for(s=0;s<n.length;s++)if(n[s].varname){var a={"@type":"woql:VariableOrdering","woql:index":this.jlt(s,"xsd:nonNegativeInteger"),"woql:variable":this.varj(n[s].varname)};"woql:ascending"==n[s].order?a["woql:ascending"]=this.jlt(!0,"xsd:boolean"):a["woql:ascending"]=this.jlt(!1,"xsd:boolean"),this.cursor["woql:variable_ordering"].push(a)}else n[s]["woql:index"]=this.jlt(s,"xsd:nonNegativeInteger"),this.cursor["woql:variable_ordering"].push(n[s]);return this.addSubQuery(i)},s.prototype.group_by=function(t,e,r,i){if(t&&"woql:args"==t)return["woql:variable_list","woql:group_var","woql:grouped","woql:query"];this.cursor["@type"]&&this.wrapCursorWithAnd(),this.cursor["@type"]="woql:GroupBy",this.cursor["woql:group_by"]=[],"string"==typeof t&&(t=[t]);for(var n=0;n<t.length;n++){var o=this.varj(t[n]);o["@type"]="woql:VariableListElement",o["woql:index"]=this.jlt(n,"nonNegativeInteger"),this.cursor["woql:group_by"].push(o)}this.cursor["woql:group_template"]=[],"string"==typeof e&&(e=[e]);for(n=0;n<e.length;n++){var s=this.varj(e[n]);s["@type"]="woql:VariableListElement",s["woql:index"]=this.jlt(n,"nonNegativeInteger"),this.cursor["woql:group_template"].push(s)}return this.cursor["woql:grouped"]=this.varj(r),this.addSubQuery(i)},s.prototype.true=function(){return this.cursor["@type"]="woql:True",this},s.prototype.path=function(t,e,r,i){return t&&"woql:args"==t?["woql:subject","woql:path_pattern","woql:object","woql:path"]:(this.cursor["@type"]&&this.wrapCursorWithAnd(),this.cursor["@type"]="woql:Path",this.cursor["woql:subject"]=this.cleanSubject(t),"string"==typeof e&&(e=this.compilePathPattern(e)),this.cursor["woql:path_pattern"]=e,this.cursor["woql:object"]=this.cleanObject(r),this.cursor["woql:path"]=this.varj(i),this)},s.prototype.size=function(t,e){return t&&"woql:args"==t?["woql:resource","woql:size"]:(this.cursor["@type"]&&this.wrapCursorWithAnd(),this.cursor["@type"]="woql:Size",this.cursor["woql:resource"]=this.cleanGraph(t),this.cursor["woql:size"]=this.varj(e),this)},s.prototype.triple_count=function(t,e){return t&&"woql:args"==t?["woql:resource","woql:triple_count"]:(this.cursor["@type"]&&this.wrapCursorWithAnd(),this.cursor["@type"]="woql:TripleCount",this.cursor["woql:resource"]=this.cleanGraph(t),this.cursor["woql:triple_count"]=this.varj(e),this)}},function(t,e,r){function i(t){return(i="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}var n=r(2),o=(r(19),r(20));n.prototype.star=function(t,e,r,i){return e=e||"v:Subject",r=r||"v:Predicate",i=i||"v:Object",(t=t||!1)?this.quad(e,r,i,t):this.triple(e,r,i)},n.prototype.all=function(t,e,r,i){return this.star(i,t,e,r)},n.prototype.lib=function(){return new o},n.prototype.abstract=function(t,e){return this._add_partial(e,"system:tag","system:abstract",t),this},n.prototype.string=function(t){return{"@type":"xsd:string","@value":String(t)}},n.prototype.boolean=function(t){return t=t||!1,this.literal(t,"boolean")},n.prototype.literal=function(t,e){return{"@type":e=-1==e.indexOf(":")?"xsd:"+e:e,"@value":t}},n.prototype.iri=function(t){return{"@type":"woql:Node","woql:node":t}},n.prototype.nuke=function(t){return t?this.quad("v:A","v:B","v:C",t).delete_quad("v:A","v:B","v:C",t):this.triple("v:A","v:B","v:C").delete_triple("v:A","v:B","v:C")},n.prototype.property=function(t,e){if(this._adding_class()){var r,i=this.findLastSubject(this.cursor),o=!1;i&&(r=i["woql:graph_filter"]||i["woql:graph"]),r&&(o=r["@value"]);var s=(new n).add_property(t,e,o).domain(this._adding_class());this.and(s)}else this._add_partial(!1,t,e);return this},n.prototype.node=function(t,e){"add_quad"==(e=e||!1)?e="AddQuad":"delete_quad"==e?e="DeleteQuad":"add_triple"==e?e="AddTriple":"delete_triple"==e?e="DeleteTriple":"quad"==e?e="Quad":"triple"==e&&(e="Triple"),e&&-1==e.indexOf(":")&&(e="woql:"+e);var r={subject:t};return e&&(r.action=e),this._set_context(r),this},n.prototype.insert=function(t,e,r){return e=this.cleanType(e,!0),(r=r||!!this.triple_builder_context&&this.triple_builder_context.graph)?this.add_quad(t,"type",e,r):this.add_triple(t,"type",e)},n.prototype.insert_data=function(t,e){if(t.type&&t.id)for(var r in type=this.cleanType(t.type,!0),this.insert(t.id,type,e),t.label&&this.label(t.label),t.description&&this.description(t.description),t)-1==["id","label","type","description"].indexOf(r)&&this.property(r,t[r]);return this},n.prototype.graph=function(t){return this._set_context({graph:t})},n.prototype.domain=function(t){return t=this.cleanClass(t),this._add_partial(!1,"rdfs:domain",t)},n.prototype.label=function(t,e){if(e=e||"en","v:"==t.substring(0,2))var r=t;else r={"@value":t,"@type":"xsd:string","@language":e};return this._add_partial(!1,"rdfs:label",r)},n.prototype.description=function(t,e){if(e=e||"en","v:"==t.substring(0,2))var r=t;else r={"@value":t,"@type":"xsd:string","@language":e};return this._add_partial(!1,"rdfs:comment",r)},n.prototype.parent=function(){for(var t=0;t<arguments.length;t++){var e=this.cleanClass(t<0||arguments.length<=t?void 0:arguments[t]);this._add_partial(!1,"rdfs:subClassOf",e)}return this},n.prototype.max=function(t){return this._card(t,"max"),this},n.prototype.cardinality=function(t){return this._card(t,"cardinality"),this},n.prototype.min=function(t){return this._card(t,"min"),this},n.prototype._add_partial=function(t,e,r,i){var o=this.triple_builder_context||{};t=t||o.subject,i=i||o.graph;var s=this.findLastSubject(this.cursor);s&&!t&&(t=s["woql:subject"]);var a=o.action||s["@type"];if(!i){var u=s["woql:graph_filter"]||s["woql:graph"];i=u?u["@value"]:"schema/main"}return"woql:AddTriple"==a?this.and((new n).add_triple(t,e,r)):"woql:DeleteTriple"==a?this.and((new n).delete_triple(t,e,r)):"woql:AddQuad"==a?this.and((new n).add_quad(t,e,r,i)):"woql:DeleteQuad"==a?this.and((new n).delete_quad(t,e,r,i)):"woql:Quad"==a?this.and((new n).quad(t,e,r,i)):this.and((new n).triple(t,e,r)),this},n.prototype._adding_class=function(t){if(this.triple_builder_context){var e=this.triple_builder_context.adding_class;return e&&t&&"object"==i(e)?e["woql:node"]:e}return!1},n.prototype._set_adding_class=function(t){return this.triple_builder_context||(this.triple_builder_context={}),this.triple_builder_context.adding_class=t,this},n.prototype._set_context=function(t){for(var e in this.triple_builder_context||(this.triple_builder_context={}),t)this.triple_builder_context[e]=t[e];return this},n.prototype._get_object=function(t,e){if("woql:And"==this.cursor["@type"])for(var r=0;r<this.cursor["woql:query_list"].length;r++){var i=this.cursor["woql:query_list"][r]["woql:query"];if(this._same_entry(i["woql:subject"],t)&&this._same_entry(i["woql:predicate"],e))return i["woql:object"]}return!1},n.prototype._same_entry=function(t,e){if(t==e)return!0;if("object"==i(t)&&"string"==typeof e)return this._string_matches_object(e,t);if("object"==i(e)&&"string"==typeof t)return this._string_matches_object(t,e);if("object"==i(t)&&"object"==i(e)){for(var r in t)if(!e[r]||t[r]!=e[r])return!1;for(var r in e)if(!t[r]||t[r]!=e[r])return!1;return!0}},n.prototype._string_matches_object=function(t,e){return e["woql:node"]?t==e["woql:node"]:e["@value"]?t==e["@value"]:!!e["woql:variable_name"]&&t=="v:"+e["woql:variable_name"]["@value"]},n.prototype._card=function(t,e){var r=this.triple_builder_context||{},o=r.subject,s=r.graph,a=this.findLastProperty(this.cursor);if(a&&!o&&(o=a["woql:subject"]),"object"==i(o)){if(!o["woql:node"])return;o=o["woql:node"]}if(a&&!s){var u=a["woql:graph_filter"]||a["woql:graph"];s=!!u&&u["@value"]}var h=o+"_"+e;switch(this.and((new n).add_quad(h,"type","owl:Restriction",s).add_quad(h,"owl:onProperty",o,s)),e){case"max":this.and((new n).add_quad(h,"owl:maxCardinality",{"@value":t,"@type":"xsd:nonNegativeInteger"},s));break;case"min":this.and((new n).add_quad(h,"owl:minCardinality",{"@value":t,"@type":"xsd:nonNegativeInteger"},s));break;default:this.and((new n).add_quad(h,"owl:cardinality",{"@value":t,"@type":"xsd:nonNegativeInteger"},s))}var p=this._get_object(o,"rdfs:domain");return p&&this.and((new n).add_quad(p,"subClassOf",h,s)),this}},function(t,e,r){var i=r(21),n=r(25),o=r(26),s=r(28),a=r(29),u=r(30),h=r(4),p=r(8),c={table:function(){return new i},chart:function(){return new s},graph:function(){return new o},chooser:function(){return new n},stream:function(){return new a},document:function(){return new u},loadConfig:function(t){if(t.table)(e=new i).loadJSON(t.table,t.rules);else if(t.chooser){(e=new n).loadJSON(t.chooser,t.rules)}else if(t.graph){(e=new o).loadJSON(t.graph,t.rules)}else if(t.chart){(e=new s).loadJSON(t.chart,t.rules)}else if(t.stream){(e=new a).loadJSON(t.stream,t.rules)}else if(t.frame){var e;(e=new u).loadJSON(t.frame,t.rules)}return e},rule:function(t){return t&&"frame"==t?new p:new h},pattern:function(t){return t&&"woql"==t?(new h).pattern:(new p).pattern},matchRow:function(t,e,r,i){return(new h).matchRow(t,e,r,i)},matchColumn:function(t,e,r){return(new h).matchColumn(t,e,r)},matchCell:function(t,e,r,i,n){return(new h).matchCell(t,e,r,i,n)},matchNode:function(t,e,r,i,n){return(new h).matchNode(t,e,r,i,n)},matchEdge:function(t,e,r,i,n){return(new h).matchPair(t,e,r,i,n)},matchFrame:function(t,e,r){return(new p).testRules(t,e,r)}};t.exports=c},function(t,e,r){var i=r(2);r(0);i.prototype.getLimit=function(){return this.getPagingProperty("limit")},i.prototype.setLimit=function(t){return this.setPagingProperty("limit",t)},i.prototype.isPaged=function(t){t=t||this.query;for(var e=0,r=Object.keys(t);e<r.length;e++){var i=r[e];if("limit"==i)return!0;if(-1!==this.paging_transitive_properties.indexOf(i))return this.isPaged(t[i][t[i].length-1])}return!1},i.prototype.getPage=function(){if(this.isPaged()){var t=this.getLimit();if(this.hasStart()){var e=this.getStart();return parseInt(e/t)+1}return 1}return!1},i.prototype.setPage=function(t){var e=this.getLimit()*(t-1);return this.hasStart()?this.setStart(e):this.addStart(e),this},i.prototype.nextPage=function(){return this.setPage(this.getPage()+1)},i.prototype.firstPage=function(){return this.setPage(1)},i.prototype.previousPage=function(){var t=this.getPage()-1;return t>0&&this.setPage(t),this},i.prototype.setPageSize=function(t){return this.setPagingProperty("limit",t),this.hasStart()?this.setStart(0):this.addStart(0),this},i.prototype.hasSelect=function(){return!!this.getPagingProperty("select")},i.prototype.getSelectVariables=function(t){t=t||this.query;for(var e=0,r=Object.keys(t);e<r.length;e++){var i=r[e];if("select"==i)return t[i].slice(0,t[i].length-1);if(-1!==this.paging_transitive_properties.indexOf(i)){var n=this.getSelectVariables(t[i][t[i].length-1]);if(void 0!==n)return n}}},i.prototype.hasStart=function(){return void 0!==this.getPagingProperty("start")},i.prototype.getStart=function(){return this.getPagingProperty("start")},i.prototype.setStart=function(t){return this.setPagingProperty("start",t)},i.prototype.addStart=function(t){if(this.hasStart())this.setStart(t);else{var e={start:[t,this.query]};this.query=e}return this},i.prototype.getPagingProperty=function(t,e){e=e||this.query;for(var r=0,i=Object.keys(e);r<i.length;r++){var n=i[r];if(n==t)return e[n][0];if(-1!==this.paging_transitive_properties.indexOf(n)){var o=this.getPagingProperty(t,e[n][e[n].length-1]);if(void 0!==o)return o}}},i.prototype.setPagingProperty=function(t,e,r){r=r||this.query;for(var i=0,n=Object.keys(r);i<n.length;i++){var o=n[i];o==t?r[o][0]=e:-1!==this.paging_transitive_properties.indexOf(o)&&this.setPagingProperty(t,e,r[o][r[o].length-1])}return this}},function(t,e,r){var i=r(25),n=r(0),o=r(4);function s(t,e){return this.client=t,this.config=e||new i,this.selected=!1,this.cursor=0,this}s.prototype.options=function(t){return this.config=t,this},s.prototype.set=function(t){if(this.selected!=t){this.selected=t;var e=this.config.change;e&&e(t)}},s.prototype.setResult=function(t){this.result=t,this.choices=[];var e=0,r=t.getVariableList();for(!this.config.values()&&r.length&&this.config.values(r[0]),this.config.sort()&&this.result.sort(this.config.sort(),this.config.direction());row=this.result.next();)row&&this.includeRow(row,this.result.cursor)&&this.choices.push(this.rowToChoice(row,e++));return this},s.prototype.includeRow=function(t,e){for(var r=(new o).matchRow(this.config.rules,t,e,"hidden"),i=0;i<r.length;i++)if(r[i].rule.hidden)return!1;return!0},s.prototype.rowToChoice=function(t,e){var r={id:this.getRowID(t)};return r.label=this.getLabelFromBinding(t,e),r.title=this.getTitleFromBinding(t,e),r.selected=this.getSelectedFromBinding(t,e),r},s.prototype.getRowID=function(t){var e=t[this.config.values()];return e["@value"]?e["@value"]:e},s.prototype.getLabelFromBinding=function(t,e){var r=this.getSpecialRenderer(t,e,"label");if(r)return this.renderSpecial(r,t,e);if(this.config.labels()&&t[this.config.labels()]){var i=t[this.config.labels()];if(i["@value"]&&(i=i["@value"]),"system:unknown"!=i)return i}return n.labelFromURL(this.getRowID(t))},s.prototype.getTitleFromBinding=function(t,e){var r=this.getSpecialRenderer(t,e,"title");if(r)return this.renderSpecial(r,t,e);if(this.config.titles()&&t[this.config.titles()]){var i=t[this.config.titles()];if(i["@value"]&&(i=i["@value"]),"system:unknown"!=i)return i}return!1},s.prototype.getSelectedFromBinding=function(t,e){var r=(new o).matchRow(this.config.rules,t,e,"selected");return!(!r||!r.length)&&r[r.length-1].rule.selected},s.prototype.render=function(){if(this.renderer)return this.renderer.render(this)},s.prototype.setRenderer=function(t){return this.renderer=t,this},s.prototype.getSpecialRenderer=function(t,e,r){for(var i=(new o).matchRow(this.config.rules,t,e,r),n=0;n<i.length;n++)if(i[n].rule[r])return i[n].rule[r];return!1},s.prototype.renderSpecial=function(t,e,r){return t&&"function"==typeof t?t(e):t&&"string"==typeof t?t:void 0},s.prototype.count=function(){return this.result.count()},s.prototype.first=function(){return this.cursor=0,this.choices[this.cursor]},s.prototype.next=function(){var t=this.choices[this.cursor];return this.cursor++,t},s.prototype.prev=function(){if(this.cursor>0)return this.cursor--,this.choices[this.cursor]},t.exports=s},function(t,e,r){var i=r(28);function n(t,e){return this.client=t,this.config=e||new i,this}n.prototype.options=function(t){return this.config=t,this},n.prototype.setResult=function(t){return this.result=t,this}},function(t,e,r){var i=r(29);function n(t,e){return this.client=t,this.config=e||new i,this}n.prototype.options=function(t){return this.config=t,this},n.prototype.setResult=function(t){this.result=t},t.exports=n},function(t,e,r){var i=r(66),n=r(30),o=r(0);
/**
* @file Document Frame
* @license Apache Version 2
*/
function s(t,e){this.client=t,this.config=e||new n,this.load_schema=!1}s.prototype.options=function(t){return this.config=t,this},s.prototype.db=function(t){return this.client.db(t),this},s.prototype.load=function(t,e){return t?("doc:"==t.substring(0,4)&&(t=t.substring(4)),this.config.load_schema()?this.loadComplete(t,e):this.loadDocument(t)):e?this.loadSchema(e):void 0},s.prototype.loadDocument=function(t,e){var r=this;return e=e||"system:frame",this.client.getDocument(t,{"system:encoding":e}).then((function(t){"system:frame"==e?r.loadDataFrames(t):r.loadJSON(t)}))},s.prototype.loadSchema=function(t,e){var r=this,i=o.unshorten(t);return this.client.getClassFrame(e,i).then((function(t){return r.loadSchemaFrames(t,i)}))},s.prototype.loadComplete=function(t,e){var r=this;return e?Promise.all([this.loadDocument(t),this.loadDocumentSchema(e)]):this.loadDocument(t).then((function(t){r.loadSchema(r.document.cls)}))},s.prototype.loadJSON=function(t,e){return this.docid?this.loadDocument(this.docid):this.clsid?this.loadDocumentSchema(this.clsid):void console.error("Either docid or clid must be set before load is called")},s.prototype.loadDataFrames=function(t,e,r){e||(this.document?e=this.document.cls:t&&t.length&&t[0]&&t[0].domain&&(e=t[0].domain)),e?this.document?this.document.loadDataFrames(t):this.document=new i(e,t,r):console.log("Missing Class Failed to add dataframes due to missing class")},s.prototype.loadSchemaFrames=function(t,e){e||t&&t.length&&t[0]&&t[0].domain&&(e=t[0].domain),e?(this.document||(this.document=new i(e)),t&&(this.document.loadClassFrames(t),this.document.subjid||(this.document.newDoc=!0,this.document.fillFromSchema("_:")))):console.log("Missing Class","Failed to add class frames due to missing both class and classframes")},s.prototype.applyRules=function(t,e,r){t=t||this.document,e=e||this.config;t.filter(e.rules,(function(t,i){e.setFrameDisplayOptions(t,i),r&&r(t,i)}))},t.exports=s},function(t,e,r){function i(t){return(i="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}var n=r(0),o=r(8);
/**
* @file Javascript Terminus Document Classes
* @license Apache Version 2
* Helper classes for accessing documents returned by the Terminus DB API programmatically
*
* @example
* let doc = new TerminusDocument(client);
*
* //These set the objects document property and return promises:
*
* doc.loadDocument(URL).then(() => console.log(this.document));
* doc.loadComplete(URL, CLS).then(() => console.log(this.document))
* doc.loadSchema(cls).then(() => console.log(this.document))
*
* //These just set the object's document property
* doc.loadJSON(json_frames, cls) //console.log(this.document)
* doc.loadDataFrames(json_frames, cls)
* doc.loadClassFrames(json_frames, cls)
* @example
*
* @description Represents a frame for programmatic access to object frame, anywhere within a document
* Recursive data structure where this.children contains an indexed array of object frames
* and this.dataframes contains a property indexed array of data frames
* Every object frame carries a reference to its classframe
* This gives us instructions as to how to create new frames according to the schema
* After that it's turtles all the way down.
* @param cls - ID of the class (URL)
* @param classframe - an array of frames representing a class
* @param archetypes list of class frames
* @param parent parent object
* @returns
*/
function s(t,e,r,n,o){this.empty(),this.cls=t,r&&"object"===i(r)&&this.loadClassFrames(r),e&&"object"===i(e)?(this.originalFrames=e,this.loadDataFrames(e)):this.originalFrames=!1,this.parent=n,this.parentframe=o,this.newDoc=!1}function a(t,e,r){this.predicate=t,this.cframe=e,this.parent=r,this.values=[]}function u(t,e,r){this.err=!1,this.parent=e,this.subjid=!!e&&e.subjid,this.index=r,t&&this.load(t)}function h(t,e){this.err=!1,this.parent=e,this.subjid=!!e&&e.subjid,t&&this.load(t)}function p(t){this.min=0,this.max=0,t&&this.loadRestriction(t)}s.prototype.loadClassFrames=function(t){for(var e=0;e<t.length;e+=1){t[e]["@context"]&&(this.jsonld_context=t[e]["@context"]);var r=new h(t[e]);if(r.isValid()&&(this.classframes||(this.classframes={}),void 0===this.classframes[t[e].property]&&(this.classframes[t[e].property]=[]),this.classframes[t[e].property]=r,r.isObject()&&this.properties[t[e].property]))for(var i=0;i<this.properties[t[e].property].values.length;i+=1)this.properties[t[e].property].values[i].loadClassFrames(t[e].frame)}return this},s.prototype.hasSchema=function(){return!n.empty(this.classframes)},s.prototype.loadDataFrames=function(t){if("object"===i(t)&&t.length){this.originalFrames||(this.originalFrames=t),!this.subjid&&t[0].domainValue&&(this.subjid=t[0].domainValue);for(var e=0;e<t.length;e+=1){t[e]["@context"]&&(this.jsonld_context=t[e]["@context"]);var r=this.getPropertyClassFrame(t[e].property,t[e]);r&&r.isClassChoice()?(r=r.getChosenClassFrame(t[e].range))||console.log("no choice frame ".concat(t[e].range)):r&&r.isLogic()&&(r=r.getChosenFrame(t[e])),r&&(void 0===this.properties[t[e].property]&&(this.properties[t[e].property]=new a(t[e].property,r,this)),this.properties[t[e].property].addFrame(t[e]))}return this}},s.prototype.getAsFrame=function(t,e){if(this.parentframe)return this.parentframe;var r={type:"objectProperty",property:t};r.range=this.cls,r.domain=e.cls,r.domainValue=e.subjid,r.frame=[];for(var i=0,n=Object.keys(this.properties);i<n.length;i++){var o=n[i];r.frame=r.frame.concat(r.frame,this.properties[o].getAsFrames())}return r},s.prototype.getAsFrames=function(t,e){for(var r=[],i=0,n=Object.keys(this.properties);i<n.length;i++){var o=n[i];r=r.concat(r,this.properties[o].getAsFrames())}return r},s.prototype.empty=function(){this.properties={},this.restrictions={},this.subjid=!1,this.cls=!1},s.prototype.reset=function(t){if(t){for(var e=[],r=0;r<this.originalFrames.length;r+=1)this.originalFrames[r].property===t&&e.push(this.originalFrames[r]);this.properties[t]&&(this.properties[t]=[]),this.loadDataFrames(e)}else this.restrictions={},this.properties={},this.loadDataFrames(this.originalFrames)},s.prototype.clear=function(){for(var t=0,e=Object.keys(this.properties);t<e.length;t++){var r=e[t];this.properties[r].clear()}return this},s.prototype.filter=function(t,e){(new o).testRules(t,this,e);for(var r=0,i=Object.keys(this.properties);r<i.length;r++){var n=i[r];this.properties[n].filter(t,e)}return this},s.prototype.getPropertyClassFrame=function(t,e){return this.classframes&&"object"===i(this.classframes)&&"object"===i(this.classframes[t])?this.classframes[t]:e?new h(e):!!this.properties[t]&&new h(this.properties[t].values[0])},s.prototype.getProperties=function(t){if("filled"==t||!this.classframes)return Object.keys(this.properties);if("missing"==t){for(var e=Object.keys(this.properties),r=Object.keys(this.classframes),i=[],n=0;n<r.length;n++)-1==e.indexOf(r[n])&&-1==i.indexOf(r[n])&&i.push(r[n]);return i}return Object.keys(this.classframes)},s.prototype.getMissingPropertyList=function(){for(var t=this.getProperties("missing"),e=[],r=0;r<t.length;r++){var i=this.getPropertyClassFrame(t[r]);if(i)var n={label:i.getLabel(),value:t[r]};else n={label:t[r],value:t[r]};e.push(n)}return e},s.prototype.getFilledPropertyList=function(){for(var t=this.getProperties("filled"),e=[],r=0;r<t.length;r++){var i=this.getPropertyClassFrame(t[r]);if(i)var n={label:i.getLabel(),value:t[r]};else n={label:t[r],value:t[r]};e.push(n)}return e},s.prototype.fillFromSchema=function(t){t&&(this.subjid=t),t=t||n.genBNID();var e={};if(this.classframes)for(var r=0,i=Object.keys(this.classframes);r<i.length;r++){var o=i[r],s=this.getPropertyClassFrame(o);e[o]=new a(o,s,this),e[o].fillFromSchema(t)}this.properties=e,this.originalFrames=[];for(var u=0,h=Object.keys(this.properties);u<h.length;u++){var p=h[u];this.originalFrames.push(this.properties[p].getAsFrames())}return this},s.prototype.clone=function(t){var e={},r=new s(this.cls,!1,!1,this.parent);r.classframes=this.classframes,r.subjid=t;for(var i=0,n=Object.keys(this.properties);i<n.length;i++){var o=n[i];e[o]=this.properties[o].clone()}return r.properties=e,r},s.prototype.getChild=function(t,e){for(var r=this.getProperty(e);0<r.values.length;r++)if(r.values[0].isObject()&&r.values[0].subject===t)return r.values[0];if(!e)for(var i=0,n=Object.keys(this.properties);i<n.length;i++)for(var o=n[i],s=0;s<this.properties[o].values.length;s+=1)if(this.properties[o].values[s].subject()===t)return this.properties[o].values[s];return!1},s.prototype.addProperty=function(t,e){var r=this.getPropertyClassFrame(t),i=!1;if(r){var o=new a(t,r,this);if(r.isObject()){r.isClassChoice()||(i=r.createEmpty(n.genBNID())),e&&(i=r.createEmptyChoice(e,n.genBNID()));var s=r.getClassChoices();s&&s.length&&(i=r.createEmptyChoice(s[0],n.genBNID()))}else i=r.createEmpty();return i&&o.addValueFrame(i),void 0===this.properties[t]&&(this.properties[t]=[]),this.properties[t].push(o),o}return!1},s.prototype.addPropertyValue=function(t,e){return this.properties[t].addValue(e)},s.prototype.removeProperty=function(t){void 0!==this.properties[t]&&delete this.properties[t]},s.prototype.removePropertyValue=function(t,e,r){var i=this.properties[t];i.removeValue(e,r),0==i.values.length&&this.removeProperty(t)},s.prototype.error=function(t){console.error(t)},s.prototype.extract=function(){var t={};for(var e in this.properties)for(var r=0;r<this.properties[e].length;r++){var i=this.properties[e][r].extract();n.empty(i)||(void 0===t[e]&&(t[e]=[]),t[e]=t[e].concat(i))}return(!n.empty(t)||!this.parent)&&this.extractJSONLD(t)},s.prototype.extractJSONLD=function(t){return t["@type"]=this.cls,"_:"!=this.subject()&&(t["@id"]=this.subject()),this.jsonld_context&&(t["@context"]=this.jsonld_context),t},s.prototype.subject=function(){return this.subjid},s.prototype.get=s.prototype.subject,s.prototype.set=function(t){this.subjid=t},s.prototype.isObject=function(){return!0},s.prototype.isProperty=function(){return!1},s.prototype.isData=function(){return!1},s.prototype.subjectClass=function(){return this.cls},s.prototype.depth=function(){return this.parent?this.parent.depth()+1:0},s.prototype.getProperty=function(t){return this.properties[t]},s.prototype.first=function(t){if(this.properties&&this.properties[t])return this.properties[t].first()},s.prototype.property=function(t){return!!this.parent&&this.parent.property()},s.prototype.parentObject=function(){return!(!this.parent||!this.parent.parent)&&this.parent.parent},s.prototype.root=function(){return!this.parent},s.prototype.renderProperties=function(){for(var t=this.sortProperties(),e=[],r=0;r<t.length;r++)if(this.properties[t[r]].render){var i=this.properties[t[r]].render(this.properties[t[r]]);i&&e.push(i)}return e},s.prototype.sortProperties=function(){var t=this,e=Object.keys(this.properties);return this.compare?e.sort((function(e,r){return t.compare(e,r,t)})):e.sort((function(e,r){return t.standardCompare(e,r,t)}))},s.prototype.standardCompare=function(t,e,r){return"rdfs:label"==t?-1:"rdfs:label"==e?1:"rdfs:comment"==t?-1:"rdfs:comment"==e?1:r.properties[t].isData()&&r.properties[e].isObject()?-1:r.properties[e].isData()&&r.properties[t].isObject()?1:0},s.prototype.cardControlAllows=function(t){if(!this.parent)return!0;if(this.parent.cframe.hasRestriction()){var e=this.parent.cframe.restriction,r=this.parent.values.length;if(("add"==t||"clone"==t)&&e.max&&r>=e.max)return!1;if("delete"==t&&e.min&&r<=e.min)return!1}return!0},s.prototype.isUpdated=function(){var t=0;for(var e in this.properties){if(this.originalFrames[t]!=e)return!0;if(this.properties[e].isUpdated())return!0;t++}return t!=this.originalFrames.length},s.prototype.isNew=function(){return"_:"==this.subject().substring(0,2)},s.prototype.getSummary=function(){var t={status:"ok"};for(var e in this.isUpdated()&&(t.status="updated"),this.isNew()&&(t.status="new"),t.propcount=0,this.properties)t.propcount++;return t.long=t.propcount+" properties",t},a.prototype.addFrame=function(t){if(this.cframe.isData()){var e=new u(t,this,this.values.length);this.values.push(e)}else{var r=new s(this.range(),this.cframe.frame,t.frame,this,t);this.values.push(r)}},a.prototype.addValueFrame=function(t){t.parent=this,t.index=this.values.length,this.values.push(t)},a.prototype.fillFromSchema=function(t){if(this.isData()||this.isObject()&&!this.isClassChoice()){var e=[];if(this.cframe.hasRestriction()&&this.cframe.restriction.min)for(var r=0;r<this.cframe.restriction.min;r+=1){var i;(i=this.createEmpty(t)).parent=this,e.push(i)}else(i=this.createEmpty(t)).parent=this,e.push(i);this.values=e}else if(this.isClassChoice()){var o=this.cframe.getClassChoices();if(o&&o.length){var s=this.cframe.createEmptyChoice(o[0],n.genBNID());s.parent=this,this.values=[s]}}},a.prototype.isData=function(){return this.cframe.isData()},a.prototype.isObject=function(){return this.cframe.isObject()},a.prototype.isProperty=function(){return!0},a.prototype.property=function(){return this.predicate},a.prototype.extract=function(){for(var t=[],e=0;e<this.values.length;e++){var r=this.values[e].extract();""!==r&&!1!==r&&void 0!==r&&t.push(r)}return t},a.prototype.subject=function(){return!!this.parent&&this.parent.subject()},a.prototype.subjectClass=function(){return!!this.parent&&this.parent.subjectClass()},a.prototype.depth=function(){return!!this.parent&&this.parent.depth()},a.prototype.updated=function(){return!!this.parent&&this.parent.childUpdated()},a.prototype.range=function(){return this.cframe?this.cframe.range:""},a.prototype.getLabel=function(){return this.cframe?this.cframe.getLabel():""},a.prototype.getComment=function(){return!!this.cframe&&this.cframe.getComment()},a.prototype.hasCardinalityRestriction=function(){return!!this.cframe&&this.cframe.hasRestriction()},a.prototype.getRestriction=function(){return!!this.cframe&&this.cframe.restriction},a.prototype.isClassChoice=function(){return!!this.cframe&&this.cframe.isClassChoice()},a.prototype.deletePropertyValue=function(t,e){this.parent.removePropertyValue(this.property(),t,e)},a.prototype.get=function(){for(var t=[],e=0;e<this.values.length;e++)if(this.values[e]){var r=this.values[e].get();r&&t.push(r)}return t},a.prototype.set=function(t){for(var e=0;e<this.values.length;e++)this.values[e]&&this.values[e].set(t)},a.prototype.clear=function(){for(var t=0;t<this.values.length;t++)this.values[t].clear()},a.prototype.clone=function(){for(var t=[],e=new a(this.predicate,this.cframe,this.parent),r=0;r<this.values.length;r++)t.push(this.values[r].clone());return e.values=t,e},a.prototype.getAsFrames=function(){for(var t=[],e=0;e<this.values.length;e++)this.values[e]&&(this.isData()?t.push(this.values[e].getAsFrame()):t=t.concat(this.values[e].getAsFrames()));return t},a.prototype.createEmpty=function(){if(this.cframe.isData()){var t=this.cframe.copy();return t.set(""),t}if(this.cframe.isObject()){if(!this.cframe.isClassChoice())return this.cframe.createEmpty(n.genBNID());var e=this.cframe.getClassChoices();if(e&&e.length)return this.cframe.createEmptyChoice(e[0],n.genBNID())}},a.prototype.filter=function(t,e){(new o).testRules(t,this,e);for(var r=0;r<this.values.length;r++)this.values[r].filter(t,e);return this},a.prototype.first=function(){if(this.values&&this.values[0])return this.values[0].get()},a.prototype.renderValues=function(){for(var t=this.sortValues(),e=[],r=0;r<t.length;r++)if(t[r]&&t[r].render){var i=t[r].render(t[r]);i&&e.push(i)}return e},a.prototype.sortValues=function(){var t=this;return this.compare?this.values.sort((function(e,r){return t.compare(e,r,t)})):this.values},a.prototype.cardControlAllows=function(t){if(this.cframe.hasRestriction()){var e=this.cframe.restriction,r=this.values.length;if(("add"==t||"clone"==t)&&e.max&&r>=e.max)return!1;if("delete"==t&&e.min)return!1}return!0},a.prototype.isUpdated=function(){return!0},u.prototype.load=function(t){if("object"===i(t)){this.type=t.type,this.predicate=t.property,this.range=t.range,this.rangeValue=t.rangeValue,this.domain=t.domain,this.domainValue=t.domainValue,this.frame=t.frame,this.label=t.label,this.comment=t.comment;var e=t.restriction;this.restriction=!1,e&&"object"===i(e)&&(this.restriction=new p(e))}else this.error("No frame passed to load")},u.prototype.filter=function(t,e){(new o).testRules(t,this,e);return this},u.prototype.delete=function(){this.parent.deletePropertyValue(this.get(),this.index)},u.prototype.save=function(){this.parent&&this.parent.save()},u.prototype.reset=function(){this.set(this.originalValue)},u.prototype.clone=function(){var t=this.parent.addPropertyValue(this.get()),e=this.copy(t);e.setNew(),e.mode="edit",e.index=this.parent.values.length,this.parent.values.push(e)},u.prototype.depth=function(){return!!this.parent&&this.parent.depth()},u.prototype.property=function(){return!!this.parent&&this.parent.property()},u.prototype.subject=function(){return!!this.parent&&this.parent.subject()},u.prototype.subjectClass=function(){return!!this.parent&&this.parent.subjectClass()},u.prototype.type=function(){return!!this.range&&this.range},u.prototype.isValidType=function(t){return-1!==["datatypeProperty","objectProperty","restriction "].indexOf(t)},u.prototype.getAsFrame=function(){var t={type:this.type,property:this.property()};return this.range&&(t.range=this.range),this.rangeValue&&(t.rangeValue=this.rangeValue),this.domain&&(t.domain=this.domain),this.domainValue&&(t.domainValue=this.domainValue),this.frame&&(t.frame=this.frame),this.label&&(t.label=this.label),this.comment&&(t.comment=this.comment),t},u.prototype.hasRestriction=function(){return!!this.restriction&&this.restriction.hasCardRestriction()},u.prototype.copy=function(t){var e=new u(this,this.parent);return t&&(e.domainValue=t),e},u.prototype.getLabel=function(){var t="";return"rdfs:label"==this.predicate?"Name":"rdfs:comment"==this.predicate?"Description":(this.label&&"object"===i(this.label)&&(t=this.label["@value"]),this.label&&"string"==typeof this.label&&(t=this.label),!t&&this.property()&&(t=n.labelFromURL(this.property())),t||(t=n.labelFromURL(this.cls)),t)},u.prototype.getType=function(){return this.range?this.range:!(!this.rangeValue||!this.rangeValue.type)&&this.rangeValue.type},s.prototype.getLabel=u.prototype.getLabel,u.prototype.getComment=function(){var t="";return this.comment&&"object"===i(this.comment)&&(t=this.comment["@value"]),this.comment&&"string"==typeof this.comment&&(t=this.comment),t},s.prototype.getComment=u.prototype.getComment,u.prototype.error=function(t){return t&&(this.err=t),this.err},u.prototype.isValid=function(){return this.type&&this.isValidType(this.type)?this.predicate?this.domain?this.range?!(this.isObjectProperty()&&(!this.frame||"object"!==i(this.frame)))||(this.error("Missing Object Frame"),!1):(this.error("Missing Frame Range"),!1):(this.error("Missing Frame Domain"),!1):(this.error("Missing Frame Property"),!1):(this.error("Missing or Illegal Frame Type ".concat(this.type)),!1)},u.prototype.isObjectProperty=function(){return"objectProperty"===this.type},u.prototype.isDatatypeProperty=function(){return"datatypeProperty"===this.type},u.prototype.isLogic=function(){return"and"===this.type||"or"===this.type||"xor"===this.type},u.prototype.isRestriction=function(){return"restriction"===this.type},u.prototype.ftype=function(){return this.isDocument()?"document":this.isDatatypeProperty()?"data":this.isChoice()?"oneOf":this.isObject()?"object":this.isLogic()?"logic":this.isClassChoice()?"class_choice":void 0},u.prototype.isClassChoice=function(){return this.frame&&"class_choice"===this.frame.type},u.prototype.isString=function(){return this.range===n.getStdURL("xsd","string")},u.prototype.getChoiceOptions=function(){for(var t=[],e=0;e<this.frame.elements.length;e+=1){var r={};this.frame.elements[e].label?r.label=this.frame.elements[e].label["@value"]:r.label=n.labelFromURL(this.frame.elements[e].class),r.value=this.frame.elements[e].class,t.push(r)}return t},u.prototype.lang=function(){return"en"},u.prototype.isChoice=function(){return this.frame&&"oneOf"===this.frame.type},u.prototype.isDocument=function(){return this.frame&&"document"===this.frame.type},u.prototype.isData=function(){return this.isDocument()||this.isChoice()||this.isDatatypeProperty()},u.prototype.isObject=function(){return this.isObjectProperty()&&this.frame&&!(this.isChoice()||this.isDocument())},u.prototype.isProperty=function(){return!1},u.prototype.getTypeShorthand=function(){return this.isDocument()?"document":this.isChoice()?"choice":n.getShorthand(this.getType())||this.getType()},u.prototype.get=function(){return this.contents?this.contents:this.isDatatypeProperty()&&this.rangeValue&&void 0!==this.rangeValue["@value"]?this.rangeValue["@value"]:this.isChoice()||this.isDocument()?this.frame.domainValue:""},u.prototype.set=function(t,e){e&&(t=e(t,this)),this.contents=t,(this.isChoice()||this.isDocument())&&(this.frame.domainValue=t),this.isDatatypeProperty()&&this.rangeValue&&(this.rangeValue["@value"]=t)},u.prototype.clear=function(){(this.isDocument()||this.isChoice()||this.isDatatypeProperty())&&this.set("")},u.prototype.cardControlAllows=function(t){if(this.parent.cframe.hasRestriction()){var e=this.parent.cframe.restriction,r=this.parent.values.length;if(("add"==t||"clone"==t)&&e.max&&r>=e.max)return!1;if("delete"==t&&e.min&&r<=e.min)return!1}return!0},u.prototype.extract=function(){var t=this.get();if(""!==t&&!1!==t){if(this.isDatatypeProperty()){var e={"@value":this.get()};return this.isString()?e["@language"]=this.lang():e["@type"]=this.getType(),e}if(this.isChoice()||this.isDocument())return{"@id":t}}return t},h.prototype=u.prototype,h.prototype.loadFromObjectFrame=function(t,e){this.type="objectProperty",this.predicate=t.property,this.range=t.range,this.rangeValue=e.subjid,this.domain=t.cls,this.domainValue=t.subjid,this.label=t.getLabel(),this.comment=t.getComment(),this.restriction=t.restriction},h.prototype.createEmptyChoice=function(t,e){var r=this.getChosenClassFrames(t),i=new s(t);return e&&(i.subjid=e),i.loadClassFrames(r),i.fillFromSchema()},h.prototype.getChosenClassFrames=function(t){for(var e=[],r=0;r<this.frame.operands.length;r+=1)for(var i=0;i<this.frame.operands[r].length;i+=1)t===this.frame.operands[r][i].domain&&(e=e.concat(this.frame.operands[r][i]));return e},h.prototype.createEmpty=function(t){if(this.isObject()){var e=new s(this.range);return t&&(e.subjid=t),e.loadClassFrames(this.frame),e.fillFromSchema()}if(this.isData()){var r=this.copy();return r.set(""),r}},h.prototype.cloneDataFrame=function(t,e){return e},h.prototype.clone=function(t,e){if(this.isObject())console.log("cannot clone class frame");else if(this.isData())return this.cloneDataFrame(t,e)},h.prototype.getClassChoices=function(){var t=[];if(this.frame.operands)for(var e=0;e<this.frame.operands.length;e+=1)for(var r=0;r<this.frame.operands[e].length;r+=1){var i=this.frame.operands[e][r].domain;i&&-1===t.indexOf(i)&&t.push(i)}return t},h.prototype.getChosenClassFrame=function(t){for(var e=0;e<this.frame.operands.length;e+=1){var r=this.frame.operands[e];if(r.length)for(var i=0;i<r.length;i+=1){if(r[i]&&t===r[i].domain)return new h(r)}else if(r.range&&t===r.range){return new h(r)}}return!1},h.prototype.getChosenFrame=function(t){return t},p.prototype.hasCardRestriction=function(){return 0!==this.min||0!==this.max},p.prototype.loadRestriction=function(t){if(void 0!==t.cardinality)this.max=t.cardinality,this.min=t.cardinality;else if(void 0!==t.maxCardinality)this.max=t.maxCardinality;else if(void 0!==t.minCardinality)this.min=t.minCardinality;else if(void 0!==t.type&&"and"===t.type&&"object"===i(t.operands))for(var e=0;e<t.operands.length;e+=1){var r=new p(t.operands[e]);(0===this.max&&r.max>0||this.max>0&&r.max>0&&r.max<this.max)&&(this.max=r.max),(0===this.min&&r.min>0||this.min>0&&r.min>0&&r.min>this.min)&&(this.min=r.min)}},t.exports=s}])}));
//# sourceMappingURL=terminusdb-client.min.js.map