solid-ui
Version:
UI library for Solid applications
1 lines • 524 kB
JavaScript
import*as e from"rdflib";import*as t from"solid-logic";var n={6466(e,t,n){n.d(t,{v:()=>h});var a=n(467),i=n(3029),r=n(2901),o=n(4756),s=n.n(o),c=n(5619),l=n(4961),u=n(1214),p=n(7367),d=n(9612),m=n(7423),f=n(675),h=function(){return(0,r.A)(function e(t,n,a,r,o,s,l,p,d,m,h,v){if((0,i.A)(this,e),this.subject=t,this.noun=n,this.context=a,this.statusElement=r,this.targetIsProtected=o,this.targetDoc=s,this.targetACLDoc=l,this.defaultHolder=p,this.defaultACLDoc=d,this.prospectiveDefaultHolder=m,this.store=h,this.dom=v,this.rootElement=v.createElement("div"),this.rootElement.setAttribute("style",f.i.aclGroupContent),this.isContainer="/"===s.uri.slice(-1),p&&d){this.isUsingDefaults=!0;var x=(0,c._E)(this.targetDoc,l,p,d);this.mainCombo=new u.h(s,l,this,x,{defaults:this.isContainer}),this.defaultsCombo=null,this.defaultsDiffer=!1}else this.isUsingDefaults=!1,this.mainCombo=new u.h(s,l,this,h),this.defaultsCombo=new u.h(s,l,this,h,{defaults:this.isContainer}),this.defaultsDiffer=!(0,c.P3)(this.mainCombo.aclMap,this.defaultsCombo.aclMap)},[{key:"isEditable",get:function(){return!this.isUsingDefaults}},{key:"render",value:function(){if(this.rootElement.innerHTML="",this.isUsingDefaults){if(this.renderStatus("The sharing for this ".concat(this.noun," is the default for folder ")),this.defaultHolder){var e=this.statusElement.appendChild(this.dom.createElement("a"));e.href=this.defaultHolder.uri,e.innerText=(0,p.DR)(this.defaultHolder)}}else!this.defaultsDiffer&&this.isContainer?this.renderStatus("This is also the default for things in this folder."):this.renderStatus("");return this.rootElement.appendChild(this.mainCombo.render()),this.defaultsCombo&&this.defaultsDiffer?(this.rootElement.appendChild(this.renderRemoveDefaultsController()),this.rootElement.appendChild(this.defaultsCombo.render())):this.isEditable&&this.isContainer&&this.rootElement.appendChild(this.renderAddDefaultsController()),!this.targetIsProtected&&this.isUsingDefaults?this.rootElement.appendChild(this.renderAddAclsController()):this.targetIsProtected||this.rootElement.appendChild(this.renderRemoveAclsController()),this.rootElement}},{key:"renderRemoveAclsController",value:function(){var e=this,t=this.dom.createElement("button");return t.innerText="Remove custom sharing settings for this ".concat(this.noun," -- just use default").concat(this.prospectiveDefaultHolder?" for ".concat(d.P(this.prospectiveDefaultHolder)):""),t.setAttribute("style",f.i.bigButton),t.addEventListener("click",function(){return e.removeAcls().then(function(){return e.render()}).catch(function(t){return e.renderStatus(t)})}),t}},{key:"renderAddAclsController",value:function(){var e=this,t=this.dom.createElement("button");return t.innerText="Set specific sharing for this ".concat(this.noun),t.setAttribute("style",f.i.bigButton),t.addEventListener("click",function(){return e.addAcls().then(function(){return e.render()}).catch(function(t){return e.renderStatus(t)})}),t}},{key:"renderAddDefaultsController",value:function(){var e=this,t=this.dom.createElement("div");t.setAttribute("style",f.i.defaultsController);var n=t.appendChild(this.dom.createElement("div"));n.innerText="Sharing for things within the folder currently tracks sharing for the folder.",n.setAttribute("style",f.i.defaultsControllerNotice);var a=t.appendChild(this.dom.createElement("button"));return a.innerText="Set the sharing of folder contents separately from the sharing for the folder",a.setAttribute("style",f.i.bigButton),a.addEventListener("click",function(){return e.addDefaults().then(function(){return e.render()})}),t}},{key:"renderRemoveDefaultsController",value:function(){var e=this,t=this.dom.createElement("div");t.setAttribute("style",f.i.defaultsController);var n=t.appendChild(this.dom.createElement("div"));n.innerText="Access to things within this folder:",n.setAttribute("style",f.i.defaultsControllerNotice);var a=t.appendChild(this.dom.createElement("button"));return a.innerText="Set default for folder contents to just track the sharing for the folder",a.setAttribute("style",f.i.bigButton),a.addEventListener("click",function(){return e.removeDefaults().then(function(){return e.render()}).catch(function(t){return e.renderStatus(t)})}),t}},{key:"renderTemporaryStatus",value:function(e){var t=this;this.statusElement.setAttribute("style",f.i.aclControlBoxStatusRevealed),this.statusElement.innerText=e,this.statusElement.setAttribute("style",f.i.temporaryStatusInit),setTimeout(function(){t.statusElement.setAttribute("style",f.i.temporaryStatusEnd)}),setTimeout(function(){t.statusElement.innerText=""},5e3)}},{key:"renderStatus",value:function(e){e||this.statusElement.setAttribute("style",f.i.aclControlBoxStatusRevealed),this.statusElement.innerText=e}},{key:"addAcls",value:(o=(0,a.A)(s().mark(function e(){var t,n,a,i=this;return s().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(this.defaultHolder&&this.defaultACLDoc){e.next=1;break}return t="Unable to find defaults to copy",m.z3(t),e.abrupt("return",Promise.reject(t));case 1:return(0,c._E)(this.targetDoc,this.targetACLDoc,this.defaultHolder,this.defaultACLDoc).statements.forEach(function(e){return i.store.add(e.subject,e.predicate,e.object,i.targetACLDoc)}),e.prev=2,e.next=3,this.store.fetcher.putBack(this.targetACLDoc);case 3:return this.isUsingDefaults=!1,e.abrupt("return",Promise.resolve());case 4:return e.prev=4,a=e.catch(2),n=" Error writing back access control file! ".concat(a),m.z3(n),e.abrupt("return",Promise.reject(n));case 5:case"end":return e.stop()}},e,this,[[2,4]])})),function(){return o.apply(this,arguments)})},{key:"addDefaults",value:(n=(0,a.A)(s().mark(function e(){return s().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:this.defaultsCombo=new u.h(this.targetDoc,this.targetACLDoc,this,this.store,{defaults:!0}),this.defaultsDiffer=!0;case 1:case"end":return e.stop()}},e,this)})),function(){return n.apply(this,arguments)})},{key:"removeAcls",value:(t=(0,a.A)(s().mark(function e(){var t,n,a;return s().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=1,this.store.fetcher.delete(this.targetACLDoc.uri,{});case 1:return this.isUsingDefaults=!0,e.prev=2,e.next=3,(0,c.L$)(this.targetDoc.uri);case 3:this.prospectiveDefaultHolder=e.sent,e.next=5;break;case 4:e.prev=4,n=e.catch(2),m.R8(n);case 5:e.next=7;break;case 6:return e.prev=6,a=e.catch(0),t="Error deleting access control file: ".concat(this.targetACLDoc,": ").concat(a),m.z3(t),e.abrupt("return",Promise.reject(t));case 7:case"end":return e.stop()}},e,this,[[0,6],[2,4]])})),function(){return t.apply(this,arguments)})},{key:"removeDefaults",value:(e=(0,a.A)(s().mark(function e(){var t,n;return s().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return t=this.defaultsCombo,e.prev=1,this.defaultsCombo=null,this.defaultsDiffer=!1,e.next=2,this.save();case 2:e.next=4;break;case 3:return e.prev=3,n=e.catch(1),this.defaultsCombo=t,this.defaultsDiffer=!0,m.z3(n),e.abrupt("return",Promise.reject(n));case 4:case"end":return e.stop()}},e,this,[[1,3]])})),function(){return e.apply(this,arguments)})},{key:"save",value:function(){var e=this,t=(0,l.graph)();this.isContainer?this.defaultsCombo&&this.defaultsDiffer?((0,c.cl)(t,this.targetDoc,this.mainCombo.byCombo,this.targetACLDoc,!0),(0,c.cl)(t,this.targetDoc,this.defaultsCombo.byCombo,this.targetACLDoc,!1,!0)):(0,c.cl)(t,this.targetDoc,this.mainCombo.byCombo,this.targetACLDoc,!0,!0):(0,c.cl)(t,this.targetDoc,this.mainCombo.byCombo,this.targetACLDoc,!0),t.fetcher=(0,l.fetcher)(t,{fetch:this.store.fetcher._fetch});var n=t.updater||new l.UpdateManager(t);return new Promise(function(a,i){n.put(e.targetACLDoc,t.statementsMatching(void 0,void 0,void 0,e.targetACLDoc),"text/turtle",function(n,r,o){if(!r)return i(new Error("ACL file save failed: ".concat(o)));e.store.fetcher.unload(e.targetACLDoc),e.store.add(t.statements),e.store.fetcher.requested[e.targetACLDoc.uri]="done",e.mainCombo.store=e.store,e.defaultsCombo&&(e.defaultsCombo.store=e.store),e.defaultsDiffer=!!e.defaultsCombo&&!(0,c.P3)(e.mainCombo.aclMap,e.defaultsCombo.aclMap),m.Rm("ACL modification: success!"),a()})})}}]);var e,t,n,o}()},1214(e,t,n){n.d(t,{h:()=>w});var a=n(467),i=n(3453),r=n(3029),o=n(2901),s=n(4756),c=n.n(s),l=n(4961),u=n(5619),p=n(386),d=n(3291),m=n(1795),f=n(1928),h=n(7423),v=n(675),x=m.A.acl,b={13:"Owners",9:"Owners (write locked)",5:"Editors",3:"Posters",2:"Submitters",1:"Viewers"},g={13:!0,5:!0,3:!0,2:!0,1:!0},y={13:"can read, write, and control sharing.",9:"can read and control sharing, currently write-locked.",5:"can read and change information",3:"can add new information, and read but not change existing information",2:"can add new information but not read any",1:"can read but not change information"},w=function(){return(0,o.A)(function e(t,n,a,i){var o=arguments.length>4&&void 0!==arguments[4]?arguments[4]:{};(0,r.A)(this,e),this.doc=t,this.aclDoc=n,this.controller=a,this._options=o,this.defaults=this._options.defaults||!1,this._store=i,this.aclMap=(0,u.fg)(t,n,i,this.defaults),this.byCombo=(0,u.xw)(this.aclMap),this.addAgentButton=new f.g(this),this.rootElement=this.controller.dom.createElement("div"),this.rootElement.setAttribute("style",v.i.accessGroupList)},[{key:"store",get:function(){return this._store},set:function(e){this._store=e,this.aclMap=(0,u.fg)(this.doc,this.aclDoc,e,this.defaults),this.byCombo=(0,u.xw)(this.aclMap)}},{key:"render",value:function(){var e=this;return this.rootElement.innerHTML="",this.renderGroups().forEach(function(t){return e.rootElement.appendChild(t)}),this.controller.isEditable&&this.rootElement.appendChild(this.addAgentButton.render()),this.rootElement}},{key:"renderGroups",value:function(){for(var e=[],t=15;t>0;t--){var n=A(t);(this.controller.isEditable&&g[t]||this.byCombo[n])&&e.push(this.renderGroup(t,n))}return e}},{key:"renderGroup",value:function(e,t){var n=this,a=this.controller.dom.createElement("div");return a.setAttribute("style",v.i.accessGroupListItem),p.DK(a,function(e){return n.handleDroppedUris(e,t).then(function(){return n.controller.render()}).catch(function(e){return n.controller.renderStatus(e)})}),this.renderGroupElements(e,t).forEach(function(e){return a.appendChild(e)}),a}},{key:"renderGroupElements",value:function(e,t){var n=this,a=this.controller.dom.createElement("div");if(a.setAttribute("style",v.i.group),this.controller.isEditable)switch(e){case 1:a.setAttribute("style",v.i.group1);break;case 2:a.setAttribute("style",v.i.group2);break;case 3:a.setAttribute("style",v.i.group3);break;case 5:a.setAttribute("style",v.i.group5);break;case 9:a.setAttribute("style",v.i.group9);break;case 13:a.setAttribute("style",v.i.group13);break;default:a.setAttribute("style",v.i.group)}a.innerText=b[e]||function(e){for(var t="",n=["Read","Append","Write","Control"],a=0;a<4;a++)e&1<<a&&(t+=n[a]);return t}(e);var r=this.controller.dom.createElement("div");if(r.setAttribute("style",v.i.group),this.controller.isEditable)switch(e){case 1:r.setAttribute("style",v.i.group1);break;case 2:r.setAttribute("style",v.i.group2);break;case 3:r.setAttribute("style",v.i.group3);break;case 5:r.setAttribute("style",v.i.group5);break;case 9:r.setAttribute("style",v.i.group9);break;case 13:r.setAttribute("style",v.i.group13);break;default:r.setAttribute("style",v.i.group)}var o=r.appendChild(this.controller.dom.createElement("table"));(this.byCombo[t]||[]).map(function(e){var a=(0,i.A)(e,2),r=a[0],s=a[1];return n.renderAgent(o,t,r,s)}).forEach(function(e){return o.appendChild(e)});var s=this.controller.dom.createElement("div");if(s.setAttribute("style",v.i.group),this.controller.isEditable)switch(e){case 1:s.setAttribute("style",v.i.group1);break;case 2:s.setAttribute("style",v.i.group2);break;case 3:s.setAttribute("style",v.i.group3);break;case 5:s.setAttribute("style",v.i.group5);break;case 9:s.setAttribute("style",v.i.group9);break;case 13:s.setAttribute("style",v.i.group13);break;default:s.setAttribute("style",v.i.group)}return s.innerText=y[e]||"Unusual combination",[a,r,s]}},{key:"renderAgent",value:function(e,t,n,a){var i=this,r=d.Cl(this.controller.dom,x(n),(0,l.sym)(a),this.controller.isEditable?{deleteFunction:function(){return i.deleteAgent(t,n,a).then(function(){return e.removeChild(r)}).catch(function(e){return i.controller.renderStatus(e)})}}:{});return r}},{key:"deleteAgent",value:(s=(0,a.A)(c().mark(function e(t,n,a){var r,o;return c().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return r=this.byCombo[t]||[],(o=r.find(function(e){var t=(0,i.A)(e,2),r=t[0],o=t[1];return r===n&&o===a}))&&r.splice(r.indexOf(o),1),e.next=1,this.controller.save();case 1:case"end":return e.stop()}},e,this)})),function(e,t,n){return s.apply(this,arguments)})},{key:"addNewURI",value:(n=(0,a.A)(c().mark(function e(t){return c().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=1,this.handleDroppedUri(t,A(1));case 1:return e.next=2,this.controller.save();case 2:case"end":return e.stop()}},e,this)})),function(e){return n.apply(this,arguments)})},{key:"handleDroppedUris",value:(t=(0,a.A)(c().mark(function e(t,n){var a,i=this;return c().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=1,Promise.all(t.map(function(e){return i.handleDroppedUri(e,n)}));case 1:return e.next=2,this.controller.save();case 2:e.next=4;break;case 3:return e.prev=3,a=e.catch(0),e.abrupt("return",Promise.reject(a));case 4:case"end":return e.stop()}},e,this,[[0,3]])})),function(e,n){return t.apply(this,arguments)})},{key:"handleDroppedUri",value:(e=(0,a.A)(c().mark(function e(t,n){var a,i,r,o,s,u,p,d,m,f=arguments;return c().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(a=f.length>2&&void 0!==f[2]&&f[2],i=k(t,this.store),r=(0,l.sym)(t),i||a){e.next=5;break}return h.Rm(" Not obvious: looking up dropped thing ".concat(r)),e.prev=1,e.next=2,null===(o=this._store)||void 0===o||null===(o=o.fetcher)||void 0===o?void 0:o.load(r.doc());case 2:e.next=4;break;case 3:return e.prev=3,m=e.catch(1),s="Ignore error looking up dropped thing: ".concat(m),h.z3(s),e.abrupt("return",Promise.reject(new Error(s)));case 4:return e.abrupt("return",this.handleDroppedUri(t,n,!0));case 5:if(i){e.next=6;break}return u=Object.keys(this.store.findTypeURIs(r)),p=u.length>0?"Detected RDF types: ".concat(u.join(", ")):"No RDF type was detected for this URI.",d="Error: Failed to add access target: ".concat(t," is not a recognized ACL target type.")+" Expected one of: vcard:WebID, vcard:Group, foaf:Person, foaf:Agent, solid:AppProvider, solid:AppProviderClass, or recognized ACL classes. Hint: try dropping a WebID profile URI, a vcard:Group URI, or a web app origin."+p,h.z3(d),e.abrupt("return",Promise.reject(new Error(d)));case 6:this.setACLCombo(n,t,i,this.controller.subject);case 7:case"end":return e.stop()}},e,this,[[1,3]])})),function(t,n){return e.apply(this,arguments)})},{key:"setACLCombo",value:function(e,t,n,a){e in this.byCombo||(this.byCombo[e]=[]),this.removeAgentFromCombos(t),this.byCombo[e].push([n.pred,n.obj.uri]),h.Rm("ACL: setting access to ".concat(a," by ").concat(n.pred,": ").concat(n.obj))}},{key:"removeAgentFromCombos",value:function(e){for(var t=0;t<16;t++){var n=this.byCombo[A(t)];if(n)for(var a=0;a<n.length;a++)for(;a<n.length&&n[a][1]===e;)n.splice(a,1)}}}]);var e,t,n,s}();function A(e){for(var t=["Read","Append","Write","Control"],n=[],a=0;a<4;a++)e&1<<a&&n.push("http://www.w3.org/ns/auth/acl#"+t[a]);return n.sort(),n.join("\n")}function k(e,t){var n=(0,l.sym)(e),a=t.findTypeURIs(n);for(var i in a)h.Rm(" drop object type includes: "+i);if(e.startsWith("http")&&3===e.split("/").length)return{pred:"origin",obj:n};if(e.startsWith("http")&&4===e.split("/").length&&e.endsWith("/"))return h.Rm("Assuming final slash on dragged origin URI was unintended!"),{pred:"origin",obj:(0,l.sym)(e.slice(0,-1))};if(m.A.vcard("WebID").uri in a)return{pred:"agent",obj:n};if(m.A.vcard("Group").uri in a)return{pred:"agentGroup",obj:n};if(n.sameTerm(m.A.foaf("Agent"))||n.sameTerm(m.A.acl("AuthenticatedAgent"))||n.sameTerm(m.A.rdf("Resource"))||n.sameTerm(m.A.owl("Thing")))return{pred:"agentClass",obj:n};if(m.A.vcard("Individual").uri in a||m.A.foaf("Person").uri in a||m.A.foaf("Agent").uri in a){var r=t.any(n,m.A.foaf("preferredURI"));return r?{pred:"agent",obj:(0,l.sym)(r)}:{pred:"agent",obj:n}}return m.A.solid("AppProvider").uri in a?{pred:"origin",obj:n}:m.A.solid("AppProviderClass").uri in a?{pred:"originClass",obj:n}:(h.Rm(" Triage fails for "+e),null)}},7367(e,t,n){n.d(t,{DR:()=>x,Fp:()=>f,wR:()=>b});var a=n(467),i=n(4756),r=n.n(i),o=n(1795),s=n(9612),c=n(5619),l=n(6466),u=n(675),p=n(7423),d=window,m=Symbol("prevent double triggering of drop event");function f(e){if((0,p.Rm)("preventBrowserDropEvents called."),void 0!==d){if(d[m])return;d[m]=!0}e.addEventListener("drop",v,!1),e.addEventListener("dragenter",h,!1),e.addEventListener("dragover",h,!1)}function h(e){e.stopPropagation(),e.preventDefault()}function v(e){e.dataTransfer.files.length>0&&(d.confirm("Are you sure you want to drop this file here? (Cancel opens it in a new tab)")||(e.stopPropagation(),e.preventDefault(),(0,p.Rm)("@@@@ document-level DROP suppressed: "+e.dataTransfer.dropEffect)))}function x(e){var t=e.uri;"/"===t.slice(-1)&&(t=t.slice(0,-1));var n=t.lastIndexOf("/");return n>=0&&(t=t.slice(n+1)),t||"/"}function b(e,t,n,a){var i=t.dom,r=e.doc(),o=i.createElement("div");o.setAttribute("style",u.i.aclControlBoxContainer);var c=o.appendChild(i.createElement("h1"));c.textContent="Sharing for ".concat(n," ").concat(s.P(e)),c.setAttribute("style",u.i.aclControlBoxHeader);var l=o.appendChild(i.createElement("div"));l.setAttribute("style",u.i.aclControlBoxStatus);try{(function(e,t,n,a,i,r,o){return g.apply(this,arguments)})(r,a,e,n,t,i,l).then(function(e){return o.appendChild(e.render())})}catch(e){l.innerText=e}return o}function g(){return g=(0,a.A)(r().mark(function e(t,n,i,o,s,u,d){return r().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",new Promise(function(e,m){return(0,c.VM)(t,function(){var t=(0,a.A)(r().mark(function t(a,f,h,v,x,b){var g,k,C,E,_;return r().wrap(function(t){for(;;)switch(t.prev=t.next){case 0:if(E=function(e){return new l.v(i,o,s,d,k,h,v,x,b,e,n,u)},a){t.next=1;break}return t.abrupt("return",m(new Error("Error reading ".concat(f?"":" default ","ACL. status ").concat(h,": ").concat(v))));case 1:if(g=y(h),(k=w(h,v,n)||A(h))||!g){t.next=5;break}return t.prev=2,t.next=3,(0,c.L$)(g);case 3:return C=t.sent,t.abrupt("return",e(E(C)));case 4:t.prev=4,_=t.catch(2),(0,p.R8)(_);case 5:return t.abrupt("return",e(E()));case 6:case"end":return t.stop()}},t,null,[[2,4]])}));return function(e,n,a,i,r,o){return t.apply(this,arguments)}}())}));case 1:case"end":return e.stop()}},e)})),g.apply(this,arguments)}function y(e){var t=e.uri.split("#")[0],n=t.slice(0,-1).lastIndexOf("/"),a=t.indexOf("//");return a>=0&&n<a+2||n<0?null:t.slice(0,n+1)}function w(e,t,n){return n.holds(e,o.A.rdf("type"),o.A.space("Storage"),t)}function A(e){return e.uri===e.site().uri}},5619(e,t,n){n.d(t,{D9:()=>w,H0:()=>C,L$:()=>L,Lu:()=>y,P3:()=>f,Tm:()=>b,Uf:()=>v,VM:()=>j,_7:()=>h,_E:()=>d,cH:()=>A,cl:()=>g,fb:()=>T,fg:()=>m,n1:()=>_,pe:()=>S,pp:()=>E,xo:()=>k,xw:()=>x});var a=n(467),i=n(4756),r=n.n(i),o=n(1795),s=n(3138),c=n(9612),l=n(7423),u=n(4961),p=s.solidLogicSingleton.store;function d(e,t,n,a){var i=o.A.acl,r="/"===e.uri.slice(-1),s=p.each(void 0,i("default"),n,a).concat(p.each(void 0,i("defaultForNew"),n,a)).reduce(function(t,n){return t.concat(p.statementsMatching(n,o.A.rdf("type"),i("Authorization"),a)).concat(p.statementsMatching(n,i("agent"),void 0,a)).concat(p.statementsMatching(n,i("agentClass"),void 0,a)).concat(p.statementsMatching(n,i("agentGroup"),void 0,a)).concat(p.statementsMatching(n,i("origin"),void 0,a)).concat(p.statementsMatching(n,i("originClass"),void 0,a)).concat(p.statementsMatching(n,i("mode"),void 0,a)).concat((0,u.st)(n,i("accessTo"),e,a)).concat(r?(0,u.st)(n,i("default"),e,a):[])},[]),c=(0,u.graph)();return s.forEach(function(e){return c.add(l(e.subject),l(e.predicate),l(e.object),(0,u.sym)(t.uri))}),c;function l(e){var n=a.uri.length;return(0,u.sym)(e.uri.slice(0,n)===a.uri?t.uri+e.uri.slice(n):e.uri)}}function m(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:p,a=arguments.length>3&&void 0!==arguments[3]&&arguments[3]?function(t,n){return t.each(void 0,n.acl("default"),e).concat(t.each(void 0,n.acl("defaultForNew"),e))}(n,o.A):n.each(void 0,o.A.acl("accessTo"),e),i=o.A.acl,r={agent:{},agentClass:{},agentGroup:{},origin:{},originClass:{}};return Object.keys(r).forEach(function(e){a.forEach(function(t){n.each(t,i("mode")).forEach(function(a){n.each(t,i(e)).forEach(function(n){r[e][n.uri]=r[e][n.uri]||{},r[e][n.uri][a.uri]=t})})})}),r}function f(e,t){var n=function(e,t){for(var n in{agent:!0,agentClass:!0,agentGroup:!0,origin:!0,originClass:!0})if(e[n])for(var a in e[n])for(var i in e[n][a])if(!t[n][a]||!t[n][a][i])return!1;return!0};return n(e,t)&&n(t,e)}function h(e){for(var t,n,a=e[0],i=function(i){["agent","agentClass","agentGroup","origin","originClass"].forEach(function(r){if((t=e[i])[r])for(n in t[r])for(var o in t[r][n])a[r][n]||(a[r][n]=[]),a[r][n][o]=!0})},r=1;r<e.length;r++)i(r);return a}function v(e,t){var n=[],a=function(e){e.length?j(e.shift().doc(),function(i,r,o,s,c,l){var u=!r;if(!i||!c||!l)return t(i,s);var p=u?m(c,l):m(o,s);n.push(p),a(e.slice(1))}):t(!0,h(n))};a(e)}function x(e){var t={};return["agent","agentClass","agentGroup","origin","originClass"].forEach(function(n){for(var a in e[n]){var i=[];for(var r in e[n][a])i.push(r);i.sort();var o=i.join("\n");t[o]||(t[o]=[]),t[o].push([n,a])}}),t}function b(e,t,n,a){return g(e,t,x(n),a)}function g(e,t,n,a,i,r){var s=o.A.acl;for(var c in n){var l=n[c];if(l.length){var u=c.split("\n"),p=u.map(function(e){return e.split("#")[1]}).join("");r&&!i&&(p+="Default");var d=e.sym(a.uri+"#"+p);e.add(d,o.A.rdf("type"),s("Authorization"),a),i&&e.add(d,s("accessTo"),t,a),r&&e.add(d,s("default"),t,a);for(var m=0;m<u.length;m++)e.add(d,s("mode"),e.sym(u[m]),a);for(var f=0;f<l.length;f++){var h=l[f][0],v=l[f][1];e.add(d,s(h),e.sym(v),a)}}}}function y(e){return w(x(e))}function w(e){var t="";for(var n in e){t+=n.split("\n").map(function(e){return e.split("#")[1][0]}).join("")+":";for(var a=e[n],i=0;i<a.length;i++){var r=a[i][0],s=(0,u.sym)(a[i][1]);t+="agent"===r?"@":"",t+=s.sameTerm(o.A.foaf("Agent"))?"*":c.P(s),i<a.length-1&&(t+=",")}t+=";"}return"{"+t.slice(0,-1)+"}"}function A(e,t,n){var a=(0,u.graph)();return b(a,e,t,n),(0,u.serialize)(n,a,n.uri,"text/turtle")||""}function k(e,t,n,a,i){return C(e,t,x(n),a,i)}function C(e,t,n,a,i){var r,o=(0,u.graph)();g(o,t,n,a,!0),null===(r=e.updater)||void 0===r||r.put(a,o.statementsMatching(void 0,void 0,void 0,a),"text/turtle",function(r,o,s){var c;o?(null===(c=e.fetcher)||void 0===c||c.unload(a),g(e,t,n,a,!0),e.fetcher.requested[a.uri]="done",i(o)):i(o,s)})}function E(e,t,n){var a=p.each(void 0,o.A.vcard("hasMember"),e);a?_(e,a,t,n):(t("This card is in no groups"),n(!0))}function _(e,t,n,a){n=n||l.Rm;var i=e.doc();j(i,function(r,o,s,l,u,d){if(!r||!u||!d)return a(!1,l);var h=o?m(s,l):m(u,d);v(t,function(t,r){if(!t)return a(!1,r);f(r,h)?n("Nice - same ACL. no change "+c.P(e)+" "+i):(n("Group ACLs differ for "+c.P(e)+" "+i),k(p,s,r,l,a))})})}function T(e,t,n){var a=p.any(e,s.ACL_LINK);if(!p.fetcher)throw new Error("Store has no fetcher");a?p.fetcher.webOperation("PUT",a.value,{data:t,contentType:"text/turtle"}).then(function(e){n(e.ok,e.error||"")}):p.fetcher.nowOrWhenFetched(e,void 0,function(a,i){if(!a)return n(a,"Gettting headers for ACL: "+i);var r=p.any(e,s.ACL_LINK);if(r){if(!p.fetcher)throw new Error("Store has no fetcher");p.fetcher.webOperation("PUT",r.value,{data:t,contentType:"text/turtle"}).then(function(e){n(e.ok,e.error||"")})}else n(!1,"No Link rel=ACL header for "+e)})}function j(e,t){S(e,function(n,a,i,r){var s=o.A.acl;if(!n)return t(!1,!1,a,r);var c=function(n){"/"===n.slice(-1)&&(n=n.slice(0,-1));var a=n.lastIndexOf("/");if(n.indexOf("/",n.indexOf("//")+2)>a)return t(!1,!0,404,"Found no ACL resource");n=n.slice(0,a+1);var r=(0,u.sym)(n);S(r,function(a,o,l){if(!a)return t(!1,!0,o,"( No ACL pointer ".concat(n," ").concat(o,")").concat(l));if(403===o)return t(!1,!0,o,"( default ACL file FORBIDDEN. Stop.".concat(n,")"));if(404===o)return c(n);if(200!==o)return t(!1,!0,o,"Error status '".concat(o,"' searching for default for ").concat(r));if(!p.each(void 0,s("default"),p.sym(n),l).concat(p.each(void 0,s("defaultForNew"),p.sym(n),l)).length)return c(n);var u=p.sym(n);return t(!0,!1,e,i,u,l)})};return n?404!==a?403===a?t(!1,!1,a,"(Sharing not available to you)".concat(r)):200!==a?t(!1,!1,a,"Error ".concat(a," accessing Access Control information for ").concat(e,": ").concat(r)):t(!0,!0,e,i):void c(e.uri):t(!1,!1,a,"Error accessing Access Control information for ".concat(e,") ").concat(r))})}function S(e,t){if(!p.fetcher)throw new Error("kb has no fetcher");p.fetcher.nowOrWhenFetched(e,void 0,function(n,a){if(!n)return t(n,"Can't get headers to find ACL for ".concat(e,": ").concat(a));var i=p.any(e,s.ACL_LINK);if(i){if(!p.fetcher)throw new Error("kb has no fetcher");if(p.fetcher.nonexistent[i.value])return t(!0,404,i,"ACL file ".concat(i," does not exist."));p.fetcher.nowOrWhenFetched(i,void 0,function(e,n,a){e?t(!0,200,i):t(!0,a.status,i,"Can't read Access Control File ".concat(i,": ").concat(n))})}else t(!1,900,"No Link rel=ACL header for ".concat(e))})}function L(e){return R.apply(this,arguments)}function R(){return(R=(0,a.A)(r().mark(function e(t){return r().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",new Promise(function(e,n){return j((0,u.sym)(t),function(a,i,r,o,s){return a?e(i?r:s):n(new Error("Error loading ".concat(t)))})}));case 1:case"end":return e.stop()}},e)}))).apply(this,arguments)}},1928(e,t,n){n.d(t,{g:()=>v});var a=n(467),i=n(3029),r=n(2901),o=n(4467),s=n(4756),c=n.n(s),l=n(7423),u=n(3378),p=n(967),d=n(1795),m=n(9612),f=n(3291),h=n(675),v=function(){return(0,r.A)(function e(t){(0,i.A)(this,e),(0,o.A)(this,"isExpanded",!1),this.groupList=t,this.rootElement=t.controller.dom.createElement("div"),this.barElement=t.controller.dom.createElement("div")},[{key:"render",value:function(){return this.rootElement.innerHTML="",this.rootElement.appendChild(this.renderAddButton()),this.rootElement.appendChild(this.barElement),this.rootElement}},{key:"renderAddButton",value:function(){var e=this;return f.x6(this.groupList.controller.dom,"".concat(u.Pt.iconBase,"noun_34653_green.svg"),"Add ...",function(){e.toggleBar(),e.renderBar()})}},{key:"renderBar",value:function(){this.barElement.innerHTML="",this.isExpanded&&(this.barElement.appendChild(this.renderPersonButton()),this.barElement.appendChild(this.renderGroupButton()),this.barElement.appendChild(this.renderPublicButton()),this.barElement.appendChild(this.renderAuthenticatedAgentButton()),this.barElement.appendChild(this.renderBotButton()),this.barElement.appendChild(this.renderAppsButton()))}},{key:"renderSimplifiedBar",value:function(e){var t=this;Array.from(this.barElement.children).filter(function(t){return t!==e}).forEach(function(e){return t.barElement.removeChild(e)})}},{key:"renderPersonButton",value:function(){var e=this;return f.x6(this.groupList.controller.dom,u.Pt.iconBase+f.p_["vcard:Individual"],"Add Person",function(t){e.renderSimplifiedBar(t.target),e.renderNameForm(d.A.vcard("Individual"),"person").then(function(t){return e.addPerson(t)}).then(function(){return e.renderCleanup()}).catch(function(t){return e.groupList.controller.renderStatus(t)})})}},{key:"renderGroupButton",value:function(){var e=this;return f.x6(this.groupList.controller.dom,u.Pt.iconBase+f.p_["vcard:Group"],"Add Group",function(t){e.renderSimplifiedBar(t.target),e.renderNameForm(d.A.vcard("Group"),"group").then(function(t){return e.addGroup(t)}).then(function(){return e.renderCleanup()}).catch(function(t){return e.groupList.controller.renderStatus(t)})})}},{key:"renderNameForm",value:function(e,t){return f.RG(this.groupList.controller.dom,this.groupList.store,this.barElement,d.A.vcard("URI"),e,t)}},{key:"renderPublicButton",value:function(){var e=this;return f.x6(this.groupList.controller.dom,u.Pt.iconBase+f.p_["foaf:Agent"],"Add Everyone",function(){return e.addAgent(d.A.foaf("Agent").uri).then(function(){return e.groupList.controller.renderTemporaryStatus("Adding the general public to those who can read. Drag the globe to a different level to give them more access.")}).then(function(){return e.renderCleanup()})})}},{key:"renderAuthenticatedAgentButton",value:function(){var e=this;return f.x6(this.groupList.controller.dom,"".concat(u.Pt.iconBase,"noun_99101.svg"),"Anyone logged In",function(){return e.addAgent(d.A.acl("AuthenticatedAgent").uri).then(function(){return e.groupList.controller.renderTemporaryStatus("Adding anyone logged in to those who can read. Drag the ID icon to a different level to give them more access.")}).then(function(){return e.renderCleanup()})})}},{key:"renderBotButton",value:function(){var e=this;return f.x6(this.groupList.controller.dom,u.Pt.iconBase+"noun_Robot_849764.svg","A Software Agent (bot)",function(t){e.renderSimplifiedBar(t.target),e.renderNameForm(d.A.schema("Application"),"bot").then(function(t){return e.addBot(t)}).then(function(){return e.renderCleanup()})})}},{key:"renderAppsButton",value:function(){var e=this;return f.x6(this.groupList.controller.dom,"".concat(u.Pt.iconBase,"noun_15177.svg"),"A Web App (origin)",function(t){e.renderSimplifiedBar(t.target);var n={div:e.barElement,dom:e.groupList.controller.dom},a=e.renderAppsTable(n).catch(function(t){return e.groupList.controller.renderStatus(t)});e.renderAppsView();var i=e.renderNameForm(d.A.schema("WebApplication"),"webapp domain").then(function(t){return e.getOriginFromName(t)});Promise.race([a,i]).then(function(t){t&&e.groupList.addNewURI(t)}).then(function(){return e.renderCleanup()})})}},{key:"renderAppsView",value:function(){var e=this,t=this.groupList.controller.context.session.paneRegistry.byName("trustedApplications");if(t){var n=t.render(null,this.groupList.controller.context);n.setAttribute("style",h.i.trustedAppController);var a=f.x7(this.groupList.controller.dom,function(){return e.renderCleanup()});a.setAttribute("style",h.i.trustedAppCancelButton),n.insertBefore(a,n.firstChild),this.barElement.appendChild(n)}}},{key:"renderAppsTable",value:(x=(0,a.A)(c().mark(function e(t){var n,a,i=this;return c().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=1,(0,p.ensureLoadedProfile)(t);case 1:return n=this.groupList.store.each(t.me,d.A.acl("trustedApp")),a=n.flatMap(function(e){return i.groupList.store.each(e,d.A.acl("origin"))}),this.barElement.appendChild(this.groupList.controller.dom.createElement("p")).textContent="You have ".concat(a.length," selected web apps."),e.abrupt("return",new Promise(function(e,t){var a=i.barElement.appendChild(i.groupList.controller.dom.createElement("table"));a.setAttribute("style",h.i.trustedAppAddApplicationsTable),n.forEach(function(n){var r=i.groupList.store.any(n,d.A.acl("origin"));r||t(new Error("Unable to pick app: ".concat(n.value)));var o=f.Cl(i.groupList.controller.dom,d.A.acl("origin"),r,{}),s=i.groupList.controller.dom.createElement("table"),c=s.appendChild(i.groupList.controller.dom.createElement("tr"));c.appendChild(i.groupList.controller.dom.createElement("td")).appendChild(o),c.appendChild(i.groupList.controller.dom.createElement("td")).textContent="Give access to ".concat(i.groupList.controller.noun," ").concat(m.P(i.groupList.controller.subject),"?"),c.appendChild(i.groupList.controller.dom.createElement("td")).appendChild(f.kz(i.groupList.controller.dom,function(){return e(r.value)})),a.appendChild(s)})}));case 2:case"end":return e.stop()}},e,this)})),function(e){return x.apply(this,arguments)})},{key:"renderCleanup",value:function(){this.renderBar(),this.groupList.render()}},{key:"addPerson",value:(v=(0,a.A)(c().mark(function e(t){var n;return c().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(t){e.next=1;break}return e.abrupt("return",this.toggleBar());case 1:if(n=/^https?:/i,t.match(n)){e.next=2;break}return e.abrupt("return",Promise.reject(new Error("Not a http URI")));case 2:return l.Rm("Adding to ACL person: ".concat(t)),e.next=3,this.groupList.addNewURI(t);case 3:this.toggleBar();case 4:case"end":return e.stop()}},e,this)})),function(e){return v.apply(this,arguments)})},{key:"addGroup",value:(s=(0,a.A)(c().mark(function e(t){var n;return c().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(t){e.next=1;break}return e.abrupt("return",this.toggleBar());case 1:if(n=/^https?:/i,t.match(n)){e.next=2;break}return e.abrupt("return",Promise.reject(new Error("Not a http URI")));case 2:return l.Rm("Adding to ACL group: "+t),e.next=3,this.groupList.addNewURI(t);case 3:this.toggleBar();case 4:case"end":return e.stop()}},e,this)})),function(e){return s.apply(this,arguments)})},{key:"addAgent",value:(n=(0,a.A)(c().mark(function e(t){return c().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=1,this.groupList.addNewURI(t);case 1:this.toggleBar();case 2:case"end":return e.stop()}},e,this)})),function(e){return n.apply(this,arguments)})},{key:"addBot",value:(t=(0,a.A)(c().mark(function e(t){var n;return c().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(t){e.next=1;break}return e.abrupt("return",this.toggleBar());case 1:if(n=/^https?:/i,t.match(n)){e.next=2;break}return e.abrupt("return",Promise.reject(new Error("Not a http URI")));case 2:return l.Rm("Adding to ACL bot: "+t),e.next=3,this.groupList.addNewURI(t);case 3:this.toggleBar();case 4:case"end":return e.stop()}},e,this)})),function(e){return t.apply(this,arguments)})},{key:"getOriginFromName",value:(e=(0,a.A)(c().mark(function e(t){var n,a;return c().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(t){e.next=1;break}return e.abrupt("return",Promise.resolve());case 1:if(n=/^([a-z0-9]+(-[a-z0-9]+)*\.)+[a-z]{2,}$/i,t.match(n)){e.next=2;break}return e.abrupt("return",Promise.reject(new Error("Not a domain name")));case 2:return a="https://"+t,l.Rm("Adding to ACL origin: "+a),this.toggleBar(),e.abrupt("return",a);case 3:case"end":return e.stop()}},e,this)})),function(t){return e.apply(this,arguments)})},{key:"toggleBar",value:function(){this.isExpanded=!this.isExpanded}}]);var e,t,n,s,v,x}()},5923(e,t,n){n.d(t,{B:()=>r,u:()=>o});var a=n(5619),i=n(7367),r={adoptACLDefault:a._E,readACL:a.fg,sameACL:a.P3,ACLunion:a._7,loadUnionACL:a.Uf,ACLbyCombination:a.xw,makeACLGraph:a.Tm,makeACLGraphbyCombo:a.cl,ACLToString:a.Lu,comboToString:a.D9,makeACLString:a.cH,putACLObject:a.xo,putACLbyCombo:a.H0,fixIndividualCardACL:a.pp,fixIndividualACL:a.n1,setACL:a.fb,getACLorDefault:a.VM,getACL:a.pe},o={preventBrowserDropEvents:i.Fp,shortNameForFolder:i.DR,ACLControlBox5:i.wR}},7236(e,t,n){n.d(t,{eD:()=>S,z6:()=>k});var a=n(467),i=n(4756),r=n.n(i),o=n(7423),s=n(3378),c=n(6127),l=n(1795),u=n(8153),p=n(4961),d=n(675),m=n(52),f=n(9612),h=n(4608),v=n(3138),x=n(967),b={icons:s.Pt,ns:l.A,media:c.$,pad:u,style:d.i,utils:m,widgets:h},g=p.Namespace("http://www.w3.org/2002/01/bookmark#"),y=f.P,w=window.document||null;function A(e,t){return new Promise(function(n,a){v.store.updater.update(e,t,function(e,t,i){t?n():a(new Error(i))})})}function k(e){return C.apply(this,arguments)}function C(){return(C=(0,a.A)(r().mark(function e(t){var n,a,i,s;return r().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return n=g("Bookmark"),a="bookmarks.ttl",e.next=1,(0,x.findAppInstances)(t,n,true);case 1:if(!(t.instances&&t.instances.length>0)){e.next=2;break}t.bookmarkDocument=t.instances[0],t.instances.length>1&&o.R8("More than one bookmark file! "+t.instances),e.next=9;break;case 2:if(!t.publicProfile){e.next=8;break}return i=p.sym(t.publicProfile.dir().uri+a),e.prev=3,o.Rm("Creating new bookmark file "+i),e.next=4,v.store.fetcher.createIfNotExists(i);case 4:e.next=6;break;case 5:return e.prev=5,s=e.catch(3),o.R8("Can't make fresh bookmark file:"+s),e.abrupt("return",t);case 6:return e.next=7,v.createTypeIndexLogic.registerInTypeIndex(i,t.index,n);case 7:t.bookmarkDocument=i,e.next=9;break;case 8:o.R8("You seem to have no bookmark file, nor even a profile file!");case 9:return e.abrupt("return",t);case 10:case"end":return e.stop()}},e,null,[[3,5]])}))).apply(this,arguments)}function E(e,t){return _.apply(this,arguments)}function _(){return(_=(0,a.A)(r().mark(function e(t,n){var a,i,s,c,u,d,m,f;return r().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(a="",i=v.authn.currentUser()){e.next=1;break}throw new Error("Must be logged on to add Bookmark");case 1:return s=v.store.any(n,l.A.foaf("maker")),a=y(s)+": "+v.store.anyValue(n,l.A.sioc("content")).slice(0,80),c=t.bookmarkDocument,u=b.widgets.newThing(c,a),d=[p.st(c,b.ns.dct("references"),u,c),p.st(u,b.ns.rdf("type"),g("Bookmark"),c),p.st(u,b.ns.dct("created"),new Date,c),p.st(u,g("recalls"),n,c),p.st(u,b.ns.foaf("maker"),i,c),p.st(u,b.ns.dct("title"),a,c)],e.prev=2,e.next=3,A([],d);case 3:e.next=5;break;case 4:return e.prev=4,f=e.catch(2),m="Making bookmark: "+f,o.R8(m),e.abrupt("return",null);case 5:return e.abrupt("return",u);case 6:case"end":return e.stop()}},e,null,[[2,4]])}))).apply(this,arguments)}function T(e,t,n){return j.apply(this,arguments)}function j(){return(j=(0,a.A)(r().mark(function e(t,n,a){var i,s,c,l;return r().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=1,v.store.fetcher.load(t.bookmarkDocument);case 1:if(!(i=v.store.each(null,g("recalls"),n,t.bookmarkDocument)).length){e.next=9;break}if(confirm("Delete bookmark on this?"+i.length)){e.next=2;break}return e.abrupt("return");case 2:s=0;case 3:if(!(s<i.length)){e.next=8;break}return e.prev=4,e.next=5,A(v.store.connectedStatements(i[s]),[]);case 5:a.style.backgroundColor="white",o.Rm("Bookmark deleted: "+i[s]),e.next=7;break;case 6:e.prev=6,l=e.catch(4),o.z3("Cant delete bookmark:"+l),o.R8("Cannot delete bookmark:"+l);case 7:s++,e.next=3;break;case 8:e.next=11;break;case 9:return e.next=10,E(t,n);case 10:c=e.sent,a.style.backgroundColor="yellow",o.Rm("Bookmark added: "+c);case 11:case"end":return e.stop()}},e,null,[[4,6]])}))).apply(this,arguments)}function S(e,t){return L.apply(this,arguments)}function L(){return L=(0,a.A)(r().mark(function e(t,n){var i,o,s;return r().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(o=function(){return o=(0,a.A)(r().mark(function e(n){var a;return r().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=1,v.store.fetcher.load(t.bookmarkDocument);case 1:a=v.store.any(null,g("recalls"),n.target,t.bookmarkDocument),n.style=b.style.buttonStyle,a&&(n.style.backgroundColor="yellow");case 2:case"end":return e.stop()}},e)})),o.apply(this,arguments)},i=function(e){return o.apply(this,arguments)},!t.bookmarkDocument){e.next=2;break}return(s=b.widgets.button(w,b.icons.iconBase+"noun_45961.svg",y(g("Bookmark")),function(){T(t,n,s)})).target=n,e.next=1,i(s);case 1:return e.abrupt("return",s);case 2:case"end":return e.stop()}},e)})),L.apply(this,arguments)}},2465(e,t,n){n.d(t,{YM:()=>h,n6:()=>y,oQ:()=>b,oy:()=>A,x6:()=>v});var a=n(467),i=n(3029),r=n(2901),o=n(4756),s=n.n(o),c=n(7423),l=n(2893),u=n(3138),p=n(1795),d=n(4961),m=n(630),f=n(6855),h=function(){return(0,r.A)(function e(t,n){(0,i.A)(this,e),this.channel=t,this.channelRoot=t.doc(),this.options=n,this.dateFolder=new l.J(this.channelRoot,"chat.ttl"),this.div=null},[{key:"createMessage",value:(o=(0,a.A)(s().mark(function e(t){return s().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.updateMessage(t));case 1:case"end":return e.stop()}},e,this)})),function(e){return o.apply(this,arguments)})},{key:"updateMessage",value:(n=(0,a.A)(s().mark(function e(t){var n,a,i,r,o,l,h,v,x,b,g,w,A,k,C,E,_,T,j,S=arguments;return s().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(n=S.length>1&&void 0!==S[1]?S[1]:null,a=S.length>2?S[2]:void 0,i=S.length>3&&void 0!==S[3]?S[3]:null,r=[],o=new Date,l=""+o.getTime(),h=d.term(o),v=n?n.doc():this.dateFolder.leafDocumentFromDate(o),x=u.store.sym(v.uri+"#Msg"+l),b=u.authn.currentUser(),(g=(0,m.YJ)()).id=x.uri,!n){e.next=4;break}if((w=u.store.any(n,p.A.foaf("maker"))).uri!==b.uri){e.next=2;break}return e.next=1,y(n);case 1:A=e.sent,r.push(d.st(A,p.A.dct("isReplacedBy"),x,v)),(k=u.store.any(A,p.A.sioc("has_reply")))&&r.push(d.st(x,p.A.sioc("has_reply"),k,v)),a&&r.push(d.st(x,p.A.schema("dateDeleted"),h,v)),e.next=3;break;case 2:throw C="Error you cannot delete/edit a message from someone else : \n"+w.uri,c.R8(C),alert(C),new Error(C);case 3:e.next=5;break;case 4:r.push(d.st(this.channel,p.A.wf("message"),x,v));case 5:if(r.push(d.st(x,p.A.sioc("content"),u.store.literal(t),v)),g.content=t,r.push(d.st(x,p.A.dct("created"),h,v)),g.created=h.value,!b){e.next=7;break}return r.push(d.st(x,p.A.foaf("maker"),b,v)),g.maker=b.uri,e.next=6,(0,f.Tn)(b);case 6:E=e.sent,_=(0,m.vt)(g,E),r.push(d.st(x,d.sym("".concat(m.yv,"proofValue")),d.lit(_),v));case 7:return i&&(r.push(d.st(i,p.A.sioc("has_member"),x,v)),i.doc().sameTerm(x.doc())||r.push(d.st(i,p.A.sioc("has_member"),x,i.doc()))),e.prev=8,e.next=9,u.store.updater.updateMany([],r);case 9:e.next=11;break;case 10:throw e.prev=10,j=e.catch(8),T="Error saving chat message: "+j,c.R8(T),alert(T),new Error(T);case 11:return e.abrupt("return",x);case 12:case"end":return e.stop()}},e,this,[[8,10]])})),function(e){return n.apply(this,arguments)})},{key:"deleteMessage",value:(t=(0,a.A)(s().mark(function e(t){return s().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.updateMessage("(message deleted)",t,!0));case 1:case"end":return e.stop()}},e,this)})),function(e){return t.apply(this,arguments)})},{key:"createThread",value:(e=(0,a.A)(s().mark(function e(t){var n,a,i;return s().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(n=u.store.each(t,p.A.sioc("has_reply"),null,t.doc()).filter(function(e){return u.store.holds(e,p.A.rdf("type"),p.A.sioc("Thread"),e.doc())}),!(n.length>0)){e.next=1;break}return e.abrupt("return",n[0]);case 1:return a=d.sym(t.uri+"-thread"),i=[d.st(a,p.A.rdf("type"),p.A.sioc("Thread"),a.doc()),d.st(t,p.A.sioc("has_reply"),a,a.doc())],e.next=2,u.store.updater.update([],i);case 2:return e.abrupt("return",a);case 3:case"end":return e.stop()}},e)})),function(t){return e.apply(this,arguments)})}]);var e,t,n,o}();function v(e){return x.apply(this,arguments)}function x(){return(x=(0,a.A)(s().mark(function e(t){var n,a,i,r,o;return s().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:n=[t],(a={})[t.uri]=!0,i=t;case 1:if((r=u.store.any(null,p.A.dct("isReplacedBy"),i,i.doc()))&&!a[r.uri]){e.next=2;break}return e.abrupt("continue",4);case 2:return e.next=3,u.store.fetcher.load(r);case 3:n.unshift(r),a[r.uri]=!0,i=r,e.next=1;break;case 4:i=t;case 5:if((o=u.store.any(i,p.A.dct("isReplacedBy"),null,i.doc()))&&!a[o.uri]){e.next=6;break}return e.abrupt("continue",7);case 6:n.push(o),a[o.uri]=!0,i=o,e.next=5;break;case 7:return e.abrupt("return",n);case 8:case"end":return e.stop()}},e)}))).apply(this,arguments)}function b(e){return g.apply(this,arguments)}function g(){return(g=(0,a.A)(s().mark(function e(t){var n,a;return s().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:n=t,a={};case 1:if(!n){e.next=4;break}if(!a[n.uri]){e.next=2;break}return c.z3("originalVersion: verion loop"+t),e.abrupt("return",t);case 2:return a[n.uri]=!0,t=n,e.next=3,u.store.fetcher.load(t);case 3:n=u.store.any(null,p.A.dct("isReplacedBy"),t,t.doc()),e.next=1;break;case 4:return e.abrupt("return",t);case 5:case"end":return e.stop()}},e)}))).apply(this,arguments)}function y(e){return w.apply(this,arguments)}function w(){return(w=(0,a.A)(s().mark(function e(t){var n,a;return s().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:n=t,a={};case 1:if(!n){e.next=4;break}if(!a[n.uri]){e.next=2;break}return c.z3("mostRecentVersion: verion loop"+t),e.abrupt("return",t);case 2:return a[n.uri]=!0,t=n,e.next=3,u.store.fetcher.load(t);case 3:n=u.store.any(t,p.A.dct("isReplacedBy"),null,t.doc()),e.next=1;break;case 4:return e.abrupt("return",t);case 5:case"end":return e.stop()}},e)}))).apply(this,arguments)}function A(e){return u.store.holds(e,p.A.schema("dateDeleted"),null,e.doc())}},2893(e,t,n){n.d(t,{J:()=>f});var a=n(3029),i=n(2901),r=n(467),o=n(4756),s=n.n(o),c=n(7423),l=n(3138),u=n(1795),p=n(4961);function d(e){return m.apply(this,arguments)}function m(){return(m=(0,r.A)(s().mark(function e(t){return s().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=1,l.store.fetcher.load(t);case 1:return e.abrupt("return",!(l.store.statementsMatching(null,u.A.dct("created"),null,t).length>0));case 2:case"end":return e.stop()}},e)}))).apply(this,arguments)}var f=function(){return(0,i.A)(function e(t,n,i){(0,a.A)(this,e),this.root=t,this.rootFolder=t.dir(),this.leafFileName=n||"index.ttl",this.membershipProperty=i||u.A.wf("leafObject")},[{key:"leafDocumentFromDate",value:function(e){var t=e.toISOString().split("T")[0].replace(/-/g,"/");return t=this.root.dir().uri+t+"/"+this.leafFileName,l.store.sym(t)}},{key:"dateFromLeafDocument",value:function(e){var t=this.rootFolder.uri.length,n=e.uri.slice(t,t+10).replace(/\//g,"-");return new Date(n)}},{key:"loadPrevious",value:(t=(0,r.A)(s().mark(function e(t,n){var a,i,o,p,m,f;return s().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:i=function(){return(i=(0,r.A)(s().mark(function e(t,i){var r,o,p,d,m,f,h,v,x,b;return s().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return p=function(e){return(e=e.filter(o)).sort(),n||e.reverse(),e.pop()},o=function(e){var t=e.uri.slice(0,-1).split("/").slice(-1)[0];return!!"0123456789".includes(t[0])},r=function(e){return!(n?e.uri>=t.uri:e.uri<=t.uri)},d=t.dir(),e.prev=1,e.next=2,l.store.fetcher.load(d);case 2:if(m=(m=l.store.each(d,u.A.ldp("contains"))).filter(r),!(f=p(m))){e.next=3;break}return e.abrupt("return",f);case 3:e.next=6;break;case 4:if(e.prev=4,!(b=e.catch(1)).response||!b.response.status||404!==b.response.status){e.next=5;break}c.Rm("Error 404 for chat parent file "+d),e.next=6;break;case 5:throw c.Rm("*** Error NON 404 for chat parent file "+d),new Error("*** ".concat(b.message," for chat folder ").concat(d));case 6:if(0!==i){e.next=7;break}return e.abrupt("return",null);case 7:return e.next=8,a(d,i-1);case 8:if(h=e.sent){e.next=9;break}return e.abrupt("return",null);case 9:return e.next=10,l.store.fetcher.load(h);case 10:return v=l.store.each(h,u.A.ldp("contains")),x=p(v),e.abrupt("return",x);case 11:case"end":return e.stop()}},e,null,[[1,4]])}))).apply(this,arguments)},a=function(e,t){return i.apply(this,arguments)},o=this.leafDocumentFromDate(t).dir();case 1:return e.next=2,a(o,3);case 2:if(!(p=e.sent)){e.next=6;break}return m=l.store.sym(p.uri+this.leafFileName),f=this.dateFromLeafDocument(m),e.next=3,d(m);case 3:if(e.sent){e.next=4;break}return e.abrupt("return",f);case 4:t=f,o=this.leafDocumentFromDate(t).dir();case 5:e.next=7;break;case 6:return e.abrupt("return",null);case 7:e.next=1;break;case 8:case"end":return e.stop()}},e,this)})),function(e,n){return t.apply(this,arguments)})},{key:"firstLeaf",value:(e=(0,r.A)(s().mark(function e(t){var n,a,i,o,l,d,m,f,h,v,x;return s().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return o=function(){return(o=(0,r.A)(s().mark(function e(i){var r,o;return s().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return r=function(e){var t=e.uri.slice(0,-1).split("/").slice(-1)[0];return!!"0123456789".includes(t[0])},delete a.requested[i.uri],e.next=1,a.load(i,{force:!0});case 1:if(0!==(o=(o=n.each(i,u.A.ldp("contains"))).filter(r)).length){e.next=2;break}throw new Error(" @@@ No children to parent2 "+i);case 2:return o.sort(),t&&o.reverse(),e.abrupt("return",o[0]);case 3:case"end":return e.stop()}},e)}))).apply(this,arguments)},i=function(e){return o.apply(this,arguments)},n=p.graph(),a=new p.Fetcher(n),e.next=1,i(this.root.dir());case 1:return l=e.sent,e.next=2,i(l);case 2:return d=e.sent,e.next=3,i(d);case 3:return m=e.sent,f=p.sym(m.uri+"chat.ttl"),e.next=4,a.load(f);case 4:if(0!==(h=n.each(this.root,this.membershipProperty,null,f)).length){e.next=5;break}throw v=" INCONSISTENCY -- no chat leafObject in file "+f,c.uP(v),new Error(v);case 5:return(x=h.map(function(e){return[n.any(e,u.A.dct("created")),e]})).sort(),t&&x.reverse(),e.abrupt("return",x[0][1]);case 6:case"end":return e.stop()}},e,this)})),function(t){return e.apply(this,arguments)})}]);var e,t}()},9509(e,t,n){n.d(t,{r5:()=>y,rg:()=>b});var a=n(467),i=n(4756),r=n.n(i),o=n(4961),s=n(3138),c=n(7423),l=n(3378),u=n(1795),p=n(3291),d=n(3468),m=n(2465),f=n(3262);function h(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!n){if(Array.isArray(e)||(n=function(e,t){if(e){if("string"==typeof e)return v(e,t);var n={}.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?v(e,t):void 0}}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var a=0,i=function(){};return{s:i,n:function(){return a>=e.length?{done:!0}:{done:!1,value:e[a++]}},e:function(e){throw e},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var r,o=!0,s=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return o=e.done,e},e:function(e){s=!0,r=e},f:function(){try{o||null==n.return||n.return()}finally{if(s)throw r}}}}function v(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,a=Array(t);n<t;n++)a[n]=e[n];return a}function x(e){"Notification"in window?"granted"===Notification.permission?new Notification(e):"denied"!==Notification.permission&&Notification.requestPermission().then(function(t){"granted"===t&&new Notification(e)}):c.R8("This browser does no t support desktop notification")}function b(e,t