@semapps/semantic-data-provider 0.4.3 → 0.4.4
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/dist/index.cjs.js +1 -3
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.es.js +1 -3
- package/dist/index.es.js.map +1 -1
- package/package.json +2 -2
package/dist/index.cjs.js
CHANGED
|
@@ -1,4 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("jsonld"),t=require("speakingurl"),r=require("@rdfjs/data-model"),n=require("crypto"),a=require("react-admin"),o=require("react"),i=require("@material-ui/core/styles");function s(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var u=s(e),c=s(t),l=s(r),f=s(n),p=s(o);function d(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function h(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?d(Object(r),!0).forEach((function(t){m(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):d(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function v(){
|
|
2
|
-
/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */
|
|
3
|
-
v=function(){return e};var e={},t=Object.prototype,r=t.hasOwnProperty,n="function"==typeof Symbol?Symbol:{},a=n.iterator||"@@iterator",o=n.asyncIterator||"@@asyncIterator",i=n.toStringTag||"@@toStringTag";function s(e,t,r){return Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{s({},"")}catch(e){s=function(e,t,r){return e[t]=r}}function u(e,t,r,n){var a=t&&t.prototype instanceof f?t:f,o=Object.create(a.prototype),i=new j(n||[]);return o._invoke=function(e,t,r){var n="suspendedStart";return function(a,o){if("executing"===n)throw new Error("Generator is already running");if("completed"===n){if("throw"===a)throw o;return E()}for(r.method=a,r.arg=o;;){var i=r.delegate;if(i){var s=x(i,r);if(s){if(s===l)continue;return s}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if("suspendedStart"===n)throw n="completed",r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);n="executing";var u=c(e,t,r);if("normal"===u.type){if(n=r.done?"completed":"suspendedYield",u.arg===l)continue;return{value:u.arg,done:r.done}}"throw"===u.type&&(n="completed",r.method="throw",r.arg=u.arg)}}}(e,r,i),o}function c(e,t,r){try{return{type:"normal",arg:e.call(t,r)}}catch(e){return{type:"throw",arg:e}}}e.wrap=u;var l={};function f(){}function p(){}function d(){}var h={};s(h,a,(function(){return this}));var y=Object.getPrototypeOf,g=y&&y(y(O([])));g&&g!==t&&r.call(g,a)&&(h=g);var b=d.prototype=f.prototype=Object.create(h);function m(e){["next","throw","return"].forEach((function(t){s(e,t,(function(e){return this._invoke(t,e)}))}))}function w(e,t){var n;this._invoke=function(a,o){function i(){return new t((function(n,i){!function n(a,o,i,s){var u=c(e[a],e,o);if("throw"!==u.type){var l=u.arg,f=l.value;return f&&"object"==typeof f&&r.call(f,"__await")?t.resolve(f.__await).then((function(e){n("next",e,i,s)}),(function(e){n("throw",e,i,s)})):t.resolve(f).then((function(e){l.value=e,i(l)}),(function(e){return n("throw",e,i,s)}))}s(u.arg)}(a,o,n,i)}))}return n=n?n.then(i,i):i()}}function x(e,t){var r=e.iterator[t.method];if(void 0===r){if(t.delegate=null,"throw"===t.method){if(e.iterator.return&&(t.method="return",t.arg=void 0,x(e,t),"throw"===t.method))return l;t.method="throw",t.arg=new TypeError("The iterator does not provide a 'throw' method")}return l}var n=c(r,e.iterator,t.arg);if("throw"===n.type)return t.method="throw",t.arg=n.arg,t.delegate=null,l;var a=n.arg;return a?a.done?(t[e.resultName]=a.value,t.next=e.nextLoc,"return"!==t.method&&(t.method="next",t.arg=void 0),t.delegate=null,l):a:(t.method="throw",t.arg=new TypeError("iterator result is not an object"),t.delegate=null,l)}function k(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function S(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function j(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(k,this),this.reset(!0)}function O(e){if(e){var t=e[a];if(t)return t.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var n=-1,o=function t(){for(;++n<e.length;)if(r.call(e,n))return t.value=e[n],t.done=!1,t;return t.value=void 0,t.done=!0,t};return o.next=o}}return{next:E}}function E(){return{value:void 0,done:!0}}return p.prototype=d,s(b,"constructor",d),s(d,"constructor",p),p.displayName=s(d,i,"GeneratorFunction"),e.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===p||"GeneratorFunction"===(t.displayName||t.name))},e.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,d):(e.__proto__=d,s(e,i,"GeneratorFunction")),e.prototype=Object.create(b),e},e.awrap=function(e){return{__await:e}},m(w.prototype),s(w.prototype,o,(function(){return this})),e.AsyncIterator=w,e.async=function(t,r,n,a,o){void 0===o&&(o=Promise);var i=new w(u(t,r,n,a),o);return e.isGeneratorFunction(r)?i:i.next().then((function(e){return e.done?e.value:i.next()}))},m(b),s(b,i,"Generator"),s(b,a,(function(){return this})),s(b,"toString",(function(){return"[object Generator]"})),e.keys=function(e){var t=[];for(var r in e)t.push(r);return t.reverse(),function r(){for(;t.length;){var n=t.pop();if(n in e)return r.value=n,r.done=!1,r}return r.done=!0,r}},e.values=O,j.prototype={constructor:j,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(S),!e)for(var t in this)"t"===t.charAt(0)&&r.call(this,t)&&!isNaN(+t.slice(1))&&(this[t]=void 0)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var t=this;function n(r,n){return i.type="throw",i.arg=e,t.next=r,n&&(t.method="next",t.arg=void 0),!!n}for(var a=this.tryEntries.length-1;a>=0;--a){var o=this.tryEntries[a],i=o.completion;if("root"===o.tryLoc)return n("end");if(o.tryLoc<=this.prev){var s=r.call(o,"catchLoc"),u=r.call(o,"finallyLoc");if(s&&u){if(this.prev<o.catchLoc)return n(o.catchLoc,!0);if(this.prev<o.finallyLoc)return n(o.finallyLoc)}else if(s){if(this.prev<o.catchLoc)return n(o.catchLoc,!0)}else{if(!u)throw new Error("try statement without catch or finally");if(this.prev<o.finallyLoc)return n(o.finallyLoc)}}}},abrupt:function(e,t){for(var n=this.tryEntries.length-1;n>=0;--n){var a=this.tryEntries[n];if(a.tryLoc<=this.prev&&r.call(a,"finallyLoc")&&this.prev<a.finallyLoc){var o=a;break}}o&&("break"===e||"continue"===e)&&o.tryLoc<=t&&t<=o.finallyLoc&&(o=null);var i=o?o.completion:{};return i.type=e,i.arg=t,o?(this.method="next",this.next=o.finallyLoc,l):this.complete(i)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),l},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.finallyLoc===e)return this.complete(r.completion,r.afterLoc),S(r),l}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.tryLoc===e){var n=r.completion;if("throw"===n.type){var a=n.arg;S(r)}return a}}throw new Error("illegal catch attempt")},delegateYield:function(e,t,r){return this.delegate={iterator:O(e),resultName:t,nextLoc:r},"next"===this.method&&(this.arg=void 0),l}},e}function y(e){return(y="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function g(e,t,r,n,a,o,i){try{var s=e[o](i),u=s.value}catch(e){return void r(e)}s.done?t(u):Promise.resolve(u).then(n,a)}function b(e){return function(){var t=this,r=arguments;return new Promise((function(n,a){var o=e.apply(t,r);function i(e){g(o,n,a,i,s,"next",e)}function s(e){g(o,n,a,i,s,"throw",e)}i(void 0)}))}}function m(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function w(){return(w=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e}).apply(this,arguments)}function x(e,t){if(null==e)return{};var r,n,a=function(e,t){if(null==e)return{};var r,n,a={},o=Object.keys(e);for(n=0;n<o.length;n++)r=o[n],t.indexOf(r)>=0||(a[r]=e[r]);return a}(e,t);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);for(n=0;n<o.length;n++)r=o[n],t.indexOf(r)>=0||Object.prototype.propertyIsEnumerable.call(e,r)&&(a[r]=e[r])}return a}function k(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var r=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null==r)return;var n,a,o=[],i=!0,s=!1;try{for(r=r.call(e);!(i=(n=r.next()).done)&&(o.push(n.value),!t||o.length!==t);i=!0);}catch(e){s=!0,a=e}finally{try{i||null==r.return||r.return()}finally{if(s)throw a}}return o}(e,t)||j(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function S(e){return function(e){if(Array.isArray(e))return O(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||j(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function j(e,t){if(e){if("string"==typeof e)return O(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?O(e,t):void 0}}function O(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}function E(e,t){var r="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!r){if(Array.isArray(e)||(r=j(e))||t&&e&&"number"==typeof e.length){r&&(e=r);var n=0,a=function(){};return{s:a,n:function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}},e:function(e){throw e},f:a}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,i=!0,s=!1;return{s:function(){r=r.call(e)},n:function(){var e=r.next();return i=e.done,e},e:function(e){s=!0,o=e},f:function(){try{i||null==r.return||r.return()}finally{if(s)throw o}}}}var C="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function A(e,t){return e(t={exports:{}},t.exports),t.exports}var P=A((function(e){var t,r;t=C,r=function(){function e(e){var t=[];if(0===e.length)return"";if("string"!=typeof e[0])throw new TypeError("Url must be a string. Received "+e[0]);if(e[0].match(/^[^/:]+:\/*$/)&&e.length>1){var r=e.shift();e[0]=r+e[0]}e[0].match(/^file:\/\/\//)?e[0]=e[0].replace(/^([^/:]+):\/*/,"$1:///"):e[0]=e[0].replace(/^([^/:]+):\/*/,"$1://");for(var n=0;n<e.length;n++){var a=e[n];if("string"!=typeof a)throw new TypeError("Url must be a string. Received "+a);""!==a&&(n>0&&(a=a.replace(/^[\/]+/,"")),a=n<e.length-1?a.replace(/[\/]+$/,""):a.replace(/[\/]+$/,"/"),t.push(a))}var o=t.join("/"),i=(o=o.replace(/\/(\?|&|#[^!])/g,"$1")).split("?");return o=i.shift()+(i.length>0?"?":"")+i.join("&")}return function(){return e("object"==typeof arguments[0]?arguments[0]:[].slice.call(arguments))}},e.exports?e.exports=r():t.urljoin=r()})),_=function(){var e=b(v().mark((function e(t,r){var n,a,o,i;return v().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=r.httpClient,a=r.jsonContext,e.next=3,n(t);case 3:if(o=e.sent,(i=o.json).id=i.id||i["@id"],i["@context"]===a){e.next=10;break}return e.next=9,u.default.compact(i,a);case 9:i=e.sent;case 10:return e.abrupt("return",i);case 11:case"end":return e.stop()}}),e)})));return function(t,r){return e.apply(this,arguments)}}(),L=function(e){return function(){var t=b(v().mark((function t(r,n){var a,o,i,s,u,c,l,f;return v().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(o=e.resources,i=o[r]){t.next=4;break}throw new Error("Resource ".concat(r," is not mapped in resources file"));case 4:return t.next=6,_(n.id,e);case 6:if(s=t.sent,null!==(a=i.list)&&void 0!==a&&a.forceArray){c=E(null===(u=i.list)||void 0===u?void 0:u.forceArray);try{for(c.s();!(l=c.n()).done;)f=l.value,s[f]&&!Array.isArray(s[f])&&(s[f]=[s[f]])}catch(e){c.e(e)}finally{c.f()}}return t.abrupt("return",{data:s});case 9:case"end":return t.stop()}}),t)})));return function(e,r){return t.apply(this,arguments)}}()},N=function(e){return e&&e.rawFile&&e.rawFile instanceof File},T=function(e){var t=Object.keys(e.dataServers).find((function(t){return e.dataServers[t].uploadsContainer}));if(t)return P(e.dataServers[t].baseUrl,e.dataServers[t].uploadsContainer)},q=function(){var e=b(v().mark((function e(t,r){var n,a;return v().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n=T(r)){e.next=3;break}throw new Error("You must define an uploadsContainer in one of the server's configuration");case 3:return console.log("upload raw file",y(t),t),e.next=6,r.httpClient(n,{method:"POST",body:t,headers:new Headers({Slug:(o=t.name,i=void 0,s=void 0,i="",s=o.split("."),s.length>1&&(i=s.pop(),o=s.join(".")),c.default(o,{lang:"fr"})+"."+i),"Content-Type":t.type})});case 6:if(201!==(a=e.sent).status){e.next=9;break}return e.abrupt("return",a.headers.get("Location"));case 9:case"end":return e.stop()}var o,i,s}),e)})));return function(t,r){return e.apply(this,arguments)}}(),U=function(){var e=b(v().mark((function e(t,r){var n,a;return v().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:e.t0=v().keys(t);case 1:if((e.t1=e.t0()).done){e.next=22;break}if(n=e.t1.value,!t.hasOwnProperty(n)){e.next=20;break}if(!Array.isArray(t[n])){e.next=16;break}a=0;case 6:if(!(a<t[n].length)){e.next=14;break}if(!N(t[n][a])){e.next=11;break}return e.next=10,q(t[n][a].rawFile,r);case 10:t[n][a]=e.sent;case 11:a++,e.next=6;break;case 14:e.next=20;break;case 16:if(!N(t[n])){e.next=20;break}return e.next=19,q(t[n].rawFile,r);case 19:t[n]=e.sent;case 20:e.next=1;break;case 22:return e.abrupt("return",t);case 23:case"end":return e.stop()}}),e)})));return function(t,r){return e.apply(this,arguments)}}(),I=function(e,t){return Object.keys(t).find((function(r){return t[r][e]}))},D=function(e,t){switch(e){case"@default":return I("default",t);case"@pod":return I("pod",t);case"@authServer":return I("authServer",t);default:return e}},M=function(e,t,r){var n={},a=[];return t=function(e,t){if(Array.isArray(e))return e.includes("@all")?Object.keys(t):e.map((function(e){return D(e,t)}));if("string"==typeof e){if("@all"===e)return Object.keys(t);if("@remote"===e){var r=I("default",t);return Object.keys(t).filter((function(e){return e!==r}))}return[D(e,t)]}return!1}(t,r),Object.keys(r).forEach((function(o){Object.keys(r[o].containers).forEach((function(i){t&&!t.includes(i)||Object.keys(r[o].containers[i]).forEach((function(t){e.includes(t)&&r[o].containers[i][t].map((function(e){var t=P(r[i].baseUrl,e);a.includes(t)||(a.push(t),n[o]||(n[o]=[]),n[o].push(t))}))}))}))})),n},B=function(e){return function(){var t=b(v().mark((function t(r,n){var a,o,i,s,u,c,l,f,p,d,y,g,b,m,w,x;return v().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(o=e.dataServers,i=e.resources,s=e.httpClient,u=e.jsonContext,c=i[r],l=new Headers,null===(a=c.create)||void 0===a||!a.container){t.next=9;break}p=Object.keys(c.create.container)[0],f=P(o[p].baseUrl,Object.values(c.create.container)[0]),t.next=19;break;case 9:if(p=(null===(d=c.create)||void 0===d?void 0:d.server)||Object.keys(o).find((function(e){return!0===o[e].default}))){t.next=12;break}throw new Error("You must define a server for the creation, or a container, or a default server");case 12:if(y=M(c.types,[p],o),(g=Object.keys(y))&&0!==g.length){t.next=16;break}throw new Error("No container with types ".concat(JSON.stringify(c.types)," found on server ").concat(p));case 16:if(!(g.length>1||y[g[0]].length>1)){t.next=18;break}throw new Error("More than one container detected with types ".concat(JSON.stringify(c.types)," on server ").concat(p));case 18:f=y[g[0]][0];case 19:if(!n.data){t.next=34;break}return null!==(b=c.fieldsMapping)&&void 0!==b&&b.title&&(Array.isArray(c.fieldsMapping.title)?l.set("Slug",c.fieldsMapping.title.map((function(e){return n.data[e]})).join(" ")):l.set("Slug",n.data[c.fieldsMapping.title])),t.next=23,U(n.data,e);case 23:return n.data=t.sent,t.next=26,s(f,{method:"POST",headers:l,body:JSON.stringify(h({"@context":u,"@type":c.types},n.data))});case 26:return m=t.sent,w=m.headers,x=w.get("Location"),t.next=31,L(e)(r,{id:x});case 31:return t.abrupt("return",t.sent);case 34:if(!n.id){t.next=41;break}return l.set("Content-Type","application/sparql-update"),t.next=38,s(f,{method:"PATCH",headers:l,body:"\n PREFIX ldp: <http://www.w3.org/ns/ldp#>\n INSERT DATA { <".concat(f,"> ldp:contains <").concat(n.id,">. };\n ")});case 38:return t.next=40,L(e)(r,{id:n.id});case 40:return t.abrupt("return",t.sent);case 41:case"end":return t.stop()}}),t)})));return function(e,r){return t.apply(this,arguments)}}()},R=function(e){return function(){var t=b(v().mark((function t(r,n){var a;return v().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return a=e.httpClient,t.next=3,a(n.id,{method:"DELETE"});case 3:return t.abrupt("return",{data:{id:n.id}});case 4:case"end":return t.stop()}}),t)})));return function(e,r){return t.apply(this,arguments)}}()},F=function(e){return function(){var t=b(v().mark((function t(r,n){var a,o,i,s,u;return v().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:a=e.httpClient,o=[],i=E(n.ids),t.prev=3,i.s();case 5:if((s=i.n()).done){t.next=17;break}return u=s.value,t.prev=7,t.next=10,a(u,{method:"DELETE"});case 10:o.push(u),t.next=15;break;case 13:t.prev=13,t.t0=t.catch(7);case 15:t.next=5;break;case 17:t.next=22;break;case 19:t.prev=19,t.t1=t.catch(3),i.e(t.t1);case 22:return t.prev=22,i.f(),t.finish(22);case 25:return t.abrupt("return",{data:o});case 26:case"end":return t.stop()}}),t,null,[[3,19,22,25],[7,13]])})));return function(e,r){return t.apply(this,arguments)}}()},H=function(e){return function(){return e.dataServers}},W=function(e){return function(){return e.resources}};var G=function(){var e=b(v().mark((function e(t,r,n,a){var o,i,s,c,l,f,p;return v().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return o=a.httpClient,i=a.jsonContext,s=Object.keys(t).reduce((function(e,r){return h(h({},e),Object.fromEntries(t[r].map((function(e){return[e,r]}))))}),{}),c=Object.keys(s).map((function(e){return o(e).then((function(e){var t=e.json;return t["@context"]!==i?u.default.compact(t,i):t})).then((function(t){if(r="ldp:Container",a=(n=t).type||n["@type"],Array.isArray(a)?a.includes(r):a===r)return t["ldp:contains"];throw new Error(e+" is not a LDP container");var r,n,a}))})),e.next=5,Promise.all(c);case 5:if(0!==(l=e.sent).length){e.next=10;break}return e.abrupt("return",{data:[],total:0});case 10:return l=(f=[].concat).apply.apply(f,S(l)),p=l.map((function(e){return e.id=e.id||e["@id"],e})),n.filter&&(n.filter.a&&(n.filter.type=n.filter.a,delete n.filter.a),Object.keys(n.filter).length>0&&(p=p.filter((function(e){return Object.entries(n.filter).some((function(t){var r=k(t,2),n=r[0],a=r[1];return"q"==n?Object.entries(e).some((function(e){var t=k(e,2);t[0];var r,n=t[1];return(null==(r=n)||"object"!=typeof r||!1!==Array.isArray(r))&&(Array.isArray(n)?n.some((function(e){return e.includes(a)})):n.includes(a))})):(Array.isArray(e[n]),e[n].includes(a))}))})))),n.sort&&(p=p.sort((function(e,t){return!e[n.sort.field]||!t[n.sort.field]||("ASC"===n.sort.order?e[n.sort.field].localeCompare(t[n.sort.field]):t[n.sort.field].localeCompare(e[n.sort.field]))}))),n.pagination&&(p=p.slice((n.pagination.page-1)*n.pagination.perPage,n.pagination.page*n.pagination.perPage)),e.abrupt("return",{data:p,total:l.length});case 16:case"end":return e.stop()}}),e)})));return function(t,r,n,a){return e.apply(this,arguments)}}(),z=function(e){var t,r={};if(e){var n,a=E(e);try{for(a.s();!(n=a.n()).done;){var o=n.value;t=o.includes("/")?o.split("/").reverse():[o],r=h(h({},r),t.reduce((function(e,t){return m({},t,h({"@embed":"@last"},e))}),{}))}}catch(e){a.e(e)}finally{a.f()}return r}},J=function(e,t){if(e.startsWith("http://")||e.startsWith("https://"))return e;if("a"===e)return"http://www.w3.org/1999/02/22-rdf-syntax-ns#type";var r=k(e.split(":"),2),n=r[0],a=r[1];if(a){var o=t.find((function(e){return e.prefix===n}));if(o)return o.url+a;throw new Error("No ontology found with prefix "+n)}throw new Error('The value "'.concat(e,'" is not correct. It must include a prefix or be a full URI.'))},$=r.triple(r.variable("s1"),r.namedNode("http://www.w3.org/1999/02/22-rdf-syntax-ns#type"),r.variable("type")),Y=function(e,t){var n,a;return e?(n=(a=e,a?Array.isArray(a)?a:[a]:[]).map((function(e,n){return r.triple(r.variable("s1"),r.namedNode(J(e,t)),r.variable("o"+(n+1)))})),{construct:[$].concat(S(n)),where:[$].concat(S(n.map((function(e){return{type:"optional",patterns:[e]}}))))}):{construct:n=[r.triple(r.variable("s1"),r.variable("p1"),r.variable("o1"))],where:n}},Q=A((function(e,t){var r;e.exports=r=r||function(e,t){var r;if("undefined"!=typeof window&&window.crypto&&(r=window.crypto),"undefined"!=typeof self&&self.crypto&&(r=self.crypto),"undefined"!=typeof globalThis&&globalThis.crypto&&(r=globalThis.crypto),!r&&"undefined"!=typeof window&&window.msCrypto&&(r=window.msCrypto),!r&&void 0!==C&&C.crypto&&(r=C.crypto),!r)try{r=f.default}catch(e){}var n=function(){if(r){if("function"==typeof r.getRandomValues)try{return r.getRandomValues(new Uint32Array(1))[0]}catch(e){}if("function"==typeof r.randomBytes)try{return r.randomBytes(4).readInt32LE()}catch(e){}}throw new Error("Native crypto module could not be used to get secure random number.")},a=Object.create||function(){function e(){}return function(t){var r;return e.prototype=t,r=new e,e.prototype=null,r}}(),o={},i=o.lib={},s=i.Base={extend:function(e){var t=a(this);return e&&t.mixIn(e),t.hasOwnProperty("init")&&this.init!==t.init||(t.init=function(){t.$super.init.apply(this,arguments)}),t.init.prototype=t,t.$super=this,t},create:function(){var e=this.extend();return e.init.apply(e,arguments),e},init:function(){},mixIn:function(e){for(var t in e)e.hasOwnProperty(t)&&(this[t]=e[t]);e.hasOwnProperty("toString")&&(this.toString=e.toString)},clone:function(){return this.init.prototype.extend(this)}},u=i.WordArray=s.extend({init:function(e,t){e=this.words=e||[],this.sigBytes=null!=t?t:4*e.length},toString:function(e){return(e||l).stringify(this)},concat:function(e){var t=this.words,r=e.words,n=this.sigBytes,a=e.sigBytes;if(this.clamp(),n%4)for(var o=0;o<a;o++){var i=r[o>>>2]>>>24-o%4*8&255;t[n+o>>>2]|=i<<24-(n+o)%4*8}else for(var s=0;s<a;s+=4)t[n+s>>>2]=r[s>>>2];return this.sigBytes+=a,this},clamp:function(){var t=this.words,r=this.sigBytes;t[r>>>2]&=4294967295<<32-r%4*8,t.length=e.ceil(r/4)},clone:function(){var e=s.clone.call(this);return e.words=this.words.slice(0),e},random:function(e){for(var t=[],r=0;r<e;r+=4)t.push(n());return new u.init(t,e)}}),c=o.enc={},l=c.Hex={stringify:function(e){for(var t=e.words,r=e.sigBytes,n=[],a=0;a<r;a++){var o=t[a>>>2]>>>24-a%4*8&255;n.push((o>>>4).toString(16)),n.push((15&o).toString(16))}return n.join("")},parse:function(e){for(var t=e.length,r=[],n=0;n<t;n+=2)r[n>>>3]|=parseInt(e.substr(n,2),16)<<24-n%8*4;return new u.init(r,t/2)}},p=c.Latin1={stringify:function(e){for(var t=e.words,r=e.sigBytes,n=[],a=0;a<r;a++){var o=t[a>>>2]>>>24-a%4*8&255;n.push(String.fromCharCode(o))}return n.join("")},parse:function(e){for(var t=e.length,r=[],n=0;n<t;n++)r[n>>>2]|=(255&e.charCodeAt(n))<<24-n%4*8;return new u.init(r,t)}},d=c.Utf8={stringify:function(e){try{return decodeURIComponent(escape(p.stringify(e)))}catch(e){throw new Error("Malformed UTF-8 data")}},parse:function(e){return p.parse(unescape(encodeURIComponent(e)))}},h=i.BufferedBlockAlgorithm=s.extend({reset:function(){this._data=new u.init,this._nDataBytes=0},_append:function(e){"string"==typeof e&&(e=d.parse(e)),this._data.concat(e),this._nDataBytes+=e.sigBytes},_process:function(t){var r,n=this._data,a=n.words,o=n.sigBytes,i=this.blockSize,s=o/(4*i),c=(s=t?e.ceil(s):e.max((0|s)-this._minBufferSize,0))*i,l=e.min(4*c,o);if(c){for(var f=0;f<c;f+=i)this._doProcessBlock(a,f);r=a.splice(0,c),n.sigBytes-=l}return new u.init(r,l)},clone:function(){var e=s.clone.call(this);return e._data=this._data.clone(),e},_minBufferSize:0});i.Hasher=h.extend({cfg:s.extend(),init:function(e){this.cfg=this.cfg.extend(e),this.reset()},reset:function(){h.reset.call(this),this._doReset()},update:function(e){return this._append(e),this._process(),this},finalize:function(e){return e&&this._append(e),this._doFinalize()},blockSize:16,_createHelper:function(e){return function(t,r){return new e.init(r).finalize(t)}},_createHmacHelper:function(e){return function(t,r){return new v.HMAC.init(e,r).finalize(t)}}});var v=o.algo={};return o}(Math)})),V=A((function(e,t){var r;e.exports=(r=Q,function(e){var t=r,n=t.lib,a=n.WordArray,o=n.Hasher,i=t.algo,s=[];!function(){for(var t=0;t<64;t++)s[t]=4294967296*e.abs(e.sin(t+1))|0}();var u=i.MD5=o.extend({_doReset:function(){this._hash=new a.init([1732584193,4023233417,2562383102,271733878])},_doProcessBlock:function(e,t){for(var r=0;r<16;r++){var n=t+r,a=e[n];e[n]=16711935&(a<<8|a>>>24)|4278255360&(a<<24|a>>>8)}var o=this._hash.words,i=e[t+0],u=e[t+1],d=e[t+2],h=e[t+3],v=e[t+4],y=e[t+5],g=e[t+6],b=e[t+7],m=e[t+8],w=e[t+9],x=e[t+10],k=e[t+11],S=e[t+12],j=e[t+13],O=e[t+14],E=e[t+15],C=o[0],A=o[1],P=o[2],_=o[3];C=c(C,A,P,_,i,7,s[0]),_=c(_,C,A,P,u,12,s[1]),P=c(P,_,C,A,d,17,s[2]),A=c(A,P,_,C,h,22,s[3]),C=c(C,A,P,_,v,7,s[4]),_=c(_,C,A,P,y,12,s[5]),P=c(P,_,C,A,g,17,s[6]),A=c(A,P,_,C,b,22,s[7]),C=c(C,A,P,_,m,7,s[8]),_=c(_,C,A,P,w,12,s[9]),P=c(P,_,C,A,x,17,s[10]),A=c(A,P,_,C,k,22,s[11]),C=c(C,A,P,_,S,7,s[12]),_=c(_,C,A,P,j,12,s[13]),P=c(P,_,C,A,O,17,s[14]),C=l(C,A=c(A,P,_,C,E,22,s[15]),P,_,u,5,s[16]),_=l(_,C,A,P,g,9,s[17]),P=l(P,_,C,A,k,14,s[18]),A=l(A,P,_,C,i,20,s[19]),C=l(C,A,P,_,y,5,s[20]),_=l(_,C,A,P,x,9,s[21]),P=l(P,_,C,A,E,14,s[22]),A=l(A,P,_,C,v,20,s[23]),C=l(C,A,P,_,w,5,s[24]),_=l(_,C,A,P,O,9,s[25]),P=l(P,_,C,A,h,14,s[26]),A=l(A,P,_,C,m,20,s[27]),C=l(C,A,P,_,j,5,s[28]),_=l(_,C,A,P,d,9,s[29]),P=l(P,_,C,A,b,14,s[30]),C=f(C,A=l(A,P,_,C,S,20,s[31]),P,_,y,4,s[32]),_=f(_,C,A,P,m,11,s[33]),P=f(P,_,C,A,k,16,s[34]),A=f(A,P,_,C,O,23,s[35]),C=f(C,A,P,_,u,4,s[36]),_=f(_,C,A,P,v,11,s[37]),P=f(P,_,C,A,b,16,s[38]),A=f(A,P,_,C,x,23,s[39]),C=f(C,A,P,_,j,4,s[40]),_=f(_,C,A,P,i,11,s[41]),P=f(P,_,C,A,h,16,s[42]),A=f(A,P,_,C,g,23,s[43]),C=f(C,A,P,_,w,4,s[44]),_=f(_,C,A,P,S,11,s[45]),P=f(P,_,C,A,E,16,s[46]),C=p(C,A=f(A,P,_,C,d,23,s[47]),P,_,i,6,s[48]),_=p(_,C,A,P,b,10,s[49]),P=p(P,_,C,A,O,15,s[50]),A=p(A,P,_,C,y,21,s[51]),C=p(C,A,P,_,S,6,s[52]),_=p(_,C,A,P,h,10,s[53]),P=p(P,_,C,A,x,15,s[54]),A=p(A,P,_,C,u,21,s[55]),C=p(C,A,P,_,m,6,s[56]),_=p(_,C,A,P,E,10,s[57]),P=p(P,_,C,A,g,15,s[58]),A=p(A,P,_,C,j,21,s[59]),C=p(C,A,P,_,v,6,s[60]),_=p(_,C,A,P,k,10,s[61]),P=p(P,_,C,A,d,15,s[62]),A=p(A,P,_,C,w,21,s[63]),o[0]=o[0]+C|0,o[1]=o[1]+A|0,o[2]=o[2]+P|0,o[3]=o[3]+_|0},_doFinalize:function(){var t=this._data,r=t.words,n=8*this._nDataBytes,a=8*t.sigBytes;r[a>>>5]|=128<<24-a%32;var o=e.floor(n/4294967296),i=n;r[15+(a+64>>>9<<4)]=16711935&(o<<8|o>>>24)|4278255360&(o<<24|o>>>8),r[14+(a+64>>>9<<4)]=16711935&(i<<8|i>>>24)|4278255360&(i<<24|i>>>8),t.sigBytes=4*(r.length+1),this._process();for(var s=this._hash,u=s.words,c=0;c<4;c++){var l=u[c];u[c]=16711935&(l<<8|l>>>24)|4278255360&(l<<24|l>>>8)}return s},clone:function(){var e=o.clone.call(this);return e._hash=this._hash.clone(),e}});function c(e,t,r,n,a,o,i){var s=e+(t&r|~t&n)+a+i;return(s<<o|s>>>32-o)+t}function l(e,t,r,n,a,o,i){var s=e+(t&n|r&~n)+a+i;return(s<<o|s>>>32-o)+t}function f(e,t,r,n,a,o,i){var s=e+(t^r^n)+a+i;return(s<<o|s>>>32-o)+t}function p(e,t,r,n,a,o,i){var s=e+(r^(t|~n))+a+i;return(s<<o|s>>>32-o)+t}t.MD5=o._createHelper(u),t.HmacMD5=o._createHmacHelper(u)}(Math),r.MD5)})),X=function(e){return V(e)},K=function(e){return e.includes("/")&&e.split("/")[0]},Z=function(e){return e.includes("/")?e.split("/")[1]:e},ee=function(e){return e.map((function(t){var r=t.query,n=e.find((function(e){return t.parentNode===e.node}));return void 0!==n&&(r=r.concat(n.query[0])),{type:"bgp",triples:r}}))},te=function(e,t,n){var a=[],o=function(e){var t=[];if(e){var r,n=E(e);try{for(n.s();!(r=n.n()).done;){var a=r.value;if(a.includes("/"))for(var o=a.split("/"),i=1;i<=o.length;i++)t.push(o.slice(0,i).join("/"));else t.push(a)}}catch(e){n.e(e)}finally{n.f()}}return t}(e);if(o&&n&&n.length>0){var i,s=E(o);try{for(s.s();!(i=s.n()).done;){var u=i.value,c=K(u),l=Z(u),f=X(u),p=c?X(c):"1",d=[r.triple(r.variable("s"+p),r.namedNode(J(l,n)),r.variable("s"+f)),r.triple(r.variable("s"+f),r.variable("p"+f),r.variable("o"+f))];a.push({node:u,parentNode:c,query:d,filter:""})}}catch(e){s.e(e)}finally{s.f()}return{construct:a.length>0?a.map((function(e){return e.query})).reduce((function(e,t){return e.concat(t)})):null,where:{type:"union",patterns:[t.where].concat(S(ee(a)))}}}return{construct:"",where:""}},re=l.default.literal,ne=l.default.namedNode,ae=l.default.triple,oe=l.default.variable,ie=new(0,require("sparqljs").Generator)({}),se=["q","sparqlWhere","blankNodes","_servers","_predicates"],ue=function(e){var t=e.containers,r=e.params.filter,n=e.blankNodes,a=e.predicates,o=e.ontologies,i=Y(a,o),s={queryType:"CONSTRUCT",template:i.construct,where:[],type:"query",prefixes:Object.fromEntries(o.map((function(e){return[e.prefix,e.url]})))},u=[{type:"values",values:t.map((function(e){return{"?containerUri":ne(e)}}))},ae(oe("containerUri"),ne("http://www.w3.org/ns/ldp#contains"),oe("s1")),{type:"filter",expression:{type:"operation",operator:"isiri",args:[oe("s1")]}}],c=[];if(r&&Object.keys(r).length>0){var l=r.sparqlWhere&&Object.keys(r.sparqlWhere).length>0,f=r.q&&r.q.length>0;l&&[].concat(r.sparqlWhere).forEach((function(e){c.push(e)})),f&&c.push({type:"group",patterns:[{queryType:"SELECT",variables:[oe("s1")],where:[ae(oe("s1"),oe("p1"),oe("o1")),{type:"filter",expression:{type:"operation",operator:"isliteral",args:[oe("o1")]}},{type:"filter",expression:{type:"operation",operator:"regex",args:[{type:"operation",operator:"lcase",args:[{type:"operation",operator:"str",args:[oe("o1")]}]},re(r.q.toLowerCase(),"",ne("http://www.w3.org/2001/XMLSchema#string"))]}}],type:"query"}]}),Object.entries(r).forEach((function(e){var t=k(e,2),r=t[0],n=t[1];se.includes(r)||c.unshift(ae(oe("s1"),ne(J(r,o)),ne(J(n,o))))}))}var p=te(n,i,o);return p&&p.construct?(c=c.concat(p.where),s.template=s.template.concat(p.construct)):c.push(i.where),s.where.push({type:"union",patterns:[u,{type:"graph",name:ne("http://semapps.org/mirror"),patterns:u}]},{type:"union",patterns:[c,{type:"graph",name:ne("http://semapps.org/mirror"),patterns:c}]}),ie.stringify(s)},ce=function(e,t){for(var r=[],n=0,a=Object.keys(t);n<a.length;n++){var o=a[n];if(t[o].blankNodes)for(var i=0,s=Object.keys(t[o].blankNodes);i<s.length;i++){var u=s[i];e.includes(u)&&r.push.apply(r,S(t[o].blankNodes[u]))}}return S(new Set(r))},le=["@context"],fe=function(e,t){switch(y(e)){case"string":return e.localeCompare(t);case"number":case"bigint":return e-t;default:return 0}},pe=function(){var e=b(v().mark((function e(t,r,n,a){var o,i,s,c,l,f,p,d,y,g;return v().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return o=a.dataServers,i=a.resources,s=a.httpClient,c=a.jsonContext,l=a.ontologies,f=i[r],p=Object.keys(t).map((function(e){return new Promise((function(r,a){var i,p,d,v,y,g,b=(null===(i=n.filter)||void 0===i?void 0:i.blankNodes)||(null===(p=f.list)||void 0===p?void 0:p.blankNodes)||ce(t[e],o),m=(null===(d=n.filter)||void 0===d?void 0:d._predicates)||(null===(v=f.list)||void 0===v?void 0:v.predicates);null!==(y=n.filter)&&void 0!==y&&y.sparqlWhere&&("string"==typeof n.filter.sparqlWhere||n.filter.sparqlWhere instanceof String)&&(n.filter.sparqlWhere=JSON.parse(decodeURIComponent(n.filter.sparqlWhere)));var w=ue({containers:t[e],params:h(h({},n),{},{filter:h(h({},null===(g=f.list)||void 0===g?void 0:g.filter),n.filter)}),blankNodes:b,predicates:m,ontologies:l});s(o[e].sparqlEndpoint,{method:"POST",body:w}).then((function(e){var t,r=e.json,n=!1!==(null===(t=f.list)||void 0===t?void 0:t.explicitEmbedOnFraming)?h({"@context":c,"@type":f.types,"@embed":"@never"},z(b)):{"@context":c,"@type":f.types};return u.default.frame(r,n,{omitGraph:!1})})).then((function(e){if(e["@id"]){var t=e;e={"@context":t["@context"],"@graph":[x(t,le)]}}r(e["@graph"]||[])})).catch((function(e){return a(e)}))}))})),e.next=5,Promise.all(p);case 5:if(0!==(d=e.sent).length){e.next=10;break}return e.abrupt("return",{data:[],total:0});case 10:return d=(y=[]).concat.apply(y,S(d)),g=d.map((function(e){return e.id=e.id||e["@id"],e})),n.sort&&(g=g.sort((function(e,t){return void 0!==e[n.sort.field]&&void 0!==t[n.sort.field]?"ASC"===n.sort.order?fe(e[n.sort.field],t[n.sort.field]):fe(t[n.sort.field],e[n.sort.field]):0}))),n.pagination&&(g=g.slice((n.pagination.page-1)*n.pagination.perPage,n.pagination.page*n.pagination.perPage)),e.abrupt("return",{data:g,total:d.length});case 15:case"end":return e.stop()}}),e)})));return function(t,r,n,a){return e.apply(this,arguments)}}(),de=function(e,t){var r={};return Object.keys(e).forEach((function(n){if(!t[n])throw new Error("No server found with key "+n);r[n]=[],e[n].forEach((function(e){r[n].push(P(t[n].baseUrl,e))}))})),r},he=function(e){return function(){var t=b(v().mark((function t(r){var n,a,o,i,s,u,c,l,f,p,d,h=arguments;return v().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(i=h.length>1&&void 0!==h[1]?h[1]:{},s=e.dataServers,u=e.resources,c=u[r]){t.next=5;break}throw new Error("Resource ".concat(r," is not mapped in resources file"));case 5:if(null!==(n=i.filter)&&void 0!==n&&n._servers||null===(a=c.list)||void 0===a||!a.containers){t.next=11;break}if(!Array.isArray(null===(f=c.list)||void 0===f?void 0:f.containers)){t.next=8;break}throw new Error("The list.containers property of ".concat(r," dataModel must be of type object ({ serverKey: [containerUri] })"));case 8:l=de(c.list.containers,s),t.next=12;break;case 11:l=M(c.types,(null===(p=i.filter)||void 0===p?void 0:p._servers)||(null===(d=c.list)||void 0===d?void 0:d.servers),s);case 12:if(null===(o=c.list)||void 0===o||!o.fetchContainer){t.next=16;break}return t.abrupt("return",G(l,r,i,e));case 16:return t.abrupt("return",pe(l,r,i,e));case 17:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}()},ve=function(e){return function(){var t=b(v().mark((function t(r,n){var a,o;return v().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return a=e.returnFailedResources,t.next=3,Promise.all(n.ids.map((function(t){return L(e)(r,{id:"object"===y(t)?t["@id"]:t}).then((function(e){return e.data})).catch((function(){if(a)return{id:t,_error:!0}}))})));case 3:return o=(o=t.sent).filter((function(e){return e})),t.abrupt("return",{data:o});case 6:case"end":return t.stop()}}),t)})));return function(e,r){return t.apply(this,arguments)}}()},ye=function(e){return function(){var t=b(v().mark((function t(r,n){return v().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n.filter=h(h({},n.filter),{},m({},n.target,n.id)),delete n.target,t.next=4,he(e)(r,n);case 4:return t.abrupt("return",t.sent);case 5:case"end":return t.stop()}}),t)})));return function(e,r){return t.apply(this,arguments)}}()},ge=function(e){return function(){var t=b(v().mark((function t(r,n){var a,o;return v().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return a=e.httpClient,o=e.jsonContext,t.next=3,U(n.data,e);case 3:return n.data=t.sent,t.next=6,a(n.id,{method:"PUT",body:JSON.stringify(h({"@context":o},n.data))});case 6:return t.abrupt("return",{data:n.data});case 7:case"end":return t.stop()}}),t)})));return function(e,r){return t.apply(this,arguments)}}()};function be(e){this.message=e}be.prototype=new Error,be.prototype.name="InvalidCharacterError";var me="undefined"!=typeof window&&window.atob&&window.atob.bind(window)||function(e){var t=String(e).replace(/=+$/,"");if(t.length%4==1)throw new be("'atob' failed: The string to be decoded is not correctly encoded.");for(var r,n,a=0,o=0,i="";n=t.charAt(o++);~n&&(r=a%4?64*r+n:n,a++%4)?i+=String.fromCharCode(255&r>>(-2*a&6)):0)n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(n);return i};function we(e){var t=e.replace(/-/g,"+").replace(/_/g,"/");switch(t.length%4){case 0:break;case 2:t+="==";break;case 3:t+="=";break;default:throw"Illegal base64url string!"}try{return function(e){return decodeURIComponent(me(e).replace(/(.)/g,(function(e,t){var r=t.charCodeAt(0).toString(16).toUpperCase();return r.length<2&&(r="0"+r),"%"+r})))}(t)}catch(e){return me(t)}}function xe(e){this.message=e}function ke(e,t){if("string"!=typeof e)throw new xe("Invalid token specified");var r=!0===(t=t||{}).header?0:1;try{return JSON.parse(we(e.split(".")[r]))}catch(e){throw new xe("Invalid token specified: "+e.message)}}xe.prototype=new Error,xe.prototype.name="InvalidTokenError";var Se=function(){var e=b(v().mark((function e(t){var r,n,a,o,i,s,u,c,l,f,p,d;return v().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r=t.dataServers,n=t.httpClient,a=localStorage.getItem("token"),o=I("pod",r),i=I("authServer",r),!a){e.next=24;break}return s=ke(a),u=s.webId,e.prev=6,e.next=9,n(u);case 9:l=e.sent,f=l.json,c=f,e.next=20;break;case 14:return e.prev=14,e.t0=e.catch(6),console.error(e.t0),localStorage.clear(),window.location.reload(),e.abrupt("return");case 20:o&&(t.dataServers[o].name="My Pod",t.dataServers[o].baseUrl=P(u,"data"),t.dataServers[o].sparqlEndpoint=(null===(p=c.endpoints)||void 0===p?void 0:p["void:sparqlEndpoint"])||P(u,"sparql")),i&&(t.dataServers[i].proxyUrl=null===(d=c.endpoints)||void 0===d?void 0:d.proxyUrl),e.next=24;break;case 24:case"end":return e.stop()}}),e,null,[[6,14]])})));return function(t){return e.apply(this,arguments)}}(),je=function(e){return e?Array.isArray(e)?e:[e]:void 0},Oe=function(){var e=b(v().mark((function e(t){var r,n,a,o,i,s,u,c;return v().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=Object.entries(t.dataServers).filter((function(e){var t=k(e,2);return t[0],!0!==t[1].pod})).map((function(e){var r=k(e,2),n=r[0],a=r[1];return t.httpClient(new URL("/.well-known/void",a.baseUrl).toString()).then((function(e){return{key:n,datasets:e.json["@graph"]}})).catch((function(e){if(404===e.status||401===e.status)return{key:n,error:e};throw e}))})),n=[],e.prev=2,e.next=5,Promise.all(r);case 5:n=e.sent,e.next=10;break;case 8:e.prev=8,e.t0=e.catch(2);case 10:a=E(n);try{for(a.s();!(o=a.n()).done;)if(i=o.value,t.dataServers[i.key].containers=t.dataServers[i.key].containers||{},t.dataServers[i.key].blankNodes=t.dataServers[i.key].blankNodes||{},i.datasets){s=E(i.datasets);try{for(c=function(){var e=u.value,r=Object.keys(t.dataServers).find((function(r){return e["void:uriSpace"]===t.dataServers[r].baseUrl}));if(r){r===i.key&&(t.dataServers[i.key].name=t.dataServers[i.key].name||e["dc:title"],t.dataServers[i.key].description=t.dataServers[i.key].description||e["dc:description"],t.dataServers[i.key].sparqlEndpoint=t.dataServers[i.key].sparqlEndpoint||e["void:sparqlEndpoint"]),t.dataServers[i.key].containers[r]=t.dataServers[i.key].containers[r]||{};var n,a=E(je(e["void:classPartition"]));try{for(a.s();!(n=a.n()).done;){var o,s=n.value,c=E(je(s["void:class"]));try{for(c.s();!(o=c.n()).done;){var l=o.value,f=s["void:uriSpace"].replace(e["void:uriSpace"],"/");t.dataServers[i.key].containers[r][l]?t.dataServers[i.key].containers[r][l].push(f):t.dataServers[i.key].containers[r][l]=[f],je(s["semapps:blankNodes"])&&(t.dataServers[i.key].blankNodes[s["void:uriSpace"]]=je(s["semapps:blankNodes"]))}}catch(e){c.e(e)}finally{c.f()}}}catch(e){a.e(e)}finally{a.f()}}},s.s();!(u=s.n()).done;)c()}catch(e){s.e(e)}finally{s.f()}}}catch(e){a.e(e)}finally{a.f()}case 12:case"end":return e.stop()}}),e,null,[[2,8]])})));return function(t){return e.apply(this,arguments)}}(),Ee=function(e,t){return Object.keys(t).find((function(r){return t[r].pod?t[r].baseUrl&&e.startsWith(t[r].baseUrl.replace("/data","")):e.startsWith(t[r].baseUrl)}))},Ce=function(e,t){return"function"==typeof e?e(t):e},Ae=function(e){return"string"==typeof e&&e.startsWith("http")},Pe=function(e){var t=o.useContext(a.DataProviderContext),r=k(o.useState(),2),n=r[0],i=r[1];return o.useEffect((function(){t.getDataModels().then((function(t){return i(t[e])}))}),[t,e,i]),n},_e=function(){var e=o.useContext(a.DataProviderContext),t=k(o.useState(),2),r=t[0],n=t[1];return o.useEffect((function(){e.getDataServers().then((function(e){return n(e)}))}),[e,n]),r},Le=function(e,t,r){var n=[];if(Object.keys(r[t].containers[t]).length>0&&Object.keys(r[t].containers[t]).forEach((function(a){e.includes(a)&&r[t].containers[t][a].map((function(e){var a=P(r[t].baseUrl,e);n.includes(a)||n.push(a)}))})),0===n.length)throw new Error("No container found matching with types ".concat(JSON.stringify(e),". You can set explicitely the create.container property of the resource."));if(n.length>1)throw new Error("More than one container found matching with types ".concat(JSON.stringify(e),". You must set the create.server or create.container property for the resource."));return n[0]},Ne=["children","record","filter","source"],Te=function(e){var t=e.children,r=e.record,n=e.filter,a=e.source,i=x(e,Ne),s=k(o.useState(),2),u=s[0],c=s[1];return o.useEffect((function(){if(r&&a&&Array.isArray(null==r?void 0:r[a])){var e=null==r?void 0:r[a].filter((function(e){var t=!0;for(var r in n){var a=e[r];Array.isArray(a)?a.includes(n[r])||(t=!1):a!==n[r]&&(t=!1)}return t})),t=h({},r);t[a]=e.length>0?e:void 0,c(t)}}),[r,a,n]),p.default.createElement(p.default.Fragment,null,p.default.Children.map(t,(function(e,t){return p.default.cloneElement(e,h(h({},i),{},{record:u,addLabel:!0,source:a}))})))},qe=["children","groupReference","groupLabel","groupHeader","filterProperty"],Ue=["reificationClass","children"],Ie=i.makeStyles({form:{display:"flex"},input:{paddingRight:"20px"}}),De=i.makeStyles({root:{display:"none"}});exports.FilterHandler=Te,exports.GroupedReferenceHandler=function(e){var t=e.children,r=e.groupReference,n=e.groupLabel,o=e.groupHeader,i=e.filterProperty,s=x(e,qe),u=a.useQueryWithStore({type:"getList",resource:r,payload:{}}).data;return p.default.createElement(p.default.Fragment,null,null==u?void 0:u.map((function(e,r){var a={};return a[i]=e.id,p.default.createElement(p.default.Fragment,null,o&&o(h(h({},s),{},{group:e})),p.default.createElement(Te,w({},s,{filter:a,label:e[n]}),t))})))},exports.ReificationArrayInput=function(e){var t=e.reificationClass;e.children;var r=x(e,Ue),n=Ie(),o=De();return p.default.createElement(a.ArrayInput,r,p.default.createElement(a.SimpleFormIterator,{classes:{form:n.form}},p.default.Children.map(e.children,(function(e,t){return p.default.cloneElement(e,{className:n.input})})),p.default.createElement(a.TextInput,{className:o.root,source:"type",initialValue:t})))},exports.buildBlankNodesQuery=te,exports.buildSparqlQuery=ue,exports.dataProvider=function(e){if(!I("default",e.dataServers))throw new Error("You must define a default server in your dataServers config");var t;e.jsonContext||(e.jsonContext=Object.fromEntries(e.ontologies.map((function(e){return[e.prefix,e.url]})))),e.returnFailedResources||(e.returnFailedResources=!1),e.httpClient=(t=e.dataServers,function(e){var r,n,o=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},i=I("authServer",t),s=Ee(e,t),u=s!==i&&(null===(r=t[i])||void 0===r?void 0:r.proxyUrl)&&!0!==(null===(n=t[s])||void 0===n?void 0:n.noProxy);switch(o.headers||(o.headers=new Headers),o.method){case"POST":case"PATCH":case"PUT":o.headers.has("Accept")||o.headers.set("Accept","application/ld+json"),o.headers.has("Content-Type")||o.headers.set("Content-Type","application/ld+json");break;case"DELETE":break;case"GET":default:o.headers.has("Accept")||o.headers.set("Accept","application/ld+json")}if(u){var c=new FormData;return c.append("id",e),c.append("method",o.method||"GET"),c.append("headers",JSON.stringify(Object.fromEntries(o.headers.entries()))),o.body&&(o.body instanceof File?c.append("body",o.body,o.body.name):c.append("body",o.body)),a.fetchUtils.fetchJson(t[i].proxyUrl,{method:"POST",headers:new Headers({Authorization:"Bearer ".concat(localStorage.getItem("token"))}),body:c})}if(s===i){var l=localStorage.getItem("token");l&&o.headers.set("Authorization","Bearer ".concat(l))}return a.fetchUtils.fetchJson(e,o)});var r=Se(e),n=Oe(e),o=function(e){return b(v().mark((function t(){var a=arguments;return v().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,r;case 2:return t.next=4,n;case 4:return t.next=6,e.apply(void 0,a);case 6:return t.abrupt("return",t.sent);case 7:case"end":return t.stop()}}),t)})))};return{getList:o(he(e)),getMany:o(ve(e)),getManyReference:o(ye(e)),getOne:o(L(e)),create:o(B(e)),update:o(ge(e)),updateMany:function(){throw new Error("updateMany is not implemented yet")},delete:o(R(e)),deleteMany:o(F(e)),getDataModels:o(W(e)),getDataServers:o(H(e)),getLocalDataServers:H(e),fetch:o(e.httpClient)}},exports.useContainers=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"@all",r=Pe(e),n=_e(),a=o.useState(),i=k(a,2),s=i[0],u=i[1];return o.useEffect((function(){r&&n&&u(M(r.types,t,n))}),[r,n,t]),s},exports.useCreateContainer=function(e){var t=Pe(e),r=_e(),n=k(o.useState(),2),a=n[0],i=n[1];return o.useEffect((function(){var n,a;if(t&&r)if(null!==(n=t.create)&&void 0!==n&&n.container){var o=k(Object.entries(t.create.container)[0],2),s=o[0],u=o[1];if(!s||!r[s])throw new Error("Wrong key for the dataModel.create.container config of resource "+e);i(P(r[s].baseUrl,u))}else if(null!==(a=t.create)&&void 0!==a&&a.server){var c;i(Le(t.types,null===(c=t.create)||void 0===c?void 0:c.server,r))}else{var l=I("default",r);i(Le(t.types,l,r))}}),[t,r,i]),a},exports.useDataModel=Pe,exports.useDataModels=function(){var e=o.useContext(a.DataProviderContext),t=k(o.useState(),2),r=t[0],n=t[1];return o.useEffect((function(){e.getDataModels().then((function(e){return n(e)}))}),[e,n]),r},exports.useDataServers=_e,exports.useGetExternalLink=function(e){var t=o.useContext(a.DataProviderContext).getLocalDataServers(),r=o.useMemo((function(){if(t)return Object.fromEntries(Object.values(t).map((function(e){var t=void 0!==e.externalLinks?e.externalLinks:!e.default;return[e.baseUrl,t]})))}),[t]);return o.useCallback((function(t){var n=Ce(e,t);if(!1===n)return!1;if(null==t||!t.id)return!1;var a=Object.keys(r).find((function(e){return null==t?void 0:t.id.startsWith(e)}));if(!a)return!1;var o=Ce(r[a],t);return!1!==o&&(Ae(n)?n:Ae(o)?o:t.id)}),[r,e])};
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("jsonld"),r=require("speakingurl"),t=require("@rdfjs/data-model"),n=require("crypto"),a=require("react-admin"),o=require("react"),i=require("@material-ui/core/styles");function s(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var u=s(e),c=s(r),l=s(t),f=s(n),p=s(o);function d(e,r){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);r&&(n=n.filter((function(r){return Object.getOwnPropertyDescriptor(e,r).enumerable}))),t.push.apply(t,n)}return t}function h(e){for(var r=1;r<arguments.length;r++){var t=null!=arguments[r]?arguments[r]:{};r%2?d(Object(t),!0).forEach((function(r){b(e,r,t[r])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):d(Object(t)).forEach((function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(t,r))}))}return e}function v(e){return(v="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function y(e,r,t,n,a,o,i){try{var s=e[o](i),u=s.value}catch(e){return void t(e)}s.done?r(u):Promise.resolve(u).then(n,a)}function g(e){return function(){var r=this,t=arguments;return new Promise((function(n,a){var o=e.apply(r,t);function i(e){y(o,n,a,i,s,"next",e)}function s(e){y(o,n,a,i,s,"throw",e)}i(void 0)}))}}function b(e,r,t){return r in e?Object.defineProperty(e,r,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[r]=t,e}function m(){return(m=Object.assign||function(e){for(var r=1;r<arguments.length;r++){var t=arguments[r];for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])}return e}).apply(this,arguments)}function w(e,r){if(null==e)return{};var t,n,a=function(e,r){if(null==e)return{};var t,n,a={},o=Object.keys(e);for(n=0;n<o.length;n++)t=o[n],r.indexOf(t)>=0||(a[t]=e[t]);return a}(e,r);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);for(n=0;n<o.length;n++)t=o[n],r.indexOf(t)>=0||Object.prototype.propertyIsEnumerable.call(e,t)&&(a[t]=e[t])}return a}function x(e,r){return function(e){if(Array.isArray(e))return e}(e)||function(e,r){var t=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null==t)return;var n,a,o=[],i=!0,s=!1;try{for(t=t.call(e);!(i=(n=t.next()).done)&&(o.push(n.value),!r||o.length!==r);i=!0);}catch(e){s=!0,a=e}finally{try{i||null==t.return||t.return()}finally{if(s)throw a}}return o}(e,r)||S(e,r)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function k(e){return function(e){if(Array.isArray(e))return j(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||S(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function S(e,r){if(e){if("string"==typeof e)return j(e,r);var t=Object.prototype.toString.call(e).slice(8,-1);return"Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t?Array.from(e):"Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?j(e,r):void 0}}function j(e,r){(null==r||r>e.length)&&(r=e.length);for(var t=0,n=new Array(r);t<r;t++)n[t]=e[t];return n}function O(e,r){var t="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!t){if(Array.isArray(e)||(t=S(e))||r&&e&&"number"==typeof e.length){t&&(e=t);var n=0,a=function(){};return{s:a,n:function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}},e:function(e){throw e},f:a}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,i=!0,s=!1;return{s:function(){t=t.call(e)},n:function(){var e=t.next();return i=e.done,e},e:function(e){s=!0,o=e},f:function(){try{i||null==t.return||t.return()}finally{if(s)throw o}}}}var E="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function C(e,r){return e(r={exports:{}},r.exports),r.exports}var A=C((function(e){var r,t;r=E,t=function(){function e(e){var r=[];if(0===e.length)return"";if("string"!=typeof e[0])throw new TypeError("Url must be a string. Received "+e[0]);if(e[0].match(/^[^/:]+:\/*$/)&&e.length>1){var t=e.shift();e[0]=t+e[0]}e[0].match(/^file:\/\/\//)?e[0]=e[0].replace(/^([^/:]+):\/*/,"$1:///"):e[0]=e[0].replace(/^([^/:]+):\/*/,"$1://");for(var n=0;n<e.length;n++){var a=e[n];if("string"!=typeof a)throw new TypeError("Url must be a string. Received "+a);""!==a&&(n>0&&(a=a.replace(/^[\/]+/,"")),a=n<e.length-1?a.replace(/[\/]+$/,""):a.replace(/[\/]+$/,"/"),r.push(a))}var o=r.join("/"),i=(o=o.replace(/\/(\?|&|#[^!])/g,"$1")).split("?");return o=i.shift()+(i.length>0?"?":"")+i.join("&")}return function(){return e("object"==typeof arguments[0]?arguments[0]:[].slice.call(arguments))}},e.exports?e.exports=t():r.urljoin=t()})),R=function(){var e=g(regeneratorRuntime.mark((function e(r,t){var n,a,o,i;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=t.httpClient,a=t.jsonContext,e.next=3,n(r);case 3:if(o=e.sent,i=o.json){e.next=7;break}throw new Error("Not a valid JSON: "+r);case 7:if(i.id=i.id||i["@id"],i["@context"]===a){e.next=12;break}return e.next=11,u.default.compact(i,a);case 11:i=e.sent;case 12:return e.abrupt("return",i);case 13:case"end":return e.stop()}}),e)})));return function(r,t){return e.apply(this,arguments)}}(),P=function(e){return function(){var r=g(regeneratorRuntime.mark((function r(t,n){var a,o,i,s,u,c,l,f;return regeneratorRuntime.wrap((function(r){for(;;)switch(r.prev=r.next){case 0:if(o=e.resources,i=o[t]){r.next=4;break}throw new Error("Resource ".concat(t," is not mapped in resources file"));case 4:return r.next=6,R(n.id,e);case 6:if(s=r.sent,null!==(a=i.list)&&void 0!==a&&a.forceArray){c=O(null===(u=i.list)||void 0===u?void 0:u.forceArray);try{for(c.s();!(l=c.n()).done;)f=l.value,s[f]&&!Array.isArray(s[f])&&(s[f]=[s[f]])}catch(e){c.e(e)}finally{c.f()}}return r.abrupt("return",{data:s});case 9:case"end":return r.stop()}}),r)})));return function(e,t){return r.apply(this,arguments)}}()},T=function(e){return e&&e.rawFile&&e.rawFile instanceof File},q=function(e){var r=Object.keys(e.dataServers).find((function(r){return e.dataServers[r].uploadsContainer}));if(r)return A(e.dataServers[r].baseUrl,e.dataServers[r].uploadsContainer)},N=function(){var e=g(regeneratorRuntime.mark((function e(r,t){var n,a;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n=q(t)){e.next=3;break}throw new Error("You must define an uploadsContainer in one of the server's configuration");case 3:return e.next=5,t.httpClient(n,{method:"POST",body:r,headers:new Headers({Slug:(o=r.name,i=void 0,s=void 0,i="",s=o.split("."),s.length>1&&(i=s.pop(),o=s.join(".")),c.default(o,{lang:"fr"})+"."+i),"Content-Type":r.type})});case 5:if(201!==(a=e.sent).status){e.next=8;break}return e.abrupt("return",a.headers.get("Location"));case 8:case"end":return e.stop()}var o,i,s}),e)})));return function(r,t){return e.apply(this,arguments)}}(),_=function(){var e=g(regeneratorRuntime.mark((function e(r,t){var n,a;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:e.t0=regeneratorRuntime.keys(r);case 1:if((e.t1=e.t0()).done){e.next=22;break}if(n=e.t1.value,!r.hasOwnProperty(n)){e.next=20;break}if(!Array.isArray(r[n])){e.next=16;break}a=0;case 6:if(!(a<r[n].length)){e.next=14;break}if(!T(r[n][a])){e.next=11;break}return e.next=10,N(r[n][a].rawFile,t);case 10:r[n][a]=e.sent;case 11:a++,e.next=6;break;case 14:e.next=20;break;case 16:if(!T(r[n])){e.next=20;break}return e.next=19,N(r[n].rawFile,t);case 19:r[n]=e.sent;case 20:e.next=1;break;case 22:return e.abrupt("return",r);case 23:case"end":return e.stop()}}),e)})));return function(r,t){return e.apply(this,arguments)}}(),U=function(e,r){return Object.keys(r).find((function(t){return r[t][e]}))},I=function(e,r){switch(e){case"@default":return U("default",r);case"@pod":return U("pod",r);case"@authServer":return U("authServer",r);default:return e}},D=function(e,r,t){var n={},a=[];return r=function(e,r){if(Array.isArray(e))return e.includes("@all")?Object.keys(r):e.map((function(e){return I(e,r)}));if("string"==typeof e){if("@all"===e)return Object.keys(r);if("@remote"===e){var t=U("default",r);return Object.keys(r).filter((function(e){return e!==t}))}return[I(e,r)]}return!1}(r,t),Object.keys(t).forEach((function(o){Object.keys(t[o].containers).forEach((function(i){r&&!r.includes(i)||Object.keys(t[o].containers[i]).forEach((function(r){e.includes(r)&&t[o].containers[i][r].map((function(e){var r=A(t[i].baseUrl,e);a.includes(r)||(a.push(r),n[o]||(n[o]=[]),n[o].push(r))}))}))}))})),n},M=function(e){return function(){var r=g(regeneratorRuntime.mark((function r(t,n){var a,o,i,s,u,c,l,f,p,d,v,y,g,b,m,w;return regeneratorRuntime.wrap((function(r){for(;;)switch(r.prev=r.next){case 0:if(o=e.dataServers,i=e.resources,s=e.httpClient,u=e.jsonContext,c=i[t],l=new Headers,null===(a=c.create)||void 0===a||!a.container){r.next=9;break}p=Object.keys(c.create.container)[0],f=A(o[p].baseUrl,Object.values(c.create.container)[0]),r.next=19;break;case 9:if(p=(null===(d=c.create)||void 0===d?void 0:d.server)||Object.keys(o).find((function(e){return!0===o[e].default}))){r.next=12;break}throw new Error("You must define a server for the creation, or a container, or a default server");case 12:if(v=D(c.types,[p],o),(y=Object.keys(v))&&0!==y.length){r.next=16;break}throw new Error("No container with types ".concat(JSON.stringify(c.types)," found on server ").concat(p));case 16:if(!(y.length>1||v[y[0]].length>1)){r.next=18;break}throw new Error("More than one container detected with types ".concat(JSON.stringify(c.types)," on server ").concat(p));case 18:f=v[y[0]][0];case 19:if(!n.data){r.next=34;break}return null!==(g=c.fieldsMapping)&&void 0!==g&&g.title&&(Array.isArray(c.fieldsMapping.title)?l.set("Slug",c.fieldsMapping.title.map((function(e){return n.data[e]})).join(" ")):l.set("Slug",n.data[c.fieldsMapping.title])),r.next=23,_(n.data,e);case 23:return n.data=r.sent,r.next=26,s(f,{method:"POST",headers:l,body:JSON.stringify(h({"@context":u,"@type":c.types},n.data))});case 26:return b=r.sent,m=b.headers,w=m.get("Location"),r.next=31,P(e)(t,{id:w});case 31:return r.abrupt("return",r.sent);case 34:if(!n.id){r.next=41;break}return l.set("Content-Type","application/sparql-update"),r.next=38,s(f,{method:"PATCH",headers:l,body:"\n PREFIX ldp: <http://www.w3.org/ns/ldp#>\n INSERT DATA { <".concat(f,"> ldp:contains <").concat(n.id,">. };\n ")});case 38:return r.next=40,P(e)(t,{id:n.id});case 40:return r.abrupt("return",r.sent);case 41:case"end":return r.stop()}}),r)})));return function(e,t){return r.apply(this,arguments)}}()},B=function(e){return function(){var r=g(regeneratorRuntime.mark((function r(t,n){var a;return regeneratorRuntime.wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return a=e.httpClient,r.next=3,a(n.id,{method:"DELETE"});case 3:return r.abrupt("return",{data:{id:n.id}});case 4:case"end":return r.stop()}}),r)})));return function(e,t){return r.apply(this,arguments)}}()},L=function(e){return function(){var r=g(regeneratorRuntime.mark((function r(t,n){var a,o,i,s,u;return regeneratorRuntime.wrap((function(r){for(;;)switch(r.prev=r.next){case 0:a=e.httpClient,o=[],i=O(n.ids),r.prev=3,i.s();case 5:if((s=i.n()).done){r.next=17;break}return u=s.value,r.prev=7,r.next=10,a(u,{method:"DELETE"});case 10:o.push(u),r.next=15;break;case 13:r.prev=13,r.t0=r.catch(7);case 15:r.next=5;break;case 17:r.next=22;break;case 19:r.prev=19,r.t1=r.catch(3),i.e(r.t1);case 22:return r.prev=22,i.f(),r.finish(22);case 25:return r.abrupt("return",{data:o});case 26:case"end":return r.stop()}}),r,null,[[3,19,22,25],[7,13]])})));return function(e,t){return r.apply(this,arguments)}}()},H=function(e){return function(){return e.dataServers}},F=function(e){return function(){return e.resources}};var W=function(){var e=g(regeneratorRuntime.mark((function e(r,t,n,a){var o,i,s,c,l,f,p;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return o=a.httpClient,i=a.jsonContext,s=Object.keys(r).reduce((function(e,t){return h(h({},e),Object.fromEntries(r[t].map((function(e){return[e,t]}))))}),{}),c=Object.keys(s).map((function(e){return o(e).then((function(e){var r=e.json;return r["@context"]!==i?u.default.compact(r,i):r})).then((function(r){if(t="ldp:Container",a=(n=r).type||n["@type"],Array.isArray(a)?a.includes(t):a===t)return r["ldp:contains"];throw new Error(e+" is not a LDP container");var t,n,a}))})),e.next=5,Promise.all(c);case 5:if(0!==(l=e.sent).length){e.next=10;break}return e.abrupt("return",{data:[],total:0});case 10:return l=(f=[].concat).apply.apply(f,k(l)),p=l.map((function(e){return e.id=e.id||e["@id"],e})),n.filter&&(n.filter.a&&(n.filter.type=n.filter.a,delete n.filter.a),Object.keys(n.filter).length>0&&(p=p.filter((function(e){return Object.entries(n.filter).some((function(r){var t=x(r,2),n=t[0],a=t[1];return"q"==n?Object.entries(e).some((function(e){var r=x(e,2);r[0];var t,n=r[1];return(null==(t=n)||"object"!=typeof t||!1!==Array.isArray(t))&&(Array.isArray(n)?n.some((function(e){return e.includes(a)})):n.includes(a))})):(Array.isArray(e[n]),e[n].includes(a))}))})))),n.sort&&(p=p.sort((function(e,r){return!e[n.sort.field]||!r[n.sort.field]||("ASC"===n.sort.order?e[n.sort.field].localeCompare(r[n.sort.field]):r[n.sort.field].localeCompare(e[n.sort.field]))}))),n.pagination&&(p=p.slice((n.pagination.page-1)*n.pagination.perPage,n.pagination.page*n.pagination.perPage)),e.abrupt("return",{data:p,total:l.length});case 16:case"end":return e.stop()}}),e)})));return function(r,t,n,a){return e.apply(this,arguments)}}(),J=function(e){var r,t={};if(e){var n,a=O(e);try{for(a.s();!(n=a.n()).done;){var o=n.value;r=o.includes("/")?o.split("/").reverse():[o],t=h(h({},t),r.reduce((function(e,r){return b({},r,h({"@embed":"@last"},e))}),{}))}}catch(e){a.e(e)}finally{a.f()}return t}},z=function(e,r){if(e.startsWith("http://")||e.startsWith("https://"))return e;if("a"===e)return"http://www.w3.org/1999/02/22-rdf-syntax-ns#type";var t=x(e.split(":"),2),n=t[0],a=t[1];if(a){var o=r.find((function(e){return e.prefix===n}));if(o)return o.url+a;throw new Error("No ontology found with prefix "+n)}throw new Error('The value "'.concat(e,'" is not correct. It must include a prefix or be a full URI.'))},$=t.triple(t.variable("s1"),t.namedNode("http://www.w3.org/1999/02/22-rdf-syntax-ns#type"),t.variable("type")),G=function(e,r){var n,a;return e?(n=(a=e,a?Array.isArray(a)?a:[a]:[]).map((function(e,n){return t.triple(t.variable("s1"),t.namedNode(z(e,r)),t.variable("o"+(n+1)))})),{construct:[$].concat(k(n)),where:[$].concat(k(n.map((function(e){return{type:"optional",patterns:[e]}}))))}):{construct:n=[t.triple(t.variable("s1"),t.variable("p1"),t.variable("o1"))],where:n}},Y=C((function(e,r){var t;e.exports=t=t||function(e,r){var t;if("undefined"!=typeof window&&window.crypto&&(t=window.crypto),"undefined"!=typeof self&&self.crypto&&(t=self.crypto),"undefined"!=typeof globalThis&&globalThis.crypto&&(t=globalThis.crypto),!t&&"undefined"!=typeof window&&window.msCrypto&&(t=window.msCrypto),!t&&void 0!==E&&E.crypto&&(t=E.crypto),!t)try{t=f.default}catch(e){}var n=function(){if(t){if("function"==typeof t.getRandomValues)try{return t.getRandomValues(new Uint32Array(1))[0]}catch(e){}if("function"==typeof t.randomBytes)try{return t.randomBytes(4).readInt32LE()}catch(e){}}throw new Error("Native crypto module could not be used to get secure random number.")},a=Object.create||function(){function e(){}return function(r){var t;return e.prototype=r,t=new e,e.prototype=null,t}}(),o={},i=o.lib={},s=i.Base={extend:function(e){var r=a(this);return e&&r.mixIn(e),r.hasOwnProperty("init")&&this.init!==r.init||(r.init=function(){r.$super.init.apply(this,arguments)}),r.init.prototype=r,r.$super=this,r},create:function(){var e=this.extend();return e.init.apply(e,arguments),e},init:function(){},mixIn:function(e){for(var r in e)e.hasOwnProperty(r)&&(this[r]=e[r]);e.hasOwnProperty("toString")&&(this.toString=e.toString)},clone:function(){return this.init.prototype.extend(this)}},u=i.WordArray=s.extend({init:function(e,r){e=this.words=e||[],this.sigBytes=null!=r?r:4*e.length},toString:function(e){return(e||l).stringify(this)},concat:function(e){var r=this.words,t=e.words,n=this.sigBytes,a=e.sigBytes;if(this.clamp(),n%4)for(var o=0;o<a;o++){var i=t[o>>>2]>>>24-o%4*8&255;r[n+o>>>2]|=i<<24-(n+o)%4*8}else for(var s=0;s<a;s+=4)r[n+s>>>2]=t[s>>>2];return this.sigBytes+=a,this},clamp:function(){var r=this.words,t=this.sigBytes;r[t>>>2]&=4294967295<<32-t%4*8,r.length=e.ceil(t/4)},clone:function(){var e=s.clone.call(this);return e.words=this.words.slice(0),e},random:function(e){for(var r=[],t=0;t<e;t+=4)r.push(n());return new u.init(r,e)}}),c=o.enc={},l=c.Hex={stringify:function(e){for(var r=e.words,t=e.sigBytes,n=[],a=0;a<t;a++){var o=r[a>>>2]>>>24-a%4*8&255;n.push((o>>>4).toString(16)),n.push((15&o).toString(16))}return n.join("")},parse:function(e){for(var r=e.length,t=[],n=0;n<r;n+=2)t[n>>>3]|=parseInt(e.substr(n,2),16)<<24-n%8*4;return new u.init(t,r/2)}},p=c.Latin1={stringify:function(e){for(var r=e.words,t=e.sigBytes,n=[],a=0;a<t;a++){var o=r[a>>>2]>>>24-a%4*8&255;n.push(String.fromCharCode(o))}return n.join("")},parse:function(e){for(var r=e.length,t=[],n=0;n<r;n++)t[n>>>2]|=(255&e.charCodeAt(n))<<24-n%4*8;return new u.init(t,r)}},d=c.Utf8={stringify:function(e){try{return decodeURIComponent(escape(p.stringify(e)))}catch(e){throw new Error("Malformed UTF-8 data")}},parse:function(e){return p.parse(unescape(encodeURIComponent(e)))}},h=i.BufferedBlockAlgorithm=s.extend({reset:function(){this._data=new u.init,this._nDataBytes=0},_append:function(e){"string"==typeof e&&(e=d.parse(e)),this._data.concat(e),this._nDataBytes+=e.sigBytes},_process:function(r){var t,n=this._data,a=n.words,o=n.sigBytes,i=this.blockSize,s=o/(4*i),c=(s=r?e.ceil(s):e.max((0|s)-this._minBufferSize,0))*i,l=e.min(4*c,o);if(c){for(var f=0;f<c;f+=i)this._doProcessBlock(a,f);t=a.splice(0,c),n.sigBytes-=l}return new u.init(t,l)},clone:function(){var e=s.clone.call(this);return e._data=this._data.clone(),e},_minBufferSize:0});i.Hasher=h.extend({cfg:s.extend(),init:function(e){this.cfg=this.cfg.extend(e),this.reset()},reset:function(){h.reset.call(this),this._doReset()},update:function(e){return this._append(e),this._process(),this},finalize:function(e){return e&&this._append(e),this._doFinalize()},blockSize:16,_createHelper:function(e){return function(r,t){return new e.init(t).finalize(r)}},_createHmacHelper:function(e){return function(r,t){return new v.HMAC.init(e,t).finalize(r)}}});var v=o.algo={};return o}(Math)})),Q=C((function(e,r){var t;e.exports=(t=Y,function(e){var r=t,n=r.lib,a=n.WordArray,o=n.Hasher,i=r.algo,s=[];!function(){for(var r=0;r<64;r++)s[r]=4294967296*e.abs(e.sin(r+1))|0}();var u=i.MD5=o.extend({_doReset:function(){this._hash=new a.init([1732584193,4023233417,2562383102,271733878])},_doProcessBlock:function(e,r){for(var t=0;t<16;t++){var n=r+t,a=e[n];e[n]=16711935&(a<<8|a>>>24)|4278255360&(a<<24|a>>>8)}var o=this._hash.words,i=e[r+0],u=e[r+1],d=e[r+2],h=e[r+3],v=e[r+4],y=e[r+5],g=e[r+6],b=e[r+7],m=e[r+8],w=e[r+9],x=e[r+10],k=e[r+11],S=e[r+12],j=e[r+13],O=e[r+14],E=e[r+15],C=o[0],A=o[1],R=o[2],P=o[3];C=c(C,A,R,P,i,7,s[0]),P=c(P,C,A,R,u,12,s[1]),R=c(R,P,C,A,d,17,s[2]),A=c(A,R,P,C,h,22,s[3]),C=c(C,A,R,P,v,7,s[4]),P=c(P,C,A,R,y,12,s[5]),R=c(R,P,C,A,g,17,s[6]),A=c(A,R,P,C,b,22,s[7]),C=c(C,A,R,P,m,7,s[8]),P=c(P,C,A,R,w,12,s[9]),R=c(R,P,C,A,x,17,s[10]),A=c(A,R,P,C,k,22,s[11]),C=c(C,A,R,P,S,7,s[12]),P=c(P,C,A,R,j,12,s[13]),R=c(R,P,C,A,O,17,s[14]),C=l(C,A=c(A,R,P,C,E,22,s[15]),R,P,u,5,s[16]),P=l(P,C,A,R,g,9,s[17]),R=l(R,P,C,A,k,14,s[18]),A=l(A,R,P,C,i,20,s[19]),C=l(C,A,R,P,y,5,s[20]),P=l(P,C,A,R,x,9,s[21]),R=l(R,P,C,A,E,14,s[22]),A=l(A,R,P,C,v,20,s[23]),C=l(C,A,R,P,w,5,s[24]),P=l(P,C,A,R,O,9,s[25]),R=l(R,P,C,A,h,14,s[26]),A=l(A,R,P,C,m,20,s[27]),C=l(C,A,R,P,j,5,s[28]),P=l(P,C,A,R,d,9,s[29]),R=l(R,P,C,A,b,14,s[30]),C=f(C,A=l(A,R,P,C,S,20,s[31]),R,P,y,4,s[32]),P=f(P,C,A,R,m,11,s[33]),R=f(R,P,C,A,k,16,s[34]),A=f(A,R,P,C,O,23,s[35]),C=f(C,A,R,P,u,4,s[36]),P=f(P,C,A,R,v,11,s[37]),R=f(R,P,C,A,b,16,s[38]),A=f(A,R,P,C,x,23,s[39]),C=f(C,A,R,P,j,4,s[40]),P=f(P,C,A,R,i,11,s[41]),R=f(R,P,C,A,h,16,s[42]),A=f(A,R,P,C,g,23,s[43]),C=f(C,A,R,P,w,4,s[44]),P=f(P,C,A,R,S,11,s[45]),R=f(R,P,C,A,E,16,s[46]),C=p(C,A=f(A,R,P,C,d,23,s[47]),R,P,i,6,s[48]),P=p(P,C,A,R,b,10,s[49]),R=p(R,P,C,A,O,15,s[50]),A=p(A,R,P,C,y,21,s[51]),C=p(C,A,R,P,S,6,s[52]),P=p(P,C,A,R,h,10,s[53]),R=p(R,P,C,A,x,15,s[54]),A=p(A,R,P,C,u,21,s[55]),C=p(C,A,R,P,m,6,s[56]),P=p(P,C,A,R,E,10,s[57]),R=p(R,P,C,A,g,15,s[58]),A=p(A,R,P,C,j,21,s[59]),C=p(C,A,R,P,v,6,s[60]),P=p(P,C,A,R,k,10,s[61]),R=p(R,P,C,A,d,15,s[62]),A=p(A,R,P,C,w,21,s[63]),o[0]=o[0]+C|0,o[1]=o[1]+A|0,o[2]=o[2]+R|0,o[3]=o[3]+P|0},_doFinalize:function(){var r=this._data,t=r.words,n=8*this._nDataBytes,a=8*r.sigBytes;t[a>>>5]|=128<<24-a%32;var o=e.floor(n/4294967296),i=n;t[15+(a+64>>>9<<4)]=16711935&(o<<8|o>>>24)|4278255360&(o<<24|o>>>8),t[14+(a+64>>>9<<4)]=16711935&(i<<8|i>>>24)|4278255360&(i<<24|i>>>8),r.sigBytes=4*(t.length+1),this._process();for(var s=this._hash,u=s.words,c=0;c<4;c++){var l=u[c];u[c]=16711935&(l<<8|l>>>24)|4278255360&(l<<24|l>>>8)}return s},clone:function(){var e=o.clone.call(this);return e._hash=this._hash.clone(),e}});function c(e,r,t,n,a,o,i){var s=e+(r&t|~r&n)+a+i;return(s<<o|s>>>32-o)+r}function l(e,r,t,n,a,o,i){var s=e+(r&n|t&~n)+a+i;return(s<<o|s>>>32-o)+r}function f(e,r,t,n,a,o,i){var s=e+(r^t^n)+a+i;return(s<<o|s>>>32-o)+r}function p(e,r,t,n,a,o,i){var s=e+(t^(r|~n))+a+i;return(s<<o|s>>>32-o)+r}r.MD5=o._createHelper(u),r.HmacMD5=o._createHmacHelper(u)}(Math),t.MD5)})),V=function(e){return Q(e)},X=function(e){return e.includes("/")&&e.split("/")[0]},K=function(e){return e.includes("/")?e.split("/")[1]:e},Z=function(e){return e.map((function(r){var t=r.query,n=e.find((function(e){return r.parentNode===e.node}));return void 0!==n&&(t=t.concat(n.query[0])),{type:"bgp",triples:t}}))},ee=function(e,r,n){var a=[],o=function(e){var r=[];if(e){var t,n=O(e);try{for(n.s();!(t=n.n()).done;){var a=t.value;if(a.includes("/"))for(var o=a.split("/"),i=1;i<=o.length;i++)r.push(o.slice(0,i).join("/"));else r.push(a)}}catch(e){n.e(e)}finally{n.f()}}return r}(e);if(o&&n&&n.length>0){var i,s=O(o);try{for(s.s();!(i=s.n()).done;){var u=i.value,c=X(u),l=K(u),f=V(u),p=c?V(c):"1",d=[t.triple(t.variable("s"+p),t.namedNode(z(l,n)),t.variable("s"+f)),t.triple(t.variable("s"+f),t.variable("p"+f),t.variable("o"+f))];a.push({node:u,parentNode:c,query:d,filter:""})}}catch(e){s.e(e)}finally{s.f()}return{construct:a.length>0?a.map((function(e){return e.query})).reduce((function(e,r){return e.concat(r)})):null,where:{type:"union",patterns:[r.where].concat(k(Z(a)))}}}return{construct:"",where:""}},re=l.default.literal,te=l.default.namedNode,ne=l.default.triple,ae=l.default.variable,oe=new(0,require("sparqljs").Generator)({}),ie=["q","sparqlWhere","blankNodes","_servers","_predicates"],se=function(e){var r=e.containers,t=e.params.filter,n=e.blankNodes,a=e.predicates,o=e.ontologies,i=G(a,o),s={queryType:"CONSTRUCT",template:i.construct,where:[],type:"query",prefixes:Object.fromEntries(o.map((function(e){return[e.prefix,e.url]})))},u=[{type:"values",values:r.map((function(e){return{"?containerUri":te(e)}}))},ne(ae("containerUri"),te("http://www.w3.org/ns/ldp#contains"),ae("s1")),{type:"filter",expression:{type:"operation",operator:"isiri",args:[ae("s1")]}}],c=[];if(t&&Object.keys(t).length>0){var l=t.sparqlWhere&&Object.keys(t.sparqlWhere).length>0,f=t.q&&t.q.length>0;l&&[].concat(t.sparqlWhere).forEach((function(e){c.push(e)})),f&&c.push({type:"group",patterns:[{queryType:"SELECT",variables:[ae("s1")],where:[ne(ae("s1"),ae("p1"),ae("o1")),{type:"filter",expression:{type:"operation",operator:"isliteral",args:[ae("o1")]}},{type:"filter",expression:{type:"operation",operator:"regex",args:[{type:"operation",operator:"lcase",args:[{type:"operation",operator:"str",args:[ae("o1")]}]},re(t.q.toLowerCase(),"",te("http://www.w3.org/2001/XMLSchema#string"))]}}],type:"query"}]}),Object.entries(t).forEach((function(e){var r=x(e,2),t=r[0],n=r[1];ie.includes(t)||c.unshift(ne(ae("s1"),te(z(t,o)),te(z(n,o))))}))}var p=ee(n,i,o);return p&&p.construct?(c=c.concat(p.where),s.template=s.template.concat(p.construct)):c.push(i.where),s.where.push({type:"union",patterns:[u,{type:"graph",name:te("http://semapps.org/mirror"),patterns:u}]},{type:"union",patterns:[c,{type:"graph",name:te("http://semapps.org/mirror"),patterns:c}]}),oe.stringify(s)},ue=function(e,r){for(var t=[],n=0,a=Object.keys(r);n<a.length;n++){var o=a[n];if(r[o].blankNodes)for(var i=0,s=Object.keys(r[o].blankNodes);i<s.length;i++){var u=s[i];e.includes(u)&&t.push.apply(t,k(r[o].blankNodes[u]))}}return k(new Set(t))},ce=["@context"],le=function(e,r){switch(v(e)){case"string":return e.localeCompare(r);case"number":case"bigint":return e-r;default:return 0}},fe=function(){var e=g(regeneratorRuntime.mark((function e(r,t,n,a){var o,i,s,c,l,f,p,d,v,y;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return o=a.dataServers,i=a.resources,s=a.httpClient,c=a.jsonContext,l=a.ontologies,f=i[t],p=Object.keys(r).map((function(e){return new Promise((function(t,a){var i,p,d,v,y,g,b=(null===(i=n.filter)||void 0===i?void 0:i.blankNodes)||(null===(p=f.list)||void 0===p?void 0:p.blankNodes)||ue(r[e],o),m=(null===(d=n.filter)||void 0===d?void 0:d._predicates)||(null===(v=f.list)||void 0===v?void 0:v.predicates);null!==(y=n.filter)&&void 0!==y&&y.sparqlWhere&&("string"==typeof n.filter.sparqlWhere||n.filter.sparqlWhere instanceof String)&&(n.filter.sparqlWhere=JSON.parse(decodeURIComponent(n.filter.sparqlWhere)));var x=se({containers:r[e],params:h(h({},n),{},{filter:h(h({},null===(g=f.list)||void 0===g?void 0:g.filter),n.filter)}),blankNodes:b,predicates:m,ontologies:l});s(o[e].sparqlEndpoint,{method:"POST",body:x}).then((function(e){var r,t=e.json,n=!1!==(null===(r=f.list)||void 0===r?void 0:r.explicitEmbedOnFraming)?h({"@context":c,"@type":f.types,"@embed":"@never"},J(b)):{"@context":c,"@type":f.types};return u.default.frame(t,n,{omitGraph:!1})})).then((function(e){if(e["@id"]){var r=e;e={"@context":r["@context"],"@graph":[w(r,ce)]}}t(e["@graph"]||[])})).catch((function(e){return a(e)}))}))})),e.next=5,Promise.all(p);case 5:if(0!==(d=e.sent).length){e.next=10;break}return e.abrupt("return",{data:[],total:0});case 10:return d=(v=[]).concat.apply(v,k(d)),y=d.map((function(e){return e.id=e.id||e["@id"],e})),n.sort&&(y=y.sort((function(e,r){return void 0!==e[n.sort.field]&&void 0!==r[n.sort.field]?"ASC"===n.sort.order?le(e[n.sort.field],r[n.sort.field]):le(r[n.sort.field],e[n.sort.field]):0}))),n.pagination&&(y=y.slice((n.pagination.page-1)*n.pagination.perPage,n.pagination.page*n.pagination.perPage)),e.abrupt("return",{data:y,total:d.length});case 15:case"end":return e.stop()}}),e)})));return function(r,t,n,a){return e.apply(this,arguments)}}(),pe=function(e,r){var t={};return Object.keys(e).forEach((function(n){if(!r[n])throw new Error("No server found with key "+n);t[n]=[],e[n].forEach((function(e){t[n].push(A(r[n].baseUrl,e))}))})),t},de=function(e){return function(){var r=g(regeneratorRuntime.mark((function r(t){var n,a,o,i,s,u,c,l,f,p,d,h=arguments;return regeneratorRuntime.wrap((function(r){for(;;)switch(r.prev=r.next){case 0:if(i=h.length>1&&void 0!==h[1]?h[1]:{},s=e.dataServers,u=e.resources,c=u[t]){r.next=5;break}throw new Error("Resource ".concat(t," is not mapped in resources file"));case 5:if(null!==(n=i.filter)&&void 0!==n&&n._servers||null===(a=c.list)||void 0===a||!a.containers){r.next=11;break}if(!Array.isArray(null===(f=c.list)||void 0===f?void 0:f.containers)){r.next=8;break}throw new Error("The list.containers property of ".concat(t," dataModel must be of type object ({ serverKey: [containerUri] })"));case 8:l=pe(c.list.containers,s),r.next=12;break;case 11:l=D(c.types,(null===(p=i.filter)||void 0===p?void 0:p._servers)||(null===(d=c.list)||void 0===d?void 0:d.servers),s);case 12:if(null===(o=c.list)||void 0===o||!o.fetchContainer){r.next=16;break}return r.abrupt("return",W(l,t,i,e));case 16:return r.abrupt("return",fe(l,t,i,e));case 17:case"end":return r.stop()}}),r)})));return function(e){return r.apply(this,arguments)}}()},he=function(e){return function(){var r=g(regeneratorRuntime.mark((function r(t,n){var a,o;return regeneratorRuntime.wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return a=e.returnFailedResources,r.next=3,Promise.all(n.ids.map((function(r){return P(e)(t,{id:"object"===v(r)?r["@id"]:r}).then((function(e){return e.data})).catch((function(){if(a)return{id:r,_error:!0}}))})));case 3:return o=(o=r.sent).filter((function(e){return e})),r.abrupt("return",{data:o});case 6:case"end":return r.stop()}}),r)})));return function(e,t){return r.apply(this,arguments)}}()},ve=function(e){return function(){var r=g(regeneratorRuntime.mark((function r(t,n){return regeneratorRuntime.wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return n.filter=h(h({},n.filter),{},b({},n.target,n.id)),delete n.target,r.next=4,de(e)(t,n);case 4:return r.abrupt("return",r.sent);case 5:case"end":return r.stop()}}),r)})));return function(e,t){return r.apply(this,arguments)}}()},ye=function(e){return function(){var r=g(regeneratorRuntime.mark((function r(t,n){var a,o;return regeneratorRuntime.wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return a=e.httpClient,o=e.jsonContext,r.next=3,_(n.data,e);case 3:return n.data=r.sent,r.next=6,a(n.id,{method:"PUT",body:JSON.stringify(h({"@context":o},n.data))});case 6:return r.abrupt("return",{data:n.data});case 7:case"end":return r.stop()}}),r)})));return function(e,t){return r.apply(this,arguments)}}()};function ge(e){this.message=e}ge.prototype=new Error,ge.prototype.name="InvalidCharacterError";var be="undefined"!=typeof window&&window.atob&&window.atob.bind(window)||function(e){var r=String(e).replace(/=+$/,"");if(r.length%4==1)throw new ge("'atob' failed: The string to be decoded is not correctly encoded.");for(var t,n,a=0,o=0,i="";n=r.charAt(o++);~n&&(t=a%4?64*t+n:n,a++%4)?i+=String.fromCharCode(255&t>>(-2*a&6)):0)n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(n);return i};function me(e){var r=e.replace(/-/g,"+").replace(/_/g,"/");switch(r.length%4){case 0:break;case 2:r+="==";break;case 3:r+="=";break;default:throw"Illegal base64url string!"}try{return function(e){return decodeURIComponent(be(e).replace(/(.)/g,(function(e,r){var t=r.charCodeAt(0).toString(16).toUpperCase();return t.length<2&&(t="0"+t),"%"+t})))}(r)}catch(e){return be(r)}}function we(e){this.message=e}function xe(e,r){if("string"!=typeof e)throw new we("Invalid token specified");var t=!0===(r=r||{}).header?0:1;try{return JSON.parse(me(e.split(".")[t]))}catch(e){throw new we("Invalid token specified: "+e.message)}}we.prototype=new Error,we.prototype.name="InvalidTokenError";var ke=function(){var e=g(regeneratorRuntime.mark((function e(r){var t,n,a,o,i,s,u,c,l,f,p,d;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t=r.dataServers,n=r.httpClient,a=localStorage.getItem("token"),o=U("pod",t),i=U("authServer",t),!a){e.next=24;break}return s=xe(a),u=s.webId,e.prev=6,e.next=9,n(u);case 9:l=e.sent,f=l.json,c=f,e.next=20;break;case 14:return e.prev=14,e.t0=e.catch(6),console.error(e.t0),localStorage.clear(),window.location.reload(),e.abrupt("return");case 20:o&&(r.dataServers[o].name="My Pod",r.dataServers[o].baseUrl=A(u,"data"),r.dataServers[o].sparqlEndpoint=(null===(p=c.endpoints)||void 0===p?void 0:p["void:sparqlEndpoint"])||A(u,"sparql")),i&&(r.dataServers[i].proxyUrl=null===(d=c.endpoints)||void 0===d?void 0:d.proxyUrl),e.next=24;break;case 24:case"end":return e.stop()}}),e,null,[[6,14]])})));return function(r){return e.apply(this,arguments)}}(),Se=function(e){return e?Array.isArray(e)?e:[e]:void 0},je=function(){var e=g(regeneratorRuntime.mark((function e(r){var t,n,a,o,i,s,u,c;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=Object.entries(r.dataServers).filter((function(e){var r=x(e,2);return r[0],!0!==r[1].pod})).map((function(e){var t=x(e,2),n=t[0],a=t[1];return r.httpClient(new URL("/.well-known/void",a.baseUrl).toString()).then((function(e){return{key:n,datasets:e.json["@graph"]}})).catch((function(e){if(404===e.status||401===e.status)return{key:n,error:e};throw e}))})),n=[],e.prev=2,e.next=5,Promise.all(t);case 5:n=e.sent,e.next=10;break;case 8:e.prev=8,e.t0=e.catch(2);case 10:a=O(n);try{for(a.s();!(o=a.n()).done;)if(i=o.value,r.dataServers[i.key].containers=r.dataServers[i.key].containers||{},r.dataServers[i.key].blankNodes=r.dataServers[i.key].blankNodes||{},i.datasets){s=O(i.datasets);try{for(c=function(){var e=u.value,t=Object.keys(r.dataServers).find((function(t){return e["void:uriSpace"]===r.dataServers[t].baseUrl}));if(t){t===i.key&&(r.dataServers[i.key].name=r.dataServers[i.key].name||e["dc:title"],r.dataServers[i.key].description=r.dataServers[i.key].description||e["dc:description"],r.dataServers[i.key].sparqlEndpoint=r.dataServers[i.key].sparqlEndpoint||e["void:sparqlEndpoint"]),r.dataServers[i.key].containers[t]=r.dataServers[i.key].containers[t]||{};var n,a=O(Se(e["void:classPartition"]));try{for(a.s();!(n=a.n()).done;){var o,s=n.value,c=O(Se(s["void:class"]));try{for(c.s();!(o=c.n()).done;){var l=o.value,f=s["void:uriSpace"].replace(e["void:uriSpace"],"/");r.dataServers[i.key].containers[t][l]?r.dataServers[i.key].containers[t][l].push(f):r.dataServers[i.key].containers[t][l]=[f],Se(s["semapps:blankNodes"])&&(r.dataServers[i.key].blankNodes[s["void:uriSpace"]]=Se(s["semapps:blankNodes"]))}}catch(e){c.e(e)}finally{c.f()}}}catch(e){a.e(e)}finally{a.f()}}},s.s();!(u=s.n()).done;)c()}catch(e){s.e(e)}finally{s.f()}}}catch(e){a.e(e)}finally{a.f()}case 12:case"end":return e.stop()}}),e,null,[[2,8]])})));return function(r){return e.apply(this,arguments)}}(),Oe=function(e,r){return Object.keys(r).find((function(t){return r[t].pod?r[t].baseUrl&&e.startsWith(r[t].baseUrl.replace("/data","")):e.startsWith(r[t].baseUrl)}))},Ee=function(e,r){return"function"==typeof e?e(r):e},Ce=function(e){return"string"==typeof e&&e.startsWith("http")},Ae=function(e){var r=o.useContext(a.DataProviderContext),t=x(o.useState(),2),n=t[0],i=t[1];return o.useEffect((function(){r.getDataModels().then((function(r){return i(r[e])}))}),[r,e,i]),n},Re=function(){var e=o.useContext(a.DataProviderContext),r=x(o.useState(),2),t=r[0],n=r[1];return o.useEffect((function(){e.getDataServers().then((function(e){return n(e)}))}),[e,n]),t},Pe=function(e,r,t){var n=[];if(Object.keys(t[r].containers[r]).length>0&&Object.keys(t[r].containers[r]).forEach((function(a){e.includes(a)&&t[r].containers[r][a].map((function(e){var a=A(t[r].baseUrl,e);n.includes(a)||n.push(a)}))})),0===n.length)throw new Error("No container found matching with types ".concat(JSON.stringify(e),". You can set explicitely the create.container property of the resource."));if(n.length>1)throw new Error("More than one container found matching with types ".concat(JSON.stringify(e),". You must set the create.server or create.container property for the resource."));return n[0]},Te=["children","record","filter","source"],qe=function(e){var r=e.children,t=e.record,n=e.filter,a=e.source,i=w(e,Te),s=x(o.useState(),2),u=s[0],c=s[1];return o.useEffect((function(){if(t&&a&&Array.isArray(null==t?void 0:t[a])){var e=null==t?void 0:t[a].filter((function(e){var r=!0;for(var t in n){var a=e[t];Array.isArray(a)?a.includes(n[t])||(r=!1):a!==n[t]&&(r=!1)}return r})),r=h({},t);r[a]=e.length>0?e:void 0,c(r)}}),[t,a,n]),p.default.createElement(p.default.Fragment,null,p.default.Children.map(r,(function(e,r){return p.default.cloneElement(e,h(h({},i),{},{record:u,addLabel:!0,source:a}))})))},Ne=["children","groupReference","groupLabel","groupHeader","filterProperty"],_e=["reificationClass","children"],Ue=i.makeStyles({form:{display:"flex"},input:{paddingRight:"20px"}}),Ie=i.makeStyles({root:{display:"none"}});exports.FilterHandler=qe,exports.GroupedReferenceHandler=function(e){var r=e.children,t=e.groupReference,n=e.groupLabel,o=e.groupHeader,i=e.filterProperty,s=w(e,Ne),u=a.useQueryWithStore({type:"getList",resource:t,payload:{}}).data;return p.default.createElement(p.default.Fragment,null,null==u?void 0:u.map((function(e,t){var a={};return a[i]=e.id,p.default.createElement(p.default.Fragment,null,o&&o(h(h({},s),{},{group:e})),p.default.createElement(qe,m({},s,{filter:a,label:e[n]}),r))})))},exports.ReificationArrayInput=function(e){var r=e.reificationClass;e.children;var t=w(e,_e),n=Ue(),o=Ie();return p.default.createElement(a.ArrayInput,t,p.default.createElement(a.SimpleFormIterator,{classes:{form:n.form}},p.default.Children.map(e.children,(function(e,r){return p.default.cloneElement(e,{className:n.input})})),p.default.createElement(a.TextInput,{className:o.root,source:"type",initialValue:r})))},exports.buildBlankNodesQuery=ee,exports.buildSparqlQuery=se,exports.dataProvider=function(e){if(!U("default",e.dataServers))throw new Error("You must define a default server in your dataServers config");var r;e.jsonContext||(e.jsonContext=Object.fromEntries(e.ontologies.map((function(e){return[e.prefix,e.url]})))),e.returnFailedResources||(e.returnFailedResources=!1),e.httpClient=(r=e.dataServers,function(e){var t,n,o=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},i=U("authServer",r),s=Oe(e,r),u=s!==i&&(null===(t=r[i])||void 0===t?void 0:t.proxyUrl)&&!0!==(null===(n=r[s])||void 0===n?void 0:n.noProxy);switch(o.headers||(o.headers=new Headers),o.method){case"POST":case"PATCH":case"PUT":o.headers.has("Accept")||o.headers.set("Accept","application/ld+json"),o.headers.has("Content-Type")||o.headers.set("Content-Type","application/ld+json");break;case"DELETE":break;case"GET":default:o.headers.has("Accept")||o.headers.set("Accept","application/ld+json")}if(u){var c=new FormData;return c.append("id",e),c.append("method",o.method||"GET"),c.append("headers",JSON.stringify(Object.fromEntries(o.headers.entries()))),o.body&&(o.body instanceof File?c.append("body",o.body,o.body.name):c.append("body",o.body)),a.fetchUtils.fetchJson(r[i].proxyUrl,{method:"POST",headers:new Headers({Authorization:"Bearer ".concat(localStorage.getItem("token"))}),body:c})}if(s===i){var l=localStorage.getItem("token");l&&o.headers.set("Authorization","Bearer ".concat(l))}return a.fetchUtils.fetchJson(e,o)});var t=ke(e),n=je(e),o=function(e){return g(regeneratorRuntime.mark((function r(){var a=arguments;return regeneratorRuntime.wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return r.next=2,t;case 2:return r.next=4,n;case 4:return r.next=6,e.apply(void 0,a);case 6:return r.abrupt("return",r.sent);case 7:case"end":return r.stop()}}),r)})))};return{getList:o(de(e)),getMany:o(he(e)),getManyReference:o(ve(e)),getOne:o(P(e)),create:o(M(e)),update:o(ye(e)),updateMany:function(){throw new Error("updateMany is not implemented yet")},delete:o(B(e)),deleteMany:o(L(e)),getDataModels:o(F(e)),getDataServers:o(H(e)),getLocalDataServers:H(e),fetch:o(e.httpClient)}},exports.useContainers=function(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"@all",t=Ae(e),n=Re(),a=o.useState(),i=x(a,2),s=i[0],u=i[1];return o.useEffect((function(){t&&n&&u(D(t.types,r,n))}),[t,n,r]),s},exports.useCreateContainer=function(e){var r=Ae(e),t=Re(),n=x(o.useState(),2),a=n[0],i=n[1];return o.useEffect((function(){var n,a;if(r&&t)if(null!==(n=r.create)&&void 0!==n&&n.container){var o=x(Object.entries(r.create.container)[0],2),s=o[0],u=o[1];if(!s||!t[s])throw new Error("Wrong key for the dataModel.create.container config of resource "+e);i(A(t[s].baseUrl,u))}else if(null!==(a=r.create)&&void 0!==a&&a.server){var c;i(Pe(r.types,null===(c=r.create)||void 0===c?void 0:c.server,t))}else{var l=U("default",t);i(Pe(r.types,l,t))}}),[r,t,i]),a},exports.useDataModel=Ae,exports.useDataModels=function(){var e=o.useContext(a.DataProviderContext),r=x(o.useState(),2),t=r[0],n=r[1];return o.useEffect((function(){e.getDataModels().then((function(e){return n(e)}))}),[e,n]),t},exports.useDataServers=Re,exports.useGetExternalLink=function(e){var r=o.useContext(a.DataProviderContext).getLocalDataServers(),t=o.useMemo((function(){if(r)return Object.fromEntries(Object.values(r).map((function(e){var r=void 0!==e.externalLinks?e.externalLinks:!e.default;return[e.baseUrl,r]})))}),[r]);return o.useCallback((function(r){var n=Ee(e,r);if(!1===n)return!1;if(null==r||!r.id)return!1;var a=Object.keys(t).find((function(e){return null==r?void 0:r.id.startsWith(e)}));if(!a)return!1;var o=Ee(t[a],r);return!1!==o&&(Ce(n)?n:Ce(o)?o:r.id)}),[t,e])};
|
|
4
2
|
//# sourceMappingURL=index.cjs.js.map
|