@matdata/yasr 5.20.2 → 5.20.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/build/yasr.min.js CHANGED
@@ -40,11 +40,11 @@ b`.split(/\n/).length!=3?function(e){for(var t=0,o=[],i=e.length;t<=i;){var s=e.
40
40
  `+he),Le&&bs([oe,x,ee],Rt=>{he=Oo(he,Rt," ")}),te&&Et?te.createHTML(he):he},n.setConfig=function(){let xe=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};Yt(xe),Be=!0},n.clearConfig=function(){pt=null,Be=!1},n.isValidAttribute=function(xe,N,K){pt||Yt({});let be=rt(xe),Ye=rt(N);return ur(be,Ye,K)},n.addHook=function(xe,N){typeof N=="function"&&Go(k[xe],N)},n.removeHook=function(xe,N){if(N!==void 0){let K=tC(k[xe],N);return K===-1?void 0:rC(k[xe],K,1)[0]}return yp(k[xe])},n.removeHooks=function(xe){k[xe]=[]},n.removeAllHooks=function(){k=Ap()},n}var Vo=Sp();var Or=Ar(ag()),ri=class{constructor(n){this.namespace=n}set(n,a,l,c){if(Or.default.enabled&&(this.removeExpiredKeys(),n&&a!==void 0)){a.documentElement&&(a=new XMLSerializer().serializeToString(a.documentElement));try{Or.default.set(n,{namespace:this.namespace,val:a,exp:l,time:new Date().getTime()/1e3})}catch(p){if(p instanceof Error){let g=p;if(g.quotaExceeded=IA(p),g.quotaExceeded&&c)c(p);else throw g}throw p}}}remove(n){Or.default.enabled&&n&&Or.default.remove(n)}removeExpiredKeys(){Or.default.enabled&&Or.default.each((n,a)=>{n&&n.exp&&new Date().getTime()/1e3-n.time>n.exp&&this.remove(a)})}removeAll(){Or.default.enabled}removeNamespace(){Or.default.each((n,a)=>{n.namespace&&n.namespace===this.namespace&&this.remove(a)})}get(n){if(Or.default.enabled&&n)if(this.removeExpiredKeys(),n){var a=Or.default.get(n);return a?a.val:void 0}else return}};function IA(r){var n=!1;if(r)if(r.code)switch(r.code){case 22:n=!0;break;case 1014:r.name==="NS_ERROR_DOM_QUOTA_REACHED"&&(n=!0);break}else r.number===-2147024882&&(n=!0);return n}var{sanitize:Ck}=Vo;function Xo(r,n){if(r)return r.classList?r.classList.contains(n):!!r.className.match(new RegExp("(\\s|^)"+n+"(\\s|$)"))}function Qe(r,...n){if(r)for(let a of n)r.classList?r.classList.add(a):Xo(r,a)||(r.className+=" "+a)}function hn(r,n){if(r){if(r.classList)r.classList.remove(n);else if(Xo(r,n)){var a=new RegExp("(\\s|^)"+n+"(\\s|$)");r.className=r.className.replace(a," ")}}}function au(r,n){if(typeof r=="string"){let a=JSON.parse(r);if(n&&a.results)for(let l in a.results.bindings)a.results.bindings[l]=n(a.results.bindings[l]);return a}if(typeof r=="object"&&r.constructor==={}.constructor){if(n&&r.results)for(let a in r.results.bindings)r.results.bindings[a]=n(r.results.bindings[a]);return r}throw new Error("Could not parse json")}var Sg=Ar(_g());var jo="http://www.w3.org/1999/02/22-rdf-syntax-ns#",zo="http://www.w3.org/2001/XMLSchema#",Es="http://www.w3.org/2000/10/swap/",gr={xsd:{decimal:`${zo}decimal`,boolean:`${zo}boolean`,double:`${zo}double`,integer:`${zo}integer`,string:`${zo}string`},rdf:{type:`${jo}type`,nil:`${jo}nil`,first:`${jo}first`,rest:`${jo}rest`,langString:`${jo}langString`},owl:{sameAs:"http://www.w3.org/2002/07/owl#sameAs"},r:{forSome:`${Es}reify#forSome`,forAll:`${Es}reify#forAll`},log:{implies:`${Es}log#implies`,isImpliedBy:`${Es}log#isImpliedBy`}};var{xsd:Cs}=gr,tR=/\\u([a-fA-F0-9]{4})|\\U([a-fA-F0-9]{8})|\\([^])/g,Ng={"\\":"\\","'":"'",'"':'"',n:`
41
41
  `,r:"\r",t:" ",f:"\f",b:"\b",_:"_","~":"~",".":".","-":"-","!":"!",$:"$","&":"&","(":"(",")":")","*":"*","+":"+",",":",",";":";","=":"=","/":"/","?":"?","#":"#","@":"@","%":"%"},rR=/[\x00-\x20<>\\"\{\}\|\^\`]/,nR={_iri:!0,_unescapedIri:!0,_simpleQuotedString:!0,_langcode:!0,_blank:!0,_newline:!0,_comment:!0,_whitespace:!0,_endOfFile:!0},iR=/$0^/,qo=class{constructor(n){if(this._iri=/^<((?:[^ <>{}\\]|\\[uU])+)>[ \t]*/,this._unescapedIri=/^<([^\x00-\x20<>\\"\{\}\|\^\`]*)>[ \t]*/,this._simpleQuotedString=/^"([^"\\\r\n]*)"(?=[^"])/,this._simpleApostropheString=/^'([^'\\\r\n]*)'(?=[^'])/,this._langcode=/^@([a-z]+(?:-[a-z0-9]+)*)(?=[^a-z0-9\-])/i,this._prefix=/^((?:[A-Za-z\xc0-\xd6\xd8-\xf6\xf8-\u02ff\u0370-\u037d\u037f-\u1fff\u200c\u200d\u2070-\u218f\u2c00-\u2fef\u3001-\ud7ff\uf900-\ufdcf\ufdf0-\ufffd]|[\ud800-\udb7f][\udc00-\udfff])(?:\.?[\-0-9A-Z_a-z\xb7\xc0-\xd6\xd8-\xf6\xf8-\u037d\u037f-\u1fff\u200c\u200d\u203f\u2040\u2070-\u218f\u2c00-\u2fef\u3001-\ud7ff\uf900-\ufdcf\ufdf0-\ufffd]|[\ud800-\udb7f][\udc00-\udfff])*)?:(?=[#\s<])/,this._prefixed=/^((?:[A-Za-z\xc0-\xd6\xd8-\xf6\xf8-\u02ff\u0370-\u037d\u037f-\u1fff\u200c\u200d\u2070-\u218f\u2c00-\u2fef\u3001-\ud7ff\uf900-\ufdcf\ufdf0-\ufffd]|[\ud800-\udb7f][\udc00-\udfff])(?:\.?[\-0-9A-Z_a-z\xb7\xc0-\xd6\xd8-\xf6\xf8-\u037d\u037f-\u1fff\u200c\u200d\u203f\u2040\u2070-\u218f\u2c00-\u2fef\u3001-\ud7ff\uf900-\ufdcf\ufdf0-\ufffd]|[\ud800-\udb7f][\udc00-\udfff])*)?:((?:(?:[0-:A-Z_a-z\xc0-\xd6\xd8-\xf6\xf8-\u02ff\u0370-\u037d\u037f-\u1fff\u200c\u200d\u2070-\u218f\u2c00-\u2fef\u3001-\ud7ff\uf900-\ufdcf\ufdf0-\ufffd]|[\ud800-\udb7f][\udc00-\udfff]|%[0-9a-fA-F]{2}|\\[!#-\/;=?\-@_~])(?:(?:[\.\-0-:A-Z_a-z\xb7\xc0-\xd6\xd8-\xf6\xf8-\u037d\u037f-\u1fff\u200c\u200d\u203f\u2040\u2070-\u218f\u2c00-\u2fef\u3001-\ud7ff\uf900-\ufdcf\ufdf0-\ufffd]|[\ud800-\udb7f][\udc00-\udfff]|%[0-9a-fA-F]{2}|\\[!#-\/;=?\-@_~])*(?:[\-0-:A-Z_a-z\xb7\xc0-\xd6\xd8-\xf6\xf8-\u037d\u037f-\u1fff\u200c\u200d\u203f\u2040\u2070-\u218f\u2c00-\u2fef\u3001-\ud7ff\uf900-\ufdcf\ufdf0-\ufffd]|[\ud800-\udb7f][\udc00-\udfff]|%[0-9a-fA-F]{2}|\\[!#-\/;=?\-@_~]))?)?)(?:[ \t]+|(?=\.?[,;!\^\s#()\[\]\{\}"'<>]))/,this._variable=/^\?(?:(?:[A-Z_a-z\xc0-\xd6\xd8-\xf6\xf8-\u02ff\u0370-\u037d\u037f-\u1fff\u200c\u200d\u2070-\u218f\u2c00-\u2fef\u3001-\ud7ff\uf900-\ufdcf\ufdf0-\ufffd]|[\ud800-\udb7f][\udc00-\udfff])(?:[\-0-:A-Z_a-z\xb7\xc0-\xd6\xd8-\xf6\xf8-\u037d\u037f-\u1fff\u200c\u200d\u203f\u2040\u2070-\u218f\u2c00-\u2fef\u3001-\ud7ff\uf900-\ufdcf\ufdf0-\ufffd]|[\ud800-\udb7f][\udc00-\udfff])*)(?=[.,;!\^\s#()\[\]\{\}"'<>])/,this._blank=/^_:((?:[0-9A-Z_a-z\xc0-\xd6\xd8-\xf6\xf8-\u02ff\u0370-\u037d\u037f-\u1fff\u200c\u200d\u2070-\u218f\u2c00-\u2fef\u3001-\ud7ff\uf900-\ufdcf\ufdf0-\ufffd]|[\ud800-\udb7f][\udc00-\udfff])(?:\.?[\-0-9A-Z_a-z\xb7\xc0-\xd6\xd8-\xf6\xf8-\u037d\u037f-\u1fff\u200c\u200d\u203f\u2040\u2070-\u218f\u2c00-\u2fef\u3001-\ud7ff\uf900-\ufdcf\ufdf0-\ufffd]|[\ud800-\udb7f][\udc00-\udfff])*)(?:[ \t]+|(?=\.?[,;:\s#()\[\]\{\}"'<>]))/,this._number=/^[\-+]?(?:(\d+\.\d*|\.?\d+)[eE][\-+]?|\d*(\.)?)\d+(?=\.?[,;:\s#()\[\]\{\}"'<>])/,this._boolean=/^(?:true|false)(?=[.,;\s#()\[\]\{\}"'<>])/,this._keyword=/^@[a-z]+(?=[\s#<:])/i,this._sparqlKeyword=/^(?:PREFIX|BASE|GRAPH)(?=[\s#<])/i,this._shortPredicates=/^a(?=[\s#()\[\]\{\}"'<>])/,this._newline=/^[ \t]*(?:#[^\n\r]*)?(?:\r\n|\n|\r)[ \t]*/,this._comment=/#([^\n\r]*)/,this._whitespace=/^[ \t]+/,this._endOfFile=/^(?:#[^\n\r]*)?$/,n=n||{},this._isImpliedBy=n.isImpliedBy,this._lineMode=!!n.lineMode){this._n3Mode=!1;for(let a in this)!(a in nR)&&this[a]instanceof RegExp&&(this[a]=iR)}else this._n3Mode=n.n3!==!1;this.comments=!!n.comments,this._literalClosingPos=0}_tokenizeToEnd(n,a){let l=this._input,c=l.length;for(;;){let y,T;for(;y=this._newline.exec(l);)this.comments&&(T=this._comment.exec(y[0]))&&p("comment",T[1],"",this._line,y[0].length),l=l.substr(y[0].length,l.length),c=l.length,this._line++;if(!y&&(y=this._whitespace.exec(l))&&(l=l.substr(y[0].length,l.length)),this._endOfFile.test(l))return a&&(this.comments&&(T=this._comment.exec(l))&&p("comment",T[1],"",this._line,l.length),l=null,p("eof","","",this._line,0)),this._input=l;let U=this._line,A=l[0],F="",M="",X="",S=null,Z=0,_=!1;switch(A){case"^":if(l.length<3)break;if(l[1]==="^"){if(this._previousMarker="^^",l=l.substr(2),l[0]!=="<"){_=!0;break}}else{this._n3Mode&&(Z=1,F="^");break}case"<":if(S=this._unescapedIri.exec(l))F="IRI",M=S[1];else if(S=this._iri.exec(l)){if(M=this._unescape(S[1]),M===null||rR.test(M))return g(this);F="IRI"}else l.length>1&&l[1]==="<"?(F="<<",Z=2):this._n3Mode&&l.length>1&&l[1]==="="&&(Z=2,this._isImpliedBy?(F="abbreviation",M="<"):(F="inverse",M=">"));break;case">":l.length>1&&l[1]===">"&&(F=">>",Z=2);break;case"_":((S=this._blank.exec(l))||a&&(S=this._blank.exec(`${l} `)))&&(F="blank",X="_",M=S[1]);break;case'"':if(S=this._simpleQuotedString.exec(l))M=S[1];else if({value:M,matchLength:Z}=this._parseLiteral(l),M===null)return g(this);(S!==null||Z!==0)&&(F="literal",this._literalClosingPos=0);break;case"'":if(!this._lineMode){if(S=this._simpleApostropheString.exec(l))M=S[1];else if({value:M,matchLength:Z}=this._parseLiteral(l),M===null)return g(this);(S!==null||Z!==0)&&(F="literal",this._literalClosingPos=0)}break;case"?":this._n3Mode&&(S=this._variable.exec(l))&&(F="var",M=S[0]);break;case"@":this._previousMarker==="literal"&&(S=this._langcode.exec(l))?(F="langcode",M=S[1]):(S=this._keyword.exec(l))&&(F=S[0]);break;case".":if(l.length===1?a:l[1]<"0"||l[1]>"9"){F=".",Z=1;break}case"0":case"1":case"2":case"3":case"4":case"5":case"6":case"7":case"8":case"9":case"+":case"-":(S=this._number.exec(l)||a&&(S=this._number.exec(`${l} `)))&&(F="literal",M=S[0],X=typeof S[1]=="string"?Cs.double:typeof S[2]=="string"?Cs.decimal:Cs.integer);break;case"B":case"b":case"p":case"P":case"G":case"g":(S=this._sparqlKeyword.exec(l))?F=S[0].toUpperCase():_=!0;break;case"f":case"t":(S=this._boolean.exec(l))?(F="literal",M=S[0],X=Cs.boolean):_=!0;break;case"a":(S=this._shortPredicates.exec(l))?(F="abbreviation",M="a"):_=!0;break;case"=":this._n3Mode&&l.length>1&&(F="abbreviation",l[1]!==">"?(Z=1,M="="):(Z=2,M=">"));break;case"!":if(!this._n3Mode)break;case",":case";":case"[":case"]":case"(":case")":case"}":this._lineMode||(Z=1,F=A);break;case"{":!this._lineMode&&l.length>=2&&(l[1]==="|"?(F="{|",Z=2):(F=A,Z=1));break;case"|":l.length>=2&&l[1]==="}"&&(F="|}",Z=2);break;default:_=!0}if(_&&((this._previousMarker==="@prefix"||this._previousMarker==="PREFIX")&&(S=this._prefix.exec(l))?(F="prefix",M=S[1]||""):((S=this._prefixed.exec(l))||a&&(S=this._prefixed.exec(`${l} `)))&&(F="prefixed",X=S[1]||"",M=this._unescape(S[2]))),this._previousMarker==="^^")switch(F){case"prefixed":F="type";break;case"IRI":F="typeIRI";break;default:F=""}if(!F)return a||!/^'''|^"""/.test(l)&&/\n|\r/.test(l)?g(this):this._input=l;let G=Z||S[0].length,J=p(F,M,X,U,G);this.previousToken=J,this._previousMarker=F,l=l.substr(G,l.length)}function p(y,T,U,A,F){let M=l?c-l.length:c,X=M+F,S={type:y,value:T,prefix:U,line:A,start:M,end:X};return n(null,S),S}function g(y){n(y._syntaxError(/^\S*/.exec(l)[0]))}}_unescape(n){let a=!1,l=n.replace(tR,(c,p,g,y)=>{if(typeof p=="string")return String.fromCharCode(Number.parseInt(p,16));if(typeof g=="string"){let T=Number.parseInt(g,16);return T<=65535?String.fromCharCode(Number.parseInt(g,16)):String.fromCharCode(55296+((T-=65536)>>10),56320+(T&1023))}return y in Ng?Ng[y]:(a=!0,"")});return a?null:l}_parseLiteral(n){if(n.length>=3){let a=n.match(/^(?:"""|"|'''|'|)/)[0],l=a.length,c=Math.max(this._literalClosingPos,l);for(;(c=n.indexOf(a,c))>0;){let p=0;for(;n[c-p-1]==="\\";)p++;if(p%2===0){let g=n.substring(l,c),y=g.split(/\r\n|\r|\n/).length-1,T=c+l;if(l===1&&y!==0||l===3&&this._lineMode)break;return this._line+=y,{value:this._unescape(g),matchLength:T}}c++}this._literalClosingPos=n.length-l+1}return{value:"",matchLength:0}}_syntaxError(n){this._input=null;let a=new Error(`Unexpected "${n}" on line ${this._line}.`);return a.context={token:void 0,line:this._line,previousToken:this.previousToken},a}_readStartingBom(n){return n.startsWith("\uFEFF")?n.substr(1):n}tokenize(n,a){if(this._line=1,typeof n=="string")if(this._input=this._readStartingBom(n),typeof a=="function")queueMicrotask(()=>this._tokenizeToEnd(a,!0));else{let l=[],c;if(this._tokenizeToEnd((p,g)=>p?c=p:l.push(g),!0),c)throw c;return l}else this._pendingBuffer=null,typeof n.setEncoding=="function"&&n.setEncoding("utf8"),n.on("data",l=>{this._input!==null&&l.length!==0&&(this._pendingBuffer&&(l=Sg.Buffer.concat([this._pendingBuffer,l]),this._pendingBuffer=null),l[l.length-1]&128?this._pendingBuffer=l:(typeof this._input>"u"?this._input=this._readStartingBom(typeof l=="string"?l:l.toString()):this._input+=l,this._tokenizeToEnd(a,!1)))}),n.on("end",()=>{typeof this._input=="string"&&this._tokenizeToEnd(a,!0)}),n.on("error",a)}};var{rdf:oR,xsd:eo}=gr,ea,aR=0;var sR={namedNode:Lg,blankNode:Fg,variable:Ug,literal:Bg,defaultGraph:lR,quad:xu,triple:xu,fromTerm:Ko,fromQuad:kg},wg=sR,gn=class r{constructor(n){this.id=n}get value(){return this.id}equals(n){return n instanceof r?this.id===n.id:!!n&&this.termType===n.termType&&this.value===n.value}hashCode(){return 0}toJSON(){return{termType:this.termType,value:this.value}}},As=class extends gn{get termType(){return"NamedNode"}},$o=class r extends gn{get termType(){return"Literal"}get value(){return this.id.substring(1,this.id.lastIndexOf('"'))}get language(){let n=this.id,a=n.lastIndexOf('"')+1;return a<n.length&&n[a++]==="@"?n.substr(a).toLowerCase():""}get datatype(){return new As(this.datatypeString)}get datatypeString(){let n=this.id,a=n.lastIndexOf('"')+1,l=a<n.length?n[a]:"";return l==="^"?n.substr(a+2):l!=="@"?eo.string:oR.langString}equals(n){return n instanceof r?this.id===n.id:!!n&&!!n.datatype&&this.termType===n.termType&&this.value===n.value&&this.language===n.language&&this.datatype.value===n.datatype.value}toJSON(){return{termType:this.termType,value:this.value,language:this.language,datatype:{termType:"NamedNode",value:this.datatypeString}}}},bu=class extends gn{constructor(n){super(`_:${n}`)}get termType(){return"BlankNode"}get value(){return this.id.substr(2)}},vu=class extends gn{constructor(n){super(`?${n}`)}get termType(){return"Variable"}get value(){return this.id.substr(1)}},yu=class extends gn{constructor(){return super(""),ea||this}get termType(){return"DefaultGraph"}equals(n){return this===n||!!n&&this.termType===n.termType}};ea=new yu;var Rs=class extends gn{constructor(n,a,l,c){super(""),this._subject=n,this._predicate=a,this._object=l,this._graph=c||ea}get termType(){return"Quad"}get subject(){return this._subject}get predicate(){return this._predicate}get object(){return this._object}get graph(){return this._graph}toJSON(){return{termType:this.termType,subject:this._subject.toJSON(),predicate:this._predicate.toJSON(),object:this._object.toJSON(),graph:this._graph.toJSON()}}equals(n){return!!n&&this._subject.equals(n.subject)&&this._predicate.equals(n.predicate)&&this._object.equals(n.object)&&this._graph.equals(n.graph)}};function Lg(r){return new As(r)}function Fg(r){return new bu(r||`n3-${aR++}`)}function Bg(r,n){if(typeof n=="string")return new $o(`"${r}"@${n.toLowerCase()}`);let a=n?n.value:"";return a===""&&(typeof r=="boolean"?a=eo.boolean:typeof r=="number"&&(Number.isFinite(r)?a=Number.isInteger(r)?eo.integer:eo.double:(a=eo.double,Number.isNaN(r)||(r=r>0?"INF":"-INF")))),a===""||a===eo.string?new $o(`"${r}"`):new $o(`"${r}"^^${a}`)}function Ug(r){return new vu(r)}function lR(){return ea}function xu(r,n,a,l){return new Rs(r,n,a,l)}function Ko(r){if(r instanceof gn)return r;switch(r.termType){case"NamedNode":return Lg(r.value);case"BlankNode":return Fg(r.value);case"Variable":return Ug(r.value);case"DefaultGraph":return ea;case"Literal":return Bg(r.value,r.language||r.datatype);case"Quad":return kg(r);default:throw new Error(`Unexpected termType: ${r.termType}`)}}function kg(r){if(r instanceof Rs)return r;if(r.termType!=="Quad")throw new Error(`Unexpected termType: ${r.termType}`);return xu(Ko(r.subject),Ko(r.predicate),Ko(r.object),Ko(r.graph))}var Mg=0,oi=class{constructor(n){this._contextStack=[],this._graph=null,n=n||{},this._setBase(n.baseIRI),n.factory&&Gg(this,n.factory);let a=typeof n.format=="string"?n.format.match(/\w*$/)[0].toLowerCase():"",l=/turtle/.test(a),c=/trig/.test(a),p=/triple/.test(a),g=/quad/.test(a),y=this._n3Mode=/n3/.test(a),T=p||g;(this._supportsNamedGraphs=!(l||y))||(this._readPredicateOrNamedGraph=this._readPredicate),this._supportsQuads=!(l||c||p||y),this._isImpliedBy=n.isImpliedBy,this._supportsRDFStar=a===""||/star|\*$/.test(a),T&&(this._resolveRelativeIRI=U=>null),this._blankNodePrefix=typeof n.blankNodePrefix!="string"?"":n.blankNodePrefix.replace(/^(?!_:)/,"_:"),this._lexer=n.lexer||new qo({lineMode:T,n3:y,isImpliedBy:this._isImpliedBy}),this._explicitQuantifiers=!!n.explicitQuantifiers}static _resetBlankNodePrefix(){Mg=0}_setBase(n){if(!n)this._base="",this._basePath="";else{let a=n.indexOf("#");a>=0&&(n=n.substr(0,a)),this._base=n,this._basePath=n.indexOf("/")<0?n:n.replace(/[^\/?]*(?:\?.*)?$/,""),n=n.match(/^(?:([a-z][a-z0-9+.-]*:))?(?:\/\/[^\/]*)?/i),this._baseRoot=n[0],this._baseScheme=n[1]}}_saveContext(n,a,l,c,p){let g=this._n3Mode;this._contextStack.push({type:n,subject:l,predicate:c,object:p,graph:a,inverse:g?this._inversePredicate:!1,blankPrefix:g?this._prefixes._:"",quantified:g?this._quantified:null}),g&&(this._inversePredicate=!1,this._prefixes._=this._graph?`${this._graph.value}.`:".",this._quantified=Object.create(this._quantified))}_restoreContext(n,a){let l=this._contextStack.pop();if(!l||l.type!==n)return this._error(`Unexpected ${a.type}`,a);this._subject=l.subject,this._predicate=l.predicate,this._object=l.object,this._graph=l.graph,this._n3Mode&&(this._inversePredicate=l.inverse,this._prefixes._=l.blankPrefix,this._quantified=l.quantified)}_readInTopContext(n){switch(n.type){case"eof":return this._graph!==null?this._error("Unclosed graph",n):(delete this._prefixes._,this._callback(null,null,this._prefixes));case"PREFIX":this._sparqlStyle=!0;case"@prefix":return this._readPrefix;case"BASE":this._sparqlStyle=!0;case"@base":return this._readBaseIRI;case"{":if(this._supportsNamedGraphs)return this._graph="",this._subject=null,this._readSubject;case"GRAPH":if(this._supportsNamedGraphs)return this._readNamedGraphLabel;default:return this._readSubject(n)}}_readEntity(n,a){let l;switch(n.type){case"IRI":case"typeIRI":let c=this._resolveIRI(n.value);if(c===null)return this._error("Invalid IRI",n);l=this._factory.namedNode(c);break;case"type":case"prefixed":let p=this._prefixes[n.prefix];if(p===void 0)return this._error(`Undefined prefix "${n.prefix}:"`,n);l=this._factory.namedNode(p+n.value);break;case"blank":l=this._factory.blankNode(this._prefixes[n.prefix]+n.value);break;case"var":l=this._factory.variable(n.value.substr(1));break;default:return this._error(`Expected entity but got ${n.type}`,n)}return!a&&this._n3Mode&&l.id in this._quantified&&(l=this._quantified[l.id]),l}_readSubject(n){switch(this._predicate=null,n.type){case"[":return this._saveContext("blank",this._graph,this._subject=this._factory.blankNode(),null,null),this._readBlankNodeHead;case"(":return this._saveContext("list",this._graph,this.RDF_NIL,null,null),this._subject=null,this._readListItem;case"{":return this._n3Mode?(this._saveContext("formula",this._graph,this._graph=this._factory.blankNode(),null,null),this._readSubject):this._error("Unexpected graph",n);case"}":return this._readPunctuation(n);case"@forSome":return this._n3Mode?(this._subject=null,this._predicate=this.N3_FORSOME,this._quantifier="blankNode",this._readQuantifierList):this._error('Unexpected "@forSome"',n);case"@forAll":return this._n3Mode?(this._subject=null,this._predicate=this.N3_FORALL,this._quantifier="variable",this._readQuantifierList):this._error('Unexpected "@forAll"',n);case"literal":if(!this._n3Mode)return this._error("Unexpected literal",n);if(n.prefix.length===0)return this._literalValue=n.value,this._completeSubjectLiteral;this._subject=this._factory.literal(n.value,this._factory.namedNode(n.prefix));break;case"<<":return this._supportsRDFStar?(this._saveContext("<<",this._graph,null,null,null),this._graph=null,this._readSubject):this._error("Unexpected RDF-star syntax",n);default:if((this._subject=this._readEntity(n))===void 0)return;if(this._n3Mode)return this._getPathReader(this._readPredicateOrNamedGraph)}return this._readPredicateOrNamedGraph}_readPredicate(n){let a=n.type;switch(a){case"inverse":this._inversePredicate=!0;case"abbreviation":this._predicate=this.ABBREVIATIONS[n.value];break;case".":case"]":case"}":return this._predicate===null?this._error(`Unexpected ${a}`,n):(this._subject=null,a==="]"?this._readBlankNodeTail(n):this._readPunctuation(n));case";":return this._predicate!==null?this._readPredicate:this._error("Expected predicate but got ;",n);case"[":if(this._n3Mode)return this._saveContext("blank",this._graph,this._subject,this._subject=this._factory.blankNode(),null),this._readBlankNodeHead;case"blank":if(!this._n3Mode)return this._error("Disallowed blank node as predicate",n);default:if((this._predicate=this._readEntity(n))===void 0)return}return this._readObject}_readObject(n){switch(n.type){case"literal":if(n.prefix.length===0)return this._literalValue=n.value,this._readDataTypeOrLang;this._object=this._factory.literal(n.value,this._factory.namedNode(n.prefix));break;case"[":return this._saveContext("blank",this._graph,this._subject,this._predicate,this._subject=this._factory.blankNode()),this._readBlankNodeHead;case"(":return this._saveContext("list",this._graph,this._subject,this._predicate,this.RDF_NIL),this._subject=null,this._readListItem;case"{":return this._n3Mode?(this._saveContext("formula",this._graph,this._subject,this._predicate,this._graph=this._factory.blankNode()),this._readSubject):this._error("Unexpected graph",n);case"<<":return this._supportsRDFStar?(this._saveContext("<<",this._graph,this._subject,this._predicate,null),this._graph=null,this._readSubject):this._error("Unexpected RDF-star syntax",n);default:if((this._object=this._readEntity(n))===void 0)return;if(this._n3Mode)return this._getPathReader(this._getContextEndReader())}return this._getContextEndReader()}_readPredicateOrNamedGraph(n){return n.type==="{"?this._readGraph(n):this._readPredicate(n)}_readGraph(n){return n.type!=="{"?this._error(`Expected graph but got ${n.type}`,n):(this._graph=this._subject,this._subject=null,this._readSubject)}_readBlankNodeHead(n){return n.type==="]"?(this._subject=null,this._readBlankNodeTail(n)):(this._predicate=null,this._readPredicate(n))}_readBlankNodeTail(n){if(n.type!=="]")return this._readBlankNodePunctuation(n);this._subject!==null&&this._emit(this._subject,this._predicate,this._object,this._graph);let a=this._predicate===null;return this._restoreContext("blank",n),this._object!==null?this._getContextEndReader():this._predicate!==null?this._readObject:a?this._readPredicateOrNamedGraph:this._readPredicateAfterBlank}_readPredicateAfterBlank(n){switch(n.type){case".":case"}":return this._subject=null,this._readPunctuation(n);default:return this._readPredicate(n)}}_readListItem(n){let a=null,l=null,c=this._readListItem,p=this._subject,g=this._contextStack,y=g[g.length-1];switch(n.type){case"[":this._saveContext("blank",this._graph,l=this._factory.blankNode(),this.RDF_FIRST,this._subject=a=this._factory.blankNode()),c=this._readBlankNodeHead;break;case"(":this._saveContext("list",this._graph,l=this._factory.blankNode(),this.RDF_FIRST,this.RDF_NIL),this._subject=null;break;case")":if(this._restoreContext("list",n),g.length!==0&&g[g.length-1].type==="list"&&this._emit(this._subject,this._predicate,this._object,this._graph),this._predicate===null){if(c=this._readPredicate,this._subject===this.RDF_NIL)return c}else if(c=this._getContextEndReader(),this._object===this.RDF_NIL)return c;l=this.RDF_NIL;break;case"literal":n.prefix.length===0?(this._literalValue=n.value,c=this._readListItemDataTypeOrLang):(a=this._factory.literal(n.value,this._factory.namedNode(n.prefix)),c=this._getContextEndReader());break;case"{":return this._n3Mode?(this._saveContext("formula",this._graph,this._subject,this._predicate,this._graph=this._factory.blankNode()),this._readSubject):this._error("Unexpected graph",n);default:if((a=this._readEntity(n))===void 0)return}if(l===null&&(this._subject=l=this._factory.blankNode()),p===null?y.predicate===null?y.subject=l:y.object=l:this._emit(p,this.RDF_REST,l,this._graph),a!==null){if(this._n3Mode&&(n.type==="IRI"||n.type==="prefixed"))return this._saveContext("item",this._graph,l,this.RDF_FIRST,a),this._subject=a,this._predicate=null,this._getPathReader(this._readListItem);this._emit(l,this.RDF_FIRST,a,this._graph)}return c}_readDataTypeOrLang(n){return this._completeObjectLiteral(n,!1)}_readListItemDataTypeOrLang(n){return this._completeObjectLiteral(n,!0)}_completeLiteral(n){let a=this._factory.literal(this._literalValue);switch(n.type){case"type":case"typeIRI":let l=this._readEntity(n);if(l===void 0)return;a=this._factory.literal(this._literalValue,l),n=null;break;case"langcode":a=this._factory.literal(this._literalValue,n.value),n=null;break}return{token:n,literal:a}}_completeSubjectLiteral(n){return this._subject=this._completeLiteral(n).literal,this._readPredicateOrNamedGraph}_completeObjectLiteral(n,a){let l=this._completeLiteral(n);if(l)return this._object=l.literal,a&&this._emit(this._subject,this.RDF_FIRST,this._object,this._graph),l.token===null?this._getContextEndReader():(this._readCallback=this._getContextEndReader(),this._readCallback(l.token))}_readFormulaTail(n){return n.type!=="}"?this._readPunctuation(n):(this._subject!==null&&this._emit(this._subject,this._predicate,this._object,this._graph),this._restoreContext("formula",n),this._object===null?this._readPredicate:this._getContextEndReader())}_readPunctuation(n){let a,l=this._graph,c=this._subject,p=this._inversePredicate;switch(n.type){case"}":if(this._graph===null)return this._error("Unexpected graph closing",n);if(this._n3Mode)return this._readFormulaTail(n);this._graph=null;case".":this._subject=null,a=this._contextStack.length?this._readSubject:this._readInTopContext,p&&(this._inversePredicate=!1);break;case";":a=this._readPredicate;break;case",":a=this._readObject;break;case"{|":if(!this._supportsRDFStar)return this._error("Unexpected RDF-star syntax",n);let g=this._predicate,y=this._object;this._subject=this._factory.quad(c,g,y,this.DEFAULTGRAPH),a=this._readPredicate;break;case"|}":if(this._subject.termType!=="Quad")return this._error("Unexpected asserted triple closing",n);this._subject=null,a=this._readPunctuation;break;default:if(this._supportsQuads&&this._graph===null&&(l=this._readEntity(n))!==void 0){a=this._readQuadPunctuation;break}return this._error(`Expected punctuation to follow "${this._object.id}"`,n)}if(c!==null){let g=this._predicate,y=this._object;p?this._emit(y,g,c,l):this._emit(c,g,y,l)}return a}_readBlankNodePunctuation(n){let a;switch(n.type){case";":a=this._readPredicate;break;case",":a=this._readObject;break;default:return this._error(`Expected punctuation to follow "${this._object.id}"`,n)}return this._emit(this._subject,this._predicate,this._object,this._graph),a}_readQuadPunctuation(n){return n.type!=="."?this._error("Expected dot to follow quad",n):this._readInTopContext}_readPrefix(n){return n.type!=="prefix"?this._error("Expected prefix to follow @prefix",n):(this._prefix=n.value,this._readPrefixIRI)}_readPrefixIRI(n){if(n.type!=="IRI")return this._error(`Expected IRI to follow prefix "${this._prefix}:"`,n);let a=this._readEntity(n);return this._prefixes[this._prefix]=a.value,this._prefixCallback(this._prefix,a),this._readDeclarationPunctuation}_readBaseIRI(n){let a=n.type==="IRI"&&this._resolveIRI(n.value);return a?(this._setBase(a),this._readDeclarationPunctuation):this._error("Expected valid IRI to follow base declaration",n)}_readNamedGraphLabel(n){switch(n.type){case"IRI":case"blank":case"prefixed":return this._readSubject(n),this._readGraph;case"[":return this._readNamedGraphBlankLabel;default:return this._error("Invalid graph label",n)}}_readNamedGraphBlankLabel(n){return n.type!=="]"?this._error("Invalid graph label",n):(this._subject=this._factory.blankNode(),this._readGraph)}_readDeclarationPunctuation(n){return this._sparqlStyle?(this._sparqlStyle=!1,this._readInTopContext(n)):n.type!=="."?this._error("Expected declaration to end with a dot",n):this._readInTopContext}_readQuantifierList(n){let a;switch(n.type){case"IRI":case"prefixed":if((a=this._readEntity(n,!0))!==void 0)break;default:return this._error(`Unexpected ${n.type}`,n)}return this._explicitQuantifiers?(this._subject===null?this._emit(this._graph||this.DEFAULTGRAPH,this._predicate,this._subject=this._factory.blankNode(),this.QUANTIFIERS_GRAPH):this._emit(this._subject,this.RDF_REST,this._subject=this._factory.blankNode(),this.QUANTIFIERS_GRAPH),this._emit(this._subject,this.RDF_FIRST,a,this.QUANTIFIERS_GRAPH)):this._quantified[a.id]=this._factory[this._quantifier](this._factory.blankNode().value),this._readQuantifierPunctuation}_readQuantifierPunctuation(n){return n.type===","?this._readQuantifierList:(this._explicitQuantifiers&&(this._emit(this._subject,this.RDF_REST,this.RDF_NIL,this.QUANTIFIERS_GRAPH),this._subject=null),this._readCallback=this._getContextEndReader(),this._readCallback(n))}_getPathReader(n){return this._afterPath=n,this._readPath}_readPath(n){switch(n.type){case"!":return this._readForwardPath;case"^":return this._readBackwardPath;default:let a=this._contextStack,l=a.length&&a[a.length-1];if(l&&l.type==="item"){let c=this._subject;this._restoreContext("item",n),this._emit(this._subject,this.RDF_FIRST,c,this._graph)}return this._afterPath(n)}}_readForwardPath(n){let a,l,c=this._factory.blankNode();if((l=this._readEntity(n))!==void 0)return this._predicate===null?(a=this._subject,this._subject=c):(a=this._object,this._object=c),this._emit(a,l,c,this._graph),this._readPath}_readBackwardPath(n){let a=this._factory.blankNode(),l,c;if((l=this._readEntity(n))!==void 0)return this._predicate===null?(c=this._subject,this._subject=a):(c=this._object,this._object=a),this._emit(a,l,c,this._graph),this._readPath}_readRDFStarTailOrGraph(n){return n.type!==">>"?this._supportsQuads&&this._graph===null&&(this._graph=this._readEntity(n))!==void 0?this._readRDFStarTail:this._error(`Expected >> to follow "${this._object.id}"`,n):this._readRDFStarTail(n)}_readRDFStarTail(n){if(n.type!==">>")return this._error(`Expected >> but got ${n.type}`,n);let a=this._factory.quad(this._subject,this._predicate,this._object,this._graph||this.DEFAULTGRAPH);return this._restoreContext("<<",n),this._subject===null?(this._subject=a,this._readPredicate):(this._object=a,this._getContextEndReader())}_getContextEndReader(){let n=this._contextStack;if(!n.length)return this._readPunctuation;switch(n[n.length-1].type){case"blank":return this._readBlankNodeTail;case"list":return this._readListItem;case"formula":return this._readFormulaTail;case"<<":return this._readRDFStarTailOrGraph}}_emit(n,a,l,c){this._callback(null,this._factory.quad(n,a,l,c||this.DEFAULTGRAPH))}_error(n,a){let l=new Error(`${n} on line ${a.line}.`);l.context={token:a,line:a.line,previousToken:this._lexer.previousToken},this._callback(l),this._callback=_s}_resolveIRI(n){return/^[a-z][a-z0-9+.-]*:/i.test(n)?n:this._resolveRelativeIRI(n)}_resolveRelativeIRI(n){if(!n.length)return this._base;switch(n[0]){case"#":return this._base+n;case"?":return this._base.replace(/(?:\?.*)?$/,n);case"/":return(n[1]==="/"?this._baseScheme:this._baseRoot)+this._removeDotSegments(n);default:return/^[^/:]*:/.test(n)?null:this._removeDotSegments(this._basePath+n)}}_removeDotSegments(n){if(!/(^|\/)\.\.?($|[/#?])/.test(n))return n;let a=n.length,l="",c=-1,p=-1,g=0,y="/";for(;c<a;){switch(y){case":":if(p<0&&n[++c]==="/"&&n[++c]==="/")for(;(p=c+1)<a&&n[p]!=="/";)c=p;break;case"?":case"#":c=a;break;case"/":if(n[c+1]===".")switch(y=n[++c+1],y){case"/":l+=n.substring(g,c-1),g=c+1;break;case void 0:case"?":case"#":return l+n.substring(g,c)+n.substr(c+1);case".":if(y=n[++c+1],y===void 0||y==="/"||y==="?"||y==="#"){if(l+=n.substring(g,c-2),(g=l.lastIndexOf("/"))>=p&&(l=l.substr(0,g)),y!=="/")return`${l}/${n.substr(c+1)}`;g=c+1}}}y=n[++c]}return l+n.substring(g)}parse(n,a,l){let c,p,g;if(a&&(a.onQuad||a.onPrefix||a.onComment)?(c=a.onQuad,p=a.onPrefix,g=a.onComment):(c=a,p=l),this._readCallback=this._readInTopContext,this._sparqlStyle=!1,this._prefixes=Object.create(null),this._prefixes._=this._blankNodePrefix?this._blankNodePrefix.substr(2):`b${Mg++}_`,this._prefixCallback=p||_s,this._inversePredicate=!1,this._quantified=Object.create(null),!c){let T=[],U;if(this._callback=(A,F)=>{A?U=A:F&&T.push(F)},this._lexer.tokenize(n).every(A=>this._readCallback=this._readCallback(A)),U)throw U;return T}let y=(T,U)=>{T!==null?(this._callback(T),this._callback=_s):this._readCallback&&(this._readCallback=this._readCallback(U))};g&&(this._lexer.comments=!0,y=(T,U)=>{T!==null?(this._callback(T),this._callback=_s):this._readCallback&&(U.type==="comment"?g(U.value):this._readCallback=this._readCallback(U))}),this._callback=c,this._lexer.tokenize(n,y)}};function _s(){}function Gg(r,n){r._factory=n,r.DEFAULTGRAPH=n.defaultGraph(),r.RDF_FIRST=n.namedNode(gr.rdf.first),r.RDF_REST=n.namedNode(gr.rdf.rest),r.RDF_NIL=n.namedNode(gr.rdf.nil),r.N3_FORALL=n.namedNode(gr.r.forAll),r.N3_FORSOME=n.namedNode(gr.r.forSome),r.ABBREVIATIONS={a:n.namedNode(gr.rdf.type),"=":n.namedNode(gr.owl.sameAs),">":n.namedNode(gr.log.implies),"<":n.namedNode(gr.log.isImpliedBy)},r.QUANTIFIERS_GRAPH=n.namedNode("urn:n3:quantifiers")}Gg(oi.prototype,wg);function Tu(r){if(r.termType==="NamedNode")return{value:r.value,type:"uri"};if(r.termType==="Literal"){let n={value:r.value,type:"literal"},a=r.language;a&&(n["xml:lang"]=a);let l=r.datatypeString;return l&&(n.datatype=l),n}return r.termType==="BlankNode"?{value:r.value,type:"bnode"}:{value:r.value,type:"uri"}}function Og(r){let n=Iu(r),a=["subject","predicate","object"],l=n.map(c=>({subject:Tu(c.subject),predicate:Tu(c.predicate),object:Tu(c.object)}));return{head:{vars:a},results:{bindings:l}}}function Iu(r){return new oi().parse(r||"")}function fR(r){let n={vars:[]};for(let a=0;a<r.childNodes.length;a++){let l=r.childNodes[a];if(l.nodeName=="variable"){let c=l.getAttribute("name");c&&n.vars.push(c)}}return n}var cR=["uri","literal","bnode","typed-literal"];function dR(r,n){let a={bindings:[]};for(let l=0;l<r.childNodes.length;l++){let c=r.childNodes[l],p={};for(let g=0;g<c.childNodes.length;g++){let y=c.childNodes[g];if(y.nodeName=="binding"){let T=y.getAttribute("name");if(T)for(let U=0;U<y.childNodes.length;U++){let A=y.childNodes[U];if(A.nodeName==="#text"||cR.indexOf(A.nodeName)<0)continue;let F={type:A.nodeName,value:Wl(A.innerHTML)},M=A.getAttribute("datatype");M&&(F.datatype=M),p[T]=F}}}ms(p)||a.bindings.push(n(p))}return a}function hR(r){return r.innerHTML==="true"}function Eu(r,n){if(typeof r!="string")return;let l=new DOMParser().parseFromString(r,"text/xml");if(!l.childNodes.length)return;let c=l.childNodes[0],p={};for(let g=0;g<c.childNodes.length;g++){let y=c.childNodes[g];y.nodeName=="head"&&(p.head=fR(y)),y.nodeName=="results"&&(p.results=dR(y,n)),y.nodeName=="boolean"&&(p.boolean=hR(y))}return p}var Dg=Ar(Wg());function Zg(r){let n=Dg.parse(r,{header:!0,skipEmptyLines:!0});if(n.meta.fields===void 0)throw new Error("Could not parse CSV, no headers found!");let a=n.meta.fields,c=n.data.map(g=>{let y={};for(let T in g)y[T]={value:g[T],type:"literal"};return y});return{head:{vars:a},results:{bindings:c}}}function Vg(r){let n=r.split(`
42
42
  `);n.pop();let[a,...l]=n,c=a.split(" ").map(y=>y.substring(1)),p=l.map(y=>{let T={};for(let[U,A]of y.split(" ").entries()){let F=c[U];if(A[0]==="<")T[F]={value:A.substring(1,A.length-1),type:"uri"};else if(A[0]==='"'){let M=A.lastIndexOf('"'),X=A.substring(1,M);if(M===A.length-1)T[F]={value:X,type:"literal"};else if(M<A.lastIndexOf("@")){let S=A.substring(A.lastIndexOf("@")+1);T[F]={value:X,type:"literal","xml:lang":S}}else if(M<A.lastIndexOf("^^")){let S=A.substring(A.lastIndexOf("^^")+2);T[F]={value:X,type:"typed-literal",datatype:S}}}}return T});return{head:{vars:c},results:{bindings:p}}}function to(r){return r==null?"":`${r}`}function Ns(r={}){let{separator:n,decimals:a}=r;return n?a?l=>l.toFixed(a).replace(".",n):l=>`${l}`.replace(".",n):a?l=>l.toFixed(a):l=>`${l}`}function mn(r={}){let n=typeof r.quote=="string"?r.quote:'"',a=typeof r.escapedQuote=="string"?r.escapedQuote:`${n}${n}`;if(!n||n===a)return c=>c;let l=new RegExp(n,"g");return c=>(c.includes(n)&&(c=c.replace(l,a)),`${n}${c}${n}`)}var pR='"';var Kk=new RegExp(pR,"g");function Ss(r={stringFormatter:mn()}){return n=>r.stringFormatter(n.toString().slice(7,-1))}function ws(r={stringFormatter:mn()}){return n=>{if(n===null)return"";let a=JSON.stringify(n);return a===void 0?"":(a[0]==='"'&&(a=a.replace(/^"(.+)"$/,"$1")),r.stringFormatter(a))}}var gR=RegExp(`[^.[\\]]+|\\[(?:([^"'][^[]*)|(["'])((?:(?!\\2)[^\\\\]|\\\\.)*?)\\2)\\]|(?=(?:\\.|\\[\\])(?:\\.|\\[\\]|$))`,"g");function mR(r){var n,a,l;let c=[],p;for(;p=gR.exec(r);)c.push((l=(n=p[3])!==null&&n!==void 0?n:(a=p[1])===null||a===void 0?void 0:a.trim())!==null&&l!==void 0?l:p[0]);return c}function Ru(r,n,a){if(n in r){let p=r[n];return p===void 0?a:p}let l=Array.isArray(n)?n:mR(n,r),c=r;for(let p of l)if(c=c?.[p],c===void 0)return a;return c}function Ls(r,n){try{return Array.isArray(n)?r.push(...n):r.push(n),r}catch{return r.concat(n)}}function ta(r,n){let a=!0;return r.reduce((l,c)=>(c==null&&(c=""),a?(a=!1,`${c}`):`${l}${n}${c}`),"")}var _u;(function(r){r.header="header",r.undefined="undefined",r.boolean="boolean",r.number="number",r.bigint="bigint",r.string="string",r.symbol="symbol",r.function="function",r.object="object"})(_u||(_u={}));var ai=class{constructor(n){this.opts=this.preprocessOpts(n)}preprocessOpts(n){let a=Object.assign({},n);a.fields&&(a.fields=this.preprocessFieldsInfo(a.fields,a.defaultValue)),a.transforms=a.transforms||[];let l=a.formatters&&a.formatters.string||mn(),c=ws({stringFormatter:l}),p={header:l,undefined:to,boolean:to,number:Ns(),bigint:to,string:l,symbol:Ss({stringFormatter:l}),function:c,object:c};return a.formatters=Object.assign(Object.assign({},p),a.formatters),a.delimiter=a.delimiter||",",a.eol=a.eol||`
43
- `,a.header=a.header!==!1,a.includeEmptyRows=a.includeEmptyRows||!1,a.withBOM=a.withBOM||!1,a}preprocessFieldsInfo(n,a){return n.map(l=>{if(typeof l=="string")return{label:l,value:c=>Ru(c,l,a)};if(typeof l=="object"){let c="default"in l?l.default:a;if(typeof l.value=="string"){let p=l.value;return{label:l.label||l.value,value:g=>Ru(g,p,c)}}if(typeof l.value=="function"){let p=l.label||l.value.name||"",g={label:p,default:c},y=l.value;return{label:p,value(T){let U=y(T,g);return U===void 0?c:U}}}}throw new Error("Invalid field info option. "+JSON.stringify(l))})}getHeader(){return ta(this.opts.fields.map(n=>this.opts.formatters.header(n.label)),this.opts.delimiter)}preprocessRow(n){return this.opts.transforms.reduce((a,l)=>a.map(c=>l(c)).reduce(Ls,[]),[n])}processRow(n){if(!n)return;let a=this.opts.fields.map(l=>this.processCell(n,l));if(!(!this.opts.includeEmptyRows&&a.every(l=>l==="")))return ta(a,this.opts.delimiter)}processCell(n,a){return this.processValue(a.value(n))}processValue(n){let a=this.opts.formatters[typeof n];return a(n)}};var ro=class extends ai{constructor(n){super(n)}parse(n){let a=this.preprocessData(n);this.opts.fields=this.opts.fields||this.preprocessFieldsInfo(a.reduce((g,y)=>(Object.keys(y).forEach(T=>{g.includes(T)||g.push(T)}),g),[]),this.opts.defaultValue);let l=this.opts.header?this.getHeader():"",c=this.processData(a);return(this.opts.withBOM?"\uFEFF":"")+l+(l&&c?this.opts.eol:"")+c}preprocessData(n){let a=Array.isArray(n)?n:[n];if(!this.opts.fields){if(n==null||a.length===0)throw new Error('Data should not be empty or the "fields" option should be included');if(typeof a[0]!="object")throw new Error('Data items should be objects or the "fields" option should be included')}return this.opts.transforms.length===0?a:a.map(l=>this.preprocessRow(l)).reduce(Ls,[])}processData(n){return ta(n.map(a=>this.processRow(a)).filter(a=>a),this.opts.eol)}};var Ut;(function(r){r[r.BACKSPACE=8]="BACKSPACE",r[r.FORM_FEED=12]="FORM_FEED",r[r.NEWLINE=10]="NEWLINE",r[r.CARRIAGE_RETURN=13]="CARRIAGE_RETURN",r[r.TAB=9]="TAB",r[r.SPACE=32]="SPACE",r[r.EXCLAMATION_MARK=33]="EXCLAMATION_MARK",r[r.QUOTATION_MARK=34]="QUOTATION_MARK",r[r.NUMBER_SIGN=35]="NUMBER_SIGN",r[r.DOLLAR_SIGN=36]="DOLLAR_SIGN",r[r.PERCENT_SIGN=37]="PERCENT_SIGN",r[r.AMPERSAND=38]="AMPERSAND",r[r.APOSTROPHE=39]="APOSTROPHE",r[r.LEFT_PARENTHESIS=40]="LEFT_PARENTHESIS",r[r.RIGHT_PARENTHESIS=41]="RIGHT_PARENTHESIS",r[r.ASTERISK=42]="ASTERISK",r[r.PLUS_SIGN=43]="PLUS_SIGN",r[r.COMMA=44]="COMMA",r[r.HYPHEN_MINUS=45]="HYPHEN_MINUS",r[r.FULL_STOP=46]="FULL_STOP",r[r.SOLIDUS=47]="SOLIDUS",r[r.DIGIT_ZERO=48]="DIGIT_ZERO",r[r.DIGIT_ONE=49]="DIGIT_ONE",r[r.DIGIT_TWO=50]="DIGIT_TWO",r[r.DIGIT_THREE=51]="DIGIT_THREE",r[r.DIGIT_FOUR=52]="DIGIT_FOUR",r[r.DIGIT_FIVE=53]="DIGIT_FIVE",r[r.DIGIT_SIX=54]="DIGIT_SIX",r[r.DIGIT_SEVEN=55]="DIGIT_SEVEN",r[r.DIGIT_EIGHT=56]="DIGIT_EIGHT",r[r.DIGIT_NINE=57]="DIGIT_NINE",r[r.COLON=58]="COLON",r[r.SEMICOLON=59]="SEMICOLON",r[r.LESS_THAN_SIGN=60]="LESS_THAN_SIGN",r[r.EQUALS_SIGN=61]="EQUALS_SIGN",r[r.GREATER_THAN_SIGN=62]="GREATER_THAN_SIGN",r[r.QUESTION_MARK=63]="QUESTION_MARK",r[r.COMMERCIAL_AT=64]="COMMERCIAL_AT",r[r.LATIN_CAPITAL_LETTER_A=65]="LATIN_CAPITAL_LETTER_A",r[r.LATIN_CAPITAL_LETTER_B=66]="LATIN_CAPITAL_LETTER_B",r[r.LATIN_CAPITAL_LETTER_C=67]="LATIN_CAPITAL_LETTER_C",r[r.LATIN_CAPITAL_LETTER_D=68]="LATIN_CAPITAL_LETTER_D",r[r.LATIN_CAPITAL_LETTER_E=69]="LATIN_CAPITAL_LETTER_E",r[r.LATIN_CAPITAL_LETTER_F=70]="LATIN_CAPITAL_LETTER_F",r[r.LATIN_CAPITAL_LETTER_G=71]="LATIN_CAPITAL_LETTER_G",r[r.LATIN_CAPITAL_LETTER_H=72]="LATIN_CAPITAL_LETTER_H",r[r.LATIN_CAPITAL_LETTER_I=73]="LATIN_CAPITAL_LETTER_I",r[r.LATIN_CAPITAL_LETTER_J=74]="LATIN_CAPITAL_LETTER_J",r[r.LATIN_CAPITAL_LETTER_K=75]="LATIN_CAPITAL_LETTER_K",r[r.LATIN_CAPITAL_LETTER_L=76]="LATIN_CAPITAL_LETTER_L",r[r.LATIN_CAPITAL_LETTER_M=77]="LATIN_CAPITAL_LETTER_M",r[r.LATIN_CAPITAL_LETTER_N=78]="LATIN_CAPITAL_LETTER_N",r[r.LATIN_CAPITAL_LETTER_O=79]="LATIN_CAPITAL_LETTER_O",r[r.LATIN_CAPITAL_LETTER_P=80]="LATIN_CAPITAL_LETTER_P",r[r.LATIN_CAPITAL_LETTER_Q=81]="LATIN_CAPITAL_LETTER_Q",r[r.LATIN_CAPITAL_LETTER_R=82]="LATIN_CAPITAL_LETTER_R",r[r.LATIN_CAPITAL_LETTER_S=83]="LATIN_CAPITAL_LETTER_S",r[r.LATIN_CAPITAL_LETTER_T=84]="LATIN_CAPITAL_LETTER_T",r[r.LATIN_CAPITAL_LETTER_U=85]="LATIN_CAPITAL_LETTER_U",r[r.LATIN_CAPITAL_LETTER_V=86]="LATIN_CAPITAL_LETTER_V",r[r.LATIN_CAPITAL_LETTER_W=87]="LATIN_CAPITAL_LETTER_W",r[r.LATIN_CAPITAL_LETTER_X=88]="LATIN_CAPITAL_LETTER_X",r[r.LATIN_CAPITAL_LETTER_Y=89]="LATIN_CAPITAL_LETTER_Y",r[r.LATIN_CAPITAL_LETTER_Z=90]="LATIN_CAPITAL_LETTER_Z",r[r.LEFT_SQUARE_BRACKET=91]="LEFT_SQUARE_BRACKET",r[r.REVERSE_SOLIDUS=92]="REVERSE_SOLIDUS",r[r.RIGHT_SQUARE_BRACKET=93]="RIGHT_SQUARE_BRACKET",r[r.CIRCUMFLEX_ACCENT=94]="CIRCUMFLEX_ACCENT",r[r.LOW_LINE=95]="LOW_LINE",r[r.GRAVE_ACCENT=96]="GRAVE_ACCENT",r[r.LATIN_SMALL_LETTER_A=97]="LATIN_SMALL_LETTER_A",r[r.LATIN_SMALL_LETTER_B=98]="LATIN_SMALL_LETTER_B",r[r.LATIN_SMALL_LETTER_C=99]="LATIN_SMALL_LETTER_C",r[r.LATIN_SMALL_LETTER_D=100]="LATIN_SMALL_LETTER_D",r[r.LATIN_SMALL_LETTER_E=101]="LATIN_SMALL_LETTER_E",r[r.LATIN_SMALL_LETTER_F=102]="LATIN_SMALL_LETTER_F",r[r.LATIN_SMALL_LETTER_G=103]="LATIN_SMALL_LETTER_G",r[r.LATIN_SMALL_LETTER_H=104]="LATIN_SMALL_LETTER_H",r[r.LATIN_SMALL_LETTER_I=105]="LATIN_SMALL_LETTER_I",r[r.LATIN_SMALL_LETTER_J=106]="LATIN_SMALL_LETTER_J",r[r.LATIN_SMALL_LETTER_K=107]="LATIN_SMALL_LETTER_K",r[r.LATIN_SMALL_LETTER_L=108]="LATIN_SMALL_LETTER_L",r[r.LATIN_SMALL_LETTER_M=109]="LATIN_SMALL_LETTER_M",r[r.LATIN_SMALL_LETTER_N=110]="LATIN_SMALL_LETTER_N",r[r.LATIN_SMALL_LETTER_O=111]="LATIN_SMALL_LETTER_O",r[r.LATIN_SMALL_LETTER_P=112]="LATIN_SMALL_LETTER_P",r[r.LATIN_SMALL_LETTER_Q=113]="LATIN_SMALL_LETTER_Q",r[r.LATIN_SMALL_LETTER_R=114]="LATIN_SMALL_LETTER_R",r[r.LATIN_SMALL_LETTER_S=115]="LATIN_SMALL_LETTER_S",r[r.LATIN_SMALL_LETTER_T=116]="LATIN_SMALL_LETTER_T",r[r.LATIN_SMALL_LETTER_U=117]="LATIN_SMALL_LETTER_U",r[r.LATIN_SMALL_LETTER_V=118]="LATIN_SMALL_LETTER_V",r[r.LATIN_SMALL_LETTER_W=119]="LATIN_SMALL_LETTER_W",r[r.LATIN_SMALL_LETTER_X=120]="LATIN_SMALL_LETTER_X",r[r.LATIN_SMALL_LETTER_Y=121]="LATIN_SMALL_LETTER_Y",r[r.LATIN_SMALL_LETTER_Z=122]="LATIN_SMALL_LETTER_Z",r[r.LEFT_CURLY_BRACKET=123]="LEFT_CURLY_BRACKET",r[r.VERTICAL_LINE=124]="VERTICAL_LINE",r[r.RIGHT_CURLY_BRACKET=125]="RIGHT_CURLY_BRACKET",r[r.TILDE=126]="TILDE"})(Ut||(Ut={}));var bR={[Ut.QUOTATION_MARK]:Ut.QUOTATION_MARK,[Ut.REVERSE_SOLIDUS]:Ut.REVERSE_SOLIDUS,[Ut.SOLIDUS]:Ut.SOLIDUS,[Ut.LATIN_SMALL_LETTER_B]:Ut.BACKSPACE,[Ut.LATIN_SMALL_LETTER_F]:Ut.FORM_FEED,[Ut.LATIN_SMALL_LETTER_N]:Ut.NEWLINE,[Ut.LATIN_SMALL_LETTER_R]:Ut.CARRIAGE_RETURN,[Ut.LATIN_SMALL_LETTER_T]:Ut.TAB};var Qg;(function(r){r[r.LEFT_BRACE=0]="LEFT_BRACE",r[r.RIGHT_BRACE=1]="RIGHT_BRACE",r[r.LEFT_BRACKET=2]="LEFT_BRACKET",r[r.RIGHT_BRACKET=3]="RIGHT_BRACKET",r[r.COLON=4]="COLON",r[r.COMMA=5]="COMMA",r[r.TRUE=6]="TRUE",r[r.FALSE=7]="FALSE",r[r.NULL=8]="NULL",r[r.STRING=9]="STRING",r[r.NUMBER=10]="NUMBER",r[r.SEPARATOR=11]="SEPARATOR"})(Qg||(Qg={}));var Pg;(function(r){r[r.START=0]="START",r[r.ENDED=1]="ENDED",r[r.ERROR=2]="ERROR",r[r.TRUE1=3]="TRUE1",r[r.TRUE2=4]="TRUE2",r[r.TRUE3=5]="TRUE3",r[r.FALSE1=6]="FALSE1",r[r.FALSE2=7]="FALSE2",r[r.FALSE3=8]="FALSE3",r[r.FALSE4=9]="FALSE4",r[r.NULL1=10]="NULL1",r[r.NULL2=11]="NULL2",r[r.NULL3=12]="NULL3",r[r.STRING_DEFAULT=13]="STRING_DEFAULT",r[r.STRING_AFTER_BACKSLASH=14]="STRING_AFTER_BACKSLASH",r[r.STRING_UNICODE_DIGIT_1=15]="STRING_UNICODE_DIGIT_1",r[r.STRING_UNICODE_DIGIT_2=16]="STRING_UNICODE_DIGIT_2",r[r.STRING_UNICODE_DIGIT_3=17]="STRING_UNICODE_DIGIT_3",r[r.STRING_UNICODE_DIGIT_4=18]="STRING_UNICODE_DIGIT_4",r[r.STRING_INCOMPLETE_CHAR=19]="STRING_INCOMPLETE_CHAR",r[r.NUMBER_AFTER_INITIAL_MINUS=20]="NUMBER_AFTER_INITIAL_MINUS",r[r.NUMBER_AFTER_INITIAL_ZERO=21]="NUMBER_AFTER_INITIAL_ZERO",r[r.NUMBER_AFTER_INITIAL_NON_ZERO=22]="NUMBER_AFTER_INITIAL_NON_ZERO",r[r.NUMBER_AFTER_FULL_STOP=23]="NUMBER_AFTER_FULL_STOP",r[r.NUMBER_AFTER_DECIMAL=24]="NUMBER_AFTER_DECIMAL",r[r.NUMBER_AFTER_E=25]="NUMBER_AFTER_E",r[r.NUMBER_AFTER_E_AND_SIGN=26]="NUMBER_AFTER_E_AND_SIGN",r[r.NUMBER_AFTER_E_AND_DIGIT=27]="NUMBER_AFTER_E_AND_DIGIT",r[r.SEPARATOR=28]="SEPARATOR",r[r.BOM_OR_START=29]="BOM_OR_START",r[r.BOM=30]="BOM"})(Pg||(Pg={}));var Fs;(function(r){r[r.OBJECT=0]="OBJECT",r[r.ARRAY=1]="ARRAY"})(Fs||(Fs={}));var Hg;(function(r){r[r.VALUE=0]="VALUE",r[r.KEY=1]="KEY",r[r.COLON=2]="COLON",r[r.COMMA=3]="COMMA",r[r.ENDED=4]="ENDED",r[r.ERROR=5]="ERROR",r[r.SEPARATOR=6]="SEPARATOR"})(Hg||(Hg={}));function Yg(r){let n=r.head.vars,a=r.results?.bindings;return new ro({fields:n}).parse(a?a.map(c=>Mo(c,p=>p.value)):[])}var Bs=r=>{for(let n in r)r[n].type!=="uri"&&(r[n].value=r[n].value.replace(/{{(.*?)}}/g,a=>(a=a.substring(2,a.length-2).trim(),r[a]?r[a].value:a)));return r},Su=class{constructor(n,a){n.executionTime&&(this.executionTime=n.executionTime),a&&(this.executionTime=a),n instanceof Error?this.error=n:n.content?this.setResponse(n):this.setSummary(n)}setResponse(n){this.res=n}setSummary(n){!n.data&&!n.error?this.summary={data:n}:this.summary=n}hasError(){return!!(this.res&&this.res.status>=400||this.errorSummary||this.error||this.summary&&this.summary.error)}getError(){if(!this.errorSummary){if(this.res&&this.res.status>=400){let n=this.res.content||this.res.statusText;this.errorSummary={text:n,status:this.res.status,statusText:this.res.ok?void 0:this.res.statusText}}if(this.summary&&this.summary.error&&(this.errorSummary=this.summary.error),this.error){let n=this.error;this.errorSummary={text:this.error.message,status:n.status,statusText:n.statusText}}}return this.errorSummary}getContentType(){if(this.res)return this.res.headers.get("content-type")||void 0;if(this.summary)return this.summary.contentType}getAsJson(){if(this.json)return this.json;if(!(this.json===!1||this.hasError()))return this.getParserFromContentType()?this.json:this.doLuckyGuess()?this.json:(this.json||(this.json=!1),this.json)}getData(){if(this.res){if(this.res.content)return this.res.content;if(this.res.body)return this.res.body;if(this.res.text)return this.res.text}if(this.summary)return this.summary.data}getResponseTime(){return this.executionTime}getParserFromContentType(){let n=this.getContentType();if(n){let a=as(this.getData());try{if(n.indexOf("json")>-1){if(n.indexOf("sparql-results+json")>=0)return this.json=au(a,Bs),this.type="json",!0;if(n.indexOf("application/rdf+json")>-1)return this.type="json",!0;this.type="json"}else{if(n.indexOf("xml")>-1)return this.json=Eu(a,Bs),this.type="xml",!0;if(n.indexOf("csv")>-1)return this.json=Zg(a),this.type="csv",!0;if(n.indexOf("tab-separated")>-1)return this.json=Vg(a),this.type="tsv",!0;if(n.indexOf("turtle")>0||n.indexOf("trig")>0||n.indexOf("triple")>0||n.indexOf("quad")>0)return this.json=Og(a),this.type="ttl",!0}}catch(l){l instanceof Error?this.errorSummary={text:l.message}:this.errorSummary={text:l}}}return!1}doLuckyGuess(){let n=as(this.getData());try{return this.json=au(n,Bs),this.type="json",!0}catch{}try{return this.json=Eu(n,Bs),this.type="xml",!0}catch{}return!1}getVariables(){let n=this.getAsJson();return n&&n.head?n.head.vars:[]}getBoolean(){let n=this.getAsJson();if(n&&"boolean"in n)return n.boolean}getBindings(){let n=this.getAsJson();return n&&n.results?n.results.bindings:null}getStatements(){return!this.statements&&this.type==="ttl"&&(this.statements=Iu(this.getData())),this.statements?this.statements:null}getOriginalResponseAsString(){let n=this.getData();return typeof n=="string"?n:this.type==="json"?JSON.stringify(n,void 0,2):n}getType(){return this.type||this.getAsJson(),this.type}getStatus(){if(this.res)return this.res.status;if(this.summary)return this.summary.status}getAsStoreObject(n){let a=this.summary;if(!a&&this.res&&(a={contentType:this.getContentType(),data:this.getOriginalResponseAsString(),error:this.getError(),status:this.getStatus(),executionTime:this.getResponseTime()}),a)return a.data&&a.data.length>n?void 0:a;if(this.error)return{error:this.getError(),executionTime:this.getResponseTime()}}asCsv(){let n=this.getAsJson();if(this.type==="csv")return this.getOriginalResponseAsString();if(n&&n.results)return Yg(n)}},Us=Su;function ks(r){var n=document.createElement("link");n.setAttribute("rel","stylesheet"),n.setAttribute("type","text/css"),n.setAttribute("href",r),document.getElementsByTagName("head")[0].appendChild(n)}function Ms(r,n){return new Promise((a,l)=>{var c=document.createElement("script");c.setAttribute("type","text/javascript"),c.setAttribute("async",""),c.setAttribute("src",r),n&&(c.innerHTML=n),c.onload=()=>a(),document.getElementsByTagName("head")[0].appendChild(c)})}Vo.addHook("afterSanitizeAttributes",r=>{r instanceof HTMLAnchorElement&&(r.target="_blank",r.rel="noopener noreferrer")});var wu=Vo.sanitize;var ra=class{constructor(n){this.priority=10;this.hideFromSelection=!0;this.yasr=n}draw(){let n=document.createElement("div");n.className="booleanResult";let a=this.yasr.results?.getBoolean(),l=document.createElement("i");l.className=a?"fas fa-check":"fas fa-xmark",n.appendChild(l);let c=document.createElement("span");c.textContent=a?"True":"False",n.appendChild(c),this.yasr.resultsEl.appendChild(n)}canHandleResults(){return!!this.yasr.results?.getBoolean&&(this.yasr.results.getBoolean()===!0||this.yasr.results.getBoolean()==!1)}getIcon(){return document.createElement("")}};var gm=Ar(bn()),FG=Ar(Bu()),BG=Ar($g()),UG=Ar(rm()),kG=Ar(om()),MG=Ar(lm()),GG=Ar(cm()),OG=Ar(pm());var Gs=class Gs{constructor(n){this.label="Response";this.priority=2;this.helpReference="https://yasgui-doc.matdata.eu/docs/user-guide#response-plugin";this.yasr=n,this.config=Gs.defaults,n.config.plugins.response&&n.config.plugins.response.dynamicConfig&&(this.config={...this.config,...n.config.plugins.response.dynamicConfig})}canHandleResults(){if(!this.yasr.results||!this.yasr.results.getOriginalResponseAsString)return!1;var n=this.yasr.results.getOriginalResponseAsString();return!((!n||n.length==0)&&this.yasr.results.getError())}getIcon(){let n=document.createElement("i");return n.className="fas fa-align-left",n}download(n){if(!this.yasr.results)return;let a=this.yasr.results.getContentType(),l=this.yasr.results.getType(),c=l==="xml"?"rdf":l;return{getData:()=>this.yasr.results?.getOriginalResponseAsString()||"",filename:`${n||"queryResults"}${c?"."+c:""}`,contentType:a||"text/plain",title:"Download result"}}draw(n){let a={...this.config,...n},l=this.yasr.results?.getOriginalResponseAsString()||"",c=l.split(`
43
+ `,a.header=a.header!==!1,a.includeEmptyRows=a.includeEmptyRows||!1,a.withBOM=a.withBOM||!1,a}preprocessFieldsInfo(n,a){return n.map(l=>{if(typeof l=="string")return{label:l,value:c=>Ru(c,l,a)};if(typeof l=="object"){let c="default"in l?l.default:a;if(typeof l.value=="string"){let p=l.value;return{label:l.label||l.value,value:g=>Ru(g,p,c)}}if(typeof l.value=="function"){let p=l.label||l.value.name||"",g={label:p,default:c},y=l.value;return{label:p,value(T){let U=y(T,g);return U===void 0?c:U}}}}throw new Error("Invalid field info option. "+JSON.stringify(l))})}getHeader(){return ta(this.opts.fields.map(n=>this.opts.formatters.header(n.label)),this.opts.delimiter)}preprocessRow(n){return this.opts.transforms.reduce((a,l)=>a.map(c=>l(c)).reduce(Ls,[]),[n])}processRow(n){if(!n)return;let a=this.opts.fields.map(l=>this.processCell(n,l));if(!(!this.opts.includeEmptyRows&&a.every(l=>l==="")))return ta(a,this.opts.delimiter)}processCell(n,a){return this.processValue(a.value(n))}processValue(n){let a=this.opts.formatters[typeof n];return a(n)}};var ro=class extends ai{constructor(n){super(n)}parse(n){let a=this.preprocessData(n);this.opts.fields=this.opts.fields||this.preprocessFieldsInfo(a.reduce((g,y)=>(Object.keys(y).forEach(T=>{g.includes(T)||g.push(T)}),g),[]),this.opts.defaultValue);let l=this.opts.header?this.getHeader():"",c=this.processData(a);return(this.opts.withBOM?"\uFEFF":"")+l+(l&&c?this.opts.eol:"")+c}preprocessData(n){let a=Array.isArray(n)?n:[n];if(!this.opts.fields){if(n==null||a.length===0)throw new Error('Data should not be empty or the "fields" option should be included');if(typeof a[0]!="object")throw new Error('Data items should be objects or the "fields" option should be included')}return this.opts.transforms.length===0?a:a.map(l=>this.preprocessRow(l)).reduce(Ls,[])}processData(n){return ta(n.map(a=>this.processRow(a)).filter(a=>a),this.opts.eol)}};var Ut;(function(r){r[r.BACKSPACE=8]="BACKSPACE",r[r.FORM_FEED=12]="FORM_FEED",r[r.NEWLINE=10]="NEWLINE",r[r.CARRIAGE_RETURN=13]="CARRIAGE_RETURN",r[r.TAB=9]="TAB",r[r.SPACE=32]="SPACE",r[r.EXCLAMATION_MARK=33]="EXCLAMATION_MARK",r[r.QUOTATION_MARK=34]="QUOTATION_MARK",r[r.NUMBER_SIGN=35]="NUMBER_SIGN",r[r.DOLLAR_SIGN=36]="DOLLAR_SIGN",r[r.PERCENT_SIGN=37]="PERCENT_SIGN",r[r.AMPERSAND=38]="AMPERSAND",r[r.APOSTROPHE=39]="APOSTROPHE",r[r.LEFT_PARENTHESIS=40]="LEFT_PARENTHESIS",r[r.RIGHT_PARENTHESIS=41]="RIGHT_PARENTHESIS",r[r.ASTERISK=42]="ASTERISK",r[r.PLUS_SIGN=43]="PLUS_SIGN",r[r.COMMA=44]="COMMA",r[r.HYPHEN_MINUS=45]="HYPHEN_MINUS",r[r.FULL_STOP=46]="FULL_STOP",r[r.SOLIDUS=47]="SOLIDUS",r[r.DIGIT_ZERO=48]="DIGIT_ZERO",r[r.DIGIT_ONE=49]="DIGIT_ONE",r[r.DIGIT_TWO=50]="DIGIT_TWO",r[r.DIGIT_THREE=51]="DIGIT_THREE",r[r.DIGIT_FOUR=52]="DIGIT_FOUR",r[r.DIGIT_FIVE=53]="DIGIT_FIVE",r[r.DIGIT_SIX=54]="DIGIT_SIX",r[r.DIGIT_SEVEN=55]="DIGIT_SEVEN",r[r.DIGIT_EIGHT=56]="DIGIT_EIGHT",r[r.DIGIT_NINE=57]="DIGIT_NINE",r[r.COLON=58]="COLON",r[r.SEMICOLON=59]="SEMICOLON",r[r.LESS_THAN_SIGN=60]="LESS_THAN_SIGN",r[r.EQUALS_SIGN=61]="EQUALS_SIGN",r[r.GREATER_THAN_SIGN=62]="GREATER_THAN_SIGN",r[r.QUESTION_MARK=63]="QUESTION_MARK",r[r.COMMERCIAL_AT=64]="COMMERCIAL_AT",r[r.LATIN_CAPITAL_LETTER_A=65]="LATIN_CAPITAL_LETTER_A",r[r.LATIN_CAPITAL_LETTER_B=66]="LATIN_CAPITAL_LETTER_B",r[r.LATIN_CAPITAL_LETTER_C=67]="LATIN_CAPITAL_LETTER_C",r[r.LATIN_CAPITAL_LETTER_D=68]="LATIN_CAPITAL_LETTER_D",r[r.LATIN_CAPITAL_LETTER_E=69]="LATIN_CAPITAL_LETTER_E",r[r.LATIN_CAPITAL_LETTER_F=70]="LATIN_CAPITAL_LETTER_F",r[r.LATIN_CAPITAL_LETTER_G=71]="LATIN_CAPITAL_LETTER_G",r[r.LATIN_CAPITAL_LETTER_H=72]="LATIN_CAPITAL_LETTER_H",r[r.LATIN_CAPITAL_LETTER_I=73]="LATIN_CAPITAL_LETTER_I",r[r.LATIN_CAPITAL_LETTER_J=74]="LATIN_CAPITAL_LETTER_J",r[r.LATIN_CAPITAL_LETTER_K=75]="LATIN_CAPITAL_LETTER_K",r[r.LATIN_CAPITAL_LETTER_L=76]="LATIN_CAPITAL_LETTER_L",r[r.LATIN_CAPITAL_LETTER_M=77]="LATIN_CAPITAL_LETTER_M",r[r.LATIN_CAPITAL_LETTER_N=78]="LATIN_CAPITAL_LETTER_N",r[r.LATIN_CAPITAL_LETTER_O=79]="LATIN_CAPITAL_LETTER_O",r[r.LATIN_CAPITAL_LETTER_P=80]="LATIN_CAPITAL_LETTER_P",r[r.LATIN_CAPITAL_LETTER_Q=81]="LATIN_CAPITAL_LETTER_Q",r[r.LATIN_CAPITAL_LETTER_R=82]="LATIN_CAPITAL_LETTER_R",r[r.LATIN_CAPITAL_LETTER_S=83]="LATIN_CAPITAL_LETTER_S",r[r.LATIN_CAPITAL_LETTER_T=84]="LATIN_CAPITAL_LETTER_T",r[r.LATIN_CAPITAL_LETTER_U=85]="LATIN_CAPITAL_LETTER_U",r[r.LATIN_CAPITAL_LETTER_V=86]="LATIN_CAPITAL_LETTER_V",r[r.LATIN_CAPITAL_LETTER_W=87]="LATIN_CAPITAL_LETTER_W",r[r.LATIN_CAPITAL_LETTER_X=88]="LATIN_CAPITAL_LETTER_X",r[r.LATIN_CAPITAL_LETTER_Y=89]="LATIN_CAPITAL_LETTER_Y",r[r.LATIN_CAPITAL_LETTER_Z=90]="LATIN_CAPITAL_LETTER_Z",r[r.LEFT_SQUARE_BRACKET=91]="LEFT_SQUARE_BRACKET",r[r.REVERSE_SOLIDUS=92]="REVERSE_SOLIDUS",r[r.RIGHT_SQUARE_BRACKET=93]="RIGHT_SQUARE_BRACKET",r[r.CIRCUMFLEX_ACCENT=94]="CIRCUMFLEX_ACCENT",r[r.LOW_LINE=95]="LOW_LINE",r[r.GRAVE_ACCENT=96]="GRAVE_ACCENT",r[r.LATIN_SMALL_LETTER_A=97]="LATIN_SMALL_LETTER_A",r[r.LATIN_SMALL_LETTER_B=98]="LATIN_SMALL_LETTER_B",r[r.LATIN_SMALL_LETTER_C=99]="LATIN_SMALL_LETTER_C",r[r.LATIN_SMALL_LETTER_D=100]="LATIN_SMALL_LETTER_D",r[r.LATIN_SMALL_LETTER_E=101]="LATIN_SMALL_LETTER_E",r[r.LATIN_SMALL_LETTER_F=102]="LATIN_SMALL_LETTER_F",r[r.LATIN_SMALL_LETTER_G=103]="LATIN_SMALL_LETTER_G",r[r.LATIN_SMALL_LETTER_H=104]="LATIN_SMALL_LETTER_H",r[r.LATIN_SMALL_LETTER_I=105]="LATIN_SMALL_LETTER_I",r[r.LATIN_SMALL_LETTER_J=106]="LATIN_SMALL_LETTER_J",r[r.LATIN_SMALL_LETTER_K=107]="LATIN_SMALL_LETTER_K",r[r.LATIN_SMALL_LETTER_L=108]="LATIN_SMALL_LETTER_L",r[r.LATIN_SMALL_LETTER_M=109]="LATIN_SMALL_LETTER_M",r[r.LATIN_SMALL_LETTER_N=110]="LATIN_SMALL_LETTER_N",r[r.LATIN_SMALL_LETTER_O=111]="LATIN_SMALL_LETTER_O",r[r.LATIN_SMALL_LETTER_P=112]="LATIN_SMALL_LETTER_P",r[r.LATIN_SMALL_LETTER_Q=113]="LATIN_SMALL_LETTER_Q",r[r.LATIN_SMALL_LETTER_R=114]="LATIN_SMALL_LETTER_R",r[r.LATIN_SMALL_LETTER_S=115]="LATIN_SMALL_LETTER_S",r[r.LATIN_SMALL_LETTER_T=116]="LATIN_SMALL_LETTER_T",r[r.LATIN_SMALL_LETTER_U=117]="LATIN_SMALL_LETTER_U",r[r.LATIN_SMALL_LETTER_V=118]="LATIN_SMALL_LETTER_V",r[r.LATIN_SMALL_LETTER_W=119]="LATIN_SMALL_LETTER_W",r[r.LATIN_SMALL_LETTER_X=120]="LATIN_SMALL_LETTER_X",r[r.LATIN_SMALL_LETTER_Y=121]="LATIN_SMALL_LETTER_Y",r[r.LATIN_SMALL_LETTER_Z=122]="LATIN_SMALL_LETTER_Z",r[r.LEFT_CURLY_BRACKET=123]="LEFT_CURLY_BRACKET",r[r.VERTICAL_LINE=124]="VERTICAL_LINE",r[r.RIGHT_CURLY_BRACKET=125]="RIGHT_CURLY_BRACKET",r[r.TILDE=126]="TILDE"})(Ut||(Ut={}));var bR={[Ut.QUOTATION_MARK]:Ut.QUOTATION_MARK,[Ut.REVERSE_SOLIDUS]:Ut.REVERSE_SOLIDUS,[Ut.SOLIDUS]:Ut.SOLIDUS,[Ut.LATIN_SMALL_LETTER_B]:Ut.BACKSPACE,[Ut.LATIN_SMALL_LETTER_F]:Ut.FORM_FEED,[Ut.LATIN_SMALL_LETTER_N]:Ut.NEWLINE,[Ut.LATIN_SMALL_LETTER_R]:Ut.CARRIAGE_RETURN,[Ut.LATIN_SMALL_LETTER_T]:Ut.TAB};var Qg;(function(r){r[r.LEFT_BRACE=0]="LEFT_BRACE",r[r.RIGHT_BRACE=1]="RIGHT_BRACE",r[r.LEFT_BRACKET=2]="LEFT_BRACKET",r[r.RIGHT_BRACKET=3]="RIGHT_BRACKET",r[r.COLON=4]="COLON",r[r.COMMA=5]="COMMA",r[r.TRUE=6]="TRUE",r[r.FALSE=7]="FALSE",r[r.NULL=8]="NULL",r[r.STRING=9]="STRING",r[r.NUMBER=10]="NUMBER",r[r.SEPARATOR=11]="SEPARATOR"})(Qg||(Qg={}));var Pg;(function(r){r[r.START=0]="START",r[r.ENDED=1]="ENDED",r[r.ERROR=2]="ERROR",r[r.TRUE1=3]="TRUE1",r[r.TRUE2=4]="TRUE2",r[r.TRUE3=5]="TRUE3",r[r.FALSE1=6]="FALSE1",r[r.FALSE2=7]="FALSE2",r[r.FALSE3=8]="FALSE3",r[r.FALSE4=9]="FALSE4",r[r.NULL1=10]="NULL1",r[r.NULL2=11]="NULL2",r[r.NULL3=12]="NULL3",r[r.STRING_DEFAULT=13]="STRING_DEFAULT",r[r.STRING_AFTER_BACKSLASH=14]="STRING_AFTER_BACKSLASH",r[r.STRING_UNICODE_DIGIT_1=15]="STRING_UNICODE_DIGIT_1",r[r.STRING_UNICODE_DIGIT_2=16]="STRING_UNICODE_DIGIT_2",r[r.STRING_UNICODE_DIGIT_3=17]="STRING_UNICODE_DIGIT_3",r[r.STRING_UNICODE_DIGIT_4=18]="STRING_UNICODE_DIGIT_4",r[r.STRING_INCOMPLETE_CHAR=19]="STRING_INCOMPLETE_CHAR",r[r.NUMBER_AFTER_INITIAL_MINUS=20]="NUMBER_AFTER_INITIAL_MINUS",r[r.NUMBER_AFTER_INITIAL_ZERO=21]="NUMBER_AFTER_INITIAL_ZERO",r[r.NUMBER_AFTER_INITIAL_NON_ZERO=22]="NUMBER_AFTER_INITIAL_NON_ZERO",r[r.NUMBER_AFTER_FULL_STOP=23]="NUMBER_AFTER_FULL_STOP",r[r.NUMBER_AFTER_DECIMAL=24]="NUMBER_AFTER_DECIMAL",r[r.NUMBER_AFTER_E=25]="NUMBER_AFTER_E",r[r.NUMBER_AFTER_E_AND_SIGN=26]="NUMBER_AFTER_E_AND_SIGN",r[r.NUMBER_AFTER_E_AND_DIGIT=27]="NUMBER_AFTER_E_AND_DIGIT",r[r.SEPARATOR=28]="SEPARATOR",r[r.BOM_OR_START=29]="BOM_OR_START",r[r.BOM=30]="BOM"})(Pg||(Pg={}));var Fs;(function(r){r[r.OBJECT=0]="OBJECT",r[r.ARRAY=1]="ARRAY"})(Fs||(Fs={}));var Hg;(function(r){r[r.VALUE=0]="VALUE",r[r.KEY=1]="KEY",r[r.COLON=2]="COLON",r[r.COMMA=3]="COMMA",r[r.ENDED=4]="ENDED",r[r.ERROR=5]="ERROR",r[r.SEPARATOR=6]="SEPARATOR"})(Hg||(Hg={}));function Yg(r){let n=r.head.vars,a=r.results?.bindings;return new ro({fields:n}).parse(a?a.map(c=>Mo(c,p=>p.value)):[])}var Bs=r=>{for(let n in r)r[n].type!=="uri"&&(r[n].value=r[n].value.replace(/{{(.*?)}}/g,a=>(a=a.substring(2,a.length-2).trim(),r[a]?r[a].value:a)));return r},Su=class{constructor(n,a){n.executionTime&&(this.executionTime=n.executionTime),a&&(this.executionTime=a),n instanceof Error?this.error=n:n.content?this.setResponse(n):this.setSummary(n)}setResponse(n){this.res=n}setSummary(n){!n.data&&!n.error?this.summary={data:n}:this.summary=n}hasError(){return!!(this.res&&this.res.status>=400||this.errorSummary||this.error||this.summary&&this.summary.error)}getError(){if(!this.errorSummary){if(this.res&&this.res.status>=400){let n=this.res.content||this.res.statusText;this.errorSummary={text:n,status:this.res.status,statusText:this.res.ok?void 0:this.res.statusText}}if(this.summary&&this.summary.error&&(this.errorSummary=this.summary.error),this.error){let n=this.error;this.errorSummary={text:this.error.message,status:n.status,statusText:n.statusText}}}return this.errorSummary}getContentType(){if(this.res)return this.res.headers.get("content-type")||void 0;if(this.summary)return this.summary.contentType}getAsJson(){if(this.json)return this.json;if(!(this.json===!1||this.hasError()))return this.getParserFromContentType()?this.json:this.doLuckyGuess()?this.json:(this.json||(this.json=!1),this.json)}getData(){if(this.res){if(this.res.content)return this.res.content;if(this.res.body)return this.res.body;if(this.res.text)return this.res.text}if(this.summary)return this.summary.data}getResponseTime(){return this.executionTime}getParserFromContentType(){let n=this.getContentType();if(n){let a=as(this.getData());try{if(n.indexOf("json")>-1){if(n.indexOf("sparql-results+json")>=0)return this.json=au(a,Bs),this.type="json",!0;if(n.indexOf("application/rdf+json")>-1)return this.type="json",!0;this.type="json"}else{if(n.indexOf("xml")>-1)return this.json=Eu(a,Bs),this.type="xml",!0;if(n.indexOf("csv")>-1)return this.json=Zg(a),this.type="csv",!0;if(n.indexOf("tab-separated")>-1)return this.json=Vg(a),this.type="tsv",!0;if(n.indexOf("turtle")>0||n.indexOf("trig")>0||n.indexOf("triple")>0||n.indexOf("quad")>0)return this.json=Og(a),this.type="ttl",!0}}catch(l){l instanceof Error?this.errorSummary={text:l.message}:this.errorSummary={text:l}}}return!1}doLuckyGuess(){let n=as(this.getData());try{return this.json=au(n,Bs),this.type="json",!0}catch{}try{return this.json=Eu(n,Bs),this.type="xml",!0}catch{}return!1}getVariables(){let n=this.getAsJson();return n&&n.head?n.head.vars:[]}getBoolean(){let n=this.getAsJson();if(n&&"boolean"in n)return n.boolean}getBindings(){let n=this.getAsJson();return n&&n.results?n.results.bindings:null}getStatements(){return!this.statements&&this.type==="ttl"&&(this.statements=Iu(this.getData())),this.statements?this.statements:null}getOriginalResponseAsString(){let n=this.getData();return typeof n=="string"?n:this.type==="json"?JSON.stringify(n,void 0,2):n}getType(){return this.type||this.getAsJson(),this.type}getStatus(){if(this.res)return this.res.status;if(this.summary)return this.summary.status}getAsStoreObject(n){let a=this.summary;if(!a&&this.res&&(a={contentType:this.getContentType(),data:this.getOriginalResponseAsString(),error:this.getError(),status:this.getStatus(),executionTime:this.getResponseTime()}),a){if(a.data!==void 0){let l=0;if(typeof a.data=="string")l=a.data.length;else try{l=JSON.stringify(a.data).length}catch{return}if(l>n)return}return a}if(this.error)return{error:this.getError(),executionTime:this.getResponseTime()}}asCsv(){let n=this.getAsJson();if(this.type==="csv")return this.getOriginalResponseAsString();if(n&&n.results)return Yg(n)}},Us=Su;function ks(r){var n=document.createElement("link");n.setAttribute("rel","stylesheet"),n.setAttribute("type","text/css"),n.setAttribute("href",r),document.getElementsByTagName("head")[0].appendChild(n)}function Ms(r,n){return new Promise((a,l)=>{var c=document.createElement("script");c.setAttribute("type","text/javascript"),c.setAttribute("async",""),c.setAttribute("src",r),n&&(c.innerHTML=n),c.onload=()=>a(),document.getElementsByTagName("head")[0].appendChild(c)})}Vo.addHook("afterSanitizeAttributes",r=>{r instanceof HTMLAnchorElement&&(r.target="_blank",r.rel="noopener noreferrer")});var wu=Vo.sanitize;var ra=class{constructor(n){this.priority=10;this.hideFromSelection=!0;this.yasr=n}draw(){let n=document.createElement("div");n.className="booleanResult";let a=this.yasr.results?.getBoolean(),l=document.createElement("i");l.className=a?"fas fa-check":"fas fa-xmark",n.appendChild(l);let c=document.createElement("span");c.textContent=a?"True":"False",n.appendChild(c),this.yasr.resultsEl.appendChild(n)}canHandleResults(){return!!this.yasr.results?.getBoolean&&(this.yasr.results.getBoolean()===!0||this.yasr.results.getBoolean()==!1)}getIcon(){return document.createElement("")}};var gm=Ar(bn()),FG=Ar(Bu()),BG=Ar($g()),UG=Ar(rm()),kG=Ar(om()),MG=Ar(lm()),GG=Ar(cm()),OG=Ar(pm());var Gs=class Gs{constructor(n){this.label="Response";this.priority=2;this.helpReference="https://yasgui-doc.matdata.eu/docs/user-guide#response-plugin";this.yasr=n,this.config=Gs.defaults,n.config.plugins.response&&n.config.plugins.response.dynamicConfig&&(this.config={...this.config,...n.config.plugins.response.dynamicConfig})}canHandleResults(){if(!this.yasr.results||!this.yasr.results.getOriginalResponseAsString)return!1;var n=this.yasr.results.getOriginalResponseAsString();return!((!n||n.length==0)&&this.yasr.results.getError())}getIcon(){let n=document.createElement("i");return n.className="fas fa-align-left",n}download(n){if(!this.yasr.results)return;let a=this.yasr.results.getContentType(),l=this.yasr.results.getType(),c=l==="xml"?"rdf":l;return{getData:()=>this.yasr.results?.getOriginalResponseAsString()||"",filename:`${n||"queryResults"}${c?"."+c:""}`,contentType:a||"text/plain",title:"Download result"}}draw(n){let a={...this.config,...n},l=this.yasr.results?.getOriginalResponseAsString()||"",c=l.split(`
44
44
  `);c.length>a.maxLines&&(l=c.slice(0,a.maxLines).join(`
45
45
  `));let g=document.documentElement.getAttribute("data-theme")==="dark"?"material-palenight":"default",y={readOnly:!0,lineNumbers:!0,lineWrapping:!0,foldGutter:!0,gutters:["CodeMirror-linenumbers","CodeMirror-foldgutter"],value:l,extraKeys:{Tab:!1},theme:g};this.yasr.results?.getType()==="json"&&(y.mode={name:"javascript",json:!0}),this.cm=(0,gm.default)(this.yasr.resultsEl,y),c.length>a.maxLines&&this.showLess(!1)}limitData(n){let a=n.split(`
46
46
  `);return a.length>this.config.maxLines&&(n=a.slice(0,this.config.maxLines).join(`
47
- `)),n}showLess(n=!0){if(!this.cm)return;Qe(this.cm.getWrapperElement(),"overflow"),this.overLay&&(this.overLay.remove(),this.overLay=void 0),this.overLay=document.createElement("div"),Qe(this.overLay,"overlay");let a=document.createElement("div");Qe(a,"overlay_content");let l=document.createElement("button");l.title="Show all",Qe(l,"yasr_btn","overlay_btn"),l.textContent="Show all",l.addEventListener("click",()=>this.showMore()),a.append(l);let c=document.createElement("button");c.title="Download result",Qe(c,"yasr_btn","overlay_btn");let p=document.createElement("span");p.innerText="Download result",c.appendChild(p);let g=document.createElement("i");Qe(g,"fas"),Qe(g,"fa-download"),c.appendChild(g),c.addEventListener("click",()=>this.yasr.download()),c.addEventListener("keydown",y=>{(y.code==="Space"||y.code==="Enter")&&this.yasr.download()}),a.appendChild(c),this.overLay.appendChild(a),this.cm.getWrapperElement().appendChild(this.overLay),n&&this.cm.setValue(this.limitData(this.yasr.results?.getOriginalResponseAsString()||""))}showMore(){this.cm&&(hn(this.cm.getWrapperElement(),"overflow"),this.overLay?.remove(),this.overLay=void 0,this.cm.setValue(this.yasr.results?.getOriginalResponseAsString()||""),this.cm.refresh())}};Gs.defaults={maxLines:30};var na=Gs;var ia=class{constructor(n){this.priority=20;this.hideFromSelection=!0;this.yasr=n}canHandleResults(){return!!this.yasr.results&&!!this.yasr.results.getError()}getTryBtn(n){let a=document.createElement("a");return a.href=n,a.rel="noopener noreferrer",a.target="_blank",a.className="yasr_tryQuery",a.textContent="Try query in a new browser window",a}getCorsMessage(){let n=document.createElement("div");n.className="redOutline";let a=document.createElement("p");a.textContent="Unable to get response from endpoint. Possible reasons:",n.appendChild(a);let l=document.createElement("ul"),c=document.createElement("li");c.textContent="Incorrect endpoint URL",l.appendChild(c);let p=document.createElement("li");p.textContent="Endpoint is down",l.appendChild(p);let g=document.createElement("li");g.textContent="Credentials have expired",l.appendChild(g);let y=document.createElement("li"),T=document.createElement("span");T.textContent="Endpoint is not accessible from the YASGUI server and website, and the endpoint is not ",y.appendChild(T);let U=document.createElement("a");return U.textContent="CORS-enabled",U.href="http://enable-cors.org/",U.target="_blank",U.rel="noopener noreferrer",y.appendChild(U),l.appendChild(y),n.appendChild(l),n}getStatusSpecificGuidance(n){let a=document.createElement("div");a.className="statusGuidance";let l=document.createElement("h4"),c=document.createElement("ul");switch(n){case 401:l.textContent="Authentication Required",a.appendChild(l);let p=document.createElement("li");p.textContent="The endpoint requires authentication credentials",c.appendChild(p);let g=document.createElement("li");g.textContent="Check if you need to provide an API key, username/password, or bearer token",c.appendChild(g);let y=document.createElement("li");return y.textContent="Verify your credentials are correct and not expired",c.appendChild(y),a.appendChild(c),a;case 403:l.textContent="Access Forbidden",a.appendChild(l);let T=document.createElement("li");T.textContent="You don't have permission to access this endpoint",c.appendChild(T);let U=document.createElement("li");U.textContent="Your credentials may be valid but lack sufficient privileges",c.appendChild(U);let A=document.createElement("li");A.textContent="Contact the endpoint administrator to request access",c.appendChild(A);let F=document.createElement("li");return F.textContent="A firewall such as OWASP is blocking is blocking SPARQL queries because they resemble SQL injection attempts. Contact the endpoint administrator to whitelist your queries or adjust firewall settings",c.appendChild(F),a.appendChild(c),a;case 404:l.textContent="Endpoint Not Found",a.appendChild(l);let M=document.createElement("li");M.textContent="The endpoint URL may be incorrect or has changed",c.appendChild(M);let X=document.createElement("li");X.textContent="Check for typos in the endpoint address",c.appendChild(X);let S=document.createElement("li");return S.textContent="Verify the endpoint is still active and hasn't been moved",c.appendChild(S),a.appendChild(c),a;case 429:l.textContent="Too Many Requests",a.appendChild(l);let Z=document.createElement("li");Z.textContent="You've exceeded the rate limit for this endpoint",c.appendChild(Z);let _=document.createElement("li");_.textContent="Wait a few moments before trying again",c.appendChild(_);let G=document.createElement("li");return G.textContent="Consider reducing query frequency or contacting the endpoint provider for higher limits",c.appendChild(G),a.appendChild(c),a;case 500:l.textContent="Internal Server Error",a.appendChild(l);let J=document.createElement("li");J.textContent="The SPARQL endpoint encountered an error while processing your query",c.appendChild(J);let q=document.createElement("li");q.textContent="Try simplifying your query or reducing the result limit",c.appendChild(q);let te=document.createElement("li");te.textContent="Check the error message below for specific details",c.appendChild(te);let ae=document.createElement("li");return ae.textContent="If the problem persists, contact the endpoint administrator",c.appendChild(ae),a.appendChild(c),a;case 502:case 503:case 504:l.textContent=n===502?"Bad Gateway":n===503?"Service Unavailable":"Gateway Timeout",a.appendChild(l);let R=document.createElement("li");R.textContent="The endpoint is temporarily unavailable or overloaded",c.appendChild(R);let w=document.createElement("li");w.textContent="Try again in a few moments",c.appendChild(w);let P=document.createElement("li");return P.textContent="The service may be undergoing maintenance",c.appendChild(P),a.appendChild(c),a;default:if(n>=400&&n<500){l.textContent="Client Error",a.appendChild(l);let $=document.createElement("li");$.textContent="There's an issue with the request",c.appendChild($);let fe=document.createElement("li");return fe.textContent="Check the error message below for details",c.appendChild(fe),a.appendChild(c),a}return null}}async draw(){let n=document.createElement("div");n.className="errorResult",this.yasr.resultsEl.appendChild(n);let a=this.yasr.results?.getError();if(!a)return;let l=document.createElement("div");l.className="errorHeader",n.appendChild(l);let c=await this.yasr.renderError(a);if(c){let g=document.createElement("div");g.className="redOutline",g.appendChild(c),n.appendChild(g);return}if(a.status){var p="Error";a.statusText&&a.statusText.length<100&&(p=a.statusText),p+=` (#${a.status})`;let g=document.createElement("span");if(g.className="status",g.textContent=p,l.appendChild(g),this.yasr.config.getPlainQueryLinkToEndpoint){let T=this.yasr.config.getPlainQueryLinkToEndpoint();T&&l.appendChild(this.getTryBtn(T))}let y=this.getStatusSpecificGuidance(a.status);if(y&&n.appendChild(y),a.text){let T=document.createElement("div");Qe(T,"errorMessageContainer"),n.appendChild(T);let U=document.createElement("pre");Qe(U,"errorMessage"),U.textContent=a.text,T.appendChild(U)}}else{if(this.yasr.config.getPlainQueryLinkToEndpoint){let y=this.yasr.config.getPlainQueryLinkToEndpoint();y&&l.appendChild(this.getTryBtn(y))}if(!a.text||a.text.indexOf("Request has been terminated")>=0||a.text.indexOf("Failed to fetch")>=0||a.text.indexOf("NetworkError")>=0||a.text.indexOf("Network request failed")>=0)n.appendChild(this.getCorsMessage());else{let y=document.createElement("pre");y.textContent=a.text,n.appendChild(y)}}}getIcon(){return document.createElement("")}};var ar=class ar extends mm.EventEmitter{constructor(a,l={},c){super();this.plugins={};this.helpDrawn=!1;this.isFullscreen=!1;this.isLoading=!1;this.utils={addScript:Ms,addCSS:ks,sanitize:wu};if(!a)throw new Error("No parent passed as argument. Dont know where to draw YASR");this.rootEl=document.createElement("div"),this.rootEl.className="yasr",a.appendChild(this.rootEl),this.config=Ol({},ar.defaults,l),this.storage=new ri(ar.storageNamespace),this.getConfigFromStorage(),this.headerEl=document.createElement("div"),this.headerEl.className="yasr_header",this.rootEl.appendChild(this.headerEl),this.fallbackInfoEl=document.createElement("div"),this.fallbackInfoEl.className="yasr_fallback_info",this.rootEl.appendChild(this.fallbackInfoEl),this.resultsEl=document.createElement("div"),this.resultsEl.className="yasr_results",this.resultsEl.id=Dl("resultsId"),this.rootEl.appendChild(this.resultsEl),this.createLoadingElement(),this.initializePlugins(),this.drawHeader();let p=c||this.getResponseFromStorage();p&&this.setResponse(p)}getConfigFromStorage(){let a=this.getStorageId(this.config.persistenceLabelConfig);if(a){let l=this.storage.get(a);if(l){this.selectedPlugin=l.selectedPlugin;for(let c in l.pluginsConfig){let p=l.pluginsConfig[c];p&&this.config.plugins[c]&&(this.config.plugins[c].dynamicConfig=p)}}}}async renderError(a){let l;if(this.config.errorRenderers!==void 0){for(let c of this.config.errorRenderers)if(l=await c(a),l!==void 0)break}return l}getStorageId(a,l){let c=l||this.config.persistenceId;if(c)return typeof c=="string"?c+"_"+a:c(this)+"_"+a}somethingDrawn(){return!!this.resultsEl.children.length}emptyFallbackElement(){for(;this.fallbackInfoEl.firstChild;)this.fallbackInfoEl.removeChild(this.fallbackInfoEl.firstChild)}getSelectedPluginName(){return this.selectedPlugin||this.config.defaultPlugin}getSelectedPlugin(){if(this.plugins[this.getSelectedPluginName()])return this.plugins[this.getSelectedPluginName()];console.warn(`Tried using plugin ${this.getSelectedPluginName()}, but seems this plugin isnt registered in yasr.`)}updatePluginSelectors(a){if(this.pluginSelectorsEl)for(let l in this.config.plugins){let c=this.plugins[l];c&&!c.hideFromSelection&&(a&&(a.indexOf(l)>=0?hn(this.pluginSelectorsEl.querySelector(".select_"+l),"disabled"):Qe(this.pluginSelectorsEl.querySelector(".select_"+l),"disabled")),l===this.getSelectedPluginName()?Qe(this.pluginSelectorsEl.querySelector(".select_"+l),"selected"):hn(this.pluginSelectorsEl.querySelector(".select_"+l),"selected"))}}getCompatiblePlugins(){if(!this.results)return Object.keys(Gl(this.config.plugins,l=>typeof l=="object"&&l.enabled||l===!0));let a=[];for(let l in this.plugins)this.plugins[l].canHandleResults()&&a.push({name:l,priority:this.plugins[l].priority});return a.sort((l,c)=>c.priority-l.priority).map(l=>l.name)}draw(){if(this.updateHelpButton(),this.updateResponseInfo(),!this.results)return;let a=this.getCompatiblePlugins();if(this.drawnPlugin&&this.getSelectedPluginName()!==this.drawnPlugin){for(;this.pluginControls.firstChild;)this.pluginControls.firstChild.remove();this.plugins[this.drawnPlugin].destroy?.()}let l;if(this.getSelectedPlugin()&&this.getSelectedPlugin()?.canHandleResults()?(l=this.getSelectedPluginName(),this.emptyFallbackElement()):a[0]&&(this.drawnPlugin&&this.plugins[this.drawnPlugin].destroy?.(),l=a[0],this.fillFallbackBox(l)),l){this.drawnPlugin=l,this.emit("draw",this,this.plugins[l]);let c=this.plugins[l];(c.initialize?c.initialize():Promise.resolve()).then(async()=>{if(l){for(;this.resultsEl.firstChild;)this.resultsEl.firstChild.remove();await this.plugins[l].draw(this.config.plugins[l].dynamicConfig),this.emit("drawn",this,this.plugins[l]),this.updateExportHeaders(),this.updatePluginSelectors(a)}},g=>console.error)}else this.resultsEl.textContent="cannot render result",this.updateExportHeaders(),this.updatePluginSelectors(a)}refresh(){this.draw()}destroy(){this.drawnPlugin&&this.plugins[this.drawnPlugin]?.destroy?.(),this.removeAllListeners(),this.rootEl.remove()}getPrefixes(){return this.config.prefixes?typeof this.config.prefixes=="function"?this.config.prefixes(this):this.config.prefixes:{}}selectPlugin(a){this.selectedPlugin!==a&&(this.config.plugins[a]?this.selectedPlugin=a:(console.warn(`Plugin ${a} does not exist.`),this.selectedPlugin=this.config.defaultPlugin),this.storeConfig(),this.emit("change",this),this.updatePluginSelectors(),this.draw())}drawPluginSelectors(){this.pluginSelectorsEl=document.createElement("ul"),this.pluginSelectorsEl.className="yasr_btnGroup";let a=this.config.pluginOrder;Object.keys(this.config.plugins).sort().forEach(l=>{a.indexOf(l)===-1&&a.push(l)});for(let l of a){if(!this.config.plugins[l]||!this.config.plugins[l].enabled)continue;let c=this.plugins[l];if(!c||c.hideFromSelection)continue;let p=c.label||l,g=document.createElement("button");if(Qe(g,"yasr_btn","select_"+l),g.title=p,g.type="button",g.setAttribute("aria-label",`Shows ${p} view`),c.getIcon){let U=c.getIcon();U&&(Qe(U,"plugin_icon"),g.appendChild(U))}let y=document.createElement("span");y.textContent=p,g.appendChild(y),g.addEventListener("click",()=>this.selectPlugin(l));let T=document.createElement("li");T.appendChild(g),this.pluginSelectorsEl.appendChild(T)}this.pluginSelectorsEl.children.length>=1&&this.headerEl.appendChild(this.pluginSelectorsEl),this.updatePluginSelectors()}fillFallbackBox(a){if(this.emptyFallbackElement(),this.plugins[a||this.drawnPlugin||""]?.hideFromSelection)return;let l=this.getSelectedPlugin(),c=this.plugins[a||this.drawnPlugin||""]?.label||a||this.drawnPlugin,p=l?.label||this.getSelectedPluginName(),g=document.createElement("p");if(g.innerText=`Could not render results with the ${p} plugin, the results currently are rendered with the ${c} plugin. ${this.getSelectedPlugin()?.helpReference?"See ":""}`,l?.helpReference){let y=document.createElement("a");y.innerText=`${p} documentation`,y.href=l.helpReference,y.rel="noopener noreferrer",y.target="_blank",g.append(y),g.innerHTML+=" for more information."}this.fallbackInfoEl.appendChild(g)}drawPluginElement(){let a=document.createElement("div");Qe(a,"space_element"),this.headerEl.appendChild(a),this.pluginControls=document.createElement("div"),this.pluginControls.setAttribute("id","yasr_plugin_control"),Qe(this.pluginControls,"yasr_plugin_control"),this.pluginControls.setAttribute("aria-controls",this.resultsEl.id),this.headerEl.appendChild(this.pluginControls)}drawHeader(){this.drawPluginSelectors(),this.drawResponseInfo(),this.drawPluginElement(),this.drawDownloadIcon(),this.drawFullscreenButton(),this.loadingEl&&this.headerEl.appendChild(this.loadingEl),this.drawDocumentationButton()}drawDownloadIcon(){this.downloadBtn=document.createElement("a"),Qe(this.downloadBtn,"yasr_btn","yasr_downloadIcon","btn_icon"),this.downloadBtn.download="",this.downloadBtn.setAttribute("aria-label","Download Results"),this.downloadBtn.setAttribute("tabindex","0"),this.downloadBtn.setAttribute("role","button");let a=document.createElement("i");Qe(a,"fas","fa-download"),a.setAttribute("aria-hidden","true"),this.downloadBtn.appendChild(a),this.downloadBtn.addEventListener("click",()=>{Xo(this.downloadBtn,"disabled")||this.download()}),this.downloadBtn.addEventListener("keydown",l=>{if(l.code==="Space"||l.code==="Enter"){if(Xo(this.downloadBtn,"disabled"))return;this.download()}}),this.headerEl.appendChild(this.downloadBtn)}drawResponseInfo(){this.dataElement=document.createElement("div"),Qe(this.dataElement,"yasr_response_chip"),this.headerEl.appendChild(this.dataElement),this.updateResponseInfo()}updateResponseInfo(){let a="";if(this.results){hn(this.dataElement,"empty");let l=this.results.getBindings();l&&(a+=`${l.length} result${l.length===1?"":"s"}`);let c=this.results.getResponseTime();if(c){a||(a="Response");let p=c/1e3;a+=` in ${p} second${p===1?"":"s"}`}}else Qe(this.dataElement,"empty");this.dataElement.innerText=a}updateHelpButton(){let a=this.getSelectedPlugin();if(a?.helpReference){let l=`View documentation of ${a.label||this.getSelectedPluginName()}`;this.documentationLink.href=a.helpReference,this.documentationLink.title=l,this.documentationLink.setAttribute("aria-label",l),hn(this.documentationLink,"disabled")}else Qe(this.documentationLink,"disabled"),this.documentationLink.title="This plugin doesn't have a help reference yet. Please contact the maintainer to fix this"}updateExportHeaders(){if(this.downloadBtn&&this.drawnPlugin){this.downloadBtn.title="";let a=this.plugins[this.drawnPlugin];if(a&&a.download){let l=a.download(this.config.getDownloadFileName?.());if(hn(this.downloadBtn,"disabled"),l){l.title&&(this.downloadBtn.title=l.title);return}}this.downloadBtn.title="Download not supported",Qe(this.downloadBtn,"disabled")}}drawFullscreenButton(){this.fullscreenBtn=document.createElement("button"),Qe(this.fullscreenBtn,"yasr_btn","yasr_fullscreenButton","btn_icon"),this.fullscreenBtn.setAttribute("aria-label","Toggle fullscreen"),this.fullscreenBtn.setAttribute("tabindex","0"),this.fullscreenBtn.setAttribute("role","button");let a=document.createElement("i");Qe(a,"fas"),Qe(a,"fa-expand"),Qe(a,"fullscreenIcon"),a.setAttribute("aria-hidden","true"),this.fullscreenBtn.appendChild(a);let l=document.createElement("i");Qe(l,"fas"),Qe(l,"fa-compress"),Qe(l,"fullscreenExitIcon"),l.setAttribute("aria-hidden","true"),this.fullscreenBtn.appendChild(l),this.fullscreenBtn.title="Toggle fullscreen (F10)",this.fullscreenBtn.addEventListener("click",()=>{this.toggleFullscreen()}),this.fullscreenBtn.addEventListener("keydown",c=>{(c.code==="Space"||c.code==="Enter")&&this.toggleFullscreen()}),this.headerEl.appendChild(this.fullscreenBtn)}toggleFullscreen(){this.isFullscreen=!this.isFullscreen,this.isFullscreen?(Qe(this.rootEl,"fullscreen"),this.fullscreenBtn&&(this.fullscreenBtn.title="Exit fullscreen (F10)")):(hn(this.rootEl,"fullscreen"),this.fullscreenBtn&&(this.fullscreenBtn.title="Toggle fullscreen (F10)"))}getIsFullscreen(){return this.isFullscreen}createLoadingElement(){this.loadingEl=document.createElement("div"),this.loadingEl.className="yasr_loading_indicator",this.loadingEl.title="Executing query...",this.loadingEl.innerHTML='<div class="yasr_loading_spinner"></div>',this.loadingEl.style.display="none"}showLoading(){this.isLoading=!0,this.loadingEl&&(this.loadingEl.style.display="flex")}hideLoading(){this.isLoading=!1,this.loadingEl&&(this.loadingEl.style.display="none")}drawDocumentationButton(){this.documentationLink=document.createElement("a"),Qe(this.documentationLink,"yasr_btn","yasr_external_ref_btn");let a=document.createElement("i");Qe(a,"fas","fa-circle-question"),this.documentationLink.appendChild(a),this.documentationLink.href="https://yasgui-doc.matdata.eu/docs/user-guide",this.documentationLink.target="_blank",this.documentationLink.rel="noopener noreferrer",this.headerEl.appendChild(this.documentationLink)}download(){if(!this.drawnPlugin)return;let a=this.plugins[this.drawnPlugin];if(a&&a.download){let l=a.download(this.config.getDownloadFileName?.());if(!l)return;let c=l.getData(),p;if(c.startsWith("data:"))p=c;else{let y=new Blob([c],{type:l.contentType??"text/plain"});p=window.URL.createObjectURL(y)}let g=document.createElement("a");g.href=p,g.download=l.filename,g.click()}}handleLocalStorageQuotaFull(a){console.warn("Localstorage quota exceeded. Clearing all queries"),ar.clearStorage()}getResponseFromStorage(){let a=this.getStorageId(this.config.persistenceLabelResponse);if(a)return this.storage.get(a)}getPersistentConfig(){return{selectedPlugin:this.getSelectedPluginName(),pluginsConfig:Mo(this.config.plugins,a=>a.dynamicConfig)}}storePluginConfig(a,l){this.config.plugins[a].dynamicConfig=l,this.storeConfig(),this.emit("change",this)}storeConfig(){let a=this.getStorageId(this.config.persistenceLabelConfig);a&&this.storage.set(a,this.getPersistentConfig(),this.config.persistencyExpire,this.handleLocalStorageQuotaFull)}storeResponse(){let a=this.getStorageId(this.config.persistenceLabelResponse);if(a&&this.results){let l=this.results.getAsStoreObject(this.config.maxPersistentResponseSize);l&&!l.error?this.storage.set(a,l,this.config.persistencyExpire,this.handleLocalStorageQuotaFull):this.storage.remove(a)}}setResponse(a,l){a&&(this.hideLoading(),this.results=new Us(a,l),this.draw(),this.storeResponse())}executeQuery(a,l){return this.config.executeQuery?this.config.executeQuery(a,l):Promise.reject(new Error("No executeQuery handler configured on this Yasr instance"))}initializePlugins(){for(let a in this.config.plugins)this.config.plugins[a]&&(ar.plugins[a]?this.plugins[a]=new ar.plugins[a](this):console.warn("Wanted to initialize plugin "+a+" but could not find a matching registered plugin"))}static registerPlugin(a,l,c=!0){ar.plugins[a]=l,c?ar.defaults.plugins[a]={enabled:!0}:ar.defaults.plugins[a]={enabled:!1}}static clearStorage(){new ri(ar.storageNamespace).removeNamespace()}};ar.defaults=Zl(),ar.plugins={},ar.Dependencies={},ar.storageNamespace="triply";var $r=ar;function CR(r,n,a=!0){$r.plugins[r]=n,a?$r.defaults.plugins[r]={enabled:!0}:$r.defaults.plugins[r]={enabled:!1}}$r.registerPlugin("boolean",ra);$r.registerPlugin("response",na);$r.registerPlugin("error",ia);var AR=$r;return Ib(RR);})();
47
+ `)),n}showLess(n=!0){if(!this.cm)return;Qe(this.cm.getWrapperElement(),"overflow"),this.overLay&&(this.overLay.remove(),this.overLay=void 0),this.overLay=document.createElement("div"),Qe(this.overLay,"overlay");let a=document.createElement("div");Qe(a,"overlay_content");let l=document.createElement("button");l.title="Show all",Qe(l,"yasr_btn","overlay_btn"),l.textContent="Show all",l.addEventListener("click",()=>this.showMore()),a.append(l);let c=document.createElement("button");c.title="Download result",Qe(c,"yasr_btn","overlay_btn");let p=document.createElement("span");p.innerText="Download result",c.appendChild(p);let g=document.createElement("i");Qe(g,"fas"),Qe(g,"fa-download"),c.appendChild(g),c.addEventListener("click",()=>this.yasr.download()),c.addEventListener("keydown",y=>{(y.code==="Space"||y.code==="Enter")&&this.yasr.download()}),a.appendChild(c),this.overLay.appendChild(a),this.cm.getWrapperElement().appendChild(this.overLay),n&&this.cm.setValue(this.limitData(this.yasr.results?.getOriginalResponseAsString()||""))}showMore(){this.cm&&(hn(this.cm.getWrapperElement(),"overflow"),this.overLay?.remove(),this.overLay=void 0,this.cm.setValue(this.yasr.results?.getOriginalResponseAsString()||""),this.cm.refresh())}};Gs.defaults={maxLines:30};var na=Gs;var ia=class{constructor(n){this.priority=20;this.hideFromSelection=!0;this.yasr=n}canHandleResults(){return!!this.yasr.results&&!!this.yasr.results.getError()}getTryBtn(n){let a=document.createElement("a");return a.href=n,a.rel="noopener noreferrer",a.target="_blank",a.className="yasr_tryQuery",a.textContent="Try query in a new browser window",a}getCorsMessage(){let n=document.createElement("div");n.className="redOutline";let a=document.createElement("p");a.textContent="Unable to get response from endpoint. Possible reasons:",n.appendChild(a);let l=document.createElement("ul"),c=document.createElement("li");c.textContent="Incorrect endpoint URL",l.appendChild(c);let p=document.createElement("li");p.textContent="Endpoint is down",l.appendChild(p);let g=document.createElement("li");g.textContent="Credentials have expired",l.appendChild(g);let y=document.createElement("li"),T=document.createElement("span");T.textContent="Endpoint is not accessible from the YASGUI server and website, and the endpoint is not ",y.appendChild(T);let U=document.createElement("a");return U.textContent="CORS-enabled",U.href="http://enable-cors.org/",U.target="_blank",U.rel="noopener noreferrer",y.appendChild(U),l.appendChild(y),n.appendChild(l),n}getStatusSpecificGuidance(n){let a=document.createElement("div");a.className="statusGuidance";let l=document.createElement("h4"),c=document.createElement("ul");switch(n){case 401:l.textContent="Authentication Required",a.appendChild(l);let p=document.createElement("li");p.textContent="The endpoint requires authentication credentials",c.appendChild(p);let g=document.createElement("li");g.textContent="Check if you need to provide an API key, username/password, or bearer token",c.appendChild(g);let y=document.createElement("li");return y.textContent="Verify your credentials are correct and not expired",c.appendChild(y),a.appendChild(c),a;case 403:l.textContent="Access Forbidden",a.appendChild(l);let T=document.createElement("li");T.textContent="You don't have permission to access this endpoint",c.appendChild(T);let U=document.createElement("li");U.textContent="Your credentials may be valid but lack sufficient privileges",c.appendChild(U);let A=document.createElement("li");A.textContent="Contact the endpoint administrator to request access",c.appendChild(A);let F=document.createElement("li");return F.textContent="A firewall such as OWASP is blocking is blocking SPARQL queries because they resemble SQL injection attempts. Contact the endpoint administrator to whitelist your queries or adjust firewall settings",c.appendChild(F),a.appendChild(c),a;case 404:l.textContent="Endpoint Not Found",a.appendChild(l);let M=document.createElement("li");M.textContent="The endpoint URL may be incorrect or has changed",c.appendChild(M);let X=document.createElement("li");X.textContent="Check for typos in the endpoint address",c.appendChild(X);let S=document.createElement("li");return S.textContent="Verify the endpoint is still active and hasn't been moved",c.appendChild(S),a.appendChild(c),a;case 429:l.textContent="Too Many Requests",a.appendChild(l);let Z=document.createElement("li");Z.textContent="You've exceeded the rate limit for this endpoint",c.appendChild(Z);let _=document.createElement("li");_.textContent="Wait a few moments before trying again",c.appendChild(_);let G=document.createElement("li");return G.textContent="Consider reducing query frequency or contacting the endpoint provider for higher limits",c.appendChild(G),a.appendChild(c),a;case 500:l.textContent="Internal Server Error",a.appendChild(l);let J=document.createElement("li");J.textContent="The SPARQL endpoint encountered an error while processing your query",c.appendChild(J);let q=document.createElement("li");q.textContent="Try simplifying your query or reducing the result limit",c.appendChild(q);let te=document.createElement("li");te.textContent="Check the error message below for specific details",c.appendChild(te);let ae=document.createElement("li");return ae.textContent="If the problem persists, contact the endpoint administrator",c.appendChild(ae),a.appendChild(c),a;case 502:case 503:case 504:l.textContent=n===502?"Bad Gateway":n===503?"Service Unavailable":"Gateway Timeout",a.appendChild(l);let R=document.createElement("li");R.textContent="The endpoint is temporarily unavailable or overloaded",c.appendChild(R);let w=document.createElement("li");w.textContent="Try again in a few moments",c.appendChild(w);let P=document.createElement("li");return P.textContent="The service may be undergoing maintenance",c.appendChild(P),a.appendChild(c),a;default:if(n>=400&&n<500){l.textContent="Client Error",a.appendChild(l);let $=document.createElement("li");$.textContent="There's an issue with the request",c.appendChild($);let fe=document.createElement("li");return fe.textContent="Check the error message below for details",c.appendChild(fe),a.appendChild(c),a}return null}}async draw(){let n=document.createElement("div");n.className="errorResult",this.yasr.resultsEl.appendChild(n);let a=this.yasr.results?.getError();if(!a)return;let l=document.createElement("div");l.className="errorHeader",n.appendChild(l);let c=await this.yasr.renderError(a);if(c){let g=document.createElement("div");g.className="redOutline",g.appendChild(c),n.appendChild(g);return}if(a.status){var p="Error";a.statusText&&a.statusText.length<100&&(p=a.statusText),p+=` (#${a.status})`;let g=document.createElement("span");if(g.className="status",g.textContent=p,l.appendChild(g),this.yasr.config.getPlainQueryLinkToEndpoint){let T=this.yasr.config.getPlainQueryLinkToEndpoint();T&&l.appendChild(this.getTryBtn(T))}let y=this.getStatusSpecificGuidance(a.status);if(y&&n.appendChild(y),a.text){let T=document.createElement("div");Qe(T,"errorMessageContainer"),n.appendChild(T);let U=document.createElement("pre");Qe(U,"errorMessage"),U.textContent=a.text,T.appendChild(U)}}else{if(this.yasr.config.getPlainQueryLinkToEndpoint){let y=this.yasr.config.getPlainQueryLinkToEndpoint();y&&l.appendChild(this.getTryBtn(y))}if(!a.text||a.text.indexOf("Request has been terminated")>=0||a.text.indexOf("Failed to fetch")>=0||a.text.indexOf("NetworkError")>=0||a.text.indexOf("Network request failed")>=0)n.appendChild(this.getCorsMessage());else{let y=document.createElement("pre");y.textContent=a.text,n.appendChild(y)}}}getIcon(){return document.createElement("")}};var ar=class ar extends mm.EventEmitter{constructor(a,l={},c){super();this.plugins={};this.helpDrawn=!1;this.isFullscreen=!1;this.isLoading=!1;this.utils={addScript:Ms,addCSS:ks,sanitize:wu};if(!a)throw new Error("No parent passed as argument. Dont know where to draw YASR");this.rootEl=document.createElement("div"),this.rootEl.className="yasr",a.appendChild(this.rootEl),this.config=Ol({},ar.defaults,l),this.storage=new ri(ar.storageNamespace),this.getConfigFromStorage(),this.headerEl=document.createElement("div"),this.headerEl.className="yasr_header",this.rootEl.appendChild(this.headerEl),this.fallbackInfoEl=document.createElement("div"),this.fallbackInfoEl.className="yasr_fallback_info",this.rootEl.appendChild(this.fallbackInfoEl),this.resultsEl=document.createElement("div"),this.resultsEl.className="yasr_results",this.resultsEl.id=Dl("resultsId"),this.rootEl.appendChild(this.resultsEl),this.createLoadingElement(),this.initializePlugins(),this.drawHeader();let p=c||this.getResponseFromStorage();p&&this.setResponse(p)}getConfigFromStorage(){let a=this.getStorageId(this.config.persistenceLabelConfig);if(a){let l=this.storage.get(a);if(l){this.selectedPlugin=l.selectedPlugin;for(let c in l.pluginsConfig){let p=l.pluginsConfig[c];p&&this.config.plugins[c]&&(this.config.plugins[c].dynamicConfig=p)}}}}async renderError(a){let l;if(this.config.errorRenderers!==void 0){for(let c of this.config.errorRenderers)if(l=await c(a),l!==void 0)break}return l}getStorageId(a,l){let c=l||this.config.persistenceId;if(c)return typeof c=="string"?c+"_"+a:c(this)+"_"+a}somethingDrawn(){return!!this.resultsEl.children.length}emptyFallbackElement(){for(;this.fallbackInfoEl.firstChild;)this.fallbackInfoEl.removeChild(this.fallbackInfoEl.firstChild)}getSelectedPluginName(){return this.selectedPlugin||this.config.defaultPlugin}getSelectedPlugin(){if(this.plugins[this.getSelectedPluginName()])return this.plugins[this.getSelectedPluginName()];console.warn(`Tried using plugin ${this.getSelectedPluginName()}, but seems this plugin isnt registered in yasr.`)}updatePluginSelectors(a){if(this.pluginSelectorsEl)for(let l in this.config.plugins){let c=this.plugins[l];c&&!c.hideFromSelection&&(a&&(a.indexOf(l)>=0?hn(this.pluginSelectorsEl.querySelector(".select_"+l),"disabled"):Qe(this.pluginSelectorsEl.querySelector(".select_"+l),"disabled")),l===this.getSelectedPluginName()?Qe(this.pluginSelectorsEl.querySelector(".select_"+l),"selected"):hn(this.pluginSelectorsEl.querySelector(".select_"+l),"selected"))}}getCompatiblePlugins(){if(!this.results)return Object.keys(Gl(this.config.plugins,l=>typeof l=="object"&&l.enabled||l===!0));let a=[];for(let l in this.plugins)this.plugins[l].canHandleResults()&&a.push({name:l,priority:this.plugins[l].priority});return a.sort((l,c)=>c.priority-l.priority).map(l=>l.name)}draw(){if(this.updateHelpButton(),this.updateResponseInfo(),!this.results)return;let a=this.getCompatiblePlugins();if(this.drawnPlugin&&this.getSelectedPluginName()!==this.drawnPlugin){for(;this.pluginControls.firstChild;)this.pluginControls.firstChild.remove();this.plugins[this.drawnPlugin].destroy?.()}let l;if(this.getSelectedPlugin()&&this.getSelectedPlugin()?.canHandleResults()?(l=this.getSelectedPluginName(),this.emptyFallbackElement()):a[0]&&(this.drawnPlugin&&this.plugins[this.drawnPlugin].destroy?.(),l=a[0],this.fillFallbackBox(l)),l){this.drawnPlugin=l,this.emit("draw",this,this.plugins[l]);let c=this.plugins[l];(c.initialize?c.initialize():Promise.resolve()).then(async()=>{if(l){for(;this.resultsEl.firstChild;)this.resultsEl.firstChild.remove();await this.plugins[l].draw(this.config.plugins[l].dynamicConfig),this.emit("drawn",this,this.plugins[l]),this.updateExportHeaders(),this.updatePluginSelectors(a)}},g=>console.error)}else this.resultsEl.textContent="cannot render result",this.updateExportHeaders(),this.updatePluginSelectors(a)}refresh(){this.draw()}destroy(){this.drawnPlugin&&this.plugins[this.drawnPlugin]?.destroy?.(),this.removeAllListeners(),this.rootEl.remove()}getPrefixes(){return this.config.prefixes?typeof this.config.prefixes=="function"?this.config.prefixes(this):this.config.prefixes:{}}selectPlugin(a){this.selectedPlugin!==a&&(this.config.plugins[a]?this.selectedPlugin=a:(console.warn(`Plugin ${a} does not exist.`),this.selectedPlugin=this.config.defaultPlugin),this.storeConfig(),this.emit("change",this),this.updatePluginSelectors(),this.draw())}drawPluginSelectors(){this.pluginSelectorsEl=document.createElement("ul"),this.pluginSelectorsEl.className="yasr_btnGroup";let a=this.config.pluginOrder;Object.keys(this.config.plugins).sort().forEach(l=>{a.indexOf(l)===-1&&a.push(l)});for(let l of a){if(!this.config.plugins[l]||!this.config.plugins[l].enabled)continue;let c=this.plugins[l];if(!c||c.hideFromSelection)continue;let p=c.label||l,g=document.createElement("button");if(Qe(g,"yasr_btn","select_"+l),g.title=p,g.type="button",g.setAttribute("aria-label",`Shows ${p} view`),c.getIcon){let U=c.getIcon();U&&(Qe(U,"plugin_icon"),g.appendChild(U))}let y=document.createElement("span");y.textContent=p,g.appendChild(y),g.addEventListener("click",()=>this.selectPlugin(l));let T=document.createElement("li");T.appendChild(g),this.pluginSelectorsEl.appendChild(T)}this.pluginSelectorsEl.children.length>=1&&this.headerEl.appendChild(this.pluginSelectorsEl),this.updatePluginSelectors()}fillFallbackBox(a){if(this.emptyFallbackElement(),this.plugins[a||this.drawnPlugin||""]?.hideFromSelection)return;let l=this.getSelectedPlugin(),c=this.plugins[a||this.drawnPlugin||""]?.label||a||this.drawnPlugin,p=l?.label||this.getSelectedPluginName(),g=document.createElement("p");if(g.innerText=`Could not render results with the ${p} plugin, the results currently are rendered with the ${c} plugin. ${this.getSelectedPlugin()?.helpReference?"See ":""}`,l?.helpReference){let y=document.createElement("a");y.innerText=`${p} documentation`,y.href=l.helpReference,y.rel="noopener noreferrer",y.target="_blank",g.append(y),g.innerHTML+=" for more information."}this.fallbackInfoEl.appendChild(g)}drawPluginElement(){let a=document.createElement("div");Qe(a,"space_element"),this.headerEl.appendChild(a),this.pluginControls=document.createElement("div"),this.pluginControls.setAttribute("id","yasr_plugin_control"),Qe(this.pluginControls,"yasr_plugin_control"),this.pluginControls.setAttribute("aria-controls",this.resultsEl.id),this.headerEl.appendChild(this.pluginControls)}drawHeader(){this.drawPluginSelectors(),this.drawResponseInfo(),this.drawPluginElement(),this.drawDownloadIcon(),this.drawFullscreenButton(),this.loadingEl&&this.headerEl.appendChild(this.loadingEl),this.drawDocumentationButton()}drawDownloadIcon(){this.downloadBtn=document.createElement("a"),Qe(this.downloadBtn,"yasr_btn","yasr_downloadIcon","btn_icon"),this.downloadBtn.download="",this.downloadBtn.setAttribute("aria-label","Download Results"),this.downloadBtn.setAttribute("tabindex","0"),this.downloadBtn.setAttribute("role","button");let a=document.createElement("i");Qe(a,"fas","fa-download"),a.setAttribute("aria-hidden","true"),this.downloadBtn.appendChild(a),this.downloadBtn.addEventListener("click",()=>{Xo(this.downloadBtn,"disabled")||this.download()}),this.downloadBtn.addEventListener("keydown",l=>{if(l.code==="Space"||l.code==="Enter"){if(Xo(this.downloadBtn,"disabled"))return;this.download()}}),this.headerEl.appendChild(this.downloadBtn)}drawResponseInfo(){this.dataElement=document.createElement("div"),Qe(this.dataElement,"yasr_response_chip"),this.headerEl.appendChild(this.dataElement),this.updateResponseInfo()}updateResponseInfo(){let a="";if(this.results){hn(this.dataElement,"empty");let l=this.results.getBindings();l&&(a+=`${l.length} result${l.length===1?"":"s"}`);let c=this.results.getResponseTime();if(c){a||(a="Response");let p=c/1e3;a+=` in ${p} second${p===1?"":"s"}`}}else Qe(this.dataElement,"empty");this.dataElement.innerText=a}updateHelpButton(){let a=this.getSelectedPlugin();if(a?.helpReference){let l=`View documentation of ${a.label||this.getSelectedPluginName()}`;this.documentationLink.href=a.helpReference,this.documentationLink.title=l,this.documentationLink.setAttribute("aria-label",l),hn(this.documentationLink,"disabled")}else Qe(this.documentationLink,"disabled"),this.documentationLink.title="This plugin doesn't have a help reference yet. Please contact the maintainer to fix this"}updateExportHeaders(){if(this.downloadBtn&&this.drawnPlugin){this.downloadBtn.title="";let a=this.plugins[this.drawnPlugin];if(a&&a.download){let l=a.download(this.config.getDownloadFileName?.());if(hn(this.downloadBtn,"disabled"),l){l.title&&(this.downloadBtn.title=l.title);return}}this.downloadBtn.title="Download not supported",Qe(this.downloadBtn,"disabled")}}drawFullscreenButton(){this.fullscreenBtn=document.createElement("button"),Qe(this.fullscreenBtn,"yasr_btn","yasr_fullscreenButton","btn_icon"),this.fullscreenBtn.setAttribute("aria-label","Toggle fullscreen"),this.fullscreenBtn.setAttribute("tabindex","0"),this.fullscreenBtn.setAttribute("role","button");let a=document.createElement("i");Qe(a,"fas"),Qe(a,"fa-expand"),Qe(a,"fullscreenIcon"),a.setAttribute("aria-hidden","true"),this.fullscreenBtn.appendChild(a);let l=document.createElement("i");Qe(l,"fas"),Qe(l,"fa-compress"),Qe(l,"fullscreenExitIcon"),l.setAttribute("aria-hidden","true"),this.fullscreenBtn.appendChild(l),this.fullscreenBtn.title="Toggle fullscreen (F10)",this.fullscreenBtn.addEventListener("click",()=>{this.toggleFullscreen()}),this.fullscreenBtn.addEventListener("keydown",c=>{(c.code==="Space"||c.code==="Enter")&&this.toggleFullscreen()}),this.headerEl.appendChild(this.fullscreenBtn)}toggleFullscreen(){this.isFullscreen=!this.isFullscreen,this.isFullscreen?(Qe(this.rootEl,"fullscreen"),this.fullscreenBtn&&(this.fullscreenBtn.title="Exit fullscreen (F10)")):(hn(this.rootEl,"fullscreen"),this.fullscreenBtn&&(this.fullscreenBtn.title="Toggle fullscreen (F10)"))}getIsFullscreen(){return this.isFullscreen}createLoadingElement(){this.loadingEl=document.createElement("div"),this.loadingEl.className="yasr_loading_indicator",this.loadingEl.title="Executing query...",this.loadingEl.innerHTML='<div class="yasr_loading_spinner"></div>',this.loadingEl.style.display="none"}showLoading(){this.isLoading=!0,this.loadingEl&&(this.loadingEl.style.display="flex")}hideLoading(){this.isLoading=!1,this.loadingEl&&(this.loadingEl.style.display="none")}drawDocumentationButton(){this.documentationLink=document.createElement("a"),Qe(this.documentationLink,"yasr_btn","yasr_external_ref_btn");let a=document.createElement("i");Qe(a,"fas","fa-circle-question"),this.documentationLink.appendChild(a),this.documentationLink.href="https://yasgui-doc.matdata.eu/docs/user-guide",this.documentationLink.target="_blank",this.documentationLink.rel="noopener noreferrer",this.headerEl.appendChild(this.documentationLink)}download(){if(!this.drawnPlugin)return;let a=this.plugins[this.drawnPlugin];if(a&&a.download){let l=a.download(this.config.getDownloadFileName?.());if(!l)return;let c=l.getData(),p;if(c.startsWith("data:"))p=c;else{let y=new Blob([c],{type:l.contentType??"text/plain"});p=window.URL.createObjectURL(y)}let g=document.createElement("a");g.href=p,g.download=l.filename,g.click()}}handleLocalStorageQuotaFull(a){console.warn("Localstorage quota exceeded. Clearing all queries"),ar.clearStorage()}getResponseFromStorage(){if(this.config.maxPersistentResponseSize<=0){let l=this.getStorageId(this.config.persistenceLabelResponse);l&&this.storage.remove(l);return}let a=this.getStorageId(this.config.persistenceLabelResponse);if(a)return this.storage.get(a)}getPersistentConfig(){return{selectedPlugin:this.getSelectedPluginName(),pluginsConfig:Mo(this.config.plugins,a=>a.dynamicConfig)}}storePluginConfig(a,l){this.config.plugins[a].dynamicConfig=l,this.storeConfig(),this.emit("change",this)}storeConfig(){let a=this.getStorageId(this.config.persistenceLabelConfig);a&&this.storage.set(a,this.getPersistentConfig(),this.config.persistencyExpire,this.handleLocalStorageQuotaFull)}storeResponse(){let a=this.getStorageId(this.config.persistenceLabelResponse);if(a&&this.config.maxPersistentResponseSize<=0){this.storage.remove(a);return}if(a&&this.results){let l=this.results.getAsStoreObject(this.config.maxPersistentResponseSize);l&&!l.error?this.storage.set(a,l,this.config.persistencyExpire,this.handleLocalStorageQuotaFull):this.storage.remove(a)}}setResponse(a,l){a&&(this.hideLoading(),this.results=new Us(a,l),this.draw(),this.storeResponse())}executeQuery(a,l){return this.config.executeQuery?this.config.executeQuery(a,l):Promise.reject(new Error("No executeQuery handler configured on this Yasr instance"))}initializePlugins(){for(let a in this.config.plugins)this.config.plugins[a]&&(ar.plugins[a]?this.plugins[a]=new ar.plugins[a](this):console.warn("Wanted to initialize plugin "+a+" but could not find a matching registered plugin"))}static registerPlugin(a,l,c=!0){ar.plugins[a]=l,c?ar.defaults.plugins[a]={enabled:!0}:ar.defaults.plugins[a]={enabled:!1}}static clearStorage(){new ri(ar.storageNamespace).removeNamespace()}};ar.defaults=Zl(),ar.plugins={},ar.Dependencies={},ar.storageNamespace="triply";var $r=ar;function CR(r,n,a=!0){$r.plugins[r]=n,a?$r.defaults.plugins[r]={enabled:!0}:$r.defaults.plugins[r]={enabled:!1}}$r.registerPlugin("boolean",ra);$r.registerPlugin("response",na);$r.registerPlugin("error",ia);var AR=$r;return Ib(RR);})();
48
48
  /*! Bundled license information:
49
49
 
50
50
  ieee754/index.js: