UNPKG

solid-panes

Version:

Solid-compatible Panes: applets and views for the mashlib and databrowser

1 lines • 2.8 MB
module.exports=function(e){var t={};function n(r){if(t[r])return t[r].exports;var i=t[r]={i:r,l:!1,exports:{}};return e[r].call(i.exports,i,i.exports,n),i.l=!0,i.exports}return n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var i in e)n.d(r,i,function(t){return e[t]}.bind(null,i));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=549)}([function(e,t,n){"use strict";var r=n(26),i=n(24);Object.defineProperty(t,"__esModule",{value:!0}),Object.defineProperty(t,"ns",{enumerable:!0,get:function(){return l.default}}),Object.defineProperty(t,"acl",{enumerable:!0,get:function(){return o.acl}}),Object.defineProperty(t,"aclControl",{enumerable:!0,get:function(){return o.aclControl}}),Object.defineProperty(t,"authn",{enumerable:!0,get:function(){return u.authn}}),Object.defineProperty(t,"create",{enumerable:!0,get:function(){return s.default}}),Object.defineProperty(t,"icons",{enumerable:!0,get:function(){return d.default}}),Object.defineProperty(t,"matrix",{enumerable:!0,get:function(){return p.default}}),Object.defineProperty(t,"media",{enumerable:!0,get:function(){return f.default}}),Object.defineProperty(t,"messageArea",{enumerable:!0,get:function(){return h.default}}),Object.defineProperty(t,"infiniteMessageArea",{enumerable:!0,get:function(){return m.infiniteMessageArea}}),Object.defineProperty(t,"pad",{enumerable:!0,get:function(){return v.default}}),Object.defineProperty(t,"preferences",{enumerable:!0,get:function(){return g.default}}),Object.defineProperty(t,"store",{enumerable:!0,get:function(){return b.default}}),Object.defineProperty(t,"style",{enumerable:!0,get:function(){return y.default}}),Object.defineProperty(t,"table",{enumerable:!0,get:function(){return w.default}}),Object.defineProperty(t,"utils",{enumerable:!0,get:function(){return E.default}}),Object.defineProperty(t,"widgets",{enumerable:!0,get:function(){return A.default}}),Object.defineProperty(t,"versionInfo",{enumerable:!0,get:function(){return C.default}}),Object.defineProperty(t,"initHeader",{enumerable:!0,get:function(){return _.initHeader}}),t.tabs=t.log=t.rdf=t.dom=void 0;var a=i(n(3));t.rdf=a;var l=r(n(20)),o=n(388),u=n(476),s=r(n(477)),d=r(n(38)),c=i(n(74));t.log=c;var p=r(n(478)),f=r(n(104)),h=r(n(479)),m=n(480),v=r(n(75)),g=r(n(484)),b=r(n(23)),y=r(n(52)),w=r(n(485)),x=i(n(486));t.tabs=x;var E=r(n(27)),A=r(n(33)),C=r(n(493)),_=n(494),S=window?window.document:null;t.dom=S,"undefined"!=typeof window&&(window.UI={ns:l.default,rdf:a,acl:o.acl,aclControl:o.aclControl,authn:u.authn,create:s.default,dom:S,icons:d.default,log:c,matrix:p.default,media:f.default,messageArea:h.default,infiniteMessageArea:m.infiniteMessageArea,pad:v.default,preferences:g.default,store:b.default,style:y.default,table:w.default,tabs:x,utils:E.default,widgets:A.default,versionInfo:C.default,initHeader:_.initHeader})},function(e,t){e.exports=function(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}},function(e,t,n){"use strict";n.d(t,"n",(function(){return r})),n.d(t,"a",(function(){return i})),n.d(t,"h",(function(){return a})),n.d(t,"s",(function(){return l})),n.d(t,"c",(function(){return o})),n.d(t,"b",(function(){return u})),n.d(t,"d",(function(){return s})),n.d(t,"e",(function(){return d})),n.d(t,"f",(function(){return c})),n.d(t,"g",(function(){return p})),n.d(t,"i",(function(){return f})),n.d(t,"j",(function(){return h})),n.d(t,"k",(function(){return m})),n.d(t,"l",(function(){return v})),n.d(t,"m",(function(){return g})),n.d(t,"o",(function(){return b})),n.d(t,"p",(function(){return y})),n.d(t,"q",(function(){return w})),n.d(t,"r",(function(){return x})),n.d(t,"t",(function(){return E}));var r="NamedNode",i="BlankNode",a="Literal",l="Variable",o="DefaultGraph",u="Collection",s="Empty",d="Graph",c="text/html",p="application/ld+json",f="text/n3",h="application/n3",m="application/nquads",v="application/n-quads",g="application/n-triples",b="application/rdf+xml",y="application/sparql-update",w="text/turtle",x="application/x-turtle",E="application/xhtml+xml"},function(e,t,n){"use strict";n.r(t),n.d(t,"isStatement",(function(){return I.j})),n.d(t,"isStore",(function(){return I.k})),n.d(t,"isCollection",(function(){return I.b})),n.d(t,"isRDFlibObject",(function(){return I.i})),n.d(t,"isVariable",(function(){return I.n})),n.d(t,"isTerm",(function(){return I.m})),n.d(t,"isLiteral",(function(){return I.d})),n.d(t,"isQuad",(function(){return I.g})),n.d(t,"isNamedNode",(function(){return I.e})),n.d(t,"isBlankNode",(function(){return I.a})),n.d(t,"isSubject",(function(){return I.l})),n.d(t,"isPredicate",(function(){return I.f})),n.d(t,"isRDFObject",(function(){return I.h})),n.d(t,"isGraph",(function(){return I.c})),n.d(t,"BlankNode",(function(){return r.a})),n.d(t,"Collection",(function(){return i.a})),n.d(t,"convert",(function(){return a})),n.d(t,"DataFactory",(function(){return qe})),n.d(t,"Empty",(function(){return A})),n.d(t,"Fetcher",(function(){return ke})),n.d(t,"Formula",(function(){return q})),n.d(t,"Store",(function(){return re})),n.d(t,"jsonParser",(function(){return Te})),n.d(t,"Literal",(function(){return X.a})),n.d(t,"log",(function(){return N.a})),n.d(t,"N3Parser",(function(){return ie.a})),n.d(t,"NamedNode",(function(){return R.a})),n.d(t,"Namespace",(function(){return F.a})),n.d(t,"Node",(function(){return z})),n.d(t,"parse",(function(){return ae.a})),n.d(t,"Query",(function(){return G})),n.d(t,"queryToSPARQL",(function(){return De})),n.d(t,"RDFaProcessor",(function(){return le.a})),n.d(t,"RDFParser",(function(){return oe.a})),n.d(t,"serialize",(function(){return O.a})),n.d(t,"Serializer",(function(){return Be.a})),n.d(t,"SPARQLToQuery",(function(){return Ne})),n.d(t,"sparqlUpdateParser",(function(){return Fe.a})),n.d(t,"Statement",(function(){return Oe.a})),n.d(t,"term",(function(){return at})),n.d(t,"UpdateManager",(function(){return Pe})),n.d(t,"UpdatesSocket",(function(){return Ve})),n.d(t,"UpdatesVia",(function(){return ze})),n.d(t,"uri",(function(){return W})),n.d(t,"Util",(function(){return V})),n.d(t,"Variable",(function(){return j.a})),n.d(t,"IndexedFormula",(function(){return re})),n.d(t,"NextId",(function(){return lt})),n.d(t,"fromNT",(function(){return it})),n.d(t,"fetcher",(function(){return Ge})),n.d(t,"graph",(function(){return Je})),n.d(t,"lit",(function(){return Ke})),n.d(t,"st",(function(){return Xe})),n.d(t,"sym",(function(){return Ye})),n.d(t,"blankNode",(function(){return Qe})),n.d(t,"defaultGraph",(function(){return Ze})),n.d(t,"literal",(function(){return et})),n.d(t,"namedNode",(function(){return Ye})),n.d(t,"quad",(function(){return tt})),n.d(t,"triple",(function(){return nt})),n.d(t,"variable",(function(){return $e})),n.d(t,"termValue",(function(){return de.a}));var r=n(40),i=n(62),a=n(124),l=n(7),o=n.n(l),u=n(11),s=n.n(u),d=n(5),c=n.n(d),p=n(28),f=n.n(p),h=n(15),m=n.n(h),v=n(21),g=n.n(v),b=n(1),y=n.n(b),w=n(18),x=n(2);function E(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(e){return!1}}var A=function(e){g()(r,e);var t,n=(t=r,function(){var e,n=m()(t);if(E()){var r=m()(this).constructor;e=Reflect.construct(n,arguments,r)}else e=n.apply(this,arguments);return f()(this,e)});function r(){var e;return o()(this,r),e=n.call(this,""),y()(c()(e),"termType",x.d),e}return s()(r,[{key:"toString",value:function(){return"()"}}]),r}(w.a),C=n(163),_=n.n(C),S=n(256),k=n.n(S),T=n(34),D=n(76),B=n(35),N=n(4),F=n(19),O=n(77),I=n(9),j=n(46),M=n(31),R=n(14);function P(e){if("undefined"==typeof Symbol||null==e[Symbol.iterator]){if(Array.isArray(e)||(e=function(e,t){if(!e)return;if("string"==typeof e)return L(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(n);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return L(e,t)}(e))){var t=0,n=function(){};return{s:n,n:function(){return t>=e.length?{done:!0}:{done:!1,value:e[t++]}},e:function(e){throw e},f:n}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var r,i,a=!0,l=!1;return{s:function(){r=e[Symbol.iterator]()},n:function(){var e=r.next();return a=e.done,e},e:function(e){l=!0,i=e},f:function(){try{a||null==r.return||r.return()}finally{if(l)throw i}}}}function L(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function U(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(e){return!1}}var q=function(e){g()(r,e);var t,n=(t=r,function(){var e,n=m()(t);if(U()){var r=m()(this).constructor;e=Reflect.construct(n,arguments,r)}else e=n.apply(this,arguments);return f()(this,e)});function r(){var e,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:[],l=arguments.length>3&&void 0!==arguments[3]?arguments[3]:[],u=arguments.length>4&&void 0!==arguments[4]?arguments[4]:{};o()(this,r),(e=n.call(this,"")).statements=t,e.constraints=i,e.initBindings=a,e.optional=l,y()(c()(e),"termType",x.e),y()(c()(e),"classOrder",T.a.Graph),y()(c()(e),"fetcher",void 0),y()(c()(e),"isVar",0),y()(c()(e),"ns",F.a),y()(c()(e),"rdfFactory",void 0),e.rdfFactory=u&&u.rdfFactory||B.a;var s,d=P(M.b);try{var p=function(){var t=s.value;e[t]=function(){var n;return(n=e.rdfFactory)[t].apply(n,arguments)}};for(d.s();!(s=d.n()).done;)p()}catch(e){d.e(e)}finally{d.f()}return e}return s()(r,[{key:"add",value:function(e,t,n,r){var i=this;return 1===arguments.length&&e.forEach((function(e){return i.add(e.subject,e.predicate,e.object,e.graph)})),this.statements.push(this.rdfFactory.quad(e,t,n,r))}},{key:"addStatement",value:function(e){return this.add(e)}},{key:"bnode",value:function(e){return this.rdfFactory.blankNode(e)}},{key:"addAll",value:function(e){var t=this;e.forEach((function(e){t.add(e.subject,e.predicate,e.object,e.graph)}))}},{key:"any",value:function(e,t,n,r){var i=this.anyStatementMatching(e,t,n,r);return null==i?null:null==e?i.subject:null==t?i.predicate:null==n?i.object:null}},{key:"anyValue",value:function(e,t,n,r){var i=this.any(e,t,n,r);return i?i.value:void 0}},{key:"anyJS",value:function(e,t,n,r){var i=this.any(e,t,n,r);return i?w.a.toJS(i):void 0}},{key:"anyStatementMatching",value:function(e,t,n,r){var i=this.statementsMatching(e,t,n,r,!0);if(i&&0!==i.length)return i[0]}},{key:"id",value:function(e){return this.rdfFactory.id(e)}},{key:"statementsMatching",value:function(e,t,n,r,i){var a=this.statements.filter((function(i){return(!e||e.equals(i.subject))&&(!t||t.equals(i.predicate))&&(!n||n.equals(i.object))&&(!r||r.equals(i.subject))}));return i?0===a.length?[]:[a[0]]:a}},{key:"bottomTypeURIs",value:function(e){var t,n,r,i,a,l;for(var o in t=[],e)if(e.hasOwnProperty(o)){for(l=e[o],n=!0,r=0,i=(a=this.each(void 0,this.rdfFactory.namedNode("http://www.w3.org/2000/01/rdf-schema#subClassOf"),this.rdfFactory.namedNode(o))).length;r<i;r++)if(a[r].uri in e){n=!1;break}n&&(t[o]=l)}return t}},{key:"collection",value:function(){return new i.a}},{key:"each",value:function(e,t,n,r){var i=[],a=this.statementsMatching(e,t,n,r,!1);if(null==e)for(var l=0,o=a.length;l<o;l++)i.push(a[l].subject);else if(null==t)for(var u=0,s=a.length;u<s;u++)i.push(a[u].predicate);else if(null==n)for(var d=0,c=a.length;d<c;d++)i.push(a[d].object);else if(null==r)for(var p=0,f=a.length;p<f;p++)i.push(new R.a(a[p].graph.value));return i}},{key:"equals",value:function(e){return!!e&&this.hashString()===e.hashString()}},{key:"findMembersNT",value:function(e){var t,n,r,i,a,l,o,u,s,d,c,p,f,h;for(var m in(p={})[e.toNT()]=!0,i={},l=this.transitiveClosure(p,this.rdfFactory.namedNode("http://www.w3.org/2000/01/rdf-schema#subClassOf"),!0))if(l.hasOwnProperty(m)){for(var v=0,g=(o=this.statementsMatching(void 0,this.rdfFactory.namedNode("http://www.w3.org/1999/02/22-rdf-syntax-ns#type"),this.fromNT(m))).length;v<g;v++)i[(f=o[v]).subject.toNT()]=f;for(var b=0,y=(u=this.each(void 0,this.rdfFactory.namedNode("http://www.w3.org/2000/01/rdf-schema#domain"),this.fromNT(m))).length;b<y;b++)for(a=u[b],r=0,t=(s=this.statementsMatching(void 0,a)).length;r<t;r++)i[(f=s[r]).subject.toNT()]=f;for(var w=0,x=(d=this.each(void 0,this.rdfFactory.namedNode("http://www.w3.org/2000/01/rdf-schema#range"),this.fromNT(m))).length;w<x;w++)for(a=d[w],h=0,n=(c=this.statementsMatching(void 0,a)).length;h<n;h++)i[(f=c[h]).object.toNT()]=f}return i}},{key:"findMemberURIs",value:function(e){return this.NTtoURI(this.findMembersNT(e))}},{key:"findSubClassesNT",value:function(e){var t={};return t[e.toNT()]=!0,this.transitiveClosure(t,this.rdfFactory.namedNode("http://www.w3.org/2000/01/rdf-schema#subClassOf"),!0)}},{key:"findSuperClassesNT",value:function(e){var t={};return t[e.toNT()]=!0,this.transitiveClosure(t,this.rdfFactory.namedNode("http://www.w3.org/2000/01/rdf-schema#subClassOf"),!1)}},{key:"findTypesNT",value:function(e){var t,n,r,i,a,l;l=[];for(var o=0,u=(t=this.statementsMatching(e,void 0,void 0)).length;o<u;o++)if("http://www.w3.org/1999/02/22-rdf-syntax-ns#type"===(a=t[o]).predicate.uri)l[a.object.toNT()]=a;else for(var s=0,d=(n=this.each(a.predicate,this.rdfFactory.namedNode("http://www.w3.org/2000/01/rdf-schema#domain"))).length;s<d;s++)l[n[s].toNT()]=a;for(var c=0,p=(r=this.statementsMatching(void 0,void 0,e)).length;c<p;c++){a=r[c];for(var f=0,h=(i=this.each(a.predicate,this.rdfFactory.namedNode("http://www.w3.org/2000/01/rdf-schema#range"))).length;f<h;f++)l[i[f].toNT()]=a}return this.transitiveClosure(l,this.rdfFactory.namedNode("http://www.w3.org/2000/01/rdf-schema#subClassOf"),!1)}},{key:"findTypeURIs",value:function(e){return this.NTtoURI(this.findTypesNT(e))}},{key:"connectedStatements",value:function(e,t,n){n=n||[];for(var r=[e],i={},a={},l=[],o=this,u=function(e){var u=function(e){"BlankNode"!==e.termType||i[e.value]||(i[e.value]=!0,r.push(e))},s=o.statementsMatching(null,null,e,t).concat(o.statementsMatching(e,null,null,t));(s=s.filter((function(e){if(n[e.predicate.value])return!1;var t=e.toNT();return!a[t]&&(a[t]=!0,!0)}))).forEach((function(e){u(e.subject),u(e.object)})),l=l.concat(s)};r.length;)u(r.shift());return l}},{key:"formula",value:function(e){return new r}},{key:"fromNT",value:function(e){var t,n,r;switch(e[0]){case"<":return this.sym(e.slice(1,-1));case'"':if(r=void 0,t=void 0,(n=e.lastIndexOf('"'))<e.length-1)if("@"===e[n+1])r=e.slice(n+2);else{if("^^"!==e.slice(n+1,n+3))throw new Error("Can't convert string from NT: "+e);t=this.fromNT(e.slice(n+3))}return e=(e=(e=(e=e.slice(1,n)).replace(/\\"/g,'"')).replace(/\\n/g,"\n")).replace(/\\\\/g,"\\"),this.rdfFactory.literal(e,r||t);case"_":return this.rdfFactory.blankNode(e.slice(2));case"?":return new j.a(e.slice(1))}throw new Error("Can't convert from NT: "+e)}},{key:"holds",value:function(e,t,n,r){var i;if(1===arguments.length){if(!e)return!0;if(e instanceof Array){for(i=0;i<e.length;i++)if(!this.holds(e[i]))return!1;return!0}if(Object(I.j)(e))return this.holds(e.subject,e.predicate,e.object,e.graph);if(e.statements)return this.holds(e.statements)}var a=this.anyStatementMatching(e,t,n,r);return null!=a}},{key:"holdsStatement",value:function(e){return this.holds(e.subject,e.predicate,e.object,e.graph)}},{key:"list",value:function(e,t){if(t.rdfFactory.supports.COLLECTIONS){var n=t.rdfFactory.collection();return e.forEach((function(e){n.append(e)})),n}var r=t.rdfFactory.blankNode(),i=Object(M.c)(t.rdfFactory,r,e);return t.addAll(i),r}},{key:"NTtoURI",value:function(e){var t,n,r={};for(t in e)e.hasOwnProperty(t)&&(n=e[t],"<"===t[0]&&(r[t.slice(1,-1)]=n));return r}},{key:"serialize",value:function(e,t,n){var r,i,a;switch((a=Object(O.a)(this)).suggestNamespaces(this.ns),a.setBase(e),i=n?this.statementsMatching(void 0,void 0,void 0,n):this.statements,null!=t?t:"text/n3"){case"application/rdf+xml":r=a.statementsToXML(i);break;case"text/n3":case"text/turtle":r=a.statementsToN3(i);break;default:throw new Error("serialize: Content-type "+t+" not supported.")}return r}},{key:"substitute",value:function(e){var t=this.statements.map((function(t){return t.substitute(e)}));console.log("Formula subs statmnts:"+t);var n=new r;return n.addAll(t),console.log("indexed-form subs formula:"+n),n}},{key:"sym",value:function(e,t){if(t)throw new Error("This feature (kb.sym with 2 args) is removed. Do not assume prefix mappings.");return this.rdfFactory.namedNode(e)}},{key:"the",value:function(e,t,n,r){var i=this.any(e,t,n,r);return null==i&&N.a.error("No value found for the() {"+e+" "+t+" "+n+"}."),i}},{key:"transitiveClosure",value:function(e,t,n){var r,i,a,l,o,u={};Object.assign(u,e);for(var s={};;){if(null==(o=function(){for(var e in u)if(u.hasOwnProperty(e))return e}()))return s;for(r=0,i=(l=n?this.each(void 0,t,this.fromNT(o)):this.each(this.fromNT(o),t)).length;r<i;r++)(a=l[r].toNT())in s||a in u||(u[a]=u[o]);s[o]=u[o],delete u[o]}}},{key:"topTypeURIs",value:function(e){var t,n,r,i,a,l,o;for(n in l=[],e)if(e.hasOwnProperty(n)){for(o=e[n],i=0,t=0,r=(a=this.each(this.rdfFactory.namedNode(n),this.rdfFactory.namedNode("http://www.w3.org/2000/01/rdf-schema#subClassOf"))).length;t<r;t++)if("http://www.w3.org/2000/01/rdf-schema#Resource"!==a[t].uri){i++;break}i||(l[n]=o)}return l["http://www.w3.org/2000/01/rdf-schema#Resource"]&&delete l["http://www.w3.org/2000/01/rdf-schema#Resource"],l["http://www.w3.org/2002/07/owl#Thing"]&&delete l["http://www.w3.org/2002/07/owl#Thing"],l}},{key:"toString",value:function(){return"{"+this.statements.join("\n")+"}"}},{key:"variable",value:function(e){return new j.a(e)}},{key:"whether",value:function(e,t,n,r){return this.statementsMatching(e,t,n,r,!1).length}}]),r}(w.a),V=n(16);w.a.fromValue=i.b;var z=w.a,H={xsd:Object(F.a)("http://www.w3.org/2001/XMLSchema#")};w.a.toJS=function(e){return Object(I.b)(e)?e.elements.map(w.a.toJS):Object(I.d)(e)?e.datatype.equals(H.xsd("boolean"))?"1"===e.value||"true"===e.value:e.datatype.equals(H.xsd("dateTime"))||e.datatype.equals(H.xsd("date"))?new Date(e.value):e.datatype.equals(H.xsd("integer"))||e.datatype.equals(H.xsd("float"))||e.datatype.equals(H.xsd("decimal"))?Number(e.value):e.value:e};var W=n(8),G=function e(t,n){o()(this,e),this.pat=new re,this.vars=[],this.name=t,this.id=n};function J(e,t,n,r){function i(e){var t,n="";for(t in e)e.hasOwnProperty(t)&&(n+=" "+t+" -> "+e[t]);return n}function a(e){var t,n="Bindings: ",r=e.length;for(t=0;t<r;t++)n+=i(e[t][0])+";\n\t";return n}function l(e,t,n,r){var i;if(e.length!==t.length)return[];if(!e.length)return[[[],null]];var a=function(e,t,n,r){var i=n[e];if(void 0===i){if(e.isVar){var a=[];return a[e]=t,[[a,null]]}i=e}if(!i.complexType)return r.redirections[i]&&(i=r.redirections[i]),r.redirections[t]&&(t=r.redirections[t]),i.equals(t)||i.uri&&i.uri===D.a?[[[],null]]:[];if(e instanceof Array)return t instanceof Array?l(e,t,n):[];throw new Error("query.js: oops - code not written yet")}(e[0],t[0],n,r);if(0===a.length)return a;var o,u,s,d,c,p,f,h=[],m=a.length;for(o=0;o<m;o++){for(c in f=[],u=a[o][0])u.hasOwnProperty(c)&&(f[c]=u[c]);for(c in n)n.hasOwnProperty(c)&&(f[c]=n[c]);for(d=(i=l(e.slice(1),t.slice(1),f,r)).length,s=0;s<d;s++){for(c in p=i[s][0],u)u.hasOwnProperty(c)&&(p[c]=u[c]);h.push([p,null])}}return h}function o(e,t){var n,r={};for(n in e)e.hasOwnProperty(n)&&(r[n]=e[n]);for(n in t)t.hasOwnProperty(n)&&(r[n]=t[n]);return r}function u(e,t){return this.trunkBindings=t,this.originalCallback=e,this.branches=[],this}function s(e,t){return this.count=0,this.success=!1,this.done=!1,this.callback=e,this.onDone=t,this}u.prototype.checkAllDone=function(){var e;for(e=0;e<this.branches.length;e++)if(!this.branches[e].done)return;N.a.debug("OPTIONAL BIDNINGS ALL DONE:"),this.doCallBacks(this.branches.length-1,this.trunkBindings)},u.prototype.doCallBacks=function(e,t){var n;if(e<0)return this.originalCallback(t);for(n=0;n<this.branches[e].results.length;n++)this.doCallBacks(e-1,o(t,this.branches[e].results[n]))},s.prototype.reportMatch=function(e){this.callback(e),this.success=!0},s.prototype.reportDone=function(){this.done=!0,N.a.info("Mandatory query branch finished.***"),void 0!==this.onDone&&this.onDone()};var d=function(e){return this.count=0,this.done=!1,this.results=[],this.junction=e,e.branches.push(this),this};function c(e,t,n){var r,i,a,l,o,u;for(t.nvars=0,t.index=null,r=[t.subject,t.predicate,t.object,t.why],l=[e.subjectIndex,e.predicateIndex,e.objectIndex,e.whyIndex],a=0;a<4;a++){var s=r[a];if(s.uri&&s.uri===D.a);else if(s.isVar&&void 0===n[s])t.nvars++;else{if(u=void 0,s=void 0===(u=n[o=r[a]])?o:u,e.redirections[e.id(s)]&&(s=e.redirections[e.id(s)]),!(i=l[a][e.id(s)]))return t.index=[],!1;(null===t.index||t.index.length>i.length)&&(t.index=i)}}return null===t.index&&(t.index=e.statements),!0}function p(e,t){return e.nvars!==t.nvars?e.nvars-t.nvars:e.index.length-t.index.length}d.prototype.reportMatch=function(e){this.results.push(e)},d.prototype.reportDone=function(){N.a.debug("Optional branch finished - results.length = "+this.results.length),0===this.results.length&&(this.results.push({}),N.a.debug("Optional branch FAILED - that's OK.")),this.done=!0,this.junction.checkAllDone()};var f=function e(n,r,a,l,o,s,c){N.a.debug("Match begins, Branch count now: "+c.count+" for "+c.pattern_debug);var p,f,h=n.fetcher?n.fetcher:null,v=r.statements;if(0===v.length){if(N.a.debug("FOUND MATCH WITH BINDINGS:"+i(a)),0===r.optional.length)c.reportMatch(a);else{N.a.debug("OPTIONAL: "+r.optional);var g,b=new u(t,a),y=[];for(g=0;g<r.optional.length;g++)y[g]=new d(b),y[g].pattern_debug=r.optional[g];for(g=0;g<r.optional.length;g++)y[g].count=y[g].count+1,e(n,r.optional[g],a,"",o,t,y[g])}return c.count--,void N.a.debug("Match ends -- success , Branch count now: "+c.count+" for "+c.pattern_debug)}var w=v.length;if(h){0;var x=function(t,i){var u=t.uri.split("#")[0];h.nowOrWhenFetched(u,void 0,(function(i,u,d){i||console.log("Error following link to <"+t.uri+"> in query: "+u),e(n,r,a,l,o,s,c)}))};for(f=0;f<w;f++){if(p=v[f],void 0!==a[p.subject]&&a[p.subject].uri&&h&&"unrequested"===h.getState(Object(W.docpart)(a[p.subject].uri)))return void x(a[p.subject]);if(void 0!==a[p.object]&&a[p.object].uri&&h&&"unrequested"===h.getState(Object(W.docpart)(a[p.object].uri)))return void x(a[p.object])}}m(n,r,a,l,o,s,c)},h=function(e,t){var n,r,i=!0;for(n in e)e.hasOwnProperty(n)&&t[n]&&(r=t[n].test)&&!r(e[n])&&(i=!1);return i},m=function(e,t,n,r,o,u,s){var d,m,v,g,b,y,w,x=t.statements,E=x.length;for(d=0;d<E;d++)c(e,w=x[d],n);x.sort(p),w=x[0];var A,C=e.formula();C.optional=t.optional,C.constraints=t.constraints,C.statements=x.slice(1),N.a.debug(r+"match2 searching "+w.index.length+" for "+w+"; bindings so far="+i(n));var _,S,k=w.index.length,T=0;for(A=0;A<k;A++)for(S=w.index[A],_=l([w.subject,w.predicate,w.object,w.why],[S.subject,S.predicate,S.object,S.why],n,e),N.a.info(r+" From first: "+_.length+": "+a(_)),v=_.length,m=0;m<v;m++)if(b=[],y=_[m][0],h(y,t.constraints)){for(g in y)y.hasOwnProperty(g)&&(b[g]=y[g]);for(g in n)n.hasOwnProperty(g)&&(b[g]=n[g]);s.count++,T++,f(e,C,b,r+" ",o,u,s)}else N.a.debug("Branch count CS: "+s.count);s.count--,0===T&&N.a.debug("Match2 fails completely on "+w),N.a.debug("Match2 ends, Branch count: "+s.count+" for "+s.pattern_debug),0===s.count&&(N.a.debug("Branch finished."),s.reportDone())},v=this;N.a.debug("Query on "+this.statements.length);var g=new s(t,r);g.count++,e.sync?f(v,e.pat,e.pat.initBindings,"",n,t,g):setTimeout((function(){f(v,e.pat,e.pat.initBindings,"",n,t,g)}),0)}var K=n(68),X=n(36);function Y(e){if("undefined"==typeof Symbol||null==e[Symbol.iterator]){if(Array.isArray(e)||(e=function(e,t){if(!e)return;if("string"==typeof e)return $(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(n);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return $(e,t)}(e))){var t=0,n=function(){};return{s:n,n:function(){return t>=e.length?{done:!0}:{done:!1,value:e[t++]}},e:function(e){throw e},f:n}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var r,i,a=!0,l=!1;return{s:function(){r=e[Symbol.iterator]()},n:function(){var e=r.next();return a=e.done,e},e:function(e){l=!0,i=e},f:function(){try{a||null==r.return||r.return()}finally{if(l)throw i}}}}function $(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function Q(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(e){return!1}}var Z="http://www.w3.org/2002/07/owl#";function ee(e,t,n,r){var i=e.any(t,n,void 0);return!!i&&(e.equate(i,r),!0)}function te(e,t,n,r){var i=e.any(void 0,n,r);return!!i&&(e.equate(i,t),!0)}function ne(e,t,n,r,i){e.typeCallback&&e.typeCallback(e,r,i);var a=e.classActions[e.id(r)],l=!1;if(a)for(var o=0;o<a.length;o++)l=l||a[o](e,t,n,r,i);return l}var re=function(e){g()(i,e);var t,n=(t=i,function(){var e,n=m()(t);if(Q()){var r=m()(this).constructor;e=Reflect.construct(n,arguments,r)}else e=n.apply(this,arguments);return f()(this,e)});function i(e){var t,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return o()(this,i),t=n.call(this,void 0,void 0,void 0,void 0,r),y()(c()(t),"updater",void 0),y()(c()(t),"namespaces",void 0),y()(c()(t),"classActions",void 0),y()(c()(t),"propertyActions",void 0),y()(c()(t),"redirections",void 0),y()(c()(t),"aliases",void 0),y()(c()(t),"HTTPRedirects",void 0),y()(c()(t),"subjectIndex",void 0),y()(c()(t),"predicateIndex",void 0),y()(c()(t),"objectIndex",void 0),y()(c()(t),"whyIndex",void 0),y()(c()(t),"index",void 0),y()(c()(t),"features",void 0),y()(c()(t),"_universalVariables",void 0),y()(c()(t),"_existentialVariables",void 0),y()(c()(t),"rdfArrayRemove",void 0),y()(c()(t),"dataCallbacks",void 0),t.propertyActions={},t.classActions={},t.redirections=[],t.aliases=[],t.HTTPRedirects=[],t.subjectIndex=[],t.predicateIndex=[],t.objectIndex=[],t.whyIndex=[],t.index=[t.subjectIndex,t.predicateIndex,t.objectIndex,t.whyIndex],t.namespaces={},t.features=e||["sameAs","InverseFunctionalProperty","FunctionalProperty"],t.rdfArrayRemove=r.rdfArrayRemove||V.RDFArrayRemove,r.dataCallback&&(t.dataCallbacks=[r.dataCallback]),t.initPropertyActions(t.features),t}return s()(i,[{key:"substitute",value:function(e){var t=this.statements.map((function(t){return t.substitute(e)})),n=new i;return n.add(t),n}},{key:"addDataCallback",value:function(e){this.dataCallbacks||(this.dataCallbacks=[]),this.dataCallbacks.push(e)}},{key:"applyPatch",value:function(e,t,n){var r,i=this,a=null;function l(l){if(e.delete){r=e.delete,a&&(r=r.substitute(a)),r=r.statements;var o=[],u=r.map((function(e){var n=i.statementsMatching(e.subject,e.predicate,e.object,t);return 0===n.length?(o.push(e),null):n[0]}));if(o.length)return n("Could not find to delete: "+o.join("\n or "));u.map((function(e){i.remove(e)}))}e.insert&&(r=e.insert,a&&(r=r.substitute(a)),(r=r.statements).map((function(e){e.graph=t,i.add(e.subject,e.predicate,e.object,e.graph)}))),l()}if(e.where){var o=new G("patch");o.pat=e.where,o.pat.statements.map((function(e){e.graph=Ye(t.value)})),o.sync=!0;var u=[];i.query(o,(function(e){u.push(e)}),i.fetcher,(function(){return 0===u.length?n("No match found to be patched:"+e.where):u.length>1?n("Patch ambiguous. No patch done."):(a=u[0],void l(n))}))}else l(n)}},{key:"declareExistential",value:function(e){return this._existentialVariables||(this._existentialVariables=[]),this._existentialVariables.push(e),e}},{key:"initPropertyActions",value:function(e){this.propertyActions[this.rdfFactory.id(this.rdfFactory.namedNode("http://www.w3.org/1999/02/22-rdf-syntax-ns#type"))]=[ne],Object(M.a)(e,"sameAs")>=0&&(this.propertyActions[this.rdfFactory.id(this.rdfFactory.namedNode("".concat(Z,"sameAs")))]=[function(e,t,n,r,i){return e.equate(t,r),!0}]),Object(M.a)(e,"InverseFunctionalProperty")>=0&&(this.classActions[this.rdfFactory.id(this.rdfFactory.namedNode("".concat(Z,"InverseFunctionalProperty")))]=[function(e,t,n,r,i){return e.newPropertyAction(t,te)}]),Object(M.a)(e,"FunctionalProperty")>=0&&(this.classActions[this.rdfFactory.id(this.rdfFactory.namedNode("".concat(Z,"FunctionalProperty")))]=[function(e,t,n,r,i){return e.newPropertyAction(t,ee)}])}},{key:"addStatement",value:function(e){return this.add(e.subject,e.predicate,e.object,e.graph),this.statements.length}},{key:"add",value:function(e,t,n,r){var i,a,l;if(1===arguments.length){if(e instanceof Array)for(i=0;i<e.length;i++)this.add(e[i]);else Object(I.g)(e)?this.add(e.subject,e.predicate,e.object,e.graph):Object(I.k)(e)&&this.add(e.statements);return this}r||(r=this.fetcher?this.fetcher.appNode:this.rdfFactory.defaultGraph()),"string"==typeof e&&(e=this.rdfFactory.namedNode(e)),t=z.fromValue(t);var o=z.fromValue(n);if(r=z.fromValue(r),!Object(I.l)(e))throw new Error("Subject is not a subject type");if(!Object(I.f)(t))throw new Error("Predicate ".concat(t," is not a predicate type"));if(!Object(I.i)(o))throw new Error("Object ".concat(o," is not an object type"));if(!Object(I.c)(r))throw new Error("Why is not a graph type");this.predicateCallback&&this.predicateCallback(this,t,r);var u=this.id(this.canon(t)),s=!1;if(a=this.propertyActions[u])for(i=0;i<a.length;i++)s=s||a[i](this,e,t,o,r);if(this.holds(e,t,o,r))return null;var d=[this.id(this.canon(e)),u,this.id(this.canon(o)),this.id(this.canon(r))];for(l=this.rdfFactory.quad(e,t,o,r),i=0;i<4;i++){var c=this.index[i],p=d[i];c[p]||(c[p]=[]),c[p].push(l)}if(this.statements.push(l),this.dataCallbacks){var f,h=Y(this.dataCallbacks);try{for(h.s();!(f=h.n()).done;){var m=f.value;m(l)}}catch(e){h.e(e)}finally{h.f()}}return l}},{key:"canon",value:function(e){if(!e)return e;var t=this.redirections[this.id(e)];if(t)return t;switch(e.termType){case x.a:return new r.a(e.value);case x.b:return e;case x.c:return new K.a;case x.d:case x.e:return e;case x.h:return new X.a(e.value,e.language,e.datatype);case x.n:return new R.a(e.value);case x.s:return new j.a(e.value);default:throw new Error("Term Type not recognized for canonization: ".concat(e.termType))}}},{key:"check",value:function(){this.checkStatementList(this.statements);for(var e=0;e<4;e++){var t=this.index[e];for(var n in t)t.hasOwnProperty(n)&&this.checkStatementList(t[n],e)}}},{key:"checkStatementList",value:function(e,t){void 0===t&&(t=0);for(var n,r=" found in "+["subject","predicate","object","why"][t]+" index.",i=0;i<e.length;i++){for(var a=[(n=e[i]).subject,n.predicate,n.object,n.graph],l=function(e,t){for(var n=0;n<e.length;n++)if(e[n].subject.equals(t.subject)&&e[n].predicate.equals(t.predicate)&&e[n].object.equals(t.object)&&e[n].why.equals(t.graph))return!0},o=0;o<4;o++){var u=this.canon(a[o]),s=this.id(u);this.index[o][s]&&l(this.index[o][s],n)}if(!l(this.statements,n))throw new Error("Statement list does not statement "+n+"@"+n.graph+r)}}},{key:"close",value:function(){return this}},{key:"compareTerms",value:function(e,t){return Object.prototype.hasOwnProperty.call(e,"compareTerm")?e.compareTerm(t):T.a[e.termType]<T.a[t.termType]?-1:T.a[e.termType]>T.a[t.termType]?1:e.value<t.value?-1:e.value>t.value?1:0}},{key:"copyTo",value:function(e,t,n){n||(n=[]);var r=this.statementsMatching(e);-1!==Object(M.a)(n,"two-direction")&&r.concat(this.statementsMatching(void 0,void 0,e));for(var i=0;i<r.length;i++){var a=r[i];switch(a.object.termType){case"NamedNode":this.add(t,a.predicate,a.object);break;case"Literal":case"BlankNode":case"Collection":this.add(t,a.predicate,a.object.copy(this))}-1!==Object(M.a)(n,"delete")&&this.remove(a)}}},{key:"equate",value:function(e,t){var n=this.canon(e),r=this.canon(t),i=this.compareTerms(n,r);return!i||(i<0?this.replaceWith(r,n):this.replaceWith(n,r))}},{key:"formula",value:function(e){return new i(e)}},{key:"match",value:function(e,t,n,r){return this.statementsMatching(z.fromValue(e),z.fromValue(t),z.fromValue(n),z.fromValue(r))}},{key:"mentionsURI",value:function(e){var t="<"+e+">";return!!this.subjectIndex[t]||!!this.objectIndex[t]||!!this.predicateIndex[t]}},{key:"newExistential",value:function(e){if(!e)return this.bnode();var t=this.sym(e);return this.declareExistential(t)}},{key:"newPropertyAction",value:function(e,t){var n=this.id(e);this.propertyActions[n]||(this.propertyActions[n]=[]),this.propertyActions[n].push(t);for(var r=this.statementsMatching(void 0,e,void 0),i=!1,a=0;a<r.length;a++)i=i||t(this,r[a].subject,e,r[a].object);return i}},{key:"newUniversal",value:function(e){var t=this.sym(e);return this._universalVariables||(this._universalVariables=[]),this._universalVariables.push(t),t}},{key:"variable",value:function(e){return new j.a(e)}},{key:"nextSymbol",value:function(e){for(var t=0;;t++){var n=e.value+"#n"+t;if(!this.mentionsURI(n))return this.sym(n)}}},{key:"query",value:function(e,t,n,r){return J.call(this,e,t,n,r)}},{key:"querySync",value:function(e){var t=[];var n=!1;if(e.sync=!0,J.call(this,e,(function(e){t.push(e)}),null,(function(){n=!0})),!n)throw new Error("Sync query should have called done function");return t}},{key:"remove",value:function(e){if(e instanceof Array){for(var t=0;t<e.length;t++)this.remove(e[t]);return this}if(Object(I.k)(e))return this.remove(e.statements);var n=this.statementsMatching(e.subject,e.predicate,e.object,e.graph);if(!n.length)throw new Error("Statement to be removed is not on store: "+e);return this.removeStatement(n[0]),this}},{key:"removeDocument",value:function(e){for(var t=this.statementsMatching(void 0,void 0,void 0,e).slice(),n=0;n<t.length;n++)this.removeStatement(t[n]);return this}},{key:"removeMany",value:function(e,t,n,r,i){for(var a=this.statementsMatching(e,t,n,r,!1),l=[],o=0;o<a.length;o++)l.push(a[o]);for(i&&(l=l.slice(0,i)),o=0;o<l.length;o++)this.remove(l[o])}},{key:"removeMatches",value:function(e,t,n,r){return this.removeStatements(this.statementsMatching(e,t,n,r)),this}},{key:"removeStatement",value:function(e){for(var t=[e.subject,e.predicate,e.object,e.graph],n=0;n<4;n++){var r=this.canon(t[n]),i=this.id(r);this.index[n][i]&&this.rdfArrayRemove(this.index[n][i],e)}return this.rdfArrayRemove(this.statements,e),this}},{key:"removeStatements",value:function(e){for(var t=0;t<e.length;t++)this.remove(e[t]);return this}},{key:"replaceWith",value:function(e,t){for(var n=this.id(e),r=this.id(t),i=function(e){var t=e[n];if(t){var i=e[r];e[r]=i?t.concat(i):t,delete e[n]}},a=0;a<4;a++)i(this.index[a]);if(this.redirections[n]=t,e.value){if(this.aliases[r]||(this.aliases[r]=[]),this.aliases[r].push(e),this.aliases[n])for(a=0;a<this.aliases[n].length;a++)this.redirections[this.id(this.aliases[n][a])]=t,this.aliases[r].push(this.aliases[n][a]);this.add(t,this.sym("http://www.w3.org/2007/ont/link#uri"),e),this.fetcher&&this.fetcher.nowKnownAs(e,t)}return i(this.classActions),i(this.propertyActions),!0}},{key:"allAliases",value:function(e){var t=this.aliases[this.id(this.canon(e))]||[];return t.push(this.canon(e)),t}},{key:"sameThings",value:function(e,t){if(e.equals(t))return!0;var n=this.canon(e);if(!n)return!1;var r=this.canon(t);return!!r&&n.value===r.value}},{key:"setPrefixForURI",value:function(e,t){"tab"===e&&this.namespaces.tab||"ns"!==e.slice(0,2)&&"default"!==e.slice(0,7)&&(this.namespaces[e]=t)}},{key:"statementsMatching",value:function(e,t,n,r,i){var a,l,o=[e,t,n,r],u=[],s=[],d=[],c=[];for(a=0;a<4;a++)u[a]=this.canon(z.fromValue(o[a])),u[a]?(c.push(a),s[a]=this.id(u[a])):d.push(a);if(0===c.length)return this.statements;if(1===c.length)return a=c[0],(l=this.index[a][s[a]])&&i&&l.length>1&&(l=l.slice(0,1)),l=l||[];var p,f,h=1e10;for(f=0;f<c.length;f++){if(a=c[f],!(l=this.index[a][s[a]]))return[];l.length<h&&(h=l.length,p=f)}for(var m=c[p],v=this.index[m][s[m]],g=c.slice(0,p).concat(c.slice(p+1)),b=[],y=["subject","predicate","object","why"],w=0;w<v.length;w++){var x=v[w];for(f=0;f<g.length;f++)if(a=g[f],!this.canon(x[y[a]]).equals(u[a])){x=null;break}if(null!=x&&(b.push(x),i))break}return b}},{key:"uris",value:function(e){var t=this.canon(e),n=this.aliases[this.id(t)];if(!t.value)return[];var r=[t.value];if(n)for(var i=0;i<n.length;i++)r.push(n[i].uri);return r}},{key:"length",get:function(){return this.statements.length}}],[{key:"defaultGraphURI",get:function(){return D.a}}]),i}(q);y()(re,"handleRDFType",void 0),re.handleRDFType=ne;var ie=n(66),ae=n(78),le=n(67),oe=n(88),ue=n(257),se=n(161),de=n(53);function ce(e){return function(){var t,n=m()(e);if(pe()){var r=m()(this).constructor;t=Reflect.construct(n,arguments,r)}else t=n.apply(this,arguments);return f()(this,t)}}function pe(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(e){return!1}}var fe="undefined"==typeof window?ue.fetch:se.fetch,he={"text/n3":!0,"text/turtle":!0,"application/rdf+xml":!0,"application/xhtml+xml":!0,"text/html":!0,"application/ld+json":!0},me={rdf:x.o,owl:x.o,n3:"text/n3",ttl:"text/turtle",nt:"text/n3",acl:"text/n3",html:"text/html",xml:"text/xml"},ve=function(e){return{link:Object(F.a)("http://www.w3.org/2007/ont/link#",e),http:Object(F.a)("http://www.w3.org/2007/ont/http#",e),httph:Object(F.a)("http://www.w3.org/2007/ont/httph#",e),rdf:Object(F.a)("http://www.w3.org/1999/02/22-rdf-syntax-ns#",e),rdfs:Object(F.a)("http://www.w3.org/2000/01/rdf-schema#",e),dc:Object(F.a)("http://purl.org/dc/elements/1.1/",e),ldp:Object(F.a)("http://www.w3.org/ns/ldp#",e)}},ge=ve(),be=function e(t,n){o()(this,e),y()(this,"response",void 0),y()(this,"dom",void 0),this.response=t,this.dom=n};y()(be,"pattern",void 0);var ye=function(e){g()(n,e);var t=ce(n);function n(){return o()(this,n),t.apply(this,arguments)}return s()(n,[{key:"parse",value:function(e,t,n){var r=e.store;if(this.dom||(this.dom=V.parseXML(t)),"parsererror"===this.dom.documentElement.nodeName)return e.failFetch(n,"Badly formed XML in "+n.resource.value,"parse_error");var i=new oe.a(r);try{i.parse(this.dom,n.original.value,n.original)}catch(t){return e.failFetch(n,"Syntax error parsing RDF/XML! "+t,"parse_error")}return n.noMeta||r.add(n.original,ge.rdf("type"),ge.link("RDFDocument"),e.appNode),e.doneFetch(n,this.response)}}],[{key:"toString",value:function(){return"RDFXMLHandler"}},{key:"register",value:function(e){e.mediatypes[x.o]={q:.9}}}]),n}(be);ye.pattern=new RegExp("application/rdf\\+xml");var we=function(e){g()(n,e);var t=ce(n);function n(){return o()(this,n),t.apply(this,arguments)}return s()(n,[{key:"parse",value:function(e,t,n){var r,i;this.dom||(this.dom=V.parseXML(t));var a=e.store,l=this.dom.getElementsByTagName("title");l.length>0&&a.add(n.resource,ge.dc("title"),a.rdfFactory.literal(l[0].textContent),n.resource);for(var o=this.dom.getElementsByTagName("link"),u=o.length-1;u>=0;u--)i=!1,(r=o[u].getAttribute("rel"))||(r=o[u].getAttribute("rev"),i=!0),r&&e.linkData(n.original,r,o[u].getAttribute("href"),n.resource,i);for(var s=this.dom.getElementsByTagName("script"),d=0;d<s.length;d++){var c=s[d].getAttribute("type");he[c]&&(Object(ae.a)(s[d].textContent,a,n.original.value,c),Object(ae.a)(s[d].textContent,a,n.original.value,c))}if(n.noMeta||a.add(n.resource,ge.rdf("type"),ge.link("WebPage"),e.appNode),!n.noRDFa&&le.b)try{Object(le.b)(this.dom,a,n.original.value)}catch(t){var p="Error trying to parse "+n.resource+" as RDFa:\n"+t+":\n"+t.stack;return e.failFetch(n,p,"parse_error")}return e.doneFetch(n,this.response)}}],[{key:"toString",value:function(){return"XHTMLHandler"}},{key:"register",value:function(e){e.mediatypes[x.t]={}}}]),n}(be);we.pattern=new RegExp("application/xhtml");var xe=function(e){g()(n,e);var t=ce(n);function n(){return o()(this,n),t.apply(this,arguments)}return s()(n,[{key:"parse",value:function(e,t,n){for(var r=V.parseXML(t),i=0;i<r.childNodes.length;i++)if(1===r.childNodes[i].nodeType){var a=r.childNodes[i].namespaceURI;if(a&&a===a.rdf)return e.addStatus(n.req,"Has XML root element in the RDF namespace, so assume RDF/XML."),new ye(this.response,r).parse(e,t,n);break}if(r.doctype&&("html"===r.doctype.name&&r.doctype.publicId.match(/^-\/\/W3C\/\/DTD XHTML/)&&r.doctype.systemId.match(/http:\/\/www.w3.org\/TR\/xhtml/)))return e.addStatus(n.req,"Has XHTML DOCTYPE. Switching to XHTML Handler.\n"),new we(this.response,r).parse(e,t,n);var l=r.getElementsByTagName("html")[0];if(l){var o=l.getAttribute("xmlns");if(o&&o.match(/^http:\/\/www.w3.org\/1999\/xhtml/))return e.addStatus(n.req,"Has a default namespace for XHTML. Switching to XHTMLHandler.\n"),new we(this.response,r).parse(e,t,n)}return e.failFetch(n,"Unsupported dialect of XML: not RDF or XHTML namespace, etc.\n"+t.slice(0,80),901)}}],[{key:"toString",value:function(){return"XMLHandler"}},{key:"register",value:function(e){e.mediatypes["text/xml"]={q:.5},e.mediatypes["application/xml"]={q:.5}}}]),n}(be);xe.pattern=new RegExp("(text|application)/(.*)xml");var Ee=function(e){g()(n,e);var t=ce(n);function n(){return o()(this,n),t.apply(this,arguments)}return s()(n,[{key:"parse",value:function(e,t,n){var r=e.store;if(Se(t))return e.addStatus(n.req,"Has an XML declaration. We'll assume it's XHTML as the content-type was text/html.\n"),new we(this.response).parse(e,t,n);if(function(e){var t=e.indexOf("<!DOCTYPE html"),n=e.indexOf(">");if(-1===t||-1===n||t>n)return!1;return-1!==e.substr(t,n-t).indexOf("XHTML")}(t))return e.addStatus(n.req,"Has XHTML DOCTYPE. Switching to XHTMLHandler.\n"),new we(this.response).parse(e,t,n);if(function(e){return!!e.match(/[^(<html)]*<html\s+[^<]*xmlns=['"]http:\/\/www.w3.org\/1999\/xhtml["'][^<]*>/)}(t))return e.addStatus(n.req,"Has default namespace for XHTML, so switching to XHTMLHandler.\n"),new we(this.response).parse(e,t,n);var i=new RegExp("<title>([\\s\\S]+?)</title>","im").exec(t);return i&&r.add(n.resource,ge.dc("title"),r.rdfFactory.literal(i[1]),n.resource),r.add(n.resource,ge.rdf("type"),ge.link("WebPage"),e.appNode),e.addStatus(n.req,"non-XML HTML document, not parsed for data."),e.doneFetch(n,this.response)}}],[{key:"toString",value:function(){return"HTMLHandler"}},{key:"register",value:function(e){e.mediatypes["text/html"]={q:.9}}}]),n}(be);Ee.pattern=new RegExp("text/html");var Ae=function(e){g()(n,e);var t=ce(n);function n(){return o()(this,n),t.apply(this,arguments)}return s()(n,[{key:"parse",value:function(e,t,n){return Se(t)?(e.addStatus(n.req,"Warning: "+n.resource+" has an XML declaration. We'll assume it's XML but its content-type wasn't XML.\n"),new xe(this.response).parse(e,t,n)):t.slice(0,500).match(/xmlns:/)?(e.addStatus(n.req,"May have an XML namespace. We'll assume it's XML but its content-type wasn't XML.\n"),new xe(this.response).parse(e,t,n)):(e.addStatus(n.req,"Plain text document, no known RDF semantics."),e.doneFetch(n,this.response))}}],[{key:"toString",value:function(){return"TextHandler"}},{key:"register",value:function(e){e.mediatypes["text/plain"]={q:.5}}}]),n}(be);Ae.pattern=new RegExp("text/plain");var Ce=function(e){g()(n,e);var t=ce(n);function n(){return o()(this,n),t.apply(this,arguments)}return s()(n,[{key:"parse",value:function(e,t,n,r){var i=e.store,a=Object(ie.a)(i,i,n.original.value,n.original.value,null,null,"",null);try{a.loadBuf(t)}catch(t){var l="Error trying to parse "+n.resource+" as Notation3:\n"+t;return e.failFetch(n,l,"parse_error",r)}return e.addStatus(n.req,"N3 parsed: "+a.statementCount+" triples in "+a.lines+" lines."),e.store.add(n.original,ge.rdf("type"),ge.link("RDFDocument"),e.appNode),e.doneFetch(n,this.response)}}],[{key:"toString",value:function(){return"N3Handler"}},{key:"register",value:function(e){e.mediatypes["text/n3"]={q:"1.0"},e.mediatypes["text/turtle"]={q:1}}}]),n}(be);Ce.pattern=new RegExp("(application|text)/(x-)?(rdf\\+)?(n3|turtle)");var _e={RDFXMLHandler:ye,XHTMLHandler:we,XMLHandler:xe,HTMLHandler:Ee,TextHandler:Ae,N3Handler:Ce};function Se(e){return!!e.match(/\s*<\?xml\s+version\s*=[^<>]+\?>/)}var ke=function(){function e(t){var n=this,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(o()(this,e),y()(this,"store",void 0),y()(this,"timeout",void 0),y()(this,"_fetch",void 0),y()(this,"mediatypes",void 0),y()(this,"appNode",void 0),y()(this,"requested",void 0),y()(this,"timeouts",void 0),y()(this,"redirectedTo",void 0),y()(this,"fetchQueue",void 0),y()(this,"fetchCallbacks",void 0),y()(this,"nonexistent",void 0),y()(this,"lookedUp",void 0),y()(this,"handlers",void 0),y()(this,"ns",void 0),y()(this,"fireCallbacks",void 0),this.store=t||new re,this.ns=ve(this.store.rdfFactory),this.timeout=r.timeout||3e4,this._fetch=r.fetch||fe,!this._fetch)throw new Error("No _fetch function availble for Fetcher");this.appNode=this.store.rdfFactory.blankNode(),this.store.fetcher=this,this.requested={},this.timeouts={},this.redirectedTo={},this.fetchQueue={},this.fetchCallbacks={},this.nonexistent={},this.lookedUp={},this.handlers=[],this.mediatypes={"image/*":{q:.9},"*/*":{q:.1}},V.callbackify(this,["request","fail","refresh","retract","done"]),Object.keys(r.handlers||_e).map((function(e){return n.addHandler(_e[e])}))}var t;return s()(e,[{key:"load",value:function(e){var t=this,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(n=Object.assign({},n),e instanceof Array)return Promise.all(e.map((function(e){return t.load(e,Object.assign({},n))})));var r=e,i=Object(de.a)(r);i=i.split("#")[0],n=this.initFetchOptions(i,n);var a=this.initFetchOptions(i,n);return this.pendingFetchPromise(i,a.baseURI,a)}},{key:"pendingFetchPromise",value:function(e,t,n){var r,i=this;return!n.force&&this.fetchQueue[t]?r=this.fetchQueue[t]:(r=Promise.race([this.setRequestTimeout(e,n),this.fetchUri(e,n)]),this.fetchQueue[t]=r,this.cleanupFetchRequest(t,null,this.timeout)),r.then((function(t){return e in i.timeouts&&(i.timeouts[e].forEach(clearTimeout),delete i.timeouts[e]),t}))}},{key:"cleanupFetchRequest",value:function(e,t,n){var r=this;void 0!==t&&console.warn("_options is deprecated"),this.timeouts[e]=(this.timeouts[e]||[]).concat(setTimeout((function(){r.isPending(e)||delete r.fetchQueue[e]}),n))}},{key:"initFetchOptions",value:function(t,n){var r=this.store;!n.method||"GET"===n.method.toUpperCase()||(n.force=!0),n.resource=r.rdfFactory.namedNode(t),n.baseURI=n.baseURI||t,n.original=r.rdfFactory.namedNode(n.baseURI),n.req=r.bnode(),n.headers=n.headers||new Headers,n.contentType&&(n.headers["content-type"]=n.contentType),n.force&&(n.cache="no-cache");var i=this.acceptString();n.headers.accept=i;var a=e.offlineOverride(t);n.requestedURI=a,e.setCredentials(a,n);var l=e.proxyIfNecessary(a);return a!==l&&(n.proxyUsed=!0),n.actualProxyURI=l,n}},{key:"fetchUri",value:function(t,n){var r=this;if(!t)return Promise.reject(new Error("Cannot fetch an empty uri"));if(e.unsupportedProtocol(t))return this.failFetch(n,"fetcher: Unsupported protocol","unsupported_protocol");var i=this.getState(t);if(n.force)delete this.nonexistent[t];else{if("fetched"===i)return Promise.resolve(this.doneFetch(n,{status:200,ok:!0,statusText:"Already loaded into quadstore."}));if("failed"===i&&404===this.requested[t]){var a="Previously failed: "+this.requested[t],l={url:t,status:this.requested[t],statusText:a,responseText:a,headers:new Headers,ok:!1,body:null,bodyUsed:!1,size:0,timeout:0};return this.failFetch(n,a,this.requested[t],l)}}this.fireCallbacks("request",[t]),this.requested[t]=!0,n.noMeta||this.saveRequestMetadata(t,n);var o=n.actualProxyURI;return this._fetch(o,n).then((function(e){return r.handleResponse(e,t,n)}),(function(e){var i={url:o,status:999,statusText:(e.name||"network failure")+": "+(e.errno||e.code||e.type),responseText:e.message,headers:new Headers,ok:!1,body:null,bodyUsed:!1,size:0,timeout:0};return console.log("Fetcher: <"+o+"> Non-HTTP fetch exception: "+e),r.handleError(i,t,n)}))}},{key:"nowOrWhenFetched",value:function(e,t,n){var r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{},i=Object(de.a)(e);"function"==typeof t?n=t:void 0===t||(Object(I.e)(t)?r.referringTerm=t:r=t),this.load(i,r).then((function(e){if(n)if(e)if(e.ok)n(!0,"OK",e);else{var t="HTTP error: Status "+e.status+" ("+e.statusText+")";e.responseText&&(t+=" "+e.responseText),console.log(t+" fetching "+i),n(!1,t,e)}else{var r="@@ nowOrWhenFetched: no response object!";console.log(r),n(!1,r)}}),(function(e){var t=e.message||e.statusText;t="Failed to load <"+i+"> "+t,console.log(t),e.response&&e.response.status&&(t+=" status: "+e.response.status),n(!1,t,e.response)}))}},{key:"addStatus",value:function(e,t){var n=new Date;t="["+n.getHours()+":"+n.getMinutes()+":"+n.getSeconds()+"."+n.getMilliseconds()+"] "+t;var r=this.store,i=r.the(e,this.ns.link("status"));Object(I.b)(i)?i.append(r.rdfFactory.literal(t)):N.a.warn("web.js: No list to add to: "+i+","+t)}},{key:"failFetch",value:function(e,t,n,r){this.addStatus(e.req,t),e.noMeta||this.store.add(e.original,this.ns.link("error"),this.store.rdfFactory.literal(t));var i=(e.method||"GET").toUpperCase();("GET"===i||"HEA