@coasys/ad4m-connect 0.8.1 → 0.8.2-prerelease

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/core.js CHANGED
@@ -58,7 +58,7 @@ For more information, please visit: https://go.apollo.dev/c/docs`):new $(9);if(t
58
58
  `)}function fu(t){for(var e=0;e<t.length;++e)if(t[e]!==" "&&t[e]!==" ")return!1;return!0}function fp(t){for(var e,r=!0,n=!0,i=0,a=null,o=0;o<t.length;++o)switch(t.charCodeAt(o)){case 13:t.charCodeAt(o+1)===10&&++o;case 10:r=!1,n=!0,i=0;break;case 9:case 32:++i;break;default:n&&!r&&(a===null||i<a)&&(a=i),n=!1}return(e=a)!==null&&e!==void 0?e:0}var pp=function(){function t(r){var n=new ve(_.SOF,0,0,0,0,null);this.source=r,this.lastToken=n,this.token=n,this.line=1,this.lineStart=0}var e=t.prototype;return e.advance=function(){this.lastToken=this.token;var n=this.token=this.lookahead();return n},e.lookahead=function(){var n=this.token;if(n.kind!==_.EOF)do{var i;n=(i=n.next)!==null&&i!==void 0?i:n.next=hp(this,n)}while(n.kind===_.COMMENT);return n},t}();function dp(t){return t===_.BANG||t===_.DOLLAR||t===_.AMP||t===_.PAREN_L||t===_.PAREN_R||t===_.SPREAD||t===_.COLON||t===_.EQUALS||t===_.AT||t===_.BRACKET_L||t===_.BRACKET_R||t===_.BRACE_L||t===_.PIPE||t===_.BRACE_R}function Sr(t){return isNaN(t)?_.EOF:t<127?JSON.stringify(String.fromCharCode(t)):'"\\u'.concat(("00"+t.toString(16).toUpperCase()).slice(-4),'"')}function hp(t,e){for(var r=t.source,n=r.body,i=n.length,a=e.end;a<i;){var o=n.charCodeAt(a),s=t.line,u=1+a-t.lineStart;switch(o){case 65279:case 9:case 32:case 44:++a;continue;case 10:++a,++t.line,t.lineStart=a;continue;case 13:n.charCodeAt(a+1)===10?a+=2:++a,++t.line,t.lineStart=a;continue;case 33:return new ve(_.BANG,a,a+1,s,u,e);case 35:return yp(r,a,s,u,e);case 36:return new ve(_.DOLLAR,a,a+1,s,u,e);case 38:return new ve(_.AMP,a,a+1,s,u,e);case 40:return new ve(_.PAREN_L,a,a+1,s,u,e);case 41:return new ve(_.PAREN_R,a,a+1,s,u,e);case 46:if(n.charCodeAt(a+1)===46&&n.charCodeAt(a+2)===46)return new ve(_.SPREAD,a,a+3,s,u,e);break;case 58:return new ve(_.COLON,a,a+1,s,u,e);case 61:return new ve(_.EQUALS,a,a+1,s,u,e);case 64:return new ve(_.AT,a,a+1,s,u,e);case 91:return new ve(_.BRACKET_L,a,a+1,s,u,e);case 93:return new ve(_.BRACKET_R,a,a+1,s,u,e);case 123:return new ve(_.BRACE_L,a,a+1,s,u,e);case 124:return new ve(_.PIPE,a,a+1,s,u,e);case 125:return new ve(_.BRACE_R,a,a+1,s,u,e);case 34:return n.charCodeAt(a+1)===34&&n.charCodeAt(a+2)===34?bp(r,a,s,u,e,t):gp(r,a,s,u,e);case 45:case 48:case 49:case 50:case 51:case 52:case 53:case 54:case 55:case 56:case 57:return vp(r,a,o,s,u,e);case 65:case 66:case 67:case 68:case 69:case 70:case 71:case 72:case 73:case 74:case 75:case 76:case 77:case 78:case 79:case 80:case 81:case 82:case 83:case 84:case 85:case 86:case 87:case 88:case 89:case 90:case 95:case 97:case 98:case 99:case 100:case 101:case 102:case 103:case 104:case 105:case 106:case 107:case 108:case 109:case 110:case 111:case 112:case 113:case 114:case 115:case 116:case 117:case 118:case 119:case 120:case 121:case 122:return wp(r,a,s,u,e)}throw He(r,a,mp(o))}var l=t.line,f=1+a-t.lineStart;return new ve(_.EOF,i,i,l,f,e)}function mp(t){return t<32&&t!==9&&t!==10&&t!==13?"Cannot contain the invalid character ".concat(Sr(t),"."):t===39?`Unexpected single quote character ('), did you mean to use a double quote (")?`:"Cannot parse the unexpected character ".concat(Sr(t),".")}function yp(t,e,r,n,i){var a=t.body,o,s=e;do o=a.charCodeAt(++s);while(!isNaN(o)&&(o>31||o===9));return new ve(_.COMMENT,e,s,r,n,i,a.slice(e+1,s))}function vp(t,e,r,n,i,a){var o=t.body,s=r,u=e,l=!1;if(s===45&&(s=o.charCodeAt(++u)),s===48){if(s=o.charCodeAt(++u),s>=48&&s<=57)throw He(t,u,"Invalid number, unexpected digit after 0: ".concat(Sr(s),"."))}else u=Po(t,u,s),s=o.charCodeAt(u);if(s===46&&(l=!0,s=o.charCodeAt(++u),u=Po(t,u,s),s=o.charCodeAt(u)),(s===69||s===101)&&(l=!0,s=o.charCodeAt(++u),(s===43||s===45)&&(s=o.charCodeAt(++u)),u=Po(t,u,s),s=o.charCodeAt(u)),s===46||_p(s))throw He(t,u,"Invalid number, expected digit but got: ".concat(Sr(s),"."));return new ve(l?_.FLOAT:_.INT,e,u,n,i,a,o.slice(e,u))}function Po(t,e,r){var n=t.body,i=e,a=r;if(a>=48&&a<=57){do a=n.charCodeAt(++i);while(a>=48&&a<=57);return i}throw He(t,i,"Invalid number, expected digit but got: ".concat(Sr(a),"."))}function gp(t,e,r,n,i){for(var a=t.body,o=e+1,s=o,u=0,l="";o<a.length&&!isNaN(u=a.charCodeAt(o))&&u!==10&&u!==13;){if(u===34)return l+=a.slice(s,o),new ve(_.STRING,e,o+1,r,n,i,l);if(u<32&&u!==9)throw He(t,o,"Invalid character within String: ".concat(Sr(u),"."));if(++o,u===92){switch(l+=a.slice(s,o-1),u=a.charCodeAt(o),u){case 34:l+='"';break;case 47:l+="/";break;case 92:l+="\\";break;case 98:l+="\b";break;case 102:l+="\f";break;case 110:l+=`
59
59
  `;break;case 114:l+="\r";break;case 116:l+=" ";break;case 117:{var f=Sp(a.charCodeAt(o+1),a.charCodeAt(o+2),a.charCodeAt(o+3),a.charCodeAt(o+4));if(f<0){var d=a.slice(o+1,o+5);throw He(t,o,"Invalid character escape sequence: \\u".concat(d,"."))}l+=String.fromCharCode(f),o+=4;break}default:throw He(t,o,"Invalid character escape sequence: \\".concat(String.fromCharCode(u),"."))}++o,s=o}}throw He(t,o,"Unterminated string.")}function bp(t,e,r,n,i,a){for(var o=t.body,s=e+3,u=s,l=0,f="";s<o.length&&!isNaN(l=o.charCodeAt(s));){if(l===34&&o.charCodeAt(s+1)===34&&o.charCodeAt(s+2)===34)return f+=o.slice(u,s),new ve(_.BLOCK_STRING,e,s+3,r,n,i,lp(f));if(l<32&&l!==9&&l!==10&&l!==13)throw He(t,s,"Invalid character within String: ".concat(Sr(l),"."));l===10?(++s,++a.line,a.lineStart=s):l===13?(o.charCodeAt(s+1)===10?s+=2:++s,++a.line,a.lineStart=s):l===92&&o.charCodeAt(s+1)===34&&o.charCodeAt(s+2)===34&&o.charCodeAt(s+3)===34?(f+=o.slice(u,s)+'"""',s+=4,u=s):++s}throw He(t,s,"Unterminated string.")}function Sp(t,e,r,n){return Fi(t)<<12|Fi(e)<<8|Fi(r)<<4|Fi(n)}function Fi(t){return t>=48&&t<=57?t-48:t>=65&&t<=70?t-55:t>=97&&t<=102?t-87:-1}function wp(t,e,r,n,i){for(var a=t.body,o=a.length,s=e+1,u=0;s!==o&&!isNaN(u=a.charCodeAt(s))&&(u===95||u>=48&&u<=57||u>=65&&u<=90||u>=97&&u<=122);)++s;return new ve(_.NAME,e,s,r,n,i,a.slice(e,s))}function _p(t){return t===95||t>=65&&t<=90||t>=97&&t<=122}function Ep(t,e){var r=new xp(t,e);return r.parseDocument()}var xp=function(){function t(r,n){var i=cp(r)?r:new Lu(r);this._lexer=new pp(i),this._options=n}var e=t.prototype;return e.parseName=function(){var n=this.expectToken(_.NAME);return{kind:j.NAME,value:n.value,loc:this.loc(n)}},e.parseDocument=function(){var n=this._lexer.token;return{kind:j.DOCUMENT,definitions:this.many(_.SOF,this.parseDefinition,_.EOF),loc:this.loc(n)}},e.parseDefinition=function(){if(this.peek(_.NAME))switch(this._lexer.token.value){case"query":case"mutation":case"subscription":return this.parseOperationDefinition();case"fragment":return this.parseFragmentDefinition();case"schema":case"scalar":case"type":case"interface":case"union":case"enum":case"input":case"directive":return this.parseTypeSystemDefinition();case"extend":return this.parseTypeSystemExtension()}else{if(this.peek(_.BRACE_L))return this.parseOperationDefinition();if(this.peekDescription())return this.parseTypeSystemDefinition()}throw this.unexpected()},e.parseOperationDefinition=function(){var n=this._lexer.token;if(this.peek(_.BRACE_L))return{kind:j.OPERATION_DEFINITION,operation:"query",name:void 0,variableDefinitions:[],directives:[],selectionSet:this.parseSelectionSet(),loc:this.loc(n)};var i=this.parseOperationType(),a;return this.peek(_.NAME)&&(a=this.parseName()),{kind:j.OPERATION_DEFINITION,operation:i,name:a,variableDefinitions:this.parseVariableDefinitions(),directives:this.parseDirectives(!1),selectionSet:this.parseSelectionSet(),loc:this.loc(n)}},e.parseOperationType=function(){var n=this.expectToken(_.NAME);switch(n.value){case"query":return"query";case"mutation":return"mutation";case"subscription":return"subscription"}throw this.unexpected(n)},e.parseVariableDefinitions=function(){return this.optionalMany(_.PAREN_L,this.parseVariableDefinition,_.PAREN_R)},e.parseVariableDefinition=function(){var n=this._lexer.token;return{kind:j.VARIABLE_DEFINITION,variable:this.parseVariable(),type:(this.expectToken(_.COLON),this.parseTypeReference()),defaultValue:this.expectOptionalToken(_.EQUALS)?this.parseValueLiteral(!0):void 0,directives:this.parseDirectives(!0),loc:this.loc(n)}},e.parseVariable=function(){var n=this._lexer.token;return this.expectToken(_.DOLLAR),{kind:j.VARIABLE,name:this.parseName(),loc:this.loc(n)}},e.parseSelectionSet=function(){var n=this._lexer.token;return{kind:j.SELECTION_SET,selections:this.many(_.BRACE_L,this.parseSelection,_.BRACE_R),loc:this.loc(n)}},e.parseSelection=function(){return this.peek(_.SPREAD)?this.parseFragment():this.parseField()},e.parseField=function(){var n=this._lexer.token,i=this.parseName(),a,o;return this.expectOptionalToken(_.COLON)?(a=i,o=this.parseName()):o=i,{kind:j.FIELD,alias:a,name:o,arguments:this.parseArguments(!1),directives:this.parseDirectives(!1),selectionSet:this.peek(_.BRACE_L)?this.parseSelectionSet():void 0,loc:this.loc(n)}},e.parseArguments=function(n){var i=n?this.parseConstArgument:this.parseArgument;return this.optionalMany(_.PAREN_L,i,_.PAREN_R)},e.parseArgument=function(){var n=this._lexer.token,i=this.parseName();return this.expectToken(_.COLON),{kind:j.ARGUMENT,name:i,value:this.parseValueLiteral(!1),loc:this.loc(n)}},e.parseConstArgument=function(){var n=this._lexer.token;return{kind:j.ARGUMENT,name:this.parseName(),value:(this.expectToken(_.COLON),this.parseValueLiteral(!0)),loc:this.loc(n)}},e.parseFragment=function(){var n=this._lexer.token;this.expectToken(_.SPREAD);var i=this.expectOptionalKeyword("on");return!i&&this.peek(_.NAME)?{kind:j.FRAGMENT_SPREAD,name:this.parseFragmentName(),directives:this.parseDirectives(!1),loc:this.loc(n)}:{kind:j.INLINE_FRAGMENT,typeCondition:i?this.parseNamedType():void 0,directives:this.parseDirectives(!1),selectionSet:this.parseSelectionSet(),loc:this.loc(n)}},e.parseFragmentDefinition=function(){var n,i=this._lexer.token;return this.expectKeyword("fragment"),((n=this._options)===null||n===void 0?void 0:n.experimentalFragmentVariables)===!0?{kind:j.FRAGMENT_DEFINITION,name:this.parseFragmentName(),variableDefinitions:this.parseVariableDefinitions(),typeCondition:(this.expectKeyword("on"),this.parseNamedType()),directives:this.parseDirectives(!1),selectionSet:this.parseSelectionSet(),loc:this.loc(i)}:{kind:j.FRAGMENT_DEFINITION,name:this.parseFragmentName(),typeCondition:(this.expectKeyword("on"),this.parseNamedType()),directives:this.parseDirectives(!1),selectionSet:this.parseSelectionSet(),loc:this.loc(i)}},e.parseFragmentName=function(){if(this._lexer.token.value==="on")throw this.unexpected();return this.parseName()},e.parseValueLiteral=function(n){var i=this._lexer.token;switch(i.kind){case _.BRACKET_L:return this.parseList(n);case _.BRACE_L:return this.parseObject(n);case _.INT:return this._lexer.advance(),{kind:j.INT,value:i.value,loc:this.loc(i)};case _.FLOAT:return this._lexer.advance(),{kind:j.FLOAT,value:i.value,loc:this.loc(i)};case _.STRING:case _.BLOCK_STRING:return this.parseStringLiteral();case _.NAME:switch(this._lexer.advance(),i.value){case"true":return{kind:j.BOOLEAN,value:!0,loc:this.loc(i)};case"false":return{kind:j.BOOLEAN,value:!1,loc:this.loc(i)};case"null":return{kind:j.NULL,loc:this.loc(i)};default:return{kind:j.ENUM,value:i.value,loc:this.loc(i)}}case _.DOLLAR:if(!n)return this.parseVariable();break}throw this.unexpected()},e.parseStringLiteral=function(){var n=this._lexer.token;return this._lexer.advance(),{kind:j.STRING,value:n.value,block:n.kind===_.BLOCK_STRING,loc:this.loc(n)}},e.parseList=function(n){var i=this,a=this._lexer.token,o=function(){return i.parseValueLiteral(n)};return{kind:j.LIST,values:this.any(_.BRACKET_L,o,_.BRACKET_R),loc:this.loc(a)}},e.parseObject=function(n){var i=this,a=this._lexer.token,o=function(){return i.parseObjectField(n)};return{kind:j.OBJECT,fields:this.any(_.BRACE_L,o,_.BRACE_R),loc:this.loc(a)}},e.parseObjectField=function(n){var i=this._lexer.token,a=this.parseName();return this.expectToken(_.COLON),{kind:j.OBJECT_FIELD,name:a,value:this.parseValueLiteral(n),loc:this.loc(i)}},e.parseDirectives=function(n){for(var i=[];this.peek(_.AT);)i.push(this.parseDirective(n));return i},e.parseDirective=function(n){var i=this._lexer.token;return this.expectToken(_.AT),{kind:j.DIRECTIVE,name:this.parseName(),arguments:this.parseArguments(n),loc:this.loc(i)}},e.parseTypeReference=function(){var n=this._lexer.token,i;return this.expectOptionalToken(_.BRACKET_L)?(i=this.parseTypeReference(),this.expectToken(_.BRACKET_R),i={kind:j.LIST_TYPE,type:i,loc:this.loc(n)}):i=this.parseNamedType(),this.expectOptionalToken(_.BANG)?{kind:j.NON_NULL_TYPE,type:i,loc:this.loc(n)}:i},e.parseNamedType=function(){var n=this._lexer.token;return{kind:j.NAMED_TYPE,name:this.parseName(),loc:this.loc(n)}},e.parseTypeSystemDefinition=function(){var n=this.peekDescription()?this._lexer.lookahead():this._lexer.token;if(n.kind===_.NAME)switch(n.value){case"schema":return this.parseSchemaDefinition();case"scalar":return this.parseScalarTypeDefinition();case"type":return this.parseObjectTypeDefinition();case"interface":return this.parseInterfaceTypeDefinition();case"union":return this.parseUnionTypeDefinition();case"enum":return this.parseEnumTypeDefinition();case"input":return this.parseInputObjectTypeDefinition();case"directive":return this.parseDirectiveDefinition()}throw this.unexpected(n)},e.peekDescription=function(){return this.peek(_.STRING)||this.peek(_.BLOCK_STRING)},e.parseDescription=function(){if(this.peekDescription())return this.parseStringLiteral()},e.parseSchemaDefinition=function(){var n=this._lexer.token,i=this.parseDescription();this.expectKeyword("schema");var a=this.parseDirectives(!0),o=this.many(_.BRACE_L,this.parseOperationTypeDefinition,_.BRACE_R);return{kind:j.SCHEMA_DEFINITION,description:i,directives:a,operationTypes:o,loc:this.loc(n)}},e.parseOperationTypeDefinition=function(){var n=this._lexer.token,i=this.parseOperationType();this.expectToken(_.COLON);var a=this.parseNamedType();return{kind:j.OPERATION_TYPE_DEFINITION,operation:i,type:a,loc:this.loc(n)}},e.parseScalarTypeDefinition=function(){var n=this._lexer.token,i=this.parseDescription();this.expectKeyword("scalar");var a=this.parseName(),o=this.parseDirectives(!0);return{kind:j.SCALAR_TYPE_DEFINITION,description:i,name:a,directives:o,loc:this.loc(n)}},e.parseObjectTypeDefinition=function(){var n=this._lexer.token,i=this.parseDescription();this.expectKeyword("type");var a=this.parseName(),o=this.parseImplementsInterfaces(),s=this.parseDirectives(!0),u=this.parseFieldsDefinition();return{kind:j.OBJECT_TYPE_DEFINITION,description:i,name:a,interfaces:o,directives:s,fields:u,loc:this.loc(n)}},e.parseImplementsInterfaces=function(){var n;if(!this.expectOptionalKeyword("implements"))return[];if(((n=this._options)===null||n===void 0?void 0:n.allowLegacySDLImplementsInterfaces)===!0){var i=[];this.expectOptionalToken(_.AMP);do i.push(this.parseNamedType());while(this.expectOptionalToken(_.AMP)||this.peek(_.NAME));return i}return this.delimitedMany(_.AMP,this.parseNamedType)},e.parseFieldsDefinition=function(){var n;return((n=this._options)===null||n===void 0?void 0:n.allowLegacySDLEmptyFields)===!0&&this.peek(_.BRACE_L)&&this._lexer.lookahead().kind===_.BRACE_R?(this._lexer.advance(),this._lexer.advance(),[]):this.optionalMany(_.BRACE_L,this.parseFieldDefinition,_.BRACE_R)},e.parseFieldDefinition=function(){var n=this._lexer.token,i=this.parseDescription(),a=this.parseName(),o=this.parseArgumentDefs();this.expectToken(_.COLON);var s=this.parseTypeReference(),u=this.parseDirectives(!0);return{kind:j.FIELD_DEFINITION,description:i,name:a,arguments:o,type:s,directives:u,loc:this.loc(n)}},e.parseArgumentDefs=function(){return this.optionalMany(_.PAREN_L,this.parseInputValueDef,_.PAREN_R)},e.parseInputValueDef=function(){var n=this._lexer.token,i=this.parseDescription(),a=this.parseName();this.expectToken(_.COLON);var o=this.parseTypeReference(),s;this.expectOptionalToken(_.EQUALS)&&(s=this.parseValueLiteral(!0));var u=this.parseDirectives(!0);return{kind:j.INPUT_VALUE_DEFINITION,description:i,name:a,type:o,defaultValue:s,directives:u,loc:this.loc(n)}},e.parseInterfaceTypeDefinition=function(){var n=this._lexer.token,i=this.parseDescription();this.expectKeyword("interface");var a=this.parseName(),o=this.parseImplementsInterfaces(),s=this.parseDirectives(!0),u=this.parseFieldsDefinition();return{kind:j.INTERFACE_TYPE_DEFINITION,description:i,name:a,interfaces:o,directives:s,fields:u,loc:this.loc(n)}},e.parseUnionTypeDefinition=function(){var n=this._lexer.token,i=this.parseDescription();this.expectKeyword("union");var a=this.parseName(),o=this.parseDirectives(!0),s=this.parseUnionMemberTypes();return{kind:j.UNION_TYPE_DEFINITION,description:i,name:a,directives:o,types:s,loc:this.loc(n)}},e.parseUnionMemberTypes=function(){return this.expectOptionalToken(_.EQUALS)?this.delimitedMany(_.PIPE,this.parseNamedType):[]},e.parseEnumTypeDefinition=function(){var n=this._lexer.token,i=this.parseDescription();this.expectKeyword("enum");var a=this.parseName(),o=this.parseDirectives(!0),s=this.parseEnumValuesDefinition();return{kind:j.ENUM_TYPE_DEFINITION,description:i,name:a,directives:o,values:s,loc:this.loc(n)}},e.parseEnumValuesDefinition=function(){return this.optionalMany(_.BRACE_L,this.parseEnumValueDefinition,_.BRACE_R)},e.parseEnumValueDefinition=function(){var n=this._lexer.token,i=this.parseDescription(),a=this.parseName(),o=this.parseDirectives(!0);return{kind:j.ENUM_VALUE_DEFINITION,description:i,name:a,directives:o,loc:this.loc(n)}},e.parseInputObjectTypeDefinition=function(){var n=this._lexer.token,i=this.parseDescription();this.expectKeyword("input");var a=this.parseName(),o=this.parseDirectives(!0),s=this.parseInputFieldsDefinition();return{kind:j.INPUT_OBJECT_TYPE_DEFINITION,description:i,name:a,directives:o,fields:s,loc:this.loc(n)}},e.parseInputFieldsDefinition=function(){return this.optionalMany(_.BRACE_L,this.parseInputValueDef,_.BRACE_R)},e.parseTypeSystemExtension=function(){var n=this._lexer.lookahead();if(n.kind===_.NAME)switch(n.value){case"schema":return this.parseSchemaExtension();case"scalar":return this.parseScalarTypeExtension();case"type":return this.parseObjectTypeExtension();case"interface":return this.parseInterfaceTypeExtension();case"union":return this.parseUnionTypeExtension();case"enum":return this.parseEnumTypeExtension();case"input":return this.parseInputObjectTypeExtension()}throw this.unexpected(n)},e.parseSchemaExtension=function(){var n=this._lexer.token;this.expectKeyword("extend"),this.expectKeyword("schema");var i=this.parseDirectives(!0),a=this.optionalMany(_.BRACE_L,this.parseOperationTypeDefinition,_.BRACE_R);if(i.length===0&&a.length===0)throw this.unexpected();return{kind:j.SCHEMA_EXTENSION,directives:i,operationTypes:a,loc:this.loc(n)}},e.parseScalarTypeExtension=function(){var n=this._lexer.token;this.expectKeyword("extend"),this.expectKeyword("scalar");var i=this.parseName(),a=this.parseDirectives(!0);if(a.length===0)throw this.unexpected();return{kind:j.SCALAR_TYPE_EXTENSION,name:i,directives:a,loc:this.loc(n)}},e.parseObjectTypeExtension=function(){var n=this._lexer.token;this.expectKeyword("extend"),this.expectKeyword("type");var i=this.parseName(),a=this.parseImplementsInterfaces(),o=this.parseDirectives(!0),s=this.parseFieldsDefinition();if(a.length===0&&o.length===0&&s.length===0)throw this.unexpected();return{kind:j.OBJECT_TYPE_EXTENSION,name:i,interfaces:a,directives:o,fields:s,loc:this.loc(n)}},e.parseInterfaceTypeExtension=function(){var n=this._lexer.token;this.expectKeyword("extend"),this.expectKeyword("interface");var i=this.parseName(),a=this.parseImplementsInterfaces(),o=this.parseDirectives(!0),s=this.parseFieldsDefinition();if(a.length===0&&o.length===0&&s.length===0)throw this.unexpected();return{kind:j.INTERFACE_TYPE_EXTENSION,name:i,interfaces:a,directives:o,fields:s,loc:this.loc(n)}},e.parseUnionTypeExtension=function(){var n=this._lexer.token;this.expectKeyword("extend"),this.expectKeyword("union");var i=this.parseName(),a=this.parseDirectives(!0),o=this.parseUnionMemberTypes();if(a.length===0&&o.length===0)throw this.unexpected();return{kind:j.UNION_TYPE_EXTENSION,name:i,directives:a,types:o,loc:this.loc(n)}},e.parseEnumTypeExtension=function(){var n=this._lexer.token;this.expectKeyword("extend"),this.expectKeyword("enum");var i=this.parseName(),a=this.parseDirectives(!0),o=this.parseEnumValuesDefinition();if(a.length===0&&o.length===0)throw this.unexpected();return{kind:j.ENUM_TYPE_EXTENSION,name:i,directives:a,values:o,loc:this.loc(n)}},e.parseInputObjectTypeExtension=function(){var n=this._lexer.token;this.expectKeyword("extend"),this.expectKeyword("input");var i=this.parseName(),a=this.parseDirectives(!0),o=this.parseInputFieldsDefinition();if(a.length===0&&o.length===0)throw this.unexpected();return{kind:j.INPUT_OBJECT_TYPE_EXTENSION,name:i,directives:a,fields:o,loc:this.loc(n)}},e.parseDirectiveDefinition=function(){var n=this._lexer.token,i=this.parseDescription();this.expectKeyword("directive"),this.expectToken(_.AT);var a=this.parseName(),o=this.parseArgumentDefs(),s=this.expectOptionalKeyword("repeatable");this.expectKeyword("on");var u=this.parseDirectiveLocations();return{kind:j.DIRECTIVE_DEFINITION,description:i,name:a,arguments:o,repeatable:s,locations:u,loc:this.loc(n)}},e.parseDirectiveLocations=function(){return this.delimitedMany(_.PIPE,this.parseDirectiveLocation)},e.parseDirectiveLocation=function(){var n=this._lexer.token,i=this.parseName();if(up[i.value]!==void 0)return i;throw this.unexpected(n)},e.loc=function(n){var i;if(((i=this._options)===null||i===void 0?void 0:i.noLocation)!==!0)return new Cu(n,this._lexer.lastToken,this._lexer.source)},e.peek=function(n){return this._lexer.token.kind===n},e.expectToken=function(n){var i=this._lexer.token;if(i.kind===n)return this._lexer.advance(),i;throw He(this._lexer.source,i.start,"Expected ".concat(Fu(n),", found ").concat(Co(i),"."))},e.expectOptionalToken=function(n){var i=this._lexer.token;if(i.kind===n)return this._lexer.advance(),i},e.expectKeyword=function(n){var i=this._lexer.token;if(i.kind===_.NAME&&i.value===n)this._lexer.advance();else throw He(this._lexer.source,i.start,'Expected "'.concat(n,'", found ').concat(Co(i),"."))},e.expectOptionalKeyword=function(n){var i=this._lexer.token;return i.kind===_.NAME&&i.value===n?(this._lexer.advance(),!0):!1},e.unexpected=function(n){var i=n??this._lexer.token;return He(this._lexer.source,i.start,"Unexpected ".concat(Co(i),"."))},e.any=function(n,i,a){this.expectToken(n);for(var o=[];!this.expectOptionalToken(a);)o.push(i.call(this));return o},e.optionalMany=function(n,i,a){if(this.expectOptionalToken(n)){var o=[];do o.push(i.call(this));while(!this.expectOptionalToken(a));return o}return[]},e.many=function(n,i,a){this.expectToken(n);var o=[];do o.push(i.call(this));while(!this.expectOptionalToken(a));return o},e.delimitedMany=function(n,i){this.expectOptionalToken(n);var a=[];do a.push(i.call(this));while(this.expectOptionalToken(n));return a},t}();function Co(t){var e=t.value;return Fu(t.kind)+(e!=null?' "'.concat(e,'"'):"")}function Fu(t){return dp(t)?'"'.concat(t,'"'):t}var Ki=new Map,Uo=new Map,Mu=!0,ta=!1;function ju(t){return t.replace(/[\s,]+/g," ").trim()}function Op(t){return ju(t.source.body.substring(t.start,t.end))}function Tp(t){var e=new Set,r=[];return t.definitions.forEach(function(n){if(n.kind==="FragmentDefinition"){var i=n.name.value,a=Op(n.loc),o=Uo.get(i);o&&!o.has(a)?Mu&&console.warn("Warning: fragment with name "+i+` already exists.
60
60
  graphql-tag enforces all fragment names across your application to be unique; read more about
61
- this in the docs: http://dev.apollodata.com/core/fragments.html#unique-names`):o||Uo.set(i,o=new Set),o.add(a),e.has(a)||(e.add(a),r.push(n))}else r.push(n)}),ea(ea({},t),{definitions:r})}function Ip(t){var e=new Set(t.definitions);e.forEach(function(n){n.loc&&delete n.loc,Object.keys(n).forEach(function(i){var a=n[i];a&&typeof a=="object"&&e.add(a)})});var r=t.loc;return r&&(delete r.startToken,delete r.endToken),t}function Dp(t){var e=ju(t);if(!Ki.has(e)){var r=Ep(t,{experimentalFragmentVariables:ta,allowLegacyFragmentVariables:ta});if(!r||r.kind!=="Document")throw new Error("Not a valid GraphQL document.");Ki.set(e,Ip(Tp(r)))}return Ki.get(e)}function O(t){for(var e=[],r=1;r<arguments.length;r++)e[r-1]=arguments[r];typeof t=="string"&&(t=[t]);var n=t[0];return e.forEach(function(i,a){i&&i.kind==="Document"?n+=i.loc.source.body:n+=i,n+=t[a+1]}),Dp(n)}function kp(){Ki.clear(),Uo.clear()}function Ap(){Mu=!1}function Np(){ta=!0}function Pp(){ta=!1}var kn={gql:O,resetCaches:kp,disableFragmentWarnings:Ap,enableExperimentalFragmentVariables:Np,disableExperimentalFragmentVariables:Pp};(function(t){t.gql=kn.gql,t.resetCaches=kn.resetCaches,t.disableFragmentWarnings=kn.disableFragmentWarnings,t.enableExperimentalFragmentVariables=kn.enableExperimentalFragmentVariables,t.disableExperimentalFragmentVariables=kn.disableExperimentalFragmentVariables})(O||(O={}));O.default=O;function D(t){if(!t)throw"Got no result from Apollo";if(t.error)throw t.error;if(t.errors)throw t.errors;return t.data}function Cp(){}function Zo(){return Cp}var g=Zo,$e=Zo,J=Zo,$u=function(t,e,r,n){var i=arguments.length,a=i<3?e:n===null?n=Object.getOwnPropertyDescriptor(e,r):n,o;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")a=Reflect.decorate(t,e,r,n);else for(var s=t.length-1;s>=0;s--)(o=t[s])&&(a=(i<3?o(a):i>3?o(e,r,a):o(e,r))||a);return i>3&&a&&Object.defineProperty(e,r,a),a},Uu=function(t,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(t,e)},wr=class{constructor(e){this.code=e}};$u([g(),Uu("design:type",String)],wr.prototype,"code",void 0);wr=$u([J(),Uu("design:paramtypes",[String])],wr);var es=function(t,e,r,n){var i=arguments.length,a=i<3?e:n===null?n=Object.getOwnPropertyDescriptor(e,r):n,o;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")a=Reflect.decorate(t,e,r,n);else for(var s=t.length-1;s>=0;s--)(o=t[s])&&(a=(i<3?o(a):i>3?o(e,r,a):o(e,r))||a);return i>3&&a&&Object.defineProperty(e,r,a),a},ts=function(t,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(t,e)},gt=class{constructor(e,r){this.address=e,this.name=r}};es([g(),ts("design:type",String)],gt.prototype,"address",void 0);es([g(),ts("design:type",String)],gt.prototype,"name",void 0);gt=es([J(),ts("design:paramtypes",[String,String])],gt);var ue=function(t,e,r,n){var i=arguments.length,a=i<3?e:n===null?n=Object.getOwnPropertyDescriptor(e,r):n,o;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")a=Reflect.decorate(t,e,r,n);else for(var s=t.length-1;s>=0;s--)(o=t[s])&&(a=(i<3?o(a):i>3?o(e,r,a):o(e,r))||a);return i>3&&a&&Object.defineProperty(e,r,a),a},_e=function(t,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(t,e)},Gt=class{constructor(e,r){this.key=r,this.signature=e}};ue([g(),_e("design:type",String)],Gt.prototype,"signature",void 0);ue([g(),_e("design:type",String)],Gt.prototype,"key",void 0);ue([g(),_e("design:type",Boolean)],Gt.prototype,"valid",void 0);ue([g(),_e("design:type",Boolean)],Gt.prototype,"invalid",void 0);Gt=ue([J(),$e(),_e("design:paramtypes",[String,String])],Gt);var _r=class{};ue([g(),_e("design:type",String)],_r.prototype,"signature",void 0);ue([g(),_e("design:type",String)],_r.prototype,"key",void 0);ue([g(),_e("design:type",Boolean)],_r.prototype,"valid",void 0);ue([g(),_e("design:type",Boolean)],_r.prototype,"invalid",void 0);_r=ue([$e()],_r);function Xt(t){let e=class{constructor(n,i,a,o){this.author=n,this.timestamp=i,this.data=a,this.proof=o}};return ue([g(),_e("design:type",String)],e.prototype,"author",void 0),ue([g(),_e("design:type",String)],e.prototype,"timestamp",void 0),ue([g(),_e("design:type",Object)],e.prototype,"data",void 0),ue([g(),_e("design:type",Gt)],e.prototype,"proof",void 0),e=ue([J(),_e("design:paramtypes",[String,String,Object,Gt])],e),e}function Rp(t){let e=class{};return ue([g(),_e("design:type",String)],e.prototype,"author",void 0),ue([g(),_e("design:type",String)],e.prototype,"timestamp",void 0),ue([g(),_e("design:type",Object)],e.prototype,"data",void 0),ue([g(),_e("design:type",_r)],e.prototype,"proof",void 0),e=ue([$e()],e),e}var pu=class extends Xt(){};pu=ue([J()],pu);var ra=class extends Xt(){};ue([g(),_e("design:type",gt)],ra.prototype,"language",void 0);ue([g(),_e("design:type",wr)],ra.prototype,"icon",void 0);ra=ue([J()],ra);function kS(t){return t&&t.author&&t.timestamp&&t.data}var Se=function(t,e,r,n){var i=arguments.length,a=i<3?e:n===null?n=Object.getOwnPropertyDescriptor(e,r):n,o;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")a=Reflect.decorate(t,e,r,n);else for(var s=t.length-1;s>=0;s--)(o=t[s])&&(a=(i<3?o(a):i>3?o(e,r,a):o(e,r))||a);return i>3&&a&&Object.defineProperty(e,r,a),a},Ae=function(t,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(t,e)},bt=class{constructor(e){this.source=e.source?e.source:"",this.target=e.target?e.target:"",this.predicate=e.predicate?e.predicate:""}};Se([g(),Ae("design:type",String)],bt.prototype,"source",void 0);Se([g(),Ae("design:type",String)],bt.prototype,"target",void 0);Se([g(),Ae("design:type",String)],bt.prototype,"predicate",void 0);bt=Se([J(),Ae("design:paramtypes",[Object])],bt);var na=class{};Se([g(),Ae("design:type",Array)],na.prototype,"additions",void 0);Se([g(),Ae("design:type",Array)],na.prototype,"removals",void 0);na=Se([$e()],na);var ia=class{constructor(e,r){this.additions=e,this.removals=r}};Se([g(),Ae("design:type",Array)],ia.prototype,"additions",void 0);Se([g(),Ae("design:type",Array)],ia.prototype,"removals",void 0);ia=Se([J(),Ae("design:paramtypes",[Array,Array])],ia);var Kn=class{};Se([g(),Ae("design:type",String)],Kn.prototype,"source",void 0);Se([g(),Ae("design:type",String)],Kn.prototype,"target",void 0);Se([g(),Ae("design:type",String)],Kn.prototype,"predicate",void 0);Kn=Se([$e()],Kn);var Er=class extends Xt(){hash(){let e=JSON.stringify(this.data,Object.keys(this.data).sort())+JSON.stringify(this.author)+this.timestamp,r=0,n,i;for(n=0;n<e.length;n++)i=e.charCodeAt(n),r=(r<<5)-r+i,r|=0;return r}};Se([g(),Ae("design:type",String)],Er.prototype,"status",void 0);Er=Se([J()],Er);var qo=class extends Rp(){};Se([g(),Ae("design:type",String)],qo.prototype,"status",void 0);qo=Se([$e()],qo);function FS(t,e){return t.author==e.author&&t.timestamp==e.timestamp&&t.data.source==e.data.source&&t.data.predicate==e.data.predicate&&t.data.target==e.data.target}function MS(t){return t&&t.source&&t.target}var aa=class{constructor(e,r){this.oldLink=e,this.newLink=r}};Se([g(),Ae("design:type",Er)],aa.prototype,"oldLink",void 0);Se([g(),Ae("design:type",Er)],aa.prototype,"newLink",void 0);aa=Se([J(),Ae("design:paramtypes",[Er,Er])],aa);var Or=function(t,e,r,n){var i=arguments.length,a=i<3?e:n===null?n=Object.getOwnPropertyDescriptor(e,r):n,o;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")a=Reflect.decorate(t,e,r,n);else for(var s=t.length-1;s>=0;s--)(o=t[s])&&(a=(i<3?o(a):i>3?o(e,r,a):o(e,r))||a);return i>3&&a&&Object.defineProperty(e,r,a),a},Yn=function(t,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(t,e)},Vo,Kt=class{constructor(e){e?this.links=e:this.links=[]}get(e){if(!e||!e.source&&!e.predicate&&!e.target)return this.links;if(e.source){let n=JSON.parse(JSON.stringify(this.links));return e.target&&(n=n.filter(i=>i.data.target===e.target)),e.predicate&&(n=n.filter(i=>i.data.predicate===e.predicate)),e.fromDate&&(n=n.filter(i=>new Date(i.timestamp)>=e.fromDate)),e.untilDate&&(n=n.filter(i=>new Date(i.timestamp)<=e.untilDate)),e.limit&&(n=n.slice(0,e.limit)),n}if(e.target){let n=JSON.parse(JSON.stringify(this.links));return e.predicate&&(n=n.filter(i=>i.data.predicate===e.predicate)),e.fromDate&&(n=n.filter(i=>new Date(i.timestamp)>=e.fromDate)),e.untilDate&&(n=n.filter(i=>new Date(i.timestamp)<=e.untilDate)),e.limit&&(n=n.slice(0,e.limit)),n}let r=JSON.parse(JSON.stringify(this.links));return r=r.filter(n=>n.data.predicate===e.predicate),e.limit&&(r=r.slice(0,e.limit)),r}getSingleTarget(e){delete e.target;let r=this.get(e);return r.length?r[0].data.target:null}};Or([g(),Yn("design:type",Array)],Kt.prototype,"links",void 0);Kt=Or([J(),Yn("design:paramtypes",[Array])],Kt);var Bo=class{};Or([g(),Yn("design:type",Array)],Bo.prototype,"links",void 0);Bo=Or([$e()],Bo);var Qo=Vo=class{constructor(e){e?this.links=e:this.links=[]}static fromLink(e){let r=new Vo;return r.links.push(e),r}};Or([g(),Yn("design:type",Array)],Qo.prototype,"links",void 0);Qo=Vo=Or([$e(),Yn("design:paramtypes",[Array])],Qo);var Wo=class extends Xt(){};Wo=Or([J()],Wo);var L=function(t,e,r,n){var i=arguments.length,a=i<3?e:n===null?n=Object.getOwnPropertyDescriptor(e,r):n,o;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")a=Reflect.decorate(t,e,r,n);else for(var s=t.length-1;s>=0;s--)(o=t[s])&&(a=(i<3?o(a):i>3?o(e,r,a):o(e,r))||a);return i>3&&a&&Object.defineProperty(e,r,a),a},F=function(t,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(t,e)},Qt=class{constructor(e,r){this.did=e,r?this.perspective=r:this.perspective=new Kt}};L([g(),F("design:type",String)],Qt.prototype,"did",void 0);L([g(),F("design:type",Kt)],Qt.prototype,"perspective",void 0);L([g(),F("design:type",String)],Qt.prototype,"directMessageLanguage",void 0);Qt=L([J(),F("design:paramtypes",[String,Kt])],Qt);var du=class extends Xt(){};du=L([J()],du);var zt=class{constructor(e,r,n,i,a,o){this.did=e,this.didSigningKeyId=r,this.deviceKeyType=n,this.deviceKey=i,this.deviceKeySignedByDid=a,this.didSignedByDeviceKey=o}};L([g(),F("design:type",String)],zt.prototype,"did",void 0);L([g(),F("design:type",String)],zt.prototype,"didSigningKeyId",void 0);L([g(),F("design:type",String)],zt.prototype,"deviceKeyType",void 0);L([g(),F("design:type",String)],zt.prototype,"deviceKey",void 0);L([g(),F("design:type",String)],zt.prototype,"deviceKeySignedByDid",void 0);L([g(),F("design:type",String)],zt.prototype,"didSignedByDeviceKey",void 0);zt=L([J(),F("design:paramtypes",[String,String,String,String,String,String])],zt);var Jt=class{constructor(e,r,n,i,a,o){this.did=e,this.didSigningKeyId=r,this.deviceKeyType=n,this.deviceKey=i,this.deviceKeySignedByDid=a,this.didSignedByDeviceKey=o}};L([g(),F("design:type",String)],Jt.prototype,"did",void 0);L([g(),F("design:type",String)],Jt.prototype,"didSigningKeyId",void 0);L([g(),F("design:type",String)],Jt.prototype,"deviceKeyType",void 0);L([g(),F("design:type",String)],Jt.prototype,"deviceKey",void 0);L([g(),F("design:type",String)],Jt.prototype,"deviceKeySignedByDid",void 0);L([g(),F("design:type",String)],Jt.prototype,"didSignedByDeviceKey",void 0);Jt=L([$e(),F("design:paramtypes",[String,String,String,String,String,String])],Jt);var oa=class{constructor(e,r){this.signature=e,this.publicKey=r}};L([g(),F("design:type",String)],oa.prototype,"signature",void 0);L([g(),F("design:type",String)],oa.prototype,"publicKey",void 0);oa=L([J(),F("design:paramtypes",[String,String])],oa);var Zr=class{constructor(e,r){this.domain=e,this.pointers=r}};L([g(),F("design:type",String)],Zr.prototype,"domain",void 0);L([g(),F("design:type",Array)],Zr.prototype,"pointers",void 0);Zr=L([J(),F("design:paramtypes",[String,Array])],Zr);var sa=class{constructor(e,r){this.with=e,this.can=r}};L([g(),F("design:type",Zr)],sa.prototype,"with",void 0);L([g(),F("design:type",Array)],sa.prototype,"can",void 0);sa=L([J(),F("design:paramtypes",[Zr,Array])],sa);var Nt=class{constructor(e,r,n,i,a){this.appName=e,this.appDesc=r,this.appIconPath=a,this.appUrl=n,this.capabilities=i}};L([g(),F("design:type",String)],Nt.prototype,"appName",void 0);L([g(),F("design:type",String)],Nt.prototype,"appDesc",void 0);L([g(),F("design:type",String)],Nt.prototype,"appUrl",void 0);L([g(),F("design:type",String)],Nt.prototype,"appIconPath",void 0);L([g(),F("design:type",Array)],Nt.prototype,"capabilities",void 0);Nt=L([J(),F("design:paramtypes",[String,String,String,Array,String])],Nt);var en=class{constructor(e,r,n,i){this.requestId=e,this.auth=r,this.token=n,this.revoked=i}};L([g(),F("design:type",String)],en.prototype,"requestId",void 0);L([g(),F("design:type",String)],en.prototype,"token",void 0);L([g(),F("design:type",Boolean)],en.prototype,"revoked",void 0);L([g(),F("design:type",Nt)],en.prototype,"auth",void 0);en=L([J(),F("design:paramtypes",[String,Nt,String,Boolean])],en);var tn=class{constructor(e,r){this.domain=e,this.pointers=r}};L([g(),F("design:type",String)],tn.prototype,"domain",void 0);L([g(),F("design:type",Array)],tn.prototype,"pointers",void 0);tn=L([$e(),F("design:paramtypes",[String,Array])],tn);var ca=class{constructor(e,r){this.with=e,this.can=r}};L([g(),F("design:type",tn)],ca.prototype,"with",void 0);L([g(),F("design:type",Array)],ca.prototype,"can",void 0);ca=L([$e(),F("design:paramtypes",[tn,Array])],ca);var Ht=class{constructor(e,r,n,i,a,o){this.appName=e,this.appDesc=r,this.appUrl=i,this.appDomain=n,this.capabilities=o,this.appIconPath=a}};L([g(),F("design:type",String)],Ht.prototype,"appName",void 0);L([g(),F("design:type",String)],Ht.prototype,"appDesc",void 0);L([g(),F("design:type",String)],Ht.prototype,"appDomain",void 0);L([g(),F("design:type",String)],Ht.prototype,"appUrl",void 0);L([g(),F("design:type",String)],Ht.prototype,"appIconPath",void 0);L([g(),F("design:type",Array)],Ht.prototype,"capabilities",void 0);Ht=L([$e(),F("design:paramtypes",[String,String,String,String,String,Array])],Ht);var nn=function(t,e,r,n){var i=arguments.length,a=i<3?e:n===null?n=Object.getOwnPropertyDescriptor(e,r):n,o;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")a=Reflect.decorate(t,e,r,n);else for(var s=t.length-1;s>=0;s--)(o=t[s])&&(a=(i<3?o(a):i>3?o(e,r,a):o(e,r))||a);return i>3&&a&&Object.defineProperty(e,r,a),a},an=function(t,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(t,e)},rt=class{constructor(e){e?(this.isInitialized=e.isInitialized,this.isInitialized||(this.isInitialized=!1),this.isUnlocked=e.isUnlocked,this.isUnlocked||(this.isUnlocked=!1),this.did=e.did,this.didDocument=e.didDocument,this.error=e.error):(this.isInitialized=!1,this.isUnlocked=!1)}};nn([g(),an("design:type",Boolean)],rt.prototype,"isInitialized",void 0);nn([g(),an("design:type",Boolean)],rt.prototype,"isUnlocked",void 0);nn([g(),an("design:type",String)],rt.prototype,"did",void 0);nn([g(),an("design:type",String)],rt.prototype,"didDocument",void 0);nn([g(),an("design:type",String)],rt.prototype,"error",void 0);rt=nn([J(),an("design:paramtypes",[Object])],rt);var hu=function(t,e,r,n,i){if(n==="m")throw new TypeError("Private method is not writable");if(n==="a"&&!i)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?i.call(t,r):i?i.value=r:e.set(t,r),r},ye=function(t,e,r,n){if(r==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!n:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?n:r==="a"?n.call(t):n?n.value:e.get(t)},Qe,We,Go=class{constructor(e,r){Qe.set(this,void 0),We.set(this,void 0),hu(this,Qe,e,"f"),hu(this,We,r,"f")}async otherAgents(){return await ye(this,Qe,"f").otherAgents(ye(this,We,"f"))}async hasTelepresenceAdapter(){return await ye(this,Qe,"f").hasTelepresenceAdapter(ye(this,We,"f"))}async onlineAgents(){return await ye(this,Qe,"f").onlineAgents(ye(this,We,"f"))}async setOnlineStatus(e){return await ye(this,Qe,"f").setOnlineStatus(ye(this,We,"f"),e)}async setOnlineStatusU(e){return await ye(this,Qe,"f").setOnlineStatusU(ye(this,We,"f"),e)}async sendSignal(e,r){return await ye(this,Qe,"f").sendSignal(ye(this,We,"f"),e,r)}async sendSignalU(e,r){return await ye(this,Qe,"f").sendSignalU(ye(this,We,"f"),e,r)}async sendBroadcast(e){return await ye(this,Qe,"f").sendBroadcast(ye(this,We,"f"),e)}async sendBroadcastU(e){return await ye(this,Qe,"f").sendBroadcastU(ye(this,We,"f"),e)}async addSignalHandler(e){await ye(this,Qe,"f").addSignalHandler(ye(this,We,"f"),e)}removeSignalHandler(e){ye(this,Qe,"f").removeSignalHandler(ye(this,We,"f"),e)}};Qe=new WeakMap,We=new WeakMap;var Tr=function(t,e,r,n){var i=arguments.length,a=i<3?e:n===null?n=Object.getOwnPropertyDescriptor(e,r):n,o;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")a=Reflect.decorate(t,e,r,n);else for(var s=t.length-1;s>=0;s--)(o=t[s])&&(a=(i<3?o(a):i>3?o(e,r,a):o(e,r))||a);return i>3&&a&&Object.defineProperty(e,r,a),a},Ir=function(t,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(t,e)},je=class{constructor(e){e&&(this.source=e.source,this.predicate=e.predicate,this.target=e.target,e.fromDate&&(this.fromDate=e.fromDate),e.untilDate&&(this.untilDate=e.untilDate),e.limit&&(this.limit=e.limit))}isMatch(e){return!(this.source&&this.source!==e.source||this.predicate&&this.predicate!==e.predicate||this.target&&this.target!==e.target)}};Tr([g(),Ir("design:type",String)],je.prototype,"source",void 0);Tr([g(),Ir("design:type",String)],je.prototype,"target",void 0);Tr([g(),Ir("design:type",String)],je.prototype,"predicate",void 0);Tr([g(),Ir("design:type",Date)],je.prototype,"fromDate",void 0);Tr([g(),Ir("design:type",Date)],je.prototype,"untilDate",void 0);Tr([g(),Ir("design:type",Number)],je.prototype,"limit",void 0);je=Tr([J(),$e(),Ir("design:paramtypes",[Object])],je);var mu=function(t,e,r,n,i){if(n==="m")throw new TypeError("Private method is not writable");if(n==="a"&&!i)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?i.call(t,r):i?i.value=r:e.set(t,r),r},Be=function(t,e,r,n){if(r==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!n:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?n:r==="a"?n.call(t):n?n.value:e.get(t)},ct,It;function Ro(t){return encodeURIComponent(t).replace(/[!'()*]/g,e=>`%${e.charCodeAt(0).toString(16).toUpperCase()}`)}var St=class{constructor(){ct.set(this,void 0),It.set(this,void 0)}static fromUrl(e){if(!e||!e.startsWith("literal://"))throw new Error("Can't create Literal from non-literal URL");let r=new St;return mu(r,It,e,"f"),r}static from(e){let r=new St;return mu(r,ct,e,"f"),r}toUrl(){if(Be(this,It,"f")&&!Be(this,ct,"f"))return Be(this,It,"f");if(!Be(this,It,"f")&&!Be(this,ct,"f"))throw new Error("Can't turn empty Literal into URL");let e;switch(typeof Be(this,ct,"f")){case"string":e=`string:${Ro(Be(this,ct,"f"))}`;break;case"number":e=`number:${Ro(Be(this,ct,"f"))}`;break;case"object":e=`json:${Ro(JSON.stringify(Be(this,ct,"f")))}`;break}return`literal://${e}`}get(){if(Be(this,ct,"f"))return Be(this,ct,"f");if(!Be(this,It,"f"))throw new Error("Can't render empty Literal");if(!Be(this,It,"f").startsWith("literal://"))throw new Error("Can't render Literal from non-literal URL");let e=Be(this,It,"f").substring(10);if(e.startsWith("string:"))return decodeURIComponent(e.substring(7));if(e.startsWith("number:")){let r=e.substring(7);return parseFloat(r)}if(e.startsWith("json:")){let r=e.substring(5);return JSON.parse(decodeURIComponent(r))}throw new Error(`Can't parse unknown literal: ${e}`)}};ct=new WeakMap,It=new WeakMap;function Wt(t){return t.charAt(0).toUpperCase()+t.slice(1)}function qu(t){return`set${Wt(t)}`}function At(t){return t.endsWith("y")?t.slice(0,-1)+"ies":t+"s"}function rs(t){return t.endsWith("ies")?t.slice(0,-3)+"y":t.endsWith("s")?t.slice(0,-1):t}function Lp(t){return`add${Wt(rs(t))}`}function Fp(t){let e=t.substring(3),r=At(e);return r.charAt(0).toLowerCase()+r.slice(1)}function Mp(t){return`remove${Wt(rs(t))}`}function jp(t){let e=t.substring(6),r=At(e);return r.charAt(0).toLowerCase()+r.slice(1)}function $p(t){let e=t.substring(13),r=At(e);return r.charAt(0).toLowerCase()+r.slice(1)}function Up(t){return`setCollection${Wt(rs(t))}`}function dr(t){if(Array.isArray(t))return`[${t.map(dr).join(", ")}]`;let e=Object.keys(t),r=[];for(let n of e){let i=JSON.stringify(t[n]),a=`${n}: ${i}`;r.push(a)}return`{${r.join(", ")}}`}var Lo=function(t,e,r,n,i){if(n==="m")throw new TypeError("Private method is not writable");if(n==="a"&&!i)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?i.call(t,r):i?i.value=r:e.set(t,r),r},U=function(t,e,r,n){if(r==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!n:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?n:r==="a"?n.call(t):n?n.value:e.get(t)},Re,Le,fe,ua=class{constructor(t,e,r){Re.set(this,void 0),Le.set(this,void 0),fe.set(this,void 0),Lo(this,Re,e,"f"),Lo(this,Le,r,"f"),Lo(this,fe,t,"f")}get baseExpression(){return U(this,Re,"f")}async init(){let isInstance=await U(this,fe,"f").isSubjectInstance(U(this,Re,"f"),U(this,Le,"f"));if(!isInstance)throw`Not a valid subject instance of ${U(this,Le,"f")} for ${U(this,Re,"f")}`;let results=await U(this,fe,"f").infer(`subject_class("${U(this,Le,"f")}", C), property(C, Property)`),properties=results.map(t=>t.Property);for(let t of properties){let e=await U(this,fe,"f").infer(`subject_class("${U(this,Le,"f")}", C), property_resolve(C, "${t}")`);Object.defineProperty(this,t,{configurable:!0,get:async()=>{let r=await U(this,fe,"f").infer(`subject_class("${U(this,Le,"f")}", C), property_getter(C, "${U(this,Re,"f")}", "${t}", Value)`);if(r&&r.length>0){let n=r[0].Value;if(e)try{let i=await U(this,fe,"f").getExpression(n);try{return JSON.parse(i.data)}catch{return i.data}}catch{return n}else return n}else return r||void 0}})}let setters=await U(this,fe,"f").infer(`subject_class("${U(this,Le,"f")}", C), property_setter(C, Property, Setter)`);for(let setter of setters||[])if(setter){let property=setter.Property,actions=eval(setter.Setter),resolveLanguageResults=await U(this,fe,"f").infer(`subject_class("${U(this,Le,"f")}", C), property_resolve_language(C, "${property}", Language)`),resolveLanguage;resolveLanguageResults&&resolveLanguageResults.length>0&&(resolveLanguage=resolveLanguageResults[0].Language),this[qu(property)]=async t=>{resolveLanguage&&(t=await U(this,fe,"f").createExpression(t,resolveLanguage)),await U(this,fe,"f").executeAction(actions,U(this,Re,"f"),[{name:"value",value:t}])}}let results2=await U(this,fe,"f").infer(`subject_class("${U(this,Le,"f")}", C), collection(C, Collection)`);results2||(results2=[]);let collections=results2.map(t=>t.Collection);for(let t of collections)Object.defineProperty(this,t,{configurable:!0,get:async()=>{let e=await U(this,fe,"f").infer(`subject_class("${U(this,Le,"f")}", C), collection_getter(C, "${U(this,Re,"f")}", "${t}", Value)`);return e&&e.length>0&&e[0].Value?e[0].Value.filter(n=>n!==""&&n!==""):[]}});let adders=await U(this,fe,"f").infer(`subject_class("${U(this,Le,"f")}", C), collection_adder(C, Collection, Adder)`);adders||(adders=[]);for(let adder of adders)if(adder){let collection=adder.Collection,actions=eval(adder.Adder);this[Lp(collection)]=async t=>{Array.isArray(t)?await Promise.all(t.map(e=>U(this,fe,"f").executeAction(actions,U(this,Re,"f"),[{name:"value",value:e}]))):await U(this,fe,"f").executeAction(actions,U(this,Re,"f"),[{name:"value",value:t}])}}let removers=await U(this,fe,"f").infer(`subject_class("${U(this,Le,"f")}", C), collection_remover(C, Collection, Remover)`);removers||(removers=[]);for(let remover of removers)if(remover){let collection=remover.Collection,actions=eval(remover.Remover);this[Mp(collection)]=async t=>{Array.isArray(t)?await Promise.all(t.map(e=>U(this,fe,"f").executeAction(actions,U(this,Re,"f"),[{name:"value",value:e}]))):await U(this,fe,"f").executeAction(actions,U(this,Re,"f"),[{name:"value",value:t}])}}let collectionSetters=await U(this,fe,"f").infer(`subject_class("${U(this,Le,"f")}", C), collection_setter(C, Collection, Setter)`);collectionSetters||(collectionSetters=[]);for(let collectionSetter of collectionSetters)if(collectionSetter){let collection=collectionSetter.Collection,actions=eval(collectionSetter.Setter);this[Up(collection)]=async t=>{Array.isArray(t)?await U(this,fe,"f").executeAction(actions,U(this,Re,"f"),t.map(e=>({name:"value",value:e}))):await U(this,fe,"f").executeAction(actions,U(this,Re,"f"),[{name:"value",value:t}])}}}};Re=new WeakMap,Le=new WeakMap,fe=new WeakMap;var Gr=function(t,e,r,n,i){if(n==="m")throw new TypeError("Private method is not writable");if(n==="a"&&!i)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?i.call(t,r):i?i.value=r:e.set(t,r),r},R=function(t,e,r,n){if(r==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!n:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?n:r==="a"?n.call(t):n?n.value:e.get(t)},ce,be,hr,mr,yr,Pn,Xr=class{constructor(t,e){ce.set(this,void 0),be.set(this,void 0),hr.set(this,void 0),mr.set(this,void 0),yr.set(this,void 0),Pn.set(this,void 0),Gr(this,hr,[],"f"),Gr(this,mr,[],"f"),Gr(this,yr,[],"f"),Gr(this,Pn,[],"f"),Gr(this,ce,t,"f"),Gr(this,be,e,"f"),this.uuid=R(this,ce,"f").uuid,this.name=R(this,ce,"f").name,this.sharedUrl=R(this,ce,"f").sharedUrl,this.neighbourhood=R(this,ce,"f").neighbourhood,this.state=R(this,ce,"f").state,R(this,be,"f").addPerspectiveLinkAddedListener(R(this,ce,"f").uuid,R(this,hr,"f")),R(this,be,"f").addPerspectiveLinkRemovedListener(R(this,ce,"f").uuid,R(this,mr,"f")),R(this,be,"f").addPerspectiveLinkUpdatedListener(R(this,ce,"f").uuid,R(this,yr,"f")),R(this,be,"f").addPerspectiveSyncStateChangeListener(R(this,ce,"f").uuid,R(this,Pn,"f"))}async executeAction(t,e,r){let n=a=>{if(a)return a==="this"?e:a},i=a=>{if(r){let o=a;for(let s of r)o=o.replace(s.name,s.value);return o}else return a};for(let a of t){let o=n(i(a.source)),s=n(i(a.predicate)),u=n(i(a.target)),l=a?.local??!1;switch(a.action){case"addLink":await this.add(new bt({source:o,predicate:s,target:u}),l?"local":"shared");break;case"removeLink":let f=await this.get(new je({source:o,predicate:s,target:u}));for(let h of f)await this.remove(h);break;case"setSingleTarget":await this.setSingleTarget(new bt({source:o,predicate:s,target:u}),l?"local":"shared");break;case"collectionSetter":let d=await this.get(new je({source:o,predicate:s}));await this.removeLinks(d),await this.addLinks(r.map(h=>new bt({source:o,predicate:s,target:h.value})),l?"local":"shared");break}}}async get(t){return await R(this,be,"f").queryLinks(R(this,ce,"f").uuid,t)}async infer(t){return await R(this,be,"f").queryProlog(R(this,ce,"f").uuid,t)}async add(t,e="shared"){return await R(this,be,"f").addLink(R(this,ce,"f").uuid,t,e)}async addLinks(t,e="shared"){return await R(this,be,"f").addLinks(R(this,ce,"f").uuid,t,e)}async removeLinks(t){return await R(this,be,"f").removeLinks(R(this,ce,"f").uuid,t)}async linkMutations(t,e="shared"){return await R(this,be,"f").linkMutations(R(this,ce,"f").uuid,t,e)}async addLinkExpression(t,e="shared"){return await R(this,be,"f").addLinkExpression(R(this,ce,"f").uuid,t,e)}async update(t,e){return await R(this,be,"f").updateLink(R(this,ce,"f").uuid,t,e)}async remove(t){return await R(this,be,"f").removeLink(R(this,ce,"f").uuid,t)}async getExpression(t){return await R(this,be,"f").getExpression(t)}async createExpression(t,e){return await R(this,be,"f").createExpression(t,e)}async addListener(t,e){t==="link-added"?R(this,hr,"f").push(e):t==="link-removed"?R(this,mr,"f").push(e):t==="link-updated"&&R(this,yr,"f").push(e)}async addSyncStateChangeListener(t){R(this,Pn,"f").push(t)}async removeListener(t,e){if(t==="link-added"){let r=R(this,hr,"f").indexOf(e);R(this,hr,"f").splice(r,1)}else if(t==="link-removed"){let r=R(this,mr,"f").indexOf(e);R(this,mr,"f").splice(r,1)}else if(t==="link-updated"){let r=R(this,yr,"f").indexOf(e);R(this,yr,"f").splice(r,1)}}async snapshot(){return R(this,be,"f").snapshotByUUID(R(this,ce,"f").uuid)}async loadSnapshot(t){let e=JSON.parse(JSON.stringify(t));delete e.__typename,e.links.forEach(r=>{delete r.data.__typename});for(let r of e.links)await this.addLinkExpression(r)}async getSingleTarget(t){delete t.target;let e=await this.get(t);return e.length?e[0].data.target:null}async setSingleTarget(t,e="shared"){let r=new je({source:t.source,predicate:t.predicate}),n=await this.get(r),i=[];for(let o of n)delete o.__typename,delete o.data.__typename,delete o.proof.__typename,i.push(o);let a=[t];await this.linkMutations({additions:a,removals:i},e)}async sdnaFlows(){return(await this.infer("register_sdna_flow(X, _)")).map(e=>e.X)}async availableFlows(t){return(await this.infer(`flowable("${t}", F), register_sdna_flow(X, F)`)).map(r=>r.X)}async startFlow(flowName,exprAddr){let startAction=await this.infer(`start_action(Action, F), register_sdna_flow("${flowName}", F)`);startAction=eval(startAction[0].Action),await this.executeAction(startAction,exprAddr,void 0)}async expressionsInFlowState(t,e){return(await this.infer(`register_sdna_flow("${t}", F), flow_state(X, ${e}, F)`)).map(n=>n.X)}async flowState(t,e){return(await this.infer(`register_sdna_flow("${t}", F), flow_state("${e}", X, F)`))[0].X}async flowActions(t,e){return(await this.infer(`register_sdna_flow("${t}", Flow), flow_state("${e}", State, Flow), action(State, Name, _, _)`)).map(n=>n.Name)}async runFlowAction(flowName,exprAddr,actionName){let action=await this.infer(`register_sdna_flow("${flowName}", Flow), flow_state("${exprAddr}", State, Flow), action(State, "${actionName}", _, Action)`);action=eval(action[0].Action),await this.executeAction(action,exprAddr,void 0)}async getSdna(){return(await this.get(new je({predicate:"ad4m://sdna"}))).map(e=>e.data.target).map(e=>St.fromUrl(e).get())}async addSdna(t,e,r){return R(this,be,"f").addSdna(R(this,ce,"f").uuid,t,e,r)}async subjectClasses(){try{return(await this.infer("subject_class(X, _)")).map(t=>t.X)}catch{return[]}}async stringOrTemplateObjectToSubjectClass(t){if(typeof t=="string")return t;{let e=await this.subjectClassesByTemplate(t);return e[0]?e[0]:t.className}}async createSubject(subjectClass,exprAddr){let className=await this.stringOrTemplateObjectToSubjectClass(subjectClass),result=await this.infer(`subject_class("${className}", C), constructor(C, Actions)`);if(!result.length)throw"No constructor found for given subject class: "+className;let actions=result.map(x=>eval(x.Actions));return await this.executeAction(actions[0],exprAddr,void 0),this.getSubjectProxy(exprAddr,subjectClass)}async removeSubject(subjectClass,exprAddr){let className=await this.stringOrTemplateObjectToSubjectClass(subjectClass),result=await this.infer(`subject_class("${className}", C), destructor(C, Actions)`);if(!result.length)throw"No constructor found for given subject class: "+className;let actions=result.map(x=>eval(x.Actions));await this.executeAction(actions[0],exprAddr,void 0)}async isSubjectInstance(t,e){let r=await this.stringOrTemplateObjectToSubjectClass(e);return await this.infer(`subject_class("${r}", C), instance(C, "${t}")`)}async getSubjectProxy(t,e){if(!await this.isSubjectInstance(t,e))throw`Expression ${t} is not a subject instance of given class: ${JSON.stringify(e)}`;let r=await this.stringOrTemplateObjectToSubjectClass(e),n=new ua(this,t,r);return await n.init(),n}async getAllSubjectInstances(t){let e=[];typeof t=="string"?e=[t]:e=await this.subjectClassesByTemplate(t);let r=[];for(let n of e){let i=await this.infer(`subject_class("${n}", C), instance(C, X)`),a=await Promise.all(i.map(async o=>await this.getSubjectProxy(o.X,n)));r=r.concat(a)}return r}async getAllSubjectProxies(t){let e=[];typeof t=="string"?e=[t]:e=await this.subjectClassesByTemplate(t);let r=[];for(let n of e)r=await this.infer(`subject_class("${n}", C), instance(C, X)`);return r}async subjectClassesByTemplate(t){let e=[],r=[];Object.getPrototypeOf(t).__properties?Object.keys(Object.getPrototypeOf(t).__properties).forEach(l=>e.push(l)):e.push(...Object.keys(t).filter(l=>!Array.isArray(t[l]))),Object.getPrototypeOf(t).__collections?Object.keys(Object.getPrototypeOf(t).__collections).filter(l=>l!=="isSubjectInstance").forEach(l=>!r.includes(l)):r.push(...Object.keys(t).filter(l=>Array.isArray(t[l])).filter(l=>l!=="isSubjectInstance"));let n=Object.getOwnPropertyNames(t).filter(l=>typeof t[l]=="function"&&l.startsWith("set")&&!l.startsWith("setCollection"));n=n.concat(Object.getOwnPropertyNames(Object.getPrototypeOf(t)).filter(l=>typeof t[l]=="function"&&l.startsWith("set")&&!l.startsWith("setCollection")));let i=Object.getOwnPropertyNames(t).filter(l=>typeof t[l]=="function"&&l.startsWith("add"));i=i.concat(Object.getOwnPropertyNames(Object.getPrototypeOf(t)).filter(l=>typeof t[l]=="function"&&l.startsWith("add")));let a=Object.getOwnPropertyNames(t).filter(l=>typeof t[l]=="function"&&l.startsWith("remove"));a=a.concat(Object.getOwnPropertyNames(Object.getPrototypeOf(t)).filter(l=>typeof t[l]=="function"&&l.startsWith("remove")));let o=Object.getOwnPropertyNames(t).filter(l=>typeof t[l]=="function"&&l.startsWith("setCollection"));o=o.concat(Object.getOwnPropertyNames(Object.getPrototypeOf(t)).filter(l=>typeof t[l]=="function"&&l.startsWith("setCollection")));let s="subject_class(Class, C)";for(let l of e)s+=`, property(C, "${l}")`;for(let l of r)s+=`, collection(C, "${l}")`;for(let l of n){let f=l.substring(3);f=f.charAt(0).toLowerCase()+f.slice(1),s+=`, property_setter(C, "${f}", _)`}for(let l of i)s+=`, collection_adder(C, "${Fp(l)}", _)`;for(let l of a)s+=`, collection_remover(C, "${jp(l)}", _)`;for(let l of o)s+=`, collection_setter(C, "${$p(l)}", _)`;s+=".";let u=await this.infer(s);return u?u.map(l=>l.Class):[]}async ensureSDNASubjectClass(t){if((await this.subjectClassesByTemplate(new t)).length>0)return;let{name:r,sdna:n}=t.generateSDNA();await this.addSdna(r,n,"subject_class")}getNeighbourhoodProxy(){return R(this,be,"f").getNeighbourhoodProxy(R(this,ce,"f").uuid)}};ce=new WeakMap,be=new WeakMap,hr=new WeakMap,mr=new WeakMap,yr=new WeakMap,Pn=new WeakMap;var lr=function(t,e,r,n,i){if(n==="m")throw new TypeError("Private method is not writable");if(n==="a"&&!i)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?i.call(t,r):i?i.value=r:e.set(t,r),r},z=function(t,e,r,n){if(r==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!n:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?n:r==="a"?n.call(t):n?n.value:e.get(t)},ie,Cn,Rn,Ln,zi,Fn,Ji,Je=`
61
+ this in the docs: http://dev.apollodata.com/core/fragments.html#unique-names`):o||Uo.set(i,o=new Set),o.add(a),e.has(a)||(e.add(a),r.push(n))}else r.push(n)}),ea(ea({},t),{definitions:r})}function Ip(t){var e=new Set(t.definitions);e.forEach(function(n){n.loc&&delete n.loc,Object.keys(n).forEach(function(i){var a=n[i];a&&typeof a=="object"&&e.add(a)})});var r=t.loc;return r&&(delete r.startToken,delete r.endToken),t}function Dp(t){var e=ju(t);if(!Ki.has(e)){var r=Ep(t,{experimentalFragmentVariables:ta,allowLegacyFragmentVariables:ta});if(!r||r.kind!=="Document")throw new Error("Not a valid GraphQL document.");Ki.set(e,Ip(Tp(r)))}return Ki.get(e)}function O(t){for(var e=[],r=1;r<arguments.length;r++)e[r-1]=arguments[r];typeof t=="string"&&(t=[t]);var n=t[0];return e.forEach(function(i,a){i&&i.kind==="Document"?n+=i.loc.source.body:n+=i,n+=t[a+1]}),Dp(n)}function kp(){Ki.clear(),Uo.clear()}function Ap(){Mu=!1}function Np(){ta=!0}function Pp(){ta=!1}var kn={gql:O,resetCaches:kp,disableFragmentWarnings:Ap,enableExperimentalFragmentVariables:Np,disableExperimentalFragmentVariables:Pp};(function(t){t.gql=kn.gql,t.resetCaches=kn.resetCaches,t.disableFragmentWarnings=kn.disableFragmentWarnings,t.enableExperimentalFragmentVariables=kn.enableExperimentalFragmentVariables,t.disableExperimentalFragmentVariables=kn.disableExperimentalFragmentVariables})(O||(O={}));O.default=O;function D(t){if(!t)throw"Got no result from Apollo";if(t.error)throw t.error;if(t.errors)throw t.errors;return t.data}function Cp(){}function Zo(){return Cp}var g=Zo,$e=Zo,J=Zo,$u=function(t,e,r,n){var i=arguments.length,a=i<3?e:n===null?n=Object.getOwnPropertyDescriptor(e,r):n,o;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")a=Reflect.decorate(t,e,r,n);else for(var s=t.length-1;s>=0;s--)(o=t[s])&&(a=(i<3?o(a):i>3?o(e,r,a):o(e,r))||a);return i>3&&a&&Object.defineProperty(e,r,a),a},Uu=function(t,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(t,e)},wr=class{constructor(e){this.code=e}};$u([g(),Uu("design:type",String)],wr.prototype,"code",void 0);wr=$u([J(),Uu("design:paramtypes",[String])],wr);var es=function(t,e,r,n){var i=arguments.length,a=i<3?e:n===null?n=Object.getOwnPropertyDescriptor(e,r):n,o;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")a=Reflect.decorate(t,e,r,n);else for(var s=t.length-1;s>=0;s--)(o=t[s])&&(a=(i<3?o(a):i>3?o(e,r,a):o(e,r))||a);return i>3&&a&&Object.defineProperty(e,r,a),a},ts=function(t,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(t,e)},gt=class{constructor(e,r){this.address=e,this.name=r}};es([g(),ts("design:type",String)],gt.prototype,"address",void 0);es([g(),ts("design:type",String)],gt.prototype,"name",void 0);gt=es([J(),ts("design:paramtypes",[String,String])],gt);var ue=function(t,e,r,n){var i=arguments.length,a=i<3?e:n===null?n=Object.getOwnPropertyDescriptor(e,r):n,o;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")a=Reflect.decorate(t,e,r,n);else for(var s=t.length-1;s>=0;s--)(o=t[s])&&(a=(i<3?o(a):i>3?o(e,r,a):o(e,r))||a);return i>3&&a&&Object.defineProperty(e,r,a),a},_e=function(t,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(t,e)},Gt=class{constructor(e,r){this.key=r,this.signature=e}};ue([g(),_e("design:type",String)],Gt.prototype,"signature",void 0);ue([g(),_e("design:type",String)],Gt.prototype,"key",void 0);ue([g(),_e("design:type",Boolean)],Gt.prototype,"valid",void 0);ue([g(),_e("design:type",Boolean)],Gt.prototype,"invalid",void 0);Gt=ue([J(),$e(),_e("design:paramtypes",[String,String])],Gt);var _r=class{};ue([g(),_e("design:type",String)],_r.prototype,"signature",void 0);ue([g(),_e("design:type",String)],_r.prototype,"key",void 0);ue([g(),_e("design:type",Boolean)],_r.prototype,"valid",void 0);ue([g(),_e("design:type",Boolean)],_r.prototype,"invalid",void 0);_r=ue([$e()],_r);function Xt(t){let e=class{constructor(n,i,a,o){this.author=n,this.timestamp=i,this.data=a,this.proof=o}};return ue([g(),_e("design:type",String)],e.prototype,"author",void 0),ue([g(),_e("design:type",String)],e.prototype,"timestamp",void 0),ue([g(),_e("design:type",Object)],e.prototype,"data",void 0),ue([g(),_e("design:type",Gt)],e.prototype,"proof",void 0),e=ue([J(),_e("design:paramtypes",[String,String,Object,Gt])],e),e}function Rp(t){let e=class{};return ue([g(),_e("design:type",String)],e.prototype,"author",void 0),ue([g(),_e("design:type",String)],e.prototype,"timestamp",void 0),ue([g(),_e("design:type",Object)],e.prototype,"data",void 0),ue([g(),_e("design:type",_r)],e.prototype,"proof",void 0),e=ue([$e()],e),e}var pu=class extends Xt(){};pu=ue([J()],pu);var ra=class extends Xt(){};ue([g(),_e("design:type",gt)],ra.prototype,"language",void 0);ue([g(),_e("design:type",wr)],ra.prototype,"icon",void 0);ra=ue([J()],ra);function kS(t){return t&&t.author&&t.timestamp&&t.data}var Se=function(t,e,r,n){var i=arguments.length,a=i<3?e:n===null?n=Object.getOwnPropertyDescriptor(e,r):n,o;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")a=Reflect.decorate(t,e,r,n);else for(var s=t.length-1;s>=0;s--)(o=t[s])&&(a=(i<3?o(a):i>3?o(e,r,a):o(e,r))||a);return i>3&&a&&Object.defineProperty(e,r,a),a},Ae=function(t,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(t,e)},bt=class{constructor(e){this.source=e.source?e.source:"",this.target=e.target?e.target:"",this.predicate=e.predicate?e.predicate:""}};Se([g(),Ae("design:type",String)],bt.prototype,"source",void 0);Se([g(),Ae("design:type",String)],bt.prototype,"target",void 0);Se([g(),Ae("design:type",String)],bt.prototype,"predicate",void 0);bt=Se([J(),Ae("design:paramtypes",[Object])],bt);var na=class{};Se([g(),Ae("design:type",Array)],na.prototype,"additions",void 0);Se([g(),Ae("design:type",Array)],na.prototype,"removals",void 0);na=Se([$e()],na);var ia=class{constructor(e,r){this.additions=e,this.removals=r}};Se([g(),Ae("design:type",Array)],ia.prototype,"additions",void 0);Se([g(),Ae("design:type",Array)],ia.prototype,"removals",void 0);ia=Se([J(),Ae("design:paramtypes",[Array,Array])],ia);var Kn=class{};Se([g(),Ae("design:type",String)],Kn.prototype,"source",void 0);Se([g(),Ae("design:type",String)],Kn.prototype,"target",void 0);Se([g(),Ae("design:type",String)],Kn.prototype,"predicate",void 0);Kn=Se([$e()],Kn);var Er=class extends Xt(){hash(){let e=JSON.stringify(this.data,Object.keys(this.data).sort())+JSON.stringify(this.author)+this.timestamp,r=0,n,i;for(n=0;n<e.length;n++)i=e.charCodeAt(n),r=(r<<5)-r+i,r|=0;return r}};Se([g(),Ae("design:type",String)],Er.prototype,"status",void 0);Er=Se([J()],Er);var qo=class extends Rp(){};Se([g(),Ae("design:type",String)],qo.prototype,"status",void 0);qo=Se([$e()],qo);function FS(t,e){return t.author==e.author&&t.timestamp==e.timestamp&&t.data.source==e.data.source&&t.data.predicate==e.data.predicate&&t.data.target==e.data.target}function MS(t){return t&&t.source&&t.target}var aa=class{constructor(e,r){this.oldLink=e,this.newLink=r}};Se([g(),Ae("design:type",Er)],aa.prototype,"oldLink",void 0);Se([g(),Ae("design:type",Er)],aa.prototype,"newLink",void 0);aa=Se([J(),Ae("design:paramtypes",[Er,Er])],aa);var Or=function(t,e,r,n){var i=arguments.length,a=i<3?e:n===null?n=Object.getOwnPropertyDescriptor(e,r):n,o;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")a=Reflect.decorate(t,e,r,n);else for(var s=t.length-1;s>=0;s--)(o=t[s])&&(a=(i<3?o(a):i>3?o(e,r,a):o(e,r))||a);return i>3&&a&&Object.defineProperty(e,r,a),a},Yn=function(t,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(t,e)},Vo,Kt=class{constructor(e){e?this.links=e:this.links=[]}get(e){if(!e||!e.source&&!e.predicate&&!e.target)return this.links;if(e.source){let n=JSON.parse(JSON.stringify(this.links));return e.target&&(n=n.filter(i=>i.data.target===e.target)),e.predicate&&(n=n.filter(i=>i.data.predicate===e.predicate)),e.fromDate&&(n=n.filter(i=>new Date(i.timestamp)>=e.fromDate)),e.untilDate&&(n=n.filter(i=>new Date(i.timestamp)<=e.untilDate)),e.limit&&(n=n.slice(0,e.limit)),n}if(e.target){let n=JSON.parse(JSON.stringify(this.links));return e.predicate&&(n=n.filter(i=>i.data.predicate===e.predicate)),e.fromDate&&(n=n.filter(i=>new Date(i.timestamp)>=e.fromDate)),e.untilDate&&(n=n.filter(i=>new Date(i.timestamp)<=e.untilDate)),e.limit&&(n=n.slice(0,e.limit)),n}let r=JSON.parse(JSON.stringify(this.links));return r=r.filter(n=>n.data.predicate===e.predicate),e.limit&&(r=r.slice(0,e.limit)),r}getSingleTarget(e){delete e.target;let r=this.get(e);return r.length?r[0].data.target:null}};Or([g(),Yn("design:type",Array)],Kt.prototype,"links",void 0);Kt=Or([J(),Yn("design:paramtypes",[Array])],Kt);var Bo=class{};Or([g(),Yn("design:type",Array)],Bo.prototype,"links",void 0);Bo=Or([$e()],Bo);var Qo=Vo=class{constructor(e){e?this.links=e:this.links=[]}static fromLink(e){let r=new Vo;return r.links.push(e),r}};Or([g(),Yn("design:type",Array)],Qo.prototype,"links",void 0);Qo=Vo=Or([$e(),Yn("design:paramtypes",[Array])],Qo);var Wo=class extends Xt(){};Wo=Or([J()],Wo);var L=function(t,e,r,n){var i=arguments.length,a=i<3?e:n===null?n=Object.getOwnPropertyDescriptor(e,r):n,o;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")a=Reflect.decorate(t,e,r,n);else for(var s=t.length-1;s>=0;s--)(o=t[s])&&(a=(i<3?o(a):i>3?o(e,r,a):o(e,r))||a);return i>3&&a&&Object.defineProperty(e,r,a),a},F=function(t,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(t,e)},Qt=class{constructor(e,r){this.did=e,r?this.perspective=r:this.perspective=new Kt}};L([g(),F("design:type",String)],Qt.prototype,"did",void 0);L([g(),F("design:type",Kt)],Qt.prototype,"perspective",void 0);L([g(),F("design:type",String)],Qt.prototype,"directMessageLanguage",void 0);Qt=L([J(),F("design:paramtypes",[String,Kt])],Qt);var du=class extends Xt(){};du=L([J()],du);var zt=class{constructor(e,r,n,i,a,o){this.did=e,this.didSigningKeyId=r,this.deviceKeyType=n,this.deviceKey=i,this.deviceKeySignedByDid=a,this.didSignedByDeviceKey=o}};L([g(),F("design:type",String)],zt.prototype,"did",void 0);L([g(),F("design:type",String)],zt.prototype,"didSigningKeyId",void 0);L([g(),F("design:type",String)],zt.prototype,"deviceKeyType",void 0);L([g(),F("design:type",String)],zt.prototype,"deviceKey",void 0);L([g(),F("design:type",String)],zt.prototype,"deviceKeySignedByDid",void 0);L([g(),F("design:type",String)],zt.prototype,"didSignedByDeviceKey",void 0);zt=L([J(),F("design:paramtypes",[String,String,String,String,String,String])],zt);var Jt=class{constructor(e,r,n,i,a,o){this.did=e,this.didSigningKeyId=r,this.deviceKeyType=n,this.deviceKey=i,this.deviceKeySignedByDid=a,this.didSignedByDeviceKey=o}};L([g(),F("design:type",String)],Jt.prototype,"did",void 0);L([g(),F("design:type",String)],Jt.prototype,"didSigningKeyId",void 0);L([g(),F("design:type",String)],Jt.prototype,"deviceKeyType",void 0);L([g(),F("design:type",String)],Jt.prototype,"deviceKey",void 0);L([g(),F("design:type",String)],Jt.prototype,"deviceKeySignedByDid",void 0);L([g(),F("design:type",String)],Jt.prototype,"didSignedByDeviceKey",void 0);Jt=L([$e(),F("design:paramtypes",[String,String,String,String,String,String])],Jt);var oa=class{constructor(e,r){this.signature=e,this.publicKey=r}};L([g(),F("design:type",String)],oa.prototype,"signature",void 0);L([g(),F("design:type",String)],oa.prototype,"publicKey",void 0);oa=L([J(),F("design:paramtypes",[String,String])],oa);var Zr=class{constructor(e,r){this.domain=e,this.pointers=r}};L([g(),F("design:type",String)],Zr.prototype,"domain",void 0);L([g(),F("design:type",Array)],Zr.prototype,"pointers",void 0);Zr=L([J(),F("design:paramtypes",[String,Array])],Zr);var sa=class{constructor(e,r){this.with=e,this.can=r}};L([g(),F("design:type",Zr)],sa.prototype,"with",void 0);L([g(),F("design:type",Array)],sa.prototype,"can",void 0);sa=L([J(),F("design:paramtypes",[Zr,Array])],sa);var Nt=class{constructor(e,r,n,i,a){this.appName=e,this.appDesc=r,this.appIconPath=a,this.appUrl=n,this.capabilities=i}};L([g(),F("design:type",String)],Nt.prototype,"appName",void 0);L([g(),F("design:type",String)],Nt.prototype,"appDesc",void 0);L([g(),F("design:type",String)],Nt.prototype,"appUrl",void 0);L([g(),F("design:type",String)],Nt.prototype,"appIconPath",void 0);L([g(),F("design:type",Array)],Nt.prototype,"capabilities",void 0);Nt=L([J(),F("design:paramtypes",[String,String,String,Array,String])],Nt);var en=class{constructor(e,r,n,i){this.requestId=e,this.auth=r,this.token=n,this.revoked=i}};L([g(),F("design:type",String)],en.prototype,"requestId",void 0);L([g(),F("design:type",String)],en.prototype,"token",void 0);L([g(),F("design:type",Boolean)],en.prototype,"revoked",void 0);L([g(),F("design:type",Nt)],en.prototype,"auth",void 0);en=L([J(),F("design:paramtypes",[String,Nt,String,Boolean])],en);var tn=class{constructor(e,r){this.domain=e,this.pointers=r}};L([g(),F("design:type",String)],tn.prototype,"domain",void 0);L([g(),F("design:type",Array)],tn.prototype,"pointers",void 0);tn=L([$e(),F("design:paramtypes",[String,Array])],tn);var ca=class{constructor(e,r){this.with=e,this.can=r}};L([g(),F("design:type",tn)],ca.prototype,"with",void 0);L([g(),F("design:type",Array)],ca.prototype,"can",void 0);ca=L([$e(),F("design:paramtypes",[tn,Array])],ca);var Ht=class{constructor(e,r,n,i,a,o){this.appName=e,this.appDesc=r,this.appUrl=i,this.appDomain=n,this.capabilities=o,this.appIconPath=a}};L([g(),F("design:type",String)],Ht.prototype,"appName",void 0);L([g(),F("design:type",String)],Ht.prototype,"appDesc",void 0);L([g(),F("design:type",String)],Ht.prototype,"appDomain",void 0);L([g(),F("design:type",String)],Ht.prototype,"appUrl",void 0);L([g(),F("design:type",String)],Ht.prototype,"appIconPath",void 0);L([g(),F("design:type",Array)],Ht.prototype,"capabilities",void 0);Ht=L([$e(),F("design:paramtypes",[String,String,String,String,String,Array])],Ht);var nn=function(t,e,r,n){var i=arguments.length,a=i<3?e:n===null?n=Object.getOwnPropertyDescriptor(e,r):n,o;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")a=Reflect.decorate(t,e,r,n);else for(var s=t.length-1;s>=0;s--)(o=t[s])&&(a=(i<3?o(a):i>3?o(e,r,a):o(e,r))||a);return i>3&&a&&Object.defineProperty(e,r,a),a},an=function(t,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(t,e)},rt=class{constructor(e){e?(this.isInitialized=e.isInitialized,this.isInitialized||(this.isInitialized=!1),this.isUnlocked=e.isUnlocked,this.isUnlocked||(this.isUnlocked=!1),this.did=e.did,this.didDocument=e.didDocument,this.error=e.error):(this.isInitialized=!1,this.isUnlocked=!1)}};nn([g(),an("design:type",Boolean)],rt.prototype,"isInitialized",void 0);nn([g(),an("design:type",Boolean)],rt.prototype,"isUnlocked",void 0);nn([g(),an("design:type",String)],rt.prototype,"did",void 0);nn([g(),an("design:type",String)],rt.prototype,"didDocument",void 0);nn([g(),an("design:type",String)],rt.prototype,"error",void 0);rt=nn([J(),an("design:paramtypes",[Object])],rt);var hu=function(t,e,r,n,i){if(n==="m")throw new TypeError("Private method is not writable");if(n==="a"&&!i)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?i.call(t,r):i?i.value=r:e.set(t,r),r},ye=function(t,e,r,n){if(r==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!n:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?n:r==="a"?n.call(t):n?n.value:e.get(t)},Qe,We,Go=class{constructor(e,r){Qe.set(this,void 0),We.set(this,void 0),hu(this,Qe,e,"f"),hu(this,We,r,"f")}async otherAgents(){return await ye(this,Qe,"f").otherAgents(ye(this,We,"f"))}async hasTelepresenceAdapter(){return await ye(this,Qe,"f").hasTelepresenceAdapter(ye(this,We,"f"))}async onlineAgents(){return await ye(this,Qe,"f").onlineAgents(ye(this,We,"f"))}async setOnlineStatus(e){return await ye(this,Qe,"f").setOnlineStatus(ye(this,We,"f"),e)}async setOnlineStatusU(e){return await ye(this,Qe,"f").setOnlineStatusU(ye(this,We,"f"),e)}async sendSignal(e,r){return await ye(this,Qe,"f").sendSignal(ye(this,We,"f"),e,r)}async sendSignalU(e,r){return await ye(this,Qe,"f").sendSignalU(ye(this,We,"f"),e,r)}async sendBroadcast(e){return await ye(this,Qe,"f").sendBroadcast(ye(this,We,"f"),e)}async sendBroadcastU(e){return await ye(this,Qe,"f").sendBroadcastU(ye(this,We,"f"),e)}async addSignalHandler(e){await ye(this,Qe,"f").addSignalHandler(ye(this,We,"f"),e)}removeSignalHandler(e){ye(this,Qe,"f").removeSignalHandler(ye(this,We,"f"),e)}};Qe=new WeakMap,We=new WeakMap;var Tr=function(t,e,r,n){var i=arguments.length,a=i<3?e:n===null?n=Object.getOwnPropertyDescriptor(e,r):n,o;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")a=Reflect.decorate(t,e,r,n);else for(var s=t.length-1;s>=0;s--)(o=t[s])&&(a=(i<3?o(a):i>3?o(e,r,a):o(e,r))||a);return i>3&&a&&Object.defineProperty(e,r,a),a},Ir=function(t,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(t,e)},je=class{constructor(e){e&&(this.source=e.source,this.predicate=e.predicate,this.target=e.target,e.fromDate&&(this.fromDate=e.fromDate),e.untilDate&&(this.untilDate=e.untilDate),e.limit&&(this.limit=e.limit))}isMatch(e){return!(this.source&&this.source!==e.source||this.predicate&&this.predicate!==e.predicate||this.target&&this.target!==e.target)}};Tr([g(),Ir("design:type",String)],je.prototype,"source",void 0);Tr([g(),Ir("design:type",String)],je.prototype,"target",void 0);Tr([g(),Ir("design:type",String)],je.prototype,"predicate",void 0);Tr([g(),Ir("design:type",Date)],je.prototype,"fromDate",void 0);Tr([g(),Ir("design:type",Date)],je.prototype,"untilDate",void 0);Tr([g(),Ir("design:type",Number)],je.prototype,"limit",void 0);je=Tr([J(),$e(),Ir("design:paramtypes",[Object])],je);var mu=function(t,e,r,n,i){if(n==="m")throw new TypeError("Private method is not writable");if(n==="a"&&!i)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?i.call(t,r):i?i.value=r:e.set(t,r),r},Be=function(t,e,r,n){if(r==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!n:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?n:r==="a"?n.call(t):n?n.value:e.get(t)},ct,It;function Ro(t){return encodeURIComponent(t).replace(/[!'()*]/g,e=>`%${e.charCodeAt(0).toString(16).toUpperCase()}`)}var St=class{constructor(){ct.set(this,void 0),It.set(this,void 0)}static fromUrl(e){if(!e||!e.startsWith("literal://"))throw new Error("Can't create Literal from non-literal URL");let r=new St;return mu(r,It,e,"f"),r}static from(e){let r=new St;return mu(r,ct,e,"f"),r}toUrl(){if(Be(this,It,"f")&&!Be(this,ct,"f"))return Be(this,It,"f");if(!Be(this,It,"f")&&!Be(this,ct,"f"))throw new Error("Can't turn empty Literal into URL");let e;switch(typeof Be(this,ct,"f")){case"string":e=`string:${Ro(Be(this,ct,"f"))}`;break;case"number":e=`number:${Ro(Be(this,ct,"f"))}`;break;case"object":e=`json:${Ro(JSON.stringify(Be(this,ct,"f")))}`;break}return`literal://${e}`}get(){if(Be(this,ct,"f"))return Be(this,ct,"f");if(!Be(this,It,"f"))throw new Error("Can't render empty Literal");if(!Be(this,It,"f").startsWith("literal://"))throw new Error("Can't render Literal from non-literal URL");let e=Be(this,It,"f").substring(10);if(e.startsWith("string:"))return decodeURIComponent(e.substring(7));if(e.startsWith("number:")){let r=e.substring(7);return parseFloat(r)}if(e.startsWith("json:")){let r=e.substring(5);return JSON.parse(decodeURIComponent(r))}throw new Error(`Can't parse unknown literal: ${e}`)}};ct=new WeakMap,It=new WeakMap;function Wt(t){return t.charAt(0).toUpperCase()+t.slice(1)}function qu(t){return`set${Wt(t)}`}function At(t){return t.endsWith("y")?t.slice(0,-1)+"ies":t+"s"}function rs(t){return t.endsWith("ies")?t.slice(0,-3)+"y":t.endsWith("s")?t.slice(0,-1):t}function Lp(t){return`add${Wt(rs(t))}`}function Fp(t){let e=t.substring(3),r=At(e);return r.charAt(0).toLowerCase()+r.slice(1)}function Mp(t){return`remove${Wt(rs(t))}`}function jp(t){let e=t.substring(6),r=At(e);return r.charAt(0).toLowerCase()+r.slice(1)}function $p(t){let e=t.substring(13),r=At(e);return r.charAt(0).toLowerCase()+r.slice(1)}function Up(t){return`setCollection${Wt(rs(t))}`}function dr(t){if(Array.isArray(t))return`[${t.map(dr).join(", ")}]`;let e=Object.keys(t),r=[];for(let n of e){let i=JSON.stringify(t[n]),a=`${n}: ${i}`;r.push(a)}return`{${r.join(", ")}}`}var Lo=function(t,e,r,n,i){if(n==="m")throw new TypeError("Private method is not writable");if(n==="a"&&!i)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?i.call(t,r):i?i.value=r:e.set(t,r),r},U=function(t,e,r,n){if(r==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!n:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?n:r==="a"?n.call(t):n?n.value:e.get(t)},Re,Le,fe,ua=class{constructor(t,e,r){Re.set(this,void 0),Le.set(this,void 0),fe.set(this,void 0),Lo(this,Re,e,"f"),Lo(this,Le,r,"f"),Lo(this,fe,t,"f")}get baseExpression(){return U(this,Re,"f")}async init(){let isInstance=await U(this,fe,"f").isSubjectInstance(U(this,Re,"f"),U(this,Le,"f"));if(!isInstance)throw`Not a valid subject instance of ${U(this,Le,"f")} for ${U(this,Re,"f")}`;let results=await U(this,fe,"f").infer(`subject_class("${U(this,Le,"f")}", C), property(C, Property)`),properties=results.map(t=>t.Property);for(let t of properties){let e=await U(this,fe,"f").infer(`subject_class("${U(this,Le,"f")}", C), property_resolve(C, "${t}")`);Object.defineProperty(this,t,{configurable:!0,get:async()=>{let r=await U(this,fe,"f").infer(`subject_class("${U(this,Le,"f")}", C), property_getter(C, "${U(this,Re,"f")}", "${t}", Value)`);if(r&&r.length>0){let n=r[0].Value;if(e)try{if(n){let i=await U(this,fe,"f").getExpression(n);try{return JSON.parse(i.data)}catch{return i.data}}else return n}catch{return n}else return n}else return r||void 0}})}let setters=await U(this,fe,"f").infer(`subject_class("${U(this,Le,"f")}", C), property_setter(C, Property, Setter)`);for(let setter of setters||[])if(setter){let property=setter.Property,actions=eval(setter.Setter),resolveLanguageResults=await U(this,fe,"f").infer(`subject_class("${U(this,Le,"f")}", C), property_resolve_language(C, "${property}", Language)`),resolveLanguage;resolveLanguageResults&&resolveLanguageResults.length>0&&(resolveLanguage=resolveLanguageResults[0].Language),this[qu(property)]=async t=>{resolveLanguage&&(t=await U(this,fe,"f").createExpression(t,resolveLanguage)),await U(this,fe,"f").executeAction(actions,U(this,Re,"f"),[{name:"value",value:t}])}}let results2=await U(this,fe,"f").infer(`subject_class("${U(this,Le,"f")}", C), collection(C, Collection)`);results2||(results2=[]);let collections=results2.map(t=>t.Collection);for(let t of collections)Object.defineProperty(this,t,{configurable:!0,get:async()=>{let e=await U(this,fe,"f").infer(`subject_class("${U(this,Le,"f")}", C), collection_getter(C, "${U(this,Re,"f")}", "${t}", Value)`);return e&&e.length>0&&e[0].Value?e[0].Value.filter(n=>n!==""&&n!==""):[]}});let adders=await U(this,fe,"f").infer(`subject_class("${U(this,Le,"f")}", C), collection_adder(C, Collection, Adder)`);adders||(adders=[]);for(let adder of adders)if(adder){let collection=adder.Collection,actions=eval(adder.Adder);this[Lp(collection)]=async t=>{Array.isArray(t)?await Promise.all(t.map(e=>U(this,fe,"f").executeAction(actions,U(this,Re,"f"),[{name:"value",value:e}]))):await U(this,fe,"f").executeAction(actions,U(this,Re,"f"),[{name:"value",value:t}])}}let removers=await U(this,fe,"f").infer(`subject_class("${U(this,Le,"f")}", C), collection_remover(C, Collection, Remover)`);removers||(removers=[]);for(let remover of removers)if(remover){let collection=remover.Collection,actions=eval(remover.Remover);this[Mp(collection)]=async t=>{Array.isArray(t)?await Promise.all(t.map(e=>U(this,fe,"f").executeAction(actions,U(this,Re,"f"),[{name:"value",value:e}]))):await U(this,fe,"f").executeAction(actions,U(this,Re,"f"),[{name:"value",value:t}])}}let collectionSetters=await U(this,fe,"f").infer(`subject_class("${U(this,Le,"f")}", C), collection_setter(C, Collection, Setter)`);collectionSetters||(collectionSetters=[]);for(let collectionSetter of collectionSetters)if(collectionSetter){let collection=collectionSetter.Collection,actions=eval(collectionSetter.Setter);this[Up(collection)]=async t=>{Array.isArray(t)?await U(this,fe,"f").executeAction(actions,U(this,Re,"f"),t.map(e=>({name:"value",value:e}))):await U(this,fe,"f").executeAction(actions,U(this,Re,"f"),[{name:"value",value:t}])}}}};Re=new WeakMap,Le=new WeakMap,fe=new WeakMap;var Gr=function(t,e,r,n,i){if(n==="m")throw new TypeError("Private method is not writable");if(n==="a"&&!i)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?i.call(t,r):i?i.value=r:e.set(t,r),r},R=function(t,e,r,n){if(r==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!n:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?n:r==="a"?n.call(t):n?n.value:e.get(t)},ce,be,hr,mr,yr,Pn,Xr=class{constructor(t,e){ce.set(this,void 0),be.set(this,void 0),hr.set(this,void 0),mr.set(this,void 0),yr.set(this,void 0),Pn.set(this,void 0),Gr(this,hr,[],"f"),Gr(this,mr,[],"f"),Gr(this,yr,[],"f"),Gr(this,Pn,[],"f"),Gr(this,ce,t,"f"),Gr(this,be,e,"f"),this.uuid=R(this,ce,"f").uuid,this.name=R(this,ce,"f").name,this.sharedUrl=R(this,ce,"f").sharedUrl,this.neighbourhood=R(this,ce,"f").neighbourhood,this.state=R(this,ce,"f").state,R(this,be,"f").addPerspectiveLinkAddedListener(R(this,ce,"f").uuid,R(this,hr,"f")),R(this,be,"f").addPerspectiveLinkRemovedListener(R(this,ce,"f").uuid,R(this,mr,"f")),R(this,be,"f").addPerspectiveLinkUpdatedListener(R(this,ce,"f").uuid,R(this,yr,"f")),R(this,be,"f").addPerspectiveSyncStateChangeListener(R(this,ce,"f").uuid,R(this,Pn,"f"))}async executeAction(t,e,r){let n=a=>{if(a)return a==="this"?e:a},i=a=>{if(r){let o=a;for(let s of r)o=o.replace(s.name,s.value);return o}else return a};for(let a of t){let o=n(i(a.source)),s=n(i(a.predicate)),u=n(i(a.target)),l=a?.local??!1;switch(a.action){case"addLink":await this.add(new bt({source:o,predicate:s,target:u}),l?"local":"shared");break;case"removeLink":let f=await this.get(new je({source:o,predicate:s,target:u}));for(let h of f)await this.remove(h);break;case"setSingleTarget":await this.setSingleTarget(new bt({source:o,predicate:s,target:u}),l?"local":"shared");break;case"collectionSetter":let d=await this.get(new je({source:o,predicate:s}));await this.removeLinks(d),await this.addLinks(r.map(h=>new bt({source:o,predicate:s,target:h.value})),l?"local":"shared");break}}}async get(t){return await R(this,be,"f").queryLinks(R(this,ce,"f").uuid,t)}async infer(t){return await R(this,be,"f").queryProlog(R(this,ce,"f").uuid,t)}async add(t,e="shared"){return await R(this,be,"f").addLink(R(this,ce,"f").uuid,t,e)}async addLinks(t,e="shared"){return await R(this,be,"f").addLinks(R(this,ce,"f").uuid,t,e)}async removeLinks(t){return await R(this,be,"f").removeLinks(R(this,ce,"f").uuid,t)}async linkMutations(t,e="shared"){return await R(this,be,"f").linkMutations(R(this,ce,"f").uuid,t,e)}async addLinkExpression(t,e="shared"){return await R(this,be,"f").addLinkExpression(R(this,ce,"f").uuid,t,e)}async update(t,e){return await R(this,be,"f").updateLink(R(this,ce,"f").uuid,t,e)}async remove(t){return await R(this,be,"f").removeLink(R(this,ce,"f").uuid,t)}async getExpression(t){return await R(this,be,"f").getExpression(t)}async createExpression(t,e){return await R(this,be,"f").createExpression(t,e)}async addListener(t,e){t==="link-added"?R(this,hr,"f").push(e):t==="link-removed"?R(this,mr,"f").push(e):t==="link-updated"&&R(this,yr,"f").push(e)}async addSyncStateChangeListener(t){R(this,Pn,"f").push(t)}async removeListener(t,e){if(t==="link-added"){let r=R(this,hr,"f").indexOf(e);R(this,hr,"f").splice(r,1)}else if(t==="link-removed"){let r=R(this,mr,"f").indexOf(e);R(this,mr,"f").splice(r,1)}else if(t==="link-updated"){let r=R(this,yr,"f").indexOf(e);R(this,yr,"f").splice(r,1)}}async snapshot(){return R(this,be,"f").snapshotByUUID(R(this,ce,"f").uuid)}async loadSnapshot(t){let e=JSON.parse(JSON.stringify(t));delete e.__typename,e.links.forEach(r=>{delete r.data.__typename});for(let r of e.links)await this.addLinkExpression(r)}async getSingleTarget(t){delete t.target;let e=await this.get(t);return e.length?e[0].data.target:null}async setSingleTarget(t,e="shared"){let r=new je({source:t.source,predicate:t.predicate}),n=await this.get(r),i=[];for(let o of n)delete o.__typename,delete o.data.__typename,delete o.proof.__typename,i.push(o);let a=[t];await this.linkMutations({additions:a,removals:i},e)}async sdnaFlows(){return(await this.infer("register_sdna_flow(X, _)")).map(e=>e.X)}async availableFlows(t){return(await this.infer(`flowable("${t}", F), register_sdna_flow(X, F)`)).map(r=>r.X)}async startFlow(flowName,exprAddr){let startAction=await this.infer(`start_action(Action, F), register_sdna_flow("${flowName}", F)`);startAction=eval(startAction[0].Action),await this.executeAction(startAction,exprAddr,void 0)}async expressionsInFlowState(t,e){return(await this.infer(`register_sdna_flow("${t}", F), flow_state(X, ${e}, F)`)).map(n=>n.X)}async flowState(t,e){return(await this.infer(`register_sdna_flow("${t}", F), flow_state("${e}", X, F)`))[0].X}async flowActions(t,e){return(await this.infer(`register_sdna_flow("${t}", Flow), flow_state("${e}", State, Flow), action(State, Name, _, _)`)).map(n=>n.Name)}async runFlowAction(flowName,exprAddr,actionName){let action=await this.infer(`register_sdna_flow("${flowName}", Flow), flow_state("${exprAddr}", State, Flow), action(State, "${actionName}", _, Action)`);action=eval(action[0].Action),await this.executeAction(action,exprAddr,void 0)}async getSdna(){return(await this.get(new je({predicate:"ad4m://sdna"}))).map(e=>e.data.target).map(e=>St.fromUrl(e).get())}async addSdna(t,e,r){return R(this,be,"f").addSdna(R(this,ce,"f").uuid,t,e,r)}async subjectClasses(){try{return(await this.infer("subject_class(X, _)")).map(t=>t.X)}catch{return[]}}async stringOrTemplateObjectToSubjectClass(t){if(typeof t=="string")return t;{let e=await this.subjectClassesByTemplate(t);return e[0]?e[0]:t.className}}async createSubject(subjectClass,exprAddr){let className=await this.stringOrTemplateObjectToSubjectClass(subjectClass),result=await this.infer(`subject_class("${className}", C), constructor(C, Actions)`);if(!result.length)throw"No constructor found for given subject class: "+className;let actions=result.map(x=>eval(x.Actions));return await this.executeAction(actions[0],exprAddr,void 0),this.getSubjectProxy(exprAddr,subjectClass)}async removeSubject(subjectClass,exprAddr){let className=await this.stringOrTemplateObjectToSubjectClass(subjectClass),result=await this.infer(`subject_class("${className}", C), destructor(C, Actions)`);if(!result.length)throw"No constructor found for given subject class: "+className;let actions=result.map(x=>eval(x.Actions));await this.executeAction(actions[0],exprAddr,void 0)}async isSubjectInstance(t,e){let r=await this.stringOrTemplateObjectToSubjectClass(e);return await this.infer(`subject_class("${r}", C), instance(C, "${t}")`)}async getSubjectProxy(t,e){if(!await this.isSubjectInstance(t,e))throw`Expression ${t} is not a subject instance of given class: ${JSON.stringify(e)}`;let r=await this.stringOrTemplateObjectToSubjectClass(e),n=new ua(this,t,r);return await n.init(),n}async getAllSubjectInstances(t){let e=[];typeof t=="string"?e=[t]:e=await this.subjectClassesByTemplate(t);let r=[];for(let n of e){let i=await this.infer(`subject_class("${n}", C), instance(C, X)`),a=await Promise.all(i.map(async o=>await this.getSubjectProxy(o.X,n)));r=r.concat(a)}return r}async getAllSubjectProxies(t){let e=[];typeof t=="string"?e=[t]:e=await this.subjectClassesByTemplate(t);let r=[];for(let n of e)r=await this.infer(`subject_class("${n}", C), instance(C, X)`);return r}async subjectClassesByTemplate(t){let e=[],r=[];Object.getPrototypeOf(t).__properties?Object.keys(Object.getPrototypeOf(t).__properties).forEach(l=>e.push(l)):e.push(...Object.keys(t).filter(l=>!Array.isArray(t[l]))),Object.getPrototypeOf(t).__collections?Object.keys(Object.getPrototypeOf(t).__collections).filter(l=>l!=="isSubjectInstance").forEach(l=>!r.includes(l)):r.push(...Object.keys(t).filter(l=>Array.isArray(t[l])).filter(l=>l!=="isSubjectInstance"));let n=Object.getOwnPropertyNames(t).filter(l=>typeof t[l]=="function"&&l.startsWith("set")&&!l.startsWith("setCollection"));n=n.concat(Object.getOwnPropertyNames(Object.getPrototypeOf(t)).filter(l=>typeof t[l]=="function"&&l.startsWith("set")&&!l.startsWith("setCollection")));let i=Object.getOwnPropertyNames(t).filter(l=>typeof t[l]=="function"&&l.startsWith("add"));i=i.concat(Object.getOwnPropertyNames(Object.getPrototypeOf(t)).filter(l=>typeof t[l]=="function"&&l.startsWith("add")));let a=Object.getOwnPropertyNames(t).filter(l=>typeof t[l]=="function"&&l.startsWith("remove"));a=a.concat(Object.getOwnPropertyNames(Object.getPrototypeOf(t)).filter(l=>typeof t[l]=="function"&&l.startsWith("remove")));let o=Object.getOwnPropertyNames(t).filter(l=>typeof t[l]=="function"&&l.startsWith("setCollection"));o=o.concat(Object.getOwnPropertyNames(Object.getPrototypeOf(t)).filter(l=>typeof t[l]=="function"&&l.startsWith("setCollection")));let s="subject_class(Class, C)";for(let l of e)s+=`, property(C, "${l}")`;for(let l of r)s+=`, collection(C, "${l}")`;for(let l of n){let f=l.substring(3);f=f.charAt(0).toLowerCase()+f.slice(1),s+=`, property_setter(C, "${f}", _)`}for(let l of i)s+=`, collection_adder(C, "${Fp(l)}", _)`;for(let l of a)s+=`, collection_remover(C, "${jp(l)}", _)`;for(let l of o)s+=`, collection_setter(C, "${$p(l)}", _)`;s+=".";let u=await this.infer(s);return u?u.map(l=>l.Class):[]}async ensureSDNASubjectClass(t){if((await this.subjectClassesByTemplate(new t)).length>0)return;let{name:r,sdna:n}=t.generateSDNA();await this.addSdna(r,n,"subject_class")}getNeighbourhoodProxy(){return R(this,be,"f").getNeighbourhoodProxy(R(this,ce,"f").uuid)}};ce=new WeakMap,be=new WeakMap,hr=new WeakMap,mr=new WeakMap,yr=new WeakMap,Pn=new WeakMap;var lr=function(t,e,r,n,i){if(n==="m")throw new TypeError("Private method is not writable");if(n==="a"&&!i)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?i.call(t,r):i?i.value=r:e.set(t,r),r},z=function(t,e,r,n){if(r==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!n:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?n:r==="a"?n.call(t):n?n.value:e.get(t)},ie,Cn,Rn,Ln,zi,Fn,Ji,Je=`
62
62
  author
63
63
  timestamp
64
64
  status
@@ -1009,5 +1009,5 @@ type Subscription {
1009
1009
  perspectiveUpdated: PerspectiveHandle
1010
1010
  runtimeMessageReceived: PerspectiveExpression
1011
1011
  }
1012
- `;function Tu(t){return t?.length?t.length===1?t.toString():t.length===2?t.join(" and "):t.slice(0,-1).join(", ")+", and "+t.slice(-1):""}function Tw(t){let e=t.can.includes("*")?["READ","WRITE","UPDATE"]:t.can,r=t.with.domain==="*"?"":t.with.domain,n=t.with.pointers.includes("*")?["all AD4M data"]:t.with.pointers;return`${Tu(e)} your ${r} actions, with access to ${Tu(n)}`}var pr=function(t,e,r,n,i){if(n==="m")throw new TypeError("Private method is not writable");if(n==="a"&&!i)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?i.call(t,r):i?i.value=r:e.set(t,r),r},M=function(t,e,r,n){if(r==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!n:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?n:r==="a"?n.call(t):n?n.value:e.get(t)},Me,ke,Zi,re,Iu=class{constructor(t,e,r){Me.set(this,void 0),ke.set(this,void 0),Zi.set(this,void 0),re.set(this,void 0),pr(this,Me,e||St.from(Bu(24)).toUrl(),"f"),pr(this,re,t,"f"),pr(this,Zi,r||"ad4m://self","f")}get baseExpression(){return M(this,Me,"f")}async getData(id){let tempId=id??M(this,Me,"f"),isInstance=await M(this,re,"f").isSubjectInstance(tempId,M(this,ke,"f"));if(!isInstance)throw`Not a valid subject instance of ${M(this,ke,"f")} for ${tempId}`;let results=await M(this,re,"f").infer(`subject_class("${M(this,ke,"f")}", C), property(C, Property)`),properties=results.map(t=>t.Property);for(let t of properties){let e=await M(this,re,"f").infer(`subject_class("${M(this,ke,"f")}", C), property_resolve(C, "${t}")`),r=async()=>{let n=await M(this,re,"f").infer(`subject_class("${M(this,ke,"f")}", C), property_getter(C, "${tempId}", "${t}", Value)`);if(n&&n.length>0){let i=n[0].Value;if(e)try{let a=await M(this,re,"f").getExpression(i);try{return JSON.parse(a.data)}catch{return a.data}}catch{return i}else return i}else return n||void 0};this[t]=await r()}let results2=await M(this,re,"f").infer(`subject_class("${M(this,ke,"f")}", C), collection(C, Collection)`);results2||(results2=[]);let collections=results2.map(t=>t.Collection);for(let c of collections){let getProperty=async()=>{let results=await M(this,re,"f").infer(`subject_class("${M(this,ke,"f")}", C), collection_getter(C, "${tempId}", "${c}", Value)`);return results&&results.length>0&&results[0].Value?eval(results[0].Value):[]};this[c]=await getProperty()}return pr(this,Me,tempId,"f"),this}async setProperty(key,value){let setters=await M(this,re,"f").infer(`subject_class("${M(this,ke,"f")}", C), property_setter(C, "${key}", Setter)`);if(setters&&setters.length>0){let actions=eval(setters[0].Setter),resolveLanguageResults=await M(this,re,"f").infer(`subject_class("${M(this,ke,"f")}", C), property_resolve_language(C, "${key}", Language)`),resolveLanguage;resolveLanguageResults&&resolveLanguageResults.length>0&&(resolveLanguage=resolveLanguageResults[0].Language),resolveLanguage&&(value=await M(this,re,"f").createExpression(value,resolveLanguage)),await M(this,re,"f").executeAction(actions,M(this,Me,"f"),[{name:"value",value}])}}async setCollectionSetter(key,value){let collectionSetters=await M(this,re,"f").infer(`subject_class("${M(this,ke,"f")}", C), collection_setter(C, "${At(key)}", Setter)`);if(collectionSetters||(collectionSetters=[]),collectionSetters.length>0){let actions=eval(collectionSetters[0].Setter);value&&(Array.isArray(value)?await M(this,re,"f").executeAction(actions,M(this,Me,"f"),value.map(t=>({name:"value",value:t}))):await M(this,re,"f").executeAction(actions,M(this,Me,"f"),[{name:"value",value}]))}}async setCollectionAdder(key,value){let adders=await M(this,re,"f").infer(`subject_class("${M(this,ke,"f")}", C), collection_adder(C, "${At(key)}", Adder)`);if(adders||(adders=[]),adders.length>0){let actions=eval(adders[0].Adder);value&&(Array.isArray(value)?await Promise.all(value.map(t=>M(this,re,"f").executeAction(actions,M(this,Me,"f"),[{name:"value",value:t}]))):await M(this,re,"f").executeAction(actions,M(this,Me,"f"),[{name:"value",value}]))}}async setCollectionRemover(key,value){let removers=await M(this,re,"f").infer(`subject_class("${M(this,ke,"f")}", C), collection_remover(C, "${At(key)}", Remover)`);if(removers||(removers=[]),removers.length>0){let actions=eval(removers[0].Remover);value&&(Array.isArray(value)?await Promise.all(value.map(t=>M(this,re,"f").executeAction(actions,M(this,Me,"f"),[{name:"value",value:t}]))):await M(this,re,"f").executeAction(actions,M(this,Me,"f"),[{name:"value",value}]))}}async save(){pr(this,ke,await M(this,re,"f").stringOrTemplateObjectToSubjectClass(this),"f"),await M(this,re,"f").createSubject(this,M(this,Me,"f")),await M(this,re,"f").add(new bt({source:M(this,Zi,"f"),predicate:"ad4m://has_child",target:this.baseExpression})),await this.update()}async update(){pr(this,ke,await M(this,re,"f").stringOrTemplateObjectToSubjectClass(this),"f");let t=Object.entries(this);for(let[e,r]of t)if(r)if(r?.action)switch(r.action){case"setter":await this.setCollectionSetter(e,r.value);break;case"adder":await this.setCollectionAdder(e,r.value);break;case"remover":await this.setCollectionRemover(e,r.value);default:await this.setCollectionSetter(e,r.value);break}else Array.isArray(r)&&r.length>0?await this.setCollectionSetter(e,r):await this.setProperty(e,r);await this.getData()}async get(){return pr(this,ke,await M(this,re,"f").stringOrTemplateObjectToSubjectClass(this),"f"),await this.getData()}async delete(){await M(this,re,"f").removeSubject(this,M(this,Me,"f"))}static async all(t){let e=await t.stringOrTemplateObjectToSubjectClass(this),r=await t.getAllSubjectProxies(e),n=[];if(r){for(let i of r){let a=new this(t,i.X);n.push(await a.get())}return n}return[]}static async query(t,e){let r=e?.source||"ad4m://self",n=await t.stringOrTemplateObjectToSubjectClass(this),i=[];if(e)try{if((await t.infer(`findall([Timestamp, Base], (subject_class("${n}", C), instance(C, Base), link("${r}", Predicate, Base, Timestamp, Author)), AllData), sort(AllData, SortedData), length(SortedData, DataLength).`))[0].DataLength>=e.size){let s=`findall([Timestamp, Base], (subject_class("${n}", C), instance(C, Base), link("${r}", Predicate, Base, Timestamp, Author)), AllData), sort(AllData, SortedData), reverse(SortedData, ReverseSortedData), paginate(ReverseSortedData, ${e.page}, ${e.size}, PageData).`;i=await t.infer(s),i=i[0].PageData.map(u=>({Base:u[1],Timestamp:u[0]}))}else i=await t.infer(`subject_class("${n}", C), instance(C, Base), triple("${r}", Predicate, Base).`)}catch(o){console.log("Query failed",o)}else i=await t.infer(`subject_class("${n}", C), instance(C, Base), triple("${r}", Predicate, Base).`);return i?await Promise.all(i.map(async o=>await new this(t,o.Base).get())):[]}};Me=new WeakMap,ke=new WeakMap,Zi=new WeakMap,re=new WeakMap;function Gp(){let t=new AbortController;return setTimeout(()=>t.abort(),20),t}function os(t,e=5e3){return Xe(this,null,function*(){return Promise.race([new Promise((r,n)=>{let i=new WebSocket(t);i.onopen=()=>{r(i)},i.onerror=a=>{n(a)}}),new Promise((r,n)=>{setTimeout(()=>{n(new Error("WebSocket connection timed out"))},e)})])})}function ss(t){return Xe(this,null,function*(){try{let e=yield fetch(`http://localhost:${t}/graphql/`,{signal:Gp().signal,mode:"no-cors"});if(e.status===400||e.status===0)return t;throw new Error(`Could not connect to port ${t}`)}catch(e){throw new Error(`Could not connect to port ${t}`)}})}var Kp=t=>{let e=new Set;do for(let r of Reflect.ownKeys(t))e.add([t,r]);while((t=Reflect.getPrototypeOf(t))&&t!==Object.prototype);return e};function cs(t,{include:e,exclude:r}={}){let n=i=>{let a=o=>typeof o=="string"?i===o:o.test(i);return e?e.some(a):r?!r.some(a):!0};for(let[i,a]of Kp(t.constructor.prototype)){if(a==="constructor"||!n(a))continue;let o=Reflect.getOwnPropertyDescriptor(i,a);o&&typeof o.value=="function"&&(t[a]=t[a].bind(t))}return t}var us=class{constructor({appName:e,appDesc:r,appIconPath:n,appUrl:i,appDomain:a,capabilities:o,port:s,token:u,url:l}){this.activeSocket=null;this.requestedRestart=!1;this.authState="unauthenticated";this.connectionState="not_connected";this.port=12e3;this.capabilities=[];this.listeners={authstatechange:[],configstatechange:[],connectionstatechange:[]};cs(this);this.appName=e,this.appDesc=r,this.appDomain=a,this.appUrl=i,this.appIconPath=n,this.capabilities=o,this.port=s||this.port,this.url=l||`ws://localhost:${this.port}/graphql`,this.token=u||this.token,this.buildClient()}notifyConfigChange(e,r){this.listeners.configstatechange.forEach(n=>{n(e,r)})}notifyConnectionChange(e){this.connectionState!==e&&(this.connectionState=e,this.listeners.connectionstatechange.forEach(r=>{r(e)}))}notifyAuthChange(e){this.authState!==e&&(this.authState=e,this.listeners.authstatechange.forEach(r=>{r(e)}))}setPort(e){this.port!==e&&(this.port=e,this.setUrl(`ws://localhost:${this.port}/graphql`),this.notifyConfigChange("port",e))}setUrl(e){this.url!==e&&(this.url=e,this.notifyConfigChange("url",e))}setToken(e){this.token!==e&&(this.token=e,this.notifyConfigChange("token",e))}on(e,r){this.listeners[e].push(r)}connect(e){return Xe(this,null,function*(){try{if(e){yield os(e,1e4),this.setUrl(e);let r=this.buildClient();return yield this.checkAuth(),r}else{let r=yield this.ensureConnection();return yield this.checkAuth(),r}}catch(r){this.notifyConnectionChange("not_connected"),this.notifyAuthChange("unauthenticated")}})}connectToPort(e){return Xe(this,null,function*(){try{if(e){let r=yield ss(e);this.setPort(r)}else{let r=yield this.findPort();this.setPort(r)}return this.buildClient()}catch(r){this.notifyConnectionChange("not_connected"),this.notifyAuthChange("unauthenticated")}})}ensureConnection(){return Xe(this,null,function*(){var r,n;if(((r=this.activeSocket)==null?void 0:r.readyState)===WebSocket.OPEN&&((n=this.activeSocket)==null?void 0:n.url)===this.url&&this.ad4mClient)return this.ad4mClient;try{return yield os(this.url,1e4),this.buildClient()}catch(i){return this.connectToPort()}})}findPort(){return Xe(this,null,function*(){let e=[...Array(10).keys()].map((i,a)=>ss(12e3+a)),n=(yield Promise.allSettled(e)).find(i=>i.status==="fulfilled");if(n)return n.value;throw Error("Couldn't find an open port")})}buildClient(){this.notifyConnectionChange("connecting");try{new WebSocket(this.url)}catch(e){this.notifyConnectionChange("not_connected")}return this.apolloClient&&this.wsClient&&(this.requestedRestart=!0,this.wsClient.dispose(),this.apolloClient.stop()),this.wsClient=iu({url:this.url,connectionParams:()=>Xe(this,null,function*(){return{headers:{authorization:this.token}}}),on:{connecting:()=>{this.requestedRestart||this.notifyConnectionChange("connecting")},opened:e=>{this.activeSocket=e},error:e=>{this.notifyConnectionChange("not_connected"),this.notifyAuthChange("unauthenticated")},connected:()=>{this.notifyConnectionChange("connected")},closed:()=>{this.requestedRestart||(this.notifyConnectionChange(this.token?"disconnected":"not_connected"),this.notifyAuthChange("unauthenticated"),this.requestedRestart=!1)}}}),this.apolloClient=new ko({link:new au(this.wsClient),cache:new Ai({resultCaching:!1,addTypename:!1}),defaultOptions:{watchQuery:{fetchPolicy:"no-cache"},query:{fetchPolicy:"no-cache"},mutate:{fetchPolicy:"no-cache"}}}),this.ad4mClient=new fa(this.apolloClient),this.ad4mClient}checkAuth(){return Xe(this,null,function*(){try{return(yield this.ad4mClient.agent.isLocked())?this.notifyAuthChange("locked"):(yield this.ad4mClient.agent.status(),this.notifyAuthChange("authenticated")),!0}catch(e){return e.message==="Socket closed with event 4500 Cannot extractByTags from a ciphered wallet. You must unlock first."?(this.notifyAuthChange("locked"),!0):(this.notifyAuthChange("unauthenticated"),!1)}})}requestCapability(e=!1){return Xe(this,null,function*(){var r;return e&&this.setToken(null),this.requestId=yield(r=this.ad4mClient)==null?void 0:r.agent.requestCapability({appName:this.appName,appDesc:this.appDesc,appUrl:this.appUrl,appIconPath:this.appIconPath,appDomain:this.appDomain,capabilities:this.capabilities}),this.requestId})}verifyCode(e){return Xe(this,null,function*(){var n;let r=yield(n=this.ad4mClient)==null?void 0:n.agent.generateJwt(this.requestId,e);return this.setToken(r),yield this.buildClient(),yield this.checkAuth(),this.token})}};export{us as default};
1012
+ `;function Tu(t){return t?.length?t.length===1?t.toString():t.length===2?t.join(" and "):t.slice(0,-1).join(", ")+", and "+t.slice(-1):""}function Tw(t){let e=t.can.includes("*")?["READ","WRITE","UPDATE"]:t.can,r=t.with.domain==="*"?"":t.with.domain,n=t.with.pointers.includes("*")?["all AD4M data"]:t.with.pointers;return`${Tu(e)} your ${r} actions, with access to ${Tu(n)}`}var pr=function(t,e,r,n,i){if(n==="m")throw new TypeError("Private method is not writable");if(n==="a"&&!i)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?i.call(t,r):i?i.value=r:e.set(t,r),r},M=function(t,e,r,n){if(r==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!n:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?n:r==="a"?n.call(t):n?n.value:e.get(t)},Me,ke,Zi,re,Iu=class{constructor(t,e,r){Me.set(this,void 0),ke.set(this,void 0),Zi.set(this,void 0),re.set(this,void 0),pr(this,Me,e||St.from(Bu(24)).toUrl(),"f"),pr(this,re,t,"f"),pr(this,Zi,r||"ad4m://self","f")}get baseExpression(){return M(this,Me,"f")}async getData(id){let tempId=id??M(this,Me,"f"),isInstance=await M(this,re,"f").isSubjectInstance(tempId,M(this,ke,"f"));if(!isInstance)throw`Not a valid subject instance of ${M(this,ke,"f")} for ${tempId}`;let results=await M(this,re,"f").infer(`subject_class("${M(this,ke,"f")}", C), property(C, Property)`),properties=results.map(t=>t.Property);for(let t of properties){let e=await M(this,re,"f").infer(`subject_class("${M(this,ke,"f")}", C), property_resolve(C, "${t}")`),r=async()=>{let n=await M(this,re,"f").infer(`subject_class("${M(this,ke,"f")}", C), property_getter(C, "${tempId}", "${t}", Value)`);if(n&&n.length>0){let i=n[0].Value;if(e)try{let a=await M(this,re,"f").getExpression(i);try{return JSON.parse(a.data)}catch{return a.data}}catch{return i}else return i}else return n||void 0};this[t]=await r()}let results2=await M(this,re,"f").infer(`subject_class("${M(this,ke,"f")}", C), collection(C, Collection)`);results2||(results2=[]);let collections=results2.map(t=>t.Collection);for(let c of collections){let getProperty=async()=>{let results=await M(this,re,"f").infer(`subject_class("${M(this,ke,"f")}", C), collection_getter(C, "${tempId}", "${c}", Value)`);return results&&results.length>0&&results[0].Value?eval(results[0].Value):[]};this[c]=await getProperty()}return pr(this,Me,tempId,"f"),this}async setProperty(key,value){let setters=await M(this,re,"f").infer(`subject_class("${M(this,ke,"f")}", C), property_setter(C, "${key}", Setter)`);if(setters&&setters.length>0){let actions=eval(setters[0].Setter),resolveLanguageResults=await M(this,re,"f").infer(`subject_class("${M(this,ke,"f")}", C), property_resolve_language(C, "${key}", Language)`),resolveLanguage;resolveLanguageResults&&resolveLanguageResults.length>0&&(resolveLanguage=resolveLanguageResults[0].Language),resolveLanguage&&(value=await M(this,re,"f").createExpression(value,resolveLanguage)),await M(this,re,"f").executeAction(actions,M(this,Me,"f"),[{name:"value",value}])}}async setCollectionSetter(key,value){let collectionSetters=await M(this,re,"f").infer(`subject_class("${M(this,ke,"f")}", C), collection_setter(C, "${At(key)}", Setter)`);if(collectionSetters||(collectionSetters=[]),collectionSetters.length>0){let actions=eval(collectionSetters[0].Setter);value&&(Array.isArray(value)?await M(this,re,"f").executeAction(actions,M(this,Me,"f"),value.map(t=>({name:"value",value:t}))):await M(this,re,"f").executeAction(actions,M(this,Me,"f"),[{name:"value",value}]))}}async setCollectionAdder(key,value){let adders=await M(this,re,"f").infer(`subject_class("${M(this,ke,"f")}", C), collection_adder(C, "${At(key)}", Adder)`);if(adders||(adders=[]),adders.length>0){let actions=eval(adders[0].Adder);value&&(Array.isArray(value)?await Promise.all(value.map(t=>M(this,re,"f").executeAction(actions,M(this,Me,"f"),[{name:"value",value:t}]))):await M(this,re,"f").executeAction(actions,M(this,Me,"f"),[{name:"value",value}]))}}async setCollectionRemover(key,value){let removers=await M(this,re,"f").infer(`subject_class("${M(this,ke,"f")}", C), collection_remover(C, "${At(key)}", Remover)`);if(removers||(removers=[]),removers.length>0){let actions=eval(removers[0].Remover);value&&(Array.isArray(value)?await Promise.all(value.map(t=>M(this,re,"f").executeAction(actions,M(this,Me,"f"),[{name:"value",value:t}]))):await M(this,re,"f").executeAction(actions,M(this,Me,"f"),[{name:"value",value}]))}}async save(){pr(this,ke,await M(this,re,"f").stringOrTemplateObjectToSubjectClass(this),"f"),await M(this,re,"f").createSubject(this,M(this,Me,"f")),await M(this,re,"f").add(new bt({source:M(this,Zi,"f"),predicate:"ad4m://has_child",target:this.baseExpression})),await this.update()}async update(){pr(this,ke,await M(this,re,"f").stringOrTemplateObjectToSubjectClass(this),"f");let t=Object.entries(this);for(let[e,r]of t)if(r)if(r?.action)switch(r.action){case"setter":await this.setCollectionSetter(e,r.value);break;case"adder":await this.setCollectionAdder(e,r.value);break;case"remover":await this.setCollectionRemover(e,r.value);default:await this.setCollectionSetter(e,r.value);break}else Array.isArray(r)&&r.length>0?await this.setCollectionSetter(e,r):await this.setProperty(e,r);await this.getData()}async get(){return pr(this,ke,await M(this,re,"f").stringOrTemplateObjectToSubjectClass(this),"f"),await this.getData()}async delete(){await M(this,re,"f").removeSubject(this,M(this,Me,"f"))}static async all(t){let e=await t.stringOrTemplateObjectToSubjectClass(this),r=await t.getAllSubjectProxies(e),n=[];if(r){for(let i of r){let a=new this(t,i.X);n.push(await a.get())}return n}return[]}static async query(t,e){let r=e?.source||"ad4m://self",n=await t.stringOrTemplateObjectToSubjectClass(this),i=[];if(e)try{if((await t.infer(`findall([Timestamp, Base], (subject_class("${n}", C), instance(C, Base), link("${r}", Predicate, Base, Timestamp, Author)), AllData), sort(AllData, SortedData), length(SortedData, DataLength).`))[0].DataLength>=e.size){let s=`findall([Timestamp, Base], (subject_class("${n}", C), instance(C, Base), link("${r}", Predicate, Base, Timestamp, Author)), AllData), sort(AllData, SortedData), reverse(SortedData, ReverseSortedData), paginate(ReverseSortedData, ${e.page}, ${e.size}, PageData).`;i=await t.infer(s),i=i[0].PageData.map(u=>({Base:u[1],Timestamp:u[0]}))}else i=await t.infer(`subject_class("${n}", C), instance(C, Base), triple("${r}", Predicate, Base).`)}catch(o){console.log("Query failed",o)}else i=await t.infer(`subject_class("${n}", C), instance(C, Base), triple("${r}", Predicate, Base).`);return i?await Promise.all(i.map(async o=>await new this(t,o.Base).get())):[]}};Me=new WeakMap,ke=new WeakMap,Zi=new WeakMap,re=new WeakMap;function Gp(){let t=new AbortController;return setTimeout(()=>t.abort(),20),t}function os(t,e=1e4){return Xe(this,null,function*(){return Promise.race([new Promise((r,n)=>{t.includes("localhost")||r(new WebSocket(t));let i=new WebSocket(t);i.onopen=()=>{r(i)},i.onerror=a=>{n(a)}}),new Promise((r,n)=>{setTimeout(()=>{n(new Error("WebSocket connection timed out"))},e)})])})}function ss(t){return Xe(this,null,function*(){try{let e=yield fetch(`http://localhost:${t}/graphql/`,{signal:Gp().signal,mode:"no-cors"});if(e.status===400||e.status===0)return t;throw new Error(`Could not connect to port ${t}`)}catch(e){throw new Error(`Could not connect to port ${t}`)}})}var Kp=t=>{let e=new Set;do for(let r of Reflect.ownKeys(t))e.add([t,r]);while((t=Reflect.getPrototypeOf(t))&&t!==Object.prototype);return e};function cs(t,{include:e,exclude:r}={}){let n=i=>{let a=o=>typeof o=="string"?i===o:o.test(i);return e?e.some(a):r?!r.some(a):!0};for(let[i,a]of Kp(t.constructor.prototype)){if(a==="constructor"||!n(a))continue;let o=Reflect.getOwnPropertyDescriptor(i,a);o&&typeof o.value=="function"&&(t[a]=t[a].bind(t))}return t}var us=class{constructor({appName:e,appDesc:r,appIconPath:n,appUrl:i,appDomain:a,capabilities:o,port:s,token:u,url:l}){this.activeSocket=null;this.requestedRestart=!1;this.authState="unauthenticated";this.connectionState="not_connected";this.port=12e3;this.capabilities=[];this.listeners={authstatechange:[],configstatechange:[],connectionstatechange:[]};cs(this);this.appName=e,this.appDesc=r,this.appDomain=a,this.appUrl=i,this.appIconPath=n,this.capabilities=o,this.port=s||this.port,this.url=l||`ws://localhost:${this.port}/graphql`,this.token=u||this.token,this.buildClient()}notifyConfigChange(e,r){this.listeners.configstatechange.forEach(n=>{n(e,r)})}notifyConnectionChange(e){this.connectionState!==e&&(this.connectionState=e,this.listeners.connectionstatechange.forEach(r=>{r(e)}))}notifyAuthChange(e){this.authState!==e&&(this.authState=e,this.listeners.authstatechange.forEach(r=>{r(e)}))}setPort(e){this.port!==e&&(this.port=e,this.setUrl(`ws://localhost:${this.port}/graphql`),this.notifyConfigChange("port",e))}setUrl(e){this.url!==e&&(this.url=e,this.notifyConfigChange("url",e))}setToken(e){this.token!==e&&(this.token=e,this.notifyConfigChange("token",e))}on(e,r){this.listeners[e].push(r)}connect(e){return Xe(this,null,function*(){try{if(e){yield os(e,1e4),this.setUrl(e);let r=this.buildClient();return yield this.checkAuth(),r}else{let r=yield this.ensureConnection();return yield this.checkAuth(),r}}catch(r){this.notifyConnectionChange("not_connected"),this.notifyAuthChange("unauthenticated")}})}connectToPort(e){return Xe(this,null,function*(){try{if(e){let r=yield ss(e);this.setPort(r)}else{let r=yield this.findPort();this.setPort(r)}return this.buildClient()}catch(r){this.notifyConnectionChange("not_connected"),this.notifyAuthChange("unauthenticated")}})}ensureConnection(){return Xe(this,null,function*(){var r,n;if(((r=this.activeSocket)==null?void 0:r.readyState)===WebSocket.OPEN&&((n=this.activeSocket)==null?void 0:n.url)===this.url&&this.ad4mClient)return this.ad4mClient;try{return yield os(this.url,1e4),this.buildClient()}catch(i){return this.connectToPort()}})}findPort(){return Xe(this,null,function*(){let e=[...Array(10).keys()].map((i,a)=>ss(12e3+a)),n=(yield Promise.allSettled(e)).find(i=>i.status==="fulfilled");if(n)return n.value;throw Error("Couldn't find an open port")})}buildClient(){this.notifyConnectionChange("connecting");try{new WebSocket(this.url)}catch(e){this.notifyConnectionChange("not_connected")}return this.apolloClient&&this.wsClient&&(this.requestedRestart=!0,this.wsClient.dispose(),this.apolloClient.stop()),this.wsClient=iu({url:this.url,connectionParams:()=>Xe(this,null,function*(){return{headers:{authorization:this.token}}}),on:{connecting:()=>{this.requestedRestart||this.notifyConnectionChange("connecting")},opened:e=>{this.activeSocket=e},error:e=>{this.notifyConnectionChange("not_connected"),this.notifyAuthChange("unauthenticated")},connected:()=>{this.notifyConnectionChange("connected")},closed:()=>{this.requestedRestart||(this.notifyConnectionChange(this.token?"disconnected":"not_connected"),this.notifyAuthChange("unauthenticated"),this.requestedRestart=!1)}}}),this.apolloClient=new ko({link:new au(this.wsClient),cache:new Ai({resultCaching:!1,addTypename:!1}),defaultOptions:{watchQuery:{fetchPolicy:"no-cache"},query:{fetchPolicy:"no-cache"},mutate:{fetchPolicy:"no-cache"}}}),this.ad4mClient=new fa(this.apolloClient),this.ad4mClient}checkAuth(){return Xe(this,null,function*(){try{return(yield this.ad4mClient.agent.isLocked())?this.notifyAuthChange("locked"):(yield this.ad4mClient.agent.status(),this.notifyAuthChange("authenticated")),!0}catch(e){return e.message==="Socket closed with event 4500 Cannot extractByTags from a ciphered wallet. You must unlock first."?(this.notifyAuthChange("locked"),!0):(this.notifyAuthChange("unauthenticated"),!1)}})}requestCapability(e=!1){return Xe(this,null,function*(){var r;return e&&this.setToken(null),this.requestId=yield(r=this.ad4mClient)==null?void 0:r.agent.requestCapability({appName:this.appName,appDesc:this.appDesc,appUrl:this.appUrl,appIconPath:this.appIconPath,appDomain:this.appDomain,capabilities:this.capabilities}),this.requestId})}verifyCode(e){return Xe(this,null,function*(){var n;let r=yield(n=this.ad4mClient)==null?void 0:n.agent.generateJwt(this.requestId,e);return this.setToken(r),yield this.buildClient(),yield this.checkAuth(),this.token})}};export{us as default};
1013
1013
  //! @fayeed - make it support node.js
package/dist/utils.js CHANGED
@@ -1 +1 @@
1
- var a=(e,t,o)=>new Promise((n,s)=>{var c=r=>{try{l(o.next(r))}catch(u){s(u)}},p=r=>{try{l(o.throw(r))}catch(u){s(u)}},l=r=>r.done?n(r.value):Promise.resolve(r.value).then(c,p);l((o=o.apply(e,t)).next())});var i="0.8.1";function b(){let e=new AbortController;return setTimeout(()=>e.abort(),20),e}function w(e,t=5e3){return a(this,null,function*(){return Promise.race([new Promise((o,n)=>{let s=new WebSocket(e);s.onopen=()=>{o(s)},s.onerror=c=>{n(c)}}),new Promise((o,n)=>{setTimeout(()=>{n(new Error("WebSocket connection timed out"))},t)})])})}function j(e){return a(this,null,function*(){try{let t=yield fetch(`http://localhost:${e}/graphql/`,{signal:b().signal,mode:"no-cors"});if(t.status===400||t.status===0)return e;throw new Error(`Could not connect to port ${e}`)}catch(t){throw new Error(`Could not connect to port ${e}`)}})}function v(){return new Promise((e,t)=>{let o=document.querySelector("ad4m-connect"),n=o==null?void 0:o.getAd4mClient();n?e(n):t("No Ad4mClient found")})}function y(e){let t=document.querySelector("ad4m-connect");t==null||t.addEventListener("authstatechange",o=>{e(o.detail)})}function S(){let e=navigator.userAgent,t="";return e.search("Windows")!==-1?t="Windows":e.search("Mac")!==-1?t="MacOS":e.search("X11")!==-1&&e.search("Linux")===-1?t="UNIX":e.search("Linux")!==-1&&e.search("X11")!==-1&&(t="Linux"),t}function d(){try{localStorage.setItem("test",""),localStorage.removeItem("test")}catch(e){return!1}return!0}function x(e,t){d()&&localStorage.setItem(`${i}/${e}`,t)}function A(e){return d()?localStorage.getItem(`${i}/${e}`):null}function C(e){d()&&localStorage.removeItem(`${i}/${e}`)}export{j as checkPort,w as connectWebSocket,S as detectOS,v as getAd4mClient,A as getForVersion,y as onAuthStateChanged,C as removeForVersion,x as setForVersion};
1
+ var a=(e,t,o)=>new Promise((n,r)=>{var c=s=>{try{l(o.next(s))}catch(u){r(u)}},p=s=>{try{l(o.throw(s))}catch(u){r(u)}},l=s=>s.done?n(s.value):Promise.resolve(s.value).then(c,p);l((o=o.apply(e,t)).next())});var i="0.8.2-prerelease";function b(){let e=new AbortController;return setTimeout(()=>e.abort(),20),e}function w(e,t=1e4){return a(this,null,function*(){return Promise.race([new Promise((o,n)=>{e.includes("localhost")||o(new WebSocket(e));let r=new WebSocket(e);r.onopen=()=>{o(r)},r.onerror=c=>{n(c)}}),new Promise((o,n)=>{setTimeout(()=>{n(new Error("WebSocket connection timed out"))},t)})])})}function j(e){return a(this,null,function*(){try{let t=yield fetch(`http://localhost:${e}/graphql/`,{signal:b().signal,mode:"no-cors"});if(t.status===400||t.status===0)return e;throw new Error(`Could not connect to port ${e}`)}catch(t){throw new Error(`Could not connect to port ${e}`)}})}function v(){return new Promise((e,t)=>{let o=document.querySelector("ad4m-connect"),n=o==null?void 0:o.getAd4mClient();n?e(n):t("No Ad4mClient found")})}function y(e){let t=document.querySelector("ad4m-connect");t==null||t.addEventListener("authstatechange",o=>{e(o.detail)})}function S(){let e=navigator.userAgent,t="";return e.search("Windows")!==-1?t="Windows":e.search("Mac")!==-1?t="MacOS":e.search("X11")!==-1&&e.search("Linux")===-1?t="UNIX":e.search("Linux")!==-1&&e.search("X11")!==-1&&(t="Linux"),t}function d(){try{localStorage.setItem("test",""),localStorage.removeItem("test")}catch(e){return!1}return!0}function x(e,t){d()&&localStorage.setItem(`${i}/${e}`,t)}function A(e){return d()?localStorage.getItem(`${i}/${e}`):null}function C(e){d()&&localStorage.removeItem(`${i}/${e}`)}export{j as checkPort,w as connectWebSocket,S as detectOS,v as getAd4mClient,A as getForVersion,y as onAuthStateChanged,C as removeForVersion,x as setForVersion};
package/dist/web.js CHANGED
@@ -60,7 +60,7 @@ For more information, please visit: https://go.apollo.dev/c/docs`):new U(9);if(t
60
60
  `)}function Vl(r){for(var e=0;e<r.length;++e)if(r[e]!==" "&&r[e]!==" ")return!1;return!0}function o1(r){for(var e,t=!0,n=!0,i=0,a=null,o=0;o<r.length;++o)switch(r.charCodeAt(o)){case 13:r.charCodeAt(o+1)===10&&++o;case 10:t=!1,n=!0,i=0;break;case 9:case 32:++i;break;default:n&&!t&&(a===null||i<a)&&(a=i),n=!1}return(e=a)!==null&&e!==void 0?e:0}var s1=function(){function r(t){var n=new Se(w.SOF,0,0,0,0,null);this.source=t,this.lastToken=n,this.token=n,this.line=1,this.lineStart=0}var e=r.prototype;return e.advance=function(){this.lastToken=this.token;var n=this.token=this.lookahead();return n},e.lookahead=function(){var n=this.token;if(n.kind!==w.EOF)do{var i;n=(i=n.next)!==null&&i!==void 0?i:n.next=u1(this,n)}while(n.kind===w.COMMENT);return n},r}();function c1(r){return r===w.BANG||r===w.DOLLAR||r===w.AMP||r===w.PAREN_L||r===w.PAREN_R||r===w.SPREAD||r===w.COLON||r===w.EQUALS||r===w.AT||r===w.BRACKET_L||r===w.BRACKET_R||r===w.BRACE_L||r===w.PIPE||r===w.BRACE_R}function Mr(r){return isNaN(r)?w.EOF:r<127?JSON.stringify(String.fromCharCode(r)):'"\\u'.concat(("00"+r.toString(16).toUpperCase()).slice(-4),'"')}function u1(r,e){for(var t=r.source,n=t.body,i=n.length,a=e.end;a<i;){var o=n.charCodeAt(a),s=r.line,u=1+a-r.lineStart;switch(o){case 65279:case 9:case 32:case 44:++a;continue;case 10:++a,++r.line,r.lineStart=a;continue;case 13:n.charCodeAt(a+1)===10?a+=2:++a,++r.line,r.lineStart=a;continue;case 33:return new Se(w.BANG,a,a+1,s,u,e);case 35:return p1(t,a,s,u,e);case 36:return new Se(w.DOLLAR,a,a+1,s,u,e);case 38:return new Se(w.AMP,a,a+1,s,u,e);case 40:return new Se(w.PAREN_L,a,a+1,s,u,e);case 41:return new Se(w.PAREN_R,a,a+1,s,u,e);case 46:if(n.charCodeAt(a+1)===46&&n.charCodeAt(a+2)===46)return new Se(w.SPREAD,a,a+3,s,u,e);break;case 58:return new Se(w.COLON,a,a+1,s,u,e);case 61:return new Se(w.EQUALS,a,a+1,s,u,e);case 64:return new Se(w.AT,a,a+1,s,u,e);case 91:return new Se(w.BRACKET_L,a,a+1,s,u,e);case 93:return new Se(w.BRACKET_R,a,a+1,s,u,e);case 123:return new Se(w.BRACE_L,a,a+1,s,u,e);case 124:return new Se(w.PIPE,a,a+1,s,u,e);case 125:return new Se(w.BRACE_R,a,a+1,s,u,e);case 34:return n.charCodeAt(a+1)===34&&n.charCodeAt(a+2)===34?h1(t,a,s,u,e,r):d1(t,a,s,u,e);case 45:case 48:case 49:case 50:case 51:case 52:case 53:case 54:case 55:case 56:case 57:return f1(t,a,o,s,u,e);case 65:case 66:case 67:case 68:case 69:case 70:case 71:case 72:case 73:case 74:case 75:case 76:case 77:case 78:case 79:case 80:case 81:case 82:case 83:case 84:case 85:case 86:case 87:case 88:case 89:case 90:case 95:case 97:case 98:case 99:case 100:case 101:case 102:case 103:case 104:case 105:case 106:case 107:case 108:case 109:case 110:case 111:case 112:case 113:case 114:case 115:case 116:case 117:case 118:case 119:case 120:case 121:case 122:return y1(t,a,s,u,e)}throw nt(t,a,l1(o))}var l=r.line,p=1+a-r.lineStart;return new Se(w.EOF,i,i,l,p,e)}function l1(r){return r<32&&r!==9&&r!==10&&r!==13?"Cannot contain the invalid character ".concat(Mr(r),"."):r===39?`Unexpected single quote character ('), did you mean to use a double quote (")?`:"Cannot parse the unexpected character ".concat(Mr(r),".")}function p1(r,e,t,n,i){var a=r.body,o,s=e;do o=a.charCodeAt(++s);while(!isNaN(o)&&(o>31||o===9));return new Se(w.COMMENT,e,s,t,n,i,a.slice(e+1,s))}function f1(r,e,t,n,i,a){var o=r.body,s=t,u=e,l=!1;if(s===45&&(s=o.charCodeAt(++u)),s===48){if(s=o.charCodeAt(++u),s>=48&&s<=57)throw nt(r,u,"Invalid number, unexpected digit after 0: ".concat(Mr(s),"."))}else u=Ps(r,u,s),s=o.charCodeAt(u);if(s===46&&(l=!0,s=o.charCodeAt(++u),u=Ps(r,u,s),s=o.charCodeAt(u)),(s===69||s===101)&&(l=!0,s=o.charCodeAt(++u),(s===43||s===45)&&(s=o.charCodeAt(++u)),u=Ps(r,u,s),s=o.charCodeAt(u)),s===46||g1(s))throw nt(r,u,"Invalid number, expected digit but got: ".concat(Mr(s),"."));return new Se(l?w.FLOAT:w.INT,e,u,n,i,a,o.slice(e,u))}function Ps(r,e,t){var n=r.body,i=e,a=t;if(a>=48&&a<=57){do a=n.charCodeAt(++i);while(a>=48&&a<=57);return i}throw nt(r,i,"Invalid number, expected digit but got: ".concat(Mr(a),"."))}function d1(r,e,t,n,i){for(var a=r.body,o=e+1,s=o,u=0,l="";o<a.length&&!isNaN(u=a.charCodeAt(o))&&u!==10&&u!==13;){if(u===34)return l+=a.slice(s,o),new Se(w.STRING,e,o+1,t,n,i,l);if(u<32&&u!==9)throw nt(r,o,"Invalid character within String: ".concat(Mr(u),"."));if(++o,u===92){switch(l+=a.slice(s,o-1),u=a.charCodeAt(o),u){case 34:l+='"';break;case 47:l+="/";break;case 92:l+="\\";break;case 98:l+="\b";break;case 102:l+="\f";break;case 110:l+=`
61
61
  `;break;case 114:l+="\r";break;case 116:l+=" ";break;case 117:{var p=m1(a.charCodeAt(o+1),a.charCodeAt(o+2),a.charCodeAt(o+3),a.charCodeAt(o+4));if(p<0){var f=a.slice(o+1,o+5);throw nt(r,o,"Invalid character escape sequence: \\u".concat(f,"."))}l+=String.fromCharCode(p),o+=4;break}default:throw nt(r,o,"Invalid character escape sequence: \\".concat(String.fromCharCode(u),"."))}++o,s=o}}throw nt(r,o,"Unterminated string.")}function h1(r,e,t,n,i,a){for(var o=r.body,s=e+3,u=s,l=0,p="";s<o.length&&!isNaN(l=o.charCodeAt(s));){if(l===34&&o.charCodeAt(s+1)===34&&o.charCodeAt(s+2)===34)return p+=o.slice(u,s),new Se(w.BLOCK_STRING,e,s+3,t,n,i,a1(p));if(l<32&&l!==9&&l!==10&&l!==13)throw nt(r,s,"Invalid character within String: ".concat(Mr(l),"."));l===10?(++s,++a.line,a.lineStart=s):l===13?(o.charCodeAt(s+1)===10?s+=2:++s,++a.line,a.lineStart=s):l===92&&o.charCodeAt(s+1)===34&&o.charCodeAt(s+2)===34&&o.charCodeAt(s+3)===34?(p+=o.slice(u,s)+'"""',s+=4,u=s):++s}throw nt(r,s,"Unterminated string.")}function m1(r,e,t,n){return ya(r)<<12|ya(e)<<8|ya(t)<<4|ya(n)}function ya(r){return r>=48&&r<=57?r-48:r>=65&&r<=70?r-55:r>=97&&r<=102?r-87:-1}function y1(r,e,t,n,i){for(var a=r.body,o=a.length,s=e+1,u=0;s!==o&&!isNaN(u=a.charCodeAt(s))&&(u===95||u>=48&&u<=57||u>=65&&u<=90||u>=97&&u<=122);)++s;return new Se(w.NAME,e,s,t,n,i,a.slice(e,s))}function g1(r){return r===95||r>=65&&r<=90||r>=97&&r<=122}function v1(r,e){var t=new b1(r,e);return t.parseDocument()}var b1=function(){function r(t,n){var i=n1(t)?t:new dp(t);this._lexer=new s1(i),this._options=n}var e=r.prototype;return e.parseName=function(){var n=this.expectToken(w.NAME);return{kind:j.NAME,value:n.value,loc:this.loc(n)}},e.parseDocument=function(){var n=this._lexer.token;return{kind:j.DOCUMENT,definitions:this.many(w.SOF,this.parseDefinition,w.EOF),loc:this.loc(n)}},e.parseDefinition=function(){if(this.peek(w.NAME))switch(this._lexer.token.value){case"query":case"mutation":case"subscription":return this.parseOperationDefinition();case"fragment":return this.parseFragmentDefinition();case"schema":case"scalar":case"type":case"interface":case"union":case"enum":case"input":case"directive":return this.parseTypeSystemDefinition();case"extend":return this.parseTypeSystemExtension()}else{if(this.peek(w.BRACE_L))return this.parseOperationDefinition();if(this.peekDescription())return this.parseTypeSystemDefinition()}throw this.unexpected()},e.parseOperationDefinition=function(){var n=this._lexer.token;if(this.peek(w.BRACE_L))return{kind:j.OPERATION_DEFINITION,operation:"query",name:void 0,variableDefinitions:[],directives:[],selectionSet:this.parseSelectionSet(),loc:this.loc(n)};var i=this.parseOperationType(),a;return this.peek(w.NAME)&&(a=this.parseName()),{kind:j.OPERATION_DEFINITION,operation:i,name:a,variableDefinitions:this.parseVariableDefinitions(),directives:this.parseDirectives(!1),selectionSet:this.parseSelectionSet(),loc:this.loc(n)}},e.parseOperationType=function(){var n=this.expectToken(w.NAME);switch(n.value){case"query":return"query";case"mutation":return"mutation";case"subscription":return"subscription"}throw this.unexpected(n)},e.parseVariableDefinitions=function(){return this.optionalMany(w.PAREN_L,this.parseVariableDefinition,w.PAREN_R)},e.parseVariableDefinition=function(){var n=this._lexer.token;return{kind:j.VARIABLE_DEFINITION,variable:this.parseVariable(),type:(this.expectToken(w.COLON),this.parseTypeReference()),defaultValue:this.expectOptionalToken(w.EQUALS)?this.parseValueLiteral(!0):void 0,directives:this.parseDirectives(!0),loc:this.loc(n)}},e.parseVariable=function(){var n=this._lexer.token;return this.expectToken(w.DOLLAR),{kind:j.VARIABLE,name:this.parseName(),loc:this.loc(n)}},e.parseSelectionSet=function(){var n=this._lexer.token;return{kind:j.SELECTION_SET,selections:this.many(w.BRACE_L,this.parseSelection,w.BRACE_R),loc:this.loc(n)}},e.parseSelection=function(){return this.peek(w.SPREAD)?this.parseFragment():this.parseField()},e.parseField=function(){var n=this._lexer.token,i=this.parseName(),a,o;return this.expectOptionalToken(w.COLON)?(a=i,o=this.parseName()):o=i,{kind:j.FIELD,alias:a,name:o,arguments:this.parseArguments(!1),directives:this.parseDirectives(!1),selectionSet:this.peek(w.BRACE_L)?this.parseSelectionSet():void 0,loc:this.loc(n)}},e.parseArguments=function(n){var i=n?this.parseConstArgument:this.parseArgument;return this.optionalMany(w.PAREN_L,i,w.PAREN_R)},e.parseArgument=function(){var n=this._lexer.token,i=this.parseName();return this.expectToken(w.COLON),{kind:j.ARGUMENT,name:i,value:this.parseValueLiteral(!1),loc:this.loc(n)}},e.parseConstArgument=function(){var n=this._lexer.token;return{kind:j.ARGUMENT,name:this.parseName(),value:(this.expectToken(w.COLON),this.parseValueLiteral(!0)),loc:this.loc(n)}},e.parseFragment=function(){var n=this._lexer.token;this.expectToken(w.SPREAD);var i=this.expectOptionalKeyword("on");return!i&&this.peek(w.NAME)?{kind:j.FRAGMENT_SPREAD,name:this.parseFragmentName(),directives:this.parseDirectives(!1),loc:this.loc(n)}:{kind:j.INLINE_FRAGMENT,typeCondition:i?this.parseNamedType():void 0,directives:this.parseDirectives(!1),selectionSet:this.parseSelectionSet(),loc:this.loc(n)}},e.parseFragmentDefinition=function(){var n,i=this._lexer.token;return this.expectKeyword("fragment"),((n=this._options)===null||n===void 0?void 0:n.experimentalFragmentVariables)===!0?{kind:j.FRAGMENT_DEFINITION,name:this.parseFragmentName(),variableDefinitions:this.parseVariableDefinitions(),typeCondition:(this.expectKeyword("on"),this.parseNamedType()),directives:this.parseDirectives(!1),selectionSet:this.parseSelectionSet(),loc:this.loc(i)}:{kind:j.FRAGMENT_DEFINITION,name:this.parseFragmentName(),typeCondition:(this.expectKeyword("on"),this.parseNamedType()),directives:this.parseDirectives(!1),selectionSet:this.parseSelectionSet(),loc:this.loc(i)}},e.parseFragmentName=function(){if(this._lexer.token.value==="on")throw this.unexpected();return this.parseName()},e.parseValueLiteral=function(n){var i=this._lexer.token;switch(i.kind){case w.BRACKET_L:return this.parseList(n);case w.BRACE_L:return this.parseObject(n);case w.INT:return this._lexer.advance(),{kind:j.INT,value:i.value,loc:this.loc(i)};case w.FLOAT:return this._lexer.advance(),{kind:j.FLOAT,value:i.value,loc:this.loc(i)};case w.STRING:case w.BLOCK_STRING:return this.parseStringLiteral();case w.NAME:switch(this._lexer.advance(),i.value){case"true":return{kind:j.BOOLEAN,value:!0,loc:this.loc(i)};case"false":return{kind:j.BOOLEAN,value:!1,loc:this.loc(i)};case"null":return{kind:j.NULL,loc:this.loc(i)};default:return{kind:j.ENUM,value:i.value,loc:this.loc(i)}}case w.DOLLAR:if(!n)return this.parseVariable();break}throw this.unexpected()},e.parseStringLiteral=function(){var n=this._lexer.token;return this._lexer.advance(),{kind:j.STRING,value:n.value,block:n.kind===w.BLOCK_STRING,loc:this.loc(n)}},e.parseList=function(n){var i=this,a=this._lexer.token,o=function(){return i.parseValueLiteral(n)};return{kind:j.LIST,values:this.any(w.BRACKET_L,o,w.BRACKET_R),loc:this.loc(a)}},e.parseObject=function(n){var i=this,a=this._lexer.token,o=function(){return i.parseObjectField(n)};return{kind:j.OBJECT,fields:this.any(w.BRACE_L,o,w.BRACE_R),loc:this.loc(a)}},e.parseObjectField=function(n){var i=this._lexer.token,a=this.parseName();return this.expectToken(w.COLON),{kind:j.OBJECT_FIELD,name:a,value:this.parseValueLiteral(n),loc:this.loc(i)}},e.parseDirectives=function(n){for(var i=[];this.peek(w.AT);)i.push(this.parseDirective(n));return i},e.parseDirective=function(n){var i=this._lexer.token;return this.expectToken(w.AT),{kind:j.DIRECTIVE,name:this.parseName(),arguments:this.parseArguments(n),loc:this.loc(i)}},e.parseTypeReference=function(){var n=this._lexer.token,i;return this.expectOptionalToken(w.BRACKET_L)?(i=this.parseTypeReference(),this.expectToken(w.BRACKET_R),i={kind:j.LIST_TYPE,type:i,loc:this.loc(n)}):i=this.parseNamedType(),this.expectOptionalToken(w.BANG)?{kind:j.NON_NULL_TYPE,type:i,loc:this.loc(n)}:i},e.parseNamedType=function(){var n=this._lexer.token;return{kind:j.NAMED_TYPE,name:this.parseName(),loc:this.loc(n)}},e.parseTypeSystemDefinition=function(){var n=this.peekDescription()?this._lexer.lookahead():this._lexer.token;if(n.kind===w.NAME)switch(n.value){case"schema":return this.parseSchemaDefinition();case"scalar":return this.parseScalarTypeDefinition();case"type":return this.parseObjectTypeDefinition();case"interface":return this.parseInterfaceTypeDefinition();case"union":return this.parseUnionTypeDefinition();case"enum":return this.parseEnumTypeDefinition();case"input":return this.parseInputObjectTypeDefinition();case"directive":return this.parseDirectiveDefinition()}throw this.unexpected(n)},e.peekDescription=function(){return this.peek(w.STRING)||this.peek(w.BLOCK_STRING)},e.parseDescription=function(){if(this.peekDescription())return this.parseStringLiteral()},e.parseSchemaDefinition=function(){var n=this._lexer.token,i=this.parseDescription();this.expectKeyword("schema");var a=this.parseDirectives(!0),o=this.many(w.BRACE_L,this.parseOperationTypeDefinition,w.BRACE_R);return{kind:j.SCHEMA_DEFINITION,description:i,directives:a,operationTypes:o,loc:this.loc(n)}},e.parseOperationTypeDefinition=function(){var n=this._lexer.token,i=this.parseOperationType();this.expectToken(w.COLON);var a=this.parseNamedType();return{kind:j.OPERATION_TYPE_DEFINITION,operation:i,type:a,loc:this.loc(n)}},e.parseScalarTypeDefinition=function(){var n=this._lexer.token,i=this.parseDescription();this.expectKeyword("scalar");var a=this.parseName(),o=this.parseDirectives(!0);return{kind:j.SCALAR_TYPE_DEFINITION,description:i,name:a,directives:o,loc:this.loc(n)}},e.parseObjectTypeDefinition=function(){var n=this._lexer.token,i=this.parseDescription();this.expectKeyword("type");var a=this.parseName(),o=this.parseImplementsInterfaces(),s=this.parseDirectives(!0),u=this.parseFieldsDefinition();return{kind:j.OBJECT_TYPE_DEFINITION,description:i,name:a,interfaces:o,directives:s,fields:u,loc:this.loc(n)}},e.parseImplementsInterfaces=function(){var n;if(!this.expectOptionalKeyword("implements"))return[];if(((n=this._options)===null||n===void 0?void 0:n.allowLegacySDLImplementsInterfaces)===!0){var i=[];this.expectOptionalToken(w.AMP);do i.push(this.parseNamedType());while(this.expectOptionalToken(w.AMP)||this.peek(w.NAME));return i}return this.delimitedMany(w.AMP,this.parseNamedType)},e.parseFieldsDefinition=function(){var n;return((n=this._options)===null||n===void 0?void 0:n.allowLegacySDLEmptyFields)===!0&&this.peek(w.BRACE_L)&&this._lexer.lookahead().kind===w.BRACE_R?(this._lexer.advance(),this._lexer.advance(),[]):this.optionalMany(w.BRACE_L,this.parseFieldDefinition,w.BRACE_R)},e.parseFieldDefinition=function(){var n=this._lexer.token,i=this.parseDescription(),a=this.parseName(),o=this.parseArgumentDefs();this.expectToken(w.COLON);var s=this.parseTypeReference(),u=this.parseDirectives(!0);return{kind:j.FIELD_DEFINITION,description:i,name:a,arguments:o,type:s,directives:u,loc:this.loc(n)}},e.parseArgumentDefs=function(){return this.optionalMany(w.PAREN_L,this.parseInputValueDef,w.PAREN_R)},e.parseInputValueDef=function(){var n=this._lexer.token,i=this.parseDescription(),a=this.parseName();this.expectToken(w.COLON);var o=this.parseTypeReference(),s;this.expectOptionalToken(w.EQUALS)&&(s=this.parseValueLiteral(!0));var u=this.parseDirectives(!0);return{kind:j.INPUT_VALUE_DEFINITION,description:i,name:a,type:o,defaultValue:s,directives:u,loc:this.loc(n)}},e.parseInterfaceTypeDefinition=function(){var n=this._lexer.token,i=this.parseDescription();this.expectKeyword("interface");var a=this.parseName(),o=this.parseImplementsInterfaces(),s=this.parseDirectives(!0),u=this.parseFieldsDefinition();return{kind:j.INTERFACE_TYPE_DEFINITION,description:i,name:a,interfaces:o,directives:s,fields:u,loc:this.loc(n)}},e.parseUnionTypeDefinition=function(){var n=this._lexer.token,i=this.parseDescription();this.expectKeyword("union");var a=this.parseName(),o=this.parseDirectives(!0),s=this.parseUnionMemberTypes();return{kind:j.UNION_TYPE_DEFINITION,description:i,name:a,directives:o,types:s,loc:this.loc(n)}},e.parseUnionMemberTypes=function(){return this.expectOptionalToken(w.EQUALS)?this.delimitedMany(w.PIPE,this.parseNamedType):[]},e.parseEnumTypeDefinition=function(){var n=this._lexer.token,i=this.parseDescription();this.expectKeyword("enum");var a=this.parseName(),o=this.parseDirectives(!0),s=this.parseEnumValuesDefinition();return{kind:j.ENUM_TYPE_DEFINITION,description:i,name:a,directives:o,values:s,loc:this.loc(n)}},e.parseEnumValuesDefinition=function(){return this.optionalMany(w.BRACE_L,this.parseEnumValueDefinition,w.BRACE_R)},e.parseEnumValueDefinition=function(){var n=this._lexer.token,i=this.parseDescription(),a=this.parseName(),o=this.parseDirectives(!0);return{kind:j.ENUM_VALUE_DEFINITION,description:i,name:a,directives:o,loc:this.loc(n)}},e.parseInputObjectTypeDefinition=function(){var n=this._lexer.token,i=this.parseDescription();this.expectKeyword("input");var a=this.parseName(),o=this.parseDirectives(!0),s=this.parseInputFieldsDefinition();return{kind:j.INPUT_OBJECT_TYPE_DEFINITION,description:i,name:a,directives:o,fields:s,loc:this.loc(n)}},e.parseInputFieldsDefinition=function(){return this.optionalMany(w.BRACE_L,this.parseInputValueDef,w.BRACE_R)},e.parseTypeSystemExtension=function(){var n=this._lexer.lookahead();if(n.kind===w.NAME)switch(n.value){case"schema":return this.parseSchemaExtension();case"scalar":return this.parseScalarTypeExtension();case"type":return this.parseObjectTypeExtension();case"interface":return this.parseInterfaceTypeExtension();case"union":return this.parseUnionTypeExtension();case"enum":return this.parseEnumTypeExtension();case"input":return this.parseInputObjectTypeExtension()}throw this.unexpected(n)},e.parseSchemaExtension=function(){var n=this._lexer.token;this.expectKeyword("extend"),this.expectKeyword("schema");var i=this.parseDirectives(!0),a=this.optionalMany(w.BRACE_L,this.parseOperationTypeDefinition,w.BRACE_R);if(i.length===0&&a.length===0)throw this.unexpected();return{kind:j.SCHEMA_EXTENSION,directives:i,operationTypes:a,loc:this.loc(n)}},e.parseScalarTypeExtension=function(){var n=this._lexer.token;this.expectKeyword("extend"),this.expectKeyword("scalar");var i=this.parseName(),a=this.parseDirectives(!0);if(a.length===0)throw this.unexpected();return{kind:j.SCALAR_TYPE_EXTENSION,name:i,directives:a,loc:this.loc(n)}},e.parseObjectTypeExtension=function(){var n=this._lexer.token;this.expectKeyword("extend"),this.expectKeyword("type");var i=this.parseName(),a=this.parseImplementsInterfaces(),o=this.parseDirectives(!0),s=this.parseFieldsDefinition();if(a.length===0&&o.length===0&&s.length===0)throw this.unexpected();return{kind:j.OBJECT_TYPE_EXTENSION,name:i,interfaces:a,directives:o,fields:s,loc:this.loc(n)}},e.parseInterfaceTypeExtension=function(){var n=this._lexer.token;this.expectKeyword("extend"),this.expectKeyword("interface");var i=this.parseName(),a=this.parseImplementsInterfaces(),o=this.parseDirectives(!0),s=this.parseFieldsDefinition();if(a.length===0&&o.length===0&&s.length===0)throw this.unexpected();return{kind:j.INTERFACE_TYPE_EXTENSION,name:i,interfaces:a,directives:o,fields:s,loc:this.loc(n)}},e.parseUnionTypeExtension=function(){var n=this._lexer.token;this.expectKeyword("extend"),this.expectKeyword("union");var i=this.parseName(),a=this.parseDirectives(!0),o=this.parseUnionMemberTypes();if(a.length===0&&o.length===0)throw this.unexpected();return{kind:j.UNION_TYPE_EXTENSION,name:i,directives:a,types:o,loc:this.loc(n)}},e.parseEnumTypeExtension=function(){var n=this._lexer.token;this.expectKeyword("extend"),this.expectKeyword("enum");var i=this.parseName(),a=this.parseDirectives(!0),o=this.parseEnumValuesDefinition();if(a.length===0&&o.length===0)throw this.unexpected();return{kind:j.ENUM_TYPE_EXTENSION,name:i,directives:a,values:o,loc:this.loc(n)}},e.parseInputObjectTypeExtension=function(){var n=this._lexer.token;this.expectKeyword("extend"),this.expectKeyword("input");var i=this.parseName(),a=this.parseDirectives(!0),o=this.parseInputFieldsDefinition();if(a.length===0&&o.length===0)throw this.unexpected();return{kind:j.INPUT_OBJECT_TYPE_EXTENSION,name:i,directives:a,fields:o,loc:this.loc(n)}},e.parseDirectiveDefinition=function(){var n=this._lexer.token,i=this.parseDescription();this.expectKeyword("directive"),this.expectToken(w.AT);var a=this.parseName(),o=this.parseArgumentDefs(),s=this.expectOptionalKeyword("repeatable");this.expectKeyword("on");var u=this.parseDirectiveLocations();return{kind:j.DIRECTIVE_DEFINITION,description:i,name:a,arguments:o,repeatable:s,locations:u,loc:this.loc(n)}},e.parseDirectiveLocations=function(){return this.delimitedMany(w.PIPE,this.parseDirectiveLocation)},e.parseDirectiveLocation=function(){var n=this._lexer.token,i=this.parseName();if(i1[i.value]!==void 0)return i;throw this.unexpected(n)},e.loc=function(n){var i;if(((i=this._options)===null||i===void 0?void 0:i.noLocation)!==!0)return new pp(n,this._lexer.lastToken,this._lexer.source)},e.peek=function(n){return this._lexer.token.kind===n},e.expectToken=function(n){var i=this._lexer.token;if(i.kind===n)return this._lexer.advance(),i;throw nt(this._lexer.source,i.start,"Expected ".concat(hp(n),", found ").concat(Ns(i),"."))},e.expectOptionalToken=function(n){var i=this._lexer.token;if(i.kind===n)return this._lexer.advance(),i},e.expectKeyword=function(n){var i=this._lexer.token;if(i.kind===w.NAME&&i.value===n)this._lexer.advance();else throw nt(this._lexer.source,i.start,'Expected "'.concat(n,'", found ').concat(Ns(i),"."))},e.expectOptionalKeyword=function(n){var i=this._lexer.token;return i.kind===w.NAME&&i.value===n?(this._lexer.advance(),!0):!1},e.unexpected=function(n){var i=n??this._lexer.token;return nt(this._lexer.source,i.start,"Unexpected ".concat(Ns(i),"."))},e.any=function(n,i,a){this.expectToken(n);for(var o=[];!this.expectOptionalToken(a);)o.push(i.call(this));return o},e.optionalMany=function(n,i,a){if(this.expectOptionalToken(n)){var o=[];do o.push(i.call(this));while(!this.expectOptionalToken(a));return o}return[]},e.many=function(n,i,a){this.expectToken(n);var o=[];do o.push(i.call(this));while(!this.expectOptionalToken(a));return o},e.delimitedMany=function(n,i){this.expectOptionalToken(n);var a=[];do a.push(i.call(this));while(this.expectOptionalToken(n));return a},r}();function Ns(r){var e=r.value;return hp(r.kind)+(e!=null?' "'.concat(e,'"'):"")}function hp(r){return c1(r)?'"'.concat(r,'"'):r}var Ta=new Map,Us=new Map,mp=!0,La=!1;function yp(r){return r.replace(/[\s,]+/g," ").trim()}function C1(r){return yp(r.source.body.substring(r.start,r.end))}function S1(r){var e=new Set,t=[];return r.definitions.forEach(function(n){if(n.kind==="FragmentDefinition"){var i=n.name.value,a=C1(n.loc),o=Us.get(i);o&&!o.has(a)?mp&&console.warn("Warning: fragment with name "+i+` already exists.
62
62
  graphql-tag enforces all fragment names across your application to be unique; read more about
63
- this in the docs: http://dev.apollodata.com/core/fragments.html#unique-names`):o||Us.set(i,o=new Set),o.add(a),e.has(a)||(e.add(a),t.push(n))}else t.push(n)}),Ra(Ra({},r),{definitions:t})}function w1(r){var e=new Set(r.definitions);e.forEach(function(n){n.loc&&delete n.loc,Object.keys(n).forEach(function(i){var a=n[i];a&&typeof a=="object"&&e.add(a)})});var t=r.loc;return t&&(delete t.startToken,delete t.endToken),r}function _1(r){var e=yp(r);if(!Ta.has(e)){var t=v1(r,{experimentalFragmentVariables:La,allowLegacyFragmentVariables:La});if(!t||t.kind!=="Document")throw new Error("Not a valid GraphQL document.");Ta.set(e,w1(S1(t)))}return Ta.get(e)}function E(r){for(var e=[],t=1;t<arguments.length;t++)e[t-1]=arguments[t];typeof r=="string"&&(r=[r]);var n=r[0];return e.forEach(function(i,a){i&&i.kind==="Document"?n+=i.loc.source.body:n+=i,n+=r[a+1]}),_1(n)}function E1(){Ta.clear(),Us.clear()}function x1(){mp=!1}function O1(){La=!0}function T1(){La=!1}var ri={gql:E,resetCaches:E1,disableFragmentWarnings:x1,enableExperimentalFragmentVariables:O1,disableExperimentalFragmentVariables:T1};(function(r){r.gql=ri.gql,r.resetCaches=ri.resetCaches,r.disableFragmentWarnings=ri.disableFragmentWarnings,r.enableExperimentalFragmentVariables=ri.enableExperimentalFragmentVariables,r.disableExperimentalFragmentVariables=ri.disableExperimentalFragmentVariables})(E||(E={}));E.default=E;function A(r){if(!r)throw"Got no result from Apollo";if(r.error)throw r.error;if(r.errors)throw r.errors;return r.data}function A1(){}function Zs(){return A1}var v=Zs,Ge=Zs,J=Zs,gp=function(r,e,t,n){var i=arguments.length,a=i<3?e:n===null?n=Object.getOwnPropertyDescriptor(e,t):n,o;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")a=Reflect.decorate(r,e,t,n);else for(var s=r.length-1;s>=0;s--)(o=r[s])&&(a=(i<3?o(a):i>3?o(e,t,a):o(e,t))||a);return i>3&&a&&Object.defineProperty(e,t,a),a},vp=function(r,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(r,e)},jr=class{constructor(e){this.code=e}};gp([v(),vp("design:type",String)],jr.prototype,"code",void 0);jr=gp([J(),vp("design:paramtypes",[String])],jr);var ec=function(r,e,t,n){var i=arguments.length,a=i<3?e:n===null?n=Object.getOwnPropertyDescriptor(e,t):n,o;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")a=Reflect.decorate(r,e,t,n);else for(var s=r.length-1;s>=0;s--)(o=r[s])&&(a=(i<3?o(a):i>3?o(e,t,a):o(e,t))||a);return i>3&&a&&Object.defineProperty(e,t,a),a},tc=function(r,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(r,e)},xt=class{constructor(e,t){this.address=e,this.name=t}};ec([v(),tc("design:type",String)],xt.prototype,"address",void 0);ec([v(),tc("design:type",String)],xt.prototype,"name",void 0);xt=ec([J(),tc("design:paramtypes",[String,String])],xt);var fe=function(r,e,t,n){var i=arguments.length,a=i<3?e:n===null?n=Object.getOwnPropertyDescriptor(e,t):n,o;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")a=Reflect.decorate(r,e,t,n);else for(var s=r.length-1;s>=0;s--)(o=r[s])&&(a=(i<3?o(a):i>3?o(e,t,a):o(e,t))||a);return i>3&&a&&Object.defineProperty(e,t,a),a},Te=function(r,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(r,e)},ir=class{constructor(e,t){this.key=t,this.signature=e}};fe([v(),Te("design:type",String)],ir.prototype,"signature",void 0);fe([v(),Te("design:type",String)],ir.prototype,"key",void 0);fe([v(),Te("design:type",Boolean)],ir.prototype,"valid",void 0);fe([v(),Te("design:type",Boolean)],ir.prototype,"invalid",void 0);ir=fe([J(),Ge(),Te("design:paramtypes",[String,String])],ir);var Ur=class{};fe([v(),Te("design:type",String)],Ur.prototype,"signature",void 0);fe([v(),Te("design:type",String)],Ur.prototype,"key",void 0);fe([v(),Te("design:type",Boolean)],Ur.prototype,"valid",void 0);fe([v(),Te("design:type",Boolean)],Ur.prototype,"invalid",void 0);Ur=fe([Ge()],Ur);function lr(r){let e=class{constructor(n,i,a,o){this.author=n,this.timestamp=i,this.data=a,this.proof=o}};return fe([v(),Te("design:type",String)],e.prototype,"author",void 0),fe([v(),Te("design:type",String)],e.prototype,"timestamp",void 0),fe([v(),Te("design:type",Object)],e.prototype,"data",void 0),fe([v(),Te("design:type",ir)],e.prototype,"proof",void 0),e=fe([J(),Te("design:paramtypes",[String,String,Object,ir])],e),e}function I1(r){let e=class{};return fe([v(),Te("design:type",String)],e.prototype,"author",void 0),fe([v(),Te("design:type",String)],e.prototype,"timestamp",void 0),fe([v(),Te("design:type",Object)],e.prototype,"data",void 0),fe([v(),Te("design:type",Ur)],e.prototype,"proof",void 0),e=fe([Ge()],e),e}var Ql=class extends lr(){};Ql=fe([J()],Ql);var Fa=class extends lr(){};fe([v(),Te("design:type",xt)],Fa.prototype,"language",void 0);fe([v(),Te("design:type",jr)],Fa.prototype,"icon",void 0);Fa=fe([J()],Fa);function _6(r){return r&&r.author&&r.timestamp&&r.data}var Ee=function(r,e,t,n){var i=arguments.length,a=i<3?e:n===null?n=Object.getOwnPropertyDescriptor(e,t):n,o;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")a=Reflect.decorate(r,e,t,n);else for(var s=r.length-1;s>=0;s--)(o=r[s])&&(a=(i<3?o(a):i>3?o(e,t,a):o(e,t))||a);return i>3&&a&&Object.defineProperty(e,t,a),a},$e=function(r,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(r,e)},Ot=class{constructor(e){this.source=e.source?e.source:"",this.target=e.target?e.target:"",this.predicate=e.predicate?e.predicate:""}};Ee([v(),$e("design:type",String)],Ot.prototype,"source",void 0);Ee([v(),$e("design:type",String)],Ot.prototype,"target",void 0);Ee([v(),$e("design:type",String)],Ot.prototype,"predicate",void 0);Ot=Ee([J(),$e("design:paramtypes",[Object])],Ot);var $a=class{};Ee([v(),$e("design:type",Array)],$a.prototype,"additions",void 0);Ee([v(),$e("design:type",Array)],$a.prototype,"removals",void 0);$a=Ee([Ge()],$a);var Ma=class{constructor(e,t){this.additions=e,this.removals=t}};Ee([v(),$e("design:type",Array)],Ma.prototype,"additions",void 0);Ee([v(),$e("design:type",Array)],Ma.prototype,"removals",void 0);Ma=Ee([J(),$e("design:paramtypes",[Array,Array])],Ma);var Ci=class{};Ee([v(),$e("design:type",String)],Ci.prototype,"source",void 0);Ee([v(),$e("design:type",String)],Ci.prototype,"target",void 0);Ee([v(),$e("design:type",String)],Ci.prototype,"predicate",void 0);Ci=Ee([Ge()],Ci);var qr=class extends lr(){hash(){let e=JSON.stringify(this.data,Object.keys(this.data).sort())+JSON.stringify(this.author)+this.timestamp,t=0,n,i;for(n=0;n<e.length;n++)i=e.charCodeAt(n),t=(t<<5)-t+i,t|=0;return t}};Ee([v(),$e("design:type",String)],qr.prototype,"status",void 0);qr=Ee([J()],qr);var qs=class extends I1(){};Ee([v(),$e("design:type",String)],qs.prototype,"status",void 0);qs=Ee([Ge()],qs);function k6(r,e){return r.author==e.author&&r.timestamp==e.timestamp&&r.data.source==e.data.source&&r.data.predicate==e.data.predicate&&r.data.target==e.data.target}function D6(r){return r&&r.source&&r.target}var ja=class{constructor(e,t){this.oldLink=e,this.newLink=t}};Ee([v(),$e("design:type",qr)],ja.prototype,"oldLink",void 0);Ee([v(),$e("design:type",qr)],ja.prototype,"newLink",void 0);ja=Ee([J(),$e("design:paramtypes",[qr,qr])],ja);var Vr=function(r,e,t,n){var i=arguments.length,a=i<3?e:n===null?n=Object.getOwnPropertyDescriptor(e,t):n,o;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")a=Reflect.decorate(r,e,t,n);else for(var s=r.length-1;s>=0;s--)(o=r[s])&&(a=(i<3?o(a):i>3?o(e,t,a):o(e,t))||a);return i>3&&a&&Object.defineProperty(e,t,a),a},Ei=function(r,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(r,e)},Bs,ar=class{constructor(e){e?this.links=e:this.links=[]}get(e){if(!e||!e.source&&!e.predicate&&!e.target)return this.links;if(e.source){let n=JSON.parse(JSON.stringify(this.links));return e.target&&(n=n.filter(i=>i.data.target===e.target)),e.predicate&&(n=n.filter(i=>i.data.predicate===e.predicate)),e.fromDate&&(n=n.filter(i=>new Date(i.timestamp)>=e.fromDate)),e.untilDate&&(n=n.filter(i=>new Date(i.timestamp)<=e.untilDate)),e.limit&&(n=n.slice(0,e.limit)),n}if(e.target){let n=JSON.parse(JSON.stringify(this.links));return e.predicate&&(n=n.filter(i=>i.data.predicate===e.predicate)),e.fromDate&&(n=n.filter(i=>new Date(i.timestamp)>=e.fromDate)),e.untilDate&&(n=n.filter(i=>new Date(i.timestamp)<=e.untilDate)),e.limit&&(n=n.slice(0,e.limit)),n}let t=JSON.parse(JSON.stringify(this.links));return t=t.filter(n=>n.data.predicate===e.predicate),e.limit&&(t=t.slice(0,e.limit)),t}getSingleTarget(e){delete e.target;let t=this.get(e);return t.length?t[0].data.target:null}};Vr([v(),Ei("design:type",Array)],ar.prototype,"links",void 0);ar=Vr([J(),Ei("design:paramtypes",[Array])],ar);var Vs=class{};Vr([v(),Ei("design:type",Array)],Vs.prototype,"links",void 0);Vs=Vr([Ge()],Vs);var Qs=Bs=class{constructor(e){e?this.links=e:this.links=[]}static fromLink(e){let t=new Bs;return t.links.push(e),t}};Vr([v(),Ei("design:type",Array)],Qs.prototype,"links",void 0);Qs=Bs=Vr([Ge(),Ei("design:paramtypes",[Array])],Qs);var Ws=class extends lr(){};Ws=Vr([J()],Ws);var F=function(r,e,t,n){var i=arguments.length,a=i<3?e:n===null?n=Object.getOwnPropertyDescriptor(e,t):n,o;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")a=Reflect.decorate(r,e,t,n);else for(var s=r.length-1;s>=0;s--)(o=r[s])&&(a=(i<3?o(a):i>3?o(e,t,a):o(e,t))||a);return i>3&&a&&Object.defineProperty(e,t,a),a},$=function(r,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(r,e)},rr=class{constructor(e,t){this.did=e,t?this.perspective=t:this.perspective=new ar}};F([v(),$("design:type",String)],rr.prototype,"did",void 0);F([v(),$("design:type",ar)],rr.prototype,"perspective",void 0);F([v(),$("design:type",String)],rr.prototype,"directMessageLanguage",void 0);rr=F([J(),$("design:paramtypes",[String,ar])],rr);var Wl=class extends lr(){};Wl=F([J()],Wl);var or=class{constructor(e,t,n,i,a,o){this.did=e,this.didSigningKeyId=t,this.deviceKeyType=n,this.deviceKey=i,this.deviceKeySignedByDid=a,this.didSignedByDeviceKey=o}};F([v(),$("design:type",String)],or.prototype,"did",void 0);F([v(),$("design:type",String)],or.prototype,"didSigningKeyId",void 0);F([v(),$("design:type",String)],or.prototype,"deviceKeyType",void 0);F([v(),$("design:type",String)],or.prototype,"deviceKey",void 0);F([v(),$("design:type",String)],or.prototype,"deviceKeySignedByDid",void 0);F([v(),$("design:type",String)],or.prototype,"didSignedByDeviceKey",void 0);or=F([J(),$("design:paramtypes",[String,String,String,String,String,String])],or);var sr=class{constructor(e,t,n,i,a,o){this.did=e,this.didSigningKeyId=t,this.deviceKeyType=n,this.deviceKey=i,this.deviceKeySignedByDid=a,this.didSignedByDeviceKey=o}};F([v(),$("design:type",String)],sr.prototype,"did",void 0);F([v(),$("design:type",String)],sr.prototype,"didSigningKeyId",void 0);F([v(),$("design:type",String)],sr.prototype,"deviceKeyType",void 0);F([v(),$("design:type",String)],sr.prototype,"deviceKey",void 0);F([v(),$("design:type",String)],sr.prototype,"deviceKeySignedByDid",void 0);F([v(),$("design:type",String)],sr.prototype,"didSignedByDeviceKey",void 0);sr=F([Ge(),$("design:paramtypes",[String,String,String,String,String,String])],sr);var Ua=class{constructor(e,t){this.signature=e,this.publicKey=t}};F([v(),$("design:type",String)],Ua.prototype,"signature",void 0);F([v(),$("design:type",String)],Ua.prototype,"publicKey",void 0);Ua=F([J(),$("design:paramtypes",[String,String])],Ua);var wn=class{constructor(e,t){this.domain=e,this.pointers=t}};F([v(),$("design:type",String)],wn.prototype,"domain",void 0);F([v(),$("design:type",Array)],wn.prototype,"pointers",void 0);wn=F([J(),$("design:paramtypes",[String,Array])],wn);var qa=class{constructor(e,t){this.with=e,this.can=t}};F([v(),$("design:type",wn)],qa.prototype,"with",void 0);F([v(),$("design:type",Array)],qa.prototype,"can",void 0);qa=F([J(),$("design:paramtypes",[wn,Array])],qa);var jt=class{constructor(e,t,n,i,a){this.appName=e,this.appDesc=t,this.appIconPath=a,this.appUrl=n,this.capabilities=i}};F([v(),$("design:type",String)],jt.prototype,"appName",void 0);F([v(),$("design:type",String)],jt.prototype,"appDesc",void 0);F([v(),$("design:type",String)],jt.prototype,"appUrl",void 0);F([v(),$("design:type",String)],jt.prototype,"appIconPath",void 0);F([v(),$("design:type",Array)],jt.prototype,"capabilities",void 0);jt=F([J(),$("design:paramtypes",[String,String,String,Array,String])],jt);var _n=class{constructor(e,t,n,i){this.requestId=e,this.auth=t,this.token=n,this.revoked=i}};F([v(),$("design:type",String)],_n.prototype,"requestId",void 0);F([v(),$("design:type",String)],_n.prototype,"token",void 0);F([v(),$("design:type",Boolean)],_n.prototype,"revoked",void 0);F([v(),$("design:type",jt)],_n.prototype,"auth",void 0);_n=F([J(),$("design:paramtypes",[String,jt,String,Boolean])],_n);var En=class{constructor(e,t){this.domain=e,this.pointers=t}};F([v(),$("design:type",String)],En.prototype,"domain",void 0);F([v(),$("design:type",Array)],En.prototype,"pointers",void 0);En=F([Ge(),$("design:paramtypes",[String,Array])],En);var Ba=class{constructor(e,t){this.with=e,this.can=t}};F([v(),$("design:type",En)],Ba.prototype,"with",void 0);F([v(),$("design:type",Array)],Ba.prototype,"can",void 0);Ba=F([Ge(),$("design:paramtypes",[En,Array])],Ba);var cr=class{constructor(e,t,n,i,a,o){this.appName=e,this.appDesc=t,this.appUrl=i,this.appDomain=n,this.capabilities=o,this.appIconPath=a}};F([v(),$("design:type",String)],cr.prototype,"appName",void 0);F([v(),$("design:type",String)],cr.prototype,"appDesc",void 0);F([v(),$("design:type",String)],cr.prototype,"appDomain",void 0);F([v(),$("design:type",String)],cr.prototype,"appUrl",void 0);F([v(),$("design:type",String)],cr.prototype,"appIconPath",void 0);F([v(),$("design:type",Array)],cr.prototype,"capabilities",void 0);cr=F([Ge(),$("design:paramtypes",[String,String,String,String,String,Array])],cr);var On=function(r,e,t,n){var i=arguments.length,a=i<3?e:n===null?n=Object.getOwnPropertyDescriptor(e,t):n,o;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")a=Reflect.decorate(r,e,t,n);else for(var s=r.length-1;s>=0;s--)(o=r[s])&&(a=(i<3?o(a):i>3?o(e,t,a):o(e,t))||a);return i>3&&a&&Object.defineProperty(e,t,a),a},Tn=function(r,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(r,e)},ct=class{constructor(e){e?(this.isInitialized=e.isInitialized,this.isInitialized||(this.isInitialized=!1),this.isUnlocked=e.isUnlocked,this.isUnlocked||(this.isUnlocked=!1),this.did=e.did,this.didDocument=e.didDocument,this.error=e.error):(this.isInitialized=!1,this.isUnlocked=!1)}};On([v(),Tn("design:type",Boolean)],ct.prototype,"isInitialized",void 0);On([v(),Tn("design:type",Boolean)],ct.prototype,"isUnlocked",void 0);On([v(),Tn("design:type",String)],ct.prototype,"did",void 0);On([v(),Tn("design:type",String)],ct.prototype,"didDocument",void 0);On([v(),Tn("design:type",String)],ct.prototype,"error",void 0);ct=On([J(),Tn("design:paramtypes",[Object])],ct);var Gl=function(r,e,t,n,i){if(n==="m")throw new TypeError("Private method is not writable");if(n==="a"&&!i)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?r!==e||!i:!e.has(r))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?i.call(r,t):i?i.value=t:e.set(r,t),t},Ce=function(r,e,t,n){if(t==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?r!==e||!n:!e.has(r))throw new TypeError("Cannot read private member from an object whose class did not declare it");return t==="m"?n:t==="a"?n.call(r):n?n.value:e.get(r)},Ye,Xe,Gs=class{constructor(e,t){Ye.set(this,void 0),Xe.set(this,void 0),Gl(this,Ye,e,"f"),Gl(this,Xe,t,"f")}async otherAgents(){return await Ce(this,Ye,"f").otherAgents(Ce(this,Xe,"f"))}async hasTelepresenceAdapter(){return await Ce(this,Ye,"f").hasTelepresenceAdapter(Ce(this,Xe,"f"))}async onlineAgents(){return await Ce(this,Ye,"f").onlineAgents(Ce(this,Xe,"f"))}async setOnlineStatus(e){return await Ce(this,Ye,"f").setOnlineStatus(Ce(this,Xe,"f"),e)}async setOnlineStatusU(e){return await Ce(this,Ye,"f").setOnlineStatusU(Ce(this,Xe,"f"),e)}async sendSignal(e,t){return await Ce(this,Ye,"f").sendSignal(Ce(this,Xe,"f"),e,t)}async sendSignalU(e,t){return await Ce(this,Ye,"f").sendSignalU(Ce(this,Xe,"f"),e,t)}async sendBroadcast(e){return await Ce(this,Ye,"f").sendBroadcast(Ce(this,Xe,"f"),e)}async sendBroadcastU(e){return await Ce(this,Ye,"f").sendBroadcastU(Ce(this,Xe,"f"),e)}async addSignalHandler(e){await Ce(this,Ye,"f").addSignalHandler(Ce(this,Xe,"f"),e)}removeSignalHandler(e){Ce(this,Ye,"f").removeSignalHandler(Ce(this,Xe,"f"),e)}};Ye=new WeakMap,Xe=new WeakMap;var Qr=function(r,e,t,n){var i=arguments.length,a=i<3?e:n===null?n=Object.getOwnPropertyDescriptor(e,t):n,o;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")a=Reflect.decorate(r,e,t,n);else for(var s=r.length-1;s>=0;s--)(o=r[s])&&(a=(i<3?o(a):i>3?o(e,t,a):o(e,t))||a);return i>3&&a&&Object.defineProperty(e,t,a),a},Wr=function(r,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(r,e)},We=class{constructor(e){e&&(this.source=e.source,this.predicate=e.predicate,this.target=e.target,e.fromDate&&(this.fromDate=e.fromDate),e.untilDate&&(this.untilDate=e.untilDate),e.limit&&(this.limit=e.limit))}isMatch(e){return!(this.source&&this.source!==e.source||this.predicate&&this.predicate!==e.predicate||this.target&&this.target!==e.target)}};Qr([v(),Wr("design:type",String)],We.prototype,"source",void 0);Qr([v(),Wr("design:type",String)],We.prototype,"target",void 0);Qr([v(),Wr("design:type",String)],We.prototype,"predicate",void 0);Qr([v(),Wr("design:type",Date)],We.prototype,"fromDate",void 0);Qr([v(),Wr("design:type",Date)],We.prototype,"untilDate",void 0);Qr([v(),Wr("design:type",Number)],We.prototype,"limit",void 0);We=Qr([J(),Ge(),Wr("design:paramtypes",[Object])],We);var Kl=function(r,e,t,n,i){if(n==="m")throw new TypeError("Private method is not writable");if(n==="a"&&!i)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?r!==e||!i:!e.has(r))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?i.call(r,t):i?i.value=t:e.set(r,t),t},Je=function(r,e,t,n){if(t==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?r!==e||!n:!e.has(r))throw new TypeError("Cannot read private member from an object whose class did not declare it");return t==="m"?n:t==="a"?n.call(r):n?n.value:e.get(r)},mt,Lt;function Rs(r){return encodeURIComponent(r).replace(/[!'()*]/g,e=>`%${e.charCodeAt(0).toString(16).toUpperCase()}`)}var Tt=class{constructor(){mt.set(this,void 0),Lt.set(this,void 0)}static fromUrl(e){if(!e||!e.startsWith("literal://"))throw new Error("Can't create Literal from non-literal URL");let t=new Tt;return Kl(t,Lt,e,"f"),t}static from(e){let t=new Tt;return Kl(t,mt,e,"f"),t}toUrl(){if(Je(this,Lt,"f")&&!Je(this,mt,"f"))return Je(this,Lt,"f");if(!Je(this,Lt,"f")&&!Je(this,mt,"f"))throw new Error("Can't turn empty Literal into URL");let e;switch(typeof Je(this,mt,"f")){case"string":e=`string:${Rs(Je(this,mt,"f"))}`;break;case"number":e=`number:${Rs(Je(this,mt,"f"))}`;break;case"object":e=`json:${Rs(JSON.stringify(Je(this,mt,"f")))}`;break}return`literal://${e}`}get(){if(Je(this,mt,"f"))return Je(this,mt,"f");if(!Je(this,Lt,"f"))throw new Error("Can't render empty Literal");if(!Je(this,Lt,"f").startsWith("literal://"))throw new Error("Can't render Literal from non-literal URL");let e=Je(this,Lt,"f").substring(10);if(e.startsWith("string:"))return decodeURIComponent(e.substring(7));if(e.startsWith("number:")){let t=e.substring(7);return parseFloat(t)}if(e.startsWith("json:")){let t=e.substring(5);return JSON.parse(decodeURIComponent(t))}throw new Error(`Can't parse unknown literal: ${e}`)}};mt=new WeakMap,Lt=new WeakMap;function nr(r){return r.charAt(0).toUpperCase()+r.slice(1)}function bp(r){return`set${nr(r)}`}function Mt(r){return r.endsWith("y")?r.slice(0,-1)+"ies":r+"s"}function rc(r){return r.endsWith("ies")?r.slice(0,-3)+"y":r.endsWith("s")?r.slice(0,-1):r}function k1(r){return`add${nr(rc(r))}`}function D1(r){let e=r.substring(3),t=Mt(e);return t.charAt(0).toLowerCase()+t.slice(1)}function P1(r){return`remove${nr(rc(r))}`}function N1(r){let e=r.substring(6),t=Mt(e);return t.charAt(0).toLowerCase()+t.slice(1)}function R1(r){let e=r.substring(13),t=Mt(e);return t.charAt(0).toLowerCase()+t.slice(1)}function L1(r){return`setCollection${nr(rc(r))}`}function Dr(r){if(Array.isArray(r))return`[${r.map(Dr).join(", ")}]`;let e=Object.keys(r),t=[];for(let n of e){let i=JSON.stringify(r[n]),a=`${n}: ${i}`;t.push(a)}return`{${t.join(", ")}}`}var Ls=function(r,e,t,n,i){if(n==="m")throw new TypeError("Private method is not writable");if(n==="a"&&!i)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?r!==e||!i:!e.has(r))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?i.call(r,t):i?i.value=t:e.set(r,t),t},q=function(r,e,t,n){if(t==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?r!==e||!n:!e.has(r))throw new TypeError("Cannot read private member from an object whose class did not declare it");return t==="m"?n:t==="a"?n.call(r):n?n.value:e.get(r)},qe,Be,he,Va=class{constructor(r,e,t){qe.set(this,void 0),Be.set(this,void 0),he.set(this,void 0),Ls(this,qe,e,"f"),Ls(this,Be,t,"f"),Ls(this,he,r,"f")}get baseExpression(){return q(this,qe,"f")}async init(){let isInstance=await q(this,he,"f").isSubjectInstance(q(this,qe,"f"),q(this,Be,"f"));if(!isInstance)throw`Not a valid subject instance of ${q(this,Be,"f")} for ${q(this,qe,"f")}`;let results=await q(this,he,"f").infer(`subject_class("${q(this,Be,"f")}", C), property(C, Property)`),properties=results.map(r=>r.Property);for(let r of properties){let e=await q(this,he,"f").infer(`subject_class("${q(this,Be,"f")}", C), property_resolve(C, "${r}")`);Object.defineProperty(this,r,{configurable:!0,get:async()=>{let t=await q(this,he,"f").infer(`subject_class("${q(this,Be,"f")}", C), property_getter(C, "${q(this,qe,"f")}", "${r}", Value)`);if(t&&t.length>0){let n=t[0].Value;if(e)try{let i=await q(this,he,"f").getExpression(n);try{return JSON.parse(i.data)}catch{return i.data}}catch{return n}else return n}else return t||void 0}})}let setters=await q(this,he,"f").infer(`subject_class("${q(this,Be,"f")}", C), property_setter(C, Property, Setter)`);for(let setter of setters||[])if(setter){let property=setter.Property,actions=eval(setter.Setter),resolveLanguageResults=await q(this,he,"f").infer(`subject_class("${q(this,Be,"f")}", C), property_resolve_language(C, "${property}", Language)`),resolveLanguage;resolveLanguageResults&&resolveLanguageResults.length>0&&(resolveLanguage=resolveLanguageResults[0].Language),this[bp(property)]=async r=>{resolveLanguage&&(r=await q(this,he,"f").createExpression(r,resolveLanguage)),await q(this,he,"f").executeAction(actions,q(this,qe,"f"),[{name:"value",value:r}])}}let results2=await q(this,he,"f").infer(`subject_class("${q(this,Be,"f")}", C), collection(C, Collection)`);results2||(results2=[]);let collections=results2.map(r=>r.Collection);for(let r of collections)Object.defineProperty(this,r,{configurable:!0,get:async()=>{let e=await q(this,he,"f").infer(`subject_class("${q(this,Be,"f")}", C), collection_getter(C, "${q(this,qe,"f")}", "${r}", Value)`);return e&&e.length>0&&e[0].Value?e[0].Value.filter(n=>n!==""&&n!==""):[]}});let adders=await q(this,he,"f").infer(`subject_class("${q(this,Be,"f")}", C), collection_adder(C, Collection, Adder)`);adders||(adders=[]);for(let adder of adders)if(adder){let collection=adder.Collection,actions=eval(adder.Adder);this[k1(collection)]=async r=>{Array.isArray(r)?await Promise.all(r.map(e=>q(this,he,"f").executeAction(actions,q(this,qe,"f"),[{name:"value",value:e}]))):await q(this,he,"f").executeAction(actions,q(this,qe,"f"),[{name:"value",value:r}])}}let removers=await q(this,he,"f").infer(`subject_class("${q(this,Be,"f")}", C), collection_remover(C, Collection, Remover)`);removers||(removers=[]);for(let remover of removers)if(remover){let collection=remover.Collection,actions=eval(remover.Remover);this[P1(collection)]=async r=>{Array.isArray(r)?await Promise.all(r.map(e=>q(this,he,"f").executeAction(actions,q(this,qe,"f"),[{name:"value",value:e}]))):await q(this,he,"f").executeAction(actions,q(this,qe,"f"),[{name:"value",value:r}])}}let collectionSetters=await q(this,he,"f").infer(`subject_class("${q(this,Be,"f")}", C), collection_setter(C, Collection, Setter)`);collectionSetters||(collectionSetters=[]);for(let collectionSetter of collectionSetters)if(collectionSetter){let collection=collectionSetter.Collection,actions=eval(collectionSetter.Setter);this[L1(collection)]=async r=>{Array.isArray(r)?await q(this,he,"f").executeAction(actions,q(this,qe,"f"),r.map(e=>({name:"value",value:e}))):await q(this,he,"f").executeAction(actions,q(this,qe,"f"),[{name:"value",value:r}])}}}};qe=new WeakMap,Be=new WeakMap,he=new WeakMap;var mn=function(r,e,t,n,i){if(n==="m")throw new TypeError("Private method is not writable");if(n==="a"&&!i)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?r!==e||!i:!e.has(r))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?i.call(r,t):i?i.value=t:e.set(r,t),t},L=function(r,e,t,n){if(t==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?r!==e||!n:!e.has(r))throw new TypeError("Cannot read private member from an object whose class did not declare it");return t==="m"?n:t==="a"?n.call(r):n?n.value:e.get(r)},pe,_e,Pr,Nr,Rr,ai,Sn=class{constructor(r,e){pe.set(this,void 0),_e.set(this,void 0),Pr.set(this,void 0),Nr.set(this,void 0),Rr.set(this,void 0),ai.set(this,void 0),mn(this,Pr,[],"f"),mn(this,Nr,[],"f"),mn(this,Rr,[],"f"),mn(this,ai,[],"f"),mn(this,pe,r,"f"),mn(this,_e,e,"f"),this.uuid=L(this,pe,"f").uuid,this.name=L(this,pe,"f").name,this.sharedUrl=L(this,pe,"f").sharedUrl,this.neighbourhood=L(this,pe,"f").neighbourhood,this.state=L(this,pe,"f").state,L(this,_e,"f").addPerspectiveLinkAddedListener(L(this,pe,"f").uuid,L(this,Pr,"f")),L(this,_e,"f").addPerspectiveLinkRemovedListener(L(this,pe,"f").uuid,L(this,Nr,"f")),L(this,_e,"f").addPerspectiveLinkUpdatedListener(L(this,pe,"f").uuid,L(this,Rr,"f")),L(this,_e,"f").addPerspectiveSyncStateChangeListener(L(this,pe,"f").uuid,L(this,ai,"f"))}async executeAction(r,e,t){let n=a=>{if(a)return a==="this"?e:a},i=a=>{if(t){let o=a;for(let s of t)o=o.replace(s.name,s.value);return o}else return a};for(let a of r){let o=n(i(a.source)),s=n(i(a.predicate)),u=n(i(a.target)),l=a?.local??!1;switch(a.action){case"addLink":await this.add(new Ot({source:o,predicate:s,target:u}),l?"local":"shared");break;case"removeLink":let p=await this.get(new We({source:o,predicate:s,target:u}));for(let h of p)await this.remove(h);break;case"setSingleTarget":await this.setSingleTarget(new Ot({source:o,predicate:s,target:u}),l?"local":"shared");break;case"collectionSetter":let f=await this.get(new We({source:o,predicate:s}));await this.removeLinks(f),await this.addLinks(t.map(h=>new Ot({source:o,predicate:s,target:h.value})),l?"local":"shared");break}}}async get(r){return await L(this,_e,"f").queryLinks(L(this,pe,"f").uuid,r)}async infer(r){return await L(this,_e,"f").queryProlog(L(this,pe,"f").uuid,r)}async add(r,e="shared"){return await L(this,_e,"f").addLink(L(this,pe,"f").uuid,r,e)}async addLinks(r,e="shared"){return await L(this,_e,"f").addLinks(L(this,pe,"f").uuid,r,e)}async removeLinks(r){return await L(this,_e,"f").removeLinks(L(this,pe,"f").uuid,r)}async linkMutations(r,e="shared"){return await L(this,_e,"f").linkMutations(L(this,pe,"f").uuid,r,e)}async addLinkExpression(r,e="shared"){return await L(this,_e,"f").addLinkExpression(L(this,pe,"f").uuid,r,e)}async update(r,e){return await L(this,_e,"f").updateLink(L(this,pe,"f").uuid,r,e)}async remove(r){return await L(this,_e,"f").removeLink(L(this,pe,"f").uuid,r)}async getExpression(r){return await L(this,_e,"f").getExpression(r)}async createExpression(r,e){return await L(this,_e,"f").createExpression(r,e)}async addListener(r,e){r==="link-added"?L(this,Pr,"f").push(e):r==="link-removed"?L(this,Nr,"f").push(e):r==="link-updated"&&L(this,Rr,"f").push(e)}async addSyncStateChangeListener(r){L(this,ai,"f").push(r)}async removeListener(r,e){if(r==="link-added"){let t=L(this,Pr,"f").indexOf(e);L(this,Pr,"f").splice(t,1)}else if(r==="link-removed"){let t=L(this,Nr,"f").indexOf(e);L(this,Nr,"f").splice(t,1)}else if(r==="link-updated"){let t=L(this,Rr,"f").indexOf(e);L(this,Rr,"f").splice(t,1)}}async snapshot(){return L(this,_e,"f").snapshotByUUID(L(this,pe,"f").uuid)}async loadSnapshot(r){let e=JSON.parse(JSON.stringify(r));delete e.__typename,e.links.forEach(t=>{delete t.data.__typename});for(let t of e.links)await this.addLinkExpression(t)}async getSingleTarget(r){delete r.target;let e=await this.get(r);return e.length?e[0].data.target:null}async setSingleTarget(r,e="shared"){let t=new We({source:r.source,predicate:r.predicate}),n=await this.get(t),i=[];for(let o of n)delete o.__typename,delete o.data.__typename,delete o.proof.__typename,i.push(o);let a=[r];await this.linkMutations({additions:a,removals:i},e)}async sdnaFlows(){return(await this.infer("register_sdna_flow(X, _)")).map(e=>e.X)}async availableFlows(r){return(await this.infer(`flowable("${r}", F), register_sdna_flow(X, F)`)).map(t=>t.X)}async startFlow(flowName,exprAddr){let startAction=await this.infer(`start_action(Action, F), register_sdna_flow("${flowName}", F)`);startAction=eval(startAction[0].Action),await this.executeAction(startAction,exprAddr,void 0)}async expressionsInFlowState(r,e){return(await this.infer(`register_sdna_flow("${r}", F), flow_state(X, ${e}, F)`)).map(n=>n.X)}async flowState(r,e){return(await this.infer(`register_sdna_flow("${r}", F), flow_state("${e}", X, F)`))[0].X}async flowActions(r,e){return(await this.infer(`register_sdna_flow("${r}", Flow), flow_state("${e}", State, Flow), action(State, Name, _, _)`)).map(n=>n.Name)}async runFlowAction(flowName,exprAddr,actionName){let action=await this.infer(`register_sdna_flow("${flowName}", Flow), flow_state("${exprAddr}", State, Flow), action(State, "${actionName}", _, Action)`);action=eval(action[0].Action),await this.executeAction(action,exprAddr,void 0)}async getSdna(){return(await this.get(new We({predicate:"ad4m://sdna"}))).map(e=>e.data.target).map(e=>Tt.fromUrl(e).get())}async addSdna(r,e,t){return L(this,_e,"f").addSdna(L(this,pe,"f").uuid,r,e,t)}async subjectClasses(){try{return(await this.infer("subject_class(X, _)")).map(r=>r.X)}catch{return[]}}async stringOrTemplateObjectToSubjectClass(r){if(typeof r=="string")return r;{let e=await this.subjectClassesByTemplate(r);return e[0]?e[0]:r.className}}async createSubject(subjectClass,exprAddr){let className=await this.stringOrTemplateObjectToSubjectClass(subjectClass),result=await this.infer(`subject_class("${className}", C), constructor(C, Actions)`);if(!result.length)throw"No constructor found for given subject class: "+className;let actions=result.map(x=>eval(x.Actions));return await this.executeAction(actions[0],exprAddr,void 0),this.getSubjectProxy(exprAddr,subjectClass)}async removeSubject(subjectClass,exprAddr){let className=await this.stringOrTemplateObjectToSubjectClass(subjectClass),result=await this.infer(`subject_class("${className}", C), destructor(C, Actions)`);if(!result.length)throw"No constructor found for given subject class: "+className;let actions=result.map(x=>eval(x.Actions));await this.executeAction(actions[0],exprAddr,void 0)}async isSubjectInstance(r,e){let t=await this.stringOrTemplateObjectToSubjectClass(e);return await this.infer(`subject_class("${t}", C), instance(C, "${r}")`)}async getSubjectProxy(r,e){if(!await this.isSubjectInstance(r,e))throw`Expression ${r} is not a subject instance of given class: ${JSON.stringify(e)}`;let t=await this.stringOrTemplateObjectToSubjectClass(e),n=new Va(this,r,t);return await n.init(),n}async getAllSubjectInstances(r){let e=[];typeof r=="string"?e=[r]:e=await this.subjectClassesByTemplate(r);let t=[];for(let n of e){let i=await this.infer(`subject_class("${n}", C), instance(C, X)`),a=await Promise.all(i.map(async o=>await this.getSubjectProxy(o.X,n)));t=t.concat(a)}return t}async getAllSubjectProxies(r){let e=[];typeof r=="string"?e=[r]:e=await this.subjectClassesByTemplate(r);let t=[];for(let n of e)t=await this.infer(`subject_class("${n}", C), instance(C, X)`);return t}async subjectClassesByTemplate(r){let e=[],t=[];Object.getPrototypeOf(r).__properties?Object.keys(Object.getPrototypeOf(r).__properties).forEach(l=>e.push(l)):e.push(...Object.keys(r).filter(l=>!Array.isArray(r[l]))),Object.getPrototypeOf(r).__collections?Object.keys(Object.getPrototypeOf(r).__collections).filter(l=>l!=="isSubjectInstance").forEach(l=>!t.includes(l)):t.push(...Object.keys(r).filter(l=>Array.isArray(r[l])).filter(l=>l!=="isSubjectInstance"));let n=Object.getOwnPropertyNames(r).filter(l=>typeof r[l]=="function"&&l.startsWith("set")&&!l.startsWith("setCollection"));n=n.concat(Object.getOwnPropertyNames(Object.getPrototypeOf(r)).filter(l=>typeof r[l]=="function"&&l.startsWith("set")&&!l.startsWith("setCollection")));let i=Object.getOwnPropertyNames(r).filter(l=>typeof r[l]=="function"&&l.startsWith("add"));i=i.concat(Object.getOwnPropertyNames(Object.getPrototypeOf(r)).filter(l=>typeof r[l]=="function"&&l.startsWith("add")));let a=Object.getOwnPropertyNames(r).filter(l=>typeof r[l]=="function"&&l.startsWith("remove"));a=a.concat(Object.getOwnPropertyNames(Object.getPrototypeOf(r)).filter(l=>typeof r[l]=="function"&&l.startsWith("remove")));let o=Object.getOwnPropertyNames(r).filter(l=>typeof r[l]=="function"&&l.startsWith("setCollection"));o=o.concat(Object.getOwnPropertyNames(Object.getPrototypeOf(r)).filter(l=>typeof r[l]=="function"&&l.startsWith("setCollection")));let s="subject_class(Class, C)";for(let l of e)s+=`, property(C, "${l}")`;for(let l of t)s+=`, collection(C, "${l}")`;for(let l of n){let p=l.substring(3);p=p.charAt(0).toLowerCase()+p.slice(1),s+=`, property_setter(C, "${p}", _)`}for(let l of i)s+=`, collection_adder(C, "${D1(l)}", _)`;for(let l of a)s+=`, collection_remover(C, "${N1(l)}", _)`;for(let l of o)s+=`, collection_setter(C, "${R1(l)}", _)`;s+=".";let u=await this.infer(s);return u?u.map(l=>l.Class):[]}async ensureSDNASubjectClass(r){if((await this.subjectClassesByTemplate(new r)).length>0)return;let{name:t,sdna:n}=r.generateSDNA();await this.addSdna(t,n,"subject_class")}getNeighbourhoodProxy(){return L(this,_e,"f").getNeighbourhoodProxy(L(this,pe,"f").uuid)}};pe=new WeakMap,_e=new WeakMap,Pr=new WeakMap,Nr=new WeakMap,Rr=new WeakMap,ai=new WeakMap;var Ar=function(r,e,t,n,i){if(n==="m")throw new TypeError("Private method is not writable");if(n==="a"&&!i)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?r!==e||!i:!e.has(r))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?i.call(r,t):i?i.value=t:e.set(r,t),t},H=function(r,e,t,n){if(t==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?r!==e||!n:!e.has(r))throw new TypeError("Cannot read private member from an object whose class did not declare it");return t==="m"?n:t==="a"?n.call(r):n?n.value:e.get(r)},se,oi,si,ci,Aa,ui,Ia,rt=`
63
+ this in the docs: http://dev.apollodata.com/core/fragments.html#unique-names`):o||Us.set(i,o=new Set),o.add(a),e.has(a)||(e.add(a),t.push(n))}else t.push(n)}),Ra(Ra({},r),{definitions:t})}function w1(r){var e=new Set(r.definitions);e.forEach(function(n){n.loc&&delete n.loc,Object.keys(n).forEach(function(i){var a=n[i];a&&typeof a=="object"&&e.add(a)})});var t=r.loc;return t&&(delete t.startToken,delete t.endToken),r}function _1(r){var e=yp(r);if(!Ta.has(e)){var t=v1(r,{experimentalFragmentVariables:La,allowLegacyFragmentVariables:La});if(!t||t.kind!=="Document")throw new Error("Not a valid GraphQL document.");Ta.set(e,w1(S1(t)))}return Ta.get(e)}function E(r){for(var e=[],t=1;t<arguments.length;t++)e[t-1]=arguments[t];typeof r=="string"&&(r=[r]);var n=r[0];return e.forEach(function(i,a){i&&i.kind==="Document"?n+=i.loc.source.body:n+=i,n+=r[a+1]}),_1(n)}function E1(){Ta.clear(),Us.clear()}function x1(){mp=!1}function O1(){La=!0}function T1(){La=!1}var ri={gql:E,resetCaches:E1,disableFragmentWarnings:x1,enableExperimentalFragmentVariables:O1,disableExperimentalFragmentVariables:T1};(function(r){r.gql=ri.gql,r.resetCaches=ri.resetCaches,r.disableFragmentWarnings=ri.disableFragmentWarnings,r.enableExperimentalFragmentVariables=ri.enableExperimentalFragmentVariables,r.disableExperimentalFragmentVariables=ri.disableExperimentalFragmentVariables})(E||(E={}));E.default=E;function A(r){if(!r)throw"Got no result from Apollo";if(r.error)throw r.error;if(r.errors)throw r.errors;return r.data}function A1(){}function Zs(){return A1}var v=Zs,Ge=Zs,J=Zs,gp=function(r,e,t,n){var i=arguments.length,a=i<3?e:n===null?n=Object.getOwnPropertyDescriptor(e,t):n,o;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")a=Reflect.decorate(r,e,t,n);else for(var s=r.length-1;s>=0;s--)(o=r[s])&&(a=(i<3?o(a):i>3?o(e,t,a):o(e,t))||a);return i>3&&a&&Object.defineProperty(e,t,a),a},vp=function(r,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(r,e)},jr=class{constructor(e){this.code=e}};gp([v(),vp("design:type",String)],jr.prototype,"code",void 0);jr=gp([J(),vp("design:paramtypes",[String])],jr);var ec=function(r,e,t,n){var i=arguments.length,a=i<3?e:n===null?n=Object.getOwnPropertyDescriptor(e,t):n,o;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")a=Reflect.decorate(r,e,t,n);else for(var s=r.length-1;s>=0;s--)(o=r[s])&&(a=(i<3?o(a):i>3?o(e,t,a):o(e,t))||a);return i>3&&a&&Object.defineProperty(e,t,a),a},tc=function(r,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(r,e)},xt=class{constructor(e,t){this.address=e,this.name=t}};ec([v(),tc("design:type",String)],xt.prototype,"address",void 0);ec([v(),tc("design:type",String)],xt.prototype,"name",void 0);xt=ec([J(),tc("design:paramtypes",[String,String])],xt);var fe=function(r,e,t,n){var i=arguments.length,a=i<3?e:n===null?n=Object.getOwnPropertyDescriptor(e,t):n,o;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")a=Reflect.decorate(r,e,t,n);else for(var s=r.length-1;s>=0;s--)(o=r[s])&&(a=(i<3?o(a):i>3?o(e,t,a):o(e,t))||a);return i>3&&a&&Object.defineProperty(e,t,a),a},Te=function(r,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(r,e)},ir=class{constructor(e,t){this.key=t,this.signature=e}};fe([v(),Te("design:type",String)],ir.prototype,"signature",void 0);fe([v(),Te("design:type",String)],ir.prototype,"key",void 0);fe([v(),Te("design:type",Boolean)],ir.prototype,"valid",void 0);fe([v(),Te("design:type",Boolean)],ir.prototype,"invalid",void 0);ir=fe([J(),Ge(),Te("design:paramtypes",[String,String])],ir);var Ur=class{};fe([v(),Te("design:type",String)],Ur.prototype,"signature",void 0);fe([v(),Te("design:type",String)],Ur.prototype,"key",void 0);fe([v(),Te("design:type",Boolean)],Ur.prototype,"valid",void 0);fe([v(),Te("design:type",Boolean)],Ur.prototype,"invalid",void 0);Ur=fe([Ge()],Ur);function lr(r){let e=class{constructor(n,i,a,o){this.author=n,this.timestamp=i,this.data=a,this.proof=o}};return fe([v(),Te("design:type",String)],e.prototype,"author",void 0),fe([v(),Te("design:type",String)],e.prototype,"timestamp",void 0),fe([v(),Te("design:type",Object)],e.prototype,"data",void 0),fe([v(),Te("design:type",ir)],e.prototype,"proof",void 0),e=fe([J(),Te("design:paramtypes",[String,String,Object,ir])],e),e}function I1(r){let e=class{};return fe([v(),Te("design:type",String)],e.prototype,"author",void 0),fe([v(),Te("design:type",String)],e.prototype,"timestamp",void 0),fe([v(),Te("design:type",Object)],e.prototype,"data",void 0),fe([v(),Te("design:type",Ur)],e.prototype,"proof",void 0),e=fe([Ge()],e),e}var Ql=class extends lr(){};Ql=fe([J()],Ql);var Fa=class extends lr(){};fe([v(),Te("design:type",xt)],Fa.prototype,"language",void 0);fe([v(),Te("design:type",jr)],Fa.prototype,"icon",void 0);Fa=fe([J()],Fa);function _6(r){return r&&r.author&&r.timestamp&&r.data}var Ee=function(r,e,t,n){var i=arguments.length,a=i<3?e:n===null?n=Object.getOwnPropertyDescriptor(e,t):n,o;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")a=Reflect.decorate(r,e,t,n);else for(var s=r.length-1;s>=0;s--)(o=r[s])&&(a=(i<3?o(a):i>3?o(e,t,a):o(e,t))||a);return i>3&&a&&Object.defineProperty(e,t,a),a},$e=function(r,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(r,e)},Ot=class{constructor(e){this.source=e.source?e.source:"",this.target=e.target?e.target:"",this.predicate=e.predicate?e.predicate:""}};Ee([v(),$e("design:type",String)],Ot.prototype,"source",void 0);Ee([v(),$e("design:type",String)],Ot.prototype,"target",void 0);Ee([v(),$e("design:type",String)],Ot.prototype,"predicate",void 0);Ot=Ee([J(),$e("design:paramtypes",[Object])],Ot);var $a=class{};Ee([v(),$e("design:type",Array)],$a.prototype,"additions",void 0);Ee([v(),$e("design:type",Array)],$a.prototype,"removals",void 0);$a=Ee([Ge()],$a);var Ma=class{constructor(e,t){this.additions=e,this.removals=t}};Ee([v(),$e("design:type",Array)],Ma.prototype,"additions",void 0);Ee([v(),$e("design:type",Array)],Ma.prototype,"removals",void 0);Ma=Ee([J(),$e("design:paramtypes",[Array,Array])],Ma);var Ci=class{};Ee([v(),$e("design:type",String)],Ci.prototype,"source",void 0);Ee([v(),$e("design:type",String)],Ci.prototype,"target",void 0);Ee([v(),$e("design:type",String)],Ci.prototype,"predicate",void 0);Ci=Ee([Ge()],Ci);var qr=class extends lr(){hash(){let e=JSON.stringify(this.data,Object.keys(this.data).sort())+JSON.stringify(this.author)+this.timestamp,t=0,n,i;for(n=0;n<e.length;n++)i=e.charCodeAt(n),t=(t<<5)-t+i,t|=0;return t}};Ee([v(),$e("design:type",String)],qr.prototype,"status",void 0);qr=Ee([J()],qr);var qs=class extends I1(){};Ee([v(),$e("design:type",String)],qs.prototype,"status",void 0);qs=Ee([Ge()],qs);function k6(r,e){return r.author==e.author&&r.timestamp==e.timestamp&&r.data.source==e.data.source&&r.data.predicate==e.data.predicate&&r.data.target==e.data.target}function D6(r){return r&&r.source&&r.target}var ja=class{constructor(e,t){this.oldLink=e,this.newLink=t}};Ee([v(),$e("design:type",qr)],ja.prototype,"oldLink",void 0);Ee([v(),$e("design:type",qr)],ja.prototype,"newLink",void 0);ja=Ee([J(),$e("design:paramtypes",[qr,qr])],ja);var Vr=function(r,e,t,n){var i=arguments.length,a=i<3?e:n===null?n=Object.getOwnPropertyDescriptor(e,t):n,o;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")a=Reflect.decorate(r,e,t,n);else for(var s=r.length-1;s>=0;s--)(o=r[s])&&(a=(i<3?o(a):i>3?o(e,t,a):o(e,t))||a);return i>3&&a&&Object.defineProperty(e,t,a),a},Ei=function(r,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(r,e)},Bs,ar=class{constructor(e){e?this.links=e:this.links=[]}get(e){if(!e||!e.source&&!e.predicate&&!e.target)return this.links;if(e.source){let n=JSON.parse(JSON.stringify(this.links));return e.target&&(n=n.filter(i=>i.data.target===e.target)),e.predicate&&(n=n.filter(i=>i.data.predicate===e.predicate)),e.fromDate&&(n=n.filter(i=>new Date(i.timestamp)>=e.fromDate)),e.untilDate&&(n=n.filter(i=>new Date(i.timestamp)<=e.untilDate)),e.limit&&(n=n.slice(0,e.limit)),n}if(e.target){let n=JSON.parse(JSON.stringify(this.links));return e.predicate&&(n=n.filter(i=>i.data.predicate===e.predicate)),e.fromDate&&(n=n.filter(i=>new Date(i.timestamp)>=e.fromDate)),e.untilDate&&(n=n.filter(i=>new Date(i.timestamp)<=e.untilDate)),e.limit&&(n=n.slice(0,e.limit)),n}let t=JSON.parse(JSON.stringify(this.links));return t=t.filter(n=>n.data.predicate===e.predicate),e.limit&&(t=t.slice(0,e.limit)),t}getSingleTarget(e){delete e.target;let t=this.get(e);return t.length?t[0].data.target:null}};Vr([v(),Ei("design:type",Array)],ar.prototype,"links",void 0);ar=Vr([J(),Ei("design:paramtypes",[Array])],ar);var Vs=class{};Vr([v(),Ei("design:type",Array)],Vs.prototype,"links",void 0);Vs=Vr([Ge()],Vs);var Qs=Bs=class{constructor(e){e?this.links=e:this.links=[]}static fromLink(e){let t=new Bs;return t.links.push(e),t}};Vr([v(),Ei("design:type",Array)],Qs.prototype,"links",void 0);Qs=Bs=Vr([Ge(),Ei("design:paramtypes",[Array])],Qs);var Ws=class extends lr(){};Ws=Vr([J()],Ws);var F=function(r,e,t,n){var i=arguments.length,a=i<3?e:n===null?n=Object.getOwnPropertyDescriptor(e,t):n,o;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")a=Reflect.decorate(r,e,t,n);else for(var s=r.length-1;s>=0;s--)(o=r[s])&&(a=(i<3?o(a):i>3?o(e,t,a):o(e,t))||a);return i>3&&a&&Object.defineProperty(e,t,a),a},$=function(r,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(r,e)},rr=class{constructor(e,t){this.did=e,t?this.perspective=t:this.perspective=new ar}};F([v(),$("design:type",String)],rr.prototype,"did",void 0);F([v(),$("design:type",ar)],rr.prototype,"perspective",void 0);F([v(),$("design:type",String)],rr.prototype,"directMessageLanguage",void 0);rr=F([J(),$("design:paramtypes",[String,ar])],rr);var Wl=class extends lr(){};Wl=F([J()],Wl);var or=class{constructor(e,t,n,i,a,o){this.did=e,this.didSigningKeyId=t,this.deviceKeyType=n,this.deviceKey=i,this.deviceKeySignedByDid=a,this.didSignedByDeviceKey=o}};F([v(),$("design:type",String)],or.prototype,"did",void 0);F([v(),$("design:type",String)],or.prototype,"didSigningKeyId",void 0);F([v(),$("design:type",String)],or.prototype,"deviceKeyType",void 0);F([v(),$("design:type",String)],or.prototype,"deviceKey",void 0);F([v(),$("design:type",String)],or.prototype,"deviceKeySignedByDid",void 0);F([v(),$("design:type",String)],or.prototype,"didSignedByDeviceKey",void 0);or=F([J(),$("design:paramtypes",[String,String,String,String,String,String])],or);var sr=class{constructor(e,t,n,i,a,o){this.did=e,this.didSigningKeyId=t,this.deviceKeyType=n,this.deviceKey=i,this.deviceKeySignedByDid=a,this.didSignedByDeviceKey=o}};F([v(),$("design:type",String)],sr.prototype,"did",void 0);F([v(),$("design:type",String)],sr.prototype,"didSigningKeyId",void 0);F([v(),$("design:type",String)],sr.prototype,"deviceKeyType",void 0);F([v(),$("design:type",String)],sr.prototype,"deviceKey",void 0);F([v(),$("design:type",String)],sr.prototype,"deviceKeySignedByDid",void 0);F([v(),$("design:type",String)],sr.prototype,"didSignedByDeviceKey",void 0);sr=F([Ge(),$("design:paramtypes",[String,String,String,String,String,String])],sr);var Ua=class{constructor(e,t){this.signature=e,this.publicKey=t}};F([v(),$("design:type",String)],Ua.prototype,"signature",void 0);F([v(),$("design:type",String)],Ua.prototype,"publicKey",void 0);Ua=F([J(),$("design:paramtypes",[String,String])],Ua);var wn=class{constructor(e,t){this.domain=e,this.pointers=t}};F([v(),$("design:type",String)],wn.prototype,"domain",void 0);F([v(),$("design:type",Array)],wn.prototype,"pointers",void 0);wn=F([J(),$("design:paramtypes",[String,Array])],wn);var qa=class{constructor(e,t){this.with=e,this.can=t}};F([v(),$("design:type",wn)],qa.prototype,"with",void 0);F([v(),$("design:type",Array)],qa.prototype,"can",void 0);qa=F([J(),$("design:paramtypes",[wn,Array])],qa);var jt=class{constructor(e,t,n,i,a){this.appName=e,this.appDesc=t,this.appIconPath=a,this.appUrl=n,this.capabilities=i}};F([v(),$("design:type",String)],jt.prototype,"appName",void 0);F([v(),$("design:type",String)],jt.prototype,"appDesc",void 0);F([v(),$("design:type",String)],jt.prototype,"appUrl",void 0);F([v(),$("design:type",String)],jt.prototype,"appIconPath",void 0);F([v(),$("design:type",Array)],jt.prototype,"capabilities",void 0);jt=F([J(),$("design:paramtypes",[String,String,String,Array,String])],jt);var _n=class{constructor(e,t,n,i){this.requestId=e,this.auth=t,this.token=n,this.revoked=i}};F([v(),$("design:type",String)],_n.prototype,"requestId",void 0);F([v(),$("design:type",String)],_n.prototype,"token",void 0);F([v(),$("design:type",Boolean)],_n.prototype,"revoked",void 0);F([v(),$("design:type",jt)],_n.prototype,"auth",void 0);_n=F([J(),$("design:paramtypes",[String,jt,String,Boolean])],_n);var En=class{constructor(e,t){this.domain=e,this.pointers=t}};F([v(),$("design:type",String)],En.prototype,"domain",void 0);F([v(),$("design:type",Array)],En.prototype,"pointers",void 0);En=F([Ge(),$("design:paramtypes",[String,Array])],En);var Ba=class{constructor(e,t){this.with=e,this.can=t}};F([v(),$("design:type",En)],Ba.prototype,"with",void 0);F([v(),$("design:type",Array)],Ba.prototype,"can",void 0);Ba=F([Ge(),$("design:paramtypes",[En,Array])],Ba);var cr=class{constructor(e,t,n,i,a,o){this.appName=e,this.appDesc=t,this.appUrl=i,this.appDomain=n,this.capabilities=o,this.appIconPath=a}};F([v(),$("design:type",String)],cr.prototype,"appName",void 0);F([v(),$("design:type",String)],cr.prototype,"appDesc",void 0);F([v(),$("design:type",String)],cr.prototype,"appDomain",void 0);F([v(),$("design:type",String)],cr.prototype,"appUrl",void 0);F([v(),$("design:type",String)],cr.prototype,"appIconPath",void 0);F([v(),$("design:type",Array)],cr.prototype,"capabilities",void 0);cr=F([Ge(),$("design:paramtypes",[String,String,String,String,String,Array])],cr);var On=function(r,e,t,n){var i=arguments.length,a=i<3?e:n===null?n=Object.getOwnPropertyDescriptor(e,t):n,o;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")a=Reflect.decorate(r,e,t,n);else for(var s=r.length-1;s>=0;s--)(o=r[s])&&(a=(i<3?o(a):i>3?o(e,t,a):o(e,t))||a);return i>3&&a&&Object.defineProperty(e,t,a),a},Tn=function(r,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(r,e)},ct=class{constructor(e){e?(this.isInitialized=e.isInitialized,this.isInitialized||(this.isInitialized=!1),this.isUnlocked=e.isUnlocked,this.isUnlocked||(this.isUnlocked=!1),this.did=e.did,this.didDocument=e.didDocument,this.error=e.error):(this.isInitialized=!1,this.isUnlocked=!1)}};On([v(),Tn("design:type",Boolean)],ct.prototype,"isInitialized",void 0);On([v(),Tn("design:type",Boolean)],ct.prototype,"isUnlocked",void 0);On([v(),Tn("design:type",String)],ct.prototype,"did",void 0);On([v(),Tn("design:type",String)],ct.prototype,"didDocument",void 0);On([v(),Tn("design:type",String)],ct.prototype,"error",void 0);ct=On([J(),Tn("design:paramtypes",[Object])],ct);var Gl=function(r,e,t,n,i){if(n==="m")throw new TypeError("Private method is not writable");if(n==="a"&&!i)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?r!==e||!i:!e.has(r))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?i.call(r,t):i?i.value=t:e.set(r,t),t},Ce=function(r,e,t,n){if(t==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?r!==e||!n:!e.has(r))throw new TypeError("Cannot read private member from an object whose class did not declare it");return t==="m"?n:t==="a"?n.call(r):n?n.value:e.get(r)},Ye,Xe,Gs=class{constructor(e,t){Ye.set(this,void 0),Xe.set(this,void 0),Gl(this,Ye,e,"f"),Gl(this,Xe,t,"f")}async otherAgents(){return await Ce(this,Ye,"f").otherAgents(Ce(this,Xe,"f"))}async hasTelepresenceAdapter(){return await Ce(this,Ye,"f").hasTelepresenceAdapter(Ce(this,Xe,"f"))}async onlineAgents(){return await Ce(this,Ye,"f").onlineAgents(Ce(this,Xe,"f"))}async setOnlineStatus(e){return await Ce(this,Ye,"f").setOnlineStatus(Ce(this,Xe,"f"),e)}async setOnlineStatusU(e){return await Ce(this,Ye,"f").setOnlineStatusU(Ce(this,Xe,"f"),e)}async sendSignal(e,t){return await Ce(this,Ye,"f").sendSignal(Ce(this,Xe,"f"),e,t)}async sendSignalU(e,t){return await Ce(this,Ye,"f").sendSignalU(Ce(this,Xe,"f"),e,t)}async sendBroadcast(e){return await Ce(this,Ye,"f").sendBroadcast(Ce(this,Xe,"f"),e)}async sendBroadcastU(e){return await Ce(this,Ye,"f").sendBroadcastU(Ce(this,Xe,"f"),e)}async addSignalHandler(e){await Ce(this,Ye,"f").addSignalHandler(Ce(this,Xe,"f"),e)}removeSignalHandler(e){Ce(this,Ye,"f").removeSignalHandler(Ce(this,Xe,"f"),e)}};Ye=new WeakMap,Xe=new WeakMap;var Qr=function(r,e,t,n){var i=arguments.length,a=i<3?e:n===null?n=Object.getOwnPropertyDescriptor(e,t):n,o;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")a=Reflect.decorate(r,e,t,n);else for(var s=r.length-1;s>=0;s--)(o=r[s])&&(a=(i<3?o(a):i>3?o(e,t,a):o(e,t))||a);return i>3&&a&&Object.defineProperty(e,t,a),a},Wr=function(r,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(r,e)},We=class{constructor(e){e&&(this.source=e.source,this.predicate=e.predicate,this.target=e.target,e.fromDate&&(this.fromDate=e.fromDate),e.untilDate&&(this.untilDate=e.untilDate),e.limit&&(this.limit=e.limit))}isMatch(e){return!(this.source&&this.source!==e.source||this.predicate&&this.predicate!==e.predicate||this.target&&this.target!==e.target)}};Qr([v(),Wr("design:type",String)],We.prototype,"source",void 0);Qr([v(),Wr("design:type",String)],We.prototype,"target",void 0);Qr([v(),Wr("design:type",String)],We.prototype,"predicate",void 0);Qr([v(),Wr("design:type",Date)],We.prototype,"fromDate",void 0);Qr([v(),Wr("design:type",Date)],We.prototype,"untilDate",void 0);Qr([v(),Wr("design:type",Number)],We.prototype,"limit",void 0);We=Qr([J(),Ge(),Wr("design:paramtypes",[Object])],We);var Kl=function(r,e,t,n,i){if(n==="m")throw new TypeError("Private method is not writable");if(n==="a"&&!i)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?r!==e||!i:!e.has(r))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?i.call(r,t):i?i.value=t:e.set(r,t),t},Je=function(r,e,t,n){if(t==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?r!==e||!n:!e.has(r))throw new TypeError("Cannot read private member from an object whose class did not declare it");return t==="m"?n:t==="a"?n.call(r):n?n.value:e.get(r)},mt,Lt;function Rs(r){return encodeURIComponent(r).replace(/[!'()*]/g,e=>`%${e.charCodeAt(0).toString(16).toUpperCase()}`)}var Tt=class{constructor(){mt.set(this,void 0),Lt.set(this,void 0)}static fromUrl(e){if(!e||!e.startsWith("literal://"))throw new Error("Can't create Literal from non-literal URL");let t=new Tt;return Kl(t,Lt,e,"f"),t}static from(e){let t=new Tt;return Kl(t,mt,e,"f"),t}toUrl(){if(Je(this,Lt,"f")&&!Je(this,mt,"f"))return Je(this,Lt,"f");if(!Je(this,Lt,"f")&&!Je(this,mt,"f"))throw new Error("Can't turn empty Literal into URL");let e;switch(typeof Je(this,mt,"f")){case"string":e=`string:${Rs(Je(this,mt,"f"))}`;break;case"number":e=`number:${Rs(Je(this,mt,"f"))}`;break;case"object":e=`json:${Rs(JSON.stringify(Je(this,mt,"f")))}`;break}return`literal://${e}`}get(){if(Je(this,mt,"f"))return Je(this,mt,"f");if(!Je(this,Lt,"f"))throw new Error("Can't render empty Literal");if(!Je(this,Lt,"f").startsWith("literal://"))throw new Error("Can't render Literal from non-literal URL");let e=Je(this,Lt,"f").substring(10);if(e.startsWith("string:"))return decodeURIComponent(e.substring(7));if(e.startsWith("number:")){let t=e.substring(7);return parseFloat(t)}if(e.startsWith("json:")){let t=e.substring(5);return JSON.parse(decodeURIComponent(t))}throw new Error(`Can't parse unknown literal: ${e}`)}};mt=new WeakMap,Lt=new WeakMap;function nr(r){return r.charAt(0).toUpperCase()+r.slice(1)}function bp(r){return`set${nr(r)}`}function Mt(r){return r.endsWith("y")?r.slice(0,-1)+"ies":r+"s"}function rc(r){return r.endsWith("ies")?r.slice(0,-3)+"y":r.endsWith("s")?r.slice(0,-1):r}function k1(r){return`add${nr(rc(r))}`}function D1(r){let e=r.substring(3),t=Mt(e);return t.charAt(0).toLowerCase()+t.slice(1)}function P1(r){return`remove${nr(rc(r))}`}function N1(r){let e=r.substring(6),t=Mt(e);return t.charAt(0).toLowerCase()+t.slice(1)}function R1(r){let e=r.substring(13),t=Mt(e);return t.charAt(0).toLowerCase()+t.slice(1)}function L1(r){return`setCollection${nr(rc(r))}`}function Dr(r){if(Array.isArray(r))return`[${r.map(Dr).join(", ")}]`;let e=Object.keys(r),t=[];for(let n of e){let i=JSON.stringify(r[n]),a=`${n}: ${i}`;t.push(a)}return`{${t.join(", ")}}`}var Ls=function(r,e,t,n,i){if(n==="m")throw new TypeError("Private method is not writable");if(n==="a"&&!i)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?r!==e||!i:!e.has(r))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?i.call(r,t):i?i.value=t:e.set(r,t),t},q=function(r,e,t,n){if(t==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?r!==e||!n:!e.has(r))throw new TypeError("Cannot read private member from an object whose class did not declare it");return t==="m"?n:t==="a"?n.call(r):n?n.value:e.get(r)},qe,Be,he,Va=class{constructor(r,e,t){qe.set(this,void 0),Be.set(this,void 0),he.set(this,void 0),Ls(this,qe,e,"f"),Ls(this,Be,t,"f"),Ls(this,he,r,"f")}get baseExpression(){return q(this,qe,"f")}async init(){let isInstance=await q(this,he,"f").isSubjectInstance(q(this,qe,"f"),q(this,Be,"f"));if(!isInstance)throw`Not a valid subject instance of ${q(this,Be,"f")} for ${q(this,qe,"f")}`;let results=await q(this,he,"f").infer(`subject_class("${q(this,Be,"f")}", C), property(C, Property)`),properties=results.map(r=>r.Property);for(let r of properties){let e=await q(this,he,"f").infer(`subject_class("${q(this,Be,"f")}", C), property_resolve(C, "${r}")`);Object.defineProperty(this,r,{configurable:!0,get:async()=>{let t=await q(this,he,"f").infer(`subject_class("${q(this,Be,"f")}", C), property_getter(C, "${q(this,qe,"f")}", "${r}", Value)`);if(t&&t.length>0){let n=t[0].Value;if(e)try{if(n){let i=await q(this,he,"f").getExpression(n);try{return JSON.parse(i.data)}catch{return i.data}}else return n}catch{return n}else return n}else return t||void 0}})}let setters=await q(this,he,"f").infer(`subject_class("${q(this,Be,"f")}", C), property_setter(C, Property, Setter)`);for(let setter of setters||[])if(setter){let property=setter.Property,actions=eval(setter.Setter),resolveLanguageResults=await q(this,he,"f").infer(`subject_class("${q(this,Be,"f")}", C), property_resolve_language(C, "${property}", Language)`),resolveLanguage;resolveLanguageResults&&resolveLanguageResults.length>0&&(resolveLanguage=resolveLanguageResults[0].Language),this[bp(property)]=async r=>{resolveLanguage&&(r=await q(this,he,"f").createExpression(r,resolveLanguage)),await q(this,he,"f").executeAction(actions,q(this,qe,"f"),[{name:"value",value:r}])}}let results2=await q(this,he,"f").infer(`subject_class("${q(this,Be,"f")}", C), collection(C, Collection)`);results2||(results2=[]);let collections=results2.map(r=>r.Collection);for(let r of collections)Object.defineProperty(this,r,{configurable:!0,get:async()=>{let e=await q(this,he,"f").infer(`subject_class("${q(this,Be,"f")}", C), collection_getter(C, "${q(this,qe,"f")}", "${r}", Value)`);return e&&e.length>0&&e[0].Value?e[0].Value.filter(n=>n!==""&&n!==""):[]}});let adders=await q(this,he,"f").infer(`subject_class("${q(this,Be,"f")}", C), collection_adder(C, Collection, Adder)`);adders||(adders=[]);for(let adder of adders)if(adder){let collection=adder.Collection,actions=eval(adder.Adder);this[k1(collection)]=async r=>{Array.isArray(r)?await Promise.all(r.map(e=>q(this,he,"f").executeAction(actions,q(this,qe,"f"),[{name:"value",value:e}]))):await q(this,he,"f").executeAction(actions,q(this,qe,"f"),[{name:"value",value:r}])}}let removers=await q(this,he,"f").infer(`subject_class("${q(this,Be,"f")}", C), collection_remover(C, Collection, Remover)`);removers||(removers=[]);for(let remover of removers)if(remover){let collection=remover.Collection,actions=eval(remover.Remover);this[P1(collection)]=async r=>{Array.isArray(r)?await Promise.all(r.map(e=>q(this,he,"f").executeAction(actions,q(this,qe,"f"),[{name:"value",value:e}]))):await q(this,he,"f").executeAction(actions,q(this,qe,"f"),[{name:"value",value:r}])}}let collectionSetters=await q(this,he,"f").infer(`subject_class("${q(this,Be,"f")}", C), collection_setter(C, Collection, Setter)`);collectionSetters||(collectionSetters=[]);for(let collectionSetter of collectionSetters)if(collectionSetter){let collection=collectionSetter.Collection,actions=eval(collectionSetter.Setter);this[L1(collection)]=async r=>{Array.isArray(r)?await q(this,he,"f").executeAction(actions,q(this,qe,"f"),r.map(e=>({name:"value",value:e}))):await q(this,he,"f").executeAction(actions,q(this,qe,"f"),[{name:"value",value:r}])}}}};qe=new WeakMap,Be=new WeakMap,he=new WeakMap;var mn=function(r,e,t,n,i){if(n==="m")throw new TypeError("Private method is not writable");if(n==="a"&&!i)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?r!==e||!i:!e.has(r))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?i.call(r,t):i?i.value=t:e.set(r,t),t},L=function(r,e,t,n){if(t==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?r!==e||!n:!e.has(r))throw new TypeError("Cannot read private member from an object whose class did not declare it");return t==="m"?n:t==="a"?n.call(r):n?n.value:e.get(r)},pe,_e,Pr,Nr,Rr,ai,Sn=class{constructor(r,e){pe.set(this,void 0),_e.set(this,void 0),Pr.set(this,void 0),Nr.set(this,void 0),Rr.set(this,void 0),ai.set(this,void 0),mn(this,Pr,[],"f"),mn(this,Nr,[],"f"),mn(this,Rr,[],"f"),mn(this,ai,[],"f"),mn(this,pe,r,"f"),mn(this,_e,e,"f"),this.uuid=L(this,pe,"f").uuid,this.name=L(this,pe,"f").name,this.sharedUrl=L(this,pe,"f").sharedUrl,this.neighbourhood=L(this,pe,"f").neighbourhood,this.state=L(this,pe,"f").state,L(this,_e,"f").addPerspectiveLinkAddedListener(L(this,pe,"f").uuid,L(this,Pr,"f")),L(this,_e,"f").addPerspectiveLinkRemovedListener(L(this,pe,"f").uuid,L(this,Nr,"f")),L(this,_e,"f").addPerspectiveLinkUpdatedListener(L(this,pe,"f").uuid,L(this,Rr,"f")),L(this,_e,"f").addPerspectiveSyncStateChangeListener(L(this,pe,"f").uuid,L(this,ai,"f"))}async executeAction(r,e,t){let n=a=>{if(a)return a==="this"?e:a},i=a=>{if(t){let o=a;for(let s of t)o=o.replace(s.name,s.value);return o}else return a};for(let a of r){let o=n(i(a.source)),s=n(i(a.predicate)),u=n(i(a.target)),l=a?.local??!1;switch(a.action){case"addLink":await this.add(new Ot({source:o,predicate:s,target:u}),l?"local":"shared");break;case"removeLink":let p=await this.get(new We({source:o,predicate:s,target:u}));for(let h of p)await this.remove(h);break;case"setSingleTarget":await this.setSingleTarget(new Ot({source:o,predicate:s,target:u}),l?"local":"shared");break;case"collectionSetter":let f=await this.get(new We({source:o,predicate:s}));await this.removeLinks(f),await this.addLinks(t.map(h=>new Ot({source:o,predicate:s,target:h.value})),l?"local":"shared");break}}}async get(r){return await L(this,_e,"f").queryLinks(L(this,pe,"f").uuid,r)}async infer(r){return await L(this,_e,"f").queryProlog(L(this,pe,"f").uuid,r)}async add(r,e="shared"){return await L(this,_e,"f").addLink(L(this,pe,"f").uuid,r,e)}async addLinks(r,e="shared"){return await L(this,_e,"f").addLinks(L(this,pe,"f").uuid,r,e)}async removeLinks(r){return await L(this,_e,"f").removeLinks(L(this,pe,"f").uuid,r)}async linkMutations(r,e="shared"){return await L(this,_e,"f").linkMutations(L(this,pe,"f").uuid,r,e)}async addLinkExpression(r,e="shared"){return await L(this,_e,"f").addLinkExpression(L(this,pe,"f").uuid,r,e)}async update(r,e){return await L(this,_e,"f").updateLink(L(this,pe,"f").uuid,r,e)}async remove(r){return await L(this,_e,"f").removeLink(L(this,pe,"f").uuid,r)}async getExpression(r){return await L(this,_e,"f").getExpression(r)}async createExpression(r,e){return await L(this,_e,"f").createExpression(r,e)}async addListener(r,e){r==="link-added"?L(this,Pr,"f").push(e):r==="link-removed"?L(this,Nr,"f").push(e):r==="link-updated"&&L(this,Rr,"f").push(e)}async addSyncStateChangeListener(r){L(this,ai,"f").push(r)}async removeListener(r,e){if(r==="link-added"){let t=L(this,Pr,"f").indexOf(e);L(this,Pr,"f").splice(t,1)}else if(r==="link-removed"){let t=L(this,Nr,"f").indexOf(e);L(this,Nr,"f").splice(t,1)}else if(r==="link-updated"){let t=L(this,Rr,"f").indexOf(e);L(this,Rr,"f").splice(t,1)}}async snapshot(){return L(this,_e,"f").snapshotByUUID(L(this,pe,"f").uuid)}async loadSnapshot(r){let e=JSON.parse(JSON.stringify(r));delete e.__typename,e.links.forEach(t=>{delete t.data.__typename});for(let t of e.links)await this.addLinkExpression(t)}async getSingleTarget(r){delete r.target;let e=await this.get(r);return e.length?e[0].data.target:null}async setSingleTarget(r,e="shared"){let t=new We({source:r.source,predicate:r.predicate}),n=await this.get(t),i=[];for(let o of n)delete o.__typename,delete o.data.__typename,delete o.proof.__typename,i.push(o);let a=[r];await this.linkMutations({additions:a,removals:i},e)}async sdnaFlows(){return(await this.infer("register_sdna_flow(X, _)")).map(e=>e.X)}async availableFlows(r){return(await this.infer(`flowable("${r}", F), register_sdna_flow(X, F)`)).map(t=>t.X)}async startFlow(flowName,exprAddr){let startAction=await this.infer(`start_action(Action, F), register_sdna_flow("${flowName}", F)`);startAction=eval(startAction[0].Action),await this.executeAction(startAction,exprAddr,void 0)}async expressionsInFlowState(r,e){return(await this.infer(`register_sdna_flow("${r}", F), flow_state(X, ${e}, F)`)).map(n=>n.X)}async flowState(r,e){return(await this.infer(`register_sdna_flow("${r}", F), flow_state("${e}", X, F)`))[0].X}async flowActions(r,e){return(await this.infer(`register_sdna_flow("${r}", Flow), flow_state("${e}", State, Flow), action(State, Name, _, _)`)).map(n=>n.Name)}async runFlowAction(flowName,exprAddr,actionName){let action=await this.infer(`register_sdna_flow("${flowName}", Flow), flow_state("${exprAddr}", State, Flow), action(State, "${actionName}", _, Action)`);action=eval(action[0].Action),await this.executeAction(action,exprAddr,void 0)}async getSdna(){return(await this.get(new We({predicate:"ad4m://sdna"}))).map(e=>e.data.target).map(e=>Tt.fromUrl(e).get())}async addSdna(r,e,t){return L(this,_e,"f").addSdna(L(this,pe,"f").uuid,r,e,t)}async subjectClasses(){try{return(await this.infer("subject_class(X, _)")).map(r=>r.X)}catch{return[]}}async stringOrTemplateObjectToSubjectClass(r){if(typeof r=="string")return r;{let e=await this.subjectClassesByTemplate(r);return e[0]?e[0]:r.className}}async createSubject(subjectClass,exprAddr){let className=await this.stringOrTemplateObjectToSubjectClass(subjectClass),result=await this.infer(`subject_class("${className}", C), constructor(C, Actions)`);if(!result.length)throw"No constructor found for given subject class: "+className;let actions=result.map(x=>eval(x.Actions));return await this.executeAction(actions[0],exprAddr,void 0),this.getSubjectProxy(exprAddr,subjectClass)}async removeSubject(subjectClass,exprAddr){let className=await this.stringOrTemplateObjectToSubjectClass(subjectClass),result=await this.infer(`subject_class("${className}", C), destructor(C, Actions)`);if(!result.length)throw"No constructor found for given subject class: "+className;let actions=result.map(x=>eval(x.Actions));await this.executeAction(actions[0],exprAddr,void 0)}async isSubjectInstance(r,e){let t=await this.stringOrTemplateObjectToSubjectClass(e);return await this.infer(`subject_class("${t}", C), instance(C, "${r}")`)}async getSubjectProxy(r,e){if(!await this.isSubjectInstance(r,e))throw`Expression ${r} is not a subject instance of given class: ${JSON.stringify(e)}`;let t=await this.stringOrTemplateObjectToSubjectClass(e),n=new Va(this,r,t);return await n.init(),n}async getAllSubjectInstances(r){let e=[];typeof r=="string"?e=[r]:e=await this.subjectClassesByTemplate(r);let t=[];for(let n of e){let i=await this.infer(`subject_class("${n}", C), instance(C, X)`),a=await Promise.all(i.map(async o=>await this.getSubjectProxy(o.X,n)));t=t.concat(a)}return t}async getAllSubjectProxies(r){let e=[];typeof r=="string"?e=[r]:e=await this.subjectClassesByTemplate(r);let t=[];for(let n of e)t=await this.infer(`subject_class("${n}", C), instance(C, X)`);return t}async subjectClassesByTemplate(r){let e=[],t=[];Object.getPrototypeOf(r).__properties?Object.keys(Object.getPrototypeOf(r).__properties).forEach(l=>e.push(l)):e.push(...Object.keys(r).filter(l=>!Array.isArray(r[l]))),Object.getPrototypeOf(r).__collections?Object.keys(Object.getPrototypeOf(r).__collections).filter(l=>l!=="isSubjectInstance").forEach(l=>!t.includes(l)):t.push(...Object.keys(r).filter(l=>Array.isArray(r[l])).filter(l=>l!=="isSubjectInstance"));let n=Object.getOwnPropertyNames(r).filter(l=>typeof r[l]=="function"&&l.startsWith("set")&&!l.startsWith("setCollection"));n=n.concat(Object.getOwnPropertyNames(Object.getPrototypeOf(r)).filter(l=>typeof r[l]=="function"&&l.startsWith("set")&&!l.startsWith("setCollection")));let i=Object.getOwnPropertyNames(r).filter(l=>typeof r[l]=="function"&&l.startsWith("add"));i=i.concat(Object.getOwnPropertyNames(Object.getPrototypeOf(r)).filter(l=>typeof r[l]=="function"&&l.startsWith("add")));let a=Object.getOwnPropertyNames(r).filter(l=>typeof r[l]=="function"&&l.startsWith("remove"));a=a.concat(Object.getOwnPropertyNames(Object.getPrototypeOf(r)).filter(l=>typeof r[l]=="function"&&l.startsWith("remove")));let o=Object.getOwnPropertyNames(r).filter(l=>typeof r[l]=="function"&&l.startsWith("setCollection"));o=o.concat(Object.getOwnPropertyNames(Object.getPrototypeOf(r)).filter(l=>typeof r[l]=="function"&&l.startsWith("setCollection")));let s="subject_class(Class, C)";for(let l of e)s+=`, property(C, "${l}")`;for(let l of t)s+=`, collection(C, "${l}")`;for(let l of n){let p=l.substring(3);p=p.charAt(0).toLowerCase()+p.slice(1),s+=`, property_setter(C, "${p}", _)`}for(let l of i)s+=`, collection_adder(C, "${D1(l)}", _)`;for(let l of a)s+=`, collection_remover(C, "${N1(l)}", _)`;for(let l of o)s+=`, collection_setter(C, "${R1(l)}", _)`;s+=".";let u=await this.infer(s);return u?u.map(l=>l.Class):[]}async ensureSDNASubjectClass(r){if((await this.subjectClassesByTemplate(new r)).length>0)return;let{name:t,sdna:n}=r.generateSDNA();await this.addSdna(t,n,"subject_class")}getNeighbourhoodProxy(){return L(this,_e,"f").getNeighbourhoodProxy(L(this,pe,"f").uuid)}};pe=new WeakMap,_e=new WeakMap,Pr=new WeakMap,Nr=new WeakMap,Rr=new WeakMap,ai=new WeakMap;var Ar=function(r,e,t,n,i){if(n==="m")throw new TypeError("Private method is not writable");if(n==="a"&&!i)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?r!==e||!i:!e.has(r))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?i.call(r,t):i?i.value=t:e.set(r,t),t},H=function(r,e,t,n){if(t==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?r!==e||!n:!e.has(r))throw new TypeError("Cannot read private member from an object whose class did not declare it");return t==="m"?n:t==="a"?n.call(r):n?n.value:e.get(r)},se,oi,si,ci,Aa,ui,Ia,rt=`
64
64
  author
65
65
  timestamp
66
66
  status
@@ -1011,7 +1011,7 @@ type Subscription {
1011
1011
  perspectiveUpdated: PerspectiveHandle
1012
1012
  runtimeMessageReceived: PerspectiveExpression
1013
1013
  }
1014
- `;function ip(r){return r?.length?r.length===1?r.toString():r.length===2?r.join(" and "):r.slice(0,-1).join(", ")+", and "+r.slice(-1):""}function wp(r){let e=r.can.includes("*")?["READ","WRITE","UPDATE"]:r.can,t=r.with.domain==="*"?"":r.with.domain,n=r.with.pointers.includes("*")?["all AD4M data"]:r.with.pointers;return`${ip(e)} your ${t} actions, with access to ${ip(n)}`}var kr=function(r,e,t,n,i){if(n==="m")throw new TypeError("Private method is not writable");if(n==="a"&&!i)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?r!==e||!i:!e.has(r))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?i.call(r,t):i?i.value=t:e.set(r,t),t},M=function(r,e,t,n){if(t==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?r!==e||!n:!e.has(r))throw new TypeError("Cannot read private member from an object whose class did not declare it");return t==="m"?n:t==="a"?n.call(r):n?n.value:e.get(r)},Qe,Fe,Na,ae,ap=class{constructor(r,e,t){Qe.set(this,void 0),Fe.set(this,void 0),Na.set(this,void 0),ae.set(this,void 0),kr(this,Qe,e||Tt.from(Sp(24)).toUrl(),"f"),kr(this,ae,r,"f"),kr(this,Na,t||"ad4m://self","f")}get baseExpression(){return M(this,Qe,"f")}async getData(id){let tempId=id??M(this,Qe,"f"),isInstance=await M(this,ae,"f").isSubjectInstance(tempId,M(this,Fe,"f"));if(!isInstance)throw`Not a valid subject instance of ${M(this,Fe,"f")} for ${tempId}`;let results=await M(this,ae,"f").infer(`subject_class("${M(this,Fe,"f")}", C), property(C, Property)`),properties=results.map(r=>r.Property);for(let r of properties){let e=await M(this,ae,"f").infer(`subject_class("${M(this,Fe,"f")}", C), property_resolve(C, "${r}")`),t=async()=>{let n=await M(this,ae,"f").infer(`subject_class("${M(this,Fe,"f")}", C), property_getter(C, "${tempId}", "${r}", Value)`);if(n&&n.length>0){let i=n[0].Value;if(e)try{let a=await M(this,ae,"f").getExpression(i);try{return JSON.parse(a.data)}catch{return a.data}}catch{return i}else return i}else return n||void 0};this[r]=await t()}let results2=await M(this,ae,"f").infer(`subject_class("${M(this,Fe,"f")}", C), collection(C, Collection)`);results2||(results2=[]);let collections=results2.map(r=>r.Collection);for(let c of collections){let getProperty=async()=>{let results=await M(this,ae,"f").infer(`subject_class("${M(this,Fe,"f")}", C), collection_getter(C, "${tempId}", "${c}", Value)`);return results&&results.length>0&&results[0].Value?eval(results[0].Value):[]};this[c]=await getProperty()}return kr(this,Qe,tempId,"f"),this}async setProperty(key,value){let setters=await M(this,ae,"f").infer(`subject_class("${M(this,Fe,"f")}", C), property_setter(C, "${key}", Setter)`);if(setters&&setters.length>0){let actions=eval(setters[0].Setter),resolveLanguageResults=await M(this,ae,"f").infer(`subject_class("${M(this,Fe,"f")}", C), property_resolve_language(C, "${key}", Language)`),resolveLanguage;resolveLanguageResults&&resolveLanguageResults.length>0&&(resolveLanguage=resolveLanguageResults[0].Language),resolveLanguage&&(value=await M(this,ae,"f").createExpression(value,resolveLanguage)),await M(this,ae,"f").executeAction(actions,M(this,Qe,"f"),[{name:"value",value}])}}async setCollectionSetter(key,value){let collectionSetters=await M(this,ae,"f").infer(`subject_class("${M(this,Fe,"f")}", C), collection_setter(C, "${Mt(key)}", Setter)`);if(collectionSetters||(collectionSetters=[]),collectionSetters.length>0){let actions=eval(collectionSetters[0].Setter);value&&(Array.isArray(value)?await M(this,ae,"f").executeAction(actions,M(this,Qe,"f"),value.map(r=>({name:"value",value:r}))):await M(this,ae,"f").executeAction(actions,M(this,Qe,"f"),[{name:"value",value}]))}}async setCollectionAdder(key,value){let adders=await M(this,ae,"f").infer(`subject_class("${M(this,Fe,"f")}", C), collection_adder(C, "${Mt(key)}", Adder)`);if(adders||(adders=[]),adders.length>0){let actions=eval(adders[0].Adder);value&&(Array.isArray(value)?await Promise.all(value.map(r=>M(this,ae,"f").executeAction(actions,M(this,Qe,"f"),[{name:"value",value:r}]))):await M(this,ae,"f").executeAction(actions,M(this,Qe,"f"),[{name:"value",value}]))}}async setCollectionRemover(key,value){let removers=await M(this,ae,"f").infer(`subject_class("${M(this,Fe,"f")}", C), collection_remover(C, "${Mt(key)}", Remover)`);if(removers||(removers=[]),removers.length>0){let actions=eval(removers[0].Remover);value&&(Array.isArray(value)?await Promise.all(value.map(r=>M(this,ae,"f").executeAction(actions,M(this,Qe,"f"),[{name:"value",value:r}]))):await M(this,ae,"f").executeAction(actions,M(this,Qe,"f"),[{name:"value",value}]))}}async save(){kr(this,Fe,await M(this,ae,"f").stringOrTemplateObjectToSubjectClass(this),"f"),await M(this,ae,"f").createSubject(this,M(this,Qe,"f")),await M(this,ae,"f").add(new Ot({source:M(this,Na,"f"),predicate:"ad4m://has_child",target:this.baseExpression})),await this.update()}async update(){kr(this,Fe,await M(this,ae,"f").stringOrTemplateObjectToSubjectClass(this),"f");let r=Object.entries(this);for(let[e,t]of r)if(t)if(t?.action)switch(t.action){case"setter":await this.setCollectionSetter(e,t.value);break;case"adder":await this.setCollectionAdder(e,t.value);break;case"remover":await this.setCollectionRemover(e,t.value);default:await this.setCollectionSetter(e,t.value);break}else Array.isArray(t)&&t.length>0?await this.setCollectionSetter(e,t):await this.setProperty(e,t);await this.getData()}async get(){return kr(this,Fe,await M(this,ae,"f").stringOrTemplateObjectToSubjectClass(this),"f"),await this.getData()}async delete(){await M(this,ae,"f").removeSubject(this,M(this,Qe,"f"))}static async all(r){let e=await r.stringOrTemplateObjectToSubjectClass(this),t=await r.getAllSubjectProxies(e),n=[];if(t){for(let i of t){let a=new this(r,i.X);n.push(await a.get())}return n}return[]}static async query(r,e){let t=e?.source||"ad4m://self",n=await r.stringOrTemplateObjectToSubjectClass(this),i=[];if(e)try{if((await r.infer(`findall([Timestamp, Base], (subject_class("${n}", C), instance(C, Base), link("${t}", Predicate, Base, Timestamp, Author)), AllData), sort(AllData, SortedData), length(SortedData, DataLength).`))[0].DataLength>=e.size){let s=`findall([Timestamp, Base], (subject_class("${n}", C), instance(C, Base), link("${t}", Predicate, Base, Timestamp, Author)), AllData), sort(AllData, SortedData), reverse(SortedData, ReverseSortedData), paginate(ReverseSortedData, ${e.page}, ${e.size}, PageData).`;i=await r.infer(s),i=i[0].PageData.map(u=>({Base:u[1],Timestamp:u[0]}))}else i=await r.infer(`subject_class("${n}", C), instance(C, Base), triple("${t}", Predicate, Base).`)}catch(o){console.log("Query failed",o)}else i=await r.infer(`subject_class("${n}", C), instance(C, Base), triple("${t}", Predicate, Base).`);return i?await Promise.all(i.map(async o=>await new this(r,o.Base).get())):[]}};Qe=new WeakMap,Fe=new WeakMap,Na=new WeakMap,ae=new WeakMap;var eo="0.8.1";function B1(){let r=new AbortController;return setTimeout(()=>r.abort(),20),r}function oc(r,e=5e3){return ye(this,null,function*(){return Promise.race([new Promise((t,n)=>{let i=new WebSocket(r);i.onopen=()=>{t(i)},i.onerror=a=>{n(a)}}),new Promise((t,n)=>{setTimeout(()=>{n(new Error("WebSocket connection timed out"))},e)})])})}function sc(r){return ye(this,null,function*(){try{let e=yield fetch(`http://localhost:${r}/graphql/`,{signal:B1().signal,mode:"no-cors"});if(e.status===400||e.status===0)return r;throw new Error(`Could not connect to port ${r}`)}catch(e){throw new Error(`Could not connect to port ${r}`)}})}function V1(){return new Promise((r,e)=>{let t=document.querySelector("ad4m-connect"),n=t==null?void 0:t.getAd4mClient();n?r(n):e("No Ad4mClient found")})}function cc(){try{localStorage.setItem("test",""),localStorage.removeItem("test")}catch(r){return!1}return!0}function _p(r,e){cc()&&localStorage.setItem(`${eo}/${r}`,e)}function Kr(r){return cc()?localStorage.getItem(`${eo}/${r}`):null}function Ep(r){cc()&&localStorage.removeItem(`${eo}/${r}`)}var Q1=r=>{let e=new Set;do for(let t of Reflect.ownKeys(r))e.add([r,t]);while((r=Reflect.getPrototypeOf(r))&&r!==Object.prototype);return e};function xi(r,{include:e,exclude:t}={}){let n=i=>{let a=o=>typeof o=="string"?i===o:o.test(i);return e?e.some(a):t?!t.some(a):!0};for(let[i,a]of Q1(r.constructor.prototype)){if(a==="constructor"||!n(a))continue;let o=Reflect.getOwnPropertyDescriptor(i,a);o&&typeof o.value=="function"&&(r[a]=r[a].bind(r))}return r}var Oi=class{constructor({appName:e,appDesc:t,appIconPath:n,appUrl:i,appDomain:a,capabilities:o,port:s,token:u,url:l}){this.activeSocket=null;this.requestedRestart=!1;this.authState="unauthenticated";this.connectionState="not_connected";this.port=12e3;this.capabilities=[];this.listeners={authstatechange:[],configstatechange:[],connectionstatechange:[]};xi(this);this.appName=e,this.appDesc=t,this.appDomain=a,this.appUrl=i,this.appIconPath=n,this.capabilities=o,this.port=s||this.port,this.url=l||`ws://localhost:${this.port}/graphql`,this.token=u||this.token,this.buildClient()}notifyConfigChange(e,t){this.listeners.configstatechange.forEach(n=>{n(e,t)})}notifyConnectionChange(e){this.connectionState!==e&&(this.connectionState=e,this.listeners.connectionstatechange.forEach(t=>{t(e)}))}notifyAuthChange(e){this.authState!==e&&(this.authState=e,this.listeners.authstatechange.forEach(t=>{t(e)}))}setPort(e){this.port!==e&&(this.port=e,this.setUrl(`ws://localhost:${this.port}/graphql`),this.notifyConfigChange("port",e))}setUrl(e){this.url!==e&&(this.url=e,this.notifyConfigChange("url",e))}setToken(e){this.token!==e&&(this.token=e,this.notifyConfigChange("token",e))}on(e,t){this.listeners[e].push(t)}connect(e){return ye(this,null,function*(){try{if(e){yield oc(e,1e4),this.setUrl(e);let t=this.buildClient();return yield this.checkAuth(),t}else{let t=yield this.ensureConnection();return yield this.checkAuth(),t}}catch(t){this.notifyConnectionChange("not_connected"),this.notifyAuthChange("unauthenticated")}})}connectToPort(e){return ye(this,null,function*(){try{if(e){let t=yield sc(e);this.setPort(t)}else{let t=yield this.findPort();this.setPort(t)}return this.buildClient()}catch(t){this.notifyConnectionChange("not_connected"),this.notifyAuthChange("unauthenticated")}})}ensureConnection(){return ye(this,null,function*(){var t,n;if(((t=this.activeSocket)==null?void 0:t.readyState)===WebSocket.OPEN&&((n=this.activeSocket)==null?void 0:n.url)===this.url&&this.ad4mClient)return this.ad4mClient;try{return yield oc(this.url,1e4),this.buildClient()}catch(i){return this.connectToPort()}})}findPort(){return ye(this,null,function*(){let e=[...Array(10).keys()].map((i,a)=>sc(12e3+a)),n=(yield Promise.allSettled(e)).find(i=>i.status==="fulfilled");if(n)return n.value;throw Error("Couldn't find an open port")})}buildClient(){this.notifyConnectionChange("connecting");try{new WebSocket(this.url)}catch(e){this.notifyConnectionChange("not_connected")}return this.apolloClient&&this.wsClient&&(this.requestedRestart=!0,this.wsClient.dispose(),this.apolloClient.stop()),this.wsClient=Fl({url:this.url,connectionParams:()=>ye(this,null,function*(){return{headers:{authorization:this.token}}}),on:{connecting:()=>{this.requestedRestart||this.notifyConnectionChange("connecting")},opened:e=>{this.activeSocket=e},error:e=>{this.notifyConnectionChange("not_connected"),this.notifyAuthChange("unauthenticated")},connected:()=>{this.notifyConnectionChange("connected")},closed:()=>{this.requestedRestart||(this.notifyConnectionChange(this.token?"disconnected":"not_connected"),this.notifyAuthChange("unauthenticated"),this.requestedRestart=!1)}}}),this.apolloClient=new Is({link:new $l(this.wsClient),cache:new la({resultCaching:!1,addTypename:!1}),defaultOptions:{watchQuery:{fetchPolicy:"no-cache"},query:{fetchPolicy:"no-cache"},mutate:{fetchPolicy:"no-cache"}}}),this.ad4mClient=new Wa(this.apolloClient),this.ad4mClient}checkAuth(){return ye(this,null,function*(){try{return(yield this.ad4mClient.agent.isLocked())?this.notifyAuthChange("locked"):(yield this.ad4mClient.agent.status(),this.notifyAuthChange("authenticated")),!0}catch(e){return e.message==="Socket closed with event 4500 Cannot extractByTags from a ciphered wallet. You must unlock first."?(this.notifyAuthChange("locked"),!0):(this.notifyAuthChange("unauthenticated"),!1)}})}requestCapability(e=!1){return ye(this,null,function*(){var t;return e&&this.setToken(null),this.requestId=yield(t=this.ad4mClient)==null?void 0:t.agent.requestCapability({appName:this.appName,appDesc:this.appDesc,appUrl:this.appUrl,appIconPath:this.appIconPath,appDomain:this.appDomain,capabilities:this.capabilities}),this.requestId})}verifyCode(e){return ye(this,null,function*(){var n;let t=yield(n=this.ad4mClient)==null?void 0:n.agent.generateJwt(this.requestId,e);return this.setToken(t),yield this.buildClient(),yield this.checkAuth(),this.token})}};function uc(){return Y`
1014
+ `;function ip(r){return r?.length?r.length===1?r.toString():r.length===2?r.join(" and "):r.slice(0,-1).join(", ")+", and "+r.slice(-1):""}function wp(r){let e=r.can.includes("*")?["READ","WRITE","UPDATE"]:r.can,t=r.with.domain==="*"?"":r.with.domain,n=r.with.pointers.includes("*")?["all AD4M data"]:r.with.pointers;return`${ip(e)} your ${t} actions, with access to ${ip(n)}`}var kr=function(r,e,t,n,i){if(n==="m")throw new TypeError("Private method is not writable");if(n==="a"&&!i)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?r!==e||!i:!e.has(r))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?i.call(r,t):i?i.value=t:e.set(r,t),t},M=function(r,e,t,n){if(t==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?r!==e||!n:!e.has(r))throw new TypeError("Cannot read private member from an object whose class did not declare it");return t==="m"?n:t==="a"?n.call(r):n?n.value:e.get(r)},Qe,Fe,Na,ae,ap=class{constructor(r,e,t){Qe.set(this,void 0),Fe.set(this,void 0),Na.set(this,void 0),ae.set(this,void 0),kr(this,Qe,e||Tt.from(Sp(24)).toUrl(),"f"),kr(this,ae,r,"f"),kr(this,Na,t||"ad4m://self","f")}get baseExpression(){return M(this,Qe,"f")}async getData(id){let tempId=id??M(this,Qe,"f"),isInstance=await M(this,ae,"f").isSubjectInstance(tempId,M(this,Fe,"f"));if(!isInstance)throw`Not a valid subject instance of ${M(this,Fe,"f")} for ${tempId}`;let results=await M(this,ae,"f").infer(`subject_class("${M(this,Fe,"f")}", C), property(C, Property)`),properties=results.map(r=>r.Property);for(let r of properties){let e=await M(this,ae,"f").infer(`subject_class("${M(this,Fe,"f")}", C), property_resolve(C, "${r}")`),t=async()=>{let n=await M(this,ae,"f").infer(`subject_class("${M(this,Fe,"f")}", C), property_getter(C, "${tempId}", "${r}", Value)`);if(n&&n.length>0){let i=n[0].Value;if(e)try{let a=await M(this,ae,"f").getExpression(i);try{return JSON.parse(a.data)}catch{return a.data}}catch{return i}else return i}else return n||void 0};this[r]=await t()}let results2=await M(this,ae,"f").infer(`subject_class("${M(this,Fe,"f")}", C), collection(C, Collection)`);results2||(results2=[]);let collections=results2.map(r=>r.Collection);for(let c of collections){let getProperty=async()=>{let results=await M(this,ae,"f").infer(`subject_class("${M(this,Fe,"f")}", C), collection_getter(C, "${tempId}", "${c}", Value)`);return results&&results.length>0&&results[0].Value?eval(results[0].Value):[]};this[c]=await getProperty()}return kr(this,Qe,tempId,"f"),this}async setProperty(key,value){let setters=await M(this,ae,"f").infer(`subject_class("${M(this,Fe,"f")}", C), property_setter(C, "${key}", Setter)`);if(setters&&setters.length>0){let actions=eval(setters[0].Setter),resolveLanguageResults=await M(this,ae,"f").infer(`subject_class("${M(this,Fe,"f")}", C), property_resolve_language(C, "${key}", Language)`),resolveLanguage;resolveLanguageResults&&resolveLanguageResults.length>0&&(resolveLanguage=resolveLanguageResults[0].Language),resolveLanguage&&(value=await M(this,ae,"f").createExpression(value,resolveLanguage)),await M(this,ae,"f").executeAction(actions,M(this,Qe,"f"),[{name:"value",value}])}}async setCollectionSetter(key,value){let collectionSetters=await M(this,ae,"f").infer(`subject_class("${M(this,Fe,"f")}", C), collection_setter(C, "${Mt(key)}", Setter)`);if(collectionSetters||(collectionSetters=[]),collectionSetters.length>0){let actions=eval(collectionSetters[0].Setter);value&&(Array.isArray(value)?await M(this,ae,"f").executeAction(actions,M(this,Qe,"f"),value.map(r=>({name:"value",value:r}))):await M(this,ae,"f").executeAction(actions,M(this,Qe,"f"),[{name:"value",value}]))}}async setCollectionAdder(key,value){let adders=await M(this,ae,"f").infer(`subject_class("${M(this,Fe,"f")}", C), collection_adder(C, "${Mt(key)}", Adder)`);if(adders||(adders=[]),adders.length>0){let actions=eval(adders[0].Adder);value&&(Array.isArray(value)?await Promise.all(value.map(r=>M(this,ae,"f").executeAction(actions,M(this,Qe,"f"),[{name:"value",value:r}]))):await M(this,ae,"f").executeAction(actions,M(this,Qe,"f"),[{name:"value",value}]))}}async setCollectionRemover(key,value){let removers=await M(this,ae,"f").infer(`subject_class("${M(this,Fe,"f")}", C), collection_remover(C, "${Mt(key)}", Remover)`);if(removers||(removers=[]),removers.length>0){let actions=eval(removers[0].Remover);value&&(Array.isArray(value)?await Promise.all(value.map(r=>M(this,ae,"f").executeAction(actions,M(this,Qe,"f"),[{name:"value",value:r}]))):await M(this,ae,"f").executeAction(actions,M(this,Qe,"f"),[{name:"value",value}]))}}async save(){kr(this,Fe,await M(this,ae,"f").stringOrTemplateObjectToSubjectClass(this),"f"),await M(this,ae,"f").createSubject(this,M(this,Qe,"f")),await M(this,ae,"f").add(new Ot({source:M(this,Na,"f"),predicate:"ad4m://has_child",target:this.baseExpression})),await this.update()}async update(){kr(this,Fe,await M(this,ae,"f").stringOrTemplateObjectToSubjectClass(this),"f");let r=Object.entries(this);for(let[e,t]of r)if(t)if(t?.action)switch(t.action){case"setter":await this.setCollectionSetter(e,t.value);break;case"adder":await this.setCollectionAdder(e,t.value);break;case"remover":await this.setCollectionRemover(e,t.value);default:await this.setCollectionSetter(e,t.value);break}else Array.isArray(t)&&t.length>0?await this.setCollectionSetter(e,t):await this.setProperty(e,t);await this.getData()}async get(){return kr(this,Fe,await M(this,ae,"f").stringOrTemplateObjectToSubjectClass(this),"f"),await this.getData()}async delete(){await M(this,ae,"f").removeSubject(this,M(this,Qe,"f"))}static async all(r){let e=await r.stringOrTemplateObjectToSubjectClass(this),t=await r.getAllSubjectProxies(e),n=[];if(t){for(let i of t){let a=new this(r,i.X);n.push(await a.get())}return n}return[]}static async query(r,e){let t=e?.source||"ad4m://self",n=await r.stringOrTemplateObjectToSubjectClass(this),i=[];if(e)try{if((await r.infer(`findall([Timestamp, Base], (subject_class("${n}", C), instance(C, Base), link("${t}", Predicate, Base, Timestamp, Author)), AllData), sort(AllData, SortedData), length(SortedData, DataLength).`))[0].DataLength>=e.size){let s=`findall([Timestamp, Base], (subject_class("${n}", C), instance(C, Base), link("${t}", Predicate, Base, Timestamp, Author)), AllData), sort(AllData, SortedData), reverse(SortedData, ReverseSortedData), paginate(ReverseSortedData, ${e.page}, ${e.size}, PageData).`;i=await r.infer(s),i=i[0].PageData.map(u=>({Base:u[1],Timestamp:u[0]}))}else i=await r.infer(`subject_class("${n}", C), instance(C, Base), triple("${t}", Predicate, Base).`)}catch(o){console.log("Query failed",o)}else i=await r.infer(`subject_class("${n}", C), instance(C, Base), triple("${t}", Predicate, Base).`);return i?await Promise.all(i.map(async o=>await new this(r,o.Base).get())):[]}};Qe=new WeakMap,Fe=new WeakMap,Na=new WeakMap,ae=new WeakMap;var eo="0.8.2-prerelease";function B1(){let r=new AbortController;return setTimeout(()=>r.abort(),20),r}function oc(r,e=1e4){return ye(this,null,function*(){return Promise.race([new Promise((t,n)=>{r.includes("localhost")||t(new WebSocket(r));let i=new WebSocket(r);i.onopen=()=>{t(i)},i.onerror=a=>{n(a)}}),new Promise((t,n)=>{setTimeout(()=>{n(new Error("WebSocket connection timed out"))},e)})])})}function sc(r){return ye(this,null,function*(){try{let e=yield fetch(`http://localhost:${r}/graphql/`,{signal:B1().signal,mode:"no-cors"});if(e.status===400||e.status===0)return r;throw new Error(`Could not connect to port ${r}`)}catch(e){throw new Error(`Could not connect to port ${r}`)}})}function V1(){return new Promise((r,e)=>{let t=document.querySelector("ad4m-connect"),n=t==null?void 0:t.getAd4mClient();n?r(n):e("No Ad4mClient found")})}function cc(){try{localStorage.setItem("test",""),localStorage.removeItem("test")}catch(r){return!1}return!0}function _p(r,e){cc()&&localStorage.setItem(`${eo}/${r}`,e)}function Kr(r){return cc()?localStorage.getItem(`${eo}/${r}`):null}function Ep(r){cc()&&localStorage.removeItem(`${eo}/${r}`)}var Q1=r=>{let e=new Set;do for(let t of Reflect.ownKeys(r))e.add([r,t]);while((r=Reflect.getPrototypeOf(r))&&r!==Object.prototype);return e};function xi(r,{include:e,exclude:t}={}){let n=i=>{let a=o=>typeof o=="string"?i===o:o.test(i);return e?e.some(a):t?!t.some(a):!0};for(let[i,a]of Q1(r.constructor.prototype)){if(a==="constructor"||!n(a))continue;let o=Reflect.getOwnPropertyDescriptor(i,a);o&&typeof o.value=="function"&&(r[a]=r[a].bind(r))}return r}var Oi=class{constructor({appName:e,appDesc:t,appIconPath:n,appUrl:i,appDomain:a,capabilities:o,port:s,token:u,url:l}){this.activeSocket=null;this.requestedRestart=!1;this.authState="unauthenticated";this.connectionState="not_connected";this.port=12e3;this.capabilities=[];this.listeners={authstatechange:[],configstatechange:[],connectionstatechange:[]};xi(this);this.appName=e,this.appDesc=t,this.appDomain=a,this.appUrl=i,this.appIconPath=n,this.capabilities=o,this.port=s||this.port,this.url=l||`ws://localhost:${this.port}/graphql`,this.token=u||this.token,this.buildClient()}notifyConfigChange(e,t){this.listeners.configstatechange.forEach(n=>{n(e,t)})}notifyConnectionChange(e){this.connectionState!==e&&(this.connectionState=e,this.listeners.connectionstatechange.forEach(t=>{t(e)}))}notifyAuthChange(e){this.authState!==e&&(this.authState=e,this.listeners.authstatechange.forEach(t=>{t(e)}))}setPort(e){this.port!==e&&(this.port=e,this.setUrl(`ws://localhost:${this.port}/graphql`),this.notifyConfigChange("port",e))}setUrl(e){this.url!==e&&(this.url=e,this.notifyConfigChange("url",e))}setToken(e){this.token!==e&&(this.token=e,this.notifyConfigChange("token",e))}on(e,t){this.listeners[e].push(t)}connect(e){return ye(this,null,function*(){try{if(e){yield oc(e,1e4),this.setUrl(e);let t=this.buildClient();return yield this.checkAuth(),t}else{let t=yield this.ensureConnection();return yield this.checkAuth(),t}}catch(t){this.notifyConnectionChange("not_connected"),this.notifyAuthChange("unauthenticated")}})}connectToPort(e){return ye(this,null,function*(){try{if(e){let t=yield sc(e);this.setPort(t)}else{let t=yield this.findPort();this.setPort(t)}return this.buildClient()}catch(t){this.notifyConnectionChange("not_connected"),this.notifyAuthChange("unauthenticated")}})}ensureConnection(){return ye(this,null,function*(){var t,n;if(((t=this.activeSocket)==null?void 0:t.readyState)===WebSocket.OPEN&&((n=this.activeSocket)==null?void 0:n.url)===this.url&&this.ad4mClient)return this.ad4mClient;try{return yield oc(this.url,1e4),this.buildClient()}catch(i){return this.connectToPort()}})}findPort(){return ye(this,null,function*(){let e=[...Array(10).keys()].map((i,a)=>sc(12e3+a)),n=(yield Promise.allSettled(e)).find(i=>i.status==="fulfilled");if(n)return n.value;throw Error("Couldn't find an open port")})}buildClient(){this.notifyConnectionChange("connecting");try{new WebSocket(this.url)}catch(e){this.notifyConnectionChange("not_connected")}return this.apolloClient&&this.wsClient&&(this.requestedRestart=!0,this.wsClient.dispose(),this.apolloClient.stop()),this.wsClient=Fl({url:this.url,connectionParams:()=>ye(this,null,function*(){return{headers:{authorization:this.token}}}),on:{connecting:()=>{this.requestedRestart||this.notifyConnectionChange("connecting")},opened:e=>{this.activeSocket=e},error:e=>{this.notifyConnectionChange("not_connected"),this.notifyAuthChange("unauthenticated")},connected:()=>{this.notifyConnectionChange("connected")},closed:()=>{this.requestedRestart||(this.notifyConnectionChange(this.token?"disconnected":"not_connected"),this.notifyAuthChange("unauthenticated"),this.requestedRestart=!1)}}}),this.apolloClient=new Is({link:new $l(this.wsClient),cache:new la({resultCaching:!1,addTypename:!1}),defaultOptions:{watchQuery:{fetchPolicy:"no-cache"},query:{fetchPolicy:"no-cache"},mutate:{fetchPolicy:"no-cache"}}}),this.ad4mClient=new Wa(this.apolloClient),this.ad4mClient}checkAuth(){return ye(this,null,function*(){try{return(yield this.ad4mClient.agent.isLocked())?this.notifyAuthChange("locked"):(yield this.ad4mClient.agent.status(),this.notifyAuthChange("authenticated")),!0}catch(e){return e.message==="Socket closed with event 4500 Cannot extractByTags from a ciphered wallet. You must unlock first."?(this.notifyAuthChange("locked"),!0):(this.notifyAuthChange("unauthenticated"),!1)}})}requestCapability(e=!1){return ye(this,null,function*(){var t;return e&&this.setToken(null),this.requestId=yield(t=this.ad4mClient)==null?void 0:t.agent.requestCapability({appName:this.appName,appDesc:this.appDesc,appUrl:this.appUrl,appIconPath:this.appIconPath,appDomain:this.appDomain,capabilities:this.capabilities}),this.requestId})}verifyCode(e){return ye(this,null,function*(){var n;let t=yield(n=this.ad4mClient)==null?void 0:n.agent.generateJwt(this.requestId,e);return this.setToken(t),yield this.buildClient(),yield this.checkAuth(),this.token})}};function uc(){return Y`
1015
1015
  <div>
1016
1016
  <div class="lds-ring">
1017
1017
  <div></div>
@@ -1083,11 +1083,11 @@ type Subscription {
1083
1083
  <div class="items">
1084
1084
  ${t?Y`<div class="text-center">
1085
1085
  <a class="button" target="_blank" @click=${()=>r()}>
1086
- Connect to AD4M
1086
+ Connect to ADAM
1087
1087
  </a>
1088
1088
  <p>
1089
- Please connect to AD4M once you have downloaded and setup your
1090
- AD4M agent
1089
+ Please connect to ADAM once you have downloaded and setup your
1090
+ ADAM agent
1091
1091
  </p>
1092
1092
  </div>`:Y`<div class="text-center">
1093
1093
  ${e?Y`<button class="button" @click=${()=>a()}>
@@ -1114,9 +1114,14 @@ type Subscription {
1114
1114
  </button>
1115
1115
  </div>`}
1116
1116
 
1117
+ <p style="height: 10px; color: red; font-size: 14px; text-align: center; margin: 0; margin-top: -30px;">
1118
+ Please make sure you have the ADAM Launcher running on your computer and there are no browser restrictions ("Shields") blocking your connection to ADAM on localhost.
1119
+ (Safari users: please use a different browser for now. Safari is very strict about this and we are working on a solution.)
1120
+ </p>
1121
+
1117
1122
  <div class="text-center">
1118
1123
  <a class="button button--link" _target="blank" href="https://ad4m.dev"
1119
- >Learn more about AD4M</a
1124
+ >Learn more about ADAM</a
1120
1125
  >
1121
1126
  </div>
1122
1127
  </div>
@@ -1648,7 +1653,7 @@ type Subscription {
1648
1653
  width: 100vw;
1649
1654
  object-fit: cover;
1650
1655
  }
1651
- `,xe=class extends Bt{constructor(){super(...arguments);this._code=null;this._isMobile=null;this._hasClickedDownload=null;this._isRemote=!1;this._isOpen=!1;this.uiState="start";this.appName=null;this.appDesc=null;this.appDomain=null;this.appIconPath=null;this.capabilities=[];this.token=Kr("ad4murl")||"";this.port=parseInt(Kr("ad4mport"))||12e3;this.url=Kr("ad4murl")||""}get authState(){return this._client.authState}get connectionState(){return this._client.connectionState}connectedCallback(){super.connectedCallback(),xi(this),this._isMobile=W1(),this._client=new Oi({appName:this.appName,appDesc:this.appDesc,appDomain:this.appDomain,appUrl:window.location.origin,appIconPath:this.appIconPath,capabilities:Array.isArray(this.capabilities)?this.capabilities:JSON.parse(this.capabilities),port:this.port||parseInt(Kr("ad4mport"))||12e3,token:this.token||Kr("ad4mtoken"),url:this.url||Kr("ad4murl")}),this._client.on("configstatechange",this.handleConfigChange),this._client.on("authstatechange",this.handleAuthChange),this._client.on("connectionstatechange",this.handleConnectionChange),this.loadFont()}unlockAgent(t,n=!0){return ye(this,null,function*(){yield this._client.ad4mClient.agent.unlock(t,n)})}verifyCode(t){this._client.verifyCode(t)}changeUrl(t){this._client.setUrl(t)}changePort(t){this._client.setPort(t)}changeUIState(t){this.uiState=t}changeIsRemote(t){this._isRemote=t}changeCode(t){this._code=t}onDownloaded(){this._hasClickedDownload=!0}handleAuthChange(t){let n=new CustomEvent("authstatechange",{detail:t});t==="locked"&&(this._isOpen=!0),this.dispatchEvent(n),this.requestUpdate()}handleConfigChange(t,n){this[t]=n,n?_p("ad4m"+t,n):Ep("ad4m"+t),this.requestUpdate()}handleConnectionChange(t){t==="connected"&&this.changeUIState("requestcap"),t==="disconnected"&&(this._isOpen=!0),t==="not_connected"&&this.changeUIState("start");let n=new CustomEvent("connectionstatechange",{detail:t});this.dispatchEvent(n),this.requestUpdate()}loadFont(){let t=document.createElement("link");t.rel="stylesheet",t.type="text/css",t.crossOrigin="anonymous",t.href="https://fonts.googleapis.com/css2?family=DM+Sans:wght@400;500;700&display=swap",document.head.appendChild(t)}startCamera(t){return ye(this,null,function*(){try{window.BarcodeDetector.getSupportedFormats()}catch(n){window.BarcodeDetector=Qt}yield this.changeUIState("qr"),setTimeout(()=>ye(this,null,function*(){let n=this.shadowRoot.querySelector("video");if(!n)return;let i=yield navigator.mediaDevices.getUserMedia({audio:!1,video:{facingMode:"environment"}});n.srcObject=i,n.autoplay=!0}),100)})}connect(){return ye(this,null,function*(){return this._isOpen=!0,this.requestUpdate(),yield this._client.connect()})}getAd4mClient(){return this._client.ad4mClient}connectRemote(t){return ye(this,null,function*(){try{let n=yield this._client.connect(t);return this.changeUIState("requestcap"),n}catch(n){n.message==="Socket closed with event 4500 Invalid Compact JWS"&&this.changeUIState("requestcap")}})}requestCapability(t){return ye(this,null,function*(){try{yield this._client.requestCapability(t),this.changeUIState("verifycode")}catch(n){console.warn(n)}})}isAuthenticated(){return ye(this,null,function*(){return this._client.checkAuth()})}setOpen(t){this._isOpen=t}renderViews(){if(this.connectionState==="connecting")return uc();if(this.uiState==="qr")return vc({changeState:this.changeUIState,onSuccess:t=>this._client.connect(t),uiState:this.uiState});if(this.authState==="locked")return dc({unlockAgent:this.unlockAgent,reconnect:this.connect});if(this.uiState==="settings")return lc({port:this.port,changePort:this.changePort,isRemote:this._isRemote,changeIsRemote:this.changeIsRemote,url:this.url,changeState:this.changeUIState,changeUrl:this.changeUrl,connectToPort:this._client.connectToPort,connectRemote:this.connectRemote});if(this.connectionState==="not_connected")return pc({scanQrcode:this.startCamera,connect:this.connect,isMobile:this._isMobile,hasClickedDownload:this._hasClickedDownload,onDownloaded:this.onDownloaded,changeState:this.changeUIState});if(this.connectionState==="connected")return this.uiState==="verifycode"?yc({code:this._code,changeCode:this.changeCode,changeState:this.changeUIState,verifyCode:this.verifyCode}):mc({changeState:this.changeUIState,requestCapability:this.requestCapability,capabilities:this.capabilities,appname:this.appName,setOpen:this.setOpen,appiconpath:this.appIconPath});if(this.connectionState==="disconnected")return fc({reconnect:this.connect});if(this.connectionState==="port_not_found")return gc()}render(){return this._isOpen===!1||this.authState==="authenticated"?null:Y`
1656
+ `,xe=class extends Bt{constructor(){super(...arguments);this._code=null;this._isMobile=null;this._hasClickedDownload=null;this._isRemote=!1;this._isOpen=!1;this.uiState="start";this.appName=null;this.appDesc=null;this.appDomain=null;this.appIconPath=null;this.capabilities=[];this.token=Kr("ad4mToken")||"";this.port=parseInt(Kr("ad4mport"))||12e3;this.url=Kr("ad4murl")||""}get authState(){return this._client.authState}get connectionState(){return this._client.connectionState}connectedCallback(){super.connectedCallback(),xi(this),this._isMobile=W1(),this._client=new Oi({appName:this.appName,appDesc:this.appDesc,appDomain:this.appDomain,appUrl:window.location.origin,appIconPath:this.appIconPath,capabilities:Array.isArray(this.capabilities)?this.capabilities:JSON.parse(this.capabilities),port:this.port||parseInt(Kr("ad4mport"))||12e3,token:this.token||Kr("ad4mtoken"),url:this.url||Kr("ad4murl")}),this._client.on("configstatechange",this.handleConfigChange),this._client.on("authstatechange",this.handleAuthChange),this._client.on("connectionstatechange",this.handleConnectionChange),this.loadFont()}unlockAgent(t,n=!0){return ye(this,null,function*(){yield this._client.ad4mClient.agent.unlock(t,n)})}verifyCode(t){this._client.verifyCode(t)}changeUrl(t){this._client.setUrl(t)}changePort(t){this._client.setPort(t)}changeUIState(t){this.uiState=t}changeIsRemote(t){this._isRemote=t}changeCode(t){this._code=t}onDownloaded(){this._hasClickedDownload=!0}handleAuthChange(t){let n=new CustomEvent("authstatechange",{detail:t});t==="locked"&&(this._isOpen=!0),this.dispatchEvent(n),this.requestUpdate()}handleConfigChange(t,n){this[t]=n,n?_p("ad4m"+t,n):Ep("ad4m"+t),this.requestUpdate()}handleConnectionChange(t){t==="connected"&&this.changeUIState("requestcap"),t==="disconnected"&&(this._isOpen=!0),t==="not_connected"&&this.changeUIState("start");let n=new CustomEvent("connectionstatechange",{detail:t});this.dispatchEvent(n),this.requestUpdate()}loadFont(){let t=document.createElement("link");t.rel="stylesheet",t.type="text/css",t.crossOrigin="anonymous",t.href="https://fonts.googleapis.com/css2?family=DM+Sans:wght@400;500;700&display=swap",document.head.appendChild(t)}startCamera(t){return ye(this,null,function*(){try{window.BarcodeDetector.getSupportedFormats()}catch(n){window.BarcodeDetector=Qt}yield this.changeUIState("qr"),setTimeout(()=>ye(this,null,function*(){let n=this.shadowRoot.querySelector("video");if(!n)return;let i=yield navigator.mediaDevices.getUserMedia({audio:!1,video:{facingMode:"environment"}});n.srcObject=i,n.autoplay=!0}),100)})}connect(){return ye(this,null,function*(){return this._isOpen=!0,this.requestUpdate(),yield this._client.connect()})}getAd4mClient(){return this._client.ad4mClient}connectRemote(t){return ye(this,null,function*(){try{let n=yield this._client.connect(t);return this.changeUIState("requestcap"),n}catch(n){n.message==="Socket closed with event 4500 Invalid Compact JWS"&&this.changeUIState("requestcap")}})}requestCapability(t){return ye(this,null,function*(){try{yield this._client.requestCapability(t),this.changeUIState("verifycode")}catch(n){console.warn(n)}})}isAuthenticated(){return ye(this,null,function*(){return this._client.checkAuth()})}setOpen(t){this._isOpen=t}renderViews(){if(this.connectionState==="connecting")return uc();if(this.uiState==="qr")return vc({changeState:this.changeUIState,onSuccess:t=>{this.changeUrl(t),this._client.connect(t)},uiState:this.uiState});if(this.authState==="locked")return dc({unlockAgent:this.unlockAgent,reconnect:this.connect});if(this.uiState==="settings")return lc({port:this.port,changePort:this.changePort,isRemote:this._isRemote,changeIsRemote:this.changeIsRemote,url:this.url,changeState:this.changeUIState,changeUrl:this.changeUrl,connectToPort:this._client.connectToPort,connectRemote:this.connectRemote});if(this.connectionState==="not_connected")return pc({scanQrcode:this.startCamera,connect:this.connect,isMobile:this._isMobile,hasClickedDownload:this._hasClickedDownload,onDownloaded:this.onDownloaded,changeState:this.changeUIState});if(this.connectionState==="connected")return this.uiState==="verifycode"?yc({code:this._code,changeCode:this.changeCode,changeState:this.changeUIState,verifyCode:this.verifyCode}):mc({changeState:this.changeUIState,requestCapability:this.requestCapability,capabilities:this.capabilities,appname:this.appName,setOpen:this.setOpen,appiconpath:this.appIconPath});if(this.connectionState==="disconnected")return fc({reconnect:this.connect});if(this.connectionState==="port_not_found")return gc()}render(){return this._isOpen===!1||this.authState==="authenticated"?null:Y`
1652
1657
  <div class="wrapper">
1653
1658
  <div class="dialog">
1654
1659
  ${bc()}
package/package.json CHANGED
@@ -66,5 +66,5 @@
66
66
  "esbuild-plugin-replace": "^1.4.0",
67
67
  "lit": "^2.3.1"
68
68
  },
69
- "version": "0.8.1"
69
+ "version": "0.8.2-prerelease"
70
70
  }