solid-ui 3.1.1-test.0 → 3.1.2
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/components/footer/index.esm.js +3 -12
- package/dist/components/footer/index.esm.js.map +1 -1
- package/dist/components/footer/index.esm.min.js +1 -1
- package/dist/components/footer/index.esm.min.js.map +1 -1
- package/dist/components/footer/index.js +3 -12
- package/dist/components/footer/index.js.map +1 -1
- package/dist/components/footer/index.min.js +1 -1
- package/dist/components/footer/index.min.js.map +1 -1
- package/dist/login/login.d.ts.map +1 -1
- package/dist/login/login.js +3 -12
- package/dist/login/login.js.map +1 -1
- package/dist/solid-ui.esm.js +3 -12
- package/dist/solid-ui.esm.js.map +1 -1
- package/dist/solid-ui.esm.min.js +1 -1
- package/dist/solid-ui.esm.min.js.map +1 -1
- package/dist/solid-ui.js +3 -12
- package/dist/solid-ui.js.map +1 -1
- package/dist/solid-ui.min.js +5 -5
- package/dist/solid-ui.min.js.map +1 -1
- package/dist/versionInfo.js +3 -3
- package/package.json +223 -223
package/dist/solid-ui.min.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.UI=t():e.UI=t()}(this,()=>(()=>{var e={423(e,t,n){"use strict";function i(...e){console.log(...e)}function a(...e){console.warn(...e)}function o(...e){console.error(...e)}function s(...e){console.trace(...e)}n.d(t,{R8:()=>a,Rm:()=>i,uP:()=>s,z3:()=>o})},378(e,t,n){"use strict";n.d(t,{LN:()=>s,Pt:()=>o,i1:()=>r});var i=n(423);const a="https://solidos.github.io/solid-ui/src",o=(e=n.hmd(e)).scriptURI?{iconBase:e.scriptURI.slice(0,e.scriptURI.lastIndexOf("/"))+"/icons/",originalIconBase:e.scriptURI.slice(0,e.scriptURI.lastIndexOf("/"))+"/originalIcons/"}:"undefined"!=typeof $SolidTestEnvironment&&$SolidTestEnvironment.iconBase?{iconBase:$SolidTestEnvironment.iconBase,originalIconBase:$SolidTestEnvironment.originalIconBase}:{iconBase:a+"/icons/",originalIconBase:a+"/originalIcons/"};(0,i.Rm)(" icons.iconBase is set to : "+o.iconBase);const s=o.iconBase,r=o.originalIconBase},788(e,t,n){"use strict";n.r(t),n.d(t,{acl:()=>ca,aclControl:()=>la,create:()=>ua,createTypes:()=>m,dom:()=>Xr,icons:()=>it.Pt,infiniteMessageArea:()=>kr,initFooter:()=>Yr,initHeader:()=>qr,language:()=>o,log:()=>i,login:()=>c,matrix:()=>ma,media:()=>ba,messageArea:()=>va,ns:()=>b,pad:()=>p,participation:()=>l,preferences:()=>u,style:()=>Ke,table:()=>Dr,tabs:()=>d,utils:()=>a,widgets:()=>r});var i={};n.r(i),n.d(i,{LogLevel:()=>v,alert:()=>R,clear:()=>N,debug:()=>j,dumpHTML:()=>B,error:()=>L,escapeForXML:()=>M,info:()=>_,logAscending:()=>D,logDescending:()=>O,msg:()=>A,setInternals:()=>F,setLevel:()=>I,success:()=>S,warn:()=>T});var a={};n.r(a),n.d(a,{AJARImage:()=>ce,RDFComparePredicateObject:()=>ge,RDFComparePredicateSubject:()=>be,addLoadEvent:()=>oe,ancestor:()=>te,beep:()=>W,clearVariableNames:()=>V,emptyNode:()=>X,escapeForXML:()=>de,findPos:()=>se,genUuid:()=>Q,getAbout:()=>ne,getEyeFocus:()=>re,getTarget:()=>ee,getTerm:()=>ie,hashColor:()=>J,include:()=>ae,label:()=>z,labelForXML:()=>me,labelWithOntology:()=>ue,newVariableName:()=>G,ontologyLabel:()=>pe,predParentOf:()=>xe,predicateLabel:()=>he,predicateLabelForXML:()=>fe,shortName:()=>le,stackString:()=>K,syncTableToArray:()=>Z,syncTableToArrayReOrdered:()=>Y});var o={};n.r(o),n.d(o,{addDefaults:()=>wn,defaultPreferredLanguages:()=>yn,filterByLanguage:()=>kn,getPreferredLanguages:()=>En,getPreferredLanguagesFor:()=>Cn,languageCodeURIBase:()=>vn});var s={};n.r(s),n.d(s,{AUTOCOMPLETE_LIMIT:()=>An,ESCOResultToBindings:()=>Un,bindingToTerm:()=>Mn,dbPediaTypeMap:()=>Nn,dbpediaParameters:()=>Rn,escoParameters:()=>Sn,fetcherOptionsJsonPublicData:()=>Ln,getDbpediaDetails:()=>Qn,getWikidataDetails:()=>Vn,getWikidataDetailsOld:()=>Wn,getWikidataLocation:()=>Jn,instituteDetailsWikidataQuery:()=>_n,loadFromBindings:()=>Fn,loadPublicDataThing:()=>Gn,queryESCODataByName:()=>zn,queryPublicDataByName:()=>$n,queryPublicDataConstruct:()=>Hn,queryPublicDataSelect:()=>qn,variableNameToPredicateMap:()=>On,wikidataClasses:()=>jn,wikidataIncomingClassMap:()=>Dn,wikidataOutgoingClassMap:()=>In,wikidataParameters:()=>Bn});var r={};n.r(r),n.d(r,{Group:()=>rt,GroupBuilder:()=>ct,GroupPicker:()=>st,PeoplePicker:()=>ot,Person:()=>lt,addStyleSheet:()=>nn,allClassURIs:()=>Qt,appendForm:()=>li,askName:()=>Ut,attachmentList:()=>Vt,basicField:()=>xn,buildCheckboxForm:()=>Ci,button:()=>Ot,cancelButton:()=>Mt,clearElement:()=>yt,complain:()=>vt,continueButton:()=>Ft,createLinkDiv:()=>qt,createLinkForURI:()=>ht,createNameDiv:()=>$t,defaultAnnotationStore:()=>Jt,deleteButtonWithCheck:()=>Dt,editFormButton:()=>ci,errorMessageBlock:()=>nt,extractLogURI:()=>wt,faviconOrDefault:()=>Bt,field:()=>pn,fieldFunction:()=>dn,fieldLabel:()=>gn,fieldParams:()=>cn,fieldStore:()=>bn,fileUploadButtonDiv:()=>rn,findClosest:()=>ui,findImage:()=>Rt,findImageFromURI:()=>St,formatDateTime:()=>Et,formsFor:()=>di,iconForClass:()=>_t,imagesOf:()=>jt,index:()=>tn,isAudio:()=>an,isImage:()=>sn,isVideo:()=>on,linkButton:()=>Yt,linkIcon:()=>ft,makeDescription:()=>bi,makeDraggable:()=>et,makeDropTarget:()=>Xe,makeSelectForCategory:()=>yi,makeSelectForChoice:()=>ki,makeSelectForClassifierOptions:()=>xi,makeSelectForNestedCategory:()=>wi,makeSelectForOptions:()=>vi,mostSpecificClassURI:()=>un,newButton:()=>hi,newThing:()=>Ei,openHrefInOutlineMode:()=>Wt,personTR:()=>zt,promptForNew:()=>gi,propertiesForClass:()=>pi,propertyTriage:()=>Zt,publicData:()=>s,refreshTree:()=>Gt,removeButton:()=>Kt,renderAsDiv:()=>Ht,renderAsRow:()=>Pt,renderAutoComplete:()=>Yn,renderAutocompleteControl:()=>ti,renderNameValuePair:()=>hn,selectorPanel:()=>Xt,selectorPanelRefresh:()=>en,setImage:()=>It,setName:()=>Tt,setVisible:()=>Zn,shortDate:()=>Ct,shortTime:()=>At,sortByLabel:()=>fi,sortBySequence:()=>mi,timestamp:()=>kt,uploadFiles:()=>tt});var c={};n.r(c),n.d(c,{ensureLoadedPreferences:()=>Oi,ensureLoadedProfile:()=>Mi,ensureLoggedIn:()=>Di,filterAvailablePanes:()=>Ji,findAppInstances:()=>Fi,getUserRoles:()=>Wi,loginStatusBox:()=>Hi,newAppInstance:()=>Vi,registrationControl:()=>zi,registrationList:()=>$i,renderScopeHeadingRow:()=>Pi,renderSignInPopup:()=>qi,scopeLabel:()=>Ui,selectWorkspace:()=>Gi});var l={};n.r(l),n.d(l,{manageParticipation:()=>Ks,participationObject:()=>Zs,recordParticipation:()=>Ys,renderParticipants:()=>Qs});var p={};n.r(p),n.d(p,{getChunks:()=>ir,lightColorHash:()=>tr,manageParticipation:()=>Ks,notepad:()=>nr,notepadToHTML:()=>or,participationObject:()=>Zs,recordParticipation:()=>Ys,renderParticipants:()=>Qs,xmlEncode:()=>ar});var u={};n.r(u),n.d(u,{get:()=>jr,getPreferencesForClass:()=>Ir,recordPersonalDefaults:()=>Sr,recordSharedPreferences:()=>Lr,renderPreferencesForm:()=>Rr,set:()=>_r,value:()=>Tr});var d={};n.r(d),n.d(d,{TabWidgetElement:()=>Or,tabWidget:()=>Mr});var m={};n.r(m);var f=n(386),h=n.n(f),g=n(511);const b=h()(g);var x=n(892);let v=function(e){return e[e.Error=1]="Error",e[e.Warning=2]="Warning",e[e.Message=4]="Message",e[e.Success=8]="Success",e[e.Info=16]="Info",e[e.Debug=32]="Debug",e[e.All=63]="All",e}({}),y=7,w=!1,C=document,E=window;function k(e,t=4,n="mesg"){if(y&t)if(void 0!==C){const t=C.getElementById("status");if(!t)return;const i=C.createElement("span");i.setAttribute("class",n);const a=new Date;i.innerHTML=`${a.getHours()}:${a.getMinutes()}:${a.getSeconds()} [${n}] ${M(e)}<br/>`,w?t.insertBefore(i,t.firstChild):t.appendChild(i)}else"undefined"!=typeof console&&console.log(e)}function A(e){k(e)}function T(e){k(e,2,"warn")}function j(e){k(e,32,"dbug")}function _(e){k(e,16,"info")}function L(e){k(e,1,"eror")}function S(e){k(e,8,"good")}function R(e){E&&void 0!==E.alert?E.alert(e):T(e)}function N(){const e=C?.getElementById("status");e&&(e.innerHTML="")}function I(e){y=63,j("Log level is now "+e),y=e}function B(){if(!C)return;const e=y;y=63,j(C?.body?.innerHTML||""),y=e}function D(){w=!0}function O(){w=!1}function M(e){return e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">")}function F(e,t){E=e,C=t}const U={log:i,ns:b,rdf:g};function z(e,t=!1){function n(e){return t?e.slice(0,1).toUpperCase()+e.slice(1):e}function i(e){let t="";"/"===e.slice(-1)&&(e=e.slice(0,-1));for(let n=0;n<e.length;n++)"_"!==e[n]&&"-"!==e[n]?(t+=e[n],n+1<e.length&&e[n].toUpperCase()!==e[n]&&e[n+1].toLowerCase()!==e[n+1]&&(t+=" ")):t+=" ";return"has "===t.slice(0,4)&&(t=t.slice(4)),n(t)}const a=function(e){return x.store.any(e,U.ns.ui("label"))||x.store.any(e,U.ns.link("message"))||x.store.any(e,U.ns.vcard("fn"))||x.store.any(e,U.ns.foaf("name"))||x.store.any(e,U.ns.dct("title"))||x.store.any(e,U.ns.dc("title"))||x.store.any(e,U.ns.rss("title"))||x.store.any(e,U.ns.contact("fullName"))||x.store.any(e,x.store.sym("http://www.w3.org/2001/04/roadmap/org#name"))||x.store.any(e,U.ns.cal("summary"))||x.store.any(e,U.ns.foaf("nick"))||x.store.any(e,U.ns.as("name"))||x.store.any(e,U.ns.schema("name"))||x.store.any(e,U.ns.rdfs("label"))||x.store.any(e,x.store.sym("http://www.w3.org/2004/02/skos/core#prefLabel"))}(e);if(a)return n(a.value);if("BlankNode"===e.termType)return"...";if("Collection"===e.termType)return"("+e.elements.length+")";let o=e.uri;if(void 0===o)return e.toString();try{o=o.split("/").map(decodeURIComponent).join("/")}catch(e){for(let e=o.length-3;e>0;e--){const t="0123456789abcefABCDEF";for(;"%"===o[e]&&t.indexOf(o[e+1])>=0&&t.indexOf(o[e+2])>=0;)o=o.slice(0,e)+String.fromCharCode(parseInt(o.slice(e+1,e+3),16))+o.slice(e+3)}}o=P(o,"/profile/card#me"),o=P(o,"#this"),o=P(o,"#me");const s=o.indexOf("#");if(s>=0)return i(o.slice(s+1));const r=o.lastIndexOf("/",o.length-2);return r>=0&&r<e.uri.length?i(o.slice(r+1)):n(decodeURIComponent(e.uri))}function P(e,t){const n=-1*t.length;return e.slice(n)===t?e.slice(0,n):e}const $={log:i,ns:b,rdf:g};let q,H=0;function G(){return"v"+H++}function V(){H=0}function W(){if(!q)return;const e=new q;return function(t,n,i,a){t=+(t||.3),i=i||"sine","function"!=typeof a&&(a=function(){});const o=e.createOscillator();o.type=i,o.frequency.value=n||256,o.connect(e.destination),o.start(0),o.stop(t)}}function J(e){e=e.uri||e;return"#"+(16777215&(t=e,t.split("").reduce(function(e,t){return(e=(e<<5)-e+t.charCodeAt(0))&e},0))|12632256).toString(16);var t}function Q(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(e){const t=16*Math.random()|0;return("x"===e?t:3&t|8).toString(16)})}function Z(e,t,n,i){let a,o,s;for(s=0;s<e.children.length;s++)o=e.children[s],o.trashMe=!0;for(let r=0;r<t.length;r++){const c=t[r];for(a=!1,s=0;s<e.children.length;s++)if(o=e.children[s],o.subject&&o.subject.sameTerm(c)){if(i){const e=i(o,c);e&&e!==o&&(o.parentNode.replaceChild(e,o),e.subject=c,o=e)}o.trashMe=!1,a=!0;break}if(!a){const t=n(c);if(r>=e.children.length)e.appendChild(t);else{const n=e.children[r];e.insertBefore(t,n)}t.subject=c}}for(s=0;s<e.children.length;s++)o=e.children[s],o.trashMe&&e.removeChild(o)}function Y(e,t,n){const i={};for(let t=0;t<e.children.length;t++){const n=e.children[t];i[n.subject.toNT()]=n}for(let a=0;a<t.length;a++){const o=t[a];if(a>=e.children.length){const t=n(o);t.subject=o,e.appendChild(t)}else{const t=e.children[a];if(t.subject.sameTerm(o));else{const a=i[o.toNT()];if(a)e.removeChild(a),e.insertBefore(a,t);else{const e=n(o);t.before(e),e.subject=o}}}}for(;e.children.length>t.length;)e.removeChild(e.children[e.children.length-1])}function K(e){let t,n=e+"\n";if(!e.stack)return n+"No stack available.\n";const i=e.stack.toString().split("\n"),a=[];for(t=0;t<i.length;t++){let e=i[t];if(e.indexOf("ecmaunit.js")>-1)break;"("===e.charAt(0)&&(e="function"+e);const n=e.split("@");a.push(n)}for(t=0;t<a.length;t++)n+=" "+a[t][1]+"\n "+a[t][0];return n}function X(e){const t=e.childNodes;for(let n=t.length-1;n>=0;n--)e.removeChild(t[n]);return e}function ee(e){let t;return(e=e||window.event).target?t=e.target:e.srcElement&&(t=e.srcElement),3===t.nodeType&&(t=t.parentNode),t}function te(e,t){let n;for(n=e;n;n=n.parentNode)try{if(n.tagName===t)return n}catch(e){return}}function ne(e,t){let n,i;for(n=t;n&&1===n.nodeType;n=n.parentNode)if(i=n.getAttribute("about"),i)return e.fromNT(i);$.log.debug("getAbout: No about found")}function ie(e){const t=e.parentNode,n=t?t.AJAR_statement:void 0;switch(n?e.className:""){case"pred":case"pred selected":return n.predicate;case"obj":case"obj selected":return t.AJAR_inverse?n.subject:n.object;case"":case"selected":return ne(x.store,e);case"undetermined selected":return e.nextSibling?n.predicate:t.AJAR_inverse?n.subject:n.object}}function ae(e,t){const n=e.createElement("script");return n.setAttribute("type","text/javascript"),n.setAttribute("src",t),n}function oe(e){const t=window.onload;"function"!=typeof window.onload?window.onload=e:window.onload=function(){t(),e()}}function se(e){const t=e.ownerDocument.documentElement.getBoundingClientRect(),n=e.getBoundingClientRect();return[n.left-t.left,n.top-t.top]}function re(e,t,n,i){i||(i=window);const a=se(e)[1],o=window.SolidAppContext||{},s=a-(o&&o.scroll||52)-i.scrollY;if(t)return n?void i.scrollBy(0,a+e.clientHeight-(i.scrollY+i.innerHeight)):void i.scrollBy(0,s);const r=i.setInterval(function(){i.scrollBy(0,s/10),c++,10===c&&i.clearInterval(r)},50);let c=0}function ce(e,t,n,i){i||(i=document);const a=i.createElement("img");return a.setAttribute("src",e),a.addEventListener("copy",function(e){e.clipboardData.setData("text/plain",""),e.clipboardData.setData("text/html",""),e.preventDefault()}),void 0!==n&&a.setAttribute("title",n),a}function le(e){let t=e;"#/".indexOf(t[t.length-1])>=0&&(t=t.slice(0,-1));const n=[];for(const e in this.prefixes)n[this.prefixes[e]]=e;let i;const a=function(e){return"ns"!==e&&(i=e,!0)};let o;const s=t.lastIndexOf("#");for(s>=0&&(t=t.slice(s-1));;){const e=t.lastIndexOf("/");for(e>=0&&(t=t.slice(e+1)),o=0;o<t.length&&this.prefixchars.indexOf(t[o]);)o++;if(t=t.slice(0,o),t.length<6&&a(t))return i;if(a(t.slice(0,3)))return i;if(a(t.slice(0,2)))return i;if(a(t.slice(0,4)))return i;if(a(t.slice(0,1)))return i;if(a(t.slice(0,5)))return i;for(o=0;;o++)if(a(t.slice(0,3)+o))return i}}function pe(e){if(void 0===e.uri)return"??";let t=e.uri;const n=[];let i,a=t.lastIndexOf("#");if(a>=0)t=t.slice(0,a+1);else{if(a=t.lastIndexOf("/"),!(a>=0))return e.uri+"?!";t=t.slice(0,a+1)}for(const e in $.ns)n[$.ns[e]]=e;try{return n[t]}catch(e){}for(t=t.slice(0,-1);t;){if(a=t.lastIndexOf("/"),!(a>=0))return e.uri+"!?";if(i=t.slice(a+1),t=t.slice(0,a),"ns"!==i&&"0123456789".indexOf(i[0])<0)return i}}function ue(e,t){const n=x.store.findTypeURIs(e);return n[$.ns.rdf("Predicate").uri]||n[$.ns.rdfs("Class").uri]?z(e,t)+" ("+pe(e)+")":z(e,t)}function de(e){return e.replace(/&/g,"&").replace(/</g,"<")}function me(e){return de(z(e))}function fe(e,t){return de(he(e,t))}function he(e,t){const n=z(e);if(t){const t=x.store.any(e,$.ns.owl("inverseOf"))||x.store.any(void 0,$.ns.owl("inverseOf"),e);return t?z(t):"type"===n?"...":"is "+n+" of"}return n}function ge(e,t){const n=e.predicate.compareTerm(t.predicate);return 0!==n?n:e.object.compareTerm(t.object)}function be(e,t){const n=e.predicate.compareTerm(t.predicate);return 0!==n?n:e.subject.compareTerm(t.subject)}function xe(e){let t=e;for(;;){if(t.getAttribute("predTR"))return t;if(!t.previousSibling||"TR"!==t.previousSibling.nodeName)return $.log.error("Could not find predParent"),e;t=t.previousSibling}}"undefined"!=typeof AudioContext?q=AudioContext:"undefined"!=typeof window&&(q=window.AudioContext||window.webkitAudioContext);var ve=n(423);const ye=x.solidLogicSingleton.store;function we(e,t,n,i){const a=b.acl,o="/"===e.uri.slice(-1),s=ye.each(void 0,a("default"),n,i).concat(ye.each(void 0,a("defaultForNew"),n,i)).reduce((t,n)=>t.concat(ye.statementsMatching(n,b.rdf("type"),a("Authorization"),i)).concat(ye.statementsMatching(n,a("agent"),void 0,i)).concat(ye.statementsMatching(n,a("agentClass"),void 0,i)).concat(ye.statementsMatching(n,a("agentGroup"),void 0,i)).concat(ye.statementsMatching(n,a("origin"),void 0,i)).concat(ye.statementsMatching(n,a("originClass"),void 0,i)).concat(ye.statementsMatching(n,a("mode"),void 0,i)).concat((0,g.st)(n,a("accessTo"),e,i)).concat(o?(0,g.st)(n,a("default"),e,i):[]),[]),r=(0,g.graph)();return s.forEach(e=>r.add(c(e.subject),c(e.predicate),c(e.object),(0,g.sym)(t.uri))),r;function c(e){const n=i.uri.length;return(0,g.sym)(e.uri.slice(0,n)===i.uri?t.uri+e.uri.slice(n):e.uri)}}function Ce(e,t,n=ye,i=!1){const a=i?function(t,n){return t.each(void 0,n.acl("default"),e).concat(t.each(void 0,n.acl("defaultForNew"),e))}(n,b):n.each(void 0,b.acl("accessTo"),e),o=b.acl,s={agent:{},agentClass:{},agentGroup:{},origin:{},originClass:{}};return Object.keys(s).forEach(e=>{a.forEach(function(t){n.each(t,o("mode")).forEach(function(i){n.each(t,o(e)).forEach(function(n){s[e][n.uri]=s[e][n.uri]||{},s[e][n.uri][i.uri]=t})})})}),s}function Ee(e,t){const n=function(e,t){for(const n in{agent:!0,agentClass:!0,agentGroup:!0,origin:!0,originClass:!0})if(e[n])for(const i in e[n])for(const a in e[n][i])if(!t[n][i]||!t[n][i][a])return!1;return!0};return n(e,t)&&n(t,e)}function ke(e){const t=e[0];let n,i;for(let a=1;a<e.length;a++)["agent","agentClass","agentGroup","origin","originClass"].forEach(function(o){if(n=e[a],n[o])for(i in n[o])for(const e in n[o][i])t[o][i]||(t[o][i]=[]),t[o][i][e]=!0});return t}function Ae(e,t){const n=[],i=function(e){if(e.length){Ie(e.shift().doc(),function(a,o,s,r,c,l){const p=!o;if(!a||!c||!l)return t(a,r);const u=Ce(p?c:s);n.push(u),i(e.slice(1))})}else t(!0,ke(n))};i(e)}function Te(e){const t={};return["agent","agentClass","agentGroup","origin","originClass"].forEach(function(n){for(const i in e[n]){const a=[];for(const t in e[n][i])a.push(t);a.sort();const o=a.join("\n");t[o]||(t[o]=[]),t[o].push([n,i])}}),t}function je(e,t,n,i){return _e(e,t,Te(n),i)}function _e(e,t,n,i,a,o){const s=b.acl;for(const r in n){const c=n[r];if(!c.length)continue;const l=r.split("\n");let p=l.map(function(e){return e.split("#")[1]}).join("");o&&!a&&(p+="Default");const u=e.sym(i.uri+"#"+p);e.add(u,b.rdf("type"),s("Authorization"),i),a&&e.add(u,s("accessTo"),t,i),o&&e.add(u,s("default"),t,i);for(let t=0;t<l.length;t++)e.add(u,s("mode"),e.sym(l[t]),i);for(let t=0;t<c.length;t++){const n=c[t][0],a=c[t][1];e.add(u,s(n),e.sym(a),i)}}}function Le(e){let t="";for(const n in e){t+=n.split("\n").map(function(e){return e.split("#")[1][0]}).join("")+":";const i=e[n];for(let e=0;e<i.length;e++){const n=i[e][0],a=(0,g.sym)(i[e][1]);t+="agent"===n?"@":"",t+=a.sameTerm(b.foaf("Agent"))?"*":z(a),e<i.length-1&&(t+=",")}t+=";"}return"{"+t.slice(0,-1)+"}"}function Se(e,t,n,i,a){return Re(e,t,Te(n),i,a)}function Re(e,t,n,i,a){const o=(0,g.graph)();_e(o,t,n,i,!0),e.updater?.put(i,o.statementsMatching(void 0,void 0,void 0,i),"text/turtle",function(o,s,r){s?(e.fetcher?.unload(i),_e(e,t,n,i,!0),e.fetcher.requested[i.uri]="done",a(s)):a(s,r)})}function Ne(e,t,n,i){n=n||ve.Rm;const a=e.doc();Ie(a,function(o,s,r,c,l,p){if(!o||!l||!p)return i(!1,c);const u=Ce(s?r:l);Ae(t,function(t,o){if(!t)return i(!1,o);Ee(o,u)?n("Nice - same ACL. no change "+z(e)+" "+a):(n("Group ACLs differ for "+z(e)+" "+a),Se(ye,r,o,c,i))})})}function Ie(e,t){Be(e,function(n,i,a,o){const s=b.acl;if(!n)return t(!1,!1,i,o);const r=function(n){"/"===n.slice(-1)&&(n=n.slice(0,-1));const i=n.lastIndexOf("/");if(n.indexOf("/",n.indexOf("//")+2)>i)return t(!1,!0,404,"Found no ACL resource");n=n.slice(0,i+1);const o=(0,g.sym)(n);Be(o,function(i,c,l){if(!i)return t(!1,!0,c,`( No ACL pointer ${n} ${c})${l}`);if(403===c)return t(!1,!0,c,`( default ACL file FORBIDDEN. Stop.${n})`);if(404===c)return r(n);if(200!==c)return t(!1,!0,c,`Error status '${c}' searching for default for ${o}`);if(!ye.each(void 0,s("default"),ye.sym(n),l).concat(ye.each(void 0,s("defaultForNew"),ye.sym(n),l)).length)return r(n);const p=ye.sym(n);return t(!0,!1,e,a,p,l)})};return n?404!==i?403===i?t(!1,!1,i,`(Sharing not available to you)${o}`):200!==i?t(!1,!1,i,`Error ${i} accessing Access Control information for ${e}: ${o}`):t(!0,!0,e,a):void r(e.uri):t(!1,!1,i,`Error accessing Access Control information for ${e}) ${o}`)})}function Be(e,t){if(!ye.fetcher)throw new Error("kb has no fetcher");ye.fetcher.nowOrWhenFetched(e,void 0,function(n,i){if(!n)return t(n,`Can't get headers to find ACL for ${e}: ${i}`);const a=ye.any(e,x.ACL_LINK);if(a){if(!ye.fetcher)throw new Error("kb has no fetcher");if(ye.fetcher.nonexistent[a.value])return t(!0,404,a,`ACL file ${a} does not exist.`);ye.fetcher.nowOrWhenFetched(a,void 0,function(e,n,i){e?t(!0,200,a):t(!0,i.status,a,`Can't read Access Control File ${a}: ${n}`)})}else t(!1,900,`No Link rel=ACL header for ${e}`)})}async function De(e){return new Promise((t,n)=>Ie((0,g.sym)(e),(i,a,o,s,r)=>i?t(a?o:r):n(new Error(`Error loading ${e}`))))}var Oe=n(580),Me=n.n(Oe);const Fe=new Uint8Array(16);const Ue=[];for(let e=0;e<256;++e)Ue.push((e+256).toString(16).slice(1));function ze(e,t=0){return(Ue[e[t+0]]+Ue[e[t+1]]+Ue[e[t+2]]+Ue[e[t+3]]+"-"+Ue[e[t+4]]+Ue[e[t+5]]+"-"+Ue[e[t+6]]+Ue[e[t+7]]+"-"+Ue[e[t+8]]+Ue[e[t+9]]+"-"+Ue[e[t+10]]+Ue[e[t+11]]+Ue[e[t+12]]+Ue[e[t+13]]+Ue[e[t+14]]+Ue[e[t+15]]).toLowerCase()}const Pe=function(e,t,n){return t||e||!crypto.randomUUID?function(e,t,n){e=e||{};const i=e.random??e.rng?.()??crypto.getRandomValues(Fe);if(i.length<16)throw new Error("Random bytes length must be >= 16");if(i[6]=15&i[6]|64,i[8]=63&i[8]|128,t){if((n=n||0)<0||n+16>t.length)throw new RangeError(`UUID byte range ${n}:${n+15} is out of buffer bounds`);for(let e=0;e<16;++e)t[n+e]=i[e];return t}return ze(i)}(e,t,n):crypto.randomUUID()};var $e=n(49);const qe="#888888",He="8em",Ge=20,Ve="#fff",We="#000",Je="#888",Qe="#fee",Ze="white",Ye="4096",Ke={checkboxStyle:"color: black; font-size: 100%; padding-left: 0.5 em; padding-right: 0.5 em;",checkboxInputStyle:"font-size: 150%; height: 1.2em; width: 1.2em; background-color: #eef; border-radius:0.2em; margin: 0.1em;",fieldLabelStyle:"color: #3B5998; text-decoration: none;",formSelectStyle:"background-color: #eef; padding: 0.5em; border: .05em solid #88c; border-radius:0.2em; font-size: 100%; margin:0.4em;",textInputStyle:"background-color: #eef; padding: 0.5em; border: .05em solid #88c; border-radius:0.2em; font-size: 100%; margin:0.4em;",textInputStyleUneditable:"background-color: white; padding: 0.5em; border: .05em solid white; border-radius:0.2em; font-size: 100%; margin:0.4em;",buttonStyle:"background-color: #fff; padding: 0.7em; border: .01em solid white; border-radius:0.2em; font-size: 100%; margin: 0.3em;",commentStyle:"padding: 0.7em; border: none; font-size: 100%; white-space: pre-wrap;",iconStyle:"width: 3em; height: 3em; margin: 0.1em; border-radius: 1em;",smallButtonStyle:"margin: 0.2em; width: 1em; height:1em;",classIconStyle:"width: 3em; height: 3em; margin: 0.1em; border-radius: 0.2em; border: 0.1em solid green; padding: 0.2em; background-color: #efe;",confirmPopupStyle:"padding: 0.7em; border-radius: 0.2em; border: 0.1em solid orange; background-color: white; box-shadow: 0.5em 0.9em #888;",messageBodyStyle:"white-space: pre-wrap; width: 99%; font-size:100%; border: 0.07em solid #eee; border-radius:0.2em; padding: .3em 0.5em; margin: 0.1em;",pendingeditModifier:"color: #bbb;",personaBarStyle:"width: 100%; height: 4em; background-color: #eee; vertical-align: middle;",searchInputStyle:"border: 0.1em solid #444; border-radius: 0.2em; width: 100%; font-size: 100%; padding: 0.1em 0.6em; margin 0.2em;",autocompleteRowStyle:"border: 0.2em solid straw;",signInAndUpButtonStyle:"padding: 1em; border-radius:0.2em; font-size: 100%;",headerBannerLoginInput:"margin: 0.75em 0 0.75em 0.5em !important; padding: 0.5em !important;",signUpBackground:"background-color: #eef;",signInBackground:"background-color: #efe;",heading1Style:"font-size: 180%; font-weight: bold; color: #888888; padding: 0.5em; margin: 0.7em 0.0m;",heading2Style:"font-size: 130%; font-weight: bold; color: #888888; padding: 0.4em; margin: 0.7em 0.0em;",heading3Style:"font-size: 120%; font-weight: bold; color: #888888; padding: 0.3em; margin: 0.7em 0.0em;",heading4Style:"font-size: 110%; font-weight: bold; color: #888888; padding: 0.2em; margin: 0.7em 0.0em;",formHeadingStyle:"font-size: 110%; font-weight: bold; color: #888888; padding: 0.2em; margin: 0.7em 0.0em;",formTextInput:"font-size: 100%; margin: 0.1em; padding: 0.1em;",formGroupStyle:[`padding-left: 0em; border: 0.0em solid ${qe}; border-radius: 0.2em;`,`padding-left: 2em; border: 0.05em solid ${qe}; border-radius: 0.2em;`,`padding-left: 2em; border: 0.1em solid ${qe}; border-radius: 0.2em;`,`padding-left: 2em; border: 0.2em solid ${qe}; border-radius: 0.2em;`],formFieldLabelStyle:`color: ${"#3B5998"}; text-decoration: none;`,formFieldNameBoxStyle:`padding: 0.3em; vertical-align: middle; width:${He};`,multilineTextInputStyle:"font-size:100%; white-space: pre-wrap; background-color: #eef; border: 0.07em solid gray; padding: 1em 0.5em; margin: 1em 1em;",renderAsDivStyle:"display: flex; align-items: center; justify-content: space-between; height: 2.5em; padding: 1em;",imageDivStyle:"width:2.5em; padding:0.5em; height: 2.5em;",linkDivStyle:"width:2em; padding:0.5em; height: 4em;",aclControlBoxContainer:"margin: 1em;",aclControlBoxHeader:"font-size: 120%; margin: 0 0 1rem;",aclControlBoxStatus:"display: none; margin: 1rem 0;",aclControlBoxStatusRevealed:"display: block;",aclGroupContent:"maxWidth: 650;",accessGroupList:"display: grid; grid-template-columns: 1fr; margin: 1em; width: 100%;",accessGroupListItem:"display: grid; grid-template-columns: 100px auto 30%;",defaultsController:"display: flex;",defaultsControllerNotice:"color: #888; flexGrow: 1; fontSize: 80%;",bigButton:"background-color: white; border: 0.1em solid #888; border-radius: 0.3em; max-width: 50%; padding-bottom: 1em; padding-top: 1em;",group:"color: #888;",group1:"color: green;",group2:"color: #cc0;",group3:"color: orange;",group5:"color: red;",group9:"color: blue;",group13:"color: purple;",trustedAppAddApplicationsTable:"background-color: #eee;",trustedAppCancelButton:"float: right;",trustedAppControllerI:"border-color: orange; border-radius: 1em; border-width: 0.1em;",temporaryStatusInit:"background: green;",temporaryStatusEnd:"background: transparent; transition: background 5s linear;",headerUserMenuLink:"background: none; border: 0; color: black; cursor: pointer; display: block; font-family: Arial; font-size: 1em; text-align: left; padding: 1em; width: 100%; text-decoration: none;",headerUserMenuLinkHover:"background: none; border: 0; color: black; cursor: pointer; display: block; font-family: Arial; font-size: 1em; text-align: left; padding: 1em; width: 100%; text-decoration: none; background-image: linear-gradient(to right, #7C4DFF 0%, #18A9E6 50%, #01C9EA 100%);",headerUserMenuTrigger:"background: none; border: 0; cursor: pointer; width: 60px; height: 60px;",headerUserMenuTriggerImg:"border-radius: 50%; height: 56px; width: 28px !important;",headerUserMenuButton:"background: none; border: 0; color: black; cursor: pointer; display: block; font-family: Arial; font-size: 1em; text-align: left; padding: 1em; width: 100%;",headerUserMenuButtonHover:"background: none; border: 0; color: black; cursor: pointer; display: block; font-family: Arial; font-size: 1em; text-align: left; padding: 1em; width: 100%; background-image: linear-gradient(to right, #7C4DFF 0%, #18A9E6 50%, #01C9EA 100%);",headerUserMenuList:"list-style: none; margin: 0; padding: 0;",headerUserMenuListDisplay:"list-style: none; margin: 0; padding: 0; display:true;",headerUserMenuNavigationMenu:"background: white; border: solid 1px #000000; border-right: 0; position: absolute; right: 0; top: 60px; width: 200px; z-index: 1; display: true;",headerUserMenuNavigationMenuNotDisplayed:"background: white; border: solid 1px #000000; border-right: 0; position: absolute; right: 0; top: 60px; width: 200px; z-index: 1; display: none;",headerUserMenuListItem:"border-bottom: solid 1px #000000;",headerUserMenuPhoto:"border-radius: 50%; background-position: center; background-repeat: no-repeat; background-size: cover; height: 50px; width: 50px;",headerBanner:"box-shadow: 0px 1px 4px #000000; display: flex; justify-content: space-between; padding: 0 1.5em; margin-bottom: 4px;",headerBannerLink:"display: block;",headerBannerRightMenu:"display: flex;",headerBannerLogin:"margin-left: auto;",allChildrenVisible:"display:true;",headerBannerUserMenu:"border-left: solid 1px #000000; margin-left: auto;",headerBannerHelpMenu:"border-left: solid 1px #000000; margin-left: auto;",headerBannerIcon:"background-size: 65px 60px !important; height: 60px !important; width: 65px !important;",footer:"border-top: solid 1px $divider-color; font-size: 0.9em; padding: 0.5em 1.5em;",primaryButton:"background-color: #7c4dff; color: #ffffff; font-family: Raleway, Roboto, sans-serif; border-radius: 0.25em; border-color: #7c4dff; border: 1px solid; cursor: pointer; font-size: .8em; text-decoration: none; padding: 0.5em 4em; transition: 0.25s all ease-in-out; outline: none;",primaryButtonHover:"background-color: #9f7dff; color: #ffffff; font-family: Raleway, Roboto, sans-serif;border-radius: 0.25em; border-color: #7c4dff; border: 1px solid; cursor: pointer; font-size: .8em; text-decoration: none; padding: 0.5em 4em; transition: 0.25s all ease-in-out; outline: none; transition: 0.25s all ease-in-out;",primaryButtonNoBorder:"background-color: #ffffff; color: #7c4dff; font-family: Raleway, Roboto, sans-serif;border-radius: 0.25em; border-color: #7c4dff; border: 1px solid; cursor: pointer; font-size: .8em; text-decoration: none; padding: 0.5em 4em; transition: 0.25s all ease-in-out; outline: none;",primaryButtonNoBorderHover:"background-color: #7c4dff; color: #ffffff; font-family: Raleway, Roboto, sans-serif; border-radius: 0.25em; border-color: #7c4dff; border: 1px solid; cursor: pointer; font-size: .8em; text-decoration: none; padding: 0.5em 4em; transition: 0.25s all ease-in-out; outline: none; transition: 0.25s all ease-in-out;",secondaryButton:"background-color: #01c9ea; color: #ffffff; font-family: Raleway, Roboto, sans-serif;border-radius: 0.25em; border-color: #01c9ea; border: 1px solid; cursor: pointer; font-size: .8em; text-decoration: none; padding: 0.5em 4em; transition: 0.25s all ease-in-out; outline: none;",secondaryButtonHover:"background-color: #37cde6; color: #ffffff; font-family: Raleway, Roboto, sans-serif;border-radius: 0.25em; border-color: #7c4dff; border: 1px solid; cursor: pointer; font-size: .8em; text-decoration: none; padding: 0.5em 4em; transition: 0.25s all ease-in-out; outline: none; transition: 0.25s all ease-in-out;",secondaryButtonNoBorder:"background-color: #ffffff; color: #01c9ea; font-family: Raleway, Roboto, sans-serif; border-radius: 0.25em; border-color: #01c9ea; border: 1px solid; cursor: pointer; font-size: .8em; text-decoration: none; padding: 0.5em 4em; transition: 0.25s all ease-in-out; outline: none;",secondaryButtonNoBorderHover:"background-color: #01c9ea; color: #ffffff; font-family: Raleway, Roboto, sans-serif; border-radius: 0.25em; border-color: #01c9ea; border: 1px solid; cursor: pointer; font-size: .8em; text-decoration: none; padding: 0.5em 4em; transition: 0.25s all ease-in-out; outline: none; transition: 0.25s all ease-in-out;",controlStyle:`border-radius: 0.5em; margin: 0.8em; width:${"640"}; height:${"480"};`,dragEvent:"background-color: #ccc; border: 0.25em dashed black; border-radius: 0.3em;",dropEvent:"background-color: white; border: 0em solid black;",restoreStyle:"background-color: white;",errorCancelButton:"width: 2em; height: 2em; align: right;",errorMessageBlockStyle:"margin: 0.1em; padding: 0.5em; border: 0.05em solid gray; color:black;",notepadStyle:"padding: 1em; overflow: auto; resize: horizontal; min-width: 40em;",upstreamStatus:"width: 50%;",downstreamStatus:"width: 50%;",baseStyle:"font-size: 100%; font-family: monospace; width: 100%; border: none; white-space: pre-wrap;",headingCore:"font-family: sans-serif; font-weight: bold; border: none;",headingStyle:["font-size: 110%; padding-top: 0.5em; padding-bottom: 0.5em; width: 100%;","font-size: 120%; padding-top: 1em; padding-bottom: 1em; width: 100%;","font-size: 150%; padding-top: 1em; padding-bottom: 1em; width: 100%;"],participantsStyle:"margin: 0.8em;",participantsBlock:"height: 1.5em; width: 1.5em; margin: 0.3em; border 0.01em solid #888;",personTableTD:"vertical-align: middle;",tabsNavElement:"margin: 0;",tabsRootElement:"display: flex; height: 100%; width: 100%;",tabsMainElement:"margin: 0; width:100%; height: 100%;",tabContainer:"list-style-type: none; display: flex; height: 100%; width: 100%; margin: 0; padding: 0;",makeNewSlot:"background: none; border: none; font: inherit; cursor: pointer;",ellipsis:"position: absolute; right: 0; bottom: 0; width: 20%; background: none; color: inherit; border: none; padding: 0; font: inherit; cursor: pointer; outline: inherit;"};function Xe(e,t,n){const i=function(e){return e.split("\n").map(e=>e.trim()).filter(e=>e&&"#"!==e[0])},a=function(e){e.preventDefault(),e.stopPropagation(),e.dataTransfer.dropEffect="copy"},o=function(e){e.preventDefault(),e.stopPropagation(),ve.Rm("dragenter event dropEffect: "+e.dataTransfer.dropEffect),this.localStyle&&(this.savedStyle||(this.savedStyle=Ke.dragEvent)),e.dataTransfer.dropEffect="link",ve.Rm("dragenter event dropEffect 2: "+e.dataTransfer.dropEffect)},s=function(e){e.stopPropagation(),ve.Rm("dragleave event dropEffect: "+e.dataTransfer.dropEffect),this.savedStyle?this.localStyle=this.savedStyle:this.localStyle=Ke.dropEvent},r=function(e){e.preventDefault&&e.preventDefault(),e.stopPropagation&&e.stopPropagation(),ve.Rm("Drop event. dropEffect: "+e.dataTransfer.dropEffect),ve.Rm("Drop event. types: "+(e.dataTransfer.types?e.dataTransfer.types.join(", "):"NOPE"));let a,o=null;if(e.dataTransfer.types){for(let t=0;t<e.dataTransfer.types.length;t++){const s=e.dataTransfer.types[t];if("text/uri-list"===s)o=i(e.dataTransfer.getData(s)),ve.Rm("Dropped text/uri-list: "+o);else if("text/plain"===s)a=e.dataTransfer.getData(s);else if("Files"===s&&n){const t=e.dataTransfer.files;for(let e=0;t[e];e++){const n=t[e];ve.Rm("Filename: "+n.name+", type: "+(n.type||"n/a")+" size: "+n.size+" bytes, last modified: "+(n.lastModifiedDate?n.lastModifiedDate.toLocaleDateString():"n/a"))}n(t)}}const t=a?a.trim():"";null===o&&t&&"http"===t.slice(0,4)&&(o=[t],ve.Rm("Warning: Poor man's drop: using text for URI"))}else o=i(e.dataTransfer.getData("Text")),ve.Rm("WARNING non-standard drop event: "+o[0]);return ve.Rm("Dropped URI list (2): "+o),o&&t(o),this.localStyle=Ke.restoreStyle,!1};!function(e){e||ve.Rm("@@@ addTargetListeners: ele "+e),e.addEventListener("dragover",a),e.addEventListener("dragenter",o),e.addEventListener("dragleave",s),e.addEventListener("drop",r)}(e)}function et(e,t){e.setAttribute("draggable","true"),e.addEventListener("dragstart",function(n){e.style.fontWeight="bold",n.dataTransfer.setData("text/uri-list",t.uri),n.dataTransfer.setData("text/plain",t.uri),n.dataTransfer.setData("text/html",e.outerHTML),ve.Rm("Dragstart: "+e+" -> "+t+"de: "+n.dataTransfer.dropEffect)},!1),e.addEventListener("drag",function(e){e.preventDefault(),e.stopPropagation()},!1),e.addEventListener("dragend",function(n){e.style.fontWeight="normal",ve.Rm("Dragend dropeffect: "+n.dataTransfer.dropEffect),ve.Rm("Dragend: "+e+" -> "+t)},!1)}function tt(e,t,n,i,a){for(let o=0;t[o];o++){const s=t[o];ve.Rm(" dropped: Filename: "+s.name+", type: "+(s.type||"n/a")+" size: "+s.size+" bytes, last modified: "+(s.lastModifiedDate?s.lastModifiedDate.toLocaleDateString():"n/a"));const r=new FileReader;r.onload=function(t){return function(o){const s=o.target.result;let r="";ve.Rm(" File read byteLength : "+s.byteLength);let c=t.type;if(t.type&&""!==t.type){const e=$e.extension(t.type);e&&"false"!==e&&!t.name.endsWith("."+e)&&t.type!==$e.lookup(t.name)&&(r="_."+e)}else if(c=$e.lookup(t.name),!c){const e="Filename needs to have an extension which gives a type we know: "+t.name;throw ve.Rm(e),alert(e),new Error(e)}const l=t.type.startsWith("image/")&&i||n,p=l+(l.endsWith("/")?"":"/")+encodeURIComponent(t.name)+r;e.webOperation("PUT",p,{data:s,contentType:c}).then(e=>{ve.Rm(" Upload: put OK: "+p),a(t,p)},e=>{const t=" Upload: FAIL "+p+", Error: "+e;throw ve.Rm(t),alert(t),new Error(t)})}}(s),r.readAsArrayBuffer(s)}}function nt(e,t,n,i){const a=e.createElement("div"),o=i||t instanceof Error?t:null;return o?(console.error(`errorMessageBlock: ${o} at: ${o.stack||"??"}`,o),a.textContent=o.message):a.textContent=t,a.appendChild(Mt(e,()=>{a.parentNode&&a.parentNode.removeChild(a)})).style=Ke.errorCancelButton,a.setAttribute("style",Ke.errorMessageBlockStyle),a.style.backgroundColor=n||Qe,a}Ke.setStyle=function(e,t){e.style=Ke[t]};var it=n(378);const at=x.solidLogicSingleton.store;class ot{constructor(e,t,n,i){this.options=i||{},this.element=e,this.typeIndex=t,this.groupPickedCb=n,this.selectedgroup=this.options.selectedgroup,this.onSelectGroup=this.onSelectGroup.bind(this)}render(){const e=document.createElement("div");if(e.style.maxWidth="350px",e.style.minHeight="200px",e.style.outline="1px solid black",e.style.display="flex",this.selectedgroup){e.style.flexDirection="column";const t=document.createElement("div");new rt(t,this.selectedgroup).render();const n=document.createElement("button");n.textContent=Me()("Change group"),n.addEventListener("click",e=>{this.selectedgroup=null,this.render()}),e.appendChild(t),e.appendChild(n)}else this.findAddressBook(this.typeIndex).then(({book:t})=>{const n=document.createElement("button");n.textContent=Me()("Pick an existing group"),n.style.margin="auto",n.addEventListener("click",n=>{new st(e,t,this.onSelectGroup).render()});const i=document.createElement("button");i.textContent=Me()("Create a new group"),i.style.margin="auto",i.addEventListener("click",e=>{this.createNewGroup(t,this.options.defaultNewGroupName).then(({group:e})=>{new ct(this.element,t,e,this.onSelectGroup).render()}).catch(e=>{this.element.appendChild(nt(document,Me()(`Error creating a new group. (${e})`)))})}),e.appendChild(n),e.appendChild(i),this.element.innerHTML="",this.element.appendChild(e)}).catch(e=>{this.element.appendChild(nt(document,Me()(`Could find your groups. (${e})`)))});return this.element.innerHTML="",this.element.appendChild(e),this}findAddressBook(e){return new Promise((t,n)=>{at.fetcher.nowOrWhenFetched(e,(i,a)=>{if(!i)return n(a);const o=at.any(null,b.solid("forClass"),b.vcard("AddressBook"));if(!o)return n(new Error("no address book registered in the solid type index "+e));const s=at.any(o,b.solid("instance"));if(!s)return n(new Error("incomplete address book registration"));at.fetcher.load(s).then(function(e){return t({book:s})}).catch(function(e){return n(new Error("Could not load address book "+e))})})})}createNewGroup(e,t){const{groupIndex:n,groupContainer:i}=dt(e),a=g.sym(`${i.uri}${Pe().slice(0,8)}.ttl#this`),o=t||"Untitled Group",s=[a.doc(),n].map(t=>{const i=g.st(a,b.rdf("type"),b.vcard("Group"),t),s=g.st(a,b.vcard("fn"),o,a.doc(),t),r=g.st(e,b.vcard("includesGroup"),a,t),c=t.equals(n)?[i,s,r]:[i,s];return ut(t.uri,{toIns:c}).then(()=>{c.forEach(e=>{at.add(e)})})});return Promise.all(s).then(()=>({group:a})).catch(e=>{throw ve.Rm("Could not create new group. PATCH failed "+e),new Error(`Couldn't create new group. PATCH failed for (${e.xhr?e.xhr.responseURL:""} )`)})}onSelectGroup(e){this.selectedgroup=e,this.groupPickedCb(e),this.render()}}class st{constructor(e,t,n){this.element=e,this.book=t,this.onSelectGroup=n}render(){return this.loadGroups().then(e=>{const t=document.createElement("div");t.style.display="flex",t.style.flexDirection="column",e.forEach(e=>{const n=document.createElement("button");n.addEventListener("click",this.handleClickGroup(e)),new rt(n,e).render(),t.appendChild(n)}),this.element.innerHTML="",this.element.appendChild(t)}).catch(e=>{this.element.appendChild(nt(document,Me()(`There was an error loading your groups. (${e})`)))}),this}loadGroups(){return new Promise((e,t)=>{const{groupIndex:n}=dt(this.book);at.fetcher.nowOrWhenFetched(n,(n,i)=>{if(!n)return t(i);const a=at.each(this.book,b.vcard("includesGroup"));return e(a)})})}handleClickGroup(e){return t=>{this.onSelectGroup(e)}}}class rt{constructor(e,t){this.element=e,this.group=t}render(){const e=document.createElement("div");return e.textContent=Me()(pt(this.group,b.vcard("fn"),`[${this.group.value}]`)),this.element.innerHTML="",this.element.appendChild(e),this}}class ct{constructor(e,t,n,i,a){this.element=e,this.book=t,this.group=n,this.onGroupChanged=(e,t,n)=>{a&&a(e,t,n)},this.groupChangedCb=a,this.doneBuildingCb=i}refresh(){}render(){const e=document.createElement("div");e.style.maxWidth="350px",e.style.minHeight="200px",e.style.outline="1px solid black",e.style.display="flex",e.style.flexDirection="column",Xe(e,e=>{e.forEach(e=>{this.add(e).catch(e=>{this.element.appendChild(nt(document,Me()(`Could not add the given WebId. (${e})`)))})})});const t=document.createElement("input");t.type="text",t.value=pt(this.group,b.vcard("fn"),"Untitled Group"),t.addEventListener("change",e=>{this.setGroupName(e.target.value).catch(e=>{this.element.appendChild(nt(document,`Error changing group name. (${e})`))})});const n=document.createElement("label");if(n.textContent=Me()("Group Name:"),n.appendChild(t),e.appendChild(n),at.any(this.group,b.vcard("hasMember")))at.match(this.group,b.vcard("hasMember")).forEach(t=>{const n=t.object,i=document.createElement("div");new lt(i,n,this.handleRemove(n)).render(),e.appendChild(i)});else{const t=document.createElement("p");t.textContent=Me()`
|
|
1
|
+
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.UI=t():e.UI=t()}(this,()=>(()=>{var e={423(e,t,n){"use strict";function i(...e){console.log(...e)}function a(...e){console.warn(...e)}function o(...e){console.error(...e)}function s(...e){console.trace(...e)}n.d(t,{R8:()=>a,Rm:()=>i,uP:()=>s,z3:()=>o})},378(e,t,n){"use strict";n.d(t,{LN:()=>s,Pt:()=>o,i1:()=>r});var i=n(423);const a="https://solidos.github.io/solid-ui/src",o=(e=n.hmd(e)).scriptURI?{iconBase:e.scriptURI.slice(0,e.scriptURI.lastIndexOf("/"))+"/icons/",originalIconBase:e.scriptURI.slice(0,e.scriptURI.lastIndexOf("/"))+"/originalIcons/"}:"undefined"!=typeof $SolidTestEnvironment&&$SolidTestEnvironment.iconBase?{iconBase:$SolidTestEnvironment.iconBase,originalIconBase:$SolidTestEnvironment.originalIconBase}:{iconBase:a+"/icons/",originalIconBase:a+"/originalIcons/"};(0,i.Rm)(" icons.iconBase is set to : "+o.iconBase);const s=o.iconBase,r=o.originalIconBase},788(e,t,n){"use strict";n.r(t),n.d(t,{acl:()=>ca,aclControl:()=>la,create:()=>ua,createTypes:()=>m,dom:()=>Xr,icons:()=>it.Pt,infiniteMessageArea:()=>kr,initFooter:()=>Yr,initHeader:()=>qr,language:()=>o,log:()=>i,login:()=>c,matrix:()=>ma,media:()=>ba,messageArea:()=>va,ns:()=>b,pad:()=>p,participation:()=>l,preferences:()=>u,style:()=>Ke,table:()=>Dr,tabs:()=>d,utils:()=>a,widgets:()=>r});var i={};n.r(i),n.d(i,{LogLevel:()=>v,alert:()=>R,clear:()=>N,debug:()=>j,dumpHTML:()=>B,error:()=>L,escapeForXML:()=>M,info:()=>_,logAscending:()=>D,logDescending:()=>O,msg:()=>A,setInternals:()=>F,setLevel:()=>I,success:()=>S,warn:()=>T});var a={};n.r(a),n.d(a,{AJARImage:()=>ce,RDFComparePredicateObject:()=>ge,RDFComparePredicateSubject:()=>be,addLoadEvent:()=>oe,ancestor:()=>te,beep:()=>W,clearVariableNames:()=>V,emptyNode:()=>X,escapeForXML:()=>de,findPos:()=>se,genUuid:()=>Q,getAbout:()=>ne,getEyeFocus:()=>re,getTarget:()=>ee,getTerm:()=>ie,hashColor:()=>J,include:()=>ae,label:()=>U,labelForXML:()=>me,labelWithOntology:()=>ue,newVariableName:()=>G,ontologyLabel:()=>pe,predParentOf:()=>xe,predicateLabel:()=>he,predicateLabelForXML:()=>fe,shortName:()=>le,stackString:()=>K,syncTableToArray:()=>Z,syncTableToArrayReOrdered:()=>Y});var o={};n.r(o),n.d(o,{addDefaults:()=>wn,defaultPreferredLanguages:()=>yn,filterByLanguage:()=>kn,getPreferredLanguages:()=>En,getPreferredLanguagesFor:()=>Cn,languageCodeURIBase:()=>vn});var s={};n.r(s),n.d(s,{AUTOCOMPLETE_LIMIT:()=>An,ESCOResultToBindings:()=>zn,bindingToTerm:()=>Mn,dbPediaTypeMap:()=>Nn,dbpediaParameters:()=>Rn,escoParameters:()=>Sn,fetcherOptionsJsonPublicData:()=>Ln,getDbpediaDetails:()=>Qn,getWikidataDetails:()=>Vn,getWikidataDetailsOld:()=>Wn,getWikidataLocation:()=>Jn,instituteDetailsWikidataQuery:()=>_n,loadFromBindings:()=>Fn,loadPublicDataThing:()=>Gn,queryESCODataByName:()=>Un,queryPublicDataByName:()=>$n,queryPublicDataConstruct:()=>Hn,queryPublicDataSelect:()=>qn,variableNameToPredicateMap:()=>On,wikidataClasses:()=>jn,wikidataIncomingClassMap:()=>Dn,wikidataOutgoingClassMap:()=>In,wikidataParameters:()=>Bn});var r={};n.r(r),n.d(r,{Group:()=>rt,GroupBuilder:()=>ct,GroupPicker:()=>st,PeoplePicker:()=>ot,Person:()=>lt,addStyleSheet:()=>nn,allClassURIs:()=>Qt,appendForm:()=>li,askName:()=>zt,attachmentList:()=>Vt,basicField:()=>xn,buildCheckboxForm:()=>Ci,button:()=>Ot,cancelButton:()=>Mt,clearElement:()=>yt,complain:()=>vt,continueButton:()=>Ft,createLinkDiv:()=>qt,createLinkForURI:()=>ht,createNameDiv:()=>$t,defaultAnnotationStore:()=>Jt,deleteButtonWithCheck:()=>Dt,editFormButton:()=>ci,errorMessageBlock:()=>nt,extractLogURI:()=>wt,faviconOrDefault:()=>Bt,field:()=>pn,fieldFunction:()=>dn,fieldLabel:()=>gn,fieldParams:()=>cn,fieldStore:()=>bn,fileUploadButtonDiv:()=>rn,findClosest:()=>ui,findImage:()=>Rt,findImageFromURI:()=>St,formatDateTime:()=>Et,formsFor:()=>di,iconForClass:()=>_t,imagesOf:()=>jt,index:()=>tn,isAudio:()=>an,isImage:()=>sn,isVideo:()=>on,linkButton:()=>Yt,linkIcon:()=>ft,makeDescription:()=>bi,makeDraggable:()=>et,makeDropTarget:()=>Xe,makeSelectForCategory:()=>yi,makeSelectForChoice:()=>ki,makeSelectForClassifierOptions:()=>xi,makeSelectForNestedCategory:()=>wi,makeSelectForOptions:()=>vi,mostSpecificClassURI:()=>un,newButton:()=>hi,newThing:()=>Ei,openHrefInOutlineMode:()=>Wt,personTR:()=>Ut,promptForNew:()=>gi,propertiesForClass:()=>pi,propertyTriage:()=>Zt,publicData:()=>s,refreshTree:()=>Gt,removeButton:()=>Kt,renderAsDiv:()=>Ht,renderAsRow:()=>Pt,renderAutoComplete:()=>Yn,renderAutocompleteControl:()=>ti,renderNameValuePair:()=>hn,selectorPanel:()=>Xt,selectorPanelRefresh:()=>en,setImage:()=>It,setName:()=>Tt,setVisible:()=>Zn,shortDate:()=>Ct,shortTime:()=>At,sortByLabel:()=>fi,sortBySequence:()=>mi,timestamp:()=>kt,uploadFiles:()=>tt});var c={};n.r(c),n.d(c,{ensureLoadedPreferences:()=>Oi,ensureLoadedProfile:()=>Mi,ensureLoggedIn:()=>Di,filterAvailablePanes:()=>Ji,findAppInstances:()=>Fi,getUserRoles:()=>Wi,loginStatusBox:()=>Hi,newAppInstance:()=>Vi,registrationControl:()=>Ui,registrationList:()=>$i,renderScopeHeadingRow:()=>Pi,renderSignInPopup:()=>qi,scopeLabel:()=>zi,selectWorkspace:()=>Gi});var l={};n.r(l),n.d(l,{manageParticipation:()=>Ks,participationObject:()=>Zs,recordParticipation:()=>Ys,renderParticipants:()=>Qs});var p={};n.r(p),n.d(p,{getChunks:()=>ir,lightColorHash:()=>tr,manageParticipation:()=>Ks,notepad:()=>nr,notepadToHTML:()=>or,participationObject:()=>Zs,recordParticipation:()=>Ys,renderParticipants:()=>Qs,xmlEncode:()=>ar});var u={};n.r(u),n.d(u,{get:()=>jr,getPreferencesForClass:()=>Ir,recordPersonalDefaults:()=>Sr,recordSharedPreferences:()=>Lr,renderPreferencesForm:()=>Rr,set:()=>_r,value:()=>Tr});var d={};n.r(d),n.d(d,{TabWidgetElement:()=>Or,tabWidget:()=>Mr});var m={};n.r(m);var f=n(386),h=n.n(f),g=n(511);const b=h()(g);var x=n(892);let v=function(e){return e[e.Error=1]="Error",e[e.Warning=2]="Warning",e[e.Message=4]="Message",e[e.Success=8]="Success",e[e.Info=16]="Info",e[e.Debug=32]="Debug",e[e.All=63]="All",e}({}),y=7,w=!1,C=document,E=window;function k(e,t=4,n="mesg"){if(y&t)if(void 0!==C){const t=C.getElementById("status");if(!t)return;const i=C.createElement("span");i.setAttribute("class",n);const a=new Date;i.innerHTML=`${a.getHours()}:${a.getMinutes()}:${a.getSeconds()} [${n}] ${M(e)}<br/>`,w?t.insertBefore(i,t.firstChild):t.appendChild(i)}else"undefined"!=typeof console&&console.log(e)}function A(e){k(e)}function T(e){k(e,2,"warn")}function j(e){k(e,32,"dbug")}function _(e){k(e,16,"info")}function L(e){k(e,1,"eror")}function S(e){k(e,8,"good")}function R(e){E&&void 0!==E.alert?E.alert(e):T(e)}function N(){const e=C?.getElementById("status");e&&(e.innerHTML="")}function I(e){y=63,j("Log level is now "+e),y=e}function B(){if(!C)return;const e=y;y=63,j(C?.body?.innerHTML||""),y=e}function D(){w=!0}function O(){w=!1}function M(e){return e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">")}function F(e,t){E=e,C=t}const z={log:i,ns:b,rdf:g};function U(e,t=!1){function n(e){return t?e.slice(0,1).toUpperCase()+e.slice(1):e}function i(e){let t="";"/"===e.slice(-1)&&(e=e.slice(0,-1));for(let n=0;n<e.length;n++)"_"!==e[n]&&"-"!==e[n]?(t+=e[n],n+1<e.length&&e[n].toUpperCase()!==e[n]&&e[n+1].toLowerCase()!==e[n+1]&&(t+=" ")):t+=" ";return"has "===t.slice(0,4)&&(t=t.slice(4)),n(t)}const a=function(e){return x.store.any(e,z.ns.ui("label"))||x.store.any(e,z.ns.link("message"))||x.store.any(e,z.ns.vcard("fn"))||x.store.any(e,z.ns.foaf("name"))||x.store.any(e,z.ns.dct("title"))||x.store.any(e,z.ns.dc("title"))||x.store.any(e,z.ns.rss("title"))||x.store.any(e,z.ns.contact("fullName"))||x.store.any(e,x.store.sym("http://www.w3.org/2001/04/roadmap/org#name"))||x.store.any(e,z.ns.cal("summary"))||x.store.any(e,z.ns.foaf("nick"))||x.store.any(e,z.ns.as("name"))||x.store.any(e,z.ns.schema("name"))||x.store.any(e,z.ns.rdfs("label"))||x.store.any(e,x.store.sym("http://www.w3.org/2004/02/skos/core#prefLabel"))}(e);if(a)return n(a.value);if("BlankNode"===e.termType)return"...";if("Collection"===e.termType)return"("+e.elements.length+")";let o=e.uri;if(void 0===o)return e.toString();try{o=o.split("/").map(decodeURIComponent).join("/")}catch(e){for(let e=o.length-3;e>0;e--){const t="0123456789abcefABCDEF";for(;"%"===o[e]&&t.indexOf(o[e+1])>=0&&t.indexOf(o[e+2])>=0;)o=o.slice(0,e)+String.fromCharCode(parseInt(o.slice(e+1,e+3),16))+o.slice(e+3)}}o=P(o,"/profile/card#me"),o=P(o,"#this"),o=P(o,"#me");const s=o.indexOf("#");if(s>=0)return i(o.slice(s+1));const r=o.lastIndexOf("/",o.length-2);return r>=0&&r<e.uri.length?i(o.slice(r+1)):n(decodeURIComponent(e.uri))}function P(e,t){const n=-1*t.length;return e.slice(n)===t?e.slice(0,n):e}const $={log:i,ns:b,rdf:g};let q,H=0;function G(){return"v"+H++}function V(){H=0}function W(){if(!q)return;const e=new q;return function(t,n,i,a){t=+(t||.3),i=i||"sine","function"!=typeof a&&(a=function(){});const o=e.createOscillator();o.type=i,o.frequency.value=n||256,o.connect(e.destination),o.start(0),o.stop(t)}}function J(e){e=e.uri||e;return"#"+(16777215&(t=e,t.split("").reduce(function(e,t){return(e=(e<<5)-e+t.charCodeAt(0))&e},0))|12632256).toString(16);var t}function Q(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(e){const t=16*Math.random()|0;return("x"===e?t:3&t|8).toString(16)})}function Z(e,t,n,i){let a,o,s;for(s=0;s<e.children.length;s++)o=e.children[s],o.trashMe=!0;for(let r=0;r<t.length;r++){const c=t[r];for(a=!1,s=0;s<e.children.length;s++)if(o=e.children[s],o.subject&&o.subject.sameTerm(c)){if(i){const e=i(o,c);e&&e!==o&&(o.parentNode.replaceChild(e,o),e.subject=c,o=e)}o.trashMe=!1,a=!0;break}if(!a){const t=n(c);if(r>=e.children.length)e.appendChild(t);else{const n=e.children[r];e.insertBefore(t,n)}t.subject=c}}for(s=0;s<e.children.length;s++)o=e.children[s],o.trashMe&&e.removeChild(o)}function Y(e,t,n){const i={};for(let t=0;t<e.children.length;t++){const n=e.children[t];i[n.subject.toNT()]=n}for(let a=0;a<t.length;a++){const o=t[a];if(a>=e.children.length){const t=n(o);t.subject=o,e.appendChild(t)}else{const t=e.children[a];if(t.subject.sameTerm(o));else{const a=i[o.toNT()];if(a)e.removeChild(a),e.insertBefore(a,t);else{const e=n(o);t.before(e),e.subject=o}}}}for(;e.children.length>t.length;)e.removeChild(e.children[e.children.length-1])}function K(e){let t,n=e+"\n";if(!e.stack)return n+"No stack available.\n";const i=e.stack.toString().split("\n"),a=[];for(t=0;t<i.length;t++){let e=i[t];if(e.indexOf("ecmaunit.js")>-1)break;"("===e.charAt(0)&&(e="function"+e);const n=e.split("@");a.push(n)}for(t=0;t<a.length;t++)n+=" "+a[t][1]+"\n "+a[t][0];return n}function X(e){const t=e.childNodes;for(let n=t.length-1;n>=0;n--)e.removeChild(t[n]);return e}function ee(e){let t;return(e=e||window.event).target?t=e.target:e.srcElement&&(t=e.srcElement),3===t.nodeType&&(t=t.parentNode),t}function te(e,t){let n;for(n=e;n;n=n.parentNode)try{if(n.tagName===t)return n}catch(e){return}}function ne(e,t){let n,i;for(n=t;n&&1===n.nodeType;n=n.parentNode)if(i=n.getAttribute("about"),i)return e.fromNT(i);$.log.debug("getAbout: No about found")}function ie(e){const t=e.parentNode,n=t?t.AJAR_statement:void 0;switch(n?e.className:""){case"pred":case"pred selected":return n.predicate;case"obj":case"obj selected":return t.AJAR_inverse?n.subject:n.object;case"":case"selected":return ne(x.store,e);case"undetermined selected":return e.nextSibling?n.predicate:t.AJAR_inverse?n.subject:n.object}}function ae(e,t){const n=e.createElement("script");return n.setAttribute("type","text/javascript"),n.setAttribute("src",t),n}function oe(e){const t=window.onload;"function"!=typeof window.onload?window.onload=e:window.onload=function(){t(),e()}}function se(e){const t=e.ownerDocument.documentElement.getBoundingClientRect(),n=e.getBoundingClientRect();return[n.left-t.left,n.top-t.top]}function re(e,t,n,i){i||(i=window);const a=se(e)[1],o=window.SolidAppContext||{},s=a-(o&&o.scroll||52)-i.scrollY;if(t)return n?void i.scrollBy(0,a+e.clientHeight-(i.scrollY+i.innerHeight)):void i.scrollBy(0,s);const r=i.setInterval(function(){i.scrollBy(0,s/10),c++,10===c&&i.clearInterval(r)},50);let c=0}function ce(e,t,n,i){i||(i=document);const a=i.createElement("img");return a.setAttribute("src",e),a.addEventListener("copy",function(e){e.clipboardData.setData("text/plain",""),e.clipboardData.setData("text/html",""),e.preventDefault()}),void 0!==n&&a.setAttribute("title",n),a}function le(e){let t=e;"#/".indexOf(t[t.length-1])>=0&&(t=t.slice(0,-1));const n=[];for(const e in this.prefixes)n[this.prefixes[e]]=e;let i;const a=function(e){return"ns"!==e&&(i=e,!0)};let o;const s=t.lastIndexOf("#");for(s>=0&&(t=t.slice(s-1));;){const e=t.lastIndexOf("/");for(e>=0&&(t=t.slice(e+1)),o=0;o<t.length&&this.prefixchars.indexOf(t[o]);)o++;if(t=t.slice(0,o),t.length<6&&a(t))return i;if(a(t.slice(0,3)))return i;if(a(t.slice(0,2)))return i;if(a(t.slice(0,4)))return i;if(a(t.slice(0,1)))return i;if(a(t.slice(0,5)))return i;for(o=0;;o++)if(a(t.slice(0,3)+o))return i}}function pe(e){if(void 0===e.uri)return"??";let t=e.uri;const n=[];let i,a=t.lastIndexOf("#");if(a>=0)t=t.slice(0,a+1);else{if(a=t.lastIndexOf("/"),!(a>=0))return e.uri+"?!";t=t.slice(0,a+1)}for(const e in $.ns)n[$.ns[e]]=e;try{return n[t]}catch(e){}for(t=t.slice(0,-1);t;){if(a=t.lastIndexOf("/"),!(a>=0))return e.uri+"!?";if(i=t.slice(a+1),t=t.slice(0,a),"ns"!==i&&"0123456789".indexOf(i[0])<0)return i}}function ue(e,t){const n=x.store.findTypeURIs(e);return n[$.ns.rdf("Predicate").uri]||n[$.ns.rdfs("Class").uri]?U(e,t)+" ("+pe(e)+")":U(e,t)}function de(e){return e.replace(/&/g,"&").replace(/</g,"<")}function me(e){return de(U(e))}function fe(e,t){return de(he(e,t))}function he(e,t){const n=U(e);if(t){const t=x.store.any(e,$.ns.owl("inverseOf"))||x.store.any(void 0,$.ns.owl("inverseOf"),e);return t?U(t):"type"===n?"...":"is "+n+" of"}return n}function ge(e,t){const n=e.predicate.compareTerm(t.predicate);return 0!==n?n:e.object.compareTerm(t.object)}function be(e,t){const n=e.predicate.compareTerm(t.predicate);return 0!==n?n:e.subject.compareTerm(t.subject)}function xe(e){let t=e;for(;;){if(t.getAttribute("predTR"))return t;if(!t.previousSibling||"TR"!==t.previousSibling.nodeName)return $.log.error("Could not find predParent"),e;t=t.previousSibling}}"undefined"!=typeof AudioContext?q=AudioContext:"undefined"!=typeof window&&(q=window.AudioContext||window.webkitAudioContext);var ve=n(423);const ye=x.solidLogicSingleton.store;function we(e,t,n,i){const a=b.acl,o="/"===e.uri.slice(-1),s=ye.each(void 0,a("default"),n,i).concat(ye.each(void 0,a("defaultForNew"),n,i)).reduce((t,n)=>t.concat(ye.statementsMatching(n,b.rdf("type"),a("Authorization"),i)).concat(ye.statementsMatching(n,a("agent"),void 0,i)).concat(ye.statementsMatching(n,a("agentClass"),void 0,i)).concat(ye.statementsMatching(n,a("agentGroup"),void 0,i)).concat(ye.statementsMatching(n,a("origin"),void 0,i)).concat(ye.statementsMatching(n,a("originClass"),void 0,i)).concat(ye.statementsMatching(n,a("mode"),void 0,i)).concat((0,g.st)(n,a("accessTo"),e,i)).concat(o?(0,g.st)(n,a("default"),e,i):[]),[]),r=(0,g.graph)();return s.forEach(e=>r.add(c(e.subject),c(e.predicate),c(e.object),(0,g.sym)(t.uri))),r;function c(e){const n=i.uri.length;return(0,g.sym)(e.uri.slice(0,n)===i.uri?t.uri+e.uri.slice(n):e.uri)}}function Ce(e,t,n=ye,i=!1){const a=i?function(t,n){return t.each(void 0,n.acl("default"),e).concat(t.each(void 0,n.acl("defaultForNew"),e))}(n,b):n.each(void 0,b.acl("accessTo"),e),o=b.acl,s={agent:{},agentClass:{},agentGroup:{},origin:{},originClass:{}};return Object.keys(s).forEach(e=>{a.forEach(function(t){n.each(t,o("mode")).forEach(function(i){n.each(t,o(e)).forEach(function(n){s[e][n.uri]=s[e][n.uri]||{},s[e][n.uri][i.uri]=t})})})}),s}function Ee(e,t){const n=function(e,t){for(const n in{agent:!0,agentClass:!0,agentGroup:!0,origin:!0,originClass:!0})if(e[n])for(const i in e[n])for(const a in e[n][i])if(!t[n][i]||!t[n][i][a])return!1;return!0};return n(e,t)&&n(t,e)}function ke(e){const t=e[0];let n,i;for(let a=1;a<e.length;a++)["agent","agentClass","agentGroup","origin","originClass"].forEach(function(o){if(n=e[a],n[o])for(i in n[o])for(const e in n[o][i])t[o][i]||(t[o][i]=[]),t[o][i][e]=!0});return t}function Ae(e,t){const n=[],i=function(e){if(e.length){Ie(e.shift().doc(),function(a,o,s,r,c,l){const p=!o;if(!a||!c||!l)return t(a,r);const u=Ce(p?c:s);n.push(u),i(e.slice(1))})}else t(!0,ke(n))};i(e)}function Te(e){const t={};return["agent","agentClass","agentGroup","origin","originClass"].forEach(function(n){for(const i in e[n]){const a=[];for(const t in e[n][i])a.push(t);a.sort();const o=a.join("\n");t[o]||(t[o]=[]),t[o].push([n,i])}}),t}function je(e,t,n,i){return _e(e,t,Te(n),i)}function _e(e,t,n,i,a,o){const s=b.acl;for(const r in n){const c=n[r];if(!c.length)continue;const l=r.split("\n");let p=l.map(function(e){return e.split("#")[1]}).join("");o&&!a&&(p+="Default");const u=e.sym(i.uri+"#"+p);e.add(u,b.rdf("type"),s("Authorization"),i),a&&e.add(u,s("accessTo"),t,i),o&&e.add(u,s("default"),t,i);for(let t=0;t<l.length;t++)e.add(u,s("mode"),e.sym(l[t]),i);for(let t=0;t<c.length;t++){const n=c[t][0],a=c[t][1];e.add(u,s(n),e.sym(a),i)}}}function Le(e){let t="";for(const n in e){t+=n.split("\n").map(function(e){return e.split("#")[1][0]}).join("")+":";const i=e[n];for(let e=0;e<i.length;e++){const n=i[e][0],a=(0,g.sym)(i[e][1]);t+="agent"===n?"@":"",t+=a.sameTerm(b.foaf("Agent"))?"*":U(a),e<i.length-1&&(t+=",")}t+=";"}return"{"+t.slice(0,-1)+"}"}function Se(e,t,n,i,a){return Re(e,t,Te(n),i,a)}function Re(e,t,n,i,a){const o=(0,g.graph)();_e(o,t,n,i,!0),e.updater?.put(i,o.statementsMatching(void 0,void 0,void 0,i),"text/turtle",function(o,s,r){s?(e.fetcher?.unload(i),_e(e,t,n,i,!0),e.fetcher.requested[i.uri]="done",a(s)):a(s,r)})}function Ne(e,t,n,i){n=n||ve.Rm;const a=e.doc();Ie(a,function(o,s,r,c,l,p){if(!o||!l||!p)return i(!1,c);const u=Ce(s?r:l);Ae(t,function(t,o){if(!t)return i(!1,o);Ee(o,u)?n("Nice - same ACL. no change "+U(e)+" "+a):(n("Group ACLs differ for "+U(e)+" "+a),Se(ye,r,o,c,i))})})}function Ie(e,t){Be(e,function(n,i,a,o){const s=b.acl;if(!n)return t(!1,!1,i,o);const r=function(n){"/"===n.slice(-1)&&(n=n.slice(0,-1));const i=n.lastIndexOf("/");if(n.indexOf("/",n.indexOf("//")+2)>i)return t(!1,!0,404,"Found no ACL resource");n=n.slice(0,i+1);const o=(0,g.sym)(n);Be(o,function(i,c,l){if(!i)return t(!1,!0,c,`( No ACL pointer ${n} ${c})${l}`);if(403===c)return t(!1,!0,c,`( default ACL file FORBIDDEN. Stop.${n})`);if(404===c)return r(n);if(200!==c)return t(!1,!0,c,`Error status '${c}' searching for default for ${o}`);if(!ye.each(void 0,s("default"),ye.sym(n),l).concat(ye.each(void 0,s("defaultForNew"),ye.sym(n),l)).length)return r(n);const p=ye.sym(n);return t(!0,!1,e,a,p,l)})};return n?404!==i?403===i?t(!1,!1,i,`(Sharing not available to you)${o}`):200!==i?t(!1,!1,i,`Error ${i} accessing Access Control information for ${e}: ${o}`):t(!0,!0,e,a):void r(e.uri):t(!1,!1,i,`Error accessing Access Control information for ${e}) ${o}`)})}function Be(e,t){if(!ye.fetcher)throw new Error("kb has no fetcher");ye.fetcher.nowOrWhenFetched(e,void 0,function(n,i){if(!n)return t(n,`Can't get headers to find ACL for ${e}: ${i}`);const a=ye.any(e,x.ACL_LINK);if(a){if(!ye.fetcher)throw new Error("kb has no fetcher");if(ye.fetcher.nonexistent[a.value])return t(!0,404,a,`ACL file ${a} does not exist.`);ye.fetcher.nowOrWhenFetched(a,void 0,function(e,n,i){e?t(!0,200,a):t(!0,i.status,a,`Can't read Access Control File ${a}: ${n}`)})}else t(!1,900,`No Link rel=ACL header for ${e}`)})}async function De(e){return new Promise((t,n)=>Ie((0,g.sym)(e),(i,a,o,s,r)=>i?t(a?o:r):n(new Error(`Error loading ${e}`))))}var Oe=n(580),Me=n.n(Oe);const Fe=new Uint8Array(16);const ze=[];for(let e=0;e<256;++e)ze.push((e+256).toString(16).slice(1));function Ue(e,t=0){return(ze[e[t+0]]+ze[e[t+1]]+ze[e[t+2]]+ze[e[t+3]]+"-"+ze[e[t+4]]+ze[e[t+5]]+"-"+ze[e[t+6]]+ze[e[t+7]]+"-"+ze[e[t+8]]+ze[e[t+9]]+"-"+ze[e[t+10]]+ze[e[t+11]]+ze[e[t+12]]+ze[e[t+13]]+ze[e[t+14]]+ze[e[t+15]]).toLowerCase()}const Pe=function(e,t,n){return t||e||!crypto.randomUUID?function(e,t,n){e=e||{};const i=e.random??e.rng?.()??crypto.getRandomValues(Fe);if(i.length<16)throw new Error("Random bytes length must be >= 16");if(i[6]=15&i[6]|64,i[8]=63&i[8]|128,t){if((n=n||0)<0||n+16>t.length)throw new RangeError(`UUID byte range ${n}:${n+15} is out of buffer bounds`);for(let e=0;e<16;++e)t[n+e]=i[e];return t}return Ue(i)}(e,t,n):crypto.randomUUID()};var $e=n(49);const qe="#888888",He="8em",Ge=20,Ve="#fff",We="#000",Je="#888",Qe="#fee",Ze="white",Ye="4096",Ke={checkboxStyle:"color: black; font-size: 100%; padding-left: 0.5 em; padding-right: 0.5 em;",checkboxInputStyle:"font-size: 150%; height: 1.2em; width: 1.2em; background-color: #eef; border-radius:0.2em; margin: 0.1em;",fieldLabelStyle:"color: #3B5998; text-decoration: none;",formSelectStyle:"background-color: #eef; padding: 0.5em; border: .05em solid #88c; border-radius:0.2em; font-size: 100%; margin:0.4em;",textInputStyle:"background-color: #eef; padding: 0.5em; border: .05em solid #88c; border-radius:0.2em; font-size: 100%; margin:0.4em;",textInputStyleUneditable:"background-color: white; padding: 0.5em; border: .05em solid white; border-radius:0.2em; font-size: 100%; margin:0.4em;",buttonStyle:"background-color: #fff; padding: 0.7em; border: .01em solid white; border-radius:0.2em; font-size: 100%; margin: 0.3em;",commentStyle:"padding: 0.7em; border: none; font-size: 100%; white-space: pre-wrap;",iconStyle:"width: 3em; height: 3em; margin: 0.1em; border-radius: 1em;",smallButtonStyle:"margin: 0.2em; width: 1em; height:1em;",classIconStyle:"width: 3em; height: 3em; margin: 0.1em; border-radius: 0.2em; border: 0.1em solid green; padding: 0.2em; background-color: #efe;",confirmPopupStyle:"padding: 0.7em; border-radius: 0.2em; border: 0.1em solid orange; background-color: white; box-shadow: 0.5em 0.9em #888;",messageBodyStyle:"white-space: pre-wrap; width: 99%; font-size:100%; border: 0.07em solid #eee; border-radius:0.2em; padding: .3em 0.5em; margin: 0.1em;",pendingeditModifier:"color: #bbb;",personaBarStyle:"width: 100%; height: 4em; background-color: #eee; vertical-align: middle;",searchInputStyle:"border: 0.1em solid #444; border-radius: 0.2em; width: 100%; font-size: 100%; padding: 0.1em 0.6em; margin 0.2em;",autocompleteRowStyle:"border: 0.2em solid straw;",signInAndUpButtonStyle:"padding: 1em; border-radius:0.2em; font-size: 100%;",headerBannerLoginInput:"margin: 0.75em 0 0.75em 0.5em !important; padding: 0.5em !important;",signUpBackground:"background-color: #eef;",signInBackground:"background-color: #efe;",heading1Style:"font-size: 180%; font-weight: bold; color: #888888; padding: 0.5em; margin: 0.7em 0.0m;",heading2Style:"font-size: 130%; font-weight: bold; color: #888888; padding: 0.4em; margin: 0.7em 0.0em;",heading3Style:"font-size: 120%; font-weight: bold; color: #888888; padding: 0.3em; margin: 0.7em 0.0em;",heading4Style:"font-size: 110%; font-weight: bold; color: #888888; padding: 0.2em; margin: 0.7em 0.0em;",formHeadingStyle:"font-size: 110%; font-weight: bold; color: #888888; padding: 0.2em; margin: 0.7em 0.0em;",formTextInput:"font-size: 100%; margin: 0.1em; padding: 0.1em;",formGroupStyle:[`padding-left: 0em; border: 0.0em solid ${qe}; border-radius: 0.2em;`,`padding-left: 2em; border: 0.05em solid ${qe}; border-radius: 0.2em;`,`padding-left: 2em; border: 0.1em solid ${qe}; border-radius: 0.2em;`,`padding-left: 2em; border: 0.2em solid ${qe}; border-radius: 0.2em;`],formFieldLabelStyle:`color: ${"#3B5998"}; text-decoration: none;`,formFieldNameBoxStyle:`padding: 0.3em; vertical-align: middle; width:${He};`,multilineTextInputStyle:"font-size:100%; white-space: pre-wrap; background-color: #eef; border: 0.07em solid gray; padding: 1em 0.5em; margin: 1em 1em;",renderAsDivStyle:"display: flex; align-items: center; justify-content: space-between; height: 2.5em; padding: 1em;",imageDivStyle:"width:2.5em; padding:0.5em; height: 2.5em;",linkDivStyle:"width:2em; padding:0.5em; height: 4em;",aclControlBoxContainer:"margin: 1em;",aclControlBoxHeader:"font-size: 120%; margin: 0 0 1rem;",aclControlBoxStatus:"display: none; margin: 1rem 0;",aclControlBoxStatusRevealed:"display: block;",aclGroupContent:"maxWidth: 650;",accessGroupList:"display: grid; grid-template-columns: 1fr; margin: 1em; width: 100%;",accessGroupListItem:"display: grid; grid-template-columns: 100px auto 30%;",defaultsController:"display: flex;",defaultsControllerNotice:"color: #888; flexGrow: 1; fontSize: 80%;",bigButton:"background-color: white; border: 0.1em solid #888; border-radius: 0.3em; max-width: 50%; padding-bottom: 1em; padding-top: 1em;",group:"color: #888;",group1:"color: green;",group2:"color: #cc0;",group3:"color: orange;",group5:"color: red;",group9:"color: blue;",group13:"color: purple;",trustedAppAddApplicationsTable:"background-color: #eee;",trustedAppCancelButton:"float: right;",trustedAppControllerI:"border-color: orange; border-radius: 1em; border-width: 0.1em;",temporaryStatusInit:"background: green;",temporaryStatusEnd:"background: transparent; transition: background 5s linear;",headerUserMenuLink:"background: none; border: 0; color: black; cursor: pointer; display: block; font-family: Arial; font-size: 1em; text-align: left; padding: 1em; width: 100%; text-decoration: none;",headerUserMenuLinkHover:"background: none; border: 0; color: black; cursor: pointer; display: block; font-family: Arial; font-size: 1em; text-align: left; padding: 1em; width: 100%; text-decoration: none; background-image: linear-gradient(to right, #7C4DFF 0%, #18A9E6 50%, #01C9EA 100%);",headerUserMenuTrigger:"background: none; border: 0; cursor: pointer; width: 60px; height: 60px;",headerUserMenuTriggerImg:"border-radius: 50%; height: 56px; width: 28px !important;",headerUserMenuButton:"background: none; border: 0; color: black; cursor: pointer; display: block; font-family: Arial; font-size: 1em; text-align: left; padding: 1em; width: 100%;",headerUserMenuButtonHover:"background: none; border: 0; color: black; cursor: pointer; display: block; font-family: Arial; font-size: 1em; text-align: left; padding: 1em; width: 100%; background-image: linear-gradient(to right, #7C4DFF 0%, #18A9E6 50%, #01C9EA 100%);",headerUserMenuList:"list-style: none; margin: 0; padding: 0;",headerUserMenuListDisplay:"list-style: none; margin: 0; padding: 0; display:true;",headerUserMenuNavigationMenu:"background: white; border: solid 1px #000000; border-right: 0; position: absolute; right: 0; top: 60px; width: 200px; z-index: 1; display: true;",headerUserMenuNavigationMenuNotDisplayed:"background: white; border: solid 1px #000000; border-right: 0; position: absolute; right: 0; top: 60px; width: 200px; z-index: 1; display: none;",headerUserMenuListItem:"border-bottom: solid 1px #000000;",headerUserMenuPhoto:"border-radius: 50%; background-position: center; background-repeat: no-repeat; background-size: cover; height: 50px; width: 50px;",headerBanner:"box-shadow: 0px 1px 4px #000000; display: flex; justify-content: space-between; padding: 0 1.5em; margin-bottom: 4px;",headerBannerLink:"display: block;",headerBannerRightMenu:"display: flex;",headerBannerLogin:"margin-left: auto;",allChildrenVisible:"display:true;",headerBannerUserMenu:"border-left: solid 1px #000000; margin-left: auto;",headerBannerHelpMenu:"border-left: solid 1px #000000; margin-left: auto;",headerBannerIcon:"background-size: 65px 60px !important; height: 60px !important; width: 65px !important;",footer:"border-top: solid 1px $divider-color; font-size: 0.9em; padding: 0.5em 1.5em;",primaryButton:"background-color: #7c4dff; color: #ffffff; font-family: Raleway, Roboto, sans-serif; border-radius: 0.25em; border-color: #7c4dff; border: 1px solid; cursor: pointer; font-size: .8em; text-decoration: none; padding: 0.5em 4em; transition: 0.25s all ease-in-out; outline: none;",primaryButtonHover:"background-color: #9f7dff; color: #ffffff; font-family: Raleway, Roboto, sans-serif;border-radius: 0.25em; border-color: #7c4dff; border: 1px solid; cursor: pointer; font-size: .8em; text-decoration: none; padding: 0.5em 4em; transition: 0.25s all ease-in-out; outline: none; transition: 0.25s all ease-in-out;",primaryButtonNoBorder:"background-color: #ffffff; color: #7c4dff; font-family: Raleway, Roboto, sans-serif;border-radius: 0.25em; border-color: #7c4dff; border: 1px solid; cursor: pointer; font-size: .8em; text-decoration: none; padding: 0.5em 4em; transition: 0.25s all ease-in-out; outline: none;",primaryButtonNoBorderHover:"background-color: #7c4dff; color: #ffffff; font-family: Raleway, Roboto, sans-serif; border-radius: 0.25em; border-color: #7c4dff; border: 1px solid; cursor: pointer; font-size: .8em; text-decoration: none; padding: 0.5em 4em; transition: 0.25s all ease-in-out; outline: none; transition: 0.25s all ease-in-out;",secondaryButton:"background-color: #01c9ea; color: #ffffff; font-family: Raleway, Roboto, sans-serif;border-radius: 0.25em; border-color: #01c9ea; border: 1px solid; cursor: pointer; font-size: .8em; text-decoration: none; padding: 0.5em 4em; transition: 0.25s all ease-in-out; outline: none;",secondaryButtonHover:"background-color: #37cde6; color: #ffffff; font-family: Raleway, Roboto, sans-serif;border-radius: 0.25em; border-color: #7c4dff; border: 1px solid; cursor: pointer; font-size: .8em; text-decoration: none; padding: 0.5em 4em; transition: 0.25s all ease-in-out; outline: none; transition: 0.25s all ease-in-out;",secondaryButtonNoBorder:"background-color: #ffffff; color: #01c9ea; font-family: Raleway, Roboto, sans-serif; border-radius: 0.25em; border-color: #01c9ea; border: 1px solid; cursor: pointer; font-size: .8em; text-decoration: none; padding: 0.5em 4em; transition: 0.25s all ease-in-out; outline: none;",secondaryButtonNoBorderHover:"background-color: #01c9ea; color: #ffffff; font-family: Raleway, Roboto, sans-serif; border-radius: 0.25em; border-color: #01c9ea; border: 1px solid; cursor: pointer; font-size: .8em; text-decoration: none; padding: 0.5em 4em; transition: 0.25s all ease-in-out; outline: none; transition: 0.25s all ease-in-out;",controlStyle:`border-radius: 0.5em; margin: 0.8em; width:${"640"}; height:${"480"};`,dragEvent:"background-color: #ccc; border: 0.25em dashed black; border-radius: 0.3em;",dropEvent:"background-color: white; border: 0em solid black;",restoreStyle:"background-color: white;",errorCancelButton:"width: 2em; height: 2em; align: right;",errorMessageBlockStyle:"margin: 0.1em; padding: 0.5em; border: 0.05em solid gray; color:black;",notepadStyle:"padding: 1em; overflow: auto; resize: horizontal; min-width: 40em;",upstreamStatus:"width: 50%;",downstreamStatus:"width: 50%;",baseStyle:"font-size: 100%; font-family: monospace; width: 100%; border: none; white-space: pre-wrap;",headingCore:"font-family: sans-serif; font-weight: bold; border: none;",headingStyle:["font-size: 110%; padding-top: 0.5em; padding-bottom: 0.5em; width: 100%;","font-size: 120%; padding-top: 1em; padding-bottom: 1em; width: 100%;","font-size: 150%; padding-top: 1em; padding-bottom: 1em; width: 100%;"],participantsStyle:"margin: 0.8em;",participantsBlock:"height: 1.5em; width: 1.5em; margin: 0.3em; border 0.01em solid #888;",personTableTD:"vertical-align: middle;",tabsNavElement:"margin: 0;",tabsRootElement:"display: flex; height: 100%; width: 100%;",tabsMainElement:"margin: 0; width:100%; height: 100%;",tabContainer:"list-style-type: none; display: flex; height: 100%; width: 100%; margin: 0; padding: 0;",makeNewSlot:"background: none; border: none; font: inherit; cursor: pointer;",ellipsis:"position: absolute; right: 0; bottom: 0; width: 20%; background: none; color: inherit; border: none; padding: 0; font: inherit; cursor: pointer; outline: inherit;"};function Xe(e,t,n){const i=function(e){return e.split("\n").map(e=>e.trim()).filter(e=>e&&"#"!==e[0])},a=function(e){e.preventDefault(),e.stopPropagation(),e.dataTransfer.dropEffect="copy"},o=function(e){e.preventDefault(),e.stopPropagation(),ve.Rm("dragenter event dropEffect: "+e.dataTransfer.dropEffect),this.localStyle&&(this.savedStyle||(this.savedStyle=Ke.dragEvent)),e.dataTransfer.dropEffect="link",ve.Rm("dragenter event dropEffect 2: "+e.dataTransfer.dropEffect)},s=function(e){e.stopPropagation(),ve.Rm("dragleave event dropEffect: "+e.dataTransfer.dropEffect),this.savedStyle?this.localStyle=this.savedStyle:this.localStyle=Ke.dropEvent},r=function(e){e.preventDefault&&e.preventDefault(),e.stopPropagation&&e.stopPropagation(),ve.Rm("Drop event. dropEffect: "+e.dataTransfer.dropEffect),ve.Rm("Drop event. types: "+(e.dataTransfer.types?e.dataTransfer.types.join(", "):"NOPE"));let a,o=null;if(e.dataTransfer.types){for(let t=0;t<e.dataTransfer.types.length;t++){const s=e.dataTransfer.types[t];if("text/uri-list"===s)o=i(e.dataTransfer.getData(s)),ve.Rm("Dropped text/uri-list: "+o);else if("text/plain"===s)a=e.dataTransfer.getData(s);else if("Files"===s&&n){const t=e.dataTransfer.files;for(let e=0;t[e];e++){const n=t[e];ve.Rm("Filename: "+n.name+", type: "+(n.type||"n/a")+" size: "+n.size+" bytes, last modified: "+(n.lastModifiedDate?n.lastModifiedDate.toLocaleDateString():"n/a"))}n(t)}}const t=a?a.trim():"";null===o&&t&&"http"===t.slice(0,4)&&(o=[t],ve.Rm("Warning: Poor man's drop: using text for URI"))}else o=i(e.dataTransfer.getData("Text")),ve.Rm("WARNING non-standard drop event: "+o[0]);return ve.Rm("Dropped URI list (2): "+o),o&&t(o),this.localStyle=Ke.restoreStyle,!1};!function(e){e||ve.Rm("@@@ addTargetListeners: ele "+e),e.addEventListener("dragover",a),e.addEventListener("dragenter",o),e.addEventListener("dragleave",s),e.addEventListener("drop",r)}(e)}function et(e,t){e.setAttribute("draggable","true"),e.addEventListener("dragstart",function(n){e.style.fontWeight="bold",n.dataTransfer.setData("text/uri-list",t.uri),n.dataTransfer.setData("text/plain",t.uri),n.dataTransfer.setData("text/html",e.outerHTML),ve.Rm("Dragstart: "+e+" -> "+t+"de: "+n.dataTransfer.dropEffect)},!1),e.addEventListener("drag",function(e){e.preventDefault(),e.stopPropagation()},!1),e.addEventListener("dragend",function(n){e.style.fontWeight="normal",ve.Rm("Dragend dropeffect: "+n.dataTransfer.dropEffect),ve.Rm("Dragend: "+e+" -> "+t)},!1)}function tt(e,t,n,i,a){for(let o=0;t[o];o++){const s=t[o];ve.Rm(" dropped: Filename: "+s.name+", type: "+(s.type||"n/a")+" size: "+s.size+" bytes, last modified: "+(s.lastModifiedDate?s.lastModifiedDate.toLocaleDateString():"n/a"));const r=new FileReader;r.onload=function(t){return function(o){const s=o.target.result;let r="";ve.Rm(" File read byteLength : "+s.byteLength);let c=t.type;if(t.type&&""!==t.type){const e=$e.extension(t.type);e&&"false"!==e&&!t.name.endsWith("."+e)&&t.type!==$e.lookup(t.name)&&(r="_."+e)}else if(c=$e.lookup(t.name),!c){const e="Filename needs to have an extension which gives a type we know: "+t.name;throw ve.Rm(e),alert(e),new Error(e)}const l=t.type.startsWith("image/")&&i||n,p=l+(l.endsWith("/")?"":"/")+encodeURIComponent(t.name)+r;e.webOperation("PUT",p,{data:s,contentType:c}).then(e=>{ve.Rm(" Upload: put OK: "+p),a(t,p)},e=>{const t=" Upload: FAIL "+p+", Error: "+e;throw ve.Rm(t),alert(t),new Error(t)})}}(s),r.readAsArrayBuffer(s)}}function nt(e,t,n,i){const a=e.createElement("div"),o=i||t instanceof Error?t:null;return o?(console.error(`errorMessageBlock: ${o} at: ${o.stack||"??"}`,o),a.textContent=o.message):a.textContent=t,a.appendChild(Mt(e,()=>{a.parentNode&&a.parentNode.removeChild(a)})).style=Ke.errorCancelButton,a.setAttribute("style",Ke.errorMessageBlockStyle),a.style.backgroundColor=n||Qe,a}Ke.setStyle=function(e,t){e.style=Ke[t]};var it=n(378);const at=x.solidLogicSingleton.store;class ot{constructor(e,t,n,i){this.options=i||{},this.element=e,this.typeIndex=t,this.groupPickedCb=n,this.selectedgroup=this.options.selectedgroup,this.onSelectGroup=this.onSelectGroup.bind(this)}render(){const e=document.createElement("div");if(e.style.maxWidth="350px",e.style.minHeight="200px",e.style.outline="1px solid black",e.style.display="flex",this.selectedgroup){e.style.flexDirection="column";const t=document.createElement("div");new rt(t,this.selectedgroup).render();const n=document.createElement("button");n.textContent=Me()("Change group"),n.addEventListener("click",e=>{this.selectedgroup=null,this.render()}),e.appendChild(t),e.appendChild(n)}else this.findAddressBook(this.typeIndex).then(({book:t})=>{const n=document.createElement("button");n.textContent=Me()("Pick an existing group"),n.style.margin="auto",n.addEventListener("click",n=>{new st(e,t,this.onSelectGroup).render()});const i=document.createElement("button");i.textContent=Me()("Create a new group"),i.style.margin="auto",i.addEventListener("click",e=>{this.createNewGroup(t,this.options.defaultNewGroupName).then(({group:e})=>{new ct(this.element,t,e,this.onSelectGroup).render()}).catch(e=>{this.element.appendChild(nt(document,Me()(`Error creating a new group. (${e})`)))})}),e.appendChild(n),e.appendChild(i),this.element.innerHTML="",this.element.appendChild(e)}).catch(e=>{this.element.appendChild(nt(document,Me()(`Could find your groups. (${e})`)))});return this.element.innerHTML="",this.element.appendChild(e),this}findAddressBook(e){return new Promise((t,n)=>{at.fetcher.nowOrWhenFetched(e,(i,a)=>{if(!i)return n(a);const o=at.any(null,b.solid("forClass"),b.vcard("AddressBook"));if(!o)return n(new Error("no address book registered in the solid type index "+e));const s=at.any(o,b.solid("instance"));if(!s)return n(new Error("incomplete address book registration"));at.fetcher.load(s).then(function(e){return t({book:s})}).catch(function(e){return n(new Error("Could not load address book "+e))})})})}createNewGroup(e,t){const{groupIndex:n,groupContainer:i}=dt(e),a=g.sym(`${i.uri}${Pe().slice(0,8)}.ttl#this`),o=t||"Untitled Group",s=[a.doc(),n].map(t=>{const i=g.st(a,b.rdf("type"),b.vcard("Group"),t),s=g.st(a,b.vcard("fn"),o,a.doc(),t),r=g.st(e,b.vcard("includesGroup"),a,t),c=t.equals(n)?[i,s,r]:[i,s];return ut(t.uri,{toIns:c}).then(()=>{c.forEach(e=>{at.add(e)})})});return Promise.all(s).then(()=>({group:a})).catch(e=>{throw ve.Rm("Could not create new group. PATCH failed "+e),new Error(`Couldn't create new group. PATCH failed for (${e.xhr?e.xhr.responseURL:""} )`)})}onSelectGroup(e){this.selectedgroup=e,this.groupPickedCb(e),this.render()}}class st{constructor(e,t,n){this.element=e,this.book=t,this.onSelectGroup=n}render(){return this.loadGroups().then(e=>{const t=document.createElement("div");t.style.display="flex",t.style.flexDirection="column",e.forEach(e=>{const n=document.createElement("button");n.addEventListener("click",this.handleClickGroup(e)),new rt(n,e).render(),t.appendChild(n)}),this.element.innerHTML="",this.element.appendChild(t)}).catch(e=>{this.element.appendChild(nt(document,Me()(`There was an error loading your groups. (${e})`)))}),this}loadGroups(){return new Promise((e,t)=>{const{groupIndex:n}=dt(this.book);at.fetcher.nowOrWhenFetched(n,(n,i)=>{if(!n)return t(i);const a=at.each(this.book,b.vcard("includesGroup"));return e(a)})})}handleClickGroup(e){return t=>{this.onSelectGroup(e)}}}class rt{constructor(e,t){this.element=e,this.group=t}render(){const e=document.createElement("div");return e.textContent=Me()(pt(this.group,b.vcard("fn"),`[${this.group.value}]`)),this.element.innerHTML="",this.element.appendChild(e),this}}class ct{constructor(e,t,n,i,a){this.element=e,this.book=t,this.group=n,this.onGroupChanged=(e,t,n)=>{a&&a(e,t,n)},this.groupChangedCb=a,this.doneBuildingCb=i}refresh(){}render(){const e=document.createElement("div");e.style.maxWidth="350px",e.style.minHeight="200px",e.style.outline="1px solid black",e.style.display="flex",e.style.flexDirection="column",Xe(e,e=>{e.forEach(e=>{this.add(e).catch(e=>{this.element.appendChild(nt(document,Me()(`Could not add the given WebId. (${e})`)))})})});const t=document.createElement("input");t.type="text",t.value=pt(this.group,b.vcard("fn"),"Untitled Group"),t.addEventListener("change",e=>{this.setGroupName(e.target.value).catch(e=>{this.element.appendChild(nt(document,`Error changing group name. (${e})`))})});const n=document.createElement("label");if(n.textContent=Me()("Group Name:"),n.appendChild(t),e.appendChild(n),at.any(this.group,b.vcard("hasMember")))at.match(this.group,b.vcard("hasMember")).forEach(t=>{const n=t.object,i=document.createElement("div");new lt(i,n,this.handleRemove(n)).render(),e.appendChild(i)});else{const t=document.createElement("p");t.textContent=Me()`
|
|
2
2
|
To add someone to this group, drag and drop their WebID URL onto the box.
|
|
3
|
-
`,e.appendChild(t)}const i=document.createElement("button");return i.textContent=Me()("Done"),i.addEventListener("click",e=>{this.doneBuildingCb(this.group)}),e.appendChild(i),this.element.innerHTML="",this.element.appendChild(e),this}add(e){return new Promise((t,n)=>{at.fetcher.nowOrWhenFetched(e,(i,a)=>{if(!i)return this.onGroupChanged(a),n(a);const o=g.namedNode(e),s=at.any(o,b.rdf("type"));return s&&s.equals(b.foaf("Person"))?t(o):n(new Error(`Only people supported right now. (tried to add something of type ${s.value})`))})}).then(e=>{const t=g.st(this.group,b.vcard("hasMember"),e);return at.holdsStatement(t)?e:ut(this.group.doc().uri,{toIns:[t]}).then(()=>{t.why=this.group.doc(),at.add(t),this.onGroupChanged(null,"added",e),this.render()})})}handleRemove(e){return t=>{const n=g.st(this.group,b.vcard("hasMember"),e);return ut(this.group.doc().uri,{toDel:[n]}).then(()=>(at.remove(n),this.onGroupChanged(null,"removed",e),this.render(),!0)).catch(t=>{const n=at.any(e,b.foaf("name")),i=n&&n.value?`Could not remove ${n.value}. (${t})`:`Could not remove ${e.value}. (${t})`;throw new Error(i)})}}setGroupName(e){const{groupIndex:t}=dt(this.book),n=[this.group.doc(),t].map(t=>{const n=at.match(this.group,b.vcard("fn"),null,t),i=g.st(this.group,b.vcard("fn"),g.literal(e));return ut(t.value,{toDel:n,toIns:[i]}).then(e=>{at.removeStatements(n),i.why=t,at.add(i)})});return Promise.all(n)}}class lt{constructor(e,t,n){this.webIdNode=t,this.element=e,this.handleRemove=n}render(){const e=document.createElement("div");e.style.display="flex";const t=pt(this.webIdNode,b.foaf("img"),it.LN+"noun_15059.svg"),n=document.createElement("img");n.src=Me()(t),n.width="50",n.height="50",n.style.margin="5px";const i=pt(this.webIdNode,b.foaf("name"),`[${this.webIdNode}]`),a=document.createElement("span");a.innerHTML=Me()(i),a.style.flexGrow="1",a.style.margin="auto 0";const o=document.createElement("button");return o.textContent="Remove",o.addEventListener("click",e=>this.handleRemove().catch(e=>{this.element.appendChild(nt(document,Me()(`${e}`)))})),o.style.margin="5px",e.appendChild(n),e.appendChild(a),e.appendChild(o),this.element.innerHTML="",this.element.appendChild(e),this}}function pt(e,t,n){const i=at.any(e,t);return i?i.value:n}function ut(e,{toDel:t,toIns:n}){return new Promise((e,i)=>{at.updater.update(t,n,(t,n,a)=>{if(!n)return i(new Error(`PATCH failed for resource <${t}>: ${a}`));e()})})}function dt(e){return{groupIndex:at.any(e,b.vcard("groupIndex")),groupContainer:at.sym(e.dir().uri+"Group/")}}const mt="data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMjAiIGhlaWdodD0iMjAiIHZpZXdCb3g9IjAgMCAyMCAyMCIgZmlsbD0ibm9uZSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4KPHBhdGggZD0iTTEzLjAxNTcgOS4yNzM2M0MxNC4yOTU0IDguMzQwMzEgMTUuMTI4OCA2LjgyOTg0IDE1LjEyODggNS4xMjgyQzE1LjEyODggMi4zMDA1MSAxMi44MjgzIDAgMTAuMDAwNiAwQzcuMTcyODkgMCA0Ljg3MjM4IDIuMzAwNTEgNC44NzIzOCA1LjEyODJDNC44NzIzOCA2LjgyOTg0IDUuNzA1NyA4LjM0MDMxIDYuOTg1NDcgOS4yNzM2M0MzLjgwNDIyIDEwLjQ5MSAxLjUzOTA2IDEzLjU3NTQgMS41MzkwNiAxNy4xNzk1QzEuNTM5MDYgMTguNzM0NyAyLjgwNDM0IDIwIDQuMzU5NTcgMjBIMTUuNjQxNkMxNy4xOTY4IDIwIDE4LjQ2MjEgMTguNzM0NyAxOC40NjIxIDE3LjE3OTVDMTguNDYyMSAxMy41NzU0IDE2LjE5NyAxMC40OTEgMTMuMDE1NyA5LjI3MzYzWk02LjQxMDg2IDUuMTI4MkM2LjQxMDg2IDMuMTQ4ODMgOC4wMjEyMSAxLjUzODQ4IDEwLjAwMDYgMS41Mzg0OEMxMS45OCAxLjUzODQ4IDEzLjU5MDMgMy4xNDg4MyAxMy41OTAzIDUuMTI4MkMxMy41OTAzIDcuMTA3NTggMTEuOTggOC43MTc5NyAxMC4wMDA2IDguNzE3OTdDOC4wMjEyMSA4LjcxNzk3IDYuNDEwODYgNy4xMDc1OCA2LjQxMDg2IDUuMTI4MlpNMTUuNjQxNiAxOC40NjE1SDQuMzU5NTdDMy42NTI2NiAxOC40NjE1IDMuMDc3NTQgMTcuODg2NCAzLjA3NzU0IDE3LjE3OTVDMy4wNzc1NCAxMy4zNjIgNi4xODMxNiAxMC4yNTY0IDEwLjAwMDYgMTAuMjU2NEMxMy44MTgxIDEwLjI1NjQgMTYuOTIzNyAxMy4zNjIgMTYuOTIzNyAxNy4xNzk1QzE2LjkyMzcgMTcuODg2NCAxNi4zNDg2IDE4LjQ2MTUgMTUuNjQxNiAxOC40NjE1WiIgZmlsbD0iIzMxNDE1OCIvPgo8L3N2Zz4K";function ft(e,t,n){const i=e.createElement("a");i.setAttribute("href",t.uri),t.uri.startsWith("http")&&i.setAttribute("target","_blank");const a=i.appendChild(e.createElement("img"));return a.setAttribute("src",n||it.i1+"go-to-this.png"),a.setAttribute("style","margin: 0.3em;"),i}const ht=(e,t,n)=>{const i=ft(e,n);t.appendChild(i).classList.add("HoverControlHide"),t.appendChild(e.createElement("br"))},{iconBase:gt}=it.Pt,bt=gt+"noun_1180156.svg",xt=gt+"noun_1180158.svg";function vt(e,t){if(!t)return;const n=function(e){let t=e&&e.statusArea||e&&e.div||null;if(t)return t;let n=e&&e.dom;if(n||"undefined"==typeof document||(n=document),n){const i=n.getElementsByTagName("body")[0];return t=n.createElement("div"),i.insertBefore(t,i.firstElementChild),e&&(e.statusArea=t),t}return null}(e);ve.Rm("Complaint: "+t),n?n.appendChild(nt(e&&e.dom||document,t)):alert(t)}function yt(e){for(;e.firstChild;)e.removeChild(e.firstChild);return e}function wt(e){const t=e.search(/logFile=/),n=e.search(/&rulesFile=/);return e.substring(t+8,n)}function Ct(e,t){if(!e)return"???";const n=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];try{const i=(new Date).toISOString();return e.slice(0,10)!==i.slice(0,10)||t?e.slice(0,4)===i.slice(0,4)?n[parseInt(e.slice(5,7),10)-1]+" "+parseInt(e.slice(8,10),10):e.slice(0,10):e.slice(11,16)}catch(e){return"shortdate:"+e}}function Et(e,t){return t.split("{").map(function(t){const n=t.split("}")[0];return t?("000"+(e["get"+n]()+({Month:1}[n]||0))).slice(-({Milliseconds:3,FullYear:4}[n]||2))+t.split("}")[1]:""}).join("")}function kt(){return Et(new Date,"{FullYear}-{Month}-{Date}T{Hours}:{Minutes}:{Seconds}.{Milliseconds}")}function At(){return Et(new Date,"{Hours}:{Minutes}:{Seconds}.{Milliseconds}")}function Tt(e,t){const n=x.store,i=function(e){const t=n.any(e,b.vcard("fn"))||n.any(e,b.foaf("name"))||n.any(e,b.vcard("organization-name"));return t?t.value:null},a=t.sameTerm(b.foaf("Agent"))?"Everyone":i(t);if(e.textContent=a||z(t),!a&&t.uri){if(!n.fetcher)throw new Error("kb has no fetcher");n.fetcher.nowOrWhenFetched(t.doc(),void 0,function(n){e.textContent=i(t)||z(t)})}}function jt(e,t){return t.each(e,b.sioc("avatar")).concat(t.each(e,b.foaf("img"))).concat(t.each(e,b.vcard("logo"))).concat(t.each(e,b.vcard("hasPhoto"))).concat(t.each(e,b.vcard("photo"))).concat(t.each(e,b.foaf("depiction")))}const _t={"solid:AppProviderClass":"noun_144.svg","solid:AppProvider":"noun_15177.svg","solid:Pod":"noun_Cabinet_1434380.svg","vcard:Group":"noun_339237.svg","vcard:Organization":"noun_143899.svg","vcard:Individual":mt,"schema:Person":mt,"foaf:Person":mt,"foaf:Agent":"noun_98053.svg","acl:AuthenticatedAgent":"noun_99101.svg","prov:SoftwareAgent":"noun_Robot_849764.svg","vcard:AddressBook":"noun_15695.svg","trip:Trip":"noun_581629.svg","meeting:LongChat":"noun_1689339.svg","meeting:Meeting":"noun_66617.svg","meeting:Project":"noun_1036577.svg","ui:Form":"noun_122196.svg","rdfs:Class":"class-rectangle.svg","rdf:Property":"property-diamond.svg","owl:Ontology":"noun_classification_1479198.svg","wf:Tracker":"noun_122196.svg","wf:Task":"noun_17020_gray-tick.svg","wf:Open":"noun_17020_sans-tick.svg","wf:Closed":"noun_17020.svg"};function Lt(e){const t=e.uri.split("#")[0],n=t.indexOf("//");if(n<0)throw new Error("This URI does not have a web site part (origin)");const i=t.indexOf("/",n+2);return i<0?t.slice(0)+"/":t.slice(0,i+1)}function St(e){const t=gt;return"string"!=typeof e&&e.uri?4!==e.uri.split("/").length||e.uri.split("/")[1]||e.uri.split("/")[3]?e.uri.startsWith("message:")||e.uri.startsWith("mid:")?t+"noun_480183.svg":e.uri.startsWith("mailto:")?t+"noun_567486.svg":e.uri.startsWith("https:")&&e.uri.indexOf("#")<0?Lt(e)+"favicon.ico":null:t+"noun_15177.svg":t+"noun_10636_grey.svg"}function Rt(e){const t=x.store,n=gt;if(e.sameTerm(b.foaf("Agent"))||e.sameTerm(b.rdf("Resource")))return n+"noun_98053.svg";const i=t.any(e,b.sioc("avatar"))||t.any(e,b.foaf("img"))||t.any(e,b.vcard("logo"))||t.any(e,b.vcard("hasPhoto"))||t.any(e,b.vcard("photo"))||t.any(e,b.foaf("depiction"));return i?i.uri:null}function Nt(e,t,n){const i=x.store,a=Rt(t);if(a)return e.setAttribute("src",a),!0;const o=n[t.uri];if(o)return e.setAttribute("src",o),e.style=Ke.classIconStyle,!0;const s=St(t);if(s)return e.setAttribute("src",s),!0;const r=i.findTypeURIs(t);for(const t in r)if(n[t])return e.setAttribute("src",n[t]),!1;return e.setAttribute("src",gt+"noun_10636_grey.svg"),!1}function It(e,t){const n=x.store,i={};for(const e in _t){const t=e.split(":")[0],n=e.split(":")[1],a=b[t](n),o=_t[e];o.startsWith("data:")?i[a.uri]=o:i[a.uri]=g.uri.join(o,gt)}if(!Nt(e,t,i)&&t.uri){if(!n.fetcher)throw new Error("kb has no fetcher");n.fetcher.nowOrWhenFetched(t.doc(),void 0,n=>{n&&Nt(e,t,i)})}}function Bt(e,t){const n=e.createElement("img");n.style=Ke.iconStyle;if(n.setAttribute("src",gt+(function(e){if(!e.uri)return!1;const t=e.uri.split("/");return 3===t.length||4===t.length&&""===t[3]}(t)?"noun_15177.svg":"noun_681601.svg")),t.uri&&t.uri.startsWith("https:")&&t.uri.indexOf("#")<0){const i=e.createElement("object");return i.setAttribute("data",Lt(t)+"favicon.ico"),i.setAttribute("type","image/x-icon"),i.appendChild(n),i}return It(n,t),n}function Dt(e,t,n,i){const a=gt+"noun_2188_red.svg",o=e.createElement("img");o.setAttribute("src",a),o.setAttribute("style",Ke.smallButtonStyle),o.style.float="right";const s="Remove this "+n;return o.title=s,o.classList.add("hoverControlHide"),o.addEventListener("click",function(){const n=e.createElement("div");t.insertBefore(n,o),n.style.position="relative",n.appendChild(function(e,t,n,i){function a(){t.parentElement.removeChild(t)}function o(){a(),i()}const s=e.createElement("div");s.style=Ke.confirmPopupStyle,s.style.position="absolute",s.style.top="-1em",s.style.display="grid",s.style.gridTemplateColumns="auto auto";const r=e.createElement("div");r.style.gridColumn="1/2",r.style.gridRow="1";const c=e.createElement("div");c.style.gridColumn="1/2",c.style.gridRow="2";const l=Mt(e,a);s.appendChild(l),l.style.gridColumn="1",l.style.gridRow="2";const p=s.appendChild(e.createElement("button"));p.style=Ke.buttonStyle,p.style.gridRow="2",p.style.gridColumn="2",p.textContent="Cancel";const u=Ot(e,it.Pt.iconBase+"noun_925021.svg","Delete it");s.appendChild(u),u.style.gridRow="1",u.style.gridColumn="1";const d=s.appendChild(e.createElement("button"));return d.style=Ke.buttonStyle,d.style.gridRow="1",d.style.gridColumn="2",d.textContent=n,s.appendChild(d),u.addEventListener("click",o),d.addEventListener("click",o),p.addEventListener("click",a),s}(e,n,s,i))}),t.classList.add("hoverControl"),t.appendChild(o),o.setAttribute("data-testid","deleteButtonWithCheck"),o}function Ot(e,t,n,i,a={buttonColor:"Primary",needsBorder:!1}){const o=e.createElement("button");if(o.setAttribute("type","button"),t){const i=o.appendChild(e.createElement("img"));i.setAttribute("src",t),i.setAttribute("style","width: 2em; height: 2em;"),i.title=n,o.setAttribute("style",Ke.buttonStyle)}else o.textContent=n.toLocaleUpperCase(),o.onmouseover=function(){"Secondary"===a.buttonColor?a.needsBorder?o.setAttribute("style",Ke.secondaryButtonNoBorderHover):o.setAttribute("style",Ke.secondaryButtonHover):a.needsBorder?o.setAttribute("style",Ke.primaryButtonNoBorderHover):o.setAttribute("style",Ke.primaryButtonHover)},o.onmouseout=function(){"Secondary"===a.buttonColor?a.needsBorder?o.setAttribute("style",Ke.secondaryButtonNoBorder):o.setAttribute("style",Ke.secondaryButton):a.needsBorder?o.setAttribute("style",Ke.primaryButtonNoBorder):o.setAttribute("style",Ke.primaryButton)},"Secondary"===a.buttonColor?a.needsBorder?o.setAttribute("style",Ke.secondaryButtonNoBorder):o.setAttribute("style",Ke.secondaryButton):a.needsBorder?o.setAttribute("style",Ke.primaryButtonNoBorder):o.setAttribute("style",Ke.primaryButton);return i&&o.addEventListener("click",i,!1),o}function Mt(e,t){const n=Ot(e,bt,"Cancel",t);return n.firstChild&&(n.firstChild.style.opacity="0.3"),n}function Ft(e,t){return Ot(e,xt,"Continue",t)}function Ut(e,t,n,i,a,o){return new Promise(function(t,s){const r=e.createElement("div");i=i||b.foaf("name");const c=(o=o||(a?z(a):" "))+" "+z(i)+": ";r.appendChild(e.createElement("p")).textContent=c;const l=e.createElement("input");function p(){r.parentNode.removeChild(r),t(l.value.trim())}l.setAttribute("type","text"),l.setAttribute("size","100"),l.setAttribute("maxLength","2048"),l.setAttribute("style",Ke.textInputStyle),l.select(),r.appendChild(l),n.appendChild(r),l.addEventListener("keyup",function(e){13===e.keyCode&&p()},!1),r.appendChild(e.createElement("br")),r.appendChild(Mt(e,function(e){r.parentNode.removeChild(r),t(null)})),r.appendChild(Ft(e,function(e){p()})),l.focus()})}const zt=Pt;function Pt(e,t,n,i){const a=e.createElement("tr");i=i||{};const o=a.appendChild(e.createElement("td")),s=a.appendChild(e.createElement("td")),r=a.appendChild(e.createElement("td")),c=i.image||Bt(e,n);o.setAttribute("style","vertical-align: middle; width:2.5em; padding:0.5em; height: 2.5em;"),s.setAttribute("style","vertical-align: middle; text-align:left;"),r.setAttribute("style","vertical-align: middle; width:2em; padding:0.5em; height: 4em;"),o.appendChild(c);const l=s.appendChild(e.createElement("div")),p=l.appendChild(e.createElement("span"));if(i.title?p.textContent=i.title:Tt(p,n),"function"==typeof i.renderNameSuffix){const t=i.renderNameSuffix(n,e);if(t){const n=l.appendChild(e.createElement("span"));n.setAttribute("style","margin-left: 0.4em; opacity: 0.8;"),"string"==typeof t?n.textContent=t:n.appendChild(t)}}if("function"==typeof i.renderSupportingInfo){const t=i.renderSupportingInfo(n,e);if(t){const n=s.appendChild(e.createElement("div"));n.setAttribute("style","font-size: 90%; opacity: 0.8;"),"string"==typeof t?n.textContent=t:n.appendChild(t)}}if(i.deleteFunction&&Dt(e,r,i.noun||"one",i.deleteFunction),n.uri){if(!1!==i.link){r.appendChild(ft(e,n)).classList.add("HoverControlHide"),r.appendChild(e.createElement("br"))}!1!==i.draggable&&(c.setAttribute("draggable","false"),et(a,n))}return a.subject=n,a}function $t(e,t,n,i){const a=t.appendChild(e.createElement("div"));n?a.textContent=n:Tt(a,i)}function qt(e,t,n,i){const a=t.appendChild(e.createElement("div"));a.setAttribute("style",Ke.linkDivStyle),i.deleteFunction&&Dt(e,a,i.noun||"one",i.deleteFunction),n.uri&&(!1!==i.link&&ht(e,a,n),et(t,n))}function Ht(e,t,n){const i=e.createElement("div");i.setAttribute("style",Ke.renderAsDivStyle);if(((e,t,n)=>{const i=t.appendChild(e.createElement("div"));i.setAttribute("style",Ke.imageDivStyle),i.appendChild(n),n.setAttribute("draggable","false")})(e,i,(n=n||{}).image||Bt(e,t)),$t(e,i,n.title,t),qt(e,i,t,n),n.clickable&&n.onClickFunction&&((e,t)=>{e.addEventListener("click",t)})(i,n.onClickFunction),n.wrapInATR){const n=((e,t,n)=>{const i=e.createElement("tr");return i.appendChild(e.createElement("td")).appendChild(t),i.subject=n,i})(e,i,t);return n}return i}function Gt(e){if(e.refresh)e.refresh();else for(let t=0;t<e.children.length;t++)Gt(e.children[t])}function Vt(e,t,n,i={}){const a=new Set,o=!(!i.renderSupportingInfo&&!i.renderNameSuffix),s=i.refreshOnDocumentLoad??!0;function r(n){const r=n,l={noun:h};if(l.renderSupportingInfo=i.renderSupportingInfo,l.renderNameSuffix=i.renderNameSuffix,o&&s&&n?.uri&&v.fetcher){const e=n.doc(),t=e?.uri?v.fetcher.requested?.[e.uri]:void 0,i="done"!==t&&"failed"!==t;e?.uri&&i&&!a.has(e.uri)&&(a.add(e.uri),v.fetcher.nowOrWhenFetched(e,void 0,()=>{a.delete(e.uri),c()}))}return d&&(l.deleteFunction=function(){!function(e){if(!v.updater)throw new Error("kb has no updater");v.updater.update((0,g.st)(t,f,e,u),[],function(e,t,n,i){t?c():vt(void 0,"Error deleting one: "+n)})}(r)}),zt(e,f,n,l)}const c=function(){const e=v.each(t,f);e.sort(),Z(E,e,r,o?function(e,t){return r(t)}:void 0)};function l(e){const n=[];if(e.forEach(function(e){const i=(0,g.sym)(e);ve.Rm("Dropped on attachemnt "+e),n.push((0,g.st)(t,f,i,u))}),!v.updater)throw new Error("kb has no updater");v.updater.update([],n,function(e,t,n,i){t?c():vt(void 0,"Error adding one: "+n)})}function p(e){tt(v.fetcher,e,i.uploadFolder?.uri,i.uploadFolder?.uri,function(e,n){const i=[(0,g.st)(t,f,v.sym(n),u)];if(!v.updater)throw new Error("kb has no updater");v.updater.update([],i,function(e,t,n,i){t?c():vt(void 0,"Error adding link to uploaded file: "+n)})})}const u=i.doc||t.doc();void 0===i.modify&&(i.modify=!0);const d=i.modify,m=i.promptIcon||gt+"noun_748003.svg",f=i.predicate||b.wf("attachment"),h=i.noun||"attachment",v=x.store,y=n.appendChild(e.createElement("table"));y.setAttribute("style","margin-top: 1em; margin-bottom: 1em;");const w=y.appendChild(e.createElement("tr")),C=w.appendChild(e.createElement("td")),E=w.appendChild(e.createElement("td")).appendChild(e.createElement("table"));if(E.appendChild(e.createElement("tr")),y.refresh=c,c(),d){const t=Ot(e,m,"Drop attachments here");C.appendChild(t);const n=i.uploadFolder?p:null;Xe(t,l,n);const a=t.querySelector("img");if(a&&Xe(a,l,n),Xe(C,l,n),i.uploadFolder){const t=rn(e,p);C.appendChild(t)}}return y}function Wt(e){e.preventDefault(),e.stopPropagation();const t=ee(e).getAttribute("href");if(!t)return ve.Rm("openHrefInOutlineMode: No href found!\n");const n=window.document;n.outlineManager?n.outlineManager.GotoSubject(x.store.sym(t),!0,void 0,!0,void 0):window&&window.panes&&window.panes.getOutliner?window.panes.getOutliner().GotoSubject(x.store.sym(t),!0,void 0,!0,void 0):ve.Rm("ERROR: Can't access outline manager in this config")}function Jt(e){if(void 0===e.uri)return;let t=e.uri;if("http://"!==t.slice(0,7))return;t=t.slice(7);const n=t.indexOf("#");if(n>=0)t=t.slice(0,n);else{const e=t.lastIndexOf("/");if(e<0)return;t=t.slice(0,e)}return x.store.sym("http://tabulator.org/wiki/annnotation/"+t)}function Qt(){const e={};return x.store.statementsMatching(void 0,b.rdf("type"),void 0).forEach(function(t){t.object.value&&(e[t.object.value]=!0)}),x.store.statementsMatching(void 0,b.rdfs("subClassOf"),void 0).forEach(function(t){t.object.value&&(e[t.object.value]=!0),t.subject.value&&(e[t.subject.value]=!0)}),x.store.each(void 0,b.rdf("type"),b.rdfs("Class")).forEach(function(t){t.value&&(e[t.value]=!0)}),e}function Zt(e){const t={},n={},i={};let a=0,o=0,s=0;const r=e.predicateIndex;for(const e in r){"Literal"===r[e][0].object.termType?(n[e]=!0,o++):(i[e]=!0,a++)}const c=e.each(void 0,b.rdf("type"),b.rdf("Property"));for(let e=0;e<c.length;e++){const t=c[e].toNT();i[t]||n[t]||(n[t]=!0,i[t]=!0,s++)}return t.op=i,t.dp=n,_(`propertyTriage: ${a} non-lit, ${o} literal. ${s} unknown.`),t}function Yt(e,t){const n=e.createElement("button");return n.setAttribute("type","button"),n.textContent="Goto "+z(t),n.addEventListener("click",function(n){e.outlineManager.GotoSubject(t,!0,void 0,!0,void 0)},!0),n}function Kt(e,t){const n=e.createElement("button");return n.setAttribute("type","button"),n.textContent="✕",n.addEventListener("click",function(e){t.parentNode.removeChild(t)},!0),n}function Xt(e,t,n,i,a,o,s,r,c){return en(e.createElement("div"),e,t,n,i,a,o,s,r,c)}function en(e,t,n,i,a,o,s,r,c,l){const p="border: 0.1em solid #ddd; border-bottom: none; width: 95%; height: 2em; padding: 0.5em;";let u=null;e.innerHTML="";const d=function(e,s){let d,m;const f=function(){const e=o?n.each(void 0,a,s):n.each(s,a);x.setAttribute("class",0===e.length?"hideTillHover":""),m.setAttribute("src",r.connectIcon||gt+"noun_25830.svg"),m.setAttribute("title",e.length?e.length:"attach")},h=tn.twoLine.widgetForClass(i);d=h(t,s),d.setAttribute("style",p);const g=t.createElement("div");g.setAttribute("class","hideTillHover"),g.setAttribute("style","float:right; width:10%");const b=t.createElement("a");b.setAttribute("href",s.uri),b.setAttribute("style","float:right"),g.appendChild(b).textContent=">",e.appendChild(g);const x=t.createElement("div");return x.setAttribute("style",(o?"float:left;":"float:right;")+" width:30px;"),m=t.createElement("img"),f(),x.appendChild(m),e.appendChild(x),d.addEventListener("click",function(e){u===d?(d.setAttribute("style",p),u=null):(u&&u.setAttribute("style",p),d.setAttribute("style",p+"background-color: #ccc; color:black;"),u=d),c(s,e,u===d),f()},!1),m.addEventListener("click",function(e){l(s,e,o,f)},!1),e.appendChild(d),e};for(let n=0;n<s.length;n++){const i=t.createElement("div");e.appendChild(i),d(i,s[n])}return e}let tn={};function nn(e,t){const n=e.querySelectorAll("link");for(let e=0;e<n.length;e++)if("stylesheet"===(n[e].getAttribute("rel")||"")&&(n[e].getAttribute("href")||"")===t)return;const i=e.createElement("link");i.setAttribute("rel","stylesheet"),i.setAttribute("type","text/css"),i.setAttribute("href",t),e.getElementsByTagName("head")[0].appendChild(i)}function an(e){return sn(e,"audio")}function on(e){return sn(e,"video")}function sn(e,t){const n=t||"image",i=x.store.findTypeURIs(e),a=g.Util.mediaTypeClass(n+"/*").uri.split("*")[0];for(const e in i)if(e.startsWith(a))return!0;return{audio:"http://purl.org/dc/dcmitype/Sound",image:"http://purl.org/dc/dcmitype/Image",video:"http://purl.org/dc/dcmitype/MovingImage"}[n]in i}function rn(e,t){const n=e.createElement("div"),i=n.appendChild(e.createElement("input"));i.setAttribute("type","file"),i.setAttribute("multiple","true"),i.addEventListener("change",e=>{ve.Rm("File drop event: ",e),e.files?t(e.files):e.target&&e.target.files?t(e.target.files):alert("Sorry no files .. internal error?")},!1),i.style="display:none";return Xe(n.appendChild(Ot(e,gt+"noun_Upload_76574_000000.svg","Upload files",e=>{i.click()})),null,t),n}tn={line:{},twoLine:{"":function(e,t){const n=e.createElement("div");return n.textContent=z(t),n},"http://www.w3.org/2000/10/swap/pim/qif#Transaction":function(e,t){let n="";const i=function(e){const i=x.store.any(t,b.qu(e));return i||(n+="@@ No value for "+e+"! "),i?de(i.value):"?"},a=e.createElement("table");return a.innerHTML=`\n <tr>\n <td colspan="2"> ${i("payee")}</td>\n < /tr>\n < tr >\n <td>${i("date").slice(0,10)}</td>\n <td style = "text-align: right;">${i("amount")}</td>\n </tr>`,n&&(a.innerHTML=`\n <tr>\n <td><a href="${de(t.uri)}">${de(n)}</a></td>\n </tr>`),a},"http://www.w3.org/ns/pim/trip#Trip":function(e,t){const n=function(e){const n=x.store.any(t,e);return n?de(n.value):"?"},i=e.createElement("table");return i.innerHTML=`\n <tr>\n <td colspan="2">${n(b.dc("title"))}</td>\n </tr>\n <tr style="color: #777">\n <td>${n(b.cal("dtstart"))}</td>\n <td>${n(b.cal("dtend"))}</td>\n </tr>`,i},widgetForClass:function(e){let t=tn.twoLine[e.uri];const n=x.store;if(t)return t;const i=n.findSuperClassesNT(e);for(const e in i)if(t=tn.twoLine[n.fromNT(e).uri],t)return t;return tn.twoLine[""]}}};const cn={[b.ui("ColorField").uri]:{size:9,type:"color",style:"height: 3em;",dt:"color",pattern:/^\s*#[0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f]([0-9a-f][0-9a-f])?\s*$/},[b.ui("DateField").uri]:{size:20,type:"date",dt:"date",pattern:/^\s*[0-9][0-9][0-9][0-9](-[0-1]?[0-9]-[0-3]?[0-9])?Z?\s*$/},[b.ui("DateTimeField").uri]:{size:20,type:"datetime-local",dt:"dateTime",pattern:/^\s*[0-9][0-9][0-9][0-9](-[0-1]?[0-9]-[0-3]?[0-9])?(T[0-2][0-9]:[0-5][0-9](:[0-5][0-9])?)?Z?\s*$/},[b.ui("TimeField").uri]:{size:10,type:"time",dt:"time",pattern:/^\s*([0-2]?[0-9]:[0-5][0-9](:[0-5][0-9])?)\s*$/},[b.ui("IntegerField").uri]:{size:12,style:"text-align: right;",dt:"integer",pattern:/^\s*-?[0-9]+\s*$/},[b.ui("DecimalField").uri]:{size:12,style:"text-align: right;",dt:"decimal",pattern:/^\s*-?[0-9]*(\.[0-9]*)?\s*$/},[b.ui("FloatField").uri]:{size:12,style:"text-align: right;",dt:"float",pattern:/^\s*-?[0-9]*(\.[0-9]*)?((e|E)-?[0-9]*)?\s*$/},[b.ui("SingleLineTextField").uri]:{},[b.ui("NamedNodeURIField").uri]:{namedNode:!0},[b.ui("TextField").uri]:{},[b.ui("PhoneField").uri]:{size:20,uriPrefix:"tel:",pattern:/^\+?[\d-]+[\d]*$/},[b.ui("EmailField").uri]:{size:30,uriPrefix:"mailto:",pattern:/^\s*.*@.*\..*\s*$/},[b.ui("Group").uri]:{style:Ke.formGroupStyle},[b.ui("Comment").uri]:{element:"p",style:Ke.commentStyle},[b.ui("Heading").uri]:{element:"h3",style:Ke.formHeadingStyle}},ln=x.solidLogicSingleton.store,pn={};function un(e){const t=ln,n=t.findTypeURIs(e),i=t.bottomTypeURIs(n),a=[];for(const e in i)a.push(e);return a[0]}function dn(e,t){const n=un(t),i=pn[n];return j("paneUtils: Going to implement field "+t+" of type "+n),i||function(e,i){const a=nt(e,"No handler for field "+t+" of type "+n);return i&&i.appendChild(a),a}}const mn="https://www.w3.org/ns/css#";const fn=x.solidLogicSingleton.store;function hn(e,t,n,i,a){n.style.display="flex",n.style.flexDirection="row";const o=n.appendChild(e.createElement("div"));o.style.width=He;const s=n.appendChild(e.createElement("div"));return o.setAttribute("class","formFieldName"),o.setAttribute("style",Ke.formFieldNameBoxStyle),s.setAttribute("class","formFieldValue"),a?o.appendChild(e.createTextNode(a)):t.any(i,b.ui("property"))?o.appendChild(gn(e,t.any(i,b.ui("property")),i)):(s.appendChild(nt(e,"No property or label given for form field: "+i)),o.appendChild(e.createTextNode("???"))),s}function gn(e,t,n){let i=fn.any(n,b.ui("label"));if(i||(i=z(t,!0)),void 0===t)return e.createTextNode("@@Internal error: undefined property");const a=e.createElement("a");return t.uri&&a.setAttribute("href",t.uri),a.setAttribute("style","color: #3B5998; text-decoration: none;"),a.textContent=i,a}function bn(e,t,n){const i=fn.statementsMatching(e,t);if(0===i.length)return n;if(!fn.updater)throw new Error("Store has no updater");return i.length>0&&i[0].why.value&&fn.updater.editable(i[0].why.value,fn)?fn.sym(i[0].why.value):n}function xn(e,t,n,i,a,o,s){const r=fn,c=a.doc?a.doc():null,l=e.createElement("div"),p=r.any(a,b.ui("property"));if(t&&t.appendChild(l),!p)return l.appendChild(nt(e,"Error: No property given for text field: "+a));const u=hn(e,r,l,a),d=r.anyJS(a,b.ui("suppressEmptyUneditable"),null,c),m=un(a);let f=cn[m];void 0===f&&(f={style:""});const h=f.style||"",x=Ke.textInputStyle+h,v=e.createElement("input");v.style=x,u.appendChild(v),v.setAttribute("type",f.type?f.type:"text");const y=(v.getAttribute("type")||"").toLowerCase(),w="date"===y||"datetime-local"===y,C=r.anyJS(a,b.ui("size"))||Ge||20;v.setAttribute("size",C);const E=r.any(a,b.ui("maxLength"));v.setAttribute("maxLength",E?""+E:Ye),o=o||bn(i,p,o);let k=r.any(i,p,void 0,o);if(k||(k=r.any(a,b.ui("default"))),k&&k.value&&f.uriPrefix?v.value=decodeURIComponent(k.value.replace(f.uriPrefix,"")).replace(/ /g,""):k&&(v.value=k.value||k.value||""),v.setAttribute("style",x),!r.updater)throw new Error("kb has no updater");return r.updater.editable(o.uri)?(v.addEventListener("keyup",function(e){f.pattern&&v.setAttribute("style",x+(v.value.match(f.pattern)?"color: green;":"color: red;"))},!0),v.addEventListener("change",function(t){if(w&&e.activeElement===v)return void(v.dataset&&(v.dataset.deferredChange="true"));if(f.pattern&&!v.value.match(f.pattern))return;const n=!w;n&&(v.disabled=!0),v.setAttribute("style",x+"color: gray;");const a=r.statementsMatching(i,p);let c;f.namedNode?c=r.sym(v.value):f.uriPrefix?(c=encodeURIComponent(v.value.replace(/ /g,"")),c=r.sym(f.uriPrefix+v.value)):c=f.dt?new g.Literal(v.value.trim(),void 0,b.xsd(f.dt)):new g.Literal(v.value);let u=a.map(e=>(0,g.st)(e.subject,e.predicate,c,e.why));0===u.length&&(u=[(0,g.st)(i,p,c,o)]),function e(t,n,i){const a=[];if(n.forEach(e=>{a.includes(e.why.uri)||a.push(e.why.uri)}),t.forEach(e=>{a.includes(e.why.uri)||a.push(e.why.uri)}),0===a.length)throw new Error("updateMany has no docs to patch");if(!r.updater)throw new Error("kb has no updater");if(1===a.length)return r.updater.update(t,n,i);const o=a.pop(),s=n.filter(e=>e.why.uri===o),c=n.filter(e=>e.why.uri!==o),l=t.filter(e=>e.why.uri===o),p=t.filter(e=>e.why.uri!==o);r.updater.update(l,s,function(t,n,a){n?e(p,c,i):i(t,n,a)})}(a,u,function(t,i,a){i?(n&&(v.disabled=!1),v.setAttribute("style",x)):l.appendChild(nt(e,a)),s(i,a)})},!0),v.addEventListener("blur",function(e){if(w&&v.dataset&&"true"===v.dataset.deferredChange){delete v.dataset.deferredChange;const e=new Event("change",{bubbles:!0});v.dispatchEvent(e)}},!0),l):(v.readOnly=!0,v.style=Ke.textInputStyleUneditable+h,d&&""===v.value&&(l.style.display="none"),l)}const vn="https://www.w3.org/ns/iana/language-code/",yn=["en","fr","de","it","ar"];function wn(e){return e||(e=[]),e.concat(yn.filter(t=>!e.includes(t)))}async function Cn(e){const t=e.doc();await(x.store.fetcher?.load(t));const n=x.store.any(e,b.schema("knowsLanguage"),null,t);if(!n)return yn;const i=[];return n.elements.forEach(e=>{const n=x.store.any(e,b.solid("publicId"),null,t);if(!n)return void console.warn("getPreferredLanguages: No publiID of language.");if(!n.value.startsWith(vn))return void console.error(`What should be a language code ${n.value} does not start with ${vn}`);const a=n.value.slice(vn.length);i.push(a)}),i.length>0?(console.log(` User knows languages with codes: "${i.join(",")}"`),wn(i)):null}async function En(){const e=await x.authn.currentUser();if(e){const t=await Cn(e);if(t)return t}if("undefined"!=typeof navigator){if(navigator.languages)return wn(navigator.languages.map(e=>e.split("-")[0]));if(navigator.language)return wn([navigator.language.split("-")[0]])}return yn}function kn(e,t){const n={};e.forEach(e=>{const t=e.subject.value;n[t]=n[t]||[],n[t].push(e)});const i=t||yn;i.reverse();const a=[];for(const e in n){const t=n[e].map(e=>{const t=e.name["xml:lang"];return[i.indexOf(t),e]});t.sort(),t.reverse(),a.push(t[0][1])}return ve.Rm(` Filter by language: ${e.length} -> ${a.length}`),a}const An=200,Tn=/\$\(subject\)/g,jn={Corporation:"http://www.wikidata.org/entity/Q6881511",EducationalOrganization:"http://www.wikidata.org/entity/Q178706",GovernmentOrganization:"http://www.wikidata.org/entity/Q327333",MedicalOrganization:"http://www.wikidata.org/entity/Q4287745",MusicGroup:"http://www.wikidata.org/entity/Q32178211",NGO:"http://www.wikidata.org/entity/Q163740",Occupation:"http://www.wikidata.org/entity/Q28640",Project:"http://www.wikidata.org/entity/Q170584",ResearchOrganization:"http://www.wikidata.org/entity/Q31855",SportsOrganization:"http://www.wikidata.org/entity/Q4438121"},_n='prefix vcard: <http://www.w3.org/2006/vcard/ns#>\nCONSTRUCT\n{ wd:Q49108 vcard:fn ?itemLabel.\nwd:Q49108 rdf:type ?klass. ?klass rdfs:label ?klassLabel; rdfs:comment ?klassDescription .\nwd:Q49108 schema:logo ?logo;\n schema:image ?image;\n schema:logo ?sealImage;\n schema:subOrganization ?subsidiary .\n ?subsidiary rdfs:label ?subsidiaryLabel .\n ?supersidiary schema:subOrganization wd:Q49108 .\n ?supersidiary rdfs:label ?supersidiaryLabel .\n wd:Q49108 schema:location ?location .\n ?location schema:elevation ?elevation .\n ?location wdt:P131 ?region . ?region rdfs:label ?regionLabel .\n ?location wdt:P625 ?coordinates .\n ?location schema:country ?country . ?country rdfs:label ?countryLabel .\n}\nWHERE\n{ optional {wd:Q49108 rdfs:label ?itemLabel} .\n optional {wd:Q49108 wdt:P154 ?logo .}\n optional {wd:Q49108 wdt:P31 ?klass .}\n optional {wd:Q49108 wdt:P158 ?sealImage .}\n optional {wd:Q49108 wdt:P18 ?image .}\n\n optional { wd:Q49108 wdt:P355 ?subsidiary . }\n optional { ?supersidiary wdt:P355 wd:Q49108. }\n\n optional { wd:Q49108 wdt:P276 ?location .\n\n optional { ?location schema:eleveation ?elevation }\n optional { ?location wdt:P131 ?region }\n optional { ?location wdt:P625 ?coordinates }\n optional { ?location wdt:P17 ?country }\n }\n SERVICE wikibase:label { bd:serviceParam wikibase:language "fr,en,de,it". }\n}',Ln={credentials:"omit",headers:new Headers({Accept:"application/json"})},Sn={label:"ESCO",logo:x.store.sym("https://ec.europa.eu/esco/portal/static_resource2/images/logo/logo_en.gif"),searchByNameURI:"https://ec.europa.eu/esco/api/search?language=$(language)&type=occupation&text=$(name)"},Rn={label:"DBPedia",logo:x.store.sym("https://upload.wikimedia.org/wikipedia/commons/thumb/7/73/DBpediaLogo.svg/263px-DBpediaLogo.svg.png"),searchByNameQuery:'select distinct ?subject, ?name where {\n ?subject a $(targetClass); rdfs:label ?name\n FILTER regex(?name, "$(name)", "i")\n } LIMIT $(limit)',endpoint:"https://dbpedia.org/sparql/"},Nn={AcademicInsitution:"http://umbel.org/umbel/rc/EducationalOrganization"},In={AcademicInsitution:"http://www.wikidata.org/entity/Q4671277",Enterprise:"http://www.wikidata.org/entity/Q6881511",Business:"http://www.wikidata.org/entity/Q4830453",NGO:"http://www.wikidata.org/entity/Q79913",CharitableOrganization:"http://www.wikidata.org/entity/Q708676",Insitute:"http://www.wikidata.org/entity/Q1664720"},Bn={label:"WikiData",limit:3e3,logo:x.store.sym("https://www.wikimedia.org/static/images/project-logos/wikidatawiki.png"),endpoint:"https://query.wikidata.org/sparql",searchByNameQuery:'SELECT ?subject ?name\n WHERE {\n ?klass wdt:P279* $(targetClass) .\n ?subject wdt:P31 ?klass .\n ?subject rdfs:label ?name.\n FILTER regex(?name, "$(name)", "i")\n } LIMIT $(limit) ',insitituteDetailsQuery:'CONSTRUCT\n{ wd:Q49108 schema:name ?itemLabel;\n schema:logo ?logo;\n schema:logo ?sealImage;\n schema:subOrganization ?subsidiary .\n ?subsidiary schema:name ?subsidiaryLabel .\n}\nWHERE\n{\n wd:Q49108 # rdfs:label ?itemLabel ;\n wdt:P154 ?logo;\n wdt:P158 ?sealImage ;\n wdt:P355 ?subsidiary .\n # ?subsidiary rdfs:label ?subsidiaryLabel .\n\n SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE], fr". }\n}'},Dn={"http://www.wikidata.org/entity/Q15936437":b.schema("CollegeOrUniversity"),"http://www.wikidata.org/entity/Q1664720":b.schema("EducationalOrganization"),"http://www.wikidata.org/entity/Q43229":b.schema("Organization"),"http://www.wikidata.org/entity/Q3918":b.schema("CollegeOrUniversity"),"http://www.wikidata.org/entity/Q170584":b.schema("Project"),"http://www.wikidata.org/entity/Q327333":b.schema("GovernmentOrganization"),"http://www.wikidata.org/entity/Q2221906":b.schema("Place"),"http://www.wikidata.org/entity/Q167037":b.schema("Corporation")},On={targetClass:b.rdf("type"),sealImage:b.schema("logo"),shortName:b.foaf("nick"),subsidiary:b.schema("subOrganization"),city:b.vcard("locality"),state:b.vcard("region"),country:b.vcard("country-name"),homepage:b.foaf("homepage"),lat:b.schema("latitude"),long:b.schema("longitude")};function Mn(e){const t=e.type.toLowerCase();if("uri"===t||"iri"===t)return x.store.sym(e.value);if("literal"===t)return e["xml:lang"]?new g.Literal(e.value,e["xml:lang"]):new g.Literal(e.value);throw new Error(`bindingToTerm: Unexpected type "${e.type}" in sparql binding}`)}function Fn(e,t,n,i,a=On){const o={};ve.Rm(`loadFromBindings: subject: ${t}`),ve.Rm(` doc: ${i}`),n.forEach(e=>{for(const t in e){const n=e[t],i=JSON.stringify(n);o[t]=o[t]||new Set,o[t].add(i)}});for(const n in o){const s=o[n];ve.Rm(` results ${n} -> ${s}`),s.forEach(o=>{const s=JSON.parse(o),{type:r,value:c}=s;let l;if("uri"===r)l=e.sym(c);else{if("literal"!==r)throw new Error(`loadFromBindings: unexpected type: ${r}`);l=new g.Literal(c,s.language,s.datatype)}if("type"===n)Dn[c]?l=Dn[c]:ve.R8("Unmapped Wikidata Class: "+c);else if("coordinates"===n){ve.Rm(" @@@ hey a point: "+c);const n=/.*\(([-0-9.-]*) ([-0-9.-]*)\)/.exec(c);if(n){const a=b.xsd("float"),o=new g.Literal(n[1],null,a),s=new g.Literal(n[2],null,a);e.add(t,b.schema("longitude"),s,i),e.add(t,b.schema("latitude"),o,i)}else ve.Rm("Bad coordinates syntax: "+c)}else{const o=a[n]||b.schema(n);e.add(t,o,l,i),ve.Rm(` public data ${o} ${l}.`)}})}}function Un(e){return e._embedded.results.map(e=>({name:{value:e.title,type:"literal"},subject:{type:"IRI",value:e.uri}}))}async function zn(e,t,n){if(!n.searchByNameURI)throw new Error("Missing queryTarget.searchByNameURI on queryESCODataByName");const i=n.limit||An,a=n.searchByNameURI.replace("$(name)",e).replace("$(limit)",""+i).replace("$(targetClass)",t.toNT());ve.Rm("Querying ESCO data - uri: "+a);const o=await(x.store.fetcher?.webOperation("GET",a,Ln)),s=o?.responseText||"";if(ve.Rm(" Query result text"+s.slice(0,500)+"..."),0===s.length)throw new Error("Wot no text back from ESCO query "+a);const r=JSON.parse(s);return ve.Rm(" ESCO Query result JSON"+JSON.stringify(r,null,4).slice(0,500)+"..."),Un(r)}function Pn(e){const t=e.indexOf("SPARQL-QUERY");if(t<0)return e;ve.R8(" ### Fixing JSON with wikidata error code injection "+e.slice(t,t+200));const n=e.lastIndexOf("}, {");return e.slice(0,n)+" } ] } } "}async function $n(e,t,n,i){function a(n){const a=i.limit||An;return n.replace("$(name)",e).replace("$(limit)",""+a).replace("$(language)",o).replace("$(targetClass)",t.toNT())}if(!t)throw new Error("queryPublicDataByName: No class provided");const o=(await En()||yn)[0]||"en";if(i.searchByNameQuery){const e=a(i.searchByNameQuery);return ve.Rm("Querying public data - sparql: "+e),qn(e,i)}if(i.searchByNameURI){const e=a(i.searchByNameURI);let t;try{t=await(x.store.fetcher?.webOperation("GET",e,Ln))}catch(t){throw new Error(`Exception when trying to fetch ${e} \n ${t}`)}const n=t.responseText||"";if(200!==t.status)throw new Error(`HTTP error status ${t.status} trying to fetch ${e} `);if(ve.Rm(" Query result text"+n.slice(0,500)+"..."),0===n.length)throw new Error("queryPublicDataByName: No text back from public data query "+e);const o=Pn(n),s=JSON.parse(o);if(ve.Rm(" API Query result JSON"+JSON.stringify(s,null,4).slice(0,500)+"..."),s._embedded){ve.Rm(" Looks like ESCO");return Un(s)}throw alert("Code me: unrecognized API return format"),new Error(`*** Need to add code to parse unrecognized API JSON return\n${JSON.stringify(s,null,4)}`)}throw new Error("Query source must have either rest API or SPARQL endpoint.")}async function qn(e,t){if(!t.endpoint)throw new Error("Missing queryTarget.endpoint required for queryPublicDataSelect");const n=new URL(t.endpoint);n.searchParams.append("query",e);const i=n.href;ve.Rm(" queryPublicDataSelect uri: "+i);const a=new Headers;a.append("Accept","application/json");const o={credentials:"omit",headers:a},s=await(x.store.fetcher?.webOperation("GET",i,o)),r=s?.responseText||"";if(0===r.length)throw new Error("No text back from query "+i);const c=Pn(r),l=JSON.parse(c);ve.Rm(" Query result JSON"+JSON.stringify(l,null,4).slice(0,100)+"...");return l.results.bindings}async function Hn(e,t,n){if(ve.Rm("queryPublicDataConstruct: sparql:",e),!n.endpoint)throw new Error("Missing queryTarget.endpoint required for queryPublicDataConstruct");const i=new URL(n.endpoint);i.searchParams.append("query",e);const a=i.href;ve.Rm(" queryPublicDataConstruct uri: "+a);const o=new Headers;o.append("Accept","text/turtle");const s={credentials:"omit",headers:o},r=await(x.store.fetcher?.webOperation("GET",a,s)),c=r?.responseText||"No response text?",l=c.length>500?c.slice(0,200)+" ... "+c.slice(-200):c;if(ve.Rm(" queryPublicDataConstruct result text:"+l),0===c.length)throw new Error("queryPublicDataConstruct: No text back from construct query:"+a);(0,g.parse)(c,x.store,t.uri,"text/turtle")}async function Gn(e,t,n){if(n.uri.startsWith("https://dbpedia.org/resource/"))return Qn(e,t,n);if(!n.uri.match(/^https?:\/\/www\.wikidata\.org\/entity\/.*/)){const t=n.uri.startsWith("http:")?e.sym("https:"+n.uri.slice(5)):n,i=new Headers;return i.append("Accept","text/turtle"),e.fetcher.load(t,{credentials:"omit",headers:i})}await Vn(e,t,n)}async function Vn(e,t,n){const i=_n.replace(/wd:Q49108/g,n.toNT());await Hn(i,n,Bn),ve.Rm("getWikidataDetails: loaded.",n)}async function Wn(e,t,n){const i='select distinct * where {\n optional { $(subject) wdt:P31 ?targetClass } # instance of\n optional { $(subject) wdt:P154 ?logo }\n optional { $(subject) wdt:P158 ?sealImage }\n# optional { $(subject) wdt:P159 ?headquartersLocation }\n\noptional { $(subject) wdt:P17 ?country }\noptional { $(subject) wdt:P18 ?image }\noptional { $(subject) wdt:P1813 ?shortName }\n\noptional { $(subject) wdt:P355 ?subsidiary }\n# SERVICE wikibase:label { bd:serviceParam wikibase:language "fr,en,de,it" }\n}'.replace(Tn,n.toNT());Fn(e,n,await qn(i,Bn),n.doc())}async function Jn(e,t,n){const i='select distinct * where {\n\n $(subject) wdt:P276 ?location .\n\n optional { ?location wdt:P2044 ?elevation }\n optional { ?location wdt:P131 ?region }\n optional { ?location wdt:P625 ?coordinates }\noptional { ?location wdt:P17 ?country }\n\n# SERVICE wikibase:label { bd:serviceParam wikibase:language "fr,en,de,it" }\n}'.replace(Tn,n.toNT());ve.Rm(" location query sparql:"+i);const a=await qn(i,Bn);ve.Rm(" location query bindings:",a),Fn(e,n,a,n.doc())}async function Qn(e,t,n){const i=`select distinct ?city, ?state, ?country, ?homepage, ?logo, ?lat, ?long, WHERE {\n OPTIONAL { <${n}> <http://dbpedia.org/ontology/city> ?city }\n OPTIONAL { ${n} <http://dbpedia.org/ontology/state> ?state }\n OPTIONAL { ${n} <http://dbpedia.org/ontology/country> ?country }\n OPTIONAL { ${n} foaf:homepage ?homepage }\n OPTIONAL { ${n} foaf:lat ?lat; foaf:long ?long }\n OPTIONAL { ${n} <http://dbpedia.org/ontology/country> ?country }\n }`;Fn(e,n,await qn(i,Rn),n.doc()),ve.Rm("Finished getDbpediaDetails.")}function Zn(e,t){e.style.display=t?"":"none"}async function Yn(e,t,n,i){function a(e,n){ve.Rm("Auto complete: finish! "+e),"Literal"===e.termType&&t.queryParams.objectURIBase&&(e=x.store.sym(t.queryParams.objectURIBase.value+e.value)),r(),i(e,n)}async function o(e,t){if(n.acceptButton)return n.acceptButton.disbaled=!1,Zn(n.acceptButton,!0),C.value=t.value,b=t,v=e,ve.Rm("Auto complete: name: "+t),ve.Rm("Auto complete: waiting for accept "+e),void r();Zn(n.cancelButton,!0),a(e,t)}async function s(e){b&&C.value===b.value&&a(v,b)}function r(){for(;y.children.length>1;)y.removeChild(y.lastChild)}function c(){t.currentObject?(C.value=t.currentName?t.currentName.value:"??? wot no name for "+t.currentObject,b=t.currentName,u=t.currentName?t.currentName.value:void 0,v=t.currentObject):(C.value="",u=void 0,v=void 0),n.deleteButton&&Zn(n.deleteButton,!!t.currentObject),n.acceptButton&&Zn(n.acceptButton,!1),n.editButton&&Zn(n.editButton,!0),n.cancelButton&&Zn(n.cancelButton,!1),m=!1,r()}const l=t.targetClass;if(!l)throw new Error("renderAutoComplete: missing targetClass");let p;n.acceptButton&&n.acceptButton.addEventListener("click",s,!1),n.cancelButton&&n.cancelButton.addEventListener("click",async function(e){ve.Rm("Auto complete: Canceled by user! "),t.permanent?c():g.parentNode&&g.parentNode.removeChild(g)},!1);let u,d=!1,m=!1,f=!1,h=20;const g=e.createElement("div");let b,v;const y=g.appendChild(e.createElement("table"));y.setAttribute("data-testid","autocomplete-table"),y.setAttribute("style","max-width: 30em; margin: 0.5em;");const w=y.appendChild(e.createElement("tr"));Ke.setStyle(w,"autocompleteRowStyle");const C=w.appendChild(e.createElement("td")).appendChild(e.createElement("input"));C.setAttribute("type","text"),c();const E=t.size||Ge||20;C.setAttribute("size",E),C.setAttribute("data-testid","autocomplete-input");const k=Ke.textInputStyle||"border: 0.1em solid #444; border-radius: 0.5em; width: 100%; font-size: 100%; padding: 0.1em 0.6em";return C.setAttribute("style",k),C.addEventListener("keyup",function(e){13===e.keyCode&&s()},!1),C.addEventListener("input",async function(i){Zn(n.cancelButton,!0),async function(){function n(t){const n=e.createElement("tr");Ke.setStyle(n,"autocompleteRowStyle"),n.setAttribute("style","padding: 0.3em;"),n.style.color=f?"#080":"#088",n.textContent=t.name.value;const i=Mn(t.subject),a=Mn(t.name);return n.addEventListener("click",async e=>{ve.Rm(" click row textContent: "+n.textContent),ve.Rm(" click name: "+a.value),i&&a&&o(i,a)}),n}function i(e,t){return t.name.value>e.name.value?1:t.name.name<e.name.value?-1:0}if(m)return void ve.Rm(`Ignoring "${C.value}" because of lock `);ve.Rm(`Setting lock at "${C.value}"`),m=!0;const a=await En(),s=C.value.trim().toLowerCase();if(s.length<4)r(),h=20;else{f&&u&&s.startsWith(u)||(ve.Rm(` Querying database at "${s}" cf last "${u}".`),p=await async function(n,i){let a;try{a=await $n(n,l,0,t.queryParams)}catch(t){return function(t){const n=y.appendChild(e.createElement("tr"));ve.Rm(t);const i=new Error(t);n.appendChild(nt(e,i,"pink")),Ke.setStyle(n,"autocompleteRowStyle"),n.style.padding="1em"}("Error querying db of organizations: "+t),void(m=!1)}d=a.length<An,u=d?n:void 0;r();const o=kn(a,i);return o}(s,a));const c=function(e,t){return t.filter(t=>function(e,t){const n=e.split(" ");for(let e=0;e<n.length;e++){const i=n[e];if(t.toLowerCase().indexOf(i)<0)return!1}return!0}(e,t.name.value))}(s,p);d&&c.length<=40&&(h=c.length),f=d&&c.length<=h,ve.Rm(` Filter:"${s}" lastBindings: ${p.length}, slimmed to ${c.length}; rows: ${h}, Enough? ${d}, All displayed? ${f}`);const g=c.slice(0,h);g.sort(i),r();for(const e of g)y.appendChild(n(e));1===c.length&&o(Mn(c[0].subject),Mn(c[0].name))}m=!1}()}),g}const Kn=it.Pt.iconBase+"noun_34653_green.svg",Xn=it.Pt.iconBase+"noun_Search_875351.svg",ei=it.Pt.iconBase+"noun_253504.svg";async function ti(e,t,n,i,a,o){async function s(e,t){return i.permanent?(Zn(m,!0),Zn(c,!1),Zn(l,!1)):v&&(y.removeChild(v),v=void 0),a(e,t)}async function r(){v=e.createElement("div"),v.setAttribute("style","display: flex; flex-flow: wrap;"),v.appendChild(await Yn(e,i,g,s)),v.appendChild(c),v.appendChild(l),v.appendChild(m),v.appendChild(p),y.appendChild(v)}const c=Ft(e);c.setAttribute("data-testid","accept-button");const l=Mt(e);l.setAttribute("data-testid","cancel-button");const p=e.createElement("div"),u=i.targetClass?z(i.targetClass):"item",d=Dt(e,p,u,o);d.setAttribute("data-testid","delete-button");const m=Ot(e,ei,"Edit",e=>{f=!f,h()});m.setAttribute("data-testid","edit-button");let f=!0;function h(){f?(Zn(m,!1),Zn(c,!1),Zn(l,!1)):(Zn(m,!0),Zn(c,!1),Zn(l,!1))}const g={acceptButton:c,cancelButton:l,editButton:m,deleteButton:d};let v;const y=e.createElement("div");if(y.style.display="flex",y.style.flexDirection="row",(i.permanent||i.currentObject)&&await r(),n.editable){if(y.style.width="100%",n.manualURIEntry){Xe(y.appendChild(Ot(e,Kn,n.idNoun,async function(n){const i=await Ut(e,x.store,y,b.vcard("url"),void 0,"Solid ID");if(i)return a(t,i)})),async function(e){for(const n of e)await a(t,n)},void 0)}!n.dbLookup||i.currentObject||i.permanent||y.appendChild(Ot(e,Xn,n.idNoun,async function(e){v?(y.removeChild(v),v=void 0):await r()}))}return h(),y}
|
|
3
|
+
`,e.appendChild(t)}const i=document.createElement("button");return i.textContent=Me()("Done"),i.addEventListener("click",e=>{this.doneBuildingCb(this.group)}),e.appendChild(i),this.element.innerHTML="",this.element.appendChild(e),this}add(e){return new Promise((t,n)=>{at.fetcher.nowOrWhenFetched(e,(i,a)=>{if(!i)return this.onGroupChanged(a),n(a);const o=g.namedNode(e),s=at.any(o,b.rdf("type"));return s&&s.equals(b.foaf("Person"))?t(o):n(new Error(`Only people supported right now. (tried to add something of type ${s.value})`))})}).then(e=>{const t=g.st(this.group,b.vcard("hasMember"),e);return at.holdsStatement(t)?e:ut(this.group.doc().uri,{toIns:[t]}).then(()=>{t.why=this.group.doc(),at.add(t),this.onGroupChanged(null,"added",e),this.render()})})}handleRemove(e){return t=>{const n=g.st(this.group,b.vcard("hasMember"),e);return ut(this.group.doc().uri,{toDel:[n]}).then(()=>(at.remove(n),this.onGroupChanged(null,"removed",e),this.render(),!0)).catch(t=>{const n=at.any(e,b.foaf("name")),i=n&&n.value?`Could not remove ${n.value}. (${t})`:`Could not remove ${e.value}. (${t})`;throw new Error(i)})}}setGroupName(e){const{groupIndex:t}=dt(this.book),n=[this.group.doc(),t].map(t=>{const n=at.match(this.group,b.vcard("fn"),null,t),i=g.st(this.group,b.vcard("fn"),g.literal(e));return ut(t.value,{toDel:n,toIns:[i]}).then(e=>{at.removeStatements(n),i.why=t,at.add(i)})});return Promise.all(n)}}class lt{constructor(e,t,n){this.webIdNode=t,this.element=e,this.handleRemove=n}render(){const e=document.createElement("div");e.style.display="flex";const t=pt(this.webIdNode,b.foaf("img"),it.LN+"noun_15059.svg"),n=document.createElement("img");n.src=Me()(t),n.width="50",n.height="50",n.style.margin="5px";const i=pt(this.webIdNode,b.foaf("name"),`[${this.webIdNode}]`),a=document.createElement("span");a.innerHTML=Me()(i),a.style.flexGrow="1",a.style.margin="auto 0";const o=document.createElement("button");return o.textContent="Remove",o.addEventListener("click",e=>this.handleRemove().catch(e=>{this.element.appendChild(nt(document,Me()(`${e}`)))})),o.style.margin="5px",e.appendChild(n),e.appendChild(a),e.appendChild(o),this.element.innerHTML="",this.element.appendChild(e),this}}function pt(e,t,n){const i=at.any(e,t);return i?i.value:n}function ut(e,{toDel:t,toIns:n}){return new Promise((e,i)=>{at.updater.update(t,n,(t,n,a)=>{if(!n)return i(new Error(`PATCH failed for resource <${t}>: ${a}`));e()})})}function dt(e){return{groupIndex:at.any(e,b.vcard("groupIndex")),groupContainer:at.sym(e.dir().uri+"Group/")}}const mt="data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMjAiIGhlaWdodD0iMjAiIHZpZXdCb3g9IjAgMCAyMCAyMCIgZmlsbD0ibm9uZSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4KPHBhdGggZD0iTTEzLjAxNTcgOS4yNzM2M0MxNC4yOTU0IDguMzQwMzEgMTUuMTI4OCA2LjgyOTg0IDE1LjEyODggNS4xMjgyQzE1LjEyODggMi4zMDA1MSAxMi44MjgzIDAgMTAuMDAwNiAwQzcuMTcyODkgMCA0Ljg3MjM4IDIuMzAwNTEgNC44NzIzOCA1LjEyODJDNC44NzIzOCA2LjgyOTg0IDUuNzA1NyA4LjM0MDMxIDYuOTg1NDcgOS4yNzM2M0MzLjgwNDIyIDEwLjQ5MSAxLjUzOTA2IDEzLjU3NTQgMS41MzkwNiAxNy4xNzk1QzEuNTM5MDYgMTguNzM0NyAyLjgwNDM0IDIwIDQuMzU5NTcgMjBIMTUuNjQxNkMxNy4xOTY4IDIwIDE4LjQ2MjEgMTguNzM0NyAxOC40NjIxIDE3LjE3OTVDMTguNDYyMSAxMy41NzU0IDE2LjE5NyAxMC40OTEgMTMuMDE1NyA5LjI3MzYzWk02LjQxMDg2IDUuMTI4MkM2LjQxMDg2IDMuMTQ4ODMgOC4wMjEyMSAxLjUzODQ4IDEwLjAwMDYgMS41Mzg0OEMxMS45OCAxLjUzODQ4IDEzLjU5MDMgMy4xNDg4MyAxMy41OTAzIDUuMTI4MkMxMy41OTAzIDcuMTA3NTggMTEuOTggOC43MTc5NyAxMC4wMDA2IDguNzE3OTdDOC4wMjEyMSA4LjcxNzk3IDYuNDEwODYgNy4xMDc1OCA2LjQxMDg2IDUuMTI4MlpNMTUuNjQxNiAxOC40NjE1SDQuMzU5NTdDMy42NTI2NiAxOC40NjE1IDMuMDc3NTQgMTcuODg2NCAzLjA3NzU0IDE3LjE3OTVDMy4wNzc1NCAxMy4zNjIgNi4xODMxNiAxMC4yNTY0IDEwLjAwMDYgMTAuMjU2NEMxMy44MTgxIDEwLjI1NjQgMTYuOTIzNyAxMy4zNjIgMTYuOTIzNyAxNy4xNzk1QzE2LjkyMzcgMTcuODg2NCAxNi4zNDg2IDE4LjQ2MTUgMTUuNjQxNiAxOC40NjE1WiIgZmlsbD0iIzMxNDE1OCIvPgo8L3N2Zz4K";function ft(e,t,n){const i=e.createElement("a");i.setAttribute("href",t.uri),t.uri.startsWith("http")&&i.setAttribute("target","_blank");const a=i.appendChild(e.createElement("img"));return a.setAttribute("src",n||it.i1+"go-to-this.png"),a.setAttribute("style","margin: 0.3em;"),i}const ht=(e,t,n)=>{const i=ft(e,n);t.appendChild(i).classList.add("HoverControlHide"),t.appendChild(e.createElement("br"))},{iconBase:gt}=it.Pt,bt=gt+"noun_1180156.svg",xt=gt+"noun_1180158.svg";function vt(e,t){if(!t)return;const n=function(e){let t=e&&e.statusArea||e&&e.div||null;if(t)return t;let n=e&&e.dom;if(n||"undefined"==typeof document||(n=document),n){const i=n.getElementsByTagName("body")[0];return t=n.createElement("div"),i.insertBefore(t,i.firstElementChild),e&&(e.statusArea=t),t}return null}(e);ve.Rm("Complaint: "+t),n?n.appendChild(nt(e&&e.dom||document,t)):alert(t)}function yt(e){for(;e.firstChild;)e.removeChild(e.firstChild);return e}function wt(e){const t=e.search(/logFile=/),n=e.search(/&rulesFile=/);return e.substring(t+8,n)}function Ct(e,t){if(!e)return"???";const n=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];try{const i=(new Date).toISOString();return e.slice(0,10)!==i.slice(0,10)||t?e.slice(0,4)===i.slice(0,4)?n[parseInt(e.slice(5,7),10)-1]+" "+parseInt(e.slice(8,10),10):e.slice(0,10):e.slice(11,16)}catch(e){return"shortdate:"+e}}function Et(e,t){return t.split("{").map(function(t){const n=t.split("}")[0];return t?("000"+(e["get"+n]()+({Month:1}[n]||0))).slice(-({Milliseconds:3,FullYear:4}[n]||2))+t.split("}")[1]:""}).join("")}function kt(){return Et(new Date,"{FullYear}-{Month}-{Date}T{Hours}:{Minutes}:{Seconds}.{Milliseconds}")}function At(){return Et(new Date,"{Hours}:{Minutes}:{Seconds}.{Milliseconds}")}function Tt(e,t){const n=x.store,i=function(e){const t=n.any(e,b.vcard("fn"))||n.any(e,b.foaf("name"))||n.any(e,b.vcard("organization-name"));return t?t.value:null},a=t.sameTerm(b.foaf("Agent"))?"Everyone":i(t);if(e.textContent=a||U(t),!a&&t.uri){if(!n.fetcher)throw new Error("kb has no fetcher");n.fetcher.nowOrWhenFetched(t.doc(),void 0,function(n){e.textContent=i(t)||U(t)})}}function jt(e,t){return t.each(e,b.sioc("avatar")).concat(t.each(e,b.foaf("img"))).concat(t.each(e,b.vcard("logo"))).concat(t.each(e,b.vcard("hasPhoto"))).concat(t.each(e,b.vcard("photo"))).concat(t.each(e,b.foaf("depiction")))}const _t={"solid:AppProviderClass":"noun_144.svg","solid:AppProvider":"noun_15177.svg","solid:Pod":"noun_Cabinet_1434380.svg","vcard:Group":"noun_339237.svg","vcard:Organization":"noun_143899.svg","vcard:Individual":mt,"schema:Person":mt,"foaf:Person":mt,"foaf:Agent":"noun_98053.svg","acl:AuthenticatedAgent":"noun_99101.svg","prov:SoftwareAgent":"noun_Robot_849764.svg","vcard:AddressBook":"noun_15695.svg","trip:Trip":"noun_581629.svg","meeting:LongChat":"noun_1689339.svg","meeting:Meeting":"noun_66617.svg","meeting:Project":"noun_1036577.svg","ui:Form":"noun_122196.svg","rdfs:Class":"class-rectangle.svg","rdf:Property":"property-diamond.svg","owl:Ontology":"noun_classification_1479198.svg","wf:Tracker":"noun_122196.svg","wf:Task":"noun_17020_gray-tick.svg","wf:Open":"noun_17020_sans-tick.svg","wf:Closed":"noun_17020.svg"};function Lt(e){const t=e.uri.split("#")[0],n=t.indexOf("//");if(n<0)throw new Error("This URI does not have a web site part (origin)");const i=t.indexOf("/",n+2);return i<0?t.slice(0)+"/":t.slice(0,i+1)}function St(e){const t=gt;return"string"!=typeof e&&e.uri?4!==e.uri.split("/").length||e.uri.split("/")[1]||e.uri.split("/")[3]?e.uri.startsWith("message:")||e.uri.startsWith("mid:")?t+"noun_480183.svg":e.uri.startsWith("mailto:")?t+"noun_567486.svg":e.uri.startsWith("https:")&&e.uri.indexOf("#")<0?Lt(e)+"favicon.ico":null:t+"noun_15177.svg":t+"noun_10636_grey.svg"}function Rt(e){const t=x.store,n=gt;if(e.sameTerm(b.foaf("Agent"))||e.sameTerm(b.rdf("Resource")))return n+"noun_98053.svg";const i=t.any(e,b.sioc("avatar"))||t.any(e,b.foaf("img"))||t.any(e,b.vcard("logo"))||t.any(e,b.vcard("hasPhoto"))||t.any(e,b.vcard("photo"))||t.any(e,b.foaf("depiction"));return i?i.uri:null}function Nt(e,t,n){const i=x.store,a=Rt(t);if(a)return e.setAttribute("src",a),!0;const o=n[t.uri];if(o)return e.setAttribute("src",o),e.style=Ke.classIconStyle,!0;const s=St(t);if(s)return e.setAttribute("src",s),!0;const r=i.findTypeURIs(t);for(const t in r)if(n[t])return e.setAttribute("src",n[t]),!1;return e.setAttribute("src",gt+"noun_10636_grey.svg"),!1}function It(e,t){const n=x.store,i={};for(const e in _t){const t=e.split(":")[0],n=e.split(":")[1],a=b[t](n),o=_t[e];o.startsWith("data:")?i[a.uri]=o:i[a.uri]=g.uri.join(o,gt)}if(!Nt(e,t,i)&&t.uri){if(!n.fetcher)throw new Error("kb has no fetcher");n.fetcher.nowOrWhenFetched(t.doc(),void 0,n=>{n&&Nt(e,t,i)})}}function Bt(e,t){const n=e.createElement("img");n.style=Ke.iconStyle;if(n.setAttribute("src",gt+(function(e){if(!e.uri)return!1;const t=e.uri.split("/");return 3===t.length||4===t.length&&""===t[3]}(t)?"noun_15177.svg":"noun_681601.svg")),t.uri&&t.uri.startsWith("https:")&&t.uri.indexOf("#")<0){const i=e.createElement("object");return i.setAttribute("data",Lt(t)+"favicon.ico"),i.setAttribute("type","image/x-icon"),i.appendChild(n),i}return It(n,t),n}function Dt(e,t,n,i){const a=gt+"noun_2188_red.svg",o=e.createElement("img");o.setAttribute("src",a),o.setAttribute("style",Ke.smallButtonStyle),o.style.float="right";const s="Remove this "+n;return o.title=s,o.classList.add("hoverControlHide"),o.addEventListener("click",function(){const n=e.createElement("div");t.insertBefore(n,o),n.style.position="relative",n.appendChild(function(e,t,n,i){function a(){t.parentElement.removeChild(t)}function o(){a(),i()}const s=e.createElement("div");s.style=Ke.confirmPopupStyle,s.style.position="absolute",s.style.top="-1em",s.style.display="grid",s.style.gridTemplateColumns="auto auto";const r=e.createElement("div");r.style.gridColumn="1/2",r.style.gridRow="1";const c=e.createElement("div");c.style.gridColumn="1/2",c.style.gridRow="2";const l=Mt(e,a);s.appendChild(l),l.style.gridColumn="1",l.style.gridRow="2";const p=s.appendChild(e.createElement("button"));p.style=Ke.buttonStyle,p.style.gridRow="2",p.style.gridColumn="2",p.textContent="Cancel";const u=Ot(e,it.Pt.iconBase+"noun_925021.svg","Delete it");s.appendChild(u),u.style.gridRow="1",u.style.gridColumn="1";const d=s.appendChild(e.createElement("button"));return d.style=Ke.buttonStyle,d.style.gridRow="1",d.style.gridColumn="2",d.textContent=n,s.appendChild(d),u.addEventListener("click",o),d.addEventListener("click",o),p.addEventListener("click",a),s}(e,n,s,i))}),t.classList.add("hoverControl"),t.appendChild(o),o.setAttribute("data-testid","deleteButtonWithCheck"),o}function Ot(e,t,n,i,a={buttonColor:"Primary",needsBorder:!1}){const o=e.createElement("button");if(o.setAttribute("type","button"),t){const i=o.appendChild(e.createElement("img"));i.setAttribute("src",t),i.setAttribute("style","width: 2em; height: 2em;"),i.title=n,o.setAttribute("style",Ke.buttonStyle)}else o.textContent=n.toLocaleUpperCase(),o.onmouseover=function(){"Secondary"===a.buttonColor?a.needsBorder?o.setAttribute("style",Ke.secondaryButtonNoBorderHover):o.setAttribute("style",Ke.secondaryButtonHover):a.needsBorder?o.setAttribute("style",Ke.primaryButtonNoBorderHover):o.setAttribute("style",Ke.primaryButtonHover)},o.onmouseout=function(){"Secondary"===a.buttonColor?a.needsBorder?o.setAttribute("style",Ke.secondaryButtonNoBorder):o.setAttribute("style",Ke.secondaryButton):a.needsBorder?o.setAttribute("style",Ke.primaryButtonNoBorder):o.setAttribute("style",Ke.primaryButton)},"Secondary"===a.buttonColor?a.needsBorder?o.setAttribute("style",Ke.secondaryButtonNoBorder):o.setAttribute("style",Ke.secondaryButton):a.needsBorder?o.setAttribute("style",Ke.primaryButtonNoBorder):o.setAttribute("style",Ke.primaryButton);return i&&o.addEventListener("click",i,!1),o}function Mt(e,t){const n=Ot(e,bt,"Cancel",t);return n.firstChild&&(n.firstChild.style.opacity="0.3"),n}function Ft(e,t){return Ot(e,xt,"Continue",t)}function zt(e,t,n,i,a,o){return new Promise(function(t,s){const r=e.createElement("div");i=i||b.foaf("name");const c=(o=o||(a?U(a):" "))+" "+U(i)+": ";r.appendChild(e.createElement("p")).textContent=c;const l=e.createElement("input");function p(){r.parentNode.removeChild(r),t(l.value.trim())}l.setAttribute("type","text"),l.setAttribute("size","100"),l.setAttribute("maxLength","2048"),l.setAttribute("style",Ke.textInputStyle),l.select(),r.appendChild(l),n.appendChild(r),l.addEventListener("keyup",function(e){13===e.keyCode&&p()},!1),r.appendChild(e.createElement("br")),r.appendChild(Mt(e,function(e){r.parentNode.removeChild(r),t(null)})),r.appendChild(Ft(e,function(e){p()})),l.focus()})}const Ut=Pt;function Pt(e,t,n,i){const a=e.createElement("tr");i=i||{};const o=a.appendChild(e.createElement("td")),s=a.appendChild(e.createElement("td")),r=a.appendChild(e.createElement("td")),c=i.image||Bt(e,n);o.setAttribute("style","vertical-align: middle; width:2.5em; padding:0.5em; height: 2.5em;"),s.setAttribute("style","vertical-align: middle; text-align:left;"),r.setAttribute("style","vertical-align: middle; width:2em; padding:0.5em; height: 4em;"),o.appendChild(c);const l=s.appendChild(e.createElement("div")),p=l.appendChild(e.createElement("span"));if(i.title?p.textContent=i.title:Tt(p,n),"function"==typeof i.renderNameSuffix){const t=i.renderNameSuffix(n,e);if(t){const n=l.appendChild(e.createElement("span"));n.setAttribute("style","margin-left: 0.4em; opacity: 0.8;"),"string"==typeof t?n.textContent=t:n.appendChild(t)}}if("function"==typeof i.renderSupportingInfo){const t=i.renderSupportingInfo(n,e);if(t){const n=s.appendChild(e.createElement("div"));n.setAttribute("style","font-size: 90%; opacity: 0.8;"),"string"==typeof t?n.textContent=t:n.appendChild(t)}}if(i.deleteFunction&&Dt(e,r,i.noun||"one",i.deleteFunction),n.uri){if(!1!==i.link){r.appendChild(ft(e,n)).classList.add("HoverControlHide"),r.appendChild(e.createElement("br"))}!1!==i.draggable&&(c.setAttribute("draggable","false"),et(a,n))}return a.subject=n,a}function $t(e,t,n,i){const a=t.appendChild(e.createElement("div"));n?a.textContent=n:Tt(a,i)}function qt(e,t,n,i){const a=t.appendChild(e.createElement("div"));a.setAttribute("style",Ke.linkDivStyle),i.deleteFunction&&Dt(e,a,i.noun||"one",i.deleteFunction),n.uri&&(!1!==i.link&&ht(e,a,n),et(t,n))}function Ht(e,t,n){const i=e.createElement("div");i.setAttribute("style",Ke.renderAsDivStyle);if(((e,t,n)=>{const i=t.appendChild(e.createElement("div"));i.setAttribute("style",Ke.imageDivStyle),i.appendChild(n),n.setAttribute("draggable","false")})(e,i,(n=n||{}).image||Bt(e,t)),$t(e,i,n.title,t),qt(e,i,t,n),n.clickable&&n.onClickFunction&&((e,t)=>{e.addEventListener("click",t)})(i,n.onClickFunction),n.wrapInATR){const n=((e,t,n)=>{const i=e.createElement("tr");return i.appendChild(e.createElement("td")).appendChild(t),i.subject=n,i})(e,i,t);return n}return i}function Gt(e){if(e.refresh)e.refresh();else for(let t=0;t<e.children.length;t++)Gt(e.children[t])}function Vt(e,t,n,i={}){const a=new Set,o=!(!i.renderSupportingInfo&&!i.renderNameSuffix),s=i.refreshOnDocumentLoad??!0;function r(n){const r=n,l={noun:h};if(l.renderSupportingInfo=i.renderSupportingInfo,l.renderNameSuffix=i.renderNameSuffix,o&&s&&n?.uri&&v.fetcher){const e=n.doc(),t=e?.uri?v.fetcher.requested?.[e.uri]:void 0,i="done"!==t&&"failed"!==t;e?.uri&&i&&!a.has(e.uri)&&(a.add(e.uri),v.fetcher.nowOrWhenFetched(e,void 0,()=>{a.delete(e.uri),c()}))}return d&&(l.deleteFunction=function(){!function(e){if(!v.updater)throw new Error("kb has no updater");v.updater.update((0,g.st)(t,f,e,u),[],function(e,t,n,i){t?c():vt(void 0,"Error deleting one: "+n)})}(r)}),Ut(e,f,n,l)}const c=function(){const e=v.each(t,f);e.sort(),Z(E,e,r,o?function(e,t){return r(t)}:void 0)};function l(e){const n=[];if(e.forEach(function(e){const i=(0,g.sym)(e);ve.Rm("Dropped on attachemnt "+e),n.push((0,g.st)(t,f,i,u))}),!v.updater)throw new Error("kb has no updater");v.updater.update([],n,function(e,t,n,i){t?c():vt(void 0,"Error adding one: "+n)})}function p(e){tt(v.fetcher,e,i.uploadFolder?.uri,i.uploadFolder?.uri,function(e,n){const i=[(0,g.st)(t,f,v.sym(n),u)];if(!v.updater)throw new Error("kb has no updater");v.updater.update([],i,function(e,t,n,i){t?c():vt(void 0,"Error adding link to uploaded file: "+n)})})}const u=i.doc||t.doc();void 0===i.modify&&(i.modify=!0);const d=i.modify,m=i.promptIcon||gt+"noun_748003.svg",f=i.predicate||b.wf("attachment"),h=i.noun||"attachment",v=x.store,y=n.appendChild(e.createElement("table"));y.setAttribute("style","margin-top: 1em; margin-bottom: 1em;");const w=y.appendChild(e.createElement("tr")),C=w.appendChild(e.createElement("td")),E=w.appendChild(e.createElement("td")).appendChild(e.createElement("table"));if(E.appendChild(e.createElement("tr")),y.refresh=c,c(),d){const t=Ot(e,m,"Drop attachments here");C.appendChild(t);const n=i.uploadFolder?p:null;Xe(t,l,n);const a=t.querySelector("img");if(a&&Xe(a,l,n),Xe(C,l,n),i.uploadFolder){const t=rn(e,p);C.appendChild(t)}}return y}function Wt(e){e.preventDefault(),e.stopPropagation();const t=ee(e).getAttribute("href");if(!t)return ve.Rm("openHrefInOutlineMode: No href found!\n");const n=window.document;n.outlineManager?n.outlineManager.GotoSubject(x.store.sym(t),!0,void 0,!0,void 0):window&&window.panes&&window.panes.getOutliner?window.panes.getOutliner().GotoSubject(x.store.sym(t),!0,void 0,!0,void 0):ve.Rm("ERROR: Can't access outline manager in this config")}function Jt(e){if(void 0===e.uri)return;let t=e.uri;if("http://"!==t.slice(0,7))return;t=t.slice(7);const n=t.indexOf("#");if(n>=0)t=t.slice(0,n);else{const e=t.lastIndexOf("/");if(e<0)return;t=t.slice(0,e)}return x.store.sym("http://tabulator.org/wiki/annnotation/"+t)}function Qt(){const e={};return x.store.statementsMatching(void 0,b.rdf("type"),void 0).forEach(function(t){t.object.value&&(e[t.object.value]=!0)}),x.store.statementsMatching(void 0,b.rdfs("subClassOf"),void 0).forEach(function(t){t.object.value&&(e[t.object.value]=!0),t.subject.value&&(e[t.subject.value]=!0)}),x.store.each(void 0,b.rdf("type"),b.rdfs("Class")).forEach(function(t){t.value&&(e[t.value]=!0)}),e}function Zt(e){const t={},n={},i={};let a=0,o=0,s=0;const r=e.predicateIndex;for(const e in r){"Literal"===r[e][0].object.termType?(n[e]=!0,o++):(i[e]=!0,a++)}const c=e.each(void 0,b.rdf("type"),b.rdf("Property"));for(let e=0;e<c.length;e++){const t=c[e].toNT();i[t]||n[t]||(n[t]=!0,i[t]=!0,s++)}return t.op=i,t.dp=n,_(`propertyTriage: ${a} non-lit, ${o} literal. ${s} unknown.`),t}function Yt(e,t){const n=e.createElement("button");return n.setAttribute("type","button"),n.textContent="Goto "+U(t),n.addEventListener("click",function(n){e.outlineManager.GotoSubject(t,!0,void 0,!0,void 0)},!0),n}function Kt(e,t){const n=e.createElement("button");return n.setAttribute("type","button"),n.textContent="✕",n.addEventListener("click",function(e){t.parentNode.removeChild(t)},!0),n}function Xt(e,t,n,i,a,o,s,r,c){return en(e.createElement("div"),e,t,n,i,a,o,s,r,c)}function en(e,t,n,i,a,o,s,r,c,l){const p="border: 0.1em solid #ddd; border-bottom: none; width: 95%; height: 2em; padding: 0.5em;";let u=null;e.innerHTML="";const d=function(e,s){let d,m;const f=function(){const e=o?n.each(void 0,a,s):n.each(s,a);x.setAttribute("class",0===e.length?"hideTillHover":""),m.setAttribute("src",r.connectIcon||gt+"noun_25830.svg"),m.setAttribute("title",e.length?e.length:"attach")},h=tn.twoLine.widgetForClass(i);d=h(t,s),d.setAttribute("style",p);const g=t.createElement("div");g.setAttribute("class","hideTillHover"),g.setAttribute("style","float:right; width:10%");const b=t.createElement("a");b.setAttribute("href",s.uri),b.setAttribute("style","float:right"),g.appendChild(b).textContent=">",e.appendChild(g);const x=t.createElement("div");return x.setAttribute("style",(o?"float:left;":"float:right;")+" width:30px;"),m=t.createElement("img"),f(),x.appendChild(m),e.appendChild(x),d.addEventListener("click",function(e){u===d?(d.setAttribute("style",p),u=null):(u&&u.setAttribute("style",p),d.setAttribute("style",p+"background-color: #ccc; color:black;"),u=d),c(s,e,u===d),f()},!1),m.addEventListener("click",function(e){l(s,e,o,f)},!1),e.appendChild(d),e};for(let n=0;n<s.length;n++){const i=t.createElement("div");e.appendChild(i),d(i,s[n])}return e}let tn={};function nn(e,t){const n=e.querySelectorAll("link");for(let e=0;e<n.length;e++)if("stylesheet"===(n[e].getAttribute("rel")||"")&&(n[e].getAttribute("href")||"")===t)return;const i=e.createElement("link");i.setAttribute("rel","stylesheet"),i.setAttribute("type","text/css"),i.setAttribute("href",t),e.getElementsByTagName("head")[0].appendChild(i)}function an(e){return sn(e,"audio")}function on(e){return sn(e,"video")}function sn(e,t){const n=t||"image",i=x.store.findTypeURIs(e),a=g.Util.mediaTypeClass(n+"/*").uri.split("*")[0];for(const e in i)if(e.startsWith(a))return!0;return{audio:"http://purl.org/dc/dcmitype/Sound",image:"http://purl.org/dc/dcmitype/Image",video:"http://purl.org/dc/dcmitype/MovingImage"}[n]in i}function rn(e,t){const n=e.createElement("div"),i=n.appendChild(e.createElement("input"));i.setAttribute("type","file"),i.setAttribute("multiple","true"),i.addEventListener("change",e=>{ve.Rm("File drop event: ",e),e.files?t(e.files):e.target&&e.target.files?t(e.target.files):alert("Sorry no files .. internal error?")},!1),i.style="display:none";return Xe(n.appendChild(Ot(e,gt+"noun_Upload_76574_000000.svg","Upload files",e=>{i.click()})),null,t),n}tn={line:{},twoLine:{"":function(e,t){const n=e.createElement("div");return n.textContent=U(t),n},"http://www.w3.org/2000/10/swap/pim/qif#Transaction":function(e,t){let n="";const i=function(e){const i=x.store.any(t,b.qu(e));return i||(n+="@@ No value for "+e+"! "),i?de(i.value):"?"},a=e.createElement("table");return a.innerHTML=`\n <tr>\n <td colspan="2"> ${i("payee")}</td>\n < /tr>\n < tr >\n <td>${i("date").slice(0,10)}</td>\n <td style = "text-align: right;">${i("amount")}</td>\n </tr>`,n&&(a.innerHTML=`\n <tr>\n <td><a href="${de(t.uri)}">${de(n)}</a></td>\n </tr>`),a},"http://www.w3.org/ns/pim/trip#Trip":function(e,t){const n=function(e){const n=x.store.any(t,e);return n?de(n.value):"?"},i=e.createElement("table");return i.innerHTML=`\n <tr>\n <td colspan="2">${n(b.dc("title"))}</td>\n </tr>\n <tr style="color: #777">\n <td>${n(b.cal("dtstart"))}</td>\n <td>${n(b.cal("dtend"))}</td>\n </tr>`,i},widgetForClass:function(e){let t=tn.twoLine[e.uri];const n=x.store;if(t)return t;const i=n.findSuperClassesNT(e);for(const e in i)if(t=tn.twoLine[n.fromNT(e).uri],t)return t;return tn.twoLine[""]}}};const cn={[b.ui("ColorField").uri]:{size:9,type:"color",style:"height: 3em;",dt:"color",pattern:/^\s*#[0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f]([0-9a-f][0-9a-f])?\s*$/},[b.ui("DateField").uri]:{size:20,type:"date",dt:"date",pattern:/^\s*[0-9][0-9][0-9][0-9](-[0-1]?[0-9]-[0-3]?[0-9])?Z?\s*$/},[b.ui("DateTimeField").uri]:{size:20,type:"datetime-local",dt:"dateTime",pattern:/^\s*[0-9][0-9][0-9][0-9](-[0-1]?[0-9]-[0-3]?[0-9])?(T[0-2][0-9]:[0-5][0-9](:[0-5][0-9])?)?Z?\s*$/},[b.ui("TimeField").uri]:{size:10,type:"time",dt:"time",pattern:/^\s*([0-2]?[0-9]:[0-5][0-9](:[0-5][0-9])?)\s*$/},[b.ui("IntegerField").uri]:{size:12,style:"text-align: right;",dt:"integer",pattern:/^\s*-?[0-9]+\s*$/},[b.ui("DecimalField").uri]:{size:12,style:"text-align: right;",dt:"decimal",pattern:/^\s*-?[0-9]*(\.[0-9]*)?\s*$/},[b.ui("FloatField").uri]:{size:12,style:"text-align: right;",dt:"float",pattern:/^\s*-?[0-9]*(\.[0-9]*)?((e|E)-?[0-9]*)?\s*$/},[b.ui("SingleLineTextField").uri]:{},[b.ui("NamedNodeURIField").uri]:{namedNode:!0},[b.ui("TextField").uri]:{},[b.ui("PhoneField").uri]:{size:20,uriPrefix:"tel:",pattern:/^\+?[\d-]+[\d]*$/},[b.ui("EmailField").uri]:{size:30,uriPrefix:"mailto:",pattern:/^\s*.*@.*\..*\s*$/},[b.ui("Group").uri]:{style:Ke.formGroupStyle},[b.ui("Comment").uri]:{element:"p",style:Ke.commentStyle},[b.ui("Heading").uri]:{element:"h3",style:Ke.formHeadingStyle}},ln=x.solidLogicSingleton.store,pn={};function un(e){const t=ln,n=t.findTypeURIs(e),i=t.bottomTypeURIs(n),a=[];for(const e in i)a.push(e);return a[0]}function dn(e,t){const n=un(t),i=pn[n];return j("paneUtils: Going to implement field "+t+" of type "+n),i||function(e,i){const a=nt(e,"No handler for field "+t+" of type "+n);return i&&i.appendChild(a),a}}const mn="https://www.w3.org/ns/css#";const fn=x.solidLogicSingleton.store;function hn(e,t,n,i,a){n.style.display="flex",n.style.flexDirection="row";const o=n.appendChild(e.createElement("div"));o.style.width=He;const s=n.appendChild(e.createElement("div"));return o.setAttribute("class","formFieldName"),o.setAttribute("style",Ke.formFieldNameBoxStyle),s.setAttribute("class","formFieldValue"),a?o.appendChild(e.createTextNode(a)):t.any(i,b.ui("property"))?o.appendChild(gn(e,t.any(i,b.ui("property")),i)):(s.appendChild(nt(e,"No property or label given for form field: "+i)),o.appendChild(e.createTextNode("???"))),s}function gn(e,t,n){let i=fn.any(n,b.ui("label"));if(i||(i=U(t,!0)),void 0===t)return e.createTextNode("@@Internal error: undefined property");const a=e.createElement("a");return t.uri&&a.setAttribute("href",t.uri),a.setAttribute("style","color: #3B5998; text-decoration: none;"),a.textContent=i,a}function bn(e,t,n){const i=fn.statementsMatching(e,t);if(0===i.length)return n;if(!fn.updater)throw new Error("Store has no updater");return i.length>0&&i[0].why.value&&fn.updater.editable(i[0].why.value,fn)?fn.sym(i[0].why.value):n}function xn(e,t,n,i,a,o,s){const r=fn,c=a.doc?a.doc():null,l=e.createElement("div"),p=r.any(a,b.ui("property"));if(t&&t.appendChild(l),!p)return l.appendChild(nt(e,"Error: No property given for text field: "+a));const u=hn(e,r,l,a),d=r.anyJS(a,b.ui("suppressEmptyUneditable"),null,c),m=un(a);let f=cn[m];void 0===f&&(f={style:""});const h=f.style||"",x=Ke.textInputStyle+h,v=e.createElement("input");v.style=x,u.appendChild(v),v.setAttribute("type",f.type?f.type:"text");const y=(v.getAttribute("type")||"").toLowerCase(),w="date"===y||"datetime-local"===y,C=r.anyJS(a,b.ui("size"))||Ge||20;v.setAttribute("size",C);const E=r.any(a,b.ui("maxLength"));v.setAttribute("maxLength",E?""+E:Ye),o=o||bn(i,p,o);let k=r.any(i,p,void 0,o);if(k||(k=r.any(a,b.ui("default"))),k&&k.value&&f.uriPrefix?v.value=decodeURIComponent(k.value.replace(f.uriPrefix,"")).replace(/ /g,""):k&&(v.value=k.value||k.value||""),v.setAttribute("style",x),!r.updater)throw new Error("kb has no updater");return r.updater.editable(o.uri)?(v.addEventListener("keyup",function(e){f.pattern&&v.setAttribute("style",x+(v.value.match(f.pattern)?"color: green;":"color: red;"))},!0),v.addEventListener("change",function(t){if(w&&e.activeElement===v)return void(v.dataset&&(v.dataset.deferredChange="true"));if(f.pattern&&!v.value.match(f.pattern))return;const n=!w;n&&(v.disabled=!0),v.setAttribute("style",x+"color: gray;");const a=r.statementsMatching(i,p);let c;f.namedNode?c=r.sym(v.value):f.uriPrefix?(c=encodeURIComponent(v.value.replace(/ /g,"")),c=r.sym(f.uriPrefix+v.value)):c=f.dt?new g.Literal(v.value.trim(),void 0,b.xsd(f.dt)):new g.Literal(v.value);let u=a.map(e=>(0,g.st)(e.subject,e.predicate,c,e.why));0===u.length&&(u=[(0,g.st)(i,p,c,o)]),function e(t,n,i){const a=[];if(n.forEach(e=>{a.includes(e.why.uri)||a.push(e.why.uri)}),t.forEach(e=>{a.includes(e.why.uri)||a.push(e.why.uri)}),0===a.length)throw new Error("updateMany has no docs to patch");if(!r.updater)throw new Error("kb has no updater");if(1===a.length)return r.updater.update(t,n,i);const o=a.pop(),s=n.filter(e=>e.why.uri===o),c=n.filter(e=>e.why.uri!==o),l=t.filter(e=>e.why.uri===o),p=t.filter(e=>e.why.uri!==o);r.updater.update(l,s,function(t,n,a){n?e(p,c,i):i(t,n,a)})}(a,u,function(t,i,a){i?(n&&(v.disabled=!1),v.setAttribute("style",x)):l.appendChild(nt(e,a)),s(i,a)})},!0),v.addEventListener("blur",function(e){if(w&&v.dataset&&"true"===v.dataset.deferredChange){delete v.dataset.deferredChange;const e=new Event("change",{bubbles:!0});v.dispatchEvent(e)}},!0),l):(v.readOnly=!0,v.style=Ke.textInputStyleUneditable+h,d&&""===v.value&&(l.style.display="none"),l)}const vn="https://www.w3.org/ns/iana/language-code/",yn=["en","fr","de","it","ar"];function wn(e){return e||(e=[]),e.concat(yn.filter(t=>!e.includes(t)))}async function Cn(e){const t=e.doc();await(x.store.fetcher?.load(t));const n=x.store.any(e,b.schema("knowsLanguage"),null,t);if(!n)return yn;const i=[];return n.elements.forEach(e=>{const n=x.store.any(e,b.solid("publicId"),null,t);if(!n)return void console.warn("getPreferredLanguages: No publiID of language.");if(!n.value.startsWith(vn))return void console.error(`What should be a language code ${n.value} does not start with ${vn}`);const a=n.value.slice(vn.length);i.push(a)}),i.length>0?(console.log(` User knows languages with codes: "${i.join(",")}"`),wn(i)):null}async function En(){const e=await x.authn.currentUser();if(e){const t=await Cn(e);if(t)return t}if("undefined"!=typeof navigator){if(navigator.languages)return wn(navigator.languages.map(e=>e.split("-")[0]));if(navigator.language)return wn([navigator.language.split("-")[0]])}return yn}function kn(e,t){const n={};e.forEach(e=>{const t=e.subject.value;n[t]=n[t]||[],n[t].push(e)});const i=t||yn;i.reverse();const a=[];for(const e in n){const t=n[e].map(e=>{const t=e.name["xml:lang"];return[i.indexOf(t),e]});t.sort(),t.reverse(),a.push(t[0][1])}return ve.Rm(` Filter by language: ${e.length} -> ${a.length}`),a}const An=200,Tn=/\$\(subject\)/g,jn={Corporation:"http://www.wikidata.org/entity/Q6881511",EducationalOrganization:"http://www.wikidata.org/entity/Q178706",GovernmentOrganization:"http://www.wikidata.org/entity/Q327333",MedicalOrganization:"http://www.wikidata.org/entity/Q4287745",MusicGroup:"http://www.wikidata.org/entity/Q32178211",NGO:"http://www.wikidata.org/entity/Q163740",Occupation:"http://www.wikidata.org/entity/Q28640",Project:"http://www.wikidata.org/entity/Q170584",ResearchOrganization:"http://www.wikidata.org/entity/Q31855",SportsOrganization:"http://www.wikidata.org/entity/Q4438121"},_n='prefix vcard: <http://www.w3.org/2006/vcard/ns#>\nCONSTRUCT\n{ wd:Q49108 vcard:fn ?itemLabel.\nwd:Q49108 rdf:type ?klass. ?klass rdfs:label ?klassLabel; rdfs:comment ?klassDescription .\nwd:Q49108 schema:logo ?logo;\n schema:image ?image;\n schema:logo ?sealImage;\n schema:subOrganization ?subsidiary .\n ?subsidiary rdfs:label ?subsidiaryLabel .\n ?supersidiary schema:subOrganization wd:Q49108 .\n ?supersidiary rdfs:label ?supersidiaryLabel .\n wd:Q49108 schema:location ?location .\n ?location schema:elevation ?elevation .\n ?location wdt:P131 ?region . ?region rdfs:label ?regionLabel .\n ?location wdt:P625 ?coordinates .\n ?location schema:country ?country . ?country rdfs:label ?countryLabel .\n}\nWHERE\n{ optional {wd:Q49108 rdfs:label ?itemLabel} .\n optional {wd:Q49108 wdt:P154 ?logo .}\n optional {wd:Q49108 wdt:P31 ?klass .}\n optional {wd:Q49108 wdt:P158 ?sealImage .}\n optional {wd:Q49108 wdt:P18 ?image .}\n\n optional { wd:Q49108 wdt:P355 ?subsidiary . }\n optional { ?supersidiary wdt:P355 wd:Q49108. }\n\n optional { wd:Q49108 wdt:P276 ?location .\n\n optional { ?location schema:eleveation ?elevation }\n optional { ?location wdt:P131 ?region }\n optional { ?location wdt:P625 ?coordinates }\n optional { ?location wdt:P17 ?country }\n }\n SERVICE wikibase:label { bd:serviceParam wikibase:language "fr,en,de,it". }\n}',Ln={credentials:"omit",headers:new Headers({Accept:"application/json"})},Sn={label:"ESCO",logo:x.store.sym("https://ec.europa.eu/esco/portal/static_resource2/images/logo/logo_en.gif"),searchByNameURI:"https://ec.europa.eu/esco/api/search?language=$(language)&type=occupation&text=$(name)"},Rn={label:"DBPedia",logo:x.store.sym("https://upload.wikimedia.org/wikipedia/commons/thumb/7/73/DBpediaLogo.svg/263px-DBpediaLogo.svg.png"),searchByNameQuery:'select distinct ?subject, ?name where {\n ?subject a $(targetClass); rdfs:label ?name\n FILTER regex(?name, "$(name)", "i")\n } LIMIT $(limit)',endpoint:"https://dbpedia.org/sparql/"},Nn={AcademicInsitution:"http://umbel.org/umbel/rc/EducationalOrganization"},In={AcademicInsitution:"http://www.wikidata.org/entity/Q4671277",Enterprise:"http://www.wikidata.org/entity/Q6881511",Business:"http://www.wikidata.org/entity/Q4830453",NGO:"http://www.wikidata.org/entity/Q79913",CharitableOrganization:"http://www.wikidata.org/entity/Q708676",Insitute:"http://www.wikidata.org/entity/Q1664720"},Bn={label:"WikiData",limit:3e3,logo:x.store.sym("https://www.wikimedia.org/static/images/project-logos/wikidatawiki.png"),endpoint:"https://query.wikidata.org/sparql",searchByNameQuery:'SELECT ?subject ?name\n WHERE {\n ?klass wdt:P279* $(targetClass) .\n ?subject wdt:P31 ?klass .\n ?subject rdfs:label ?name.\n FILTER regex(?name, "$(name)", "i")\n } LIMIT $(limit) ',insitituteDetailsQuery:'CONSTRUCT\n{ wd:Q49108 schema:name ?itemLabel;\n schema:logo ?logo;\n schema:logo ?sealImage;\n schema:subOrganization ?subsidiary .\n ?subsidiary schema:name ?subsidiaryLabel .\n}\nWHERE\n{\n wd:Q49108 # rdfs:label ?itemLabel ;\n wdt:P154 ?logo;\n wdt:P158 ?sealImage ;\n wdt:P355 ?subsidiary .\n # ?subsidiary rdfs:label ?subsidiaryLabel .\n\n SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE], fr". }\n}'},Dn={"http://www.wikidata.org/entity/Q15936437":b.schema("CollegeOrUniversity"),"http://www.wikidata.org/entity/Q1664720":b.schema("EducationalOrganization"),"http://www.wikidata.org/entity/Q43229":b.schema("Organization"),"http://www.wikidata.org/entity/Q3918":b.schema("CollegeOrUniversity"),"http://www.wikidata.org/entity/Q170584":b.schema("Project"),"http://www.wikidata.org/entity/Q327333":b.schema("GovernmentOrganization"),"http://www.wikidata.org/entity/Q2221906":b.schema("Place"),"http://www.wikidata.org/entity/Q167037":b.schema("Corporation")},On={targetClass:b.rdf("type"),sealImage:b.schema("logo"),shortName:b.foaf("nick"),subsidiary:b.schema("subOrganization"),city:b.vcard("locality"),state:b.vcard("region"),country:b.vcard("country-name"),homepage:b.foaf("homepage"),lat:b.schema("latitude"),long:b.schema("longitude")};function Mn(e){const t=e.type.toLowerCase();if("uri"===t||"iri"===t)return x.store.sym(e.value);if("literal"===t)return e["xml:lang"]?new g.Literal(e.value,e["xml:lang"]):new g.Literal(e.value);throw new Error(`bindingToTerm: Unexpected type "${e.type}" in sparql binding}`)}function Fn(e,t,n,i,a=On){const o={};ve.Rm(`loadFromBindings: subject: ${t}`),ve.Rm(` doc: ${i}`),n.forEach(e=>{for(const t in e){const n=e[t],i=JSON.stringify(n);o[t]=o[t]||new Set,o[t].add(i)}});for(const n in o){const s=o[n];ve.Rm(` results ${n} -> ${s}`),s.forEach(o=>{const s=JSON.parse(o),{type:r,value:c}=s;let l;if("uri"===r)l=e.sym(c);else{if("literal"!==r)throw new Error(`loadFromBindings: unexpected type: ${r}`);l=new g.Literal(c,s.language,s.datatype)}if("type"===n)Dn[c]?l=Dn[c]:ve.R8("Unmapped Wikidata Class: "+c);else if("coordinates"===n){ve.Rm(" @@@ hey a point: "+c);const n=/.*\(([-0-9.-]*) ([-0-9.-]*)\)/.exec(c);if(n){const a=b.xsd("float"),o=new g.Literal(n[1],null,a),s=new g.Literal(n[2],null,a);e.add(t,b.schema("longitude"),s,i),e.add(t,b.schema("latitude"),o,i)}else ve.Rm("Bad coordinates syntax: "+c)}else{const o=a[n]||b.schema(n);e.add(t,o,l,i),ve.Rm(` public data ${o} ${l}.`)}})}}function zn(e){return e._embedded.results.map(e=>({name:{value:e.title,type:"literal"},subject:{type:"IRI",value:e.uri}}))}async function Un(e,t,n){if(!n.searchByNameURI)throw new Error("Missing queryTarget.searchByNameURI on queryESCODataByName");const i=n.limit||An,a=n.searchByNameURI.replace("$(name)",e).replace("$(limit)",""+i).replace("$(targetClass)",t.toNT());ve.Rm("Querying ESCO data - uri: "+a);const o=await(x.store.fetcher?.webOperation("GET",a,Ln)),s=o?.responseText||"";if(ve.Rm(" Query result text"+s.slice(0,500)+"..."),0===s.length)throw new Error("Wot no text back from ESCO query "+a);const r=JSON.parse(s);return ve.Rm(" ESCO Query result JSON"+JSON.stringify(r,null,4).slice(0,500)+"..."),zn(r)}function Pn(e){const t=e.indexOf("SPARQL-QUERY");if(t<0)return e;ve.R8(" ### Fixing JSON with wikidata error code injection "+e.slice(t,t+200));const n=e.lastIndexOf("}, {");return e.slice(0,n)+" } ] } } "}async function $n(e,t,n,i){function a(n){const a=i.limit||An;return n.replace("$(name)",e).replace("$(limit)",""+a).replace("$(language)",o).replace("$(targetClass)",t.toNT())}if(!t)throw new Error("queryPublicDataByName: No class provided");const o=(await En()||yn)[0]||"en";if(i.searchByNameQuery){const e=a(i.searchByNameQuery);return ve.Rm("Querying public data - sparql: "+e),qn(e,i)}if(i.searchByNameURI){const e=a(i.searchByNameURI);let t;try{t=await(x.store.fetcher?.webOperation("GET",e,Ln))}catch(t){throw new Error(`Exception when trying to fetch ${e} \n ${t}`)}const n=t.responseText||"";if(200!==t.status)throw new Error(`HTTP error status ${t.status} trying to fetch ${e} `);if(ve.Rm(" Query result text"+n.slice(0,500)+"..."),0===n.length)throw new Error("queryPublicDataByName: No text back from public data query "+e);const o=Pn(n),s=JSON.parse(o);if(ve.Rm(" API Query result JSON"+JSON.stringify(s,null,4).slice(0,500)+"..."),s._embedded){ve.Rm(" Looks like ESCO");return zn(s)}throw alert("Code me: unrecognized API return format"),new Error(`*** Need to add code to parse unrecognized API JSON return\n${JSON.stringify(s,null,4)}`)}throw new Error("Query source must have either rest API or SPARQL endpoint.")}async function qn(e,t){if(!t.endpoint)throw new Error("Missing queryTarget.endpoint required for queryPublicDataSelect");const n=new URL(t.endpoint);n.searchParams.append("query",e);const i=n.href;ve.Rm(" queryPublicDataSelect uri: "+i);const a=new Headers;a.append("Accept","application/json");const o={credentials:"omit",headers:a},s=await(x.store.fetcher?.webOperation("GET",i,o)),r=s?.responseText||"";if(0===r.length)throw new Error("No text back from query "+i);const c=Pn(r),l=JSON.parse(c);ve.Rm(" Query result JSON"+JSON.stringify(l,null,4).slice(0,100)+"...");return l.results.bindings}async function Hn(e,t,n){if(ve.Rm("queryPublicDataConstruct: sparql:",e),!n.endpoint)throw new Error("Missing queryTarget.endpoint required for queryPublicDataConstruct");const i=new URL(n.endpoint);i.searchParams.append("query",e);const a=i.href;ve.Rm(" queryPublicDataConstruct uri: "+a);const o=new Headers;o.append("Accept","text/turtle");const s={credentials:"omit",headers:o},r=await(x.store.fetcher?.webOperation("GET",a,s)),c=r?.responseText||"No response text?",l=c.length>500?c.slice(0,200)+" ... "+c.slice(-200):c;if(ve.Rm(" queryPublicDataConstruct result text:"+l),0===c.length)throw new Error("queryPublicDataConstruct: No text back from construct query:"+a);(0,g.parse)(c,x.store,t.uri,"text/turtle")}async function Gn(e,t,n){if(n.uri.startsWith("https://dbpedia.org/resource/"))return Qn(e,t,n);if(!n.uri.match(/^https?:\/\/www\.wikidata\.org\/entity\/.*/)){const t=n.uri.startsWith("http:")?e.sym("https:"+n.uri.slice(5)):n,i=new Headers;return i.append("Accept","text/turtle"),e.fetcher.load(t,{credentials:"omit",headers:i})}await Vn(e,t,n)}async function Vn(e,t,n){const i=_n.replace(/wd:Q49108/g,n.toNT());await Hn(i,n,Bn),ve.Rm("getWikidataDetails: loaded.",n)}async function Wn(e,t,n){const i='select distinct * where {\n optional { $(subject) wdt:P31 ?targetClass } # instance of\n optional { $(subject) wdt:P154 ?logo }\n optional { $(subject) wdt:P158 ?sealImage }\n# optional { $(subject) wdt:P159 ?headquartersLocation }\n\noptional { $(subject) wdt:P17 ?country }\noptional { $(subject) wdt:P18 ?image }\noptional { $(subject) wdt:P1813 ?shortName }\n\noptional { $(subject) wdt:P355 ?subsidiary }\n# SERVICE wikibase:label { bd:serviceParam wikibase:language "fr,en,de,it" }\n}'.replace(Tn,n.toNT());Fn(e,n,await qn(i,Bn),n.doc())}async function Jn(e,t,n){const i='select distinct * where {\n\n $(subject) wdt:P276 ?location .\n\n optional { ?location wdt:P2044 ?elevation }\n optional { ?location wdt:P131 ?region }\n optional { ?location wdt:P625 ?coordinates }\noptional { ?location wdt:P17 ?country }\n\n# SERVICE wikibase:label { bd:serviceParam wikibase:language "fr,en,de,it" }\n}'.replace(Tn,n.toNT());ve.Rm(" location query sparql:"+i);const a=await qn(i,Bn);ve.Rm(" location query bindings:",a),Fn(e,n,a,n.doc())}async function Qn(e,t,n){const i=`select distinct ?city, ?state, ?country, ?homepage, ?logo, ?lat, ?long, WHERE {\n OPTIONAL { <${n}> <http://dbpedia.org/ontology/city> ?city }\n OPTIONAL { ${n} <http://dbpedia.org/ontology/state> ?state }\n OPTIONAL { ${n} <http://dbpedia.org/ontology/country> ?country }\n OPTIONAL { ${n} foaf:homepage ?homepage }\n OPTIONAL { ${n} foaf:lat ?lat; foaf:long ?long }\n OPTIONAL { ${n} <http://dbpedia.org/ontology/country> ?country }\n }`;Fn(e,n,await qn(i,Rn),n.doc()),ve.Rm("Finished getDbpediaDetails.")}function Zn(e,t){e.style.display=t?"":"none"}async function Yn(e,t,n,i){function a(e,n){ve.Rm("Auto complete: finish! "+e),"Literal"===e.termType&&t.queryParams.objectURIBase&&(e=x.store.sym(t.queryParams.objectURIBase.value+e.value)),r(),i(e,n)}async function o(e,t){if(n.acceptButton)return n.acceptButton.disbaled=!1,Zn(n.acceptButton,!0),C.value=t.value,b=t,v=e,ve.Rm("Auto complete: name: "+t),ve.Rm("Auto complete: waiting for accept "+e),void r();Zn(n.cancelButton,!0),a(e,t)}async function s(e){b&&C.value===b.value&&a(v,b)}function r(){for(;y.children.length>1;)y.removeChild(y.lastChild)}function c(){t.currentObject?(C.value=t.currentName?t.currentName.value:"??? wot no name for "+t.currentObject,b=t.currentName,u=t.currentName?t.currentName.value:void 0,v=t.currentObject):(C.value="",u=void 0,v=void 0),n.deleteButton&&Zn(n.deleteButton,!!t.currentObject),n.acceptButton&&Zn(n.acceptButton,!1),n.editButton&&Zn(n.editButton,!0),n.cancelButton&&Zn(n.cancelButton,!1),m=!1,r()}const l=t.targetClass;if(!l)throw new Error("renderAutoComplete: missing targetClass");let p;n.acceptButton&&n.acceptButton.addEventListener("click",s,!1),n.cancelButton&&n.cancelButton.addEventListener("click",async function(e){ve.Rm("Auto complete: Canceled by user! "),t.permanent?c():g.parentNode&&g.parentNode.removeChild(g)},!1);let u,d=!1,m=!1,f=!1,h=20;const g=e.createElement("div");let b,v;const y=g.appendChild(e.createElement("table"));y.setAttribute("data-testid","autocomplete-table"),y.setAttribute("style","max-width: 30em; margin: 0.5em;");const w=y.appendChild(e.createElement("tr"));Ke.setStyle(w,"autocompleteRowStyle");const C=w.appendChild(e.createElement("td")).appendChild(e.createElement("input"));C.setAttribute("type","text"),c();const E=t.size||Ge||20;C.setAttribute("size",E),C.setAttribute("data-testid","autocomplete-input");const k=Ke.textInputStyle||"border: 0.1em solid #444; border-radius: 0.5em; width: 100%; font-size: 100%; padding: 0.1em 0.6em";return C.setAttribute("style",k),C.addEventListener("keyup",function(e){13===e.keyCode&&s()},!1),C.addEventListener("input",async function(i){Zn(n.cancelButton,!0),async function(){function n(t){const n=e.createElement("tr");Ke.setStyle(n,"autocompleteRowStyle"),n.setAttribute("style","padding: 0.3em;"),n.style.color=f?"#080":"#088",n.textContent=t.name.value;const i=Mn(t.subject),a=Mn(t.name);return n.addEventListener("click",async e=>{ve.Rm(" click row textContent: "+n.textContent),ve.Rm(" click name: "+a.value),i&&a&&o(i,a)}),n}function i(e,t){return t.name.value>e.name.value?1:t.name.name<e.name.value?-1:0}if(m)return void ve.Rm(`Ignoring "${C.value}" because of lock `);ve.Rm(`Setting lock at "${C.value}"`),m=!0;const a=await En(),s=C.value.trim().toLowerCase();if(s.length<4)r(),h=20;else{f&&u&&s.startsWith(u)||(ve.Rm(` Querying database at "${s}" cf last "${u}".`),p=await async function(n,i){let a;try{a=await $n(n,l,0,t.queryParams)}catch(t){return function(t){const n=y.appendChild(e.createElement("tr"));ve.Rm(t);const i=new Error(t);n.appendChild(nt(e,i,"pink")),Ke.setStyle(n,"autocompleteRowStyle"),n.style.padding="1em"}("Error querying db of organizations: "+t),void(m=!1)}d=a.length<An,u=d?n:void 0;r();const o=kn(a,i);return o}(s,a));const c=function(e,t){return t.filter(t=>function(e,t){const n=e.split(" ");for(let e=0;e<n.length;e++){const i=n[e];if(t.toLowerCase().indexOf(i)<0)return!1}return!0}(e,t.name.value))}(s,p);d&&c.length<=40&&(h=c.length),f=d&&c.length<=h,ve.Rm(` Filter:"${s}" lastBindings: ${p.length}, slimmed to ${c.length}; rows: ${h}, Enough? ${d}, All displayed? ${f}`);const g=c.slice(0,h);g.sort(i),r();for(const e of g)y.appendChild(n(e));1===c.length&&o(Mn(c[0].subject),Mn(c[0].name))}m=!1}()}),g}const Kn=it.Pt.iconBase+"noun_34653_green.svg",Xn=it.Pt.iconBase+"noun_Search_875351.svg",ei=it.Pt.iconBase+"noun_253504.svg";async function ti(e,t,n,i,a,o){async function s(e,t){return i.permanent?(Zn(m,!0),Zn(c,!1),Zn(l,!1)):v&&(y.removeChild(v),v=void 0),a(e,t)}async function r(){v=e.createElement("div"),v.setAttribute("style","display: flex; flex-flow: wrap;"),v.appendChild(await Yn(e,i,g,s)),v.appendChild(c),v.appendChild(l),v.appendChild(m),v.appendChild(p),y.appendChild(v)}const c=Ft(e);c.setAttribute("data-testid","accept-button");const l=Mt(e);l.setAttribute("data-testid","cancel-button");const p=e.createElement("div"),u=i.targetClass?U(i.targetClass):"item",d=Dt(e,p,u,o);d.setAttribute("data-testid","delete-button");const m=Ot(e,ei,"Edit",e=>{f=!f,h()});m.setAttribute("data-testid","edit-button");let f=!0;function h(){f?(Zn(m,!1),Zn(c,!1),Zn(l,!1)):(Zn(m,!0),Zn(c,!1),Zn(l,!1))}const g={acceptButton:c,cancelButton:l,editButton:m,deleteButton:d};let v;const y=e.createElement("div");if(y.style.display="flex",y.style.flexDirection="row",(i.permanent||i.currentObject)&&await r(),n.editable){if(y.style.width="100%",n.manualURIEntry){Xe(y.appendChild(Ot(e,Kn,n.idNoun,async function(n){const i=await zt(e,x.store,y,b.vcard("url"),void 0,"Solid ID");if(i)return a(t,i)})),async function(e){for(const n of e)await a(t,n)},void 0)}!n.dbLookup||i.currentObject||i.permanent||y.appendChild(Ot(e,Xn,n.idNoun,async function(e){v?(y.removeChild(v),v=void 0):await r()}))}return h(),y}
|
|
4
4
|
/**
|
|
5
5
|
* @version IconicMultiSelect v0.7.0
|
|
6
6
|
* @licence MIT
|
|
@@ -10,15 +10,15 @@ const ni={multiselect__container:"\n -webkit-box-align: center;\n
|
|
|
10
10
|
* @version IconicMultiSelect v0.7.0
|
|
11
11
|
* @licence MIT
|
|
12
12
|
*/
|
|
13
|
-
class ii{_data;_domElements;_event=()=>{};_itemTemplate;_multiselect;_noData;_noResults;_options=[];_placeholder;_select;_selectContainer;_selectedOptions=[];_tagTemplate;_textField;_valueField;_cross='\n <svg\n width="24"\n height="24"\n viewBox="0 0 24 24"\n fill="none"\n xmlns="http://www.w3.org/2000/svg"\n >\n <path\n d="M6.2253 4.81108C5.83477 4.42056 5.20161 4.42056 4.81108 4.81108C4.42056 5.20161 4.42056 5.83477 4.81108 6.2253L10.5858 12L4.81114 17.7747C4.42062 18.1652 4.42062 18.7984 4.81114 19.1889C5.20167 19.5794 5.83483 19.5794 6.22535 19.1889L12 13.4142L17.7747 19.1889C18.1652 19.5794 18.7984 19.5794 19.1889 19.1889C19.5794 18.7984 19.5794 18.1652 19.1889 17.7747L13.4142 12L19.189 6.2253C19.5795 5.83477 19.5795 5.20161 19.189 4.81108C18.7985 4.42056 18.1653 4.42056 17.7748 4.81108L12 10.5858L6.2253 4.81108Z"\n fill="currentColor"\n />\n </svg>\n ';constructor({data:e,itemTemplate:t,noData:n,noResults:i,placeholder:a,select:o,container:s,tagTemplate:r,textField:c,valueField:l}){this._data=e??[],this._itemTemplate=t??null,this._noData=n??"No data found.",this._noResults=i??"No results found.",this._placeholder=a??"Select...",this._select=o,this._selectContainer=s,this._tagTemplate=r??null,this._textField=c??null,this._valueField=l??null}init(){if(!this._select||"SELECT"!==this._select.nodeName)throw new Error(`The selector '${this._select}' did not select any valid select tag.`);if(this._itemTemplate&&0===this._data.length)throw new Error("itemTemplate must be initialized with data from the component settings");if(this._tagTemplate&&0===this._data.length)throw new Error("tagTemplate must be initialized with data from the component settings");this._options=this._data.length>0?this._getDataFromSettings():this._getDataFromSelectTag(),this._renderMultiselect(),this._renderOptionsList(),this._domElements={clear:this._multiselect.querySelector(".multiselect__clear-btn"),input:this._multiselect.querySelector(".multiselect__input"),optionsContainer:this._multiselect.querySelector(".multiselect__options"),optionsContainerList:this._multiselect.querySelector(".multiselect__options > ul"),options:{list:this._multiselect.querySelectorAll(".multiselect__options > ul > li"),find:function(e){for(let t=0;t<this.list.length;t++){const n=this.list[t];if(e(n))return n}},some:function(e){for(let t=0;t<this.list.length;t++){if(e(this.list[t],t))return!0}return!1}}},this._enableEventListenners(),this._initSelectedList()}subscribe(e){if("function"!=typeof e)throw new Error("parameter in the subscribe method is not a function");this._event=e}_addOptionToList(e,t){const n=`<span class="multiselect__selected" style="${ni.multiselect__selected}" data-value="${e.value}">${this._tagTemplate?this._processTemplate(this._tagTemplate,t):e.text}<span class="multiselect__remove-btn" style="${ni.multiselect__remove_btn}">${this._cross}</span></span>`;this._domElements.input.insertAdjacentHTML("beforebegin",n);const{lastElementChild:i}=this._multiselect.querySelector(`span[data-value="${e.value}"]`);i.addEventListener("click",()=>{const t=this._domElements.options.find(t=>t.dataset.value===e.value);this._handleOption(t)})}_clearSelection(){for(let e=0;e<this._selectedOptions.length;e++){const t=this._selectedOptions[e],n=this._domElements.options.find(e=>e.dataset.value===t.value);n.classList.remove("multiselect__options--selected"),n.setAttribute("style",ni.multiselect__options),this._removeOptionFromList(n.dataset.value)}this._selectedOptions=[],this._handleClearSelectionBtn(),this._handlePlaceholder(),this._dispatchEvent({action:"CLEAR_ALL_OPTIONS",selection:this._selectedOptions})}_closeList(){this._domElements.input.value="",this._domElements.optionsContainer.classList.remove("visible"),this._domElements.optionsContainer.setAttribute("style",ni.multiselect__options),this._filterOptions(""),this._removeAllArrowSelected()}_dispatchEvent(e){this._event(e)}_enableEventListenners(){document.addEventListener("mouseup",({target:e})=>{this._multiselect.contains(e)||(this._filterOptions(""),this._closeList(),this._handlePlaceholder())}),this._domElements.clear.addEventListener("click",()=>{this._clearSelection()});for(let e=0;e<this._domElements.options.list.length;e++){this._domElements.options.list[e].addEventListener("click",({target:e})=>{this._handleOption(e),this._closeList()})}this._domElements.input.addEventListener("focus",()=>{this._domElements.optionsContainer.classList.add("visible"),this._domElements.optionsContainer.setAttribute("style",ni.multiselect__options_visible)}),this._domElements.input.addEventListener("input",({target:{value:e}})=>{this._domElements.options.list.length>0&&this._filterOptions(e)}),this._domElements.input.addEventListener("keydown",e=>{this._handleArrows(e),this._handleBackspace(e),this._handleEnter(e)})}_filterOptions(e){const t=this._domElements.optionsContainer.classList.contains("visible"),n=e.toLowerCase();if(!t&&e.length>0&&(this._domElements.optionsContainer.classList.add("visible"),this._domElements.optionsContainer.setAttribute("style",ni.multiselect__options_visible)),this._domElements.options.list.length>0){for(let e=0;e<this._domElements.options.list.length;e++){const t=this._domElements.options.list[e];(this._itemTemplate?this._data[e][this._textField]:t.textContent).toLowerCase().substring(0,n.length)===n?this._domElements.optionsContainerList.appendChild(t):t.parentNode&&t.parentNode.removeChild(t)}const e=this._domElements.options.some((e,t)=>(this._itemTemplate?this._data[t][this._textField]:e.textContent).toLowerCase().substring(0,n.length)===n);this._showNoResults(!e)}}_generateId(e){let t="";const n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";for(let i=0;i<e;i++)t+=n.charAt(Math.floor(62*Math.random()));return t}_getDataFromSelectTag(){const e=[],{options:t}=this._select;for(let n=0;n<t.length;n++){const i=t[n];e.push({text:i.text,value:i.value,selected:i.hasAttribute("selected")})}return e}_getDataFromSettings(){if(this._data.length>0&&this._valueField&&this._textField){const e="string"==typeof this._valueField,t="string"==typeof this._textField,n=[];if(!e||!t)throw new Error("textField and valueField must be of type string");for(let e=0;e<this._data.length;e++){const t=this._data[e];n.push({value:t[this._valueField],text:t[this._textField],selected:"boolean"==typeof t.selected&&t.selected})}return n}return null}_handleArrows(e){if(40===e.keyCode||38===e.keyCode){e.preventDefault();const t=this._domElements.optionsContainer.classList.contains("visible"),n=this._multiselect.querySelector(".multiselect__options > ul");if(t){let t=this._multiselect.querySelector(".multiselect__options ul li.arrow-selected");const i={ArrowUp:"previous",Up:"previous",ArrowDown:"next",Down:"next"};if(!t)return n.firstElementChild.classList.add("arrow-selected"),n.firstElementChild.setAttribute("style",ni.multiselect__options_ul_li_arrow_selected),void n.firstElementChild.scrollIntoView(!1);if(t.classList.remove("arrow-selected"),t.setAttribute("style",ni.multiselect__options_ul_li),t=t[i[e.key]+"ElementSibling"],!t)return t=n.children["next"===i[e.key]?0:n.children.length-1],t.classList.add("arrow-selected"),t.setAttribute("style",ni.multiselect__options_ul_li_arrow_selected),void this._scrollIntoView(n,t);t.classList.add("arrow-selected"),t.setAttribute("style",ni.multiselect__options_ul_li_arrow_selected),this._scrollIntoView(n,t)}else this._domElements.optionsContainer.classList.add("visible"),this._domElements.optionsContainer.setAttribute("style",ni.multiselect__options_visible),n.firstElementChild.classList.add("arrow-selected"),n.firstElementChild.setAttribute("style",ni.multiselect__options_ul_li_arrow_selected),n.firstElementChild.scrollIntoView(!1)}}_handleBackspace(e){if(8===e.keyCode&&""===e.target.value){const e=this._selectedOptions.length>0?this._selectedOptions[this._selectedOptions.length-1]:null;if(e){const t=this._multiselect.querySelector(`li[data-value="${e.value}"]`);this._handleOption(t),0===this._selectedOptions.length&&(this._domElements.optionsContainer.classList.remove("visible"),this._domElements.optionsContainer.setAttribute("style",ni.multiselect__options))}}}_handleClearSelectionBtn(){this._selectedOptions.length>0?this._domElements.clear.style.display="flex":this._domElements.clear.style.display="none"}_handleEnter(e){if(13===e.keyCode){const e=this._multiselect.querySelector(".multiselect__options ul li.arrow-selected");e&&(this._handleOption(e),this._closeList())}}_handleOption(e,t=!0){for(let n=0;n<this._selectedOptions.length;n++){if(this._selectedOptions[n].value===e.dataset.value)return e.classList.remove("multiselect__options--selected"),e.setAttribute("style",ni.multiselect__options),this._selectedOptions.splice(n,1),this._removeOptionFromList(e.dataset.value),this._handleClearSelectionBtn(),this._handlePlaceholder(),t&&this._dispatchEvent({action:"REMOVE_OPTION",value:e.dataset.value,selection:this._selectedOptions})}for(let n=0;n<this._options.length;n++){const i=this._options[n];if(i.value===e.dataset.value)return e.classList.add("multiselect__options--selected"),e.setAttribute("style",ni.multiselect__options_selected),this._selectedOptions=[...this._selectedOptions,i],this._addOptionToList(i,n),this._handleClearSelectionBtn(),this._handlePlaceholder(),t&&this._dispatchEvent({action:"ADD_OPTION",value:e.dataset.value,selection:this._selectedOptions})}}_handlePlaceholder(){this._domElements.input.placeholder=this._placeholder}_initSelectedList(){let e=!1;for(let t=0;t<this._options.length;t++){const n=this._options[t];if(n.selected){e=!0;const i=this._domElements.options.find(e=>e.dataset.value===n.value);i.classList.add("multiselect__options--selected"),i.setAttribute("style",ni.multiselect__options_selected),this._selectedOptions=[...this._selectedOptions,n],this._addOptionToList(n,t)}}e&&this._handleClearSelectionBtn(),this._handlePlaceholder()}_processTemplate(e,t){let n=e;const i=e.match(/\$\{(\w+)\}/g).map(e=>e.replace(/\$\{|\}/g,""));for(let e=0;e<i.length;e++){const a=i[e];n=n.replace(`\${${a}}`,this._data[t][a]??"")}return n}_removeAllArrowSelected(){const e="arrow-selected",t=this._domElements.options.find(t=>t.classList.contains(e));t&&t.classList.remove(e)&&t.setAttribute("style",ni.multiselect__options_ul_li)}_removeOptionFromList(e){const t=this._multiselect.querySelector(`span[data-value="${e}"]`);t&&t.parentNode&&t.parentNode.removeChild(t)}_renderOptionsList(){const e=`\n <div class="multiselect__options" style="${ni.multiselect__options}">\n <ul style="${ni.multiselect__options_ul}">\n ${this._options.length>0&&!this._itemTemplate?this._options.map(e=>`\n <li data-value="${e.value}" style="${ni.multiselect__options_ul_li}">${e.text}</li>\n `).join(""):""}\n\n ${this._options.length>0&&this._itemTemplate?this._options.map((e,t)=>`\n <li data-value="${e.value}" style="${ni.multiselect__options_ul_li}">${this._processTemplate(this._itemTemplate,t)}</li>\n `).join(""):""}\n ${this._showNoData(0===this._options.length)}\n </ul>\n </div>\n `;this._multiselect.insertAdjacentHTML("beforeend",e)}_renderMultiselect(){this._select.style.display="none";const e="iconic-"+this._generateId(20);this._multiselect=document.createElement("div"),this._multiselect.setAttribute("id",e),this._multiselect.setAttribute("class","multiselect__container"),this._multiselect.setAttribute("style",ni.multiselect__container);const t=`\n <div class="multiselect__wrapper" style="${ni.multiselect__wrapper}">\n <input class="multiselect__input" style="${ni.multiselect__input}" placeholder="${this._placeholder}" />\n </div>\n <span style="display: none;" class="multiselect__clear-btn" style="${ni.multiselect__clear_btn}">${this._cross}</span>\n `;this._multiselect.innerHTML=t,this._selectContainer.appendChild(this._multiselect)}_scrollIntoView(e,t){const n=e.getBoundingClientRect(),i=t.getBoundingClientRect();n.top<i.bottom-t.offsetHeight||(e.scrollTop=t.clientHeight+(t.offsetTop-t.offsetHeight)),n.bottom>i.top+t.offsetHeight||(e.scrollTop=t.clientHeight+(t.offsetTop-t.offsetHeight)-(e.offsetHeight-(t.offsetHeight+(t.offsetHeight-t.clientHeight))))}_showNoData(e){return e?`<p class="multiselect__options--no-data" style="${ni.multiselect__options_ul_p_multiselect__options_no_data}">${this._noData}</p>`:""}_showNoResults(e){const t=this._multiselect.querySelector(".multiselect__options--no-results");if(e){const e=`<p class="multiselect__options--no-results" style="${ni.multiselect__options_ul_p_multiselect__options_no_results}">${this._noResults}</p>`;!t&&this._domElements.optionsContainerList.insertAdjacentHTML("beforeend",e)}else t&&t.parentNode&&t.parentNode.removeChild(t)}}const ai=x.store;function oi(e,t,n,i,a,o,s){const r=o.children;for(let c=0;c<s.length;c++){const l=s[c];if(un(l)===b.ui("Options").uri){const s=dn(0,l)(e,null,t,n,l,i,a);ve.Rm("Refreshing Options field by replacing it."),o.insertBefore(s,r[c]),o.removeChild(r[c+1])}}}function si(e,t,n,i,a,o,s,r){const c=b.ui,l=x.store,p=l.any(a,c("property"));if(!p){const n=nt(e,"No property to boolean field: "+a);return t&&t.appendChild(n),n}let u=l.any(a,c("label"));u||(u=z(p,!0)),o=bn(i,p,o);let d=l.any(i,p);void 0===d&&(d=!1);const m=g.st(i,p,!0,o),f=Ci(e,l,u,g.st(i,p,!1,o),m,a,o,r);return t&&t.appendChild(f),f}function ri(e,t,n,i,a,o,s){dn(0,a)(e,t,n,i,a,o,s)}function ci(e,t,n,i,a){const o=e.createElement("button");return o.setAttribute("type","button"),o.innerHTML="Edit "+z(b.ui("Form")),o.addEventListener("click",function(s){li(e,t,{},n,b.ui("FormForm"),i,a).setAttribute("style",b.ui("FormForm").sameTerm(n)?"background-color: #fee;":"background-color: #ffffe7;"),o.parentNode.removeChild(o)},!0),o}function li(e,t,n,i,a,o,s){return dn(0,a)(e,t,n,i,a,o,s)}function pi(e,t){const n=e.each(void 0,b.rdf("range"),t);[b.rdfs("comment"),b.dc("title"),b.foaf("name"),b.foaf("homepage")].forEach(function(e){n.push(e)});let i=e.each(void 0,b.rdf("type"),t);i.length>60&&(i=i.slice(0,60));const a={};for(let t=0;t<(i.length>60?60:i.length);t++)e.statementsMatching(i[t],void 0,void 0).forEach(function(e){a[e.predicate.uri]=!0});n.forEach(function(e){a[e.uri]=!0});const o=[];for(const t in a)o.push(e.sym(t));return o}function ui(e,t,n){const i=[e.sym(t)];for(;i.length>0;){const t=i.shift(),a=e.each(t,n);if(j("Lists for "+t+", "+n+": "+a.length),0!==a.length)return a;const o=e.each(t,b.rdfs("subClassOf"));for(let e=0;e<o.length;e++)i.push(o[e]),j("findClosest: add super: "+o[e])}return[]}function di(e){const t=x.store;j("formsFor: subject="+e);const n=t.findTypeURIs(e);let i;for(i in n)j(" type: "+i);const a=t.bottomTypeURIs(n);let o=[];for(const e in a)j("candidatesFor: trying bottom type ="+e),o=o.concat(ui(t,e,b.ui("creationForm"))),o=o.concat(ui(t,e,b.ui("annotationForm")));return o}function mi(e){const t=e.map(function(e){return[ai.any(e,b.ui("sequence"))||9999,e]});return t.sort(function(e,t){return e[0]-t[0]}),t.map(function(e){return e[1]})}function fi(e){const t=e.map(function(e){return[z(e).toLowerCase(),e]});return t.sort(),t.map(function(e){return e[1]})}function hi(e,t,n,i,a,o,s,r){const c=e.createElement("button");return c.setAttribute("type","button"),c.innerHTML="New "+z(a),c.addEventListener("click",function(l){c.parentNode.appendChild(gi(e,t,n,i,a,o,s,r))},!1),c}function gi(e,t,n,i,a,o,s,r){const c=e.createElement("form");if(!o){const n=ui(t,a.uri,b.ui("creationForm"));if(0===n.length){c.appendChild(e.createElement("p")).textContent="I am sorry, you need to provide information about a "+z(a)+" but I don't know enough information about those to ask you.";const t=c.appendChild(e.createElement("button"));return t.setAttribute("type","button"),t.setAttribute("style","float: right;"),t.innerHTML="Goto "+z(a),t.addEventListener("click",function(t){e.outlineManager.GotoSubject(a,!0,void 0,!0,void 0)},!1),c}j("lists[0] is "+n[0]),o=n[0]}j("form is "+o),c.setAttribute("style",`border: 0.05em solid ${qe}; color: ${qe}`),c.innerHTML="<h3>New "+z(a)+"</h3>";const l=dn(0,o),p=Ei(s);let u=!1;function d(e,t,n){return r(t,n)}_("paneUtils Object is "+p);const m=l(e,c,{},p,o,s,function(o,l){if(!o)return r(o,l);const m=[];n&&!t.holds(n,i,p,s)&&m.push(g.st(n,i,p,s)),n&&!t.holds(p,b.rdf("type"),a,s)&&m.push(g.st(p,b.rdf("type"),a,s)),m.length?t.updater.update([],m,d):r(!0,l),u||(u=c.appendChild(Yt(e,p)))});return Kt(e,m).setAttribute("style","float: right;"),c.AJAR_subject=p,c}function bi(e,t,n,i,a,o){const s=e.createElement("div"),r=t.anyJS(n,i,null,a)||"",c=e.createElement("textarea");function l(r){p.disabled=!0,p.setAttribute("style","visibility: hidden; float: right;"),c.disabled=!0,c.style.color=Je;const l=t.statementsMatching(n,i,null,a),u=g.st(n,i,c.value,a);t.updater.update(l,u,function(t,n,i){n?(c.style.color=We,c.disabled=!1):s.appendChild(nt(e,"Error (while saving change to "+a.uri+"): "+i)),o&&o(n,i)})}s.appendChild(c),c.rows=r?r.split("\n").length+2:2,c.cols=80,c.setAttribute("style",Ke.multilineTextInputStyle),null!==r?c.value=r:c.select(),s.refresh=function(){const e=t.any(n,i,null,a);e&&e.value!==c.value&&(c.value=e.value)};let p;return t.updater.editable(a.uri)?(p=Ft(e,l),p.disabled=!0,p.style.visibility="hidden",p.style.float="right",s.appendChild(p),c.addEventListener("keyup",function(e){c.style.color="green",p&&(p.disabled=!1,p.style.visibility="")},!0),c.addEventListener("change",l,!0)):(c.disabled=!0,c.style.backgroundColor=Ve),s}function xi(e,t,n,i,a,o,s,r){j("Select list length now "+a.length);let c=0;const l={},p=t.updater.editable(s.uri);for(let e=0;e<a.length;e++){const t=a[e];t.uri||ve.R8(`makeSelectForClassifierOptions: option does not have an uri: ${t}, with predicate: ${i}`),t.uri&&!(t.uri in l)&&(l[t.uri]=!0,c++)}if(0===c&&!o.mint)return nt(e,"Can't do selector with no options, subject= "+n+" property = "+i+".");let u;j("makeSelectForClassifierOptions: dataDoc="+s);const d=function(){return u={},i.sameTerm(b.rdf("type"))?u=t.findTypeURIs(n):t.each(n,i,null,s).forEach(function(e){u[e.uri]=!0}),u};u=d();const m=function(a){f.disabled=!0;const c=[];let l=[];const p=function(e){t.holds(n,i,e,s)&&c.push(g.st(n,i,e,s))};let m;for(let a=0;a<f.options.length;a++){const c=f.options[a];if(c.selected&&c.AJAR_mint){if(o.mintClass){const a=gi(e,t,n,i,o.mintClass,null,s,function(e,t){e||r(e,t,{change:"new"})});f.parentNode.appendChild(a),m=a.AJAR_subject}else m=Ei(s);l.push(g.st(n,i,m,s)),o.mintStatementsFun&&(l=l.concat(o.mintStatementsFun(m)))}c.AJAR_uri&&(c.selected&&!(c.AJAR_uri in u)&&l.push(g.st(n,i,t.sym(c.AJAR_uri),s)),!c.selected&&c.AJAR_uri in u&&p(t.sym(c.AJAR_uri)),c.selected&&(f.currentURI=c.AJAR_uri))}let h=f.subSelect;for(;h&&h.currentURI;)p(t.sym(h.currentURI)),h=h.subSelect;for(h=f.superSelect;h&&h.currentURI;)p(t.sym(h.currentURI)),h=h.superSelect;function b(e,t){r(e,{widget:"select",event:"new"})}_("makeSelectForClassifierOptions: data doc = "+s),t.updater.update(c,l,function(t,n,i){if(u=d(),!n)return f.parentNode.appendChild(nt(e,"Error updating data in select: "+i));if(f.disabled=!1,m){dn(0,o.subForm)(e,f.parentNode,{},m,o.subForm,s,b)}r&&r(n,{widget:"select",event:"change"})})},f=e.createElement("select");f.setAttribute("style",Ke.formSelectStyle),o.multiple&&f.setAttribute("multiple","true"),f.currentURI=null,f.refresh=function(){u=d();for(let e=0;e<f.children.length;e++){const t=f.children[e];t.AJAR_uri&&(t.selected=t.AJAR_uri in u)}f.disabled=!1};for(const n in l){const i=t.sym(n),a=e.createElement("option");o.disambiguate?a.appendChild(e.createTextNode(ue(i,!0))):a.appendChild(e.createTextNode(z(i,!0)));const s=t.any(i,t.sym("http://www.w3.org/ns/ui#backgroundColor"));s&&a.setAttribute("style","background-color: "+s.value+"; "),a.AJAR_uri=n,n in u&&(a.setAttribute("selected","true"),f.currentURI=n),f.appendChild(a)}if(p&&o.mint){const t=e.createElement("option");t.appendChild(e.createTextNode(o.mint)),t.AJAR_mint=!0,f.insertBefore(t,f.firstChild)}if(null==f.currentURI&&!o.multiple){const t=e.createElement("option");t.appendChild(e.createTextNode(o.nullLabel)),f.insertBefore(t,f.firstChild),t.selected=!0}return p&&f.addEventListener("change",m,!1),f}function vi(e,t,n,i,a,o,s,r){j("Select list length now "+a.length);let c=0;const l={},p=t.updater.editable(s.uri);for(let e=0;e<a.length;e++){const t=a[e];t.uri||ve.R8(`makeSelectForOptions: option does not have an uri: ${t}, with predicate: ${i}`),t.uri&&!(t.uri in l)&&(l[t.uri]=!0,c++)}if(0===c)return nt(e,"Can't do selector with no options, subject= "+n+" property = "+i+".");let u;j("makeSelectForOptions: dataDoc="+s);const d=function(){return u={},i.sameTerm(b.rdf("type"))?u=t.findTypeURIs(n):t.each(n,i,null,s).forEach(function(e){e.uri&&(u[e.uri]=!0)}),u};u=d();const m=function(a){f.disabled=!0;const o=[],c=[],l=function(e){t.holds(n,i,e,s)&&o.push(g.st(n,i,e,s))};for(let e=0;e<f.options.length;e++){const a=f.options[e];a.AJAR_uri&&(a.selected&&!(a.AJAR_uri in u)&&c.push(g.st(n,i,t.sym(a.AJAR_uri),s)),!a.selected&&a.AJAR_uri in u&&l(t.sym(a.AJAR_uri)),a.selected&&(f.currentURI=a.AJAR_uri))}let p=f.subSelect;for(;p&&p.currentURI;)l(t.sym(p.currentURI)),p=p.subSelect;for(p=f.superSelect;p&&p.currentURI;)l(t.sym(p.currentURI)),p=p.superSelect;_("selectForOptions: data doc = "+s),t.updater.update(o,c,function(t,n,i){if(u=d(),!n)return f.parentNode.appendChild(nt(e,"Error updating data in select: "+i));f.disabled=!1,r&&r(n,{widget:"select",event:"change"})})},f=e.createElement("select");f.setAttribute("style",Ke.formSelectStyle),f.currentURI=null,f.refresh=function(){u=d();for(let e=0;e<f.children.length;e++){const t=f.children[e];t.AJAR_uri&&(t.selected=t.AJAR_uri in u)}f.disabled=!1};for(const n in l){const i=t.sym(n),a=e.createElement("option");o.disambiguate?a.appendChild(e.createTextNode(ue(i,!0))):a.appendChild(e.createTextNode(z(i,!0)));const s=t.any(i,t.sym("http://www.w3.org/ns/ui#backgroundColor"));s&&a.setAttribute("style","background-color: "+s.value+"; "),a.AJAR_uri=n,n in u&&(a.setAttribute("selected","true"),f.currentURI=n),f.appendChild(a)}if(!f.currentURI){const t=e.createElement("option");t.appendChild(e.createTextNode(o.nullLabel)),f.insertBefore(t,f.firstChild),t.selected=!0}return p&&f.addEventListener("change",m,!1),f}function yi(e,t,n,i,a,o){const s=t.any(i,b.owl("disjointUnionOf"));let r,c=!1;return s?r=s.elements:(r=t.each(void 0,b.rdfs("subClassOf"),i),c=!0),j("Select list length "+r.length),0===r.length?nt(e,"Can't do "+(c?"multiple ":"")+"selector with no subclasses of category: "+i):1===r.length?nt(e,"Can't do "+(c?"multiple ":"")+"selector with only 1 subclass of category: "+i+":"+r[1]):xi(e,t,n,b.rdf("type"),r,{multiple:c,nullLabel:"* Select type *"},a,o)}function wi(e,t,n,i,a,o){function s(){c&&(r.removeChild(c),c=null),l.currentURI&&t.any(t.sym(l.currentURI),b.owl("disjointUnionOf"))&&(c=wi(e,t,n,t.sym(l.currentURI),a,o),l.subSelect=c.firstChild,l.subSelect.superSelect=l,r.appendChild(c))}const r=e.createElement("span");let c=null;const l=yi(e,t,n,i,a,function(e,t){e&&s(),o(e,t)});return r.appendChild(l),s(),r}function Ci(e,t,n,i,a,o,s,r){const c=e.createElement("div"),l=hn(e,t,c,o,n),p=t.updater.editable(s.uri),u=e.createElement("button"),d=u;function m(e){if(!e)return[];if(e.object)return e.why||(e.why=s),[e];if(e instanceof Array)return e;throw new Error("buildCheckboxForm: bad param "+e)}function f(e){return 0===e.filter(e=>!t.holds(e.subject,e.predicate,e.object,e.why)).length}if(u.style=Ke.checkboxInputStyle,l.appendChild(u),a=m(a),i=m(i),function(){let n=f(a),s=n;if(i.length){const l=f(i);if(n&&l)return c.appendChild(nt(e,"Inconsistent data in dataDoc!\n"+a+" and\n"+i)),c;if(!n&&!l){n=null;const e=t.any(o,b.ui("default"));s=e?"1"===e.value:!!r&&null}}u.state=n,u.textContent={true:"✓",false:r?"✕":" ",null:"-"}[s]}(),!p)return c;let h=!1;return u.addEventListener("click",function(n){if(h)return;h=!0,u.disabled=!0;let o=!1;const s=function(){return!o&&(o=!0,h=!1,u.disabled=!1,!0)},l=function(t){d.style.color="#000",d.style.backgroundColor="#fee",c.appendChild(nt(e,`Checkbox: Error updating dataDoc from ${u.state} to ${u.newState}:\n\n${t}`))};d.style.color="#bbb";const p=!0===u.state?a:!1===u.state?i:[];u.newState=null===u.state||!0!==u.state&&(!r||null);const m=!0===u.newState?a:!1===u.newState?i:[];ve.Rm(` Deleting ${p}`),ve.Rm(` Inserting ${m}`);try{const e=t.updater.update(p,m,function(e,n,i){if(s())if(n)d.style.color="#000",u.state=u.newState,u.textContent={true:"✓",false:"✕",null:"-"}[u.state];else{if(p.why){t.holds(p.subject,p.predicate,p.object,p.why)&&ve.Rm(" @@@@@ weird if 409 - does hold statement")}l(i)}});e&&"function"==typeof e.then&&e.catch(function(e){s()&&l(e instanceof Error?e.message:e)}).finally(function(){s()})}catch(e){throw s(),e}},!1),c}function Ei(e){const t=new Date;return g.sym(e.uri+"#id"+t.getTime())}function ki(e,t,n,i,a,o,s,r,c,l,p){const u={},d=n.updater.editable(l.uri);for(let e=0;e<o.length;e++){const t=o[e];t.uri&&!(t.uri in u)&&(u[t.uri]=!0)}if(0===Object.keys(u).length&&!c.mint)return nt(e,"Can't do selector with no options, subject= "+i+" property = "+a+".");j("makeSelectForChoice: dataDoc="+l);const m=function(e){t.removeChild(t.lastChild),f.refresh()},f=e.createElement("select");f.setAttribute("style",Ke.formSelectStyle),f.setAttribute("id","formSelect"),f.currentURI=null;for(const e in u)f.appendChild(h(e));if(d&&c.mint){const t=e.createElement("option");t.appendChild(e.createTextNode(c.mint)),t.AJAR_mint=!0,f.insertBefore(t,f.firstChild)}function h(t){const i=e.createElement("option"),a=n.sym(t);let o;o=c.disambiguate?ue(a,!0):z(a,!0),i.appendChild(e.createTextNode(o)),i.setAttribute("value",t);const r=n.any(a,n.sym("http://www.w3.org/ns/ui#backgroundColor"));return r&&i.setAttribute("style","background-color: "+r.value+"; "),i.AJAR_uri=t,Ai(a.value,s)&&i.setAttribute("selected","true"),i}return 0===f.children.length&&f.insertBefore(function(){const t=e.createElement("option");return t.appendChild(e.createTextNode(function(){let e="--- choice ---";return a&&"BlankNode"!==a.termType&&(e="* Select for property: "+z(a)+" *"),i&&"BlankNode"!==i.termType&&(e="* Select for "+z(i,!0)+" *"),e}())),t.disabled=!0,t.value=!0,t.hidden=!0,t.selected=!0,t}(),f.firstChild),f.update=function(t){s=t;const o=[],c=[],u=function(e){n.holds(i,a,e,l)&&o.push(g.st(i,a,e,l))},d=function(e){n.holds(i,a,e,l)||c.push(g.st(i,a,e,l)),r&&!n.holds(e,b.rdf("type"),n.sym(r),l)&&c.push(g.st(e,b.rdf("type"),n.sym(r),l))},m=n.each(i,a,null,l).map(e=>e.value);for(const e of m)Ai(e,s)||u(g.sym(e));for(const e of s)e in m||d(g.sym(e));n.updater.update(o,c,function(t,n,i){if(!n)return f.parentNode.appendChild(nt(e,"Error updating data in select: "+i));f.refresh(),p&&p(n,{widget:"select",event:"change"})})},f.refresh=function(){f.disabled=!0;let o,u=[];for(let t=0;t<f.options.length;t++){const d=f.options[t];if(d.selected&&d.AJAR_mint){if(c.mintClass){const t=gi(e,n,i,a,r,c.subForm,l,function(e,t){e||p(e,t,{change:"new"})});f.parentNode.appendChild(t),o=t.AJAR_subject}else o=Ei(l);u.push(g.st(i,a,n.sym(o),l)),r&&u.push(g.st(o,b.rdf("type"),n.sym(r),l)),c.mintStatementsFun&&(u=u.concat(c.mintStatementsFun(o))),f.currentURI=o}d.AJAR_uri&&(d.selected&&Ai(d.AJAR_uri,s)&&(f.currentURI=d.AJAR_uri),Ai(d.AJAR_uri,s)||d.removeAttribute("selected"),Ai(d.AJAR_uri,s)&&d.setAttribute("selected","true"))}_("selectForOptions: data doc = "+l),f.currentURI&&c.subForm&&!c.multiSelect&&ri(e,t,{},g.sym(f.currentURI),c.subForm,l,function(i,a){i?(n.updater.update([],u,function(n,i,a){i||t.appendChild(nt(e,"Error updating select: "+a))}),p&&p(i,{widget:"select",event:"new"})):t.appendChild(nt(e,"Error updating data in field of select: "+a))}),f.disabled=!1},d&&f.addEventListener("change",m,!1),f}function Ai(e,t){let n;for(n=0;n<t.length;n++)if(t[n]===e)return!0;return!1}pn[b.ui("AutocompleteField").uri]=function(e,t,n,i,a,o,s){if("NamedNode"!==i.termType)throw new Error("Sorry this field only works on NamedNode subjects (for editable)");const r=x.store,c=a.doc?a.doc():null,l=e.createElement("div");t&&t.appendChild(l);const p=e.createElement("div");p.setAttribute("class","formFieldName"),p.setAttribute("style",Ke.formFieldNameBoxStyle),l.appendChild(p);const u=e.createElement("div");u.setAttribute("class","formFieldValue"),l.appendChild(u);const d=r.any(a,b.ui("property"));if(!d)return l.appendChild(nt(e,"Error: No property given for autocomplete field: "+a));const m=r.any(a,b.ui("labelProperty"))||b.schema("name"),f=r.any(a,b.ui("dataSource"));if(!f)return l.appendChild(nt(e,"Error: No data source given for autocomplete field: "+a));const h={label:r.anyJS(f,b.schema("name"),null,f.doc()),logo:r.any(f,b.schema("logo"),null,f.doc())},v=r.any(a,b.ui("targetClass"),null,a.doc())||r.any(f,b.ui("targetClass"),null,f.doc());v&&(h.targetClass=v),h.objectURIBase=r.any(f,b.ui("objectURIBase"),null,f.doc())||void 0;const y=r.anyJS(f,b.ui("endpoint"),null,f.doc());if(y){if(h.endpoint=y,h.searchByNameQuery=r.anyJS(f,b.ui("searchByNameQuery"),null,f.doc()),!h.searchByNameQuery)return l.appendChild(nt(e,"Error: No searchByNameQuery given for endpoint data Source: "+a));h.insitituteDetailsQuery=r.anyJS(f,b.ui("insitituteDetailsQuery"),null,f.doc())}else{const t=r.anyJS(f,b.ui("searchByNameURI"));if(!t)return l.appendChild(nt(e,"Error: No searchByNameURI OR sparql endpoint given for dataSource: "+f));h.searchByNameURI=t}const w=r.anyJS(a,b.ui("suppressEmptyUneditable"),null,c),C=r.updater?.editable(o.uri),E={permanent:!0,targetClass:h.targetClass,queryParams:h};E.size=r.anyJS(a,b.ui("size"),null,c)||void 0;let k=r.any(i,d,void 0,o);if(k)E.currentObject=k,E.currentName=r.any(E.currentObject,m,null,o);else if(k=r.any(a,b.ui("default")),k)E.currentObject=k,E.currentName=r.any(E.currentObject,m,null,o);else if(w&&!C)return l.style.display="none",l;return p.appendChild(gn(e,d,a)),ti(e,i,{editable:C,dbLookup:!0},E,async function(t,n){if(!n)throw new Error("autocompleteField: No name set.");const a=r.the(i,d,null,o);if(a){const e=r.any(a,m,null,o);if(a.equals(t)&&e&&e.sameTerm(n))return}const c=a?r.statementsMatching(i,d,a,o).concat(r.statementsMatching(a,m,null,o)):[],p=[(0,g.st)(i,d,t,o),(0,g.st)(t,m,n,o)];try{await(r.updater?.updateMany(c,p))}catch(t){return s(!1,t),void l.appendChild(nt(e,"Autocomplete form data update error:"+t,null,t))}s(!0,"")},async function(t,n){const a=r.the(i,d,null,o);if(!a)return s(!1,"NO data to elete"),void l.appendChild(nt(e,"Autocomplete delete: no old data!"));const c=r.statementsMatching(i,d,a,o).concat(r.statementsMatching(a,m,null,o)),p=[];try{await(r.updater?.updateMany(c,p))}catch(t){const n=new Error("Autocomplete form data delete error:"+t);return s(!1,t),void l.appendChild(nt(e,n,null,t))}s(!0,"")}).then(e=>{u.appendChild(e)},t=>{u.appendChild(nt(e,`Error rendering autocomplete ${a}: ${t}`,"#fee",t))}),l},pn[b.ui("Form").uri]=pn[b.ui("Group").uri]=function(e,t,n,i,a,o,s){const r=e.createElement("div"),c=b.ui;if(t&&t.appendChild(r),!a)return;const l=i.toNT()+"|"+a.toNT();if(n[l])return r.appendChild(e.createTextNode("Group: see above "+l)),r;const p={};for(const e in n)p[e]=1;p[l]=1;const u=a.doc?a.doc():null,d=ai.any(a,c("weight"),null,u),m=d?Number(d.value):1;if(m>3||m<0)return r.appendChild(nt(e,`Form Group weight ${m} should be 0-3`));r.setAttribute("style",Ke.formGroupStyle[m]),r.style.display="flex",r.style.flexDirection="column",r.class="form-weight-"+m;let f,h=ai.any(a,c("parts"),null,u);if(h?f=h.elements:(h=ai.each(a,c("part"),null,u),f=mi(h)),!h)return r.appendChild(nt(e,"No parts to form! "));for(let t=0;t<f.length;t++){const a=f[t],c=dn(0,a),l=function(t,a){t&&a&&a.widget&&"select"===a.widget&&oi(e,n,i,o,s,r,f),s(t,{widget:"group",change:a})};r.appendChild(c(e,null,p,i,a,o,l))}return r},pn[b.ui("Options").uri]=function(e,t,n,i,a,o,s){const r=x.store,c=e.createElement("div"),l=a.doc?a.doc():null,p=b.ui;t&&t.appendChild(c);let u=r.any(a,p("dependingOn"));u||(u=b.rdf("type"));const d=r.each(a,p("case"),null,l);let m;d||c.appendChild(nt(e,"No cases to Options form. ")),m=u.sameTerm(b.rdf("type"))?Object.keys(r.findTypeURIs(i)).map(e=>g.sym(e)):r.each(i,u);for(let t=0;t<d.length;t++){const u=d[t],f=r.each(u,p("for"),null,l);let h=!1;for(let e=0;e<f.length;e++)for(const t of m){const n=f[e];(t.sameTerm(f)||t.termType===n.termType&&t.value===n.value)&&(h=!0)}if(h){const t=r.the(u,p("use"));if(!t)return c.appendChild(nt(e,'No "use" part for case in form '+a)),c;li(e,c,n,i,t,o,s);break}}return c},pn[b.ui("Multiple").uri]=function(e,t,n,i,a,o,s){function r(e){return e.map(e=>e.toString().slice(-7)).join(", ")}async function c(){const t=Ei(o);if(y)S(),_.elements.push(t),await R();else{const n=C?[g.st(t,w,i,o)]:[g.st(i,w,t,o)];try{await u.updater.update([],n)}catch(t){const n="Error adding to unordered multiple: "+t;m.appendChild(nt(e,n)),ve.z3(n)}N()}}function l(t){async function a(e,n){let i;for(ve.Rm("pre move: "+r(_.elements)),i=0;i<_.elements.length&&!_.elements[i].sameTerm(t);i++);if(i===_.elements.length&&alert("list move: not found element for "+t),n){if(0===i)return void alert("@@ boop - already at top -temp message");_.elements.splice(i-1,2,_.elements[i],_.elements[i-1])}else{if(i===_.elements.length-1)return void alert("@@ boop - already at bottom -temp message");_.elements.splice(i,2,_.elements[i+1],_.elements[i])}await R()}j("Multiple: render object: "+t);const c=dn(0,A)(e,null,n,t,A,o,function(e,n){ve.Rm(`Item done callback for item ${t.toString()}`),e||ve.z3(" Item done callback: Error: "+n),s(e,n)});if(c.subject=t,u.updater.editable(o.uri)&&(Dt(e,c,E,async function(){if(y){ve.Rm("pre delete: "+r(_.elements));for(let e=0;e<_.elements.length;e++)if(_.elements[e].sameTerm(t))return _.elements.splice(e,1),void await R()}else if(u.holds(i,w,t,o)){const n=[g.st(i,w,t,o)];u.updater.update(n,[],function(t,n,i){n?T.removeChild(c):T.appendChild(nt(e,"Multiple: delete failed: "+i))})}}),y)){const t=e.createElement("div");t.style.display="grid",t.style.gridTemplateColumns="auto 3em",t.style.gridTemplateRows="50% 50%";const n=Ot(e,it.Pt.iconBase+"noun_1369237.svg","Move Up",async e=>a(0,!0)),i=Ot(e,it.Pt.iconBase+"noun_1369241.svg","Move Down",async e=>a(0,!1)),o=e.createElement("div");return o.appendChild(c),t.appendChild(o),t.appendChild(n),t.appendChild(i),n.style.gridColumn=2,i.style.gridColumn=2,n.style.gridRow=1,i.style.padding="0em",n.style.padding="0em",i.style.gridRow=2,o.style.gridColumn=1,o.style.gridRowStart="span 2",t}return c}const p=it.Pt.iconBase+"noun_19460_green.svg",u=x.store,d=a.doc?a.doc():null,m=e.createElement("div"),f=m,h=b.ui;t&&t.appendChild(m);const v=u.any(a,h("ordered")),y=!!v&&g.Node.toJS(v),w=u.any(a,h("property")),C=u.anyJS(a,h("reverse"),null,d);if(!w)return m.appendChild(nt(e,"No property to multiple: "+a)),f;let E=u.any(a,h("label"));E||(E=z(w));let k=u.any(a,h("min"));k=k?0+k.value:0;const A=u.any(a,h("part"));if(!A)return m.appendChild(nt(e,"No part to multiple: "+a)),f;const T=m.appendChild(e.createElement("div"));let _,L;if(T.style.display="flex",T.style.flexDirection="column",L=C?u.any(null,w,i,o):u.any(i,w,null,o),y?(_=C?u.any(null,w,i,o):u.any(i,w,null,o),L=_?_.elements:[]):(L=C?u.each(null,w,i,o):u.each(i,w,null,o),_=null),u.updater.editable(o.uri)){const t=m.appendChild(e.createElement("div"));t.style.padding="0.5em";const n=t.appendChild(e.createElement("img"));n.setAttribute("src",p),n.setAttribute("style","margin: 0.2em; width: 1.5em; height:1.5em"),n.title="Click to add another "+E;const i=e.createElement("span");i.textContent=(0===L.length?"Add another ":"Add ")+E,t.addEventListener("click",async e=>{await c()},!0),t.appendChild(i)}function S(){_||(_=new g.Collection,C?u.add(_,w,i,o):u.add(i,w,_,o))}async function R(){ve.Rm("save list: "+r(_.elements)),S();try{await u.fetcher.putBack(o)}catch(t){return void m.appendChild(nt(e,"Error trying to put back a list: "+t))}N()}function N(){let e;if(y){const t=C?u.the(null,w,i,o):u.the(i,w,null,o);e=t?t.elements:[]}else e=C?u.each(null,w,i,o):u.each(i,w,null,o),e.sort();Y(T,e,l)}return T.refresh=N,N(),async function(){const e=k-L.length;if(e>0){for(let t=0;t<e;t++)ve.Rm("Adding extra: min "+k),await c();await R()}}().then(()=>{ve.Rm(" Multiple render: async stuff ok")},e=>{ve.z3(" Multiple render: async stuff fails. #### ",e)}),f},pn[b.ui("PhoneField").uri]=xn,pn[b.ui("EmailField").uri]=xn,pn[b.ui("ColorField").uri]=xn,pn[b.ui("DateField").uri]=xn,pn[b.ui("DateTimeField").uri]=xn,pn[b.ui("TimeField").uri]=xn,pn[b.ui("NumericField").uri]=xn,pn[b.ui("IntegerField").uri]=xn,pn[b.ui("DecimalField").uri]=xn,pn[b.ui("FloatField").uri]=xn,pn[b.ui("TextField").uri]=xn,pn[b.ui("SingleLineTextField").uri]=xn,pn[b.ui("NamedNodeURIField").uri]=xn,pn[b.ui("MultiLineTextField").uri]=function(e,t,n,i,a,o,s){const r=b.ui,c=x.store,l=a.doc?a.doc():null,p=c.any(a,r("property"));if(!p)return nt(e,"No property to text field: "+a);const u=e.createElement("div");u.style.display="flex",u.style.flexDirection="row";const d=u.appendChild(e.createElement("div"));d.style.width=He;const m=u.appendChild(e.createElement("div"));d.appendChild(gn(e,p,a)),o=bn(i,p,o);const f=c.anyJS(i,p,null,o)||"",h=c.updater.editable(o.uri),g=a&&c.anyJS(a,b.ui("suppressEmptyUneditable"),null,l);!h&&g&&""===f&&(u.style.display="none");const v=bi(e,c,i,p,o,s);return m.appendChild(v),t&&t.appendChild(u),u},pn[b.ui("BooleanField").uri]=function(e,t,n,i,a,o,s){return si(e,t,0,i,a,o,0,!1)},pn[b.ui("TristateField").uri]=function(e,t,n,i,a,o,s){return si(e,t,0,i,a,o,0,!0)},pn[b.ui("Classifier").uri]=function(e,t,n,i,a,o,s){const r=x.store,c=b.ui,l=r.any(a,c("category"));if(!l)return nt(e,"No category for classifier: "+a);j("Classifier: dataDoc="+o);const p=e.createElement("div");p.setAttribute("class","classifierBox");const u=e.createElement("div");u.setAttribute("class","formFieldName classifierBox-label"),u.appendChild(gn(e,l,a)),p.appendChild(u);const d=e.createElement("div");d.setAttribute("class","formFieldValue classifierBox-selectBox");const m=wi(e,r,i,l,o,function(e,t){return s(e,t)});if(m&&m.querySelectorAll){const e=m.querySelectorAll("select");e.length&&!r.updater.editable(o.uri)&&e.forEach(e=>{e.readOnly=!0,e.style=Ke.textInputStyleUneditable})}return d.appendChild(m),p.appendChild(d),t&&t.appendChild(p),p},pn[b.ui("Choice").uri]=function(e,t,n,i,a,o,s){const r=b.ui,c=x.store,l=a.doc?a.doc():null;let p;const u=e.createElement("div");u.setAttribute("class","choiceBox"),t&&t.appendChild(u);const d=e.createElement("div");d.setAttribute("class","formFieldName choiceBox-label"),u.appendChild(d);const m=e.createElement("div");m.setAttribute("class","formFieldValue choiceBox-selectBox"),u.appendChild(m);const f=c.any(a,r("property"));if(!f)return u.appendChild(nt(e,"No property for Choice: "+a));d.appendChild(gn(e,f,a));const h=c.any(a,r("from"));if(!h)return nt(e,"No 'from' for Choice: "+a);const v=c.any(a,r("use")),y={form:a,subForm:v,disambiguate:!1};c.any(a,r("canMintNew"))&&(y.mint="* Create new *");const w=c.any(a,r("multiselect"));w&&(y.multiSelect=!0);const C=c.each(a,r("search-full-store")).length?null:o;let E;return m.refresh=function(){let t=c.each(i,f,null,o).map(e=>e.value),n=function(e){let t,n=[];n=c.each(void 0,b.rdf("type"),h,l);for(const t in function(e,t,n){let i,a,o,s,r,c,l,p,u,d,m;const f={};f[t.toNT()]=!0;const h={},g=e.transitiveClosure(f,e.rdfFactory.namedNode("http://www.w3.org/2000/01/rdf-schema#subClassOf"),!0);for(const t in g){r=e.statementsMatching(null,e.rdfFactory.namedNode("http://www.w3.org/1999/02/22-rdf-syntax-ns#type"),e.fromNT(t),n);for(let e=0,t=r.length;e<t;e++)d=r[e],h[d.subject.toNT()]=d;c=e.each(null,e.rdfFactory.namedNode("http://www.w3.org/2000/01/rdf-schema#domain"),e.fromNT(t),n);for(let t=0,a=c.length;t<a;t++)for(s=c[t],l=e.statementsMatching(null,s,null,n),o=0,i=l.length;o<i;o++)d=l[o],h[d.subject.toNT()]=d;p=e.each(null,e.rdfFactory.namedNode("http://www.w3.org/2000/01/rdf-schema#range"),e.fromNT(t),n);for(let t=0,i=p.length;t<i;t++)for(s=p[t],u=e.statementsMatching(null,s,null,n),m=0,a=u.length;m<a;m++)d=u[m],h[d.object.toNT()]=d}return h}(c,h,e))n.push(c.fromNT(t));if(h.sameTerm(b.rdfs("Class")))for(p in Qt())n.push(c.sym(p));else if(h.sameTerm(b.rdf("Property"))){for(p in t=Zt(c),t.op)n.push(c.fromNT(p));for(p in t.dp)n.push(c.fromNT(p));y.disambiguate=!0}else if(h.sameTerm(b.owl("ObjectProperty"))){for(p in t=Zt(c),t.op)n.push(c.fromNT(p));y.disambiguate=!0}else if(h.sameTerm(b.owl("DatatypeProperty"))){for(p in t=Zt(c),t.dp)n.push(c.fromNT(p));y.disambiguate=!0}return n}(C);if(n.push(t),n=fi(n),E=ki(e,m,c,i,f,n,t,h,y,o,s),m.innerHTML="",m.appendChild(E),w){const n=new ii({placeholder:E.selected,select:E,container:m,textField:"textField",valueField:"valueField"});n.init(),n.subscribe(function(n){if("REMOVE_OPTION"===n.action&&(t=t.filter(function(e){return e!==n.value})),"CLEAR_ALL_OPTIONS"===n.action&&(t=[]),"ADD_OPTION"===n.action){if((n.value+"").includes("Create new")){const n=Ei(o),a=[];a.push(g.st(i,f,c.sym(n),o)),h&&a.push(g.st(n,b.rdf("type"),c.sym(h),o)),v&&ri(e,m,{},g.sym(n),v,o,function(i,o){i?(c.updater.update([],a,function(t,n,i){n||m.appendChild(nt(e,"Error updating select: "+i))}),t.push(n),s&&s(i,{widget:"select",event:"new"})):m.appendChild(nt(e,"Error updating data in field of select: "+o))})}else t.push(n.value)}E.update(t)})}},m.refresh(),E&&E.refresh&&E.refresh(),u},pn[b.ui("Comment").uri]=pn[b.ui("Heading").uri]=function(e,t,n,i,a,o,s){const r=b.ui,c=x.store;let l=c.any(a,r("contents"));l||(l="Error: No contents in comment field.");const p=a.doc?a.doc():null,u=un(a),d=cn[u]||{},m=e.createElement("div");t&&t.appendChild(m);const f=m.appendChild(e.createElement(d.element));f.textContent=l,function(e,t){const n=un(t),i=cn[n]||{},a=x.store.any(t,b.ui("style"));a?"Literal"===a.termType?a&&e.setAttribute("style",a.value):x.store.statementsMatching(a,null,null,t.doc()).forEach(t=>{if(t.predicate.uri&&t.predicate.uri.startsWith(mn)){const n=t.predicate.uri.slice(26);try{e.style[n]=t.object.value}catch(i){console.warn(`setFieldStyle: Error setting element style ${n} to "${t.object.value}"`),console.warn(`setFieldStyle: ... Element tagName was "${e.tagName||"???"}"`)}}}):i.style&&e.setAttribute("style",i.style)}(f,a);const h=c.anyJS(a,b.ui("suppressIfUneditable"),null,p),g=c.updater.editable(o.uri);return h&&!g&&(m.style.display="none"),m};const Ti={authEndpoint:"",fallbackAuthEndpoint:"https://databox.me/",signupEndpoint:"https://solidproject.org/get_a_pod",signupWindowHeight:600,signupWindowWidth:1024,key:"",cert:""};function ji(e){this.config=e||Ti}ji.prototype.listen=function(){return new Promise(function(e,t){const n=window.addEventListener?"addEventListener":"attachEvent";(0,window[n])("attachEvent"===n?"onmessage":"message",function(n){const i=n.data;if("User:"===i.slice(0,5)){const n=i.slice(5,i.length);return n&&n.length>0&&"http"===n.slice(0,4)?e(n):t(n)}},!0)})},ji.prototype.signup=function(e){e=e||this.config.signupEndpoint;const t=this.config.signupWindowWidth,n=this.config.signupWindowHeight,i=window.screen.width/2-(t/2+10),a=window.screen.height/2-(n/2+50),o=e+"?origin="+encodeURIComponent(window.location.origin),s="resizable,scrollbars,status,width="+t+",height="+n+",left="+i+",top="+a;window.open(o,"Solid signup",s);const r=this;return new Promise(function(e){r.listen().then(function(t){return e(t)})})};x.solidLogicSingleton.store;const{loadPreferences:_i,loadProfile:Li}=x.solidLogicSingleton.profile,{getScopedAppInstances:Si,getRegistrations:Ri,loadAllTypeIndexes:Ni,getScopedAppsFromIndex:Ii,deleteTypeIndexRegistration:Bi}=x.solidLogicSingleton.typeIndex;function Di(e){const t=x.authn.currentUser();return t?(x.authn.saveUser(t,e),Promise.resolve(e)):new Promise(t=>{x.authn.checkUser().then(n=>{if(n)return ve.Rm(`logIn: Already logged in as ${n}`),t(e);if(!e.div||!e.dom)return t(e);const i=Hi(e.dom,n=>{x.authn.saveUser(n,e),t(e)});e.div.appendChild(i)})})}async function Oi(e){if(e.preferencesFile)return Promise.resolve(e);let t;try{e=await Mi(e);const n=await _i(e.me);t,e.preferencesFile=n}catch(t){let n;if(t instanceof x.UnauthorizedError)n="Oops — you are not authenticated (properly logged in), so SolidOS cannot read your preferences file. Try logging out and then logging back in.",R(n);else{if(t instanceof x.CrossOriginForbiddenError)return n=`Unauthorized: Assuming preference file blocked for origin ${window.location.origin}`,e.preferencesFileError=n,e;if(t instanceof x.SameOriginForbiddenError)return n="You are not authorized to read your preference file. This may be because you are using an untrusted web app.",ve.R8(n),e;if(t instanceof x.NotEditableError)return n="You are not authorized to edit your preference file. This may be because you are using an untrusted web app.",ve.R8(n),e;if(t instanceof x.WebOperationError)n="You are not authorized to edit your preference file. This may be because you are using an untrusted web app.",ve.R8(n);else{if(!(t instanceof x.FetchError))throw new Error(`(via loadPrefs) ${t}`);n=`Strange: Error ${t.status} trying to read your preference file.${t.message}`,R(n)}}}return e}async function Mi(e){if(e.publicProfile)return e;try{const t=await Di(e);if(!t.me)throw new Error("Could not log in");e.publicProfile=await Li(t.me)}catch(t){throw e.div&&e.dom&&e.div.appendChild(nt(e.dom,t.message)),new Error(`Can't log in: ${t}`)}return e}async function Fi(e,t,n){let i=e.me?await Si(t,e.me):[];return!0===n?i=i.filter(e=>"public"===e.scope.label):!1===n&&(i=i.filter(e=>"private"===e.scope.label)),e.instances=i.map(e=>e.instance),e}function Ui(e,t){return`${e.me&&e.me.sameTerm(t.agent)?"":z(t.agent)+" "}${t.label}`}async function zi(e,t,n){function i(i){const a=function(e){const i=Ri(t,n),a=i.length?i[0]:Ei(e);return[(0,g.st)(a,b.solid("instance"),t,e),(0,g.st)(a,b.solid("forClass"),n,e)]}(i.index),o=`${Ui(e,i)} link to this ${e.noun}`;return Ci(e.dom,x.solidLogicSingleton.store,o,null,a,l,i.index)}const a=e.dom;if(!a||!e.div)throw new Error("registrationControl: need dom and div");const o=a.createElement("div");e.div.appendChild(o),e.me=x.authn.currentUser();const s=e.me;if(!s)return o.innerHTML='<p style="margin:2em;">(Log in to save a link to this)</p>',e;let r;try{r=await Ni(s)}catch(t){let n;return e.div&&e.preferencesFileError?(n="(Lists of stuff not available)",e.div.appendChild(a.createElement("p")).textContent=n):e.div&&(n=`registrationControl: Type indexes not available: ${t}`,e.div.appendChild(nt(e.dom,t))),ve.Rm(n),e}o.innerHTML="<table><tbody></tbody></table>",o.setAttribute("style","font-size: 120%; text-align: right; padding: 1em; border: solid gray 0.05em;");const c=o.children[0].children[0],l=new g.BlankNode;for(const e of r){c.appendChild(a.createElement("tr")).appendChild(i(e))}return e}function Pi(e,t,n){const{dom:i}=e,a=Ui(e,n),o=i.createElement("tr"),s=o.appendChild(i.createElement("td"));s.setAttribute("colspan","3"),s.style.backgoundColor={private:"#fee",public:"#efe"}[n.label]||"white";const r=s.appendChild(i.createElement("h3"));return r.textContent=a+" links",r.style.textAlign="left",o}async function $i(e,t){const n=e.dom,i=e.div,a=n.createElement("div");if(i.appendChild(a),e.me=x.authn.currentUser(),!e.me)return a.innerHTML='<p style="margin:2em;">(Log in list your stuff)</p>',e;const o=await Ni(e.me);a.innerHTML="<table><tbody></tbody></table>",a.setAttribute("style","font-size: 120%; text-align: right; padding: 1em; border: solid #eee 0.5em;");const s=a.firstChild.firstChild;for(const i of o){const a=Pi(e,0,i);s.appendChild(a);const o=await Ii(i,t.type||null);0===o.length&&(a.style.display="none");for(const e of o){const t=zt(n,b.solid("instance"),e.instance,{deleteFunction:async()=>{await Bi(e),s.removeChild(t)}});t.children[0].style.paddingLeft="3em",s.appendChild(t)}}return e}function qi(e){const t=e.createElement("div");t.setAttribute("style","position: fixed; top: 0; left: 0; right: 0; bottom: 0; display: flex; justify-content: center; align-items: center;"),e.body.appendChild(t);const n=e.createElement("div");n.setAttribute("style","\n background-color: white;\n box-shadow: 0px 1px 4px rgba(0, 0, 0, 0.2);\n -webkit-box-shadow: 0px 1px 4px rgba(0, 0, 0, 0.2);\n -moz-box-shadow: 0px 1px 4px rgba(0, 0, 0, 0.2);\n -o-box-shadow: 0px 1px 4px rgba(0, 0, 0, 0.2);\n border-radius: 4px;\n min-width: 400px;\n padding: 10px;\n z-index : 10;\n "),t.appendChild(n);const i=e.createElement("div");i.setAttribute("style","\n border-bottom: 1px solid #DDD;\n display: flex;\n flex-direction: row;\n align-items: center;\n justify-content: space-between;\n "),n.appendChild(i);const a=e.createElement("label");a.setAttribute("style","margin-right: 5px; font-weight: 800"),a.innerText="Select an identity provider";const o=e.createElement("button");o.innerHTML='<img src="https://solidos.github.io/solid-ui/src/icons/noun_1180156.svg" style="width: 2em; height: 2em;" title="Cancel">',o.setAttribute("style","background-color: transparent; border: none;"),o.addEventListener("click",()=>{t.remove()}),i.appendChild(a),i.appendChild(o);const s=async e=>{try{x.solidLogicSingleton.store.updater.flagAuthorizationMetadata();const t=new URL(window.location.href).hash;t&&window.localStorage.setItem("preLoginRedirectHash",t),window.localStorage.setItem("loginIssuer",e);const n=new URL(window.location.href);n.hash="",await x.authSession.login({redirectUrl:n.href,oidcIssuer:e})}catch(e){R(e.message)}},r=e.createElement("div");r.setAttribute("style","\n border-bottom: 1px solid #DDD;\n display: flex;\n flex-direction: column;\n padding-top: 10px;\n ");const c=e.createElement("div");c.setAttribute("style","\n display: flex;\n flex-direction: row;\n ");const l=e.createElement("label");l.innerText="Enter the URL of your identity provider:",l.setAttribute("style","color: #888");const p=e.createElement("input");p.setAttribute("type","text"),p.setAttribute("style","margin-left: 0 !important; flex: 1; margin-right: 5px !important"),p.setAttribute("placeholder","https://example.com"),p.value=localStorage.getItem("loginIssuer")||"";const u=e.createElement("button");u.innerText="Go",u.setAttribute("style","margin-top: 12px; margin-bottom: 12px;"),u.addEventListener("click",()=>{s(p.value)}),r.appendChild(l),c.appendChild(p),c.appendChild(u),r.appendChild(c),n.appendChild(r);const d=e.createElement("div");d.setAttribute("style","\n display: flex;\n flex-direction: column;\n padding-top: 10px;\n ");const m=e.createElement("label");m.innerText="Or pick an identity provider from the list below:",m.setAttribute("style","color: #888"),d.appendChild(m),(0,x.getSuggestedIssuers)().forEach(t=>{const n=e.createElement("button");n.innerText=t.name,n.setAttribute("style","height: 38px; margin-top: 10px"),n.addEventListener("click",()=>{s(t.uri)}),d.appendChild(n)}),n.appendChild(d)}function Hi(e,t=null,n={}){let i=(0,x.offlineTestID)();const a=e.createElement("div");function o(e){e&&(i=x.authn.saveUser(e),a.refresh(),t&&t(i.uri))}function s(e){const n=i;x.authSession.logout().then(function(){const e=`Your WebID was ${n}. It has been forgotten.`;i=null;try{R(e)}catch(t){window.alert(e)}a.refresh(),t&&t(null)},e=>{R("Fail to log out:"+e)})}function r(){i=x.authn.currentUser(),a.refresh()}return a.refresh=function(){const t=x.authSession.info;i=t&&t.webId&&t.isLoggedIn?x.solidLogicSingleton.store.sym(t.webId):null,(i&&a.me!==i.uri||!i&&a.me)&&(yt(a),i?a.appendChild(function(t,n){const i=n.buttonStyle||Ke.signInAndUpButtonStyle;let a="WebID logout";if(t){const e=x.solidLogicSingleton.store.any(t,b.foaf("nick"))||x.solidLogicSingleton.store.any(t,b.foaf("name"));e&&(a="Logout "+e.value)}const o=e.createElement("input");return o.setAttribute("type","button"),o.setAttribute("value",a),o.setAttribute("style",`${i}`),o.addEventListener("click",s,!1),o}(i,n)):a.appendChild(function(e,t,n={}){const i=(n=n||{}).buttonStyle||Ke.signInAndUpButtonStyle,a=e.createElement("div"),o="SolidSignInOrSignUpBox";ve.Rm("widgets.signInOrSignUpBox"),a.setUserCallback=t,a.setAttribute("class",o),a.setAttribute("style","display:flex;");const s=e.createElement("input");a.appendChild(s),s.setAttribute("type","button"),s.setAttribute("value","Log in"),s.setAttribute("style",`${i}${Ke.headerBannerLoginInput}`+Ke.signUpBackground),x.authSession.events.on("login",()=>{const t=x.authn.currentUser();if(t){const n=t.uri,i=e.getElementsByClassName(o);ve.Rm(`Logged in, ${i.length} panels to be serviced`);for(let t=0;t<i.length;t++){const a=i[t];if(a.setUserCallback)try{a.setUserCallback(n);const e=a.parentNode;e&&e.removeChild(a)}catch(t){ve.Rm(`## Error satisfying login box: ${t}`),a.appendChild(nt(e,t))}}}}),s.addEventListener("click",()=>{const n=(0,x.offlineTestID)();if(n)return t(n.uri);qi(e)},!1);const r=e.createElement("input");return a.appendChild(r),r.setAttribute("type","button"),r.setAttribute("value","Sign Up for Solid"),r.setAttribute("style",`${i}${Ke.headerBannerLoginInput}`+Ke.signInBackground),r.addEventListener("click",function(e){(new ji).signup().then(function(e){ve.Rm("signInOrSignUpBox signed up "+e),t(e)})},!1),a}(e,o,n))),a.me=i?i.uri:null},a.refresh(),r(),x.authSession.events.on("login",r),x.authSession.events.on("logout",r),a.me="99999",a.refresh(),a}function Gi(e,t,n){const i=t.noun,a=t.appPathSegment,o=(0,x.offlineTestID)(),s=e.createElement("div"),r={me:o,dom:e,div:s};function c(t,n){s.appendChild(nt(e,t,n))}function l(e){const t=x.solidLogicSingleton.store.any(e,b.space("uriPrefix"));let n;n=t?t.value:e.uri.split("#")[0],"/"!==n.slice(-1)&&(ve.Rm(`${a}: No / at end of uriPrefix ${n}`),n=`${n}/`);const i=new Date;return n+=`${a}/id${i.getTime()}/`,n}return Oi(r).then(function(t){const a=t.me,o=t.preferencesFile;let r=null,p=x.solidLogicSingleton.store.each(a,b.space("workspace"),void 0,o);const u=x.solidLogicSingleton.store.each(a,b.space("storage"));0===p.length&&u&&(c(`You don't seem to have any workspaces. You have ${u.length} storage spaces.`,"white"),u.map(function(e){return p=p.concat(x.solidLogicSingleton.store.each(e,b.ldp("contains"))),p}).filter(e=>e.id?["public","private"].includes(e.id().toLowerCase()):"")),1===p.length&&(c(`Workspace used: ${p[0].uri}`,"white"),r=l(p[0]));const d=e.createElement("table");d.setAttribute("style","border-collapse:separate; border-spacing: 0.5em;"),s.appendChild(d),s.appendChild(e.createElement("hr"));const m=s.appendChild(e.createElement("p"));m.setAttribute("style",Ke.commentStyle),m.textContent=`Where would you like to store the data for the ${i}?\n Give the URL of the folder where you would like the data stored.\n It can be anywhere in solid world - this URI is just an idea.`;const f=s.appendChild(e.createElement("input"));f.setAttribute("type","text"),f.setAttribute("style",Ke.textInputStyle),f.size=80,f.label="base URL",f.autocomplete="on",r&&(f.value=r),t.baseField=f,s.appendChild(e.createElement("br"));const h=s.appendChild(e.createElement("button"));let v,y,w,C,E,k,A;h.setAttribute("style",Ke.buttonStyle),h.textContent=`Start new ${i} at this URI`,h.addEventListener("click",function(e){let t=f.value.replace(" ","%20");"/"!==t.slice(-1)&&(t+="/"),n(null,t)}),p=p.filter(function(e){return!x.solidLogicSingleton.store.holds(e,b.rdf("type"),b.space("MasterWorkspace"))});const T="height: 3em; margin: 1em; padding: 1em white; border-radius: 0.3em;",j=`${T}border: 0px;`;for(let t=0;t<p.length;t++){if(E=p[t],C=e.createElement("tr"),0===t&&(v=e.createElement("td"),v.setAttribute("rowspan",`${p.length}`),v.textContent="Choose a workspace for this:",v.setAttribute("style","vertical-align:middle;"),C.appendChild(v)),y=e.createElement("td"),k=x.solidLogicSingleton.store.anyValue(E,b.ui("style")),!k){const e=`#${(16777215&function(e){return e.split("").reduce(function(e,t){return(e=(e<<5)-e+t.charCodeAt(0))&e},0)}(E.uri)|12632256).toString(16)}`;k=`color: black ; background-color: ${e};`}y.setAttribute("style",j+k),C.target=E.uri;let i=x.solidLogicSingleton.store.any(E,b.rdfs("label"));i||(i=E.uri.split("/").slice(-1)[0]||E.uri.split("/").slice(-2)[0]),y.textContent=i||"???",C.appendChild(y),0===t&&(w=e.createElement("td"),w.setAttribute("rowspan",`${p.length}1`),w.setAttribute("style","width:50%;"),C.appendChild(w)),d.appendChild(C),A=x.solidLogicSingleton.store.any(E,b.rdfs("comment")),A=A?A.value:"Use this workspace",y.addEventListener("click",function(t){w.textContent=A?A.value:"",w.setAttribute("style",j+k);const i=e.createElement("button");i.textContent="Continue";const a=l(E);f.value=a,i.addEventListener("click",function(e){i.disabled=!0,n(E,a),i.textContent="----\x3e"},!0),w.appendChild(i)},!0)}const _=e.createElement("tr");y=e.createElement("td"),y.setAttribute("style",T),y.textContent="+ Make a new workspace",y.addEventListener("click",async function(n){const i=d.appendChild(e.createElement("tr")).appendChild(e.createElement("td"));i.setAttribute("colspan","3"),i.style.padding="0.5em";const a=encodeURI(await Ut(e,x.solidLogicSingleton.store,i,b.solid("URL"),b.space("Workspace"),"Workspace")),o=Ei(t.preferencesFile),s=[(0,g.st)(t.me,b.space("workspace"),o,t.preferencesFile),(0,g.st)(o,b.space("uriPrefix"),a,t.preferencesFile)];if(!x.solidLogicSingleton.store.updater)throw new Error("store has no updater");await x.solidLogicSingleton.store.updater.update([],s)}),_.appendChild(y),d.appendChild(_)}).catch(e=>{s.appendChild(nt(r.dom,e))}),s}function Vi(e,t,n){const i=function(e,t){n(e,t)},a=e.createElement("div"),o=e.createElement("button");return o.setAttribute("type","button"),a.appendChild(o),o.innerHTML=`Make new ${t.noun}`,o.addEventListener("click",n=>{a.appendChild(Gi(e,t,i))},!1),a.appendChild(o),a}async function Wi(){const e=x.authSession.info;if(!e?.isLoggedIn||!e?.webId)return[];const t=x.authn.currentUser();if(!t)return[];try{const{me:e,preferencesFile:n,preferencesFileError:i}=await Oi({me:t});if(!n||i)throw new Error(i||"Unable to load user preferences file.");return x.solidLogicSingleton.store.each(e,b.rdf("type"),null,n.doc())}catch(e){ve.R8("Unable to fetch your preferences - this was the error: ",e)}return[]}async function Ji(e){const t=await Wi();return e.filter(e=>function(e,t){const n=e.audience||[];return n.reduce((e,n)=>e&&!!t.find(e=>e.equals(n)),!0)}(e,t))}x.authSession.events.on("logout",async()=>{const e=window.localStorage.getItem("loginIssuer");if(e)try{x.solidLogicSingleton.store.updater.flagAuthorizationMetadata();const t=new URL(e);t.pathname="/.well-known/openid-configuration";const n=await fetch(t.toString());if(200===n.status){const e=await n.json();e&&e.end_session_endpoint&&await fetch(e.end_session_endpoint,{credentials:"include"})}}catch(e){}window.location.reload()});class Qi{rootElement;barElement;isExpanded=!1;constructor(e){this.groupList=e,this.rootElement=e.controller.dom.createElement("div"),this.barElement=e.controller.dom.createElement("div")}render(){return this.rootElement.innerHTML="",this.rootElement.appendChild(this.renderAddButton()),this.rootElement.appendChild(this.barElement),this.rootElement}renderAddButton(){return Ot(this.groupList.controller.dom,`${it.Pt.iconBase}noun_34653_green.svg`,"Add ...",()=>{this.toggleBar(),this.renderBar()})}renderBar(){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()))}renderSimplifiedBar(e){Array.from(this.barElement.children).filter(t=>t!==e).forEach(e=>this.barElement.removeChild(e))}renderPersonButton(){return Ot(this.groupList.controller.dom,it.Pt.iconBase+_t["vcard:Individual"],"Add Person",e=>{this.renderSimplifiedBar(e.target),this.renderNameForm(b.vcard("Individual"),"person").then(e=>this.addPerson(e)).then(()=>this.renderCleanup()).catch(e=>this.groupList.controller.renderStatus(e))})}renderGroupButton(){return Ot(this.groupList.controller.dom,it.Pt.iconBase+_t["vcard:Group"],"Add Group",e=>{this.renderSimplifiedBar(e.target),this.renderNameForm(b.vcard("Group"),"group").then(e=>this.addGroup(e)).then(()=>this.renderCleanup()).catch(e=>this.groupList.controller.renderStatus(e))})}renderNameForm(e,t){return Ut(this.groupList.controller.dom,this.groupList.store,this.barElement,b.vcard("URI"),e,t)}renderPublicButton(){return Ot(this.groupList.controller.dom,it.Pt.iconBase+_t["foaf:Agent"],"Add Everyone",()=>this.addAgent(b.foaf("Agent").uri).then(()=>this.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(()=>this.renderCleanup()))}renderAuthenticatedAgentButton(){return Ot(this.groupList.controller.dom,`${it.Pt.iconBase}noun_99101.svg`,"Anyone logged In",()=>this.addAgent(b.acl("AuthenticatedAgent").uri).then(()=>this.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(()=>this.renderCleanup()))}renderBotButton(){return Ot(this.groupList.controller.dom,it.Pt.iconBase+"noun_Robot_849764.svg","A Software Agent (bot)",e=>{this.renderSimplifiedBar(e.target),this.renderNameForm(b.schema("Application"),"bot").then(e=>this.addBot(e)).then(()=>this.renderCleanup())})}renderAppsButton(){return Ot(this.groupList.controller.dom,`${it.Pt.iconBase}noun_15177.svg`,"A Web App (origin)",e=>{this.renderSimplifiedBar(e.target);const t={div:this.barElement,dom:this.groupList.controller.dom},n=this.renderAppsTable(t).catch(e=>this.groupList.controller.renderStatus(e));this.renderAppsView();const i=this.renderNameForm(b.schema("WebApplication"),"webapp domain").then(e=>this.getOriginFromName(e));Promise.race([n,i]).then(e=>{e&&this.groupList.addNewURI(e)}).then(()=>this.renderCleanup())})}renderAppsView(){const e=this.groupList.controller.context.session.paneRegistry.byName("trustedApplications");if(e){const t=e.render(null,this.groupList.controller.context);t.setAttribute("style",Ke.trustedAppController);const n=Mt(this.groupList.controller.dom,()=>this.renderCleanup());n.setAttribute("style",Ke.trustedAppCancelButton),t.insertBefore(n,t.firstChild),this.barElement.appendChild(t)}}async renderAppsTable(e){await Mi(e);const t=this.groupList.store.each(e.me,b.acl("trustedApp")),n=t.flatMap(e=>this.groupList.store.each(e,b.acl("origin")));return this.barElement.appendChild(this.groupList.controller.dom.createElement("p")).textContent=`You have ${n.length} selected web apps.`,new Promise((e,n)=>{const i=this.barElement.appendChild(this.groupList.controller.dom.createElement("table"));i.setAttribute("style",Ke.trustedAppAddApplicationsTable),t.forEach(t=>{const a=this.groupList.store.any(t,b.acl("origin"));a||n(new Error(`Unable to pick app: ${t.value}`));const o=zt(this.groupList.controller.dom,b.acl("origin"),a,{}),s=this.groupList.controller.dom.createElement("table"),r=s.appendChild(this.groupList.controller.dom.createElement("tr"));r.appendChild(this.groupList.controller.dom.createElement("td")).appendChild(o);r.appendChild(this.groupList.controller.dom.createElement("td")).textContent=`Give access to ${this.groupList.controller.noun} ${z(this.groupList.controller.subject)}?`;r.appendChild(this.groupList.controller.dom.createElement("td")).appendChild(Ft(this.groupList.controller.dom,()=>e(a.value))),i.appendChild(s)})})}renderCleanup(){this.renderBar(),this.groupList.render()}async addPerson(e){if(!e)return this.toggleBar();if(!e.match(/^https?:/i))return Promise.reject(new Error("Not a http URI"));ve.Rm(`Adding to ACL person: ${e}`),await this.groupList.addNewURI(e),this.toggleBar()}async addGroup(e){if(!e)return this.toggleBar();if(!e.match(/^https?:/i))return Promise.reject(new Error("Not a http URI"));ve.Rm("Adding to ACL group: "+e),await this.groupList.addNewURI(e),this.toggleBar()}async addAgent(e){await this.groupList.addNewURI(e),this.toggleBar()}async addBot(e){if(!e)return this.toggleBar();if(!e.match(/^https?:/i))return Promise.reject(new Error("Not a http URI"));ve.Rm("Adding to ACL bot: "+e),await this.groupList.addNewURI(e),this.toggleBar()}async getOriginFromName(e){if(!e)return Promise.resolve();if(!e.match(/^([a-z0-9]+(-[a-z0-9]+)*\.)+[a-z]{2,}$/i))return Promise.reject(new Error("Not a domain name"));const t="https://"+e;return ve.Rm("Adding to ACL origin: "+t),this.toggleBar(),t}toggleBar(){this.isExpanded=!this.isExpanded}}const Zi=b.acl,Yi={13:"Owners",9:"Owners (write locked)",5:"Editors",3:"Posters",2:"Submitters",1:"Viewers"},Ki={13:!0,5:!0,3:!0,2:!0,1:!0},Xi={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"};class ea{defaults;byCombo;aclMap;addAgentButton;rootElement;_store;constructor(e,t,n,i,a={}){this.doc=e,this.aclDoc=t,this.controller=n,this._options=a,this.defaults=this._options.defaults||!1,this._store=i,this.aclMap=Ce(e,0,i,this.defaults),this.byCombo=Te(this.aclMap),this.addAgentButton=new Qi(this),this.rootElement=this.controller.dom.createElement("div"),this.rootElement.setAttribute("style",Ke.accessGroupList)}get store(){return this._store}set store(e){this._store=e,this.aclMap=Ce(this.doc,this.aclDoc,e,this.defaults),this.byCombo=Te(this.aclMap)}render(){return this.rootElement.innerHTML="",this.renderGroups().forEach(e=>this.rootElement.appendChild(e)),this.controller.isEditable&&this.rootElement.appendChild(this.addAgentButton.render()),this.rootElement}renderGroups(){const e=[];for(let t=15;t>0;t--){const n=ta(t);(this.controller.isEditable&&Ki[t]||this.byCombo[n])&&e.push(this.renderGroup(t,n))}return e}renderGroup(e,t){const n=this.controller.dom.createElement("div");n.setAttribute("style",Ke.accessGroupListItem),Xe(n,e=>this.handleDroppedUris(e,t).then(()=>this.controller.render()).catch(e=>this.controller.renderStatus(e)));return this.renderGroupElements(e,t).forEach(e=>n.appendChild(e)),n}renderGroupElements(e,t){const n=this.controller.dom.createElement("div");if(n.setAttribute("style",Ke.group),this.controller.isEditable)switch(e){case 1:n.setAttribute("style",Ke.group1);break;case 2:n.setAttribute("style",Ke.group2);break;case 3:n.setAttribute("style",Ke.group3);break;case 5:n.setAttribute("style",Ke.group5);break;case 9:n.setAttribute("style",Ke.group9);break;case 13:n.setAttribute("style",Ke.group13);break;default:n.setAttribute("style",Ke.group)}n.innerText=Yi[e]||function(e){let t="";const n=["Read","Append","Write","Control"];for(let i=0;i<4;i++)e&1<<i&&(t+=n[i]);return t}(e);const i=this.controller.dom.createElement("div");if(i.setAttribute("style",Ke.group),this.controller.isEditable)switch(e){case 1:i.setAttribute("style",Ke.group1);break;case 2:i.setAttribute("style",Ke.group2);break;case 3:i.setAttribute("style",Ke.group3);break;case 5:i.setAttribute("style",Ke.group5);break;case 9:i.setAttribute("style",Ke.group9);break;case 13:i.setAttribute("style",Ke.group13);break;default:i.setAttribute("style",Ke.group)}const a=i.appendChild(this.controller.dom.createElement("table"));(this.byCombo[t]||[]).map(([e,n])=>this.renderAgent(a,t,e,n)).forEach(e=>a.appendChild(e));const o=this.controller.dom.createElement("div");if(o.setAttribute("style",Ke.group),this.controller.isEditable)switch(e){case 1:o.setAttribute("style",Ke.group1);break;case 2:o.setAttribute("style",Ke.group2);break;case 3:o.setAttribute("style",Ke.group3);break;case 5:o.setAttribute("style",Ke.group5);break;case 9:o.setAttribute("style",Ke.group9);break;case 13:o.setAttribute("style",Ke.group13);break;default:o.setAttribute("style",Ke.group)}return o.innerText=Xi[e]||"Unusual combination",[n,i,o]}renderAgent(e,t,n,i){const a=zt(this.controller.dom,Zi(n),(0,g.sym)(i),this.controller.isEditable?{deleteFunction:()=>this.deleteAgent(t,n,i).then(()=>e.removeChild(a)).catch(e=>this.controller.renderStatus(e))}:{});return a}async deleteAgent(e,t,n){const i=this.byCombo[e]||[],a=i.find(([e,i])=>e===t&&i===n);a&&i.splice(i.indexOf(a),1),await this.controller.save()}async addNewURI(e){await this.handleDroppedUri(e,ta(1)),await this.controller.save()}async handleDroppedUris(e,t){try{await Promise.all(e.map(e=>this.handleDroppedUri(e,t))),await this.controller.save()}catch(e){return Promise.reject(e)}}async handleDroppedUri(e,t,n=!1){const i=function(e,t){const n=(0,g.sym)(e),i=t.findTypeURIs(n);for(const e in i)ve.Rm(" drop object type includes: "+e);if(e.startsWith("http")&&3===e.split("/").length)return{pred:"origin",obj:n};if(e.startsWith("http")&&4===e.split("/").length&&e.endsWith("/"))return ve.Rm("Assuming final slash on dragged origin URI was unintended!"),{pred:"origin",obj:(0,g.sym)(e.slice(0,-1))};if(b.vcard("WebID").uri in i)return{pred:"agent",obj:n};if(b.vcard("Group").uri in i)return{pred:"agentGroup",obj:n};if(n.sameTerm(b.foaf("Agent"))||n.sameTerm(b.acl("AuthenticatedAgent"))||n.sameTerm(b.rdf("Resource"))||n.sameTerm(b.owl("Thing")))return{pred:"agentClass",obj:n};if(b.vcard("Individual").uri in i||b.foaf("Person").uri in i||b.foaf("Agent").uri in i){const e=t.any(n,b.foaf("preferredURI"));return e?{pred:"agent",obj:(0,g.sym)(e)}:{pred:"agent",obj:n}}if(b.solid("AppProvider").uri in i)return{pred:"origin",obj:n};if(b.solid("AppProviderClass").uri in i)return{pred:"originClass",obj:n};return ve.Rm(" Triage fails for "+e),null}(e,this.store),a=(0,g.sym)(e);if(!i&&!n){ve.Rm(` Not obvious: looking up dropped thing ${a}`);try{await(this._store?.fetcher?.load(a.doc()))}catch(e){const t=`Ignore error looking up dropped thing: ${e}`;return ve.z3(t),Promise.reject(new Error(t))}return this.handleDroppedUri(e,t,!0)}if(!i){const t=Object.keys(this.store.findTypeURIs(a)),n=`Error: Failed to add access target: ${e} 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.`+(t.length>0?`Detected RDF types: ${t.join(", ")}`:"No RDF type was detected for this URI.");return ve.z3(n),Promise.reject(new Error(n))}this.setACLCombo(t,e,i,this.controller.subject)}setACLCombo(e,t,n,i){e in this.byCombo||(this.byCombo[e]=[]),this.removeAgentFromCombos(t),this.byCombo[e].push([n.pred,n.obj.uri]),ve.Rm(`ACL: setting access to ${i} by ${n.pred}: ${n.obj}`)}removeAgentFromCombos(e){for(let t=0;t<16;t++){const n=this.byCombo[ta(t)];if(n)for(let t=0;t<n.length;t++)for(;t<n.length&&n[t][1]===e;)n.splice(t,1)}}}function ta(e){const t=["Read","Append","Write","Control"],n=[];for(let i=0;i<4;i++)e&1<<i&&n.push("http://www.w3.org/ns/auth/acl#"+t[i]);return n.sort(),n.join("\n")}class na{mainCombo;defaultsCombo;isContainer;defaultsDiffer;rootElement;isUsingDefaults;constructor(e,t,n,i,a,o,s,r,c,l,p,u){if(this.subject=e,this.noun=t,this.context=n,this.statusElement=i,this.targetIsProtected=a,this.targetDoc=o,this.targetACLDoc=s,this.defaultHolder=r,this.defaultACLDoc=c,this.prospectiveDefaultHolder=l,this.store=p,this.dom=u,this.rootElement=u.createElement("div"),this.rootElement.setAttribute("style",Ke.aclGroupContent),this.isContainer="/"===o.uri.slice(-1),r&&c){this.isUsingDefaults=!0;const e=we(this.targetDoc,s,r,c);this.mainCombo=new ea(o,s,this,e,{defaults:this.isContainer}),this.defaultsCombo=null,this.defaultsDiffer=!1}else this.isUsingDefaults=!1,this.mainCombo=new ea(o,s,this,p),this.defaultsCombo=new ea(o,s,this,p,{defaults:this.isContainer}),this.defaultsDiffer=!Ee(this.mainCombo.aclMap,this.defaultsCombo.aclMap)}get isEditable(){return!this.isUsingDefaults}render(){if(this.rootElement.innerHTML="",this.isUsingDefaults){if(this.renderStatus(`The sharing for this ${this.noun} is the default for folder `),this.defaultHolder){const e=this.statusElement.appendChild(this.dom.createElement("a"));e.href=this.defaultHolder.uri,e.innerText=ra(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}renderRemoveAclsController(){const e=this.dom.createElement("button");return e.innerText=`Remove custom sharing settings for this ${this.noun} -- just use default${this.prospectiveDefaultHolder?` for ${z(this.prospectiveDefaultHolder)}`:""}`,e.setAttribute("style",Ke.bigButton),e.addEventListener("click",()=>this.removeAcls().then(()=>this.render()).catch(e=>this.renderStatus(e))),e}renderAddAclsController(){const e=this.dom.createElement("button");return e.innerText=`Set specific sharing for this ${this.noun}`,e.setAttribute("style",Ke.bigButton),e.addEventListener("click",()=>this.addAcls().then(()=>this.render()).catch(e=>this.renderStatus(e))),e}renderAddDefaultsController(){const e=this.dom.createElement("div");e.setAttribute("style",Ke.defaultsController);const t=e.appendChild(this.dom.createElement("div"));t.innerText="Sharing for things within the folder currently tracks sharing for the folder.",t.setAttribute("style",Ke.defaultsControllerNotice);const n=e.appendChild(this.dom.createElement("button"));return n.innerText="Set the sharing of folder contents separately from the sharing for the folder",n.setAttribute("style",Ke.bigButton),n.addEventListener("click",()=>this.addDefaults().then(()=>this.render())),e}renderRemoveDefaultsController(){const e=this.dom.createElement("div");e.setAttribute("style",Ke.defaultsController);const t=e.appendChild(this.dom.createElement("div"));t.innerText="Access to things within this folder:",t.setAttribute("style",Ke.defaultsControllerNotice);const n=e.appendChild(this.dom.createElement("button"));return n.innerText="Set default for folder contents to just track the sharing for the folder",n.setAttribute("style",Ke.bigButton),n.addEventListener("click",()=>this.removeDefaults().then(()=>this.render()).catch(e=>this.renderStatus(e))),e}renderTemporaryStatus(e){this.statusElement.setAttribute("style",Ke.aclControlBoxStatusRevealed),this.statusElement.innerText=e,this.statusElement.setAttribute("style",Ke.temporaryStatusInit),setTimeout(()=>{this.statusElement.setAttribute("style",Ke.temporaryStatusEnd)}),setTimeout(()=>{this.statusElement.innerText=""},5e3)}renderStatus(e){e||this.statusElement.setAttribute("style",Ke.aclControlBoxStatusRevealed),this.statusElement.innerText=e}async addAcls(){if(!this.defaultHolder||!this.defaultACLDoc){const e="Unable to find defaults to copy";return ve.z3(e),Promise.reject(e)}we(this.targetDoc,this.targetACLDoc,this.defaultHolder,this.defaultACLDoc).statements.forEach(e=>this.store.add(e.subject,e.predicate,e.object,this.targetACLDoc));try{return await this.store.fetcher.putBack(this.targetACLDoc),this.isUsingDefaults=!1,Promise.resolve()}catch(e){const t=` Error writing back access control file! ${e}`;return ve.z3(t),Promise.reject(t)}}async addDefaults(){this.defaultsCombo=new ea(this.targetDoc,this.targetACLDoc,this,this.store,{defaults:!0}),this.defaultsDiffer=!0}async removeAcls(){try{await this.store.fetcher.delete(this.targetACLDoc.uri,{}),this.isUsingDefaults=!0;try{this.prospectiveDefaultHolder=await De(this.targetDoc.uri)}catch(e){ve.R8(e)}}catch(e){const t=`Error deleting access control file: ${this.targetACLDoc}: ${e}`;return ve.z3(t),Promise.reject(t)}}async removeDefaults(){const e=this.defaultsCombo;try{this.defaultsCombo=null,this.defaultsDiffer=!1,await this.save()}catch(t){return this.defaultsCombo=e,this.defaultsDiffer=!0,ve.z3(t),Promise.reject(t)}}save(){const e=(0,g.graph)();this.isContainer?this.defaultsCombo&&this.defaultsDiffer?(_e(e,this.targetDoc,this.mainCombo.byCombo,this.targetACLDoc,!0),_e(e,this.targetDoc,this.defaultsCombo.byCombo,this.targetACLDoc,!1,!0)):_e(e,this.targetDoc,this.mainCombo.byCombo,this.targetACLDoc,!0,!0):_e(e,this.targetDoc,this.mainCombo.byCombo,this.targetACLDoc,!0),e.fetcher=(0,g.fetcher)(e,{fetch:this.store.fetcher._fetch});const t=e.updater||new g.UpdateManager(e);return new Promise((n,i)=>{t.put(this.targetACLDoc,e.statementsMatching(void 0,void 0,void 0,this.targetACLDoc),"text/turtle",(t,a,o)=>{if(!a)return i(new Error(`ACL file save failed: ${o}`));this.store.fetcher.unload(this.targetACLDoc),this.store.add(e.statements),this.store.fetcher.requested[this.targetACLDoc.uri]="done",this.mainCombo.store=this.store,this.defaultsCombo&&(this.defaultsCombo.store=this.store),this.defaultsDiffer=!!this.defaultsCombo&&!Ee(this.mainCombo.aclMap,this.defaultsCombo.aclMap),ve.Rm("ACL modification: success!"),n()})})}}let ia=window;const aa=Symbol("prevent double triggering of drop event");function oa(e){e.stopPropagation(),e.preventDefault()}function sa(e){e.dataTransfer.files.length>0&&(ia.confirm("Are you sure you want to drop this file here? (Cancel opens it in a new tab)")||(e.stopPropagation(),e.preventDefault(),(0,ve.Rm)("@@@@ document-level DROP suppressed: "+e.dataTransfer.dropEffect)))}function ra(e){let t=e.uri;"/"===t.slice(-1)&&(t=t.slice(0,-1));const n=t.lastIndexOf("/");return n>=0&&(t=t.slice(n+1)),t||"/"}const ca={adoptACLDefault:we,readACL:Ce,sameACL:Ee,ACLunion:ke,loadUnionACL:Ae,ACLbyCombination:Te,makeACLGraph:je,makeACLGraphbyCombo:_e,ACLToString:function(e){return Le(Te(e))},comboToString:Le,makeACLString:function(e,t,n){const i=(0,g.graph)();return je(i,e,t,n),(0,g.serialize)(n,i,n.uri,"text/turtle")||""},putACLObject:Se,putACLbyCombo:Re,fixIndividualCardACL:function(e,t,n){const i=ye.each(void 0,b.vcard("hasMember"),e);i?Ne(e,i,t,n):(t("This card is in no groups"),n(!0))},fixIndividualACL:Ne,setACL:function(e,t,n){const i=ye.any(e,x.ACL_LINK);if(!ye.fetcher)throw new Error("Store has no fetcher");i?ye.fetcher.webOperation("PUT",i.value,{data:t,contentType:"text/turtle"}).then(e=>{n(e.ok,e.error||"")}):ye.fetcher.nowOrWhenFetched(e,void 0,function(i,a){if(!i)return n(i,"Gettting headers for ACL: "+a);const o=ye.any(e,x.ACL_LINK);if(o){if(!ye.fetcher)throw new Error("Store has no fetcher");ye.fetcher.webOperation("PUT",o.value,{data:t,contentType:"text/turtle"}).then(e=>{n(e.ok,e.error||"")})}else n(!1,"No Link rel=ACL header for "+e)})},getACLorDefault:Ie,getACL:Be},la={preventBrowserDropEvents:function(e){if((0,ve.Rm)("preventBrowserDropEvents called."),void 0!==ia){if(ia[aa])return;ia[aa]=!0}e.addEventListener("drop",sa,!1),e.addEventListener("dragenter",oa,!1),e.addEventListener("dragover",oa,!1)},shortNameForFolder:ra,ACLControlBox5:function(e,t,n,i){const a=t.dom,o=e.doc(),s=a.createElement("div");s.setAttribute("style",Ke.aclControlBoxContainer);const r=s.appendChild(a.createElement("h1"));r.textContent=`Sharing for ${n} ${z(e)}`,r.setAttribute("style",Ke.aclControlBoxHeader);const c=s.appendChild(a.createElement("div"));c.setAttribute("style",Ke.aclControlBoxStatus);try{(async function(e,t,n,i,a,o,s){return new Promise((r,c)=>Ie(e,async(e,l,p,u,d,m)=>{if(!e)return c(new Error(`Error reading ${l?"":" default "}ACL. status ${p}: ${u}`));const f=function(e){const t=e.uri.split("#")[0],n=t.slice(0,-1).lastIndexOf("/"),i=t.indexOf("//");return i>=0&&n<i+2||n<0?null:t.slice(0,n+1)}(p),h=function(e,t,n){return n.holds(e,b.rdf("type"),b.space("Storage"),t)}(p,u,t)||function(e){return e.uri===e.site().uri}(p);if(!h&&f)try{const e=await De(f);return r(g(e))}catch(e){(0,ve.R8)(e)}return r(g());function g(e){return new na(n,i,a,s,h,p,u,d,m,e,t,o)}}))})(o,i,e,n,t,a,c).then(e=>s.appendChild(e.render()))}catch(e){c.innerText=e}return s}},pa=x.solidLogicSingleton.store;const ua={newThingUI:function(e,t,n){const i=e.dom,a=e.div;if(e.me&&!e.me.uri)throw new Error("newThingUI: Invalid userid: "+e.me);const o="padding: 0.7em; width: 2em; height: 2em;",s=a.appendChild(i.createElement("img"));let r=!1;s.setAttribute("src",it.Pt.iconBase+"noun_34653_green.svg"),s.setAttribute("style",o),s.setAttribute("title","Add another tool");const c=function(e){const t=a.appendChild(i.createElement("pre"));t.setAttribute("style","background-color: pink"),t.appendChild(i.createTextNode(e))};function l(e){for(let t=0;t<u.length;t++){let n=o+e;u[t].disabled&&(n+="opacity: 0.3;"),u[t].setAttribute("style",n)}}function p(e){r=!r,s.setAttribute("style",o+(r?"background-color: yellow;":"")),l(r?"":"display: none;")}s.addEventListener("click",p);const u=[],d=Object.values(n).filter(e=>e.mintNew),m=d.reduce((e,t)=>(t.mintClass&&(e[t.mintClass.uri]=(e[t.mintClass.uri]||0)+1),e),{});d.forEach(n=>{const a=e.div.appendChild(i.createElement("img"));a.setAttribute("src",n.icon);const s=n.mintClass?m[n.mintClass.uri]>1?`${z(n.mintClass)} (using ${n.name} pane)`:z(n.mintClass):n.name+" @@";a.setAttribute("title","Make new "+s),a.setAttribute("style",o+"display: none;"),u.push(a),a.disabled||a.addEventListener("click",function(r){var u;!function(e){l("display: none;"),e.setAttribute("style",o+"background-color: yellow;")}(a),u={event:r,folder:e.folder||null,iconEle:a,pane:n,noun:s,noIndexHTML:!0,div:e.div,me:e.me,dom:e.dom,refreshTarget:e.refreshTarget},new Promise(function(n,a){let o;function s(n,o){Mi(e).then(e=>{const s=Object.assign({newBase:o,folder:u.folder||void 0,workspace:n},u);for(const e in u)s[e]=u[e];ve.Rm(`newThingUI: Minting new ${s.pane.name} at ${s.newBase}`),u.pane.mintNew(t,s).then(function(e){if(!e||!e.newInstance)throw new Error("Cannot mint new - missing newInstance");if(e.folder){const t=e.newInstance.uri.slice(e.folder.uri.length).includes("/");ve.Rm(" new thing is packge? "+t),t?pa.add(e.folder,b.ldp("contains"),pa.sym(e.newBase),e.folder.doc()):pa.add(e.folder,b.ldp("contains"),e.newInstance,e.folder.doc()),e.refreshTarget&&e.refreshTarget.refresh&&e.refreshTarget.refresh()}else{const t=u.div.appendChild(i.createElement("p"));t.setAttribute("style","font-size: 120%;"),t.innerHTML="Your <a target='_blank' href='"+e.newInstance.uri+"'><b>new "+u.noun+"</b></a> is ready to be set up. <br/><br/><a target='_blank' href='"+e.newInstance.uri+"'>Go to your new "+u.noun+".</a>"}p()}).catch(function(e){c(e),a(e)})},e=>{c("Error logging on: "+e)})}const r=u.pane;if(u.noun=r.mintClass?z(r.mintClass):r.name,u.appPathSegment=u.noun.slice(0,1).toUpperCase()+u.noun.slice(1),u.folder){const e=function(e){if(e){let t=u.folder.uri;t.endsWith("/")||(t+="/"),t=t+encodeURIComponent(e)+"/",s(null,t)}else p()};Ut(i,0,u.div,b.foaf("name"),null,u.noun).then(e)}else o=Gi(i,{noun:u.noun,appPathSegment:u.appPathSegment},s),u.div.appendChild(o)})})})}},da=x.solidLogicSingleton.store;const ma={matrixForQuery:function(e,t,n,i,a,o,s){const r=e.createElement("table"),c=e.createElement("tr");c.appendChild(e.createElement("td")).setAttribute("class","MatrixCorner"),r.appendChild(c),r.lastHeader=c;let l=[];const p=[],u=function(e,t,n,i){for(;e.firstChild;)e.removeChild(e.firstChild);e.setAttribute("style",""),e.style.textAlign="center",o.cellFunction?o.cellFunction(e,t,n,i):(e.textContent=z(i),e.setAttribute("style","padding: 0.3em")),delete e.old},d=function(t){const n=t.toNT();if(p[n])return p[n];const i=e.createElement("tr"),a=i.appendChild(e.createElement("td"));a.setAttribute("style","padding: 0.3em;"),a.textContent=z(t),"NamedNode"===t.termType&&da.fetcher.nowOrWhenFetched(t.uri.split("#")[0],void 0,function(e,n,i){e&&(a.textContent=z(t))});for(let n=0;n<l.length;n++)u(i.appendChild(e.createElement("td")),g.fromNT(l[n]),t,null);i.dataValueNT=n,p[n]=i;for(let e=r.lastHeader.nextSibling;e;e=e.nextSibling)if(n>e.dataValueNT&&o&&o.yDecreasing||n<e.dataValueNT&&(!o||!o.yDecreasing))return r.insertBefore(i,e);return r.appendChild(i)},m=function(t){const n=t.toNT();let i=null;for(let e=0;e<l.length;e++){if(l[e]===n)return e;if(n>l[e]&&o.xDecreasing||n<l[e]&&!o.xDecreasing){l=l.slice(0,e).concat([n]).concat(l.slice(e)),i=e;break}}null===i&&(i=l.length,l.push(n));for(let n=r.firstChild;n;n=n.nextSibling){const a=n.dataValueNT,o=e.createElement("td");if(o.style.textAlign="center",n===r.firstChild?o.textContent=z(t):u(o,t,g.fromNT(a),null),i===l.length-1)n.appendChild(o);else{let e=n.firstChild;for(let t=0;t<i+1;t++)e=e.nextSibling;n.insertBefore(o,e)}}return i},f=function(){let e,t;const n=[],i=[];if(o.set_y)for(let e=0;e<o.set_y.length;e++)i[o.set_y[e]]=!0;if(o.set_x)for(let e=0;e<o.set_x.length;e++)n[m(o.set_x[e])+1]=!0;for(let a=1;a<r.children.length;a++){e=r.children[a];for(let a=1;a<e.children.length;a++)if(t=e.children[a],t.old){const n=g.fromNT(e.dataValueNT),i=g.fromNT(l[a-1]);u(t,i,n,null)}else i[e.dataValueNT]=!0,n[a]=!0}for(let t=0;t<r.children.length;t++)if(e=r.children[t],t>0&&!i[e.dataValueNT])delete p[e.dataValueNT],r.removeChild(e);else for(let t=e.children.length-1;t>0;t--){const i=e.children[t];n[t]||e.removeChild(i)}const a=[];for(let e=0;e<l.length;e++)n[e+1]&&a.push(l[e]);l=a};r.refresh=function(){!function(){for(let e=1;e<r.children.length;e++){const t=r.children[e];for(let e=1;e<t.children.length;e++)t.children[e].old=!0}}(),da.query(t,h,void 0,f)};const h=function(e){const t=e[n.toString()],o=e[i.toString()],s=e[a.toString()],r=d(o),c=m(t),l=r.children[c+1];u(l,t,o,s)};if(o.set_y)for(let e=0;e<o.set_y.length;e++)d(o.set_y[e]);if(o.set_x)for(let e=0;e<o.set_x.length;e++)m(o.set_x[e]);return da.query(t,h,void 0,s),r}},fa=it.Pt.iconBase+"noun_Camera_1618446_000000.svg",ha=it.Pt.iconBase+"noun_479395.svg";function ga(e,t,n,i){const a=e.createElement("div");let o,s,r,c;const l=a.appendChild(e.createElement("table")),p=l.appendChild(e.createElement("tr")).appendChild(e.createElement("td"));p.setAttribute("colspan","4");const u=l.appendChild(e.createElement("tr"));u.appendChild(e.createElement("td")).appendChild(Mt(e)).addEventListener("click",e=>{b(),i(null)});const d=u.appendChild(e.createElement("td")).appendChild(Ot(e,ha,"Retake"));d.addEventListener("click",e=>{p.removeChild(c),h()}),d.style.visibility="collapse";const m=u.appendChild(e.createElement("td")).appendChild(Ot(e,it.Pt.iconBase+"noun_10636.svg","Snap"));m.addEventListener("click",function(){c=e.createElement("canvas"),c.setAttribute("width",Ke.canvasWidth),c.setAttribute("height",Ke.canvasHeight),c.setAttribute("style",Ke.controlStyle),p.appendChild(c);c.getContext("2d").drawImage(r,0,0,c.width,c.height),r.parentNode.removeChild(r),c.toBlob(e=>{const t=`got blob type ${e.type} size ${e.size}`;ve.Rm(t),o=n(),s=e,f.style.visibility="visible",d.style.visibility="visible",m.style.visibility="collapse"},"image/png")}),m.style.visibility="collapse";const f=u.appendChild(e.createElement("td")).appendChild(Ft(e));function h(){if(r=p.appendChild(e.createElement("video")),r.setAttribute("controls","1"),r.setAttribute("autoplay","1"),r.setAttribute("style",Ke.controlStyle),!navigator.mediaDevices)throw new Error("navigator.mediaDevices not available");navigator.mediaDevices.getUserMedia(g).then(e=>{r.srcObject=e,m.style.visibility="visible",f.style.visibility="collapse",d.style.visibility="collapse"})}f.addEventListener("click",e=>{!function(e,n){const a=e.type;ve.Rm("Putting "+e.size+" bytes of "+a+" to "+n),t.fetcher.webOperation("PUT",n.uri,{data:e,contentType:a}).then(e=>{ve.Rm("ok saved "+n),b(),i(n)},e=>{b(),alert(e)})}(s,o)}),f.style.visibility="collapse";const g={video:!0};function b(){r&&r.srcObject&&r.srcObject.getVideoTracks().forEach(e=>e.stop())}return h(),a}const ba={cameraCaptureControl:ga,cameraButton:function(e,t,n,i){const a=e.createElement("div"),o=Ot(e,fa,"Take picture");let s;async function r(e){a.removeChild(s),a.appendChild(o),i(e)}return a.appendChild(o),o.addEventListener("click",i=>{a.removeChild(o),s=ga(e,t,n,r),a.appendChild(s)}),a}},xa={icons:it.Pt,ns:b,rdf:g,style:Ke,widgets:r};function va(e,t,n,i,a){t=t||x.solidLogicSingleton.store,i=i.doc();const o=xa.ns,s=g.Namespace("http://www.w3.org/2005/01/wf/flow#"),r=g.Namespace("http://purl.org/dc/terms/"),c=!!(a=a||{}).newestFirst,l="white-space: pre-wrap; width: 90%; font-size:100%; border: 0.07em solid #eee; padding: .2em 0.5em; margin: 0.1em 1em 0.1em 1em;",p=e.createElement("div");let u,d;const m=x.solidLogicSingleton.store.updater,f=function(t,n){const i=e.createElement("a");return n&&n.uri&&(i.setAttribute("href",n.uri),i.addEventListener("click",xa.widgets.openHrefInOutlineMode,!0),i.setAttribute("style","color: #3B5998; text-decoration: none; ")),i.textContent=t,i},h=function(t,n){const i=e.createElement("pre");return i.setAttribute("style",n||"color: grey"),p.appendChild(i),i.appendChild(e.createTextNode(t)),i},b=function(e){h(e,"color: #800;")};function v(e){const t=x.solidLogicSingleton.store.any(e,xa.ns.foaf("nick"));return t?""+t.value:""+z(e)}function y(t,n,i,a){const o=t.appendChild(f(v(n),n));n.uri&&x.solidLogicSingleton.store.fetcher.nowOrWhenFetched(n.doc(),void 0,function(e,t){o.textContent=v(n)}),t.appendChild(e.createElement("br")),t.appendChild(f(i,a))}function w(e,n){const i={};let a,s;for(a=n.firstChild;a;a=a.nextSibling)a.AJAR_subject&&(i[a.AJAR_subject.uri]=!0);const r=t.each(e,o.wf("message")),c={};for(r.forEach(function(e){c[e.uri]=!0,i[e.uri]||C(e)}),a=n.firstChild;a;)s=a.nextSibling,a.AJAR_subject&&!c[a.AJAR_subject.uri]&&n.removeChild(a),a=s}const C=function(e){const n={"?msg":e,"?creator":t.any(e,o.foaf("maker")),"?date":t.any(e,r("created")),"?content":t.any(e,o.sioc("content"))};E(n,!0)},E=function(i,a){const o=i["?creator"],s=i["?msg"],r=i["?date"],p=i["?content"],d=r.value,f=e.createElement("tr");f.AJAR_date=d,f.AJAR_subject=s;let h=!1;for(let e=u.firstChild;e;e=e.nextSibling)if(d>e.AJAR_date&&c||d<e.AJAR_date&&!c){u.insertBefore(f,e),h=!0;break}h||u.appendChild(f);const g=e.createElement("td");f.appendChild(g),y(g,o,xa.widgets.shortDate(d),s);const x=e.createElement("td");f.appendChild(x);const v=e.createElement("p");v.setAttribute("style",l+(a?"background-color: #e8ffe8;":"background-color: #white;")),x.appendChild(v),v.textContent=p.value;const C=e.createElement("td");f.appendChild(C);const E=e.createElement("button");C.appendChild(E),E.textContent="-",f.setAttribute("class","hoverControl"),E.setAttribute("class","hoverControlHide"),E.setAttribute("style","color: red;"),E.addEventListener("click",function(i){C.removeChild(E);const a=e.createElement("button");a.textContent="cancel",C.appendChild(a).addEventListener("click",function(e){C.removeChild(o),C.removeChild(a),C.appendChild(E)},!1);const o=e.createElement("button");o.textContent="Delete message",C.appendChild(o).addEventListener("click",function(e){C.removeChild(o),C.removeChild(a),function(e){const i=t.statementsMatching(e).concat(t.statementsMatching(void 0,void 0,e));m.update(i,[],function(e,t,i){t?w(n,u):b("Cant delete messages:"+i)})}(s)},!1)},!1)};u=e.createElement("table"),u.fresh=!1,p.appendChild(u),u.setAttribute("style","width: 100%;");const k=function(){const a=e.createElement("tr"),s=e.createElement("td"),c=e.createElement("td"),p=e.createElement("td");a.appendChild(s),a.appendChild(c),a.appendChild(p),a.AJAR_date="9999-01-01T00:00:00Z";const u=function(){f.setAttribute("class","pendingedit"),f.disabled=!0;const s=[],c=new Date,l=""+c.getTime(),p=g.term(c),u=t.sym(i.uri+"#Msg"+l);s.push(new g.Statement(n,o.wf("message"),u,i)),s.push(new g.Statement(u,o.sioc("content"),t.literal(f.value),i)),s.push(new g.Statement(u,r("created"),p,i)),d&&s.push(new g.Statement(u,o.foaf("maker"),d,i));m.update([],s,function(n,i,o){if(i){const e={"?msg":u,"?content":t.literal(f.value),"?date":p,"?creator":d};E(e,!1),f.value="",f.setAttribute("class",""),f.disabled=!1}else a.appendChild(xa.widgets.errorMessageBlock(e,"Error writing message: "+o))})};let f,h;a.appendChild(e.createElement("br"));return Di({div:c,dom:e}).then(t=>{d=t.me,y(s,d,"",null),f=e.createElement("textarea"),c.innerHTML="",c.appendChild(f),f.rows=3,f.setAttribute("style",l+"background-color: #eef;"),f.addEventListener("keyup",function(e){13===e.keyCode&&(e.altKey||u())},!1),p.innerHTML="",h=xa.widgets.button(e,xa.icons.iconBase+"noun_383448.svg","Send"),h.setAttribute("style",xa.style.buttonStyle+"float: right;"),h.addEventListener("click",u,!1),p.appendChild(h)}),a}();let A;if(c?u.insertBefore(k,u.firstChild):u.appendChild(k),a.query)A=a.query;else{A=new g.Query("Messages");const e={};["msg","date","creator","content"].forEach(function(t){A.vars.push(e[t]=g.variable(t))}),A.pat.add(n,s("message"),e.msg),A.pat.add(e.msg,o.dct("created"),e.date),A.pat.add(e.msg,o.foaf("maker"),e.creator),A.pat.add(e.msg,o.sioc("content"),e.content)}return t.query(A,E,void 0,function(){u.fresh=!0}),p.refresh=function(){w(n,u)},p}async function ya(e){return await x.store.fetcher.load(e),!(x.store.statementsMatching(null,b.dct("created"),null,e).length>0)}class wa{constructor(e,t,n){this.root=e,this.rootFolder=e.dir(),this.leafFileName=t||"index.ttl",this.membershipProperty=n||b.wf("leafObject")}leafDocumentFromDate(e){let t=e.toISOString().split("T")[0].replace(/-/g,"/");return t=this.root.dir().uri+t+"/"+this.leafFileName,x.store.sym(t)}dateFromLeafDocument(e){const t=this.rootFolder.uri.length,n=e.uri.slice(t,t+10).replace(/\//g,"-");return new Date(n)}async loadPrevious(e,t){async function n(e,i){function a(e){const t=e.uri.slice(0,-1).split("/").slice(-1)[0];return!!"0123456789".includes(t[0])}function o(e){return(e=e.filter(a)).sort(),t||e.reverse(),e.pop()}const s=e.dir();try{await x.store.fetcher.load(s);let n=x.store.each(s,b.ldp("contains"));n=n.filter(function(n){return!(t?n.uri>=e.uri:n.uri<=e.uri)});const i=o(n);if(i)return i}catch(e){if(!e.response||!e.response.status||404!==e.response.status)throw ve.Rm("*** Error NON 404 for chat parent file "+s),new Error(`*** ${e.message} for chat folder ${s}`);ve.Rm("Error 404 for chat parent file "+s)}if(0===i)return null;const r=await n(s,i-1);if(!r)return null;await x.store.fetcher.load(r);return o(x.store.each(r,b.ldp("contains")))}let i=this.leafDocumentFromDate(e).dir();for(;;){const t=await n(i,3);if(!t)return null;{const n=x.store.sym(t.uri+this.leafFileName),a=this.dateFromLeafDocument(n);if(!await ya(n))return a;e=a,i=this.leafDocumentFromDate(e).dir()}}}async firstLeaf(e){const t=g.graph(),n=new g.Fetcher(t);async function i(i){delete n.requested[i.uri],await n.load(i,{force:!0});let a=t.each(i,b.ldp("contains"));if(a=a.filter(function(e){const t=e.uri.slice(0,-1).split("/").slice(-1)[0];return!!"0123456789".includes(t[0])}),0===a.length)throw new Error(" @@@ No children to parent2 "+i);return a.sort(),e&&a.reverse(),a[0]}const a=await i(this.root.dir()),o=await i(a),s=await i(o),r=g.sym(s.uri+"chat.ttl");await n.load(r);const c=t.each(this.root,this.membershipProperty,null,r);if(0===c.length){const e=" INCONSISTENCY -- no chat leafObject in file "+r;throw ve.uP(e),new Error(e)}const l=c.map(e=>[t.any(e,b.dct("created")),e]);return l.sort(),e&&l.reverse(),l[0][1]}}function Ca(e,t=""){if("number"!=typeof e){throw new TypeError(`${t&&`"${t}" `}expected number, got ${typeof e}`)}if(!Number.isSafeInteger(e)||e<0){throw new RangeError(`${t&&`"${t}" `}expected integer >= 0, got ${e}`)}}function Ea(e,t,n=""){const i=(a=e)instanceof Uint8Array||ArrayBuffer.isView(a)&&"Uint8Array"===a.constructor.name&&"BYTES_PER_ELEMENT"in a&&1===a.BYTES_PER_ELEMENT;var a;const o=e?.length,s=void 0!==t;if(!i||s&&o!==t){const a=(n&&`"${n}" `)+"expected Uint8Array"+(s?` of length ${t}`:"")+", got "+(i?`length=${o}`:"type="+typeof e);if(!i)throw new TypeError(a);throw new RangeError(a)}return e}function ka(e,t=!0){if(e.destroyed)throw new Error("Hash instance has been destroyed");if(t&&e.finished)throw new Error("Hash#digest() has already been called")}function Aa(...e){for(let t=0;t<e.length;t++)e[t].fill(0)}function Ta(e){return new DataView(e.buffer,e.byteOffset,e.byteLength)}function ja(e,t){return e<<32-t|e>>>t}const _a=(()=>"function"==typeof Uint8Array.from([]).toHex&&"function"==typeof Uint8Array.fromHex)(),La=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0"));function Sa(e){if(Ea(e),_a)return e.toHex();let t="";for(let n=0;n<e.length;n++)t+=La[e[n]];return t}const Ra=48,Na=57,Ia=65,Ba=70,Da=97,Oa=102;function Ma(e){return e>=Ra&&e<=Na?e-Ra:e>=Ia&&e<=Ba?e-(Ia-10):e>=Da&&e<=Oa?e-(Da-10):void 0}function Fa(e){if("string"!=typeof e)throw new TypeError("hex string expected, got "+typeof e);if(_a)try{return Uint8Array.fromHex(e)}catch(e){if(e instanceof SyntaxError)throw new RangeError(e.message);throw e}const t=e.length,n=t/2;if(t%2)throw new RangeError("hex string expected, got unpadded hex of length "+t);const i=new Uint8Array(n);for(let t=0,a=0;t<n;t++,a+=2){const n=Ma(e.charCodeAt(a)),o=Ma(e.charCodeAt(a+1));if(void 0===n||void 0===o){const t=e[a]+e[a+1];throw new RangeError('hex string expected, got non-hex character "'+t+'" at index '+a)}i[t]=16*n+o}return i}function Ua(e,t={}){const n=(t,n)=>e(n).update(t).digest(),i=e(void 0);return n.outputLen=i.outputLen,n.blockLen=i.blockLen,n.canXOF=i.canXOF,n.create=t=>e(t),Object.assign(n,t),Object.freeze(n)}function za(e=32){Ca(e,"bytesLength");const t="object"==typeof globalThis?globalThis.crypto:null;if("function"!=typeof t?.getRandomValues)throw new Error("crypto.getRandomValues must be defined");if(e>65536)throw new RangeError(`"bytesLength" expected <= 65536, got ${e}`);return t.getRandomValues(new Uint8Array(e))}const Pa=e=>({oid:Uint8Array.from([6,9,96,134,72,1,101,3,4,2,e])});function $a(e,t,n){return e&t^~e&n}function qa(e,t,n){return e&t^e&n^t&n}class Ha{blockLen;outputLen;canXOF=!1;padOffset;isLE;buffer;view;finished=!1;length=0;pos=0;destroyed=!1;constructor(e,t,n,i){this.blockLen=e,this.outputLen=t,this.padOffset=n,this.isLE=i,this.buffer=new Uint8Array(e),this.view=Ta(this.buffer)}update(e){ka(this),Ea(e);const{view:t,buffer:n,blockLen:i}=this,a=e.length;for(let o=0;o<a;){const s=Math.min(i-this.pos,a-o);if(s===i){const t=Ta(e);for(;i<=a-o;o+=i)this.process(t,o);continue}n.set(e.subarray(o,o+s),this.pos),this.pos+=s,o+=s,this.pos===i&&(this.process(t,0),this.pos=0)}return this.length+=e.length,this.roundClean(),this}digestInto(e){ka(this),function(e,t){Ea(e,void 0,"digestInto() output");const n=t.outputLen;if(e.length<n)throw new RangeError('"digestInto() output" expected to be of length >='+n)}(e,this),this.finished=!0;const{buffer:t,view:n,blockLen:i,isLE:a}=this;let{pos:o}=this;t[o++]=128,Aa(this.buffer.subarray(o)),this.padOffset>i-o&&(this.process(n,0),o=0);for(let e=o;e<i;e++)t[e]=0;n.setBigUint64(i-8,BigInt(8*this.length),a),this.process(n,0);const s=Ta(e),r=this.outputLen;if(r%4)throw new Error("_sha2: outputLen must be aligned to 32bit");const c=r/4,l=this.get();if(c>l.length)throw new Error("_sha2: outputLen bigger than state");for(let e=0;e<c;e++)s.setUint32(4*e,l[e],a)}digest(){const{buffer:e,outputLen:t}=this;this.digestInto(e);const n=e.slice(0,t);return this.destroy(),n}_cloneInto(e){e||=new this.constructor,e.set(...this.get());const{blockLen:t,buffer:n,length:i,finished:a,destroyed:o,pos:s}=this;return e.destroyed=o,e.finished=a,e.length=i,e.pos=s,i%t&&e.buffer.set(n),e}clone(){return this._cloneInto()}}const Ga=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]);const Va=Uint32Array.from([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),Wa=new Uint32Array(64);class Ja extends Ha{constructor(e){super(64,e,8,!1)}get(){const{A:e,B:t,C:n,D:i,E:a,F:o,G:s,H:r}=this;return[e,t,n,i,a,o,s,r]}set(e,t,n,i,a,o,s,r){this.A=0|e,this.B=0|t,this.C=0|n,this.D=0|i,this.E=0|a,this.F=0|o,this.G=0|s,this.H=0|r}process(e,t){for(let n=0;n<16;n++,t+=4)Wa[n]=e.getUint32(t,!1);for(let e=16;e<64;e++){const t=Wa[e-15],n=Wa[e-2],i=ja(t,7)^ja(t,18)^t>>>3,a=ja(n,17)^ja(n,19)^n>>>10;Wa[e]=a+Wa[e-7]+i+Wa[e-16]|0}let{A:n,B:i,C:a,D:o,E:s,F:r,G:c,H:l}=this;for(let e=0;e<64;e++){const t=l+(ja(s,6)^ja(s,11)^ja(s,25))+$a(s,r,c)+Va[e]+Wa[e]|0,p=(ja(n,2)^ja(n,13)^ja(n,22))+qa(n,i,a)|0;l=c,c=r,r=s,s=o+t|0,o=a,a=i,i=n,n=t+p|0}n=n+this.A|0,i=i+this.B|0,a=a+this.C|0,o=o+this.D|0,s=s+this.E|0,r=r+this.F|0,c=c+this.G|0,l=l+this.H|0,this.set(n,i,a,o,s,r,c,l)}roundClean(){Aa(Wa)}destroy(){this.destroyed=!0,this.set(0,0,0,0,0,0,0,0),Aa(this.buffer)}}class Qa extends Ja{A=0|Ga[0];B=0|Ga[1];C=0|Ga[2];D=0|Ga[3];E=0|Ga[4];F=0|Ga[5];G=0|Ga[6];H=0|Ga[7];constructor(){super(32)}}const Za=Ua(()=>new Qa,Pa(1));
|
|
13
|
+
class ii{_data;_domElements;_event=()=>{};_itemTemplate;_multiselect;_noData;_noResults;_options=[];_placeholder;_select;_selectContainer;_selectedOptions=[];_tagTemplate;_textField;_valueField;_cross='\n <svg\n width="24"\n height="24"\n viewBox="0 0 24 24"\n fill="none"\n xmlns="http://www.w3.org/2000/svg"\n >\n <path\n d="M6.2253 4.81108C5.83477 4.42056 5.20161 4.42056 4.81108 4.81108C4.42056 5.20161 4.42056 5.83477 4.81108 6.2253L10.5858 12L4.81114 17.7747C4.42062 18.1652 4.42062 18.7984 4.81114 19.1889C5.20167 19.5794 5.83483 19.5794 6.22535 19.1889L12 13.4142L17.7747 19.1889C18.1652 19.5794 18.7984 19.5794 19.1889 19.1889C19.5794 18.7984 19.5794 18.1652 19.1889 17.7747L13.4142 12L19.189 6.2253C19.5795 5.83477 19.5795 5.20161 19.189 4.81108C18.7985 4.42056 18.1653 4.42056 17.7748 4.81108L12 10.5858L6.2253 4.81108Z"\n fill="currentColor"\n />\n </svg>\n ';constructor({data:e,itemTemplate:t,noData:n,noResults:i,placeholder:a,select:o,container:s,tagTemplate:r,textField:c,valueField:l}){this._data=e??[],this._itemTemplate=t??null,this._noData=n??"No data found.",this._noResults=i??"No results found.",this._placeholder=a??"Select...",this._select=o,this._selectContainer=s,this._tagTemplate=r??null,this._textField=c??null,this._valueField=l??null}init(){if(!this._select||"SELECT"!==this._select.nodeName)throw new Error(`The selector '${this._select}' did not select any valid select tag.`);if(this._itemTemplate&&0===this._data.length)throw new Error("itemTemplate must be initialized with data from the component settings");if(this._tagTemplate&&0===this._data.length)throw new Error("tagTemplate must be initialized with data from the component settings");this._options=this._data.length>0?this._getDataFromSettings():this._getDataFromSelectTag(),this._renderMultiselect(),this._renderOptionsList(),this._domElements={clear:this._multiselect.querySelector(".multiselect__clear-btn"),input:this._multiselect.querySelector(".multiselect__input"),optionsContainer:this._multiselect.querySelector(".multiselect__options"),optionsContainerList:this._multiselect.querySelector(".multiselect__options > ul"),options:{list:this._multiselect.querySelectorAll(".multiselect__options > ul > li"),find:function(e){for(let t=0;t<this.list.length;t++){const n=this.list[t];if(e(n))return n}},some:function(e){for(let t=0;t<this.list.length;t++){if(e(this.list[t],t))return!0}return!1}}},this._enableEventListenners(),this._initSelectedList()}subscribe(e){if("function"!=typeof e)throw new Error("parameter in the subscribe method is not a function");this._event=e}_addOptionToList(e,t){const n=`<span class="multiselect__selected" style="${ni.multiselect__selected}" data-value="${e.value}">${this._tagTemplate?this._processTemplate(this._tagTemplate,t):e.text}<span class="multiselect__remove-btn" style="${ni.multiselect__remove_btn}">${this._cross}</span></span>`;this._domElements.input.insertAdjacentHTML("beforebegin",n);const{lastElementChild:i}=this._multiselect.querySelector(`span[data-value="${e.value}"]`);i.addEventListener("click",()=>{const t=this._domElements.options.find(t=>t.dataset.value===e.value);this._handleOption(t)})}_clearSelection(){for(let e=0;e<this._selectedOptions.length;e++){const t=this._selectedOptions[e],n=this._domElements.options.find(e=>e.dataset.value===t.value);n.classList.remove("multiselect__options--selected"),n.setAttribute("style",ni.multiselect__options),this._removeOptionFromList(n.dataset.value)}this._selectedOptions=[],this._handleClearSelectionBtn(),this._handlePlaceholder(),this._dispatchEvent({action:"CLEAR_ALL_OPTIONS",selection:this._selectedOptions})}_closeList(){this._domElements.input.value="",this._domElements.optionsContainer.classList.remove("visible"),this._domElements.optionsContainer.setAttribute("style",ni.multiselect__options),this._filterOptions(""),this._removeAllArrowSelected()}_dispatchEvent(e){this._event(e)}_enableEventListenners(){document.addEventListener("mouseup",({target:e})=>{this._multiselect.contains(e)||(this._filterOptions(""),this._closeList(),this._handlePlaceholder())}),this._domElements.clear.addEventListener("click",()=>{this._clearSelection()});for(let e=0;e<this._domElements.options.list.length;e++){this._domElements.options.list[e].addEventListener("click",({target:e})=>{this._handleOption(e),this._closeList()})}this._domElements.input.addEventListener("focus",()=>{this._domElements.optionsContainer.classList.add("visible"),this._domElements.optionsContainer.setAttribute("style",ni.multiselect__options_visible)}),this._domElements.input.addEventListener("input",({target:{value:e}})=>{this._domElements.options.list.length>0&&this._filterOptions(e)}),this._domElements.input.addEventListener("keydown",e=>{this._handleArrows(e),this._handleBackspace(e),this._handleEnter(e)})}_filterOptions(e){const t=this._domElements.optionsContainer.classList.contains("visible"),n=e.toLowerCase();if(!t&&e.length>0&&(this._domElements.optionsContainer.classList.add("visible"),this._domElements.optionsContainer.setAttribute("style",ni.multiselect__options_visible)),this._domElements.options.list.length>0){for(let e=0;e<this._domElements.options.list.length;e++){const t=this._domElements.options.list[e];(this._itemTemplate?this._data[e][this._textField]:t.textContent).toLowerCase().substring(0,n.length)===n?this._domElements.optionsContainerList.appendChild(t):t.parentNode&&t.parentNode.removeChild(t)}const e=this._domElements.options.some((e,t)=>(this._itemTemplate?this._data[t][this._textField]:e.textContent).toLowerCase().substring(0,n.length)===n);this._showNoResults(!e)}}_generateId(e){let t="";const n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";for(let i=0;i<e;i++)t+=n.charAt(Math.floor(62*Math.random()));return t}_getDataFromSelectTag(){const e=[],{options:t}=this._select;for(let n=0;n<t.length;n++){const i=t[n];e.push({text:i.text,value:i.value,selected:i.hasAttribute("selected")})}return e}_getDataFromSettings(){if(this._data.length>0&&this._valueField&&this._textField){const e="string"==typeof this._valueField,t="string"==typeof this._textField,n=[];if(!e||!t)throw new Error("textField and valueField must be of type string");for(let e=0;e<this._data.length;e++){const t=this._data[e];n.push({value:t[this._valueField],text:t[this._textField],selected:"boolean"==typeof t.selected&&t.selected})}return n}return null}_handleArrows(e){if(40===e.keyCode||38===e.keyCode){e.preventDefault();const t=this._domElements.optionsContainer.classList.contains("visible"),n=this._multiselect.querySelector(".multiselect__options > ul");if(t){let t=this._multiselect.querySelector(".multiselect__options ul li.arrow-selected");const i={ArrowUp:"previous",Up:"previous",ArrowDown:"next",Down:"next"};if(!t)return n.firstElementChild.classList.add("arrow-selected"),n.firstElementChild.setAttribute("style",ni.multiselect__options_ul_li_arrow_selected),void n.firstElementChild.scrollIntoView(!1);if(t.classList.remove("arrow-selected"),t.setAttribute("style",ni.multiselect__options_ul_li),t=t[i[e.key]+"ElementSibling"],!t)return t=n.children["next"===i[e.key]?0:n.children.length-1],t.classList.add("arrow-selected"),t.setAttribute("style",ni.multiselect__options_ul_li_arrow_selected),void this._scrollIntoView(n,t);t.classList.add("arrow-selected"),t.setAttribute("style",ni.multiselect__options_ul_li_arrow_selected),this._scrollIntoView(n,t)}else this._domElements.optionsContainer.classList.add("visible"),this._domElements.optionsContainer.setAttribute("style",ni.multiselect__options_visible),n.firstElementChild.classList.add("arrow-selected"),n.firstElementChild.setAttribute("style",ni.multiselect__options_ul_li_arrow_selected),n.firstElementChild.scrollIntoView(!1)}}_handleBackspace(e){if(8===e.keyCode&&""===e.target.value){const e=this._selectedOptions.length>0?this._selectedOptions[this._selectedOptions.length-1]:null;if(e){const t=this._multiselect.querySelector(`li[data-value="${e.value}"]`);this._handleOption(t),0===this._selectedOptions.length&&(this._domElements.optionsContainer.classList.remove("visible"),this._domElements.optionsContainer.setAttribute("style",ni.multiselect__options))}}}_handleClearSelectionBtn(){this._selectedOptions.length>0?this._domElements.clear.style.display="flex":this._domElements.clear.style.display="none"}_handleEnter(e){if(13===e.keyCode){const e=this._multiselect.querySelector(".multiselect__options ul li.arrow-selected");e&&(this._handleOption(e),this._closeList())}}_handleOption(e,t=!0){for(let n=0;n<this._selectedOptions.length;n++){if(this._selectedOptions[n].value===e.dataset.value)return e.classList.remove("multiselect__options--selected"),e.setAttribute("style",ni.multiselect__options),this._selectedOptions.splice(n,1),this._removeOptionFromList(e.dataset.value),this._handleClearSelectionBtn(),this._handlePlaceholder(),t&&this._dispatchEvent({action:"REMOVE_OPTION",value:e.dataset.value,selection:this._selectedOptions})}for(let n=0;n<this._options.length;n++){const i=this._options[n];if(i.value===e.dataset.value)return e.classList.add("multiselect__options--selected"),e.setAttribute("style",ni.multiselect__options_selected),this._selectedOptions=[...this._selectedOptions,i],this._addOptionToList(i,n),this._handleClearSelectionBtn(),this._handlePlaceholder(),t&&this._dispatchEvent({action:"ADD_OPTION",value:e.dataset.value,selection:this._selectedOptions})}}_handlePlaceholder(){this._domElements.input.placeholder=this._placeholder}_initSelectedList(){let e=!1;for(let t=0;t<this._options.length;t++){const n=this._options[t];if(n.selected){e=!0;const i=this._domElements.options.find(e=>e.dataset.value===n.value);i.classList.add("multiselect__options--selected"),i.setAttribute("style",ni.multiselect__options_selected),this._selectedOptions=[...this._selectedOptions,n],this._addOptionToList(n,t)}}e&&this._handleClearSelectionBtn(),this._handlePlaceholder()}_processTemplate(e,t){let n=e;const i=e.match(/\$\{(\w+)\}/g).map(e=>e.replace(/\$\{|\}/g,""));for(let e=0;e<i.length;e++){const a=i[e];n=n.replace(`\${${a}}`,this._data[t][a]??"")}return n}_removeAllArrowSelected(){const e="arrow-selected",t=this._domElements.options.find(t=>t.classList.contains(e));t&&t.classList.remove(e)&&t.setAttribute("style",ni.multiselect__options_ul_li)}_removeOptionFromList(e){const t=this._multiselect.querySelector(`span[data-value="${e}"]`);t&&t.parentNode&&t.parentNode.removeChild(t)}_renderOptionsList(){const e=`\n <div class="multiselect__options" style="${ni.multiselect__options}">\n <ul style="${ni.multiselect__options_ul}">\n ${this._options.length>0&&!this._itemTemplate?this._options.map(e=>`\n <li data-value="${e.value}" style="${ni.multiselect__options_ul_li}">${e.text}</li>\n `).join(""):""}\n\n ${this._options.length>0&&this._itemTemplate?this._options.map((e,t)=>`\n <li data-value="${e.value}" style="${ni.multiselect__options_ul_li}">${this._processTemplate(this._itemTemplate,t)}</li>\n `).join(""):""}\n ${this._showNoData(0===this._options.length)}\n </ul>\n </div>\n `;this._multiselect.insertAdjacentHTML("beforeend",e)}_renderMultiselect(){this._select.style.display="none";const e="iconic-"+this._generateId(20);this._multiselect=document.createElement("div"),this._multiselect.setAttribute("id",e),this._multiselect.setAttribute("class","multiselect__container"),this._multiselect.setAttribute("style",ni.multiselect__container);const t=`\n <div class="multiselect__wrapper" style="${ni.multiselect__wrapper}">\n <input class="multiselect__input" style="${ni.multiselect__input}" placeholder="${this._placeholder}" />\n </div>\n <span style="display: none;" class="multiselect__clear-btn" style="${ni.multiselect__clear_btn}">${this._cross}</span>\n `;this._multiselect.innerHTML=t,this._selectContainer.appendChild(this._multiselect)}_scrollIntoView(e,t){const n=e.getBoundingClientRect(),i=t.getBoundingClientRect();n.top<i.bottom-t.offsetHeight||(e.scrollTop=t.clientHeight+(t.offsetTop-t.offsetHeight)),n.bottom>i.top+t.offsetHeight||(e.scrollTop=t.clientHeight+(t.offsetTop-t.offsetHeight)-(e.offsetHeight-(t.offsetHeight+(t.offsetHeight-t.clientHeight))))}_showNoData(e){return e?`<p class="multiselect__options--no-data" style="${ni.multiselect__options_ul_p_multiselect__options_no_data}">${this._noData}</p>`:""}_showNoResults(e){const t=this._multiselect.querySelector(".multiselect__options--no-results");if(e){const e=`<p class="multiselect__options--no-results" style="${ni.multiselect__options_ul_p_multiselect__options_no_results}">${this._noResults}</p>`;!t&&this._domElements.optionsContainerList.insertAdjacentHTML("beforeend",e)}else t&&t.parentNode&&t.parentNode.removeChild(t)}}const ai=x.store;function oi(e,t,n,i,a,o,s){const r=o.children;for(let c=0;c<s.length;c++){const l=s[c];if(un(l)===b.ui("Options").uri){const s=dn(0,l)(e,null,t,n,l,i,a);ve.Rm("Refreshing Options field by replacing it."),o.insertBefore(s,r[c]),o.removeChild(r[c+1])}}}function si(e,t,n,i,a,o,s,r){const c=b.ui,l=x.store,p=l.any(a,c("property"));if(!p){const n=nt(e,"No property to boolean field: "+a);return t&&t.appendChild(n),n}let u=l.any(a,c("label"));u||(u=U(p,!0)),o=bn(i,p,o);let d=l.any(i,p);void 0===d&&(d=!1);const m=g.st(i,p,!0,o),f=Ci(e,l,u,g.st(i,p,!1,o),m,a,o,r);return t&&t.appendChild(f),f}function ri(e,t,n,i,a,o,s){dn(0,a)(e,t,n,i,a,o,s)}function ci(e,t,n,i,a){const o=e.createElement("button");return o.setAttribute("type","button"),o.innerHTML="Edit "+U(b.ui("Form")),o.addEventListener("click",function(s){li(e,t,{},n,b.ui("FormForm"),i,a).setAttribute("style",b.ui("FormForm").sameTerm(n)?"background-color: #fee;":"background-color: #ffffe7;"),o.parentNode.removeChild(o)},!0),o}function li(e,t,n,i,a,o,s){return dn(0,a)(e,t,n,i,a,o,s)}function pi(e,t){const n=e.each(void 0,b.rdf("range"),t);[b.rdfs("comment"),b.dc("title"),b.foaf("name"),b.foaf("homepage")].forEach(function(e){n.push(e)});let i=e.each(void 0,b.rdf("type"),t);i.length>60&&(i=i.slice(0,60));const a={};for(let t=0;t<(i.length>60?60:i.length);t++)e.statementsMatching(i[t],void 0,void 0).forEach(function(e){a[e.predicate.uri]=!0});n.forEach(function(e){a[e.uri]=!0});const o=[];for(const t in a)o.push(e.sym(t));return o}function ui(e,t,n){const i=[e.sym(t)];for(;i.length>0;){const t=i.shift(),a=e.each(t,n);if(j("Lists for "+t+", "+n+": "+a.length),0!==a.length)return a;const o=e.each(t,b.rdfs("subClassOf"));for(let e=0;e<o.length;e++)i.push(o[e]),j("findClosest: add super: "+o[e])}return[]}function di(e){const t=x.store;j("formsFor: subject="+e);const n=t.findTypeURIs(e);let i;for(i in n)j(" type: "+i);const a=t.bottomTypeURIs(n);let o=[];for(const e in a)j("candidatesFor: trying bottom type ="+e),o=o.concat(ui(t,e,b.ui("creationForm"))),o=o.concat(ui(t,e,b.ui("annotationForm")));return o}function mi(e){const t=e.map(function(e){return[ai.any(e,b.ui("sequence"))||9999,e]});return t.sort(function(e,t){return e[0]-t[0]}),t.map(function(e){return e[1]})}function fi(e){const t=e.map(function(e){return[U(e).toLowerCase(),e]});return t.sort(),t.map(function(e){return e[1]})}function hi(e,t,n,i,a,o,s,r){const c=e.createElement("button");return c.setAttribute("type","button"),c.innerHTML="New "+U(a),c.addEventListener("click",function(l){c.parentNode.appendChild(gi(e,t,n,i,a,o,s,r))},!1),c}function gi(e,t,n,i,a,o,s,r){const c=e.createElement("form");if(!o){const n=ui(t,a.uri,b.ui("creationForm"));if(0===n.length){c.appendChild(e.createElement("p")).textContent="I am sorry, you need to provide information about a "+U(a)+" but I don't know enough information about those to ask you.";const t=c.appendChild(e.createElement("button"));return t.setAttribute("type","button"),t.setAttribute("style","float: right;"),t.innerHTML="Goto "+U(a),t.addEventListener("click",function(t){e.outlineManager.GotoSubject(a,!0,void 0,!0,void 0)},!1),c}j("lists[0] is "+n[0]),o=n[0]}j("form is "+o),c.setAttribute("style",`border: 0.05em solid ${qe}; color: ${qe}`),c.innerHTML="<h3>New "+U(a)+"</h3>";const l=dn(0,o),p=Ei(s);let u=!1;function d(e,t,n){return r(t,n)}_("paneUtils Object is "+p);const m=l(e,c,{},p,o,s,function(o,l){if(!o)return r(o,l);const m=[];n&&!t.holds(n,i,p,s)&&m.push(g.st(n,i,p,s)),n&&!t.holds(p,b.rdf("type"),a,s)&&m.push(g.st(p,b.rdf("type"),a,s)),m.length?t.updater.update([],m,d):r(!0,l),u||(u=c.appendChild(Yt(e,p)))});return Kt(e,m).setAttribute("style","float: right;"),c.AJAR_subject=p,c}function bi(e,t,n,i,a,o){const s=e.createElement("div"),r=t.anyJS(n,i,null,a)||"",c=e.createElement("textarea");function l(r){p.disabled=!0,p.setAttribute("style","visibility: hidden; float: right;"),c.disabled=!0,c.style.color=Je;const l=t.statementsMatching(n,i,null,a),u=g.st(n,i,c.value,a);t.updater.update(l,u,function(t,n,i){n?(c.style.color=We,c.disabled=!1):s.appendChild(nt(e,"Error (while saving change to "+a.uri+"): "+i)),o&&o(n,i)})}s.appendChild(c),c.rows=r?r.split("\n").length+2:2,c.cols=80,c.setAttribute("style",Ke.multilineTextInputStyle),null!==r?c.value=r:c.select(),s.refresh=function(){const e=t.any(n,i,null,a);e&&e.value!==c.value&&(c.value=e.value)};let p;return t.updater.editable(a.uri)?(p=Ft(e,l),p.disabled=!0,p.style.visibility="hidden",p.style.float="right",s.appendChild(p),c.addEventListener("keyup",function(e){c.style.color="green",p&&(p.disabled=!1,p.style.visibility="")},!0),c.addEventListener("change",l,!0)):(c.disabled=!0,c.style.backgroundColor=Ve),s}function xi(e,t,n,i,a,o,s,r){j("Select list length now "+a.length);let c=0;const l={},p=t.updater.editable(s.uri);for(let e=0;e<a.length;e++){const t=a[e];t.uri||ve.R8(`makeSelectForClassifierOptions: option does not have an uri: ${t}, with predicate: ${i}`),t.uri&&!(t.uri in l)&&(l[t.uri]=!0,c++)}if(0===c&&!o.mint)return nt(e,"Can't do selector with no options, subject= "+n+" property = "+i+".");let u;j("makeSelectForClassifierOptions: dataDoc="+s);const d=function(){return u={},i.sameTerm(b.rdf("type"))?u=t.findTypeURIs(n):t.each(n,i,null,s).forEach(function(e){u[e.uri]=!0}),u};u=d();const m=function(a){f.disabled=!0;const c=[];let l=[];const p=function(e){t.holds(n,i,e,s)&&c.push(g.st(n,i,e,s))};let m;for(let a=0;a<f.options.length;a++){const c=f.options[a];if(c.selected&&c.AJAR_mint){if(o.mintClass){const a=gi(e,t,n,i,o.mintClass,null,s,function(e,t){e||r(e,t,{change:"new"})});f.parentNode.appendChild(a),m=a.AJAR_subject}else m=Ei(s);l.push(g.st(n,i,m,s)),o.mintStatementsFun&&(l=l.concat(o.mintStatementsFun(m)))}c.AJAR_uri&&(c.selected&&!(c.AJAR_uri in u)&&l.push(g.st(n,i,t.sym(c.AJAR_uri),s)),!c.selected&&c.AJAR_uri in u&&p(t.sym(c.AJAR_uri)),c.selected&&(f.currentURI=c.AJAR_uri))}let h=f.subSelect;for(;h&&h.currentURI;)p(t.sym(h.currentURI)),h=h.subSelect;for(h=f.superSelect;h&&h.currentURI;)p(t.sym(h.currentURI)),h=h.superSelect;function b(e,t){r(e,{widget:"select",event:"new"})}_("makeSelectForClassifierOptions: data doc = "+s),t.updater.update(c,l,function(t,n,i){if(u=d(),!n)return f.parentNode.appendChild(nt(e,"Error updating data in select: "+i));if(f.disabled=!1,m){dn(0,o.subForm)(e,f.parentNode,{},m,o.subForm,s,b)}r&&r(n,{widget:"select",event:"change"})})},f=e.createElement("select");f.setAttribute("style",Ke.formSelectStyle),o.multiple&&f.setAttribute("multiple","true"),f.currentURI=null,f.refresh=function(){u=d();for(let e=0;e<f.children.length;e++){const t=f.children[e];t.AJAR_uri&&(t.selected=t.AJAR_uri in u)}f.disabled=!1};for(const n in l){const i=t.sym(n),a=e.createElement("option");o.disambiguate?a.appendChild(e.createTextNode(ue(i,!0))):a.appendChild(e.createTextNode(U(i,!0)));const s=t.any(i,t.sym("http://www.w3.org/ns/ui#backgroundColor"));s&&a.setAttribute("style","background-color: "+s.value+"; "),a.AJAR_uri=n,n in u&&(a.setAttribute("selected","true"),f.currentURI=n),f.appendChild(a)}if(p&&o.mint){const t=e.createElement("option");t.appendChild(e.createTextNode(o.mint)),t.AJAR_mint=!0,f.insertBefore(t,f.firstChild)}if(null==f.currentURI&&!o.multiple){const t=e.createElement("option");t.appendChild(e.createTextNode(o.nullLabel)),f.insertBefore(t,f.firstChild),t.selected=!0}return p&&f.addEventListener("change",m,!1),f}function vi(e,t,n,i,a,o,s,r){j("Select list length now "+a.length);let c=0;const l={},p=t.updater.editable(s.uri);for(let e=0;e<a.length;e++){const t=a[e];t.uri||ve.R8(`makeSelectForOptions: option does not have an uri: ${t}, with predicate: ${i}`),t.uri&&!(t.uri in l)&&(l[t.uri]=!0,c++)}if(0===c)return nt(e,"Can't do selector with no options, subject= "+n+" property = "+i+".");let u;j("makeSelectForOptions: dataDoc="+s);const d=function(){return u={},i.sameTerm(b.rdf("type"))?u=t.findTypeURIs(n):t.each(n,i,null,s).forEach(function(e){e.uri&&(u[e.uri]=!0)}),u};u=d();const m=function(a){f.disabled=!0;const o=[],c=[],l=function(e){t.holds(n,i,e,s)&&o.push(g.st(n,i,e,s))};for(let e=0;e<f.options.length;e++){const a=f.options[e];a.AJAR_uri&&(a.selected&&!(a.AJAR_uri in u)&&c.push(g.st(n,i,t.sym(a.AJAR_uri),s)),!a.selected&&a.AJAR_uri in u&&l(t.sym(a.AJAR_uri)),a.selected&&(f.currentURI=a.AJAR_uri))}let p=f.subSelect;for(;p&&p.currentURI;)l(t.sym(p.currentURI)),p=p.subSelect;for(p=f.superSelect;p&&p.currentURI;)l(t.sym(p.currentURI)),p=p.superSelect;_("selectForOptions: data doc = "+s),t.updater.update(o,c,function(t,n,i){if(u=d(),!n)return f.parentNode.appendChild(nt(e,"Error updating data in select: "+i));f.disabled=!1,r&&r(n,{widget:"select",event:"change"})})},f=e.createElement("select");f.setAttribute("style",Ke.formSelectStyle),f.currentURI=null,f.refresh=function(){u=d();for(let e=0;e<f.children.length;e++){const t=f.children[e];t.AJAR_uri&&(t.selected=t.AJAR_uri in u)}f.disabled=!1};for(const n in l){const i=t.sym(n),a=e.createElement("option");o.disambiguate?a.appendChild(e.createTextNode(ue(i,!0))):a.appendChild(e.createTextNode(U(i,!0)));const s=t.any(i,t.sym("http://www.w3.org/ns/ui#backgroundColor"));s&&a.setAttribute("style","background-color: "+s.value+"; "),a.AJAR_uri=n,n in u&&(a.setAttribute("selected","true"),f.currentURI=n),f.appendChild(a)}if(!f.currentURI){const t=e.createElement("option");t.appendChild(e.createTextNode(o.nullLabel)),f.insertBefore(t,f.firstChild),t.selected=!0}return p&&f.addEventListener("change",m,!1),f}function yi(e,t,n,i,a,o){const s=t.any(i,b.owl("disjointUnionOf"));let r,c=!1;return s?r=s.elements:(r=t.each(void 0,b.rdfs("subClassOf"),i),c=!0),j("Select list length "+r.length),0===r.length?nt(e,"Can't do "+(c?"multiple ":"")+"selector with no subclasses of category: "+i):1===r.length?nt(e,"Can't do "+(c?"multiple ":"")+"selector with only 1 subclass of category: "+i+":"+r[1]):xi(e,t,n,b.rdf("type"),r,{multiple:c,nullLabel:"* Select type *"},a,o)}function wi(e,t,n,i,a,o){function s(){c&&(r.removeChild(c),c=null),l.currentURI&&t.any(t.sym(l.currentURI),b.owl("disjointUnionOf"))&&(c=wi(e,t,n,t.sym(l.currentURI),a,o),l.subSelect=c.firstChild,l.subSelect.superSelect=l,r.appendChild(c))}const r=e.createElement("span");let c=null;const l=yi(e,t,n,i,a,function(e,t){e&&s(),o(e,t)});return r.appendChild(l),s(),r}function Ci(e,t,n,i,a,o,s,r){const c=e.createElement("div"),l=hn(e,t,c,o,n),p=t.updater.editable(s.uri),u=e.createElement("button"),d=u;function m(e){if(!e)return[];if(e.object)return e.why||(e.why=s),[e];if(e instanceof Array)return e;throw new Error("buildCheckboxForm: bad param "+e)}function f(e){return 0===e.filter(e=>!t.holds(e.subject,e.predicate,e.object,e.why)).length}if(u.style=Ke.checkboxInputStyle,l.appendChild(u),a=m(a),i=m(i),function(){let n=f(a),s=n;if(i.length){const l=f(i);if(n&&l)return c.appendChild(nt(e,"Inconsistent data in dataDoc!\n"+a+" and\n"+i)),c;if(!n&&!l){n=null;const e=t.any(o,b.ui("default"));s=e?"1"===e.value:!!r&&null}}u.state=n,u.textContent={true:"✓",false:r?"✕":" ",null:"-"}[s]}(),!p)return c;let h=!1;return u.addEventListener("click",function(n){if(h)return;h=!0,u.disabled=!0;let o=!1;const s=function(){return!o&&(o=!0,h=!1,u.disabled=!1,!0)},l=function(t){d.style.color="#000",d.style.backgroundColor="#fee",c.appendChild(nt(e,`Checkbox: Error updating dataDoc from ${u.state} to ${u.newState}:\n\n${t}`))};d.style.color="#bbb";const p=!0===u.state?a:!1===u.state?i:[];u.newState=null===u.state||!0!==u.state&&(!r||null);const m=!0===u.newState?a:!1===u.newState?i:[];ve.Rm(` Deleting ${p}`),ve.Rm(` Inserting ${m}`);try{const e=t.updater.update(p,m,function(e,n,i){if(s())if(n)d.style.color="#000",u.state=u.newState,u.textContent={true:"✓",false:"✕",null:"-"}[u.state];else{if(p.why){t.holds(p.subject,p.predicate,p.object,p.why)&&ve.Rm(" @@@@@ weird if 409 - does hold statement")}l(i)}});e&&"function"==typeof e.then&&e.catch(function(e){s()&&l(e instanceof Error?e.message:e)}).finally(function(){s()})}catch(e){throw s(),e}},!1),c}function Ei(e){const t=new Date;return g.sym(e.uri+"#id"+t.getTime())}function ki(e,t,n,i,a,o,s,r,c,l,p){const u={},d=n.updater.editable(l.uri);for(let e=0;e<o.length;e++){const t=o[e];t.uri&&!(t.uri in u)&&(u[t.uri]=!0)}if(0===Object.keys(u).length&&!c.mint)return nt(e,"Can't do selector with no options, subject= "+i+" property = "+a+".");j("makeSelectForChoice: dataDoc="+l);const m=function(e){t.removeChild(t.lastChild),f.refresh()},f=e.createElement("select");f.setAttribute("style",Ke.formSelectStyle),f.setAttribute("id","formSelect"),f.currentURI=null;for(const e in u)f.appendChild(h(e));if(d&&c.mint){const t=e.createElement("option");t.appendChild(e.createTextNode(c.mint)),t.AJAR_mint=!0,f.insertBefore(t,f.firstChild)}function h(t){const i=e.createElement("option"),a=n.sym(t);let o;o=c.disambiguate?ue(a,!0):U(a,!0),i.appendChild(e.createTextNode(o)),i.setAttribute("value",t);const r=n.any(a,n.sym("http://www.w3.org/ns/ui#backgroundColor"));return r&&i.setAttribute("style","background-color: "+r.value+"; "),i.AJAR_uri=t,Ai(a.value,s)&&i.setAttribute("selected","true"),i}return 0===f.children.length&&f.insertBefore(function(){const t=e.createElement("option");return t.appendChild(e.createTextNode(function(){let e="--- choice ---";return a&&"BlankNode"!==a.termType&&(e="* Select for property: "+U(a)+" *"),i&&"BlankNode"!==i.termType&&(e="* Select for "+U(i,!0)+" *"),e}())),t.disabled=!0,t.value=!0,t.hidden=!0,t.selected=!0,t}(),f.firstChild),f.update=function(t){s=t;const o=[],c=[],u=function(e){n.holds(i,a,e,l)&&o.push(g.st(i,a,e,l))},d=function(e){n.holds(i,a,e,l)||c.push(g.st(i,a,e,l)),r&&!n.holds(e,b.rdf("type"),n.sym(r),l)&&c.push(g.st(e,b.rdf("type"),n.sym(r),l))},m=n.each(i,a,null,l).map(e=>e.value);for(const e of m)Ai(e,s)||u(g.sym(e));for(const e of s)e in m||d(g.sym(e));n.updater.update(o,c,function(t,n,i){if(!n)return f.parentNode.appendChild(nt(e,"Error updating data in select: "+i));f.refresh(),p&&p(n,{widget:"select",event:"change"})})},f.refresh=function(){f.disabled=!0;let o,u=[];for(let t=0;t<f.options.length;t++){const d=f.options[t];if(d.selected&&d.AJAR_mint){if(c.mintClass){const t=gi(e,n,i,a,r,c.subForm,l,function(e,t){e||p(e,t,{change:"new"})});f.parentNode.appendChild(t),o=t.AJAR_subject}else o=Ei(l);u.push(g.st(i,a,n.sym(o),l)),r&&u.push(g.st(o,b.rdf("type"),n.sym(r),l)),c.mintStatementsFun&&(u=u.concat(c.mintStatementsFun(o))),f.currentURI=o}d.AJAR_uri&&(d.selected&&Ai(d.AJAR_uri,s)&&(f.currentURI=d.AJAR_uri),Ai(d.AJAR_uri,s)||d.removeAttribute("selected"),Ai(d.AJAR_uri,s)&&d.setAttribute("selected","true"))}_("selectForOptions: data doc = "+l),f.currentURI&&c.subForm&&!c.multiSelect&&ri(e,t,{},g.sym(f.currentURI),c.subForm,l,function(i,a){i?(n.updater.update([],u,function(n,i,a){i||t.appendChild(nt(e,"Error updating select: "+a))}),p&&p(i,{widget:"select",event:"new"})):t.appendChild(nt(e,"Error updating data in field of select: "+a))}),f.disabled=!1},d&&f.addEventListener("change",m,!1),f}function Ai(e,t){let n;for(n=0;n<t.length;n++)if(t[n]===e)return!0;return!1}pn[b.ui("AutocompleteField").uri]=function(e,t,n,i,a,o,s){if("NamedNode"!==i.termType)throw new Error("Sorry this field only works on NamedNode subjects (for editable)");const r=x.store,c=a.doc?a.doc():null,l=e.createElement("div");t&&t.appendChild(l);const p=e.createElement("div");p.setAttribute("class","formFieldName"),p.setAttribute("style",Ke.formFieldNameBoxStyle),l.appendChild(p);const u=e.createElement("div");u.setAttribute("class","formFieldValue"),l.appendChild(u);const d=r.any(a,b.ui("property"));if(!d)return l.appendChild(nt(e,"Error: No property given for autocomplete field: "+a));const m=r.any(a,b.ui("labelProperty"))||b.schema("name"),f=r.any(a,b.ui("dataSource"));if(!f)return l.appendChild(nt(e,"Error: No data source given for autocomplete field: "+a));const h={label:r.anyJS(f,b.schema("name"),null,f.doc()),logo:r.any(f,b.schema("logo"),null,f.doc())},v=r.any(a,b.ui("targetClass"),null,a.doc())||r.any(f,b.ui("targetClass"),null,f.doc());v&&(h.targetClass=v),h.objectURIBase=r.any(f,b.ui("objectURIBase"),null,f.doc())||void 0;const y=r.anyJS(f,b.ui("endpoint"),null,f.doc());if(y){if(h.endpoint=y,h.searchByNameQuery=r.anyJS(f,b.ui("searchByNameQuery"),null,f.doc()),!h.searchByNameQuery)return l.appendChild(nt(e,"Error: No searchByNameQuery given for endpoint data Source: "+a));h.insitituteDetailsQuery=r.anyJS(f,b.ui("insitituteDetailsQuery"),null,f.doc())}else{const t=r.anyJS(f,b.ui("searchByNameURI"));if(!t)return l.appendChild(nt(e,"Error: No searchByNameURI OR sparql endpoint given for dataSource: "+f));h.searchByNameURI=t}const w=r.anyJS(a,b.ui("suppressEmptyUneditable"),null,c),C=r.updater?.editable(o.uri),E={permanent:!0,targetClass:h.targetClass,queryParams:h};E.size=r.anyJS(a,b.ui("size"),null,c)||void 0;let k=r.any(i,d,void 0,o);if(k)E.currentObject=k,E.currentName=r.any(E.currentObject,m,null,o);else if(k=r.any(a,b.ui("default")),k)E.currentObject=k,E.currentName=r.any(E.currentObject,m,null,o);else if(w&&!C)return l.style.display="none",l;return p.appendChild(gn(e,d,a)),ti(e,i,{editable:C,dbLookup:!0},E,async function(t,n){if(!n)throw new Error("autocompleteField: No name set.");const a=r.the(i,d,null,o);if(a){const e=r.any(a,m,null,o);if(a.equals(t)&&e&&e.sameTerm(n))return}const c=a?r.statementsMatching(i,d,a,o).concat(r.statementsMatching(a,m,null,o)):[],p=[(0,g.st)(i,d,t,o),(0,g.st)(t,m,n,o)];try{await(r.updater?.updateMany(c,p))}catch(t){return s(!1,t),void l.appendChild(nt(e,"Autocomplete form data update error:"+t,null,t))}s(!0,"")},async function(t,n){const a=r.the(i,d,null,o);if(!a)return s(!1,"NO data to elete"),void l.appendChild(nt(e,"Autocomplete delete: no old data!"));const c=r.statementsMatching(i,d,a,o).concat(r.statementsMatching(a,m,null,o)),p=[];try{await(r.updater?.updateMany(c,p))}catch(t){const n=new Error("Autocomplete form data delete error:"+t);return s(!1,t),void l.appendChild(nt(e,n,null,t))}s(!0,"")}).then(e=>{u.appendChild(e)},t=>{u.appendChild(nt(e,`Error rendering autocomplete ${a}: ${t}`,"#fee",t))}),l},pn[b.ui("Form").uri]=pn[b.ui("Group").uri]=function(e,t,n,i,a,o,s){const r=e.createElement("div"),c=b.ui;if(t&&t.appendChild(r),!a)return;const l=i.toNT()+"|"+a.toNT();if(n[l])return r.appendChild(e.createTextNode("Group: see above "+l)),r;const p={};for(const e in n)p[e]=1;p[l]=1;const u=a.doc?a.doc():null,d=ai.any(a,c("weight"),null,u),m=d?Number(d.value):1;if(m>3||m<0)return r.appendChild(nt(e,`Form Group weight ${m} should be 0-3`));r.setAttribute("style",Ke.formGroupStyle[m]),r.style.display="flex",r.style.flexDirection="column",r.class="form-weight-"+m;let f,h=ai.any(a,c("parts"),null,u);if(h?f=h.elements:(h=ai.each(a,c("part"),null,u),f=mi(h)),!h)return r.appendChild(nt(e,"No parts to form! "));for(let t=0;t<f.length;t++){const a=f[t],c=dn(0,a),l=function(t,a){t&&a&&a.widget&&"select"===a.widget&&oi(e,n,i,o,s,r,f),s(t,{widget:"group",change:a})};r.appendChild(c(e,null,p,i,a,o,l))}return r},pn[b.ui("Options").uri]=function(e,t,n,i,a,o,s){const r=x.store,c=e.createElement("div"),l=a.doc?a.doc():null,p=b.ui;t&&t.appendChild(c);let u=r.any(a,p("dependingOn"));u||(u=b.rdf("type"));const d=r.each(a,p("case"),null,l);let m;d||c.appendChild(nt(e,"No cases to Options form. ")),m=u.sameTerm(b.rdf("type"))?Object.keys(r.findTypeURIs(i)).map(e=>g.sym(e)):r.each(i,u);for(let t=0;t<d.length;t++){const u=d[t],f=r.each(u,p("for"),null,l);let h=!1;for(let e=0;e<f.length;e++)for(const t of m){const n=f[e];(t.sameTerm(f)||t.termType===n.termType&&t.value===n.value)&&(h=!0)}if(h){const t=r.the(u,p("use"));if(!t)return c.appendChild(nt(e,'No "use" part for case in form '+a)),c;li(e,c,n,i,t,o,s);break}}return c},pn[b.ui("Multiple").uri]=function(e,t,n,i,a,o,s){function r(e){return e.map(e=>e.toString().slice(-7)).join(", ")}async function c(){const t=Ei(o);if(y)S(),_.elements.push(t),await R();else{const n=C?[g.st(t,w,i,o)]:[g.st(i,w,t,o)];try{await u.updater.update([],n)}catch(t){const n="Error adding to unordered multiple: "+t;m.appendChild(nt(e,n)),ve.z3(n)}N()}}function l(t){async function a(e,n){let i;for(ve.Rm("pre move: "+r(_.elements)),i=0;i<_.elements.length&&!_.elements[i].sameTerm(t);i++);if(i===_.elements.length&&alert("list move: not found element for "+t),n){if(0===i)return void alert("@@ boop - already at top -temp message");_.elements.splice(i-1,2,_.elements[i],_.elements[i-1])}else{if(i===_.elements.length-1)return void alert("@@ boop - already at bottom -temp message");_.elements.splice(i,2,_.elements[i+1],_.elements[i])}await R()}j("Multiple: render object: "+t);const c=dn(0,A)(e,null,n,t,A,o,function(e,n){ve.Rm(`Item done callback for item ${t.toString()}`),e||ve.z3(" Item done callback: Error: "+n),s(e,n)});if(c.subject=t,u.updater.editable(o.uri)&&(Dt(e,c,E,async function(){if(y){ve.Rm("pre delete: "+r(_.elements));for(let e=0;e<_.elements.length;e++)if(_.elements[e].sameTerm(t))return _.elements.splice(e,1),void await R()}else if(u.holds(i,w,t,o)){const n=[g.st(i,w,t,o)];u.updater.update(n,[],function(t,n,i){n?T.removeChild(c):T.appendChild(nt(e,"Multiple: delete failed: "+i))})}}),y)){const t=e.createElement("div");t.style.display="grid",t.style.gridTemplateColumns="auto 3em",t.style.gridTemplateRows="50% 50%";const n=Ot(e,it.Pt.iconBase+"noun_1369237.svg","Move Up",async e=>a(0,!0)),i=Ot(e,it.Pt.iconBase+"noun_1369241.svg","Move Down",async e=>a(0,!1)),o=e.createElement("div");return o.appendChild(c),t.appendChild(o),t.appendChild(n),t.appendChild(i),n.style.gridColumn=2,i.style.gridColumn=2,n.style.gridRow=1,i.style.padding="0em",n.style.padding="0em",i.style.gridRow=2,o.style.gridColumn=1,o.style.gridRowStart="span 2",t}return c}const p=it.Pt.iconBase+"noun_19460_green.svg",u=x.store,d=a.doc?a.doc():null,m=e.createElement("div"),f=m,h=b.ui;t&&t.appendChild(m);const v=u.any(a,h("ordered")),y=!!v&&g.Node.toJS(v),w=u.any(a,h("property")),C=u.anyJS(a,h("reverse"),null,d);if(!w)return m.appendChild(nt(e,"No property to multiple: "+a)),f;let E=u.any(a,h("label"));E||(E=U(w));let k=u.any(a,h("min"));k=k?0+k.value:0;const A=u.any(a,h("part"));if(!A)return m.appendChild(nt(e,"No part to multiple: "+a)),f;const T=m.appendChild(e.createElement("div"));let _,L;if(T.style.display="flex",T.style.flexDirection="column",L=C?u.any(null,w,i,o):u.any(i,w,null,o),y?(_=C?u.any(null,w,i,o):u.any(i,w,null,o),L=_?_.elements:[]):(L=C?u.each(null,w,i,o):u.each(i,w,null,o),_=null),u.updater.editable(o.uri)){const t=m.appendChild(e.createElement("div"));t.style.padding="0.5em";const n=t.appendChild(e.createElement("img"));n.setAttribute("src",p),n.setAttribute("style","margin: 0.2em; width: 1.5em; height:1.5em"),n.title="Click to add another "+E;const i=e.createElement("span");i.textContent=(0===L.length?"Add another ":"Add ")+E,t.addEventListener("click",async e=>{await c()},!0),t.appendChild(i)}function S(){_||(_=new g.Collection,C?u.add(_,w,i,o):u.add(i,w,_,o))}async function R(){ve.Rm("save list: "+r(_.elements)),S();try{await u.fetcher.putBack(o)}catch(t){return void m.appendChild(nt(e,"Error trying to put back a list: "+t))}N()}function N(){let e;if(y){const t=C?u.the(null,w,i,o):u.the(i,w,null,o);e=t?t.elements:[]}else e=C?u.each(null,w,i,o):u.each(i,w,null,o),e.sort();Y(T,e,l)}return T.refresh=N,N(),async function(){const e=k-L.length;if(e>0){for(let t=0;t<e;t++)ve.Rm("Adding extra: min "+k),await c();await R()}}().then(()=>{ve.Rm(" Multiple render: async stuff ok")},e=>{ve.z3(" Multiple render: async stuff fails. #### ",e)}),f},pn[b.ui("PhoneField").uri]=xn,pn[b.ui("EmailField").uri]=xn,pn[b.ui("ColorField").uri]=xn,pn[b.ui("DateField").uri]=xn,pn[b.ui("DateTimeField").uri]=xn,pn[b.ui("TimeField").uri]=xn,pn[b.ui("NumericField").uri]=xn,pn[b.ui("IntegerField").uri]=xn,pn[b.ui("DecimalField").uri]=xn,pn[b.ui("FloatField").uri]=xn,pn[b.ui("TextField").uri]=xn,pn[b.ui("SingleLineTextField").uri]=xn,pn[b.ui("NamedNodeURIField").uri]=xn,pn[b.ui("MultiLineTextField").uri]=function(e,t,n,i,a,o,s){const r=b.ui,c=x.store,l=a.doc?a.doc():null,p=c.any(a,r("property"));if(!p)return nt(e,"No property to text field: "+a);const u=e.createElement("div");u.style.display="flex",u.style.flexDirection="row";const d=u.appendChild(e.createElement("div"));d.style.width=He;const m=u.appendChild(e.createElement("div"));d.appendChild(gn(e,p,a)),o=bn(i,p,o);const f=c.anyJS(i,p,null,o)||"",h=c.updater.editable(o.uri),g=a&&c.anyJS(a,b.ui("suppressEmptyUneditable"),null,l);!h&&g&&""===f&&(u.style.display="none");const v=bi(e,c,i,p,o,s);return m.appendChild(v),t&&t.appendChild(u),u},pn[b.ui("BooleanField").uri]=function(e,t,n,i,a,o,s){return si(e,t,0,i,a,o,0,!1)},pn[b.ui("TristateField").uri]=function(e,t,n,i,a,o,s){return si(e,t,0,i,a,o,0,!0)},pn[b.ui("Classifier").uri]=function(e,t,n,i,a,o,s){const r=x.store,c=b.ui,l=r.any(a,c("category"));if(!l)return nt(e,"No category for classifier: "+a);j("Classifier: dataDoc="+o);const p=e.createElement("div");p.setAttribute("class","classifierBox");const u=e.createElement("div");u.setAttribute("class","formFieldName classifierBox-label"),u.appendChild(gn(e,l,a)),p.appendChild(u);const d=e.createElement("div");d.setAttribute("class","formFieldValue classifierBox-selectBox");const m=wi(e,r,i,l,o,function(e,t){return s(e,t)});if(m&&m.querySelectorAll){const e=m.querySelectorAll("select");e.length&&!r.updater.editable(o.uri)&&e.forEach(e=>{e.readOnly=!0,e.style=Ke.textInputStyleUneditable})}return d.appendChild(m),p.appendChild(d),t&&t.appendChild(p),p},pn[b.ui("Choice").uri]=function(e,t,n,i,a,o,s){const r=b.ui,c=x.store,l=a.doc?a.doc():null;let p;const u=e.createElement("div");u.setAttribute("class","choiceBox"),t&&t.appendChild(u);const d=e.createElement("div");d.setAttribute("class","formFieldName choiceBox-label"),u.appendChild(d);const m=e.createElement("div");m.setAttribute("class","formFieldValue choiceBox-selectBox"),u.appendChild(m);const f=c.any(a,r("property"));if(!f)return u.appendChild(nt(e,"No property for Choice: "+a));d.appendChild(gn(e,f,a));const h=c.any(a,r("from"));if(!h)return nt(e,"No 'from' for Choice: "+a);const v=c.any(a,r("use")),y={form:a,subForm:v,disambiguate:!1};c.any(a,r("canMintNew"))&&(y.mint="* Create new *");const w=c.any(a,r("multiselect"));w&&(y.multiSelect=!0);const C=c.each(a,r("search-full-store")).length?null:o;let E;return m.refresh=function(){let t=c.each(i,f,null,o).map(e=>e.value),n=function(e){let t,n=[];n=c.each(void 0,b.rdf("type"),h,l);for(const t in function(e,t,n){let i,a,o,s,r,c,l,p,u,d,m;const f={};f[t.toNT()]=!0;const h={},g=e.transitiveClosure(f,e.rdfFactory.namedNode("http://www.w3.org/2000/01/rdf-schema#subClassOf"),!0);for(const t in g){r=e.statementsMatching(null,e.rdfFactory.namedNode("http://www.w3.org/1999/02/22-rdf-syntax-ns#type"),e.fromNT(t),n);for(let e=0,t=r.length;e<t;e++)d=r[e],h[d.subject.toNT()]=d;c=e.each(null,e.rdfFactory.namedNode("http://www.w3.org/2000/01/rdf-schema#domain"),e.fromNT(t),n);for(let t=0,a=c.length;t<a;t++)for(s=c[t],l=e.statementsMatching(null,s,null,n),o=0,i=l.length;o<i;o++)d=l[o],h[d.subject.toNT()]=d;p=e.each(null,e.rdfFactory.namedNode("http://www.w3.org/2000/01/rdf-schema#range"),e.fromNT(t),n);for(let t=0,i=p.length;t<i;t++)for(s=p[t],u=e.statementsMatching(null,s,null,n),m=0,a=u.length;m<a;m++)d=u[m],h[d.object.toNT()]=d}return h}(c,h,e))n.push(c.fromNT(t));if(h.sameTerm(b.rdfs("Class")))for(p in Qt())n.push(c.sym(p));else if(h.sameTerm(b.rdf("Property"))){for(p in t=Zt(c),t.op)n.push(c.fromNT(p));for(p in t.dp)n.push(c.fromNT(p));y.disambiguate=!0}else if(h.sameTerm(b.owl("ObjectProperty"))){for(p in t=Zt(c),t.op)n.push(c.fromNT(p));y.disambiguate=!0}else if(h.sameTerm(b.owl("DatatypeProperty"))){for(p in t=Zt(c),t.dp)n.push(c.fromNT(p));y.disambiguate=!0}return n}(C);if(n.push(t),n=fi(n),E=ki(e,m,c,i,f,n,t,h,y,o,s),m.innerHTML="",m.appendChild(E),w){const n=new ii({placeholder:E.selected,select:E,container:m,textField:"textField",valueField:"valueField"});n.init(),n.subscribe(function(n){if("REMOVE_OPTION"===n.action&&(t=t.filter(function(e){return e!==n.value})),"CLEAR_ALL_OPTIONS"===n.action&&(t=[]),"ADD_OPTION"===n.action){if((n.value+"").includes("Create new")){const n=Ei(o),a=[];a.push(g.st(i,f,c.sym(n),o)),h&&a.push(g.st(n,b.rdf("type"),c.sym(h),o)),v&&ri(e,m,{},g.sym(n),v,o,function(i,o){i?(c.updater.update([],a,function(t,n,i){n||m.appendChild(nt(e,"Error updating select: "+i))}),t.push(n),s&&s(i,{widget:"select",event:"new"})):m.appendChild(nt(e,"Error updating data in field of select: "+o))})}else t.push(n.value)}E.update(t)})}},m.refresh(),E&&E.refresh&&E.refresh(),u},pn[b.ui("Comment").uri]=pn[b.ui("Heading").uri]=function(e,t,n,i,a,o,s){const r=b.ui,c=x.store;let l=c.any(a,r("contents"));l||(l="Error: No contents in comment field.");const p=a.doc?a.doc():null,u=un(a),d=cn[u]||{},m=e.createElement("div");t&&t.appendChild(m);const f=m.appendChild(e.createElement(d.element));f.textContent=l,function(e,t){const n=un(t),i=cn[n]||{},a=x.store.any(t,b.ui("style"));a?"Literal"===a.termType?a&&e.setAttribute("style",a.value):x.store.statementsMatching(a,null,null,t.doc()).forEach(t=>{if(t.predicate.uri&&t.predicate.uri.startsWith(mn)){const n=t.predicate.uri.slice(26);try{e.style[n]=t.object.value}catch(i){console.warn(`setFieldStyle: Error setting element style ${n} to "${t.object.value}"`),console.warn(`setFieldStyle: ... Element tagName was "${e.tagName||"???"}"`)}}}):i.style&&e.setAttribute("style",i.style)}(f,a);const h=c.anyJS(a,b.ui("suppressIfUneditable"),null,p),g=c.updater.editable(o.uri);return h&&!g&&(m.style.display="none"),m};const Ti={authEndpoint:"",fallbackAuthEndpoint:"https://databox.me/",signupEndpoint:"https://solidproject.org/get_a_pod",signupWindowHeight:600,signupWindowWidth:1024,key:"",cert:""};function ji(e){this.config=e||Ti}ji.prototype.listen=function(){return new Promise(function(e,t){const n=window.addEventListener?"addEventListener":"attachEvent";(0,window[n])("attachEvent"===n?"onmessage":"message",function(n){const i=n.data;if("User:"===i.slice(0,5)){const n=i.slice(5,i.length);return n&&n.length>0&&"http"===n.slice(0,4)?e(n):t(n)}},!0)})},ji.prototype.signup=function(e){e=e||this.config.signupEndpoint;const t=this.config.signupWindowWidth,n=this.config.signupWindowHeight,i=window.screen.width/2-(t/2+10),a=window.screen.height/2-(n/2+50),o=e+"?origin="+encodeURIComponent(window.location.origin),s="resizable,scrollbars,status,width="+t+",height="+n+",left="+i+",top="+a;window.open(o,"Solid signup",s);const r=this;return new Promise(function(e){r.listen().then(function(t){return e(t)})})};x.solidLogicSingleton.store;const{loadPreferences:_i,loadProfile:Li}=x.solidLogicSingleton.profile,{getScopedAppInstances:Si,getRegistrations:Ri,loadAllTypeIndexes:Ni,getScopedAppsFromIndex:Ii,deleteTypeIndexRegistration:Bi}=x.solidLogicSingleton.typeIndex;function Di(e){const t=x.authn.currentUser();return t?(x.authn.saveUser(t,e),Promise.resolve(e)):new Promise(t=>{x.authn.checkUser().then(n=>{if(n)return ve.Rm(`logIn: Already logged in as ${n}`),t(e);if(!e.div||!e.dom)return t(e);const i=Hi(e.dom,n=>{x.authn.saveUser(n,e),t(e)});e.div.appendChild(i)})})}async function Oi(e){if(e.preferencesFile)return Promise.resolve(e);let t;try{e=await Mi(e);const n=await _i(e.me);t,e.preferencesFile=n}catch(t){let n;if(t instanceof x.UnauthorizedError)n="Oops — you are not authenticated (properly logged in), so SolidOS cannot read your preferences file. Try logging out and then logging back in.",R(n);else{if(t instanceof x.CrossOriginForbiddenError)return n=`Unauthorized: Assuming preference file blocked for origin ${window.location.origin}`,e.preferencesFileError=n,e;if(t instanceof x.SameOriginForbiddenError)return n="You are not authorized to read your preference file. This may be because you are using an untrusted web app.",ve.R8(n),e;if(t instanceof x.NotEditableError)return n="You are not authorized to edit your preference file. This may be because you are using an untrusted web app.",ve.R8(n),e;if(t instanceof x.WebOperationError)n="You are not authorized to edit your preference file. This may be because you are using an untrusted web app.",ve.R8(n);else{if(!(t instanceof x.FetchError))throw new Error(`(via loadPrefs) ${t}`);n=`Strange: Error ${t.status} trying to read your preference file.${t.message}`,R(n)}}e.preferencesFileError=n}return e}async function Mi(e){if(e.publicProfile)return e;try{const t=await Di(e);if(!t.me)throw new Error("Could not log in");e.publicProfile=await Li(t.me)}catch(t){throw e.div&&e.dom&&e.div.appendChild(nt(e.dom,t.message)),new Error(`Can't log in: ${t}`)}return e}async function Fi(e,t,n){let i=e.me?await Si(t,e.me):[];return!0===n?i=i.filter(e=>"public"===e.scope.label):!1===n&&(i=i.filter(e=>"private"===e.scope.label)),e.instances=i.map(e=>e.instance),e}function zi(e,t){return`${e.me&&e.me.sameTerm(t.agent)?"":U(t.agent)+" "}${t.label}`}async function Ui(e,t,n){function i(i){const a=function(e){const i=Ri(t,n),a=i.length?i[0]:Ei(e);return[(0,g.st)(a,b.solid("instance"),t,e),(0,g.st)(a,b.solid("forClass"),n,e)]}(i.index),o=`${zi(e,i)} link to this ${e.noun}`;return Ci(e.dom,x.solidLogicSingleton.store,o,null,a,l,i.index)}const a=e.dom;if(!a||!e.div)throw new Error("registrationControl: need dom and div");const o=a.createElement("div");e.div.appendChild(o),e.me=x.authn.currentUser();const s=e.me;if(!s)return o.innerHTML='<p style="margin:2em;">(Log in to save a link to this)</p>',e;let r;try{r=await Ni(s)}catch(t){let n;return e.div&&e.preferencesFileError?(n="(Lists of stuff not available)",e.div.appendChild(a.createElement("p")).textContent=n):e.div&&(n=`registrationControl: Type indexes not available: ${t}`,e.div.appendChild(nt(e.dom,t))),ve.Rm(n),e}o.innerHTML="<table><tbody></tbody></table>",o.setAttribute("style","font-size: 120%; text-align: right; padding: 1em; border: solid gray 0.05em;");const c=o.children[0].children[0],l=new g.BlankNode;for(const e of r){c.appendChild(a.createElement("tr")).appendChild(i(e))}return e}function Pi(e,t,n){const{dom:i}=e,a=zi(e,n),o=i.createElement("tr"),s=o.appendChild(i.createElement("td"));s.setAttribute("colspan","3"),s.style.backgoundColor={private:"#fee",public:"#efe"}[n.label]||"white";const r=s.appendChild(i.createElement("h3"));return r.textContent=a+" links",r.style.textAlign="left",o}async function $i(e,t){const n=e.dom,i=e.div,a=n.createElement("div");if(i.appendChild(a),e.me=x.authn.currentUser(),!e.me)return a.innerHTML='<p style="margin:2em;">(Log in list your stuff)</p>',e;const o=await Ni(e.me);a.innerHTML="<table><tbody></tbody></table>",a.setAttribute("style","font-size: 120%; text-align: right; padding: 1em; border: solid #eee 0.5em;");const s=a.firstChild.firstChild;for(const i of o){const a=Pi(e,0,i);s.appendChild(a);const o=await Ii(i,t.type||null);0===o.length&&(a.style.display="none");for(const e of o){const t=Ut(n,b.solid("instance"),e.instance,{deleteFunction:async()=>{await Bi(e),s.removeChild(t)}});t.children[0].style.paddingLeft="3em",s.appendChild(t)}}return e}function qi(e){const t=e.createElement("div");t.setAttribute("style","position: fixed; top: 0; left: 0; right: 0; bottom: 0; display: flex; justify-content: center; align-items: center;"),e.body.appendChild(t);const n=e.createElement("div");n.setAttribute("style","\n background-color: white;\n box-shadow: 0px 1px 4px rgba(0, 0, 0, 0.2);\n -webkit-box-shadow: 0px 1px 4px rgba(0, 0, 0, 0.2);\n -moz-box-shadow: 0px 1px 4px rgba(0, 0, 0, 0.2);\n -o-box-shadow: 0px 1px 4px rgba(0, 0, 0, 0.2);\n border-radius: 4px;\n min-width: 400px;\n padding: 10px;\n z-index : 10;\n "),t.appendChild(n);const i=e.createElement("div");i.setAttribute("style","\n border-bottom: 1px solid #DDD;\n display: flex;\n flex-direction: row;\n align-items: center;\n justify-content: space-between;\n "),n.appendChild(i);const a=e.createElement("label");a.setAttribute("style","margin-right: 5px; font-weight: 800"),a.innerText="Select an identity provider";const o=e.createElement("button");o.innerHTML='<img src="https://solidos.github.io/solid-ui/src/icons/noun_1180156.svg" style="width: 2em; height: 2em;" title="Cancel">',o.setAttribute("style","background-color: transparent; border: none;"),o.addEventListener("click",()=>{t.remove()}),i.appendChild(a),i.appendChild(o);const s=async e=>{try{x.solidLogicSingleton.store.updater.flagAuthorizationMetadata();const t=new URL(window.location.href).hash;t&&window.localStorage.setItem("preLoginRedirectHash",t),window.localStorage.setItem("loginIssuer",e);const n=new URL(window.location.href);n.hash="",await x.authSession.login({redirectUrl:n.href,oidcIssuer:e})}catch(e){R(e.message)}},r=e.createElement("div");r.setAttribute("style","\n border-bottom: 1px solid #DDD;\n display: flex;\n flex-direction: column;\n padding-top: 10px;\n ");const c=e.createElement("div");c.setAttribute("style","\n display: flex;\n flex-direction: row;\n ");const l=e.createElement("label");l.innerText="Enter the URL of your identity provider:",l.setAttribute("style","color: #888");const p=e.createElement("input");p.setAttribute("type","text"),p.setAttribute("style","margin-left: 0 !important; flex: 1; margin-right: 5px !important"),p.setAttribute("placeholder","https://example.com"),p.value=localStorage.getItem("loginIssuer")||"";const u=e.createElement("button");u.innerText="Go",u.setAttribute("style","margin-top: 12px; margin-bottom: 12px;"),u.addEventListener("click",()=>{s(p.value)}),r.appendChild(l),c.appendChild(p),c.appendChild(u),r.appendChild(c),n.appendChild(r);const d=e.createElement("div");d.setAttribute("style","\n display: flex;\n flex-direction: column;\n padding-top: 10px;\n ");const m=e.createElement("label");m.innerText="Or pick an identity provider from the list below:",m.setAttribute("style","color: #888"),d.appendChild(m),(0,x.getSuggestedIssuers)().forEach(t=>{const n=e.createElement("button");n.innerText=t.name,n.setAttribute("style","height: 38px; margin-top: 10px"),n.addEventListener("click",()=>{s(t.uri)}),d.appendChild(n)}),n.appendChild(d)}function Hi(e,t=null,n={}){let i=(0,x.offlineTestID)();const a=e.createElement("div");function o(e){e&&(i=x.authn.saveUser(e),a.refresh(),t&&t(i.uri))}function s(e){const n=i;x.authSession.logout().then(function(){const e=`Your WebID was ${n}. It has been forgotten.`;i=null;try{R(e)}catch(t){window.alert(e)}a.refresh(),t&&t(null)},e=>{R("Fail to log out:"+e)})}function r(){i=x.authn.currentUser(),a.refresh()}return a.refresh=function(){const t=x.authSession.info;i=t&&t.webId&&t.isLoggedIn?x.solidLogicSingleton.store.sym(t.webId):null,(i&&a.me!==i.uri||!i&&a.me)&&(yt(a),i?a.appendChild(function(t,n){const i=n.buttonStyle||Ke.signInAndUpButtonStyle;let a="WebID logout";if(t){const e=x.solidLogicSingleton.store.any(t,b.foaf("nick"))||x.solidLogicSingleton.store.any(t,b.foaf("name"));e&&(a="Logout "+e.value)}const o=e.createElement("input");return o.setAttribute("type","button"),o.setAttribute("value",a),o.setAttribute("style",`${i}`),o.addEventListener("click",s,!1),o}(i,n)):a.appendChild(function(e,t,n={}){const i=(n=n||{}).buttonStyle||Ke.signInAndUpButtonStyle,a=e.createElement("div"),o="SolidSignInOrSignUpBox";ve.Rm("widgets.signInOrSignUpBox"),a.setUserCallback=t,a.setAttribute("class",o),a.setAttribute("style","display:flex;");const s=e.createElement("input");a.appendChild(s),s.setAttribute("type","button"),s.setAttribute("value","Log in"),s.setAttribute("style",`${i}${Ke.headerBannerLoginInput}`+Ke.signUpBackground),x.authSession.events.on("login",()=>{const t=x.authn.currentUser();if(t){const n=t.uri,i=e.getElementsByClassName(o);ve.Rm(`Logged in, ${i.length} panels to be serviced`);for(let t=0;t<i.length;t++){const a=i[t];if(a.setUserCallback)try{a.setUserCallback(n);const e=a.parentNode;e&&e.removeChild(a)}catch(t){ve.Rm(`## Error satisfying login box: ${t}`),a.appendChild(nt(e,t))}}}}),s.addEventListener("click",()=>{const n=(0,x.offlineTestID)();if(n)return t(n.uri);qi(e)},!1);const r=e.createElement("input");return a.appendChild(r),r.setAttribute("type","button"),r.setAttribute("value","Sign Up for Solid"),r.setAttribute("style",`${i}${Ke.headerBannerLoginInput}`+Ke.signInBackground),r.addEventListener("click",function(e){(new ji).signup().then(function(e){ve.Rm("signInOrSignUpBox signed up "+e),t(e)})},!1),a}(e,o,n))),a.me=i?i.uri:null},a.refresh(),r(),x.authSession.events.on("login",r),x.authSession.events.on("logout",r),a.me="99999",a.refresh(),a}function Gi(e,t,n){const i=t.noun,a=t.appPathSegment,o=(0,x.offlineTestID)(),s=e.createElement("div"),r={me:o,dom:e,div:s};function c(t,n){s.appendChild(nt(e,t,n))}function l(e){const t=x.solidLogicSingleton.store.any(e,b.space("uriPrefix"));let n;n=t?t.value:e.uri.split("#")[0],"/"!==n.slice(-1)&&(ve.Rm(`${a}: No / at end of uriPrefix ${n}`),n=`${n}/`);const i=new Date;return n+=`${a}/id${i.getTime()}/`,n}return Oi(r).then(function(t){const a=t.me,o=t.preferencesFile;let r=null,p=x.solidLogicSingleton.store.each(a,b.space("workspace"),void 0,o);const u=x.solidLogicSingleton.store.each(a,b.space("storage"));0===p.length&&u&&(c(`You don't seem to have any workspaces. You have ${u.length} storage spaces.`,"white"),u.map(function(e){return p=p.concat(x.solidLogicSingleton.store.each(e,b.ldp("contains"))),p}).filter(e=>e.id?["public","private"].includes(e.id().toLowerCase()):"")),1===p.length&&(c(`Workspace used: ${p[0].uri}`,"white"),r=l(p[0]));const d=e.createElement("table");d.setAttribute("style","border-collapse:separate; border-spacing: 0.5em;"),s.appendChild(d),s.appendChild(e.createElement("hr"));const m=s.appendChild(e.createElement("p"));m.setAttribute("style",Ke.commentStyle),m.textContent=`Where would you like to store the data for the ${i}?\n Give the URL of the folder where you would like the data stored.\n It can be anywhere in solid world - this URI is just an idea.`;const f=s.appendChild(e.createElement("input"));f.setAttribute("type","text"),f.setAttribute("style",Ke.textInputStyle),f.size=80,f.label="base URL",f.autocomplete="on",r&&(f.value=r),t.baseField=f,s.appendChild(e.createElement("br"));const h=s.appendChild(e.createElement("button"));let v,y,w,C,E,k,A;h.setAttribute("style",Ke.buttonStyle),h.textContent=`Start new ${i} at this URI`,h.addEventListener("click",function(e){let t=f.value.replace(" ","%20");"/"!==t.slice(-1)&&(t+="/"),n(null,t)}),p=p.filter(function(e){return!x.solidLogicSingleton.store.holds(e,b.rdf("type"),b.space("MasterWorkspace"))});const T="height: 3em; margin: 1em; padding: 1em white; border-radius: 0.3em;",j=`${T}border: 0px;`;for(let t=0;t<p.length;t++){if(E=p[t],C=e.createElement("tr"),0===t&&(v=e.createElement("td"),v.setAttribute("rowspan",`${p.length}`),v.textContent="Choose a workspace for this:",v.setAttribute("style","vertical-align:middle;"),C.appendChild(v)),y=e.createElement("td"),k=x.solidLogicSingleton.store.anyValue(E,b.ui("style")),!k){const e=`#${(16777215&function(e){return e.split("").reduce(function(e,t){return(e=(e<<5)-e+t.charCodeAt(0))&e},0)}(E.uri)|12632256).toString(16)}`;k=`color: black ; background-color: ${e};`}y.setAttribute("style",j+k),C.target=E.uri;let i=x.solidLogicSingleton.store.any(E,b.rdfs("label"));i||(i=E.uri.split("/").slice(-1)[0]||E.uri.split("/").slice(-2)[0]),y.textContent=i||"???",C.appendChild(y),0===t&&(w=e.createElement("td"),w.setAttribute("rowspan",`${p.length}1`),w.setAttribute("style","width:50%;"),C.appendChild(w)),d.appendChild(C),A=x.solidLogicSingleton.store.any(E,b.rdfs("comment")),A=A?A.value:"Use this workspace",y.addEventListener("click",function(t){w.textContent=A?A.value:"",w.setAttribute("style",j+k);const i=e.createElement("button");i.textContent="Continue";const a=l(E);f.value=a,i.addEventListener("click",function(e){i.disabled=!0,n(E,a),i.textContent="----\x3e"},!0),w.appendChild(i)},!0)}const _=e.createElement("tr");y=e.createElement("td"),y.setAttribute("style",T),y.textContent="+ Make a new workspace",y.addEventListener("click",async function(n){const i=d.appendChild(e.createElement("tr")).appendChild(e.createElement("td"));i.setAttribute("colspan","3"),i.style.padding="0.5em";const a=encodeURI(await zt(e,x.solidLogicSingleton.store,i,b.solid("URL"),b.space("Workspace"),"Workspace")),o=Ei(t.preferencesFile),s=[(0,g.st)(t.me,b.space("workspace"),o,t.preferencesFile),(0,g.st)(o,b.space("uriPrefix"),a,t.preferencesFile)];if(!x.solidLogicSingleton.store.updater)throw new Error("store has no updater");await x.solidLogicSingleton.store.updater.update([],s)}),_.appendChild(y),d.appendChild(_)}).catch(e=>{s.appendChild(nt(r.dom,e))}),s}function Vi(e,t,n){const i=function(e,t){n(e,t)},a=e.createElement("div"),o=e.createElement("button");return o.setAttribute("type","button"),a.appendChild(o),o.innerHTML=`Make new ${t.noun}`,o.addEventListener("click",n=>{a.appendChild(Gi(e,t,i))},!1),a.appendChild(o),a}async function Wi(){try{const{me:e,preferencesFile:t,preferencesFileError:n}=await Oi({});if(!t||n)throw new Error(n);return x.solidLogicSingleton.store.each(e,b.rdf("type"),null,t.doc())}catch(e){ve.R8("Unable to fetch your preferences - this was the error: ",e)}return[]}async function Ji(e){const t=await Wi();return e.filter(e=>function(e,t){const n=e.audience||[];return n.reduce((e,n)=>e&&!!t.find(e=>e.equals(n)),!0)}(e,t))}x.authSession.events.on("logout",async()=>{const e=window.localStorage.getItem("loginIssuer");if(e)try{x.solidLogicSingleton.store.updater.flagAuthorizationMetadata();const t=new URL(e);t.pathname="/.well-known/openid-configuration";const n=await fetch(t.toString());if(200===n.status){const e=await n.json();e&&e.end_session_endpoint&&await fetch(e.end_session_endpoint,{credentials:"include"})}}catch(e){}window.location.reload()});class Qi{rootElement;barElement;isExpanded=!1;constructor(e){this.groupList=e,this.rootElement=e.controller.dom.createElement("div"),this.barElement=e.controller.dom.createElement("div")}render(){return this.rootElement.innerHTML="",this.rootElement.appendChild(this.renderAddButton()),this.rootElement.appendChild(this.barElement),this.rootElement}renderAddButton(){return Ot(this.groupList.controller.dom,`${it.Pt.iconBase}noun_34653_green.svg`,"Add ...",()=>{this.toggleBar(),this.renderBar()})}renderBar(){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()))}renderSimplifiedBar(e){Array.from(this.barElement.children).filter(t=>t!==e).forEach(e=>this.barElement.removeChild(e))}renderPersonButton(){return Ot(this.groupList.controller.dom,it.Pt.iconBase+_t["vcard:Individual"],"Add Person",e=>{this.renderSimplifiedBar(e.target),this.renderNameForm(b.vcard("Individual"),"person").then(e=>this.addPerson(e)).then(()=>this.renderCleanup()).catch(e=>this.groupList.controller.renderStatus(e))})}renderGroupButton(){return Ot(this.groupList.controller.dom,it.Pt.iconBase+_t["vcard:Group"],"Add Group",e=>{this.renderSimplifiedBar(e.target),this.renderNameForm(b.vcard("Group"),"group").then(e=>this.addGroup(e)).then(()=>this.renderCleanup()).catch(e=>this.groupList.controller.renderStatus(e))})}renderNameForm(e,t){return zt(this.groupList.controller.dom,this.groupList.store,this.barElement,b.vcard("URI"),e,t)}renderPublicButton(){return Ot(this.groupList.controller.dom,it.Pt.iconBase+_t["foaf:Agent"],"Add Everyone",()=>this.addAgent(b.foaf("Agent").uri).then(()=>this.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(()=>this.renderCleanup()))}renderAuthenticatedAgentButton(){return Ot(this.groupList.controller.dom,`${it.Pt.iconBase}noun_99101.svg`,"Anyone logged In",()=>this.addAgent(b.acl("AuthenticatedAgent").uri).then(()=>this.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(()=>this.renderCleanup()))}renderBotButton(){return Ot(this.groupList.controller.dom,it.Pt.iconBase+"noun_Robot_849764.svg","A Software Agent (bot)",e=>{this.renderSimplifiedBar(e.target),this.renderNameForm(b.schema("Application"),"bot").then(e=>this.addBot(e)).then(()=>this.renderCleanup())})}renderAppsButton(){return Ot(this.groupList.controller.dom,`${it.Pt.iconBase}noun_15177.svg`,"A Web App (origin)",e=>{this.renderSimplifiedBar(e.target);const t={div:this.barElement,dom:this.groupList.controller.dom},n=this.renderAppsTable(t).catch(e=>this.groupList.controller.renderStatus(e));this.renderAppsView();const i=this.renderNameForm(b.schema("WebApplication"),"webapp domain").then(e=>this.getOriginFromName(e));Promise.race([n,i]).then(e=>{e&&this.groupList.addNewURI(e)}).then(()=>this.renderCleanup())})}renderAppsView(){const e=this.groupList.controller.context.session.paneRegistry.byName("trustedApplications");if(e){const t=e.render(null,this.groupList.controller.context);t.setAttribute("style",Ke.trustedAppController);const n=Mt(this.groupList.controller.dom,()=>this.renderCleanup());n.setAttribute("style",Ke.trustedAppCancelButton),t.insertBefore(n,t.firstChild),this.barElement.appendChild(t)}}async renderAppsTable(e){await Mi(e);const t=this.groupList.store.each(e.me,b.acl("trustedApp")),n=t.flatMap(e=>this.groupList.store.each(e,b.acl("origin")));return this.barElement.appendChild(this.groupList.controller.dom.createElement("p")).textContent=`You have ${n.length} selected web apps.`,new Promise((e,n)=>{const i=this.barElement.appendChild(this.groupList.controller.dom.createElement("table"));i.setAttribute("style",Ke.trustedAppAddApplicationsTable),t.forEach(t=>{const a=this.groupList.store.any(t,b.acl("origin"));a||n(new Error(`Unable to pick app: ${t.value}`));const o=Ut(this.groupList.controller.dom,b.acl("origin"),a,{}),s=this.groupList.controller.dom.createElement("table"),r=s.appendChild(this.groupList.controller.dom.createElement("tr"));r.appendChild(this.groupList.controller.dom.createElement("td")).appendChild(o);r.appendChild(this.groupList.controller.dom.createElement("td")).textContent=`Give access to ${this.groupList.controller.noun} ${U(this.groupList.controller.subject)}?`;r.appendChild(this.groupList.controller.dom.createElement("td")).appendChild(Ft(this.groupList.controller.dom,()=>e(a.value))),i.appendChild(s)})})}renderCleanup(){this.renderBar(),this.groupList.render()}async addPerson(e){if(!e)return this.toggleBar();if(!e.match(/^https?:/i))return Promise.reject(new Error("Not a http URI"));ve.Rm(`Adding to ACL person: ${e}`),await this.groupList.addNewURI(e),this.toggleBar()}async addGroup(e){if(!e)return this.toggleBar();if(!e.match(/^https?:/i))return Promise.reject(new Error("Not a http URI"));ve.Rm("Adding to ACL group: "+e),await this.groupList.addNewURI(e),this.toggleBar()}async addAgent(e){await this.groupList.addNewURI(e),this.toggleBar()}async addBot(e){if(!e)return this.toggleBar();if(!e.match(/^https?:/i))return Promise.reject(new Error("Not a http URI"));ve.Rm("Adding to ACL bot: "+e),await this.groupList.addNewURI(e),this.toggleBar()}async getOriginFromName(e){if(!e)return Promise.resolve();if(!e.match(/^([a-z0-9]+(-[a-z0-9]+)*\.)+[a-z]{2,}$/i))return Promise.reject(new Error("Not a domain name"));const t="https://"+e;return ve.Rm("Adding to ACL origin: "+t),this.toggleBar(),t}toggleBar(){this.isExpanded=!this.isExpanded}}const Zi=b.acl,Yi={13:"Owners",9:"Owners (write locked)",5:"Editors",3:"Posters",2:"Submitters",1:"Viewers"},Ki={13:!0,5:!0,3:!0,2:!0,1:!0},Xi={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"};class ea{defaults;byCombo;aclMap;addAgentButton;rootElement;_store;constructor(e,t,n,i,a={}){this.doc=e,this.aclDoc=t,this.controller=n,this._options=a,this.defaults=this._options.defaults||!1,this._store=i,this.aclMap=Ce(e,0,i,this.defaults),this.byCombo=Te(this.aclMap),this.addAgentButton=new Qi(this),this.rootElement=this.controller.dom.createElement("div"),this.rootElement.setAttribute("style",Ke.accessGroupList)}get store(){return this._store}set store(e){this._store=e,this.aclMap=Ce(this.doc,this.aclDoc,e,this.defaults),this.byCombo=Te(this.aclMap)}render(){return this.rootElement.innerHTML="",this.renderGroups().forEach(e=>this.rootElement.appendChild(e)),this.controller.isEditable&&this.rootElement.appendChild(this.addAgentButton.render()),this.rootElement}renderGroups(){const e=[];for(let t=15;t>0;t--){const n=ta(t);(this.controller.isEditable&&Ki[t]||this.byCombo[n])&&e.push(this.renderGroup(t,n))}return e}renderGroup(e,t){const n=this.controller.dom.createElement("div");n.setAttribute("style",Ke.accessGroupListItem),Xe(n,e=>this.handleDroppedUris(e,t).then(()=>this.controller.render()).catch(e=>this.controller.renderStatus(e)));return this.renderGroupElements(e,t).forEach(e=>n.appendChild(e)),n}renderGroupElements(e,t){const n=this.controller.dom.createElement("div");if(n.setAttribute("style",Ke.group),this.controller.isEditable)switch(e){case 1:n.setAttribute("style",Ke.group1);break;case 2:n.setAttribute("style",Ke.group2);break;case 3:n.setAttribute("style",Ke.group3);break;case 5:n.setAttribute("style",Ke.group5);break;case 9:n.setAttribute("style",Ke.group9);break;case 13:n.setAttribute("style",Ke.group13);break;default:n.setAttribute("style",Ke.group)}n.innerText=Yi[e]||function(e){let t="";const n=["Read","Append","Write","Control"];for(let i=0;i<4;i++)e&1<<i&&(t+=n[i]);return t}(e);const i=this.controller.dom.createElement("div");if(i.setAttribute("style",Ke.group),this.controller.isEditable)switch(e){case 1:i.setAttribute("style",Ke.group1);break;case 2:i.setAttribute("style",Ke.group2);break;case 3:i.setAttribute("style",Ke.group3);break;case 5:i.setAttribute("style",Ke.group5);break;case 9:i.setAttribute("style",Ke.group9);break;case 13:i.setAttribute("style",Ke.group13);break;default:i.setAttribute("style",Ke.group)}const a=i.appendChild(this.controller.dom.createElement("table"));(this.byCombo[t]||[]).map(([e,n])=>this.renderAgent(a,t,e,n)).forEach(e=>a.appendChild(e));const o=this.controller.dom.createElement("div");if(o.setAttribute("style",Ke.group),this.controller.isEditable)switch(e){case 1:o.setAttribute("style",Ke.group1);break;case 2:o.setAttribute("style",Ke.group2);break;case 3:o.setAttribute("style",Ke.group3);break;case 5:o.setAttribute("style",Ke.group5);break;case 9:o.setAttribute("style",Ke.group9);break;case 13:o.setAttribute("style",Ke.group13);break;default:o.setAttribute("style",Ke.group)}return o.innerText=Xi[e]||"Unusual combination",[n,i,o]}renderAgent(e,t,n,i){const a=Ut(this.controller.dom,Zi(n),(0,g.sym)(i),this.controller.isEditable?{deleteFunction:()=>this.deleteAgent(t,n,i).then(()=>e.removeChild(a)).catch(e=>this.controller.renderStatus(e))}:{});return a}async deleteAgent(e,t,n){const i=this.byCombo[e]||[],a=i.find(([e,i])=>e===t&&i===n);a&&i.splice(i.indexOf(a),1),await this.controller.save()}async addNewURI(e){await this.handleDroppedUri(e,ta(1)),await this.controller.save()}async handleDroppedUris(e,t){try{await Promise.all(e.map(e=>this.handleDroppedUri(e,t))),await this.controller.save()}catch(e){return Promise.reject(e)}}async handleDroppedUri(e,t,n=!1){const i=function(e,t){const n=(0,g.sym)(e),i=t.findTypeURIs(n);for(const e in i)ve.Rm(" drop object type includes: "+e);if(e.startsWith("http")&&3===e.split("/").length)return{pred:"origin",obj:n};if(e.startsWith("http")&&4===e.split("/").length&&e.endsWith("/"))return ve.Rm("Assuming final slash on dragged origin URI was unintended!"),{pred:"origin",obj:(0,g.sym)(e.slice(0,-1))};if(b.vcard("WebID").uri in i)return{pred:"agent",obj:n};if(b.vcard("Group").uri in i)return{pred:"agentGroup",obj:n};if(n.sameTerm(b.foaf("Agent"))||n.sameTerm(b.acl("AuthenticatedAgent"))||n.sameTerm(b.rdf("Resource"))||n.sameTerm(b.owl("Thing")))return{pred:"agentClass",obj:n};if(b.vcard("Individual").uri in i||b.foaf("Person").uri in i||b.foaf("Agent").uri in i){const e=t.any(n,b.foaf("preferredURI"));return e?{pred:"agent",obj:(0,g.sym)(e)}:{pred:"agent",obj:n}}if(b.solid("AppProvider").uri in i)return{pred:"origin",obj:n};if(b.solid("AppProviderClass").uri in i)return{pred:"originClass",obj:n};return ve.Rm(" Triage fails for "+e),null}(e,this.store),a=(0,g.sym)(e);if(!i&&!n){ve.Rm(` Not obvious: looking up dropped thing ${a}`);try{await(this._store?.fetcher?.load(a.doc()))}catch(e){const t=`Ignore error looking up dropped thing: ${e}`;return ve.z3(t),Promise.reject(new Error(t))}return this.handleDroppedUri(e,t,!0)}if(!i){const t=Object.keys(this.store.findTypeURIs(a)),n=`Error: Failed to add access target: ${e} 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.`+(t.length>0?`Detected RDF types: ${t.join(", ")}`:"No RDF type was detected for this URI.");return ve.z3(n),Promise.reject(new Error(n))}this.setACLCombo(t,e,i,this.controller.subject)}setACLCombo(e,t,n,i){e in this.byCombo||(this.byCombo[e]=[]),this.removeAgentFromCombos(t),this.byCombo[e].push([n.pred,n.obj.uri]),ve.Rm(`ACL: setting access to ${i} by ${n.pred}: ${n.obj}`)}removeAgentFromCombos(e){for(let t=0;t<16;t++){const n=this.byCombo[ta(t)];if(n)for(let t=0;t<n.length;t++)for(;t<n.length&&n[t][1]===e;)n.splice(t,1)}}}function ta(e){const t=["Read","Append","Write","Control"],n=[];for(let i=0;i<4;i++)e&1<<i&&n.push("http://www.w3.org/ns/auth/acl#"+t[i]);return n.sort(),n.join("\n")}class na{mainCombo;defaultsCombo;isContainer;defaultsDiffer;rootElement;isUsingDefaults;constructor(e,t,n,i,a,o,s,r,c,l,p,u){if(this.subject=e,this.noun=t,this.context=n,this.statusElement=i,this.targetIsProtected=a,this.targetDoc=o,this.targetACLDoc=s,this.defaultHolder=r,this.defaultACLDoc=c,this.prospectiveDefaultHolder=l,this.store=p,this.dom=u,this.rootElement=u.createElement("div"),this.rootElement.setAttribute("style",Ke.aclGroupContent),this.isContainer="/"===o.uri.slice(-1),r&&c){this.isUsingDefaults=!0;const e=we(this.targetDoc,s,r,c);this.mainCombo=new ea(o,s,this,e,{defaults:this.isContainer}),this.defaultsCombo=null,this.defaultsDiffer=!1}else this.isUsingDefaults=!1,this.mainCombo=new ea(o,s,this,p),this.defaultsCombo=new ea(o,s,this,p,{defaults:this.isContainer}),this.defaultsDiffer=!Ee(this.mainCombo.aclMap,this.defaultsCombo.aclMap)}get isEditable(){return!this.isUsingDefaults}render(){if(this.rootElement.innerHTML="",this.isUsingDefaults){if(this.renderStatus(`The sharing for this ${this.noun} is the default for folder `),this.defaultHolder){const e=this.statusElement.appendChild(this.dom.createElement("a"));e.href=this.defaultHolder.uri,e.innerText=ra(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}renderRemoveAclsController(){const e=this.dom.createElement("button");return e.innerText=`Remove custom sharing settings for this ${this.noun} -- just use default${this.prospectiveDefaultHolder?` for ${U(this.prospectiveDefaultHolder)}`:""}`,e.setAttribute("style",Ke.bigButton),e.addEventListener("click",()=>this.removeAcls().then(()=>this.render()).catch(e=>this.renderStatus(e))),e}renderAddAclsController(){const e=this.dom.createElement("button");return e.innerText=`Set specific sharing for this ${this.noun}`,e.setAttribute("style",Ke.bigButton),e.addEventListener("click",()=>this.addAcls().then(()=>this.render()).catch(e=>this.renderStatus(e))),e}renderAddDefaultsController(){const e=this.dom.createElement("div");e.setAttribute("style",Ke.defaultsController);const t=e.appendChild(this.dom.createElement("div"));t.innerText="Sharing for things within the folder currently tracks sharing for the folder.",t.setAttribute("style",Ke.defaultsControllerNotice);const n=e.appendChild(this.dom.createElement("button"));return n.innerText="Set the sharing of folder contents separately from the sharing for the folder",n.setAttribute("style",Ke.bigButton),n.addEventListener("click",()=>this.addDefaults().then(()=>this.render())),e}renderRemoveDefaultsController(){const e=this.dom.createElement("div");e.setAttribute("style",Ke.defaultsController);const t=e.appendChild(this.dom.createElement("div"));t.innerText="Access to things within this folder:",t.setAttribute("style",Ke.defaultsControllerNotice);const n=e.appendChild(this.dom.createElement("button"));return n.innerText="Set default for folder contents to just track the sharing for the folder",n.setAttribute("style",Ke.bigButton),n.addEventListener("click",()=>this.removeDefaults().then(()=>this.render()).catch(e=>this.renderStatus(e))),e}renderTemporaryStatus(e){this.statusElement.setAttribute("style",Ke.aclControlBoxStatusRevealed),this.statusElement.innerText=e,this.statusElement.setAttribute("style",Ke.temporaryStatusInit),setTimeout(()=>{this.statusElement.setAttribute("style",Ke.temporaryStatusEnd)}),setTimeout(()=>{this.statusElement.innerText=""},5e3)}renderStatus(e){e||this.statusElement.setAttribute("style",Ke.aclControlBoxStatusRevealed),this.statusElement.innerText=e}async addAcls(){if(!this.defaultHolder||!this.defaultACLDoc){const e="Unable to find defaults to copy";return ve.z3(e),Promise.reject(e)}we(this.targetDoc,this.targetACLDoc,this.defaultHolder,this.defaultACLDoc).statements.forEach(e=>this.store.add(e.subject,e.predicate,e.object,this.targetACLDoc));try{return await this.store.fetcher.putBack(this.targetACLDoc),this.isUsingDefaults=!1,Promise.resolve()}catch(e){const t=` Error writing back access control file! ${e}`;return ve.z3(t),Promise.reject(t)}}async addDefaults(){this.defaultsCombo=new ea(this.targetDoc,this.targetACLDoc,this,this.store,{defaults:!0}),this.defaultsDiffer=!0}async removeAcls(){try{await this.store.fetcher.delete(this.targetACLDoc.uri,{}),this.isUsingDefaults=!0;try{this.prospectiveDefaultHolder=await De(this.targetDoc.uri)}catch(e){ve.R8(e)}}catch(e){const t=`Error deleting access control file: ${this.targetACLDoc}: ${e}`;return ve.z3(t),Promise.reject(t)}}async removeDefaults(){const e=this.defaultsCombo;try{this.defaultsCombo=null,this.defaultsDiffer=!1,await this.save()}catch(t){return this.defaultsCombo=e,this.defaultsDiffer=!0,ve.z3(t),Promise.reject(t)}}save(){const e=(0,g.graph)();this.isContainer?this.defaultsCombo&&this.defaultsDiffer?(_e(e,this.targetDoc,this.mainCombo.byCombo,this.targetACLDoc,!0),_e(e,this.targetDoc,this.defaultsCombo.byCombo,this.targetACLDoc,!1,!0)):_e(e,this.targetDoc,this.mainCombo.byCombo,this.targetACLDoc,!0,!0):_e(e,this.targetDoc,this.mainCombo.byCombo,this.targetACLDoc,!0),e.fetcher=(0,g.fetcher)(e,{fetch:this.store.fetcher._fetch});const t=e.updater||new g.UpdateManager(e);return new Promise((n,i)=>{t.put(this.targetACLDoc,e.statementsMatching(void 0,void 0,void 0,this.targetACLDoc),"text/turtle",(t,a,o)=>{if(!a)return i(new Error(`ACL file save failed: ${o}`));this.store.fetcher.unload(this.targetACLDoc),this.store.add(e.statements),this.store.fetcher.requested[this.targetACLDoc.uri]="done",this.mainCombo.store=this.store,this.defaultsCombo&&(this.defaultsCombo.store=this.store),this.defaultsDiffer=!!this.defaultsCombo&&!Ee(this.mainCombo.aclMap,this.defaultsCombo.aclMap),ve.Rm("ACL modification: success!"),n()})})}}let ia=window;const aa=Symbol("prevent double triggering of drop event");function oa(e){e.stopPropagation(),e.preventDefault()}function sa(e){e.dataTransfer.files.length>0&&(ia.confirm("Are you sure you want to drop this file here? (Cancel opens it in a new tab)")||(e.stopPropagation(),e.preventDefault(),(0,ve.Rm)("@@@@ document-level DROP suppressed: "+e.dataTransfer.dropEffect)))}function ra(e){let t=e.uri;"/"===t.slice(-1)&&(t=t.slice(0,-1));const n=t.lastIndexOf("/");return n>=0&&(t=t.slice(n+1)),t||"/"}const ca={adoptACLDefault:we,readACL:Ce,sameACL:Ee,ACLunion:ke,loadUnionACL:Ae,ACLbyCombination:Te,makeACLGraph:je,makeACLGraphbyCombo:_e,ACLToString:function(e){return Le(Te(e))},comboToString:Le,makeACLString:function(e,t,n){const i=(0,g.graph)();return je(i,e,t,n),(0,g.serialize)(n,i,n.uri,"text/turtle")||""},putACLObject:Se,putACLbyCombo:Re,fixIndividualCardACL:function(e,t,n){const i=ye.each(void 0,b.vcard("hasMember"),e);i?Ne(e,i,t,n):(t("This card is in no groups"),n(!0))},fixIndividualACL:Ne,setACL:function(e,t,n){const i=ye.any(e,x.ACL_LINK);if(!ye.fetcher)throw new Error("Store has no fetcher");i?ye.fetcher.webOperation("PUT",i.value,{data:t,contentType:"text/turtle"}).then(e=>{n(e.ok,e.error||"")}):ye.fetcher.nowOrWhenFetched(e,void 0,function(i,a){if(!i)return n(i,"Gettting headers for ACL: "+a);const o=ye.any(e,x.ACL_LINK);if(o){if(!ye.fetcher)throw new Error("Store has no fetcher");ye.fetcher.webOperation("PUT",o.value,{data:t,contentType:"text/turtle"}).then(e=>{n(e.ok,e.error||"")})}else n(!1,"No Link rel=ACL header for "+e)})},getACLorDefault:Ie,getACL:Be},la={preventBrowserDropEvents:function(e){if((0,ve.Rm)("preventBrowserDropEvents called."),void 0!==ia){if(ia[aa])return;ia[aa]=!0}e.addEventListener("drop",sa,!1),e.addEventListener("dragenter",oa,!1),e.addEventListener("dragover",oa,!1)},shortNameForFolder:ra,ACLControlBox5:function(e,t,n,i){const a=t.dom,o=e.doc(),s=a.createElement("div");s.setAttribute("style",Ke.aclControlBoxContainer);const r=s.appendChild(a.createElement("h1"));r.textContent=`Sharing for ${n} ${U(e)}`,r.setAttribute("style",Ke.aclControlBoxHeader);const c=s.appendChild(a.createElement("div"));c.setAttribute("style",Ke.aclControlBoxStatus);try{(async function(e,t,n,i,a,o,s){return new Promise((r,c)=>Ie(e,async(e,l,p,u,d,m)=>{if(!e)return c(new Error(`Error reading ${l?"":" default "}ACL. status ${p}: ${u}`));const f=function(e){const t=e.uri.split("#")[0],n=t.slice(0,-1).lastIndexOf("/"),i=t.indexOf("//");return i>=0&&n<i+2||n<0?null:t.slice(0,n+1)}(p),h=function(e,t,n){return n.holds(e,b.rdf("type"),b.space("Storage"),t)}(p,u,t)||function(e){return e.uri===e.site().uri}(p);if(!h&&f)try{const e=await De(f);return r(g(e))}catch(e){(0,ve.R8)(e)}return r(g());function g(e){return new na(n,i,a,s,h,p,u,d,m,e,t,o)}}))})(o,i,e,n,t,a,c).then(e=>s.appendChild(e.render()))}catch(e){c.innerText=e}return s}},pa=x.solidLogicSingleton.store;const ua={newThingUI:function(e,t,n){const i=e.dom,a=e.div;if(e.me&&!e.me.uri)throw new Error("newThingUI: Invalid userid: "+e.me);const o="padding: 0.7em; width: 2em; height: 2em;",s=a.appendChild(i.createElement("img"));let r=!1;s.setAttribute("src",it.Pt.iconBase+"noun_34653_green.svg"),s.setAttribute("style",o),s.setAttribute("title","Add another tool");const c=function(e){const t=a.appendChild(i.createElement("pre"));t.setAttribute("style","background-color: pink"),t.appendChild(i.createTextNode(e))};function l(e){for(let t=0;t<u.length;t++){let n=o+e;u[t].disabled&&(n+="opacity: 0.3;"),u[t].setAttribute("style",n)}}function p(e){r=!r,s.setAttribute("style",o+(r?"background-color: yellow;":"")),l(r?"":"display: none;")}s.addEventListener("click",p);const u=[],d=Object.values(n).filter(e=>e.mintNew),m=d.reduce((e,t)=>(t.mintClass&&(e[t.mintClass.uri]=(e[t.mintClass.uri]||0)+1),e),{});d.forEach(n=>{const a=e.div.appendChild(i.createElement("img"));a.setAttribute("src",n.icon);const s=n.mintClass?m[n.mintClass.uri]>1?`${U(n.mintClass)} (using ${n.name} pane)`:U(n.mintClass):n.name+" @@";a.setAttribute("title","Make new "+s),a.setAttribute("style",o+"display: none;"),u.push(a),a.disabled||a.addEventListener("click",function(r){var u;!function(e){l("display: none;"),e.setAttribute("style",o+"background-color: yellow;")}(a),u={event:r,folder:e.folder||null,iconEle:a,pane:n,noun:s,noIndexHTML:!0,div:e.div,me:e.me,dom:e.dom,refreshTarget:e.refreshTarget},new Promise(function(n,a){let o;function s(n,o){Mi(e).then(e=>{const s=Object.assign({newBase:o,folder:u.folder||void 0,workspace:n},u);for(const e in u)s[e]=u[e];ve.Rm(`newThingUI: Minting new ${s.pane.name} at ${s.newBase}`),u.pane.mintNew(t,s).then(function(e){if(!e||!e.newInstance)throw new Error("Cannot mint new - missing newInstance");if(e.folder){const t=e.newInstance.uri.slice(e.folder.uri.length).includes("/");ve.Rm(" new thing is packge? "+t),t?pa.add(e.folder,b.ldp("contains"),pa.sym(e.newBase),e.folder.doc()):pa.add(e.folder,b.ldp("contains"),e.newInstance,e.folder.doc()),e.refreshTarget&&e.refreshTarget.refresh&&e.refreshTarget.refresh()}else{const t=u.div.appendChild(i.createElement("p"));t.setAttribute("style","font-size: 120%;"),t.innerHTML="Your <a target='_blank' href='"+e.newInstance.uri+"'><b>new "+u.noun+"</b></a> is ready to be set up. <br/><br/><a target='_blank' href='"+e.newInstance.uri+"'>Go to your new "+u.noun+".</a>"}p()}).catch(function(e){c(e),a(e)})},e=>{c("Error logging on: "+e)})}const r=u.pane;if(u.noun=r.mintClass?U(r.mintClass):r.name,u.appPathSegment=u.noun.slice(0,1).toUpperCase()+u.noun.slice(1),u.folder){const e=function(e){if(e){let t=u.folder.uri;t.endsWith("/")||(t+="/"),t=t+encodeURIComponent(e)+"/",s(null,t)}else p()};zt(i,0,u.div,b.foaf("name"),null,u.noun).then(e)}else o=Gi(i,{noun:u.noun,appPathSegment:u.appPathSegment},s),u.div.appendChild(o)})})})}},da=x.solidLogicSingleton.store;const ma={matrixForQuery:function(e,t,n,i,a,o,s){const r=e.createElement("table"),c=e.createElement("tr");c.appendChild(e.createElement("td")).setAttribute("class","MatrixCorner"),r.appendChild(c),r.lastHeader=c;let l=[];const p=[],u=function(e,t,n,i){for(;e.firstChild;)e.removeChild(e.firstChild);e.setAttribute("style",""),e.style.textAlign="center",o.cellFunction?o.cellFunction(e,t,n,i):(e.textContent=U(i),e.setAttribute("style","padding: 0.3em")),delete e.old},d=function(t){const n=t.toNT();if(p[n])return p[n];const i=e.createElement("tr"),a=i.appendChild(e.createElement("td"));a.setAttribute("style","padding: 0.3em;"),a.textContent=U(t),"NamedNode"===t.termType&&da.fetcher.nowOrWhenFetched(t.uri.split("#")[0],void 0,function(e,n,i){e&&(a.textContent=U(t))});for(let n=0;n<l.length;n++)u(i.appendChild(e.createElement("td")),g.fromNT(l[n]),t,null);i.dataValueNT=n,p[n]=i;for(let e=r.lastHeader.nextSibling;e;e=e.nextSibling)if(n>e.dataValueNT&&o&&o.yDecreasing||n<e.dataValueNT&&(!o||!o.yDecreasing))return r.insertBefore(i,e);return r.appendChild(i)},m=function(t){const n=t.toNT();let i=null;for(let e=0;e<l.length;e++){if(l[e]===n)return e;if(n>l[e]&&o.xDecreasing||n<l[e]&&!o.xDecreasing){l=l.slice(0,e).concat([n]).concat(l.slice(e)),i=e;break}}null===i&&(i=l.length,l.push(n));for(let n=r.firstChild;n;n=n.nextSibling){const a=n.dataValueNT,o=e.createElement("td");if(o.style.textAlign="center",n===r.firstChild?o.textContent=U(t):u(o,t,g.fromNT(a),null),i===l.length-1)n.appendChild(o);else{let e=n.firstChild;for(let t=0;t<i+1;t++)e=e.nextSibling;n.insertBefore(o,e)}}return i},f=function(){let e,t;const n=[],i=[];if(o.set_y)for(let e=0;e<o.set_y.length;e++)i[o.set_y[e]]=!0;if(o.set_x)for(let e=0;e<o.set_x.length;e++)n[m(o.set_x[e])+1]=!0;for(let a=1;a<r.children.length;a++){e=r.children[a];for(let a=1;a<e.children.length;a++)if(t=e.children[a],t.old){const n=g.fromNT(e.dataValueNT),i=g.fromNT(l[a-1]);u(t,i,n,null)}else i[e.dataValueNT]=!0,n[a]=!0}for(let t=0;t<r.children.length;t++)if(e=r.children[t],t>0&&!i[e.dataValueNT])delete p[e.dataValueNT],r.removeChild(e);else for(let t=e.children.length-1;t>0;t--){const i=e.children[t];n[t]||e.removeChild(i)}const a=[];for(let e=0;e<l.length;e++)n[e+1]&&a.push(l[e]);l=a};r.refresh=function(){!function(){for(let e=1;e<r.children.length;e++){const t=r.children[e];for(let e=1;e<t.children.length;e++)t.children[e].old=!0}}(),da.query(t,h,void 0,f)};const h=function(e){const t=e[n.toString()],o=e[i.toString()],s=e[a.toString()],r=d(o),c=m(t),l=r.children[c+1];u(l,t,o,s)};if(o.set_y)for(let e=0;e<o.set_y.length;e++)d(o.set_y[e]);if(o.set_x)for(let e=0;e<o.set_x.length;e++)m(o.set_x[e]);return da.query(t,h,void 0,s),r}},fa=it.Pt.iconBase+"noun_Camera_1618446_000000.svg",ha=it.Pt.iconBase+"noun_479395.svg";function ga(e,t,n,i){const a=e.createElement("div");let o,s,r,c;const l=a.appendChild(e.createElement("table")),p=l.appendChild(e.createElement("tr")).appendChild(e.createElement("td"));p.setAttribute("colspan","4");const u=l.appendChild(e.createElement("tr"));u.appendChild(e.createElement("td")).appendChild(Mt(e)).addEventListener("click",e=>{b(),i(null)});const d=u.appendChild(e.createElement("td")).appendChild(Ot(e,ha,"Retake"));d.addEventListener("click",e=>{p.removeChild(c),h()}),d.style.visibility="collapse";const m=u.appendChild(e.createElement("td")).appendChild(Ot(e,it.Pt.iconBase+"noun_10636.svg","Snap"));m.addEventListener("click",function(){c=e.createElement("canvas"),c.setAttribute("width",Ke.canvasWidth),c.setAttribute("height",Ke.canvasHeight),c.setAttribute("style",Ke.controlStyle),p.appendChild(c);c.getContext("2d").drawImage(r,0,0,c.width,c.height),r.parentNode.removeChild(r),c.toBlob(e=>{const t=`got blob type ${e.type} size ${e.size}`;ve.Rm(t),o=n(),s=e,f.style.visibility="visible",d.style.visibility="visible",m.style.visibility="collapse"},"image/png")}),m.style.visibility="collapse";const f=u.appendChild(e.createElement("td")).appendChild(Ft(e));function h(){if(r=p.appendChild(e.createElement("video")),r.setAttribute("controls","1"),r.setAttribute("autoplay","1"),r.setAttribute("style",Ke.controlStyle),!navigator.mediaDevices)throw new Error("navigator.mediaDevices not available");navigator.mediaDevices.getUserMedia(g).then(e=>{r.srcObject=e,m.style.visibility="visible",f.style.visibility="collapse",d.style.visibility="collapse"})}f.addEventListener("click",e=>{!function(e,n){const a=e.type;ve.Rm("Putting "+e.size+" bytes of "+a+" to "+n),t.fetcher.webOperation("PUT",n.uri,{data:e,contentType:a}).then(e=>{ve.Rm("ok saved "+n),b(),i(n)},e=>{b(),alert(e)})}(s,o)}),f.style.visibility="collapse";const g={video:!0};function b(){r&&r.srcObject&&r.srcObject.getVideoTracks().forEach(e=>e.stop())}return h(),a}const ba={cameraCaptureControl:ga,cameraButton:function(e,t,n,i){const a=e.createElement("div"),o=Ot(e,fa,"Take picture");let s;async function r(e){a.removeChild(s),a.appendChild(o),i(e)}return a.appendChild(o),o.addEventListener("click",i=>{a.removeChild(o),s=ga(e,t,n,r),a.appendChild(s)}),a}},xa={icons:it.Pt,ns:b,rdf:g,style:Ke,widgets:r};function va(e,t,n,i,a){t=t||x.solidLogicSingleton.store,i=i.doc();const o=xa.ns,s=g.Namespace("http://www.w3.org/2005/01/wf/flow#"),r=g.Namespace("http://purl.org/dc/terms/"),c=!!(a=a||{}).newestFirst,l="white-space: pre-wrap; width: 90%; font-size:100%; border: 0.07em solid #eee; padding: .2em 0.5em; margin: 0.1em 1em 0.1em 1em;",p=e.createElement("div");let u,d;const m=x.solidLogicSingleton.store.updater,f=function(t,n){const i=e.createElement("a");return n&&n.uri&&(i.setAttribute("href",n.uri),i.addEventListener("click",xa.widgets.openHrefInOutlineMode,!0),i.setAttribute("style","color: #3B5998; text-decoration: none; ")),i.textContent=t,i},h=function(t,n){const i=e.createElement("pre");return i.setAttribute("style",n||"color: grey"),p.appendChild(i),i.appendChild(e.createTextNode(t)),i},b=function(e){h(e,"color: #800;")};function v(e){const t=x.solidLogicSingleton.store.any(e,xa.ns.foaf("nick"));return t?""+t.value:""+U(e)}function y(t,n,i,a){const o=t.appendChild(f(v(n),n));n.uri&&x.solidLogicSingleton.store.fetcher.nowOrWhenFetched(n.doc(),void 0,function(e,t){o.textContent=v(n)}),t.appendChild(e.createElement("br")),t.appendChild(f(i,a))}function w(e,n){const i={};let a,s;for(a=n.firstChild;a;a=a.nextSibling)a.AJAR_subject&&(i[a.AJAR_subject.uri]=!0);const r=t.each(e,o.wf("message")),c={};for(r.forEach(function(e){c[e.uri]=!0,i[e.uri]||C(e)}),a=n.firstChild;a;)s=a.nextSibling,a.AJAR_subject&&!c[a.AJAR_subject.uri]&&n.removeChild(a),a=s}const C=function(e){const n={"?msg":e,"?creator":t.any(e,o.foaf("maker")),"?date":t.any(e,r("created")),"?content":t.any(e,o.sioc("content"))};E(n,!0)},E=function(i,a){const o=i["?creator"],s=i["?msg"],r=i["?date"],p=i["?content"],d=r.value,f=e.createElement("tr");f.AJAR_date=d,f.AJAR_subject=s;let h=!1;for(let e=u.firstChild;e;e=e.nextSibling)if(d>e.AJAR_date&&c||d<e.AJAR_date&&!c){u.insertBefore(f,e),h=!0;break}h||u.appendChild(f);const g=e.createElement("td");f.appendChild(g),y(g,o,xa.widgets.shortDate(d),s);const x=e.createElement("td");f.appendChild(x);const v=e.createElement("p");v.setAttribute("style",l+(a?"background-color: #e8ffe8;":"background-color: #white;")),x.appendChild(v),v.textContent=p.value;const C=e.createElement("td");f.appendChild(C);const E=e.createElement("button");C.appendChild(E),E.textContent="-",f.setAttribute("class","hoverControl"),E.setAttribute("class","hoverControlHide"),E.setAttribute("style","color: red;"),E.addEventListener("click",function(i){C.removeChild(E);const a=e.createElement("button");a.textContent="cancel",C.appendChild(a).addEventListener("click",function(e){C.removeChild(o),C.removeChild(a),C.appendChild(E)},!1);const o=e.createElement("button");o.textContent="Delete message",C.appendChild(o).addEventListener("click",function(e){C.removeChild(o),C.removeChild(a),function(e){const i=t.statementsMatching(e).concat(t.statementsMatching(void 0,void 0,e));m.update(i,[],function(e,t,i){t?w(n,u):b("Cant delete messages:"+i)})}(s)},!1)},!1)};u=e.createElement("table"),u.fresh=!1,p.appendChild(u),u.setAttribute("style","width: 100%;");const k=function(){const a=e.createElement("tr"),s=e.createElement("td"),c=e.createElement("td"),p=e.createElement("td");a.appendChild(s),a.appendChild(c),a.appendChild(p),a.AJAR_date="9999-01-01T00:00:00Z";const u=function(){f.setAttribute("class","pendingedit"),f.disabled=!0;const s=[],c=new Date,l=""+c.getTime(),p=g.term(c),u=t.sym(i.uri+"#Msg"+l);s.push(new g.Statement(n,o.wf("message"),u,i)),s.push(new g.Statement(u,o.sioc("content"),t.literal(f.value),i)),s.push(new g.Statement(u,r("created"),p,i)),d&&s.push(new g.Statement(u,o.foaf("maker"),d,i));m.update([],s,function(n,i,o){if(i){const e={"?msg":u,"?content":t.literal(f.value),"?date":p,"?creator":d};E(e,!1),f.value="",f.setAttribute("class",""),f.disabled=!1}else a.appendChild(xa.widgets.errorMessageBlock(e,"Error writing message: "+o))})};let f,h;a.appendChild(e.createElement("br"));return Di({div:c,dom:e}).then(t=>{d=t.me,y(s,d,"",null),f=e.createElement("textarea"),c.innerHTML="",c.appendChild(f),f.rows=3,f.setAttribute("style",l+"background-color: #eef;"),f.addEventListener("keyup",function(e){13===e.keyCode&&(e.altKey||u())},!1),p.innerHTML="",h=xa.widgets.button(e,xa.icons.iconBase+"noun_383448.svg","Send"),h.setAttribute("style",xa.style.buttonStyle+"float: right;"),h.addEventListener("click",u,!1),p.appendChild(h)}),a}();let A;if(c?u.insertBefore(k,u.firstChild):u.appendChild(k),a.query)A=a.query;else{A=new g.Query("Messages");const e={};["msg","date","creator","content"].forEach(function(t){A.vars.push(e[t]=g.variable(t))}),A.pat.add(n,s("message"),e.msg),A.pat.add(e.msg,o.dct("created"),e.date),A.pat.add(e.msg,o.foaf("maker"),e.creator),A.pat.add(e.msg,o.sioc("content"),e.content)}return t.query(A,E,void 0,function(){u.fresh=!0}),p.refresh=function(){w(n,u)},p}async function ya(e){return await x.store.fetcher.load(e),!(x.store.statementsMatching(null,b.dct("created"),null,e).length>0)}class wa{constructor(e,t,n){this.root=e,this.rootFolder=e.dir(),this.leafFileName=t||"index.ttl",this.membershipProperty=n||b.wf("leafObject")}leafDocumentFromDate(e){let t=e.toISOString().split("T")[0].replace(/-/g,"/");return t=this.root.dir().uri+t+"/"+this.leafFileName,x.store.sym(t)}dateFromLeafDocument(e){const t=this.rootFolder.uri.length,n=e.uri.slice(t,t+10).replace(/\//g,"-");return new Date(n)}async loadPrevious(e,t){async function n(e,i){function a(e){const t=e.uri.slice(0,-1).split("/").slice(-1)[0];return!!"0123456789".includes(t[0])}function o(e){return(e=e.filter(a)).sort(),t||e.reverse(),e.pop()}const s=e.dir();try{await x.store.fetcher.load(s);let n=x.store.each(s,b.ldp("contains"));n=n.filter(function(n){return!(t?n.uri>=e.uri:n.uri<=e.uri)});const i=o(n);if(i)return i}catch(e){if(!e.response||!e.response.status||404!==e.response.status)throw ve.Rm("*** Error NON 404 for chat parent file "+s),new Error(`*** ${e.message} for chat folder ${s}`);ve.Rm("Error 404 for chat parent file "+s)}if(0===i)return null;const r=await n(s,i-1);if(!r)return null;await x.store.fetcher.load(r);return o(x.store.each(r,b.ldp("contains")))}let i=this.leafDocumentFromDate(e).dir();for(;;){const t=await n(i,3);if(!t)return null;{const n=x.store.sym(t.uri+this.leafFileName),a=this.dateFromLeafDocument(n);if(!await ya(n))return a;e=a,i=this.leafDocumentFromDate(e).dir()}}}async firstLeaf(e){const t=g.graph(),n=new g.Fetcher(t);async function i(i){delete n.requested[i.uri],await n.load(i,{force:!0});let a=t.each(i,b.ldp("contains"));if(a=a.filter(function(e){const t=e.uri.slice(0,-1).split("/").slice(-1)[0];return!!"0123456789".includes(t[0])}),0===a.length)throw new Error(" @@@ No children to parent2 "+i);return a.sort(),e&&a.reverse(),a[0]}const a=await i(this.root.dir()),o=await i(a),s=await i(o),r=g.sym(s.uri+"chat.ttl");await n.load(r);const c=t.each(this.root,this.membershipProperty,null,r);if(0===c.length){const e=" INCONSISTENCY -- no chat leafObject in file "+r;throw ve.uP(e),new Error(e)}const l=c.map(e=>[t.any(e,b.dct("created")),e]);return l.sort(),e&&l.reverse(),l[0][1]}}function Ca(e,t=""){if("number"!=typeof e){throw new TypeError(`${t&&`"${t}" `}expected number, got ${typeof e}`)}if(!Number.isSafeInteger(e)||e<0){throw new RangeError(`${t&&`"${t}" `}expected integer >= 0, got ${e}`)}}function Ea(e,t,n=""){const i=(a=e)instanceof Uint8Array||ArrayBuffer.isView(a)&&"Uint8Array"===a.constructor.name&&"BYTES_PER_ELEMENT"in a&&1===a.BYTES_PER_ELEMENT;var a;const o=e?.length,s=void 0!==t;if(!i||s&&o!==t){const a=(n&&`"${n}" `)+"expected Uint8Array"+(s?` of length ${t}`:"")+", got "+(i?`length=${o}`:"type="+typeof e);if(!i)throw new TypeError(a);throw new RangeError(a)}return e}function ka(e,t=!0){if(e.destroyed)throw new Error("Hash instance has been destroyed");if(t&&e.finished)throw new Error("Hash#digest() has already been called")}function Aa(...e){for(let t=0;t<e.length;t++)e[t].fill(0)}function Ta(e){return new DataView(e.buffer,e.byteOffset,e.byteLength)}function ja(e,t){return e<<32-t|e>>>t}const _a=(()=>"function"==typeof Uint8Array.from([]).toHex&&"function"==typeof Uint8Array.fromHex)(),La=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0"));function Sa(e){if(Ea(e),_a)return e.toHex();let t="";for(let n=0;n<e.length;n++)t+=La[e[n]];return t}const Ra=48,Na=57,Ia=65,Ba=70,Da=97,Oa=102;function Ma(e){return e>=Ra&&e<=Na?e-Ra:e>=Ia&&e<=Ba?e-(Ia-10):e>=Da&&e<=Oa?e-(Da-10):void 0}function Fa(e){if("string"!=typeof e)throw new TypeError("hex string expected, got "+typeof e);if(_a)try{return Uint8Array.fromHex(e)}catch(e){if(e instanceof SyntaxError)throw new RangeError(e.message);throw e}const t=e.length,n=t/2;if(t%2)throw new RangeError("hex string expected, got unpadded hex of length "+t);const i=new Uint8Array(n);for(let t=0,a=0;t<n;t++,a+=2){const n=Ma(e.charCodeAt(a)),o=Ma(e.charCodeAt(a+1));if(void 0===n||void 0===o){const t=e[a]+e[a+1];throw new RangeError('hex string expected, got non-hex character "'+t+'" at index '+a)}i[t]=16*n+o}return i}function za(e,t={}){const n=(t,n)=>e(n).update(t).digest(),i=e(void 0);return n.outputLen=i.outputLen,n.blockLen=i.blockLen,n.canXOF=i.canXOF,n.create=t=>e(t),Object.assign(n,t),Object.freeze(n)}function Ua(e=32){Ca(e,"bytesLength");const t="object"==typeof globalThis?globalThis.crypto:null;if("function"!=typeof t?.getRandomValues)throw new Error("crypto.getRandomValues must be defined");if(e>65536)throw new RangeError(`"bytesLength" expected <= 65536, got ${e}`);return t.getRandomValues(new Uint8Array(e))}const Pa=e=>({oid:Uint8Array.from([6,9,96,134,72,1,101,3,4,2,e])});function $a(e,t,n){return e&t^~e&n}function qa(e,t,n){return e&t^e&n^t&n}class Ha{blockLen;outputLen;canXOF=!1;padOffset;isLE;buffer;view;finished=!1;length=0;pos=0;destroyed=!1;constructor(e,t,n,i){this.blockLen=e,this.outputLen=t,this.padOffset=n,this.isLE=i,this.buffer=new Uint8Array(e),this.view=Ta(this.buffer)}update(e){ka(this),Ea(e);const{view:t,buffer:n,blockLen:i}=this,a=e.length;for(let o=0;o<a;){const s=Math.min(i-this.pos,a-o);if(s===i){const t=Ta(e);for(;i<=a-o;o+=i)this.process(t,o);continue}n.set(e.subarray(o,o+s),this.pos),this.pos+=s,o+=s,this.pos===i&&(this.process(t,0),this.pos=0)}return this.length+=e.length,this.roundClean(),this}digestInto(e){ka(this),function(e,t){Ea(e,void 0,"digestInto() output");const n=t.outputLen;if(e.length<n)throw new RangeError('"digestInto() output" expected to be of length >='+n)}(e,this),this.finished=!0;const{buffer:t,view:n,blockLen:i,isLE:a}=this;let{pos:o}=this;t[o++]=128,Aa(this.buffer.subarray(o)),this.padOffset>i-o&&(this.process(n,0),o=0);for(let e=o;e<i;e++)t[e]=0;n.setBigUint64(i-8,BigInt(8*this.length),a),this.process(n,0);const s=Ta(e),r=this.outputLen;if(r%4)throw new Error("_sha2: outputLen must be aligned to 32bit");const c=r/4,l=this.get();if(c>l.length)throw new Error("_sha2: outputLen bigger than state");for(let e=0;e<c;e++)s.setUint32(4*e,l[e],a)}digest(){const{buffer:e,outputLen:t}=this;this.digestInto(e);const n=e.slice(0,t);return this.destroy(),n}_cloneInto(e){e||=new this.constructor,e.set(...this.get());const{blockLen:t,buffer:n,length:i,finished:a,destroyed:o,pos:s}=this;return e.destroyed=o,e.finished=a,e.length=i,e.pos=s,i%t&&e.buffer.set(n),e}clone(){return this._cloneInto()}}const Ga=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]);const Va=Uint32Array.from([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),Wa=new Uint32Array(64);class Ja extends Ha{constructor(e){super(64,e,8,!1)}get(){const{A:e,B:t,C:n,D:i,E:a,F:o,G:s,H:r}=this;return[e,t,n,i,a,o,s,r]}set(e,t,n,i,a,o,s,r){this.A=0|e,this.B=0|t,this.C=0|n,this.D=0|i,this.E=0|a,this.F=0|o,this.G=0|s,this.H=0|r}process(e,t){for(let n=0;n<16;n++,t+=4)Wa[n]=e.getUint32(t,!1);for(let e=16;e<64;e++){const t=Wa[e-15],n=Wa[e-2],i=ja(t,7)^ja(t,18)^t>>>3,a=ja(n,17)^ja(n,19)^n>>>10;Wa[e]=a+Wa[e-7]+i+Wa[e-16]|0}let{A:n,B:i,C:a,D:o,E:s,F:r,G:c,H:l}=this;for(let e=0;e<64;e++){const t=l+(ja(s,6)^ja(s,11)^ja(s,25))+$a(s,r,c)+Va[e]+Wa[e]|0,p=(ja(n,2)^ja(n,13)^ja(n,22))+qa(n,i,a)|0;l=c,c=r,r=s,s=o+t|0,o=a,a=i,i=n,n=t+p|0}n=n+this.A|0,i=i+this.B|0,a=a+this.C|0,o=o+this.D|0,s=s+this.E|0,r=r+this.F|0,c=c+this.G|0,l=l+this.H|0,this.set(n,i,a,o,s,r,c,l)}roundClean(){Aa(Wa)}destroy(){this.destroyed=!0,this.set(0,0,0,0,0,0,0,0),Aa(this.buffer)}}class Qa extends Ja{A=0|Ga[0];B=0|Ga[1];C=0|Ga[2];D=0|Ga[3];E=0|Ga[4];F=0|Ga[5];G=0|Ga[6];H=0|Ga[7];constructor(){super(32)}}const Za=za(()=>new Qa,Pa(1));
|
|
14
14
|
/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
|
|
15
|
-
const Ya=(e,t,n)=>Ea(e,t,n),Ka=Ca,Xa=Sa,eo=(...e)=>function(...e){let t=0;for(let n=0;n<e.length;n++){const i=e[n];Ea(i),t+=i.length}const n=new Uint8Array(t);for(let t=0,i=0;t<e.length;t++){const a=e[t];n.set(a,i),i+=a.length}return n}(...e),to=BigInt(0),no=BigInt(1);function io(e,t=""){if("boolean"!=typeof e){throw new TypeError((t&&`"${t}" `)+"expected boolean, got type="+typeof e)}return e}function ao(e){if("bigint"==typeof e){if(!mo(e))throw new RangeError("positive bigint expected, got "+e)}else Ka(e);return e}function oo(e,t=""){if("number"!=typeof e){throw new TypeError((t&&`"${t}" `)+"expected number, got type="+typeof e)}if(!Number.isSafeInteger(e)){throw new RangeError((t&&`"${t}" `)+"expected safe integer, got "+e)}}function so(e){const t=ao(e).toString(16);return 1&t.length?"0"+t:t}function ro(e){if("string"!=typeof e)throw new TypeError("hex string expected, got "+typeof e);return""===e?to:BigInt("0x"+e)}function co(e){return ro(Sa(e))}function lo(e){return ro(Sa(function(e){return Uint8Array.from(Ya(e))}(Ea(e)).reverse()))}function po(e,t){if(Ca(t),0===t)throw new RangeError("zero length");const n=(e=ao(e)).toString(16);if(n.length>2*t)throw new RangeError("number too large");return Fa(n.padStart(2*t,"0"))}function uo(e,t){return po(e,t).reverse()}const mo=e=>"bigint"==typeof e&&to<=e;function fo(e,t,n,i){if(!function(e,t,n){return mo(e)&&mo(t)&&mo(n)&&t<=e&&e<n}(t,n,i))throw new RangeError("expected valid "+e+": "+n+" <= n < "+i+", got "+t)}function ho(e){if(e<to)throw new Error("expected non-negative bigint, got "+e);let t;for(t=0;e>to;e>>=no,t+=1);return t}const go=e=>(no<<BigInt(e))-no;function bo(e,t={},n={}){if("[object Object]"!==Object.prototype.toString.call(e))throw new TypeError("expected valid options object");const i=(t,n)=>Object.entries(t).forEach(([t,i])=>function(t,n,i){if(!i&&"function"!==n&&!Object.hasOwn(e,t))throw new TypeError(`param "${t}" is invalid: expected own property`);const a=e[t];if(i&&void 0===a)return;const o=typeof a;if(o!==n||null===a)throw new TypeError(`param "${t}" is invalid: expected ${n}, got ${o}`)}(t,i,n));i(t,!1),i(n,!0)}const xo=BigInt(0),vo=BigInt(1),yo=BigInt(2),wo=BigInt(3),Co=BigInt(4),Eo=BigInt(5),ko=BigInt(7),Ao=BigInt(8),To=BigInt(9),jo=BigInt(16);function _o(e,t){if(t<=xo)throw new Error("mod: expected positive modulus, got "+t);const n=e%t;return n>=xo?n:t+n}function Lo(e,t,n){if(t<xo)throw new Error("pow2: expected non-negative exponent, got "+t);let i=e;for(;t-- >xo;)i*=i,i%=n;return i}function So(e,t){if(e===xo)throw new Error("invert: expected non-zero number");if(t<=xo)throw new Error("invert: expected positive modulus, got "+t);let n=_o(e,t),i=t,a=xo,o=vo,s=vo,r=xo;for(;n!==xo;){const e=i/n,t=i-n*e,c=a-s*e,l=o-r*e;i=n,n=t,a=s,o=r,s=c,r=l}if(i!==vo)throw new Error("invert: does not exist");return _o(a,t)}function Ro(e,t,n){const i=e;if(!i.eql(i.sqr(t),n))throw new Error("Cannot find square root")}function No(e,t){const n=e,i=(n.ORDER+vo)/Co,a=n.pow(t,i);return Ro(n,a,t),a}function Io(e,t){const n=e,i=(n.ORDER-Eo)/Ao,a=n.mul(t,yo),o=n.pow(a,i),s=n.mul(t,o),r=n.mul(n.mul(s,yo),o),c=n.mul(s,n.sub(r,n.ONE));return Ro(n,c,t),c}function Bo(e){if(e<wo)throw new Error("sqrt is not defined for small field");let t=e-vo,n=0;for(;t%yo===xo;)t/=yo,n++;let i=yo;const a=$o(e);for(;1===
|
|
15
|
+
const Ya=(e,t,n)=>Ea(e,t,n),Ka=Ca,Xa=Sa,eo=(...e)=>function(...e){let t=0;for(let n=0;n<e.length;n++){const i=e[n];Ea(i),t+=i.length}const n=new Uint8Array(t);for(let t=0,i=0;t<e.length;t++){const a=e[t];n.set(a,i),i+=a.length}return n}(...e),to=BigInt(0),no=BigInt(1);function io(e,t=""){if("boolean"!=typeof e){throw new TypeError((t&&`"${t}" `)+"expected boolean, got type="+typeof e)}return e}function ao(e){if("bigint"==typeof e){if(!mo(e))throw new RangeError("positive bigint expected, got "+e)}else Ka(e);return e}function oo(e,t=""){if("number"!=typeof e){throw new TypeError((t&&`"${t}" `)+"expected number, got type="+typeof e)}if(!Number.isSafeInteger(e)){throw new RangeError((t&&`"${t}" `)+"expected safe integer, got "+e)}}function so(e){const t=ao(e).toString(16);return 1&t.length?"0"+t:t}function ro(e){if("string"!=typeof e)throw new TypeError("hex string expected, got "+typeof e);return""===e?to:BigInt("0x"+e)}function co(e){return ro(Sa(e))}function lo(e){return ro(Sa(function(e){return Uint8Array.from(Ya(e))}(Ea(e)).reverse()))}function po(e,t){if(Ca(t),0===t)throw new RangeError("zero length");const n=(e=ao(e)).toString(16);if(n.length>2*t)throw new RangeError("number too large");return Fa(n.padStart(2*t,"0"))}function uo(e,t){return po(e,t).reverse()}const mo=e=>"bigint"==typeof e&&to<=e;function fo(e,t,n,i){if(!function(e,t,n){return mo(e)&&mo(t)&&mo(n)&&t<=e&&e<n}(t,n,i))throw new RangeError("expected valid "+e+": "+n+" <= n < "+i+", got "+t)}function ho(e){if(e<to)throw new Error("expected non-negative bigint, got "+e);let t;for(t=0;e>to;e>>=no,t+=1);return t}const go=e=>(no<<BigInt(e))-no;function bo(e,t={},n={}){if("[object Object]"!==Object.prototype.toString.call(e))throw new TypeError("expected valid options object");const i=(t,n)=>Object.entries(t).forEach(([t,i])=>function(t,n,i){if(!i&&"function"!==n&&!Object.hasOwn(e,t))throw new TypeError(`param "${t}" is invalid: expected own property`);const a=e[t];if(i&&void 0===a)return;const o=typeof a;if(o!==n||null===a)throw new TypeError(`param "${t}" is invalid: expected ${n}, got ${o}`)}(t,i,n));i(t,!1),i(n,!0)}const xo=BigInt(0),vo=BigInt(1),yo=BigInt(2),wo=BigInt(3),Co=BigInt(4),Eo=BigInt(5),ko=BigInt(7),Ao=BigInt(8),To=BigInt(9),jo=BigInt(16);function _o(e,t){if(t<=xo)throw new Error("mod: expected positive modulus, got "+t);const n=e%t;return n>=xo?n:t+n}function Lo(e,t,n){if(t<xo)throw new Error("pow2: expected non-negative exponent, got "+t);let i=e;for(;t-- >xo;)i*=i,i%=n;return i}function So(e,t){if(e===xo)throw new Error("invert: expected non-zero number");if(t<=xo)throw new Error("invert: expected positive modulus, got "+t);let n=_o(e,t),i=t,a=xo,o=vo,s=vo,r=xo;for(;n!==xo;){const e=i/n,t=i-n*e,c=a-s*e,l=o-r*e;i=n,n=t,a=s,o=r,s=c,r=l}if(i!==vo)throw new Error("invert: does not exist");return _o(a,t)}function Ro(e,t,n){const i=e;if(!i.eql(i.sqr(t),n))throw new Error("Cannot find square root")}function No(e,t){const n=e,i=(n.ORDER+vo)/Co,a=n.pow(t,i);return Ro(n,a,t),a}function Io(e,t){const n=e,i=(n.ORDER-Eo)/Ao,a=n.mul(t,yo),o=n.pow(a,i),s=n.mul(t,o),r=n.mul(n.mul(s,yo),o),c=n.mul(s,n.sub(r,n.ONE));return Ro(n,c,t),c}function Bo(e){if(e<wo)throw new Error("sqrt is not defined for small field");let t=e-vo,n=0;for(;t%yo===xo;)t/=yo,n++;let i=yo;const a=$o(e);for(;1===zo(a,i);)if(i++>1e3)throw new Error("Cannot find square root: probably non-prime P");if(1===n)return No;let o=a.pow(i,t);const s=(t+vo)/yo;return function(e,i){const a=e;if(a.is0(i))return i;if(1!==zo(a,i))throw new Error("Cannot find square root");let r=n,c=a.mul(a.ONE,o),l=a.pow(i,t),p=a.pow(i,s);for(;!a.eql(l,a.ONE);){if(a.is0(l))return a.ZERO;let e=1,t=a.sqr(l);for(;!a.eql(t,a.ONE);)if(e++,t=a.sqr(t),e===r)throw new Error("Cannot find square root");const n=vo<<BigInt(r-e-1),i=a.pow(c,n);r=e,c=a.sqr(i),l=a.mul(l,c),p=a.mul(p,i)}return p}}function Do(e){return e%Co===wo?No:e%Ao===Eo?Io:e%jo===To?function(e){const t=$o(e),n=Bo(e),i=n(t,t.neg(t.ONE)),a=n(t,i),o=n(t,t.neg(i)),s=(e+ko)/jo;return(e,t)=>{const n=e;let r=n.pow(t,s),c=n.mul(r,i);const l=n.mul(r,a),p=n.mul(r,o),u=n.eql(n.sqr(c),t),d=n.eql(n.sqr(l),t);r=n.cmov(r,c,u),c=n.cmov(p,l,d);const m=n.eql(n.sqr(c),t),f=n.cmov(r,c,m);return Ro(n,f,t),f}}(e):Bo(e)}const Oo=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function Mo(e,t,n){const i=e;if(n<xo)throw new Error("invalid exponent, negatives unsupported");if(n===xo)return i.ONE;if(n===vo)return t;let a=i.ONE,o=t;for(;n>xo;)n&vo&&(a=i.mul(a,o)),o=i.sqr(o),n>>=vo;return a}function Fo(e,t,n=!1){const i=e,a=new Array(t.length).fill(n?i.ZERO:void 0),o=t.reduce((e,t,n)=>i.is0(t)?e:(a[n]=e,i.mul(e,t)),i.ONE),s=i.inv(o);return t.reduceRight((e,t,n)=>i.is0(t)?e:(a[n]=i.mul(e,a[n]),i.mul(e,t)),s),a}function zo(e,t){const n=e,i=(n.ORDER-vo)/yo,a=n.pow(t,i),o=n.eql(a,n.ONE),s=n.eql(a,n.ZERO),r=n.eql(a,n.neg(n.ONE));if(!o&&!s&&!r)throw new Error("invalid Legendre symbol result");return o?1:s?0:-1}const Uo=new WeakMap;class Po{ORDER;BITS;BYTES;isLE;ZERO=xo;ONE=vo;_lengths;_mod;constructor(e,t={}){if(e<=vo)throw new Error("invalid field: expected ORDER > 1, got "+e);let n;this.isLE=!1,null!=t&&"object"==typeof t&&("number"==typeof t.BITS&&(n=t.BITS),"function"==typeof t.sqrt&&Object.defineProperty(this,"sqrt",{value:t.sqrt,enumerable:!0}),"boolean"==typeof t.isLE&&(this.isLE=t.isLE),t.allowedLengths&&(this._lengths=Object.freeze(t.allowedLengths.slice())),"boolean"==typeof t.modFromBytes&&(this._mod=t.modFromBytes));const{nBitLength:i,nByteLength:a}=function(e,t){if(void 0!==t&&Ka(t),e<=xo)throw new Error("invalid n length: expected positive n, got "+e);if(void 0!==t&&t<1)throw new Error("invalid n length: expected positive bit length, got "+t);const n=ho(e);if(void 0!==t&&t<n)throw new Error(`invalid n length: expected bit length (${n}) >= n.length (${t})`);const i=void 0!==t?t:n;return{nBitLength:i,nByteLength:Math.ceil(i/8)}}(e,n);if(a>2048)throw new Error("invalid field: expected ORDER of <= 2048 bytes");this.ORDER=e,this.BITS=i,this.BYTES=a,Object.freeze(this)}create(e){return _o(e,this.ORDER)}isValid(e){if("bigint"!=typeof e)throw new TypeError("invalid field element: expected bigint, got "+typeof e);return xo<=e&&e<this.ORDER}is0(e){return e===xo}isValidNot0(e){return!this.is0(e)&&this.isValid(e)}isOdd(e){return(e&vo)===vo}neg(e){return _o(-e,this.ORDER)}eql(e,t){return e===t}sqr(e){return _o(e*e,this.ORDER)}add(e,t){return _o(e+t,this.ORDER)}sub(e,t){return _o(e-t,this.ORDER)}mul(e,t){return _o(e*t,this.ORDER)}pow(e,t){return Mo(this,e,t)}div(e,t){return _o(e*So(t,this.ORDER),this.ORDER)}sqrN(e){return e*e}addN(e,t){return e+t}subN(e,t){return e-t}mulN(e,t){return e*t}inv(e){return So(e,this.ORDER)}sqrt(e){let t=Uo.get(this);return t||Uo.set(this,t=Do(this.ORDER)),t(this,e)}toBytes(e){return this.isLE?uo(e,this.BYTES):po(e,this.BYTES)}fromBytes(e,t=!1){Ya(e);const{_lengths:n,BYTES:i,isLE:a,ORDER:o,_mod:s}=this;if(n){if(e.length<1||!n.includes(e.length)||e.length>i)throw new Error("Field.fromBytes: expected "+n+" bytes, got "+e.length);const t=new Uint8Array(i);t.set(e,a?0:t.length-e.length),e=t}if(e.length!==i)throw new Error("Field.fromBytes: expected "+i+" bytes, got "+e.length);let r=a?lo(e):co(e);if(s&&(r=_o(r,o)),!t&&!this.isValid(r))throw new Error("invalid field element: outside of range 0..ORDER");return r}invertBatch(e){return Fo(this,e)}cmov(e,t,n){return io(n,"condition"),n?t:e}}function $o(e,t={}){return new Po(e,t)}function qo(e){if("bigint"!=typeof e)throw new Error("field order must be bigint");if(e<=vo)throw new Error("field order must be greater than 1");const t=ho(e-vo);return Math.ceil(t/8)}function Ho(e,t,n=!1){Ya(e);const i=e.length,a=qo(t),o=Math.max(function(e){const t=qo(e);return t+Math.ceil(t/2)}(t),16);if(i<o||i>1024)throw new Error("expected "+o+"-1024 bytes of input, got "+i);const s=_o(n?lo(e):co(e),t-vo)+vo;return n?uo(s,a):po(s,a)}Object.freeze(Po.prototype);
|
|
16
16
|
/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
|
|
17
17
|
const Go=BigInt(0),Vo=BigInt(1);function Wo(e,t){const n=t.negate();return e?n:t}function Jo(e,t){const n=Fo(e.Fp,t.map(e=>e.Z));return t.map((t,i)=>e.fromAffine(t.toAffine(n[i])))}function Qo(e,t){if(!Number.isSafeInteger(e)||e<=0||e>t)throw new Error("invalid window size, expected [1.."+t+"], got W="+e)}function Zo(e,t){Qo(e,t);const n=2**e;return{windows:Math.ceil(t/e)+1,windowSize:2**(e-1),mask:go(e),maxNumber:n,shiftBy:BigInt(e)}}function Yo(e,t,n){const{windowSize:i,mask:a,maxNumber:o,shiftBy:s}=n;let r=Number(e&a),c=e>>s;r>i&&(r-=o,c+=Vo);const l=t*i;return{nextN:c,offset:l+Math.abs(r)-1,isZero:0===r,isNeg:r<0,isNegF:t%2!=0,offsetF:l}}const Ko=new WeakMap,Xo=new WeakMap;function es(e){return Xo.get(e)||1}function ts(e){if(e!==Go)throw new Error("invalid wNAF")}class ns{BASE;ZERO;Fn;bits;constructor(e,t){this.BASE=e.BASE,this.ZERO=e.ZERO,this.Fn=e.Fn,this.bits=t}_unsafeLadder(e,t,n=this.ZERO){let i=e;for(;t>Go;)t&Vo&&(n=n.add(i)),i=i.double(),t>>=Vo;return n}precomputeWindow(e,t){const{windows:n,windowSize:i}=Zo(t,this.bits),a=[];let o=e,s=o;for(let e=0;e<n;e++){s=o,a.push(s);for(let e=1;e<i;e++)s=s.add(o),a.push(s);o=s.double()}return a}wNAF(e,t,n){if(!this.Fn.isValid(n))throw new Error("invalid scalar");let i=this.ZERO,a=this.BASE;const o=Zo(e,this.bits);for(let e=0;e<o.windows;e++){const{nextN:s,offset:r,isZero:c,isNeg:l,isNegF:p,offsetF:u}=Yo(n,e,o);n=s,c?a=a.add(Wo(p,t[u])):i=i.add(Wo(l,t[r]))}return ts(n),{p:i,f:a}}wNAFUnsafe(e,t,n,i=this.ZERO){const a=Zo(e,this.bits);for(let e=0;e<a.windows&&n!==Go;e++){const{nextN:o,offset:s,isZero:r,isNeg:c}=Yo(n,e,a);if(n=o,!r){const e=t[s];i=i.add(c?e.negate():e)}}return ts(n),i}getPrecomputes(e,t,n){let i=Ko.get(t);return i||(i=this.precomputeWindow(t,e),1!==e&&("function"==typeof n&&(i=n(i)),Ko.set(t,i))),i}cached(e,t,n){const i=es(e);return this.wNAF(i,this.getPrecomputes(i,e,n),t)}unsafe(e,t,n,i){const a=es(e);return 1===a?this._unsafeLadder(e,t,i):this.wNAFUnsafe(a,this.getPrecomputes(a,e,n),t,i)}createCache(e,t){Qo(t,this.bits),Xo.set(e,t),Ko.delete(e)}hasCache(e){return 1!==es(e)}}function is(e,t,n){if(t){if(t.ORDER!==e)throw new Error("Field.ORDER must match order: Fp == p, Fn == n");return function(e){if(bo(e,Oo.reduce((e,t)=>(e[t]="function",e),{ORDER:"bigint",BYTES:"number",BITS:"number"})),oo(e.BYTES,"BYTES"),oo(e.BITS,"BITS"),e.BYTES<1||e.BITS<1)throw new Error("invalid field: expected BYTES/BITS > 0");if(e.ORDER<=vo)throw new Error("invalid field: expected ORDER > 1, got "+e.ORDER)}(t),t}return $o(e,{isLE:n})}function as(e,t){return function(n){const i=e(n);return{secretKey:i,publicKey:t(i)}}}
|
|
18
18
|
/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
|
|
19
19
|
const os=(e,t)=>(e+(e>=0?t:-t)/ps)/t;class ss extends Error{constructor(e=""){super(e)}}const rs={Err:ss,_tlv:{encode:(e,t)=>{const{Err:n}=rs;if(oo(e,"tag"),e<0||e>255)throw new n("tlv.encode: wrong tag");if("string"!=typeof t)throw new TypeError('"data" expected string, got type='+typeof t);if(1&t.length)throw new n("tlv.encode: unpadded data");const i=t.length/2,a=so(i);if(a.length/2&128)throw new n("tlv.encode: long form length too big");const o=i>127?so(a.length/2|128):"";return so(e)+o+a+t},decode(e,t){const{Err:n}=rs;t=Ya(t,void 0,"DER data");let i=0;if(e<0||e>255)throw new n("tlv.encode: wrong tag");if(t.length<2||t[i++]!==e)throw new n("tlv.decode: wrong tlv");const a=t[i++];let o=0;if(!!(128&a)){const e=127&a;if(!e)throw new n("tlv.decode(long): indefinite length not supported");if(e>4)throw new n("tlv.decode(long): byte length is too big");const s=t.subarray(i,i+e);if(s.length!==e)throw new n("tlv.decode: length bytes not complete");if(0===s[0])throw new n("tlv.decode(long): zero leftmost byte");for(const e of s)o=o<<8|e;if(i+=e,o<128)throw new n("tlv.decode(long): not minimal encoding")}else o=a;const s=t.subarray(i,i+o);if(s.length!==o)throw new n("tlv.decode: wrong value length");return{v:s,l:t.subarray(i+o)}}},_int:{encode(e){const{Err:t}=rs;if(ao(e),e<cs)throw new t("integer: negative integers are not allowed");let n=so(e);if(8&Number.parseInt(n[0],16)&&(n="00"+n),1&n.length)throw new t("unexpected DER parsing assertion: unpadded hex");return n},decode(e){const{Err:t}=rs;if(e.length<1)throw new t("invalid signature integer: empty");if(128&e[0])throw new t("invalid signature integer: negative");if(e.length>1&&0===e[0]&&!(128&e[1]))throw new t("invalid signature integer: unnecessary leading zero");return co(e)}},toSig(e){const{Err:t,_int:n,_tlv:i}=rs,a=Ya(e,void 0,"signature"),{v:o,l:s}=i.decode(48,a);if(s.length)throw new t("invalid signature: left bytes after parsing");const{v:r,l:c}=i.decode(2,o),{v:l,l:p}=i.decode(2,c);if(p.length)throw new t("invalid signature: left bytes after parsing");return{r:n.decode(r),s:n.decode(l)}},hexFromSig(e){const{_tlv:t,_int:n}=rs,i=t.encode(2,n.encode(e.r))+t.encode(2,n.encode(e.s));return t.encode(48,i)}};Object.freeze(rs._tlv),Object.freeze(rs._int),Object.freeze(rs);const cs=BigInt(0),ls=BigInt(1),ps=BigInt(2),us=BigInt(3),ds=BigInt(4);function ms(e,t={}){const n=function(e,t,n={},i){if(void 0===i&&(i="edwards"===e),!t||"object"!=typeof t)throw new Error(`expected valid ${e} CURVE object`);for(const e of["p","n","h"]){const n=t[e];if(!("bigint"==typeof n&&n>Go))throw new Error(`CURVE.${e} must be positive bigint`)}const a=is(t.p,n.Fp,i),o=is(t.n,n.Fn,i),s=["Gx","Gy","a","weierstrass"===e?"b":"d"];for(const e of s)if(!a.isValid(t[e]))throw new Error(`CURVE.${e} must be valid field element of CURVE.Fp`);return{CURVE:t=Object.freeze(Object.assign({},t)),Fp:a,Fn:o}}("weierstrass",e,t),i=n.Fp,a=n.Fn;let o=n.CURVE;const{h:s,n:r}=o;bo(t,{},{allowInfinityPoint:"boolean",clearCofactor:"function",isTorsionFree:"function",fromBytes:"function",toBytes:"function",endo:"object"});const{endo:c,allowInfinityPoint:l}=t;if(c&&(!i.is0(o.a)||"bigint"!=typeof c.beta||!Array.isArray(c.basises)))throw new Error('invalid endo: expected "beta": bigint and "basises": array');const p=hs(i,a);function u(){if(!i.isOdd)throw new Error("compression is not supported: Field does not have .isOdd()")}const d=void 0===t.toBytes?function(e,t,n){if(l&&t.is0())return Uint8Array.of(0);const{x:a,y:o}=t.toAffine(),s=i.toBytes(a);if(io(n,"isCompressed"),n){u();const e=!i.isOdd(o);return eo(fs(e),s)}return eo(Uint8Array.of(4),s,i.toBytes(o))}:t.toBytes,m=void 0===t.fromBytes?function(e){Ya(e,void 0,"Point");const{publicKey:t,publicKeyUncompressed:n}=p,a=e.length,o=e[0],s=e.subarray(1);if(l&&1===a&&0===o)return{x:i.ZERO,y:i.ZERO};if(a!==t||2!==o&&3!==o){if(a===n&&4===o){const e=i.BYTES,t=i.fromBytes(s.subarray(0,e)),n=i.fromBytes(s.subarray(e,2*e));if(!h(t,n))throw new Error("bad point: is not on curve");return{x:t,y:n}}throw new Error(`bad point: got length ${a}, expected compressed=${t} or uncompressed=${n}`)}{const e=i.fromBytes(s);if(!i.isValid(e))throw new Error("bad point: is not on curve, wrong x");const t=f(e);let n;try{n=i.sqrt(t)}catch(e){const t=e instanceof Error?": "+e.message:"";throw new Error("bad point: is not on curve, sqrt error"+t)}u();return!(1&~o)!==i.isOdd(n)&&(n=i.neg(n)),{x:e,y:n}}}:t.fromBytes;function f(e){const t=i.sqr(e),n=i.mul(t,e);return i.add(i.add(n,i.mul(e,o.a)),o.b)}function h(e,t){const n=i.sqr(t),a=f(e);return i.eql(n,a)}if(!h(o.Gx,o.Gy))throw new Error("bad curve params: generator point");const g=i.mul(i.pow(o.a,us),ds),b=i.mul(i.sqr(o.b),BigInt(27));if(i.is0(i.add(g,b)))throw new Error("bad curve params: a or b");function x(e,t,n=!1){if(!i.isValid(t)||n&&i.is0(t))throw new Error(`bad point coordinate ${e}`);return t}function v(e){if(!(e instanceof C))throw new Error("Weierstrass Point expected")}function y(e){if(!c||!c.basises)throw new Error("no endo");return function(e,t,n){fo("scalar",e,cs,n);const[[i,a],[o,s]]=t,r=os(s*e,n),c=os(-a*e,n);let l=e-r*i-c*o,p=-r*a-c*s;const u=l<cs,d=p<cs;u&&(l=-l),d&&(p=-p);const m=go(Math.ceil(ho(n)/2))+ls;if(l<cs||l>=m||p<cs||p>=m)throw new Error("splitScalar (endomorphism): failed for k");return{k1neg:u,k1:l,k2neg:d,k2:p}}(e,c.basises,a.ORDER)}function w(e,t,n,a,o){return n=new C(i.mul(n.X,e),n.Y,n.Z),t=Wo(a,t),n=Wo(o,n),t.add(n)}class C{static BASE=new C(o.Gx,o.Gy,i.ONE);static ZERO=new C(i.ZERO,i.ONE,i.ZERO);static Fp=i;static Fn=a;X;Y;Z;constructor(e,t,n){this.X=x("x",e),this.Y=x("y",t,!0),this.Z=x("z",n),Object.freeze(this)}static CURVE(){return o}static fromAffine(e){const{x:t,y:n}=e||{};if(!e||!i.isValid(t)||!i.isValid(n))throw new Error("invalid affine point");if(e instanceof C)throw new Error("projective point not allowed");return i.is0(t)&&i.is0(n)?C.ZERO:new C(t,n,i.ONE)}static fromBytes(e){const t=C.fromAffine(m(Ya(e,void 0,"point")));return t.assertValidity(),t}static fromHex(e){return C.fromBytes((e=>Fa(e))(e))}get x(){return this.toAffine().x}get y(){return this.toAffine().y}precompute(e=8,t=!0){return k.createCache(this,e),t||this.multiply(us),this}assertValidity(){const e=this;if(e.is0()){if(t.allowInfinityPoint&&i.is0(e.X)&&i.eql(e.Y,i.ONE)&&i.is0(e.Z))return;throw new Error("bad point: ZERO")}const{x:n,y:a}=e.toAffine();if(!i.isValid(n)||!i.isValid(a))throw new Error("bad point: x or y not field elements");if(!h(n,a))throw new Error("bad point: equation left != right");if(!e.isTorsionFree())throw new Error("bad point: not in prime-order subgroup")}hasEvenY(){const{y:e}=this.toAffine();if(!i.isOdd)throw new Error("Field doesn't support isOdd");return!i.isOdd(e)}equals(e){v(e);const{X:t,Y:n,Z:a}=this,{X:o,Y:s,Z:r}=e,c=i.eql(i.mul(t,r),i.mul(o,a)),l=i.eql(i.mul(n,r),i.mul(s,a));return c&&l}negate(){return new C(this.X,i.neg(this.Y),this.Z)}double(){const{a:e,b:t}=o,n=i.mul(t,us),{X:a,Y:s,Z:r}=this;let c=i.ZERO,l=i.ZERO,p=i.ZERO,u=i.mul(a,a),d=i.mul(s,s),m=i.mul(r,r),f=i.mul(a,s);return f=i.add(f,f),p=i.mul(a,r),p=i.add(p,p),c=i.mul(e,p),l=i.mul(n,m),l=i.add(c,l),c=i.sub(d,l),l=i.add(d,l),l=i.mul(c,l),c=i.mul(f,c),p=i.mul(n,p),m=i.mul(e,m),f=i.sub(u,m),f=i.mul(e,f),f=i.add(f,p),p=i.add(u,u),u=i.add(p,u),u=i.add(u,m),u=i.mul(u,f),l=i.add(l,u),m=i.mul(s,r),m=i.add(m,m),u=i.mul(m,f),c=i.sub(c,u),p=i.mul(m,d),p=i.add(p,p),p=i.add(p,p),new C(c,l,p)}add(e){v(e);const{X:t,Y:n,Z:a}=this,{X:s,Y:r,Z:c}=e;let l=i.ZERO,p=i.ZERO,u=i.ZERO;const d=o.a,m=i.mul(o.b,us);let f=i.mul(t,s),h=i.mul(n,r),g=i.mul(a,c),b=i.add(t,n),x=i.add(s,r);b=i.mul(b,x),x=i.add(f,h),b=i.sub(b,x),x=i.add(t,a);let y=i.add(s,c);return x=i.mul(x,y),y=i.add(f,g),x=i.sub(x,y),y=i.add(n,a),l=i.add(r,c),y=i.mul(y,l),l=i.add(h,g),y=i.sub(y,l),u=i.mul(d,x),l=i.mul(m,g),u=i.add(l,u),l=i.sub(h,u),u=i.add(h,u),p=i.mul(l,u),h=i.add(f,f),h=i.add(h,f),g=i.mul(d,g),x=i.mul(m,x),h=i.add(h,g),g=i.sub(f,g),g=i.mul(d,g),x=i.add(x,g),f=i.mul(h,x),p=i.add(p,f),f=i.mul(y,x),l=i.mul(b,l),l=i.sub(l,f),f=i.mul(b,h),u=i.mul(y,u),u=i.add(u,f),new C(l,p,u)}subtract(e){return v(e),this.add(e.negate())}is0(){return this.equals(C.ZERO)}multiply(e){const{endo:n}=t;if(!a.isValidNot0(e))throw new RangeError("invalid scalar: out of range");let i,o;const s=e=>k.cached(this,e,e=>Jo(C,e));if(n){const{k1neg:t,k1:a,k2neg:r,k2:c}=y(e),{p:l,f:p}=s(a),{p:u,f:d}=s(c);o=p.add(d),i=w(n.beta,l,u,t,r)}else{const{p:t,f:n}=s(e);i=t,o=n}return Jo(C,[i,o])[0]}multiplyUnsafe(e){const{endo:n}=t,i=this,o=e;if(!a.isValid(o))throw new RangeError("invalid scalar: out of range");if(o===cs||i.is0())return C.ZERO;if(o===ls)return i;if(k.hasCache(this))return this.multiply(o);if(n){const{k1neg:e,k1:t,k2neg:a,k2:s}=y(o),{p1:r,p2:c}=function(e,t,n,i){let a=t,o=e.ZERO,s=e.ZERO;for(;n>Go||i>Go;)n&Vo&&(o=o.add(a)),i&Vo&&(s=s.add(a)),a=a.double(),n>>=Vo,i>>=Vo;return{p1:o,p2:s}}(C,i,t,s);return w(n.beta,r,c,e,a)}return k.unsafe(i,o)}toAffine(e){let t=e;const{X:n,Y:a,Z:o}=this;if(i.eql(o,i.ONE))return{x:n,y:a};const s=this.is0();null==t&&(t=s?i.ONE:i.inv(o));const r=i.mul(n,t),c=i.mul(a,t),l=i.mul(o,t);if(s)return{x:i.ZERO,y:i.ZERO};if(!i.eql(l,i.ONE))throw new Error("invZ was invalid");return{x:r,y:c}}isTorsionFree(){const{isTorsionFree:e}=t;return s===ls||(e?e(C,this):k.unsafe(this,r).is0())}clearCofactor(){const{clearCofactor:e}=t;return s===ls?this:e?e(C,this):this.multiplyUnsafe(s)}isSmallOrder(){return s===ls?this.is0():this.clearCofactor().is0()}toBytes(e=!0){return io(e,"isCompressed"),this.assertValidity(),d(C,this,e)}toHex(e=!0){return Xa(this.toBytes(e))}toString(){return`<Point ${this.is0()?"ZERO":this.toHex()}>`}}const E=a.BITS,k=new ns(C,t.endo?Math.ceil(E/2):E);return E>=8&&C.BASE.precompute(8),Object.freeze(C.prototype),Object.freeze(C),C}function fs(e){return Uint8Array.of(e?2:3)}function hs(e,t){return{secretKey:t.BYTES,publicKey:1+e.BYTES,publicKeyUncompressed:1+2*e.BYTES,publicKeyHasPrefix:!0,signature:2*t.BYTES}}
|
|
20
20
|
/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
|
|
21
|
-
const gs={p:BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),n:BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),h:BigInt(1),a:BigInt(0),b:BigInt(7),Gx:BigInt("0x79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"),Gy:BigInt("0x483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8")},bs={beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),basises:[[BigInt("0x3086d221a7d46bcde86c90e49284eb15"),-BigInt("0xe4437ed6010e88286f547fa90abfe4c3")],[BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),BigInt("0x3086d221a7d46bcde86c90e49284eb15")]]},xs=BigInt(0),vs=BigInt(2);const ys=$o(gs.p,{sqrt:function(e){const t=gs.p,n=BigInt(3),i=BigInt(6),a=BigInt(11),o=BigInt(22),s=BigInt(23),r=BigInt(44),c=BigInt(88),l=e*e*e%t,p=l*l*e%t,u=Lo(p,n,t)*p%t,d=Lo(u,n,t)*p%t,m=Lo(d,vs,t)*l%t,f=Lo(m,a,t)*m%t,h=Lo(f,o,t)*f%t,g=Lo(h,r,t)*h%t,b=Lo(g,c,t)*g%t,x=Lo(b,r,t)*h%t,v=Lo(x,n,t)*p%t,y=Lo(v,s,t)*f%t,w=Lo(y,i,t)*l%t,C=Lo(w,vs,t);if(!ys.eql(ys.sqr(C),e))throw new Error("Cannot find square root");return C}}),ws=ms(gs,{Fp:ys,endo:bs}),Cs={};function Es(e,...t){let n=Cs[e];if(void 0===n){const t=Za(function(e){if("string"!=typeof e)throw new TypeError("ascii string expected, got "+typeof e);return Uint8Array.from(e,(t,n)=>{const i=t.charCodeAt(0);if(1!==t.length||i>127)throw new RangeError(`string contains non-ASCII character "${e[n]}" with code ${i} at position ${n}`);return i})}(e));n=eo(t,t),Cs[e]=n}return Za(eo(n,...t))}const ks=e=>e.toBytes(!0).slice(1),As=e=>e%vs===xs;function Ts(e){const{Fn:t,BASE:n}=ws,i=t.fromBytes(e),a=n.multiply(i);return{scalar:As(a.y)?i:t.neg(i),bytes:ks(a)}}function js(e){const t=ys;if(!t.isValidNot0(e))throw new Error("invalid x: Fail if x ≥ p");const n=t.create(e*e),i=t.create(n*e+BigInt(7));let a=t.sqrt(i);As(a)||(a=t.neg(a));const o=ws.fromAffine({x:e,y:a});return o.assertValidity(),o}const _s=co;function Ls(...e){return ws.Fn.create(_s(Es("BIP0340/challenge",...e)))}function Ss(e){return Ts(e).bytes}function Rs(e,t,n=za(32)){const{Fn:i,BASE:a}=ws,o=Ya(e,void 0,"message"),{bytes:s,scalar:r}=Ts(t),c=Ya(n,32,"auxRand"),l=i.toBytes(r^_s(Es("BIP0340/aux",c))),p=Es("BIP0340/nonce",l,s,o),u=i.create(_s(p));if(0n===u)throw new Error("sign failed: k is zero");const d=a.multiply(u),m=As(d.y)?u:i.neg(u),f=ks(d),h=Ls(f,s,o),g=new Uint8Array(64);if(g.set(f,0),g.set(i.toBytes(i.create(m+h*r)),32),!Ns(g,o,s))throw new Error("sign: Invalid signature produced");return g}function Ns(e,t,n){const{Fp:i,Fn:a,BASE:o}=ws,s=Ya(e,64,"signature"),r=Ya(t,void 0,"message"),c=Ya(n,32,"publicKey");try{const e=js(_s(c)),t=_s(s.subarray(0,32));if(!i.isValidNot0(t))return!1;const n=_s(s.subarray(32,64));if(!a.isValidNot0(n))return!1;const l=Ls(a.toBytes(t),ks(e),r),p=o.multiplyUnsafe(n).add(e.multiplyUnsafe(a.neg(l))),{x:u,y:d}=p.toAffine();return!(p.is0()||!As(d)||u!==t)}catch(e){return!1}}const Is=(()=>{const e=e=>Ho(e=void 0===e?za(48):e,gs.n);return Object.freeze({keygen:as(e,Ss),getPublicKey:Ss,sign:Rs,verify:Ns,Point:ws,utils:Object.freeze({randomSecretKey:e,taggedHash:Es,lift_x:js,pointToBytes:ks}),lengths:Object.freeze({secretKey:32,publicKey:32,publicKeyHasPrefix:!1,signature:64,seed:48})})})();new TextDecoder("utf-8");const Bs=new TextEncoder,Ds="https://w3id.org/security#";function Os(e){const t=Za(Bs.encode(function(e){return JSON.stringify(e)}(e)));return Sa(t)}const Ms=e=>{let t=x.store.any(e,b.space("preferencesFile"),null,e.doc())?.value;if(t=t?.split("/").slice(0,-2).join("/"),!t)throw new Error(`prefererencesFile is expected to exist in ${e}`);return t},Fs=e=>{let t;try{t=`${Ms(e)}/profile/keys/publicKey.ttl`}catch(e){ve.z3(e)}return t};async function Us(e,t,n){try{await x.store.fetcher.load(t);const i=x.store.any(e,b.solid(n));return i?.value}catch(e){if(404===e.response.status){ve.Rm("createIfNotExists: doc does NOT exist, will create... "+t);try{await x.store.fetcher.webOperation("PUT",t,{data:"",contentType:"text/turtle"})}catch(e){throw ve.Rm("createIfNotExists doc FAILED: "+t+": "+e),e}return void delete x.store.fetcher.requested[t]}throw ve.Rm("createIfNotExists doc FAILED: "+t+": "+e),e}}async function zs(e,t){await x.store.fetcher.load(e);const n=x.store.any(x.store.sym(e),x.store.sym("http://www.iana.org/assignments/link-relations/acl"));if(!n)throw new Error("Key ACL doc not found!");try{await x.store.fetcher.webOperation("PUT",n.value,{data:t,contentType:"text/turtle"})}catch(e){if(404!==e?.response?.status)throw new Error(e);ve.Rm("delete "+n.value+" "+e.response.status)}}function Ps(e){return Sa(Is.getPublicKey(Fa(e)))}async function $s(e){await x.store.fetcher.load(e);const t=await Fs(e),n=await(e=>{let t;try{t=`${Ms(e)}/settings/keys/privateKey.ttl`}catch(e){ve.z3(e)}return t})(e),i=await async function(e,t){return await Us(e,t,"publicKey")}(e,t);let a=await async function(e,t){return await Us(e,t,"privateKey")}(e,n),o=!0;if(a&&i!==Ps(a)&&confirm("This is strange the publicKey is not valid for\n"+e?.uri+"'shall we repair keeping the private key ?")&&(o=!1),!a||!i||!o){let r=[],c=[];if(a||(a=Sa(Is.utils.randomSecretKey()),c=[g.st(e,b.solid("privateKey"),g.literal(a),x.store.sym(n))],await qs(n,[],c,e.uri)),!i||!o){r=[],i&&(r=[g.st(e,b.solid("publicKey"),g.lit(i),x.store.sym(t))],ve.Rm("delete invalid publicKey "+r));const n=Ps(a);c=[g.st(e,b.solid("publicKey"),g.literal(n),x.store.sym(t))],await qs(t,r,c)}const l=n.substring(0,n.lastIndexOf("/")+1);await zs(l,(s=e.uri,`\n@prefix : <#>.\n@prefix acl: <http://www.w3.org/ns/auth/acl#>.\n@prefix foaf: <http://xmlns.com/foaf/0.1/>.\n@prefix key: <./>.\n\n:ReadWrite\n a acl:Authorization;\n acl:accessTo key:;\n acl:default key:;\n acl:agent <${s}>;\n acl:mode acl:Read, acl:Write.\n`))}var s;return a}async function qs(e,t,n,i=""){await(async e=>{await x.store.fetcher.load(e);const t=x.store.any(x.store.sym(e),x.store.sym("http://www.iana.org/assignments/link-relations/acl"));if(t)try{const e=await x.store.fetcher.webOperation("DELETE",t.value);ve.Rm("delete keyAcl"+t.value+" "+e.status)}catch(e){if(404!==e.response.status)throw new Error(e);ve.Rm("delete keyAcl"+t.value+" "+e.response.status)}})(e),await x.store.updater.updateMany(t,n);const a=((e,t)=>{let n="acl:agentClass foaf:Agent";return t?.length&&(n=`acl:agent <${t}>`),`\n@prefix foaf: <http://xmlns.com/foaf/0.1/>.\n@prefix acl: <http://www.w3.org/ns/auth/acl#>.\n<#Read>\n a acl:Authorization;\n ${n};\n acl:accessTo <${e.split("/").pop()}>;\n acl:mode acl:Read.\n`})(e,i);await zs(e,a)}class Hs{constructor(e,t){this.channel=e,this.channelRoot=e.doc(),this.options=t,this.dateFolder=new wa(this.channelRoot,"chat.ttl"),this.div=null}async createMessage(e){return this.updateMessage(e)}async updateMessage(e,t=null,n,i=null){const a=[],o=new Date,s=""+o.getTime(),r=g.term(o),c=t?t.doc():this.dateFolder.leafDocumentFromDate(o),l=x.store.sym(c.uri+"#Msg"+s),p=x.authn.currentUser(),u={id:"",created:"",dateDeleted:"",content:"",maker:"",sig:""};if(u.id=l.uri,t){const e=x.store.any(t,b.foaf("maker"));if(e.uri!==p.uri){const t="Error you cannot delete/edit a message from someone else : \n"+e.uri;throw ve.R8(t),alert(t),new Error(t)}{const e=await Vs(t);a.push(g.st(e,b.dct("isReplacedBy"),l,c));const i=x.store.any(e,b.sioc("has_reply"));i&&a.push(g.st(l,b.sioc("has_reply"),i,c)),n&&a.push(g.st(l,b.schema("dateDeleted"),r,c))}}else a.push(g.st(this.channel,b.wf("message"),l,c));if(a.push(g.st(l,b.sioc("content"),x.store.literal(e),c)),u.content=e,a.push(g.st(l,b.dct("created"),r,c)),u.created=r.value,p){a.push(g.st(l,b.foaf("maker"),p,c)),u.maker=p.uri;const e=function(e,t){return Sa(Is.sign(Fa(Os(e)),Fa(t)))}(u,await $s(p));a.push(g.st(l,g.sym(`${Ds}proofValue`),g.lit(e),c))}i&&(a.push(g.st(i,b.sioc("has_member"),l,c)),i.doc().sameTerm(l.doc())||a.push(g.st(i,b.sioc("has_member"),l,i.doc())));try{await x.store.updater.updateMany([],a)}catch(e){const t="Error saving chat message: "+e;throw ve.R8(t),alert(t),new Error(t)}return l}async deleteMessage(e){return this.updateMessage("(message deleted)",e,!0)}async createThread(e){const t=x.store.each(e,b.sioc("has_reply"),null,e.doc()).filter(e=>x.store.holds(e,b.rdf("type"),b.sioc("Thread"),e.doc()));if(t.length>0)return t[0];const n=g.sym(e.uri+"-thread"),i=[g.st(n,b.rdf("type"),b.sioc("Thread"),n.doc()),g.st(e,b.sioc("has_reply"),n,n.doc())];return await x.store.updater.update([],i),n}}async function Gs(e){const t=[e],n={};n[e.uri]=!0;let i=e;for(;;){const e=x.store.any(null,b.dct("isReplacedBy"),i,i.doc());if(!e||n[e.uri])break;await x.store.fetcher.load(e),t.unshift(e),n[e.uri]=!0,i=e}for(i=e;;){const e=x.store.any(i,b.dct("isReplacedBy"),null,i.doc());if(!e||n[e.uri])break;t.push(e),n[e.uri]=!0,i=e}return t}async function Vs(e){let t=e;const n={};for(;t;){if(n[t.uri])return ve.z3("mostRecentVersion: verion loop"+e),e;n[t.uri]=!0,e=t,await x.store.fetcher.load(e),t=x.store.any(e,b.dct("isReplacedBy"),null,e.doc())}return e}function Ws(e){return x.store.holds(e,b.schema("dateDeleted"),null,e.doc())}const Js=x.solidLogicSingleton.store;function Qs(e,t,n,i,a,o){t.setAttribute("style",Ke.participantsStyle);const s=function(n){const i=Js.any(n,b.wf("participant"));let a;if(!i)return a=e.createElement("tr"),a.textContent="???",a;const s=Js.anyValue(n,b.ui("backgroundColor"))||Ze,r=e.createElement("div");r.setAttribute("style",Ke.participantsBlock),r.style.backgroundColor=s,a=zt(e,null,i,o),t.appendChild(a);const c=e.createElement("td");return c.setAttribute("style",Ke.personTableTD),c.appendChild(r),a.insertBefore(c,a.firstChild),a},r=function(){const e=Js.each(i,b.wf("participation")).map(function(e){return(0,ve.Rm)("in participants"),[Js.anyValue(e,b.cal("dtstart"))||"9999-12-31",e]});e.sort();const n=e.map(function(e){return e[1]});Z(t,n,s)};return t.refresh=r,r(),t}function Zs(e,t,n){return new Promise(function(i,a){if(!n)throw new Error("No user id");const o=Js.each(e,b.wf("participation")).filter(function(e){return Js.holds(e,b.wf("participant"),n)});if(o.length>1){const e=[];for(const t of o){const n=Js.anyValue(t,b.cal("dtstart"));n&&e.push([n,t])}e.sort(),ve.R8("Multiple participation objects, picking earliest, in "+t),i(e[0][1])}if(o.length)i(o[0]);else{const o=Ei(t),s=[(0,g.st)(e,b.wf("participation"),o,t),(0,g.st)(o,b.wf("participant"),n,t),(0,g.st)(o,b.cal("dtstart"),new Date,t),(0,g.st)(o,b.ui("backgroundColor"),tr(n),t)];Js.updater.update([],s,function(e,t,n){t?i(o):a(new Error("Error recording your participation: "+n))}),i(o)}})}function Ys(e,t,n){const i=x.authn.currentUser();if(!i)return;const a=Js.each(e,b.wf("participation")).filter(function(e){return Js.holds(e,b.wf("participant"),i)});if(a.length>1)throw new Error("Multiple records of your participation");if(a.length)return a[0];{if(!Js.updater.editable(t))return ve.Rm("Not recording participation, as no write access as "+i+" to "+t),null;const a=Ei(t),o=[(0,g.st)(e,b.wf("participation"),a,t),(0,g.st)(a,b.wf("participant"),i,t),(0,g.st)(a,b.cal("dtstart"),new Date,t),(0,g.st)(a,b.ui("backgroundColor"),tr(i),t)];return Js.updater.update([],o,function(e,t,i){if(!t)throw new Error("Error recording your participation: "+i);n&&n.refresh&&n.refresh()}),a}}function Ks(e,t,n,i,a,o){const s=e.createElement("table");t.appendChild(s),Qs(e,s,0,i,0,o);try{Ys(i,n,s)}catch(n){t.appendChild(nt(e,"Error recording your participation: "+n))}return s}const Xs=x.solidLogicSingleton.store,er=(0,g.Namespace)("http://www.w3.org/ns/pim/pad#");function tr(e){return e&&e.uri?"#"+(16777215&(t=e.uri,t.split("").reduce(function(e,t){return(e=(e<<5)-e+t.charCodeAt(0))&e},0))|12632256).toString(16):"#ffffff";var t}function nr(e,t,n,i,a){const o=(a=a||{}).exists,s=e.createElement("table"),r=Xs;if(i&&!i.uri)throw new Error("UI.pad.notepad: Invalid userid");const c=Xs.updater,l=(0,g.Namespace)("http://www.w3.org/ns/pim/pad#");s.setAttribute("style",Ke.notepadStyle);let p=null,u=null;if(a.statusArea){const t=a.statusArea.appendChild(e.createElement("table")).appendChild(e.createElement("tr"));p=t.appendChild(e.createElement("td")),u=t.appendChild(e.createElement("td")),p&&p.setAttribute("style",Ke.upstreamStatus),u&&u.setAttribute("style",Ke.downstreamStatus)}const d=function(t,n=!1){(0,ve.Rm)(t),a.statusArea&&(n?p:u).appendChild(nt(e,t,"pink"))},m=function(e){a.statusArea&&(a.statusArea.innerHTML="")},f=function(e,t,n){const i=e.subject;t=t||"";const a=Ke.baseStyle,o=Ke.headingCore,s=Ke.headingStyle,c=r.any(i,b.dc("author"));if(!t&&c){t="color: "+(n?"#888":"black")+"; background-color: "+tr(c)+";"}let p=r.any(i,l("indent"));p=p?p.value:0;const u=p>=0?a+"text-indent: "+3*p+"em;":o+s[-1-p];e.setAttribute("style",u+t)},h=function(e){const i=e.subject;if(!i)throw new Error("No chunk for line to be deleted!");const a=r.any(void 0,l("next"),i),o=r.any(i,l("next"));if(a.sameTerm(n)&&o.sameTerm(n))return void(0,ve.Rm)("You can't delete the only line.");const s=r.statementsMatching(i,void 0,void 0,t).concat(r.statementsMatching(void 0,void 0,i,t)),p=[(0,g.st)(a,l("next"),o,t)];if(i instanceof g.NamedNode){const e=i.uri.slice(-4);(0,ve.Rm)("Deleting line "+e)}if(!c)throw new Error("have no updater");c.update(s,p,function(t,n,a,o){if(n){const t=e.parentNode;if(t){const e=t.previousSibling;t.parentNode&&t.parentNode.removeChild(t),e&&e.firstChild&&e.firstChild.focus()}}else if(o&&409===o.status)f(e,"color: black; background-color: #ffd;"),e.state=0,W(),setTimeout(function(){A()},1e3);else{(0,ve.Rm)(" removePart FAILED "+i+": "+a),(0,ve.Rm)(" removePart was deleting :'"+s),f(e,"color: black; background-color: #fdd;");const t=o?o.status:" [no response field] ";d("Error "+t+" saving changes: "+String(a))}})},x=function(e,n){let i=null;e.addEventListener("keydown",function(i){if(!c)throw new Error("no updater");let a,o;switch(i.keyCode){case 13:{const t=i.shiftKey;if((0,ve.Rm)("enter"),t?(o=r.any(void 0,l("next"),n),a="newlinesAfter"):(o=r.any(n,l("next")),a="newlinesBefore"),o[a]=o[a]||0,o[a]+=1,o[a]>1)return void(0,ve.Rm)(" queueing newline queue = "+o[a]);(0,ve.Rm)(" go ahead line before "+o[a]),y(e,t);break}case 8:if(0===e.value.length)switch((0,ve.Rm)("Delete key line "+n.uri.slice(-4)+" state "+e.state),e.state){case 1:case 2:return void(e.state=4);case 3:case 4:return;case void 0:case 0:e.state=3,h(e),i.preventDefault();break;default:throw new Error("pad: Unexpected state "+e)}break;case 9:{const a=i.shiftKey?-1:1;!function(e,n,i){const a=r.statementsMatching(n,l("indent")),o=a.length?Number(a[0].object.value):0;if(o+i<-3)return;const s=o+i,p=(0,g.st)(n,l("indent"),s,t);if(!c)throw new Error("no updater");c.update(a,p,function(n,i,a){i?f(e):((0,ve.Rm)("Indent change FAILED '"+s+"' for "+t+": "+a),f(e,"color: black; background-color: #fdd;"),c.requestDownstreamAction(t,A))})}(e,n,a),i.preventDefault();break}case 27:(0,ve.Rm)("escape"),c.requestDownstreamAction(t,A),i.preventDefault();break;case 38:e.parentNode.previousSibling&&(e.parentNode.previousSibling.firstChild.focus(),i.preventDefault());break;case 40:e.parentNode.nextSibling&&(e.parentNode.nextSibling.firstChild.focus(),i.preventDefault())}});const a=function(e){const n=e.subject;f(e,void 0,!0);const i=r.any(n,b.sioc("content")).value,o=[(0,g.st)(n,b.sioc("content"),i,t)];let s;e.value&&(s=[(0,g.st)(n,b.sioc("content"),e.value,t)]);const l=e.value;if(e.lastSent&&i!==e.lastSent&&console.warn("Out of order, last sent expected '"+i+"' but found '"+e.lastSent+"'"),e.lastSent=l,!c)throw new Error("no updater");c.update(o,s,function(n,o,s,r){if(o)m(),f(e),(0,ve.Rm)(" Patch ok '"+i+"' -> '"+l+"' "),4===e.state?(e.state=3,h(e)):3===e.state||(2===e.state?(e.state=1,a(e)):e.state=0);else if((0,ve.Rm)(" patch FAILED "+r.status+" for '"+i+"' -> '"+l+"': "+s),409===r.status)f(e,"color: black; background-color: #fdd;"),e.state=0,W(),setTimeout(function(){c.requestDownstreamAction(t,A)},1e3);else{f(e,"color: black; background-color: #fdd;");const t=r?.status;t&&502!==t&&503!==t?(e.state=0,d(" Error "+t+" sending data: "+s,!0),W()):(e.lastSent=void 0,e.state=0,setTimeout(()=>{0!==e.state&&void 0!==e.state||(e.state=1,a(e))},2e3))}})};e.addEventListener("input",function(t){switch(f(e,void 0,!0),(0,ve.Rm)("Input event state "+e.state+" value '"+e.value+"'"),e.state){case 3:case 4:case 2:return;case 1:return void(e.state=2);case 0:case void 0:null!==i&&clearTimeout(i),i=setTimeout(()=>{i=null,0!==e.state&&void 0!==e.state||(e.state=1,a(e))},400)}})},v=function(t,n,a){let o=r.any(n,b.sioc("content"));o=o?o.value:"";const c=e.createElement("tr");a?s.insertBefore(c,t):t&&t.nextSibling?s.insertBefore(c,t.nextSibling):s.appendChild(c);const l=c.appendChild(e.createElement("input"));return l.subject=n,l.setAttribute("type","text"),l.value=o,i?(f(l,""),x(l,n)):(f(l,"color: #222; background-color: #fff"),(0,ve.Rm)("Note can't add listeners - not logged in")),l},y=function(e,a){const o=Xs;let s,r,p,u,d,m=0,h=null;e?("input"!==e.tagName.toLowerCase()&&(0,ve.Rm)("return pressed when current document is: "+e.tagName),s=e.subject,m=o.any(s,l("indent")),m=m?Number(m.value):0,a?(r=o.any(void 0,l("next"),s),p=s,u=r,h="newlinesAfter"):(r=s,p=o.any(s,l("next")),u=p,h="newlinesBefore"),d=e.parentNode):(r=n,p=n,d=void 0);const x=Ei(t),w=x.uri.slice(-4),C=[(0,g.st)(r,l("next"),p,t)],E=[(0,g.st)(r,l("next"),x,t),(0,g.st)(x,l("next"),p,t),(0,g.st)(x,b.dc("author"),i,t),(0,g.st)(x,b.sioc("content"),"",t)];if(m>0&&E.push((0,g.st)(x,l("indent"),m,t)),(0,ve.Rm)(" Fresh chunk "+w+" proposed"),!c)throw new Error("no updater");c.update(C,E,function(e,t,n,i){if(t){const e=v(d,x,a);f(e),e.focus(),h&&((0,ve.Rm)(" Fresh chunk "+w+" updated, queue = "+u[h]),u[h]-=1,u[h]>0&&((0,ve.Rm)(" Implementing queued newlines = "+p.newLinesBefore),y(e,a)))}else(0,ve.Rm)(" ERROR writing new line "+w+": "+n)})},w=function(){const e={};let t=0;function i(e){d(e),t++}if(!r.the(n,l("next")))return i("No initial next pointer"),!1;let a,o=n;for(;a=r.the(o,l("next")),a||i("No next pointer from "+o),!a.sameTerm(n);){o=a;const t=a.uri.split("#")[1];if(e[a.uri])return i("Loop!"),!1;e[a.uri]=!0;let n=r.each(a,l("next")).length;1!==n&&i("Should be 1 not "+n+" next pointer for "+t),n=r.each(a,l("indent")).length,n>1&&i("Should be 0 or 1 not "+n+" indent for "+t),n=r.each(a,b.sioc("content")).length,1!==n&&i("Should be 1 not "+n+" contents for "+t),n=r.each(a,b.dc("author")).length,1!==n&&i("Should be 1 not "+n+" author for "+t);r.statementsMatching(void 0,b.sioc("contents")).forEach(function(t){e[t.subject.value]||i("Loose chunk! "+t.subject.value)})}return!t},C=function(){if(1!==r.each(n,l("next")).length){const e="Pad: Inconsistent data - NEXT pointers: "+r.each(n,l("next")).length;return(0,ve.Rm)(e),void(a.statusArea&&(a.statusArea.textContent+=e))}let e;const t=[];for(let e=r.the(n,l("next"));!e.sameTerm(n);e=r.the(e,l("next")))for(let n=0;n<s.children.length;n++){const i=s.children[n];i.firstChild&&i.firstChild.subject.sameTerm(e)&&(t[e.uri]=i.firstChild)}for(let n=s.children.length-1;n>=0;n--)e=s.children[n],t[e.firstChild.subject.uri]||s.removeChild(e);e=s.firstChild;for(let i=r.the(n,l("next"));!i.sameTerm(n);i=r.the(i,l("next"))){const n=r.any(i,b.sioc("content")).value;if(e&&t[i.uri]){const t=e.firstChild;n!==t.value&&(t.value=n),f(t),t.state=0,delete t.lastSent,e=e.nextSibling}else v(e,i,!0)}},E=function(e){if(e.refresh)e.refresh();else for(let t=0;t<e.children.length;t++)E(e.children[t])};let k=!1;const A=function(){if(k)return void(0,ve.Rm)(" Already reloading - stop");k=!0;let e=1e3;const n=function(){if((0,ve.Rm)("try reload - timeout = "+e),!c)throw new Error("no updater");c.reload(c.store,t,function(i,a,o){k=!1,i?((0,ve.Rm)(" reloaded OK"),m(),w()?E(s):d("CONSISTENCY CHECK FAILED")):0===o.status?(d("Network error refreshing the pad. Retrying in "+e/1e3),k=!0,e*=2,setTimeout(n,e)):d("Error "+o.status+"refreshing the pad:"+a+". Stopped. "+t)})};n()};if(s.refresh=C,s.reloadAndSync=A,i||(0,ve.Rm)("Warning: must be logged in for pad to be edited"),o)(0,ve.Rm)("Existing pad."),w()?(C(),r.holds(n,l("next"),n)&&y()):(0,ve.Rm)(s.textContent="Inconsistent data. Abort");else{(0,ve.Rm)("No pad exists - making new one.");const e=[(0,g.st)(n,b.rdf("type"),l("Notepad"),t),(0,g.st)(n,b.dc("author"),i,t),(0,g.st)(n,b.dc("created"),new Date,t),(0,g.st)(n,l("next"),n,t)];if(!c)throw new Error("no updater");c.update([],e,function(e,t,n){t?((0,ve.Rm)("Initial pad created"),y()):d(n||"")})}return s}function ir(e,t){const n=[];for(let i=t.the(e,er("next"));!i.sameTerm(e);i=t.the(i,er("next")))n.push(i);return n}function ar(e){return e.replace("&","&").replace("<","<").replace(">",">")}function or(e,t){const n=ir(e,t);let i="<html>\n <head>\n";const a=t.anyValue(e,b.dct("title"));a&&(i+=` <title>${ar(a)}</title>\n`),i+=" </head>\n <body>\n";let o=0;function s(e){for(;o>e;o--)i+="</ul>\n"}return n.forEach(e=>{const n=t.anyJS(e,er("indent")),a=t.anyJS(e,b.sioc("content"));if(!a)return;const r=ar(a);if(n<0){s(0);const e=n>=-3?4+n:1;i+=`\n<h${e}>${r}</h${e}>\n`}else n>0?(s(n),function(e){for(;o<e;o++)i+="<ul>\n"}(n),i+=`<li>${r}</li>\n`):(s(n),i+=`<p>${r}</p>\n`)}),s(0),i+=" </body>\n</html>\n",i}const sr={icons:it.Pt,ns:b,media:ba,pad:p,style:Ke,utils:a,widgets:r},rr=g.Namespace("http://www.w3.org/2002/01/bookmark#"),cr=z,lr=window.document||null;function pr(e,t){return new Promise(function(n,i){x.store.updater.update(e,t,function(e,t,a){t?n():i(new Error(a))})})}async function ur(e,t,n){await x.store.fetcher.load(e.bookmarkDocument);const i=x.store.each(null,rr("recalls"),t,e.bookmarkDocument);if(i.length){if(!confirm("Delete bookmark on this?"+i.length))return;for(let e=0;e<i.length;e++)try{await pr(x.store.connectedStatements(i[e]),[]),n.style.backgroundColor="white",ve.Rm("Bookmark deleted: "+i[e])}catch(e){ve.z3("Cant delete bookmark:"+e),ve.R8("Cannot delete bookmark:"+e)}}else{const i=await async function(e,t){let n="";const i=x.authn.currentUser();if(!i)throw new Error("Must be logged on to add Bookmark");const a=x.store.any(t,b.foaf("maker"));n=cr(a)+": "+x.store.anyValue(t,b.sioc("content")).slice(0,80);const o=e.bookmarkDocument,s=sr.widgets.newThing(o,n),r=[g.st(o,sr.ns.dct("references"),s,o),g.st(s,sr.ns.rdf("type"),rr("Bookmark"),o),g.st(s,sr.ns.dct("created"),new Date,o),g.st(s,rr("recalls"),t,o),g.st(s,sr.ns.foaf("maker"),i,o),g.st(s,sr.ns.dct("title"),n,o)];try{await pr([],r)}catch(e){const t="Making bookmark: "+e;return ve.R8(t),null}return s}(e,t);n.style.backgroundColor="yellow",ve.Rm("Bookmark added: "+i)}}const dr=window.document,mr={};async function fr(e,t,n,i){async function a(t){c.value===x.store.any(e,b.foaf("maker")).value&&(s(),await async function(e,t,n,i){const a=e.parentNode,o=Cr(n,a,i,n.options,await Vs(t));a.insertBefore(o,e),o.originalRow=e,e.style.visibility="hidden"}(t,e,i,n))}const o=dr.createElement("div");if(await Vs(e).value===b.schema("dateDeleted").value)return o;function s(){o.parentElement.parentElement.removeChild(o.parentElement)}async function r(e){await x.store.updater.update(x.store.connectedStatements(e),[])}let c=x.authn.currentUser();function l(e,n,i,a,o,s){function c(){l.style.backgroundColor=d?"yellow":"white"}const l=Ot(dr,i,z(a),async function(i){if(d)await r(d),d=null,c();else{d=Ei(o);const i=[g.st(d,b.schema("agent"),e.me,o),g.st(d,b.rdf("type"),a,o),g.st(d,b.schema("target"),n,o)];if(await x.store.updater.update([],i),c(),s){let e=!1;for(let t=0;t<s.length;t++){const n=p(s[t]);n&&(await r(n),e=!0)}e&&Gt(t)}}});function p(t){const i=x.store.each(null,b.schema("agent"),e.me,o).filter(e=>x.store.holds(e,b.rdf("type"),t,o)).filter(e=>x.store.holds(e,b.schema("target"),n,o));return i.length?i[0]:null}function u(){d=p(a),c()}let d;return l.refresh=u,u(),l}if(c&&x.store.holds(e,b.foaf("maker"),c)&&(o.appendChild(Dt(dr,o,"message",async function(){const a=x.store.any(e,b.foaf("maker"));if(c)if(c.sameTerm(a)){try{await i.deleteMessage(e)}catch(e){const i="Error deleting messaage "+e;ve.R8(i),alert(i),(n.statusArea||t.parentNode).appendChild(nt(dr,i))}t.parentNode.removeChild(t)}else alert("You can't delete the message, you are not logged in as the author, "+a);else alert("You can't delete the message, you are not logged in.");s()})),o.appendChild(Ot(dr,it.Pt.iconBase+"noun_253504.svg","edit",()=>a(t)))),async function(e,t){let n;if(e.bookmarkDocument)return n=sr.widgets.button(lr,sr.icons.iconBase+"noun_45961.svg",cr(rr("Bookmark")),()=>{ur(e,t,n)}),n.target=t,await async function(t){await x.store.fetcher.load(e.bookmarkDocument);const n=x.store.any(null,rr("recalls"),t.target,e.bookmarkDocument);t.style=sr.style.buttonStyle,n&&(t.style.backgroundColor="yellow")}(n),n}(n).then(e=>{e&&o.appendChild(e)}),c=x.authn.currentUser(),c&&await Vs(e).value!==b.schema("dateDeleted").value){const t={me:c,dom:dr,div:o};o.appendChild(l(t,e,it.Pt.iconBase+"noun_1384132.svg",b.schema("AgreeAction"),e.doc(),[b.schema("DisagreeAction")])),o.appendChild(l(t,e,it.Pt.iconBase+"noun_1384135.svg",b.schema("DisagreeAction"),e.doc(),[b.schema("AgreeAction")]))}x.store.any(e,b.dct("created"))&&o.appendChild(Ot(dr,it.Pt.iconBase+"noun-reply-5506924.svg","Reply in thread",async()=>{await async function(){const t=await i.createThread(e),a=n.chatOptions;if(!a)throw new Error("replyInThread: missing options");a.showThread(t,a),s()}()}));const p=o.appendChild(Mt(dr));return p.style.float="right",p.firstChild.style.opacity="0.3",p.addEventListener("click",s),o}mr[b.schema("AgreeAction")]="👍",mr[b.schema("DisagreeAction")]="👎",mr[b.schema("EndorseAction")]="⭐️",mr[b.schema("LikeAction")]="❤️";const hr=window.document,gr=Ke.messageBodyStyle,br=z;const xr=function(e,t){const n=hr.createElement("a");return t&&t.uri&&(n.setAttribute("href",t.uri),n.addEventListener("click",Wt,!0),n.setAttribute("style","color: #3B5998; text-decoration: none; ")),n.textContent=e,n};function vr(e){const t=x.store.any(e,b.foaf("nick"));return t?""+t.value:""+br(e)}function yr(e,t,n,i){const a=e.appendChild(xr(vr(t),t));t.uri&&x.store.fetcher.nowOrWhenFetched(t.doc(),void 0,function(e,n){a.textContent=vr(t)}),e.appendChild(hr.createElement("br")),e.appendChild(xr(n,i))}async function wr(e,t,n,i,a){let o=!1;const s="1"===i.colorizeByAuthor||!0===i.colorizeByAuthor,r=x.store.any(t,b.foaf("maker")),c=x.store.any(t,b.dct("created")),l=await Vs(t),p=x.store.any(l,b.foaf("maker")),u=r.uri===p?.uri?l:t,d=x.store.any(u,b.sioc("content")),m=await Gs(u);m.length>1&&ve.Rm("renderMessageRow versions: ",m.join(", "));const f=m.map(e=>x.store.each(e,b.sioc("has_reply"))).flat();let h=null;const g=[];for(const e of f)x.store.holds(e,b.rdf("type"),b.sioc("Thread"))?(h=e,ve.Rm("renderMessageRow: found thread: "+h)):g.push(e);g.length>1&&ve.Rm("renderMessageRow: found normal replies: ",g),h||(h=x.store.any(null,b.sioc("has_member"),t));const v=x.store.any(u,$rdf.sym(`${Ds}proofValue`)),y={id:"",created:"",dateDeleted:"",content:"",maker:"",sig:""};y.id=u.uri,y.created=x.store.any(u,b.dct("created")).value,y.content=d.value,y.maker=r.uri,v?.value?async function(e){await x.store.fetcher.load(e);const t=await Fs(e);try{await x.store.fetcher.load(t);const n=x.store.any(e,b.solid("publicKey"));return n?.value}catch(e){return}}(r).then(e=>{e||ve.R8("message is signed but "+r.uri+" is missing publicKey");e?.match(/[0-9A-Fa-f]{6}/g)?v?.value&&!function(e,t,n){return Is.verify(Fa(e),Fa(Os(t)),Fa(n))}(v?.value,y,e)&&ve.R8("invalid signature\n"+y.id):ve.R8("invalid publicKey hex string\n"+r.uri+"\n"+e)}):(o=!0,ve.R8(u.uri+" is unsigned"));const w=await async function(e){let t=e;const n={};for(;t;){if(n[t.uri])return ve.z3("originalVersion: verion loop"+e),e;n[t.uri]=!0,e=t,await x.store.fetcher.load(e),t=x.store.any(null,b.dct("isReplacedBy"),e,e.doc())}return e}(t),C=!t.sameTerm(w),E=x.store.the(w,b.dct("created"),null,w.doc())||x.store.the(t,b.dct("created"),null,t.doc()),k=hr.createElement("tr");o&&k.setAttribute("style","background-color: red"),k.AJAR_date=E.value,k.AJAR_subject=t;const A=hr.createElement("td");if(k.appendChild(A),i.authorDateOnLeft)yr(A,r,Ct(E.value),t);else{const e=hr.createElement("img");e.setAttribute("style","max-height: 2.5em; max-width: 2.5em; border-radius: 0.5em; margin: auto;"),It(e,r),A.appendChild(e)}let T=Ct(E.value);C&&(T+=" ... "+Ct(c.value));const j=k.appendChild(hr.createElement("td"));i.authorDateOnLeft||function(e,t,n,i){const a=e.appendChild(xr(br(t),t));t.uri&&x.store.fetcher.nowOrWhenFetched(t.doc(),void 0,function(e,n){a.textContent=vr(t)});const o=e.appendChild(xr(n,i));o.style.fontSize="80%",o.style.marginLeft="1em",e.appendChild(hr.createElement("br"))}(j,r,T,t);const _=d?d.value.trim():"??? no content?";let L=null;if(/^https?:\/[^ <>]*$/i.test(_)){if(/\.(gif|jpg|jpeg|tiff|png|svg)$/i.test(_)&&i.expandImagesInline){const e=function(e,t){const n=hr.createElement("img");let i="10";t.inlineImageHeightEms&&(i=(""+t.inlineImageHeightEms).trim()),n.setAttribute("style","max-height: "+i+"em; border-radius: 1em; margin: 0.7em;"),e&&n.setAttribute("src",e);const a=hr.createElement("a");return a.setAttribute("href",e),a.setAttribute("target","images"),a.appendChild(n),et(n,$rdf.sym(e)),a}(_,i);j.appendChild(e)}else{const e=j.appendChild(hr.createElement("a"));L=e.appendChild(hr.createElement("p")),e.href=_,L.textContent=_,j.appendChild(e)}}else L=hr.createElement("p"),j.appendChild(L),L.textContent=_;if(L){const e=s?tr(r):function(e){return e?"#e8ffe8":"white"}(n);L.setAttribute("style",gr+"background-color: "+e+";")}const S=await async function(e,t){const n=dr.createElement("span");async function i(){if(n.innerHTML="",Ws(e))return n;const i=(await Gs(e)).map(e=>x.store.each(null,b.schema("target"),e,t)).flat();if(0===i.length)return n;const a=i.map(e=>[x.store.any(e,b.rdf("type"),null,t),x.store.any(e,b.sioc("content"),null,t),x.store.any(e,b.schema("agent"),null,t)]);a.sort(),a.forEach(e=>{const[t,i,a]=e;let o;a?(o=dr.createElement("a"),o.setAttribute("href",a.uri)):o=dr.createTextNode(""),o.textContent=i||mr[t]||"⬜️",n.appendChild(o)})}return i().then(ve.Rm("sentimentStripLinked: sentimentStripLinked async refreshed")),n.refresh=i,n}(t,t.doc());S.children.length&&(j.appendChild(hr.createElement("br")),j.appendChild(S));const R=hr.createElement("td");k.appendChild(R);const N=Ot(hr,it.Pt.iconBase+"noun_243787.svg","...");return R.appendChild(N),N.addEventListener("click",async function(n){if(k.toolTR)return k.parentNode.removeChild(k.toolTR),void delete k.toolTR;const o=hr.createElement("tr"),s=await fr(t,k,{...a,chatOptions:i},e);s.style="border: 0.05em solid #888; border-radius: 0 0 0.7em 0.7em; border-top: 0; height:3.5em; background-color: #fff;",k.nextSibling?k.parentElement.insertBefore(o,k.nextSibling):k.parentElement.appendChild(o),k.toolTR=o,o.appendChild(hr.createElement("td"));const r=o.appendChild(hr.createElement("td"));o.appendChild(hr.createElement("td")),r.appendChild(s)}),h&&i.showThread&&R.appendChild(Ot(hr,it.Pt.iconBase+"noun_1180164.svg","see thread",e=>{i.showThread(h,i)})),k}function Cr(e,t,n,i,a){async function o(e){await s(h.value,!0)}async function s(o,s){let r;s&&(h.setAttribute("style",gr+"color: #bbb;"),h.disabled=!0);try{r=await e.updateMessage(o,a,null,i.thread)}catch(e){return void(n.statusArea||u).appendChild(nt(hr,"Error writing message: "+e))}await async function(o){if(await Er(e,t,o,!1,i,n),a){const e=u.originalRow;e.parentNode?e.parentNode.removeChild(e):(ve.R8("No parentNode on old message "+e.textContent),e.style.backgroundColor="#fee",e.style.visibility="hidden"),u.parentNode.removeChild(u)}else s&&(h.value="",h.setAttribute("style",gr),h.disabled=!1,h.scrollIntoView(i.newestFirst),h.focus(),h.select())}(r)}function r(e){const n=t.chatDocument.dir().uri;tt(x.store.fetcher,e,n+"Files",n+"Pictures",async function(e,t){await s(t)})}const c=async function(e){for(const t of e)await s(t)};let l,p;a?(l=x.store.anyValue(a,b.dct("created"),null,a.doc()),p=it.Pt.iconBase+"noun_1180158.svg"):(p=it.Pt.iconBase+"noun_383448.svg",l="9999-01-01T00:00:00Z");const u=hr.createElement("tr"),d=hr.createElement("td"),m=hr.createElement("td"),f=hr.createElement("td");let h,v;u.appendChild(d),u.appendChild(m),u.appendChild(f),u.AJAR_date=l;return Di({div:m,dom:hr}).then(t=>{!function(){if(i.menuHandler){const e=Ot(hr,it.Pt.iconBase+"noun_243787.svg","More");e.setAttribute("style",Ke.buttonStyle+"float: right;"),f.appendChild(e)}i.menuHandler;const t=x.authn.currentUser();if(yr(d,t,"",null),h=hr.createElement("textarea"),m.innerHTML="",m.appendChild(h),h.rows=3,a&&(h.value=x.store.anyValue(a,b.sioc("content"),null,a.doc())),h.setAttribute("style",gr+"background-color: #eef;"),h.addEventListener("keydown",async function(e){"Enter"===e.code&&(!e.shiftKey&&!i.shiftEnterSendsMessage||e.shiftKey&&i.shiftEnterSendsMessage)&&await o()},!1),Xe(h,c,r),f.innerHTML="",v=Ot(hr,p,"Send"),v.style.float="right",v.addEventListener("click",e=>o(),!1),f.appendChild(v),a){const e=f.appendChild(Mt(hr));e.style.float="left",e.addEventListener("click",e=>function(e){e.originalRow.style.visibility="visible",e.parentNode.removeChild(e)}(u),!1),f.appendChild(e)}const n=e.dateFolder.leafDocumentFromDate(new Date);let l;m.appendChild(ba.cameraButton(hr,x.store,function(){return l=$rdf.sym(n.dir().uri+"Image_"+Date.now()+".png"),l},async function(e){e&&await s(e.uri)})),Ys(e.channel,e.channel.doc())}(),Object.assign(t,n),async function(e){const t=rr("Bookmark");if(await Fi(e,t,!0),e.instances&&e.instances.length>0)e.bookmarkDocument=e.instances[0],e.instances.length>1&&ve.R8("More than one bookmark file! "+e.instances);else if(e.publicProfile){const n=g.sym(e.publicProfile.dir().uri+"bookmarks.ttl");try{ve.Rm("Creating new bookmark file "+n),await x.store.fetcher.createIfNotExists(n)}catch(t){return ve.R8("Can't make fresh bookmark file:"+t),e}await x.createTypeIndexLogic.registerInTypeIndex(n,e.index,t),e.bookmarkDocument=n}else ve.R8("You seem to have no bookmark file, nor even a profile file!");return e}(t).then(e=>{})}),u}async function Er(e,t,n,i,a,o){const s=await wr(e,n,i,a,o);a.selectedMessage&&a.selectedMessage.sameTerm(n)&&(s.style.backgroundColor="yellow",a.selectedElement=s,t.selectedElement=s);let r=!1;for(let e=t.firstChild;e;e=e.nextSibling){const n=!0===a.newestfirst,i=s.AJAR_date;if(i>e.AJAR_date&&n||i<e.AJAR_date&&!n){t.insertBefore(s,e),r=!0;break}}r||t.appendChild(s)}async function kr(e,t,n,i){async function a(e,t){if(Ws(e)&&!i.showDeletedMessages)return;let n=x.store.any(null,b.sioc("has_member"),e,e.doc());const a=x.store.any(e,b.sioc("id"),null,e.doc());if(a&&!n&&(n=x.store.any(null,b.sioc("has_member"),a,e.doc())),i.thread){if(x.store.holds(e,b.sioc("has_reply"),i.thread));else if(!n||!n.sameTerm(i.thread))return}else if(n)return;t.fresh||await Er(u,t,e,t.fresh,i,h)}async function o(e){const t=e?w:C;let n=t.messageTable.date;if(e&&w.limit&&n<=w.limit)return v||await c(),!0;if(n=await d.loadPrevious(n,e),n||e||v||await c(),!n)return!0;let i=!1;if(!e){const e=d.leafDocumentFromDate(new Date);i=d.leafDocumentFromDate(n).sameTerm(e)}const a=await s(n,i);return t.messageTable=a,(e?p:!p)?m.appendChild(a):m.insertBefore(a,m.firstChild),i}async function s(t,n){const i=d.leafDocumentFromDate(t);try{await x.store.fetcher.createIfNotExists(i)}catch(a){const o=e.createElement("table").appendChild(e.createElement("tr"));return a.response&&a.response.status&&404===a.response.status?await r(t,n):(ve.Rm("*** Error NON 404 for chat file "+i),o.appendChild(nt(e,a,"pink")),o)}return await r(t,n)}async function r(t,n){async function s(){return await o(!1)}const r=e.createElement("table");r.style.width="100%",r.extendBackwards=async function(){const e=await o(!0);return e?r.initial=!0:r.extendedBack=!0,e},r.extendForwards=s,r.date=t;const c=d.leafDocumentFromDate(t);if(r.chatDocument=c,r.fresh=!1,r.setAttribute("style","width: 100%;"),n){r.final=!0,v=r,C.messageTable=r;const e=Cr(u,r,h,i);p?r.insertBefore(e,r.firstChild):r.appendChild(e),r.inputRow=e}{const n=e.createElement("tr"),a=n.appendChild(e.createElement("td"));a.style="text-align: center; vertical-align: middle; color: #888; font-style: italic;",a.textContent=Ct(t.toISOString(),!0);const o=n.appendChild(e.createElement("td"));i.includeRemoveButton&&o.appendChild(Mt(e,e=>{m.parentNode.removeChild(m)})),r.extendedForwards=!1,p?r.appendChild(n):r.insertBefore(n,r.firstChild)}const l=x.store.statementsMatching(null,b.wf("message"),null,c);!n&&l.length;for(const e of l)await a(e.object,r);return r.fresh=!0,r}async function c(){const e=new Date,t=d.leafDocumentFromDate(e),i=await s(e,!0);return m.appendChild(i),m.refresh=async function(){var e;await async function(){const e=d.leafDocumentFromDate(new Date);if(!e.sameTerm(C.messageTable.chatDocument)){v.inputRow&&(v.removeChild(v.inputRow),delete v.inputRow);const t=C.messageTable.chatDocument;if(await c(),!x.store.holds(t,b.rdfs("seeAlso"),e,t)){const n=[g.st(t,b.rdfs("seeAlso"),e,t)];try{x.store.updater.update([],n)}catch(e){alert("Unable to link old chat file to new one:"+e)}}}}(new Date),await async function(e,t){const n={};let i,o;for(i=t.firstChild;i;i=i.nextSibling)i.AJAR_subject&&(n[i.AJAR_subject.uri]=!0);const s=x.store.each(e,b.wf("message"),null,t.chatDocument),r={};for(const e of s)r[e.uri]=!0,n[e.uri]||await a(e,t);for(i=t.firstChild;i;)o=i.nextSibling,i.AJAR_subject&&!r[i.AJAR_subject.uri]&&t.removeChild(i),i=o;for(i=t.firstChild;i;i=i.nextSibling)i.AJAR_subject&&Gt(i)}(n,i),e=n,"Notification"in window?"granted"===Notification.permission?new Notification(e):"denied"!==Notification.permission&&Notification.requestPermission().then(function(t){"granted"===t&&new Notification(e)}):ve.R8("This browser does no t support desktop notification")},x.store.updater.addDownstreamChangeListener(t,m.refresh),v=i,C.messageTable=v,i}async function l(e,t){if(E)return;E=!0;const n=!t;let a;for(;m.scrollTop<150&&w.messageTable&&!w.messageTable.initial&&w.messageTable.extendBackwards;){if(0===m.scrollHeight)return setTimeout(l,2e3),void(E=!1);const e=m.scrollHeight-m.scrollTop;if(a=await w.messageTable.extendBackwards(),n&&(m.scrollTop=m.scrollHeight-e),t&&t(),a)break}for(;i.selectedMessage&&m.scrollHeight-m.scrollTop-m.clientHeight<150&&C.messageTable&&!C.messageTable.final&&C.messageTable.extendForwards;){const e=m.scrollTop;if(a=await C.messageTable.extendForwards(),n&&(m.scrollTop=e),t&&t(),a)break}E=!1}(i=i||{}).authorDateOnLeft=!1;const p="1"===i.newestFirst||!0===i.newestFirst,u=new Hs(n,i),d=u.dateFolder,m=e.createElement("div");u.div=m;const f=m.appendChild(e.createElement("div")),h={dom:e,statusArea:f,div:f};let v,y;const w={messageTable:null},C={messageTable:null};if(i.thread){const e=i.thread;if(y=x.store.any(null,b.sioc("has_reply"),e,e.doc()),y){const e=x.store.any(y,b.dct("created"),null,y.doc());e&&(w.limit=new Date(e.value))}}let E=!1;return await async function(){function e(){r&&r.selectedElement&&r.selectedElement.scrollIntoView({block:"center"})}let t,n,a;i.selectedMessage&&(n=i.selectedMessage.doc()),y&&(a=y.doc());const o=n||a;if(o){const e=new Date;t=d.leafDocumentFromDate(e).sameTerm(o)}let r;if(o&&!t){const n=d.dateFromLeafDocument(o);r=await s(n,t),m.appendChild(r),w.messageTable=r,C.messageTable=r,e(),setTimeout(e,1e3)}else await c(),w.messageTable=v,C.messageTable=v;await l(0,function(){i.selectedElement?i.selectedElement.scrollIntoView({block:"center"}):v.inputRow.scrollIntoView&&v.inputRow.scrollIntoView(p)}),m.addEventListener("scroll",l),i.solo&&document.body.addEventListener("scroll",l)}(),m}const Ar=x.store,Tr=[];function jr(e){return Tr[e]}function _r(e,t){if("string"!=typeof t)throw ve.Rm("Non-string value of preference "+e+": "+t),new Error("Non-string value of preference "+e+": "+t);this.value[e]=t}function Lr(e,t){return new Promise(function(n,i){const a=Ar.any(e,b.ui("sharedPreferences"));if(a)t.sharedPreferences=a,n(t);else{Ar.updater.editable(e.doc())||(ve.Rm(` Cant make shared preferences, may not change ${e.doc}`),n(t));const a=g.sym(e.doc().uri+"#SharedPreferences"),o=[g.st(e,b.ui("sharedPreferences"),a,e.doc())];ve.Rm("Creating shared preferences "+a),Ar.updater.update([],o,function(e,o,s){o?(t.sharedPreferences=a,n(t)):i(new Error("Error creating shared prefs: "+s))})}})}function Sr(e,t){return new Promise(function(n,i){Oi(t).then(t=>{if(!t.preferencesFile)return void ve.Rm("Not doing private class preferences as no access to preferences file. "+t.preferencesFileError);const a=Ar.each(null,b.solid("forClass"),e,t.preferencesFile);let o,s,r=[];if(a.length){if(a.forEach(e=>{o=o||Ar.any(e,b.solid("personalDefaults"))}),o)return t.personalDefaults=o,void n(t);o=Ei(t.preferencesFile),s=a[0]}else s=Ei(t.preferencesFile),r=[g.st(s,b.rdf("type"),b.solid("TypeRegistration"),t.preferencesFile),g.st(s,b.solid("forClass"),e,t.preferencesFile)];o=Ei(t.preferencesFile),r.push(g.st(s,b.solid("personalDefaults"),o,t.preferencesFile)),Ar.updater.update([],r,function(a,s,r){s?(t.personalDefaults=o,n(t)):i(new Error("Setting preferences for "+e+": "+r))})},e=>{i(e)})})}function Rr(e,t,n,i){const a=i.dom.createElement("div");return Zs(e,e.doc(),i.me).then(o=>{const s=i.dom;function r(e){a.appendChild(s.createElement("h5")).textContent=e}r("My view of this "+i.noun),li(s,a,{},o,n,e.doc(),(e,t)=>{e||vt(i,t)}),r("Everyone's view of this "+i.noun),Lr(e,i).then(i=>{const o=i.sharedPreferences;li(s,a,{},o,n,e.doc(),(e,t)=>{e||vt(i,t)}),r("My default view of any "+i.noun),Sr(t,i).then(e=>{li(s,a,{},e.personalDefaults,n,e.preferencesFile,(t,n)=>{t||vt(e,n)})},e=>{vt(i,e)})})},e=>{a.appendChild(nt(i.dom,e))}),a}function Nr(e){return e.datatype?e.datatype.equals(b.xsd("boolean"))?"1"===e.value:e.datatype.equals(b.xsd("dateTime"))||e.datatype.equals(b.xsd("date"))?new Date(e.value):e.datatype.equals(b.xsd("integer"))||e.datatype.equals(b.xsd("float"))||e.datatype.equals(b.xsd("decimal"))?Number(e.value):e.value:e}function Ir(e,t,n,i){return new Promise(function(a,o){Lr(e,i).then(i=>{const s=i.sharedPreferences;if(i.me)Zs(e,e.doc(),i.me).then(e=>{Sr(t,i).then(t=>{const i=[],o=t.personalDefaults;n.forEach(t=>{const n=Ar.any(e,t)||Ar.any(s,t)||Ar.any(o,t);n&&(i[t.uri]=Nr(n))}),a(i)},o)},o);else{const e=[];n.forEach(t=>{const n=Ar.any(s,t);n&&(e[t.uri]=Nr(n))}),a(e)}})})}const Br={icons:it.Pt,log:i,ns:b,utils:a,widgets:r};function Dr(e,t){const n=t.sourceDocument,i=t.tableClass,a=t.query,o=Br.ns,s=x.store,r={},c={"http://www.w3.org/2002/07/owl#sameAs":!0,"http://www.w3.org/1999/02/22-rdf-syntax-ns#type":!0},l={"http://www.w3.org/2001/XMLSchema#decimal":!0,"http://www.w3.org/2001/XMLSchema#float":!0,"http://www.w3.org/2001/XMLSchema#double":!0,"http://www.w3.org/2001/XMLSchema#integer":!0,"http://www.w3.org/2001/XMLSchema#nonNegativeInteger":!0,"http://www.w3.org/2001/XMLSchema#positiveInteger":!0,"http://www.w3.org/2001/XMLSchema#nonPositiveInteger":!0,"http://www.w3.org/2001/XMLSchema#negativeInteger":!0,"http://www.w3.org/2001/XMLSchema#long":!0,"http://www.w3.org/2001/XMLSchema#int":!0,"http://www.w3.org/2001/XMLSchema#short":!0,"http://www.w3.org/2001/XMLSchema#byte":!0,"http://www.w3.org/2001/XMLSchema#unsignedLong":!0,"http://www.w3.org/2001/XMLSchema#unsignedInt":!0,"http://www.w3.org/2001/XMLSchema#unsignedShort":!0,"http://www.w3.org/2001/XMLSchema#unsignedByte":!0},p={"http://www.w3.org/2001/XMLSchema#dateTime":!0,"http://www.w3.org/2001/XMLSchema#date":!0},u={"http://xmlns.com/foaf/0.1/Image":!0,"http://purl.org/dc/terms/Image":!0},d=t.keyVariable||"?_row";let m,f,h,b,v=0,y=null,w=null;const C=e.createElement("div");C.className="tableViewPane",C.appendChild(function(){const t=e.createElement("table");t.setAttribute("class","toolbar");const n=e.createElement("tr");return h=e.createElement("td"),n.appendChild(h),b=e.createElement("td"),n.appendChild(b),t.appendChild(n),t}());const E=e.createElement("div");let k;if(C.appendChild(E),C.refresh=function(){Y(k.query,k.logicalRows,k.columns,k)},a)k=te(a),E.appendChild(k);else{const t=function(){let e,t;const a=function(){const e={},t=s.statementsMatching(void 0,Br.ns.rdf("type"),i,n),a={};for(let n=0;n<t.length;++n){const i=t[n].object;if("NamedNode"!==i.termType)continue;const o=I(e,i);i.uri in a||(a[i.uri]=[]),a[i.uri].push(t[n].subject),o.addUse()}return[a,e]}();e=a[0],t=a[1];for(const n in e){const i=e[n];D(t[n],i)}const o=new _(null);return[o,S(t)]}();m=t[0],f=t[1],i||h.appendChild(function(t,n){const i=e.createElement("div");i.appendChild(e.createTextNode("Select type: "));const a=e.createElement("select");a.appendChild(R("All types","null"));for(const e in n)a.appendChild(R(n[e].getLabel(),e));return a.addEventListener("click",function(){let e;e="null"===a.value?t:n[a.value],T(e)},!1),i.appendChild(a),i}(m,f)),w=function(e){let t,n=-1,i=null;for(t in e){const a=e[t];a.useCount>n&&(i=a,n=a.useCount)}return i}(f),T(w||m)}return C;function A(e){const t=new g.Query,n=s.variable(d.slice(1));return function(e,t){const n=t.getColumns();for(let t=0;t<n.length;++t){const i=s.variable("_col"+t);e.vars.push(i),n[t].setVariable(i)}}(t,e),function(e,t,n){let i=n.type;i||(i=s.variable("_any")),e.pat.add(t,Br.ns.rdf("type"),i)}(t,n,e),function(e,t,n){const i=n.getColumns();for(let n=0;n<i.length;++n){const a=i[n],o=s.formula();o.add(t,a.predicate,a.getVariable()),e.pat.optional.push(o)}}(t,n,e),t}function T(t){j(b),b.appendChild(function(t){const n=e.createElement("div"),i=t.getUnusedColumns();if(i.sort(function(e,t){const n=e.sortKey(),i=t.sortKey();return(n>i)-(n<i)}),i.length>0){n.appendChild(e.createTextNode("Add column: "));const a=e.createElement("select");a.appendChild(R("","-1"));for(let e=0;e<i.length;++e){const t=i[e];a.appendChild(R(t.getLabel(),""+e))}n.appendChild(a),a.addEventListener("click",function(){const e=Number(a.value);e>=0&&(t.addColumn(i[e]),T(t))},!1)}return n}(t));!function(e,t){y&&(y.running=!1);const n=te(e,t);j(E),E.appendChild(n),y=e}(A(t),t)}function j(e){for(;e.childNodes.length>0;)e.removeChild(e.childNodes[0])}function _(e){this.type=e,this.columns=null,this.allColumns=[],this.useCount=0,this.getAllColumns=function(){return this.allColumns},this.getColumns=function(){if(!this.columns){const e=this.getAllColumns();this.columns=e.slice(0,7)}return this.columns},this.getUnusedColumns=function(){const e=this.getAllColumns(),t=this.getColumns(),n=[];for(let i=0;i<e.length;++i)-1===t.indexOf(e[i])&&n.push(e[i]);return n},this.addColumn=function(e){this.columns.push(e)},this.removeColumn=function(e){this.columns=this.columns.filter(function(t){return t!==e})},this.getLabel=function(){return z(this.type)},this.addUse=function(){this.useCount+=1}}function L(){this.useCount=0,this.checkedAnyValues=!1,this.possiblyLiteral=!0,this.possiblyNumber=!0,this.constraints=[],this.checkValue=function(e){const t=e.termType;if(this.possiblyLiteral&&"Literal"!==t&&"NamedNode"!==t)this.possiblyNumber=!1,this.possiblyLiteral=!1;else if(this.possiblyNumber)if("Literal"!==t)this.possiblyNumber=!1;else{e.value.match(/^-?\d+(\.\d*)?$/)||(this.possiblyNumber=!1)}this.checkedAnyValues=!0},this.getVariable=function(){return this.variable},this.setVariable=function(e){this.variable=e},this.getKey=function(){return this.variable.toString()},this.addUse=function(){this.useCount+=1},this.getHints=function(){return t&&t.hints&&this.variable&&t.hints[this.variable.toNT()]?t.hints[this.variable.toNT()]:{}},this.getLabel=function(){return this.getHints().label?this.getHints().label:this.predicate?this.predicate.sameTerm(o.rdf("type"))&&this.superClass?z(this.superClass,!0):z(this.predicate):this.variable?this.variable.toString():"unlabeled column?"},this.setPredicate=function(e,t,n){t?(this.inverse=e,this.constraints=this.constraints.concat(s.each(e,Br.ns.rdfs("domain"))),e.sameTerm(o.rdfs("subClassOf"))&&"NamedNode"===n.termType&&(this.superClass=n,this.alternatives=s.each(void 0,o.rdfs("subClassOf"),n))):(this.predicate=e,this.constraints=this.constraints.concat(s.each(e,Br.ns.rdfs("range"))))},this.getConstraints=function(){return this.constraints},this.filterFunction=function(){return!0},this.sortKey=function(){return this.getLabel().toLowerCase()},this.isImageColumn=function(){for(let e=0;e<this.constraints.length;e++)if(this.constraints[e].uri in u)return!0;return!1}}function S(e,t){const n=[];for(const i in e){const a=e[i];t&&!t(i,a)||n.push(a)}return n}function R(t,n){const i=e.createElement("option");return i.setAttribute("value",n),i.appendChild(e.createTextNode(t)),i}function N(e,t){let n;return t.uri in e?n=e[t.uri]:(n=new L,n.setPredicate(t),e[t.uri]=n),n}function I(e,t){let n;return t.uri in e?n=e[t.uri]:(n=new _(t),e[t.uri]=n),n}function B(e,t){const i=s.statementsMatching(e,void 0,void 0,n),a={};for(let e=0;e<i.length;++e){const n=i[e].predicate;if(n.uri in c)continue;const o=N(t,n);o.checkValue(i[e].object),a[n.uri]=o}return a}function D(e,t){const n={};for(let e=0;e<t.length;++e){const i=B(t[e],n);for(const e in i){i[e].addUse()}}const i=S(n);!function(e){function t(e,t){return(e.useCount<t.useCount)-(e.useCount>t.useCount)}e.sort(t)}(i),e.allColumns=i}function O(t,n){const i=e.createElement("a");return i.appendChild(e.createTextNode("[x]")),i.addEventListener("click",function(){t.removeColumn(n),T(t)},!1),i}function M(e,t){let n=!0;for(let i=0;i<t.length;++i){const a=t[i],o=a.getKey();let s=null;if(o in e.values&&(s=e.values[o][0]),!a.filterFunction(s)){n=!1;break}}const i=e._htmlRow;i.style.display=n?"":"none"}function F(e,t){for(let n=0;n<e.length;++n){M(e[n],t)}}function U(e,t,n){function i(e){return e?"Literal"===e.termType?e.value.toLowerCase():"NamedNode"===e.termType?z(e).toLowerCase():e.value.toLowerCase():""}!function(e,t,n,i){const a=t.getKey();if(e.sort(function(e,t){let o=null,s=null;a in e.values&&(o=e.values[a][0]),a in t.values&&(s=t.values[a][0]);const r=n(o,s);return i?-r:r}),e.length){const t=e[0]._htmlRow.parentNode;for(let n=0;n<e.length;++n)t.removeChild(e[n]._htmlRow);for(let n=0;n<e.length;++n)t.appendChild(e[n]._htmlRow)}}(e,t,function(e,t){const n=i(e),a=i(t);return n<a?-1:n>a?1:0},n)}function P(t,n,i){const a=e.createElement("div"),o=e.createElement("input");o.setAttribute("type","text"),o.style.width="70%",a.appendChild(o);const s=e.createElement("span");s.appendChild(e.createTextNode("▼")),s.addEventListener("click",function(){U(t,i,!1)},!1),a.appendChild(s);const r=e.createElement("span");r.appendChild(e.createTextNode("▲")),r.addEventListener("click",function(){U(t,i,!0)},!1),a.appendChild(r);let c=null;return i.filterFunction=function(e){if(c){if(e){let t;return t="Literal"===e.termType?e.value:"NamedNode"===e.termType?z(e):"",t.toLowerCase().indexOf(c)>=0}return!1}return!0},o.addEventListener("keyup",function(){c=""!==o.value?o.value.toLowerCase():null,F(t,n)},!1),a}function $(t,n,i,a){const o=e.createElement("div"),s=e.createElement("select");let r={};for(let e=0;e<a.length;++e){const t=a[e];r[t.uri]=!0}const c=V(i).initialSelection;c&&(r=c),s.setAttribute("multiple","true");for(let e=0;e<a.length;++e){const t=a[e],n=R(z(t),e);r[t.uri]&&(n.selected=!0),s.appendChild(n)}return o.appendChild(s),i.filterFunction=function(e){return!r||e&&r[e.uri]},s.addEventListener("click",function(){{r={};const e=s.options;for(let t=0;t<e.length;t++){const n=e[t],i=Number(n.value);e[t].selected&&(r[a[i].uri]=!0)}}F(t,n)},!0),o}function q(t,n,i){const a=e.createElement("div"),o=e.createElement("input");o.setAttribute("type","text"),o.style.width="40px",a.appendChild(o);const s=e.createElement("input");s.setAttribute("type","text"),s.style.width="40px",a.appendChild(s);let r=null,c=null;function l(){r=""===o.value?null:Number(o.value),c=""===s.value?null:Number(s.value),F(t,n)}return i.filterFunction=function(e){return e&&(e=Number(e)),!(r&&(!e||e<r))&&!(c&&(!e||e>c))},o.addEventListener("keyup",l,!1),s.addEventListener("keyup",l,!1),a}function H(e,t,n){if(n.superClass&&n.alternatives.length>0)return $(e,t,n,n.alternatives);const i=n.getConstraints();let a;for(let o=0;o<i.length;o++){if(a=i[o],n.checkedAnyValues&&n.possiblyNumber||a.uri in l)return q(e,t,n);if("http://www.w3.org/2000/01/rdf-schema#Literal"===a.uri)return P(e,t,n);const r=s.each(a,Br.ns.owl("oneOf"));if(r.length>0)return $(e,t,n,r.elements)}return function(e,t,n){return n.checkedAnyValues&&n.possiblyNumber?q(e,t,n):n.possiblyLiteral?P(e,t,n):null}(e,t,n)}function G(t,n,i){i=i||{};const a=e.createElement("a"),o=i.linkFunction;return a.setAttribute("href",t),a.appendChild(e.createTextNode(n)),o?a.addEventListener("click",function(e){e.preventDefault(),e.stopPropagation();const t=ee(e).getAttribute("href");t||ve.Rm("No href found \n"),o(t)},!0):a.addEventListener("click",Br.widgets.openHrefInOutlineMode,!0),a}function V(e){return t&&t.hints&&e.variable&&t.hints[e.variable.toNT()]?t.hints[e.variable.toNT()]:{}}function W(t,n){const i=V(n),a=i.cellFormat;if(!a){if("Literal"===t.termType){if(t.datatype){if(p[t.datatype.uri])return e.createTextNode(Br.widgets.shortDate(t.value));if(l[t.datatype.uri]){const n=e.createElement("span");return n.textContent=t.value,n.setAttribute("style","text-align: right"),n}}return e.createTextNode(t.value)}if("NamedNode"===t.termType&&n.isImageColumn())return function(t){const n=e.createElement("img");return n.setAttribute("src",t.uri),n.style.height="40px",n}(t);if("NamedNode"===t.termType||"BlankNode"===t.termType)return function(e,t){let n=!1;return e.uri&&(n=e.uri.match(/^mailto:(.*)/)),G(e.uri,n?n[1]:z(e),t)}(t,i);if("Collection"===t.termType){const i=e.createElement("span");return i.appendChild(e.createTextNode("[")),t.elements.forEach(function(t){i.appendChild(W(t,n)),i.appendChild(e.createTextNode(", "))}),i.removeChild(i.lastChild),i.appendChild(e.createTextNode("]")),i}return e.createTextNode("unknown termtype '"+t.termType+"'!")}if("shortDate"===a)return e.createTextNode(Br.widgets.shortDate(t.value))}function J(e,t){let n,i=null;if("Literal"===e.termType)i="value";else{if("NamedNode"!==e.termType)return t.indexOf(e)>=0;i="uri"}for(n=0;n<t.length;++n)if(t[n].termType===e.termType&&t[n][i]===e[i])return!0;return!1}function Q(t,n,i){let a,o=!1;for(a in i){const e=i[a];a in t.values||(t.values[a]=[]),J(e,t.values[a])||(t.values[a].push(e),o=!0)}o&&(j(t._htmlRow),function(t,n,i){const a=e.createElement("td");n._subject&&"uri"in n._subject&&a.appendChild(G(n._subject.uri,"→")),t.appendChild(a);for(let a=0;a<i.length;++a){const o=i[a],s=e.createElement("td");let r;const c=o.getKey();if(c in n.values){const t=n.values[c];let i=!1;n.originalValues&&n.originalValues[c]&&t.length!==n.originalValues[c].length&&(i=!0);for(let a=0;a<t.length;++a){const l=t[a];n.originalValues&&n.originalValues[c]&&n.originalValues[c].length>a&&(r=n.originalValues[c][a],l.toString()!==r.toString()&&(i=!0)),s.appendChild(W(l,o)),a!==t.length-1&&s.appendChild(e.createTextNode(",\n")),i&&(s.style.background="#efe")}}t.appendChild(s)}n._htmlRow=t}(t._htmlRow,t,n)),M(t,n)}function Z(e){if("uri"in e)return e.uri;if("_subject_id"in e)return e._subject_id;{const t=""+v;return e._subject_id=t,++v,t}}function Y(n,i,a,o){n.running=!0;const c=Date.now();let l=e.createElement("tr");o.appendChild(l),l.textContent="Loading ...";for(let e=0;e<i.length;e++)i[e].original=!0,i[e].originalValues||(i[e].originalValues=i[e].values),i[e].values={};s.query(n,function(t){if(!n.running)return;l.textContent+=".";let s,c=null,p=null;if(d in t&&(p=t[d],s=Z(p),s in r&&(c=r[s])),!c){const t=e.createElement("tr");o.appendChild(t),c={_htmlRow:t,_subject:p,values:{}},i.push(c),p&&(r[s]=c)}delete c.original,Q(c,a,t)},void 0,function(){l&&l.parentNode&&l.parentNode.removeChild&&(l.parentNode.removeChild(l),l=null);const e=Date.now()-c;ve.Rm("Query done: "+i.length+" rows, "+e+"ms");for(let e=i.length-1;e>=0;e--)if(i[e].original){ve.Rm(" deleting row "+i[e]._subject);const t=i[e]._htmlRow;t.parentNode.removeChild(t),delete r[Z(i[e]._subject)],i.splice(e,1)}if(t.sortBy){const e=function(e,t){for(const n in e){const i=e[n];if(i.variable.toNT()===t)return i}throw new Error(`getColumnForVariable: no column for variable ${t}`)}(a,t.sortBy);U(i,e,t.sortReverse)}t.onDone&&t.onDone(C)})}function K(e,t){Br.log.debug(">> processing formula");for(let n=0;n<t.statements.length;++n){const i=t.statements[n];if("NamedNode"===i.predicate.termType&&"Variable"===i.object.termType){const t=i.object.toString();if(t in e){e[t].setPredicate(i.predicate,!1,i.subject)}}if("NamedNode"===i.predicate.termType&&"Variable"===i.subject.termType){const t=i.subject.toString();if(t in e){e[t].setPredicate(i.predicate,!0,i.object)}}}for(let n=0;n<t.optional.length;++n)Br.log.debug("recurse to optional subformula "+n),K(e,t.optional[n]);Br.log.debug("<< finished processing formula")}function X(e){const t=[],n={};for(let i=0;i<e.vars.length;++i){const a=new L,o=e.vars[i];Br.log.debug("column "+i+" : "+o),a.setVariable(o),n[o]=a,t.push(a)}return K(n,e.pat),t}function te(t,n){let i;i=a?X(t):n.getColumns();const o=[],s=e.createElement("table");return s.appendChild(function(t,n){const i=e.createElement("tr"),a=e.createElement("th");i.appendChild(a);for(let a=0;a<t.length;++a){const o=e.createElement("th"),s=t[a];o.appendChild(e.createTextNode(s.getLabel())),n&&o.appendChild(O(n,s)),i.appendChild(o)}return i}(i,n)),s.appendChild(function(t,n){const i=e.createElement("tr");i.className="selectors",i.appendChild(e.createElement("td"));for(let a=0;a<n.length;++a){const o=e.createElement("td"),s=H(t,n,n[a]);s&&o.appendChild(s),i.appendChild(o)}return i}(o,i)),s.logicalRows=o,s.columns=i,s.query=t,Y(t,o,i,s),s}}class Or extends HTMLElement{bodyContainer;refresh;tabContainer}function Mr(e){const t=e.subject,n=e.dom||document,i=parseInt(e.orientation||"0"),a=e.backgroundColor||"#ddddcc",o=2&i,s=1&i,r=e.onClose,[c,l]=function(e){return function(e){let t=0;for(let n=0;n<3;n++)t+=parseInt(e.slice(2*n+1,2*n+3),16);return t>384}(e)?[Fr(e,"#ffffff",.3),"#000000"]:[Fr(e,"#000000",.3),"#ffffff"]}(a),p=`display: grid; width: auto; height: 100%; border: 0.1em; border-style: solid; border-color: ${c}; padding: 1em;`,u=n.createElement("div");u.setAttribute("style",Ke.tabsRootElement),u.style.flexDirection=(s?"row":"column")+(o?"-reverse":"");const d=u.appendChild(n.createElement("nav"));d.setAttribute("style",Ke.tabsNavElement);const m=u.appendChild(n.createElement("div"));m.setAttribute("style",Ke.tabsMainElement);const f=d.appendChild(n.createElement("ul"));f.setAttribute("style",Ke.tabContainer),f.style.flexDirection=""+(s?"column":"row");const h=m;u.tabContainer=f,u.bodyContainer=h;const g=["0.2em","0.2em","0","0"],b=`border-radius: ${g.concat(g).slice(i,i+4).join(" ")};`,v=["0.3em","0.3em","0","0.3em"],y=v.concat(v).slice(i,i+4),w=`margin: ${y.join(" ")};`,C=`padding: ${y.join(" ")};`,E=b+`position: relative; padding: 0.7em; max-width: 20em; color: ${l};`,k=`${E+w} opacity: 50%; background-color: ${a};`,A=`${E+w} background-color: ${c};`,T="height: 100%; width: 100%;",j=T+"display: none;";if(u.refresh=L,L(),!e.startEmpty&&f.children.length&&e.selectedTab){const t=Array.from(f.children).map(e=>e.firstChild).find(t=>t.dataset.name===e.selectedTab),n=e.selectedTab.uri,i=Array.from(f.children).find(e=>e.subject&&e.subject.uri&&e.subject.uri===n),a=i||t||f.children[0],o=a.firstChild;o?.click?o.click():a instanceof HTMLElement&&a.click()}else if(!e.startEmpty){const e=f.children[0],t=e?.firstChild;t?.click?t.click():e instanceof HTMLElement&&e.click()}return u;function _(t){const i=n.createElement("li");i.setAttribute("style",k),i.subject=t;const a=i.appendChild(n.createElement("button"));if(a.setAttribute("style",Ke.makeNewSlot),a.onclick=function(){if(S(),R(),i.setAttribute("style",A),!i.bodyTR)return;i.bodyTR.setAttribute("style",T);const n=o(i);e.renderMain&&i.subject&&!1!==n.asSettings&&(n.innerHTML="loading item ..."+t,e.renderMain(n,i.subject),n.asSettings=!1)},e.renderTabSettings&&i.subject){const a=n.createElement("button");a.textContent="...",a.setAttribute("style",Ke.ellipsis),a.onclick=function(){if(S(),R(),i.setAttribute("style",A),!i.bodyTR)return;i.bodyTR.setAttribute("style",T);const n=o(i);e.renderTabSettings&&i.subject&&!0!==n.asSettings&&(n.innerHTML="loading settings ..."+t,e.renderTabSettings(n,i.subject),n.asSettings=!0)},i.appendChild(a)}return e.renderTab?e.renderTab(a,t):a.innerHTML=z(t),i;function o(e){const t=e.bodyTR?.children[0];if(t)return t;const i=e.bodyTR.appendChild(n.createElement("div"));return i.setAttribute("style",p),i}}function L(){const i=e.items?e.items:!1!==e.ordered?x.store.the(t,e.predicate).elements:x.store.each(t,e.predicate);let a,o,s,c,l,p=!1;for(c=0;c<f.children.length;c++)if(a=f.children[c],c>=i.length||a.subject&&!a.subject.sameTerm(i[c])){p=!0;break}if(!p&&i.length===f.children.length)return;for(l=f.children.length-1;l>=0&&(a=f.children[l],s=l-f.children.length+i.length,!a.subject||a.subject.sameTerm(i[s]));l--);const u=i.slice(c,l-f.children.length+i.length+1);for(;l>=c;)f.removeChild(f.children[c]),h.removeChild(h.children[c]),l-=1;for(o=0;o<u.length;o++){const e=_(u[o]),t=n.createElement("div");e.bodyTR=t,c===f.children.length?(f.appendChild(e),h.appendChild(t)):(f.insertBefore(e,f.children[c+o]),h.insertBefore(t,h.children[c+o]))}r&&function(e){if(e.dataset.onCloseSet){const t=e.querySelector(".unstyled");e.removeChild(t)}const t=n.createElement("li");t.classList.add("unstyled");const i=Mt(n,r);i.setAttribute("style",i.getAttribute("style")+C),t.appendChild(i),e.appendChild(t),e.dataset.onCloseSet="true"}(f)}function S(){for(let e=0;e<f.children.length;e++){const t=f.children[e];t.classList.contains("unstyled")||t.setAttribute("style",k)}}function R(){for(let e=0;e<h.children.length;e++)h.children[e].setAttribute("style",j)}}function Fr(e,t,n){let i,a,o,s="#";const r="0123456789abcdef";for(let c=0;c<3;c++){i=parseInt(e.slice(2*c+1,2*c+3),16),a=parseInt(t.slice(2*c+1,2*c+3),16),o=i*(1-n)+a*n;const l=parseInt((""+o).split(".")[0]),p=parseInt((""+l/16).split(".")[0]),u=parseInt((""+l%16).split(".")[0]);s+=r[p]+r[u]}return s}const Ur='\n<svg xmlns="http://www.w3.org/2000/svg" width="26" height="26" viewBox="0 0 26 26" fill="none">\n <path fill-rule="evenodd" clip-rule="evenodd" d="M13 25C19.6274 25 25 19.6274 25 13C25 6.37258 19.6274 1 13 1C6.37258 1 1 6.37258 1 13C1 19.6274 6.37258 25 13 25Z" fill="#D8D8D8" stroke="#8B8B8B"/>\n <mask id="mask0" mask-type="alpha" maskUnits="userSpaceOnUse" x="0" y="0" width="26" height="26">\n <path fill-rule="evenodd" clip-rule="evenodd" d="M13 25C19.6274 25 25 19.6274 25 13C25 6.37258 19.6274 1 13 1C6.37258 1 1 6.37258 1 13C1 19.6274 6.37258 25 13 25Z" fill="white" stroke="white"/>\n </mask>\n <g mask="url(#mask0)">\n <path fill-rule="evenodd" clip-rule="evenodd" d="M17.0468 10.4586C17.0468 14.4979 15.4281 16.9214 12.9999 16.9214C10.5718 16.9214 8.95298 14.4979 8.95298 10.4586C8.95298 6.41931 12.9999 6.41931 12.9999 6.41931C12.9999 6.41931 17.0468 6.41931 17.0468 10.4586ZM4.09668 23.3842C6.52483 17.7293 12.9999 17.7293 12.9999 17.7293C12.9999 17.7293 19.475 17.7293 21.9031 23.3842C21.9031 23.3842 17.8481 25 12.9999 25C8.15169 25 4.09668 23.3842 4.09668 23.3842Z" fill="#8B8B8B"/>\n </g>\n</svg>';var zr=n(565);const Pr=it.Pt.iconBase+"noun_help.svg",$r="https://solidproject.org/assets/img/solid-emblem.svg";async function qr(e,t,n){const i=document.getElementById("PageHeader");if(!i)return;const a=(0,zr.E6)();Hr(i,e,a,t,n)(),x.authSession.events.on("logout",Hr(i,e,a,t,n)),x.authSession.events.on("login",Hr(i,e,a,t,n))}function Hr(e,t,n,i,a){return async()=>{const o=x.authn.currentUser();e.innerHTML="",e.appendChild(await async function(e,t,n,i,a){const o=document.createElement("a");o.href=t.uri,o.setAttribute("style",Ke.headerBannerLink);const s=document.createElement("img");a&&(s.src=a.logo?a.logo:$r);s.setAttribute("style",Ke.headerBannerIcon),o.appendChild(s);const r=n?await async function(e,t,n){const i=e.fetcher;i&&await i.load(t);const a=document.createElement("ul");a.setAttribute("style",Ke.headerUserMenuList),n&&n.forEach(function(e){"url"===(e.url?"url":"onclick")?a.appendChild(Wr(Vr(e.label,e.url,e.target))):a.appendChild(Wr(Gr(e.label,e.onclick)))});const o=document.createElement("nav");o.setAttribute("style",Ke.headerUserMenuNavigationMenuNotDisplayed),o.setAttribute("aria-hidden","true"),o.setAttribute("id","loggedInNav"),o.appendChild(a);const s=document.createElement("button");s.setAttribute("style",Ke.headerUserMenuTrigger),s.type="button";const r=function(e,t){let n=null;try{if(n=Rt(t),!n)return Ur}catch{return Ur}const i=document.createElement("div");return i.setAttribute("style",Ke.headerUserMenuPhoto),i.style.backgroundImage=`url(${n})`,i}(0,t);"string"==typeof r?s.innerHTML=r:s.appendChild(r);const c=document.createElement("div");c.setAttribute("style",Ke.headerBannerUserMenuNotDisplayed),c.appendChild(s),c.appendChild(o);const l=(0,zr.nF)(e=>Jr(e,s,o),50);s.addEventListener("click",l);let p=setTimeout(()=>null,0);return c.addEventListener("mouseover",e=>{clearTimeout(p),l(e);const t=document.getElementById("loggedInNav");t?.setAttribute("style",Ke.headerUserMenuNavigationMenu)}),c.addEventListener("mouseout",e=>{p=setTimeout(()=>l(e),200);const t=document.getElementById("loggedInNav");t?.setAttribute("style",Ke.headerUserMenuNavigationMenuNotDisplayed)}),c}(e,n,i):function(){const e=document.createElement("div");return e.setAttribute("style",Ke.headerBannerLogin),e.appendChild(Hi(document,null,{})),e}(),c=document.createElement("div");c.setAttribute("style",Ke.headerBanner),c.appendChild(o);const l=document.createElement("div");if(l.setAttribute("style",Ke.headerBannerRightMenu),l.appendChild(r),a&&a.helpMenuList){const e=function(e,t){if(!t)return;const n=document.createElement("ul");n.setAttribute("style",Ke.headerUserMenuList),t.forEach(function(e){"url"===(e.url?"url":"onclick")?n.appendChild(Wr(Vr(e.label,e.url,e.target))):n.appendChild(Wr(Gr(e.label,e.onclick)))});const i=document.createElement("nav");i.setAttribute("style",Ke.headerUserMenuNavigationMenuNotDisplayed),i.setAttribute("aria-hidden","true"),i.setAttribute("id","helperNav"),i.appendChild(n);const a=document.createElement("div");a.setAttribute("style",Ke.headerBannerUserMenu),a.appendChild(i);const o=document.createElement("button");o.setAttribute("style",Ke.headerUserMenuTrigger),o.type="button";const s=document.createElement("img");s.src=e&&e.helpIcon?e.helpIcon:it.Pt.iconBase+Pr,s.setAttribute("style",Ke.headerUserMenuTriggerImg),a.appendChild(o),o.appendChild(s);const r=(0,zr.nF)(e=>Jr(e,o,i),50);o.addEventListener("click",r);let c=setTimeout(()=>null,0);return a.addEventListener("mouseover",e=>{clearTimeout(c),r(e);const t=document.getElementById("helperNav");t?.setAttribute("style",Ke.headerUserMenuNavigationMenu)}),a.addEventListener("mouseout",e=>{c=setTimeout(()=>r(e),200);const t=document.getElementById("helperNav");t?.setAttribute("style",Ke.headerUserMenuNavigationMenuNotDisplayed)}),a}(a,a.helpMenuList);l.appendChild(e)}return c.appendChild(l),c}(t,n,o,i,a))}}function Gr(e,t){const n=document.createElement("button");return n.setAttribute("style",Ke.headerUserMenuButton),n.onmouseover=function(){n.setAttribute("style",Ke.headerUserMenuButtonHover)},n.onmouseout=function(){n.setAttribute("style",Ke.headerUserMenuButton)},n.addEventListener("click",t),n.innerText=e,n}function Vr(e,t,n){const i=document.createElement("a");return i.setAttribute("style",Ke.headerUserMenuLink),i.onmouseover=function(){i.setAttribute("style",Ke.headerUserMenuLinkHover)},i.onmouseout=function(){i.setAttribute("style",Ke.headerUserMenuLink)},i.href=t,i.innerText=e,n&&(i.target=n),i}function Wr(e){const t=document.createElement("li");return t.setAttribute("style",Ke.headerUserMenuListItem),t.appendChild(e),t}function Jr(e,t,n){const i="true"===t.getAttribute("aria-expanded"),a="mouseover"===e.type,o="mouseout"===e.type;i&&a||!i&&o||(t.setAttribute("aria-expanded",(!i).toString()),n.setAttribute("aria-hidden",i.toString()))}const Qr="https://solidproject.org",Zr="solidproject.org";async function Yr(e,t){const n=document.getElementById("PageFooter");if(!n)return;const i=(0,zr.E6)(),a=await(0,zr.bB)(i,e);Kr(n,e,i,a,t)(),x.authSession.events.on("login",Kr(n,e,i,a,t)),x.authSession.events.on("logout",Kr(n,e,i,a,t))}function Kr(e,t,n,i,a){return async()=>{const o=x.authn.currentUser();e.innerHTML="",e.appendChild(await function(e,t,n,i,a){const o=document.createElement("div");o.setAttribute("style",Ke.footer);const s=document.createElement("a");if(s.href=a&&a.solidProjectUrl?a.solidProjectUrl:Qr,s.innerText=a&&a.solidProjectName?a.solidProjectName:Zr,!n||!i||t&&t.equals(i)){const e=document.createElement("span");return e.innerText="Powered by ",o.appendChild(e),o.appendChild(s),o}const r=document.createElement("span");r.innerText="You're visiting ";const c=document.createElement("a");c.href=n.uri,c.innerText="the Pod";const l=document.createElement("span");l.innerText=" controlled by ";const p=document.createElement("a");p.href=i.uri,p.innerText=(0,zr.mG)(e,i);const u=document.createElement("span");u.innerText=". For more info, check out ";const d=document.createElement("span");return d.innerText=".",o.appendChild(r),o.appendChild(c),o.appendChild(l),o.appendChild(p),o.appendChild(u),o.appendChild(s),o.appendChild(d),o}(t,o,n,i,a))}}const Xr=window?window.document:null;"undefined"!=typeof window&&(window.UI={ns:b,acl:ca,aclControl:la,create:ua,createTypes:m,dom:Xr,icons:it.Pt,language:o,log:i,login:c,matrix:ma,media:ba,messageArea:va,infiniteMessageArea:kr,pad:p,participation:l,preferences:u,style:Ke,table:Dr,tabs:d,utils:a,widgets:r,initHeader:qr,initFooter:Yr})},565(e,t,n){"use strict";n.d(t,{E6:()=>o,bB:()=>s,mG:()=>r,nF:()=>c});var i=n(511),a=n(788);function o(){const{origin:e,pathname:t}=document.location,n="databrowser"===document.body?.dataset?.appShell,a=t.split("/").filter(Boolean),o=a[a.length-1]||"",s=/\.[^/]+$/.test(o);return n&&a.length>0&&!s?(0,i.sym)(`${e}/${a[0]}/`):(0,i.sym)(e).site()}async function s(e,t){try{if(!t.any(e,null,a.ns.ldp("Container"),e)){const n=(await t.fetcher.webOperation("GET",e.uri,t.fetcher.initFetchOptions(e.uri,{headers:{accept:"text/turtle"}}))).responseText;(0,i.parse)(n,t,e.uri,"text/turtle")}}catch(t){return console.error("Error loading pod "+e+": "+t),null}if(!t.holds(e,a.ns.rdf("type"),a.ns.space("Storage"),e))return console.warn("Pod "+e+" does not declare itself as a space:Storage"),null;const n=t.any(e,a.ns.solid("owner"),null,e)||t.any(null,a.ns.space("storage"),e,e);if(n){try{await t.fetcher.load(n.doc())}catch(e){return console.warn("Unable to load profile of pod owner "+n),null}return t.holds(n,a.ns.space("storage"),e,n.doc())||console.warn(`Pod owner ${n} does NOT list pod ${e} as their storage`),n}{const n=(0,i.sym)(`${e.uri}profile/card#me`);try{await t.fetcher.load(n)}catch(e){return console.error("Ooops. Guessed wrong pod owner webid {$guess} : can't load it."),null}return t.holds(n,a.ns.space("storage"),e,n.doc())?(console.warn("Using guessed pod owner webid but it links back."),n):null}}function r(e,t){return e.anyValue(t,a.ns.vcard("fn"),null,t.doc())||e.anyValue(t,a.ns.foaf("name"),null,t.doc())||t.uri}function c(e,t,n={}){let i,a,o,s=null,r=0;const c=function(){r=n.leading?Date.now():0,s=null,o=e.apply(i,a),s||(i=a=null)};return function(){const l=Date.now();r||n.leading||(r=l);const p=t-(l-r);return i=this,a=arguments,p<=0||p>t?(s&&(clearTimeout(s),s=null),r=l,o=e.apply(i,a),s||(i=a=null)):s||!1===n.trailing||(s=setTimeout(c,p)),o}}},580(e){"use strict";
|
|
21
|
+
const gs={p:BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),n:BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),h:BigInt(1),a:BigInt(0),b:BigInt(7),Gx:BigInt("0x79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"),Gy:BigInt("0x483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8")},bs={beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),basises:[[BigInt("0x3086d221a7d46bcde86c90e49284eb15"),-BigInt("0xe4437ed6010e88286f547fa90abfe4c3")],[BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),BigInt("0x3086d221a7d46bcde86c90e49284eb15")]]},xs=BigInt(0),vs=BigInt(2);const ys=$o(gs.p,{sqrt:function(e){const t=gs.p,n=BigInt(3),i=BigInt(6),a=BigInt(11),o=BigInt(22),s=BigInt(23),r=BigInt(44),c=BigInt(88),l=e*e*e%t,p=l*l*e%t,u=Lo(p,n,t)*p%t,d=Lo(u,n,t)*p%t,m=Lo(d,vs,t)*l%t,f=Lo(m,a,t)*m%t,h=Lo(f,o,t)*f%t,g=Lo(h,r,t)*h%t,b=Lo(g,c,t)*g%t,x=Lo(b,r,t)*h%t,v=Lo(x,n,t)*p%t,y=Lo(v,s,t)*f%t,w=Lo(y,i,t)*l%t,C=Lo(w,vs,t);if(!ys.eql(ys.sqr(C),e))throw new Error("Cannot find square root");return C}}),ws=ms(gs,{Fp:ys,endo:bs}),Cs={};function Es(e,...t){let n=Cs[e];if(void 0===n){const t=Za(function(e){if("string"!=typeof e)throw new TypeError("ascii string expected, got "+typeof e);return Uint8Array.from(e,(t,n)=>{const i=t.charCodeAt(0);if(1!==t.length||i>127)throw new RangeError(`string contains non-ASCII character "${e[n]}" with code ${i} at position ${n}`);return i})}(e));n=eo(t,t),Cs[e]=n}return Za(eo(n,...t))}const ks=e=>e.toBytes(!0).slice(1),As=e=>e%vs===xs;function Ts(e){const{Fn:t,BASE:n}=ws,i=t.fromBytes(e),a=n.multiply(i);return{scalar:As(a.y)?i:t.neg(i),bytes:ks(a)}}function js(e){const t=ys;if(!t.isValidNot0(e))throw new Error("invalid x: Fail if x ≥ p");const n=t.create(e*e),i=t.create(n*e+BigInt(7));let a=t.sqrt(i);As(a)||(a=t.neg(a));const o=ws.fromAffine({x:e,y:a});return o.assertValidity(),o}const _s=co;function Ls(...e){return ws.Fn.create(_s(Es("BIP0340/challenge",...e)))}function Ss(e){return Ts(e).bytes}function Rs(e,t,n=Ua(32)){const{Fn:i,BASE:a}=ws,o=Ya(e,void 0,"message"),{bytes:s,scalar:r}=Ts(t),c=Ya(n,32,"auxRand"),l=i.toBytes(r^_s(Es("BIP0340/aux",c))),p=Es("BIP0340/nonce",l,s,o),u=i.create(_s(p));if(0n===u)throw new Error("sign failed: k is zero");const d=a.multiply(u),m=As(d.y)?u:i.neg(u),f=ks(d),h=Ls(f,s,o),g=new Uint8Array(64);if(g.set(f,0),g.set(i.toBytes(i.create(m+h*r)),32),!Ns(g,o,s))throw new Error("sign: Invalid signature produced");return g}function Ns(e,t,n){const{Fp:i,Fn:a,BASE:o}=ws,s=Ya(e,64,"signature"),r=Ya(t,void 0,"message"),c=Ya(n,32,"publicKey");try{const e=js(_s(c)),t=_s(s.subarray(0,32));if(!i.isValidNot0(t))return!1;const n=_s(s.subarray(32,64));if(!a.isValidNot0(n))return!1;const l=Ls(a.toBytes(t),ks(e),r),p=o.multiplyUnsafe(n).add(e.multiplyUnsafe(a.neg(l))),{x:u,y:d}=p.toAffine();return!(p.is0()||!As(d)||u!==t)}catch(e){return!1}}const Is=(()=>{const e=e=>Ho(e=void 0===e?Ua(48):e,gs.n);return Object.freeze({keygen:as(e,Ss),getPublicKey:Ss,sign:Rs,verify:Ns,Point:ws,utils:Object.freeze({randomSecretKey:e,taggedHash:Es,lift_x:js,pointToBytes:ks}),lengths:Object.freeze({secretKey:32,publicKey:32,publicKeyHasPrefix:!1,signature:64,seed:48})})})();new TextDecoder("utf-8");const Bs=new TextEncoder,Ds="https://w3id.org/security#";function Os(e){const t=Za(Bs.encode(function(e){return JSON.stringify(e)}(e)));return Sa(t)}const Ms=e=>{let t=x.store.any(e,b.space("preferencesFile"),null,e.doc())?.value;if(t=t?.split("/").slice(0,-2).join("/"),!t)throw new Error(`prefererencesFile is expected to exist in ${e}`);return t},Fs=e=>{let t;try{t=`${Ms(e)}/profile/keys/publicKey.ttl`}catch(e){ve.z3(e)}return t};async function zs(e,t,n){try{await x.store.fetcher.load(t);const i=x.store.any(e,b.solid(n));return i?.value}catch(e){if(404===e.response.status){ve.Rm("createIfNotExists: doc does NOT exist, will create... "+t);try{await x.store.fetcher.webOperation("PUT",t,{data:"",contentType:"text/turtle"})}catch(e){throw ve.Rm("createIfNotExists doc FAILED: "+t+": "+e),e}return void delete x.store.fetcher.requested[t]}throw ve.Rm("createIfNotExists doc FAILED: "+t+": "+e),e}}async function Us(e,t){await x.store.fetcher.load(e);const n=x.store.any(x.store.sym(e),x.store.sym("http://www.iana.org/assignments/link-relations/acl"));if(!n)throw new Error("Key ACL doc not found!");try{await x.store.fetcher.webOperation("PUT",n.value,{data:t,contentType:"text/turtle"})}catch(e){if(404!==e?.response?.status)throw new Error(e);ve.Rm("delete "+n.value+" "+e.response.status)}}function Ps(e){return Sa(Is.getPublicKey(Fa(e)))}async function $s(e){await x.store.fetcher.load(e);const t=await Fs(e),n=await(e=>{let t;try{t=`${Ms(e)}/settings/keys/privateKey.ttl`}catch(e){ve.z3(e)}return t})(e),i=await async function(e,t){return await zs(e,t,"publicKey")}(e,t);let a=await async function(e,t){return await zs(e,t,"privateKey")}(e,n),o=!0;if(a&&i!==Ps(a)&&confirm("This is strange the publicKey is not valid for\n"+e?.uri+"'shall we repair keeping the private key ?")&&(o=!1),!a||!i||!o){let r=[],c=[];if(a||(a=Sa(Is.utils.randomSecretKey()),c=[g.st(e,b.solid("privateKey"),g.literal(a),x.store.sym(n))],await qs(n,[],c,e.uri)),!i||!o){r=[],i&&(r=[g.st(e,b.solid("publicKey"),g.lit(i),x.store.sym(t))],ve.Rm("delete invalid publicKey "+r));const n=Ps(a);c=[g.st(e,b.solid("publicKey"),g.literal(n),x.store.sym(t))],await qs(t,r,c)}const l=n.substring(0,n.lastIndexOf("/")+1);await Us(l,(s=e.uri,`\n@prefix : <#>.\n@prefix acl: <http://www.w3.org/ns/auth/acl#>.\n@prefix foaf: <http://xmlns.com/foaf/0.1/>.\n@prefix key: <./>.\n\n:ReadWrite\n a acl:Authorization;\n acl:accessTo key:;\n acl:default key:;\n acl:agent <${s}>;\n acl:mode acl:Read, acl:Write.\n`))}var s;return a}async function qs(e,t,n,i=""){await(async e=>{await x.store.fetcher.load(e);const t=x.store.any(x.store.sym(e),x.store.sym("http://www.iana.org/assignments/link-relations/acl"));if(t)try{const e=await x.store.fetcher.webOperation("DELETE",t.value);ve.Rm("delete keyAcl"+t.value+" "+e.status)}catch(e){if(404!==e.response.status)throw new Error(e);ve.Rm("delete keyAcl"+t.value+" "+e.response.status)}})(e),await x.store.updater.updateMany(t,n);const a=((e,t)=>{let n="acl:agentClass foaf:Agent";return t?.length&&(n=`acl:agent <${t}>`),`\n@prefix foaf: <http://xmlns.com/foaf/0.1/>.\n@prefix acl: <http://www.w3.org/ns/auth/acl#>.\n<#Read>\n a acl:Authorization;\n ${n};\n acl:accessTo <${e.split("/").pop()}>;\n acl:mode acl:Read.\n`})(e,i);await Us(e,a)}class Hs{constructor(e,t){this.channel=e,this.channelRoot=e.doc(),this.options=t,this.dateFolder=new wa(this.channelRoot,"chat.ttl"),this.div=null}async createMessage(e){return this.updateMessage(e)}async updateMessage(e,t=null,n,i=null){const a=[],o=new Date,s=""+o.getTime(),r=g.term(o),c=t?t.doc():this.dateFolder.leafDocumentFromDate(o),l=x.store.sym(c.uri+"#Msg"+s),p=x.authn.currentUser(),u={id:"",created:"",dateDeleted:"",content:"",maker:"",sig:""};if(u.id=l.uri,t){const e=x.store.any(t,b.foaf("maker"));if(e.uri!==p.uri){const t="Error you cannot delete/edit a message from someone else : \n"+e.uri;throw ve.R8(t),alert(t),new Error(t)}{const e=await Vs(t);a.push(g.st(e,b.dct("isReplacedBy"),l,c));const i=x.store.any(e,b.sioc("has_reply"));i&&a.push(g.st(l,b.sioc("has_reply"),i,c)),n&&a.push(g.st(l,b.schema("dateDeleted"),r,c))}}else a.push(g.st(this.channel,b.wf("message"),l,c));if(a.push(g.st(l,b.sioc("content"),x.store.literal(e),c)),u.content=e,a.push(g.st(l,b.dct("created"),r,c)),u.created=r.value,p){a.push(g.st(l,b.foaf("maker"),p,c)),u.maker=p.uri;const e=function(e,t){return Sa(Is.sign(Fa(Os(e)),Fa(t)))}(u,await $s(p));a.push(g.st(l,g.sym(`${Ds}proofValue`),g.lit(e),c))}i&&(a.push(g.st(i,b.sioc("has_member"),l,c)),i.doc().sameTerm(l.doc())||a.push(g.st(i,b.sioc("has_member"),l,i.doc())));try{await x.store.updater.updateMany([],a)}catch(e){const t="Error saving chat message: "+e;throw ve.R8(t),alert(t),new Error(t)}return l}async deleteMessage(e){return this.updateMessage("(message deleted)",e,!0)}async createThread(e){const t=x.store.each(e,b.sioc("has_reply"),null,e.doc()).filter(e=>x.store.holds(e,b.rdf("type"),b.sioc("Thread"),e.doc()));if(t.length>0)return t[0];const n=g.sym(e.uri+"-thread"),i=[g.st(n,b.rdf("type"),b.sioc("Thread"),n.doc()),g.st(e,b.sioc("has_reply"),n,n.doc())];return await x.store.updater.update([],i),n}}async function Gs(e){const t=[e],n={};n[e.uri]=!0;let i=e;for(;;){const e=x.store.any(null,b.dct("isReplacedBy"),i,i.doc());if(!e||n[e.uri])break;await x.store.fetcher.load(e),t.unshift(e),n[e.uri]=!0,i=e}for(i=e;;){const e=x.store.any(i,b.dct("isReplacedBy"),null,i.doc());if(!e||n[e.uri])break;t.push(e),n[e.uri]=!0,i=e}return t}async function Vs(e){let t=e;const n={};for(;t;){if(n[t.uri])return ve.z3("mostRecentVersion: verion loop"+e),e;n[t.uri]=!0,e=t,await x.store.fetcher.load(e),t=x.store.any(e,b.dct("isReplacedBy"),null,e.doc())}return e}function Ws(e){return x.store.holds(e,b.schema("dateDeleted"),null,e.doc())}const Js=x.solidLogicSingleton.store;function Qs(e,t,n,i,a,o){t.setAttribute("style",Ke.participantsStyle);const s=function(n){const i=Js.any(n,b.wf("participant"));let a;if(!i)return a=e.createElement("tr"),a.textContent="???",a;const s=Js.anyValue(n,b.ui("backgroundColor"))||Ze,r=e.createElement("div");r.setAttribute("style",Ke.participantsBlock),r.style.backgroundColor=s,a=Ut(e,null,i,o),t.appendChild(a);const c=e.createElement("td");return c.setAttribute("style",Ke.personTableTD),c.appendChild(r),a.insertBefore(c,a.firstChild),a},r=function(){const e=Js.each(i,b.wf("participation")).map(function(e){return(0,ve.Rm)("in participants"),[Js.anyValue(e,b.cal("dtstart"))||"9999-12-31",e]});e.sort();const n=e.map(function(e){return e[1]});Z(t,n,s)};return t.refresh=r,r(),t}function Zs(e,t,n){return new Promise(function(i,a){if(!n)throw new Error("No user id");const o=Js.each(e,b.wf("participation")).filter(function(e){return Js.holds(e,b.wf("participant"),n)});if(o.length>1){const e=[];for(const t of o){const n=Js.anyValue(t,b.cal("dtstart"));n&&e.push([n,t])}e.sort(),ve.R8("Multiple participation objects, picking earliest, in "+t),i(e[0][1])}if(o.length)i(o[0]);else{const o=Ei(t),s=[(0,g.st)(e,b.wf("participation"),o,t),(0,g.st)(o,b.wf("participant"),n,t),(0,g.st)(o,b.cal("dtstart"),new Date,t),(0,g.st)(o,b.ui("backgroundColor"),tr(n),t)];Js.updater.update([],s,function(e,t,n){t?i(o):a(new Error("Error recording your participation: "+n))}),i(o)}})}function Ys(e,t,n){const i=x.authn.currentUser();if(!i)return;const a=Js.each(e,b.wf("participation")).filter(function(e){return Js.holds(e,b.wf("participant"),i)});if(a.length>1)throw new Error("Multiple records of your participation");if(a.length)return a[0];{if(!Js.updater.editable(t))return ve.Rm("Not recording participation, as no write access as "+i+" to "+t),null;const a=Ei(t),o=[(0,g.st)(e,b.wf("participation"),a,t),(0,g.st)(a,b.wf("participant"),i,t),(0,g.st)(a,b.cal("dtstart"),new Date,t),(0,g.st)(a,b.ui("backgroundColor"),tr(i),t)];return Js.updater.update([],o,function(e,t,i){if(!t)throw new Error("Error recording your participation: "+i);n&&n.refresh&&n.refresh()}),a}}function Ks(e,t,n,i,a,o){const s=e.createElement("table");t.appendChild(s),Qs(e,s,0,i,0,o);try{Ys(i,n,s)}catch(n){t.appendChild(nt(e,"Error recording your participation: "+n))}return s}const Xs=x.solidLogicSingleton.store,er=(0,g.Namespace)("http://www.w3.org/ns/pim/pad#");function tr(e){return e&&e.uri?"#"+(16777215&(t=e.uri,t.split("").reduce(function(e,t){return(e=(e<<5)-e+t.charCodeAt(0))&e},0))|12632256).toString(16):"#ffffff";var t}function nr(e,t,n,i,a){const o=(a=a||{}).exists,s=e.createElement("table"),r=Xs;if(i&&!i.uri)throw new Error("UI.pad.notepad: Invalid userid");const c=Xs.updater,l=(0,g.Namespace)("http://www.w3.org/ns/pim/pad#");s.setAttribute("style",Ke.notepadStyle);let p=null,u=null;if(a.statusArea){const t=a.statusArea.appendChild(e.createElement("table")).appendChild(e.createElement("tr"));p=t.appendChild(e.createElement("td")),u=t.appendChild(e.createElement("td")),p&&p.setAttribute("style",Ke.upstreamStatus),u&&u.setAttribute("style",Ke.downstreamStatus)}const d=function(t,n=!1){(0,ve.Rm)(t),a.statusArea&&(n?p:u).appendChild(nt(e,t,"pink"))},m=function(e){a.statusArea&&(a.statusArea.innerHTML="")},f=function(e,t,n){const i=e.subject;t=t||"";const a=Ke.baseStyle,o=Ke.headingCore,s=Ke.headingStyle,c=r.any(i,b.dc("author"));if(!t&&c){t="color: "+(n?"#888":"black")+"; background-color: "+tr(c)+";"}let p=r.any(i,l("indent"));p=p?p.value:0;const u=p>=0?a+"text-indent: "+3*p+"em;":o+s[-1-p];e.setAttribute("style",u+t)},h=function(e){const i=e.subject;if(!i)throw new Error("No chunk for line to be deleted!");const a=r.any(void 0,l("next"),i),o=r.any(i,l("next"));if(a.sameTerm(n)&&o.sameTerm(n))return void(0,ve.Rm)("You can't delete the only line.");const s=r.statementsMatching(i,void 0,void 0,t).concat(r.statementsMatching(void 0,void 0,i,t)),p=[(0,g.st)(a,l("next"),o,t)];if(i instanceof g.NamedNode){const e=i.uri.slice(-4);(0,ve.Rm)("Deleting line "+e)}if(!c)throw new Error("have no updater");c.update(s,p,function(t,n,a,o){if(n){const t=e.parentNode;if(t){const e=t.previousSibling;t.parentNode&&t.parentNode.removeChild(t),e&&e.firstChild&&e.firstChild.focus()}}else if(o&&409===o.status)f(e,"color: black; background-color: #ffd;"),e.state=0,W(),setTimeout(function(){A()},1e3);else{(0,ve.Rm)(" removePart FAILED "+i+": "+a),(0,ve.Rm)(" removePart was deleting :'"+s),f(e,"color: black; background-color: #fdd;");const t=o?o.status:" [no response field] ";d("Error "+t+" saving changes: "+String(a))}})},x=function(e,n){let i=null;e.addEventListener("keydown",function(i){if(!c)throw new Error("no updater");let a,o;switch(i.keyCode){case 13:{const t=i.shiftKey;if((0,ve.Rm)("enter"),t?(o=r.any(void 0,l("next"),n),a="newlinesAfter"):(o=r.any(n,l("next")),a="newlinesBefore"),o[a]=o[a]||0,o[a]+=1,o[a]>1)return void(0,ve.Rm)(" queueing newline queue = "+o[a]);(0,ve.Rm)(" go ahead line before "+o[a]),y(e,t);break}case 8:if(0===e.value.length)switch((0,ve.Rm)("Delete key line "+n.uri.slice(-4)+" state "+e.state),e.state){case 1:case 2:return void(e.state=4);case 3:case 4:return;case void 0:case 0:e.state=3,h(e),i.preventDefault();break;default:throw new Error("pad: Unexpected state "+e)}break;case 9:{const a=i.shiftKey?-1:1;!function(e,n,i){const a=r.statementsMatching(n,l("indent")),o=a.length?Number(a[0].object.value):0;if(o+i<-3)return;const s=o+i,p=(0,g.st)(n,l("indent"),s,t);if(!c)throw new Error("no updater");c.update(a,p,function(n,i,a){i?f(e):((0,ve.Rm)("Indent change FAILED '"+s+"' for "+t+": "+a),f(e,"color: black; background-color: #fdd;"),c.requestDownstreamAction(t,A))})}(e,n,a),i.preventDefault();break}case 27:(0,ve.Rm)("escape"),c.requestDownstreamAction(t,A),i.preventDefault();break;case 38:e.parentNode.previousSibling&&(e.parentNode.previousSibling.firstChild.focus(),i.preventDefault());break;case 40:e.parentNode.nextSibling&&(e.parentNode.nextSibling.firstChild.focus(),i.preventDefault())}});const a=function(e){const n=e.subject;f(e,void 0,!0);const i=r.any(n,b.sioc("content")).value,o=[(0,g.st)(n,b.sioc("content"),i,t)];let s;e.value&&(s=[(0,g.st)(n,b.sioc("content"),e.value,t)]);const l=e.value;if(e.lastSent&&i!==e.lastSent&&console.warn("Out of order, last sent expected '"+i+"' but found '"+e.lastSent+"'"),e.lastSent=l,!c)throw new Error("no updater");c.update(o,s,function(n,o,s,r){if(o)m(),f(e),(0,ve.Rm)(" Patch ok '"+i+"' -> '"+l+"' "),4===e.state?(e.state=3,h(e)):3===e.state||(2===e.state?(e.state=1,a(e)):e.state=0);else if((0,ve.Rm)(" patch FAILED "+r.status+" for '"+i+"' -> '"+l+"': "+s),409===r.status)f(e,"color: black; background-color: #fdd;"),e.state=0,W(),setTimeout(function(){c.requestDownstreamAction(t,A)},1e3);else{f(e,"color: black; background-color: #fdd;");const t=r?.status;t&&502!==t&&503!==t?(e.state=0,d(" Error "+t+" sending data: "+s,!0),W()):(e.lastSent=void 0,e.state=0,setTimeout(()=>{0!==e.state&&void 0!==e.state||(e.state=1,a(e))},2e3))}})};e.addEventListener("input",function(t){switch(f(e,void 0,!0),(0,ve.Rm)("Input event state "+e.state+" value '"+e.value+"'"),e.state){case 3:case 4:case 2:return;case 1:return void(e.state=2);case 0:case void 0:null!==i&&clearTimeout(i),i=setTimeout(()=>{i=null,0!==e.state&&void 0!==e.state||(e.state=1,a(e))},400)}})},v=function(t,n,a){let o=r.any(n,b.sioc("content"));o=o?o.value:"";const c=e.createElement("tr");a?s.insertBefore(c,t):t&&t.nextSibling?s.insertBefore(c,t.nextSibling):s.appendChild(c);const l=c.appendChild(e.createElement("input"));return l.subject=n,l.setAttribute("type","text"),l.value=o,i?(f(l,""),x(l,n)):(f(l,"color: #222; background-color: #fff"),(0,ve.Rm)("Note can't add listeners - not logged in")),l},y=function(e,a){const o=Xs;let s,r,p,u,d,m=0,h=null;e?("input"!==e.tagName.toLowerCase()&&(0,ve.Rm)("return pressed when current document is: "+e.tagName),s=e.subject,m=o.any(s,l("indent")),m=m?Number(m.value):0,a?(r=o.any(void 0,l("next"),s),p=s,u=r,h="newlinesAfter"):(r=s,p=o.any(s,l("next")),u=p,h="newlinesBefore"),d=e.parentNode):(r=n,p=n,d=void 0);const x=Ei(t),w=x.uri.slice(-4),C=[(0,g.st)(r,l("next"),p,t)],E=[(0,g.st)(r,l("next"),x,t),(0,g.st)(x,l("next"),p,t),(0,g.st)(x,b.dc("author"),i,t),(0,g.st)(x,b.sioc("content"),"",t)];if(m>0&&E.push((0,g.st)(x,l("indent"),m,t)),(0,ve.Rm)(" Fresh chunk "+w+" proposed"),!c)throw new Error("no updater");c.update(C,E,function(e,t,n,i){if(t){const e=v(d,x,a);f(e),e.focus(),h&&((0,ve.Rm)(" Fresh chunk "+w+" updated, queue = "+u[h]),u[h]-=1,u[h]>0&&((0,ve.Rm)(" Implementing queued newlines = "+p.newLinesBefore),y(e,a)))}else(0,ve.Rm)(" ERROR writing new line "+w+": "+n)})},w=function(){const e={};let t=0;function i(e){d(e),t++}if(!r.the(n,l("next")))return i("No initial next pointer"),!1;let a,o=n;for(;a=r.the(o,l("next")),a||i("No next pointer from "+o),!a.sameTerm(n);){o=a;const t=a.uri.split("#")[1];if(e[a.uri])return i("Loop!"),!1;e[a.uri]=!0;let n=r.each(a,l("next")).length;1!==n&&i("Should be 1 not "+n+" next pointer for "+t),n=r.each(a,l("indent")).length,n>1&&i("Should be 0 or 1 not "+n+" indent for "+t),n=r.each(a,b.sioc("content")).length,1!==n&&i("Should be 1 not "+n+" contents for "+t),n=r.each(a,b.dc("author")).length,1!==n&&i("Should be 1 not "+n+" author for "+t);r.statementsMatching(void 0,b.sioc("contents")).forEach(function(t){e[t.subject.value]||i("Loose chunk! "+t.subject.value)})}return!t},C=function(){if(1!==r.each(n,l("next")).length){const e="Pad: Inconsistent data - NEXT pointers: "+r.each(n,l("next")).length;return(0,ve.Rm)(e),void(a.statusArea&&(a.statusArea.textContent+=e))}let e;const t=[];for(let e=r.the(n,l("next"));!e.sameTerm(n);e=r.the(e,l("next")))for(let n=0;n<s.children.length;n++){const i=s.children[n];i.firstChild&&i.firstChild.subject.sameTerm(e)&&(t[e.uri]=i.firstChild)}for(let n=s.children.length-1;n>=0;n--)e=s.children[n],t[e.firstChild.subject.uri]||s.removeChild(e);e=s.firstChild;for(let i=r.the(n,l("next"));!i.sameTerm(n);i=r.the(i,l("next"))){const n=r.any(i,b.sioc("content")).value;if(e&&t[i.uri]){const t=e.firstChild;n!==t.value&&(t.value=n),f(t),t.state=0,delete t.lastSent,e=e.nextSibling}else v(e,i,!0)}},E=function(e){if(e.refresh)e.refresh();else for(let t=0;t<e.children.length;t++)E(e.children[t])};let k=!1;const A=function(){if(k)return void(0,ve.Rm)(" Already reloading - stop");k=!0;let e=1e3;const n=function(){if((0,ve.Rm)("try reload - timeout = "+e),!c)throw new Error("no updater");c.reload(c.store,t,function(i,a,o){k=!1,i?((0,ve.Rm)(" reloaded OK"),m(),w()?E(s):d("CONSISTENCY CHECK FAILED")):0===o.status?(d("Network error refreshing the pad. Retrying in "+e/1e3),k=!0,e*=2,setTimeout(n,e)):d("Error "+o.status+"refreshing the pad:"+a+". Stopped. "+t)})};n()};if(s.refresh=C,s.reloadAndSync=A,i||(0,ve.Rm)("Warning: must be logged in for pad to be edited"),o)(0,ve.Rm)("Existing pad."),w()?(C(),r.holds(n,l("next"),n)&&y()):(0,ve.Rm)(s.textContent="Inconsistent data. Abort");else{(0,ve.Rm)("No pad exists - making new one.");const e=[(0,g.st)(n,b.rdf("type"),l("Notepad"),t),(0,g.st)(n,b.dc("author"),i,t),(0,g.st)(n,b.dc("created"),new Date,t),(0,g.st)(n,l("next"),n,t)];if(!c)throw new Error("no updater");c.update([],e,function(e,t,n){t?((0,ve.Rm)("Initial pad created"),y()):d(n||"")})}return s}function ir(e,t){const n=[];for(let i=t.the(e,er("next"));!i.sameTerm(e);i=t.the(i,er("next")))n.push(i);return n}function ar(e){return e.replace("&","&").replace("<","<").replace(">",">")}function or(e,t){const n=ir(e,t);let i="<html>\n <head>\n";const a=t.anyValue(e,b.dct("title"));a&&(i+=` <title>${ar(a)}</title>\n`),i+=" </head>\n <body>\n";let o=0;function s(e){for(;o>e;o--)i+="</ul>\n"}return n.forEach(e=>{const n=t.anyJS(e,er("indent")),a=t.anyJS(e,b.sioc("content"));if(!a)return;const r=ar(a);if(n<0){s(0);const e=n>=-3?4+n:1;i+=`\n<h${e}>${r}</h${e}>\n`}else n>0?(s(n),function(e){for(;o<e;o++)i+="<ul>\n"}(n),i+=`<li>${r}</li>\n`):(s(n),i+=`<p>${r}</p>\n`)}),s(0),i+=" </body>\n</html>\n",i}const sr={icons:it.Pt,ns:b,media:ba,pad:p,style:Ke,utils:a,widgets:r},rr=g.Namespace("http://www.w3.org/2002/01/bookmark#"),cr=U,lr=window.document||null;function pr(e,t){return new Promise(function(n,i){x.store.updater.update(e,t,function(e,t,a){t?n():i(new Error(a))})})}async function ur(e,t,n){await x.store.fetcher.load(e.bookmarkDocument);const i=x.store.each(null,rr("recalls"),t,e.bookmarkDocument);if(i.length){if(!confirm("Delete bookmark on this?"+i.length))return;for(let e=0;e<i.length;e++)try{await pr(x.store.connectedStatements(i[e]),[]),n.style.backgroundColor="white",ve.Rm("Bookmark deleted: "+i[e])}catch(e){ve.z3("Cant delete bookmark:"+e),ve.R8("Cannot delete bookmark:"+e)}}else{const i=await async function(e,t){let n="";const i=x.authn.currentUser();if(!i)throw new Error("Must be logged on to add Bookmark");const a=x.store.any(t,b.foaf("maker"));n=cr(a)+": "+x.store.anyValue(t,b.sioc("content")).slice(0,80);const o=e.bookmarkDocument,s=sr.widgets.newThing(o,n),r=[g.st(o,sr.ns.dct("references"),s,o),g.st(s,sr.ns.rdf("type"),rr("Bookmark"),o),g.st(s,sr.ns.dct("created"),new Date,o),g.st(s,rr("recalls"),t,o),g.st(s,sr.ns.foaf("maker"),i,o),g.st(s,sr.ns.dct("title"),n,o)];try{await pr([],r)}catch(e){const t="Making bookmark: "+e;return ve.R8(t),null}return s}(e,t);n.style.backgroundColor="yellow",ve.Rm("Bookmark added: "+i)}}const dr=window.document,mr={};async function fr(e,t,n,i){async function a(t){c.value===x.store.any(e,b.foaf("maker")).value&&(s(),await async function(e,t,n,i){const a=e.parentNode,o=Cr(n,a,i,n.options,await Vs(t));a.insertBefore(o,e),o.originalRow=e,e.style.visibility="hidden"}(t,e,i,n))}const o=dr.createElement("div");if(await Vs(e).value===b.schema("dateDeleted").value)return o;function s(){o.parentElement.parentElement.removeChild(o.parentElement)}async function r(e){await x.store.updater.update(x.store.connectedStatements(e),[])}let c=x.authn.currentUser();function l(e,n,i,a,o,s){function c(){l.style.backgroundColor=d?"yellow":"white"}const l=Ot(dr,i,U(a),async function(i){if(d)await r(d),d=null,c();else{d=Ei(o);const i=[g.st(d,b.schema("agent"),e.me,o),g.st(d,b.rdf("type"),a,o),g.st(d,b.schema("target"),n,o)];if(await x.store.updater.update([],i),c(),s){let e=!1;for(let t=0;t<s.length;t++){const n=p(s[t]);n&&(await r(n),e=!0)}e&&Gt(t)}}});function p(t){const i=x.store.each(null,b.schema("agent"),e.me,o).filter(e=>x.store.holds(e,b.rdf("type"),t,o)).filter(e=>x.store.holds(e,b.schema("target"),n,o));return i.length?i[0]:null}function u(){d=p(a),c()}let d;return l.refresh=u,u(),l}if(c&&x.store.holds(e,b.foaf("maker"),c)&&(o.appendChild(Dt(dr,o,"message",async function(){const a=x.store.any(e,b.foaf("maker"));if(c)if(c.sameTerm(a)){try{await i.deleteMessage(e)}catch(e){const i="Error deleting messaage "+e;ve.R8(i),alert(i),(n.statusArea||t.parentNode).appendChild(nt(dr,i))}t.parentNode.removeChild(t)}else alert("You can't delete the message, you are not logged in as the author, "+a);else alert("You can't delete the message, you are not logged in.");s()})),o.appendChild(Ot(dr,it.Pt.iconBase+"noun_253504.svg","edit",()=>a(t)))),async function(e,t){let n;if(e.bookmarkDocument)return n=sr.widgets.button(lr,sr.icons.iconBase+"noun_45961.svg",cr(rr("Bookmark")),()=>{ur(e,t,n)}),n.target=t,await async function(t){await x.store.fetcher.load(e.bookmarkDocument);const n=x.store.any(null,rr("recalls"),t.target,e.bookmarkDocument);t.style=sr.style.buttonStyle,n&&(t.style.backgroundColor="yellow")}(n),n}(n).then(e=>{e&&o.appendChild(e)}),c=x.authn.currentUser(),c&&await Vs(e).value!==b.schema("dateDeleted").value){const t={me:c,dom:dr,div:o};o.appendChild(l(t,e,it.Pt.iconBase+"noun_1384132.svg",b.schema("AgreeAction"),e.doc(),[b.schema("DisagreeAction")])),o.appendChild(l(t,e,it.Pt.iconBase+"noun_1384135.svg",b.schema("DisagreeAction"),e.doc(),[b.schema("AgreeAction")]))}x.store.any(e,b.dct("created"))&&o.appendChild(Ot(dr,it.Pt.iconBase+"noun-reply-5506924.svg","Reply in thread",async()=>{await async function(){const t=await i.createThread(e),a=n.chatOptions;if(!a)throw new Error("replyInThread: missing options");a.showThread(t,a),s()}()}));const p=o.appendChild(Mt(dr));return p.style.float="right",p.firstChild.style.opacity="0.3",p.addEventListener("click",s),o}mr[b.schema("AgreeAction")]="👍",mr[b.schema("DisagreeAction")]="👎",mr[b.schema("EndorseAction")]="⭐️",mr[b.schema("LikeAction")]="❤️";const hr=window.document,gr=Ke.messageBodyStyle,br=U;const xr=function(e,t){const n=hr.createElement("a");return t&&t.uri&&(n.setAttribute("href",t.uri),n.addEventListener("click",Wt,!0),n.setAttribute("style","color: #3B5998; text-decoration: none; ")),n.textContent=e,n};function vr(e){const t=x.store.any(e,b.foaf("nick"));return t?""+t.value:""+br(e)}function yr(e,t,n,i){const a=e.appendChild(xr(vr(t),t));t.uri&&x.store.fetcher.nowOrWhenFetched(t.doc(),void 0,function(e,n){a.textContent=vr(t)}),e.appendChild(hr.createElement("br")),e.appendChild(xr(n,i))}async function wr(e,t,n,i,a){let o=!1;const s="1"===i.colorizeByAuthor||!0===i.colorizeByAuthor,r=x.store.any(t,b.foaf("maker")),c=x.store.any(t,b.dct("created")),l=await Vs(t),p=x.store.any(l,b.foaf("maker")),u=r.uri===p?.uri?l:t,d=x.store.any(u,b.sioc("content")),m=await Gs(u);m.length>1&&ve.Rm("renderMessageRow versions: ",m.join(", "));const f=m.map(e=>x.store.each(e,b.sioc("has_reply"))).flat();let h=null;const g=[];for(const e of f)x.store.holds(e,b.rdf("type"),b.sioc("Thread"))?(h=e,ve.Rm("renderMessageRow: found thread: "+h)):g.push(e);g.length>1&&ve.Rm("renderMessageRow: found normal replies: ",g),h||(h=x.store.any(null,b.sioc("has_member"),t));const v=x.store.any(u,$rdf.sym(`${Ds}proofValue`)),y={id:"",created:"",dateDeleted:"",content:"",maker:"",sig:""};y.id=u.uri,y.created=x.store.any(u,b.dct("created")).value,y.content=d.value,y.maker=r.uri,v?.value?async function(e){await x.store.fetcher.load(e);const t=await Fs(e);try{await x.store.fetcher.load(t);const n=x.store.any(e,b.solid("publicKey"));return n?.value}catch(e){return}}(r).then(e=>{e||ve.R8("message is signed but "+r.uri+" is missing publicKey");e?.match(/[0-9A-Fa-f]{6}/g)?v?.value&&!function(e,t,n){return Is.verify(Fa(e),Fa(Os(t)),Fa(n))}(v?.value,y,e)&&ve.R8("invalid signature\n"+y.id):ve.R8("invalid publicKey hex string\n"+r.uri+"\n"+e)}):(o=!0,ve.R8(u.uri+" is unsigned"));const w=await async function(e){let t=e;const n={};for(;t;){if(n[t.uri])return ve.z3("originalVersion: verion loop"+e),e;n[t.uri]=!0,e=t,await x.store.fetcher.load(e),t=x.store.any(null,b.dct("isReplacedBy"),e,e.doc())}return e}(t),C=!t.sameTerm(w),E=x.store.the(w,b.dct("created"),null,w.doc())||x.store.the(t,b.dct("created"),null,t.doc()),k=hr.createElement("tr");o&&k.setAttribute("style","background-color: red"),k.AJAR_date=E.value,k.AJAR_subject=t;const A=hr.createElement("td");if(k.appendChild(A),i.authorDateOnLeft)yr(A,r,Ct(E.value),t);else{const e=hr.createElement("img");e.setAttribute("style","max-height: 2.5em; max-width: 2.5em; border-radius: 0.5em; margin: auto;"),It(e,r),A.appendChild(e)}let T=Ct(E.value);C&&(T+=" ... "+Ct(c.value));const j=k.appendChild(hr.createElement("td"));i.authorDateOnLeft||function(e,t,n,i){const a=e.appendChild(xr(br(t),t));t.uri&&x.store.fetcher.nowOrWhenFetched(t.doc(),void 0,function(e,n){a.textContent=vr(t)});const o=e.appendChild(xr(n,i));o.style.fontSize="80%",o.style.marginLeft="1em",e.appendChild(hr.createElement("br"))}(j,r,T,t);const _=d?d.value.trim():"??? no content?";let L=null;if(/^https?:\/[^ <>]*$/i.test(_)){if(/\.(gif|jpg|jpeg|tiff|png|svg)$/i.test(_)&&i.expandImagesInline){const e=function(e,t){const n=hr.createElement("img");let i="10";t.inlineImageHeightEms&&(i=(""+t.inlineImageHeightEms).trim()),n.setAttribute("style","max-height: "+i+"em; border-radius: 1em; margin: 0.7em;"),e&&n.setAttribute("src",e);const a=hr.createElement("a");return a.setAttribute("href",e),a.setAttribute("target","images"),a.appendChild(n),et(n,$rdf.sym(e)),a}(_,i);j.appendChild(e)}else{const e=j.appendChild(hr.createElement("a"));L=e.appendChild(hr.createElement("p")),e.href=_,L.textContent=_,j.appendChild(e)}}else L=hr.createElement("p"),j.appendChild(L),L.textContent=_;if(L){const e=s?tr(r):function(e){return e?"#e8ffe8":"white"}(n);L.setAttribute("style",gr+"background-color: "+e+";")}const S=await async function(e,t){const n=dr.createElement("span");async function i(){if(n.innerHTML="",Ws(e))return n;const i=(await Gs(e)).map(e=>x.store.each(null,b.schema("target"),e,t)).flat();if(0===i.length)return n;const a=i.map(e=>[x.store.any(e,b.rdf("type"),null,t),x.store.any(e,b.sioc("content"),null,t),x.store.any(e,b.schema("agent"),null,t)]);a.sort(),a.forEach(e=>{const[t,i,a]=e;let o;a?(o=dr.createElement("a"),o.setAttribute("href",a.uri)):o=dr.createTextNode(""),o.textContent=i||mr[t]||"⬜️",n.appendChild(o)})}return i().then(ve.Rm("sentimentStripLinked: sentimentStripLinked async refreshed")),n.refresh=i,n}(t,t.doc());S.children.length&&(j.appendChild(hr.createElement("br")),j.appendChild(S));const R=hr.createElement("td");k.appendChild(R);const N=Ot(hr,it.Pt.iconBase+"noun_243787.svg","...");return R.appendChild(N),N.addEventListener("click",async function(n){if(k.toolTR)return k.parentNode.removeChild(k.toolTR),void delete k.toolTR;const o=hr.createElement("tr"),s=await fr(t,k,{...a,chatOptions:i},e);s.style="border: 0.05em solid #888; border-radius: 0 0 0.7em 0.7em; border-top: 0; height:3.5em; background-color: #fff;",k.nextSibling?k.parentElement.insertBefore(o,k.nextSibling):k.parentElement.appendChild(o),k.toolTR=o,o.appendChild(hr.createElement("td"));const r=o.appendChild(hr.createElement("td"));o.appendChild(hr.createElement("td")),r.appendChild(s)}),h&&i.showThread&&R.appendChild(Ot(hr,it.Pt.iconBase+"noun_1180164.svg","see thread",e=>{i.showThread(h,i)})),k}function Cr(e,t,n,i,a){async function o(e){await s(h.value,!0)}async function s(o,s){let r;s&&(h.setAttribute("style",gr+"color: #bbb;"),h.disabled=!0);try{r=await e.updateMessage(o,a,null,i.thread)}catch(e){return void(n.statusArea||u).appendChild(nt(hr,"Error writing message: "+e))}await async function(o){if(await Er(e,t,o,!1,i,n),a){const e=u.originalRow;e.parentNode?e.parentNode.removeChild(e):(ve.R8("No parentNode on old message "+e.textContent),e.style.backgroundColor="#fee",e.style.visibility="hidden"),u.parentNode.removeChild(u)}else s&&(h.value="",h.setAttribute("style",gr),h.disabled=!1,h.scrollIntoView(i.newestFirst),h.focus(),h.select())}(r)}function r(e){const n=t.chatDocument.dir().uri;tt(x.store.fetcher,e,n+"Files",n+"Pictures",async function(e,t){await s(t)})}const c=async function(e){for(const t of e)await s(t)};let l,p;a?(l=x.store.anyValue(a,b.dct("created"),null,a.doc()),p=it.Pt.iconBase+"noun_1180158.svg"):(p=it.Pt.iconBase+"noun_383448.svg",l="9999-01-01T00:00:00Z");const u=hr.createElement("tr"),d=hr.createElement("td"),m=hr.createElement("td"),f=hr.createElement("td");let h,v;u.appendChild(d),u.appendChild(m),u.appendChild(f),u.AJAR_date=l;return Di({div:m,dom:hr}).then(t=>{!function(){if(i.menuHandler){const e=Ot(hr,it.Pt.iconBase+"noun_243787.svg","More");e.setAttribute("style",Ke.buttonStyle+"float: right;"),f.appendChild(e)}i.menuHandler;const t=x.authn.currentUser();if(yr(d,t,"",null),h=hr.createElement("textarea"),m.innerHTML="",m.appendChild(h),h.rows=3,a&&(h.value=x.store.anyValue(a,b.sioc("content"),null,a.doc())),h.setAttribute("style",gr+"background-color: #eef;"),h.addEventListener("keydown",async function(e){"Enter"===e.code&&(!e.shiftKey&&!i.shiftEnterSendsMessage||e.shiftKey&&i.shiftEnterSendsMessage)&&await o()},!1),Xe(h,c,r),f.innerHTML="",v=Ot(hr,p,"Send"),v.style.float="right",v.addEventListener("click",e=>o(),!1),f.appendChild(v),a){const e=f.appendChild(Mt(hr));e.style.float="left",e.addEventListener("click",e=>function(e){e.originalRow.style.visibility="visible",e.parentNode.removeChild(e)}(u),!1),f.appendChild(e)}const n=e.dateFolder.leafDocumentFromDate(new Date);let l;m.appendChild(ba.cameraButton(hr,x.store,function(){return l=$rdf.sym(n.dir().uri+"Image_"+Date.now()+".png"),l},async function(e){e&&await s(e.uri)})),Ys(e.channel,e.channel.doc())}(),Object.assign(t,n),async function(e){const t=rr("Bookmark");if(await Fi(e,t,!0),e.instances&&e.instances.length>0)e.bookmarkDocument=e.instances[0],e.instances.length>1&&ve.R8("More than one bookmark file! "+e.instances);else if(e.publicProfile){const n=g.sym(e.publicProfile.dir().uri+"bookmarks.ttl");try{ve.Rm("Creating new bookmark file "+n),await x.store.fetcher.createIfNotExists(n)}catch(t){return ve.R8("Can't make fresh bookmark file:"+t),e}await x.createTypeIndexLogic.registerInTypeIndex(n,e.index,t),e.bookmarkDocument=n}else ve.R8("You seem to have no bookmark file, nor even a profile file!");return e}(t).then(e=>{})}),u}async function Er(e,t,n,i,a,o){const s=await wr(e,n,i,a,o);a.selectedMessage&&a.selectedMessage.sameTerm(n)&&(s.style.backgroundColor="yellow",a.selectedElement=s,t.selectedElement=s);let r=!1;for(let e=t.firstChild;e;e=e.nextSibling){const n=!0===a.newestfirst,i=s.AJAR_date;if(i>e.AJAR_date&&n||i<e.AJAR_date&&!n){t.insertBefore(s,e),r=!0;break}}r||t.appendChild(s)}async function kr(e,t,n,i){async function a(e,t){if(Ws(e)&&!i.showDeletedMessages)return;let n=x.store.any(null,b.sioc("has_member"),e,e.doc());const a=x.store.any(e,b.sioc("id"),null,e.doc());if(a&&!n&&(n=x.store.any(null,b.sioc("has_member"),a,e.doc())),i.thread){if(x.store.holds(e,b.sioc("has_reply"),i.thread));else if(!n||!n.sameTerm(i.thread))return}else if(n)return;t.fresh||await Er(u,t,e,t.fresh,i,h)}async function o(e){const t=e?w:C;let n=t.messageTable.date;if(e&&w.limit&&n<=w.limit)return v||await c(),!0;if(n=await d.loadPrevious(n,e),n||e||v||await c(),!n)return!0;let i=!1;if(!e){const e=d.leafDocumentFromDate(new Date);i=d.leafDocumentFromDate(n).sameTerm(e)}const a=await s(n,i);return t.messageTable=a,(e?p:!p)?m.appendChild(a):m.insertBefore(a,m.firstChild),i}async function s(t,n){const i=d.leafDocumentFromDate(t);try{await x.store.fetcher.createIfNotExists(i)}catch(a){const o=e.createElement("table").appendChild(e.createElement("tr"));return a.response&&a.response.status&&404===a.response.status?await r(t,n):(ve.Rm("*** Error NON 404 for chat file "+i),o.appendChild(nt(e,a,"pink")),o)}return await r(t,n)}async function r(t,n){async function s(){return await o(!1)}const r=e.createElement("table");r.style.width="100%",r.extendBackwards=async function(){const e=await o(!0);return e?r.initial=!0:r.extendedBack=!0,e},r.extendForwards=s,r.date=t;const c=d.leafDocumentFromDate(t);if(r.chatDocument=c,r.fresh=!1,r.setAttribute("style","width: 100%;"),n){r.final=!0,v=r,C.messageTable=r;const e=Cr(u,r,h,i);p?r.insertBefore(e,r.firstChild):r.appendChild(e),r.inputRow=e}{const n=e.createElement("tr"),a=n.appendChild(e.createElement("td"));a.style="text-align: center; vertical-align: middle; color: #888; font-style: italic;",a.textContent=Ct(t.toISOString(),!0);const o=n.appendChild(e.createElement("td"));i.includeRemoveButton&&o.appendChild(Mt(e,e=>{m.parentNode.removeChild(m)})),r.extendedForwards=!1,p?r.appendChild(n):r.insertBefore(n,r.firstChild)}const l=x.store.statementsMatching(null,b.wf("message"),null,c);!n&&l.length;for(const e of l)await a(e.object,r);return r.fresh=!0,r}async function c(){const e=new Date,t=d.leafDocumentFromDate(e),i=await s(e,!0);return m.appendChild(i),m.refresh=async function(){var e;await async function(){const e=d.leafDocumentFromDate(new Date);if(!e.sameTerm(C.messageTable.chatDocument)){v.inputRow&&(v.removeChild(v.inputRow),delete v.inputRow);const t=C.messageTable.chatDocument;if(await c(),!x.store.holds(t,b.rdfs("seeAlso"),e,t)){const n=[g.st(t,b.rdfs("seeAlso"),e,t)];try{x.store.updater.update([],n)}catch(e){alert("Unable to link old chat file to new one:"+e)}}}}(new Date),await async function(e,t){const n={};let i,o;for(i=t.firstChild;i;i=i.nextSibling)i.AJAR_subject&&(n[i.AJAR_subject.uri]=!0);const s=x.store.each(e,b.wf("message"),null,t.chatDocument),r={};for(const e of s)r[e.uri]=!0,n[e.uri]||await a(e,t);for(i=t.firstChild;i;)o=i.nextSibling,i.AJAR_subject&&!r[i.AJAR_subject.uri]&&t.removeChild(i),i=o;for(i=t.firstChild;i;i=i.nextSibling)i.AJAR_subject&&Gt(i)}(n,i),e=n,"Notification"in window?"granted"===Notification.permission?new Notification(e):"denied"!==Notification.permission&&Notification.requestPermission().then(function(t){"granted"===t&&new Notification(e)}):ve.R8("This browser does no t support desktop notification")},x.store.updater.addDownstreamChangeListener(t,m.refresh),v=i,C.messageTable=v,i}async function l(e,t){if(E)return;E=!0;const n=!t;let a;for(;m.scrollTop<150&&w.messageTable&&!w.messageTable.initial&&w.messageTable.extendBackwards;){if(0===m.scrollHeight)return setTimeout(l,2e3),void(E=!1);const e=m.scrollHeight-m.scrollTop;if(a=await w.messageTable.extendBackwards(),n&&(m.scrollTop=m.scrollHeight-e),t&&t(),a)break}for(;i.selectedMessage&&m.scrollHeight-m.scrollTop-m.clientHeight<150&&C.messageTable&&!C.messageTable.final&&C.messageTable.extendForwards;){const e=m.scrollTop;if(a=await C.messageTable.extendForwards(),n&&(m.scrollTop=e),t&&t(),a)break}E=!1}(i=i||{}).authorDateOnLeft=!1;const p="1"===i.newestFirst||!0===i.newestFirst,u=new Hs(n,i),d=u.dateFolder,m=e.createElement("div");u.div=m;const f=m.appendChild(e.createElement("div")),h={dom:e,statusArea:f,div:f};let v,y;const w={messageTable:null},C={messageTable:null};if(i.thread){const e=i.thread;if(y=x.store.any(null,b.sioc("has_reply"),e,e.doc()),y){const e=x.store.any(y,b.dct("created"),null,y.doc());e&&(w.limit=new Date(e.value))}}let E=!1;return await async function(){function e(){r&&r.selectedElement&&r.selectedElement.scrollIntoView({block:"center"})}let t,n,a;i.selectedMessage&&(n=i.selectedMessage.doc()),y&&(a=y.doc());const o=n||a;if(o){const e=new Date;t=d.leafDocumentFromDate(e).sameTerm(o)}let r;if(o&&!t){const n=d.dateFromLeafDocument(o);r=await s(n,t),m.appendChild(r),w.messageTable=r,C.messageTable=r,e(),setTimeout(e,1e3)}else await c(),w.messageTable=v,C.messageTable=v;await l(0,function(){i.selectedElement?i.selectedElement.scrollIntoView({block:"center"}):v.inputRow.scrollIntoView&&v.inputRow.scrollIntoView(p)}),m.addEventListener("scroll",l),i.solo&&document.body.addEventListener("scroll",l)}(),m}const Ar=x.store,Tr=[];function jr(e){return Tr[e]}function _r(e,t){if("string"!=typeof t)throw ve.Rm("Non-string value of preference "+e+": "+t),new Error("Non-string value of preference "+e+": "+t);this.value[e]=t}function Lr(e,t){return new Promise(function(n,i){const a=Ar.any(e,b.ui("sharedPreferences"));if(a)t.sharedPreferences=a,n(t);else{Ar.updater.editable(e.doc())||(ve.Rm(` Cant make shared preferences, may not change ${e.doc}`),n(t));const a=g.sym(e.doc().uri+"#SharedPreferences"),o=[g.st(e,b.ui("sharedPreferences"),a,e.doc())];ve.Rm("Creating shared preferences "+a),Ar.updater.update([],o,function(e,o,s){o?(t.sharedPreferences=a,n(t)):i(new Error("Error creating shared prefs: "+s))})}})}function Sr(e,t){return new Promise(function(n,i){Oi(t).then(t=>{if(!t.preferencesFile)return void ve.Rm("Not doing private class preferences as no access to preferences file. "+t.preferencesFileError);const a=Ar.each(null,b.solid("forClass"),e,t.preferencesFile);let o,s,r=[];if(a.length){if(a.forEach(e=>{o=o||Ar.any(e,b.solid("personalDefaults"))}),o)return t.personalDefaults=o,void n(t);o=Ei(t.preferencesFile),s=a[0]}else s=Ei(t.preferencesFile),r=[g.st(s,b.rdf("type"),b.solid("TypeRegistration"),t.preferencesFile),g.st(s,b.solid("forClass"),e,t.preferencesFile)];o=Ei(t.preferencesFile),r.push(g.st(s,b.solid("personalDefaults"),o,t.preferencesFile)),Ar.updater.update([],r,function(a,s,r){s?(t.personalDefaults=o,n(t)):i(new Error("Setting preferences for "+e+": "+r))})},e=>{i(e)})})}function Rr(e,t,n,i){const a=i.dom.createElement("div");return Zs(e,e.doc(),i.me).then(o=>{const s=i.dom;function r(e){a.appendChild(s.createElement("h5")).textContent=e}r("My view of this "+i.noun),li(s,a,{},o,n,e.doc(),(e,t)=>{e||vt(i,t)}),r("Everyone's view of this "+i.noun),Lr(e,i).then(i=>{const o=i.sharedPreferences;li(s,a,{},o,n,e.doc(),(e,t)=>{e||vt(i,t)}),r("My default view of any "+i.noun),Sr(t,i).then(e=>{li(s,a,{},e.personalDefaults,n,e.preferencesFile,(t,n)=>{t||vt(e,n)})},e=>{vt(i,e)})})},e=>{a.appendChild(nt(i.dom,e))}),a}function Nr(e){return e.datatype?e.datatype.equals(b.xsd("boolean"))?"1"===e.value:e.datatype.equals(b.xsd("dateTime"))||e.datatype.equals(b.xsd("date"))?new Date(e.value):e.datatype.equals(b.xsd("integer"))||e.datatype.equals(b.xsd("float"))||e.datatype.equals(b.xsd("decimal"))?Number(e.value):e.value:e}function Ir(e,t,n,i){return new Promise(function(a,o){Lr(e,i).then(i=>{const s=i.sharedPreferences;if(i.me)Zs(e,e.doc(),i.me).then(e=>{Sr(t,i).then(t=>{const i=[],o=t.personalDefaults;n.forEach(t=>{const n=Ar.any(e,t)||Ar.any(s,t)||Ar.any(o,t);n&&(i[t.uri]=Nr(n))}),a(i)},o)},o);else{const e=[];n.forEach(t=>{const n=Ar.any(s,t);n&&(e[t.uri]=Nr(n))}),a(e)}})})}const Br={icons:it.Pt,log:i,ns:b,utils:a,widgets:r};function Dr(e,t){const n=t.sourceDocument,i=t.tableClass,a=t.query,o=Br.ns,s=x.store,r={},c={"http://www.w3.org/2002/07/owl#sameAs":!0,"http://www.w3.org/1999/02/22-rdf-syntax-ns#type":!0},l={"http://www.w3.org/2001/XMLSchema#decimal":!0,"http://www.w3.org/2001/XMLSchema#float":!0,"http://www.w3.org/2001/XMLSchema#double":!0,"http://www.w3.org/2001/XMLSchema#integer":!0,"http://www.w3.org/2001/XMLSchema#nonNegativeInteger":!0,"http://www.w3.org/2001/XMLSchema#positiveInteger":!0,"http://www.w3.org/2001/XMLSchema#nonPositiveInteger":!0,"http://www.w3.org/2001/XMLSchema#negativeInteger":!0,"http://www.w3.org/2001/XMLSchema#long":!0,"http://www.w3.org/2001/XMLSchema#int":!0,"http://www.w3.org/2001/XMLSchema#short":!0,"http://www.w3.org/2001/XMLSchema#byte":!0,"http://www.w3.org/2001/XMLSchema#unsignedLong":!0,"http://www.w3.org/2001/XMLSchema#unsignedInt":!0,"http://www.w3.org/2001/XMLSchema#unsignedShort":!0,"http://www.w3.org/2001/XMLSchema#unsignedByte":!0},p={"http://www.w3.org/2001/XMLSchema#dateTime":!0,"http://www.w3.org/2001/XMLSchema#date":!0},u={"http://xmlns.com/foaf/0.1/Image":!0,"http://purl.org/dc/terms/Image":!0},d=t.keyVariable||"?_row";let m,f,h,b,v=0,y=null,w=null;const C=e.createElement("div");C.className="tableViewPane",C.appendChild(function(){const t=e.createElement("table");t.setAttribute("class","toolbar");const n=e.createElement("tr");return h=e.createElement("td"),n.appendChild(h),b=e.createElement("td"),n.appendChild(b),t.appendChild(n),t}());const E=e.createElement("div");let k;if(C.appendChild(E),C.refresh=function(){Y(k.query,k.logicalRows,k.columns,k)},a)k=te(a),E.appendChild(k);else{const t=function(){let e,t;const a=function(){const e={},t=s.statementsMatching(void 0,Br.ns.rdf("type"),i,n),a={};for(let n=0;n<t.length;++n){const i=t[n].object;if("NamedNode"!==i.termType)continue;const o=I(e,i);i.uri in a||(a[i.uri]=[]),a[i.uri].push(t[n].subject),o.addUse()}return[a,e]}();e=a[0],t=a[1];for(const n in e){const i=e[n];D(t[n],i)}const o=new _(null);return[o,S(t)]}();m=t[0],f=t[1],i||h.appendChild(function(t,n){const i=e.createElement("div");i.appendChild(e.createTextNode("Select type: "));const a=e.createElement("select");a.appendChild(R("All types","null"));for(const e in n)a.appendChild(R(n[e].getLabel(),e));return a.addEventListener("click",function(){let e;e="null"===a.value?t:n[a.value],T(e)},!1),i.appendChild(a),i}(m,f)),w=function(e){let t,n=-1,i=null;for(t in e){const a=e[t];a.useCount>n&&(i=a,n=a.useCount)}return i}(f),T(w||m)}return C;function A(e){const t=new g.Query,n=s.variable(d.slice(1));return function(e,t){const n=t.getColumns();for(let t=0;t<n.length;++t){const i=s.variable("_col"+t);e.vars.push(i),n[t].setVariable(i)}}(t,e),function(e,t,n){let i=n.type;i||(i=s.variable("_any")),e.pat.add(t,Br.ns.rdf("type"),i)}(t,n,e),function(e,t,n){const i=n.getColumns();for(let n=0;n<i.length;++n){const a=i[n],o=s.formula();o.add(t,a.predicate,a.getVariable()),e.pat.optional.push(o)}}(t,n,e),t}function T(t){j(b),b.appendChild(function(t){const n=e.createElement("div"),i=t.getUnusedColumns();if(i.sort(function(e,t){const n=e.sortKey(),i=t.sortKey();return(n>i)-(n<i)}),i.length>0){n.appendChild(e.createTextNode("Add column: "));const a=e.createElement("select");a.appendChild(R("","-1"));for(let e=0;e<i.length;++e){const t=i[e];a.appendChild(R(t.getLabel(),""+e))}n.appendChild(a),a.addEventListener("click",function(){const e=Number(a.value);e>=0&&(t.addColumn(i[e]),T(t))},!1)}return n}(t));!function(e,t){y&&(y.running=!1);const n=te(e,t);j(E),E.appendChild(n),y=e}(A(t),t)}function j(e){for(;e.childNodes.length>0;)e.removeChild(e.childNodes[0])}function _(e){this.type=e,this.columns=null,this.allColumns=[],this.useCount=0,this.getAllColumns=function(){return this.allColumns},this.getColumns=function(){if(!this.columns){const e=this.getAllColumns();this.columns=e.slice(0,7)}return this.columns},this.getUnusedColumns=function(){const e=this.getAllColumns(),t=this.getColumns(),n=[];for(let i=0;i<e.length;++i)-1===t.indexOf(e[i])&&n.push(e[i]);return n},this.addColumn=function(e){this.columns.push(e)},this.removeColumn=function(e){this.columns=this.columns.filter(function(t){return t!==e})},this.getLabel=function(){return U(this.type)},this.addUse=function(){this.useCount+=1}}function L(){this.useCount=0,this.checkedAnyValues=!1,this.possiblyLiteral=!0,this.possiblyNumber=!0,this.constraints=[],this.checkValue=function(e){const t=e.termType;if(this.possiblyLiteral&&"Literal"!==t&&"NamedNode"!==t)this.possiblyNumber=!1,this.possiblyLiteral=!1;else if(this.possiblyNumber)if("Literal"!==t)this.possiblyNumber=!1;else{e.value.match(/^-?\d+(\.\d*)?$/)||(this.possiblyNumber=!1)}this.checkedAnyValues=!0},this.getVariable=function(){return this.variable},this.setVariable=function(e){this.variable=e},this.getKey=function(){return this.variable.toString()},this.addUse=function(){this.useCount+=1},this.getHints=function(){return t&&t.hints&&this.variable&&t.hints[this.variable.toNT()]?t.hints[this.variable.toNT()]:{}},this.getLabel=function(){return this.getHints().label?this.getHints().label:this.predicate?this.predicate.sameTerm(o.rdf("type"))&&this.superClass?U(this.superClass,!0):U(this.predicate):this.variable?this.variable.toString():"unlabeled column?"},this.setPredicate=function(e,t,n){t?(this.inverse=e,this.constraints=this.constraints.concat(s.each(e,Br.ns.rdfs("domain"))),e.sameTerm(o.rdfs("subClassOf"))&&"NamedNode"===n.termType&&(this.superClass=n,this.alternatives=s.each(void 0,o.rdfs("subClassOf"),n))):(this.predicate=e,this.constraints=this.constraints.concat(s.each(e,Br.ns.rdfs("range"))))},this.getConstraints=function(){return this.constraints},this.filterFunction=function(){return!0},this.sortKey=function(){return this.getLabel().toLowerCase()},this.isImageColumn=function(){for(let e=0;e<this.constraints.length;e++)if(this.constraints[e].uri in u)return!0;return!1}}function S(e,t){const n=[];for(const i in e){const a=e[i];t&&!t(i,a)||n.push(a)}return n}function R(t,n){const i=e.createElement("option");return i.setAttribute("value",n),i.appendChild(e.createTextNode(t)),i}function N(e,t){let n;return t.uri in e?n=e[t.uri]:(n=new L,n.setPredicate(t),e[t.uri]=n),n}function I(e,t){let n;return t.uri in e?n=e[t.uri]:(n=new _(t),e[t.uri]=n),n}function B(e,t){const i=s.statementsMatching(e,void 0,void 0,n),a={};for(let e=0;e<i.length;++e){const n=i[e].predicate;if(n.uri in c)continue;const o=N(t,n);o.checkValue(i[e].object),a[n.uri]=o}return a}function D(e,t){const n={};for(let e=0;e<t.length;++e){const i=B(t[e],n);for(const e in i){i[e].addUse()}}const i=S(n);!function(e){function t(e,t){return(e.useCount<t.useCount)-(e.useCount>t.useCount)}e.sort(t)}(i),e.allColumns=i}function O(t,n){const i=e.createElement("a");return i.appendChild(e.createTextNode("[x]")),i.addEventListener("click",function(){t.removeColumn(n),T(t)},!1),i}function M(e,t){let n=!0;for(let i=0;i<t.length;++i){const a=t[i],o=a.getKey();let s=null;if(o in e.values&&(s=e.values[o][0]),!a.filterFunction(s)){n=!1;break}}const i=e._htmlRow;i.style.display=n?"":"none"}function F(e,t){for(let n=0;n<e.length;++n){M(e[n],t)}}function z(e,t,n){function i(e){return e?"Literal"===e.termType?e.value.toLowerCase():"NamedNode"===e.termType?U(e).toLowerCase():e.value.toLowerCase():""}!function(e,t,n,i){const a=t.getKey();if(e.sort(function(e,t){let o=null,s=null;a in e.values&&(o=e.values[a][0]),a in t.values&&(s=t.values[a][0]);const r=n(o,s);return i?-r:r}),e.length){const t=e[0]._htmlRow.parentNode;for(let n=0;n<e.length;++n)t.removeChild(e[n]._htmlRow);for(let n=0;n<e.length;++n)t.appendChild(e[n]._htmlRow)}}(e,t,function(e,t){const n=i(e),a=i(t);return n<a?-1:n>a?1:0},n)}function P(t,n,i){const a=e.createElement("div"),o=e.createElement("input");o.setAttribute("type","text"),o.style.width="70%",a.appendChild(o);const s=e.createElement("span");s.appendChild(e.createTextNode("▼")),s.addEventListener("click",function(){z(t,i,!1)},!1),a.appendChild(s);const r=e.createElement("span");r.appendChild(e.createTextNode("▲")),r.addEventListener("click",function(){z(t,i,!0)},!1),a.appendChild(r);let c=null;return i.filterFunction=function(e){if(c){if(e){let t;return t="Literal"===e.termType?e.value:"NamedNode"===e.termType?U(e):"",t.toLowerCase().indexOf(c)>=0}return!1}return!0},o.addEventListener("keyup",function(){c=""!==o.value?o.value.toLowerCase():null,F(t,n)},!1),a}function $(t,n,i,a){const o=e.createElement("div"),s=e.createElement("select");let r={};for(let e=0;e<a.length;++e){const t=a[e];r[t.uri]=!0}const c=V(i).initialSelection;c&&(r=c),s.setAttribute("multiple","true");for(let e=0;e<a.length;++e){const t=a[e],n=R(U(t),e);r[t.uri]&&(n.selected=!0),s.appendChild(n)}return o.appendChild(s),i.filterFunction=function(e){return!r||e&&r[e.uri]},s.addEventListener("click",function(){{r={};const e=s.options;for(let t=0;t<e.length;t++){const n=e[t],i=Number(n.value);e[t].selected&&(r[a[i].uri]=!0)}}F(t,n)},!0),o}function q(t,n,i){const a=e.createElement("div"),o=e.createElement("input");o.setAttribute("type","text"),o.style.width="40px",a.appendChild(o);const s=e.createElement("input");s.setAttribute("type","text"),s.style.width="40px",a.appendChild(s);let r=null,c=null;function l(){r=""===o.value?null:Number(o.value),c=""===s.value?null:Number(s.value),F(t,n)}return i.filterFunction=function(e){return e&&(e=Number(e)),!(r&&(!e||e<r))&&!(c&&(!e||e>c))},o.addEventListener("keyup",l,!1),s.addEventListener("keyup",l,!1),a}function H(e,t,n){if(n.superClass&&n.alternatives.length>0)return $(e,t,n,n.alternatives);const i=n.getConstraints();let a;for(let o=0;o<i.length;o++){if(a=i[o],n.checkedAnyValues&&n.possiblyNumber||a.uri in l)return q(e,t,n);if("http://www.w3.org/2000/01/rdf-schema#Literal"===a.uri)return P(e,t,n);const r=s.each(a,Br.ns.owl("oneOf"));if(r.length>0)return $(e,t,n,r.elements)}return function(e,t,n){return n.checkedAnyValues&&n.possiblyNumber?q(e,t,n):n.possiblyLiteral?P(e,t,n):null}(e,t,n)}function G(t,n,i){i=i||{};const a=e.createElement("a"),o=i.linkFunction;return a.setAttribute("href",t),a.appendChild(e.createTextNode(n)),o?a.addEventListener("click",function(e){e.preventDefault(),e.stopPropagation();const t=ee(e).getAttribute("href");t||ve.Rm("No href found \n"),o(t)},!0):a.addEventListener("click",Br.widgets.openHrefInOutlineMode,!0),a}function V(e){return t&&t.hints&&e.variable&&t.hints[e.variable.toNT()]?t.hints[e.variable.toNT()]:{}}function W(t,n){const i=V(n),a=i.cellFormat;if(!a){if("Literal"===t.termType){if(t.datatype){if(p[t.datatype.uri])return e.createTextNode(Br.widgets.shortDate(t.value));if(l[t.datatype.uri]){const n=e.createElement("span");return n.textContent=t.value,n.setAttribute("style","text-align: right"),n}}return e.createTextNode(t.value)}if("NamedNode"===t.termType&&n.isImageColumn())return function(t){const n=e.createElement("img");return n.setAttribute("src",t.uri),n.style.height="40px",n}(t);if("NamedNode"===t.termType||"BlankNode"===t.termType)return function(e,t){let n=!1;return e.uri&&(n=e.uri.match(/^mailto:(.*)/)),G(e.uri,n?n[1]:U(e),t)}(t,i);if("Collection"===t.termType){const i=e.createElement("span");return i.appendChild(e.createTextNode("[")),t.elements.forEach(function(t){i.appendChild(W(t,n)),i.appendChild(e.createTextNode(", "))}),i.removeChild(i.lastChild),i.appendChild(e.createTextNode("]")),i}return e.createTextNode("unknown termtype '"+t.termType+"'!")}if("shortDate"===a)return e.createTextNode(Br.widgets.shortDate(t.value))}function J(e,t){let n,i=null;if("Literal"===e.termType)i="value";else{if("NamedNode"!==e.termType)return t.indexOf(e)>=0;i="uri"}for(n=0;n<t.length;++n)if(t[n].termType===e.termType&&t[n][i]===e[i])return!0;return!1}function Q(t,n,i){let a,o=!1;for(a in i){const e=i[a];a in t.values||(t.values[a]=[]),J(e,t.values[a])||(t.values[a].push(e),o=!0)}o&&(j(t._htmlRow),function(t,n,i){const a=e.createElement("td");n._subject&&"uri"in n._subject&&a.appendChild(G(n._subject.uri,"→")),t.appendChild(a);for(let a=0;a<i.length;++a){const o=i[a],s=e.createElement("td");let r;const c=o.getKey();if(c in n.values){const t=n.values[c];let i=!1;n.originalValues&&n.originalValues[c]&&t.length!==n.originalValues[c].length&&(i=!0);for(let a=0;a<t.length;++a){const l=t[a];n.originalValues&&n.originalValues[c]&&n.originalValues[c].length>a&&(r=n.originalValues[c][a],l.toString()!==r.toString()&&(i=!0)),s.appendChild(W(l,o)),a!==t.length-1&&s.appendChild(e.createTextNode(",\n")),i&&(s.style.background="#efe")}}t.appendChild(s)}n._htmlRow=t}(t._htmlRow,t,n)),M(t,n)}function Z(e){if("uri"in e)return e.uri;if("_subject_id"in e)return e._subject_id;{const t=""+v;return e._subject_id=t,++v,t}}function Y(n,i,a,o){n.running=!0;const c=Date.now();let l=e.createElement("tr");o.appendChild(l),l.textContent="Loading ...";for(let e=0;e<i.length;e++)i[e].original=!0,i[e].originalValues||(i[e].originalValues=i[e].values),i[e].values={};s.query(n,function(t){if(!n.running)return;l.textContent+=".";let s,c=null,p=null;if(d in t&&(p=t[d],s=Z(p),s in r&&(c=r[s])),!c){const t=e.createElement("tr");o.appendChild(t),c={_htmlRow:t,_subject:p,values:{}},i.push(c),p&&(r[s]=c)}delete c.original,Q(c,a,t)},void 0,function(){l&&l.parentNode&&l.parentNode.removeChild&&(l.parentNode.removeChild(l),l=null);const e=Date.now()-c;ve.Rm("Query done: "+i.length+" rows, "+e+"ms");for(let e=i.length-1;e>=0;e--)if(i[e].original){ve.Rm(" deleting row "+i[e]._subject);const t=i[e]._htmlRow;t.parentNode.removeChild(t),delete r[Z(i[e]._subject)],i.splice(e,1)}if(t.sortBy){const e=function(e,t){for(const n in e){const i=e[n];if(i.variable.toNT()===t)return i}throw new Error(`getColumnForVariable: no column for variable ${t}`)}(a,t.sortBy);z(i,e,t.sortReverse)}t.onDone&&t.onDone(C)})}function K(e,t){Br.log.debug(">> processing formula");for(let n=0;n<t.statements.length;++n){const i=t.statements[n];if("NamedNode"===i.predicate.termType&&"Variable"===i.object.termType){const t=i.object.toString();if(t in e){e[t].setPredicate(i.predicate,!1,i.subject)}}if("NamedNode"===i.predicate.termType&&"Variable"===i.subject.termType){const t=i.subject.toString();if(t in e){e[t].setPredicate(i.predicate,!0,i.object)}}}for(let n=0;n<t.optional.length;++n)Br.log.debug("recurse to optional subformula "+n),K(e,t.optional[n]);Br.log.debug("<< finished processing formula")}function X(e){const t=[],n={};for(let i=0;i<e.vars.length;++i){const a=new L,o=e.vars[i];Br.log.debug("column "+i+" : "+o),a.setVariable(o),n[o]=a,t.push(a)}return K(n,e.pat),t}function te(t,n){let i;i=a?X(t):n.getColumns();const o=[],s=e.createElement("table");return s.appendChild(function(t,n){const i=e.createElement("tr"),a=e.createElement("th");i.appendChild(a);for(let a=0;a<t.length;++a){const o=e.createElement("th"),s=t[a];o.appendChild(e.createTextNode(s.getLabel())),n&&o.appendChild(O(n,s)),i.appendChild(o)}return i}(i,n)),s.appendChild(function(t,n){const i=e.createElement("tr");i.className="selectors",i.appendChild(e.createElement("td"));for(let a=0;a<n.length;++a){const o=e.createElement("td"),s=H(t,n,n[a]);s&&o.appendChild(s),i.appendChild(o)}return i}(o,i)),s.logicalRows=o,s.columns=i,s.query=t,Y(t,o,i,s),s}}class Or extends HTMLElement{bodyContainer;refresh;tabContainer}function Mr(e){const t=e.subject,n=e.dom||document,i=parseInt(e.orientation||"0"),a=e.backgroundColor||"#ddddcc",o=2&i,s=1&i,r=e.onClose,[c,l]=function(e){return function(e){let t=0;for(let n=0;n<3;n++)t+=parseInt(e.slice(2*n+1,2*n+3),16);return t>384}(e)?[Fr(e,"#ffffff",.3),"#000000"]:[Fr(e,"#000000",.3),"#ffffff"]}(a),p=`display: grid; width: auto; height: 100%; border: 0.1em; border-style: solid; border-color: ${c}; padding: 1em;`,u=n.createElement("div");u.setAttribute("style",Ke.tabsRootElement),u.style.flexDirection=(s?"row":"column")+(o?"-reverse":"");const d=u.appendChild(n.createElement("nav"));d.setAttribute("style",Ke.tabsNavElement);const m=u.appendChild(n.createElement("div"));m.setAttribute("style",Ke.tabsMainElement);const f=d.appendChild(n.createElement("ul"));f.setAttribute("style",Ke.tabContainer),f.style.flexDirection=""+(s?"column":"row");const h=m;u.tabContainer=f,u.bodyContainer=h;const g=["0.2em","0.2em","0","0"],b=`border-radius: ${g.concat(g).slice(i,i+4).join(" ")};`,v=["0.3em","0.3em","0","0.3em"],y=v.concat(v).slice(i,i+4),w=`margin: ${y.join(" ")};`,C=`padding: ${y.join(" ")};`,E=b+`position: relative; padding: 0.7em; max-width: 20em; color: ${l};`,k=`${E+w} opacity: 50%; background-color: ${a};`,A=`${E+w} background-color: ${c};`,T="height: 100%; width: 100%;",j=T+"display: none;";if(u.refresh=L,L(),!e.startEmpty&&f.children.length&&e.selectedTab){const t=Array.from(f.children).map(e=>e.firstChild).find(t=>t.dataset.name===e.selectedTab),n=e.selectedTab.uri,i=Array.from(f.children).find(e=>e.subject&&e.subject.uri&&e.subject.uri===n),a=i||t||f.children[0],o=a.firstChild;o?.click?o.click():a instanceof HTMLElement&&a.click()}else if(!e.startEmpty){const e=f.children[0],t=e?.firstChild;t?.click?t.click():e instanceof HTMLElement&&e.click()}return u;function _(t){const i=n.createElement("li");i.setAttribute("style",k),i.subject=t;const a=i.appendChild(n.createElement("button"));if(a.setAttribute("style",Ke.makeNewSlot),a.onclick=function(){if(S(),R(),i.setAttribute("style",A),!i.bodyTR)return;i.bodyTR.setAttribute("style",T);const n=o(i);e.renderMain&&i.subject&&!1!==n.asSettings&&(n.innerHTML="loading item ..."+t,e.renderMain(n,i.subject),n.asSettings=!1)},e.renderTabSettings&&i.subject){const a=n.createElement("button");a.textContent="...",a.setAttribute("style",Ke.ellipsis),a.onclick=function(){if(S(),R(),i.setAttribute("style",A),!i.bodyTR)return;i.bodyTR.setAttribute("style",T);const n=o(i);e.renderTabSettings&&i.subject&&!0!==n.asSettings&&(n.innerHTML="loading settings ..."+t,e.renderTabSettings(n,i.subject),n.asSettings=!0)},i.appendChild(a)}return e.renderTab?e.renderTab(a,t):a.innerHTML=U(t),i;function o(e){const t=e.bodyTR?.children[0];if(t)return t;const i=e.bodyTR.appendChild(n.createElement("div"));return i.setAttribute("style",p),i}}function L(){const i=e.items?e.items:!1!==e.ordered?x.store.the(t,e.predicate).elements:x.store.each(t,e.predicate);let a,o,s,c,l,p=!1;for(c=0;c<f.children.length;c++)if(a=f.children[c],c>=i.length||a.subject&&!a.subject.sameTerm(i[c])){p=!0;break}if(!p&&i.length===f.children.length)return;for(l=f.children.length-1;l>=0&&(a=f.children[l],s=l-f.children.length+i.length,!a.subject||a.subject.sameTerm(i[s]));l--);const u=i.slice(c,l-f.children.length+i.length+1);for(;l>=c;)f.removeChild(f.children[c]),h.removeChild(h.children[c]),l-=1;for(o=0;o<u.length;o++){const e=_(u[o]),t=n.createElement("div");e.bodyTR=t,c===f.children.length?(f.appendChild(e),h.appendChild(t)):(f.insertBefore(e,f.children[c+o]),h.insertBefore(t,h.children[c+o]))}r&&function(e){if(e.dataset.onCloseSet){const t=e.querySelector(".unstyled");e.removeChild(t)}const t=n.createElement("li");t.classList.add("unstyled");const i=Mt(n,r);i.setAttribute("style",i.getAttribute("style")+C),t.appendChild(i),e.appendChild(t),e.dataset.onCloseSet="true"}(f)}function S(){for(let e=0;e<f.children.length;e++){const t=f.children[e];t.classList.contains("unstyled")||t.setAttribute("style",k)}}function R(){for(let e=0;e<h.children.length;e++)h.children[e].setAttribute("style",j)}}function Fr(e,t,n){let i,a,o,s="#";const r="0123456789abcdef";for(let c=0;c<3;c++){i=parseInt(e.slice(2*c+1,2*c+3),16),a=parseInt(t.slice(2*c+1,2*c+3),16),o=i*(1-n)+a*n;const l=parseInt((""+o).split(".")[0]),p=parseInt((""+l/16).split(".")[0]),u=parseInt((""+l%16).split(".")[0]);s+=r[p]+r[u]}return s}const zr='\n<svg xmlns="http://www.w3.org/2000/svg" width="26" height="26" viewBox="0 0 26 26" fill="none">\n <path fill-rule="evenodd" clip-rule="evenodd" d="M13 25C19.6274 25 25 19.6274 25 13C25 6.37258 19.6274 1 13 1C6.37258 1 1 6.37258 1 13C1 19.6274 6.37258 25 13 25Z" fill="#D8D8D8" stroke="#8B8B8B"/>\n <mask id="mask0" mask-type="alpha" maskUnits="userSpaceOnUse" x="0" y="0" width="26" height="26">\n <path fill-rule="evenodd" clip-rule="evenodd" d="M13 25C19.6274 25 25 19.6274 25 13C25 6.37258 19.6274 1 13 1C6.37258 1 1 6.37258 1 13C1 19.6274 6.37258 25 13 25Z" fill="white" stroke="white"/>\n </mask>\n <g mask="url(#mask0)">\n <path fill-rule="evenodd" clip-rule="evenodd" d="M17.0468 10.4586C17.0468 14.4979 15.4281 16.9214 12.9999 16.9214C10.5718 16.9214 8.95298 14.4979 8.95298 10.4586C8.95298 6.41931 12.9999 6.41931 12.9999 6.41931C12.9999 6.41931 17.0468 6.41931 17.0468 10.4586ZM4.09668 23.3842C6.52483 17.7293 12.9999 17.7293 12.9999 17.7293C12.9999 17.7293 19.475 17.7293 21.9031 23.3842C21.9031 23.3842 17.8481 25 12.9999 25C8.15169 25 4.09668 23.3842 4.09668 23.3842Z" fill="#8B8B8B"/>\n </g>\n</svg>';var Ur=n(565);const Pr=it.Pt.iconBase+"noun_help.svg",$r="https://solidproject.org/assets/img/solid-emblem.svg";async function qr(e,t,n){const i=document.getElementById("PageHeader");if(!i)return;const a=(0,Ur.E6)();Hr(i,e,a,t,n)(),x.authSession.events.on("logout",Hr(i,e,a,t,n)),x.authSession.events.on("login",Hr(i,e,a,t,n))}function Hr(e,t,n,i,a){return async()=>{const o=x.authn.currentUser();e.innerHTML="",e.appendChild(await async function(e,t,n,i,a){const o=document.createElement("a");o.href=t.uri,o.setAttribute("style",Ke.headerBannerLink);const s=document.createElement("img");a&&(s.src=a.logo?a.logo:$r);s.setAttribute("style",Ke.headerBannerIcon),o.appendChild(s);const r=n?await async function(e,t,n){const i=e.fetcher;i&&await i.load(t);const a=document.createElement("ul");a.setAttribute("style",Ke.headerUserMenuList),n&&n.forEach(function(e){"url"===(e.url?"url":"onclick")?a.appendChild(Wr(Vr(e.label,e.url,e.target))):a.appendChild(Wr(Gr(e.label,e.onclick)))});const o=document.createElement("nav");o.setAttribute("style",Ke.headerUserMenuNavigationMenuNotDisplayed),o.setAttribute("aria-hidden","true"),o.setAttribute("id","loggedInNav"),o.appendChild(a);const s=document.createElement("button");s.setAttribute("style",Ke.headerUserMenuTrigger),s.type="button";const r=function(e,t){let n=null;try{if(n=Rt(t),!n)return zr}catch{return zr}const i=document.createElement("div");return i.setAttribute("style",Ke.headerUserMenuPhoto),i.style.backgroundImage=`url(${n})`,i}(0,t);"string"==typeof r?s.innerHTML=r:s.appendChild(r);const c=document.createElement("div");c.setAttribute("style",Ke.headerBannerUserMenuNotDisplayed),c.appendChild(s),c.appendChild(o);const l=(0,Ur.nF)(e=>Jr(e,s,o),50);s.addEventListener("click",l);let p=setTimeout(()=>null,0);return c.addEventListener("mouseover",e=>{clearTimeout(p),l(e);const t=document.getElementById("loggedInNav");t?.setAttribute("style",Ke.headerUserMenuNavigationMenu)}),c.addEventListener("mouseout",e=>{p=setTimeout(()=>l(e),200);const t=document.getElementById("loggedInNav");t?.setAttribute("style",Ke.headerUserMenuNavigationMenuNotDisplayed)}),c}(e,n,i):function(){const e=document.createElement("div");return e.setAttribute("style",Ke.headerBannerLogin),e.appendChild(Hi(document,null,{})),e}(),c=document.createElement("div");c.setAttribute("style",Ke.headerBanner),c.appendChild(o);const l=document.createElement("div");if(l.setAttribute("style",Ke.headerBannerRightMenu),l.appendChild(r),a&&a.helpMenuList){const e=function(e,t){if(!t)return;const n=document.createElement("ul");n.setAttribute("style",Ke.headerUserMenuList),t.forEach(function(e){"url"===(e.url?"url":"onclick")?n.appendChild(Wr(Vr(e.label,e.url,e.target))):n.appendChild(Wr(Gr(e.label,e.onclick)))});const i=document.createElement("nav");i.setAttribute("style",Ke.headerUserMenuNavigationMenuNotDisplayed),i.setAttribute("aria-hidden","true"),i.setAttribute("id","helperNav"),i.appendChild(n);const a=document.createElement("div");a.setAttribute("style",Ke.headerBannerUserMenu),a.appendChild(i);const o=document.createElement("button");o.setAttribute("style",Ke.headerUserMenuTrigger),o.type="button";const s=document.createElement("img");s.src=e&&e.helpIcon?e.helpIcon:it.Pt.iconBase+Pr,s.setAttribute("style",Ke.headerUserMenuTriggerImg),a.appendChild(o),o.appendChild(s);const r=(0,Ur.nF)(e=>Jr(e,o,i),50);o.addEventListener("click",r);let c=setTimeout(()=>null,0);return a.addEventListener("mouseover",e=>{clearTimeout(c),r(e);const t=document.getElementById("helperNav");t?.setAttribute("style",Ke.headerUserMenuNavigationMenu)}),a.addEventListener("mouseout",e=>{c=setTimeout(()=>r(e),200);const t=document.getElementById("helperNav");t?.setAttribute("style",Ke.headerUserMenuNavigationMenuNotDisplayed)}),a}(a,a.helpMenuList);l.appendChild(e)}return c.appendChild(l),c}(t,n,o,i,a))}}function Gr(e,t){const n=document.createElement("button");return n.setAttribute("style",Ke.headerUserMenuButton),n.onmouseover=function(){n.setAttribute("style",Ke.headerUserMenuButtonHover)},n.onmouseout=function(){n.setAttribute("style",Ke.headerUserMenuButton)},n.addEventListener("click",t),n.innerText=e,n}function Vr(e,t,n){const i=document.createElement("a");return i.setAttribute("style",Ke.headerUserMenuLink),i.onmouseover=function(){i.setAttribute("style",Ke.headerUserMenuLinkHover)},i.onmouseout=function(){i.setAttribute("style",Ke.headerUserMenuLink)},i.href=t,i.innerText=e,n&&(i.target=n),i}function Wr(e){const t=document.createElement("li");return t.setAttribute("style",Ke.headerUserMenuListItem),t.appendChild(e),t}function Jr(e,t,n){const i="true"===t.getAttribute("aria-expanded"),a="mouseover"===e.type,o="mouseout"===e.type;i&&a||!i&&o||(t.setAttribute("aria-expanded",(!i).toString()),n.setAttribute("aria-hidden",i.toString()))}const Qr="https://solidproject.org",Zr="solidproject.org";async function Yr(e,t){const n=document.getElementById("PageFooter");if(!n)return;const i=(0,Ur.E6)(),a=await(0,Ur.bB)(i,e);Kr(n,e,i,a,t)(),x.authSession.events.on("login",Kr(n,e,i,a,t)),x.authSession.events.on("logout",Kr(n,e,i,a,t))}function Kr(e,t,n,i,a){return async()=>{const o=x.authn.currentUser();e.innerHTML="",e.appendChild(await function(e,t,n,i,a){const o=document.createElement("div");o.setAttribute("style",Ke.footer);const s=document.createElement("a");if(s.href=a&&a.solidProjectUrl?a.solidProjectUrl:Qr,s.innerText=a&&a.solidProjectName?a.solidProjectName:Zr,!n||!i||t&&t.equals(i)){const e=document.createElement("span");return e.innerText="Powered by ",o.appendChild(e),o.appendChild(s),o}const r=document.createElement("span");r.innerText="You're visiting ";const c=document.createElement("a");c.href=n.uri,c.innerText="the Pod";const l=document.createElement("span");l.innerText=" controlled by ";const p=document.createElement("a");p.href=i.uri,p.innerText=(0,Ur.mG)(e,i);const u=document.createElement("span");u.innerText=". For more info, check out ";const d=document.createElement("span");return d.innerText=".",o.appendChild(r),o.appendChild(c),o.appendChild(l),o.appendChild(p),o.appendChild(u),o.appendChild(s),o.appendChild(d),o}(t,o,n,i,a))}}const Xr=window?window.document:null;"undefined"!=typeof window&&(window.UI={ns:b,acl:ca,aclControl:la,create:ua,createTypes:m,dom:Xr,icons:it.Pt,language:o,log:i,login:c,matrix:ma,media:ba,messageArea:va,infiniteMessageArea:kr,pad:p,participation:l,preferences:u,style:Ke,table:Dr,tabs:d,utils:a,widgets:r,initHeader:qr,initFooter:Yr})},565(e,t,n){"use strict";n.d(t,{E6:()=>o,bB:()=>s,mG:()=>r,nF:()=>c});var i=n(511),a=n(788);function o(){const{origin:e,pathname:t}=document.location,n="databrowser"===document.body?.dataset?.appShell,a=t.split("/").filter(Boolean),o=a[a.length-1]||"",s=/\.[^/]+$/.test(o);return n&&a.length>0&&!s?(0,i.sym)(`${e}/${a[0]}/`):(0,i.sym)(e).site()}async function s(e,t){try{if(!t.any(e,null,a.ns.ldp("Container"),e)){const n=(await t.fetcher.webOperation("GET",e.uri,t.fetcher.initFetchOptions(e.uri,{headers:{accept:"text/turtle"}}))).responseText;(0,i.parse)(n,t,e.uri,"text/turtle")}}catch(t){return console.error("Error loading pod "+e+": "+t),null}if(!t.holds(e,a.ns.rdf("type"),a.ns.space("Storage"),e))return console.warn("Pod "+e+" does not declare itself as a space:Storage"),null;const n=t.any(e,a.ns.solid("owner"),null,e)||t.any(null,a.ns.space("storage"),e,e);if(n){try{await t.fetcher.load(n.doc())}catch(e){return console.warn("Unable to load profile of pod owner "+n),null}return t.holds(n,a.ns.space("storage"),e,n.doc())||console.warn(`Pod owner ${n} does NOT list pod ${e} as their storage`),n}{const n=(0,i.sym)(`${e.uri}profile/card#me`);try{await t.fetcher.load(n)}catch(e){return console.error("Ooops. Guessed wrong pod owner webid {$guess} : can't load it."),null}return t.holds(n,a.ns.space("storage"),e,n.doc())?(console.warn("Using guessed pod owner webid but it links back."),n):null}}function r(e,t){return e.anyValue(t,a.ns.vcard("fn"),null,t.doc())||e.anyValue(t,a.ns.foaf("name"),null,t.doc())||t.uri}function c(e,t,n={}){let i,a,o,s=null,r=0;const c=function(){r=n.leading?Date.now():0,s=null,o=e.apply(i,a),s||(i=a=null)};return function(){const l=Date.now();r||n.leading||(r=l);const p=t-(l-r);return i=this,a=arguments,p<=0||p>t?(s&&(clearTimeout(s),s=null),r=l,o=e.apply(i,a),s||(i=a=null)):s||!1===n.trailing||(s=setTimeout(c,p)),o}}},580(e){"use strict";
|
|
22
22
|
/*!
|
|
23
23
|
* escape-html
|
|
24
24
|
* Copyright(c) 2012-2013 TJ Holowaychuk
|